Changeset 93ee554 for functions.c
- Timestamp:
- Dec 23, 2007, 7:52:17 PM (17 years ago)
- Branches:
- master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 5bc0f68
- Parents:
- 34509d5 (diff), 78667f3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r34509d5 r93ee554 580 580 581 581 if (i>owl_view_get_size(v)-1) i=owl_view_get_size(v)-1; 582 if (i<0) i=0; 582 583 583 584 if (!found) { … … 848 849 { 849 850 int ret, ret2; 850 char *foo ;851 char *foo, *path; 851 852 852 853 if (file==NULL) { 853 854 ret=owl_zephyr_loadsubs(NULL, 0); 854 855 } else { 855 ret=owl_zephyr_loadsubs(file, 1); 856 path = owl_util_makepath(file); 857 ret=owl_zephyr_loadsubs(path, 1); 858 free(path); 856 859 } 857 860 … … 2057 2060 /* if it's a zephyr we sent, send it out the same way again */ 2058 2061 if (owl_message_is_direction_out(m)) { 2059 owl_function_zwrite_setup(owl_message_get_zwriteline(m)); 2060 owl_global_set_buffercommand(&g, owl_message_get_zwriteline(m)); 2061 return; 2062 buff = owl_strdup(owl_message_get_zwriteline(m)); 2063 } else { 2064 2065 /* Special case a personal reply to a webzephyr user on a class */ 2066 if ((type==1) && !strcasecmp(owl_message_get_opcode(m), OWL_WEBZEPHYR_OPCODE)) { 2067 class=OWL_WEBZEPHYR_CLASS; 2068 inst=owl_message_get_sender(m); 2069 to=OWL_WEBZEPHYR_PRINCIPAL; 2070 } else if (!strcasecmp(owl_message_get_class(m), OWL_WEBZEPHYR_CLASS) && owl_message_is_loginout(m)) { 2071 /* Special case LOGIN/LOGOUT notifications on class "webzephyr" */ 2072 class=OWL_WEBZEPHYR_CLASS; 2073 inst=owl_message_get_instance(m); 2074 to=OWL_WEBZEPHYR_PRINCIPAL; 2075 } else if (owl_message_is_loginout(m)) { 2076 /* Normal LOGIN/LOGOUT messages */ 2077 class="MESSAGE"; 2078 inst="PERSONAL"; 2079 to=owl_message_get_sender(m); 2080 } else if (type==1) { 2081 /* Personal reply */ 2082 class="MESSAGE"; 2083 inst="PERSONAL"; 2084 to=owl_message_get_sender(m); 2085 } else { 2086 /* General reply */ 2087 class=owl_message_get_class(m); 2088 inst=owl_message_get_instance(m); 2089 to=owl_message_get_recipient(m); 2090 cc=owl_message_get_cc_without_recipient(m); 2091 if (!strcmp(to, "") || !strcmp(to, "*")) { 2092 to=""; 2093 } else if (to[0]=='@') { 2094 /* leave it, to get the realm */ 2095 } else { 2096 to=owl_message_get_sender(m); 2097 } 2098 } 2099 2100 /* create the command line */ 2101 if (!strcasecmp(owl_message_get_opcode(m), "CRYPT")) { 2102 buff=owl_strdup("zcrypt"); 2103 } else { 2104 buff = owl_strdup("zwrite"); 2105 } 2106 if (strcasecmp(class, "message")) { 2107 buff = owl_sprintf("%s -c %s%s%s", oldbuff=buff, owl_getquoting(class), class, owl_getquoting(class)); 2108 owl_free(oldbuff); 2109 } 2110 if (strcasecmp(inst, "personal")) { 2111 buff = owl_sprintf("%s -i %s%s%s", oldbuff=buff, owl_getquoting(inst), inst, owl_getquoting(inst)); 2112 owl_free(oldbuff); 2113 } 2114 if (*to != '\0') { 2115 char *tmp, *oldtmp, *tmp2; 2116 tmp=short_zuser(to); 2117 if (cc) { 2118 tmp = owl_util_uniq(oldtmp=tmp, cc, "-"); 2119 owl_free(oldtmp); 2120 buff = owl_sprintf("%s -C %s", oldbuff=buff, tmp); 2121 owl_free(oldbuff); 2122 } else { 2123 if (owl_global_is_smartstrip(&g)) { 2124 tmp2=tmp; 2125 tmp=owl_zephyr_smartstripped_user(tmp2); 2126 owl_free(tmp2); 2127 } 2128 buff = owl_sprintf("%s %s", oldbuff=buff, tmp); 2129 owl_free(oldbuff); 2130 } 2131 owl_free(tmp); 2132 } 2133 if (cc) owl_free(cc); 2062 2134 } 2063 2064 /* Special case a personal reply to a webzephyr user on a class */2065 if ((type==1) && !strcasecmp(owl_message_get_opcode(m), OWL_WEBZEPHYR_OPCODE)) {2066 class=OWL_WEBZEPHYR_CLASS;2067 inst=owl_message_get_sender(m);2068 to=OWL_WEBZEPHYR_PRINCIPAL;2069 } else if (!strcasecmp(owl_message_get_class(m), OWL_WEBZEPHYR_CLASS) && owl_message_is_loginout(m)) {2070 /* Special case LOGIN/LOGOUT notifications on class "webzephyr" */2071 class=OWL_WEBZEPHYR_CLASS;2072 inst=owl_message_get_instance(m);2073 to=OWL_WEBZEPHYR_PRINCIPAL;2074 } else if (owl_message_is_loginout(m)) {2075 /* Normal LOGIN/LOGOUT messages */2076 class="MESSAGE";2077 inst="PERSONAL";2078 to=owl_message_get_sender(m);2079 } else if (type==1) {2080 /* Personal reply */2081 class="MESSAGE";2082 inst="PERSONAL";2083 to=owl_message_get_sender(m);2084 } else {2085 /* General reply */2086 class=owl_message_get_class(m);2087 inst=owl_message_get_instance(m);2088 to=owl_message_get_recipient(m);2089 cc=owl_message_get_cc_without_recipient(m);2090 if (!strcmp(to, "") || !strcmp(to, "*")) {2091 to="";2092 } else if (to[0]=='@') {2093 /* leave it, to get the realm */2094 } else {2095 to=owl_message_get_sender(m);2096 }2097 }2098 2099 /* create the command line */2100 if (!strcasecmp(owl_message_get_opcode(m), "CRYPT")) {2101 buff=owl_strdup("zcrypt");2102 } else {2103 buff = owl_strdup("zwrite");2104 }2105 if (strcasecmp(class, "message")) {2106 buff = owl_sprintf("%s -c %s%s%s", oldbuff=buff, owl_getquoting(class), class, owl_getquoting(class));2107 owl_free(oldbuff);2108 }2109 if (strcasecmp(inst, "personal")) {2110 buff = owl_sprintf("%s -i %s%s%s", oldbuff=buff, owl_getquoting(inst), inst, owl_getquoting(inst));2111 owl_free(oldbuff);2112 }2113 if (*to != '\0') {2114 char *tmp, *oldtmp, *tmp2;2115 tmp=short_zuser(to);2116 if (cc) {2117 tmp = owl_util_uniq(oldtmp=tmp, cc, "-");2118 owl_free(oldtmp);2119 buff = owl_sprintf("%s -C %s", oldbuff=buff, tmp);2120 owl_free(oldbuff);2121 } else {2122 if (owl_global_is_smartstrip(&g)) {2123 tmp2=tmp;2124 tmp=owl_zephyr_smartstripped_user(tmp2);2125 owl_free(tmp2);2126 }2127 buff = owl_sprintf("%s %s", oldbuff=buff, tmp);2128 owl_free(oldbuff);2129 }2130 owl_free(tmp);2131 }2132 if (cc) owl_free(cc);2133 2135 } else if (owl_message_is_type_aim(m)) { 2134 2136 /* aim */ … … 2557 2559 for (i=0; i<j; i++) { 2558 2560 f=owl_list_get_element(fl, i); 2561 snprintf(buff, sizeof(buff), "[% 2d] ", i+1); 2562 owl_fmtext_append_normal(&fm, buff); 2559 2563 owl_filter_print(f, buff); 2560 2564 owl_fmtext_append_normal(&fm, buff); … … 2622 2626 sprintf(argbuff, "class ^(un)*%s(\\.d)*$", tmpclass); 2623 2627 if (tmpinstance) { 2624 sprintf(argbuff, "%s and ( instance ^ %s(\\.d)*$ )", argbuff, tmpinstance);2628 sprintf(argbuff, "%s and ( instance ^(un)*%s(\\.d)*$ )", argbuff, tmpinstance); 2625 2629 } 2626 2630 owl_free(tmpclass); … … 2670 2674 2671 2675 argbuff=owl_malloc(strlen(longuser)+1000); 2672 sprintf(argbuff, "( type ^zephyr$ and ( class ^message$ and instance ^personal$and ");2676 sprintf(argbuff, "( type ^zephyr$ and filter personal and "); 2673 2677 sprintf(argbuff, "%s ( ( direction ^in$ and sender ^%s$ ) or ( direction ^out$ and recipient ^%s$ ) ) )", argbuff, longuser, longuser); 2674 sprintf(argbuff, "%s or ( ( class ^login$ ) and ( sender ^%s$ ) ) )", argbuff, longuser);2678 sprintf(argbuff, "%s or ( ( class ^login$ ) and ( sender ^%s$ ) )", argbuff, longuser); 2675 2679 2676 2680 owl_filter_init_fromstring(f, filtname, argbuff); … … 2800 2804 owl_message *m; 2801 2805 char *zperson, *filtname=NULL; 2806 char *argv[1]; 2802 2807 2803 2808 v=owl_global_get_current_view(&g); … … 2831 2836 /* narrow personal and login messages to the sender or recip as appropriate */ 2832 2837 if (owl_message_is_type_zephyr(m)) { 2833 if (owl_message_is_p rivate(m) || owl_message_is_loginout(m)) {2838 if (owl_message_is_personal(m) || owl_message_is_loginout(m)) { 2834 2839 if (owl_message_is_direction_in(m)) { 2835 2840 zperson=short_zuser(owl_message_get_sender(m)); … … 2858 2863 2859 2864 /* pass it off to perl */ 2860 char *argv[1];2861 2865 if(type) { 2862 2866 argv[0] = "-i"; … … 3016 3020 void owl_function_zpunt(char *class, char *inst, char *recip, int direction) 3017 3021 { 3018 owl_filter *f;3019 owl_list *fl;3020 3022 char *buff; 3021 3023 char *quoted; 3022 int ret, i, j; 3023 3024 fl=owl_global_get_puntlist(&g); 3025 3026 /* first, create the filter */ 3027 f=owl_malloc(sizeof(owl_filter)); 3024 3028 3025 buff=owl_malloc(strlen(class)+strlen(inst)+strlen(recip)+100); 3029 3026 strcpy(buff, "class"); … … 3056 3053 owl_free(quoted); 3057 3054 } 3058 3059 owl_function_debugmsg("About to filter %s", buff); 3060 ret=owl_filter_init_fromstring(f, "punt-filter", buff); 3055 3056 owl_function_punt(buff, direction); 3061 3057 owl_free(buff); 3058 } 3059 3060 void owl_function_punt(char *filter, int direction) 3061 { 3062 owl_filter *f; 3063 owl_list *fl; 3064 int ret, i, j; 3065 fl=owl_global_get_puntlist(&g); 3066 3067 /* first, create the filter */ 3068 f=malloc(sizeof(owl_filter)); 3069 3070 owl_function_debugmsg("About to filter %s", filter); 3071 ret=owl_filter_init_fromstring(f, "punt-filter", filter); 3062 3072 if (ret) { 3063 3073 owl_function_error("Error creating filter for zpunt"); … … 3070 3080 for (i=0; i<j; i++) { 3071 3081 if (owl_filter_equiv(f, owl_list_get_element(fl, i))) { 3082 owl_function_debugmsg("found an equivalent punt filter"); 3072 3083 /* if we're punting, then just silently bow out on this duplicate */ 3073 3084 if (direction==0) { … … 3080 3091 owl_filter_free(owl_list_get_element(fl, i)); 3081 3092 owl_list_remove_element(fl, i); 3093 owl_filter_free(f); 3082 3094 return; 3083 3095 } … … 3085 3097 } 3086 3098 3099 owl_function_debugmsg("punting"); 3087 3100 /* If we're punting, add the filter to the global punt list */ 3088 3101 if (direction==0) { … … 3461 3474 char *filename; 3462 3475 3463 filename=owl_ sprintf("%s/%s", owl_global_get_homedir(&g), OWL_STARTUP_FILE);3476 filename=owl_global_get_startupfile(&g); 3464 3477 file=fopen(filename, "a"); 3465 3478 if (!file) { 3466 3479 owl_function_error("Error opening startupfile for new command"); 3467 owl_free(filename);3468 3480 return; 3469 3481 } … … 3471 3483 /* delete earlier copies */ 3472 3484 owl_util_file_deleteline(filename, buff, 1); 3473 owl_free(filename);3474 3485 3475 3486 /* add this line */ … … 3483 3494 { 3484 3495 char *filename; 3485 filename=owl_ sprintf("%s/%s", owl_global_get_homedir(&g), OWL_STARTUP_FILE);3496 filename=owl_global_get_startupfile(&g); 3486 3497 owl_util_file_deleteline(filename, buff, 1); 3487 owl_free(filename);3488 3498 } 3489 3499 … … 3497 3507 3498 3508 if (!filename) { 3499 filename=owl_ sprintf("%s/%s", owl_global_get_homedir(&g), OWL_STARTUP_FILE);3509 filename=owl_global_get_startupfile(&g); 3500 3510 file=fopen(filename, "r"); 3501 owl_free(filename);3502 3511 } else { 3503 3512 file=fopen(filename, "r");
Note: See TracChangeset
for help on using the changeset viewer.