From 818d22882b42a3cd7c73f6bbceb39cb4066f3d74 Mon Sep 17 00:00:00 2001 From: hiro Date: Mon, 12 Sep 2005 06:50:32 +0000 Subject: imap.c: changed the message number limit on COPY. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@572 ee746299-78ed-0310-b773-934348b2243d --- ChangeLog | 5 +++++ ChangeLog.ja | 5 +++++ libsylph/imap.c | 42 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3e0b16bf..5929373f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-09-12 + + * libsylph/imap.c: changed the message number limit on COPY. + imap_do_copy_msgs(): update progress bar on copy. + 2005-09-09 * libsylph/imap.c: added missing translation string. diff --git a/ChangeLog.ja b/ChangeLog.ja index edd70174..11f1c3f3 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,3 +1,8 @@ +2005-09-12 + + * libsylph/imap.c: COPY のメッセージ数制限を変更。 + imap_do_copy_msgs(): コピー時にプログレスバーを更新。 + 2005-09-09 * libsylph/imap.c: 抜けていた翻訳文字列を追加。 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); -- cgit v1.2.3