Changeset 06f5ef8 for perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
- Timestamp:
- Aug 4, 2009, 9:04:56 PM (15 years ago)
- Branches:
- master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 3ff3d86
- Parents:
- 6bc35b4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
r57ba9f1 r06f5ef8 1304 1304 sub resolveConnectedJID { 1305 1305 my $givenJIDStr = shift; 1306 my $loose = shift || 0; 1306 1307 my $givenJID = new Net::Jabber::JID; 1307 1308 $givenJID->SetJID($givenJIDStr); … … 1311 1312 # Specified account exists 1312 1313 return $givenJIDStr if ($conn->jidExists($givenJIDStr) ); 1314 return resolveConnectedJID($givenJID->GetJID('base')) if $loose; 1313 1315 die("Invalid account: $givenJIDStr"); 1314 1316 } … … 1316 1318 # Disambiguate. 1317 1319 else { 1318 my $matchingJID = ""; 1319 my $errStr = 1320 "Ambiguous account reference. Please specify a resource.\n"; 1321 my $ambiguous = 0; 1320 my $JIDMatchingJID = ""; 1321 my $strMatchingJID = ""; 1322 my $JIDMatches = ""; 1323 my $strMatches = ""; 1324 my $JIDAmbiguous = 0; 1325 my $strAmbiguous = 0; 1322 1326 1323 1327 foreach my $jid ( $conn->getJIDs() ) { … … 1325 1329 $cJID->SetJID($jid); 1326 1330 if ( $givenJIDStr eq $cJID->GetJID('base') ) { 1327 $ ambiguous = 1 if ( $matchingJID ne "" );1328 $ matchingJID = $jid;1329 $ errStr.= "\t$jid\n";1331 $JIDAmbiguous = 1 if ( $JIDMatchingJID ne "" ); 1332 $JIDMatchingJID = $jid; 1333 $JIDMatches .= "\t$jid\n"; 1330 1334 } 1335 if ( $cJID->GetJID('base') =~ /$givenJIDStr/ ) { 1336 $strAmbiguous = 1 if ( $strMatchingJID ne "" ); 1337 $strMatchingJID = $jid; 1338 $strMatches .= "\t$jid\n"; 1339 } 1331 1340 } 1332 1341 1333 1342 # Need further disambiguation. 1334 if ($ambiguous) { 1335 die($errStr); 1343 if ($JIDAmbiguous) { 1344 my $errStr = 1345 "Ambiguous account reference. Please specify a resource.\n"; 1346 die($errStr.$JIDMatches); 1347 } 1348 1349 # It's this one. 1350 elsif ($JIDMatchingJID ne "") { 1351 return $JIDMatchingJID; 1352 } 1353 1354 # Further resolution by substring. 1355 elsif ($strAmbiguous) { 1356 my $errStr = 1357 "Ambiguous account reference. Please be more specific.\n"; 1358 die($errStr.$strMatches); 1359 } 1360 1361 # It's this one, by substring. 1362 elsif ($strMatchingJID ne "") { 1363 return $strMatchingJID; 1336 1364 } 1337 1365 1338 1366 # Not one of ours. 1339 els if ( $matchingJID eq "" ){1367 else { 1340 1368 die("Invalid account: $givenJIDStr"); 1341 1369 } 1342 1370 1343 # It's this one.1344 else {1345 return $matchingJID;1346 }1347 1371 } 1348 1372 return ""; … … 1387 1411 my @matches; 1388 1412 if($from) { 1389 $from_jid = resolveConnectedJID($from );1413 $from_jid = resolveConnectedJID($from, 1); 1390 1414 die("Unable to resolve account $from") unless $from_jid; 1391 1415 $to_jid = resolveDestJID($to, $from_jid);
Note: See TracChangeset
for help on using the changeset viewer.