Changeset 989fae0 for perl


Ignore:
Timestamp:
Jan 24, 2007, 5:24:09 PM (17 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
45d9eb0
Parents:
63bbef4
git-author:
Nelson Elhage <nelhage@mit.edu> (01/24/07 17:22:34)
git-committer:
Nelson Elhage <nelhage@mit.edu> (01/24/07 17:24:09)
Message:
Improving JID guessing, adding a warning when we guess. Needs to be
tweaked.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/modules/jabber.pl

    r63bbef4 r989fae0  
    583583    }
    584584
    585     ($jwrite_from, $jwrite_to, $jwrite_type) = guess_jwrite($from, $to);
     585    my @candidates = guess_jwrite($from, $to);
    586586   
    587     unless($jwrite_to) {
     587    unless(scalar @candidates) {
    588588        die("Unable to resolve JID $to");
    589589    }
    590590
    591     unless($jwrite_from) {
     591    @candidates = grep {defined $_->[0]} @candidates;
     592
     593    unless(scalar @candidates) {
    592594        if(!$from) {
    593595            die("You must specify an account with -a");
     
    596598        }
    597599    }
     600
     601
     602    ($jwrite_from, $jwrite_to, $jwrite_type) = @{$candidates[0]};
    598603   
    599604    $vars{jwrite} = {
     
    606611    };
    607612
    608     BarnOwl::message(
    609 "Type your message below.  End with a dot on a line by itself.  ^C will quit."
    610     );
     613    if(scalar @candidates > 1) {
     614        BarnOwl::message(
     615            "Warning: Guessing account and/or destination JID"
     616           );
     617    } else  {
     618        BarnOwl::message(
     619            "Type your message below.  End with a dot on a line by itself.  ^C will quit."
     620           );
     621    }
     622   
    611623    my $cmd = "jwrite $jwrite_to -a $jwrite_from";
    612624    $cmd .= " -t $jwrite_thread" if $jwrite_thread;
     
    13301342    my ($from, $to) = (@_);
    13311343    my ($from_jid, $to_jid);
     1344    my @matches;
    13321345    if($from) {
    13331346        $from_jid = resolveConnectedJID($from);
    13341347        die("Unable to resolve account $from") unless $from_jid;
    13351348        $to_jid = resolveDestJID($to, $from_jid);
     1349        push @matches, [$from_jid, $to_jid];
    13361350    } else {
    1337         for my $f ($conn->getJids) {
     1351        for my $f ($conn->getJIDs) {
    13381352            $to_jid = resolveDestJID($to, $f);
    13391353            if(defined($to_jid)) {
    1340                 $from_jid = $f;
     1354                push @matches, [$f, $to_jid];
    13411355            }
    13421356        }
    1343         $to_jid = $to if $to =~ /@/;
    1344         die("Unable to resolve JID $to") unless $to_jid;
    1345     }
    1346 
    1347     my $type = resolveType($to_jid, $from_jid);
    1348     return ($from_jid, $to_jid, $type);
     1357        if($to =~ /@/) {
     1358            push @matches, [$_, $to]
     1359               for ($conn->getJIDs);
     1360        }
     1361    }
     1362
     1363    for my $m (@matches) {
     1364        my $type = resolveType($m->[1], $m->[0]);
     1365        push @$m, $type;
     1366    }
     1367   
     1368    return @matches;
    13491369}
    13501370
Note: See TracChangeset for help on using the changeset viewer.