Changes in / [d4ecc78:19cc7b00]
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/lib/BarnOwl/Complete/Zephyr.pm
r8f16dcd r84db778 30 30 } 31 31 32 sub complete_sub {33 my $ctx = shift;34 return complete_flags($ctx,35 [],36 {37 "-r" => \&complete_realm,38 });39 }40 41 32 sub on_message { 42 33 my $m = shift; … … 50 41 BarnOwl::Completion::register_completer(zcrypt => \&complete_zwrite); 51 42 52 # TODO: Handle aliases transparently in the core completion code?53 BarnOwl::Completion::register_completer(sub => \&complete_sub);54 BarnOwl::Completion::register_completer(subscribe => \&complete_sub);55 56 43 $BarnOwl::Hooks::newMessage->add("BarnOwl::Complete::Zephyr::on_message"); 57 44 -
perl/lib/BarnOwl/Completion.pm
rf987504 rc4efb46 18 18 point_move replace_region); 19 19 20 use List::Util qw(m axfirst);20 use List::Util qw(min first); 21 21 22 22 our %completers = (); … … 76 76 sub common_prefix { 77 77 my @words = @_; 78 my $len = m ax(map {length($_)} @words);78 my $len = min(map {length($_)} @words); 79 79 my $pfx = ''; 80 80 for my $i (1..$len) { -
perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
r96f7b07 rab9cd8f 18 18 use BarnOwl::Message::IRC; 19 19 use BarnOwl::Module::IRC::Connection qw(is_private); 20 use BarnOwl::Module::IRC::Completion; 20 21 21 22 use Net::IRC; -
perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
r004d683 r57ba9f1 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; -
perlglue.xs
r6dc2d6b rd77e909 332 332 CODE: 333 333 owl_select_remove_perl_dispatch(fd); 334 335 336 AV* 337 all_filters() 338 PREINIT: 339 AV *filters; 340 owl_list *fl; 341 owl_filter *f; 342 int i; 343 CODE: 344 { 345 fl = owl_global_get_filterlist(&g); 346 filters = newAV(); 347 for(i=0;i<owl_list_get_size(fl);i++) { 348 f = owl_list_get_element(fl, i); 349 av_push(filters, newSVpv(owl_filter_get_name(f), 0)); 350 } 351 RETVAL = filters; 352 sv_2mortal((SV*)RETVAL); 353 } 354 OUTPUT: 355 RETVAL 334 356 335 357 MODULE = BarnOwl PACKAGE = BarnOwl::Internal -
t/completion.t
r7be5d8b rc4efb46 122 122 is(BarnOwl::Completion::common_prefix(qw(abc abc)), 'abc'); 123 123 124 is(BarnOwl::Completion::common_prefix('a', ''), ''); 125 124 126 ## Test complete_flags 125 127
Note: See TracChangeset
for help on using the changeset viewer.