diff options
author | Not Zed <NotZed@Ximian.com> | 2001-01-19 13:19:13 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2001-01-19 13:19:13 +0800 |
commit | bfd90f9a1f8d1054a735879df819aa2a9628acf9 (patch) | |
tree | 0aa9d158d1ae822607c0b85d555aa4193dea39c8 | |
parent | bb6fe874b049c467e6e2627a8f8dca1e2ce1bcb2 (diff) | |
download | gsoc2013-evolution-bfd90f9a1f8d1054a735879df819aa2a9628acf9.tar gsoc2013-evolution-bfd90f9a1f8d1054a735879df819aa2a9628acf9.tar.gz gsoc2013-evolution-bfd90f9a1f8d1054a735879df819aa2a9628acf9.tar.bz2 gsoc2013-evolution-bfd90f9a1f8d1054a735879df819aa2a9628acf9.tar.lz gsoc2013-evolution-bfd90f9a1f8d1054a735879df819aa2a9628acf9.tar.xz gsoc2013-evolution-bfd90f9a1f8d1054a735879df819aa2a9628acf9.tar.zst gsoc2013-evolution-bfd90f9a1f8d1054a735879df819aa2a9628acf9.zip |
Add a percentage complete indicator to the status thing.
2001-01-19 Not Zed <NotZed@Ximian.com>
* camel-filter-driver.c (report_status): Add a percentage complete
indicator to the status thing.
(camel_filter_driver_filter_mbox): Add percentage complete to
reporting.
(camel_filter_driver_filter_folder): Same.
svn path=/trunk/; revision=7635
-rw-r--r-- | camel/ChangeLog | 8 | ||||
-rw-r--r-- | camel/camel-filter-driver.c | 33 | ||||
-rw-r--r-- | camel/camel-filter-driver.h | 10 |
3 files changed, 33 insertions, 18 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 4c4e670168..06b0d553cd 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,11 @@ +2001-01-19 Not Zed <NotZed@Ximian.com> + + * camel-filter-driver.c (report_status): Add a percentage complete + indicator to the status thing. + (camel_filter_driver_filter_mbox): Add percentage complete to + reporting. + (camel_filter_driver_filter_folder): Same. + 2001-01-18 Dan Winship <danw@ximian.com> * camel-store.c (camel_folder_info_build): More tweaking... skip diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c index 42aa442c60..2de96a14ea 100644 --- a/camel/camel-filter-driver.c +++ b/camel/camel-filter-driver.c @@ -62,11 +62,11 @@ struct _CamelFilterDriverPrivate { CamelFolder *defaultfolder; /* defualt folder */ - FDStatusFunc *statusfunc; /* status callback */ + CamelFilterStatusFunc *statusfunc; /* status callback */ void *statusdata; /* status callback data */ /* for callback */ - FilterGetFolderFunc get_folder; + CamelFilterGetFolderFunc get_folder; void *data; /* run-time data */ @@ -227,7 +227,7 @@ camel_filter_driver_finalise (CamelObject *obj) * Return value: A new CamelFilterDriver widget. **/ CamelFilterDriver * -camel_filter_driver_new (FilterGetFolderFunc get_folder, void *data) +camel_filter_driver_new (CamelFilterGetFolderFunc get_folder, void *data) { CamelFilterDriver *new; struct _CamelFilterDriverPrivate *p; @@ -250,7 +250,7 @@ camel_filter_driver_set_logfile (CamelFilterDriver *d, FILE *logfile) } void -camel_filter_driver_set_status_func (CamelFilterDriver *d, FDStatusFunc *func, void *data) +camel_filter_driver_set_status_func (CamelFilterDriver *d, CamelFilterStatusFunc *func, void *data) { struct _CamelFilterDriverPrivate *p = _PRIVATE (d); @@ -286,7 +286,7 @@ camel_filter_driver_add_rule(CamelFilterDriver *d, const char *name, const char } static void -report_status (CamelFilterDriver *driver, enum filter_status_t status, const char *desc, ...) +report_status (CamelFilterDriver *driver, enum camel_filter_status_t status, int pc, const char *desc, ...) { /* call user-defined status report function */ struct _CamelFilterDriverPrivate *p = _PRIVATE (driver); @@ -296,7 +296,7 @@ report_status (CamelFilterDriver *driver, enum filter_status_t status, const cha if (p->statusfunc) { va_start (ap, desc); str = g_strdup_vprintf (desc, ap); - p->statusfunc (driver, status, str, p->statusdata); + p->statusfunc (driver, status, pc, str, p->statusdata); g_free (str); } } @@ -610,11 +610,11 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const char *mbox, co if (st.st_size > 0) pc = (int)(100.0 * ((double)camel_mime_parser_tell (mp) / (double)st.st_size)); - report_status (driver, FILTER_STATUS_START, "Getting message %d (%d%% of file)", i, pc); + report_status (driver, FILTER_STATUS_START, pc, "Getting message %d (%d%% of file)", i, pc); msg = camel_mime_message_new (); if (camel_mime_part_construct_from_parser (CAMEL_MIME_PART (msg), mp) == -1) { - report_status (driver, FILTER_STATUS_END, "Failed message %d", i); + report_status (driver, FILTER_STATUS_END, 100, "Failed message %d", i); camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, "Cannot open message"); camel_object_unref (CAMEL_OBJECT (msg)); goto fail; @@ -623,16 +623,18 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const char *mbox, co camel_filter_driver_filter_message (driver, msg, NULL, source_url, source, ex); camel_object_unref (CAMEL_OBJECT (msg)); if (camel_exception_is_set (ex)) { - report_status (driver, FILTER_STATUS_END, "Failed message %d", i); + report_status (driver, FILTER_STATUS_END, 100, "Failed message %d", i); goto fail; } - report_status (driver, FILTER_STATUS_END, "Finished message %d", i); + report_status (driver, FILTER_STATUS_END, pc, "Finished message %d", i); i++; /* skip over the FROM_END state */ camel_mime_parser_step (mp, 0, 0); } + + report_status (driver, FILTER_STATUS_END, 100, "Complete"); if (p->defaultfolder) camel_folder_sync (p->defaultfolder, FALSE, ex); @@ -667,11 +669,13 @@ camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folde } for (i = 0; i < uids->len; i++) { - report_status (driver, FILTER_STATUS_START, "Getting message %d of %d", i+1, uids->len); + int pc = (100 * i)/uids->len; + + report_status (driver, FILTER_STATUS_START, pc, "Getting message %d of %d", i+1, uids->len); message = camel_folder_get_message (folder, uids->pdata[i], ex); if (camel_exception_is_set (ex)) { - report_status (driver, FILTER_STATUS_END, "Failed at message %d of %d", i+1, uids->len); + report_status (driver, FILTER_STATUS_END, 100, "Failed at message %d of %d", i+1, uids->len); break; } @@ -686,7 +690,7 @@ camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folde camel_folder_free_message_info (folder, info); if (camel_exception_is_set (ex)) { - report_status (driver, FILTER_STATUS_END, "Failed at message %d of %d", i+1, uids->len); + report_status (driver, FILTER_STATUS_END, 100, "Failed at message %d of %d", i+1, uids->len); break; } @@ -696,6 +700,9 @@ camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folde camel_object_unref (CAMEL_OBJECT (message)); } + + if (i == uids->len) + report_status (driver, FILTER_STATUS_END, 100, "Complete"); if (freeuids) camel_folder_free_uids (folder, uids); diff --git a/camel/camel-filter-driver.h b/camel/camel-filter-driver.h index 0d3df60fe0..aba2b587e7 100644 --- a/camel/camel-filter-driver.h +++ b/camel/camel-filter-driver.h @@ -47,7 +47,7 @@ struct _CamelFilterDriverClass { /* FIXME: this maybe should change... */ /* type of status for a status report */ -enum filter_status_t { +enum camel_filter_status_t { FILTER_STATUS_NONE, FILTER_STATUS_START, /* start of new message processed */ FILTER_STATUS_ACTION, /* an action performed */ @@ -55,16 +55,16 @@ enum filter_status_t { FILTER_STATUS_END, /* end of message */ }; -typedef CamelFolder * (*FilterGetFolderFunc) (CamelFilterDriver *, const char *uri, void *data); +typedef CamelFolder * (*CamelFilterGetFolderFunc) (CamelFilterDriver *, const char *uri, void *data); /* report status */ -typedef void (FDStatusFunc)(CamelFilterDriver *driver, enum filter_status_t status, const char *desc, void *data); +typedef void (CamelFilterStatusFunc)(CamelFilterDriver *driver, enum camel_filter_status_t status, int pc, const char *desc, void *data); guint camel_filter_driver_get_type (void); -CamelFilterDriver *camel_filter_driver_new (FilterGetFolderFunc fetcher, void *data); +CamelFilterDriver *camel_filter_driver_new (CamelFilterGetFolderFunc fetcher, void *data); /* modifiers */ void camel_filter_driver_set_logfile (CamelFilterDriver *d, FILE *logfile); -void camel_filter_driver_set_status_func (CamelFilterDriver *d, FDStatusFunc *func, void *data); +void camel_filter_driver_set_status_func (CamelFilterDriver *d, CamelFilterStatusFunc *func, void *data); void camel_filter_driver_set_default_folder (CamelFilterDriver *d, CamelFolder *def); void camel_filter_driver_add_rule (CamelFilterDriver *d, const char *name, const char *match, const char *action); |