diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-09-12 06:50:32 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-09-12 06:50:32 +0000 |
commit | 818d22882b42a3cd7c73f6bbceb39cb4066f3d74 (patch) | |
tree | 46da664fd436b65acbc34ab5d8da8409c14884f5 /libsylph/imap.c | |
parent | ca84d7d81afde38df3329445cc3803bf27fe855f (diff) |
imap.c: changed the message number limit on COPY.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@572 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph/imap.c')
-rw-r--r-- | libsylph/imap.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/libsylph/imap.c b/libsylph/imap.c index 7b647567..51cd765f 100644 --- a/libsylph/imap.c +++ b/libsylph/imap.c @@ -55,7 +55,7 @@ #define IMAPS_PORT 993 #endif -#define IMAP_COPY_LIMIT 500 +#define IMAP_COPY_LIMIT 200 #define IMAP_CMD_LIMIT 1000 #define QUOTE_IF_REQUIRED(out, str) \ @@ -361,6 +361,7 @@ static gchar *imap_utf8_to_modified_utf7 (const gchar *from); static GSList *imap_get_seq_set_from_msglist (GSList *msglist, gint limit); +static gint imap_seq_set_get_count (const gchar *seq_set); static void imap_seq_set_free (GSList *seq_list); static GHashTable *imap_get_uid_table (GArray *array); @@ -1264,6 +1265,7 @@ static gint imap_do_copy_msgs(Folder *folder, FolderItem *dest, GSList *msglist, GSList *seq_list, *cur; MsgInfo *msginfo; IMAPSession *session; + gint count = 0, total; gint ok = IMAP_SUCCESS; g_return_val_if_fail(folder != NULL, -1); @@ -1290,11 +1292,14 @@ static gint imap_do_copy_msgs(Folder *folder, FolderItem *dest, GSList *msglist, destdir = imap_get_real_path(IMAP_FOLDER(folder), dest->path); + total = g_slist_length(msglist); seq_list = imap_get_seq_set_from_msglist(msglist, IMAP_COPY_LIMIT); for (cur = seq_list; cur != NULL; cur = cur->next) { gchar *seq_set = (gchar *)cur->data; + count += imap_seq_set_get_count(seq_set); + if (remove_source) { status_print(_("Moving messages %s to %s ..."), seq_set, dest->path); @@ -1308,15 +1313,19 @@ static gint imap_do_copy_msgs(Folder *folder, FolderItem *dest, GSList *msglist, src->path, G_DIR_SEPARATOR, seq_set, dest->path); } + progress_show(count, total); ui_update(); ok = imap_cmd_copy(session, seq_set, destdir); if (ok != IMAP_SUCCESS) { imap_seq_set_free(seq_list); + progress_show(0, 0); return -1; } } + progress_show(0, 0); + dest->updated = TRUE; if (remove_source) { @@ -4134,6 +4143,37 @@ static GSList *imap_get_seq_set_from_msglist(GSList *msglist, gint limit) return ret_list; } +static gint imap_seq_set_get_count(const gchar *seq_set) +{ + gint count = 0; + guint first, last; + gchar *tmp, *p, *q; + + p = q = tmp = g_strdup(seq_set); + + while (*p) { + if (*p == ',') { + *p = '\0'; + if (sscanf(q, "%u:%u", &first, &last) == 2) + count += last - first + 1; + else if (sscanf(q, "%u", &first) == 1) + count++; + q = ++p; + } else + ++p; + } + if (q != p) { + if (sscanf(q, "%u:%u", &first, &last) == 2) + count += last - first + 1; + else if (sscanf(q, "%u", &first) == 1) + count++; + } + + g_free(tmp); + + return count; +} + static void imap_seq_set_free(GSList *seq_list) { slist_free_strings(seq_list); |