Changeset c453ada for functions.c


Ignore:
Timestamp:
May 31, 2008, 11:40:29 PM (16 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
  • functions.c

    rb1fd36e rc453ada  
    211211}
    212212
    213 /* Create an outgoing AIM message, returns a pointer to the created
    214  * message or NULL if we're not logged into AIM (and thus unable to
    215  * create the message).  Does not put it on the global queue.  Use
    216  * 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 
    235213/* Create an outgoing loopback message and return a pointer to it.
    236214 * Does not append it to the global queue, use
     
    292270  owl_global_set_buffercommand(&g, line);
    293271  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);
    325272}
    326273
     
    449396  owl_free(cryptmsg);
    450397  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);
    516398}
    517399
     
    895777}
    896778
    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 
    913779void owl_function_suspend()
    914780{
     
    943809}
    944810
    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 
    969811void owl_function_quit()
    970812{
     
    988830  owl_zephyr_shutdown();
    989831 
    990   /* Quit AIM */
    991   if (owl_global_is_aimloggedin(&g)) {
    992     owl_aim_logout();
    993   }
    994 
    995832  /* done with curses */
    996833  endwin();
     
    19481785    owl_fmtext_append_normal(&fm, "no\n");
    19491786  }
    1950   owl_fmtext_append_normal(&fm, "  AIM included       : yes\n");
     1787  owl_fmtext_append_normal(&fm, "  AIM included       : no\n");
    19511788  owl_fmtext_append_normal(&fm, "  Loopback included  : yes\n");
    19521789
     
    19601797#endif
    19611798 
    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   }
    19781799
    19791800  owl_function_popless_fmtext(&fm);
     
    21201941        if (cc) owl_free(cc);
    21211942      }
    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       }
    21291943    } else {
    21301944      char *cmd;
     
    26762490  owl_free(longuser);
    26772491  owl_free(shortuser);
    2678 
    2679   return(filtname);
    2680 }
    2681 
    2682 /* Create a filter for AIM IM messages to or from the specified
    2683  * screenname.  The name of the filter will be 'aimuser-<user>'.  If a
    2684  * filter already exists with this name, no new filter will be
    2685  * 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);
    27222492
    27232493  return(filtname);
     
    28122582  if (owl_message_is_type_loopback(m)) {
    28132583    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);
    28242584  }
    28252585
     
    32573017void owl_function_buddylist(int aim, int zephyr, char *filename)
    32583018{
    3259   int i, j, x, idle;
     3019  int i, j, x;
    32603020  owl_fmtext fm;
    3261   owl_buddylist *bl;
    3262   owl_buddy *b;
    32633021  owl_list anyone;
    3264   char *foo, *timestr;
    32653022#ifdef HAVE_LIBZEPHYR
    32663023  char *tmp, *user, *line;
     
    32713028  owl_fmtext_init_null(&fm);
    32723029
    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");
    32943032
    32953033#ifdef HAVE_LIBZEPHYR
Note: See TracChangeset for help on using the changeset viewer.