Changeset 740d5f7 for functions.c


Ignore:
Timestamp:
Aug 25, 2008, 8:11:16 PM (16 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
f830d84
Parents:
147d880
Message:
Move Zephyr and AIM reply command logic into perl.

This has the side effect of fixing quoting, so you can now correctly
reply to instances like ["can't touch this"].
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    rcdc6ff1 r740d5f7  
    20202020void owl_function_reply(int type, int enter)
    20212021{
    2022   char *buff=NULL, *oldbuff;
     2022  char *buff=NULL;
    20232023  owl_message *m;
    20242024  owl_filter *f;
     
    20272027    owl_function_error("No message selected");
    20282028  } else {
    2029     char *class, *inst, *to, *cc=NULL;
    20302029   
    20312030    m=owl_view_get_element(owl_global_get_current_view(&g), owl_global_get_curmsg(&g));
     
    20442043    }
    20452044
    2046     /* loopback */
    2047     if (owl_message_is_type_loopback(m)) {
    2048       owl_function_loopwrite_setup();
    2049       return;
    2050     }
    2051 
    2052     /* zephyr */
    2053     if (owl_message_is_type_zephyr(m)) {
    2054       /* if it's a zephyr we sent, send it out the same way again */
    2055       if (owl_message_is_direction_out(m)) {
    2056           buff = owl_strdup(owl_message_get_zwriteline(m));
    2057       } else {
    2058 
    2059         /* Special case a personal reply to a webzephyr user on a class */
    2060         if ((type==1) && !strcasecmp(owl_message_get_opcode(m), OWL_WEBZEPHYR_OPCODE)) {
    2061           class=OWL_WEBZEPHYR_CLASS;
    2062           inst=owl_message_get_sender(m);
    2063           to=OWL_WEBZEPHYR_PRINCIPAL;
    2064         } else if (!strcasecmp(owl_message_get_class(m), OWL_WEBZEPHYR_CLASS) && owl_message_is_loginout(m)) {
    2065           /* Special case LOGIN/LOGOUT notifications on class "webzephyr" */
    2066           class=OWL_WEBZEPHYR_CLASS;
    2067           inst=owl_message_get_instance(m);
    2068           to=OWL_WEBZEPHYR_PRINCIPAL;
    2069         } else if (owl_message_is_loginout(m)) {
    2070           /* Normal LOGIN/LOGOUT messages */
    2071           class="MESSAGE";
    2072           inst="PERSONAL";
    2073           to=owl_message_get_sender(m);
    2074         } else if (type==1) {
    2075           /* Personal reply */
    2076           class="MESSAGE";
    2077           inst="PERSONAL";
    2078           to=owl_message_get_sender(m);
    2079         } else {
    2080           /* General reply */
    2081           class=owl_message_get_class(m);
    2082           inst=owl_message_get_instance(m);
    2083           to=owl_message_get_recipient(m);
    2084           cc=owl_message_get_cc_without_recipient(m);
    2085           if (!strcmp(to, "") || !strcmp(to, "*")) {
    2086             to="";
    2087           } else if (to[0]=='@') {
    2088             /* leave it, to get the realm */
    2089           } else {
    2090             to=owl_message_get_sender(m);
    2091           }
    2092         }
    2093 
    2094         /* create the command line */
    2095         if (!strcasecmp(owl_message_get_opcode(m), "CRYPT")) {
    2096           buff=owl_strdup("zcrypt");
    2097         } else {
    2098           buff = owl_strdup("zwrite");
    2099         }
    2100         if (strcasecmp(class, "message")) {
    2101           buff = owl_sprintf("%s -c %s%s%s", oldbuff=buff, owl_getquoting(class), class, owl_getquoting(class));
    2102           owl_free(oldbuff);
    2103         }
    2104         if (strcasecmp(inst, "personal")) {
    2105           buff = owl_sprintf("%s -i %s%s%s", oldbuff=buff, owl_getquoting(inst), inst, owl_getquoting(inst));
    2106           owl_free(oldbuff);
    2107         }
    2108         if (*to != '\0') {
    2109           char *tmp, *oldtmp, *tmp2;
    2110           tmp=short_zuser(to);
    2111           if (cc) {
    2112             tmp = owl_util_uniq(oldtmp=tmp, cc, "-");
    2113             owl_free(oldtmp);
    2114             buff = owl_sprintf("%s -C %s", oldbuff=buff, tmp);
    2115             owl_free(oldbuff);
    2116           } else {
    2117             if (owl_global_is_smartstrip(&g)) {
    2118               tmp2=tmp;
    2119               tmp=owl_zephyr_smartstripped_user(tmp2);
    2120               owl_free(tmp2);
    2121             }
    2122             buff = owl_sprintf("%s %s", oldbuff=buff, tmp);
    2123             owl_free(oldbuff);
    2124           }
    2125           owl_free(tmp);
    2126         }
    2127         if (cc) owl_free(cc);
    2128       }
    2129     } else if (owl_message_is_type_aim(m)) {
    2130       /* aim */
    2131       if (owl_message_is_direction_out(m)) {
    2132         buff=owl_sprintf("aimwrite %s", owl_message_get_recipient(m));
    2133       } else {
    2134         buff=owl_sprintf("aimwrite %s", owl_message_get_sender(m));
    2135       }
    2136     } else {
    2137       char *cmd;
    2138       if((type == 0 &&
    2139           (cmd=owl_perlconfig_message_call_method(m, "replycmd", 0, NULL))) ||
    2140          (type == 1 &&
    2141           (cmd=owl_perlconfig_message_call_method(m, "replysendercmd", 0, NULL)))) {
    2142         buff = cmd;
    2143       }
     2045    char *cmd;
     2046    if((type == 0 &&
     2047        (cmd=owl_perlconfig_message_call_method(m, "replycmd", 0, NULL))) ||
     2048       (type == 1 &&
     2049        (cmd=owl_perlconfig_message_call_method(m, "replysendercmd", 0, NULL)))) {
     2050      buff = cmd;
    21442051    }
    21452052
     
    21482055        return;
    21492056    }
    2150    
     2057
    21512058    if (enter) {
    21522059      owl_history *hist = owl_global_get_cmd_history(&g);
Note: See TracChangeset for help on using the changeset viewer.