aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog22
-rw-r--r--mail/mail-ops.c61
-rw-r--r--mail/mail-threads.c52
3 files changed, 111 insertions, 24 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index cb8264e7b3..25a244e841 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,25 @@
+2000-10-08 Miguel de Icaza <miguel@helixcode.com>
+
+ * mail-threads.c (pipe_write): Repeates writes on EINTRS.
+ (pipe_read): Repeats reads on EINTRS.
+ (mail_operation_queue): Use pipe_write
+ (mail_op_set_percentage): ditto.
+ (mail_op_hide_progressbar): ditto.
+ (mail_op_show_progressbar): ditto.
+ (mail_op_set_message): ditto.
+ (mail_op_get_password): ditto.
+ (mail_op_error): ditto.
+ (mail_op_forward_event): ditto.
+ (mail_operations_terminate): ditto.
+ (dispatch): use pipe_read.
+ (dispatch): use pipe_write
+ (dispatch): ditto.
+
+ * mail-ops.c (mail_incorporate_messages): Only show message being
+ incorporated every 2 seconds, to avoid a bunch of CORBA round trips.
+ (do_transfer_messages): ditto.
+ (do_forward_messages): ditto.
+
2000-10-07 Miguel de Icaza <miguel@helixcode.com>
* mail-ops.c (do_fetch_mail): Move the functionality to
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 9bca75bb13..e4d7314ea9 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -111,7 +111,8 @@ mail_incorporate_messages (CamelFolder *folder,
char *url, *p, *filename;
FILE *logfile;
int i;
-
+ time_t last_update = 0;
+
fc = mail_load_evolution_rule_context ();
filter = filter_driver_new (fc, mail_tool_filter_get_folder_func, 0);
@@ -159,8 +160,17 @@ mail_incorporate_messages (CamelFolder *folder,
CamelMimeMessage *message;
CamelMessageInfo *info;
gboolean free_info;
-
- mail_op_set_message ("Retrieving message %d of %d", i + 1, uids->len);
+ gboolean last_message = (i+1 == uids->len);
+ time_t now;
+
+ /*
+ * Update the time display ever 2 seconds
+ */
+ time (&now);
+ if (last_message || ((now - last_update) > 2)){
+ mail_op_set_message ("Retrieving message %d of %d", i + 1, uids->len);
+ last_update = now;
+ }
message = camel_folder_get_message (folder, uids->pdata[i], ex);
if (camel_exception_is_set (ex))
@@ -964,6 +974,7 @@ do_transfer_messages (gpointer in_data, gpointer op_data, CamelException *ex)
transfer_messages_input_t *input = (transfer_messages_input_t *) in_data;
CamelFolder *dest;
gint i;
+ time_t last_update = 0;
gchar *desc;
void (*func) (CamelFolder *, const char *,
CamelFolder *,
@@ -986,9 +997,19 @@ do_transfer_messages (gpointer in_data, gpointer op_data, CamelException *ex)
camel_folder_freeze (dest);
for (i = 0; i < input->uids->len; i++) {
- mail_op_set_message (_("%s message %d of %d (uid \"%s\")"), desc,
- i + 1, input->uids->len, (char *) input->uids->pdata[i]);
+ const gboolean last_message = (i+1 == input->uids->len);
+ time_t now;
+ /*
+ * Update the time display ever 2 seconds
+ */
+ time (&now);
+ if (last_message || ((now - last_update) > 2)){
+ mail_op_set_message (_("%s message %d of %d (uid \"%s\")"), desc,
+ i + 1, input->uids->len, (char *) input->uids->pdata[i]);
+ last_update = now;
+ }
+
(func) (input->source,
input->uids->pdata[i], dest,
ex);
@@ -1083,6 +1104,7 @@ do_flag_messages (gpointer in_data, gpointer op_data, CamelException *ex)
{
flag_messages_input_t *input = (flag_messages_input_t *) in_data;
gint i;
+ time_t last_update = 0;
mail_tool_camel_lock_up ();
camel_folder_freeze (input->source);
@@ -1091,8 +1113,15 @@ do_flag_messages (gpointer in_data, gpointer op_data, CamelException *ex)
mail_tool_camel_lock_down ();
for (i = 0; i < input->uids->len; i++) {
- mail_op_set_message ("Marking message %d of %d", i + 1,
- input->uids->len);
+ const gboolean last_message = (i+1 == input->uids->len);
+ time_t now;
+
+ time (&now);
+ if (last_message || ((now - last_update) > 2)){
+ mail_op_set_message ("Marking message %d of %d", i + 1,
+ input->uids->len);
+ last_update = now;
+ }
if (input->invert) {
const CamelMessageInfo *info;
@@ -1480,7 +1509,7 @@ do_forward_messages (gpointer in_data, gpointer op_data, CamelException *ex)
{
forward_messages_input_t *input = (forward_messages_input_t *) in_data;
forward_messages_data_t *data = (forward_messages_data_t *) op_data;
-
+ time_t last_update = 0;
CamelMimeMessage *message;
CamelMimePart *part;
int i;
@@ -1489,8 +1518,20 @@ do_forward_messages (gpointer in_data, gpointer op_data, CamelException *ex)
mail_tool_camel_lock_up ();
for (i = 0; i < input->uids->len; i++) {
- mail_op_set_message (_("Retrieving message number %d of %d (uid \"%s\")"),
- i + 1, input->uids->len, (char *) input->uids->pdata[i]);
+ const int last_message = (i+1 == input->uids->len);
+ time_t now;
+
+ /*
+ * Update the time display ever 2 seconds
+ */
+ time (&now);
+ if (last_message || ((now - last_update) > 2)){
+ mail_op_set_message (_("Retrieving message number %d of %d (uid \"%s\")"),
+ i + 1, input->uids->len, (char *) input->uids->pdata[i]);
+ last_update = now;
+ }
+
+
message =
camel_folder_get_message (input->source,
input->uids->pdata[i], ex);
diff --git a/mail/mail-threads.c b/mail/mail-threads.c
index d886a8a981..b4a2bd48d6 100644
--- a/mail/mail-threads.c
+++ b/mail/mail-threads.c
@@ -88,8 +88,7 @@ typedef struct com_msg_s
CamelObject *event_obj;
gpointer event_event_data;
gpointer event_user_data;
-}
-com_msg_t;
+} com_msg_t;
/**
* Stuff needed for blocking
@@ -234,6 +233,31 @@ f (void)
}
#endif
+static int
+pipe_write (int fd, const void *buf, size_t count)
+{
+ size_t res;
+
+ do {
+ res = write (fd, buf, count);
+ }
+ while (res == -1 && errno == EINTR);
+
+ return res;
+}
+
+static size_t
+pipe_read (int fd, void *buf, size_t count)
+{
+ size_t res;
+
+ do {
+ res = read (fd, buf, count);
+ } while (res == -1 && errno == EINTR);
+
+ return res;
+}
+
/**
* mail_operation_queue:
* @spec: describes the operation to be performed
@@ -295,7 +319,7 @@ mail_operation_queue (const mail_operation_spec * spec, gpointer input,
check_dispatcher ();
} /* else add self to queue */
- write (DISPATCH_WRITER, clur, sizeof (closure_t));
+ pipe_write (DISPATCH_WRITER, clur, sizeof (closure_t));
/* dispatch allocates a separate buffer
* to hold the closure; it's in the pipe and
* can safely be freed
@@ -321,7 +345,7 @@ mail_op_set_percentage (gfloat percentage)
msg.type = PERCENTAGE;
msg.percentage = percentage;
- write (MAIN_WRITER, &msg, sizeof (msg));
+ pipe_write (MAIN_WRITER, &msg, sizeof (msg));
}
/**
@@ -337,7 +361,7 @@ mail_op_hide_progressbar (void)
com_msg_t msg;
msg.type = HIDE_PBAR;
- write (MAIN_WRITER, &msg, sizeof (msg));
+ pipe_write (MAIN_WRITER, &msg, sizeof (msg));
}
/**
@@ -353,7 +377,7 @@ mail_op_show_progressbar (void)
com_msg_t msg;
msg.type = SHOW_PBAR;
- write (MAIN_WRITER, &msg, sizeof (msg));
+ pipe_write (MAIN_WRITER, &msg, sizeof (msg));
}
#endif
@@ -379,7 +403,7 @@ mail_op_set_message (gchar * fmt, ...)
msg.message = g_strdup_vprintf (fmt, val);
va_end (val);
- write (MAIN_WRITER, &msg, sizeof (msg));
+ pipe_write (MAIN_WRITER, &msg, sizeof (msg));
}
/**
@@ -409,7 +433,7 @@ mail_op_get_password (gchar * prompt, gboolean secret, gchar ** dest)
(*dest) = NULL;
block_prepare (&modal_block);
- write (MAIN_WRITER, &msg, sizeof (msg));
+ pipe_write (MAIN_WRITER, &msg, sizeof (msg));
block_wait (&modal_block);
return result;
@@ -436,7 +460,7 @@ mail_op_error (gchar * fmt, ...)
va_end (val);
block_prepare (&modal_block);
- write (MAIN_WRITER, &msg, sizeof (msg));
+ pipe_write (MAIN_WRITER, &msg, sizeof (msg));
block_wait (&modal_block);
}
@@ -457,7 +481,7 @@ mail_op_forward_event (CamelObjectEventHookFunc func, CamelObject *o,
msg.event_obj = o;
msg.event_event_data = event_data;
msg.event_user_data = user_data;
- write (MAIN_WRITER, &msg, sizeof (msg));
+ pipe_write (MAIN_WRITER, &msg, sizeof (msg));
}
/**
* mail_operation_wait_for_finish:
@@ -504,7 +528,7 @@ mail_operations_terminate (void)
memset (&clur, 0, sizeof (closure_t));
clur.spec = NULL;
- write (DISPATCH_WRITER, &clur, sizeof (closure_t));
+ pipe_write (DISPATCH_WRITER, &clur, sizeof (closure_t));
close (DISPATCH_WRITER);
close (MAIN_READER);
@@ -595,7 +619,7 @@ dispatch (void *unused)
while (1) {
clur = g_new (closure_t, 1);
- len = read (DISPATCH_READER, clur, sizeof (closure_t));
+ len = pipe_read (DISPATCH_READER, clur, sizeof (closure_t));
if (len <= 0)
break;
@@ -610,7 +634,7 @@ dispatch (void *unused)
msg.type = STARTING;
msg.message = g_strdup (clur->gerund);
- write (MAIN_WRITER, &msg, sizeof (msg));
+ pipe_write (MAIN_WRITER, &msg, sizeof (msg));
(clur->spec->callback) (clur->in_data, clur->op_data, clur->ex);
@@ -632,7 +656,7 @@ dispatch (void *unused)
/* Wait for the cleanup to finish before starting our next op */
block_prepare (&finish_block);
- write (MAIN_WRITER, &msg, sizeof (msg));
+ pipe_write (MAIN_WRITER, &msg, sizeof (msg));
block_wait (&finish_block);
}