Ignore:
Timestamp:
Aug 21, 2008, 6:20:01 PM (16 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
5b75e8b
Parents:
57cf4f9
Message:
Use replycmd/replysendercmd subs rather than properties for Jabber.
Location:
perl/modules/Jabber/lib/BarnOwl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm

    r38a7f22 rd5dcd7c  
    9191}
    9292
     93sub replycmd {
     94    my $self = shift;
     95    my ($recip, $account, $subject);
     96    if ($self->is_loginout) {
     97        $recip   = $self->sender;
     98        $account = $self->recipient;
     99    } elsif ($self->jtype eq 'chat') {
     100        return $self->replysendercmd;
     101    } elsif ($self->jtype eq 'groupchat') {
     102        $recip = $self->room;
     103        if ($self->is_incoming) {
     104            $account = $self->to;
     105        } else {
     106            $account = $self->from;
     107        }
     108        $subject = $self->subject;
     109    }
     110    return jwrite_cmd($recip, $account, $subject);
     111}
     112
     113sub replysendercmd {
     114    my $self = shift;
     115    if($self->jtype eq 'groupchat'
     116       || $self->jtype eq 'chat') {
     117        my ($recip, $account);
     118        if ($self->is_incoming) {
     119            $recip   = $self->from;
     120            $account = $self->to;
     121        } else {
     122            $recip   = $self->to;
     123            $account = $self->from;
     124        }
     125        return jwrite_cmd($recip, $account);
     126    }
     127    return $self->replycmd;
     128}
     129
     130sub jwrite_cmd {
     131    my ($recip, $account, $subject) = @_;
     132    if (defined $recip) {
     133        my $cmd = "jwrite $recip -a $account";
     134        if (defined $subject) {
     135            $cmd .= " -s $subject";
     136        }
     137        return $cmd;
     138    } else {
     139        return undef;
     140    }
     141}
    93142
    94143=head1 SEE ALSO
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    r7a45a72 rd5dcd7c  
    10471047        $props{loginout} = 'logout';
    10481048    }
    1049     $props{replysendercmd} = $props{replycmd} = "jwrite $from -a $to";
    10501049    BarnOwl::queue_message(BarnOwl::Message->new(%props));
    10511050}
     
    11541153
    11551154    if ( $jtype eq 'chat' ) {
    1156         $props{replycmd} =
    1157           "jwrite " . ( ( $dir eq 'in' ) ? $props{from} : $props{to} );
    1158         $props{replycmd} .=
    1159           " -a " . ( ( $dir eq 'out' ) ? $props{from} : $props{to} );
    11601155        $props{private} = 1;
    11611156
     
    11801175        my $nick = $props{nick} = $from->GetResource();
    11811176        my $room = $props{room} = $from->GetJID('base');
    1182         $props{replycmd} = "jwrite $room";
    1183         $props{replycmd} .=
    1184           " -a " . ( ( $dir eq 'out' ) ? $props{from} : $props{to} );
    1185         if ($props{subject}) {
    1186             $props{replycmd} .= " -s " . $props{subject}
    1187         }
    1188 
    1189         if ($dir eq 'out') {
    1190             $props{replysendercmd} = "jwrite ".$props{to}." -a ".$props{from};
    1191         }
    1192         else {
    1193             $props{replysendercmd} = "jwrite ".$props{from}." -a ".$props{to};
    1194         }
    11951177
    11961178        $props{sender} = $nick || $room;
     
    12031185    }
    12041186    elsif ( $jtype eq 'normal' ) {
    1205         $props{replycmd}  = "";
    12061187        $props{private} = 1;
    12071188    }
    12081189    elsif ( $jtype eq 'headline' ) {
    1209         $props{replycmd} = "";
    12101190    }
    12111191    elsif ( $jtype eq 'error' ) {
    1212         $props{replycmd} = "";
    12131192        $props{body}     = "Error "
    12141193          . $props{error_code}
     
    12181197    }
    12191198
    1220     $props{replysendercmd} = $props{replycmd} unless $props{replysendercmd};
    12211199    return %props;
    12221200}
Note: See TracChangeset for help on using the changeset viewer.