} else
reply_account = account;
- MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_FORWARDED);
- MSG_SET_PERM_FLAGS(msginfo->flags, MSG_REPLIED);
- if (MSG_IS_IMAP(msginfo->flags))
- imap_msg_set_perm_flags(msginfo, MSG_REPLIED);
- CHANGE_FLAGS(msginfo);
-
compose = compose_create(account, COMPOSE_REPLY);
- compose->replyinfo = procmsg_msginfo_copy(msginfo);
+ compose->replyinfo = procmsg_msginfo_new_ref(msginfo);
#if 0 /* NEW COMPOSE GUI */
if (followup_and_reply_to) {
}
/* Save copy folder */
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn))) {
- gchar *str;
+ gchar *savefolderid;
+
+ savefolderid = gtk_editable_get_chars(GTK_EDITABLE(compose->savemsg_entry), 0, -1);
+ fprintf(fp, "SCF:%s\n", savefolderid);
+ g_free(savefolderid);
+ }
+ /* Message-ID of message replying to */
+ if((compose->replyinfo != NULL) && (compose->replyinfo->msgid != NULL)) {
+ gchar *folderid;
- str = gtk_editable_get_chars(GTK_EDITABLE(compose->savemsg_entry), 0, -1);
- fprintf(fp, "SCF:%s\n", str);
- g_free(str);
+ folderid = folder_item_get_identifier(compose->replyinfo->folder);
+ fprintf(fp, "RMID:%s%%%s\n", folderid, compose->replyinfo->msgid);
+ g_free(folderid);
}
fprintf(fp, "\n");
struct _MsgCache {
GHashTable *msgnum_table;
+ GHashTable *msgid_table;
guint memusage;
time_t last_access;
};
MsgCache *cache;
cache = g_new0(MsgCache, 1),
- cache->msgnum_table = g_hash_table_new(NULL, NULL);
+ cache->msgnum_table = g_hash_table_new(g_int_hash, g_int_equal);
+ cache->msgid_table = g_hash_table_new(g_str_hash, g_str_equal);
cache->last_access = time(NULL);
return cache;
g_return_if_fail(cache != NULL);
g_hash_table_foreach_remove(cache->msgnum_table, msgcache_msginfo_free_func, NULL);
+ g_hash_table_destroy(cache->msgid_table);
g_hash_table_destroy(cache->msgnum_table);
g_free(cache);
}
g_return_if_fail(msginfo != NULL);
newmsginfo = procmsg_msginfo_new_ref(msginfo);
- g_hash_table_insert(cache->msgnum_table, GINT_TO_POINTER(msginfo->msgnum), newmsginfo);
+ g_hash_table_insert(cache->msgnum_table, &newmsginfo->msgnum, newmsginfo);
+ if(newmsginfo->msgid != NULL)
+ g_hash_table_insert(cache->msgid_table, newmsginfo->msgid, newmsginfo);
cache->memusage += procmsg_msginfo_memusage(msginfo);
cache->last_access = time(NULL);
g_return_if_fail(cache != NULL);
g_return_if_fail(msgnum > 0);
- msginfo = (MsgInfo *) g_hash_table_lookup(cache->msgnum_table, GINT_TO_POINTER(msgnum));
+ msginfo = (MsgInfo *) g_hash_table_lookup(cache->msgnum_table, &msgnum);
if(!msginfo)
return;
cache->memusage -= procmsg_msginfo_memusage(msginfo);
+ if(msginfo->msgid)
+ g_hash_table_remove(cache->msgid_table, msginfo->msgid);
+ g_hash_table_remove(cache->msgnum_table, &msginfo->msgnum);
procmsg_msginfo_free(msginfo);
- g_hash_table_remove(cache->msgnum_table, GINT_TO_POINTER(msgnum));
cache->last_access = time(NULL);
debug_print(_("Cache size: %d messages, %d byte\n"), g_hash_table_size(cache->msgnum_table), cache->memusage);
g_return_if_fail(cache != NULL);
g_return_if_fail(msginfo != NULL);
- oldmsginfo = g_hash_table_lookup(cache->msgnum_table, GINT_TO_POINTER(msginfo->msgnum));
+ oldmsginfo = g_hash_table_lookup(cache->msgnum_table, &msginfo->msgnum);
if(msginfo) {
- g_hash_table_remove(cache->msgnum_table, GINT_TO_POINTER(oldmsginfo->msgnum));
+ g_hash_table_remove(cache->msgid_table, oldmsginfo->msgid);
+ g_hash_table_remove(cache->msgnum_table, &oldmsginfo->msgnum);
procmsg_msginfo_free(oldmsginfo);
}
cache->memusage -= procmsg_msginfo_memusage(oldmsginfo);
newmsginfo = procmsg_msginfo_new_ref(msginfo);
- g_hash_table_insert(cache->msgnum_table, GINT_TO_POINTER(msginfo->msgnum), newmsginfo);
+ g_hash_table_insert(cache->msgnum_table, &newmsginfo->msgnum, newmsginfo);
+ if(newmsginfo->msgid)
+ g_hash_table_insert(cache->msgid_table, newmsginfo->msgid, newmsginfo);
cache->memusage += procmsg_msginfo_memusage(newmsginfo);
cache->last_access = time(NULL);
*/
msginfo->folder = item;
- g_hash_table_insert(cache->msgnum_table, GINT_TO_POINTER(msginfo->msgnum), msginfo);
+ g_hash_table_insert(cache->msgnum_table, &msginfo->msgnum, msginfo);
+ if(msginfo->msgid)
+ g_hash_table_insert(cache->msgid_table, msginfo->msgid, msginfo);
cache->memusage += procmsg_msginfo_memusage(msginfo);
}
fclose(fp);
while (fread(&num, sizeof(num), 1, fp) == 1) {
if (fread(&perm_flags, sizeof(perm_flags), 1, fp) != 1) break;
- msginfo = g_hash_table_lookup(cache->msgnum_table, GUINT_TO_POINTER(num));
+ msginfo = g_hash_table_lookup(cache->msgnum_table, &num);
if(msginfo) {
msginfo->flags.perm_flags = perm_flags;
}
g_return_val_if_fail(cache != NULL, NULL);
- msginfo = g_hash_table_lookup(cache->msgnum_table, GINT_TO_POINTER(num));
+ msginfo = g_hash_table_lookup(cache->msgnum_table, &num);
if(!msginfo)
return NULL;
cache->last_access = time(NULL);
return procmsg_msginfo_new_ref(msginfo);
}
+MsgInfo *msgcache_get_msg_by_id(MsgCache *cache, const gchar *msgid)
+{
+ MsgInfo *msginfo;
+
+ g_return_val_if_fail(cache != NULL, NULL);
+
+ msginfo = g_hash_table_lookup(cache->msgid_table, msgid);
+ if(!msginfo)
+ return NULL;
+ cache->last_access = time(NULL);
+
+ return procmsg_msginfo_new_ref(msginfo);
+}
+
static void msgcache_get_msg_list_func(gpointer key, gpointer value, gpointer user_data)
{
GSList **listptr = user_data;
Q_NEWSGROUPS = 3,
Q_MAIL_ACCOUNT_ID = 4,
Q_NEWS_ACCOUNT_ID = 5,
- Q_SAVE_COPY_FOLDER = 6
+ Q_SAVE_COPY_FOLDER = 6,
+ Q_REPLY_MESSAGE_ID = 7,
};
gint procmsg_send_message_queue(const gchar *file)
{"MAID:", NULL, FALSE},
{"NAID:", NULL, FALSE},
{"SCF:", NULL, FALSE},
+ {"RMID:", NULL, FALSE},
{NULL, NULL, FALSE}};
FILE *fp;
gint filepos;
GSList *to_list = NULL;
GSList *newsgroup_list = NULL;
gchar *savecopyfolder = NULL;
+ gchar *replymessageid = NULL;
gchar buf[BUFFSIZE];
gint hnum;
PrefsAccount *mailac = NULL, *newsac = NULL;
case Q_SAVE_COPY_FOLDER:
if (!savecopyfolder) savecopyfolder = g_strdup(p);
break;
+ case Q_REPLY_MESSAGE_ID:
+ if (!replymessageid) replymessageid = g_strdup(p);
+ break;
}
}
filepos = ftell(fp);
procmsg_save_to_outbox(outbox, file, TRUE);
}
+ if(replymessageid != NULL) {
+ gchar **tokens;
+ FolderItem *item;
+
+ tokens = g_strsplit(replymessageid, "%", 0);
+ item = folder_find_item_from_identifier(tokens[0]);
+ if(item != NULL) {
+ MsgInfo *msginfo;
+
+ msginfo = folder_item_fetch_msginfo_by_id(item, tokens[1]);
+ if(msginfo != NULL) {
+ procmsg_msginfo_unset_flags(msginfo, MSG_FORWARDED, 0);
+ procmsg_msginfo_set_flags(msginfo, MSG_REPLIED, 0);
+
+ procmsg_msginfo_free(msginfo);
+ }
+ }
+ g_strfreev(tokens);
+ }
+
+ g_free(savecopyfolder);
+ g_free(replymessageid);
+
return (newsval != 0 ? newsval : mailval);
}