0.9.4claws33
authorChristoph Hohmann <reboot@gmx.ch>
Thu, 21 Aug 2003 20:08:27 +0000 (20:08 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Thu, 21 Aug 2003 20:08:27 +0000 (20:08 +0000)
* src/folder.[ch]
* src/imap.c
* src/mbox_folder.c
* src/mh.c
* src/news.c
        optimize folder system

* src/gtk/gtkstext.c
        fix division by zero when font has 0 width for ' '

ChangeLog.claws
configure.ac
src/compose.c
src/folder.c
src/folder.h
src/gtk/gtkstext.c
src/imap.c
src/mbox_folder.c
src/mh.c
src/news.c

index 12a76db..f886009 100644 (file)
@@ -1,3 +1,15 @@
+2003-08-21 [christoph] 0.9.4claws33
+
+       * src/folder.[ch]
+       * src/imap.c
+       * src/mbox_folder.c
+       * src/mh.c
+       * src/news.c
+               optimize folder system
+
+       * src/gtk/gtkstext.c
+               fix division by zero when font has 0 width for ' '
+
 2003-08-21 [paul]      0.9.4claws32
 
        * sync with 0.9.4cvs7
index 675c946..420401d 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=4
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=32
+EXTRA_VERSION=33
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index 906c4a3..b9c5caa 100644 (file)
@@ -5137,7 +5137,7 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
                                        "/Spelling/Spelling Configuration");
                                gtkaspell_populate_submenu(gtkaspell, menuitem);
                                menu_set_sensitive(ifactory, "/Spelling", TRUE);
-                               }
+                       }
                }
        }
 #endif
index e1b6271..5284d29 100644 (file)
@@ -1014,7 +1014,7 @@ static gint folder_sort_folder_list(gconstpointer a, gconstpointer b)
 
 gint folder_item_open(FolderItem *item)
 {
-       if(((FOLDER_TYPE(item->folder) == F_IMAP) && !item->no_select) || (FOLDER_TYPE(item->folder) == F_NEWS)) {
+       if((item->folder->klass->scan_required != NULL) && (item->folder->klass->scan_required(item->folder, item))) {
                folder_item_scan_full(item, TRUE);
        }
 
@@ -1078,7 +1078,7 @@ gint folder_item_scan_full(FolderItem *item, gboolean filtering)
        GSList *newmsg_list = NULL;
        guint newcnt = 0, unreadcnt = 0, totalcnt = 0, unreadmarkedcnt = 0;
        guint cache_max_num, folder_max_num, cache_cur_num, folder_cur_num;
-       gboolean update_flags = 0;
+       gboolean update_flags = 0, old_uids_valid = FALSE;
     
        g_return_val_if_fail(item != NULL, -1);
        if (item->path == NULL) return -1;
@@ -1091,13 +1091,12 @@ gint folder_item_scan_full(FolderItem *item, gboolean filtering)
        debug_print("Scanning folder %s for cache changes.\n", item->path);
 
        /* Get list of messages for folder and cache */
-       if (folder->klass->get_num_list(item->folder, item, &folder_list) < 0) {
+       if (folder->klass->get_num_list(item->folder, item, &folder_list, &old_uids_valid) < 0) {
                debug_print("Error fetching list of message numbers\n");
                return(-1);
        }
 
-       if (!folder->klass->check_msgnum_validity || 
-           folder->klass->check_msgnum_validity(folder, item)) {
+       if (old_uids_valid) {
                if (!item->cache)
                        folder_item_read_cache(item);
                cache_list = msgcache_get_msg_list(item->cache);
index 9de967d..5479277 100644 (file)
@@ -196,15 +196,16 @@ struct _FolderClass
                                                 FolderItem     *item);
        gint            (*get_num_list)         (Folder         *folder,
                                                 FolderItem     *item,
-                                                GSList        **list);
+                                                GSList        **list,
+                                                gboolean       *old_uids_valid);
        void            (*update_mark)          (Folder         *folder,
                                                 FolderItem     *item);
        void            (*finished_copy)        (Folder         *folder,
                                                 FolderItem     *item);
        void            (*finished_remove)      (Folder         *folder,
-                                                FolderItem item);
-       gboolean        (*check_msgnum_validity)(Folder         *folder,
-                                                FolderItem item);
+                                                FolderItem     *item);
+       gboolean        (*scan_required)        (Folder         *folder,
+                                                FolderItem     *item);
 
        /* Message functions */
        MsgInfo         *(*get_msginfo)         (Folder         *folder,
index 8243bd7..52b2ad8 100644 (file)
@@ -5555,9 +5555,12 @@ draw_line (GtkSText* text,
            pixels_remaining -= running_offset;
          
          space_width = MARK_CURRENT_TEXT_FONT(text, &mark)->char_widths[' '];
-         
-         spaces_avail = pixels_remaining / space_width;
-         spaces_avail = MIN (spaces_avail, tab_mark.to_next_tab);
+         if (space_width > 0) {
+           spaces_avail = pixels_remaining / space_width;
+           spaces_avail = MIN (spaces_avail, tab_mark.to_next_tab);
+         } else {
+           spaces_avail = 0;
+         }
 
          draw_bg_rect (text, &mark, running_offset, pixel_start_height,
                        spaces_avail * space_width, LINE_HEIGHT (*lp), TRUE);
index f6de3ed..1077547 100644 (file)
@@ -403,14 +403,15 @@ static gboolean imap_rename_folder_func           (GNode          *node,
                                                 gpointer        data);
 static gint imap_get_num_list                  (Folder         *folder,
                                                 FolderItem     *item,
-                                                GSList        **list);
+                                                GSList        **list,
+                                                gboolean       *old_uids_valid);
 static GSList *imap_get_msginfos               (Folder         *folder,
                                                 FolderItem     *item,
                                                 GSList         *msgnum_list);
 static MsgInfo *imap_get_msginfo               (Folder         *folder,
                                                 FolderItem     *item,
                                                 gint            num);
-static gboolean imap_check_msgnum_validity     (Folder         *folder,
+static gboolean imap_scan_required             (Folder         *folder,
                                                 FolderItem     *item);
 static void imap_change_flags                  (Folder         *folder,
                                                 FolderItem     *item,
@@ -444,7 +445,7 @@ FolderClass imap_class =
        NULL,
        NULL,
        NULL,
-       imap_check_msgnum_validity,
+       imap_scan_required,
 
        /* Message functions */
        imap_get_msginfo,
@@ -2383,6 +2384,9 @@ static gint imap_status(IMAPSession *session, IMAPFolder *folder,
 
        *messages = *recent = *uid_next = *uid_validity = *unseen = 0;
 
+       if (path == NULL)
+               return -1;
+
        argbuf = g_ptr_array_new();
 
        real_path = imap_get_real_path(folder, path);
@@ -3570,11 +3574,11 @@ static gint get_list_of_uids(Folder *folder, IMAPFolderItem *item, GSList **msgn
        return nummsgs;
 }
 
-gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list)
+gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list, gboolean *old_uids_valid)
 {
        IMAPFolderItem *item = (IMAPFolderItem *)_item;
        IMAPSession *session;
-       gint ok, nummsgs = 0, exists, recent, unseen, uid_val, uid_next;
+       gint ok, nummsgs = 0, exists, recent, uid_val, uid_next, unseen;
        GSList *uidlist;
        gchar *dir;
        gboolean selected_folder;
@@ -3595,13 +3599,33 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list)
                if (ok != IMAP_SUCCESS)
                        return -1;
                exists = session->exists;
+
+               *old_uids_valid = TRUE;
        } else {
                ok = imap_status(session, IMAP_FOLDER(folder), item->item.path,
                                 &exists, &recent, &uid_next, &uid_val, &unseen);
                if (ok != IMAP_SUCCESS)
                        return -1;
+
+               if(item->item.mtime == uid_val)
+                       *old_uids_valid = TRUE;
+               else {
+                       *old_uids_valid = FALSE;
+
+                       debug_print("Freeing imap uid cache\n");
+                       item->lastuid = 0;
+                       g_slist_free(item->uid_list);
+                       item->uid_list = NULL;
+               
+                       item->item.mtime = uid_val;
+
+                       imap_delete_all_cached_messages((FolderItem *)item);
+               }
        }
 
+       if (!selected_folder)
+               item->uid_next = uid_next;
+
        /* If old uid_next matches new uid_next we can be sure no message
           was added to the folder */
        if (( selected_folder && !session->folder_content_changed) ||
@@ -3623,8 +3647,6 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list)
                        item->uid_list = NULL;
                }
        }
-       if (!selected_folder)
-               item->uid_next = uid_next;
 
        if (exists == 0) {
                *msgnum_list = NULL;
@@ -3767,37 +3789,43 @@ MsgInfo *imap_get_msginfo(Folder *folder, FolderItem *item, gint uid)
        return msginfo;
 }
 
-gboolean imap_check_msgnum_validity(Folder *folder, FolderItem *_item)
+gboolean imap_scan_required(Folder *folder, FolderItem *_item)
 {
        IMAPSession *session;
        IMAPFolderItem *item = (IMAPFolderItem *)_item;
        gint ok, exists = 0, recent = 0, unseen = 0;
-       guint32 uid_next, uid_validity = 0;
+       guint32 uid_next, uid_val = 0;
+       gboolean selected_folder;
        
        g_return_val_if_fail(folder != NULL, FALSE);
        g_return_val_if_fail(item != NULL, FALSE);
        g_return_val_if_fail(item->item.folder != NULL, FALSE);
        g_return_val_if_fail(FOLDER_CLASS(item->item.folder) == &imap_class, FALSE);
 
+       if (item->item.path == NULL)
+               return FALSE;
+
        session = imap_session_get(folder);
        g_return_val_if_fail(session != NULL, FALSE);
 
-       ok = imap_status(session, IMAP_FOLDER(folder), item->item.path,
-                        &exists, &recent, &uid_next, &uid_validity, &unseen);
-       if (ok != IMAP_SUCCESS)
-               return FALSE;
-
-       if(item->item.mtime == uid_validity)
-               return TRUE;
+       selected_folder = (session->mbox != NULL) &&
+                         (!strcmp(session->mbox, item->item.path));
+       if (selected_folder) {
+               ok = imap_cmd_noop(session);
+               if (ok != IMAP_SUCCESS)
+                       return FALSE;
 
-       debug_print("Freeing imap uid cache\n");
-       item->lastuid = 0;
-       g_slist_free(item->uid_list);
-       item->uid_list = NULL;
-               
-       item->item.mtime = uid_validity;
+               if (session->folder_content_changed)
+                       return TRUE;
+       } else {
+               ok = imap_status(session, IMAP_FOLDER(folder), item->item.path,
+                                &exists, &recent, &uid_next, &uid_val, &unseen);
+               if (ok != IMAP_SUCCESS)
+                       return FALSE;
 
-       imap_delete_all_cached_messages((FolderItem *)item);
+               if ((uid_next != item->uid_next) || (exists < item->item.total_msgs))
+                       return TRUE;
+       }
 
        return FALSE;
 }
index 8e96aa7..253f26f 100644 (file)
@@ -68,8 +68,9 @@ static gchar * mbox_get_new_path(FolderItem * parent, gchar * name);
 static gchar * mbox_get_folderitem_name(gchar * name);
 
 static MsgInfo *mbox_get_msginfo(Folder *folder, FolderItem *item, gint num);
-static gint mbox_get_num_list(Folder *folder, FolderItem *item, GSList **list);
-static gboolean mbox_check_msgnum_validity(Folder *folder, FolderItem *item);
+static gint mbox_get_num_list(Folder *folder, FolderItem *item,
+                             GSList **list, gboolean *old_uids_valid);
+static gboolean mbox_scan_required(Folder *folder, FolderItem *item);
 static gchar *mbox_folder_get_path(Folder *folder, FolderItem *item);
 
 FolderClass mbox_class =
@@ -96,7 +97,7 @@ FolderClass mbox_class =
        NULL,
        NULL,
        NULL,
-       mbox_check_msgnum_validity,
+       mbox_scan_required,
 
        /* Message functions */
        mbox_get_msginfo,
@@ -2077,18 +2078,30 @@ gint mbox_remove_folder(Folder *folder, FolderItem *item)
        return 0;
 }
 
-gint mbox_get_num_list(Folder *folder, FolderItem *item, GSList **mlist)
+gint mbox_get_num_list(Folder *folder, FolderItem *item, GSList **mlist, gboolean *old_uids_valid)
 {
        GList * l;
        FILE * fp;
        gchar * mbox_path;
+       mboxcache * old_cache;
        gint nummsgs = 0;
+       struct stat s;
 
        mbox_path = mbox_folder_get_path(folder, item);
-
        if (mbox_path == NULL)
                return -1;
 
+       old_cache = mbox_cache_get_mbox(mbox_path);
+       *old_uids_valid = TRUE;
+       if (old_cache != NULL) {
+               if (stat(mbox_path, &s) < 0) {
+                       FILE_OP_ERROR(mbox_path, "stat");
+               } else if (old_cache->mtime == s.st_mtime) {
+                       debug_print("Folder is not modified.\n");
+                       *old_uids_valid = FALSE;
+               }
+       }
+
        mbox_purge_deleted(mbox_path);
 
        fp = fopen(mbox_path, "rb");
@@ -2167,15 +2180,14 @@ MsgInfo *mbox_get_msginfo(Folder *folder, FolderItem *item, gint num)
        return msginfo;
 }
 
-gboolean mbox_check_msgnum_validity(Folder *folder, FolderItem *item)
+gboolean mbox_scan_required(Folder *folder, FolderItem *item)
 {
        mboxcache * old_cache;
        gboolean scan_new = TRUE;
        struct stat s;
        gchar *filename;
 
-       filename = mbox_folder_get_path(folder, item);
-       
+       filename = mbox_folder_get_path(folder, item);  
        old_cache = mbox_cache_get_mbox(filename);
 
        if (old_cache != NULL) {
index 8f6b46a..140d35d 100644 (file)
--- a/src/mh.c
+++ b/src/mh.c
@@ -65,7 +65,7 @@ static gboolean mh_is_msg_changed(Folder * folder,
                                  FolderItem * item, MsgInfo * msginfo);
 
 static gint mh_get_num_list(Folder * folder,
-                           FolderItem * item, GSList ** list);
+                           FolderItem * item, GSList ** list, gboolean *old_uids_valid);
 static void mh_scan_tree(Folder * folder);
 
 static gint mh_create_tree(Folder * folder);
@@ -191,7 +191,7 @@ void mh_get_last_num(Folder *folder, FolderItem *item)
        item->last_num = max;
 }
 
-gint mh_get_num_list(Folder *folder, FolderItem *item, GSList **list)
+gint mh_get_num_list(Folder *folder, FolderItem *item, GSList **list, gboolean *old_uids_valid)
 {
 
        gchar *path;
@@ -204,6 +204,8 @@ gint mh_get_num_list(Folder *folder, FolderItem *item, GSList **list)
 
        debug_print("mh_get_last_num(): Scanning %s ...\n", item->path);
 
+       *old_uids_valid = TRUE;
+
        path = folder_item_get_path(item);
        g_return_val_if_fail(path != NULL, -1);
        if (change_dir(path) < 0) {
index 9d6ba7e..cfbadcc 100644 (file)
@@ -97,7 +97,8 @@ static gchar *news_parse_xhdr          (const gchar   *xhdr_str,
                                          MsgInfo       *msginfo);
 gint news_get_num_list                  (Folder        *folder, 
                                          FolderItem    *item,
-                                         GSList       **list);
+                                         GSList       **list,
+                                         gboolean      *old_uids_valid);
 MsgInfo *news_get_msginfo               (Folder        *folder, 
                                          FolderItem    *item,
                                          gint           num);
@@ -760,7 +761,7 @@ gchar *news_item_get_path(Folder *folder, FolderItem *item)
        return path;
 }
 
-gint news_get_num_list(Folder *folder, FolderItem *item, GSList **msgnum_list)
+gint news_get_num_list(Folder *folder, FolderItem *item, GSList **msgnum_list, gboolean *old_uids_valid)
 {
        NNTPSession *session;
        gint i, ok, num, first, last, nummsgs = 0;
@@ -773,6 +774,8 @@ gint news_get_num_list(Folder *folder, FolderItem *item, GSList **msgnum_list)
        session = news_session_get(folder);
        g_return_val_if_fail(session != NULL, -1);
 
+       *old_uids_valid = TRUE;
+
        ok = news_select_group(session, item->path, &num, &first, &last);
        if (ok != NN_SUCCESS) {
                log_warning(_("can't set group: %s\n"), item->path);