Changeset 3abf28b


Ignore:
Timestamp:
Jun 1, 2003, 9:11:25 PM (17 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
75e3879
Parents:
df0d93a
Message:
make smartnarrow work for AIM
  (though it will crash on names with spaces)
don't set an away message by default
better default format
bold them like personal zephyrs
same with terminal bell
do some basic HTML stripping (buggy, in progress)
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • aim.c

    r0ff8fb57 r3abf28b  
    411411
    412412  /*aim_bos_setprofile(sess, fr->conn, profile, awaymsg, AIM_CAPS_BUDDYICON | AIM_CAPS_CHAT | AIM_CAPS_GETFILE | AIM_CAPS_SENDFILE | AIM_CAPS_IMIMAGE | AIM_CAPS_GAMES | AIM_CAPS_SAVESTOCKS | AIM_CAPS_SENDBUDDYLIST | AIM_CAPS_ICQ | AIM_CAPS_ICQUNKNOWN | AIM_CAPS_ICQRTF | AIM_CAPS_ICQSERVERRELAY | AIM_CAPS_TRILLIANCRYPT); */
    413   aim_bos_setprofile(sess, fr->conn, profile, awaymsg, AIM_CAPS_SENDBUDDYLIST | AIM_CAPS_CHAT );
     413  aim_bos_setprofile(sess, fr->conn, profile, "", AIM_CAPS_SENDBUDDYLIST | AIM_CAPS_CHAT );
    414414  aim_bos_reqbuddyrights(sess, fr->conn);
    415415
     
    951951  } else if (strstr(tmpstr, "haveicon") && priv->buddyicon) {
    952952    struct aim_sendimext_args args;
    953     static const char iconmsg[] = {"I have an icon"};
     953    /* static const char iconmsg[] = {"I have an icon"}; */
     954    static const char iconmsg[] = {""};
    954955   
    955956    args.destsn = userinfo->sn;
     
    961962    args.iconsum = priv->buddyiconsum;
    962963   
    963     aim_send_im_ext(sess, &args);
     964    /* aim_send_im_ext(sess, &args); */
    964965   
    965966  } else if (strstr(tmpstr, "sendbin")) {
     
    11701171  int clienttype = AIM_CLIENTTYPE_UNKNOWN;
    11711172  owl_message *m;
     1173  char *stripmsg;
    11721174  char realmsg[8192+1] = {""};
    11731175  clienttype = aim_fingerprintclient(args->features, args->featureslen);
     
    12441246
    12451247  /* create a message, and put it on the message queue */
     1248  stripmsg=owl_text_htmlstrip(realmsg);
    12461249  m=owl_malloc(sizeof(owl_message));
    1247   owl_message_create_aim(m, userinfo->sn, owl_global_get_aim_screenname(&g), realmsg);
    1248   owl_message_set_direction_in(m);
     1250  owl_message_create_incoming_aim(m, userinfo->sn, owl_global_get_aim_screenname(&g), stripmsg);
    12491251  owl_global_messagequeue_addmsg(&g, m);
     1252  owl_free(stripmsg);
    12501253 
    12511254  /* printf("icbm: message: %s\n", realmsg); */
  • commands.c

    r31e48a3 r3abf28b  
    15671567    return NULL;
    15681568  }
    1569   filtname = owl_function_fastclassinstfilt(argv[1], NULL);
     1569  filtname = owl_function_classinstfilt(argv[1], NULL);
    15701570  owl_function_change_view(filtname);
    15711571  owl_free(filtname);
     
    15791579    return NULL;
    15801580  }
    1581   filtname = owl_function_fastuserfilt(argv[1]);
     1581  filtname=owl_function_zuserfilt(argv[1]);
    15821582  owl_function_change_view(filtname);
    15831583  owl_free(filtname);
  • filter.c

    rd09e5a1 r3abf28b  
    150150      match=owl_message_get_realm(m);
    151151    } else if (!strcasecmp(field, "type")) {
    152       if (owl_message_is_type_zephyr(m)) {
    153         match="zephyr";
    154       } else if (owl_message_is_type_aim(m)) {
    155         match="aim";
    156       } else if (owl_message_is_type_admin(m)) {
    157         match="admin";
    158       } else {
    159         match="";
    160       }
     152      match=owl_message_type_to_string(m);
    161153    } else if (!strcasecmp(field, "direction")) {
    162154      if (owl_message_is_direction_out(m)) {
  • functions.c

    rdf0d93a r3abf28b  
    134134  /* create the message */
    135135  m=owl_malloc(sizeof(owl_message));
    136   owl_message_create_aim(m, owl_global_get_aim_screenname(&g), to, body);
    137   owl_message_set_direction_out(m);
     136  owl_message_create_outgoing_aim(m, owl_global_get_aim_screenname(&g), to, body);
    138137
    139138  /* add it to the global list and current view */
     
    21162115}
    21172116
    2118 char *owl_function_fastclassinstfilt(char *class, char *instance)
    2119 {
    2120   /* creates a filter for a class, instance if one doesn't exist.
    2121    * If instance is null then apply for all messgaes in the class.
    2122    * returns the name of the filter, which the caller must free.*/
     2117/* Create a filter for a class, instance if one doesn't exist.  If
     2118 * instance is NULL then catch all messgaes in the class.  Returns the
     2119 * name of the filter, which the caller must free.
     2120 */
     2121char *owl_function_classinstfilt(char *class, char *instance)
     2122{
    21232123  owl_list *fl;
    21242124  owl_filter *f;
     
    21732173}
    21742174
    2175 char *owl_function_fastuserfilt(char *user)
     2175/* Create a filter for personal zephyrs to or from the specified
     2176 * zephyr user.  Includes login/logout notifications for the user.
     2177 * The name of the filter will be 'user-<user>'.  If a filter already
     2178 * exists with this name, no new filter will be created.  This allows
     2179 * the configuration to override this function.  Returns the name of
     2180 * the filter, which the caller must free.
     2181 */
     2182char *owl_function_zuserfilt(char *user)
    21762183{
    21772184  owl_filter *f;
     
    21882195  /* if it already exists then go with it.  This lets users override */
    21892196  if (owl_global_get_filter(&g, filtname)) {
    2190     return(filtname);
     2197    return(owl_strdup(filtname));
    21912198  }
    21922199
     
    22122219}
    22132220
    2214 char *owl_function_fasttypefilt(char *type)
     2221/* Create a filter for AIM IM messages to or from the specified
     2222 * screenname.  The name of the filter will be 'aimuser-<user>'.  If a
     2223 * filter already exists with this name, no new filter will be
     2224 * created.  This allows the configuration to override this function.
     2225 * Returns the name of the filter, which the caller must free.
     2226 */
     2227char *owl_function_aimuserfilt(char *user)
     2228{
     2229  owl_filter *f;
     2230  char *argbuff, *filtname;
     2231
     2232  /* name for the filter */
     2233  filtname=owl_malloc(strlen(user)+40);
     2234  sprintf(filtname, "aimuser-%s", user);
     2235
     2236  /* if it already exists then go with it.  This lets users override */
     2237  if (owl_global_get_filter(&g, filtname)) {
     2238    return(owl_strdup(filtname));
     2239  }
     2240
     2241  /* create the new-internal filter */
     2242  f=owl_malloc(sizeof(owl_filter));
     2243
     2244  argbuff=owl_malloc(1000);
     2245  sprintf(argbuff,
     2246          "( type ^aim$ and ( ( sender ^%s$ and recipient ^%s$ ) or ( sender ^%s$ and recipient ^%s$ ) ) )",
     2247          user, owl_global_get_aim_screenname(&g), owl_global_get_aim_screenname(&g), user);
     2248
     2249  owl_filter_init_fromstring(f, filtname, argbuff);
     2250
     2251  /* add it to the global list */
     2252  owl_global_add_filter(&g, f);
     2253
     2254  /* free stuff */
     2255  owl_free(argbuff);
     2256
     2257  return(filtname);
     2258}
     2259
     2260char *owl_function_typefilt(char *type)
    22152261{
    22162262  owl_filter *f;
     
    22632309}
    22642310
     2311/* Create a filter based on the current message.  Returns the name of
     2312 * a filter or null.  The caller must free this name.
     2313 *
     2314 * if the curmsg is a personal zephyr return a filter name
     2315 *    to the zephyr converstaion with that user.
     2316 * If the curmsg is a zephyr class message, instance foo, recip *,
     2317 *    return a filter name to the class, inst.
     2318 * If the curmsg is a zephyr class message and type==0 then
     2319 *    return a filter name for just the class.
     2320 * If the curmsg is a zephyr class message and type==1 then
     2321 *    return a filter name for the class and instance.
     2322 * If the curmsg is a personal AIM message returna  filter
     2323 *    name to the AIM conversation with that user
     2324 */
    22652325char *owl_function_smartfilter(int type)
    22662326{
    2267   /* Returns the name of a filter, or null.  The caller
    2268    * must free this name.  */
    2269   /* if the curmsg is a personal message return a filter name
    2270    *    to the converstaion with that user.
    2271    * If the curmsg is a class message, instance foo, recip *
    2272    *    message, return a filter name to the class, inst.
    2273    * If the curmsg is a class message and type==0 then
    2274    *    return a filter name for just the class.
    2275    * If the curmsg is a class message and type==1 then
    2276    *    return a filter name for the class and instance.
    2277    */
    22782327  owl_view *v;
    22792328  owl_message *m;
     
    22902339  /* very simple handling of admin messages for now */
    22912340  if (owl_message_is_type_admin(m)) {
    2292     return(owl_function_fasttypefilt("admin"));
     2341    return(owl_function_typefilt("admin"));
     2342  }
     2343
     2344  /* aim messages */
     2345  if (owl_message_is_type_aim(m)) {
     2346    if (owl_message_is_direction_in(m)) {
     2347      filtname=owl_function_aimuserfilt(owl_message_get_sender(m));
     2348    } else if (owl_message_is_direction_out(m)) {
     2349      filtname=owl_function_aimuserfilt(owl_message_get_recipient(m));
     2350    }
     2351    return(filtname);
    22932352  }
    22942353
     
    23012360        zperson=short_zuser(owl_message_get_recipient(m));
    23022361      }
    2303       filtname=owl_function_fastuserfilt(zperson);
     2362      filtname=owl_function_zuserfilt(zperson);
    23042363      owl_free(zperson);
    23052364      return(filtname);
     
    23092368
    23102369  /* narrow class MESSAGE, instance foo, recip * messages to class, inst */
    2311   if (!strcasecmp(owl_message_get_class(m), "message") &&
    2312       !owl_message_is_personal(m)) {
    2313     filtname=owl_function_fastclassinstfilt(owl_message_get_class(m), owl_message_get_instance(m));
     2370  if (!strcasecmp(owl_message_get_class(m), "message") && !owl_message_is_personal(m)) {
     2371    filtname=owl_function_classinstfilt(owl_message_get_class(m), owl_message_get_instance(m));
    23142372    return(filtname);
    23152373  }
     
    23172375  /* otherwise narrow to the class */
    23182376  if (type==0) {
    2319     filtname=owl_function_fastclassinstfilt(owl_message_get_class(m), NULL);
     2377    filtname=owl_function_classinstfilt(owl_message_get_class(m), NULL);
    23202378  } else if (type==1) {
    2321     filtname=owl_function_fastclassinstfilt(owl_message_get_class(m), owl_message_get_instance(m));
     2379    filtname=owl_function_classinstfilt(owl_message_get_class(m), owl_message_get_instance(m));
    23222380  }
    23232381  return(filtname);
  • message.c

    rdf0d93a r3abf28b  
    529529}
    530530
    531 void owl_message_create_aim(owl_message *m, char *sender, char *recipient, char *text)
     531void owl_message_create_incoming_aim(owl_message *m, char *sender, char *recipient, char *text)
    532532{
    533533  char *indent;
     
    538538  owl_message_set_recipient(m, recipient);
    539539  owl_message_set_type_aim(m);
     540  owl_message_set_direction_in(m);
     541
     542  indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
     543  owl_text_indent(indent, text, OWL_MSGTAB);
     544  owl_fmtext_init_null(&(m->fmtext));
     545  owl_fmtext_append_bold(&(m->fmtext), OWL_TABSTR);
     546  owl_fmtext_append_bold(&(m->fmtext), "AIM from ");
     547  owl_fmtext_append_bold(&(m->fmtext), sender);
     548  owl_fmtext_append_bold(&(m->fmtext), "\n");
     549  owl_fmtext_append_bold(&(m->fmtext), indent);
     550  if (text[strlen(text)-1]!='\n') {
     551    owl_fmtext_append_bold(&(m->fmtext), "\n");
     552  }
     553 
     554  owl_free(indent);
     555}
     556
     557void owl_message_create_outgoing_aim(owl_message *m, char *sender, char *recipient, char *text)
     558{
     559  char *indent;
     560
     561  owl_message_init(m);
     562  owl_message_set_body(m, text);
     563  owl_message_set_sender(m, sender);
     564  owl_message_set_recipient(m, recipient);
     565  owl_message_set_type_aim(m);
     566  owl_message_set_direction_out(m);
    540567
    541568  indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
     
    543570  owl_fmtext_init_null(&(m->fmtext));
    544571  owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR);
    545   owl_fmtext_append_normal(&(m->fmtext), "AIM: ");
    546   owl_fmtext_append_normal(&(m->fmtext), sender);
    547   owl_fmtext_append_normal(&(m->fmtext), " -> ");
     572  owl_fmtext_append_normal(&(m->fmtext), "AIM sent to ");
    548573  owl_fmtext_append_normal(&(m->fmtext), recipient);
    549574  owl_fmtext_append_normal(&(m->fmtext), "\n");
     
    889914    owl_fmtext_append_ztext(&(m->fmtext), indent);
    890915
    891     /* make personal messages bold for smaat users */
     916    /* make private messages bold for smaat users */
    892917    if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
    893918      if (owl_message_is_personal(m)) {
  • owl.c

    r31e48a3 r3abf28b  
    138138
    139139  /* setup the default filters */
    140   f=malloc(sizeof(owl_filter));
    141   owl_filter_init_fromstring(f, "personal", "class ^message$ and instance ^personal$ and ( recipient ^%me%$ or sender ^%me%$ )");
     140
     141  /* the personal filter will need to change again when AIM chat's are
     142   *  included.  Also, there should be an %aimme% */
     143  f=malloc(sizeof(owl_filter));
     144  owl_filter_init_fromstring(f, "personal", "( type ^zephyr$ "
     145                             "and class ^message$ and instance ^personal$ "
     146                             "and ( recipient ^%me%$ or sender ^%me%$ ) ) "
     147                             "or ( type ^aim$ )");
    142148  owl_list_append_element(owl_global_get_filterlist(&g), f);
    143149
     
    330336
    331337      /* ring the bell if it's a personal */
    332       if (owl_global_is_personalbell(&g) && owl_message_is_personal(m)) {
     338      if (owl_global_is_personalbell(&g) &&
     339          (owl_message_is_personal(m) ||
     340          (owl_message_is_type_aim(m) && owl_message_is_to_me(m)))) {
    333341        owl_function_beep();
    334342      }
  • owl_prototypes.h

    rdf0d93a r3abf28b  
    356356extern void owl_function_show_filter(char *name);
    357357extern void owl_function_show_zpunts();
    358 extern char *owl_function_fastclassinstfilt(char *class, char *instance);
    359 extern char *owl_function_fastuserfilt(char *user);
    360 extern char *owl_function_fasttypefilt(char *type);
     358extern char *owl_function_classinstfilt(char *class, char *instance);
     359extern char *owl_function_zuserfilt(char *user);
     360extern char *owl_function_aimuserfilt(char *user);
     361extern char *owl_function_typefilt(char *type);
    361362extern void owl_function_delete_curview_msgs(int flag);
    362363extern char *owl_function_smartfilter(int type);
     
    610611extern int owl_message_search(owl_message *m, char *string);
    611612extern void owl_message_create(owl_message *m, char *header, char *text);
    612 extern void owl_message_create_aim(owl_message *m, char *sender, char *recipient, char *text);
     613extern void owl_message_create_incoming_aim(owl_message *m, char *sender, char *recipient, char *text);
     614extern void owl_message_create_outgoing_aim(owl_message *m, char *sender, char *recipient, char *text);
    613615extern void owl_message_create_admin(owl_message *m, char *header, char *text);
    614616extern void owl_message_create_from_znotice(owl_message *m, ZNotice_t *n);
     
    690692extern void owl_text_indent(char *out, char *in, int n);
    691693extern int owl_text_num_lines(char *in);
     694extern char *owl_text_htmlstrip(char *in);
    692695
    693696/* -------------------------------- util.c -------------------------------- */
  • text.c

    r1aee7d9 r3abf28b  
    127127}
    128128
     129
     130/* caller must free the return */
     131char *owl_text_htmlstrip(char *in) {
     132  char *ptr1, *end, *ptr2, *ptr3, *out;
     133
     134  out=owl_malloc(strlen(in)+30);
     135  strcpy(out, "");
     136
     137  ptr1=in;
     138  end=in+strlen(in);
     139 
     140  while(ptr1<end) {
     141    /* look for an open bracket */
     142    ptr2=strchr(ptr1, '<');
     143
     144    /* if not, copy in from here to end and exit */
     145    if (ptr2==NULL) {
     146      strcat(out, ptr1);
     147      return(out);
     148    }
     149
     150    /* otherwise copy in everything before the open bracket */
     151    if (ptr2>ptr1) {
     152      strncat(out, ptr1, ptr2-ptr1);
     153    }
     154
     155    /* find the close bracket */
     156    ptr3=strchr(ptr2, '>');
     157   
     158    /* if there is no close, copy as you are and exit */
     159    if (!ptr3) {
     160      strcat(out, ptr2);
     161    }
     162
     163    /* look for things we know */
     164    if (!strncasecmp(ptr2, "<BODY ", 6) ||
     165        !strncasecmp(ptr2, "<FONT ", 6) ||
     166        !strncasecmp(ptr2, "<HTML", 5) ||
     167        !strncasecmp(ptr2, "</FONT", 6) ||
     168        !strncasecmp(ptr2, "</HTML", 6) ||
     169        !strncasecmp(ptr2, "</BODY", 6)) {
     170
     171      /* advance to beyond the angle brakcet and go again */
     172      ptr1=ptr3+1;
     173      continue;
     174    }
     175
     176    /* if it wasn't something we know, copy to the > and  go again */
     177    strncat(out, ptr2, ptr3-ptr2);
     178    ptr1=ptr3+1;
     179  }
     180  return(out);
     181}
Note: See TracChangeset for help on using the changeset viewer.