[371] in BarnOwl Developers
[D-O-H] r513 - in trunk: . owl/perl/modules
daemon@ATHENA.MIT.EDU (nelhage@MIT.EDU)
Thu Oct 29 18:05:26 2009
Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: nelhage@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Wed, 10 Jan 2007 11:12:05 -0500 (EST)
Author: nelhage
Date: 2007-01-10 11:12:05 -0500 (Wed, 10 Jan 2007)
New Revision: 513
Modified:
trunk/
trunk/owl/perl/modules/jabber.pl
Log:
r17907@phanatique: nelhage | 2007-01-10 11:11:57 -0500
Replacing owl:: references in jabber.pl with BarnOwl::
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- bb873fd7-8e23-0410-944a-99ec44c633eb:/branches/owl/filter-rewrite:15925
bb873fd7-8e23-0410-944a-99ec44c633eb:/local/d-o-h/trunk:17902
+ bb873fd7-8e23-0410-944a-99ec44c633eb:/branches/owl/filter-rewrite:15925
bb873fd7-8e23-0410-944a-99ec44c633eb:/local/d-o-h/trunk:17907
Modified: trunk/owl/perl/modules/jabber.pl
===================================================================
--- trunk/owl/perl/modules/jabber.pl 2007-01-10 04:33:44 UTC (rev 512)
+++ trunk/owl/perl/modules/jabber.pl 2007-01-10 16:12:05 UTC (rev 513)
@@ -39,7 +39,7 @@
my $jidStr = shift;
my %args = ();
- if(owl::getvar('debug') eq 'on') {
+ if(BarnOwl::getvar('debug') eq 'on') {
$args{debuglevel} = 1;
$args{debugfile} = 'jabber.log';
}
@@ -126,13 +126,13 @@
our %vars;
sub onStart {
- if ( eval { \&owl::queue_message } ) {
+ if ( eval { \&BarnOwl::queue_message } ) {
register_owl_commands();
push @::onMainLoop, sub { owl_jabber::onMainLoop(@_) };
push @::onGetBuddyList, sub { owl_jabber::onGetBuddyList(@_) };
} else {
# Our owl doesn't support queue_message. Unfortunately, this
- # means it probably *also* doesn't support owl::error. So just
+ # means it probably *also* doesn't support BarnOwl::error. So just
# give up silently.
}
}
@@ -147,7 +147,7 @@
my $status = $client->Process(0);
if ( !defined($status) ) {
- owl::error("Jabber account $jid disconnected!");
+ BarnOwl::error("Jabber account $jid disconnected!");
do_logout($jid);
}
if ($::shutdown) {
@@ -224,30 +224,30 @@
################################################################################
### Owl Commands
sub register_owl_commands() {
- owl::new_command(
+ BarnOwl::new_command(
jabberlogin => \&cmd_login,
{ summary => "Log into jabber", },
{ usage => "jabberlogin JID" }
);
- owl::new_command(
+ BarnOwl::new_command(
jabberlogout => \&cmd_logout,
{ summary => "Log out of jabber" }
);
- owl::new_command(
+ BarnOwl::new_command(
jwrite => \&cmd_jwrite,
{
summary => "Send a Jabber Message",
usage => "jwrite JID [-g] [-t thread] [-s subject]"
}
);
- owl::new_command(
+ BarnOwl::new_command(
jlist => \&cmd_jlist,
{
summary => "Show your Jabber roster.",
usage => "jlist"
}
);
- owl::new_command(
+ BarnOwl::new_command(
jmuc => \&cmd_jmuc,
{
summary => "Jabber MUC related commands.",
@@ -257,7 +257,7 @@
. "part MUC Part a muc.\n"
. " The muc is taken from the current message if not supplied.\n\n"
. "invite JID MUC\n"
- . " Invite {jid} to [muc].\n"
+ . " Invite JID to MUC.\n"
. " The muc is taken from the current message if not supplied.\n\n"
. "configure MUC\n"
. " Configure [muc].\n"
@@ -266,7 +266,7 @@
usage => "jmuc COMMAND ARGS"
}
);
- owl::new_command(
+ BarnOwl::new_command(
jroster => \&cmd_jroster,
{
summary => "Jabber Roster related commands.",
@@ -288,12 +288,12 @@
my $jidStr = $jid->GetJID('full');
if ( !$uid || !$componentname ) {
- owl::error("usage: $cmd {jid}");
+ BarnOwl::error("usage: $cmd JID");
return;
}
if ( $conn->jidExists($jidStr) ) {
- owl::error("Already logged in as $jidStr.");
+ BarnOwl::error("Already logged in as $jidStr.");
return;
}
@@ -320,7 +320,7 @@
$vars{jlogin_authhash}->{password} = sub { return $vars{jlogin_password} || '' };
my $jidStr = $vars{jlogin_jid};
if ( !$jidStr && $vars{jlogin_havepass}) {
- owl::error("Got password but have no jid!");
+ BarnOwl::error("Got password but have no jid!");
}
else
{
@@ -347,19 +347,19 @@
my $status = $client->Connect( %{ $vars{jlogin_connhash} } );
if ( !$status ) {
$conn->removeConnection($jidStr);
- owl::error("We failed to connect");
+ BarnOwl::error("We failed to connect");
} else {
my @result = $client->AuthSend( %{ $vars{jlogin_authhash} } );
if ( !@result || $result[0] ne 'ok' ) {
- if ( !$vars{jlogin_havepass} && ( $#result == -1 || $result[0] eq '401' ) ) {
+ if ( !$vars{jlogin_havepass} && ( !@result || $result[0] eq '401' ) ) {
$vars{jlogin_havepass} = 1;
$conn->removeConnection($jidStr);
- owl::start_password( "Password for $jidStr: ", \&do_login );
+ BarnOwl::start_password( "Password for $jidStr: ", \&do_login );
return "";
}
$conn->removeConnection($jidStr);
- owl::error( "Error in connect: " . join( " ", @result ) );
+ BarnOwl::error( "Error in connect: " . join( " ", @result ) );
} else {
$conn->getRosterFromJidStr($jidStr)->fetch();
$client->PresenceSend( priority => 1 );
@@ -419,15 +419,15 @@
sub cmd_jlist {
if ( !( scalar $conn->getJids() ) ) {
- owl::error("You are not logged in to Jabber.");
+ BarnOwl::error("You are not logged in to Jabber.");
return;
}
- owl::popless_ztext( onGetBuddyList() );
+ BarnOwl::popless_ztext( onGetBuddyList() );
}
sub cmd_jwrite {
if ( !$conn->connected() ) {
- owl::error("You are not logged in to Jabber.");
+ BarnOwl::error("You are not logged in to Jabber.");
return;
}
@@ -452,7 +452,7 @@
$jwrite_type = 'groupchat' if $gc;
if ( scalar @ARGV != 1 ) {
- owl::error(
+ BarnOwl::error(
"Usage: jwrite JID [-g] [-t thread] [-s 'subject'] [-a account]");
return;
}
@@ -465,7 +465,7 @@
$jwrite_from = ( $conn->getJids() )[0];
}
else {
- owl::error("Please specify an account with -a {jid}");
+ BarnOwl::error("Please specify an account with -a JID");
return;
}
}
@@ -483,10 +483,10 @@
type => $jwrite_type
};
- owl::message(
+ BarnOwl::message(
"Type your message below. End with a dot on a line by itself. ^C will quit."
);
- owl::start_edit_win( join( ' ', @args ), \&process_owl_jwrite );
+ BarnOwl::start_edit_win( join( ' ', @args ), \&process_owl_jwrite );
}
sub cmd_jmuc {
@@ -507,7 +507,7 @@
);
my $func = $jmuc_commands{$cmd};
if ( !$func ) {
- owl::error("jmuc: Unknown command: $cmd");
+ BarnOwl::error("jmuc: Unknown command: $cmd");
return;
}
@@ -515,7 +515,7 @@
local @ARGV = @_;
my $jid;
my $muc;
- my $m = owl::getcurmsg();
+ my $m = BarnOwl::getcurmsg();
if ( $m->is_jabber && $m->{jtype} eq 'groupchat' ) {
$muc = $m->{room};
$jid = $m->{to};
@@ -530,7 +530,7 @@
return unless $jid;
}
else {
- owl::error('You must specify an account with -a {jid}');
+ BarnOwl::error('You must specify an account with -a {jid}');
}
return $func->( $jid, $muc, @ARGV );
}
@@ -622,7 +622,7 @@
my $func = $jroster_commands{$cmd};
if ( !$func ) {
- owl::error("jroster: Unknown command: $cmd");
+ BarnOwl::error("jroster: Unknown command: $cmd");
return;
}
@@ -646,7 +646,7 @@
return unless $jid;
}
else {
- owl::error('You must specify an account with -a {jid}');
+ BarnOwl::error('You must specify an account with -a {jid}');
}
return $func->( $jid, $name, \@groups, $purgeGroups, @ARGV );
}
@@ -808,8 +808,8 @@
$j->SetSubject( $vars{jwrite}{subject} ) if ( $vars{jwrite}{subject} );
my $m = j2o( $j, { direction => 'out' } );
- if ( $vars{jwrite}{type} ne 'groupchat' && owl::getvar('displayoutgoing') eq 'on') {
- owl::queue_message($m);
+ if ( $vars{jwrite}{type} ne 'groupchat' && BarnOwl::getvar('displayoutgoing') eq 'on') {
+ BarnOwl::queue_message($m);
}
if ($vars{jwrite}{sid} && $conn->sidExists( $vars{jwrite}{sid} )) {
@@ -820,14 +820,14 @@
}
delete $vars{jwrite};
- owl::message(""); # Kludge to make the ``type your message...'' message go away
+ BarnOwl::message(""); # Kludge to make the ``type your message...'' message go away
}
### XMPP Callbacks
sub process_incoming_chat_message {
my ( $sid, $j ) = @_;
- owl::queue_message( j2o( $j, { direction => 'in',
+ BarnOwl::queue_message( j2o( $j, { direction => 'in',
sid => $sid } ) );
}
@@ -836,7 +836,7 @@
my %jhash = j2hash( $j, { direction => 'in',
sid => $sid } );
$jhash{type} = 'admin';
- owl::queue_message( owl::Message->new(%jhash) );
+ BarnOwl::queue_message( BarnOwl::Message->new(%jhash) );
}
sub process_incoming_groupchat_message {
@@ -844,13 +844,13 @@
# HACK IN PROGRESS (ignoring delayed messages)
return if ( $j->DefinedX('jabber:x:delay') && $j->GetX('jabber:x:delay') );
- owl::queue_message( j2o( $j, { direction => 'in',
+ BarnOwl::queue_message( j2o( $j, { direction => 'in',
sid => $sid } ) );
}
sub process_incoming_headline_message {
my ( $sid, $j ) = @_;
- owl::queue_message( j2o( $j, { direction => 'in',
+ BarnOwl::queue_message( j2o( $j, { direction => 'in',
sid => $sid } ) );
}
@@ -870,7 +870,7 @@
# }
# }
#
- owl::queue_message( owl::Message->new(%jhash) );
+ BarnOwl::queue_message( BarnOwl::Message->new(%jhash) );
}
sub process_muc_presence {
@@ -905,7 +905,7 @@
$props{loginout} = 'logout';
}
$props{replysendercmd} = $props{replycmd} = "jwrite $from -i $sid";
- owl::queue_message(owl::Message->new(%props));
+ BarnOwl::queue_message(BarnOwl::Message->new(%props));
}
sub process_presence_subscribe {
@@ -923,7 +923,7 @@
$props{body} = "The user ($from) wants to subscribe to your ($to) presence.\nReply (r) will authorize, reply-sender (R) will deny.";
$props{replycmd} = "jroster auth $from -a $to";
$props{replysendercmd} = "jroster deauth $from -a $to";
- owl::queue_message(owl::Message->new(%props));
+ BarnOwl::queue_message(BarnOwl::Message->new(%props));
}
sub process_presence_unsubscribe {
@@ -939,7 +939,7 @@
direction => 'in');
$props{body} = "The user ($from) has been unsubscribed from your ($to) presence.\n";
- owl::queue_message(owl::Message->new(%props));
+ BarnOwl::queue_message(BarnOwl::Message->new(%props));
# Find a connection to reply with.
foreach my $jid ($conn->getJids()) {
@@ -978,7 +978,7 @@
my ( $sid, $p ) = @_;
my $code = $p->GetErrorCode();
my $error = $p->GetError();
- owl::error("Jabber: $code $error");
+ BarnOwl::error("Jabber: $code $error");
}
@@ -1055,17 +1055,17 @@
}
sub j2o {
- return owl::Message->new( j2hash(@_) );
+ return BarnOwl::Message->new( j2hash(@_) );
}
sub queue_admin_msg {
my $err = shift;
- my $m = owl::Message->new(
+ my $m = BarnOwl::Message->new(
type => 'admin',
direction => 'none',
body => $err
);
- owl::queue_message($m);
+ BarnOwl::queue_message($m);
}
sub boldify($) {
@@ -1117,7 +1117,7 @@
if ( $givenJid->GetResource() ) {
# Specified account exists
return $givenJidStr if ($conn->jidExists($givenJidStr) );
- owl::error("Invalid account: $givenJidStr");
+ BarnOwl::error("Invalid account: $givenJidStr");
}
# Disambiguate.
@@ -1144,7 +1144,7 @@
# Not one of ours.
elsif ( $matchingJid eq "" ) {
- owl::error("Invalid account: $givenJidStr");
+ BarnOwl::error("Invalid account: $givenJidStr");
}
# It's this one.
@@ -1158,9 +1158,9 @@
#####################################################################
#####################################################################
-package owl::Message::Jabber;
+package BarnOwl::Message::Jabber;
-our @ISA = qw( owl::Message );
+our @ISA = qw( BarnOwl::Message );
sub jtype { shift->{jtype} };
sub from { shift->{from} };
@@ -1184,13 +1184,13 @@
$filter = "jabber-user-$user";
$ftext = qq{type ^jabber\$ and ( ( direction ^in\$ and from ^$user ) } .
qq{or ( direction ^out\$ and to ^$user ) ) };
- owl::filter("$filter $ftext");
+ BarnOwl::filter("$filter $ftext");
return $filter;
} elsif ($self->jtype eq 'groupchat') {
my $room = $self->room;
$filter = "jabber-room-$room";
$ftext = qq{type ^jabber\$ and room ^$room\$};
- owl::filter("$filter $ftext");
+ BarnOwl::filter("$filter $ftext");
return $filter;
}
}