Esempio n. 1
0
File: mu-msg.c Progetto: bonega/mu
static void
msg_contact_foreach_file (MuMsg *msg, MuMsgContactForeachFunc func,
			  gpointer user_data)
{
	int i;
	struct {
		GMimeRecipientType     _gmime_type;
		MuMsgContactType       _type;
	} ctypes[] = {
		{GMIME_RECIPIENT_TYPE_TO,  MU_MSG_CONTACT_TYPE_TO},
		{GMIME_RECIPIENT_TYPE_CC,  MU_MSG_CONTACT_TYPE_CC},
		{GMIME_RECIPIENT_TYPE_BCC, MU_MSG_CONTACT_TYPE_BCC},
	};

	/* sender */
	addresses_foreach (g_mime_message_get_sender (msg->_file->_mime_msg),
			   MU_MSG_CONTACT_TYPE_FROM, func, user_data);

	/* reply_to */
	addresses_foreach (g_mime_message_get_reply_to (msg->_file->_mime_msg),
			   MU_MSG_CONTACT_TYPE_REPLY_TO, func, user_data);

	/* get to, cc, bcc */
	for (i = 0; i != G_N_ELEMENTS(ctypes); ++i) {
		InternetAddressList *addrlist;
		addrlist = g_mime_message_get_recipients (msg->_file->_mime_msg,
							  ctypes[i]._gmime_type);
		address_list_foreach (addrlist, ctypes[i]._type, func, user_data);
	}
}
Esempio n. 2
0
void
format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
			 notmuch_bool_t reply)
{
    /* Any changes to the JSON or S-Expression format should be
     * reflected in the file devel/schemata. */

    InternetAddressList *recipients;
    const char *recipients_string;
    const char *reply_to_string;

    sp->begin_map (sp);

    sp->map_key (sp, "Subject");
    sp->string (sp, g_mime_message_get_subject (message));

    sp->map_key (sp, "From");
    sp->string (sp, g_mime_message_get_sender (message));

    recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
    recipients_string = internet_address_list_to_string (recipients, 0);
    if (recipients_string) {
	sp->map_key (sp, "To");
	sp->string (sp, recipients_string);
    }

    recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_CC);
    recipients_string = internet_address_list_to_string (recipients, 0);
    if (recipients_string) {
	sp->map_key (sp, "Cc");
	sp->string (sp, recipients_string);
    }

    recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_BCC);
    recipients_string = internet_address_list_to_string (recipients, 0);
    if (recipients_string) {
	sp->map_key (sp, "Bcc");
	sp->string (sp, recipients_string);
    }

    reply_to_string = g_mime_message_get_reply_to (message);
    if (reply_to_string) {
	sp->map_key (sp, "Reply-To");
	sp->string (sp, reply_to_string);
    }

    if (reply) {
	sp->map_key (sp, "In-reply-to");
	sp->string (sp, g_mime_object_get_header (GMIME_OBJECT (message), "In-reply-to"));

	sp->map_key (sp, "References");
	sp->string (sp, g_mime_object_get_header (GMIME_OBJECT (message), "References"));
    } else {
	sp->map_key (sp, "Date");
	sp->string (sp, g_mime_message_get_date_as_string (message));
    }

    sp->end (sp);
}
Esempio n. 3
0
void extract_headers (GMimeMessage *message, GMimeStream *out_stream) {
  const char *subject;
  char *escaped_subject;
  const char *sender;
  char *escaped_sender;
  const char *reply_to;
  char *escaped_reply_to;
  time_t t;
  int tz;
  char buf[64];
  struct tm *t_m;
  subject = g_mime_message_get_subject(message);
  escaped_subject = str_replace((char *) subject, "\"", "");
  g_mime_stream_printf (out_stream, "subject: \"%s\", ", escaped_subject);
  g_mime_stream_printf (out_stream, "message_id: \"%s\", ", g_mime_message_get_message_id(message));
  sender = g_mime_message_get_sender(message);
  escaped_sender = str_replace((char *) sender, "\"", "");
  g_mime_stream_printf (out_stream, "sender: \"%s\", ", escaped_sender);
  reply_to = g_mime_message_get_reply_to(message);
  escaped_reply_to = str_replace((char *) reply_to, "\"", "");
  g_mime_stream_printf (out_stream, "reply_to: \"%s\", ", escaped_reply_to);
  g_mime_message_get_date (message, &t, &tz);
  t_m = localtime (&t);
  strftime(buf, sizeof(buf) - 1, "%c", t_m);
  g_mime_stream_printf (out_stream, "date: \"%s\", ", buf);
  strftime(buf, sizeof(buf) - 1, "%Y%m%d%H%M%S", t_m);
  g_mime_stream_printf (out_stream, "sort_date: \"%s\", ", buf);

  InternetAddressList *recipients;
  recipients = g_mime_message_get_recipients(message, GMIME_RECIPIENT_TYPE_TO);
  g_mime_stream_printf (out_stream, "recipients_to: [");
  extract_addresses(recipients, out_stream);
  g_mime_stream_printf (out_stream, "], ");

  recipients = g_mime_message_get_recipients(message, GMIME_RECIPIENT_TYPE_CC);
  g_mime_stream_printf (out_stream, "recipients_cc: [");
  extract_addresses(recipients, out_stream);
  g_mime_stream_printf (out_stream, "], ");

  recipients = g_mime_message_get_recipients(message, GMIME_RECIPIENT_TYPE_BCC);
  g_mime_stream_printf (out_stream, "recipients_bcc: [");
  extract_addresses(recipients, out_stream);
  g_mime_stream_printf (out_stream, "] ");
}
Esempio n. 4
0
static AddressesList *get_reply_to_addresses(GMimeMessage *message) {
  const gchar *reply_to_string = g_mime_message_get_reply_to(message); // transfer-none
  if (reply_to_string)
    return collect_str_addresses(reply_to_string);
  return NULL;
}