* src/imap.[ch]
authorChristoph Hohmann <reboot@gmx.ch>
Thu, 25 Jul 2002 23:35:09 +0000 (23:35 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Thu, 25 Jul 2002 23:35:09 +0000 (23:35 +0000)
        imap folder now remembers the last selected
        folder and imap_fetch_msginfo skips selecting
        the folder if it is already selected

ChangeLog.claws
configure.in
src/imap.c
src/imap.h

index 440491d..3af56a1 100644 (file)
@@ -1,3 +1,10 @@
+2002-07-26 [christoph] 0.8.0claws15
+
+       * src/imap.[ch]
+               imap folder now remembers the last selected
+               folder and imap_fetch_msginfo skips selecting
+               the folder if it is already selected
+
 2002-07-26 [christoph] 0.8.0claws14
 
        * src/folder.c
index f0f42e8..f488f76 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=8
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws14
+EXTRA_VERSION=claws15
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 4345162..477250c 100644 (file)
@@ -291,6 +291,8 @@ Folder *imap_folder_new(const gchar *name, const gchar *path)
 
 void imap_folder_destroy(IMAPFolder *folder)
 {
+       g_free(folder->selected_folder);
+       
        folder_remote_folder_destroy(REMOTE_FOLDER(folder));
 }
 
@@ -299,7 +301,7 @@ static void imap_folder_init(Folder *folder, const gchar *name,
 {
        folder->type = F_IMAP;
 
-       folder_remote_folder_init(folder, name, path);
+       folder_remote_folder_init((Folder *)folder, name, path);
 
 /*
        folder->get_msg_list        = imap_get_msg_list;
@@ -325,6 +327,8 @@ static void imap_folder_init(Folder *folder, const gchar *name,
 
        folder->get_num_list          = imap_get_num_list;
        folder->fetch_msginfo         = imap_fetch_msginfo;
+       
+       ((IMAPFolder *)folder)->selected_folder = NULL;
 }
 
 FolderItem *imap_folder_item_new()
@@ -391,6 +395,8 @@ static IMAPSession *imap_session_get(Folder *folder)
                        imap_parse_namespace(IMAP_SESSION(rfolder->session),
                                             IMAP_FOLDER(folder));
                        rfolder->session->last_access_time = time(NULL);
+                       g_free(((IMAPFolder *)folder)->selected_folder);
+                       ((IMAPFolder *)folder)->selected_folder = NULL;
                        imap_reset_uid_lists(folder);
                }
                statusbar_pop_all();
@@ -421,6 +427,8 @@ static IMAPSession *imap_session_get(Folder *folder)
                if (rfolder->session) {
                        imap_parse_namespace(IMAP_SESSION(rfolder->session),
                                             IMAP_FOLDER(folder));
+                       g_free(((IMAPFolder *)folder)->selected_folder);
+                       ((IMAPFolder *)folder)->selected_folder = NULL;
                        imap_reset_uid_lists(folder);
                }
        }
@@ -2250,6 +2258,9 @@ static gint imap_select(IMAPSession *session, IMAPFolder *folder,
                session->mbox = g_strdup(path);
        g_free(real_path);
 
+       g_free(folder->selected_folder);
+       folder->selected_folder = g_strdup(path);
+       
        return ok;
 }
 
@@ -3151,28 +3162,32 @@ GSList *imap_get_num_list(Folder *folder, FolderItem *_item)
        return msgnum_list;
 }
 
-MsgInfo *imap_fetch_msginfo(Folder *folder, FolderItem *item, gint num)
+MsgInfo *imap_fetch_msginfo(Folder *_folder, FolderItem *item, gint num)
 {
+       IMAPFolder *folder = (IMAPFolder *)_folder;
        gchar *tmp;
        IMAPSession *session;
        GString *str;
        MsgInfo *msginfo;
-       gint ok, exists = 0, recent = 0, unseen = 0;
-       guint32 uid_validity = 0;
        
        g_return_val_if_fail(folder != NULL, NULL);
        g_return_val_if_fail(item != NULL, NULL);
        g_return_val_if_fail(item->folder != NULL, NULL);
        g_return_val_if_fail(item->folder->type == F_IMAP, NULL);
 
-       session = imap_session_get(folder);
+       session = imap_session_get(_folder);
        g_return_val_if_fail(session != NULL, NULL);
 
-       ok = imap_select(session, IMAP_FOLDER(folder), item->path,
-                        &exists, &recent, &unseen, &uid_validity);
-       if (ok != IMAP_SUCCESS)
-               return NULL;
-       
+       if(strcmp(folder->selected_folder, item->path) != 0) {
+               gint ok, exists = 0, recent = 0, unseen = 0;
+               guint32 uid_validity = 0;
+
+               ok = imap_select(session, IMAP_FOLDER(folder), item->path,
+                                &exists, &recent, &unseen, &uid_validity);
+               if (ok != IMAP_SUCCESS)
+                       return NULL;
+       }
+               
        if (imap_cmd_envelope(SESSION(session)->sock, num, num)
            != IMAP_SUCCESS) {
                log_warning(_("can't get envelope\n"));
index 05e75e4..920ff01 100644 (file)
@@ -48,6 +48,8 @@ struct _IMAPFolder
 {
        RemoteFolder rfolder;
 
+       gchar *selected_folder;
+       
        /* list of IMAPNameSpace */
        GList *ns_personal;
        GList *ns_others;