[b405ff6] | 1 | # -*- mode: cperl; cperl-indent-level: 4; indent-tabs-mode: nil -*- |
---|
[60986b2] | 2 | package BarnOwl::Jabber; |
---|
[9f183ff] | 3 | use warnings; |
---|
| 4 | use strict; |
---|
| 5 | |
---|
[38ffdf9] | 6 | use Authen::SASL qw(Perl); |
---|
| 7 | use Net::Jabber; |
---|
[1dfc7df] | 8 | use Net::Jabber::MUC; |
---|
[6a6dd47] | 9 | use Net::DNS; |
---|
| 10 | use Getopt::Long; |
---|
| 11 | |
---|
[84296f6] | 12 | no warnings 'redefine'; |
---|
| 13 | |
---|
[38ffdf9] | 14 | ################################################################################ |
---|
| 15 | # owl perl jabber support |
---|
| 16 | # |
---|
[b6a253c] | 17 | # XXX Todo: |
---|
| 18 | # Rosters for MUCs |
---|
| 19 | # More user feedback |
---|
| 20 | # * joining MUC |
---|
| 21 | # * parting MUC |
---|
| 22 | # * presence (Roster and MUC) |
---|
| 23 | # Implementing formatting and logging callbacks for C |
---|
| 24 | # Appropriate callbacks for presence subscription messages. |
---|
[38ffdf9] | 25 | # |
---|
| 26 | ################################################################################ |
---|
| 27 | |
---|
[f62550d] | 28 | |
---|
| 29 | ################################################################################ |
---|
| 30 | ################################################################################ |
---|
[30c735c] | 31 | package BarnOwl::Jabber::Connection; |
---|
| 32 | |
---|
| 33 | use base qw(Net::Jabber::Client); |
---|
| 34 | |
---|
| 35 | sub new { |
---|
| 36 | my $class = shift; |
---|
| 37 | |
---|
| 38 | my %args = (); |
---|
| 39 | if(BarnOwl::getvar('debug') eq 'on') { |
---|
| 40 | $args{debuglevel} = 1; |
---|
| 41 | $args{debugfile} = 'jabber.log'; |
---|
| 42 | } |
---|
| 43 | my $self = $class->SUPER::new(%args); |
---|
[1dfc7df] | 44 | $self->{_BARNOWL_MUCS} = []; |
---|
| 45 | return $self; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | =head2 MUCJoin |
---|
| 49 | |
---|
| 50 | Extends MUCJoin to keep track of the MUCs we're joined to as |
---|
| 51 | Net::Jabber::MUC objects. Takes the same arguments as |
---|
| 52 | L<Net::Jabber::MUC/new> and L<Net::Jabber::MUC/Connect> |
---|
| 53 | |
---|
| 54 | =cut |
---|
| 55 | |
---|
| 56 | sub MUCJoin { |
---|
| 57 | my $self = shift; |
---|
| 58 | my $muc = Net::Jabber::MUC->new(connection => $self, @_); |
---|
| 59 | $muc->Join(@_); |
---|
| 60 | push @{$self->MUCs}, $muc; |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | =head2 MUCLeave ARGS |
---|
| 64 | |
---|
| 65 | Leave a MUC. The MUC is specified in the same form as L</FindMUC> |
---|
| 66 | |
---|
| 67 | =cut |
---|
| 68 | |
---|
| 69 | sub MUCLeave { |
---|
| 70 | my $self = shift; |
---|
| 71 | my $muc = $self->FindMUC(@_); |
---|
| 72 | return unless $muc; |
---|
| 73 | |
---|
| 74 | $muc->Leave(); |
---|
| 75 | |
---|
| 76 | $self->{_BARNOWL_MUCS} = grep {$_ != $muc} $self->MUCs; |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | =head2 FindMUC ARGS |
---|
| 80 | |
---|
| 81 | Return the Net::Jabber::MUC object representing a specific MUC we're |
---|
| 82 | joined to, undef if it doesn't exists. ARGS can be either JID => $JID, |
---|
| 83 | or Room => $room, Server => $server. |
---|
| 84 | |
---|
| 85 | =cut |
---|
| 86 | |
---|
| 87 | sub FindMUC { |
---|
| 88 | my $self = shift; |
---|
| 89 | |
---|
| 90 | my %args; |
---|
| 91 | while($#_ >= 0) { $args{ lc(pop(@_)) } = pop(@_); } |
---|
| 92 | |
---|
| 93 | my $jid; |
---|
| 94 | if($args{jid}) { |
---|
| 95 | $jid = $args{jid}; |
---|
| 96 | } elsif($args{room} && $args{server}) { |
---|
| 97 | $jid = Net::Jabber::JID->new(userid => $args{room}, |
---|
| 98 | server => $args{server}); |
---|
| 99 | } |
---|
| 100 | $jid = $jid->GetJID('base') if UNIVERSAL::isa($jid, 'Net::Jabber::JID'); |
---|
| 101 | |
---|
| 102 | foreach my $muc ($self->MUCs) { |
---|
| 103 | return $muc if $muc->BaseJID eq $jid; |
---|
| 104 | } |
---|
| 105 | return undef; |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | =head2 MUCs |
---|
| 109 | |
---|
| 110 | Returns a list (or arrayref in scalar context) of Net::Jabber::MUC |
---|
| 111 | objects we believe ourself to be connected to. |
---|
| 112 | |
---|
| 113 | =cut |
---|
| 114 | |
---|
| 115 | sub MUCs { |
---|
| 116 | my $self = shift; |
---|
| 117 | my $mucs = $self->{_BARNOWL_MUCS}; |
---|
| 118 | return wantarray ? @$mucs : $mucs; |
---|
[30c735c] | 119 | } |
---|
| 120 | |
---|
| 121 | ################################################################################ |
---|
| 122 | ################################################################################ |
---|
[60986b2] | 123 | package BarnOwl::Jabber::ConnectionManager; |
---|
[f62550d] | 124 | sub new { |
---|
| 125 | my $class = shift; |
---|
| 126 | return bless { }, $class; |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | sub addConnection { |
---|
| 130 | my $self = shift; |
---|
| 131 | my $jidStr = shift; |
---|
| 132 | |
---|
[30c735c] | 133 | my $client = BarnOwl::Jabber::Connection->new; |
---|
[bed4ff1] | 134 | |
---|
| 135 | $self->{Client}->{$jidStr} = $client; |
---|
| 136 | $self->{Roster}->{$jidStr} = $client->Roster(); |
---|
| 137 | return $client; |
---|
[f62550d] | 138 | } |
---|
| 139 | |
---|
| 140 | sub removeConnection { |
---|
| 141 | my $self = shift; |
---|
| 142 | my $jidStr = shift; |
---|
[bed4ff1] | 143 | return 0 unless exists $self->{Client}->{$jidStr}; |
---|
[4096d1f] | 144 | |
---|
[bed4ff1] | 145 | $self->{Client}->{$jidStr}->Disconnect(); |
---|
| 146 | delete $self->{Roster}->{$jidStr}; |
---|
| 147 | delete $self->{Client}->{$jidStr}; |
---|
[4096d1f] | 148 | |
---|
[bed4ff1] | 149 | return 1; |
---|
[f62550d] | 150 | } |
---|
| 151 | |
---|
| 152 | sub connected { |
---|
| 153 | my $self = shift; |
---|
| 154 | return scalar keys %{ $self->{Client} }; |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | sub getJids { |
---|
| 158 | my $self = shift; |
---|
| 159 | return keys %{ $self->{Client} }; |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | sub jidExists { |
---|
| 163 | my $self = shift; |
---|
| 164 | my $jidStr = shift; |
---|
[bed4ff1] | 165 | return exists $self->{Client}->{$jidStr}; |
---|
[f62550d] | 166 | } |
---|
| 167 | |
---|
| 168 | sub sidExists { |
---|
| 169 | my $self = shift; |
---|
| 170 | my $sid = shift || ""; |
---|
| 171 | foreach my $j ( keys %{ $self->{Client} } ) { |
---|
| 172 | return 1 if ($self->{Client}->{$j}->{SESSION}->{id} eq $sid); |
---|
| 173 | } |
---|
| 174 | return 0; |
---|
| 175 | } |
---|
| 176 | |
---|
[bed4ff1] | 177 | sub getConnectionFromSid { |
---|
[f62550d] | 178 | my $self = shift; |
---|
| 179 | my $sid = shift; |
---|
[bed4ff1] | 180 | foreach my $c (values %{ $self->{Client} }) { |
---|
| 181 | return $c if $c->{SESSION}->{id} eq $sid; |
---|
[f62550d] | 182 | } |
---|
| 183 | return undef; |
---|
| 184 | } |
---|
| 185 | |
---|
[bed4ff1] | 186 | sub getConnectionFromJidStr { |
---|
[f62550d] | 187 | my $self = shift; |
---|
| 188 | my $jidStr = shift; |
---|
[bed4ff1] | 189 | return $self->{Client}->{$jidStr}; |
---|
[f62550d] | 190 | } |
---|
| 191 | |
---|
[bed4ff1] | 192 | sub getRosterFromSid { |
---|
[f62550d] | 193 | my $self = shift; |
---|
| 194 | my $sid = shift; |
---|
[bed4ff1] | 195 | foreach my $j ( $self->getJids ) { |
---|
| 196 | return $self->{Roster}->{$j} |
---|
| 197 | if $self->{Client}->{$j}->{SESSION}->{id} eq $sid; |
---|
[f62550d] | 198 | } |
---|
| 199 | return undef; |
---|
| 200 | } |
---|
| 201 | |
---|
[bed4ff1] | 202 | sub getRosterFromJidStr { |
---|
[f62550d] | 203 | my $self = shift; |
---|
| 204 | my $jidStr = shift; |
---|
[bed4ff1] | 205 | return $self->{Roster}->{$jidStr}; |
---|
[f62550d] | 206 | return undef; |
---|
| 207 | } |
---|
| 208 | ################################################################################ |
---|
| 209 | |
---|
[30c735c] | 210 | package BarnOwl::Jabber; |
---|
[f62550d] | 211 | |
---|
[60986b2] | 212 | our $conn = new BarnOwl::Jabber::ConnectionManager unless $conn;; |
---|
[6a6dd47] | 213 | our %vars; |
---|
[38ffdf9] | 214 | |
---|
[b405ff6] | 215 | sub onStart { |
---|
[5551208] | 216 | if ( *BarnOwl::queue_message{CODE} ) { |
---|
[b405ff6] | 217 | register_owl_commands(); |
---|
[60986b2] | 218 | push @::onMainLoop, sub { BarnOwl::Jabber::onMainLoop(@_) }; |
---|
| 219 | push @::onGetBuddyList, sub { BarnOwl::Jabber::onGetBuddyList(@_) }; |
---|
[9667006] | 220 | } else { |
---|
[38ffdf9] | 221 | # Our owl doesn't support queue_message. Unfortunately, this |
---|
[d609dd6] | 222 | # means it probably *also* doesn't support BarnOwl::error. So just |
---|
[38ffdf9] | 223 | # give up silently. |
---|
| 224 | } |
---|
| 225 | } |
---|
[9f183ff] | 226 | |
---|
[60986b2] | 227 | push @::onStartSubs, sub { BarnOwl::Jabber::onStart(@_) }; |
---|
[38ffdf9] | 228 | |
---|
[b405ff6] | 229 | sub onMainLoop { |
---|
[f62550d] | 230 | return if ( !$conn->connected() ); |
---|
[6a6dd47] | 231 | |
---|
[f62550d] | 232 | foreach my $jid ( $conn->getJids() ) { |
---|
[bed4ff1] | 233 | my $client = $conn->getConnectionFromJidStr($jid); |
---|
[b405ff6] | 234 | |
---|
[5c9c27d] | 235 | my $status = $client->Process(0); |
---|
[b405ff6] | 236 | if ( !defined($status) ) { |
---|
[d609dd6] | 237 | BarnOwl::error("Jabber account $jid disconnected!"); |
---|
[960395d] | 238 | do_logout($jid); |
---|
| 239 | } |
---|
[b405ff6] | 240 | if ($::shutdown) { |
---|
| 241 | do_logout($jid); |
---|
| 242 | return; |
---|
| 243 | } |
---|
[38ffdf9] | 244 | } |
---|
| 245 | } |
---|
[b6a253c] | 246 | |
---|
[b405ff6] | 247 | sub blist_listBuddy { |
---|
[6a6dd47] | 248 | my $roster = shift; |
---|
[b405ff6] | 249 | my $buddy = shift; |
---|
[b6a253c] | 250 | my $blistStr .= " "; |
---|
[5c9c27d] | 251 | my %jq = $roster->query($buddy); |
---|
| 252 | my $res = $roster->resource($buddy); |
---|
[b6a253c] | 253 | |
---|
[f62550d] | 254 | $blistStr .= $jq{name} ? $jq{name} . "\t(" .$buddy->GetJID() . ')' : $buddy->GetJID(); |
---|
[b405ff6] | 255 | |
---|
| 256 | if ($res) { |
---|
[5c9c27d] | 257 | my %rq = $roster->resourceQuery( $buddy, $res ); |
---|
[b405ff6] | 258 | $blistStr .= " [" . ( $rq{show} ? $rq{show} : 'online' ) . "]"; |
---|
| 259 | $blistStr .= " " . $rq{status} if $rq{status}; |
---|
| 260 | $blistStr = boldify($blistStr); |
---|
[b6a253c] | 261 | } |
---|
[b405ff6] | 262 | else { |
---|
[84296f6] | 263 | if ($jq{ask}) { |
---|
| 264 | $blistStr .= " [pending]"; |
---|
| 265 | } |
---|
| 266 | elsif ($jq{subscription} eq 'none' || $jq{subscription} eq 'from') { |
---|
| 267 | $blistStr .= " [not subscribed]"; |
---|
| 268 | } |
---|
| 269 | else { |
---|
| 270 | $blistStr .= " [offline]"; |
---|
| 271 | } |
---|
[b6a253c] | 272 | } |
---|
[b405ff6] | 273 | return $blistStr . "\n"; |
---|
[b6a253c] | 274 | } |
---|
| 275 | |
---|
[84296f6] | 276 | sub getSingleBuddyList { |
---|
| 277 | my $jid = shift; |
---|
| 278 | $jid = resolveJID($jid); |
---|
| 279 | return "" unless $jid; |
---|
[6a6dd47] | 280 | my $blist = ""; |
---|
[bed4ff1] | 281 | my $roster = $conn->getRosterFromJidStr($jid); |
---|
| 282 | if ($roster) { |
---|
[84296f6] | 283 | $blist .= "\n" . boldify("Jabber Roster for $jid\n"); |
---|
| 284 | |
---|
[5c9c27d] | 285 | foreach my $group ( $roster->groups() ) { |
---|
[84296f6] | 286 | $blist .= " Group: $group\n"; |
---|
[5c9c27d] | 287 | foreach my $buddy ( $roster->jids( 'group', $group ) ) { |
---|
[84296f6] | 288 | $blist .= blist_listBuddy( $roster, $buddy ); |
---|
[b405ff6] | 289 | } |
---|
[84296f6] | 290 | } |
---|
[b405ff6] | 291 | |
---|
[5c9c27d] | 292 | my @unsorted = $roster->jids('nogroup'); |
---|
[84296f6] | 293 | if (@unsorted) { |
---|
| 294 | $blist .= " [unsorted]\n"; |
---|
| 295 | foreach my $buddy (@unsorted) { |
---|
| 296 | $blist .= blist_listBuddy( $roster, $buddy ); |
---|
[b405ff6] | 297 | } |
---|
| 298 | } |
---|
[b6a253c] | 299 | } |
---|
[6a6dd47] | 300 | return $blist; |
---|
[b6a253c] | 301 | } |
---|
[38ffdf9] | 302 | |
---|
[84296f6] | 303 | sub onGetBuddyList { |
---|
| 304 | my $blist = ""; |
---|
[f62550d] | 305 | foreach my $jid ($conn->getJids()) { |
---|
[84296f6] | 306 | $blist .= getSingleBuddyList($jid); |
---|
| 307 | } |
---|
| 308 | return $blist; |
---|
| 309 | } |
---|
| 310 | |
---|
[38ffdf9] | 311 | ################################################################################ |
---|
| 312 | ### Owl Commands |
---|
[b405ff6] | 313 | sub register_owl_commands() { |
---|
[d609dd6] | 314 | BarnOwl::new_command( |
---|
[38ffdf9] | 315 | jabberlogin => \&cmd_login, |
---|
[5adb3d7] | 316 | { summary => "Log into jabber", }, |
---|
| 317 | { usage => "jabberlogin JID" } |
---|
[38ffdf9] | 318 | ); |
---|
[d609dd6] | 319 | BarnOwl::new_command( |
---|
[38ffdf9] | 320 | jabberlogout => \&cmd_logout, |
---|
| 321 | { summary => "Log out of jabber" } |
---|
| 322 | ); |
---|
[d609dd6] | 323 | BarnOwl::new_command( |
---|
[38ffdf9] | 324 | jwrite => \&cmd_jwrite, |
---|
| 325 | { |
---|
[b405ff6] | 326 | summary => "Send a Jabber Message", |
---|
| 327 | usage => "jwrite JID [-g] [-t thread] [-s subject]" |
---|
[38ffdf9] | 328 | } |
---|
| 329 | ); |
---|
[d609dd6] | 330 | BarnOwl::new_command( |
---|
[b6a253c] | 331 | jlist => \&cmd_jlist, |
---|
[38ffdf9] | 332 | { |
---|
[b405ff6] | 333 | summary => "Show your Jabber roster.", |
---|
| 334 | usage => "jlist" |
---|
[38ffdf9] | 335 | } |
---|
| 336 | ); |
---|
[d609dd6] | 337 | BarnOwl::new_command( |
---|
[b6a253c] | 338 | jmuc => \&cmd_jmuc, |
---|
[38ffdf9] | 339 | { |
---|
[b6a253c] | 340 | summary => "Jabber MUC related commands.", |
---|
[b405ff6] | 341 | description => "jmuc sends jabber commands related to muc.\n\n" |
---|
| 342 | . "The following commands are available\n\n" |
---|
[5adb3d7] | 343 | . "join MUC Join a muc.\n\n" |
---|
| 344 | . "part MUC Part a muc.\n" |
---|
[b405ff6] | 345 | . " The muc is taken from the current message if not supplied.\n\n" |
---|
[5adb3d7] | 346 | . "invite JID MUC\n" |
---|
[d609dd6] | 347 | . " Invite JID to MUC.\n" |
---|
[b405ff6] | 348 | . " The muc is taken from the current message if not supplied.\n\n" |
---|
[5adb3d7] | 349 | . "configure MUC\n" |
---|
[d9f4a5c] | 350 | . " Configure [muc].\n" |
---|
[5adb3d7] | 351 | . " Necessary to initalize a new MUC\n" |
---|
| 352 | . " At present, only the default configuration is supported.", |
---|
| 353 | usage => "jmuc COMMAND ARGS" |
---|
[38ffdf9] | 354 | } |
---|
| 355 | ); |
---|
[d609dd6] | 356 | BarnOwl::new_command( |
---|
[f62550d] | 357 | jroster => \&cmd_jroster, |
---|
| 358 | { |
---|
| 359 | summary => "Jabber Roster related commands.", |
---|
[5adb3d7] | 360 | description => "jroster sends jabber commands related to rosters.\n\n", |
---|
| 361 | usage => "jroster COMMAND ARGS" |
---|
[f62550d] | 362 | } |
---|
| 363 | ); |
---|
[38ffdf9] | 364 | } |
---|
| 365 | |
---|
[b405ff6] | 366 | sub cmd_login { |
---|
[6a6dd47] | 367 | my $cmd = shift; |
---|
| 368 | my $jid = new Net::XMPP::JID; |
---|
| 369 | $jid->SetJID(shift); |
---|
[b405ff6] | 370 | |
---|
| 371 | my $uid = $jid->GetUserID(); |
---|
[6a6dd47] | 372 | my $componentname = $jid->GetServer(); |
---|
[b405ff6] | 373 | my $resource = $jid->GetResource() || 'owl'; |
---|
[6a6dd47] | 374 | $jid->SetResource($resource); |
---|
| 375 | my $jidStr = $jid->GetJID('full'); |
---|
| 376 | |
---|
[b405ff6] | 377 | if ( !$uid || !$componentname ) { |
---|
[d609dd6] | 378 | BarnOwl::error("usage: $cmd JID"); |
---|
[b405ff6] | 379 | return; |
---|
[38ffdf9] | 380 | } |
---|
[b6a253c] | 381 | |
---|
[f62550d] | 382 | if ( $conn->jidExists($jidStr) ) { |
---|
[d609dd6] | 383 | BarnOwl::error("Already logged in as $jidStr."); |
---|
[b405ff6] | 384 | return; |
---|
[6a6dd47] | 385 | } |
---|
| 386 | |
---|
[b405ff6] | 387 | my ( $server, $port ) = getServerFromJID($jid); |
---|
[6a6dd47] | 388 | |
---|
[84296f6] | 389 | $vars{jlogin_jid} = $jidStr; |
---|
| 390 | $vars{jlogin_havepass} = 0; |
---|
[b405ff6] | 391 | $vars{jlogin_connhash} = { |
---|
| 392 | hostname => $server, |
---|
| 393 | tls => 1, |
---|
| 394 | port => $port, |
---|
| 395 | componentname => $componentname |
---|
| 396 | }; |
---|
| 397 | $vars{jlogin_authhash} = |
---|
[84296f6] | 398 | { username => $uid, |
---|
| 399 | resource => $resource, |
---|
| 400 | }; |
---|
| 401 | |
---|
| 402 | return do_login(''); |
---|
[6a6dd47] | 403 | } |
---|
[38ffdf9] | 404 | |
---|
[84296f6] | 405 | sub do_login { |
---|
| 406 | $vars{jlogin_password} = shift; |
---|
| 407 | $vars{jlogin_authhash}->{password} = sub { return $vars{jlogin_password} || '' }; |
---|
| 408 | my $jidStr = $vars{jlogin_jid}; |
---|
| 409 | if ( !$jidStr && $vars{jlogin_havepass}) { |
---|
[d609dd6] | 410 | BarnOwl::error("Got password but have no jid!"); |
---|
[6a6dd47] | 411 | } |
---|
[84296f6] | 412 | else |
---|
| 413 | { |
---|
[f62550d] | 414 | my $client = $conn->addConnection($jidStr); |
---|
[84296f6] | 415 | |
---|
| 416 | #XXX Todo: Add more callbacks. |
---|
| 417 | # * MUC presence handlers |
---|
[60986b2] | 418 | # We use the anonymous subrefs in order to have the correct behavior |
---|
| 419 | # when we reload |
---|
[5c9c27d] | 420 | $client->SetMessageCallBacks( |
---|
[60986b2] | 421 | chat => sub { BarnOwl::Jabber::process_incoming_chat_message(@_) }, |
---|
| 422 | error => sub { BarnOwl::Jabber::process_incoming_error_message(@_) }, |
---|
| 423 | groupchat => sub { BarnOwl::Jabber::process_incoming_groupchat_message(@_) }, |
---|
| 424 | headline => sub { BarnOwl::Jabber::process_incoming_headline_message(@_) }, |
---|
| 425 | normal => sub { BarnOwl::Jabber::process_incoming_normal_message(@_) } |
---|
[84296f6] | 426 | ); |
---|
[bed4ff1] | 427 | $client->SetPresenceCallBacks( |
---|
[60986b2] | 428 | available => sub { BarnOwl::Jabber::process_presence_available(@_) }, |
---|
| 429 | # unavailable => sub { BarnOwl::Jabber::process_presence_available(@_) }, |
---|
| 430 | subscribe => sub { BarnOwl::Jabber::process_presence_subscribe(@_) }, |
---|
| 431 | subscribed => sub { BarnOwl::Jabber::process_presence_subscribed(@_) }, |
---|
| 432 | unsubscribe => sub { BarnOwl::Jabber::process_presence_unsubscribe(@_) }, |
---|
| 433 | unsubscribed => sub { BarnOwl::Jabber::process_presence_unsubscribed(@_) }, |
---|
| 434 | error => sub { BarnOwl::Jabber::process_presence_error(@_) }); |
---|
[84296f6] | 435 | |
---|
[5c9c27d] | 436 | my $status = $client->Connect( %{ $vars{jlogin_connhash} } ); |
---|
[84296f6] | 437 | if ( !$status ) { |
---|
[f62550d] | 438 | $conn->removeConnection($jidStr); |
---|
[d609dd6] | 439 | BarnOwl::error("We failed to connect"); |
---|
[46e8a1e] | 440 | } else { |
---|
[5c9c27d] | 441 | my @result = $client->AuthSend( %{ $vars{jlogin_authhash} } ); |
---|
[84296f6] | 442 | |
---|
[ffe70f9] | 443 | if ( !@result || $result[0] ne 'ok' ) { |
---|
[d609dd6] | 444 | if ( !$vars{jlogin_havepass} && ( !@result || $result[0] eq '401' ) ) { |
---|
[46e8a1e] | 445 | $vars{jlogin_havepass} = 1; |
---|
| 446 | $conn->removeConnection($jidStr); |
---|
[d609dd6] | 447 | BarnOwl::start_password( "Password for $jidStr: ", \&do_login ); |
---|
[46e8a1e] | 448 | return ""; |
---|
| 449 | } |
---|
[f62550d] | 450 | $conn->removeConnection($jidStr); |
---|
[d609dd6] | 451 | BarnOwl::error( "Error in connect: " . join( " ", @result ) ); |
---|
[46e8a1e] | 452 | } else { |
---|
[20eb22c] | 453 | $conn->getRosterFromJidStr($jidStr)->fetch(); |
---|
[bed4ff1] | 454 | $client->PresenceSend( priority => 1 ); |
---|
[84296f6] | 455 | queue_admin_msg("Connected to jabber as $jidStr"); |
---|
| 456 | } |
---|
| 457 | } |
---|
[46e8a1e] | 458 | |
---|
[6a6dd47] | 459 | } |
---|
[84296f6] | 460 | delete $vars{jlogin_jid}; |
---|
| 461 | $vars{jlogin_password} =~ tr/\0-\377/x/; |
---|
| 462 | delete $vars{jlogin_password}; |
---|
| 463 | delete $vars{jlogin_havepass}; |
---|
[6a6dd47] | 464 | delete $vars{jlogin_connhash}; |
---|
| 465 | delete $vars{jlogin_authhash}; |
---|
[38ffdf9] | 466 | return ""; |
---|
| 467 | } |
---|
| 468 | |
---|
[b405ff6] | 469 | sub do_logout { |
---|
[6a6dd47] | 470 | my $jid = shift; |
---|
[f62550d] | 471 | my $disconnected = $conn->removeConnection($jid); |
---|
| 472 | queue_admin_msg("Jabber disconnected ($jid).") if $disconnected; |
---|
[6a6dd47] | 473 | } |
---|
| 474 | |
---|
[b405ff6] | 475 | sub cmd_logout { |
---|
[6a6dd47] | 476 | # Logged into multiple accounts |
---|
[f62550d] | 477 | if ( $conn->connected() > 1 ) { |
---|
[b405ff6] | 478 | # Logged into multiple accounts, no accout specified. |
---|
| 479 | if ( !$_[1] ) { |
---|
| 480 | my $errStr = |
---|
[84296f6] | 481 | "You are logged into multiple accounts. Please specify an account to log out of.\n"; |
---|
[f62550d] | 482 | foreach my $jid ( $conn->getJids() ) { |
---|
[b405ff6] | 483 | $errStr .= "\t$jid\n"; |
---|
| 484 | } |
---|
| 485 | queue_admin_msg($errStr); |
---|
| 486 | } |
---|
| 487 | # Logged into multiple accounts, account specified. |
---|
| 488 | else { |
---|
| 489 | if ( $_[1] eq '-a' ) #All accounts. |
---|
| 490 | { |
---|
[f62550d] | 491 | foreach my $jid ( $conn->getJids() ) { |
---|
[b405ff6] | 492 | do_logout($jid); |
---|
| 493 | } |
---|
| 494 | } |
---|
| 495 | else #One account. |
---|
| 496 | { |
---|
| 497 | my $jid = resolveJID( $_[1] ); |
---|
| 498 | do_logout($jid) if ( $jid ne '' ); |
---|
| 499 | } |
---|
| 500 | } |
---|
| 501 | } |
---|
| 502 | else # Only one account logged in. |
---|
[6a6dd47] | 503 | { |
---|
[f62550d] | 504 | do_logout( ( $conn->getJids() )[0] ); |
---|
[38ffdf9] | 505 | } |
---|
| 506 | return ""; |
---|
| 507 | } |
---|
| 508 | |
---|
[b405ff6] | 509 | sub cmd_jlist { |
---|
[f62550d] | 510 | if ( !( scalar $conn->getJids() ) ) { |
---|
[d609dd6] | 511 | BarnOwl::error("You are not logged in to Jabber."); |
---|
[b405ff6] | 512 | return; |
---|
[b6a253c] | 513 | } |
---|
[d609dd6] | 514 | BarnOwl::popless_ztext( onGetBuddyList() ); |
---|
[b6a253c] | 515 | } |
---|
| 516 | |
---|
[b405ff6] | 517 | sub cmd_jwrite { |
---|
[f62550d] | 518 | if ( !$conn->connected() ) { |
---|
[d609dd6] | 519 | BarnOwl::error("You are not logged in to Jabber."); |
---|
[b405ff6] | 520 | return; |
---|
[38ffdf9] | 521 | } |
---|
| 522 | |
---|
[b405ff6] | 523 | my $jwrite_to = ""; |
---|
| 524 | my $jwrite_from = ""; |
---|
[f62550d] | 525 | my $jwrite_sid = ""; |
---|
[b405ff6] | 526 | my $jwrite_thread = ""; |
---|
[6a6dd47] | 527 | my $jwrite_subject = ""; |
---|
[b405ff6] | 528 | my $jwrite_type = "chat"; |
---|
[38ffdf9] | 529 | |
---|
[6a6dd47] | 530 | my @args = @_; |
---|
| 531 | shift; |
---|
[9f183ff] | 532 | local @ARGV = @_; |
---|
[6a6dd47] | 533 | my $gc; |
---|
[b405ff6] | 534 | GetOptions( |
---|
| 535 | 'thread=s' => \$jwrite_thread, |
---|
| 536 | 'subject=s' => \$jwrite_subject, |
---|
| 537 | 'account=s' => \$jwrite_from, |
---|
[f62550d] | 538 | 'id=s' => \$jwrite_sid, |
---|
[b405ff6] | 539 | 'groupchat' => \$gc |
---|
| 540 | ); |
---|
[6a6dd47] | 541 | $jwrite_type = 'groupchat' if $gc; |
---|
| 542 | |
---|
[b405ff6] | 543 | if ( scalar @ARGV != 1 ) { |
---|
[d609dd6] | 544 | BarnOwl::error( |
---|
[b405ff6] | 545 | "Usage: jwrite JID [-g] [-t thread] [-s 'subject'] [-a account]"); |
---|
| 546 | return; |
---|
[6a6dd47] | 547 | } |
---|
[b405ff6] | 548 | else { |
---|
| 549 | $jwrite_to = shift @ARGV; |
---|
[6a6dd47] | 550 | } |
---|
[b6a253c] | 551 | |
---|
[b405ff6] | 552 | if ( !$jwrite_from ) { |
---|
[f62550d] | 553 | if ( $conn->connected() == 1 ) { |
---|
| 554 | $jwrite_from = ( $conn->getJids() )[0]; |
---|
[b405ff6] | 555 | } |
---|
| 556 | else { |
---|
[d609dd6] | 557 | BarnOwl::error("Please specify an account with -a JID"); |
---|
[b405ff6] | 558 | return; |
---|
| 559 | } |
---|
| 560 | } |
---|
| 561 | else { |
---|
| 562 | $jwrite_from = resolveJID($jwrite_from); |
---|
| 563 | return unless $jwrite_from; |
---|
| 564 | } |
---|
| 565 | |
---|
| 566 | $vars{jwrite} = { |
---|
| 567 | to => $jwrite_to, |
---|
| 568 | from => $jwrite_from, |
---|
[f62550d] | 569 | sid => $jwrite_sid, |
---|
[b405ff6] | 570 | subject => $jwrite_subject, |
---|
| 571 | thread => $jwrite_thread, |
---|
| 572 | type => $jwrite_type |
---|
| 573 | }; |
---|
| 574 | |
---|
[d609dd6] | 575 | BarnOwl::message( |
---|
[f62550d] | 576 | "Type your message below. End with a dot on a line by itself. ^C will quit." |
---|
| 577 | ); |
---|
[d609dd6] | 578 | BarnOwl::start_edit_win( join( ' ', @args ), \&process_owl_jwrite ); |
---|
[38ffdf9] | 579 | } |
---|
| 580 | |
---|
[b405ff6] | 581 | sub cmd_jmuc { |
---|
[f62550d] | 582 | die "You are not logged in to Jabber" unless $conn->connected(); |
---|
[b405ff6] | 583 | my $ocmd = shift; |
---|
| 584 | my $cmd = shift; |
---|
| 585 | if ( !$cmd ) { |
---|
| 586 | |
---|
| 587 | #XXX TODO: Write general usage for jmuc command. |
---|
| 588 | return; |
---|
| 589 | } |
---|
| 590 | |
---|
| 591 | my %jmuc_commands = ( |
---|
| 592 | join => \&jmuc_join, |
---|
| 593 | part => \&jmuc_part, |
---|
| 594 | invite => \&jmuc_invite, |
---|
[1dfc7df] | 595 | configure => \&jmuc_configure, |
---|
| 596 | presence => \&jmuc_presence |
---|
[b405ff6] | 597 | ); |
---|
| 598 | my $func = $jmuc_commands{$cmd}; |
---|
| 599 | if ( !$func ) { |
---|
[d609dd6] | 600 | BarnOwl::error("jmuc: Unknown command: $cmd"); |
---|
[b405ff6] | 601 | return; |
---|
| 602 | } |
---|
| 603 | |
---|
| 604 | { |
---|
| 605 | local @ARGV = @_; |
---|
| 606 | my $jid; |
---|
| 607 | my $muc; |
---|
[d609dd6] | 608 | my $m = BarnOwl::getcurmsg(); |
---|
[b405ff6] | 609 | if ( $m->is_jabber && $m->{jtype} eq 'groupchat' ) { |
---|
| 610 | $muc = $m->{room}; |
---|
| 611 | $jid = $m->{to}; |
---|
| 612 | } |
---|
| 613 | |
---|
| 614 | my $getopt = Getopt::Long::Parser->new; |
---|
| 615 | $getopt->configure('pass_through'); |
---|
| 616 | $getopt->getoptions( 'account=s' => \$jid ); |
---|
| 617 | $jid ||= defaultJID(); |
---|
| 618 | if ($jid) { |
---|
| 619 | $jid = resolveJID($jid); |
---|
| 620 | return unless $jid; |
---|
| 621 | } |
---|
| 622 | else { |
---|
[d609dd6] | 623 | BarnOwl::error('You must specify an account with -a {jid}'); |
---|
[b405ff6] | 624 | } |
---|
| 625 | return $func->( $jid, $muc, @ARGV ); |
---|
| 626 | } |
---|
[6df381b] | 627 | } |
---|
| 628 | |
---|
| 629 | sub jmuc_join { |
---|
[b405ff6] | 630 | my ( $jid, $muc, @args ) = @_; |
---|
| 631 | local @ARGV = @args; |
---|
| 632 | my $password; |
---|
| 633 | GetOptions( 'password=s' => \$password ); |
---|
| 634 | |
---|
| 635 | $muc = shift @ARGV |
---|
[60986b2] | 636 | or die("Usage: jmuc join MUC [-p password] [-a account]"); |
---|
[b405ff6] | 637 | |
---|
[1dfc7df] | 638 | $conn->getConnectionFromJidStr($jid)->MUCJoin(Jid => $muc, |
---|
| 639 | Password => $password, |
---|
| 640 | History => { |
---|
| 641 | MaxChars => 0 |
---|
| 642 | }); |
---|
| 643 | return; |
---|
[6df381b] | 644 | } |
---|
| 645 | |
---|
| 646 | sub jmuc_part { |
---|
[b405ff6] | 647 | my ( $jid, $muc, @args ) = @_; |
---|
[9f183ff] | 648 | |
---|
[b405ff6] | 649 | $muc = shift @args if scalar @args; |
---|
[60986b2] | 650 | die("Usage: jmuc part MUC [-a account]") unless $muc; |
---|
[9f183ff] | 651 | |
---|
[1dfc7df] | 652 | $conn->getConnectionFromJidStr($jid)->MUCLeave(JID => $muc); |
---|
[b405ff6] | 653 | queue_admin_msg("$jid has left $muc."); |
---|
[6df381b] | 654 | } |
---|
| 655 | |
---|
[b405ff6] | 656 | sub jmuc_invite { |
---|
| 657 | my ( $jid, $muc, @args ) = @_; |
---|
| 658 | |
---|
| 659 | my $invite_jid = shift @args; |
---|
| 660 | $muc = shift @args if scalar @args; |
---|
| 661 | |
---|
[60986b2] | 662 | die('Usage: jmuc invite JID [muc] [-a account]') |
---|
[b405ff6] | 663 | unless $muc && $invite_jid; |
---|
| 664 | |
---|
[d9f4a5c] | 665 | my $message = Net::Jabber::Message->new(); |
---|
[b405ff6] | 666 | $message->SetTo($muc); |
---|
[d9f4a5c] | 667 | my $x = $message->NewChild('http://jabber.org/protocol/muc#user'); |
---|
| 668 | $x->AddInvite(); |
---|
| 669 | $x->GetInvite()->SetTo($invite_jid); |
---|
[bed4ff1] | 670 | $conn->getConnectionFromJidStr($jid)->Send($message); |
---|
[b405ff6] | 671 | queue_admin_msg("$jid has invited $invite_jid to $muc."); |
---|
[38ffdf9] | 672 | } |
---|
| 673 | |
---|
[9f183ff] | 674 | sub jmuc_configure { |
---|
[b405ff6] | 675 | my ( $jid, $muc, @args ) = @_; |
---|
| 676 | $muc = shift @args if scalar @args; |
---|
| 677 | die("Usage: jmuc configure [muc]") unless $muc; |
---|
| 678 | my $iq = Net::Jabber::IQ->new(); |
---|
| 679 | $iq->SetTo($muc); |
---|
| 680 | $iq->SetType('set'); |
---|
| 681 | my $query = $iq->NewQuery("http://jabber.org/protocol/muc#owner"); |
---|
| 682 | my $x = $query->NewChild("jabber:x:data"); |
---|
| 683 | $x->SetType('submit'); |
---|
| 684 | |
---|
[bed4ff1] | 685 | $conn->getConnectionFromJidStr($jid)->Send($iq); |
---|
[b405ff6] | 686 | queue_admin_msg("Accepted default instant configuration for $muc"); |
---|
[9f183ff] | 687 | } |
---|
| 688 | |
---|
[1dfc7df] | 689 | sub jmuc_presence { |
---|
| 690 | my ( $jid, $muc, @args ) = @_; |
---|
| 691 | |
---|
| 692 | my $m = $conn->getConnectionFromJidStr($jid)->FindMUC(jid => $muc); |
---|
| 693 | die("No such muc: $muc") unless $m; |
---|
| 694 | |
---|
| 695 | my @jids = $m->Presence(); |
---|
| 696 | BarnOwl::popless_ztext("JIDs present in " . $m->BaseJID . "\n\t" . |
---|
| 697 | join("\n\t", map {$_->GetResource}@jids)); |
---|
| 698 | } |
---|
| 699 | |
---|
[f62550d] | 700 | |
---|
| 701 | #XXX TODO: Consider merging this with jmuc and selecting off the first two args. |
---|
| 702 | sub cmd_jroster { |
---|
| 703 | die "You are not logged in to Jabber" unless $conn->connected(); |
---|
| 704 | my $ocmd = shift; |
---|
| 705 | my $cmd = shift; |
---|
| 706 | if ( !$cmd ) { |
---|
| 707 | |
---|
| 708 | #XXX TODO: Write general usage for jroster command. |
---|
| 709 | return; |
---|
| 710 | } |
---|
| 711 | |
---|
| 712 | my %jroster_commands = ( |
---|
| 713 | sub => \&jroster_sub, |
---|
| 714 | unsub => \&jroster_unsub, |
---|
| 715 | add => \&jroster_add, |
---|
| 716 | remove => \&jroster_remove, |
---|
| 717 | auth => \&jroster_auth, |
---|
| 718 | deauth => \&jroster_deauth |
---|
| 719 | ); |
---|
| 720 | |
---|
| 721 | my $func = $jroster_commands{$cmd}; |
---|
| 722 | if ( !$func ) { |
---|
[d609dd6] | 723 | BarnOwl::error("jroster: Unknown command: $cmd"); |
---|
[f62550d] | 724 | return; |
---|
| 725 | } |
---|
| 726 | |
---|
| 727 | { |
---|
| 728 | local @ARGV = @_; |
---|
| 729 | my $jid; |
---|
| 730 | my $name; |
---|
| 731 | my @groups; |
---|
| 732 | my $purgeGroups; |
---|
| 733 | my $getopt = Getopt::Long::Parser->new; |
---|
| 734 | $getopt->configure('pass_through'); |
---|
| 735 | $getopt->getoptions( |
---|
| 736 | 'account=s' => \$jid, |
---|
| 737 | 'group=s' => \@groups, |
---|
| 738 | 'purgegroups' => \$purgeGroups, |
---|
| 739 | 'name=s' => \$name |
---|
| 740 | ); |
---|
| 741 | $jid ||= defaultJID(); |
---|
| 742 | if ($jid) { |
---|
| 743 | $jid = resolveJID($jid); |
---|
| 744 | return unless $jid; |
---|
| 745 | } |
---|
| 746 | else { |
---|
[d609dd6] | 747 | BarnOwl::error('You must specify an account with -a {jid}'); |
---|
[f62550d] | 748 | } |
---|
| 749 | return $func->( $jid, $name, \@groups, $purgeGroups, @ARGV ); |
---|
| 750 | } |
---|
| 751 | } |
---|
| 752 | |
---|
| 753 | sub jroster_sub { |
---|
| 754 | my $jid = shift; |
---|
| 755 | my $name = shift; |
---|
| 756 | my @groups = @{ shift() }; |
---|
| 757 | my $purgeGroups = shift; |
---|
| 758 | my $baseJid = baseJID($jid); |
---|
| 759 | |
---|
[bed4ff1] | 760 | my $roster = $conn->getRosterFromJidStr($jid); |
---|
[f62550d] | 761 | |
---|
| 762 | # Adding lots of users with the same name is a bad idea. |
---|
| 763 | $name = "" unless (1 == scalar(@ARGV)); |
---|
| 764 | |
---|
| 765 | my $p = new Net::XMPP::Presence; |
---|
| 766 | $p->SetType('subscribe'); |
---|
| 767 | |
---|
| 768 | foreach my $to (@ARGV) { |
---|
[bed4ff1] | 769 | jroster_add($jid, $name, \@groups, $purgeGroups, ($to)) unless ($roster->exists($to)); |
---|
[f62550d] | 770 | |
---|
| 771 | $p->SetTo($to); |
---|
[bed4ff1] | 772 | $conn->getConnectionFromJidStr($jid)->Send($p); |
---|
[f62550d] | 773 | queue_admin_msg("You ($baseJid) have requested a subscription to ($to)'s presence."); |
---|
| 774 | } |
---|
| 775 | } |
---|
| 776 | |
---|
| 777 | sub jroster_unsub { |
---|
| 778 | my $jid = shift; |
---|
| 779 | my $name = shift; |
---|
| 780 | my @groups = @{ shift() }; |
---|
| 781 | my $purgeGroups = shift; |
---|
| 782 | my $baseJid = baseJID($jid); |
---|
| 783 | |
---|
| 784 | my $p = new Net::XMPP::Presence; |
---|
| 785 | $p->SetType('unsubscribe'); |
---|
| 786 | foreach my $to (@ARGV) { |
---|
| 787 | $p->SetTo($to); |
---|
[bed4ff1] | 788 | $conn->getConnectionFromJidStr($jid)->Send($p); |
---|
[f62550d] | 789 | queue_admin_msg("You ($baseJid) have unsubscribed from ($to)'s presence."); |
---|
| 790 | } |
---|
| 791 | } |
---|
| 792 | |
---|
| 793 | sub jroster_add { |
---|
| 794 | my $jid = shift; |
---|
| 795 | my $name = shift; |
---|
| 796 | my @groups = @{ shift() }; |
---|
| 797 | my $purgeGroups = shift; |
---|
| 798 | my $baseJid = baseJID($jid); |
---|
| 799 | |
---|
[bed4ff1] | 800 | my $roster = $conn->getRosterFromJidStr($jid); |
---|
[f62550d] | 801 | |
---|
| 802 | # Adding lots of users with the same name is a bad idea. |
---|
| 803 | $name = "" unless (1 == scalar(@ARGV)); |
---|
| 804 | |
---|
| 805 | foreach my $to (@ARGV) { |
---|
[bed4ff1] | 806 | my %jq = $roster->query($to); |
---|
[f62550d] | 807 | my $iq = new Net::XMPP::IQ; |
---|
| 808 | $iq->SetType('set'); |
---|
| 809 | my $item = new XML::Stream::Node('item'); |
---|
| 810 | $iq->NewChild('jabber:iq:roster')->AddChild($item); |
---|
| 811 | |
---|
| 812 | my %allGroups = (); |
---|
| 813 | |
---|
| 814 | foreach my $g (@groups) { |
---|
| 815 | $allGroups{$g} = $g; |
---|
| 816 | } |
---|
| 817 | |
---|
| 818 | unless ($purgeGroups) { |
---|
| 819 | foreach my $g (@{$jq{groups}}) { |
---|
| 820 | $allGroups{$g} = $g; |
---|
| 821 | } |
---|
| 822 | } |
---|
| 823 | |
---|
| 824 | foreach my $g (keys %allGroups) { |
---|
| 825 | $item->add_child('group')->add_cdata($g); |
---|
| 826 | } |
---|
| 827 | |
---|
| 828 | $item->put_attrib(jid => $to); |
---|
| 829 | $item->put_attrib(name => $name) if $name; |
---|
[bed4ff1] | 830 | $conn->getConnectionFromJidStr($jid)->Send($iq); |
---|
[f62550d] | 831 | my $msg = "$baseJid: " |
---|
| 832 | . ($name ? "$name ($to)" : "($to)") |
---|
| 833 | . " is on your roster in the following groups: { " |
---|
| 834 | . join(" , ", keys %allGroups) |
---|
| 835 | . " }"; |
---|
| 836 | queue_admin_msg($msg); |
---|
| 837 | } |
---|
| 838 | } |
---|
| 839 | |
---|
| 840 | sub jroster_remove { |
---|
| 841 | my $jid = shift; |
---|
| 842 | my $name = shift; |
---|
| 843 | my @groups = @{ shift() }; |
---|
| 844 | my $purgeGroups = shift; |
---|
| 845 | my $baseJid = baseJID($jid); |
---|
| 846 | |
---|
| 847 | my $iq = new Net::XMPP::IQ; |
---|
| 848 | $iq->SetType('set'); |
---|
| 849 | my $item = new XML::Stream::Node('item'); |
---|
| 850 | $iq->NewChild('jabber:iq:roster')->AddChild($item); |
---|
| 851 | $item->put_attrib(subscription=> 'remove'); |
---|
| 852 | foreach my $to (@ARGV) { |
---|
| 853 | $item->put_attrib(jid => $to); |
---|
[bed4ff1] | 854 | $conn->getConnectionFromJidStr($jid)->Send($iq); |
---|
[f62550d] | 855 | queue_admin_msg("You ($baseJid) have removed ($to) from your roster."); |
---|
| 856 | } |
---|
| 857 | } |
---|
| 858 | |
---|
| 859 | sub jroster_auth { |
---|
| 860 | my $jid = shift; |
---|
| 861 | my $name = shift; |
---|
| 862 | my @groups = @{ shift() }; |
---|
| 863 | my $purgeGroups = shift; |
---|
| 864 | my $baseJid = baseJID($jid); |
---|
| 865 | |
---|
| 866 | my $p = new Net::XMPP::Presence; |
---|
| 867 | $p->SetType('subscribed'); |
---|
| 868 | foreach my $to (@ARGV) { |
---|
| 869 | $p->SetTo($to); |
---|
[bed4ff1] | 870 | $conn->getConnectionFromJidStr($jid)->Send($p); |
---|
[f62550d] | 871 | queue_admin_msg("($to) has been subscribed to your ($baseJid) presence."); |
---|
| 872 | } |
---|
| 873 | } |
---|
| 874 | |
---|
| 875 | sub jroster_deauth { |
---|
| 876 | my $jid = shift; |
---|
| 877 | my $name = shift; |
---|
| 878 | my @groups = @{ shift() }; |
---|
| 879 | my $purgeGroups = shift; |
---|
| 880 | my $baseJid = baseJID($jid); |
---|
| 881 | |
---|
| 882 | my $p = new Net::XMPP::Presence; |
---|
| 883 | $p->SetType('unsubscribed'); |
---|
| 884 | foreach my $to (@ARGV) { |
---|
| 885 | $p->SetTo($to); |
---|
[bed4ff1] | 886 | $conn->getConnectionFromJidStr($jid)->Send($p); |
---|
[f62550d] | 887 | queue_admin_msg("($to) has been unsubscribed from your ($baseJid) presence."); |
---|
| 888 | } |
---|
| 889 | } |
---|
| 890 | |
---|
[38ffdf9] | 891 | ################################################################################ |
---|
| 892 | ### Owl Callbacks |
---|
[b405ff6] | 893 | sub process_owl_jwrite { |
---|
[38ffdf9] | 894 | my $body = shift; |
---|
| 895 | |
---|
| 896 | my $j = new Net::XMPP::Message; |
---|
| 897 | $body =~ s/\n\z//; |
---|
[b405ff6] | 898 | $j->SetMessage( |
---|
| 899 | to => $vars{jwrite}{to}, |
---|
| 900 | from => $vars{jwrite}{from}, |
---|
| 901 | type => $vars{jwrite}{type}, |
---|
| 902 | body => $body |
---|
| 903 | ); |
---|
[f62550d] | 904 | |
---|
[b405ff6] | 905 | $j->SetThread( $vars{jwrite}{thread} ) if ( $vars{jwrite}{thread} ); |
---|
| 906 | $j->SetSubject( $vars{jwrite}{subject} ) if ( $vars{jwrite}{subject} ); |
---|
| 907 | |
---|
[f62550d] | 908 | my $m = j2o( $j, { direction => 'out' } ); |
---|
[d609dd6] | 909 | if ( $vars{jwrite}{type} ne 'groupchat' && BarnOwl::getvar('displayoutgoing') eq 'on') { |
---|
| 910 | BarnOwl::queue_message($m); |
---|
[38ffdf9] | 911 | } |
---|
[f62550d] | 912 | |
---|
| 913 | if ($vars{jwrite}{sid} && $conn->sidExists( $vars{jwrite}{sid} )) { |
---|
[bed4ff1] | 914 | $conn->getConnectionFromSid($vars{jwrite}{sid})->Send($j); |
---|
[f62550d] | 915 | } |
---|
| 916 | else { |
---|
[bed4ff1] | 917 | $conn->getConnectionFromJidStr($vars{jwrite}{from})->Send($j); |
---|
[f62550d] | 918 | } |
---|
| 919 | |
---|
[6a6dd47] | 920 | delete $vars{jwrite}; |
---|
[d609dd6] | 921 | BarnOwl::message(""); # Kludge to make the ``type your message...'' message go away |
---|
[38ffdf9] | 922 | } |
---|
| 923 | |
---|
| 924 | ### XMPP Callbacks |
---|
| 925 | |
---|
[b405ff6] | 926 | sub process_incoming_chat_message { |
---|
[f62550d] | 927 | my ( $sid, $j ) = @_; |
---|
[d609dd6] | 928 | BarnOwl::queue_message( j2o( $j, { direction => 'in', |
---|
[f62550d] | 929 | sid => $sid } ) ); |
---|
[38ffdf9] | 930 | } |
---|
| 931 | |
---|
[b405ff6] | 932 | sub process_incoming_error_message { |
---|
[f62550d] | 933 | my ( $sid, $j ) = @_; |
---|
| 934 | my %jhash = j2hash( $j, { direction => 'in', |
---|
| 935 | sid => $sid } ); |
---|
[b6a253c] | 936 | $jhash{type} = 'admin'; |
---|
[d609dd6] | 937 | BarnOwl::queue_message( BarnOwl::Message->new(%jhash) ); |
---|
[38ffdf9] | 938 | } |
---|
| 939 | |
---|
[b405ff6] | 940 | sub process_incoming_groupchat_message { |
---|
[f62550d] | 941 | my ( $sid, $j ) = @_; |
---|
[b405ff6] | 942 | |
---|
[38ffdf9] | 943 | # HACK IN PROGRESS (ignoring delayed messages) |
---|
[b405ff6] | 944 | return if ( $j->DefinedX('jabber:x:delay') && $j->GetX('jabber:x:delay') ); |
---|
[d609dd6] | 945 | BarnOwl::queue_message( j2o( $j, { direction => 'in', |
---|
[f62550d] | 946 | sid => $sid } ) ); |
---|
[38ffdf9] | 947 | } |
---|
| 948 | |
---|
[b405ff6] | 949 | sub process_incoming_headline_message { |
---|
[f62550d] | 950 | my ( $sid, $j ) = @_; |
---|
[d609dd6] | 951 | BarnOwl::queue_message( j2o( $j, { direction => 'in', |
---|
[f62550d] | 952 | sid => $sid } ) ); |
---|
[38ffdf9] | 953 | } |
---|
| 954 | |
---|
[b405ff6] | 955 | sub process_incoming_normal_message { |
---|
[f62550d] | 956 | my ( $sid, $j ) = @_; |
---|
| 957 | my %jhash = j2hash( $j, { direction => 'in', |
---|
| 958 | sid => $sid } ); |
---|
[b6a253c] | 959 | |
---|
| 960 | # XXX TODO: handle things such as MUC invites here. |
---|
| 961 | |
---|
[b405ff6] | 962 | # if ($j->HasX('http://jabber.org/protocol/muc#user')) |
---|
| 963 | # { |
---|
| 964 | # my $x = $j->GetX('http://jabber.org/protocol/muc#user'); |
---|
| 965 | # if ($x->HasChild('invite')) |
---|
| 966 | # { |
---|
| 967 | # $props |
---|
| 968 | # } |
---|
| 969 | # } |
---|
| 970 | # |
---|
[d609dd6] | 971 | BarnOwl::queue_message( BarnOwl::Message->new(%jhash) ); |
---|
[b6a253c] | 972 | } |
---|
| 973 | |
---|
[b405ff6] | 974 | sub process_muc_presence { |
---|
[f62550d] | 975 | my ( $sid, $p ) = @_; |
---|
[b405ff6] | 976 | return unless ( $p->HasX('http://jabber.org/protocol/muc#user') ); |
---|
[f62550d] | 977 | } |
---|
| 978 | |
---|
| 979 | |
---|
| 980 | sub process_presence_available { |
---|
| 981 | my ( $sid, $p ) = @_; |
---|
| 982 | my $from = $p->GetFrom(); |
---|
| 983 | my $to = $p->GetTo(); |
---|
| 984 | my $type = $p->GetType(); |
---|
| 985 | my %props = ( |
---|
| 986 | to => $to, |
---|
| 987 | from => $from, |
---|
| 988 | recipient => $to, |
---|
| 989 | sender => $from, |
---|
| 990 | type => 'jabber', |
---|
| 991 | jtype => $p->GetType(), |
---|
| 992 | status => $p->GetStatus(), |
---|
| 993 | show => $p->GetShow(), |
---|
| 994 | xml => $p->GetXML(), |
---|
| 995 | direction => 'in'); |
---|
| 996 | |
---|
| 997 | if ($type eq '' || $type eq 'available') { |
---|
| 998 | $props{body} = "$from is now online. "; |
---|
| 999 | $props{loginout} = 'login'; |
---|
| 1000 | } |
---|
| 1001 | else { |
---|
| 1002 | $props{body} = "$from is now offline. "; |
---|
| 1003 | $props{loginout} = 'logout'; |
---|
| 1004 | } |
---|
| 1005 | $props{replysendercmd} = $props{replycmd} = "jwrite $from -i $sid"; |
---|
[f3c1aba] | 1006 | if(BarnOwl::getvar('debug') eq 'on') { |
---|
| 1007 | BarnOwl::queue_message(BarnOwl::Message->new(%props)); |
---|
| 1008 | } |
---|
[f62550d] | 1009 | } |
---|
| 1010 | |
---|
| 1011 | sub process_presence_subscribe { |
---|
| 1012 | my ( $sid, $p ) = @_; |
---|
| 1013 | my $from = $p->GetFrom(); |
---|
| 1014 | my $to = $p->GetTo(); |
---|
| 1015 | my %props = ( |
---|
| 1016 | to => $to, |
---|
| 1017 | from => $from, |
---|
| 1018 | xml => $p->GetXML(), |
---|
| 1019 | type => 'admin', |
---|
| 1020 | adminheader => 'Jabber presence: subscribe', |
---|
| 1021 | direction => 'in'); |
---|
| 1022 | |
---|
[5551208] | 1023 | $props{body} = "Allow user ($from) to subscribe to your ($to) presence?\n" . |
---|
| 1024 | "(Answer with the `yes' or `no' commands)"; |
---|
| 1025 | $props{yescommand} = "jroster auth $from -a $to"; |
---|
| 1026 | $props{nocommand} = "jroster deauth $from -a $to"; |
---|
| 1027 | $props{question} = "true"; |
---|
[d609dd6] | 1028 | BarnOwl::queue_message(BarnOwl::Message->new(%props)); |
---|
[f62550d] | 1029 | } |
---|
| 1030 | |
---|
| 1031 | sub process_presence_unsubscribe { |
---|
| 1032 | my ( $sid, $p ) = @_; |
---|
| 1033 | my $from = $p->GetFrom(); |
---|
| 1034 | my $to = $p->GetTo(); |
---|
| 1035 | my %props = ( |
---|
| 1036 | to => $to, |
---|
| 1037 | from => $from, |
---|
| 1038 | xml => $p->GetXML(), |
---|
| 1039 | type => 'admin', |
---|
| 1040 | adminheader => 'Jabber presence: unsubscribe', |
---|
| 1041 | direction => 'in'); |
---|
| 1042 | |
---|
| 1043 | $props{body} = "The user ($from) has been unsubscribed from your ($to) presence.\n"; |
---|
[d609dd6] | 1044 | BarnOwl::queue_message(BarnOwl::Message->new(%props)); |
---|
[f62550d] | 1045 | |
---|
| 1046 | # Find a connection to reply with. |
---|
| 1047 | foreach my $jid ($conn->getJids()) { |
---|
| 1048 | my $cJid = new Net::XMPP::JID; |
---|
| 1049 | $cJid->SetJID($jid); |
---|
| 1050 | if ($to eq $cJid->GetJID('base') || |
---|
| 1051 | $to eq $cJid->GetJID('full')) { |
---|
| 1052 | my $reply = $p->Reply(type=>"unsubscribed"); |
---|
[bed4ff1] | 1053 | $conn->getConnectionFromJidStr($jid)->Send($reply); |
---|
[f62550d] | 1054 | return; |
---|
| 1055 | } |
---|
| 1056 | } |
---|
| 1057 | } |
---|
[38ffdf9] | 1058 | |
---|
[f62550d] | 1059 | sub process_presence_subscribed { |
---|
| 1060 | my ( $sid, $p ) = @_; |
---|
| 1061 | queue_admin_msg("ignoring:".$p->GetXML()); |
---|
| 1062 | # RFC 3921 says we should respond to this with a "subscribe" |
---|
| 1063 | # but this causes a flood of sub/sub'd presence packets with |
---|
| 1064 | # some servers, so we won't. We may want to detect this condition |
---|
| 1065 | # later, and have per-server settings. |
---|
| 1066 | return; |
---|
| 1067 | } |
---|
| 1068 | |
---|
| 1069 | sub process_presence_unsubscribed { |
---|
| 1070 | my ( $sid, $p ) = @_; |
---|
| 1071 | queue_admin_msg("ignoring:".$p->GetXML()); |
---|
| 1072 | # RFC 3921 says we should respond to this with a "subscribe" |
---|
| 1073 | # but this causes a flood of unsub/unsub'd presence packets with |
---|
| 1074 | # some servers, so we won't. We may want to detect this condition |
---|
| 1075 | # later, and have per-server settings. |
---|
| 1076 | return; |
---|
[b405ff6] | 1077 | } |
---|
[38ffdf9] | 1078 | |
---|
[9667006] | 1079 | sub process_presence_error { |
---|
| 1080 | my ( $sid, $p ) = @_; |
---|
| 1081 | my $code = $p->GetErrorCode(); |
---|
| 1082 | my $error = $p->GetError(); |
---|
[d609dd6] | 1083 | BarnOwl::error("Jabber: $code $error"); |
---|
[9667006] | 1084 | } |
---|
| 1085 | |
---|
[f62550d] | 1086 | |
---|
[38ffdf9] | 1087 | ### Helper functions |
---|
| 1088 | |
---|
[b405ff6] | 1089 | sub j2hash { |
---|
| 1090 | my $j = shift; |
---|
[f62550d] | 1091 | my %initProps = %{ shift() }; |
---|
[38ffdf9] | 1092 | |
---|
[f62550d] | 1093 | my $dir = 'none'; |
---|
| 1094 | my %props = ( type => 'jabber' ); |
---|
| 1095 | |
---|
| 1096 | foreach my $k (keys %initProps) { |
---|
| 1097 | $dir = $initProps{$k} if ($k eq 'direction'); |
---|
| 1098 | $props{$k} = $initProps{$k}; |
---|
| 1099 | } |
---|
[38ffdf9] | 1100 | |
---|
[b6a253c] | 1101 | my $jtype = $props{jtype} = $j->GetType(); |
---|
[b405ff6] | 1102 | my $from = $j->GetFrom('jid'); |
---|
| 1103 | my $to = $j->GetTo('jid'); |
---|
[38ffdf9] | 1104 | |
---|
[b6a253c] | 1105 | $props{from} = $from->GetJID('full'); |
---|
| 1106 | $props{to} = $to->GetJID('full'); |
---|
[38ffdf9] | 1107 | |
---|
[b6a253c] | 1108 | $props{recipient} = $to->GetJID('base'); |
---|
| 1109 | $props{sender} = $from->GetJID('base'); |
---|
[b405ff6] | 1110 | $props{subject} = $j->GetSubject() if ( $j->DefinedSubject() ); |
---|
| 1111 | $props{thread} = $j->GetThread() if ( $j->DefinedThread() ); |
---|
| 1112 | $props{body} = $j->GetBody() if ( $j->DefinedBody() ); |
---|
| 1113 | $props{error} = $j->GetError() if ( $j->DefinedError() ); |
---|
| 1114 | $props{error_code} = $j->GetErrorCode() if ( $j->DefinedErrorCode() ); |
---|
[b6a253c] | 1115 | $props{xml} = $j->GetXML(); |
---|
[38ffdf9] | 1116 | |
---|
[b405ff6] | 1117 | if ( $jtype eq 'chat' ) { |
---|
| 1118 | $props{replycmd} = |
---|
[f62550d] | 1119 | "jwrite " . ( ( $dir eq 'in' ) ? $props{from} : $props{to} ); |
---|
| 1120 | $props{replycmd} .= |
---|
| 1121 | " -a " . ( ( $dir eq 'out' ) ? $props{from} : $props{to} ); |
---|
[cb769bb] | 1122 | $props{private} = 1; |
---|
[38ffdf9] | 1123 | } |
---|
[b405ff6] | 1124 | elsif ( $jtype eq 'groupchat' ) { |
---|
| 1125 | my $nick = $props{nick} = $from->GetResource(); |
---|
| 1126 | my $room = $props{room} = $from->GetJID('base'); |
---|
[f62550d] | 1127 | $props{replycmd} = "jwrite -g $room"; |
---|
| 1128 | $props{replycmd} .= |
---|
| 1129 | " -a " . ( ( $dir eq 'out' ) ? $props{from} : $props{to} ); |
---|
[b405ff6] | 1130 | |
---|
| 1131 | $props{sender} = $nick || $room; |
---|
| 1132 | $props{recipient} = $room; |
---|
| 1133 | |
---|
| 1134 | if ( $props{subject} && !$props{body} ) { |
---|
| 1135 | $props{body} = |
---|
| 1136 | '[' . $nick . " has set the topic to: " . $props{subject} . "]"; |
---|
| 1137 | } |
---|
[b6a253c] | 1138 | } |
---|
[b405ff6] | 1139 | elsif ( $jtype eq 'normal' ) { |
---|
| 1140 | $props{replycmd} = undef; |
---|
[cb769bb] | 1141 | $props{private} = 1; |
---|
[b6a253c] | 1142 | } |
---|
[b405ff6] | 1143 | elsif ( $jtype eq 'headline' ) { |
---|
| 1144 | $props{replycmd} = undef; |
---|
[b6a253c] | 1145 | } |
---|
[b405ff6] | 1146 | elsif ( $jtype eq 'error' ) { |
---|
| 1147 | $props{replycmd} = undef; |
---|
| 1148 | $props{body} = "Error " |
---|
| 1149 | . $props{error_code} |
---|
| 1150 | . " sending to " |
---|
| 1151 | . $props{from} . "\n" |
---|
| 1152 | . $props{error}; |
---|
| 1153 | } |
---|
| 1154 | |
---|
[f62550d] | 1155 | $props{replysendercmd} = $props{replycmd}; |
---|
[b6a253c] | 1156 | return %props; |
---|
| 1157 | } |
---|
[38ffdf9] | 1158 | |
---|
[b405ff6] | 1159 | sub j2o { |
---|
[d609dd6] | 1160 | return BarnOwl::Message->new( j2hash(@_) ); |
---|
[38ffdf9] | 1161 | } |
---|
| 1162 | |
---|
[b405ff6] | 1163 | sub queue_admin_msg { |
---|
[38ffdf9] | 1164 | my $err = shift; |
---|
[d609dd6] | 1165 | my $m = BarnOwl::Message->new( |
---|
[b405ff6] | 1166 | type => 'admin', |
---|
| 1167 | direction => 'none', |
---|
| 1168 | body => $err |
---|
| 1169 | ); |
---|
[d609dd6] | 1170 | BarnOwl::queue_message($m); |
---|
[38ffdf9] | 1171 | } |
---|
[b6a253c] | 1172 | |
---|
[b405ff6] | 1173 | sub boldify($) { |
---|
[9f183ff] | 1174 | my $str = shift; |
---|
[b6a253c] | 1175 | |
---|
[b405ff6] | 1176 | return '@b(' . $str . ')' if ( $str !~ /\)/ ); |
---|
| 1177 | return '@b<' . $str . '>' if ( $str !~ /\>/ ); |
---|
| 1178 | return '@b{' . $str . '}' if ( $str !~ /\}/ ); |
---|
| 1179 | return '@b[' . $str . ']' if ( $str !~ /\]/ ); |
---|
[b6a253c] | 1180 | |
---|
[9667006] | 1181 | my $txt = "$str"; |
---|
| 1182 | $txt =~ s{[)]}{)\@b[)]\@b(}g; |
---|
| 1183 | return '@b(' . $txt . ')'; |
---|
[b6a253c] | 1184 | } |
---|
| 1185 | |
---|
[b405ff6] | 1186 | sub getServerFromJID { |
---|
[6a6dd47] | 1187 | my $jid = shift; |
---|
| 1188 | my $res = new Net::DNS::Resolver; |
---|
[b405ff6] | 1189 | my $packet = |
---|
| 1190 | $res->search( '_xmpp-client._tcp.' . $jid->GetServer(), 'srv' ); |
---|
[6a6dd47] | 1191 | |
---|
[b405ff6] | 1192 | if ($packet) # Got srv record. |
---|
[6a6dd47] | 1193 | { |
---|
[b405ff6] | 1194 | my @answer = $packet->answer; |
---|
| 1195 | return $answer[0]{target}, $answer[0]{port}; |
---|
[6a6dd47] | 1196 | } |
---|
| 1197 | |
---|
| 1198 | return $jid->GetServer(), 5222; |
---|
| 1199 | } |
---|
| 1200 | |
---|
[9f183ff] | 1201 | sub defaultJID { |
---|
[f62550d] | 1202 | return ( $conn->getJids() )[0] if ( $conn->connected() == 1 ); |
---|
[b405ff6] | 1203 | return; |
---|
[9f183ff] | 1204 | } |
---|
| 1205 | |
---|
[84296f6] | 1206 | sub baseJID { |
---|
| 1207 | my $givenJidStr = shift; |
---|
| 1208 | my $givenJid = new Net::XMPP::JID; |
---|
| 1209 | $givenJid->SetJID($givenJidStr); |
---|
| 1210 | return $givenJid->GetJID('base'); |
---|
| 1211 | } |
---|
| 1212 | |
---|
[b405ff6] | 1213 | sub resolveJID { |
---|
[6a6dd47] | 1214 | my $givenJidStr = shift; |
---|
[b405ff6] | 1215 | my $givenJid = new Net::XMPP::JID; |
---|
[6a6dd47] | 1216 | $givenJid->SetJID($givenJidStr); |
---|
[b405ff6] | 1217 | |
---|
[6a6dd47] | 1218 | # Account fully specified. |
---|
[b405ff6] | 1219 | if ( $givenJid->GetResource() ) { |
---|
| 1220 | # Specified account exists |
---|
[f62550d] | 1221 | return $givenJidStr if ($conn->jidExists($givenJidStr) ); |
---|
[d609dd6] | 1222 | BarnOwl::error("Invalid account: $givenJidStr"); |
---|
[6a6dd47] | 1223 | } |
---|
[b405ff6] | 1224 | |
---|
[6a6dd47] | 1225 | # Disambiguate. |
---|
[b405ff6] | 1226 | else { |
---|
| 1227 | my $matchingJid = ""; |
---|
| 1228 | my $errStr = |
---|
| 1229 | "Ambiguous account reference. Please specify a resource.\n"; |
---|
| 1230 | my $ambiguous = 0; |
---|
| 1231 | |
---|
[f62550d] | 1232 | foreach my $jid ( $conn->getJids() ) { |
---|
[b405ff6] | 1233 | my $cJid = new Net::XMPP::JID; |
---|
| 1234 | $cJid->SetJID($jid); |
---|
| 1235 | if ( $givenJidStr eq $cJid->GetJID('base') ) { |
---|
| 1236 | $ambiguous = 1 if ( $matchingJid ne "" ); |
---|
| 1237 | $matchingJid = $jid; |
---|
| 1238 | $errStr .= "\t$jid\n"; |
---|
| 1239 | } |
---|
| 1240 | } |
---|
| 1241 | |
---|
| 1242 | # Need further disambiguation. |
---|
| 1243 | if ($ambiguous) { |
---|
| 1244 | queue_admin_msg($errStr); |
---|
| 1245 | } |
---|
| 1246 | |
---|
| 1247 | # Not one of ours. |
---|
| 1248 | elsif ( $matchingJid eq "" ) { |
---|
[d609dd6] | 1249 | BarnOwl::error("Invalid account: $givenJidStr"); |
---|
[b405ff6] | 1250 | } |
---|
| 1251 | |
---|
[84296f6] | 1252 | # It's this one. |
---|
[b405ff6] | 1253 | else { |
---|
| 1254 | return $matchingJid; |
---|
| 1255 | } |
---|
[6a6dd47] | 1256 | } |
---|
| 1257 | return ""; |
---|
| 1258 | } |
---|
[84296f6] | 1259 | |
---|
[25729b2] | 1260 | ##################################################################### |
---|
| 1261 | ##################################################################### |
---|
| 1262 | |
---|
[d609dd6] | 1263 | package BarnOwl::Message::Jabber; |
---|
[25729b2] | 1264 | |
---|
[d609dd6] | 1265 | our @ISA = qw( BarnOwl::Message ); |
---|
[25729b2] | 1266 | |
---|
| 1267 | sub jtype { shift->{jtype} }; |
---|
| 1268 | sub from { shift->{from} }; |
---|
| 1269 | sub to { shift->{to} }; |
---|
[0d5d51b] | 1270 | sub room { shift->{room} }; |
---|
[25729b2] | 1271 | |
---|
| 1272 | sub smartfilter { |
---|
| 1273 | my $self = shift; |
---|
| 1274 | my $inst = shift; |
---|
| 1275 | |
---|
[0d5d51b] | 1276 | my ($filter, $ftext); |
---|
| 1277 | |
---|
[25729b2] | 1278 | if($self->jtype eq 'chat') { |
---|
[0d5d51b] | 1279 | my $user; |
---|
[25729b2] | 1280 | if($self->direction eq 'in') { |
---|
| 1281 | $user = $self->from; |
---|
| 1282 | } else { |
---|
| 1283 | $user = $self->to; |
---|
| 1284 | } |
---|
| 1285 | $user = Net::Jabber::JID->new($user)->GetJID($inst ? 'full' : 'base'); |
---|
| 1286 | $filter = "jabber-user-$user"; |
---|
| 1287 | $ftext = qq{type ^jabber\$ and ( ( direction ^in\$ and from ^$user ) } . |
---|
| 1288 | qq{or ( direction ^out\$ and to ^$user ) ) }; |
---|
[d609dd6] | 1289 | BarnOwl::filter("$filter $ftext"); |
---|
[25729b2] | 1290 | return $filter; |
---|
[0d5d51b] | 1291 | } elsif ($self->jtype eq 'groupchat') { |
---|
| 1292 | my $room = $self->room; |
---|
| 1293 | $filter = "jabber-room-$room"; |
---|
| 1294 | $ftext = qq{type ^jabber\$ and room ^$room\$}; |
---|
[d609dd6] | 1295 | BarnOwl::filter("$filter $ftext"); |
---|
[0d5d51b] | 1296 | return $filter; |
---|
[25729b2] | 1297 | } |
---|
| 1298 | } |
---|
| 1299 | |
---|
[84296f6] | 1300 | 1; |
---|