Changeset c453ada
- Timestamp:
- May 31, 2008, 11:40:29 PM (16 years ago)
- Branches:
- barnowl_perlaim
- Children:
- 7a1c90d
- Parents:
- b1fd36e
- Files:
-
- 47 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile.in
r84d48cc rc453ada 10 10 11 11 CC=@CC@ 12 LIBS=@LIBS@ -L./libfaim -lfaim13 CFLAGS=@CFLAGS@ - I. -I./libfaim -DDATADIR=\"${datadir}\" -DOWL_SVN_REVNO=$(shell ./svkversion)12 LIBS=@LIBS@ 13 CFLAGS=@CFLAGS@ -DDATADIR=\"${datadir}\" -DOWL_SVN_REVNO=$(shell ./svkversion) 14 14 LDFLAGS=@LDFLAGS@ 15 15 XSUBPPDIR=@XSUBPPDIR@ … … 25 25 regex.c history.c view.c dict.c variable.c filterelement.c pair.c \ 26 26 keypress.c keymap.c keybinding.c cmd.c context.c zcrypt.c \ 27 aim.c buddy.c buddylist.ctimer.c style.c errqueue.c \27 timer.c style.c errqueue.c \ 28 28 zbuddylist.c muxevents.c popexec.c obarray.c select.c wcwidth.c \ 29 29 glib_compat.c … … 50 50 all: $(EXE) $(MODULE_DIRS) 51 51 52 $(EXE): $(AUTOGEN) $(OBJS) owl.o libfaim52 $(EXE): $(AUTOGEN) $(OBJS) owl.o 53 53 $(ATHSTATIC) $(CC) -o $(EXE) owl.o $(OBJS) $(LDFLAGS) $(LIBS) 54 54 … … 67 67 ./tester reg 68 68 69 clean: libfaimcleanmodules_clean69 clean: modules_clean 70 70 $(RM) $(EXE) tester *.o $(AUTOGEN) owl_prototypes.h.new 71 71 72 distclean: clean libfaimdistclean72 distclean: clean 73 73 $(RM) config.cache config.log config.status Makefile config.h TAGS *~ core 74 74 … … 116 116 $(BASE_OBJS) varstubs.h: owl.h config.h owl_prototypes.h 117 117 118 libfaim: libfaim/libfaim.a119 120 libfaim/libfaim.a:121 (cd libfaim; $(MAKE))122 123 libfaimclean:124 (cd libfaim; $(MAKE) clean)125 126 libfaimdistclean:127 (cd libfaim; $(MAKE) distclean)128 129 118 install: all installdirs 130 119 ${INSTALL_PROGRAM} $(EXE) ${DESTDIR}${bindir}/$(EXE) -
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 { -
configure.ac
rd9337637 rc453ada 126 126 AC_PROG_INSTALL 127 127 128 AC_CONFIG_SUBDIRS(libfaim)129 130 128 AC_OUTPUT(Makefile) -
functions.c
rb1fd36e rc453ada 211 211 } 212 212 213 /* Create an outgoing AIM message, returns a pointer to the created214 * message or NULL if we're not logged into AIM (and thus unable to215 * create the message). Does not put it on the global queue. Use216 * owl_function_add_message() for that .217 */218 owl_message *owl_function_make_outgoing_aim(char *body, char *to)219 {220 owl_message *m;221 222 /* error if we're not logged into aim */223 if (!owl_global_is_aimloggedin(&g)) return(NULL);224 225 m=owl_malloc(sizeof(owl_message));226 owl_message_create_aim(m,227 owl_global_get_aim_screenname(&g),228 to,229 body,230 OWL_MESSAGE_DIRECTION_OUT,231 0);232 return(m);233 }234 235 213 /* Create an outgoing loopback message and return a pointer to it. 236 214 * Does not append it to the global queue, use … … 292 270 owl_global_set_buffercommand(&g, line); 293 271 owl_global_set_buffercallback(&g, &owl_callback_zwrite); 294 }295 296 void owl_function_aimwrite_setup(char *line)297 {298 owl_editwin *e;299 char buff[1024];300 301 /* check the arguments */302 303 /* create and setup the editwin */304 e=owl_global_get_typwin(&g);305 owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE, owl_global_get_msg_history(&g));306 307 if (!owl_global_get_lockout_ctrld(&g)) {308 owl_function_makemsg("Type your message below. End with ^D or a dot on a line by itself. ^C will quit.");309 } else {310 owl_function_makemsg("Type your message below. End with a dot on a line by itself. ^C will quit.");311 }312 313 owl_editwin_clear(e);314 owl_editwin_set_dotsend(e);315 strcpy(buff, "----> ");316 strcat(buff, line);317 strcat(buff, "\n");318 owl_editwin_set_locktext(e, buff);319 320 /* make it active */321 owl_global_set_typwin_active(&g);322 323 owl_global_set_buffercommand(&g, line);324 owl_global_set_buffercallback(&g, &owl_callback_aimwrite);325 272 } 326 273 … … 449 396 owl_free(cryptmsg); 450 397 owl_zwrite_free(&z); 451 }452 453 void owl_callback_aimwrite(owl_editwin *e) {454 owl_function_aimwrite(owl_editwin_get_command(e),455 owl_editwin_get_text(e));456 }457 458 void owl_function_aimwrite(char *line, char *msg)459 {460 int ret;461 char *to, *format_msg;462 owl_message *m;463 464 to = line + 9;465 466 /* make a formatted copy of the message */467 format_msg=owl_strdup(msg);468 owl_text_wordunwrap(format_msg);469 470 /* send the message */471 ret=owl_aim_send_im(to, format_msg);472 if (!ret) {473 owl_function_makemsg("AIM message sent.");474 } else {475 owl_function_error("Could not send AIM message.");476 }477 478 /* create the outgoing message */479 m=owl_function_make_outgoing_aim(msg, to);480 481 if (m) {482 owl_global_messagequeue_addmsg(&g, m);483 } else {484 owl_function_error("Could not create outgoing AIM message");485 }486 487 owl_free(format_msg);488 }489 490 void owl_function_send_aimawymsg(char *to, char *msg)491 {492 int ret;493 char *format_msg;494 owl_message *m;495 496 /* make a formatted copy of the message */497 format_msg=owl_strdup(msg);498 owl_text_wordunwrap(format_msg);499 500 /* send the message */501 ret=owl_aim_send_awaymsg(to, format_msg);502 if (!ret) {503 /* owl_function_makemsg("AIM message sent."); */504 } else {505 owl_function_error("Could not send AIM message.");506 }507 508 /* create the message */509 m=owl_function_make_outgoing_aim(msg, to);510 if (m) {511 owl_global_messagequeue_addmsg(&g, m);512 } else {513 owl_function_error("Could not create AIM message");514 }515 owl_free(format_msg);516 398 } 517 399 … … 895 777 } 896 778 897 void owl_callback_aimlogin(owl_editwin *e) {898 owl_function_aimlogin(owl_editwin_get_command(e),899 owl_editwin_get_text(e));900 }901 902 void owl_function_aimlogin(char *user, char *passwd) {903 int ret;904 905 /* clear the buddylist */906 owl_buddylist_clear(owl_global_get_buddylist(&g));907 908 /* try to login */909 ret=owl_aim_login(user, passwd);910 if (ret) owl_function_makemsg("Warning: login for %s failed.\n", user);911 }912 913 779 void owl_function_suspend() 914 780 { … … 943 809 } 944 810 945 void owl_function_aaway_toggle()946 {947 if (!owl_global_is_aaway(&g)) {948 owl_global_set_aaway_msg(&g, owl_global_get_aaway_msg_default(&g));949 owl_function_aaway_on();950 } else {951 owl_function_aaway_off();952 }953 }954 955 void owl_function_aaway_on()956 {957 owl_global_set_aaway_on(&g);958 /* owl_aim_set_awaymsg(owl_global_get_zaway_msg(&g)); */959 owl_function_makemsg("AIM away set (%s)", owl_global_get_aaway_msg(&g));960 }961 962 void owl_function_aaway_off()963 {964 owl_global_set_aaway_off(&g);965 /* owl_aim_set_awaymsg(""); */966 owl_function_makemsg("AIM away off");967 }968 969 811 void owl_function_quit() 970 812 { … … 988 830 owl_zephyr_shutdown(); 989 831 990 /* Quit AIM */991 if (owl_global_is_aimloggedin(&g)) {992 owl_aim_logout();993 }994 995 832 /* done with curses */ 996 833 endwin(); … … 1948 1785 owl_fmtext_append_normal(&fm, "no\n"); 1949 1786 } 1950 owl_fmtext_append_normal(&fm, " AIM included : yes\n");1787 owl_fmtext_append_normal(&fm, " AIM included : no\n"); 1951 1788 owl_fmtext_append_normal(&fm, " Loopback included : yes\n"); 1952 1789 … … 1960 1797 #endif 1961 1798 1962 1963 owl_fmtext_append_normal(&fm, "\nAIM Status:\n");1964 owl_fmtext_append_normal(&fm, " Logged in: ");1965 if (owl_global_is_aimloggedin(&g)) {1966 owl_fmtext_append_normal(&fm, owl_global_get_aim_screenname(&g));1967 owl_fmtext_append_normal(&fm, "\n");1968 } else {1969 owl_fmtext_append_normal(&fm, "(not logged in)\n");1970 }1971 1972 owl_fmtext_append_normal(&fm, " Processing events: ");1973 if (owl_global_is_doaimevents(&g)) {1974 owl_fmtext_append_normal(&fm, "yes\n");1975 } else {1976 owl_fmtext_append_normal(&fm, "no\n");1977 }1978 1799 1979 1800 owl_function_popless_fmtext(&fm); … … 2120 1941 if (cc) owl_free(cc); 2121 1942 } 2122 } else if (owl_message_is_type_aim(m)) {2123 /* aim */2124 if (owl_message_is_direction_out(m)) {2125 buff=owl_sprintf("aimwrite %s", owl_message_get_recipient(m));2126 } else {2127 buff=owl_sprintf("aimwrite %s", owl_message_get_sender(m));2128 }2129 1943 } else { 2130 1944 char *cmd; … … 2676 2490 owl_free(longuser); 2677 2491 owl_free(shortuser); 2678 2679 return(filtname);2680 }2681 2682 /* Create a filter for AIM IM messages to or from the specified2683 * screenname. The name of the filter will be 'aimuser-<user>'. If a2684 * filter already exists with this name, no new filter will be2685 * created. This allows the configuration to override this function.2686 * Returns the name of the filter, which the caller must free.2687 */2688 char *owl_function_aimuserfilt(char *user)2689 {2690 owl_filter *f;2691 char *argbuff, *filtname;2692 char *escuser;2693 2694 /* name for the filter */2695 filtname=owl_malloc(strlen(user)+40);2696 sprintf(filtname, "aimuser-%s", user);2697 2698 /* if it already exists then go with it. This lets users override */2699 if (owl_global_get_filter(&g, filtname)) {2700 return(owl_strdup(filtname));2701 }2702 2703 /* create the new-internal filter */2704 f=owl_malloc(sizeof(owl_filter));2705 2706 escuser = owl_text_quote(user, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);2707 2708 argbuff=owl_malloc(1000);2709 sprintf(argbuff,2710 "( type ^aim$ and ( ( sender ^%s$ and recipient ^%s$ ) or ( sender ^%s$ and recipient ^%s$ ) ) )",2711 escuser, owl_global_get_aim_screenname_for_filters(&g),2712 owl_global_get_aim_screenname_for_filters(&g), escuser);2713 2714 owl_filter_init_fromstring(f, filtname, argbuff);2715 2716 /* add it to the global list */2717 owl_global_add_filter(&g, f);2718 2719 /* free stuff */2720 owl_free(argbuff);2721 owl_free(escuser);2722 2492 2723 2493 return(filtname); … … 2812 2582 if (owl_message_is_type_loopback(m)) { 2813 2583 return(owl_function_typefilt("loopback")); 2814 }2815 2816 /* aim messages */2817 if (owl_message_is_type_aim(m)) {2818 if (owl_message_is_direction_in(m)) {2819 filtname=owl_function_aimuserfilt(owl_message_get_sender(m));2820 } else if (owl_message_is_direction_out(m)) {2821 filtname=owl_function_aimuserfilt(owl_message_get_recipient(m));2822 }2823 return(filtname);2824 2584 } 2825 2585 … … 3257 3017 void owl_function_buddylist(int aim, int zephyr, char *filename) 3258 3018 { 3259 int i, j, x , idle;3019 int i, j, x; 3260 3020 owl_fmtext fm; 3261 owl_buddylist *bl;3262 owl_buddy *b;3263 3021 owl_list anyone; 3264 char *foo, *timestr;3265 3022 #ifdef HAVE_LIBZEPHYR 3266 3023 char *tmp, *user, *line; … … 3271 3028 owl_fmtext_init_null(&fm); 3272 3029 3273 /* AIM first */ 3274 if (aim && owl_global_is_aimloggedin(&g)) { 3275 bl=owl_global_get_buddylist(&g); 3276 3277 owl_fmtext_append_bold(&fm, "AIM users logged in:\n"); 3278 /* we're assuming AIM for now */ 3279 j=owl_buddylist_get_size(bl); 3280 for (i=0; i<j; i++) { 3281 b=owl_buddylist_get_buddy_n(bl, i); 3282 idle=owl_buddy_get_idle_time(b); 3283 if (idle!=0) { 3284 timestr=owl_util_minutes_to_timestr(idle); 3285 } else { 3286 timestr=owl_strdup(""); 3287 } 3288 foo=owl_sprintf(" %-20.20s %-12.12s\n", owl_buddy_get_name(b), timestr); 3289 owl_fmtext_append_normal(&fm, foo); 3290 owl_free(timestr); 3291 owl_free(foo); 3292 } 3293 } 3030 if (aim && !zephyr) 3031 owl_fmtext_append_normal(&fm, "Warning: AIM support in C has been disabled.\n"); 3294 3032 3295 3033 #ifdef HAVE_LIBZEPHYR -
glib_compat.c
rc60ade2 rc453ada 1 #include <owl.h>1 #include "owl.h" 2 2 3 3 #if (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 14) -
global.c
r9f4e3f8 rc453ada 97 97 owl_popwin_init(&(g->pw)); 98 98 99 g->aim_screenname=NULL;100 g->aim_screenname_for_filters=NULL;101 g->aim_loggedin=0;102 owl_timer_create_countdown(&(g->aim_noop_timer), 30);103 owl_timer_create_countdown(&(g->aim_ignorelogin_timer), 0);104 owl_timer_create_countdown(&(g->aim_buddyinfo_timer), 60);105 owl_buddylist_init(&(g->buddylist));106 107 99 g->havezephyr=0; 108 g->haveaim=0;109 owl_global_set_no_doaimevents(g);110 100 111 101 owl_errqueue_init(&(g->errqueue)); … … 733 723 } 734 724 735 /* AIM stuff */736 737 int owl_global_is_aimloggedin(owl_global *g)738 {739 if (g->aim_loggedin) return(1);740 return(0);741 }742 743 char *owl_global_get_aim_screenname(owl_global *g)744 {745 if (owl_global_is_aimloggedin(g)) {746 return (g->aim_screenname);747 }748 return("");749 }750 751 char *owl_global_get_aim_screenname_for_filters(owl_global *g)752 {753 if (owl_global_is_aimloggedin(g)) {754 return (g->aim_screenname_for_filters);755 }756 return("");757 }758 759 void owl_global_set_aimloggedin(owl_global *g, char *screenname)760 {761 char *sn_escaped, *quote;762 g->aim_loggedin=1;763 if (g->aim_screenname) owl_free(g->aim_screenname);764 if (g->aim_screenname_for_filters) owl_free(g->aim_screenname_for_filters);765 g->aim_screenname=owl_strdup(screenname);766 sn_escaped = owl_text_quote(screenname, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);767 quote = owl_getquoting(sn_escaped);768 g->aim_screenname_for_filters=owl_sprintf("%s%s%s", quote, sn_escaped, quote);769 owl_free(sn_escaped);770 }771 772 void owl_global_set_aimnologgedin(owl_global *g)773 {774 g->aim_loggedin=0;775 }776 777 int owl_global_is_doaimevents(owl_global *g)778 {779 if (g->aim_doprocessing) return(1);780 return(0);781 }782 783 void owl_global_set_doaimevents(owl_global *g)784 {785 g->aim_doprocessing=1;786 }787 788 void owl_global_set_no_doaimevents(owl_global *g)789 {790 g->aim_doprocessing=0;791 }792 793 aim_session_t *owl_global_get_aimsess(owl_global *g)794 {795 return(&(g->aimsess));796 }797 798 aim_conn_t *owl_global_get_bosconn(owl_global *g)799 {800 return(&(g->bosconn));801 }802 803 void owl_global_set_bossconn(owl_global *g, aim_conn_t *conn)804 {805 g->bosconn=*conn;806 }807 808 int owl_global_is_aimnop_time(owl_global *g)809 {810 if (owl_timer_is_expired(&(g->aim_noop_timer))) return(1);811 return(0);812 }813 814 void owl_global_aimnop_sent(owl_global *g)815 {816 owl_timer_reset(&(g->aim_noop_timer));817 }818 819 owl_timer *owl_global_get_aim_login_timer(owl_global *g)820 {821 return(&(g->aim_ignorelogin_timer));822 }823 824 725 /* message queue */ 825 726 … … 883 784 } 884 785 885 void owl_global_set_haveaim(owl_global *g)886 {887 g->haveaim=1;888 }889 890 int owl_global_is_haveaim(owl_global *g)891 {892 if (g->haveaim) return(1);893 return(0);894 }895 896 786 void owl_global_set_havezephyr(owl_global *g) 897 787 { … … 903 793 if (g->havezephyr) return(1); 904 794 return(0); 905 }906 907 owl_timer *owl_global_get_aim_buddyinfo_timer(owl_global *g)908 {909 return(&(g->aim_buddyinfo_timer));910 795 } 911 796 -
help.c
rec53338 rc453ada 50 50 "\n" 51 51 " z Start a zwrite command\n" 52 " a Start an aimwrite command\n"53 52 " r Reply to the current message\n" 54 53 " R Reply to sender\n" … … 85 84 "\n" 86 85 " zwrite Send a zephyr\n" 87 " aimlogin Login to AIM\n" 88 " aimwrite Send an AIM message\n" 89 "\n" 90 " addbuddy Add a zephyr or AIM buddy\n" 86 " addbuddy Add a zephyr buddy\n" 91 87 " zaway Turn zaway on or off, or set the message\n" 92 88 " zlocate Locate a user\n" 93 89 " subscribe Subscribe to a zephyr class or instance\n" 94 90 " unsubscribe Unsubscribe to a zephyr class or instance\n" 95 " blist Print a list of zephyr and AIMbuddies logged in\n"91 " blist Print a list of zephyr buddies logged in\n" 96 92 " search Search for a text string\n" 97 93 "\n" … … 107 103 " zlog Send a login or logout notification\n" 108 104 " zlist Print a list of zephyr buddies logged in\n" 109 " alist Print a list of AIM buddies logged in\n"110 105 " info Print detailed information about the current message\n" 111 106 " filter Create a message filter\n" -
keys.c
rdb0ac7e rc453ada 276 276 277 277 BIND_CMD("z", "start-command zwrite ", "start a zwrite command"); 278 BIND_CMD("a", "start-command aimwrite ", "start an aimwrite command");279 278 BIND_CMD("r", "reply", "reply to the current message"); 280 279 BIND_CMD("R", "reply sender", "reply to sender of the current message"); -
logging.c
ree310eb rc453ada 87 87 } 88 88 89 void owl_log_aim(owl_message *m, FILE *file) {90 fprintf(file, "From: <%s> To: <%s>\n", owl_message_get_sender(m), owl_message_get_recipient(m));91 fprintf(file, "Time: %s\n\n", owl_message_get_timestr(m));92 if (owl_message_is_login(m))93 fprintf(file, "LOGIN\n\n");94 else if (owl_message_is_logout(m))95 fprintf(file, "LOGOUT\n\n");96 else97 fprintf(file, "%s\n\n", owl_message_get_body(m));98 }99 100 89 void owl_log_jabber(owl_message *m, FILE *file) { 101 90 fprintf(file, "From: <%s> To: <%s>\n",owl_message_get_sender(m), owl_message_get_recipient(m)); … … 121 110 } else if (owl_message_is_type_jabber(m)) { 122 111 owl_log_jabber(m, file); 123 } else if (owl_message_is_type_aim(m)) {124 owl_log_aim(m, file);125 112 } else { 126 113 owl_log_generic(m, file); … … 154 141 } else if (owl_message_is_type_jabber(m)) { 155 142 to = owl_sprintf("jabber:%s", owl_message_get_recipient(m)); 156 } else if (owl_message_is_type_aim(m)) {157 char *temp2;158 temp = owl_aim_normalize_screenname(owl_message_get_recipient(m));159 temp2 = g_utf8_strdown(temp,-1);160 to = owl_sprintf("aim:%s", temp2);161 owl_free(temp2);162 owl_free(temp);163 143 } else { 164 144 to = owl_sprintf("loopback"); … … 267 247 from=frombuff=owl_strdup(owl_message_get_class(m)); 268 248 } 269 } else if (owl_message_is_type_aim(m)) {270 /* we do not yet handle chat rooms */271 char *normalto, *temp;272 temp = owl_aim_normalize_screenname(owl_message_get_sender(m));273 normalto = g_utf8_strdown(temp, -1);274 from=frombuff=owl_sprintf("aim:%s", normalto);275 owl_free(normalto);276 owl_free(temp);277 249 } else if (owl_message_is_type_loopback(m)) { 278 250 from=frombuff=owl_strdup("loopback"); -
message.c
r07bfbc2 rc453ada 575 575 } 576 576 577 int owl_message_is_from_me(owl_message *m)578 {579 if (owl_message_is_type_zephyr(m)) {580 if (!strcasecmp(owl_message_get_sender(m), owl_zephyr_get_sender())) {581 return(1);582 } else {583 return(0);584 }585 } else if (owl_message_is_type_aim(m)) {586 if (!strcasecmp(owl_message_get_sender(m), owl_global_get_aim_screenname(&g))) {587 return(1);588 } else {589 return(0);590 }591 } else if (owl_message_is_type_admin(m)) {592 return(0);593 }594 return(0);595 }596 597 577 int owl_message_is_mail(owl_message *m) 598 578 { … … 615 595 return(0); 616 596 } 617 }618 return(0);619 }620 621 int owl_message_is_burningears(owl_message *m)622 {623 /* we should add a global to cache the short zsender */624 char sender[LINE], *ptr;625 626 /* if the message is from us or to us, it doesn't count */627 if (owl_message_is_from_me(m) || owl_message_is_private(m)) return(0);628 629 if (owl_message_is_type_zephyr(m)) {630 strcpy(sender, owl_zephyr_get_sender());631 ptr=strchr(sender, '@');632 if (ptr) *ptr='\0';633 } else if (owl_message_is_type_aim(m)) {634 strcpy(sender, owl_global_get_aim_screenname(&g));635 } else {636 return(0);637 }638 639 if (stristr(owl_message_get_body(m), sender)) {640 return(1);641 597 } 642 598 return(0); -
owl.c
rb1fd36e rc453ada 183 183 owl_function_debugmsg("startup: first available debugging message"); 184 184 owl_global_set_startupargs(&g, argcsave, argvsave); 185 owl_global_set_haveaim(&g);186 185 187 186 /* prepare stdin dispatch */ … … 300 299 owl_function_debugmsg("startup: setting the current view"); 301 300 owl_view_create(owl_global_get_current_view(&g), "main", f, owl_global_get_style_by_name(&g, "default")); 302 303 /* AIM init */304 owl_function_debugmsg("startup: doing AIM initialization");305 owl_aim_init();306 301 307 302 /* execute the startup function in the configfile */ … … 564 559 if (owl_message_is_type_zephyr(m)) { 565 560 owl_zephyr_zaway(m); 566 } else if (owl_message_is_type_aim(m)) { 567 if (owl_message_is_private(m)) { 568 owl_function_send_aimawymsg(owl_message_get_sender(m), owl_global_get_zaway_msg(&g)); 569 } 570 } 561 } 562 /* TODO add perl hooks for away messages */ 571 563 } 572 564 … … 609 601 610 602 return 1; 611 }612 613 void owl_process_aim()614 {615 if (owl_global_is_doaimevents(&g)) {616 owl_aim_process_events();617 618 if (owl_global_is_aimloggedin(&g)) {619 if (owl_timer_is_expired(owl_global_get_aim_buddyinfo_timer(&g))) {620 /* owl_buddylist_request_idletimes(owl_global_get_buddylist(&g)); */621 owl_timer_reset(owl_global_get_aim_buddyinfo_timer(&g));622 }623 }624 }625 603 } 626 604 -
owl.h
rd7a3188 rc453ada 20 20 #include <signal.h> 21 21 #include <termios.h> 22 #include <libfaim/aim.h>23 22 #include <wchar.h> 23 #include <unistd.h> 24 #include <string.h> 25 #include <errno.h> 24 26 #include "config.h" 25 27 #include "glib.h" … … 36 38 /* logout is defined in FreeBSD. */ 37 39 #define logout logout_ 38 /* aim.h defines bool */39 #define HAS_BOOL40 40 #include <perl.h> 41 41 #include "owl_perl.h" … … 56 56 57 57 #ifndef OWL_VERSION_STRING 58 #define OWL_VERSION_STRING "1.0.1 "58 #define OWL_VERSION_STRING "1.0.1-perlaim-r" BARNOWL_STRINGIFY(OWL_SVN_REVNO) 59 59 #endif 60 60 … … 583 583 int malloced, freed; 584 584 char *searchstring; 585 aim_session_t aimsess;586 aim_conn_t bosconn;587 owl_timer aim_noop_timer;588 owl_timer aim_ignorelogin_timer;589 owl_timer aim_buddyinfo_timer;590 int aim_loggedin; /* true if currently logged into AIM */591 int aim_doprocessing; /* true if we should process AIM events (like pending login) */592 char *aim_screenname; /* currently logged in AIM screen name */593 char *aim_screenname_for_filters; /* currently logged in AIM screen name */594 585 owl_buddylist buddylist; /* list of logged in AIM buddies */ 595 586 owl_list messagequeue; /* for queueing up aim and other messages */ … … 597 588 char *response; /* response to the last question asked */ 598 589 int havezephyr; 599 int haveaim;600 590 int got_err_signal; /* 1 if we got an unexpected signal */ 601 591 siginfo_t err_signal_info; -
select.c
r2f69081 rc453ada 148 148 } 149 149 150 int owl_select_aim_hack(fd_set *rfds, fd_set *wfds)151 {152 aim_conn_t *cur;153 aim_session_t *sess;154 int max_fd;155 156 FD_ZERO(rfds);157 FD_ZERO(wfds);158 max_fd = 0;159 sess = owl_global_get_aimsess(&g);160 for (cur = sess->connlist, max_fd = 0; cur; cur = cur->next) {161 if (cur->fd != -1) {162 FD_SET(cur->fd, rfds);163 if (cur->status & AIM_CONN_STATUS_INPROGRESS) {164 /* Yes, we're checking writable sockets here. Without it, AIM165 login is really slow. */166 FD_SET(cur->fd, wfds);167 }168 169 if (cur->fd > max_fd)170 max_fd = cur->fd;171 }172 }173 return max_fd;174 }175 176 150 void owl_select() 177 151 { 178 int i, max_fd, aim_max_fd, aim_done;152 int max_fd; 179 153 fd_set r; 180 154 fd_set e; 181 fd_set aim_rfds, aim_wfds;182 155 struct timeval timeout; 183 156 … … 187 160 max_fd = owl_select_dispatch_prepare_fd_sets(&r, &e); 188 161 189 /* AIM HACK: 190 * 191 * The problem - I'm not sure where to hook into the owl/faim 192 * interface to keep track of when the AIM socket(s) open and 193 * close. In particular, the bosconn thing throws me off. So, 194 * rather than register particular dispatchers for AIM, I look up 195 * the relevant FDs and add them to select's watch lists, then 196 * check for them individually before moving on to the other 197 * dispatchers. --asedeno 198 */ 199 aim_done = 1; 200 FD_ZERO(&aim_rfds); 201 FD_ZERO(&aim_wfds); 202 if (owl_global_is_doaimevents(&g)) { 203 aim_done = 0; 204 aim_max_fd = owl_select_aim_hack(&aim_rfds, &aim_wfds); 205 if (max_fd < aim_max_fd) max_fd = aim_max_fd; 206 for(i = 0; i <= aim_max_fd; i++) { 207 if (FD_ISSET(i, &aim_rfds)) { 208 FD_SET(i, &r); 209 FD_SET(i, &e); 210 } 211 } 212 } 213 /* END AIM HACK */ 214 215 if ( select(max_fd+1, &r, &aim_wfds, &e, &timeout) ) { 216 /* Merge fd_sets and clear AIM FDs. */ 217 for(i = 0; i <= max_fd; i++) { 218 /* Merge all interesting FDs into one set, since we have a 219 single dispatch per FD. */ 220 if (FD_ISSET(i, &r) || FD_ISSET(i, &aim_wfds) || FD_ISSET(i, &e)) { 221 /* AIM HACK: no separate dispatch, just process here if 222 needed, and only once per run through. */ 223 if (!aim_done && (FD_ISSET(i, &aim_rfds) || FD_ISSET(i, &aim_wfds))) { 224 owl_process_aim(); 225 aim_done = 1; 226 } 227 else { 228 FD_SET(i, &r); 229 } 230 } 231 } 162 if ( select(max_fd+1, &r, NULL, &e, &timeout) ) { 232 163 /* NOTE: the same dispatch function is called for both exceptional 233 164 and read ready FDs. */ -
util.c
ree310eb rc453ada 78 78 } 79 79 80 if (owl_global_is_zaway(&g) || owl_global_is_aaway(&g)) { 80 /* TODO add perl hooks for sepbar away, etc. status */ 81 if (owl_global_is_zaway(&g)) { 81 82 getyx(sepwin, y, x); 82 83 wmove(sepwin, y, x+2); 83 84 wattron(sepwin, A_BOLD); 84 85 wattroff(sepwin, A_REVERSE); 85 if (owl_global_is_zaway(&g) && owl_global_is_aaway(&g)) {86 if (owl_global_is_zaway(&g)) { 86 87 waddstr(sepwin, " AWAY "); 87 } else if (owl_global_is_zaway(&g)) { 88 waddstr(sepwin, " Z-AWAY "); 89 } else if (owl_global_is_aaway(&g)) { 90 waddstr(sepwin, " A-AWAY "); 91 } 88 } /* else if... */ 92 89 wattron(sepwin, A_REVERSE); 93 90 wattroff(sepwin, A_BOLD); -
variable.c
r52f8dd6 rc453ada 239 239 "default zaway message", "" ), 240 240 241 OWLVAR_BOOL_FULL( "aaway" /* %OwlVarStub */, 0,242 "Set AIM away status",243 "",244 NULL, owl_variable_aaway_set, NULL),245 246 OWLVAR_STRING( "aaway_msg" /* %OwlVarStub */,247 OWL_DEFAULT_AAWAYMSG,248 "AIM away msg for responding when away", "" ),249 250 OWLVAR_STRING( "aaway_msg_default" /* %OwlVarStub */,251 OWL_DEFAULT_AAWAYMSG,252 "default AIM away message", "" ),253 254 241 OWLVAR_STRING( "view_home" /* %OwlVarStub */, "all", 255 242 "home view to switch to after 'X' and 'V'", … … 299 286 "than 60 columns, as a courtesy to recipients.\n"), 300 287 301 OWLVAR_INT( "aim_ignorelogin_timer" /* %OwlVarStub */, 15,302 "number of seconds after AIM login to ignore login messages",303 "This specifies the number of seconds to wait after an\n"304 "AIM login before allowing the recipt of AIM login notifications.\n"305 "By default this is set to 15. If you would like to view login\n"306 "notifications of buddies as soon as you login, set it to 0 instead."),307 308 309 288 OWLVAR_INT_FULL( "typewinsize" /* %OwlVarStub:typwin_lines */, 310 289 OWL_TYPWIN_SIZE, … … 403 382 if (newval && (*(int*)newval == 1 || *(int*)newval == 0)) { 404 383 g.debug = *(int*)newval; 405 }406 return owl_variable_bool_set_default(v, newval);407 }408 409 /* When 'aaway' is changed, need to notify the AIM server */410 int owl_variable_aaway_set(owl_variable *v, void *newval)411 {412 if (newval) {413 if (*(int*)newval == 1) {414 owl_aim_set_awaymsg(owl_global_get_aaway_msg(&g));415 } else if (*(int*)newval == 0) {416 owl_aim_set_awaymsg("");417 }418 384 } 419 385 return owl_variable_bool_set_default(v, newval);
Note: See TracChangeset
for help on using the changeset viewer.