Changeset 3ce5bdc


Ignore:
Timestamp:
Jan 24, 2007, 4:12:25 PM (14 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
63bbef4
Parents:
99c7549
git-author:
Nelson Elhage <nelhage@mit.edu> (01/24/07 16:12:20)
git-committer:
Nelson Elhage <nelhage@mit.edu> (01/24/07 16:12:25)
Message:
Guess an account for jwrite based on whether the JID is in one of your
account's rosters.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/modules/jabber.pl

    r4d17916 r3ce5bdc  
    400400    my $jid = new Net::XMPP::JID;
    401401    $jid->SetJID(shift);
    402     my $password = undef;
     402    my $password = '';
    403403    $password = shift if @_;
    404404   
     
    422422
    423423    $vars{jlogin_jid} = $jidStr;
    424     $vars{jlogin_password} = $password;
    425424    $vars{jlogin_connhash} = {
    426425        hostname      => $server,
     
    560559    my $jwrite_thread  = "";
    561560    my $jwrite_subject = "";
    562     my $to;
     561    my ($to, $from);
    563562    my $jwrite_type    = "chat";
    564563
     
    570569        'thread=s'  => \$jwrite_thread,
    571570        'subject=s' => \$jwrite_subject,
    572         'account=s' => \$jwrite_from,
     571        'account=s' => \$from,
    573572        'id=s'     =>  \$jwrite_sid,
    574573    );
     
    584583    }
    585584
    586     ($jwrite_from, $jwrite_to, $jwrite_type) = guess_jwrite($jwrite_from, $to);
     585    ($jwrite_from, $jwrite_to, $jwrite_type) = guess_jwrite($from, $to);
    587586   
    588587    unless($jwrite_to) {
     
    591590
    592591    unless($jwrite_from) {
    593         die("Unable to resolve account");
     592        if(!$from) {
     593            die("You must specify an account with -a");
     594        } else {
     595            die("Unable to resolve account $from");
     596        }
    594597    }
    595598   
     
    12961299sub resolveDestJID {
    12971300    my ($to, $from) = @_;
    1298     return $to if $to =~ /@/;
    12991301    my $jid = Net::Jabber::JID->new($to);
    13001302
     
    13021304    my @jids = $roster->jids('all');
    13031305    for my $j (@jids) {
    1304         if($roster->query($j, 'name') eq $to) {
     1306        if(($roster->query($j, 'name') || "") eq $to) {
     1307            return $j->GetJID('full');
     1308        } elsif($j->GetJID('base') eq baseJID($to)) {
    13051309            return $j->GetJID('full');
    13061310        }
     
    13131317    my $to = shift;
    13141318    my $from = shift;
     1319    return unless $from;
    13151320    my @mucs = $conn->getConnectionFromJID($from)->MUCs;
    13161321    if(grep {$_->BaseJID eq $to } @mucs) {
     
    13291334        die("Unable to resolve account $from") unless $from_jid;
    13301335        $to_jid = resolveDestJID($to, $from_jid);
    1331     } elsif($to =~ /@/) {
    1332         $to_jid = $to;
    1333         $from_jid = defaultJID();
    1334         die("You must specify an account with -a") unless $from_jid;
    13351336    } else {
    13361337        for my $f ($conn->getJids) {
     
    13401341            }
    13411342        }
     1343        $to_jid = $to if $to =~ /@/;
    13421344        die("Unable to resolve JID $to") unless $to_jid;
    13431345    }
Note: See TracChangeset for help on using the changeset viewer.