* src/compose.c
authorChristoph Hohmann <reboot@gmx.ch>
Sat, 16 Nov 2002 19:53:47 +0000 (19:53 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Sat, 16 Nov 2002 19:53:47 +0000 (19:53 +0000)
* src/folder.[ch]
* src/imap.c
* src/mbox_folder.c
* src/mh.c
* src/news.c
* src/procmsg.c
* src/summaryview.c
        replace claws' fetch_msginfo with main's get_msginfo
        (use main's implementation where possible)

ChangeLog.claws
configure.in
src/compose.c
src/folder.c
src/folder.h
src/imap.c
src/mbox_folder.c
src/mh.c
src/news.c
src/procmsg.c
src/summaryview.c

index 63beca1..45f83c5 100644 (file)
@@ -1,3 +1,16 @@
+2002-11-15 [christoph] 0.8.5claws160
+
+       * src/compose.c
+       * src/folder.[ch]
+       * src/imap.c
+       * src/mbox_folder.c
+       * src/mh.c
+       * src/news.c
+       * src/procmsg.c
+       * src/summaryview.c
+               replace claws' fetch_msginfo with main's get_msginfo
+               (use main's implementation where possible)
+
 2002-11-15 [colin]     0.8.5claws159
 
        * src/ssl_certificate.c
index 144e3a7..29ad284 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws159
+EXTRA_VERSION=claws160
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 18db192..cc11c30 100644 (file)
@@ -6387,7 +6387,7 @@ static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget)
                                               TRUE);
        }
 
-       newmsginfo = folder_item_fetch_msginfo(draft, msgnum);
+       newmsginfo = folder_item_get_msginfo(draft, msgnum);
        procmsg_msginfo_unset_flags(newmsginfo, ~0, ~0);
        MSG_SET_TMP_FLAGS(newmsginfo->flags, MSG_DRAFT);
        folder_update_item(draft, TRUE);
index c9cba06..20035e2 100644 (file)
@@ -123,8 +123,8 @@ static void folder_init(Folder *folder, const gchar *name)
        folder->item_new = NULL;
        folder->item_destroy = NULL;
        folder->fetch_msg = NULL;
-       folder->fetch_msginfo = NULL;
-       folder->fetch_msginfos = NULL;
+       folder->get_msginfo = NULL;
+       folder->get_msginfos = NULL;
        folder->get_num_list = NULL;
        folder->ui_func = NULL;
        folder->ui_func_data = NULL;
@@ -1133,7 +1133,7 @@ gint folder_item_scan(FolderItem *item)
 
                                msgcache_remove_msg(item->cache, msginfo->msgnum);
 
-                               if (NULL != (newmsginfo = folder->fetch_msginfo(folder, item, folder_cur_num))) {
+                               if (NULL != (newmsginfo = folder->get_msginfo(folder, item, folder_cur_num))) {
                                        msgcache_add_msg(item->cache, newmsginfo);
                                        if (MSG_IS_NEW(newmsginfo->flags) && !MSG_IS_IGNORE_THREAD(newmsginfo->flags))
                                                newcnt++;
@@ -1179,13 +1179,13 @@ gint folder_item_scan(FolderItem *item)
        g_slist_free(cache_list);
        g_slist_free(folder_list);
 
-       if (folder->fetch_msginfos) {
+       if (folder->get_msginfos) {
                GSList *elem;
                GSList *newmsg_list;
                MsgInfo *msginfo;
                
                if (new_list) {
-                       newmsg_list = folder->fetch_msginfos(folder, item, new_list);
+                       newmsg_list = folder->get_msginfos(folder, item, new_list);
                        for (elem = newmsg_list; elem != NULL; elem = g_slist_next(elem)) {
                                msginfo = (MsgInfo *) elem->data;
                                msgcache_add_msg(item->cache, msginfo);
@@ -1198,7 +1198,7 @@ gint folder_item_scan(FolderItem *item)
                        }
                        g_slist_free(newmsg_list);
                }
-       } else if (folder->fetch_msginfo) {
+       } else if (folder->get_msginfo) {
                GSList *elem;
        
                for (elem = new_list; elem != NULL; elem = g_slist_next(elem)) {
@@ -1206,7 +1206,7 @@ gint folder_item_scan(FolderItem *item)
                        guint num;
 
                        num = GPOINTER_TO_INT(elem->data);
-                       msginfo = folder->fetch_msginfo(folder, item, num);
+                       msginfo = folder->get_msginfo(folder, item, num);
                        if (msginfo != NULL) {
                                msgcache_add_msg(item->cache, msginfo);
                                if (MSG_IS_NEW(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
@@ -1371,7 +1371,7 @@ void folder_item_write_cache(FolderItem *item)
        g_free(mark_file);
 }
 
-MsgInfo *folder_item_fetch_msginfo(FolderItem *item, gint num)
+MsgInfo *folder_item_get_msginfo(FolderItem *item, gint num)
 {
        Folder *folder;
        MsgInfo *msginfo;
@@ -1385,8 +1385,8 @@ MsgInfo *folder_item_fetch_msginfo(FolderItem *item, gint num)
        if ((msginfo = msgcache_get_msg(item->cache, num)) != NULL)
                return msginfo;
        
-       g_return_val_if_fail(folder->fetch_msginfo, NULL);
-       if ((msginfo = folder->fetch_msginfo(folder, item, num)) != NULL) {
+       g_return_val_if_fail(folder->get_msginfo, NULL);
+       if ((msginfo = folder->get_msginfo(folder, item, num)) != NULL) {
                msgcache_add_msg(item->cache, msginfo);
                return msginfo;
        }
@@ -1394,7 +1394,7 @@ MsgInfo *folder_item_fetch_msginfo(FolderItem *item, gint num)
        return NULL;
 }
 
-MsgInfo *folder_item_fetch_msginfo_by_id(FolderItem *item, const gchar *msgid)
+MsgInfo *folder_item_get_msginfo_by_msgid(FolderItem *item, const gchar *msgid)
 {
        Folder *folder;
        MsgInfo *msginfo;
@@ -1456,7 +1456,7 @@ gint folder_item_add_msg(FolderItem *dest, const gchar *file,
        num = folder->add_msg(folder, dest, file, remove_source);
 
         if (num > 0) {
-               msginfo = folder->fetch_msginfo(folder, dest, num);
+               msginfo = folder->get_msginfo(folder, dest, num);
 
                if (msginfo != NULL) {
                        if (MSG_IS_NEW(msginfo->flags))
@@ -1652,7 +1652,7 @@ gint folder_item_move_msg(FolderItem *dest, MsgInfo *msginfo)
                MsgInfo *newmsginfo;
     
                /* Add new msginfo to dest folder */
-               if (NULL != (newmsginfo = folder->fetch_msginfo(folder, dest, num))) {
+               if (NULL != (newmsginfo = folder->get_msginfo(folder, dest, num))) {
                        newmsginfo->flags.perm_flags = msginfo->flags.perm_flags;
                        
                        if (dest->stype == F_OUTBOX || dest->stype == F_QUEUE  ||
@@ -1759,7 +1759,7 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
                if (num != -1) {
                        MsgInfo *newmsginfo;
 
-                       newmsginfo = folder->fetch_msginfo(folder, dest, num);
+                       newmsginfo = folder->get_msginfo(folder, dest, num);
                        if (newmsginfo) {
                                newmsginfo->flags.perm_flags = msginfo->flags.perm_flags;
                                if (dest->stype == F_OUTBOX ||
@@ -1858,7 +1858,7 @@ gint folder_item_copy_msg(FolderItem *dest, MsgInfo *msginfo)
        if (num != -1) {
                MsgInfo *newmsginfo;
 
-               if (NULL != (newmsginfo = folder->fetch_msginfo(folder, dest, num))) {
+               if (NULL != (newmsginfo = folder->get_msginfo(folder, dest, num))) {
                        newmsginfo->flags.perm_flags = msginfo->flags.perm_flags;
                        if (dest->stype == F_OUTBOX ||
                            dest->stype == F_QUEUE  ||
@@ -1946,7 +1946,7 @@ gint folder_item_copy_msgs_with_dest(FolderItem *dest, GSList *msglist)
                if (num != -1) {
                        MsgInfo *newmsginfo;
 
-                       newmsginfo = folder->fetch_msginfo(folder, dest, num);
+                       newmsginfo = folder->get_msginfo(folder, dest, num);
                        if (newmsginfo) {
                                newmsginfo->flags.perm_flags = msginfo->flags.perm_flags;
                                if (dest->stype == F_OUTBOX ||
index 8d8a8eb..4790d4a 100644 (file)
@@ -150,10 +150,10 @@ struct _Folder
        gchar *  (*fetch_msg)           (Folder         *folder,
                                         FolderItem     *item,
                                         gint            num);
-       MsgInfo *(*fetch_msginfo)       (Folder         *folder,
+       MsgInfo * (*get_msginfo)        (Folder         *folder,
                                         FolderItem     *item,
                                         gint            num);
-       GSList  *(*fetch_msginfos)      (Folder         *folder,
+       GSList  * (*get_msginfos)       (Folder         *folder,
                                         FolderItem     *item,
                                         GSList         *msgnum_list);
        gint     (*add_msg)             (Folder         *folder,
@@ -355,9 +355,9 @@ gint   folder_item_open                     (FolderItem     *item);
 void   folder_item_close               (FolderItem     *item);
 gint   folder_item_scan                        (FolderItem     *item);
 void   folder_item_scan_foreach                (GHashTable     *table);
-MsgInfo *folder_item_fetch_msginfo     (FolderItem     *item,
+MsgInfo *folder_item_get_msginfo       (FolderItem     *item,
                                         gint            num);
-MsgInfo *folder_item_fetch_msginfo_by_id(FolderItem    *item,
+MsgInfo *folder_item_get_msginfo_by_msgid(FolderItem   *item,
                                         const gchar    *msgid);
 GSList *folder_item_get_msg_list       (FolderItem     *item);
 gchar *folder_item_fetch_msg           (FolderItem     *item,
index bb3cd46..15fdf4a 100644 (file)
@@ -286,7 +286,7 @@ static gboolean imap_rename_folder_func             (GNode          *node,
 gint imap_get_num_list                         (Folder         *folder,
                                                 FolderItem     *item,
                                                 GSList        **list);
-MsgInfo *imap_fetch_msginfo                    (Folder         *folder,
+MsgInfo *imap_get_msginfo                      (Folder         *folder,
                                                 FolderItem     *item,
                                                 gint            num);
 gboolean imap_check_msgnum_validity            (Folder         *folder,
@@ -348,7 +348,7 @@ static void imap_folder_init(Folder *folder, const gchar *name,
        folder->check_msgnum_validity = imap_check_msgnum_validity;
 
        folder->get_num_list          = imap_get_num_list;
-       folder->fetch_msginfo         = imap_fetch_msginfo;
+       folder->get_msginfo           = imap_get_msginfo;
        
        ((IMAPFolder *)folder)->selected_folder = NULL;
 }
@@ -3291,7 +3291,7 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list)
        return nummsgs;
 }
 
-MsgInfo *imap_fetch_msginfo(Folder *_folder, FolderItem *item, gint num)
+MsgInfo *imap_get_msginfo(Folder *_folder, FolderItem *item, gint num)
 {
        IMAPFolder *folder = (IMAPFolder *)_folder;
        gchar *tmp;
index 2157bfb..5c6e9c2 100644 (file)
@@ -46,7 +46,7 @@ static gboolean mbox_purge_deleted(gchar * mbox);
 static gchar * mbox_get_new_path(FolderItem * parent, gchar * name);
 static gchar * mbox_get_folderitem_name(gchar * name);
 
-MsgInfo *mbox_fetch_msginfo(Folder *folder, FolderItem *item, gint num);
+MsgInfo *mbox_get_msginfo(Folder *folder, FolderItem *item, gint num);
 gint mbox_get_num_list(Folder *folder, FolderItem *item, GSList **list);
 gboolean mbox_check_msgnum_validity(Folder *folder, FolderItem *item);
 
@@ -75,7 +75,7 @@ static void mbox_folder_init(Folder *folder, const gchar *name, const gchar *pat
        folder->get_msg_list        = mbox_get_msg_list;
 */
        folder->fetch_msg           = mbox_fetch_msg;
-       folder->fetch_msginfo       = mbox_fetch_msginfo;
+       folder->get_msginfo         = mbox_get_msginfo;
        folder->add_msg             = mbox_add_msg;
        folder->copy_msg            = mbox_copy_msg;
        folder->remove_msg          = mbox_remove_msg;
@@ -2306,7 +2306,7 @@ gint mbox_get_num_list(Folder *folder, FolderItem *item, GSList **mlist)
        return nummsgs;
 }
 
-MsgInfo *mbox_fetch_msginfo(Folder *folder, FolderItem *item, gint num)
+MsgInfo *mbox_get_msginfo(Folder *folder, FolderItem *item, gint num)
 {
        gchar *mbox_path;
        struct _message *msg;
index 58d02d7..75b54e7 100644 (file)
--- a/src/mh.c
+++ b/src/mh.c
@@ -53,7 +53,7 @@ GSList  *mh_get_msg_list      (Folder         *folder,
 gchar   *mh_fetch_msg          (Folder         *folder,
                                 FolderItem     *item,
                                 gint            num);
-MsgInfo   *mh_fetch_msginfo    (Folder         *folder,
+MsgInfo   *mh_get_msginfo      (Folder         *folder,
                                 FolderItem     *item,
                                 gint            num);
 gint     mh_add_msg            (Folder         *folder,
@@ -133,7 +133,7 @@ static void mh_folder_init(Folder *folder, const gchar *name, const gchar *path)
 
 /*     folder->get_msg_list        = mh_get_msg_list; */
        folder->fetch_msg           = mh_fetch_msg;
-       folder->fetch_msginfo       = mh_fetch_msginfo;
+       folder->get_msginfo         = mh_get_msginfo;
        folder->add_msg             = mh_add_msg;
        folder->move_msg            = mh_move_msg;
        folder->move_msgs_with_dest = mh_move_msgs_with_dest;
@@ -311,43 +311,19 @@ gchar *mh_fetch_msg(Folder *folder, FolderItem *item, gint num)
        return file;
 }
 
-MsgInfo *mh_fetch_msginfo(Folder *folder, FolderItem *item, gint num)
+MsgInfo *mh_get_msginfo(Folder *folder, FolderItem *item, gint num)
 {
-       gchar *path;
-       gchar *file;
-       MsgFlags flags;
        MsgInfo *msginfo;
-       struct stat s;
+       gchar *file;
 
        g_return_val_if_fail(item != NULL, NULL);
        g_return_val_if_fail(num > 0, NULL);
 
-       path = folder_item_get_path(item);
-       file = g_strconcat(path, G_DIR_SEPARATOR_S, itos(num), NULL);
-       g_free(path);
-       if (!is_file_exist(file)) {
-               g_free(file);
-               return NULL;
-       }
-
-       folder_item_set_default_flags(item, &flags);
-       msginfo = procheader_parse_file(file, flags, TRUE, FALSE);
-       if(!msginfo) {
-               g_free(file);
-               return NULL;
-       }
+       file = mh_fetch_msg(folder, item, num);
+       if (!file) return NULL;
 
+       msginfo = mh_parse_msg(file, item);
        msginfo->msgnum = num;
-       msginfo->folder = item;
-
-       if (stat(file, &s) < 0) {
-               FILE_OP_ERROR(file, "stat");
-               msginfo->size = 0;
-               msginfo->mtime = 0;
-       } else {
-               msginfo->size = s.st_size;
-               msginfo->mtime = s.st_mtime;
-       }
 
        g_free(file);
 
index d634c66..fd1fe87 100644 (file)
@@ -107,10 +107,10 @@ static gint news_remove_msg                (Folder        *folder,
 gint news_get_num_list                  (Folder        *folder, 
                                          FolderItem    *item,
                                          GSList       **list);
-MsgInfo *news_fetch_msginfo             (Folder        *folder, 
+MsgInfo *news_get_msginfo               (Folder        *folder, 
                                          FolderItem    *item,
                                          gint           num);
-GSList *news_fetch_msginfos             (Folder        *folder,
+GSList *news_get_msginfos               (Folder        *folder,
                                          FolderItem    *item,
                                          GSList        *msgnum_list);
 
@@ -156,8 +156,8 @@ static void news_folder_init(Folder *folder, const gchar *name,
        folder->destroy      = news_folder_destroy;
        folder->remove_msg   = news_remove_msg;
        folder->get_num_list = news_get_num_list;
-       folder->fetch_msginfo = news_fetch_msginfo;
-       folder->fetch_msginfos = news_fetch_msginfos;
+       folder->get_msginfo  = news_get_msginfo;
+       folder->get_msginfos = news_get_msginfos;
 }
 
 #if USE_SSL
@@ -1094,7 +1094,7 @@ gint news_get_num_list(Folder *folder, FolderItem *item, GSList **msgnum_list)
                } \
        }
 
-MsgInfo *news_fetch_msginfo(Folder *folder, FolderItem *item, gint num)
+MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num)
 {
        NNTPSession *session;
        MsgInfo *msginfo = NULL;
@@ -1164,7 +1164,7 @@ MsgInfo *news_fetch_msginfo(Folder *folder, FolderItem *item, gint num)
        return msginfo;
 }
 
-static GSList *news_fetch_msginfo_from_to(NNTPSession *session, FolderItem *item, guint begin, guint end)
+static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *item, guint begin, guint end)
 {
        gchar buf[NNTPBUFSIZE];
        GSList *newlist = NULL;
@@ -1266,7 +1266,7 @@ gint news_fetch_msgnum_sort(gconstpointer a, gconstpointer b)
        return (GPOINTER_TO_INT(a) - GPOINTER_TO_INT(b));
 }
 
-GSList *news_fetch_msginfos(Folder *folder, FolderItem *item, GSList *msgnum_list)
+GSList *news_get_msginfos(Folder *folder, FolderItem *item, GSList *msgnum_list)
 {
        NNTPSession *session;
        GSList *elem, *msginfo_list = NULL, *tmp_msgnum_list, *tmp_msginfo_list;
@@ -1288,13 +1288,13 @@ GSList *news_fetch_msginfos(Folder *folder, FolderItem *item, GSList *msgnum_lis
        for(elem = g_slist_next(tmp_msgnum_list); elem != NULL; elem = g_slist_next(elem)) {
                next = GPOINTER_TO_INT(elem->data);
                if(next != (last + 1)) {
-                       tmp_msginfo_list = news_fetch_msginfo_from_to(session, item, first, last);
+                       tmp_msginfo_list = news_get_msginfos_for_range(session, item, first, last);
                        msginfo_list = g_slist_concat(msginfo_list, tmp_msginfo_list);
                        first = next;
                }
                last = next;
        }
-       tmp_msginfo_list = news_fetch_msginfo_from_to(session, item, first, last);
+       tmp_msginfo_list = news_get_msginfos_for_range(session, item, first, last);
        msginfo_list = g_slist_concat(msginfo_list, tmp_msginfo_list);
 
        g_slist_free(tmp_msgnum_list);
index 994694f..02d014b 100644 (file)
@@ -955,7 +955,7 @@ gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file,
                }
                return -1;
        }
-       msginfo = folder_item_fetch_msginfo(outbox, num);
+       msginfo = folder_item_get_msginfo(outbox, num);
        if (msginfo != NULL) {
            procmsg_msginfo_unset_flags(msginfo, ~0, 0);
            procmsg_msginfo_free(msginfo);
@@ -1395,14 +1395,14 @@ gint procmsg_send_message_queue(const gchar *file)
                if (item != NULL) {
                        MsgInfo *msginfo;
                        
-                       msginfo = folder_item_fetch_msginfo(item, atoi(tokens[1]));
+                       msginfo = folder_item_get_msginfo(item, atoi(tokens[1]));
                        if ((msginfo != NULL) && (strcmp(msginfo->msgid, tokens[2]) != 0)) {
                                procmsg_msginfo_free(msginfo);
                                msginfo = NULL;
                        }
                        
                        if (msginfo == NULL) {
-                               msginfo = folder_item_fetch_msginfo_by_id(item, tokens[2]);
+                               msginfo = folder_item_get_msginfo_by_msgid(item, tokens[2]);
                        }
                        
                        if (msginfo != NULL) {
index 45cfa27..1c6e9c3 100644 (file)
@@ -2988,13 +2988,19 @@ static void summary_delete_duplicated_func(GtkCTree *ctree, GtkCTreeNode *node,
 {
        GtkCTreeNode *found;
        MsgInfo *msginfo = GTK_CTREE_ROW(node)->row.data;
-
+       MsgInfo *dup_msginfo;
+       
        if (!msginfo->msgid || !*msginfo->msgid) return;
 
        found = g_hash_table_lookup(summaryview->msgid_table, msginfo->msgid);
-
-       if (found && found != node)
-               summary_delete_row(summaryview, node);
+       
+       if (found && found != node) {
+               dup_msginfo = gtk_ctree_node_get_row_data(ctree, found);
+               /* prefer to delete the unread one */
+               if ((MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_UNREAD(dup_msginfo->flags))
+               ||  (MSG_IS_UNREAD(msginfo->flags) == MSG_IS_UNREAD(dup_msginfo->flags)))
+                       summary_delete_row(summaryview, node);
+       }
 }
 
 static void summary_unmark_row(SummaryView *summaryview, GtkCTreeNode *row)