Changeset c453ada for commands.c


Ignore:
Timestamp:
May 31, 2008, 11:40:29 PM (13 years ago)
Author:
Geoffrey Thomas <geofft@mit.edu>
Branches:
barnowl_perlaim
Children:
7a1c90d
Parents:
b1fd36e
Message:
Remove aim.c. buddylist.c, buddy.c, libfaim, and everything that uses them.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    rb1fd36e rc453ada  
    122122              "      Send to the specified opcode\n"),
    123123
    124   OWLCMD_ARGS("aimwrite", owl_command_aimwrite, OWL_CTX_INTERACTIVE,
    125               "send an AIM message",
    126               "aimwrite <user> [-m <message...>]",
    127               "Send an aim message to a user.\n\n"
    128               "The following options are available:\n\n"
    129               "-m    Specifies a message to send without prompting.\n"),
    130 
    131124  OWLCMD_ARGS("loopwrite", owl_command_loopwrite, OWL_CTX_INTERACTIVE,
    132125              "send a loopback message",
     
    232225              "Execute the owl commands in <filename>.\n"),
    233226
    234   OWLCMD_ARGS("aim", owl_command_aim, OWL_CTX_INTERACTIVE,
    235               "AIM specific commands",
    236               "aim search <email>",
    237               ""),
    238 
    239227  OWLCMD_ARGS("addbuddy", owl_command_addbuddy, OWL_CTX_INTERACTIVE,
    240228              "add a buddy to a buddylist",
    241229              "addbuddy <protocol> <screenname>",
    242               "Add the named buddy to your buddylist.  <protocol> can be aim or zephyr\n"),
     230              "Add the named buddy to your buddylist.  <protocol> can be zephyr\n"),
    243231
    244232  OWLCMD_ARGS("delbuddy", owl_command_delbuddy, OWL_CTX_INTERACTIVE,
     
    246234              "delbuddy <protocol> <screenname>",
    247235              "Delete the named buddy from your buddylist.  <protocol> can be aim or zephyr\n"),
    248 
    249   OWLCMD_ARGS("join", owl_command_join, OWL_CTX_INTERACTIVE,
    250               "join a chat group",
    251               "join aim <groupname> [exchange]",
    252               "Join the AIM chatroom with 'groupname'.\n"),
    253236
    254237  OWLCMD_ARGS("smartzpunt", owl_command_smartzpunt, OWL_CTX_INTERACTIVE,
     
    306289              "znol [-f file]",
    307290              "Print a znol-style listing of users logged in"),
    308 
    309   OWLCMD_ARGS("alist", owl_command_alist, OWL_CTX_INTERACTIVE,
    310               "List AIM users logged in",
    311               "alist",
    312               "Print a listing of AIM users logged in"),
    313291
    314292  OWLCMD_ARGS("blist", owl_command_blist, OWL_CTX_INTERACTIVE,
     
    465443              "Turn on or off a zaway message.  If 'message' is\n"
    466444              "specified turn on zaway with that message, otherwise\n"
    467               "use the default.\n"),
    468 
    469   OWLCMD_ARGS("aaway", owl_command_aaway, OWL_CTX_INTERACTIVE,
    470               "Set, enable or disable AIM away message",
    471               "aaway [ on | off | toggle ]\n"
    472               "aaway <message>",
    473               "Turn on or off the AIM away message.  If 'message' is\n"
    474               "specified turn on aaway with that message, otherwise\n"
    475445              "use the default.\n"),
    476446
     
    530500              "    body       -  message body\n"
    531501              "    hostname   -  hostname of sending host\n"
    532               "    type       -  message type (zephyr, aim, admin)\n"
     502              "    type       -  message type (zephyr, admin...)\n"
    533503              "    direction  -  either 'in' 'out' or 'none'\n"
    534504              "    login      -  either 'login' 'logout' or 'none'\n"
     
    734704          "no argument, it makes search inactive."),
    735705
    736   OWLCMD_ARGS("aimlogin", owl_command_aimlogin, OWL_CTX_ANY,
    737               "login to an AIM account",
    738               "aimlogin <screenname> [<password>]\n",
    739               ""),
    740 
    741   OWLCMD_ARGS("aimlogout", owl_command_aimlogout, OWL_CTX_ANY,
    742               "logout from AIM",
    743               "aimlogout\n",
    744               ""),
    745 
    746706  OWLCMD_ARGS("error", owl_command_error, OWL_CTX_ANY,
    747707              "Display an error message",
     
    1015975}
    1016976
    1017 char *owl_command_alist()
    1018 {
    1019   owl_function_buddylist(1, 0, NULL);
    1020   return(NULL);
    1021 }
    1022 
    1023977char *owl_command_blist()
    1024978{
     
    1044998  sprintf(buff, "Owl version %s", OWL_VERSION_STRING);
    1045999  owl_function_makemsg(buff);
    1046 }
    1047 
    1048 char *owl_command_aim(int argc, char **argv, char *buff)
    1049 {
    1050   if (argc<2) {
    1051     owl_function_makemsg("not enough arguments to aim command");
    1052     return(NULL);
    1053   }
    1054 
    1055   if (!strcmp(argv[1], "search")) {
    1056     if (argc!=3) {
    1057       owl_function_makemsg("not enough arguments to aim search command");
    1058       return(NULL);
    1059     }
    1060     owl_aim_search(argv[2]);
    1061   } else {
    1062     owl_function_makemsg("unknown subcommand '%s' for aim command", argv[1]);
    1063     return(NULL);
    1064   }
    1065   return(NULL);
    10661000}
    10671001
     
    10731007  }
    10741008
    1075   if (!strcasecmp(argv[1], "aim")) {
    1076     if (!owl_global_is_aimloggedin(&g)) {
    1077       owl_function_makemsg("addbuddy: You must be logged into aim to use this command.");
    1078       return(NULL);
    1079     }
    1080     /*
    1081     owl_function_makemsg("This function is not yet operational.  Stay tuned.");
    1082     return(NULL);
    1083     */
    1084     owl_aim_addbuddy(argv[2]);
    1085     owl_function_makemsg("%s added as AIM buddy for %s", argv[2], owl_global_get_aim_screenname(&g));
    1086   } else if (!strcasecmp(argv[1], "zephyr")) {
     1009  /* TODO add a hook for perl modules */
     1010  if (!strcasecmp(argv[1], "zephyr")) {
    10871011    owl_zephyr_addbuddy(argv[2]);
    10881012    owl_function_makemsg("%s added as zephyr buddy", argv[2]);
    10891013  } else {
    1090     owl_function_makemsg("addbuddy: currently the only supported protocols are 'zephyr' and 'aim'");
     1014    owl_function_makemsg("addbuddy: currently the only supported protocol is 'zephyr'");
    10911015  }
    10921016
     
    11011025  }
    11021026
    1103   if (!strcasecmp(argv[1], "aim")) {
    1104     if (!owl_global_is_aimloggedin(&g)) {
    1105       owl_function_makemsg("delbuddy: You must be logged into aim to use this command.");
    1106       return(NULL);
    1107     }
    1108     owl_aim_delbuddy(argv[2]);
    1109     owl_function_makemsg("%s deleted as AIM buddy for %s", argv[2], owl_global_get_aim_screenname(&g));
    1110   } else if (!strcasecmp(argv[1], "zephyr")) {
     1027  /* TODO add a hook for perl modules */
     1028  if (!strcasecmp(argv[1], "zephyr")) {
    11111029    owl_zephyr_delbuddy(argv[2]);
    11121030    owl_function_makemsg("%s deleted as zephyr buddy", argv[2]);
    11131031  } else {
    1114     owl_function_makemsg("delbuddy: currently the only supported protocols are 'zephyr' and 'aim'");
    1115   }
    1116 
    1117   return(NULL);
    1118 }
    1119 
    1120 char *owl_command_join(int argc, char **argv, char *buff)
    1121 {
    1122   if (argc!=3 && argc!=4) {
    1123     owl_function_makemsg("usage: join <protocol> <buddyname> [exchange]");
    1124     return(NULL);
    1125   }
    1126 
    1127   if (!strcasecmp(argv[1], "aim")) {
    1128     if (!owl_global_is_aimloggedin(&g)) {
    1129       owl_function_makemsg("join aim: You must be logged into aim to use this command.");
    1130       return(NULL);
    1131     }
    1132     if (argc==3) {
    1133       owl_aim_chat_join(argv[2], 4);
    1134     } else {
    1135       owl_aim_chat_join(argv[2], atoi(argv[3]));
    1136     }
    1137     /* owl_function_makemsg("%s deleted as AIM buddy for %s", argv[2], owl_global_get_aim_screenname(&g)); */
    1138   } else {
    1139     owl_function_makemsg("join: currently the only supported protocol is 'aim'");
    1140   }
     1032    owl_function_makemsg("delbuddy: currently the only supported protocol is 'zephyr'");
     1033  }
     1034
    11411035  return(NULL);
    11421036}
     
    14211315
    14221316
    1423 char *owl_command_aaway(int argc, char **argv, char *buff)
    1424 {
     1317char *owl_command_away(int argc, char **argv, char *buff)
     1318{
     1319  /* TODO add a hook for perl modules */
    14251320  if ((argc==1) ||
    14261321      ((argc==2) && !strcmp(argv[1], "on"))) {
    1427     owl_global_set_aaway_msg(&g, owl_global_get_aaway_msg_default(&g));
    1428     owl_function_aaway_on();
     1322    owl_global_set_zaway_msg(&g, owl_global_get_zaway_msg_default(&g));
     1323    owl_function_zaway_on();
    14291324    return NULL;
    14301325  }
    14311326
    14321327  if (argc==2 && !strcmp(argv[1], "off")) {
    1433     owl_function_aaway_off();
    1434     return NULL;
    1435   }
    1436 
    1437   if (argc==2 && !strcmp(argv[1], "toggle")) {
    1438     owl_function_aaway_toggle();
    1439     return NULL;
    1440   }
    1441 
    1442   buff = skiptokens(buff, 1);
    1443   owl_global_set_aaway_msg(&g, buff);
    1444   owl_function_aaway_on();
    1445   return NULL;
    1446 }
    1447 
    1448 
    1449 char *owl_command_away(int argc, char **argv, char *buff)
    1450 {
    1451   if ((argc==1) ||
    1452       ((argc==2) && !strcmp(argv[1], "on"))) {
    1453     owl_global_set_aaway_msg(&g, owl_global_get_aaway_msg_default(&g));
    1454     owl_global_set_zaway_msg(&g, owl_global_get_zaway_msg_default(&g));
    1455     owl_function_aaway_on();
    1456     owl_function_zaway_on();
    1457     owl_function_makemsg("Away messages set.", owl_global_get_aaway_msg_default(&g));
    1458     return NULL;
    1459   }
    1460 
    1461   if (argc==2 && !strcmp(argv[1], "off")) {
    1462     owl_function_aaway_off();
    14631328    owl_function_zaway_off();
    14641329    return NULL;
     
    14691334     *  them both on)
    14701335     */
    1471     if (!owl_global_is_zaway(&g) && !owl_global_is_aaway(&g)) {
    1472       owl_function_aaway_toggle();
     1336    if (!owl_global_is_zaway(&g) /* && !owl_global_is_aaway(&g) */) {
    14731337      owl_function_zaway_toggle();
    14741338      owl_function_makemsg("Away messages set.");
    14751339    } else {
    14761340      if (owl_global_is_zaway(&g)) owl_function_zaway_toggle();
    1477       if (owl_global_is_aaway(&g)) owl_function_aaway_toggle();
    14781341      owl_function_makemsg("Away messages off.");
    14791342    }
     
    14821345
    14831346  buff = skiptokens(buff, 1);
    1484   owl_global_set_aaway_msg(&g, buff);
    14851347  owl_global_set_zaway_msg(&g, buff);
    1486   owl_function_aaway_on();
    14871348  owl_function_zaway_on();
    14881349  owl_function_makemsg("Away messages set.");
     
    18571718    owl_function_zwrite_setup(buff);
    18581719  }
    1859   return(NULL);
    1860 }
    1861 
    1862 char *owl_command_aimwrite(int argc, char **argv, char *buff)
    1863 {
    1864   char *newbuff, *recip, **myargv;
    1865   int i, j, myargc;
    1866   owl_message *m;
    1867  
    1868   if (!owl_global_is_aimloggedin(&g)) {
    1869     owl_function_makemsg("You are not logged in to AIM.");
    1870     return(NULL);
    1871   }
    1872 
    1873   if (argc < 2) {
    1874     owl_function_makemsg("Not enough arguments to the aimwrite command.");
    1875     return(NULL);
    1876   }
    1877 
    1878   myargv=argv;
    1879   if (argc<0) {
    1880     owl_function_error("Unbalanced quotes in aimwrite");
    1881     return(NULL);
    1882   }
    1883   myargc=argc;
    1884   if (myargc && *(myargv[0])!='-') {
    1885     myargc--;
    1886     myargv++;
    1887   }
    1888   while (myargc) {
    1889     if (!strcmp(myargv[0], "-m")) {
    1890       if (myargc<2) {
    1891         break;
    1892       }
    1893 
    1894       /* Once we have -m, gobble up everything else on the line */
    1895       myargv++;
    1896       myargc--;
    1897       newbuff=owl_malloc(1);
    1898       newbuff=owl_strdup("");
    1899       while (myargc) {
    1900         newbuff=realloc(newbuff, strlen(newbuff)+strlen(myargv[0])+5);
    1901         strcat(newbuff, myargv[0]);
    1902         strcat(newbuff, " ");
    1903         myargc--;
    1904         myargv++;
    1905       }
    1906       newbuff[strlen(newbuff)-1]='\0'; /* remove last space */
    1907 
    1908       recip=owl_malloc(strlen(argv[0])+5);
    1909       sprintf(recip, "%s ", argv[1]);
    1910       owl_aim_send_im(recip, newbuff);
    1911       m=owl_function_make_outgoing_aim(newbuff, recip);
    1912       if (m) {
    1913           owl_global_messagequeue_addmsg(&g, m);
    1914       } else {
    1915           owl_function_error("Could not create outgoing AIM message");
    1916       }
    1917 
    1918       owl_free(recip);
    1919       owl_free(newbuff);
    1920       return(NULL);
    1921     } else {
    1922       /* we don't care */
    1923       myargv++;
    1924       myargc--;
    1925     }
    1926   }
    1927 
    1928   /* squish arguments together to make one screenname w/o spaces for now */
    1929   newbuff=owl_malloc(strlen(buff)+5);
    1930   sprintf(newbuff, "%s ", argv[0]);
    1931   j=argc-1;
    1932   for (i=0; i<j; i++) {
    1933     strcat(newbuff, argv[i+1]);
    1934   }
    1935    
    1936   owl_function_aimwrite_setup(newbuff);
    1937   owl_free(newbuff);
    19381720  return(NULL);
    19391721}
     
    24992281}
    25002282
    2501 char *owl_command_aimlogin(int argc, char **argv, char *buff)
    2502 {
    2503   if ((argc<2) || (argc>3)) {
    2504     owl_function_makemsg("Wrong number of arguments to aimlogin command");
    2505     return(NULL);
    2506   }
    2507 
    2508   /* if we get two arguments, ask for the password */
    2509   if (argc==2) {
    2510     owl_global_set_buffercommand(&g, argv[1]);
    2511     owl_global_set_buffercallback(&g, &owl_callback_aimlogin);
    2512     owl_function_start_password("AIM Password: ");
    2513     return(NULL);
    2514   } else {
    2515     owl_function_aimlogin(argv[1], argv[2]);
    2516   }
    2517 
    2518   /* this is a test */
    2519   return(NULL);
    2520 }
    2521 
    2522 char *owl_command_aimlogout(int argc, char **argv, char *buff)
    2523 {
    2524   /* clear the buddylist */
    2525   owl_buddylist_clear(owl_global_get_buddylist(&g));
    2526 
    2527   owl_aim_logout();
    2528   return(NULL);
    2529 }
    2530 
    25312283char *owl_command_getstyle(int argc, char **argv, char *buff)
    25322284{
Note: See TracChangeset for help on using the changeset viewer.