aboutsummaryrefslogtreecommitdiff
path: root/libsylph
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2012-07-27 06:41:26 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2012-07-27 06:41:26 +0000
commitd04a449d2ffef1e80af681ef1493d98eee88e22b (patch)
tree3588de02638dc329b22fd2633c3a90279592df0b /libsylph
parentcc0f803be0553bfb6f76941bf4147f813be09948 (diff)
made export/import progress dialog cancellable.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3142 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r--libsylph/folder.c42
-rw-r--r--libsylph/folder.h22
-rw-r--r--libsylph/mbox.c18
3 files changed, 72 insertions, 10 deletions
diff --git a/libsylph/folder.c b/libsylph/folder.c
index fb5b983d..6c48d355 100644
--- a/libsylph/folder.c
+++ b/libsylph/folder.c
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2011 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2012 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -48,6 +48,10 @@ typedef struct _FolderPrivData FolderPrivData;
struct _FolderPrivData {
Folder *folder;
FolderItem *junk;
+
+ FolderUIFunc2 ui_func2;
+ gpointer ui_func2_data;
+
gpointer data;
};
@@ -442,6 +446,42 @@ void folder_set_ui_func(Folder *folder, FolderUIFunc func, gpointer data)
folder->ui_func_data = data;
}
+void folder_set_ui_func2(Folder *folder, FolderUIFunc2 func, gpointer data)
+{
+ FolderPrivData *priv;
+
+ priv = folder_get_priv(folder);
+ if (priv) {
+ priv->ui_func2 = func;
+ priv->ui_func2_data = data;
+ }
+}
+
+FolderUIFunc2 folder_get_ui_func2(Folder *folder)
+{
+ FolderPrivData *priv;
+
+ priv = folder_get_priv(folder);
+ if (priv)
+ return priv->ui_func2;
+
+ return NULL;
+}
+
+gboolean folder_call_ui_func2(Folder *folder, FolderItem *item, guint count,
+ guint total)
+{
+ FolderPrivData *priv;
+
+ priv = folder_get_priv(folder);
+ if (priv && priv->ui_func2) {
+ return priv->ui_func2(folder, item, count, total,
+ priv->ui_func2_data);
+ }
+
+ return TRUE;
+}
+
void folder_set_name(Folder *folder, const gchar *name)
{
g_return_if_fail(folder != NULL);
diff --git a/libsylph/folder.h b/libsylph/folder.h
index 221f3e23..5a9e9669 100644
--- a/libsylph/folder.h
+++ b/libsylph/folder.h
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2011 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2012 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -115,6 +115,11 @@ typedef enum
typedef void (*FolderUIFunc) (Folder *folder,
FolderItem *item,
gpointer data);
+typedef gboolean (*FolderUIFunc2) (Folder *folder,
+ FolderItem *item,
+ guint count,
+ guint total,
+ gpointer data);
typedef void (*FolderDestroyNotify) (Folder *folder,
FolderItem *item,
gpointer data);
@@ -354,9 +359,18 @@ void folder_item_destroy (FolderItem *item);
gint folder_item_compare (FolderItem *item_a,
FolderItem *item_b);
-void folder_set_ui_func (Folder *folder,
- FolderUIFunc func,
- gpointer data);
+void folder_set_ui_func (Folder *folder,
+ FolderUIFunc func,
+ gpointer data);
+void folder_set_ui_func2 (Folder *folder,
+ FolderUIFunc2 func,
+ gpointer data);
+FolderUIFunc2 folder_get_ui_func2 (Folder *folder);
+gboolean folder_call_ui_func2 (Folder *folder,
+ FolderItem *item,
+ guint count,
+ guint total);
+
void folder_set_name (Folder *folder,
const gchar *name);
void folder_tree_destroy (Folder *folder);
diff --git a/libsylph/mbox.c b/libsylph/mbox.c
index a88e555e..4a241aa1 100644
--- a/libsylph/mbox.c
+++ b/libsylph/mbox.c
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2010 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2012 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -71,7 +71,7 @@ gint proc_mbox_full(FolderItem *dest, const gchar *mbox,
gchar buf[BUFFSIZE], from_line[BUFFSIZE];
gchar *tmp_file;
gint new_msgs = 0;
- gint count = 0;
+ guint count = 0;
Folder *folder;
FilterRule *junk_rule = NULL;
GSList junk_fltlist = {NULL, NULL};
@@ -132,7 +132,11 @@ gint proc_mbox_full(FolderItem *dest, const gchar *mbox,
count++;
if (folder->ui_func)
- folder->ui_func(folder, dest, folder->ui_func_data ? dest->folder->ui_func_data : GINT_TO_POINTER(count));
+ folder->ui_func(folder, dest, folder->ui_func_data ? dest->folder->ui_func_data : GUINT_TO_POINTER(count));
+ if (folder_call_ui_func2(folder, dest, count, 0) == FALSE) {
+ debug_print("Import of mbox cancelled at %u\n", count);
+ break;
+ }
if ((tmp_fp = g_fopen(tmp_file, "wb")) == NULL) {
FILE_OP_ERROR(tmp_file, "fopen");
@@ -494,7 +498,7 @@ gint export_msgs_to_mbox(FolderItem *src, GSList *mlist, const gchar *mbox)
FILE *mbox_fp;
gchar buf[BUFFSIZE];
PrefsAccount *cur_ac;
- gint count = 0, length;
+ guint count = 0, length;
g_return_val_if_fail(src != NULL, -1);
g_return_val_if_fail(src->folder != NULL, -1);
@@ -518,7 +522,11 @@ gint export_msgs_to_mbox(FolderItem *src, GSList *mlist, const gchar *mbox)
count++;
if (src->folder->ui_func)
- src->folder->ui_func(src->folder, src, src->folder->ui_func_data ? src->folder->ui_func_data : GINT_TO_POINTER(count));
+ src->folder->ui_func(src->folder, src, src->folder->ui_func_data ? src->folder->ui_func_data : GUINT_TO_POINTER(count));
+ if (folder_call_ui_func2(src->folder, src, count, length) == FALSE) {
+ debug_print("Export to mbox cancelled at %u/%u\n", count, length);
+ break;
+ }
msg_fp = procmsg_open_message(msginfo);
if (!msg_fp)