Changeset 3abf28b for functions.c


Ignore:
Timestamp:
Jun 1, 2003, 9:11:25 PM (18 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)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.