Changeset 13a3c1db
- Timestamp:
- May 30, 2007, 12:05:27 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:
- 4508e21
- Parents:
- 1fd5e4c1
- git-author:
- Nelson Elhage <nelhage@mit.edu> (05/30/07 00:05:16)
- git-committer:
- Nelson Elhage <nelhage@mit.edu> (05/30/07 00:05:27)
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
rce74deb r13a3c1db 164 164 } 165 165 166 167 /* Add the given message to Owl's internal queue. If displayoutgoing168 * is disabled, the message is NOT added to any internal queue, -1 is169 * returned and THE CALLER IS EXPECTED TO FREE THE GIVEN MESSAGE.170 * Otherwise 0 is returned and the caller need do nothing more171 */172 int owl_function_add_message(owl_message *m)173 {174 /* if displayoutgoing is disabled, nuke the message and move on */175 if (! owl_global_is_displayoutgoing(&g)) {176 return(-1);177 }178 179 /* add it to the global list and current view */180 owl_messagelist_append_element(owl_global_get_msglist(&g), m);181 owl_view_consider_message(owl_global_get_current_view(&g), m);182 183 /* do followlast if necessary */184 if (owl_global_should_followlast(&g)) owl_function_lastmsg_noredisplay();185 186 /* redisplay etc. */187 owl_mainwin_redisplay(owl_global_get_mainwin(&g));188 if (owl_popwin_is_active(owl_global_get_popwin(&g))) {189 owl_popwin_refresh(owl_global_get_popwin(&g));190 }191 wnoutrefresh(owl_global_get_curs_recwin(&g));192 owl_global_set_needrefresh(&g);193 return(0);194 }195 196 166 /* Create an admin message, append it to the global list of messages 197 167 * and redisplay if necessary. … … 413 383 414 384 if (m) { 415 /* log it */ 416 owl_log_message(m); 417 418 /* add it or nuke it */ 419 if (owl_global_is_displayoutgoing(&g)) { 420 owl_function_add_message(m); 421 } else { 422 owl_message_free(m); 423 } 385 owl_global_messagequeue_addmsg(&g, m); 424 386 } else { 425 387 owl_function_error("Could not create outgoing zephyr message"); … … 477 439 m=owl_function_make_outgoing_zephyr(mymsg, line, owl_zwrite_get_zsig(&z)); 478 440 if (m) { 479 /* log it */ 480 owl_log_message(m); 481 482 /* add it or nuke it */ 483 if (owl_global_is_displayoutgoing(&g)) { 484 owl_function_add_message(m); 485 } else { 486 owl_message_free(m); 487 } 441 owl_global_messagequeue_addmsg(&g, m); 488 442 } else { 489 443 owl_function_error("Could not create outgoing zephyr message"); … … 525 479 526 480 if (m) { 527 /* log it */ 528 owl_log_message(m); 529 530 /* display it or nuke it */ 531 if (owl_global_is_displayoutgoing(&g)) { 532 owl_function_add_message(m); 533 } else { 534 owl_message_free(m); 535 } 481 owl_global_messagequeue_addmsg(&g, m); 536 482 } else { 537 483 owl_function_error("Could not create outgoing AIM message"); … … 562 508 m=owl_function_make_outgoing_aim(msg, to); 563 509 if (m) { 564 /* log it */ 565 owl_log_message(m); 566 567 /* display it or nuke it */ 568 if (owl_global_is_displayoutgoing(&g)) { 569 owl_function_add_message(m); 570 } else { 571 owl_message_free(m); 572 } 510 owl_global_messagequeue_addmsg(&g, m); 573 511 } else { 574 512 owl_function_error("Could not create AIM message"); … … 588 526 * an incoming message */ 589 527 min=owl_malloc(sizeof(owl_message)); 528 mout=owl_function_make_outgoing_loopback(msg); 529 530 if (owl_global_is_displayoutgoing(&g)) { 531 owl_global_messagequeue_addmsg(&g, mout); 532 } else { 533 owl_message_free(mout); 534 } 535 590 536 owl_message_create_loopback(min, msg); 591 537 owl_message_set_direction_in(min); 592 538 owl_global_messagequeue_addmsg(&g, min); 593 594 mout=owl_function_make_outgoing_loopback(msg);595 owl_log_message(mout);596 if (owl_global_is_displayoutgoing(&g)) {597 owl_function_add_message(mout);598 } else {599 owl_message_free(mout);600 }601 539 602 540 /* fake a makemsg */ -
global.c
ra387d12e r13a3c1db 779 779 * necessary. 780 780 */ 781 owl_message *owl_global_message uque_popmsg(owl_global *g)781 owl_message *owl_global_messagequeue_popmsg(owl_global *g) 782 782 { 783 783 owl_message *out; -
owl.c
rf178fb5 r13a3c1db 70 70 owl_popwin *pw; 71 71 int j, ret, initialsubs, debug, argcsave, followlast; 72 int newmsgs, zpendcount,nexttimediff;72 int newmsgs, nexttimediff; 73 73 struct sigaction sigact; 74 74 char *configfile, *tty, *perlout, *perlerr, **argvsave, buff[LINE], startupmsg[LINE]; … … 79 79 char *dir; 80 80 struct termios tio; 81 #ifdef HAVE_LIBZEPHYR 82 ZNotice_t notice; 83 #endif 81 owl_message *m; 84 82 #if OWL_STDERR_REDIR 85 83 int newstderr; … … 453 451 } 454 452 453 owl_zephyr_process_events(); 454 455 455 /* Grab incoming messages. */ 456 456 newmsgs=0; 457 zpendcount=0; 458 while(owl_zephyr_zpending() || owl_global_messagequeue_pending(&g)) { 459 #ifdef HAVE_LIBZEPHYR 460 struct sockaddr_in from; 461 #endif 462 owl_message *m=NULL; 463 owl_filter *f; 464 465 /* grab the new message, stick it in 'm' */ 466 if (owl_zephyr_zpending()) { 467 #ifdef HAVE_LIBZEPHYR 468 /* grab a zephyr notice, but if we've done 20 without stopping, 469 take a break to process keystrokes etc. */ 470 if (zpendcount>20) break; 471 ZReceiveNotice(¬ice, &from); 472 zpendcount++; 473 474 /* is this an ack from a zephyr we sent? */ 475 if (owl_zephyr_notice_is_ack(¬ice)) { 476 owl_zephyr_handle_ack(¬ice); 477 continue; 478 } 479 480 /* if it's a ping and we're not viewing pings then skip it */ 481 if (!owl_global_is_rxping(&g) && !strcasecmp(notice.z_opcode, "ping")) { 482 continue; 483 } 484 485 /* create the new message */ 486 m=owl_malloc(sizeof(owl_message)); 487 owl_message_create_from_znotice(m, ¬ice); 488 #endif 489 } else if (owl_global_messagequeue_pending(&g)) { 490 /* pick up the non-zephyr message in the message queue */ 491 m=owl_global_messageuque_popmsg(&g); 492 } else { 493 /* Not supposed to happen, but we seem to get here on resizes */ 494 owl_function_debugmsg("Bottomed out looking for zephyr"); 495 } 496 497 /* If we didn't pick up a message for some reason, don't go on */ 498 if (m==NULL) { 499 owl_function_debugmsg("m is null in main loop"); 500 continue; 501 } 502 503 /* if this message it on the puntlist, nuke it and continue */ 504 if (owl_global_message_is_puntable(&g, m)) { 505 owl_message_free(m); 506 continue; 507 } 508 509 /* login or logout that should be ignored? */ 510 if (owl_global_is_ignorelogins(&g) && owl_message_is_loginout(m)) { 511 owl_message_free(m); 512 continue; 513 } 514 515 /* otherwise add it to the global list */ 516 owl_messagelist_append_element(owl_global_get_msglist(&g), m); 517 newmsgs=1; 518 519 /* let the config know the new message has been received */ 520 owl_perlconfig_getmsg(m, 0, NULL); 521 522 /* add it to any necessary views; right now there's only the current view */ 523 owl_view_consider_message(owl_global_get_current_view(&g), m); 524 525 /* do we need to autoreply? */ 526 if (owl_global_is_zaway(&g) && !owl_message_get_attribute_value(m, "isauto")) { 527 if (owl_message_is_type_zephyr(m)) { 528 owl_zephyr_zaway(m); 529 } else if (owl_message_is_type_aim(m)) { 530 if (owl_message_is_private(m)) { 531 owl_function_send_aimawymsg(owl_message_get_sender(m), owl_global_get_zaway_msg(&g)); 532 } 533 } 534 } 535 536 /* ring the bell if it's a personal */ 537 if (!strcmp(owl_global_get_personalbell(&g), "on")) { 538 if (!owl_message_is_loginout(m) && 539 !owl_message_is_mail(m) && 540 owl_message_is_personal(m)) { 541 owl_function_beep(); 542 } 543 } else if (!strcmp(owl_global_get_personalbell(&g), "off")) { 544 /* do nothing */ 545 } else { 546 f=owl_global_get_filter(&g, owl_global_get_personalbell(&g)); 547 if (f && owl_filter_message_match(f, m)) { 548 owl_function_beep(); 549 } 550 } 551 552 553 /* if it matches the alert filter, do the alert action */ 554 f=owl_global_get_filter(&g, owl_global_get_alert_filter(&g)); 555 if (f && owl_filter_message_match(f, m)) { 556 owl_function_command(owl_global_get_alert_action(&g)); 557 } 558 559 /* if it's a zephyr login or logout, update the zbuddylist */ 560 if (owl_message_is_type_zephyr(m) && owl_message_is_loginout(m)) { 561 if (owl_message_is_login(m)) { 562 owl_zbuddylist_adduser(owl_global_get_zephyr_buddylist(&g), owl_message_get_sender(m)); 563 } else if (owl_message_is_logout(m)) { 564 owl_zbuddylist_deluser(owl_global_get_zephyr_buddylist(&g), owl_message_get_sender(m)); 565 } else { 566 owl_function_error("Internal error: received login notice that is neither login nor logout"); 567 } 568 } 569 570 /* check for burning ears message */ 571 /* this is an unsupported feature */ 572 if (owl_global_is_burningears(&g) && owl_message_is_burningears(m)) { 573 char *buff; 574 buff = owl_sprintf("@i(Burning ears message on class %s)", owl_message_get_class(m)); 575 owl_function_adminmsg(buff, ""); 576 owl_free(buff); 577 owl_function_beep(); 578 } 579 580 /* log the message if we need to */ 581 owl_log_message(m); 457 while(owl_global_messagequeue_pending(&g)) { 458 459 m = owl_global_messagequeue_popmsg(&g); 460 461 if(owl_process_message(m)) 462 newmsgs = 1; 582 463 } 583 464 … … 694 575 } 695 576 577 /* 578 * Process a new message passed to us on the message queue from some 579 * protocol. This includes adding it to the message list, updating the 580 * view and scrolling if appropriate, logging it, and so on. 581 * 582 * Either a pointer is kept to the message internally, or it is freed 583 * if unneeded. The caller no longer ``owns'' the message's memory. 584 * 585 * Returns 1 if the message was added to the message list, and 0 if it 586 * was ignored due to user settings or otherwise. 587 */ 588 int owl_process_message(owl_message *m) { 589 owl_filter *f; 590 /* if this message it on the puntlist, nuke it and continue */ 591 if (owl_global_message_is_puntable(&g, m)) { 592 owl_message_free(m); 593 return 0; 594 } 595 596 /* login or logout that should be ignored? */ 597 if (owl_global_is_ignorelogins(&g) 598 && owl_message_is_loginout(m)) { 599 owl_message_free(m); 600 return 0; 601 } 602 603 if (!owl_global_is_displayoutgoing(&g) 604 && owl_message_is_direction_out(m)) { 605 owl_message_free(m); 606 return 0; 607 } 608 609 /* add it to the global list */ 610 owl_messagelist_append_element(owl_global_get_msglist(&g), m); 611 /* add it to any necessary views; right now there's only the current view */ 612 owl_view_consider_message(owl_global_get_current_view(&g), m); 613 614 if(owl_message_is_direction_in(m)) { 615 /* let perl know about it*/ 616 owl_perlconfig_getmsg(m, 0, NULL); 617 618 /* do we need to autoreply? */ 619 if (owl_global_is_zaway(&g) && !owl_message_get_attribute_value(m, "isauto")) { 620 if (owl_message_is_type_zephyr(m)) { 621 owl_zephyr_zaway(m); 622 } else if (owl_message_is_type_aim(m)) { 623 if (owl_message_is_private(m)) { 624 owl_function_send_aimawymsg(owl_message_get_sender(m), owl_global_get_zaway_msg(&g)); 625 } 626 } 627 } 628 629 /* ring the bell if it's a personal */ 630 if (!strcmp(owl_global_get_personalbell(&g), "on")) { 631 if (!owl_message_is_loginout(m) && 632 !owl_message_is_mail(m) && 633 owl_message_is_personal(m)) { 634 owl_function_beep(); 635 } 636 } else if (!strcmp(owl_global_get_personalbell(&g), "off")) { 637 /* do nothing */ 638 } else { 639 f=owl_global_get_filter(&g, owl_global_get_personalbell(&g)); 640 if (f && owl_filter_message_match(f, m)) { 641 owl_function_beep(); 642 } 643 } 644 645 /* if it matches the alert filter, do the alert action */ 646 f=owl_global_get_filter(&g, owl_global_get_alert_filter(&g)); 647 if (f && owl_filter_message_match(f, m)) { 648 owl_function_command(owl_global_get_alert_action(&g)); 649 } 650 651 /* if it's a zephyr login or logout, update the zbuddylist */ 652 if (owl_message_is_type_zephyr(m) && owl_message_is_loginout(m)) { 653 if (owl_message_is_login(m)) { 654 owl_zbuddylist_adduser(owl_global_get_zephyr_buddylist(&g), owl_message_get_sender(m)); 655 } else if (owl_message_is_logout(m)) { 656 owl_zbuddylist_deluser(owl_global_get_zephyr_buddylist(&g), owl_message_get_sender(m)); 657 } else { 658 owl_function_error("Internal error: received login notice that is neither login nor logout"); 659 } 660 } 661 662 /* check for burning ears message */ 663 /* this is an unsupported feature */ 664 if (owl_global_is_burningears(&g) && owl_message_is_burningears(m)) { 665 char *buff; 666 buff = owl_sprintf("@i(Burning ears message on class %s)", owl_message_get_class(m)); 667 owl_function_adminmsg(buff, ""); 668 owl_free(buff); 669 owl_function_beep(); 670 } 671 } 672 673 /* log the message if we need to */ 674 owl_log_message(m); 675 676 return 1; 677 } 678 696 679 void sig_handler(int sig, siginfo_t *si, void *data) 697 680 { -
perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
r1fd5e4c1 r13a3c1db 860 860 my $m = j2o( $j, { direction => 'out' } ); 861 861 if ( $vars{jwrite}{type} ne 'groupchat') { 862 BarnOwl:: add_and_log_message($m);862 BarnOwl::queue_message($m); 863 863 } 864 864 -
perlglue.xs
ra695a68 r13a3c1db 129 129 } 130 130 131 void add_message(msg)132 SV *msg133 PREINIT:134 owl_message *m;135 CODE:136 {137 if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) {138 croak("Usage: BarnOwl::add_message($message)");139 }140 141 if (owl_global_is_displayoutgoing(&g)) {142 m = owl_perlconfig_hashref2message(msg);143 owl_function_add_message(m);144 }145 }146 147 void log_message(msg)148 SV *msg149 PREINIT:150 owl_message *m;151 CODE:152 {153 if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) {154 croak("Usage: BarnOwl::log_message($message)");155 }156 157 m = owl_perlconfig_hashref2message(msg);158 owl_log_message(m);159 owl_message_free(m);160 }161 162 void add_and_log_message(msg)163 SV *msg164 PREINIT:165 owl_message *m;166 CODE:167 {168 if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) {169 croak("Usage: BarnOwl::add_and_log_message($message)");170 }171 172 m = owl_perlconfig_hashref2message(msg);173 owl_log_message(m);174 if (owl_global_is_displayoutgoing(&g)) {175 owl_function_add_message(m);176 } else {177 owl_message_free(m);178 }179 }180 181 131 void admin_message(header, body) 182 132 char *header -
zephyr.c
r85d1795 r13a3c1db 638 638 /* display the message as an admin message in the receive window */ 639 639 mout=owl_function_make_outgoing_zephyr(owl_global_get_zaway_msg(&g), tmpbuff, "Automated reply:"); 640 owl_ function_add_message(mout);640 owl_global_messagequeue_addmsg(&g, mout); 641 641 owl_free(tmpbuff); 642 642 #endif … … 1054 1054 #endif 1055 1055 } 1056 1057 #ifdef HAVE_LIBZEPHYR 1058 void owl_zephyr_process_events() { 1059 int zpendcount=0; 1060 ZNotice_t notice; 1061 struct sockaddr_in from; 1062 owl_message *m=NULL; 1063 1064 while(owl_zephyr_zpending() && zpendcount < 20) { 1065 if (owl_zephyr_zpending()) { 1066 ZReceiveNotice(¬ice, &from); 1067 zpendcount++; 1068 1069 /* is this an ack from a zephyr we sent? */ 1070 if (owl_zephyr_notice_is_ack(¬ice)) { 1071 owl_zephyr_handle_ack(¬ice); 1072 continue; 1073 } 1074 1075 /* if it's a ping and we're not viewing pings then skip it */ 1076 if (!owl_global_is_rxping(&g) && !strcasecmp(notice.z_opcode, "ping")) { 1077 continue; 1078 } 1079 1080 /* create the new message */ 1081 m=owl_malloc(sizeof(owl_message)); 1082 owl_message_create_from_znotice(m, ¬ice); 1083 1084 owl_global_messagequeue_addmsg(&g, m); 1085 } 1086 } 1087 } 1088 1089 #else 1090 void owl_zephyr_process_events() { 1091 1092 } 1093 #endif
Note: See TracChangeset
for help on using the changeset viewer.