TnyMsg *outbox_msg;
gchar *msg_uid;
+ gchar *references;
+ gchar *in_reply_to;
+
gboolean sent;
};
priv->draft_msg = NULL;
priv->outbox_msg = NULL;
priv->msg_uid = NULL;
+ priv->references = NULL;
+ priv->in_reply_to = NULL;
}
/**
priv->outbox_msg = NULL;
}
g_free (priv->msg_uid);
+ g_free (priv->references);
+ g_free (priv->in_reply_to);
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
if (subject)
gtk_entry_set_text (GTK_ENTRY(priv->subject_field), subject);
+ modest_tny_msg_get_references (TNY_MSG (msg), NULL, &(priv->references), &(priv->in_reply_to));
+
modest_attachments_view_set_message (MODEST_ATTACHMENTS_VIEW (priv->attachments_view), msg);
priv->attachments = modest_attachments_view_get_attachments (MODEST_ATTACHMENTS_VIEW (priv->attachments_view));
update_next_cid (self, priv->attachments);
data->cc = g_strdup ( gtk_entry_get_text (GTK_ENTRY(priv->cc_field)));
data->bcc = g_strdup ( gtk_entry_get_text (GTK_ENTRY(priv->bcc_field)));
data->subject = g_strdup ( gtk_entry_get_text (GTK_ENTRY(priv->subject_field)));
+ data->references = g_strdup (priv->references);
+ data->in_reply_to = g_strdup (priv->in_reply_to);
/* GtkTextBuffer *buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->msg_body)); */
/* GtkTextIter b, e; */
g_free (data->subject);
g_free (data->plain_body);
g_free (data->html_body);
+ g_free (data->references);
+ g_free (data->in_reply_to);
if (data->draft_msg != NULL) {
g_object_unref (data->draft_msg);
GtkWidget *from_field;
gchar *last_from_account;
gchar *original_account_name;
+
+ gchar *references;
+ gchar *in_reply_to;
GtkWidget *to_field;
GtkWidget *cc_field;
priv->font_dialog = NULL;
priv->app_menu = NULL;
+ priv->references = NULL;
+ priv->in_reply_to = NULL;
+
if (!is_wp_text_buffer_started) {
is_wp_text_buffer_started = TRUE;
wp_text_buffer_library_init ();
g_free (priv->original_account_name);
g_free (priv->msg_uid);
g_free (priv->last_search);
+ g_free (priv->references);
+ g_free (priv->in_reply_to);
g_object_unref (priv->faces_model);
g_object_unref (priv->sizes_model);
g_object_unref (priv->attachments);
cc = tny_header_dup_cc (header);
bcc = tny_header_dup_bcc (header);
subject = tny_header_dup_subject (header);
+
+ modest_tny_msg_get_references (TNY_MSG (msg), NULL, &(priv->references), &(priv->in_reply_to));
priority_flags = tny_header_get_priority (header);
if (to)
data->cc = g_strdup (modest_recpt_editor_get_recipients (MODEST_RECPT_EDITOR (priv->cc_field)));
data->bcc = g_strdup (modest_recpt_editor_get_recipients (MODEST_RECPT_EDITOR (priv->bcc_field)));
data->subject = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->subject_field)));
+ data->references = g_strdup (priv->references);
+ data->in_reply_to = g_strdup (priv->in_reply_to);
if (priv->draft_msg) {
data->draft_msg = g_object_ref (priv->draft_msg);
} else if (priv->outbox_msg) {
g_free (data->plain_body);
g_free (data->html_body);
g_free (data->account_name);
+ g_free (data->references);
+ g_free (data->in_reply_to);
if (data->draft_msg != NULL) {
g_object_unref (data->draft_msg);
TnyMsg *draft_msg;
TnyMsg *outbox_msg;
gchar *msg_uid;
+ gchar *references;
+ gchar *in_reply_to;
gboolean sent;
};
priv->draft_msg = NULL;
priv->outbox_msg = NULL;
priv->msg_uid = NULL;
+ priv->references = NULL;
+ priv->in_reply_to = NULL;
priv->can_undo = FALSE;
priv->can_redo = FALSE;
if (priv->original_account_name)
g_free (priv->original_account_name);
g_free (priv->msg_uid);
+ g_free (priv->references);
+ g_free (priv->in_reply_to);
g_free (priv->last_search);
g_slist_free (priv->font_items_group);
g_slist_free (priv->size_items_group);
gtk_entry_set_text (GTK_ENTRY(priv->subject_field), subject);
modest_msg_edit_window_set_priority_flags (MODEST_MSG_EDIT_WINDOW(self),
priority_flags);
+ modest_tny_msg_get_references (TNY_MSG (msg), NULL, &(priv->references), &(priv->in_reply_to));
update_window_title (self);
data->cc = g_strdup (modest_recpt_editor_get_recipients (MODEST_RECPT_EDITOR (priv->cc_field)));
data->bcc = g_strdup (modest_recpt_editor_get_recipients (MODEST_RECPT_EDITOR (priv->bcc_field)));
data->subject = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->subject_field)));
+ data->references = g_strdup (priv->references);
+ data->in_reply_to = g_strdup (priv->in_reply_to);
if (priv->draft_msg) {
data->draft_msg = g_object_ref (priv->draft_msg);
} else if (priv->outbox_msg) {
g_free (data->plain_body);
g_free (data->html_body);
g_free (data->account_name);
+ g_free (data->in_reply_to);
+ g_free (data->references);
if (data->draft_msg != NULL) {
g_object_unref (data->draft_msg);
const gchar *html_body, const GList *attachments_list,
const GList *images_list,
TnyHeaderFlags priority_flags,
+ const gchar *references, const gchar *in_reply_to,
ModestMailOperationCreateMsgCallback callback,
gpointer userdata);
gchar *cc;
gchar *bcc;
gchar *subject;
+ gchar *references;
+ gchar *in_reply_to;
gchar *plain_body;
gchar *html_body;
GList *attachments_list;
priv = MODEST_MAIL_OPERATION_GET_PRIVATE(info->mail_op);
if (info->html_body == NULL) {
new_msg = modest_tny_msg_new (info->to, info->from, info->cc,
- info->bcc, info->subject, info->plain_body,
+ info->bcc, info->subject,
+ info->references, info->in_reply_to,
+ info->plain_body,
info->attachments_list, &attached,
&(priv->error));
} else {
new_msg = modest_tny_msg_new_html_plain (info->to, info->from, info->cc,
- info->bcc, info->subject, info->html_body,
+ info->bcc, info->subject,
+ info->references, info->in_reply_to,
+ info->html_body,
info->plain_body, info->attachments_list,
info->images_list, &attached,
&(priv->error));
g_free (info->plain_body);
g_free (info->html_body);
g_free (info->subject);
+ g_free (info->references);
+ g_free (info->in_reply_to);
g_list_foreach (info->attachments_list, (GFunc) g_object_unref, NULL);
g_list_free (info->attachments_list);
g_list_foreach (info->images_list, (GFunc) g_object_unref, NULL);
const GList *attachments_list,
const GList *images_list,
TnyHeaderFlags priority_flags,
+ const gchar *references,
+ const gchar *in_reply_to,
ModestMailOperationCreateMsgCallback callback,
gpointer userdata)
{
info->subject = g_strdup (subject);
info->plain_body = g_strdup (plain_body);
info->html_body = g_strdup (html_body);
+ info->references = g_strdup (references);
+ info->in_reply_to = g_strdup (in_reply_to);
info->attachments_list = g_list_copy ((GList *) attachments_list);
g_list_foreach (info->attachments_list, (GFunc) g_object_ref, NULL);
info->images_list = g_list_copy ((GList *) images_list);
const gchar *html_body,
const GList *attachments_list,
const GList *images_list,
+ const gchar *references,
+ const gchar *in_reply_to,
TnyHeaderFlags priority_flags)
{
ModestMailOperationPrivate *priv = NULL;
modest_mail_operation_create_msg (self, from, to, cc, bcc, subject, plain_body, html_body,
attachments_list, images_list, priority_flags,
+ references, in_reply_to,
modest_mail_operation_send_new_mail_cb, info);
}
const GList *attachments_list,
const GList *images_list,
TnyHeaderFlags priority_flags,
+ const gchar *references,
+ const gchar *in_reply_to,
SaveToDraftstCallback callback,
gpointer user_data)
{
modest_mail_operation_notify_start (self);
modest_mail_operation_create_msg (self, from, to, cc, bcc, subject, plain_body, html_body,
attachments_list, images_list, priority_flags,
+ references, in_reply_to,
modest_mail_operation_save_to_drafts_cb, info);
}
const gchar *html_body,
const GList *attachments_list,
const GList *images_list,
+ const gchar *references,
+ const gchar *in_reply_to,
TnyHeaderFlags priority_flags);
const GList *attachments_list,
const GList *images_list,
TnyHeaderFlags priority_flags,
+ const gchar *references,
+ const gchar *in_reply_to,
SaveToDraftstCallback callback,
gpointer user_data);
/**
TnyMsg*
modest_tny_msg_new (const gchar* mailto, const gchar* from, const gchar *cc,
- const gchar *bcc, const gchar* subject, const gchar *body,
+ const gchar *bcc, const gchar* subject,
+ const gchar *references, const gchar *in_reply_to,
+ const gchar *body,
GList *attachments, gint *attached, GError **err)
{
TnyMsg *new_msg;
*/
tny_mime_part_set_header_pair (TNY_MIME_PART (new_msg), "X-Mailer", "Modest "
VERSION);
+
+ if (references)
+ tny_mime_part_set_header_pair (TNY_MIME_PART (new_msg), "References", references);
+
+ if (in_reply_to)
+ tny_mime_part_set_header_pair (TNY_MIME_PART (new_msg), "In-Reply-To", in_reply_to);
/* Add the body of the new mail */
/* This is needed even if body is NULL or empty. */
TnyMsg*
modest_tny_msg_new_html_plain (const gchar* mailto, const gchar* from, const gchar *cc,
const gchar *bcc, const gchar* subject,
+ const gchar *references, const gchar *in_reply_to,
const gchar *html_body, const gchar *plain_body,
GList *attachments, GList *images, gint *attached, GError **err)
{
tny_mime_part_set_header_pair (TNY_MIME_PART (new_msg), "X-Mailer", "Modest "
VERSION);
+ if (references)
+ tny_mime_part_set_header_pair (TNY_MIME_PART (new_msg), "References", references);
+
+ if (in_reply_to)
+ tny_mime_part_set_header_pair (TNY_MIME_PART (new_msg), "In-Reply-To", in_reply_to);
+
/* Add the body of the new mail */
add_body_part (new_msg, plain_body, content_type);
add_html_body_part (new_msg, html_body);
return result;
}
+void
+modest_tny_msg_get_references (TnyMsg *msg, gchar **message_id, gchar **references, gchar **in_reply_to)
+{
+ TnyList *headers;
+ TnyIterator *iterator;
+ gchar *l_message_id;
+ gchar *l_references;
+ gchar *l_in_reply_to;
+
+ g_return_if_fail (TNY_IS_MSG (msg));
+
+ l_message_id = NULL;
+ l_references = NULL;
+ l_in_reply_to = NULL;
+
+ headers = TNY_LIST (tny_simple_list_new ());
+ tny_mime_part_get_header_pairs (TNY_MIME_PART (msg), headers);
+
+ iterator = tny_list_create_iterator (headers);
+ while (!tny_iterator_is_done (iterator)) {
+ TnyPair *pair;
+ const gchar *name;
+
+ pair = TNY_PAIR (tny_iterator_get_current (iterator));
+ name = tny_pair_get_name (pair);
+ if (!g_strcasecmp (name, "References")) {
+ if (l_references) g_free (l_references);
+ l_references = g_strdup (tny_pair_get_value (pair));
+ } else if (!g_strcasecmp (name, "In-Reply-To")) {
+ if (l_in_reply_to) g_free (l_in_reply_to);
+ l_in_reply_to = g_strdup (tny_pair_get_value (pair));
+ } else if (!g_strcasecmp (name, "Message-ID")) {
+ if (l_message_id) g_free (l_message_id);
+ l_message_id = g_strdup (tny_pair_get_value (pair));
+ }
+
+ g_object_unref (pair);
+ tny_iterator_next (iterator);
+ }
+
+ g_object_unref (iterator);
+ g_object_unref (headers);
+
+ if (message_id) {
+ *message_id = l_message_id;
+ } else {
+ g_free (l_message_id);
+ }
+
+ if (in_reply_to) {
+ *in_reply_to = l_in_reply_to;
+ } else {
+ g_free (l_in_reply_to);
+ }
+
+ if (references) {
+ *references = l_references;
+ } else {
+ g_free (l_references);
+ }
+}
+
+static void
+set_references (TnyMsg *reply_msg, TnyMsg *original_msg)
+{
+ gchar *orig_references, *orig_in_reply_to, *orig_message_id;
+ gchar *references, *in_reply_to;
+
+ modest_tny_msg_get_references (original_msg, &orig_message_id, &orig_references, &orig_in_reply_to);
+
+ references = NULL;
+ in_reply_to = NULL;
+
+ if (orig_message_id)
+ in_reply_to = g_strdup (orig_message_id);
+
+ if (orig_references) {
+ if (orig_message_id)
+ references = g_strconcat (orig_references, "\n ", orig_message_id, NULL);
+ else
+ references = g_strdup (orig_references);
+
+ } else if (orig_in_reply_to) {
+ if (orig_message_id)
+ references = g_strconcat (orig_in_reply_to, "\n ", orig_message_id, NULL);
+ else
+ references = g_strdup (orig_in_reply_to);
+ } else if (orig_message_id) {
+ references = g_strdup (orig_message_id);
+ }
+
+ g_free (orig_references);
+ g_free (orig_in_reply_to);
+ g_free (orig_message_id);
+
+ if (in_reply_to) {
+ tny_mime_part_set_header_pair (TNY_MIME_PART (reply_msg), "In-Reply-To", in_reply_to);
+ }
+ if (references) {
+ tny_mime_part_set_header_pair (TNY_MIME_PART (reply_msg), "References", references);
+ }
+}
TnyMsg*
modest_tny_msg_create_reply_msg (TnyMsg *msg,
new_msg = create_reply_forward_mail (msg, header, from, signature, TRUE, reply_type,
attachments_list);
+
+ set_references (new_msg, msg);
if (attachments_list != NULL) {
g_list_foreach (attachments_list, (GFunc) g_object_unref, NULL);
g_list_free (attachments_list);
* Returns: a new TnyMsg (free with g_object_unref)
*/
TnyMsg* modest_tny_msg_new (const gchar* mailto, const gchar* mailfrom, const gchar *cc,
- const gchar *bcc, const gchar* subject, const gchar *body,
+ const gchar *bcc, const gchar* subject,
+ const gchar *references, const gchar *in_reply_to,
+ const gchar *body,
GList *attachments, gint *attached, GError **err);
/**
* Returns: a new TnyMsg (free with g_object_unref)
*/
TnyMsg* modest_tny_msg_new_html_plain (const gchar* mailto, const gchar* mailfrom, const gchar *cc,
- const gchar *bcc, const gchar* subject,
+ const gchar *bcc, const gchar* subject,
+ const gchar *references, const gchar *in_reply_to,
const gchar *html_body, const gchar *plain_body,
GList *attachments, GList *images, gint *attached, GError **err);
GSList *
modest_tny_msg_get_all_recipients_list (TnyMsg *msg);
+/**
+ * modest_tny_msg_get_references:
+ * @msg: a #TnyMsg
+ * @message_id: a pointer to a string
+ * @references: a pointer to a string
+ * @in_reply_to: a pointer to a string
+ *
+ * obtains the Message-ID, References and In-Reply-To fields of a
+ * message
+ */
+void modest_tny_msg_get_references (TnyMsg *msg, gchar **message_id, gchar **references, gchar **in_reply_to);
+
#endif /* __MODEST_TNY_MSG_H__ */
body = use_signature ? g_strconcat("\n--\n", signature, NULL) : g_strdup("");
}
- msg = modest_tny_msg_new (to_str, from_str, cc_str, bcc_str, subject_str, body, NULL, NULL, NULL);
+ msg = modest_tny_msg_new (to_str, from_str, cc_str, bcc_str, subject_str, NULL, NULL, body, NULL, NULL, NULL);
if (!msg) {
g_printerr ("modest: failed to create new msg\n");
goto cleanup;
data->attachments,
data->images,
data->priority_flags,
+ data->references,
+ data->in_reply_to,
on_save_to_drafts_cb,
g_object_ref(edit_window));
data->html_body,
data->attachments,
data->images,
+ data->references,
+ data->in_reply_to,
data->priority_flags);
if (modest_mail_operation_get_status (mail_operation) == MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS)
*/
typedef struct {
gchar *from, *to, *cc, *bcc, *subject, *plain_body, *html_body;
+ gchar *references, *in_reply_to;
GList *attachments;
GList *images;
TnyHeaderFlags priority_flags;