Changeset 6df57d4
- Timestamp:
- Sep 30, 2011, 8:23:17 AM (13 years ago)
- Children:
- 7483942
- Parents:
- 57ad328
- git-author:
- Jason Gross <jgross@mit.edu> (05/27/11 17:39:59)
- git-committer:
- Jason Gross <jgross@mit.edu> (09/30/11 08:23:17)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
commands.c
r7803326 r6df57d4 479 479 480 480 OWLCMD_ARGS("away", owl_command_away, OWL_CTX_INTERACTIVE, 481 "Set, enable or disable both AIM and zephyraway messages",481 "Set, enable or disable all away messages", 482 482 "away [ on | off | toggle ]\n" 483 483 "away <message>", 484 "Turn on or off the AIM and zephyr away message. If\n"484 "Turn on or off all away messages. If\n" 485 485 "'message' is specified turn them on with that message,\n" 486 486 "otherwise use the default.\n" 487 "\n"488 "This command really just runs the 'aaway' and 'zaway'\n"489 "commands together\n"490 487 "\n" 491 488 "SEE ALSO: aaway, zaway"), … … 1531 1528 char *owl_command_away(int argc, const char *const *argv, const char *buff) 1532 1529 { 1533 if ((argc==1) || 1534 ((argc==2) && !strcmp(argv[1], "on"))) { 1530 bool away_off; 1531 const char *message = NULL; 1532 1533 if (argc == 1 || 1534 (argc == 2 && !strcmp(argv[1], "on"))) { 1535 away_off = false; 1535 1536 owl_global_set_aaway_msg(&g, owl_global_get_aaway_msg_default(&g)); 1536 1537 owl_global_set_zaway_msg(&g, owl_global_get_zaway_msg_default(&g)); 1538 } else if (argc == 2 && !strcmp(argv[1], "off")) { 1539 away_off = true; 1540 } else if (argc == 2 && !strcmp(argv[1], "toggle")) { 1541 away_off = owl_function_is_away(); 1542 } else { 1543 away_off = false; 1544 message = skiptokens(buff, 1); 1545 } 1546 1547 if (away_off) { 1548 owl_function_aaway_off(); 1549 owl_function_zaway_off(); 1550 owl_perlconfig_perl_call_norv("BarnOwl::Hooks::_away_off", 0, NULL); 1551 owl_function_makemsg("Away messages off."); 1552 } else if (message != NULL) { 1553 owl_global_set_aaway_msg(&g, message); 1554 owl_global_set_zaway_msg(&g, message); 1537 1555 owl_function_aaway_on(); 1538 1556 owl_function_zaway_on(); 1557 owl_perlconfig_perl_call_norv("BarnOwl::Hooks::_away_on", 1, &message); 1558 owl_function_makemsg("Away messages set (%s).", message); 1559 } else { 1560 owl_function_aaway_on(); 1561 owl_function_zaway_on(); 1562 owl_perlconfig_perl_call_norv("BarnOwl::Hooks::_away_on", 0, NULL); 1539 1563 owl_function_makemsg("Away messages set."); 1540 return NULL; 1541 } 1542 1543 if (argc==2 && !strcmp(argv[1], "off")) { 1544 owl_function_aaway_off(); 1545 owl_function_zaway_off(); 1546 return NULL; 1547 } 1548 1549 if (argc==2 && !strcmp(argv[1], "toggle")) { 1550 /* if either one is on, turn it off, otherwise toggle both (turn 1551 * them both on) 1552 */ 1553 if (!owl_global_is_zaway(&g) && !owl_global_is_aaway(&g)) { 1554 owl_function_aaway_toggle(); 1555 owl_function_zaway_toggle(); 1556 owl_function_makemsg("Away messages set."); 1557 } else { 1558 if (owl_global_is_zaway(&g)) owl_function_zaway_toggle(); 1559 if (owl_global_is_aaway(&g)) owl_function_aaway_toggle(); 1560 owl_function_makemsg("Away messages off."); 1561 } 1562 return NULL; 1563 } 1564 1565 buff = skiptokens(buff, 1); 1566 owl_global_set_aaway_msg(&g, buff); 1567 owl_global_set_zaway_msg(&g, buff); 1568 owl_function_aaway_on(); 1569 owl_function_zaway_on(); 1570 owl_function_makemsg("Away messages set."); 1564 } 1565 1571 1566 return NULL; 1572 1567 } -
functions.c
r7803326 r6df57d4 992 992 } 993 993 994 bool owl_function_is_away(void) 995 { 996 return owl_global_is_zaway(&g) || 997 owl_global_is_aaway(&g) || 998 owl_perlconfig_perl_call_bool("BarnOwl::Hooks::_get_is_away", 0, NULL); 999 } 1000 994 1001 void owl_function_quit(void) 995 1002 { -
perl/lib/BarnOwl/Hooks.pm
rb8a3e00 r6df57d4 57 57 from every function registered with this hook will be appended and 58 58 displayed in a popup window, with zephyr formatting parsed. 59 60 =item $awayOn 61 62 Called, for all protocol handlers, to go away, with the away message, 63 if any. 64 65 =item $awayOff 66 67 Called, for all protocol handlers, to come back from away. 68 69 =item $getIsAway 70 71 Called to check away status for all protocol handlers. Protocol 72 handlers should return a true value if any account of the user is away 73 for the given protocol, and a false value otherwise. 59 74 60 75 =item $getQuickstart … … 75 90 $receiveMessage $newMessage 76 91 $mainLoop $getBuddyList 77 $getQuickstart); 92 $getQuickstart 93 $awayOn $awayOff $getIsAway); 78 94 79 95 our %EXPORT_TAGS = (all => [@EXPORT_OK]); … … 88 104 our $getBuddyList = BarnOwl::Hook->new; 89 105 our $getQuickstart = BarnOwl::Hook->new; 106 our $awayOn = BarnOwl::Hook->new; 107 our $awayOff = BarnOwl::Hook->new; 108 our $getIsAway = BarnOwl::Hook->new; 90 109 91 110 # Internal startup/shutdown routines called by the C code … … 201 220 } 202 221 222 sub _away_on { 223 $awayOn->run(@_); 224 } 225 226 sub _away_off { 227 $awayOff->run(); 228 } 229 230 sub _get_is_away { 231 my @is_away = grep { $_ } $getIsAway->run(); 232 return scalar @is_away; 233 } 234 203 235 sub _new_command { 204 236 my $command = shift; -
sepbar.c
r6eb3ed9 r6df57d4 67 67 } 68 68 69 if (owl_ global_is_zaway(&g) || owl_global_is_aaway(&g)) {69 if (owl_function_is_away()) { 70 70 getyx(sepwin, y, x); 71 71 wmove(sepwin, y, x+2); 72 72 wattron(sepwin, A_BOLD); 73 73 wattroff(sepwin, A_REVERSE); 74 if (owl_global_is_zaway(&g) && owl_global_is_aaway(&g)) { 75 waddstr(sepwin, " AWAY "); 76 } else if (owl_global_is_zaway(&g)) { 77 waddstr(sepwin, " Z-AWAY "); 78 } else if (owl_global_is_aaway(&g)) { 79 waddstr(sepwin, " A-AWAY "); 80 } 74 waddstr(sepwin, " AWAY "); 81 75 wattron(sepwin, A_REVERSE); 82 76 wattroff(sepwin, A_BOLD);
Note: See TracChangeset
for help on using the changeset viewer.