[1163] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[D-O-H] r1112 - in trunk/owl/perl/modules/Jabber/lib/BarnOwl: Message Module

daemon@ATHENA.MIT.EDU (nelhage@MIT.EDU)
Thu Oct 29 18:13:40 2009

Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
X-Original-To: nelhage@nelhage.com
To: dirty-owl-hackers@mit.edu
From: nelhage@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Thu, 21 Aug 2008 18:20:01 -0400 (EDT)

Author: nelhage
Date: 2008-08-21 18:20:01 -0400 (Thu, 21 Aug 2008)
New Revision: 1112

Modified:
   trunk/owl/perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm
   trunk/owl/perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
Log:
Use replycmd/replysendercmd subs rather than properties for Jabber.


Modified: trunk/owl/perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm
===================================================================
--- trunk/owl/perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm	2008-08-21 22:18:51 UTC (rev 1111)
+++ trunk/owl/perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm	2008-08-21 22:20:01 UTC (rev 1112)
@@ -90,7 +90,56 @@
 
 }
 
+sub replycmd {
+    my $self = shift;
+    my ($recip, $account, $subject);
+    if ($self->is_loginout) {
+        $recip   = $self->sender;
+        $account = $self->recipient;
+    } elsif ($self->jtype eq 'chat') {
+        return $self->replysendercmd;
+    } elsif ($self->jtype eq 'groupchat') {
+        $recip = $self->room;
+        if ($self->is_incoming) {
+            $account = $self->to;
+        } else {
+            $account = $self->from;
+        }
+        $subject = $self->subject;
+    }
+    return jwrite_cmd($recip, $account, $subject);
+}
 
+sub replysendercmd {
+    my $self = shift;
+    if($self->jtype eq 'groupchat'
+       || $self->jtype eq 'chat') {
+        my ($recip, $account);
+        if ($self->is_incoming) {
+            $recip   = $self->from;
+            $account = $self->to;
+        } else {
+            $recip   = $self->to;
+            $account = $self->from;
+        }
+        return jwrite_cmd($recip, $account);
+    }
+    return $self->replycmd;
+}
+
+sub jwrite_cmd {
+    my ($recip, $account, $subject) = @_;
+    if (defined $recip) {
+        my $cmd = "jwrite $recip -a $account";
+        if (defined $subject) {
+            $cmd .= " -s $subject";
+        }
+        return $cmd;
+    } else {
+        return undef;
+    }
+}
+
 =head1 SEE ALSO
 
 L<BarnOwl::Message>

Modified: trunk/owl/perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
===================================================================
--- trunk/owl/perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm	2008-08-21 22:18:51 UTC (rev 1111)
+++ trunk/owl/perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm	2008-08-21 22:20:01 UTC (rev 1112)
@@ -1046,7 +1046,6 @@
         $props{body} = "$from is now offline. ";
         $props{loginout} = 'logout';
     }
-    $props{replysendercmd} = $props{replycmd} = "jwrite $from -a $to";
     BarnOwl::queue_message(BarnOwl::Message->new(%props));
 }
 
@@ -1153,10 +1152,6 @@
     $props{xml}        = $j->GetXML();
 
     if ( $jtype eq 'chat' ) {
-        $props{replycmd} =
-          "jwrite " . ( ( $dir eq 'in' ) ? $props{from} : $props{to} );
-        $props{replycmd} .=
-          " -a " . ( ( $dir eq 'out' ) ? $props{from} : $props{to} );
         $props{private} = 1;
 
         my $connection;
@@ -1179,20 +1174,7 @@
     elsif ( $jtype eq 'groupchat' ) {
         my $nick = $props{nick} = $from->GetResource();
         my $room = $props{room} = $from->GetJID('base');
-        $props{replycmd} = "jwrite $room";
-        $props{replycmd} .=
-          " -a " . ( ( $dir eq 'out' ) ? $props{from} : $props{to} );
-        if ($props{subject}) {
-            $props{replycmd} .= " -s " . $props{subject}
-        }
 
-        if ($dir eq 'out') {
-            $props{replysendercmd} = "jwrite ".$props{to}." -a ".$props{from};
-        }
-        else {
-            $props{replysendercmd} = "jwrite ".$props{from}." -a ".$props{to};
-        }
-
         $props{sender} = $nick || $room;
         $props{recipient} = $room;
 
@@ -1202,14 +1184,11 @@
         }
     }
     elsif ( $jtype eq 'normal' ) {
-        $props{replycmd}  = "";
         $props{private} = 1;
     }
     elsif ( $jtype eq 'headline' ) {
-        $props{replycmd} = "";
     }
     elsif ( $jtype eq 'error' ) {
-        $props{replycmd} = "";
         $props{body}     = "Error "
           . $props{error_code}
           . " sending to "
@@ -1217,7 +1196,6 @@
           . $props{error};
     }
 
-    $props{replysendercmd} = $props{replycmd} unless $props{replysendercmd};
     return %props;
 }
 


home help back first fref pref prev next nref lref last post