Beispiel #1
0
void mutt_attach_forward (FILE * fp, struct header *hdr,
			  ATTACHPTR ** idx, short idxlen, struct body * cur)
{
	short nattach;


	if (check_all_msg (idx, idxlen, cur, 0) == 0)
		attach_forward_msgs (fp, hdr, idx, idxlen, cur);
	else
	{
		nattach = count_tagged (idx, idxlen);
		attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach);
	}
}
Beispiel #2
0
void mutt_attach_forward (FILE * fp, HEADER * hdr,
                          ATTACHPTR ** idx, short idxlen, BODY * cur,
                          int flags)
{
  short nattach;


  if (check_all_msg (idx, idxlen, cur, 0) == 0)
    attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags);
  else {
    nattach = count_tagged (idx, idxlen);
    attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags);
  }
}
Beispiel #3
0
void mutt_attach_resend (FILE * fp, HEADER * hdr, ATTACHPTR ** idx,
                         short idxlen, BODY * cur)
{
  short i;

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

  if (cur)
    mutt_resend_message (fp, Context, cur->hdr);
  else {
    for (i = 0; i < idxlen; i++)
      if (idx[i]->content->tagged)
        mutt_resend_message (fp, Context, idx[i]->content->hdr);
  }
}
Beispiel #4
0
void mutt_attach_reply (FILE * fp, struct header *hdr,
			ATTACHPTR ** idx, short idxlen, struct body * cur,
			int flags)
{
	short mime_reply_any = 0;

	short nattach = 0;
	struct header *parent = NULL;
	struct header *tmphdr = NULL;
	short i;

	STATE st;
	char tmpbody[_POSIX_PATH_MAX];
	FILE *tmpfp;

	char prefix[SHORT_STRING];
	int rc;

	if (check_all_msg (idx, idxlen, cur, 0) == -1)
	{
		nattach = count_tagged (idx, idxlen);
		if ((parent = find_parent (idx, idxlen, cur, nattach)) == NULL)
			parent = hdr;
	}

	if (nattach > 1 && !check_can_decode (idx, idxlen, cur))
	{
		if ((rc = query_quadoption (OPT_MIMEFWDREST,
					    ("Can't decode all tagged attachments.  MIME-encapsulate the others?"))) == -1)
			return;
		else if (rc == M_YES)
			mime_reply_any = 1;
	}
	else if (nattach == 1)
		mime_reply_any = 1;

	tmphdr = mutt_new_header ();
	tmphdr->env = mutt_new_envelope ();

	if (attach_reply_envelope_defaults (tmphdr->env, idx, idxlen,
					    parent ? parent : (cur ? cur->hdr : NULL), flags) == -1)
	{
		mutt_free_header (&tmphdr);
		return;
	}

	mutt_mktemp (tmpbody, sizeof (tmpbody));
	if ((tmpfp = safe_fopen (tmpbody, "w")) == NULL)
	{
		mutt_error (("Can't create %s."), tmpbody);
		mutt_free_header (&tmphdr);
		return;
	}

	if (!parent)
	{
		if (cur)
			attach_include_reply (fp, tmpfp, cur->hdr, flags);
		else
		{
			for (i = 0; i < idxlen; i++)
			{
				if (idx[i]->content->tagged)
					attach_include_reply (fp, tmpfp, idx[i]->content->hdr, flags);
			}
		}
	}
	else
	{
		mutt_make_attribution (Context, parent, tmpfp);

		memset (&st, 0, sizeof (STATE));
		st.fpin = fp;
		st.fpout = tmpfp;

		if (!bit_val(options, OPTTEXTFLOWED))
			_mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix),
					   Context, parent, 0);
		else
			strfcpy (prefix, ">", sizeof (prefix));

		st.prefix = prefix;
		st.flags  = M_CHARCONV;

		if (bit_val(options, OPTWEED))
			st.flags |= M_WEED;

		if (bit_val(options, OPTHEADER))
			include_header (1, fp, parent, tmpfp, prefix);

		if (cur)
		{
			if (mutt_can_decode (cur))
			{
				mutt_body_handler (cur, &st);
				state_putc ('\n', &st);
			}
			else
				mutt_copy_body (fp, &tmphdr->content, cur);
		}
		else
		{
			for (i = 0; i < idxlen; i++)
			{
				if (idx[i]->content->tagged && mutt_can_decode (idx[i]->content))
				{
					mutt_body_handler (idx[i]->content, &st);
					state_putc ('\n', &st);
				}
			}
		}

		mutt_make_post_indent (Context, parent, tmpfp);

		if (mime_reply_any && !cur &&
		    copy_problematic_attachments (fp, &tmphdr->content, idx, idxlen, 0) == NULL)
		{
			mutt_free_header (&tmphdr);
			safe_fclose (&tmpfp);
			return;
		}
	}

	safe_fclose (&tmpfp);

	if (ci_send_message (flags, tmphdr, tmpbody, NULL,
			     parent ? parent : (cur ? cur->hdr : NULL)) == 0)
		mutt_set_flag (Context, hdr, M_REPLIED, 1);
}
Beispiel #5
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!"));
}
Beispiel #6
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!"));
}