# New ports collection makefile for: py-pypgsql # Date created: 01 Nov 2001 # Whom: Gerhard Haering # # $FreeBSD$ # PORTNAME= pyPgSQL PORTVERSION= 2.5.1 PORTREVISION= 2 CATEGORIES= databases python MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} MASTER_SITE_SUBDIR= pypgsql PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} MAINTAINER= python@FreeBSD.org COMMENT= A Python DB-API 2 compliant library for using PostgreSQL databases RUN_DEPENDS= ${DATETIME_DEP}:${PORTSDIR}/lang/py-mx-base USE_PGSQL= yes USE_PYTHON= yes USE_PYDISTUTILS= yes DOCS= Announce ChangeLog README README.html EXAMPLES= examples/*.py DATETIME_DEP= ${PYTHON_SITELIBDIR}/mx/DateTime/__init__.py DOCSDIR= ${PREFIX}/share/doc/py-pyPgSQL EXAMPLESDIR= ${PREFIX}/share/examples/py-pyPgSQL post-install: .if !defined(NOPORTDOCS) @${MKDIR} ${DOCSDIR} .for f in ${DOCS} @${INSTALL_DATA} ${WRKSRC}/${f} ${DOCSDIR} .endfor .endif .if !defined(NOPORTEXAMPLES) @${MKDIR} ${EXAMPLESDIR} .for f in ${EXAMPLES} @${INSTALL_DATA} ${WRKSRC}/${f} ${EXAMPLESDIR} .endfor .endif .include d class='form'>
Google Summer of Code 2013 - GNOME - Archive Integration workspace
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodney Dawes <dobey@novell.com>2005-05-14 05:29:28 +0800
committerRodney Dawes <dobey@src.gnome.org>2005-05-14 05:29:28 +0800
commitd88e794ded5fc1ea72af2a3d0ec4c46442a992cf (patch)
tree33b921e3906bc3990d30eeb0195c0fe13181cee6
parentc006784d0d4612e4c682732c7db0fea35e9407e0 (diff)
downloadgsoc2013-evolution-d88e794ded5fc1ea72af2a3d0ec4c46442a992cf.tar.gz
gsoc2013-evolution-d88e794ded5fc1ea72af2a3d0ec4c46442a992cf.tar.zst
gsoc2013-evolution-d88e794ded5fc1ea72af2a3d0ec4c46442a992cf.zip
Add profiler so that it gets disted properly
2005-05-13 Rodney Dawes <dobey@novell.com> * plugins/Makefile.am (DIST_SUBDIRS): Add profiler so that it gets disted properly 2005-05-13 Rodney Dawes <dobey@novell.com> * Makefile.am: Add new em-folder-utils.[ch] abstraction * em-folder-browser.c: Update for new menu layout Add new methods to handle the actions that were previously only available from the context menu when right-clicking on a folder * em-folder-selector.c (emfs_response): Just call emfu_folder_create if the user wants to create a new folder in the selector dialog (em_folder_selector_get_selected_path): Clean up the code to fix a couple potential crashes * em-folder-tree.[ch]: Add methods to get pointers to a CamelFolder or CamelFolderInfo object for the selected item in the tree Add a method to get a pointer to an EMFolderTreeModelStoreInfo object for the selected store in the tree Move folder operations out into em-folder-utils.[ch] so that they are abstracted from the tree and can be used by methods other than the internal context menu * em-folder-utils.[ch]: Move the folder operations code to here * em-folder-view.c: Update for the new menu layout Fix Mark as Read/Unread in the context menu to only show up in the list * mail-component.c (create_item): Just call emfu_folder_create here when the user requests to create a new folder from the New toolbar item 2005-05-13 Rodney Dawes <dobey@novell.com> * org-gnome-mailing-list-actions.xml: Update for the new menu layout 2005-05-13 Rodney Dawes <dobey@novell.com> * org-gnome-plugin-manager.xml: Update for new menu layout 2005-05-13 Rodney Dawes <dobey@novell.com> * org-gnome-save-attachments.xml: Update for new menu layout 2005-05-13 Rodney Dawes <dobey@novell.com> * e-shell-window.c (setup_widgets): Update for the new menu layout by putting the "component" switching items under the "Tools" menu 2005-05-13 Rodney Dawes <dobey@novell.com> * *.xml: Update to the new menu layout 2005-05-13 Rodney Dawes <dobey@novell.com> * e-filter-bar.[ch]: Update for the new menu layout svn path=/trunk/; revision=29354
-rw-r--r--ChangeLog5
-rw-r--r--mail/ChangeLog29
-rw-r--r--mail/Makefile.am2
-rw-r--r--mail/em-folder-browser.c125
-rw-r--r--mail/em-folder-selector.c32
-rw-r--r--mail/em-folder-tree.c800
-rw-r--r--mail/em-folder-tree.h3
-rw-r--r--mail/em-folder-utils.c744
-rw-r--r--mail/em-folder-utils.h32
-rw-r--r--mail/em-folder-view.c117
-rw-r--r--mail/mail-component.c27
-rw-r--r--plugins/Makefile.am2
-rw-r--r--plugins/mailing-list-actions/ChangeLog4
-rw-r--r--plugins/mailing-list-actions/org-gnome-mailing-list-actions.xml4
-rw-r--r--plugins/plugin-manager/ChangeLog4
-rw-r--r--plugins/plugin-manager/org-gnome-plugin-manager.xml10
-rw-r--r--plugins/save-attachments/ChangeLog4
-rw-r--r--plugins/save-attachments/org-gnome-save-attachments.xml9
-rw-r--r--shell/ChangeLog5
-rw-r--r--shell/e-shell-window.c5
-rw-r--r--ui/ChangeLog4
-rw-r--r--ui/evolution-addressbook.xml5
-rw-r--r--ui/evolution-calendar.xml5
-rw-r--r--ui/evolution-mail-global.xml94
-rw-r--r--ui/evolution-mail-list.xml104
-rw-r--r--ui/evolution-mail-message.xml198
-rw-r--r--ui/evolution-mail-messagedisplay.xml37
-rw-r--r--ui/evolution-tasks.xml5
-rw-r--r--ui/evolution.xml51
-rw-r--r--widgets/misc/ChangeLog4
-rw-r--r--widgets/misc/e-filter-bar.c22
-rw-r--r--widgets/misc/e-filter-bar.h4
32 files changed, 1451 insertions, 1045 deletions
diff --git a/ChangeLog b/ChangeLog
index 605cf5601d..9c81265d91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-05-13 Rodney Dawes <dobey@novell.com>
+
+ * plugins/Makefile.am (DIST_SUBDIRS): Add profiler so that it gets
+ disted properly
+
2005-05-12 Not Zed <NotZed@Ximian.com>
* configure.in: Added mail-remote stuff. an experimental plugin.
diff --git a/mail/ChangeLog b/mail/ChangeLog
index e477b2797e..b247d8cdde 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,32 @@
+2005-05-13 Rodney Dawes <dobey@novell.com>
+
+ * Makefile.am: Add new em-folder-utils.[ch] abstraction
+
+ * em-folder-browser.c: Update for new menu layout
+ Add new methods to handle the actions that were previously only
+ available from the context menu when right-clicking on a folder
+
+ * em-folder-selector.c (emfs_response): Just call emfu_folder_create
+ if the user wants to create a new folder in the selector dialog
+ (em_folder_selector_get_selected_path): Clean up the code to fix a
+ couple potential crashes
+
+ * em-folder-tree.[ch]: Add methods to get pointers to a CamelFolder or
+ CamelFolderInfo object for the selected item in the tree
+ Add a method to get a pointer to an EMFolderTreeModelStoreInfo object
+ for the selected store in the tree
+ Move folder operations out into em-folder-utils.[ch] so that they
+ are abstracted from the tree and can be used by methods other than
+ the internal context menu
+
+ * em-folder-utils.[ch]: Move the folder operations code to here
+
+ * em-folder-view.c: Update for the new menu layout
+ Fix Mark as Read/Unread in the context menu to only show up in the list
+
+ * mail-component.c (create_item): Just call emfu_folder_create here
+ when the user requests to create a new folder from the New toolbar item
+
2005-05-13 Shreyas Srinivasan <sshreyas@novell.com>
* Fixes bug #273868, #300113, #302831.
diff --git a/mail/Makefile.am b/mail/Makefile.am
index 567e2256b9..b32973ad58 100644
--- a/mail/Makefile.am
+++ b/mail/Makefile.am
@@ -93,6 +93,8 @@ libevolution_mail_la_SOURCES = \
em-folder-tree-model.h \
em-folder-tree.c \
em-folder-tree.h \
+ em-folder-utils.c \
+ em-folder-utils.h \
em-folder-view.c \
em-folder-view.h \
em-format-hook.c \
diff --git a/mail/em-folder-browser.c b/mail/em-folder-browser.c
index 582546facb..257ac8ad38 100644
--- a/mail/em-folder-browser.c
+++ b/mail/em-folder-browser.c
@@ -73,6 +73,7 @@
#include "em-format-html-print.h"
#include "em-folder-browser.h"
#include "em-folder-properties.h"
+#include "em-folder-utils.h"
#include "em-subscribe-editor.h"
#include "em-menu.h"
#include "message-list.h"
@@ -569,6 +570,91 @@ emfb_folder_properties(BonoboUIComponent *uid, void *data, const char *path)
}
static void
+emfb_folder_copy(BonoboUIComponent *uid, void *data, const char *path)
+{
+ EMFolderBrowser *emfb = data;
+ CamelFolderInfo *fi = NULL;
+ CamelException ex;
+
+ camel_exception_init (&ex);
+
+ if ((fi = camel_store_get_folder_info (emfb->view.folder->parent_store,
+ emfb->view.folder->full_name,
+ CAMEL_STORE_FOLDER_INFO_FAST,
+ &ex)) != NULL)
+ emfu_copy_folder (fi);
+
+ camel_exception_clear (&ex);
+
+ return;
+}
+
+static void
+emfb_folder_move(BonoboUIComponent *uid, void *data, const char *path)
+{
+ EMFolderBrowser *emfb = data;
+ CamelFolderInfo *fi = NULL;
+ CamelException ex;
+
+ camel_exception_init (&ex);
+
+ if ((fi = camel_store_get_folder_info (emfb->view.folder->parent_store,
+ emfb->view.folder->full_name,
+ CAMEL_STORE_FOLDER_INFO_FAST,
+ &ex)) != NULL)
+ emfu_move_folder (fi);
+
+ camel_exception_clear (&ex);
+
+ return;
+}
+
+static void
+emfb_folder_delete(BonoboUIComponent *uid, void *data, const char *path)
+{
+ EMFolderBrowser *emfb = data;
+
+ emfu_delete_folder (emfb->view.folder);
+
+ return;
+}
+
+static void
+emfb_folder_rename(BonoboUIComponent *uid, void *data, const char *path)
+{
+ EMFolderBrowser *emfb = data;
+
+ emfu_rename_folder (emfb->view.folder);
+
+ return;
+}
+
+static void
+emfb_folder_create(BonoboUIComponent *uid, void *data, const char *path)
+{
+ EMFolderBrowser *emfb = data;
+ CamelFolderInfo *fi = NULL;
+ CamelException ex;
+
+ camel_exception_init (&ex);
+
+ if (emfb->view.folder) {
+ if ((fi = camel_store_get_folder_info (emfb->view.folder->parent_store,
+ emfb->view.folder->full_name,
+ CAMEL_STORE_FOLDER_INFO_FAST,
+ &ex)) != NULL)
+ emfu_folder_create (fi);
+ } else {
+ emfu_folder_create (NULL);
+ }
+
+
+ camel_exception_clear (&ex);
+
+ return;
+}
+
+static void
emfb_folder_expunge(BonoboUIComponent *uid, void *data, const char *path)
{
EMFolderBrowser *emfb = data;
@@ -628,25 +714,6 @@ emfb_view_show_all(BonoboUIComponent *uid, void *data, const char *path)
/* ********************************************************************** */
static void
-emfb_empty_trash(BonoboUIComponent *uid, void *data, const char *path)
-{
- EMFolderView *emfv = data;
-
- em_utils_empty_trash (gtk_widget_get_toplevel ((GtkWidget *) emfv));
-}
-
-static void
-emfb_mail_compose(BonoboUIComponent *uid, void *data, const char *path)
-{
- EMFolderView *emfv = data;
-
- if (!em_utils_check_user_can_send_mail((GtkWidget *)emfv))
- return;
-
- em_utils_compose_new_message(emfv->folder_uri);
-}
-
-static void
emfb_mail_stop(BonoboUIComponent *uid, void *data, const char *path)
{
mail_cancel_all();
@@ -712,8 +779,12 @@ static BonoboUIVerb emfb_verbs[] = {
BONOBO_UI_UNSAFE_VERB ("ViewShowAll", emfb_view_show_all),
/* ViewThreaded is a toggle */
- BONOBO_UI_UNSAFE_VERB ("EmptyTrash", emfb_empty_trash),
- BONOBO_UI_UNSAFE_VERB ("MailCompose", emfb_mail_compose),
+ BONOBO_UI_UNSAFE_VERB ("FolderCopy", emfb_folder_copy),
+ BONOBO_UI_UNSAFE_VERB ("FolderMove", emfb_folder_move),
+ BONOBO_UI_UNSAFE_VERB ("FolderDelete", emfb_folder_delete),
+ BONOBO_UI_UNSAFE_VERB ("FolderRename", emfb_folder_rename),
+ BONOBO_UI_UNSAFE_VERB ("FolderCreate", emfb_folder_create),
+
BONOBO_UI_UNSAFE_VERB ("MailPost", emfb_mail_post),
BONOBO_UI_UNSAFE_VERB ("MailStop", emfb_mail_stop),
BONOBO_UI_UNSAFE_VERB ("ToolsFilters", emfb_tools_filters),
@@ -726,11 +797,8 @@ static BonoboUIVerb emfb_verbs[] = {
static EPixmap emfb_pixmaps[] = {
E_PIXMAP ("/commands/ChangeFolderProperties", "stock_folder-properties", E_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/ViewHideRead", "stock_mail-hide-read", E_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/ViewHideSelected", "stock_mail-hide-selected", E_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/ViewShowAll", "stock_show-all", E_ICON_SIZE_MENU),
-
- E_PIXMAP ("/commands/MailCompose", "stock_mail-compose", E_ICON_SIZE_MENU),
+ E_PIXMAP ("/commands/FolderCopy", "stock_folder-copy", E_ICON_SIZE_MENU),
+ E_PIXMAP ("/commands/FolderMove", "stock_folder-move", E_ICON_SIZE_MENU),
E_PIXMAP_END
};
@@ -740,10 +808,13 @@ static const EMFolderViewEnable emfb_enable_map[] = {
{ "EditSelectAll", EM_POPUP_SELECT_FOLDER },
{ "EditSelectThread", EM_FOLDER_VIEW_SELECT_THREADED },
{ "FolderExpunge", EM_POPUP_SELECT_FOLDER },
+ { "FolderCopy", EM_POPUP_SELECT_FOLDER },
+ { "FolderMove", EM_POPUP_SELECT_FOLDER },
+ { "FolderDelete", EM_POPUP_SELECT_FOLDER },
+ { "FolderRename", EM_POPUP_SELECT_FOLDER },
{ "MailPost", EM_POPUP_SELECT_FOLDER },
{ "MessageMarkAllAsRead", EM_POPUP_SELECT_FOLDER },
{ "ViewHideSelected", EM_POPUP_SELECT_MANY },
- { "ViewShowAll", EM_FOLDER_VIEW_SELECT_HIDDEN },
{ NULL },
};
diff --git a/mail/em-folder-selector.c b/mail/em-folder-selector.c
index 69f4662d79..4a88e29ad9 100644
--- a/mail/em-folder-selector.c
+++ b/mail/em-folder-selector.c
@@ -161,28 +161,7 @@ emfs_response (GtkWidget *dialog, int response, EMFolderSelector *emfs)
if (response != EM_FOLDER_SELECTOR_RESPONSE_NEW)
return;
- model = em_folder_tree_get_model (emfs->emft);
- emft = (EMFolderTree *) em_folder_tree_new_with_model (model);
- dialog = em_folder_selector_create_new (emft, 0, _("Create New Folder"), _("Specify where to create the folder:"));
- gtk_window_set_transient_for ((GtkWindow *) dialog, (GtkWindow *) emfs);
- uri = em_folder_selector_get_selected_uri (emfs);
- if (uri)
- em_folder_tree_set_selected (emft, uri);
-
- if (gtk_dialog_run ((GtkDialog *) dialog) == GTK_RESPONSE_OK) {
- uri = em_folder_selector_get_selected_uri ((EMFolderSelector *) dialog);
- path = em_folder_selector_get_selected_path ((EMFolderSelector *) dialog);
-
- g_free (emfs->created_uri);
- emfs->created_uri = g_strdup (uri);
-
- if (emfs->created_id == 0)
- emfs->created_id = g_signal_connect (model, "folder-added", G_CALLBACK (folder_created_cb), emfs);
-
- em_folder_tree_create_folder (emfs->emft, path, uri);
- }
-
- gtk_widget_destroy (dialog);
+ emfu_folder_create (NULL);
g_signal_stop_emission_by_name (emfs, "response");
}
@@ -421,13 +400,10 @@ em_folder_selector_get_selected_path (EMFolderSelector *emfs)
char *newpath;
name = gtk_entry_get_text (emfs->name_entry);
- if (strcmp (path, "") != 0)
- newpath = g_strdup_printf ("%s/%s", path?path:"", name);
- else
- newpath = g_strdup (name);
-
+ newpath = g_strdup_printf ("%s/%s", path?path:"", name);
+
g_free(path);
- emfs->selected_path = newpath;
+ emfs->selected_path = g_strdup (newpath);
} else {
g_free(emfs->selected_path);
emfs->selected_path = path?path:g_strdup("");
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index d0e34e9e83..c584f1f138 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -67,6 +67,7 @@
#include "em-popup.h"
#include "em-marshal.h"
#include "em-folder-tree.h"
+#include "em-folder-utils.h"
#include "em-folder-selector.h"
#include "em-folder-selection.h"
#include "em-folder-properties.h"
@@ -2003,597 +2004,40 @@ emft_popup_open_new (GtkWidget *item, EMFolderTree *emft)
#endif
-struct _EMCopyFolders {
- struct _mail_msg msg;
-
- /* input data */
- CamelStore *fromstore;
- CamelStore *tostore;
-
- char *frombase;
- char *tobase;
-
- int delete;
-};
-
-static char *
-emft_copy_folders__desc (struct _mail_msg *mm, int complete)
-{
- struct _EMCopyFolders *m = (struct _EMCopyFolders *) mm;
-
- return g_strdup_printf (_("Copying `%s' to `%s'"), m->frombase, m->tobase);
-}
-
-static void
-emft_copy_folders__copy (struct _mail_msg *mm)
-{
- struct _EMCopyFolders *m = (struct _EMCopyFolders *) mm;
- guint32 flags = CAMEL_STORE_FOLDER_INFO_FAST | CAMEL_STORE_FOLDER_INFO_RECURSIVE;
- GList *pending = NULL, *deleting = NULL, *l;
- GString *fromname, *toname;
- CamelFolderInfo *fi;
- const char *tmp;
- int fromlen;
-
- if (camel_store_supports_subscriptions (m->fromstore))
- flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIBED;
-
- if (!(fi = camel_store_get_folder_info (m->fromstore, m->frombase, flags, &mm->ex)))
- return;
-
- pending = g_list_append (pending, fi);
-
- toname = g_string_new ("");
- fromname = g_string_new ("");
-
- tmp = strrchr (m->frombase, '/');
- if (tmp == NULL)
- fromlen = 0;
- else
- fromlen = tmp - m->frombase + 1;
-
- d(printf ("top name is '%s'\n", fi->full_name));
-
- while (pending) {
- CamelFolderInfo *info = pending->data;
-
- pending = g_list_remove_link (pending, pending);
- while (info) {
- CamelFolder *fromfolder, *tofolder;
- GPtrArray *uids;
- int deleted = 0;
-
- if (info->child)
- pending = g_list_append (pending, info->child);
-
- if (m->tobase[0])
- g_string_printf (toname, "%s/%s", m->tobase, info->full_name + fromlen);
- else
- g_string_printf (toname, "%s", info->full_name + fromlen);
-
- d(printf ("Copying from '%s' to '%s'\n", info->full_name, toname->str));
-
- /* This makes sure we create the same tree, e.g. from a nonselectable source */
- /* Not sure if this is really the 'right thing', e.g. for spool stores, but it makes the ui work */
- if ((info->flags & CAMEL_FOLDER_NOSELECT) == 0) {
- d(printf ("this folder is selectable\n"));
- if (m->tostore == m->fromstore && m->delete) {
- camel_store_rename_folder (m->fromstore, info->full_name, toname->str, &mm->ex);
- if (camel_exception_is_set (&mm->ex))
- goto exception;
-
- /* this folder no longer exists, unsubscribe it */
- if (camel_store_supports_subscriptions (m->fromstore))
- camel_store_unsubscribe_folder (m->fromstore, info->full_name, NULL);
-
- deleted = 1;
- } else {
- if (!(fromfolder = camel_store_get_folder (m->fromstore, info->full_name, 0, &mm->ex)))
- goto exception;
-
- if (!(tofolder = camel_store_get_folder (m->tostore, toname->str, CAMEL_STORE_FOLDER_CREATE, &mm->ex))) {
- camel_object_unref (fromfolder);
- goto exception;
- }
-
- uids = camel_folder_get_uids (fromfolder);
- camel_folder_transfer_messages_to (fromfolder, uids, tofolder, NULL, m->delete, &mm->ex);
- camel_folder_free_uids (fromfolder, uids);
-
- if (m->delete)
- camel_folder_sync(fromfolder, TRUE, NULL);
-
- camel_object_unref (fromfolder);
- camel_object_unref (tofolder);
- }
- }
-
- if (camel_exception_is_set (&mm->ex))
- goto exception;
- else if (m->delete && !deleted)
- deleting = g_list_prepend (deleting, info);
-
- /* subscribe to the new folder if appropriate */
- if (camel_store_supports_subscriptions (m->tostore)
- && !camel_store_folder_subscribed (m->tostore, toname->str))
- camel_store_subscribe_folder (m->tostore, toname->str, NULL);
-
- info = info->next;
- }
- }
-
- /* delete the folders in reverse order from how we copyied them, if we are deleting any */
- l = deleting;
- while (l) {
- CamelFolderInfo *info = l->data;
-
- d(printf ("deleting folder '%s'\n", info->full_name));
-
- /* FIXME: we need to do something with the exception
- since otherwise the users sees a failed operation
- with no error message or even any warnings */
- if (camel_store_supports_subscriptions (m->fromstore))
- camel_store_unsubscribe_folder (m->fromstore, info->full_name, NULL);
-
- camel_store_delete_folder (m->fromstore, info->full_name, NULL);
- l = l->next;
- }
-
- exception:
-
- camel_store_free_folder_info (m->fromstore, fi);
- g_list_free (deleting);
-
- g_string_free (toname, TRUE);
- g_string_free (fromname, TRUE);
-}
-
-static void
-emft_copy_folders__free (struct _mail_msg *mm)
-{
- struct _EMCopyFolders *m = (struct _EMCopyFolders *) mm;
-
- camel_object_unref (m->fromstore);
- camel_object_unref (m->tostore);
-
- g_free (m->frombase);
- g_free (m->tobase);
-}
-
-static struct _mail_msg_op copy_folders_op = {
- emft_copy_folders__desc,
- emft_copy_folders__copy,
- NULL,
- emft_copy_folders__free,
-};
-
-static void
-emft_copy_folders (CamelStore *tostore, const char *tobase, CamelStore *fromstore, const char *frombase, int delete)
-{
- struct _EMCopyFolders *m;
-
- m = mail_msg_new (&copy_folders_op, NULL, sizeof (struct _EMCopyFolders));
- camel_object_ref (fromstore);
- m->fromstore = fromstore;
- camel_object_ref (tostore);
- m->tostore = tostore;
- m->frombase = g_strdup (frombase);
- m->tobase = g_strdup (tobase);
- m->delete = delete;
-
- e_thread_put (mail_thread_new, (EMsg *) m);
-}
-
-struct _copy_folder_data {
- EMFolderTree *emft;
- gboolean delete;
-};
-
-static void
-emft_popup_copy_folder_selected (const char *uri, void *data)
-{
- struct _copy_folder_data *cfd = data;
- struct _EMFolderTreePrivate *priv;
- CamelStore *fromstore = NULL, *tostore = NULL;
- char *tobase = NULL, *frombase = NULL, *fromuri = NULL;
- CamelException ex;
- CamelURL *url;
-
- if (uri == NULL) {
- g_free (cfd);
- return;
- }
-
- priv = cfd->emft->priv;
-
- camel_exception_init (&ex);
-
- fromuri = em_folder_tree_get_selected_uri(cfd->emft);
- g_return_if_fail(fromuri != NULL);
- frombase = em_folder_tree_get_selected_path(cfd->emft);
- g_return_if_fail(frombase != NULL);
-
- if (!(fromstore = camel_session_get_store (session, fromuri, &ex))) {
- e_error_run((GtkWindow *)gtk_widget_get_toplevel((GtkWidget *) cfd->emft),
- cfd->delete?"mail:no-move-folder-notexist":"mail:no-copy-folder-notexist", frombase, uri, ex.desc, NULL);
- goto fail;
- }
-
- if (cfd->delete && fromstore == mail_component_peek_local_store (NULL) && is_special_local_folder (frombase)) {
- e_error_run((GtkWindow *)gtk_widget_get_toplevel((GtkWidget *) cfd->emft),
- "mail:no-rename-special-folder", frombase, NULL);
- goto fail;
- }
-
- if (!(tostore = camel_session_get_store (session, uri, &ex))) {
- e_error_run((GtkWindow *)gtk_widget_get_toplevel((GtkWidget *) cfd->emft),
- cfd->delete?"mail:no-move-folder-to-notexist":"mail:no-copy-folder-to-notexist", frombase, uri, ex.desc, NULL);
- goto fail;
- }
-
- url = camel_url_new (uri, NULL);
- if (((CamelService *)tostore)->provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH)
- tobase = url->fragment;
- else if (url->path && url->path[0])
- tobase = url->path+1;
- if (tobase == NULL)
- tobase = "";
-
- emft_copy_folders (tostore, tobase, fromstore, frombase, cfd->delete);
-
- camel_url_free (url);
-fail:
- if (fromstore)
- camel_object_unref(fromstore);
- if (tostore)
- camel_object_unref(tostore);
- g_free(frombase);
- g_free(fromuri);
- camel_exception_clear (&ex);
- g_free (cfd);
-}
-
-/* tree here is the 'destination' selector, not 'self' */
-static gboolean
-emft_popup_copy_folder_exclude(EMFolderTree *tree, GtkTreeModel *model, GtkTreeIter *iter, void *data)
-{
- struct _copy_folder_data *cfd = data;
- int fromvfolder, tovfolder;
- char *fromuri, *touri;
- guint flags;
- gboolean is_store;
-
- /* handles moving to/from vfolders */
-
- fromuri = em_folder_tree_get_selected_uri(cfd->emft);
- fromvfolder = strncmp(fromuri, "vfolder:", 8) == 0;
- gtk_tree_model_get(model, iter, COL_STRING_URI, &touri, COL_UINT_FLAGS, &flags, COL_BOOL_IS_STORE, &is_store, -1);
- tovfolder = strncmp(touri, "vfolder:", 8) == 0;
- g_free(fromuri);
- g_free(touri);
-
- /* moving from vfolder to normal- not allowed */
- if (fromvfolder && !tovfolder && cfd->delete)
- return FALSE;
- /* copy/move from normal folder to vfolder - not allowed */
- if (!fromvfolder && tovfolder)
- return FALSE;
- /* copying to vfolder - not allowed */
- if (tovfolder && !cfd->delete)
- return FALSE;
-
- return (flags & EMFT_EXCLUDE_NOINFERIORS) == 0;
-}
-
static void
emft_popup_copy(EPopup *ep, EPopupItem *item, void *data)
{
EMFolderTree *emft = data;
- struct _copy_folder_data *cfd;
-
- cfd = g_malloc (sizeof (*cfd));
- cfd->emft = emft;
- cfd->delete = FALSE;
-
- em_select_folder (NULL, _("Select folder"), _("C_opy"),
- NULL, emft_popup_copy_folder_exclude, emft_popup_copy_folder_selected, cfd);
-}
+ CamelFolderInfo *fi = NULL;
-static void
-emft_popup_move(EPopup *ep, EPopupItem *item, void *data)
-{
- EMFolderTree *emft = data;
- struct _copy_folder_data *cfd;
-
- cfd = g_malloc (sizeof (*cfd));
- cfd->emft = emft;
- cfd->delete = TRUE;
-
- em_select_folder (NULL, _("Select folder"), _("_Move"),
- NULL, emft_popup_copy_folder_exclude, emft_popup_copy_folder_selected, cfd);
-}
-
-
-struct _EMCreateFolder {
- struct _mail_msg msg;
-
- /* input data */
- CamelStore *store;
- char *full_name;
- char *parent;
- char *name;
-
- /* output data */
- CamelFolderInfo *fi;
-
- /* callback data */
- void (* done) (CamelFolderInfo *fi, void *user_data);
- void *user_data;
-};
-
-static char *
-emft_create_folder__desc (struct _mail_msg *mm, int done)
-{
- struct _EMCreateFolder *m = (struct _EMCreateFolder *) mm;
-
- return g_strdup_printf (_("Creating folder `%s'"), m->full_name);
-}
-
-static void
-emft_create_folder__create (struct _mail_msg *mm)
-{
- struct _EMCreateFolder *m = (struct _EMCreateFolder *) mm;
-
- d(printf ("creating folder parent='%s' name='%s' full_name='%s'\n", m->parent, m->name, m->full_name));
-
- if ((m->fi = camel_store_create_folder (m->store, m->parent, m->name, &mm->ex))) {
- if (camel_store_supports_subscriptions (m->store))
- camel_store_subscribe_folder (m->store, m->full_name, &mm->ex);
+ if ((fi = em_folder_tree_get_selected_folder_info (emft)) != NULL) {
+ emfu_copy_folder (fi);
}
}
static void
-emft_create_folder__created (struct _mail_msg *mm)
-{
- struct _EMCreateFolder *m = (struct _EMCreateFolder *) mm;
-
- if (m->done)
- m->done (m->fi, m->user_data);
-}
-
-static void
-emft_create_folder__free (struct _mail_msg *mm)
-{
- struct _EMCreateFolder *m = (struct _EMCreateFolder *) mm;
-
- camel_store_free_folder_info (m->store, m->fi);
- camel_object_unref (m->store);
- g_free (m->full_name);
- g_free (m->parent);
- g_free (m->name);
-}
-
-static struct _mail_msg_op create_folder_op = {
- emft_create_folder__desc,
- emft_create_folder__create,
- emft_create_folder__created,
- emft_create_folder__free,
-};
-
-
-static int
-emft_create_folder (CamelStore *store, const char *full_name, void (* done) (CamelFolderInfo *fi, void *user_data), void *user_data)
-{
- char *name, *namebuf = NULL;
- struct _EMCreateFolder *m;
- const char *parent;
- int id;
-
- namebuf = g_strdup (full_name);
- if (!(name = strrchr (namebuf, '/'))) {
- name = namebuf;
- parent = "";
- } else {
- *name++ = '\0';
- parent = namebuf;
- }
-
- m = mail_msg_new (&create_folder_op, NULL, sizeof (struct _EMCreateFolder));
- camel_object_ref (store);
- m->store = store;
- m->full_name = g_strdup (full_name);
- m->parent = g_strdup (parent);
- m->name = g_strdup (name);
- m->user_data = user_data;
- m->done = done;
-
- g_free (namebuf);
-
- id = m->msg.seq;
- e_thread_put (mail_thread_new, (EMsg *) m);
-
- return id;
-}
-
-static void
-created_cb (CamelFolderInfo *fi, void *user_data)
-{
- gboolean *created = user_data;
-
- *created = fi ? TRUE : FALSE;
-}
-
-gboolean
-em_folder_tree_create_folder (EMFolderTree *emft, const char *full_name, const char *uri)
-{
- struct _EMFolderTreePrivate *priv = emft->priv;
- struct _EMFolderTreeModelStoreInfo *si;
- gboolean created = FALSE;
- CamelStore *store;
- CamelException ex;
-
- d(printf ("Creating folder: %s (%s)\n", full_name, uri));
-
- camel_exception_init (&ex);
- if (!(store = (CamelStore *) camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, &ex))) {
- e_error_run((GtkWindow *)gtk_widget_get_toplevel((GtkWidget *)emft),
- "mail:no-create-folder-nostore", full_name, ex.desc, NULL);
- goto fail;
- }
-
- if (!(si = g_hash_table_lookup (priv->model->store_hash, store))) {
- abort();
- camel_object_unref (store);
- goto fail;
- }
-
- camel_object_unref (store);
-
- mail_msg_wait (emft_create_folder (si->store, full_name, created_cb, &created));
-fail:
- camel_exception_clear(&ex);
-
- return created;
-}
-
-static void
-new_folder_created_cb (CamelFolderInfo *fi, void *user_data)
-{
- EMFolderSelector *emfs = user_data;
-
- if (fi)
- gtk_widget_destroy ((GtkWidget *) emfs);
-
- g_object_unref (emfs);
-}
-
-static void
-emft_popup_new_folder_response (EMFolderSelector *emfs, int response, EMFolderTree *emft)
+emft_popup_move(EPopup *ep, EPopupItem *item, void *data)
{
- struct _EMFolderTreePrivate *priv = emft->priv;
- struct _EMFolderTreeModelStoreInfo *si;
- const char *uri, *path;
- CamelException ex;
- CamelStore *store;
-
- if (response != GTK_RESPONSE_OK) {
- gtk_widget_destroy ((GtkWidget *) emfs);
- return;
- }
-
- uri = em_folder_selector_get_selected_uri (emfs);
- path = em_folder_selector_get_selected_path (emfs);
-
- d(printf ("Creating new folder: %s (%s)\n", path, uri));
-
- camel_exception_init (&ex);
- if (!(store = (CamelStore *) camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, &ex))) {
- camel_exception_clear (&ex);
- return;
- }
-
- if (!(si = g_hash_table_lookup (priv->model->store_hash, store))) {
- g_assert_not_reached ();
- camel_object_unref (store);
- return;
- }
-
- /* HACK: we need to create vfolders using the vfolder editor */
- if (CAMEL_IS_VEE_STORE(store)) {
- EMVFolderRule *rule;
+ EMFolderTree *emft = data;
+ CamelFolderInfo *fi = NULL;
- rule = em_vfolder_rule_new();
- filter_rule_set_name((FilterRule *)rule, path);
- vfolder_gui_add_rule(rule);
- gtk_widget_destroy((GtkWidget *)emfs);
- } else {
- g_object_ref (emfs);
- emft_create_folder (si->store, path, new_folder_created_cb, emfs);
+ if ((fi = em_folder_tree_get_selected_folder_info (emft)) != NULL) {
+ emfu_copy_folder (fi);
}
-
- camel_object_unref (store);
}
static void
emft_popup_new_folder (EPopup *ep, EPopupItem *pitem, void *data)
{
EMFolderTree *emft = data;
+ CamelFolderInfo *fi;
- EMFolderTree *folder_tree;
- GtkWidget *dialog;
- char *uri;
-
- folder_tree = (EMFolderTree *) em_folder_tree_new_with_model (emft->priv->model);
-
- dialog = em_folder_selector_create_new (folder_tree, 0, _("Create folder"), _("Specify where to create the folder:"));
- uri = em_folder_tree_get_selected_uri(emft);
- em_folder_selector_set_selected ((EMFolderSelector *) dialog, uri);
- g_free(uri);
- g_signal_connect (dialog, "response", G_CALLBACK (emft_popup_new_folder_response), emft);
- gtk_widget_show (dialog);
-}
-
-static void
-emft_popup_delete_rec (CamelStore *store, CamelFolderInfo *fi, CamelException *ex)
-{
- while (fi) {
- CamelFolder *folder;
-
- if (fi->child) {
- emft_popup_delete_rec (store, fi->child, ex);
- if (camel_exception_is_set (ex))
- return;
- }
-
- d(printf ("deleting folder '%s'\n", fi->full_name));
-
- /* shouldn't camel do this itself? */
- if (camel_store_supports_subscriptions (store))
- camel_store_unsubscribe_folder (store, fi->full_name, NULL);
-
- if (!(folder = camel_store_get_folder (store, fi->full_name, 0, ex)))
- return;
-
- if (!CAMEL_IS_VEE_FOLDER (folder)) {
- GPtrArray *uids = camel_folder_get_uids (folder);
- int i;
-
- camel_folder_freeze (folder);
- for (i = 0; i < uids->len; i++)
- camel_folder_delete_message (folder, uids->pdata[i]);
-
- camel_folder_free_uids (folder, uids);
-
- camel_folder_sync (folder, TRUE, NULL);
- camel_folder_thaw (folder);
- }
-
- camel_store_delete_folder (store, fi->full_name, ex);
- if (camel_exception_is_set (ex))
- return;
-
- fi = fi->next;
+ if ((fi = em_folder_tree_get_selected_folder_info (emft)) != NULL) {
+ emfu_folder_create (fi);
}
}
static void
-emft_popup_delete_folders (CamelStore *store, const char *full_name, CamelException *ex)
-{
- guint32 flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE | CAMEL_STORE_FOLDER_INFO_FAST;
- CamelFolderInfo *fi;
-
- if (camel_store_supports_subscriptions (store))
- flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIBED;
-
- fi = camel_store_get_folder_info (store, full_name, flags, ex);
- if (camel_exception_is_set (ex))
- return;
-
- emft_popup_delete_rec (store, fi, ex);
- camel_store_free_folder_info (store, fi);
-}
-
-static void
selfunc (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
{
struct _emft_selection_data *dat = (struct _emft_selection_data *) data;
@@ -2620,163 +2064,25 @@ emft_selection_get_selected (GtkTreeSelection *selection, GtkTreeModel **model,
}
static void
-emft_popup_delete_response (GtkWidget *dialog, int response, EMFolderTree *emft)
-{
- CamelStore *store;
- CamelException ex;
- char *full_name;
-
- full_name = g_object_get_data ((GObject *) dialog, "full_name");
- store = g_object_get_data ((GObject *) dialog, "store");
-
- if (response == GTK_RESPONSE_OK) {
- camel_exception_init (&ex);
- emft_popup_delete_folders (store, full_name, &ex);
- if (camel_exception_is_set (&ex)) {
- e_error_run((GtkWindow *)gtk_widget_get_toplevel((GtkWidget *)emft),
- "mail:no-delete-folder", full_name, ex.desc, NULL);
- camel_exception_clear (&ex);
- }
- }
-
- gtk_widget_destroy (dialog);
-}
-
-static void
emft_popup_delete_folder (EPopup *ep, EPopupItem *pitem, void *data)
{
EMFolderTree *emft = data;
- struct _EMFolderTreePrivate *priv = emft->priv;
- GtkTreeSelection *selection;
- CamelStore *local, *store;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkWidget *dialog;
- char *full_name;
-
- selection = gtk_tree_view_get_selection (priv->treeview);
- if (!emft_selection_get_selected (selection, &model, &iter))
- return;
-
- gtk_tree_model_get (model, &iter, COL_POINTER_CAMEL_STORE, &store,
- COL_STRING_FULL_NAME, &full_name, -1);
-
- local = mail_component_peek_local_store (NULL);
-
- if (store == local && is_special_local_folder (full_name)) {
- e_error_run(NULL, "mail:no-delete-special-folder", full_name, NULL);
- return;
- }
-
- camel_object_ref (store);
+ CamelFolder *folder;
- dialog = e_error_new((GtkWindow *)gtk_widget_get_toplevel((GtkWidget *)emft),
- (store && CAMEL_IS_VEE_STORE(store))?"mail:ask-delete-vfolder":"mail:ask-delete-folder",
- full_name, NULL);
- g_object_set_data_full ((GObject *) dialog, "full_name", full_name, g_free);
- g_object_set_data_full ((GObject *) dialog, "store", store, camel_object_unref);
- g_signal_connect (dialog, "response", G_CALLBACK (emft_popup_delete_response), emft);
- gtk_widget_show (dialog);
+ if ((folder = em_folder_tree_get_selected_folder (emft)) != NULL) {
+ emfu_delete_folder (folder);
+ }
}
static void
emft_popup_rename_folder (EPopup *ep, EPopupItem *pitem, void *data)
{
EMFolderTree *emft = data;
- struct _EMFolderTreePrivate *priv = emft->priv;
- char *prompt, *full_name, *name, *new_name, *uri;
- GtkTreeSelection *selection;
- const char *p;
- CamelStore *local, *store;
- gboolean done = FALSE;
- GtkTreeModel *model;
- GtkTreeIter iter;
- size_t base_len;
-
- local = mail_component_peek_local_store (NULL);
-
- selection = gtk_tree_view_get_selection (priv->treeview);
- if (!emft_selection_get_selected (selection, &model, &iter))
- return;
-
- gtk_tree_model_get (model, &iter, COL_STRING_FULL_NAME, &full_name,
- COL_STRING_DISPLAY_NAME, &name,
- COL_POINTER_CAMEL_STORE, &store,
- COL_STRING_URI, &uri, -1);
-
- /* don't allow user to rename one of the special local folders */
- if (store == local && is_special_local_folder (full_name)) {
- e_error_run((GtkWindow *)gtk_widget_get_toplevel((GtkWidget *)emft),
- "mail:no-rename-special-folder", full_name, NULL);
- g_free (full_name);
- g_free (name);
- g_free (uri);
- return;
- }
-
- if ((p = strrchr (full_name, '/')))
- base_len = (size_t) (p - full_name);
- else
- base_len = 0;
-
- prompt = g_strdup_printf (_("Rename the \"%s\" folder to:"), name);
- while (!done) {
- new_name = e_request_string (NULL, _("Rename Folder"), prompt, name);
- if (new_name == NULL || !strcmp (name, new_name)) {
- /* old name == new name */
- done = TRUE;
- } else if (strchr(new_name, '/') != NULL) {
- e_error_run((GtkWindow *)gtk_widget_get_toplevel((GtkWidget *)emft),
- "mail:no-rename-folder", name, new_name, _("Folder names cannot contain '/'"), NULL);
- done = TRUE;
- } else {
- CamelFolderInfo *fi;
- CamelException ex;
- char *path, *p;
-
- if (base_len > 0) {
- path = g_malloc (base_len + strlen (new_name) + 2);
- memcpy (path, full_name, base_len);
- p = path + base_len;
- *p++ = '/';
- strcpy (p, new_name);
- } else {
- path = g_strdup (new_name);
- }
-
- camel_exception_init (&ex);
- if ((fi = camel_store_get_folder_info (store, path, CAMEL_STORE_FOLDER_INFO_FAST, &ex)) != NULL) {
- camel_store_free_folder_info (store, fi);
- e_error_run((GtkWindow *)gtk_widget_get_toplevel((GtkWidget *)emft),
- "mail:no-rename-folder-exists", name, new_name, NULL);
- } else {
- const char *oldpath, *newpath;
-
- oldpath = full_name;
- newpath = path;
-
- d(printf ("renaming %s to %s\n", oldpath, newpath));
-
- camel_exception_clear (&ex);
- camel_store_rename_folder (store, oldpath, newpath, &ex);
- if (camel_exception_is_set (&ex)) {
- e_error_run((GtkWindow *)gtk_widget_get_toplevel((GtkWidget *)emft),
- "mail:no-rename-folder", oldpath, newpath, ex.desc, NULL);
- camel_exception_clear (&ex);
- }
-
- done = TRUE;
- }
-
- g_free (path);
- }
-
- g_free (new_name);
+ CamelFolder *folder;
+
+ if ((folder = em_folder_tree_get_selected_folder (emft)) != NULL) {
+ emfu_rename_folder (folder);
}
-
- g_free (full_name);
- g_free (name);
- g_free (uri);
}
@@ -3030,6 +2336,60 @@ em_folder_tree_get_selected_path (EMFolderTree *emft)
return name;
}
+CamelFolder *
+em_folder_tree_get_selected_folder (EMFolderTree *emft)
+{
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ char *full_name = NULL;
+ CamelException ex;
+ CamelStore *store = NULL;
+ CamelFolder *folder = NULL;
+
+ g_return_val_if_fail (EM_IS_FOLDER_TREE (emft), NULL);
+
+ camel_exception_init (&ex);
+
+ selection = gtk_tree_view_get_selection(emft->priv->treeview);
+ if (gtk_tree_selection_get_selected(selection, &model, &iter))
+ gtk_tree_model_get (model, &iter, COL_POINTER_CAMEL_STORE, &store,
+ COL_STRING_FULL_NAME, &full_name, -1);
+
+ folder = camel_store_get_folder (store, full_name, CAMEL_STORE_FOLDER_INFO_FAST, &ex);
+
+ camel_exception_clear (&ex);
+
+ return folder;
+}
+
+CamelFolderInfo *
+em_folder_tree_get_selected_folder_info (EMFolderTree *emft)
+{
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ char *full_name = NULL;
+ CamelException ex;
+ CamelStore *store = NULL;
+ CamelFolderInfo *fi = NULL;
+
+ g_return_val_if_fail (EM_IS_FOLDER_TREE (emft), NULL);
+
+ camel_exception_init (&ex);
+
+ selection = gtk_tree_view_get_selection(emft->priv->treeview);
+ if (gtk_tree_selection_get_selected(selection, &model, &iter))
+ gtk_tree_model_get (model, &iter, COL_POINTER_CAMEL_STORE, &store,
+ COL_STRING_FULL_NAME, &full_name, -1);
+
+ fi = camel_store_get_folder_info (store, full_name, CAMEL_STORE_FOLDER_INFO_FAST, &ex);
+
+ camel_exception_clear (&ex);
+
+ return fi;
+}
+
EMFolderTreeModel *
em_folder_tree_get_model (EMFolderTree *emft)
{
@@ -3038,6 +2398,18 @@ em_folder_tree_get_model (EMFolderTree *emft)
return emft->priv->model;
}
+EMFolderTreeModelStoreInfo *
+em_folder_tree_get_model_storeinfo (EMFolderTree *emft, CamelStore *store)
+{
+ struct _EMFolderTreePrivate *priv = emft->priv;
+ struct _EMFolderTreeModelStoreInfo *si;
+
+ if (!(si = g_hash_table_lookup (priv->model->store_hash, store))) {
+ g_assert_not_reached ();
+ return NULL;
+ }
+ return si;
+}
static gboolean
emft_save_state (EMFolderTree *emft)
diff --git a/mail/em-folder-tree.h b/mail/em-folder-tree.h
index e7c465998b..35381dbfa3 100644
--- a/mail/em-folder-tree.h
+++ b/mail/em-folder-tree.h
@@ -85,8 +85,11 @@ GList *em_folder_tree_get_selected_paths (EMFolderTree *emft);
void em_folder_tree_set_selected (EMFolderTree *emft, const char *uri);
char *em_folder_tree_get_selected_uri (EMFolderTree *emft);
char *em_folder_tree_get_selected_path (EMFolderTree *emft);
+CamelFolder *em_folder_tree_get_selected_folder (EMFolderTree *emft);
+CamelFolderInfo *em_folder_tree_get_selected_folder_info (EMFolderTree *emft);
EMFolderTreeModel *em_folder_tree_get_model (EMFolderTree *emft);
+EMFolderTreeModelStoreInfo *em_folder_tree_get_model_storeinfo (EMFolderTree *emft, CamelStore *store);
gboolean em_folder_tree_create_folder (EMFolderTree *emft, const char *full_name, const char *uri);
diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c
new file mode 100644
index 0000000000..1e836fa661
--- /dev/null
+++ b/mail/em-folder-utils.c
@@ -0,0 +1,744 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Authors: Jeffrey Stedfast <fejj@ximian.com>
+ *
+ * Copyright 2003 Ximian, Inc. (www.ximian.com)
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include <libxml/tree.h>
+
+#include <gtk/gtk.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <libgnome/gnome-i18n.h>
+
+#include <camel/camel-session.h>
+#include <camel/camel-store.h>
+#include <camel/camel-folder.h>
+#include <camel/camel-vee-store.h>
+#include <camel/camel-vtrash-folder.h>
+#include <camel/camel-stream-mem.h>
+#include <camel/camel-file-utils.h>
+#include <camel/camel-stream-fs.h>
+
+#include "e-util/e-mktemp.h"
+#include "e-util/e-request.h"
+#include "e-util/e-icon-factory.h"
+
+#include "widgets/misc/e-error.h"
+
+#include "em-vfolder-rule.h"
+
+#include "mail-mt.h"
+#include "mail-ops.h"
+#include "mail-tools.h"
+#include "mail-config.h"
+#include "mail-component.h"
+#include "mail-vfolder.h"
+
+#include "em-utils.h"
+#include "em-popup.h"
+#include "em-marshal.h"
+#include "em-folder-tree.h"
+#include "em-folder-tree-model.h"
+#include "em-folder-utils.h"
+#include "em-folder-selector.h"
+#include "em-folder-selection.h"
+#include "em-folder-properties.h"
+
+#define d(x)
+
+extern CamelSession *session;
+
+static gboolean
+emfu_is_special_local_folder (const char *name)
+{
+ return (!strcmp (name, "Drafts") || !strcmp (name, "Inbox") || !strcmp (name, "Outbox") || !strcmp (name, "Sent"));
+}
+
+struct _EMCopyFolders {
+ struct _mail_msg msg;
+
+ /* input data */
+ CamelStore *fromstore;
+ CamelStore *tostore;
+
+ char *frombase;
+ char *tobase;
+
+ int delete;
+};
+
+static char *
+emft_copy_folders__desc (struct _mail_msg *mm, int complete)
+{
+ struct _EMCopyFolders *m = (struct _EMCopyFolders *) mm;
+
+ return g_strdup_printf (_("Copying `%s' to `%s'"), m->frombase, m->tobase);
+}
+
+static void
+emft_copy_folders__copy (struct _mail_msg *mm)
+{
+ struct _EMCopyFolders *m = (struct _EMCopyFolders *) mm;
+ guint32 flags = CAMEL_STORE_FOLDER_INFO_FAST | CAMEL_STORE_FOLDER_INFO_RECURSIVE;
+ GList *pending = NULL, *deleting = NULL, *l;
+ GString *fromname, *toname;
+ CamelFolderInfo *fi;
+ const char *tmp;
+ int fromlen;
+
+ if (camel_store_supports_subscriptions (m->fromstore))
+ flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIBED;
+
+ if (!(fi = camel_store_get_folder_info (m->fromstore, m->frombase, flags, &mm->ex)))
+ return;
+
+ pending = g_list_append (pending, fi);
+
+ toname = g_string_new ("");
+ fromname = g_string_new ("");
+
+ tmp = strrchr (m->frombase, '/');
+ if (tmp == NULL)
+ fromlen = 0;
+ else
+ fromlen = tmp - m->frombase + 1;
+
+ d(printf ("top name is '%s'\n", fi->full_name));
+
+ while (pending) {
+ CamelFolderInfo *info = pending->data;
+
+ pending = g_list_remove_link (pending, pending);
+ while (info) {
+ CamelFolder *fromfolder, *tofolder;
+ GPtrArray *uids;
+ int deleted = 0;
+
+ if (info->child)
+ pending = g_list_append (pending, info->child);
+
+ if (m->tobase[0])
+ g_string_printf (toname, "%s/%s", m->tobase, info->full_name + fromlen);
+ else
+ g_string_printf (toname, "%s", info->full_name + fromlen);
+
+ d(printf ("Copying from '%s' to '%s'\n", info->full_name, toname->str));
+
+ /* This makes sure we create the same tree, e.g. from a nonselectable source */
+ /* Not sure if this is really the 'right thing', e.g. for spool stores, but it makes the ui work */
+ if ((info->flags & CAMEL_FOLDER_NOSELECT) == 0) {
+ d(printf ("this folder is selectable\n"));
+ if (m->tostore == m->fromstore && m->delete) {
+ camel_store_rename_folder (m->fromstore, info->full_name, toname->str, &mm->ex);
+ if (camel_exception_is_set (&mm->ex))
+ goto exception;
+
+ /* this folder no longer exists, unsubscribe it */
+ if (camel_store_supports_subscriptions (m->fromstore))
+ camel_store_unsubscribe_folder (m->fromstore, info->full_name, NULL);
+
+ deleted = 1;
+ } else {
+ if (!(fromfolder = camel_store_get_folder (m->fromstore, info->full_name, 0, &mm->