- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
raa0a0b5 r8789410 285 285 { 286 286 summary => "Send a Jabber Message", 287 usage => "jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>] [-m <message>]"287 usage => "jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]" 288 288 } 289 289 ); … … 308 308 description => "jmuc sends Jabber commands related to MUC.\n\n" 309 309 . "The following commands are available\n\n" 310 . "join <muc>[/<nick>]\n" 311 . " Join a MUC (with a given nickname, or otherwise your JID).\n\n" 310 . "join <muc> Join a MUC.\n\n" 312 311 . "part <muc> Part a MUC.\n" 313 312 . " The MUC is taken from the current message if not supplied.\n\n" … … 378 377 my $cjidStr = $conn->baseJIDExists($jidStr); 379 378 if ($cjidStr) { 380 die("Already logged in as $cjidStr.\n"); 379 BarnOwl::error("Already logged in as $cjidStr."); 380 return; 381 381 } 382 382 } … … 387 387 388 388 if ( !$uid || !$componentname ) { 389 die("usage: $cmd JID\n"); 389 BarnOwl::error("usage: $cmd JID"); 390 return; 390 391 } 391 392 392 393 if ( $conn->jidActive($jidStr) ) { 393 die("Already logged in as $jidStr.\n"); 394 BarnOwl::error("Already logged in as $jidStr."); 395 return; 394 396 } elsif ($conn->jidExists($jidStr)) { 395 397 return $conn->tryReconnect($jidStr, 1); … … 524 526 sub cmd_jlist { 525 527 if ( !( scalar $conn->getJIDs() ) ) { 526 die("You are not logged in to Jabber.\n"); 528 BarnOwl::error("You are not logged in to Jabber."); 529 return; 527 530 } 528 531 BarnOwl::popless_ztext( onGetBuddyList() ); … … 531 534 sub cmd_jwrite { 532 535 if ( !$conn->connected() ) { 533 die("You are not logged in to Jabber.\n"); 536 BarnOwl::error("You are not logged in to Jabber."); 537 return; 534 538 } 535 539 … … 539 543 my $jwrite_thread = ""; 540 544 my $jwrite_subject = ""; 541 my $jwrite_body;542 545 my ($to, $from); 543 546 my $jwrite_type = "chat"; … … 551 554 'subject=s' => \$jwrite_subject, 552 555 'account=s' => \$from, 553 'id=s' => \$jwrite_sid, 554 'message=s' => \$jwrite_body, 556 'id=s' => \$jwrite_sid, 555 557 ) or die("Usage: jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]\n"); 556 558 $jwrite_type = 'groupchat' if $gc; 557 559 558 560 if ( scalar @ARGV != 1 ) { 559 die("Usage: jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]\n"); 561 BarnOwl::error( 562 "Usage: jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]"); 563 return; 560 564 } 561 565 else { … … 566 570 567 571 unless(scalar @candidates) { 568 die("Unable to resolve JID $to \n");572 die("Unable to resolve JID $to"); 569 573 } 570 574 … … 573 577 unless(scalar @candidates) { 574 578 if(!$from) { 575 die("You must specify an account with -a \n");579 die("You must specify an account with -a"); 576 580 } else { 577 die("Unable to resolve account $from \n");581 die("Unable to resolve account $from"); 578 582 } 579 583 } … … 590 594 type => $jwrite_type 591 595 }; 592 593 if (defined($jwrite_body)) {594 process_owl_jwrite($jwrite_body);595 return;596 }597 596 598 597 if(scalar @candidates > 1) { … … 632 631 my $func = $jmuc_commands{$cmd}; 633 632 if ( !$func ) { 634 die("jmuc: Unknown command: $cmd\n"); 633 BarnOwl::error("jmuc: Unknown command: $cmd"); 634 return; 635 635 } 636 636 … … 654 654 } 655 655 else { 656 die("You must specify an account with -a <jid>\n");656 BarnOwl::error('You must specify an account with -a <jid>'); 657 657 } 658 658 return $func->( $jid, $muc, @ARGV ); … … 667 667 668 668 $muc = shift @ARGV 669 or die("Usage: jmuc join <muc> [-p <password>] [-a <account>] \n");669 or die("Usage: jmuc join <muc> [-p <password>] [-a <account>]"); 670 670 671 671 die("Error: Must specify a fully-qualified MUC name (e.g. barnowl\@conference.mit.edu)\n") … … 680 680 MaxChars => 0 681 681 }); 682 $completion_jids{$muc ->GetJID('base')} = 1;682 $completion_jids{$muc} = 1; 683 683 return; 684 684 } … … 688 688 689 689 $muc = shift @args if scalar @args; 690 die("Usage: jmuc part [<muc>] [-a <account>] \n") unless $muc;690 die("Usage: jmuc part [<muc>] [-a <account>]") unless $muc; 691 691 692 692 if($conn->getConnectionFromJID($jid)->MUCLeave(JID => $muc)) { 693 693 queue_admin_msg("$jid has left $muc."); 694 694 } else { 695 die("Error: Not joined to $muc \n");695 die("Error: Not joined to $muc"); 696 696 } 697 697 } … … 703 703 $muc = shift @args if scalar @args; 704 704 705 die( "Usage: jmuc invite <jid> [<muc>] [-a <account>]\n")705 die('Usage: jmuc invite <jid> [<muc>] [-a <account>]') 706 706 unless $muc && $invite_jid; 707 707 … … 718 718 my ( $jid, $muc, @args ) = @_; 719 719 $muc = shift @args if scalar @args; 720 die("Usage: jmuc configure [<muc>] \n") unless $muc;720 die("Usage: jmuc configure [<muc>]") unless $muc; 721 721 my $iq = Net::Jabber::IQ->new(); 722 722 $iq->SetTo($muc); … … 759 759 760 760 $muc = shift @args if scalar @args; 761 die("Usage: jmuc presence [<muc>] \n") unless $muc;761 die("Usage: jmuc presence [<muc>]") unless $muc; 762 762 763 763 if ($muc eq '-a') { … … 774 774 else { 775 775 my $m = $conn->getConnectionFromJID($jid)->FindMUC(jid => $muc); 776 die("No such muc: $muc \n") unless $m;776 die("No such muc: $muc") unless $m; 777 777 BarnOwl::popless_ztext(jmuc_presence_single($m)); 778 778 } … … 801 801 my $func = $jroster_commands{$cmd}; 802 802 if ( !$func ) { 803 die("jroster: Unknown command: $cmd\n"); 803 BarnOwl::error("jroster: Unknown command: $cmd"); 804 return; 804 805 } 805 806 … … 824 825 } 825 826 else { 826 die("You must specify an account with -a <jid>\n");827 BarnOwl::error('You must specify an account with -a <jid>'); 827 828 } 828 829 return $func->( $jid, $name, \@groups, $purgeGroups, @ARGV ); … … 848 849 } 849 850 else { 850 die("You must specify an account with -a <jid>\n");851 BarnOwl::error('You must specify an account with -a <jid>'); 851 852 } 852 853 … … 1233 1234 $completion_jids{$room} = 1; 1234 1235 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;1244 1236 $props{sender} = $nick || $room; 1245 1237 $props{recipient} = $room; … … 1339 1331 return $givenJIDStr if ($conn->jidExists($givenJIDStr) ); 1340 1332 return resolveConnectedJID($givenJID->GetJID('base')) if $loose; 1341 die("Invalid account: $givenJIDStr \n");1333 die("Invalid account: $givenJIDStr"); 1342 1334 } 1343 1335 … … 1392 1384 # Not one of ours. 1393 1385 else { 1394 die("Invalid account: $givenJIDStr \n");1386 die("Invalid account: $givenJIDStr"); 1395 1387 } 1396 1388 … … 1438 1430 if($from) { 1439 1431 $from_jid = resolveConnectedJID($from, 1); 1440 die("Unable to resolve account $from \n") unless $from_jid;1432 die("Unable to resolve account $from") unless $from_jid; 1441 1433 $to_jid = resolveDestJID($to, $from_jid); 1442 1434 push @matches, [$from_jid, $to_jid] if $to_jid;
Note: See TracChangeset
for help on using the changeset viewer.