diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | libsylph/mh.c | 63 | ||||
-rw-r--r-- | libsylph/procmsg.c | 1 | ||||
-rw-r--r-- | src/compose.c | 4 | ||||
-rw-r--r-- | src/import.c | 2 | ||||
-rw-r--r-- | src/rpop3.c | 6 |
6 files changed, 50 insertions, 34 deletions
@@ -1,5 +1,13 @@ 2009-09-15 + * libsylph/mh.c + libsylph/procmsg.c + src/rpop3.c + src/compose.c: mh_add_msgs(): generate cache on adding messages. + Cleanup the code. + +2009-09-15 + * libsylph/procmsg.c: minor optimization: use g_slist_prepend() for mark/cache queue. diff --git a/libsylph/mh.c b/libsylph/mh.c index 5accaf00..5984a031 100644 --- a/libsylph/mh.c +++ b/libsylph/mh.c @@ -446,8 +446,9 @@ static gint mh_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list, gchar *destfile; GSList *cur; MsgFileInfo *fileinfo; + MsgInfo *msginfo; gint first_ = 0; - FILE *fp; + FILE *fp = NULL; g_return_val_if_fail(dest != NULL, -1); g_return_val_if_fail(file_list != NULL, -1); @@ -457,17 +458,26 @@ static gint mh_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list, if (dest->last_num < 0) return -1; } - if ((((MsgFileInfo *)file_list->data)->flags == NULL && - file_list->next == NULL) || dest->opened) - fp = NULL; - else if ((fp = procmsg_open_mark_file(dest, DATA_APPEND)) == NULL) - g_warning("Can't open mark file.\n"); + if (!dest->opened) { + if ((fp = procmsg_open_mark_file(dest, DATA_APPEND)) == NULL) + g_warning("mh_add_msgs: can't open mark file."); + } for (cur = file_list; cur != NULL; cur = cur->next) { + MsgFlags flags = {MSG_NEW|MSG_UNREAD, 0}; + fileinfo = (MsgFileInfo *)cur->data; + if (fileinfo->flags) + flags = *fileinfo->flags; + msginfo = procheader_parse_file(fileinfo->file, flags, 0); + if (!msginfo) { + if (fp) fclose(fp); + return -1; + } destfile = mh_get_new_msg_filename(dest); - if (destfile == NULL) return -1; + if (destfile == NULL) + return -1; if (first_ == 0 || first_ > dest->last_num + 1) first_ = dest->last_num + 1; @@ -476,6 +486,7 @@ static gint mh_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list, g_warning(_("can't copy message %s to %s\n"), fileinfo->file, destfile); g_free(destfile); + if (fp) fclose(fp); return -1; } } @@ -488,31 +499,25 @@ static gint mh_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list, dest->updated = TRUE; dest->mtime = 0; - if (fileinfo->flags) { - if (MSG_IS_RECEIVED(*fileinfo->flags)) { - if (dest->unmarked_num == 0) - dest->new = 0; - dest->unmarked_num++; - procmsg_add_mark_queue(dest, dest->last_num, - *fileinfo->flags); - } else { - SET_DEST_MSG_FLAGS(fp, dest, dest->last_num, - *fileinfo->flags); - } - if (MSG_IS_NEW(*fileinfo->flags)) - dest->new++; - if (MSG_IS_UNREAD(*fileinfo->flags)) - dest->unread++; - } else { + if (MSG_IS_RECEIVED(flags)) { + /* resets new flags of existing messages on + received mode */ if (dest->unmarked_num == 0) dest->new = 0; dest->unmarked_num++; + procmsg_add_mark_queue(dest, dest->last_num, flags); + } else { + SET_DEST_MSG_FLAGS(fp, dest, dest->last_num, flags); + } + procmsg_add_cache_queue(dest, dest->last_num, msginfo); + if (MSG_IS_NEW(flags)) dest->new++; + if (MSG_IS_UNREAD(flags)) dest->unread++; - } } - if (fp) fclose(fp); + if (fp) + fclose(fp); if (first) *first = first_; @@ -603,24 +608,26 @@ static gint mh_add_msgs_msginfo(Folder *folder, FolderItem *dest, dest->mtime = 0; if (MSG_IS_RECEIVED(msginfo->flags)) { + /* resets new flags of existing messages on + received mode */ if (dest->unmarked_num == 0) dest->new = 0; dest->unmarked_num++; procmsg_add_mark_queue(dest, dest->last_num, msginfo->flags); - procmsg_add_cache_queue(dest, dest->last_num, - msginfo); } else { SET_DEST_MSG_FLAGS(fp, dest, dest->last_num, msginfo->flags); } + procmsg_add_cache_queue(dest, dest->last_num, msginfo); if (MSG_IS_NEW(msginfo->flags)) dest->new++; if (MSG_IS_UNREAD(msginfo->flags)) dest->unread++; } - if (fp) fclose(fp); + if (fp) + fclose(fp); if (first) *first = first_; diff --git a/libsylph/procmsg.c b/libsylph/procmsg.c index d0ef9d23..e5c37123 100644 --- a/libsylph/procmsg.c +++ b/libsylph/procmsg.c @@ -1547,6 +1547,7 @@ gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file) g_warning("can't save message\n"); return -1; } + procmsg_flush_folder(outbox); return 0; } diff --git a/src/compose.c b/src/compose.c index 80ef48bf..69ec4844 100644 --- a/src/compose.c +++ b/src/compose.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2008 Hiroyuki Yamamoto + * Copyright (C) 1999-2009 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -4059,7 +4059,7 @@ static gint compose_queue(Compose *compose, const gchar *file) GSList *cur; gchar buf[BUFFSIZE]; gint num; - MsgFlags flag = {0, 0}; + MsgFlags flag = {0, MSG_QUEUED}; debug_print(_("queueing message...\n")); g_return_val_if_fail(compose->to_list != NULL || diff --git a/src/import.c b/src/import.c index 3ff67bad..955d9982 100644 --- a/src/import.c +++ b/src/import.c @@ -280,7 +280,7 @@ static gint import_eml_folder(FolderItem *dest, const gchar *path) ok = folder_item_add_msg_msginfo(dest, msginfo, FALSE); procmsg_msginfo_free(msginfo); if (ok < 0) { - g_warning("import_eml_folder(): folder_item_add_msg() failed."); + g_warning("import_eml_folder(): folder_item_add_msg_msginfo() failed."); break; } } diff --git a/src/rpop3.c b/src/rpop3.c index f2e68800..347f1a83 100644 --- a/src/rpop3.c +++ b/src/rpop3.c @@ -718,7 +718,7 @@ static gint rpop3_retr_recv(Pop3Session *session, FILE *fp, guint len) { gchar *file; MsgInfo *msginfo; - MsgFlags flags = {0, 0}; + MsgFlags flags = {MSG_NEW|MSG_UNREAD, MSG_RECEIVED}; MessageView *msgview; file = get_tmp_file(); @@ -743,7 +743,7 @@ static gint rpop3_retr_recv(Pop3Session *session, FILE *fp, guint len) return -1; } - if (folder_item_add_msg(inbox, file, NULL, FALSE) < 0) { + if (folder_item_add_msg(inbox, file, &flags, FALSE) < 0) { session->error_val = PS_IOERR; return -1; } @@ -1080,7 +1080,7 @@ static void rpop3_recv(GtkButton *button, gpointer data) gtk_tree_model_get(model, &iter, COL_NUMBER, &num, COL_DELETED, &deleted, -1); if (!deleted) { - debug_print("rpop3_recv: recieving message %d\n", num); + debug_print("rpop3_recv: receiving message %d\n", num); g_array_append_val(array, num); } } |