Changeset d609dd6 for perl


Ignore:
Timestamp:
Jan 10, 2007, 11:12:05 AM (18 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:
f4d32cd
Parents:
8203afd
git-author:
Nelson Elhage <nelhage@mit.edu> (01/10/07 11:11:57)
git-committer:
Nelson Elhage <nelhage@mit.edu> (01/10/07 11:12:05)
Message:
Replacing owl:: references in jabber.pl with BarnOwl::
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/modules/jabber.pl

    rffe70f9 rd609dd6  
    4040
    4141    my %args = ();
    42     if(owl::getvar('debug') eq 'on') {
     42    if(BarnOwl::getvar('debug') eq 'on') {
    4343        $args{debuglevel} = 1;
    4444        $args{debugfile} = 'jabber.log';
     
    127127
    128128sub onStart {
    129     if ( eval { \&owl::queue_message } ) {
     129    if ( eval { \&BarnOwl::queue_message } ) {
    130130        register_owl_commands();
    131131        push @::onMainLoop,     sub { owl_jabber::onMainLoop(@_) };
     
    133133    } else {
    134134        # Our owl doesn't support queue_message. Unfortunately, this
    135         # means it probably *also* doesn't support owl::error. So just
     135        # means it probably *also* doesn't support BarnOwl::error. So just
    136136        # give up silently.
    137137    }
     
    148148        my $status = $client->Process(0);
    149149        if ( !defined($status) ) {
    150             owl::error("Jabber account $jid disconnected!");
     150            BarnOwl::error("Jabber account $jid disconnected!");
    151151            do_logout($jid);
    152152        }
     
    225225### Owl Commands
    226226sub register_owl_commands() {
    227     owl::new_command(
     227    BarnOwl::new_command(
    228228        jabberlogin => \&cmd_login,
    229229        { summary => "Log into jabber", },
    230230        { usage   => "jabberlogin JID" }
    231231    );
    232     owl::new_command(
     232    BarnOwl::new_command(
    233233        jabberlogout => \&cmd_logout,
    234234        { summary => "Log out of jabber" }
    235235    );
    236     owl::new_command(
     236    BarnOwl::new_command(
    237237        jwrite => \&cmd_jwrite,
    238238        {
     
    241241        }
    242242    );
    243     owl::new_command(
     243    BarnOwl::new_command(
    244244        jlist => \&cmd_jlist,
    245245        {
     
    248248        }
    249249    );
    250     owl::new_command(
     250    BarnOwl::new_command(
    251251        jmuc => \&cmd_jmuc,
    252252        {
     
    258258              . "            The muc is taken from the current message if not supplied.\n\n"
    259259              . "invite JID MUC\n"
    260               . "            Invite {jid} to [muc].\n"
     260              . "            Invite JID to MUC.\n"
    261261              . "            The muc is taken from the current message if not supplied.\n\n"
    262262              . "configure MUC\n"
     
    267267        }
    268268    );
    269     owl::new_command(
     269    BarnOwl::new_command(
    270270        jroster => \&cmd_jroster,
    271271        {
     
    289289
    290290    if ( !$uid || !$componentname ) {
    291         owl::error("usage: $cmd {jid}");
     291        BarnOwl::error("usage: $cmd JID");
    292292        return;
    293293    }
    294294
    295295    if ( $conn->jidExists($jidStr) ) {
    296         owl::error("Already logged in as $jidStr.");
     296        BarnOwl::error("Already logged in as $jidStr.");
    297297        return;
    298298    }
     
    321321    my $jidStr = $vars{jlogin_jid};
    322322    if ( !$jidStr && $vars{jlogin_havepass}) {
    323         owl::error("Got password but have no jid!");
     323        BarnOwl::error("Got password but have no jid!");
    324324    }
    325325    else
     
    348348        if ( !$status ) {
    349349            $conn->removeConnection($jidStr);
    350             owl::error("We failed to connect");
     350            BarnOwl::error("We failed to connect");
    351351        } else {
    352352            my @result = $client->AuthSend( %{ $vars{jlogin_authhash} } );
    353353
    354354            if ( !@result || $result[0] ne 'ok' ) {
    355                 if ( !$vars{jlogin_havepass} && ( $#result == -1 || $result[0] eq '401' ) ) {
     355                if ( !$vars{jlogin_havepass} && ( !@result || $result[0] eq '401' ) ) {
    356356                    $vars{jlogin_havepass} = 1;
    357357                    $conn->removeConnection($jidStr);
    358                     owl::start_password( "Password for $jidStr: ", \&do_login );
     358                    BarnOwl::start_password( "Password for $jidStr: ", \&do_login );
    359359                    return "";
    360360                }
    361361                $conn->removeConnection($jidStr);
    362                 owl::error( "Error in connect: " . join( " ", @result ) );
     362                BarnOwl::error( "Error in connect: " . join( " ", @result ) );
    363363            } else {
    364364                $conn->getRosterFromJidStr($jidStr)->fetch();
     
    420420sub cmd_jlist {
    421421    if ( !( scalar $conn->getJids() ) ) {
    422         owl::error("You are not logged in to Jabber.");
     422        BarnOwl::error("You are not logged in to Jabber.");
    423423        return;
    424424    }
    425     owl::popless_ztext( onGetBuddyList() );
     425    BarnOwl::popless_ztext( onGetBuddyList() );
    426426}
    427427
    428428sub cmd_jwrite {
    429429    if ( !$conn->connected() ) {
    430         owl::error("You are not logged in to Jabber.");
     430        BarnOwl::error("You are not logged in to Jabber.");
    431431        return;
    432432    }
     
    453453
    454454    if ( scalar @ARGV != 1 ) {
    455         owl::error(
     455        BarnOwl::error(
    456456            "Usage: jwrite JID [-g] [-t thread] [-s 'subject'] [-a account]");
    457457        return;
     
    466466        }
    467467        else {
    468             owl::error("Please specify an account with -a {jid}");
     468            BarnOwl::error("Please specify an account with -a JID");
    469469            return;
    470470        }
     
    484484    };
    485485
    486     owl::message(
     486    BarnOwl::message(
    487487"Type your message below.  End with a dot on a line by itself.  ^C will quit."
    488488    );
    489     owl::start_edit_win( join( ' ', @args ), \&process_owl_jwrite );
     489    BarnOwl::start_edit_win( join( ' ', @args ), \&process_owl_jwrite );
    490490}
    491491
     
    508508    my $func = $jmuc_commands{$cmd};
    509509    if ( !$func ) {
    510         owl::error("jmuc: Unknown command: $cmd");
     510        BarnOwl::error("jmuc: Unknown command: $cmd");
    511511        return;
    512512    }
     
    516516        my $jid;
    517517        my $muc;
    518         my $m = owl::getcurmsg();
     518        my $m = BarnOwl::getcurmsg();
    519519        if ( $m->is_jabber && $m->{jtype} eq 'groupchat' ) {
    520520            $muc = $m->{room};
     
    531531        }
    532532        else {
    533             owl::error('You must specify an account with -a {jid}');
     533            BarnOwl::error('You must specify an account with -a {jid}');
    534534        }
    535535        return $func->( $jid, $muc, @ARGV );
     
    623623    my $func = $jroster_commands{$cmd};
    624624    if ( !$func ) {
    625         owl::error("jroster: Unknown command: $cmd");
     625        BarnOwl::error("jroster: Unknown command: $cmd");
    626626        return;
    627627    }
     
    647647        }
    648648        else {
    649             owl::error('You must specify an account with -a {jid}');
     649            BarnOwl::error('You must specify an account with -a {jid}');
    650650        }
    651651        return $func->( $jid, $name, \@groups, $purgeGroups,  @ARGV );
     
    809809
    810810    my $m = j2o( $j, { direction => 'out' } );
    811     if ( $vars{jwrite}{type} ne 'groupchat' && owl::getvar('displayoutgoing') eq 'on') {
    812         owl::queue_message($m);
     811    if ( $vars{jwrite}{type} ne 'groupchat' && BarnOwl::getvar('displayoutgoing') eq 'on') {
     812        BarnOwl::queue_message($m);
    813813    }
    814814
     
    821821
    822822    delete $vars{jwrite};
    823     owl::message("");   # Kludge to make the ``type your message...'' message go away
     823    BarnOwl::message("");   # Kludge to make the ``type your message...'' message go away
    824824}
    825825
     
    828828sub process_incoming_chat_message {
    829829    my ( $sid, $j ) = @_;
    830     owl::queue_message( j2o( $j, { direction => 'in',
     830    BarnOwl::queue_message( j2o( $j, { direction => 'in',
    831831                                   sid => $sid } ) );
    832832}
     
    837837                              sid => $sid } );
    838838    $jhash{type} = 'admin';
    839     owl::queue_message( owl::Message->new(%jhash) );
     839    BarnOwl::queue_message( BarnOwl::Message->new(%jhash) );
    840840}
    841841
     
    845845    # HACK IN PROGRESS (ignoring delayed messages)
    846846    return if ( $j->DefinedX('jabber:x:delay') && $j->GetX('jabber:x:delay') );
    847     owl::queue_message( j2o( $j, { direction => 'in',
     847    BarnOwl::queue_message( j2o( $j, { direction => 'in',
    848848                                   sid => $sid } ) );
    849849}
     
    851851sub process_incoming_headline_message {
    852852    my ( $sid, $j ) = @_;
    853     owl::queue_message( j2o( $j, { direction => 'in',
     853    BarnOwl::queue_message( j2o( $j, { direction => 'in',
    854854                                   sid => $sid } ) );
    855855}
     
    871871    #    }
    872872    #
    873     owl::queue_message( owl::Message->new(%jhash) );
     873    BarnOwl::queue_message( BarnOwl::Message->new(%jhash) );
    874874}
    875875
     
    906906    }
    907907    $props{replysendercmd} = $props{replycmd} = "jwrite $from -i $sid";
    908     owl::queue_message(owl::Message->new(%props));
     908    BarnOwl::queue_message(BarnOwl::Message->new(%props));
    909909}
    910910
     
    924924    $props{replycmd} = "jroster auth $from -a $to";
    925925    $props{replysendercmd} = "jroster deauth $from -a $to";
    926     owl::queue_message(owl::Message->new(%props));
     926    BarnOwl::queue_message(BarnOwl::Message->new(%props));
    927927}
    928928
     
    940940
    941941    $props{body} = "The user ($from) has been unsubscribed from your ($to) presence.\n";
    942     owl::queue_message(owl::Message->new(%props));
     942    BarnOwl::queue_message(BarnOwl::Message->new(%props));
    943943
    944944    # Find a connection to reply with.
     
    979979    my $code = $p->GetErrorCode();
    980980    my $error = $p->GetError();
    981     owl::error("Jabber: $code $error");
     981    BarnOwl::error("Jabber: $code $error");
    982982}
    983983
     
    10561056
    10571057sub j2o {
    1058     return owl::Message->new( j2hash(@_) );
     1058    return BarnOwl::Message->new( j2hash(@_) );
    10591059}
    10601060
    10611061sub queue_admin_msg {
    10621062    my $err = shift;
    1063     my $m   = owl::Message->new(
     1063    my $m   = BarnOwl::Message->new(
    10641064        type      => 'admin',
    10651065        direction => 'none',
    10661066        body      => $err
    10671067    );
    1068     owl::queue_message($m);
     1068    BarnOwl::queue_message($m);
    10691069}
    10701070
     
    11181118        # Specified account exists
    11191119        return $givenJidStr if ($conn->jidExists($givenJidStr) );
    1120         owl::error("Invalid account: $givenJidStr");
     1120        BarnOwl::error("Invalid account: $givenJidStr");
    11211121    }
    11221122
     
    11451145        # Not one of ours.
    11461146        elsif ( $matchingJid eq "" ) {
    1147             owl::error("Invalid account: $givenJidStr");
     1147            BarnOwl::error("Invalid account: $givenJidStr");
    11481148        }
    11491149
     
    11591159#####################################################################
    11601160
    1161 package owl::Message::Jabber;
    1162 
    1163 our @ISA = qw( owl::Message );
     1161package BarnOwl::Message::Jabber;
     1162
     1163our @ISA = qw( BarnOwl::Message );
    11641164
    11651165sub jtype { shift->{jtype} };
     
    11851185        $ftext = qq{type ^jabber\$ and ( ( direction ^in\$ and from ^$user ) } .
    11861186                 qq{or ( direction ^out\$ and to ^$user ) ) };
    1187         owl::filter("$filter $ftext");
     1187        BarnOwl::filter("$filter $ftext");
    11881188        return $filter;
    11891189    } elsif ($self->jtype eq 'groupchat') {
     
    11911191        $filter = "jabber-room-$room";
    11921192        $ftext = qq{type ^jabber\$ and room ^$room\$};
    1193         owl::filter("$filter $ftext");
     1193        BarnOwl::filter("$filter $ftext");
    11941194        return $filter;
    11951195    }
Note: See TracChangeset for help on using the changeset viewer.