2007-01-16 [colin] 2.7.1cvs11
authorColin Leroy <colin@colino.net>
Tue, 16 Jan 2007 22:08:35 +0000 (22:08 +0000)
committerColin Leroy <colin@colino.net>
Tue, 16 Jan 2007 22:08:35 +0000 (22:08 +0000)
* src/imap.c
* src/imap.h
* src/imap_gtk.c
Manage subscribing to subfolders when only
subscribed folders are shown.

ChangeLog
PATCHSETS
configure.ac
src/imap.c
src/imap.h
src/imap_gtk.c

index 2cdae852c9b1dccd2c11d702bf9098b4b461fef7..4bcd3ed20c82cbc43f5630f7734ed424647987e4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-01-16 [colin]     2.7.1cvs11
+
+       * src/imap.c
+       * src/imap.h
+       * src/imap_gtk.c
+               Manage subscribing to subfolders when only
+               subscribed folders are shown.
+
 2007-01-16 [colin]     2.7.1cvs10
 
        * src/folderview.c
index 03d27dad0b71054c8586df2ce000fcd8be31a734..55e38d5f7a41642bbe3d6b6ce84a2060cb9d1c93 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.60.2.24 -r 1.60.2.25 src/filtering.c;  cvs diff -u -r 1.179.2.150 -r 1.179.2.151 src/imap.c;  cvs diff -u -r 1.34.2.10 -r 1.34.2.11 src/imap.h;  cvs diff -u -r 1.1.2.38 -r 1.1.2.39 src/imap_gtk.c;  cvs diff -u -r 1.105.2.79 -r 1.105.2.80 src/prefs_account.c;  cvs diff -u -r 1.49.2.24 -r 1.49.2.25 src/prefs_account.h;  cvs diff -u -r 1.1.2.46 -r 1.1.2.47 src/wizard.c;  cvs diff -u -r 1.1.4.70 -r 1.1.4.71 src/etpan/imap-thread.c;  cvs diff -u -r 1.1.4.12 -r 1.1.4.13 src/etpan/imap-thread.h;  cvs diff -u -r 1.1.2.14 -r 1.1.2.15 manual/handling.xml;  ) > 2.7.1cvs8.patchset
 ( cvs diff -u -r 1.179.2.151 -r 1.179.2.152 src/imap.c;  ) > 2.7.1cvs9.patchset
 ( cvs diff -u -r 1.207.2.142 -r 1.207.2.143 src/folderview.c;  ) > 2.7.1cvs10.patchset
+( cvs diff -u -r 1.179.2.152 -r 1.179.2.153 src/imap.c;  cvs diff -u -r 1.34.2.11 -r 1.34.2.12 src/imap.h;  cvs diff -u -r 1.1.2.39 -r 1.1.2.40 src/imap_gtk.c;  ) > 2.7.1cvs11.patchset
index 6190b20dbbf0816761f89d05b0a9293698f1bc50..0bfb7ce0ec626dcb28bbefd80ad1a45220fbe46d 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=7
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=10
+EXTRA_VERSION=11
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 1a46e48bc389567e41bf7f376cadaf4bb622c82e..de91783db5f06dcc3597a86f96a6e378f945d40a 100644 (file)
@@ -1725,12 +1725,59 @@ static gint imap_scan_tree_recursive(IMAPSession *session, FolderItem *item, gbo
        return IMAP_SUCCESS;
 }
 
-gint imap_scan_subtree(Folder *folder, FolderItem *item, gboolean subs_only)
+GList *imap_scan_subtree(Folder *folder, FolderItem *item, gboolean subs_only)
 {
        IMAPSession *session = imap_session_get(folder);
+       gchar *real_path;
+       gchar *wildcard_path;
+       gchar separator;
+       gchar wildcard[3];
+       clist * lep_list;
+       GSList *item_list = NULL, *cur;
+       GList *child_list = NULL;
+       int r;
+
        if (!session)
-               return -1;
-       return imap_scan_tree_recursive(session, item, subs_only);
+               return NULL;
+
+       separator = imap_get_path_separator(session, IMAP_FOLDER(folder), item->path);
+
+       if (item->path) {
+               wildcard[0] = separator;
+               wildcard[1] = '%';
+               wildcard[2] = '\0';
+               real_path = imap_get_real_path(session, IMAP_FOLDER(folder), item->path);
+       } else {
+               wildcard[0] = '%';
+               wildcard[1] = '\0';
+               real_path = g_strdup("");
+       }
+
+       Xstrcat_a(wildcard_path, real_path, wildcard,
+                 {g_free(real_path); return NULL;});
+       lep_list = NULL;
+       
+       if (subs_only)
+               r = imap_threaded_lsub(folder, "", wildcard_path, &lep_list);
+       else
+               r = imap_threaded_list(folder, "", wildcard_path, &lep_list);
+       if (r)
+               return NULL;
+
+       item_list = imap_list_from_lep(IMAP_FOLDER(folder),
+                              lep_list, real_path, FALSE);
+       mailimap_list_result_free(lep_list);
+
+       for (cur = item_list; cur != NULL; cur = cur->next) {
+               FolderItem *cur_item = FOLDER_ITEM(cur->data);
+               child_list = g_list_prepend(child_list,
+                               imap_get_real_path(session, 
+                                       IMAP_FOLDER(folder), cur_item->path));
+               folder_item_destroy(cur_item);
+       }
+       child_list = g_list_reverse(child_list);
+       g_slist_free(item_list);
+       return child_list;
 }
 
 static gint imap_create_tree(Folder *folder)
@@ -2078,26 +2125,30 @@ static gint imap_rename_folder(Folder *folder, FolderItem *item,
        return 0;
 }
 
-gint imap_subscribe(Folder *folder, FolderItem *item, gboolean sub)
+gint imap_subscribe(Folder *folder, FolderItem *item, gchar *rpath, gboolean sub)
 {
        gchar *path;
-       gint r;
+       gint r = -1;
        IMAPSession *session;
        debug_print("getting session...\n");
 
        session = imap_session_get(folder);
-       if (!session || !item->path) {
+       if (!session) {
                return -1;
        }
-
-       path = imap_get_real_path(session, IMAP_FOLDER(folder), item->path);
-       if (!path)
-               return -1;
-       if (!strcmp(path, "INBOX") && sub == FALSE)
+       if (item && item->path) {
+               path = imap_get_real_path(session, IMAP_FOLDER(folder), item->path);
+               if (!path)
+                       return -1;
+               if (!strcmp(path, "INBOX") && sub == FALSE)
+                       return -1;
+               debug_print("%ssubscribing %s\n", sub?"":"un", path);
+               r = imap_threaded_subscribe(folder, path, sub);
+               g_free(path);
+       } else if (rpath) {
+               r = imap_threaded_subscribe(folder, rpath, sub);
+       } else
                return -1;
-       debug_print("%ssubscribing %s\n", sub?"":"un", path);
-       r = imap_threaded_subscribe(folder, path, sub);
-       g_free(path);
        return r;
 }
 
@@ -4160,7 +4211,6 @@ static GSList * imap_list_from_lep(IMAPFolder * folder,
                        free(dup_name);
                        continue;
                }
-               
                if (!all && path_cmp(name, real_path) == 0) {
                        g_free(base);
                        free(dup_name);
@@ -4500,12 +4550,12 @@ gint imap_scan_tree_real(Folder *folder, gboolean subs_only)
        return -1;
 }
 
-gint imap_subscribe(Folder *folder, FolderItem *item, gboolean sub)
+gint imap_subscribe(Folder *folder, FolderItem *item, gchar *rpath, gboolean sub)
 {
        return -1;
 }
 
-gint imap_scan_subtree(Folder *folder, FolderItem *item, gboolean subs_only)
+GList * imap_scan_subtree(Folder *folder, FolderItem *item, gboolean subs_only)
 {
        return -1;
 }
index cf24e8a2c38acb75ea324522bbafcf9bc13ce3c0..1bcc9031705c825d210d51455d036d2fc181294c 100644 (file)
@@ -37,6 +37,6 @@ void imap_folder_unref(Folder *folder);
 gchar imap_get_path_separator_for_item (FolderItem *item);
 void imap_disconnect_all(void);
 gint imap_scan_tree_real(Folder *folder, gboolean subs_only);
-gint imap_subscribe(Folder *folder, FolderItem *item, gboolean sub);
-gint imap_scan_subtree(Folder *folder, FolderItem *item, gboolean subs_only);
+gint imap_subscribe(Folder *folder, FolderItem *item, gchar *rpath, gboolean sub);
+GList *imap_scan_subtree(Folder *folder, FolderItem *item, gboolean subs_only);
 #endif /* __IMAP_H__ */
index 6383b92d648017048d9ebfd022839413cdfd0d1f..dcd2f1d74eb549e6440f53174e805f05f27a039c 100644 (file)
@@ -401,7 +401,7 @@ static gboolean imap_gtk_subscribe_func(GNode *node, gpointer data)
        gboolean action = GPOINTER_TO_INT(data);
        
        if (item->path)
-               imap_subscribe(item->folder, item, action);
+               imap_subscribe(item->folder, item, NULL, action);
 
        return FALSE;
 }
@@ -426,12 +426,34 @@ static void subscribe_cb(FolderView *folderview, guint action,
        AUTORELEASE_STR(name, {g_free(name); return;});
        
        if (action && item->folder->account->imap_subsonly) {
-               alertpanel_notice(_("This folder is already subscribed to. To "
+               GList *child_list = imap_scan_subtree(item->folder, item, FALSE);
+               if (child_list) {
+                       GList *cur;
+                       int r = -1;
+                       gchar *child_folder = input_dialog_combo(_("Subscribe"), 
+                                       _("Choose a subfolder to subscribe to: "),
+                                       _("All of them"), child_list, TRUE);
+                       if (child_folder && strcmp(child_folder, _("All of them"))) {
+                               r = imap_subscribe(item->folder, NULL, child_folder, TRUE);
+                       } else if (child_folder) {
+                               for (cur = child_list; cur; cur = cur->next) 
+                                       r = imap_subscribe(item->folder, NULL, (gchar *)cur->data, TRUE);
+                       }
+                       g_free(child_folder);
+                       for (cur = child_list; cur; cur = cur->next) 
+                               g_free((gchar *)cur->data);
+                       if (r == 0)
+                               folderview_rescan_tree(item->folder, FALSE);
+               } else {
+                       alertpanel_notice(_("This folder is already subscribed to and "
+                                 "has no subfolders. To "
                                  "subscribe to other folders, you must first "
                                  "disable \"Show subscribed folders only\".\n"
                                  "\n"
                                  "Alternatively, you can use \"Create new folder\" "
                                  "to subscribe to a known folder."));
+               }
+               g_list_free(child_list);
                return;
        }
        message = g_strdup_printf
@@ -453,7 +475,7 @@ static void subscribe_cb(FolderView *folderview, guint action,
                g_node_traverse(item->node, G_PRE_ORDER,
                        G_TRAVERSE_ALL, -1, imap_gtk_subscribe_func, GINT_TO_POINTER(action));
        } else {
-               imap_subscribe(item->folder, item, action);
+               imap_subscribe(item->folder, item, NULL, action);
        }
 
        if (!action && item->folder->account->imap_subsonly)