Changeset c453ada for commands.c
- Timestamp:
- May 31, 2008, 11:40:29 PM (17 years ago)
- Branches:
- barnowl_perlaim
- Children:
- 7a1c90d
- Parents:
- b1fd36e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
commands.c
rb1fd36e rc453ada 122 122 " Send to the specified opcode\n"), 123 123 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 131 124 OWLCMD_ARGS("loopwrite", owl_command_loopwrite, OWL_CTX_INTERACTIVE, 132 125 "send a loopback message", … … 232 225 "Execute the owl commands in <filename>.\n"), 233 226 234 OWLCMD_ARGS("aim", owl_command_aim, OWL_CTX_INTERACTIVE,235 "AIM specific commands",236 "aim search <email>",237 ""),238 239 227 OWLCMD_ARGS("addbuddy", owl_command_addbuddy, OWL_CTX_INTERACTIVE, 240 228 "add a buddy to a buddylist", 241 229 "addbuddy <protocol> <screenname>", 242 "Add the named buddy to your buddylist. <protocol> can be aim orzephyr\n"),230 "Add the named buddy to your buddylist. <protocol> can be zephyr\n"), 243 231 244 232 OWLCMD_ARGS("delbuddy", owl_command_delbuddy, OWL_CTX_INTERACTIVE, … … 246 234 "delbuddy <protocol> <screenname>", 247 235 "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"),253 236 254 237 OWLCMD_ARGS("smartzpunt", owl_command_smartzpunt, OWL_CTX_INTERACTIVE, … … 306 289 "znol [-f file]", 307 290 "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"),313 291 314 292 OWLCMD_ARGS("blist", owl_command_blist, OWL_CTX_INTERACTIVE, … … 465 443 "Turn on or off a zaway message. If 'message' is\n" 466 444 "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"475 445 "use the default.\n"), 476 446 … … 530 500 " body - message body\n" 531 501 " hostname - hostname of sending host\n" 532 " type - message type (zephyr, a im, admin)\n"502 " type - message type (zephyr, admin...)\n" 533 503 " direction - either 'in' 'out' or 'none'\n" 534 504 " login - either 'login' 'logout' or 'none'\n" … … 734 704 "no argument, it makes search inactive."), 735 705 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 746 706 OWLCMD_ARGS("error", owl_command_error, OWL_CTX_ANY, 747 707 "Display an error message", … … 1015 975 } 1016 976 1017 char *owl_command_alist()1018 {1019 owl_function_buddylist(1, 0, NULL);1020 return(NULL);1021 }1022 1023 977 char *owl_command_blist() 1024 978 { … … 1044 998 sprintf(buff, "Owl version %s", OWL_VERSION_STRING); 1045 999 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);1066 1000 } 1067 1001 … … 1073 1007 } 1074 1008 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")) { 1087 1011 owl_zephyr_addbuddy(argv[2]); 1088 1012 owl_function_makemsg("%s added as zephyr buddy", argv[2]); 1089 1013 } else { 1090 owl_function_makemsg("addbuddy: currently the only supported protocol s are 'zephyr' and 'aim'");1014 owl_function_makemsg("addbuddy: currently the only supported protocol is 'zephyr'"); 1091 1015 } 1092 1016 … … 1101 1025 } 1102 1026 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")) { 1111 1029 owl_zephyr_delbuddy(argv[2]); 1112 1030 owl_function_makemsg("%s deleted as zephyr buddy", argv[2]); 1113 1031 } 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 1141 1035 return(NULL); 1142 1036 } … … 1421 1315 1422 1316 1423 char *owl_command_aaway(int argc, char **argv, char *buff) 1424 { 1317 char *owl_command_away(int argc, char **argv, char *buff) 1318 { 1319 /* TODO add a hook for perl modules */ 1425 1320 if ((argc==1) || 1426 1321 ((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(); 1429 1324 return NULL; 1430 1325 } 1431 1326 1432 1327 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();1463 1328 owl_function_zaway_off(); 1464 1329 return NULL; … … 1469 1334 * them both on) 1470 1335 */ 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) */) { 1473 1337 owl_function_zaway_toggle(); 1474 1338 owl_function_makemsg("Away messages set."); 1475 1339 } else { 1476 1340 if (owl_global_is_zaway(&g)) owl_function_zaway_toggle(); 1477 if (owl_global_is_aaway(&g)) owl_function_aaway_toggle();1478 1341 owl_function_makemsg("Away messages off."); 1479 1342 } … … 1482 1345 1483 1346 buff = skiptokens(buff, 1); 1484 owl_global_set_aaway_msg(&g, buff);1485 1347 owl_global_set_zaway_msg(&g, buff); 1486 owl_function_aaway_on();1487 1348 owl_function_zaway_on(); 1488 1349 owl_function_makemsg("Away messages set."); … … 1857 1718 owl_function_zwrite_setup(buff); 1858 1719 } 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);1938 1720 return(NULL); 1939 1721 } … … 2499 2281 } 2500 2282 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 2531 2283 char *owl_command_getstyle(int argc, char **argv, char *buff) 2532 2284 {
Note: See TracChangeset
for help on using the changeset viewer.