Changeset 3abf28b for functions.c
- Timestamp:
- Jun 1, 2003, 9:11:25 PM (21 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 75e3879
- Parents:
- df0d93a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
rdf0d93a r3abf28b 134 134 /* create the message */ 135 135 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); 138 137 139 138 /* add it to the global list and current view */ … … 2116 2115 } 2117 2116 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 */ 2121 char *owl_function_classinstfilt(char *class, char *instance) 2122 { 2123 2123 owl_list *fl; 2124 2124 owl_filter *f; … … 2173 2173 } 2174 2174 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 */ 2182 char *owl_function_zuserfilt(char *user) 2176 2183 { 2177 2184 owl_filter *f; … … 2188 2195 /* if it already exists then go with it. This lets users override */ 2189 2196 if (owl_global_get_filter(&g, filtname)) { 2190 return( filtname);2197 return(owl_strdup(filtname)); 2191 2198 } 2192 2199 … … 2212 2219 } 2213 2220 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 */ 2227 char *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 2260 char *owl_function_typefilt(char *type) 2215 2261 { 2216 2262 owl_filter *f; … … 2263 2309 } 2264 2310 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 */ 2265 2325 char *owl_function_smartfilter(int type) 2266 2326 { 2267 /* Returns the name of a filter, or null. The caller2268 * must free this name. */2269 /* if the curmsg is a personal message return a filter name2270 * 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 then2274 * return a filter name for just the class.2275 * If the curmsg is a class message and type==1 then2276 * return a filter name for the class and instance.2277 */2278 2327 owl_view *v; 2279 2328 owl_message *m; … … 2290 2339 /* very simple handling of admin messages for now */ 2291 2340 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); 2293 2352 } 2294 2353 … … 2301 2360 zperson=short_zuser(owl_message_get_recipient(m)); 2302 2361 } 2303 filtname=owl_function_ fastuserfilt(zperson);2362 filtname=owl_function_zuserfilt(zperson); 2304 2363 owl_free(zperson); 2305 2364 return(filtname); … … 2309 2368 2310 2369 /* 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)); 2314 2372 return(filtname); 2315 2373 } … … 2317 2375 /* otherwise narrow to the class */ 2318 2376 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); 2320 2378 } 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)); 2322 2380 } 2323 2381 return(filtname);
Note: See TracChangeset
for help on using the changeset viewer.