Changeset 2ce12de
- Timestamp:
- Jul 28, 2009, 10:53:47 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:
- 57ba9f1
- Parents:
- c1d9441
- git-author:
- Alejandro R. Sedeño <asedeno@mit.edu> (07/28/09 22:45:22)
- git-committer:
- Alejandro R. Sedeño <asedeno@mit.edu> (07/28/09 22:53:47)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
r004d683 r2ce12de 19 19 use BarnOwl::Module::Jabber::Connection; 20 20 use BarnOwl::Module::Jabber::ConnectionManager; 21 use BarnOwl::Completion::Util qw(complete_flags); 21 22 22 23 use Authen::SASL qw(Perl); … … 62 63 $conn ||= BarnOwl::Module::Jabber::ConnectionManager->new; 63 64 our %vars; 65 our %completion_jids; 64 66 65 67 sub onStart { … … 164 166 165 167 $blistStr .= sprintf '%-15s %s', $name, $buddy->GetJID(); 168 $completion_jids{$name} = 1; 169 $completion_jids{$buddy->GetJID()} = 1; 166 170 167 171 if ($res) { … … 427 431 BarnOwl::error( "Error in connect: " . join( " ", @result ) ); 428 432 } else { 429 $conn->getRosterFromJID($jidStr)->fetch(); 433 my $roster = $conn->getRosterFromJID($jidStr); 434 $roster->fetch(); 430 435 $client->PresenceSend( priority => 1 ); 431 436 my $fullJid = $client->{SESSION}->{FULLJID} || $jidStr; … … 437 442 #queue_admin_msg("Connected to jabber as $fullJid ($client->{fileno})"); 438 443 BarnOwl::add_dispatch($client->{fileno}, sub { $client->OwlProcess() }); 444 445 # populate completion from roster. 446 for my $buddy ( $roster->jids('all') ) { 447 my %jq = $roster->query($buddy); 448 my $name = $jq{name} || $buddy->GetUserID(); 449 $completion_jids{$name} = 1; 450 $completion_jids{$buddy->GetJID()} = 1; 451 } 439 452 } 440 453 } … … 647 660 MaxChars => 0 648 661 }); 662 $completion_jids{$muc} = 1; 649 663 return; 650 664 } … … 701 715 702 716 my $presence = "JIDs present in " . $m->BaseJID; 717 $completion_jids{$m->BaseJID} = 1; 703 718 if($m->Anonymous) { 704 719 $presence .= " [anonymous MUC]"; … … 875 890 $name = "" unless (1 == scalar(@ARGV)); 876 891 892 $completion_jids{$baseJID} = 1; 893 $completion_jids{$name} = 1 if $name; 894 877 895 foreach my $to (@ARGV) { 878 896 my %jq = $roster->query($to); … … 1057 1075 1058 1076 sub process_presence_available { 1059 return unless (BarnOwl::getvar('jabber:show_logins') eq 'on');1060 1077 my ( $sid, $p ) = @_; 1061 1078 my $from = $p->GetFrom('jid')->GetJID('base'); 1079 $completion_jids{$from} = 1; 1080 return unless (BarnOwl::getvar('jabber:show_logins') eq 'on'); 1062 1081 my $to = $p->GetTo(); 1063 1082 my $type = $p->GetType(); … … 1209 1228 if ($connection->FindMUC(jid => $to)); 1210 1229 } 1230 1231 # Populate completion. 1232 if ($dir eq 'in') { 1233 $completion_jids{ $props{sender} }= 1; 1234 } 1235 else { 1236 $completion_jids{ $props{recipient} } = 1; 1237 } 1211 1238 } 1212 1239 elsif ( $jtype eq 'groupchat' ) { 1213 1240 my $nick = $props{nick} = $from->GetResource(); 1214 1241 my $room = $props{room} = $from->GetJID('base'); 1242 $completion_jids{$room} = 1; 1215 1243 1216 1244 $props{sender} = $nick || $room; … … 1384 1412 } 1385 1413 1414 ################################################################################ 1415 ### Completion 1416 1417 sub complete_user_or_muc { return keys %completion_jids; } 1418 sub complete_account { return $conn->getJIDs(); } 1419 1420 sub complete_jwrite { 1421 my $ctx = shift; 1422 return complete_flags($ctx, 1423 [qw(-t -i -s)], 1424 { 1425 "-a" => \&complete_account, 1426 }, 1427 \&complete_user_or_muc } 1428 ); 1429 } 1430 1431 BarnOwl::Completion::register_completer(jwrite => sub { BarnOwl::Module::Jabber::complete_jwrite(@_)); 1432 1386 1433 1;
Note: See TracChangeset
for help on using the changeset viewer.