Changeset 7483942 for commands.c


Ignore:
Timestamp:
Jan 23, 2012, 5:30:46 PM (12 years ago)
Author:
GitHub Merge Button <merge-button@github.com>
Parents:
d126a19 (diff), 6df57d4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge 6df57d4264483d81d678c5981c422da79199945e into d126a19eb5f8a883b722fb26d21fb7b62b2aedeb
File:
1 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    rf89cc6f r7483942  
    479479
    480480  OWLCMD_ARGS("away", owl_command_away, OWL_CTX_INTERACTIVE,
    481               "Set, enable or disable both AIM and zephyr away messages",
     481              "Set, enable or disable all away messages",
    482482              "away [ on | off | toggle ]\n"
    483483              "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"
    485485              "'message' is specified turn them on with that message,\n"
    486486              "otherwise use the default.\n"
    487               "\n"
    488               "This command really just runs the 'aaway' and 'zaway'\n"
    489               "commands together\n"
    490487              "\n"
    491488              "SEE ALSO: aaway, zaway"),
     
    15311528char *owl_command_away(int argc, const char *const *argv, const char *buff)
    15321529{
    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;
    15351536    owl_global_set_aaway_msg(&g, owl_global_get_aaway_msg_default(&g));
    15361537    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);
    15371555    owl_function_aaway_on();
    15381556    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);
    15391563    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
    15711566  return NULL;
    15721567}
Note: See TracChangeset for help on using the changeset viewer.