aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/local/camel-mbox-summary.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2001-02-08 09:42:53 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-02-08 09:42:53 +0800
commit49f8a687a41e635cd83807d33c74afe8e55fb3df (patch)
tree4162f19a2db18ff787386c7c97a98e5e8a5e7744 /camel/providers/local/camel-mbox-summary.c
parent1290da3f286a31745b1814610c16918c2e84e140 (diff)
downloadgsoc2013-evolution-49f8a687a41e635cd83807d33c74afe8e55fb3df.tar
gsoc2013-evolution-49f8a687a41e635cd83807d33c74afe8e55fb3df.tar.gz
gsoc2013-evolution-49f8a687a41e635cd83807d33c74afe8e55fb3df.tar.bz2
gsoc2013-evolution-49f8a687a41e635cd83807d33c74afe8e55fb3df.tar.lz
gsoc2013-evolution-49f8a687a41e635cd83807d33c74afe8e55fb3df.tar.xz
gsoc2013-evolution-49f8a687a41e635cd83807d33c74afe8e55fb3df.tar.zst
gsoc2013-evolution-49f8a687a41e635cd83807d33c74afe8e55fb3df.zip
Changed to push the operation into a status stack.
2001-02-07 Not Zed <NotZed@Ximian.com> * camel-operation.c (camel_operation_start): Changed to push the operation into a status stack. (camel_operation_progress): Changed to only accept % complete. (camel_operation_reset): Free status stack as well. * providers/pop3/camel-pop3-folder.c (pop3_get_message): Get the octect count from the return line, and pass it to get_additional_data(). (pop3_refresh_info): Added status stuff. * providers/pop3/camel-pop3-store.c (camel_pop3_command_get_additional_data): Added a total bytes expected argument for progress reporting & fixed callers. (camel_pop3_command_get_additional_data): Added progress reporting. * providers/local/camel-mbox-summary.c (mbox_summary_sync_full): (mbox_summary_sync_quick): (summary_rebuild): Added progress reporting stuff. svn path=/trunk/; revision=8095
Diffstat (limited to 'camel/providers/local/camel-mbox-summary.c')
-rw-r--r--camel/providers/local/camel-mbox-summary.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/camel/providers/local/camel-mbox-summary.c b/camel/providers/local/camel-mbox-summary.c
index ab42e10df7..b8219b4c78 100644
--- a/camel/providers/local/camel-mbox-summary.c
+++ b/camel/providers/local/camel-mbox-summary.c
@@ -21,7 +21,8 @@
*/
#include "camel-mbox-summary.h"
-#include <camel/camel-mime-message.h>
+#include "camel/camel-mime-message.h"
+#include "camel/camel-operation.h"
#include <sys/stat.h>
#include <sys/uio.h>
@@ -230,18 +231,26 @@ summary_rebuild(CamelMboxSummary *mbs, off_t offset, CamelException *ex)
CamelMimeParser *mp;
int fd;
int ok = 0;
+ struct stat st;
+ off_t size = 0;
/* FIXME: If there is a failure, it shouldn't clear the summary and restart,
it should try and merge the summary info's. This is a bit tricky. */
+ camel_operation_start(NULL, _("Summarising folder"));
+
fd = open(cls->folder_path, O_RDONLY);
if (fd == -1) {
printf("%s failed to open: %s", cls->folder_path, strerror(errno));
camel_exception_setv(ex, 1, _("Could not open folder: %s: summarising from position %ld: %s"),
cls->folder_path, offset, strerror(errno));
+ camel_operation_end(NULL);
return -1;
}
+ if (fstat(fd, &st) == 0)
+ size = st.st_size;
+
mp = camel_mime_parser_new();
camel_mime_parser_init_with_fd(mp, fd);
camel_mime_parser_scan_from(mp, TRUE);
@@ -262,12 +271,16 @@ summary_rebuild(CamelMboxSummary *mbs, off_t offset, CamelException *ex)
d(printf("mime parser state ran out? state is %d\n", camel_mime_parser_state(mp)));
camel_object_unref(CAMEL_OBJECT(mp));
/* end of file - no content? no error either */
+ camel_operation_end(NULL);
return 0;
}
}
while (camel_mime_parser_step(mp, NULL, NULL) == HSCAN_FROM) {
CamelMessageInfo *info;
+ int pc = (camel_mime_parser_tell(mp)+1) * 100/size;
+
+ camel_operation_progress(NULL, pc);
info = camel_folder_summary_add_from_parser(s, mp);
if (info == NULL) {
@@ -284,8 +297,6 @@ summary_rebuild(CamelMboxSummary *mbs, off_t offset, CamelException *ex)
/* update the file size/mtime in the summary */
if (ok != -1) {
- struct stat st;
-
if (stat(cls->folder_path, &st) == 0) {
camel_folder_summary_touch(s);
mbs->folder_size = st.st_size;
@@ -293,6 +304,8 @@ summary_rebuild(CamelMboxSummary *mbs, off_t offset, CamelException *ex)
}
}
+ camel_operation_end(NULL);
+
return ok;
}
@@ -477,11 +490,14 @@ mbox_summary_sync_full(CamelLocalSummary *cls, gboolean expunge, CamelFolderChan
d(printf("performing full summary/sync\n"));
+ camel_operation_start(NULL, _("Synchronising folder"));
+
fd = open(cls->folder_path, O_RDONLY);
if (fd == -1) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not open folder to summarise: %s: %s"),
cls->folder_path, strerror(errno));
+ camel_operation_end(NULL);
return -1;
}
@@ -502,6 +518,10 @@ mbox_summary_sync_full(CamelLocalSummary *cls, gboolean expunge, CamelFolderChan
count = camel_folder_summary_count(s);
for (i = 0; i < count; i++) {
+ int pc = (i+1)*100/count;
+
+ camel_operation_progress(NULL, pc);
+
info = (CamelMboxMessageInfo *)camel_folder_summary_index(s, i);
g_assert(info);
@@ -630,7 +650,8 @@ mbox_summary_sync_full(CamelLocalSummary *cls, gboolean expunge, CamelFolderChan
tmpname = NULL;
camel_object_unref((CamelObject *)mp);
-
+ camel_operation_end(NULL);
+
return 0;
error:
if (fd != -1)
@@ -648,6 +669,8 @@ mbox_summary_sync_full(CamelLocalSummary *cls, gboolean expunge, CamelFolderChan
if (info)
camel_folder_summary_info_free(s, (CamelMessageInfo *)info);
+ camel_operation_end(NULL);
+
return -1;
}
@@ -668,11 +691,15 @@ mbox_summary_sync_quick(CamelLocalSummary *cls, gboolean expunge, CamelFolderCha
d(printf("Performing quick summary sync\n"));
+ camel_operation_start(NULL, _("Synchronising folder"));
+
fd = open(cls->folder_path, O_RDWR);
if (fd == -1) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not open folder to summarise: %s: %s"),
cls->folder_path, strerror(errno));
+
+ camel_operation_end(NULL);
return -1;
}
@@ -684,6 +711,9 @@ mbox_summary_sync_quick(CamelLocalSummary *cls, gboolean expunge, CamelFolderCha
count = camel_folder_summary_count(s);
for (i = 0; i < count; i++) {
int xevoffset;
+ int pc = (i+1)*100/count;
+
+ camel_operation_progress(NULL, pc);
info = (CamelMboxMessageInfo *)camel_folder_summary_index(s, i);
@@ -769,6 +799,8 @@ mbox_summary_sync_quick(CamelLocalSummary *cls, gboolean expunge, CamelFolderCha
}
camel_object_unref((CamelObject *)mp);
+
+ camel_operation_end(NULL);
return 0;
error:
@@ -779,6 +811,8 @@ mbox_summary_sync_quick(CamelLocalSummary *cls, gboolean expunge, CamelFolderCha
if (info)
camel_folder_summary_info_free(s, (CamelMessageInfo *)info);
+ camel_operation_end(NULL);
+
return -1;
}