Merge branch 'master' into nohook
authorPierre Habouzit <madcoder@debian.org>
Sun, 18 Nov 2007 12:31:56 +0000 (13:31 +0100)
committerPierre Habouzit <madcoder@debian.org>
Sun, 18 Nov 2007 12:31:56 +0000 (13:31 +0100)
1  2 
crypt.cpkg
lib-mx/mx.c
protos.h
send.c

diff --combined crypt.cpkg
@@@ -326,7 -326,7 +326,7 @@@ static gpgme_ctx_t create_gpgme_context
      if (err) {
          mutt_error(_("error creating gpgme context: %s\n"),
                     gpgme_strerror(err));
-         sleep(2);
+         mutt_sleep(2);
          mutt_exit(1);
      }
      if (!for_smime)
      err = gpgme_set_protocol(ctx, GPGME_PROTOCOL_CMS);
      if (err) {
          mutt_error(_("error enabling CMS protocol: %s\n"), gpgme_strerror(err));
-         sleep(2);
+         mutt_sleep(2);
          mutt_exit(1);
      }
      return ctx;
@@@ -352,7 -352,7 +352,7 @@@ static gpgme_data_t create_gpgme_data(v
      if (err) {
          mutt_error(_("error creating gpgme data object: %s\n"),
                     gpgme_strerror(err));
-         sleep(2);
+         mutt_sleep(2);
          mutt_exit(1);
      }
      return data;
@@@ -3400,23 -3400,6 +3400,23 @@@ crypt_ask_for_key(const char *tag, int 
      }
  }
  
 +static char *crypt_hook(address_t *adr)
 +{
 +    char *res = NULL;
 +    lua_State *L = luaM_getruntime();
 +    lua_getglobal(L, "mod_core");             /* push mod_core        1 */
 +    lua_getfield(L, -1, "crypt_hook");        /* push folder_hook()   2 */
 +    if (lua_isfunction(L, -1)) {
 +        lua_pushstring(L, adr->mailbox);
 +        if (!lua_pcall(L, 1, 1, 0)) {
 +            res = m_strdup(lua_tostring(L, -1));
 +        }
 +        lua_pop(L, 1);
 +    }
 +    lua_pop(L, 2);
 +    return res;
 +}
 +
  /* This routine attempts to find the keyids of the recipients of a
     message.  It returns NULL if any of the keys can not be found.  */
  static char *find_keys(ENVELOPE *env, unsigned int app)
      while ((addr = address_list_pop(&lst))) {
          char buf[STRING];
          int forced_valid = 0;
 -        const char *keyID;
 +        char *keyID;
          cryptkey_t *key = NULL;
  
 -        if ((keyID = mutt_crypt_hook(addr))) {
 +        if ((keyID = crypt_hook(addr))) {
              int r;
  
              snprintf(buf, sizeof(buf), _("Use keyID = \"%s\" for %s?"), keyID,
                  address_list_wipe(&lst);
                  address_list_wipe(&addr);
                  buffer_delete(&keylist);
 +                p_delete(&keyID);
                  return NULL;
              }
  
                  }
              }
          }
 +        p_delete(&keyID);
  
          if (!key) {
              key = crypt_getkeybyaddr(addr, KEYFLAG_CANENCRYPT, app, &forced_valid);
diff --combined lib-mx/mx.c
@@@ -139,7 -139,7 +139,7 @@@ int mx_lock_file (const char *path, in
          prev_sb = sb;
  
          mutt_message (_("Waiting for fcntl lock... %d"), ++attempt);
-         sleep (1);
+         mutt_sleep (1);
      }
  #endif /* USE_FCNTL */
  
          prev_sb = sb;
  
          mutt_message (_("Waiting for flock attempt... %d"), ++attempt);
-         sleep (1);
+         mutt_sleep (1);
      }
  #endif /* USE_FLOCK */
  
@@@ -600,8 -600,14 +600,8 @@@ static int _mx_close_mailbox (CONTEXT 
    if (read_msgs && quadoption (OPT_MOVE) != M_NO) {
      char *p;
  
 -    if ((p = mutt_find_hook (M_MBOXHOOK, ctx->path))) {
 -      isSpool = 1;
 -      m_strcpy(mbox, sizeof(mbox), p);
 -    }
 -    else {
 -      m_strcpy(mbox, sizeof(mbox), NONULL(Inbox));
 -      isSpool = mutt_is_spool (ctx->path) && !mutt_is_spool (mbox);
 -    }
 +    m_strcpy(mbox, sizeof(mbox), NONULL(Inbox));
 +    isSpool = mutt_is_spool (ctx->path) && !mutt_is_spool (mbox);
      mutt_expand_path (mbox, sizeof (mbox));
  
      if (isSpool) {
diff --combined protos.h
+++ b/protos.h
@@@ -7,6 -7,7 +7,7 @@@
   * please see the file GPL in the top level source directory.
   */
  
+ extern const char *madmutt_version;
  
  /* use the m_temp{fd,file} functions instead */
  void mutt_adv_mktemp (const char*, char*, ssize_t) __attribute__((deprecated));
@@@ -37,12 -38,12 +38,10 @@@ int mutt_cmp_header (const HEADER*, con
  ssize_t _mutt_expand_path(char *, ssize_t, const char *, int);
  #define mutt_expand_path(s, n) _mutt_expand_path((s), (n), (s), 0)
  
 -char *mutt_find_hook (int, const char *);
  char *mutt_get_body_charset (char *, ssize_t, BODY *);
  const char *mutt_get_name (address_t *);
 -const char *mutt_crypt_hook (address_t *);
  char *mutt_make_date (char *, ssize_t);
  
- const char *mutt_make_version(void);
  const char *mutt_fqdn (short);
  
  void mutt_add_to_reference_headers (ENVELOPE * env, ENVELOPE * curenv,
@@@ -72,6 -73,7 +71,6 @@@ void mutt_pipe_message (HEADER *)
  void mutt_print_message (HEADER *);
  void mutt_safe_path (char *s, ssize_t l, address_t * a);
  void mutt_save_path (char *s, ssize_t l, address_t * a);
 -void mutt_select_fcc (char *, ssize_t, HEADER *);
  
  void mutt_message_hook (CONTEXT *, HEADER *, int);
  void _mutt_set_flag (CONTEXT *, HEADER *, int, int, int);
@@@ -82,7 -84,6 +81,6 @@@ void mutt_shell_escape (void)
  void mutt_stamp_attachment (BODY * a);
  void mutt_tag_set_flag (int, int);
  void mutt_update_encoding (BODY * a);
- void mutt_version (void);
  void mutt_write_references (string_list_t *, FILE *);
  void mutt_write_address_list (address_t * adr, FILE * fp, int linelen,
                                int display);
@@@ -101,6 -102,7 +99,6 @@@ int mutt_fetch_recips (ENVELOPE * out, 
  int mutt_prepare_template (FILE *, CONTEXT *, HEADER *, HEADER *, short);
  int mutt_resend_message (FILE *, CONTEXT *, HEADER *);
  
 -int mutt_get_hook_type (const char *);
  int mutt_get_postponed (CONTEXT *, HEADER *, HEADER **, char *, ssize_t);
  int mutt_invoke_mta (address_t *, address_t *, address_t *, address_t *, const char *,
                       int);
@@@ -110,9 -112,11 +108,9 @@@ int mutt_lookup_mime_type (BODY *, cons
  int mutt_num_postponed (int);
  int mutt_parse_bind (BUFFER *, BUFFER *, unsigned long, BUFFER *);
  int mutt_parse_exec (BUFFER *, BUFFER *, unsigned long, BUFFER *);
 -int mutt_parse_hook (BUFFER *, BUFFER *, unsigned long, BUFFER *);
  int mutt_parse_macro (BUFFER *, BUFFER *, unsigned long, BUFFER *);
  int mutt_parse_push (BUFFER *, BUFFER *, unsigned long, BUFFER *);
  int mutt_parse_rc_line (const char *, BUFFER *, BUFFER *);
 -int mutt_parse_unhook (BUFFER *, BUFFER *, unsigned long, BUFFER *);
  int _mutt_save_message (HEADER *, CONTEXT *, int, int, int);
  int mutt_save_message (HEADER *, int, int, int, int *);
  int mutt_search_command (int, int);
diff --combined send.c
--- 1/send.c
--- 2/send.c
+++ b/send.c
@@@ -274,7 -274,7 +274,7 @@@ static int edit_envelope (ENVELOPE * en
      }
      else {
        mutt_error (_("Ignoring $strip_was: Subject would be empty."));
-       sleep (2);
+       mutt_sleep (2);
      }
    }
    if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) != 0 || (!buf[0]
@@@ -1340,8 -1340,7 +1340,8 @@@ int ci_send_message (int flags, /* sen
        killfrom = 1;             /* no need to check $use_from because if the user specified
                                     a from address it would have already been set by now */
      }
 -    mutt_select_fcc (fcc, sizeof (fcc), msg);
 +    m_strcpy(fcc, sizeof(fcc), NONULL(MAlias.record));
 +    mutt_pretty_mailbox(fcc);
      if (killfrom) {
        address_list_wipe(&msg->env->from);
        killfrom = 0;
      if (quadoption (OPT_ATTACH) == M_YES) {
        mutt_message _("No attachments made but indicator found in text. "
                       "Abort sending.");
-       sleep (2);
+       mutt_sleep (2);
      }
      mutt_message (_("Mail not sent."));
      goto main_loop;