Changeset 4fd3c04 for functions.c
- Timestamp:
- Oct 12, 2017, 8:28:02 PM (7 years ago)
- Branches:
- master
- Children:
- a882637
- Parents:
- ee6b30f
- git-author:
- Anders Kaseorg <andersk@mit.edu> (10/06/17 21:27:09)
- git-committer:
- Anders Kaseorg <andersk@mit.edu> (10/12/17 20:28:02)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
ree6b30f r4fd3c04 170 170 "':sub @b(class)', and then type ':zwrite -c @b(class)' to send.\n\n" 171 171 #endif 172 "@b(AIM:)\n"173 "Log in to AIM with ':aimlogin @b(screenname)'. Use ':aimwrite @b(screenname)',\n"174 "or 'a' and then the screen name, to send someone a message.\n\n"175 172 ; 176 173 … … 239 236 } 240 237 241 /* Create an outgoing AIM message, returns a pointer to the created242 * message or NULL if we're not logged into AIM (and thus unable to243 * create the message). Does not put it on the global queue. Use244 * owl_global_messagequeue_addmsg() for that.245 */246 CALLER_OWN owl_message *owl_function_make_outgoing_aim(const char *body, const char *to)247 {248 owl_message *m;249 250 /* error if we're not logged into aim */251 if (!owl_global_is_aimloggedin(&g)) return(NULL);252 253 m=g_slice_new(owl_message);254 owl_message_create_aim(m,255 owl_global_get_aim_screenname(&g),256 to,257 body,258 OWL_MESSAGE_DIRECTION_OUT,259 0);260 return(m);261 }262 263 238 /* Create an outgoing loopback message and return a pointer to it. 264 239 * Does not append it to the global queue, use … … 325 300 } 326 301 327 void owl_function_aimwrite_setup(const char *to)328 {329 owl_editwin *e;330 /* TODO: We probably actually want an owl_aimwrite object like331 * owl_zwrite. */332 char *line = g_strdup_printf("aimwrite %s", to);333 owl_function_write_setup("message");334 e = owl_function_start_edit_win(line);335 owl_editwin_set_cbdata(e, g_strdup(to), g_free);336 owl_editwin_set_callback(e, &owl_callback_aimwrite);337 g_free(line);338 }339 340 302 void owl_function_loopwrite_setup(void) 341 303 { … … 436 398 g_free(cryptmsg); 437 399 g_free(old_msg); 438 }439 440 void owl_callback_aimwrite(owl_editwin *e, bool success)441 {442 if (!success) return;443 char *to = owl_editwin_get_cbdata(e);444 owl_function_aimwrite(to, owl_editwin_get_text(e), true);445 }446 447 void owl_function_aimwrite(const char *to, const char *msg, bool unwrap)448 {449 int ret;450 char *format_msg;451 owl_message *m;452 453 /* make a formatted copy of the message */454 format_msg = g_strdup(msg);455 if (unwrap)456 owl_text_wordunwrap(format_msg);457 458 /* send the message */459 ret=owl_aim_send_im(to, format_msg);460 if (!ret) {461 owl_function_makemsg("AIM message sent.");462 } else {463 owl_function_error("Could not send AIM message.");464 }465 466 /* create the outgoing message */467 m=owl_function_make_outgoing_aim(msg, to);468 469 if (m) {470 owl_global_messagequeue_addmsg(&g, m);471 } else {472 owl_function_error("Could not create outgoing AIM message");473 }474 475 g_free(format_msg);476 }477 478 void owl_function_send_aimawymsg(const char *to, const char *msg)479 {480 int ret;481 char *format_msg;482 owl_message *m;483 484 /* make a formatted copy of the message */485 format_msg=g_strdup(msg);486 owl_text_wordunwrap(format_msg);487 488 /* send the message */489 ret=owl_aim_send_awaymsg(to, format_msg);490 if (!ret) {491 /* owl_function_makemsg("AIM message sent."); */492 } else {493 owl_function_error("Could not send AIM message.");494 }495 496 /* create the message */497 m=owl_function_make_outgoing_aim(msg, to);498 if (m) {499 owl_global_messagequeue_addmsg(&g, m);500 } else {501 owl_function_error("Could not create AIM message");502 }503 g_free(format_msg);504 400 } 505 401 … … 918 814 } 919 815 920 void owl_callback_aimlogin(owl_editwin *e, bool success)921 {922 if (!success) return;923 char *user = owl_editwin_get_cbdata(e);924 owl_function_aimlogin(user,925 owl_editwin_get_text(e));926 }927 928 void owl_function_aimlogin(const char *user, const char *passwd) {929 int ret;930 931 /* clear the buddylist */932 owl_buddylist_clear(owl_global_get_buddylist(&g));933 934 /* try to login */935 ret=owl_aim_login(user, passwd);936 if (ret) owl_function_makemsg("Warning: login for %s failed.\n", user);937 }938 939 816 void owl_function_suspend(void) 940 817 { … … 969 846 } 970 847 971 void owl_function_aaway_toggle(void)972 {973 if (!owl_global_is_aaway(&g)) {974 owl_global_set_aaway_msg(&g, owl_global_get_aaway_msg_default(&g));975 owl_function_aaway_on();976 } else {977 owl_function_aaway_off();978 }979 }980 981 void owl_function_aaway_on(void)982 {983 owl_global_set_aaway_on(&g);984 /* owl_aim_set_awaymsg(owl_global_get_zaway_msg(&g)); */985 owl_function_makemsg("AIM away set (%s)", owl_global_get_aaway_msg(&g));986 }987 988 void owl_function_aaway_off(void)989 {990 owl_global_set_aaway_off(&g);991 /* owl_aim_set_awaymsg(""); */992 owl_function_makemsg("AIM away off");993 }994 995 848 bool owl_function_is_away(void) 996 849 { 997 850 return owl_global_is_zaway(&g) || 998 owl_global_is_aaway(&g) ||999 851 owl_perlconfig_perl_call_bool("BarnOwl::Hooks::_get_is_away", 0, NULL); 1000 852 } … … 1017 869 if (owl_global_get_newmsgproc_pid(&g)) { 1018 870 kill(owl_global_get_newmsgproc_pid(&g), SIGHUP); 1019 }1020 1021 /* Quit AIM */1022 if (owl_global_is_aimloggedin(&g)) {1023 owl_aim_logout();1024 871 } 1025 872 … … 1822 1669 owl_fmtext_append_normal(&fm, "no\n"); 1823 1670 } 1824 owl_fmtext_append_normal(&fm, " AIM included : yes\n");1825 1671 owl_fmtext_append_normal(&fm, " Loopback included : yes\n"); 1826 1672 … … 1833 1679 owl_fmtext_append_normal(&fm, "no\n"); 1834 1680 #endif 1835 1836 1837 owl_fmtext_append_normal(&fm, "\nAIM Status:\n");1838 owl_fmtext_append_normal(&fm, " Logged in: ");1839 if (owl_global_is_aimloggedin(&g)) {1840 owl_fmtext_append_normal(&fm, owl_global_get_aim_screenname(&g));1841 owl_fmtext_append_normal(&fm, "\n");1842 } else {1843 owl_fmtext_append_normal(&fm, "(not logged in)\n");1844 }1845 1846 owl_fmtext_append_normal(&fm, " Processing events: ");1847 if (owl_global_is_doaimevents(&g)) {1848 owl_fmtext_append_normal(&fm, "yes\n");1849 } else {1850 owl_fmtext_append_normal(&fm, "no\n");1851 }1852 1681 1853 1682 owl_function_popless_fmtext(&fm); … … 2446 2275 if (f == NULL) { 2447 2276 /* Couldn't make a filter for some reason. Return NULL. */ 2448 owl_function_error("Error creating filter '%s'", filtname);2449 g_free(filtname);2450 return NULL;2451 }2452 2453 /* add it to the global list */2454 owl_global_add_filter(&g, f);2455 2456 return(filtname);2457 }2458 2459 /* Create a filter for AIM IM messages to or from the specified2460 * screenname. The name of the filter will be 'aimuser-<user>'. If a2461 * filter already exists with this name, no new filter will be2462 * created. This allows the configuration to override this function.2463 * Returns the name of the filter, which the caller must free.2464 */2465 CALLER_OWN char *owl_function_aimuserfilt(const char *user)2466 {2467 owl_filter *f;2468 char *argbuff, *filtname;2469 char *escuser;2470 2471 /* name for the filter */2472 filtname=g_strdup_printf("aimuser-%s", user);2473 2474 /* if it already exists then go with it. This lets users override */2475 if (owl_global_get_filter(&g, filtname)) {2476 return filtname;2477 }2478 2479 /* create the new-internal filter */2480 escuser = owl_text_quote(user, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);2481 2482 argbuff = g_strdup_printf(2483 "( type ^aim$ and ( ( sender ^%1$s$ and recipient ^%2$s$ ) or "2484 "( sender ^%2$s$ and recipient ^%1$s$ ) ) )",2485 escuser, owl_global_get_aim_screenname_for_filters(&g));2486 g_free(escuser);2487 2488 f = owl_filter_new_fromstring(filtname, argbuff);2489 g_free(argbuff);2490 2491 if (f == NULL) {2492 2277 owl_function_error("Error creating filter '%s'", filtname); 2493 2278 g_free(filtname); … … 2606 2391 * If the curmsg is a zephyr class message and type==1 then 2607 2392 * return a filter name for the class and instance. 2608 * If the curmsg is a personal AIM message returna filter2609 * name to the AIM conversation with that user2610 2393 */ 2611 2394 CALLER_OWN char *owl_function_smartfilter(int type, int invert_related) … … 2633 2416 if (owl_message_is_type_loopback(m)) { 2634 2417 return(owl_function_typefilt("loopback")); 2635 }2636 2637 /* aim messages */2638 if (owl_message_is_type_aim(m)) {2639 if (owl_message_is_direction_in(m)) {2640 filtname=owl_function_aimuserfilt(owl_message_get_sender(m));2641 } else if (owl_message_is_direction_out(m)) {2642 filtname=owl_function_aimuserfilt(owl_message_get_recipient(m));2643 }2644 return(filtname);2645 2418 } 2646 2419 … … 3070 2843 3071 2844 /* Popup a buddylisting. If filename is NULL use the default .anyone */ 3072 void owl_function_buddylist(int aim, intzephyr, const char *filename)3073 { 3074 int i , j, idle;2845 void owl_function_buddylist(int zephyr, const char *filename) 2846 { 2847 int i; 3075 2848 int interrupted = 0; 3076 2849 owl_fmtext fm; 3077 const owl_buddylist *bl;3078 const owl_buddy *b;3079 char *timestr;3080 2850 #ifdef HAVE_LIBZEPHYR 3081 2851 int x; … … 3088 2858 3089 2859 owl_fmtext_init_null(&fm); 3090 3091 /* AIM first */3092 if (aim && owl_global_is_aimloggedin(&g)) {3093 bl=owl_global_get_buddylist(&g);3094 3095 owl_fmtext_append_bold(&fm, "AIM users logged in:\n");3096 /* we're assuming AIM for now */3097 j=owl_buddylist_get_size(bl);3098 for (i=0; i<j; i++) {3099 b=owl_buddylist_get_buddy_n(bl, i);3100 idle=owl_buddy_get_idle_time(b);3101 if (idle!=0) {3102 timestr=owl_util_format_minutes(idle);3103 } else {3104 timestr=g_strdup("");3105 }3106 owl_fmtext_appendf_normal(&fm, " %-20.20s %-12.12s\n", owl_buddy_get_name(b), timestr);3107 g_free(timestr);3108 }3109 }3110 2860 3111 2861 #ifdef HAVE_LIBZEPHYR … … 3164 2914 #endif 3165 2915 3166 if ( aim &&zephyr) {2916 if (zephyr) { 3167 2917 if (owl_perlconfig_is_function("BarnOwl::Hooks::_get_blist")) { 3168 2918 char * perlblist = owl_perlconfig_execute("BarnOwl::Hooks::_get_blist()"); … … 3508 3258 } 3509 3259 3510 void owl_function_aimsearch_results(const char *email, GPtrArray *namelist)3511 {3512 owl_fmtext fm;3513 int i;3514 3515 owl_fmtext_init_null(&fm);3516 owl_fmtext_append_normal(&fm, "AIM screennames associated with ");3517 owl_fmtext_append_normal(&fm, email);3518 owl_fmtext_append_normal(&fm, ":\n");3519 3520 for (i = 0; i < namelist->len; i++) {3521 owl_fmtext_append_normal(&fm, " ");3522 owl_fmtext_append_normal(&fm, namelist->pdata[i]);3523 owl_fmtext_append_normal(&fm, "\n");3524 }3525 3526 owl_function_popless_fmtext(&fm);3527 owl_fmtext_cleanup(&fm);3528 }3529 3530 3260 int owl_function_get_color_count(void) 3531 3261 {
Note: See TracChangeset
for help on using the changeset viewer.