fix config file parsing and use accounts.xml, switch to current file format. also...
authorChristian Weiske <cweiske@cweiske.de>
Fri, 21 May 2010 06:23:09 +0000 (08:23 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Fri, 21 May 2010 06:23:09 +0000 (08:23 +0200)
Psist.pm

index e19ea86..8ef7239 100644 (file)
--- a/Psist.pm
+++ b/Psist.pm
@@ -75,18 +75,23 @@ sub load_config
   my $row;
   my $i;
   my $nick;
+  my $jid;
   
   print "loading contacts...\n" unless $self->{silent};
-  open(CONFIGXML, $self->{profile} . "/config.xml");
+  open(CONFIGXML, $self->{profile} . "/accounts.xml");
   while($row = <CONFIGXML>) {
-    if($row =~ /<item.*name="(.*?)".*jid="(.*?)".*>/) {
+    if($row =~ /<name type="QString">(.*?)<\/name>/) {
+        $nick = $1;
+    }
+    if($row =~ /<jid type="QString">(.*?)<\/jid>/) {
       if(length($1) == 0) {
-        $nick = $2;
+          next;
       }
-      else {
-        $nick = $1;
+      if (length($nick) == 0) {
+          $nick = $jid;
       }
-      $self->{jids}{$2} = $nick;
+      $jid = $1;
+      $self->{jids}{$jid} = $nick;
       $self->{nicks}{$nick}{lines} = 0;
       $self->{nicks}{$nick}{linest}[0] = 0;
       $self->{nicks}{$nick}{linest}[1] = 0;
@@ -250,7 +255,7 @@ sub gen_html
       my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($self->{nicks}{$nick}{last}));
       $year += 1900;
       $mon++;
-      print HTMLFIL '<tr><td class="',(($i == 1) ? 'hi' : ''),'rankc">',$i,'</td><td style="background-color: #babadc">{nickname}</td><td style="background-color: #babadc; text-align: right">',$self->{nicks}{$nick}{lines},'</td><td style="background-color: #babadc; text-align: center">';
+      print HTMLFIL '<tr><td class="',(($i == 1) ? 'hi' : ''),'rankc">',$i,'</td><td style="background-color: #babadc">', $nick, '</td><td style="background-color: #babadc; text-align: right">',$self->{nicks}{$nick}{lines},'</td><td style="background-color: #babadc; text-align: center">';
       print HTMLFIL '<img src="./blue-h.png" border="0" width="',int($self->{nicks}{$nick}{linest}[0] * 60 / $sum),'" height="15" alt="',$self->{nicks}{$nick}{linest}[0],'" title="',$self->{nicks}{$nick}{linest}[0],'" />';
       print HTMLFIL '<img src="./green-h.png" border="0" width="',int($self->{nicks}{$nick}{linest}[1] * 60 / $sum),'" height="15" alt="',$self->{nicks}{$nick}{linest}[1],'" title="',$self->{nicks}{$nick}{linest}[1],'" />';
       print HTMLFIL '<img src="./yellow-h.png" border="0" width="',int($self->{nicks}{$nick}{linest}[2] * 60 / $sum),'" height="15" alt="',$self->{nicks}{$nick}{linest}[2],'" title="',$self->{nicks}{$nick}{linest}[2],'" />';