aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/pop3
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/pop3
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/pop3')
-rw-r--r--camel/providers/pop3/camel-pop3-folder.c31
-rw-r--r--camel/providers/pop3/camel-pop3-store.c15
-rw-r--r--camel/providers/pop3/camel-pop3-store.h3
3 files changed, 39 insertions, 10 deletions
diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c
index cf55a95661..810faed846 100644
--- a/camel/providers/pop3/camel-pop3-folder.c
+++ b/camel/providers/pop3/camel-pop3-folder.c
@@ -29,6 +29,7 @@
#include "camel-stream-mem.h"
#include "camel-stream-filter.h"
#include "camel-mime-message.h"
+#include "camel-operation.h"
#include <stdlib.h>
#include <string.h>
@@ -141,9 +142,13 @@ pop3_refresh_info (CamelFolder *folder, CamelException *ex)
CamelPop3Folder *pop3_folder = (CamelPop3Folder *) folder;
CamelPop3Store *pop3_store = CAMEL_POP3_STORE (folder->parent_store);
+ camel_operation_start(NULL, _("Retrieving POP summary"));
+
status = camel_pop3_command (pop3_store, &data, ex, "STAT");
- if (status != CAMEL_POP3_OK)
+ if (status != CAMEL_POP3_OK) {
+ camel_operation_end(NULL);
return;
+ }
count = atoi (data);
g_free (data);
@@ -155,6 +160,7 @@ pop3_refresh_info (CamelFolder *folder, CamelException *ex)
pop3_store->supports_uidl = FALSE;
break;
case CAMEL_POP3_FAIL:
+ camel_operation_end(NULL);
return;
}
}
@@ -167,8 +173,10 @@ pop3_refresh_info (CamelFolder *folder, CamelException *ex)
for (i = 0; i < count; i++)
uids->pdata[i] = g_strdup_printf ("%d", i + 1);
+ camel_operation_end(NULL);
} else {
- data = camel_pop3_command_get_additional_data (pop3_store, ex);
+ data = camel_pop3_command_get_additional_data (pop3_store, 0, ex);
+ camel_operation_end(NULL);
if (camel_exception_is_set (ex))
return;
@@ -263,7 +271,7 @@ uid_to_number (CamelPop3Folder *pop3_folder, const char *uid)
static CamelMimeMessage *
pop3_get_message (CamelFolder *folder, const char *uid, CamelException *ex)
{
- int status, num;
+ int status, num, total;
char *result, *body;
CamelStream *msgstream;
CamelMimeMessage *msg;
@@ -275,19 +283,28 @@ pop3_get_message (CamelFolder *folder, const char *uid, CamelException *ex)
return NULL;
}
+ camel_operation_start(NULL, _("Retrieving POP message %d"), num);
+
status = camel_pop3_command (CAMEL_POP3_STORE (folder->parent_store),
&result, ex, "RETR %d", num);
- if (status != CAMEL_POP3_OK)
+ if (status != CAMEL_POP3_OK) {
+ camel_operation_end(NULL);
return NULL;
- g_free (result);
+ }
+
+ /* this should be "nnn octets" ? */
+ if (sscanf(result, "%d", &total) != 1)
+ total = 0;
- body = camel_pop3_command_get_additional_data (CAMEL_POP3_STORE (folder->parent_store), ex);
+ g_free (result);
+ body = camel_pop3_command_get_additional_data (CAMEL_POP3_STORE (folder->parent_store), total, ex);
if (!body) {
CamelService *service = CAMEL_SERVICE (folder->parent_store);
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Could not retrieve message from POP "
"server %s: %s"), service->url->host,
camel_exception_get_description (ex));
+ camel_operation_end(NULL);
return NULL;
}
@@ -300,6 +317,8 @@ pop3_get_message (CamelFolder *folder, const char *uid, CamelException *ex)
camel_object_unref (CAMEL_OBJECT (msgstream));
+ camel_operation_end(NULL);
+
return msg;
}
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index aefabebfa4..f0338a8584 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -35,6 +35,8 @@
#include <unistd.h>
#include <errno.h>
+#include "camel-operation.h"
+
#ifdef HAVE_KRB4
/* Specified nowhere */
#define KPOP_PORT 1109
@@ -250,7 +252,7 @@ connect_to_server (CamelService *service, /*gboolean real, */CamelException *ex)
char *p;
int len;
- buf = camel_pop3_command_get_additional_data (store, ex);
+ buf = camel_pop3_command_get_additional_data (store, 0, ex);
if (camel_exception_is_set (ex))
return FALSE;
@@ -632,6 +634,7 @@ pop3_get_response (CamelPop3Store *store, char **ret, CamelException *ex)
* camel_pop3_command_get_additional_data: get "additional data" from
* a POP3 command.
* @store: the POP3 store
+ * @total: Total bytes expected (for progress reporting), use 0 for 'unknown'.
*
* This command gets the additional data returned by "multi-line" POP
* commands, such as LIST, RETR, TOP, and UIDL. This command _must_
@@ -643,11 +646,12 @@ pop3_get_response (CamelPop3Store *store, char **ret, CamelException *ex)
* Return value: the data, which the caller must free.
**/
char *
-camel_pop3_command_get_additional_data (CamelPop3Store *store, CamelException *ex)
+camel_pop3_command_get_additional_data (CamelPop3Store *store, int total, CamelException *ex)
{
GPtrArray *data;
char *buf, *p;
int i, len = 0, status = CAMEL_POP3_OK;
+ int pc = 0;
data = g_ptr_array_new ();
while (1) {
@@ -661,6 +665,13 @@ camel_pop3_command_get_additional_data (CamelPop3Store *store, CamelException *e
g_ptr_array_add (data, buf);
len += strlen (buf) + 1;
+
+ if (total) {
+ pc = (len+1) * 100 / total;
+ camel_operation_progress(NULL, pc);
+ } else {
+ camel_operation_progress_count(NULL, len);
+ }
}
if (buf)
diff --git a/camel/providers/pop3/camel-pop3-store.h b/camel/providers/pop3/camel-pop3-store.h
index 65bf1cbdba..078a317a14 100644
--- a/camel/providers/pop3/camel-pop3-store.h
+++ b/camel/providers/pop3/camel-pop3-store.h
@@ -65,8 +65,7 @@ void camel_pop3_store_expunge (CamelPop3Store *store, CamelException *ex);
/* support functions */
enum { CAMEL_POP3_OK, CAMEL_POP3_ERR, CAMEL_POP3_FAIL };
int camel_pop3_command (CamelPop3Store *store, char **ret, CamelException *ex, char *fmt, ...);
-char *camel_pop3_command_get_additional_data (CamelPop3Store *store,
- CamelException *ex);
+char *camel_pop3_command_get_additional_data (CamelPop3Store *store, int total, CamelException *ex);
/* Standard Camel function */
CamelType camel_pop3_store_get_type (void);