Пример #1
0
static int edit_address_list (int line, ADDRESS **addr)
{
  char buf[HUGE_STRING] = ""; /* needs to be large for alias expansion */
  char *err = NULL;
  
  mutt_addrlist_to_local (*addr);
  rfc822_write_address (buf, sizeof (buf), *addr, 0);
  if (mutt_get_field (Prompts[line - 1], buf, sizeof (buf), M_ALIAS) == 0)
  {
    rfc822_free_address (addr);
    *addr = mutt_parse_adrlist (*addr, buf);
    *addr = mutt_expand_aliases (*addr);
  }

  if (option (OPTNEEDREDRAW))
  {
    unset_option (OPTNEEDREDRAW);
    return (REDRAW_FULL);
  }

  if (mutt_addrlist_to_intl (*addr, &err) != 0)
  {
    mutt_error (_("Warning: '%s' is a bad IDN."), err);
    mutt_refresh();
    FREE (&err);
  }

  /* redraw the expanded list so the user can see the result */
  buf[0] = 0;
  rfc822_write_address (buf, sizeof (buf), *addr, 1);
  move (line, HDR_XOFFSET);
  mutt_paddstr (W, buf);
  
  return 0;
}
Пример #2
0
static int edit_address (ADDRESS **a, /* const */ char *field)
{
  char buf[HUGE_STRING];
  char *err = NULL;
  int idna_ok = 0;
  
  do
  {
    buf[0] = 0;
    mutt_addrlist_to_local (*a);
    rfc822_write_address (buf, sizeof (buf), *a, 0);
    if (mutt_get_field (field, buf, sizeof (buf), M_ALIAS) != 0)
      return (-1);
    rfc822_free_address (a);
    *a = mutt_expand_aliases (mutt_parse_adrlist (NULL, buf));
    if ((idna_ok = mutt_addrlist_to_idna (*a, &err)) != 0)
    {
      mutt_error (_("Error: '%s' is a bad IDN."), err);
      mutt_refresh ();
      mutt_sleep (2);
      FREE (&err);
    }
  } 
  while (idna_ok != 0);
  return 0;
}
Пример #3
0
static int edit_address_list (int line, ADDRESS **addr)
{
  char buf[HUGE_STRING] = ""; /* needs to be large for alias expansion */

  rfc822_write_address (buf, sizeof (buf), *addr);
  if (mutt_get_field (Prompts[line - 1], buf, sizeof (buf), M_ALIAS) == 0)
  {
    rfc822_free_address (addr);
    *addr = mutt_parse_adrlist (*addr, buf);
    *addr = mutt_expand_aliases (*addr);
  }

  if (option (OPTNEEDREDRAW))
  {
    unset_option (OPTNEEDREDRAW);
    return (REDRAW_FULL);
  }

  /* redraw the expanded list so the user can see the result */
  buf[0] = 0;
  rfc822_write_address (buf, sizeof (buf), *addr);
  mvprintw (line, HDR_XOFFSET, "%-*.*s", W, W, buf);

  return 0;
}
Пример #4
0
void mutt_expand_aliases_env (ENVELOPE *env)
{
  env->from = mutt_expand_aliases (env->from);
  env->to = mutt_expand_aliases (env->to);
  env->cc = mutt_expand_aliases (env->cc);
  env->bcc = mutt_expand_aliases (env->bcc);
  env->reply_to = mutt_expand_aliases (env->reply_to);
  env->mail_followup_to = mutt_expand_aliases (env->mail_followup_to);
}
Пример #5
0
void ci_bounce_message (HEADER *h, int *redraw)
{
  char prompt[SHORT_STRING];
  char scratch[SHORT_STRING];
  char buf[HUGE_STRING] = { 0 };
  ADDRESS *adr = NULL;
  char *err = NULL;
  int rc;

 /* RfC 5322 mandates a From: header, so warn before bouncing
  * messages without one */
  if (h)
  {
    if (!h->env->from)
    {
      mutt_error _("Warning: message contains no From: header");
      mutt_sleep (2);
    }
  }
  else if (Context)
  {
    for (rc = 0; rc < Context->msgcount; rc++)
    {
      if (Context->hdrs[rc]->tagged && !Context->hdrs[rc]->env->from)
      {
	mutt_error _("Warning: message contains no From: header");
	mutt_sleep (2);
	break;
      }
    }
  }

  if(h)
    strfcpy(prompt, _("Bounce message to: "), sizeof(prompt));
  else
    strfcpy(prompt, _("Bounce tagged messages to: "), sizeof(prompt));
  
  rc = mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS);

  if (option (OPTNEEDREDRAW))
  {
    unset_option (OPTNEEDREDRAW);
    *redraw = REDRAW_FULL;
  }

  if (rc || !buf[0])
    return;

  if (!(adr = mutt_parse_adrlist (adr, buf)))
  {
    mutt_error _("Error parsing address!");
    return;
  }

  adr = mutt_expand_aliases (adr);

  if (mutt_addrlist_to_intl (adr, &err) < 0)
  {
    mutt_error (_("Bad IDN: '%s'"), err);
    FREE (&err);
    rfc822_free_address (&adr);
    return;
  }

  buf[0] = 0;
  rfc822_write_address (buf, sizeof (buf), adr, 1);

#define extra_space (15 + 7 + 2)
  snprintf (scratch, sizeof (scratch),
           (h ? _("Bounce message to %s") : _("Bounce messages to %s")), buf);

  if (mutt_strwidth (prompt) > COLS - extra_space)
  {
    mutt_format_string (prompt, sizeof (prompt),
			0, COLS-extra_space, FMT_LEFT, 0,
			scratch, sizeof (scratch), 0);
    safe_strcat (prompt, sizeof (prompt), "...?");
  }
  else
    snprintf (prompt, sizeof (prompt), "%s?", scratch);

  if (query_quadoption (OPT_BOUNCE, prompt) != M_YES)
  {
    rfc822_free_address (&adr);
    CLEARLINE (LINES - 1);
    mutt_message (h ? _("Message not bounced.") : _("Messages not bounced."));
    return;
  }

  CLEARLINE (LINES - 1);
  
  rc = mutt_bounce_message (NULL, h, adr);
  rfc822_free_address (&adr);
  /* If no error, or background, display message. */
  if ((rc == 0) || (rc == S_BKG))
    mutt_message (h ? _("Message bounced.") : _("Messages bounced."));
}
Пример #6
0
/**
 * crypt_extract_keys_from_messages - Extract keys from a message
 * @param el List of Emails to process
 *
 * The extracted keys will be added to the user's keyring.
 */
void crypt_extract_keys_from_messages(struct EmailList *el)
{
  char tempfname[PATH_MAX], *mbox = NULL;
  struct Address *tmp = NULL;

  if (!WithCrypto)
    return;

  mutt_mktemp(tempfname, sizeof(tempfname));
  FILE *fp_out = mutt_file_fopen(tempfname, "w");
  if (!fp_out)
  {
    mutt_perror(tempfname);
    return;
  }

  if (WithCrypto & APPLICATION_PGP)
    OptDontHandlePgpKeys = true;

  struct EmailNode *en = NULL;
  STAILQ_FOREACH(en, el, entries)
  {
    struct Email *e = en->email;

    mutt_parse_mime_message(Context->mailbox, e);
    if (e->security & SEC_ENCRYPT && !crypt_valid_passphrase(e->security))
    {
      mutt_file_fclose(&fp_out);
      break;
    }

    if (((WithCrypto & APPLICATION_PGP) != 0) && (e->security & APPLICATION_PGP))
    {
      mutt_copy_message_ctx(fp_out, Context->mailbox, e,
                            MUTT_CM_DECODE | MUTT_CM_CHARCONV, 0);
      fflush(fp_out);

      mutt_endwin();
      puts(_("Trying to extract PGP keys...\n"));
      crypt_pgp_invoke_import(tempfname);
    }

    if (((WithCrypto & APPLICATION_SMIME) != 0) && (e->security & APPLICATION_SMIME))
    {
      if (e->security & SEC_ENCRYPT)
      {
        mutt_copy_message_ctx(fp_out, Context->mailbox, e,
                              MUTT_CM_NOHEADER | MUTT_CM_DECODE_CRYPT | MUTT_CM_DECODE_SMIME,
                              0);
      }
      else
        mutt_copy_message_ctx(fp_out, Context->mailbox, e, 0, 0);
      fflush(fp_out);

      if (e->env->from)
        tmp = mutt_expand_aliases(e->env->from);
      else if (e->env->sender)
        tmp = mutt_expand_aliases(e->env->sender);
      mbox = tmp ? tmp->mailbox : NULL;
      if (mbox)
      {
        mutt_endwin();
        puts(_("Trying to extract S/MIME certificates..."));
        crypt_smime_invoke_import(tempfname, mbox);
        tmp = NULL;
      }
    }

    rewind(fp_out);
  }

  mutt_file_fclose(&fp_out);
  if (isendwin())
    mutt_any_key_to_continue(NULL);

  mutt_file_unlink(tempfname);

  if (WithCrypto & APPLICATION_PGP)
    OptDontHandlePgpKeys = false;
}
Пример #7
0
void mutt_attach_bounce (FILE * fp, struct header * hdr,
			 ATTACHPTR ** idx, short idxlen, struct body * cur)
{
	short i;
	char prompt[STRING];
	char buf[HUGE_STRING];
	struct address *adr = NULL;
	int ret = 0;
	int p   = 0;

	if (check_all_msg (idx, idxlen, cur, 1) == -1)
		return;

	/* one or more messages? */
	p = (cur || count_tagged (idx, idxlen) == 1);

	/* RfC 5322 mandates a From: header, so warn before bouncing
	 * messages without one */
	if (cur)
	{
		if (!cur->hdr->env->from)
		{
			mutt_error("Warning: message contains no From: header");
			mutt_sleep(2);
			mutt_clear_error();
		}
	}
	else
	{
		for (i = 0; i < idxlen; i++)
		{
			if (idx[i]->content->tagged)
			{
				if (!idx[i]->content->hdr->env->from)
				{
					mutt_error("Warning: message contains no From: header");
					mutt_sleep (2);
					mutt_clear_error ();
					break;
				}
			}
		}
	}

	if (p)
		strfcpy (prompt, ("Bounce message to: "), sizeof (prompt));
	else
		strfcpy (prompt, ("Bounce tagged messages to: "), sizeof (prompt));

	buf[0] = '\0';
	if (mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS)
	    || buf[0] == '\0')
		return;

	if (!(adr = rfc822_parse_adrlist (adr, buf)))
	{
		mutt_error("Error parsing address!");
		return;
	}

	adr = mutt_expand_aliases (adr);

	buf[0] = 0;
	rfc822_write_address (buf, sizeof (buf), adr, 1);

#define extra_space (15+7+2)
	/*
	 * See commands.c.
	 */
	snprintf (prompt, sizeof (prompt) - 4,
		  (p ? ("Bounce message to %s") : ("Bounce messages to %s")), buf);

	if (mutt_strwidth (prompt) > COLS - extra_space)
	{
		mutt_format_string (prompt, sizeof (prompt) - 4,
				    0, COLS-extra_space, FMT_LEFT, 0,
				    prompt, sizeof (prompt), 0);
		safe_strcat (prompt, sizeof (prompt), "...?");
	}
	else
		safe_strcat (prompt, sizeof (prompt), "?");

	if (query_quadoption (OPT_BOUNCE, prompt) != M_YES)
	{
		rfc822_free_address (&adr);
		CLEARLINE (LINES - 1);
		mutt_message (p ? ("Message not bounced.") : ("Messages not bounced."));
		return;
	}

	CLEARLINE (LINES - 1);

	if (cur)
		ret = mutt_bounce_message (fp, cur->hdr, adr);
	else
	{
		for (i = 0; i < idxlen; i++)
		{
			if (idx[i]->content->tagged)
				if (mutt_bounce_message (fp, idx[i]->content->hdr, adr))
					ret = 1;
		}
	}

	if (!ret)
		mutt_message (p ? ("Message bounced.") : ("Messages bounced."));
	else
		mutt_error (p ? ("Error bouncing message!") : ("Error bouncing messages!"));
}
Пример #8
0
void mutt_attach_bounce (FILE * fp, HEADER * hdr,
                         ATTACHPTR ** idx, short idxlen, BODY * cur)
{
  short i;
  char prompt[STRING];
  char buf[HUGE_STRING];
  char *err = NULL;
  ADDRESS *adr = NULL;
  int ret = 0;
  int p = 0;

  if (check_all_msg (idx, idxlen, cur, 1) == -1)
    return;

  /* one or more messages? */
  p = (cur || count_tagged (idx, idxlen) == 1);

  if (p)
    strfcpy (prompt, _("Bounce message to: "), sizeof (prompt));
  else
    strfcpy (prompt, _("Bounce tagged messages to: "), sizeof (prompt));

  buf[0] = '\0';
  if (mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS)
      || buf[0] == '\0')
    return;

  if (!(adr = rfc822_parse_adrlist (adr, buf))) {
    mutt_error _("Error parsing address!");

    return;
  }

  adr = mutt_expand_aliases (adr);

  if (mutt_addrlist_to_idna (adr, &err) < 0) {
    mutt_error (_("Bad IDN: '%s'"), err);
    mem_free (&err);
    rfc822_free_address (&adr);
    return;
  }

  buf[0] = 0;
  rfc822_write_address (buf, sizeof (buf), adr, 1);

#define extra_space (15+7+2)
  /*
   * See commands.c.
   */
  snprintf (prompt, sizeof (prompt) - 4,
            (p ? _("Bounce message to %s") : _("Bounce messages to %s")),
            buf);

  if (mutt_strwidth (prompt) > COLS - extra_space) {
    mutt_format_string (prompt, sizeof (prompt) - 4,
                        0, COLS - extra_space, 0, 0,
                        prompt, sizeof (prompt), 0);
    str_cat (prompt, sizeof (prompt), "...?");
  }
  else
    str_cat (prompt, sizeof (prompt), "?");

  if (query_quadoption (OPT_BOUNCE, prompt) != M_YES) {
    rfc822_free_address (&adr);
    CLEARLINE (LINES - 1);
    mutt_message (p ? _("Message not bounced.") : _("Messages not bounced."));
    return;
  }

  CLEARLINE (LINES - 1);

  if (cur)
    ret = mutt_bounce_message (fp, cur->hdr, adr);
  else {
    for (i = 0; i < idxlen; i++) {
      if (idx[i]->content->tagged)
        if (mutt_bounce_message (fp, idx[i]->content->hdr, adr))
          ret = 1;
    }
  }

  if (!ret)
    mutt_message (p ? _("Message bounced.") : _("Messages bounced."));
  else
    mutt_error (p ? _("Error bouncing message!") :
                _("Error bouncing messages!"));
}
Пример #9
0
void ci_bounce_message (HEADER *h, int *redraw)
{
  char prompt[SHORT_STRING];
  char scratch[SHORT_STRING];
  char buf[HUGE_STRING] = { 0 };
  ADDRESS *adr = NULL;
  char *err = NULL;
  int rc;

  if(h)
    strfcpy(prompt, _("Bounce message to: "), sizeof(prompt));
  else
    strfcpy(prompt, _("Bounce tagged messages to: "), sizeof(prompt));
  
  rc = mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS);

  if (option (OPTNEEDREDRAW))
  {
    unset_option (OPTNEEDREDRAW);
    *redraw = REDRAW_FULL;
  }

  if (rc || !buf[0])
    return;

  if (!(adr = rfc822_parse_adrlist (adr, buf)))
  {
    mutt_error _("Error parsing address!");
    return;
  }

  adr = mutt_expand_aliases (adr);

  if (mutt_addrlist_to_idna (adr, &err) < 0)
  {
    mutt_error (_("Bad IDN: '%s'"), err);
    FREE (&err);
    rfc822_free_address (&adr);
    return;
  }

  buf[0] = 0;
  rfc822_write_address (buf, sizeof (buf), adr, 1);

#define extra_space (15 + 7 + 2)
  snprintf (scratch, sizeof (scratch),
           (h ? _("Bounce message to %s") : _("Bounce messages to %s")), buf);

  if (mutt_strwidth (prompt) > COLS - extra_space)
  {
    mutt_format_string (prompt, sizeof (prompt),
			0, COLS-extra_space, FMT_LEFT, 0,
			scratch, sizeof (scratch), 0);
    safe_strcat (prompt, sizeof (prompt), "...?");
  }
  else
    snprintf (prompt, sizeof (prompt), "%s?", scratch);

  if (query_quadoption (OPT_BOUNCE, prompt) != M_YES)
  {
    rfc822_free_address (&adr);
    CLEARLINE (LINES - 1);
    mutt_message (h ? _("Message not bounced.") : _("Messages not bounced."));
    return;
  }

  CLEARLINE (LINES - 1);
  
  rc = mutt_bounce_message (NULL, h, adr);
  rfc822_free_address (&adr);
  /* If no error, or background, display message. */
  if ((rc == 0) || (rc == S_BKG))
    mutt_message (h ? _("Message bounced.") : _("Messages bounced."));
}