Changeset 9c7a701
- Timestamp:
- Feb 15, 2008, 12:56:49 AM (17 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:
- 18a54ee
- Parents:
- a6a4155
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile.in
r5ff830a r9c7a701 26 26 keypress.c keymap.c keybinding.c cmd.c context.c zcrypt.c \ 27 27 aim.c buddy.c buddylist.c timer.c style.c stylefunc.c errqueue.c \ 28 zbuddylist.c muxevents.c popexec.c obarray.c 28 zbuddylist.c muxevents.c popexec.c obarray.c select.c 29 29 OWL_SRC = owl.c 30 30 TESTER_SRC = tester.c -
global.c
reebef19 r9c7a701 117 117 118 118 owl_message_init_fmtext_cache(); 119 owl_list_create(&(g->dispatchlist)); 119 120 } 120 121 … … 932 933 return owl_obarray_insert(&(g->obarray), string); 933 934 } 935 936 owl_list *owl_global_get_dispatchlist(owl_global *g) 937 { 938 return &(g->dispatchlist); 939 } -
owl.c
reebef19 r9c7a701 46 46 #include <sys/param.h> 47 47 #include <sys/types.h> 48 #include <sys/time.h> 48 49 #include <termios.h> 49 50 #include <sys/stat.h> … … 60 61 #endif 61 62 63 #define STDIN 0 64 62 65 static const char fileIdent[] = "$Id$"; 63 66 … … 69 72 owl_editwin *tw; 70 73 owl_popwin *pw; 71 int j,ret, initialsubs, debug, argcsave, followlast;74 int ret, initialsubs, debug, argcsave, followlast; 72 75 int newmsgs, nexttimediff; 73 76 struct sigaction sigact; … … 206 209 owl_global_set_haveaim(&g); 207 210 211 /* prepare stdin dispatch */ 212 { 213 owl_dispatch *d = owl_malloc(sizeof(owl_dispatch)); 214 d->fd = STDIN; 215 d->cfunc = &owl_process_input; 216 d->pfunc = NULL; 217 owl_select_add_dispatch(d); 218 } 219 208 220 #ifdef HAVE_LIBZEPHYR 209 221 /* zephyr init */ 210 222 ret=owl_zephyr_initialize(); 211 if (!ret) 212 owl_global_set_havezephyr(&g); 223 if (!ret) { 224 owl_dispatch *d = owl_malloc(sizeof(owl_dispatch)); 225 d->fd = ZGetFD(); 226 d->cfunc = &owl_zephyr_process_events; 227 d->pfunc = NULL; 228 owl_select_add_dispatch(d); 229 owl_global_set_havezephyr(&g); 230 } 231 213 232 #endif 214 233 … … 425 444 followlast=owl_global_should_followlast(&g); 426 445 427 /* Do AIM stuff */428 if (owl_global_is_doaimevents(&g)) {429 owl_aim_process_events();430 431 if (owl_global_is_aimloggedin(&g)) {432 if (owl_timer_is_expired(owl_global_get_aim_buddyinfo_timer(&g))) {433 /* owl_buddylist_request_idletimes(owl_global_get_buddylist(&g)); */434 owl_timer_reset(owl_global_get_aim_buddyinfo_timer(&g));435 }436 }437 }438 439 446 owl_perlconfig_mainloop(); 440 447 … … 454 461 } 455 462 456 owl_zephyr_process_events();457 458 463 /* Grab incoming messages. */ 459 464 newmsgs=0; … … 530 535 * little bit, but otherwise do not. This lets input be grabbed 531 536 * as quickly as possbile */ 532 j=wgetch(typwin); 533 if (j==ERR) { 534 usleep(10000); 535 } else { 536 owl_global_set_lastinputtime(&g, now); 537 /* find and activate the current keymap. 538 * TODO: this should really get fixed by activating 539 * keymaps as we switch between windows... 540 */ 541 if (pw && owl_popwin_is_active(pw) && owl_global_get_viewwin(&g)) { 542 owl_context_set_popless(owl_global_get_context(&g), 543 owl_global_get_viewwin(&g)); 544 owl_function_activate_keymap("popless"); 545 } else if (owl_global_is_typwin_active(&g) 546 && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_ONELINE) { 547 /* 548 owl_context_set_editline(owl_global_get_context(&g), tw); 549 owl_function_activate_keymap("editline"); 550 */ 551 } else if (owl_global_is_typwin_active(&g) 552 && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_MULTILINE) { 553 owl_context_set_editmulti(owl_global_get_context(&g), tw); 554 owl_function_activate_keymap("editmulti"); 555 } else { 556 owl_context_set_recv(owl_global_get_context(&g)); 557 owl_function_activate_keymap("recv"); 558 } 559 /* now actually handle the keypress */ 560 ret = owl_keyhandler_process(owl_global_get_keyhandler(&g), j); 561 if (ret!=0 && ret!=1) { 562 owl_function_makemsg("Unable to handle keypress"); 563 } 564 } 537 538 /* select on FDs we know about. */ 539 owl_select(); 565 540 566 541 /* Log any error signals */ … … 680 655 } 681 656 657 void owl_process_aim() 658 { 659 if (owl_global_is_doaimevents(&g)) { 660 owl_aim_process_events(); 661 662 if (owl_global_is_aimloggedin(&g)) { 663 if (owl_timer_is_expired(owl_global_get_aim_buddyinfo_timer(&g))) { 664 /* owl_buddylist_request_idletimes(owl_global_get_buddylist(&g)); */ 665 owl_timer_reset(owl_global_get_aim_buddyinfo_timer(&g)); 666 } 667 } 668 } 669 } 670 671 void owl_process_input() 672 { 673 int ret, j; 674 owl_popwin *pw; 675 owl_editwin *tw; 676 677 j = wgetch(owl_global_get_curs_typwin(&g)); 678 if (j == ERR) return; 679 680 owl_global_set_lastinputtime(&g, time(NULL)); 681 pw=owl_global_get_popwin(&g); 682 tw=owl_global_get_typwin(&g); 683 684 /* find and activate the current keymap. 685 * TODO: this should really get fixed by activating 686 * keymaps as we switch between windows... 687 */ 688 if (pw && owl_popwin_is_active(pw) && owl_global_get_viewwin(&g)) { 689 owl_context_set_popless(owl_global_get_context(&g), 690 owl_global_get_viewwin(&g)); 691 owl_function_activate_keymap("popless"); 692 } else if (owl_global_is_typwin_active(&g) 693 && owl_editwin_get_style(tw) == OWL_EDITWIN_STYLE_ONELINE) { 694 /* 695 owl_context_set_editline(owl_global_get_context(&g), tw); 696 owl_function_activate_keymap("editline"); 697 */ 698 } else if (owl_global_is_typwin_active(&g) 699 && owl_editwin_get_style(tw) == OWL_EDITWIN_STYLE_MULTILINE) { 700 owl_context_set_editmulti(owl_global_get_context(&g), tw); 701 owl_function_activate_keymap("editmulti"); 702 } else { 703 owl_context_set_recv(owl_global_get_context(&g)); 704 owl_function_activate_keymap("recv"); 705 } 706 /* now actually handle the keypress */ 707 ret = owl_keyhandler_process(owl_global_get_keyhandler(&g), j); 708 if (ret != 0 && ret != 1) { 709 owl_function_makemsg("Unable to handle keypress"); 710 } 711 } 712 682 713 void sig_handler(int sig, siginfo_t *si, void *data) 683 714 { … … 694 725 owl_function_quit(); 695 726 } 696 697 727 } 698 728 -
owl.h
r88dc766 r9c7a701 537 537 owl_list strings; 538 538 } owl_obarray; 539 540 typedef struct _owl_dispatch { 541 int fd; /* FD to watch for dispatch. */ 542 void (*cfunc)(); /* C function to dispatch to. */ 543 SV *pfunc; /* Perl function to dispatch to. */ 544 } owl_dispatch; 539 545 540 546 typedef struct _owl_global { … … 608 614 struct termios startup_tio; 609 615 owl_obarray obarray; 616 owl_list dispatchlist; 610 617 } owl_global; 611 618 -
perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
rcab045b r9c7a701 69 69 } 70 70 71 sub mainloop_hook { 71 #sub mainloop_hook { 72 # return unless defined $irc; 73 # eval { 74 # $irc->do_one_loop(); 75 # }; 76 # return; 77 #} 78 79 sub OwlProcess { 72 80 return unless defined $irc; 73 81 eval { … … 76 84 return; 77 85 } 86 78 87 79 88 sub register_handlers { … … 109 118 $BarnOwl::Hooks::startup->add(\&startup); 110 119 $BarnOwl::Hooks::shutdown->add(\&shutdown); 111 $BarnOwl::Hooks::mainLoop->add(\&mainloop_hook);120 #$BarnOwl::Hooks::mainLoop->add(\&mainloop_hook); 112 121 113 122 ################################################################################ … … 165 174 BarnOwl::admin_message("IRC", "Connected to $alias as $nick"); 166 175 $ircnets{$alias} = $conn; 176 my $fd = $conn->getSocket()->fileno(); 177 BarnOwl::add_dispatch($fd, \&OwlProcess); 178 $conn->{FD} = $fd; 167 179 } else { 168 180 die("IRC::Connection->connect failed: $!"); -
perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm
r5ff830a r9c7a701 69 69 } 70 70 71 sub getSocket 72 { 73 my $self = shift; 74 return $self->conn->socket; 75 } 76 71 77 ################################################################################ 72 78 ############################### IRC callbacks ################################## … … 168 174 my $self = shift; 169 175 delete $BarnOwl::Module::IRC::ircnets{$self->alias}; 170 176 BarnOwl::remove_dispatch($self->{FD}); 171 177 BarnOwl::admin_message('IRC', 172 178 "[" . $self->alias . "] Disconnected from server"); -
perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
r879e7e94 r9c7a701 116 116 BarnOwl::error("Connection for $jid undefined -- error in reload?"); 117 117 } 118 119 my $status = $client->Process(0);120 if ( !defined($status) ) {121 BarnOwl::error("Jabber account $jid disconnected!");122 do_logout($jid);123 }124 118 if ($::shutdown) { 125 119 do_logout($jid); 126 return;120 next; 127 121 } 128 122 if ($vars{status_changed}) { … … 387 381 $conn->renameConnection($jidStr, $fullJid); 388 382 queue_admin_msg("Connected to jabber as $fullJid"); 383 # The remove_dispatch() method is called from the 384 # ConnectionManager's removeConnection() method. 385 BarnOwl::add_dispatch($client->getSocket()->fileno(), sub { $client->OwlProcess() }); 389 386 } 390 387 } -
perl/modules/Jabber/lib/BarnOwl/Module/Jabber/Connection.pm
r892568b r9c7a701 110 110 111 111 112 =head2 getSID 113 114 Returns the StreamID for this connection. 115 116 =cut 117 118 sub getStreamID { 119 my $self = shift; 120 return $self->{SESSION}->{id} || ""; 121 } 122 123 =head2 getSocket 124 125 Returns the IO::Socket for this connection. 126 127 =cut 128 129 sub getSocket { 130 my $self = shift; 131 my $sid = getStreamID($self); 132 return $self->{STREAM}->{SIDS}->{$sid}->{sock} || -1; 133 } 134 135 =head2 OwlProcess 136 137 Non-blocking connection processing. For use in a select loop. 138 139 =cut 140 141 sub OwlProcess { 142 my $self = shift; 143 my $status = $self->Process(0); 144 if ( !defined($status) ) { 145 my $jid = $self->{SESSION}->{FULLJID}; 146 BarnOwl::error("Jabber account $jid disconnected!"); 147 do_logout($jid); 148 } 149 } 150 112 151 =head1 SEE ALSO 113 152 -
perl/modules/Jabber/lib/BarnOwl/Module/Jabber/ConnectionManager.pm
r7f33c18 r9c7a701 37 37 return 0 unless exists $self->{$jidStr}; 38 38 39 BarnOwl::remove_dispatch($self->{$jidStr}->{Client}->getSocket()->fileno()); 39 40 $self->{$jidStr}->{Client}->Disconnect() 40 41 if $self->{$jidStr}->{Client}; … … 51 52 return 0 if $oldJidStr eq $newJidStr; 52 53 53 $self->{$newJidStr} = $self->{$oldJidStr}; 54 $self->{$newJidStr} = $self->{$oldJidStr}; 54 55 delete $self->{$oldJidStr}; 55 56 return 1; -
perlconfig.c
raf1920fd r9c7a701 485 485 } 486 486 487 void owl_perlconfig_dispatch_free(owl_dispatch *d) 488 { 489 SvREFCNT_dec(d->pfunc); 490 } 491 487 492 void owl_perlconfig_edit_callback(owl_editwin *e) 488 493 { … … 528 533 return; 529 534 } 535 536 void owl_perlconfig_do_dispatch(owl_dispatch *d) 537 { 538 SV *cb = d->pfunc; 539 unsigned int n_a; 540 dSP; 541 if(cb == NULL) { 542 owl_function_error("Perl callback is NULL!"); 543 } 544 545 ENTER; 546 SAVETMPS; 547 548 PUSHMARK(SP); 549 PUTBACK; 550 551 call_sv(cb, G_DISCARD|G_KEEPERR|G_EVAL); 552 553 if(SvTRUE(ERRSV)) { 554 owl_function_error("%s", SvPV(ERRSV, n_a)); 555 } 556 557 FREETMPS; 558 LEAVE; 559 } -
perlglue.xs
r65fea01 r9c7a701 342 342 desc, 343 343 ival); 344 345 void 346 add_dispatch(fd, cb) 347 int fd 348 SV * cb 349 CODE: 350 SvREFCNT_inc(cb); 351 owl_select_add_perl_dispatch(fd, cb); 352 353 void 354 remove_dispatch(fd) 355 int fd 356 CODE: 357 owl_select_remove_perl_dispatch(fd); -
zephyr.c
r247cbc9 r9c7a701 29 29 return(0); 30 30 } 31 32 31 33 32 int owl_zephyr_shutdown()
Note: See TracChangeset
for help on using the changeset viewer.