Changeset 9e88fa7 for perl


Ignore:
Timestamp:
May 23, 2010, 7:56:29 PM (14 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.7, release-1.8, release-1.9
Children:
922f589
Parents:
7cc1092 (diff), f6413c3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge branch 'twitter'
Location:
perl
Files:
10 added
8 edited

Legend:

Unmodified
Added
Removed
  • perl/modules/Makefile.am

    r636de2a r1fd469d4  
    1 MODULES = Jabber IRC WordWrap
     1MODULES = Jabber IRC WordWrap Twitter
    22
    33EXTRA_DIST = $(MODULES:=/Makefile.PL) $(MODULES:=/inc) $(MODULES:=/lib)
  • perl/lib/BarnOwl.pm

    ref4700c r675a998  
    535535    my $func = shift;
    536536    my $delta = shift;
    537     $delta = 10 unless int($delta) > 0;
     537    $delta = 10 unless defined($delta) && int($delta) > 0;
    538538    my $shift = BarnOwl::recv_getshift();
    539539    BarnOwl::recv_setshift($shift+$delta);
  • perl/lib/BarnOwl/Hooks.pm

    rb30c256 r3aa0522  
    7979our %EXPORT_TAGS = (all => [@EXPORT_OK]);
    8080
     81use BarnOwl::MainLoopCompatHook;
     82
    8183our $startup = BarnOwl::Hook->new;
    8284our $shutdown = BarnOwl::Hook->new;
    8385our $receiveMessage = BarnOwl::Hook->new;
    8486our $newMessage = BarnOwl::Hook->new;
    85 our $mainLoop = BarnOwl::Hook->new;
     87our $mainLoop = BarnOwl::MainLoopCompatHook->new;
    8688our $getBuddyList = BarnOwl::Hook->new;
    8789our $getQuickstart = BarnOwl::Hook->new;
     
    162164    }
    163165   
     166    $mainLoop->check_owlconf();
    164167    $startup->run(0);
    165168    BarnOwl::startup() if *BarnOwl::startup{CODE};
     
    186189   
    187190    BarnOwl::new_msg($m) if *BarnOwl::new_msg{CODE};
    188 }
    189 
    190 sub _mainloop_hook {
    191     $mainLoop->run;
    192     BarnOwl::mainloop_hook() if *BarnOwl::mainloop_hook{CODE};
    193191}
    194192
  • perl/lib/BarnOwl/Message/Generic.pm

    ree183be r5d1324f  
    66use base qw( BarnOwl::Message );
    77
     8sub body { "" }
     9
    810
    9111;
  • perl/lib/BarnOwl/Style/Default.pm

    r0fe69d2 r08544e0  
    3232    my $m = shift;
    3333    return $m->is_personal && $m->direction eq "in";
     34}
     35
     36sub maybe {
     37    my $x = shift;
     38    return defined($x) ? $x : "";
    3439}
    3540
     
    99104            $header .= ' / ' . $self->humanize($m->subcontext, 1);
    100105        }
    101         $header .= ' / @b{' . $m->pretty_sender . '}';
     106        $header .= ' / @b{' . maybe($m->pretty_sender) . '}';
    102107    }
    103108
  • perl/lib/BarnOwl/Timer.pm

    ree183be r8d16e58  
    2121}
    2222
     23sub stop {
     24    my $self = shift;
     25    if(defined($self->{timer})) {
     26        BarnOwl::Internal::remove_timer($self->{timer});
     27        undef $self->{timer};
     28    }
     29}
     30
    2331sub do_callback {
    2432    my $self = shift;
     
    2836sub DESTROY {
    2937    my $self = shift;
    30     if(defined($self->{timer})) {
    31         BarnOwl::Internal::remove_timer($self->{timer});
    32     }
     38    $self->stop;
    3339}
    3440
  • perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm

    rc854e74 r8278543  
    7777    } elsif ($self->jtype eq 'groupchat') {
    7878        my $room = $self->room;
    79         $filter = "jabber-room-$room";
    80         BarnOwl::command(qw[filter], $filter,
    81                          qw[type ^jabber$ and room], "^\Q$room\E\$");
     79        if ($inst) {
     80            my $subject = $self->subject;
     81            $filter = "jabber-room-$room-subject-$subject";
     82            BarnOwl::command(qw[filter], $filter,
     83                             qw[type ^jabber$ and room], "^\Q$room\E\$",
     84                             qw[and subject], "^\Q$subject\E\$");
     85        } else {
     86            $filter = "jabber-room-$room";
     87            BarnOwl::command(qw[filter], $filter,
     88                             qw[type ^jabber$ and room], "^\Q$room\E\$");
     89        }
    8290        return $filter;
    8391    } elsif ($self->login ne 'none') {
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    r8789410 raa0a0b5  
    285285        {
    286286            summary => "Send a Jabber Message",
    287             usage   => "jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]"
     287            usage   => "jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>] [-m <message>]"
    288288        }
    289289    );
     
    308308            description => "jmuc sends Jabber commands related to MUC.\n\n"
    309309              . "The following commands are available\n\n"
    310               . "join <muc>  Join a MUC.\n\n"
     310              . "join <muc>[/<nick>]\n"
     311              . "            Join a MUC (with a given nickname, or otherwise your JID).\n\n"
    311312              . "part <muc>  Part a MUC.\n"
    312313              . "            The MUC is taken from the current message if not supplied.\n\n"
     
    377378        my $cjidStr = $conn->baseJIDExists($jidStr);
    378379        if ($cjidStr) {
    379             BarnOwl::error("Already logged in as $cjidStr.");
    380             return;
     380            die("Already logged in as $cjidStr.\n");
    381381        }
    382382    }
     
    387387
    388388    if ( !$uid || !$componentname ) {
    389         BarnOwl::error("usage: $cmd JID");
    390         return;
     389        die("usage: $cmd JID\n");
    391390    }
    392391
    393392    if ( $conn->jidActive($jidStr) ) {
    394         BarnOwl::error("Already logged in as $jidStr.");
    395         return;
     393        die("Already logged in as $jidStr.\n");
    396394    } elsif ($conn->jidExists($jidStr)) {
    397395        return $conn->tryReconnect($jidStr, 1);
     
    526524sub cmd_jlist {
    527525    if ( !( scalar $conn->getJIDs() ) ) {
    528         BarnOwl::error("You are not logged in to Jabber.");
    529         return;
     526        die("You are not logged in to Jabber.\n");
    530527    }
    531528    BarnOwl::popless_ztext( onGetBuddyList() );
     
    534531sub cmd_jwrite {
    535532    if ( !$conn->connected() ) {
    536         BarnOwl::error("You are not logged in to Jabber.");
    537         return;
     533        die("You are not logged in to Jabber.\n");
    538534    }
    539535
     
    543539    my $jwrite_thread  = "";
    544540    my $jwrite_subject = "";
     541    my $jwrite_body;
    545542    my ($to, $from);
    546543    my $jwrite_type    = "chat";
     
    554551        'subject=s' => \$jwrite_subject,
    555552        'account=s' => \$from,
    556         'id=s'     =>  \$jwrite_sid,
     553        'id=s'      => \$jwrite_sid,
     554        'message=s' => \$jwrite_body,
    557555    ) or die("Usage: jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]\n");
    558556    $jwrite_type = 'groupchat' if $gc;
    559557
    560558    if ( scalar @ARGV != 1 ) {
    561         BarnOwl::error(
    562             "Usage: jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]");
    563         return;
     559        die("Usage: jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]\n");
    564560    }
    565561    else {
     
    570566
    571567    unless(scalar @candidates) {
    572         die("Unable to resolve JID $to");
     568        die("Unable to resolve JID $to\n");
    573569    }
    574570
     
    577573    unless(scalar @candidates) {
    578574        if(!$from) {
    579             die("You must specify an account with -a");
     575            die("You must specify an account with -a\n");
    580576        } else {
    581             die("Unable to resolve account $from");
     577            die("Unable to resolve account $from\n");
    582578        }
    583579    }
     
    594590        type    => $jwrite_type
    595591    };
     592
     593    if (defined($jwrite_body)) {
     594        process_owl_jwrite($jwrite_body);
     595        return;
     596    }
    596597
    597598    if(scalar @candidates > 1) {
     
    631632    my $func = $jmuc_commands{$cmd};
    632633    if ( !$func ) {
    633         BarnOwl::error("jmuc: Unknown command: $cmd");
    634         return;
     634        die("jmuc: Unknown command: $cmd\n");
    635635    }
    636636
     
    654654        }
    655655        else {
    656             BarnOwl::error('You must specify an account with -a <jid>');
     656            die("You must specify an account with -a <jid>\n");
    657657        }
    658658        return $func->( $jid, $muc, @ARGV );
     
    667667
    668668    $muc = shift @ARGV
    669       or die("Usage: jmuc join <muc> [-p <password>] [-a <account>]");
     669      or die("Usage: jmuc join <muc> [-p <password>] [-a <account>]\n");
    670670
    671671    die("Error: Must specify a fully-qualified MUC name (e.g. barnowl\@conference.mit.edu)\n")
     
    680680                                                   MaxChars => 0
    681681                                                  });
    682     $completion_jids{$muc} = 1;
     682    $completion_jids{$muc->GetJID('base')} = 1;
    683683    return;
    684684}
     
    688688
    689689    $muc = shift @args if scalar @args;
    690     die("Usage: jmuc part [<muc>] [-a <account>]") unless $muc;
     690    die("Usage: jmuc part [<muc>] [-a <account>]\n") unless $muc;
    691691
    692692    if($conn->getConnectionFromJID($jid)->MUCLeave(JID => $muc)) {
    693693        queue_admin_msg("$jid has left $muc.");
    694694    } else {
    695         die("Error: Not joined to $muc");
     695        die("Error: Not joined to $muc\n");
    696696    }
    697697}
     
    703703    $muc = shift @args if scalar @args;
    704704
    705     die('Usage: jmuc invite <jid> [<muc>] [-a <account>]')
     705    die("Usage: jmuc invite <jid> [<muc>] [-a <account>]\n")
    706706      unless $muc && $invite_jid;
    707707
     
    718718    my ( $jid, $muc, @args ) = @_;
    719719    $muc = shift @args if scalar @args;
    720     die("Usage: jmuc configure [<muc>]") unless $muc;
     720    die("Usage: jmuc configure [<muc>]\n") unless $muc;
    721721    my $iq = Net::Jabber::IQ->new();
    722722    $iq->SetTo($muc);
     
    759759
    760760    $muc = shift @args if scalar @args;
    761     die("Usage: jmuc presence [<muc>]") unless $muc;
     761    die("Usage: jmuc presence [<muc>]\n") unless $muc;
    762762
    763763    if ($muc eq '-a') {
     
    774774    else {
    775775        my $m = $conn->getConnectionFromJID($jid)->FindMUC(jid => $muc);
    776         die("No such muc: $muc") unless $m;
     776        die("No such muc: $muc\n") unless $m;
    777777        BarnOwl::popless_ztext(jmuc_presence_single($m));
    778778    }
     
    801801    my $func = $jroster_commands{$cmd};
    802802    if ( !$func ) {
    803         BarnOwl::error("jroster: Unknown command: $cmd");
    804         return;
     803        die("jroster: Unknown command: $cmd\n");
    805804    }
    806805
     
    825824        }
    826825        else {
    827             BarnOwl::error('You must specify an account with -a <jid>');
     826            die("You must specify an account with -a <jid>\n");
    828827        }
    829828        return $func->( $jid, $name, \@groups, $purgeGroups,  @ARGV );
     
    849848    }
    850849    else {
    851         BarnOwl::error('You must specify an account with -a <jid>');
     850        die("You must specify an account with -a <jid>\n");
    852851    }
    853852
     
    12341233        $completion_jids{$room} = 1;
    12351234
     1235        my $muc;
     1236        if ($dir eq 'in') {
     1237            my $connection = $conn->getConnectionFromSid($props{sid});
     1238            $muc = $connection->FindMUC(jid => $from);
     1239        } else {
     1240            my $connection = $conn->getConnectionFromJID($props{from});
     1241            $muc = $connection->FindMUC(jid => $to);
     1242        }
     1243        $props{from} = $muc->GetFullJID($from) || $nick || $room;
    12361244        $props{sender} = $nick || $room;
    12371245        $props{recipient} = $room;
     
    13311339        return $givenJIDStr if ($conn->jidExists($givenJIDStr) );
    13321340        return resolveConnectedJID($givenJID->GetJID('base')) if $loose;
    1333         die("Invalid account: $givenJIDStr");
     1341        die("Invalid account: $givenJIDStr\n");
    13341342    }
    13351343
     
    13841392        # Not one of ours.
    13851393        else {
    1386             die("Invalid account: $givenJIDStr");
     1394            die("Invalid account: $givenJIDStr\n");
    13871395        }
    13881396
     
    14301438    if($from) {
    14311439        $from_jid = resolveConnectedJID($from, 1);
    1432         die("Unable to resolve account $from") unless $from_jid;
     1440        die("Unable to resolve account $from\n") unless $from_jid;
    14331441        $to_jid = resolveDestJID($to, $from_jid);
    14341442        push @matches, [$from_jid, $to_jid] if $to_jid;
Note: See TracChangeset for help on using the changeset viewer.