Changeset 3783:9af868b4220d

Show
Ignore:
Timestamp:
2004-12-07 11:50:04 (4 years ago)
Author:
Thomas Roessler <roessler@…>
Branch:
HEAD
Message:

Add send2-hook and fix alternates handling.

Files:
6 modified

Legend:

Unmodified
Added
Removed
  • compose.c

    r3761 r3783  
    528528      case OP_COMPOSE_EDIT_FROM: 
    529529        menu->redraw = edit_address_list (HDR_FROM, &msg->env->from); 
     530        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
    530531        break; 
    531532      case OP_COMPOSE_EDIT_TO: 
    532533        menu->redraw = edit_address_list (HDR_TO, &msg->env->to); 
    533         break; 
     534        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
     535        break; 
    534536      case OP_COMPOSE_EDIT_BCC: 
    535537        menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc); 
     538        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
    536539        break; 
    537540      case OP_COMPOSE_EDIT_CC: 
    538541        menu->redraw = edit_address_list (HDR_CC, &msg->env->cc); 
    539         break; 
     542        mutt_message_hook (NULL, msg, M_SEND2HOOK);      
     543        break; 
    540544      case OP_COMPOSE_EDIT_SUBJECT: 
    541545        if (msg->env->subject) 
     
    551555            mutt_paddstr (W, msg->env->subject); 
    552556        } 
    553         break; 
     557        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
     558        break; 
    554559      case OP_COMPOSE_EDIT_REPLY_TO: 
    555560        menu->redraw = edit_address_list (HDR_REPLYTO, &msg->env->reply_to); 
     561        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
    556562        break; 
    557563      case OP_COMPOSE_EDIT_FCC: 
     
    566572        } 
    567573        MAYBE_REDRAW (menu->redraw); 
    568         break; 
     574        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
     575        break; 
    569576      case OP_COMPOSE_EDIT_MESSAGE: 
    570577        if (Editor && (mutt_strcmp ("builtin", Editor) != 0) && !option (OPTEDITHDRS)) 
     
    573580          mutt_update_encoding (msg->content); 
    574581          menu->redraw = REDRAW_CURRENT | REDRAW_STATUS; 
     582          mutt_message_hook (NULL, msg, M_SEND2HOOK); 
    575583          break; 
    576584        } 
     
    612620        } 
    613621 
    614         menu->redraw = REDRAW_FULL; 
     622        menu->redraw = REDRAW_FULL; 
     623        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
    615624        break; 
    616625 
     
    643652        } 
    644653         
    645         break; 
     654        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
     655        break; 
    646656 
    647657 
     
    689699          menu->redraw |= REDRAW_INDEX | REDRAW_STATUS; 
    690700        } 
    691         break; 
     701        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
     702        break; 
    692703 
    693704      case OP_COMPOSE_ATTACH_MESSAGE: 
     
    795806          SortAux = oldSortAux; 
    796807        } 
    797         break; 
     808        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
     809        break; 
    798810 
    799811      case OP_DELETE: 
     
    814826 
    815827        menu->redraw |= REDRAW_STATUS; 
    816         break; 
     828        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
     829        break; 
    817830 
    818831#define CURRENT idx[menu->current]->content 
     
    832845          mutt_message (_("The current attachment will be converted.")); 
    833846        menu->redraw = REDRAW_CURRENT; 
     847        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
    834848        break; 
    835849      } 
     
    848862          menu->redraw = REDRAW_CURRENT; 
    849863        } 
    850         break; 
     864        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
     865        break; 
    851866 
    852867      case OP_COMPOSE_UPDATE_ENCODING: 
     
    867882          menu->redraw = REDRAW_CURRENT | REDRAW_STATUS; 
    868883        } 
     884        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
    869885        break; 
    870886       
     
    885901          menu->redraw = REDRAW_CURRENT; 
    886902        } 
    887         break; 
     903        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
     904        break; 
    888905 
    889906      case OP_COMPOSE_EDIT_ENCODING: 
     
    903920            mutt_error _("Invalid encoding."); 
    904921        } 
    905         break; 
     922        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
     923        break; 
    906924 
    907925      case OP_COMPOSE_SEND_MESSAGE: 
     926 
     927        /* Note: We don't invoke send2-hook here, since we want to leave 
     928         * users an opportunity to change settings from the ":" prompt. 
     929         */ 
    908930       
    909931        if(check_attachments(idx, idxlen) != 0) 
     
    937959        mutt_update_encoding (idx[menu->current]->content); 
    938960        menu->redraw = REDRAW_CURRENT | REDRAW_STATUS; 
     961        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
    939962        break; 
    940963 
     
    952975# endif 
    953976        menu->redraw = REDRAW_INDEX; 
     977        /* No send2hook since this doesn't change the message. */ 
    954978        break; 
    955979 
     
    969993          menu->redraw = REDRAW_CURRENT; 
    970994 
     995        /* No send2hook since this doesn't change the message. */ 
    971996        break; 
    972997       
     
    9951020           
    9961021        } 
    997         break; 
     1022        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
     1023        break; 
    9981024 
    9991025      case OP_COMPOSE_NEW_MIME: 
     
    10621088          } 
    10631089        } 
    1064         break; 
     1090        mutt_message_hook (NULL, msg, M_SEND2HOOK);     
     1091        break; 
    10651092 
    10661093      case OP_COMPOSE_EDIT_MIME: 
     
    10711098          menu->redraw = REDRAW_FULL; 
    10721099        } 
    1073         break; 
     1100        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
     1101        break; 
    10741102 
    10751103      case OP_VIEW_ATTACH: 
     
    10781106        mutt_attach_display_loop (menu, op, NULL, NULL, NULL, &idx, &idxlen, NULL, 0); 
    10791107        menu->redraw = REDRAW_FULL; 
     1108        /* no send2hook, since this doesn't modify the message */ 
    10801109        break; 
    10811110 
     
    10841113        mutt_save_attachment_list (NULL, menu->tagprefix, menu->tagprefix ?  msg->content : idx[menu->current]->content, NULL, menu); 
    10851114        MAYBE_REDRAW (menu->redraw); 
     1115        /* no send2hook, since this doesn't modify the message */ 
    10861116        break; 
    10871117 
     
    10891119        CHECK_COUNT; 
    10901120        mutt_print_attachment_list (NULL, menu->tagprefix, menu->tagprefix ? msg->content : idx[menu->current]->content); 
     1121        /* no send2hook, since this doesn't modify the message */ 
    10911122        break; 
    10921123 
     
    10961127        mutt_pipe_attachment_list (NULL, menu->tagprefix, menu->tagprefix ? msg->content : idx[menu->current]->content, op == OP_FILTER); 
    10971128        if (op == OP_FILTER) /* cte might have changed */ 
    1098           menu->redraw = menu->tagprefix ? REDRAW_FULL : REDRAW_CURRENT;  
     1129          menu->redraw = menu->tagprefix ? REDRAW_FULL : REDRAW_CURRENT; 
    10991130        menu->redraw |= REDRAW_STATUS; 
     1131        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
    11001132        break; 
    11011133 
     
    11921224        msg->security = crypt_pgp_send_menu (msg, &menu->redraw); 
    11931225        redraw_crypt_lines (msg); 
    1194         break; 
     1226        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
     1227        break; 
    11951228 
    11961229 
     
    12171250        msg->security = crypt_smime_send_menu(msg, &menu->redraw); 
    12181251        redraw_crypt_lines (msg); 
    1219         break; 
     1252        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
     1253        break; 
    12201254 
    12211255 
     
    12241258       
    12251259        mix_make_chain (&msg->chain, &menu->redraw); 
     1260        mutt_message_hook (NULL, msg, M_SEND2HOOK); 
    12261261        break; 
    12271262#endif 
  • hook.c

    r3558 r3783  
    6767  } 
    6868 
    69   mutt_extract_token (&command, s, (data & (M_FOLDERHOOK | M_SENDHOOK | M_ACCOUNTHOOK | M_REPLYHOOK)) ?  M_TOKEN_SPACE : 0); 
     69  mutt_extract_token (&command, s, (data & (M_FOLDERHOOK | M_SENDHOOK | M_SEND2HOOK | M_ACCOUNTHOOK | M_REPLYHOOK)) ?  M_TOKEN_SPACE : 0); 
    7070 
    7171  if (!command.data) 
     
    118118        !mutt_strcmp (pattern.data, ptr->rx.pattern)) 
    119119    { 
    120       if (data & (M_FOLDERHOOK | M_SENDHOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_REPLYHOOK)) 
     120      if (data & (M_FOLDERHOOK | M_SENDHOOK | M_SEND2HOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_REPLYHOOK)) 
    121121      { 
    122122        /* these hooks allow multiple commands with the same 
     
    147147  } 
    148148 
    149   if (data & (M_SENDHOOK | M_SAVEHOOK | M_FCCHOOK | M_MESSAGEHOOK | M_REPLYHOOK)) 
     149  if (data & (M_SENDHOOK | M_SEND2HOOK | M_SAVEHOOK | M_FCCHOOK | M_MESSAGEHOOK | M_REPLYHOOK)) 
    150150  { 
    151151    if ((pat = mutt_pattern_comp (pattern.data, 
    152            (data & (M_SENDHOOK | M_FCCHOOK)) ? 0 : M_FULL_MSG, 
     152           (data & (M_SENDHOOK | M_SEND2HOOK | M_FCCHOOK)) ? 0 : M_FULL_MSG, 
    153153                                  err)) == NULL) 
    154154      goto error; 
  • init.c

    r3757 r3783  
    612612} 
    613613 
     614static void _alternates_clean (void) 
     615{ 
     616  int i; 
     617  if (Context && Context->msgcount)  
     618  { 
     619    for (i = 0; i < Context->msgcount; i++) 
     620      Context->hdrs[i]->recip_valid = 0; 
     621  } 
     622} 
     623 
     624static int parse_alternates (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) 
     625{ 
     626  _alternates_clean(); 
     627  return parse_rx_list (buf, s, data, err); 
     628} 
     629 
     630static int parse_unalternates (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) 
     631{ 
     632  _alternates_clean(); 
     633  return parse_rx_unlist (buf, s, data, err); 
     634} 
     635 
    614636static int parse_spam_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) 
    615637{ 
     
    10671089          pp->rx = safe_calloc (1, sizeof (regex_t)); 
    10681090          pp->pattern = safe_strdup ((char *) p->init); 
    1069           if (mutt_strcmp (p->option, "alternates") == 0) 
    1070             flags |= REG_ICASE; 
    1071           else if (mutt_strcmp (p->option, "mask") != 0) 
     1091          if (mutt_strcmp (p->option, "mask") != 0) 
    10721092            flags |= mutt_which_case ((const char *) p->init); 
    10731093          if (mutt_strcmp (p->option, "mask") == 0 && *s == '!') 
     
    12811301      } 
    12821302 
    1283       if (option(OPTATTACHMSG) && (!mutt_strcmp(MuttVars[idx].option, "alternates") 
    1284                                    || !mutt_strcmp(MuttVars[idx].option, "reply_regexp"))) 
     1303      if (option(OPTATTACHMSG) && !mutt_strcmp(MuttVars[idx].option, "reply_regexp")) 
    12851304      { 
    12861305        snprintf (err->data, err->dsize, "Operation not permitted when in attach-message mode."); 
     
    12981317        int not = 0; 
    12991318 
    1300         /* $alternates is case-insensitive, 
    1301            $mask is case-sensitive */ 
    1302         if (mutt_strcmp (MuttVars[idx].option, "alternates") == 0) 
    1303           flags |= REG_ICASE; 
    1304         else if (mutt_strcmp (MuttVars[idx].option, "mask") != 0) 
     1319        /* $mask is case-sensitive */ 
     1320        if (mutt_strcmp (MuttVars[idx].option, "mask") != 0) 
    13051321          flags |= mutt_which_case (tmp->data); 
    13061322 
     
    13561372          } 
    13571373#undef CUR_ENV 
    1358         } 
    1359          
    1360         if(Context && Context->msgcount && 
    1361            mutt_strcmp(MuttVars[idx].option, "alternates") == 0) 
    1362         { 
    1363           int i; 
    1364            
    1365           for(i = 0; i < Context->msgcount; i++) 
    1366             Context->hdrs[i]->recip_valid = 0; 
    13671374        } 
    13681375      } 
  • init.h

    r3759 r3783  
    28252825static int parse_subscribe (BUFFER *, BUFFER *, unsigned long, BUFFER *); 
    28262826 
     2827static int parse_alternates (BUFFER *, BUFFER *, unsigned long, BUFFER *); 
     2828static int parse_unalternates (BUFFER *, BUFFER *, unsigned long, BUFFER *); 
     2829 
    28272830struct command_t 
    28282831{ 
     
    28332836 
    28342837struct command_t Commands[] = { 
    2835   { "alternates",       parse_rx_list,          UL &Alternates }, 
    2836   { "unalternates",     parse_rx_unlist,        UL &Alternates }, 
     2838  { "alternates",       parse_alternates,       UL &Alternates }, 
     2839  { "unalternates",     parse_unalternates,     UL &Alternates }, 
    28372840#ifdef USE_SOCKET 
    28382841  { "account-hook",     mutt_parse_hook,        M_ACCOUNTHOOK }, 
     
    28742877  { "score",            mutt_parse_score,       0 }, 
    28752878  { "send-hook",        mutt_parse_hook,        M_SENDHOOK }, 
     2879  { "send2-hook",       mutt_parse_hook,        M_SEND2HOOK }, 
    28762880  { "set",              parse_set,              0 }, 
    28772881  { "source",           parse_source,           0 }, 
  • mutt.h

    r3706 r3783  
    161161#define M_ACCOUNTHOOK   (1<<9) 
    162162#define M_REPLYHOOK     (1<<10) 
     163#define M_SEND2HOOK     (1<<11) 
    163164 
    164165/* tree characters for linearize_tree and print_enriched_string */ 
  • send.c

    r3706 r3783  
    13211321      msg->security = 0; 
    13221322  } 
     1323   
     1324  /*  
     1325   * This hook is even called for postponed messages, and can, e.g., be 
     1326   * used for setting the editor, the sendmail path, or the 
     1327   * envelope sender. 
     1328   */ 
     1329  mutt_message_hook (NULL, msg, M_SEND2HOOK); 
     1330   
    13231331  /* wait until now to set the real name portion of our return address so 
    13241332     that $realname can be set in a send-hook */