Changeset 63bbef4
- Timestamp:
- Jan 24, 2007, 5:24:05 PM (18 years ago)
- 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:
- 989fae0
- Parents:
- 3ce5bdc
- git-author:
- Nelson Elhage <nelhage@mit.edu> (01/24/07 17:03:51)
- git-committer:
- Nelson Elhage <nelhage@mit.edu> (01/24/07 17:24:05)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/modules/jabber.pl
r3ce5bdc r63bbef4 155 155 } 156 156 157 sub getJ ids {157 sub getJIDs { 158 158 my $self = shift; 159 159 return keys %{ $self }; … … 248 248 } 249 249 250 foreach my $jid ( $conn->getJ ids() ) {250 foreach my $jid ( $conn->getJIDs() ) { 251 251 my $client = $conn->getConnectionFromJID($jid); 252 252 … … 335 335 sub onGetBuddyList { 336 336 my $blist = ""; 337 foreach my $jid ($conn->getJ ids()) {337 foreach my $jid ($conn->getJIDs()) { 338 338 $blist .= getSingleBuddyList($jid); 339 339 } … … 513 513 my $errStr = 514 514 "You are logged into multiple accounts. Please specify an account to log out of.\n"; 515 foreach my $jid ( $conn->getJ ids() ) {515 foreach my $jid ( $conn->getJIDs() ) { 516 516 $errStr .= "\t$jid\n"; 517 517 } … … 522 522 if ( $_[1] eq '-a' ) #All accounts. 523 523 { 524 foreach my $jid ( $conn->getJ ids() ) {524 foreach my $jid ( $conn->getJIDs() ) { 525 525 do_logout($jid); 526 526 } … … 535 535 else # Only one account logged in. 536 536 { 537 do_logout( ( $conn->getJ ids() )[0] );537 do_logout( ( $conn->getJIDs() )[0] ); 538 538 } 539 539 return ""; … … 541 541 542 542 sub cmd_jlist { 543 if ( !( scalar $conn->getJ ids() ) ) {543 if ( !( scalar $conn->getJIDs() ) ) { 544 544 BarnOwl::error("You are not logged in to Jabber."); 545 545 return; … … 672 672 or die("Usage: jmuc join MUC [-p password] [-a account]"); 673 673 674 $conn->getConnectionFromJID($jid)->MUCJoin(J id=> $muc,674 $conn->getConnectionFromJID($jid)->MUCJoin(JID => $muc, 675 675 Password => $password, 676 676 History => { … … 794 794 my @groups = @{ shift() }; 795 795 my $purgeGroups = shift; 796 my $baseJ id= baseJID($jid);796 my $baseJID = baseJID($jid); 797 797 798 798 my $roster = $conn->getRosterFromJID($jid); … … 809 809 $p->SetTo($to); 810 810 $conn->getConnectionFromJID($jid)->Send($p); 811 queue_admin_msg("You ($baseJ id) have requested a subscription to ($to)'s presence.");811 queue_admin_msg("You ($baseJID) have requested a subscription to ($to)'s presence."); 812 812 } 813 813 } … … 818 818 my @groups = @{ shift() }; 819 819 my $purgeGroups = shift; 820 my $baseJ id= baseJID($jid);820 my $baseJID = baseJID($jid); 821 821 822 822 my $p = new Net::XMPP::Presence; … … 825 825 $p->SetTo($to); 826 826 $conn->getConnectionFromJID($jid)->Send($p); 827 queue_admin_msg("You ($baseJ id) have unsubscribed from ($to)'s presence.");827 queue_admin_msg("You ($baseJID) have unsubscribed from ($to)'s presence."); 828 828 } 829 829 } … … 834 834 my @groups = @{ shift() }; 835 835 my $purgeGroups = shift; 836 my $baseJ id= baseJID($jid);836 my $baseJID = baseJID($jid); 837 837 838 838 my $roster = $conn->getRosterFromJID($jid); … … 867 867 $item->put_attrib(name => $name) if $name; 868 868 $conn->getConnectionFromJID($jid)->Send($iq); 869 my $msg = "$baseJ id: "869 my $msg = "$baseJID: " 870 870 . ($name ? "$name ($to)" : "($to)") 871 871 . " is on your roster in the following groups: { " … … 881 881 my @groups = @{ shift() }; 882 882 my $purgeGroups = shift; 883 my $baseJ id= baseJID($jid);883 my $baseJID = baseJID($jid); 884 884 885 885 my $iq = new Net::XMPP::IQ; … … 891 891 $item->put_attrib(jid => $to); 892 892 $conn->getConnectionFromJID($jid)->Send($iq); 893 queue_admin_msg("You ($baseJ id) have removed ($to) from your roster.");893 queue_admin_msg("You ($baseJID) have removed ($to) from your roster."); 894 894 } 895 895 } … … 900 900 my @groups = @{ shift() }; 901 901 my $purgeGroups = shift; 902 my $baseJ id= baseJID($jid);902 my $baseJID = baseJID($jid); 903 903 904 904 my $p = new Net::XMPP::Presence; … … 907 907 $p->SetTo($to); 908 908 $conn->getConnectionFromJID($jid)->Send($p); 909 queue_admin_msg("($to) has been subscribed to your ($baseJ id) presence.");909 queue_admin_msg("($to) has been subscribed to your ($baseJID) presence."); 910 910 } 911 911 } … … 916 916 my @groups = @{ shift() }; 917 917 my $purgeGroups = shift; 918 my $baseJ id= baseJID($jid);918 my $baseJID = baseJID($jid); 919 919 920 920 my $p = new Net::XMPP::Presence; … … 923 923 $p->SetTo($to); 924 924 $conn->getConnectionFromJID($jid)->Send($p); 925 queue_admin_msg("($to) has been unsubscribed from your ($baseJ id) presence.");925 queue_admin_msg("($to) has been unsubscribed from your ($baseJID) presence."); 926 926 } 927 927 } … … 1084 1084 1085 1085 # Find a connection to reply with. 1086 foreach my $jid ($conn->getJ ids()) {1087 my $cJ id= new Net::XMPP::JID;1088 $cJ id->SetJID($jid);1089 if ($to eq $cJ id->GetJID('base') ||1090 $to eq $cJ id->GetJID('full')) {1086 foreach my $jid ($conn->getJIDs()) { 1087 my $cJID = new Net::XMPP::JID; 1088 $cJID->SetJID($jid); 1089 if ($to eq $cJID->GetJID('base') || 1090 $to eq $cJID->GetJID('full')) { 1091 1091 my $reply = $p->Reply(type=>"unsubscribed"); 1092 1092 $conn->getConnectionFromJID($jid)->Send($reply); … … 1239 1239 1240 1240 sub defaultJID { 1241 return ( $conn->getJ ids() )[0] if ( $conn->connected() == 1 );1241 return ( $conn->getJIDs() )[0] if ( $conn->connected() == 1 ); 1242 1242 return; 1243 1243 } 1244 1244 1245 1245 sub baseJID { 1246 my $givenJ idStr = shift;1247 my $givenJ id= new Net::XMPP::JID;1248 $givenJ id->SetJID($givenJidStr);1249 return $givenJ id->GetJID('base');1246 my $givenJIDStr = shift; 1247 my $givenJID = new Net::XMPP::JID; 1248 $givenJID->SetJID($givenJIDStr); 1249 return $givenJID->GetJID('base'); 1250 1250 } 1251 1251 1252 1252 sub resolveConnectedJID { 1253 my $givenJ idStr = shift;1254 my $givenJ id= new Net::XMPP::JID;1255 $givenJ id->SetJID($givenJidStr);1253 my $givenJIDStr = shift; 1254 my $givenJID = new Net::XMPP::JID; 1255 $givenJID->SetJID($givenJIDStr); 1256 1256 1257 1257 # Account fully specified. 1258 if ( $givenJ id->GetResource() ) {1258 if ( $givenJID->GetResource() ) { 1259 1259 # Specified account exists 1260 return $givenJ idStr if ($conn->jidExists($givenJidStr) );1261 die("Invalid account: $givenJ idStr");1260 return $givenJIDStr if ($conn->jidExists($givenJIDStr) ); 1261 die("Invalid account: $givenJIDStr"); 1262 1262 } 1263 1263 1264 1264 # Disambiguate. 1265 1265 else { 1266 my $matchingJ id= "";1266 my $matchingJID = ""; 1267 1267 my $errStr = 1268 1268 "Ambiguous account reference. Please specify a resource.\n"; 1269 1269 my $ambiguous = 0; 1270 1270 1271 foreach my $jid ( $conn->getJ ids() ) {1272 my $cJ id= new Net::XMPP::JID;1273 $cJ id->SetJID($jid);1274 if ( $givenJ idStr eq $cJid->GetJID('base') ) {1275 $ambiguous = 1 if ( $matchingJ idne "" );1276 $matchingJ id= $jid;1271 foreach my $jid ( $conn->getJIDs() ) { 1272 my $cJID = new Net::XMPP::JID; 1273 $cJID->SetJID($jid); 1274 if ( $givenJIDStr eq $cJID->GetJID('base') ) { 1275 $ambiguous = 1 if ( $matchingJID ne "" ); 1276 $matchingJID = $jid; 1277 1277 $errStr .= "\t$jid\n"; 1278 1278 } … … 1285 1285 1286 1286 # Not one of ours. 1287 elsif ( $matchingJ ideq "" ) {1288 die("Invalid account: $givenJ idStr");1287 elsif ( $matchingJID eq "" ) { 1288 die("Invalid account: $givenJIDStr"); 1289 1289 } 1290 1290 1291 1291 # It's this one. 1292 1292 else { 1293 return $matchingJ id;1293 return $matchingJID; 1294 1294 } 1295 1295 } … … 1304 1304 my @jids = $roster->jids('all'); 1305 1305 for my $j (@jids) { 1306 if(($roster->query($j, 'name') || "") eq $to) {1306 if(($roster->query($j, 'name') || $j->GetUserID()) eq $to) { 1307 1307 return $j->GetJID('full'); 1308 1308 } elsif($j->GetJID('base') eq baseJID($to)) {
Note: See TracChangeset
for help on using the changeset viewer.