aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2001-02-08 09:45:37 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-02-08 09:45:37 +0800
commit4459154549f367cb1fa8a89b06e89d8f99abb4e3 (patch)
treec6d10940b9fbe3210b216c94305d8f160906d2f3 /mail
parent49f8a687a41e635cd83807d33c74afe8e55fb3df (diff)
downloadgsoc2013-evolution-4459154549f367cb1fa8a89b06e89d8f99abb4e3.tar.gz
gsoc2013-evolution-4459154549f367cb1fa8a89b06e89d8f99abb4e3.tar.zst
gsoc2013-evolution-4459154549f367cb1fa8a89b06e89d8f99abb4e3.zip
Handle internal camel status return. (receive_done): Remove active
2001-02-07 Not Zed <NotZed@Ximian.com> * mail-send-recv.c (operation_status): Handle internal camel status return. (receive_done): Remove active download when done. (mail_receive_uri): Initiate download of a single source, with no gui. (build_dialogue): Mark any new items as real active downloads. (do_show_status): Make the progress bar optional. 2001-02-06 Not Zed <NotZed@Ximian.com> * mail-send-recv.c: camel_cancel->camel_operation. * mail-ops.old.c: camel_cancel->camel_operation. * mail-ops.c: camel_cancel->camel_operation. * mail-mt.c: camel_cancel->camel_operation. * mail-callbacks.c (stop_threads): camel_cancel->camel_operation. * mail-mt.h: CamelCancel->CamelOperation. svn path=/trunk/; revision=8096
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog22
-rw-r--r--mail/mail-callbacks.c2
-rw-r--r--mail/mail-mt.c7
-rw-r--r--mail/mail-mt.h4
-rw-r--r--mail/mail-ops.c55
-rw-r--r--mail/mail-ops.h8
-rw-r--r--mail/mail-send-recv.c146
7 files changed, 186 insertions, 58 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 75ebf60d6b..ffc1d3715c 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,25 @@
+2001-02-07 Not Zed <NotZed@Ximian.com>
+
+ * mail-send-recv.c (operation_status): Handle internal camel status return.
+ (receive_done): Remove active download when done.
+ (mail_receive_uri): Initiate download of a single source, with no gui.
+ (build_dialogue): Mark any new items as real active downloads.
+ (do_show_status): Make the progress bar optional.
+
+2001-02-06 Not Zed <NotZed@Ximian.com>
+
+ * mail-send-recv.c: camel_cancel->camel_operation.
+
+ * mail-ops.old.c: camel_cancel->camel_operation.
+
+ * mail-ops.c: camel_cancel->camel_operation.
+
+ * mail-mt.c: camel_cancel->camel_operation.
+
+ * mail-callbacks.c (stop_threads): camel_cancel->camel_operation.
+
+ * mail-mt.h: CamelCancel->CamelOperation.
+
2001-02-07 Jeffrey Stedfast <fejj@ximian.com>
* mail-mt.c (set_view_data): Check current_message for NULL - this
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index e40cd3b82c..7f015b199f 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -1138,6 +1138,6 @@ edit_message (BonoboUIComponent *uih, void *user_data, const char *path)
void
stop_threads(BonoboUIComponent *uih, void *user_data, const char *path)
{
- camel_cancel_cancel(NULL);
+ camel_operation_cancel(NULL);
}
diff --git a/mail/mail-mt.c b/mail/mail-mt.c
index bec769b415..ec2529448d 100644
--- a/mail/mail-mt.c
+++ b/mail/mail-mt.c
@@ -3,6 +3,7 @@
#include <unistd.h>
#include "e-util/e-msgport.h"
+#include "camel/camel-operation.h"
#include <glib.h>
#include <pthread.h>
@@ -40,7 +41,7 @@ void *mail_msg_new(mail_msg_op_t *ops, EMsgPort *reply_port, size_t size)
msg->ops = ops;
msg->seq = mail_msg_seq++;
msg->msg.reply_port = reply_port;
- msg->cancel = camel_cancel_new();
+ msg->cancel = camel_operation_new(NULL, NULL); /* FIXME: report status somehow? */
camel_exception_init(&msg->ex);
g_hash_table_insert(mail_msg_active, (void *)msg->seq, msg);
@@ -64,7 +65,7 @@ void mail_msg_free(void *msg)
MAIL_MT_UNLOCK(mail_msg_lock);
- camel_cancel_unref(m->cancel);
+ camel_operation_unref(m->cancel);
camel_exception_clear(&m->ex);
g_free(m);
}
@@ -101,7 +102,7 @@ void mail_msg_cancel(unsigned int msgid)
m = g_hash_table_lookup(mail_msg_active, (void *)msgid);
if (m)
- camel_cancel_cancel(m->cancel);
+ camel_operation_cancel(m->cancel);
MAIL_MT_UNLOCK(mail_msg_lock);
}
diff --git a/mail/mail-mt.h b/mail/mail-mt.h
index 8642a3ebaa..935b4b15b8 100644
--- a/mail/mail-mt.h
+++ b/mail/mail-mt.h
@@ -27,13 +27,13 @@
#include "camel/camel-exception.h"
#include "e-util/e-msgport.h"
#include "camel/camel-object.h"
-#include "camel/camel-session.h"
+#include "camel/camel-operation.h"
typedef struct _mail_msg {
EMsg msg; /* parent type */
struct _mail_msg_op *ops; /* operation functions */
unsigned int seq; /* seq number for synchronisation */
- CamelCancel *cancel; /* a cancellation handle */
+ CamelOperation *cancel; /* a cancellation/status handle */
CamelException ex; /* an initialised camel exception, upto the caller to use this */
} mail_msg_t;
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 271315a2aa..3b81d62d6a 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -30,6 +30,7 @@
#include <ctype.h>
#include <errno.h>
#include <camel/camel-mime-filter-from.h>
+#include <camel/camel-operation.h>
#include "mail.h"
#include "mail-threads.h"
#include "mail-tools.h"
@@ -119,7 +120,7 @@ struct _filter_mail_msg {
CamelFolder *source_folder; /* where they come from */
GPtrArray *source_uids; /* uids to copy, or NULL == copy all */
- CamelCancel *cancel;
+ CamelOperation *cancel;
CamelFilterDriver *driver;
int delete; /* delete messages after filtering them? */
CamelFolder *destination; /* default destination for any messages, NULL for none */
@@ -129,7 +130,7 @@ struct _filter_mail_msg {
struct _fetch_mail_msg {
struct _filter_mail_msg fmsg;
- CamelCancel *cancel; /* we have our own cancellation struct, the other should be empty */
+ CamelOperation *cancel; /* we have our own cancellation struct, the other should be empty */
int keep; /* keep on server? */
char *source_uri;
@@ -148,13 +149,13 @@ filter_folder_filter(struct _mail_msg *mm)
GPtrArray *uids, *folder_uids = NULL;
if (m->cancel)
- camel_cancel_register(m->cancel);
+ camel_operation_register(m->cancel);
folder = m->source_folder;
if (folder == NULL || camel_folder_get_message_count (folder) == 0) {
if (m->cancel)
- camel_cancel_unregister(m->cancel);
+ camel_operation_unregister(m->cancel);
return;
}
@@ -183,7 +184,7 @@ filter_folder_filter(struct _mail_msg *mm)
camel_folder_thaw(m->destination);
if (m->cancel)
- camel_cancel_unregister(m->cancel);
+ camel_operation_unregister(m->cancel);
}
static void
@@ -205,7 +206,7 @@ filter_folder_free(struct _mail_msg *mm)
g_ptr_array_free(m->source_uids, TRUE);
}
if (m->cancel)
- camel_cancel_unref(m->cancel);
+ camel_operation_unref(m->cancel);
if (m->destination)
camel_object_unref((CamelObject *)m->destination);
camel_object_unref((CamelObject *)m->driver);
@@ -221,7 +222,7 @@ static struct _mail_msg_op filter_folder_op = {
void
mail_filter_folder(CamelFolder *source_folder, GPtrArray *uids,
FilterContext *fc, const char *type,
- CamelCancel *cancel)
+ CamelOperation *cancel)
{
struct _filter_mail_msg *m;
@@ -232,7 +233,7 @@ mail_filter_folder(CamelFolder *source_folder, GPtrArray *uids,
m->delete = FALSE;
if (cancel) {
m->cancel = cancel;
- camel_cancel_ref(cancel);
+ camel_operation_ref(cancel);
}
m->driver = camel_filter_driver_new(filter_get_folder, NULL);
@@ -261,11 +262,11 @@ fetch_mail_fetch(struct _mail_msg *mm)
int i;
if (m->cancel)
- camel_cancel_register(m->cancel);
+ camel_operation_register(m->cancel);
if ( (fm->destination = mail_tool_get_local_inbox(&mm->ex)) == NULL) {
if (m->cancel)
- camel_cancel_unregister(m->cancel);
+ camel_operation_unregister(m->cancel);
return;
}
@@ -324,7 +325,7 @@ fetch_mail_fetch(struct _mail_msg *mm)
}
if (m->cancel)
- camel_cancel_unregister(m->cancel);
+ camel_operation_unregister(m->cancel);
}
static void
@@ -343,7 +344,7 @@ fetch_mail_free(struct _mail_msg *mm)
g_free(m->source_uri);
if (m->cancel)
- camel_cancel_unref(m->cancel);
+ camel_operation_unref(m->cancel);
filter_folder_free(mm);
}
@@ -358,7 +359,7 @@ static struct _mail_msg_op fetch_mail_op = {
/* ouch, a 'do everything' interface ... */
void mail_fetch_mail(const char *source, int keep,
FilterContext *fc, const char *type,
- CamelCancel *cancel,
+ CamelOperation *cancel,
CamelFilterGetFolderFunc get_folder, void *get_data,
CamelFilterStatusFunc *status, void *status_data,
void (*done)(char *source, void *data), void *data)
@@ -372,7 +373,7 @@ void mail_fetch_mail(const char *source, int keep,
fm->delete = !keep;
if (cancel) {
m->cancel = cancel;
- camel_cancel_ref(cancel);
+ camel_operation_ref(cancel);
}
m->done = done;
m->data = data;
@@ -516,9 +517,9 @@ static void send_mail_send(struct _mail_msg *mm)
{
struct _send_mail_msg *m = (struct _send_mail_msg *)mm;
- camel_cancel_register(mm->cancel);
+ camel_operation_register(mm->cancel);
mail_send_message(m->message, m->destination, m->driver, &mm->ex);
- camel_cancel_unregister(mm->cancel);
+ camel_operation_unregister(mm->cancel);
}
static void send_mail_sent(struct _mail_msg *mm)
@@ -578,7 +579,7 @@ struct _send_queue_msg {
char *destination;
CamelFilterDriver *driver;
- CamelCancel *cancel;
+ CamelOperation *cancel;
/* we use camelfilterstatusfunc, even though its not the filter doing it */
CamelFilterStatusFunc *status;
@@ -617,7 +618,7 @@ send_queue_send(struct _mail_msg *mm)
return;
if (m->cancel)
- camel_cancel_register(m->cancel);
+ camel_operation_register(m->cancel);
for (i=0; i<uids->len; i++) {
CamelMimeMessage *message;
@@ -660,7 +661,7 @@ send_queue_send(struct _mail_msg *mm)
camel_folder_sync(sent_folder, FALSE, &mm->ex);
if (m->cancel)
- camel_cancel_unregister(m->cancel);
+ camel_operation_unregister(m->cancel);
}
static void
@@ -680,7 +681,7 @@ send_queue_free(struct _mail_msg *mm)
camel_object_unref((CamelObject *)m->queue);
g_free(m->destination);
if (m->cancel)
- camel_cancel_unref(m->cancel);
+ camel_operation_unref(m->cancel);
}
static struct _mail_msg_op send_queue_op = {
@@ -694,7 +695,7 @@ static struct _mail_msg_op send_queue_op = {
void
mail_send_queue(CamelFolder *queue, const char *destination,
FilterContext *fc, const char *type,
- CamelCancel *cancel,
+ CamelOperation *cancel,
CamelFilterGetFolderFunc get_folder, void *get_data,
CamelFilterStatusFunc *status, void *status_data,
void (*done)(char *destination, void *data), void *data)
@@ -707,7 +708,7 @@ mail_send_queue(CamelFolder *queue, const char *destination,
m->destination = g_strdup(destination);
if (cancel) {
m->cancel = cancel;
- camel_cancel_ref(cancel);
+ camel_operation_ref(cancel);
}
m->status = status;
m->status_data = status_data;
@@ -1426,7 +1427,7 @@ struct _get_message_msg {
void (*done) (CamelFolder *folder, char *uid, CamelMimeMessage *msg, void *data);
void *data;
CamelMimeMessage *message;
- CamelCancel *cancel;
+ CamelOperation *cancel;
};
static char *get_message_desc(struct _mail_msg *mm, int done)
@@ -1440,9 +1441,9 @@ static void get_message_get(struct _mail_msg *mm)
{
struct _get_message_msg *m = (struct _get_message_msg *)mm;
- camel_cancel_register(m->cancel);
+ camel_operation_register(m->cancel);
m->message = camel_folder_get_message(m->folder, m->uid, &mm->ex);
- camel_cancel_unregister(m->cancel);
+ camel_operation_unregister(m->cancel);
}
static void get_message_got(struct _mail_msg *mm)
@@ -1459,7 +1460,7 @@ static void get_message_free(struct _mail_msg *mm)
g_free(m->uid);
camel_object_unref((CamelObject *)m->folder);
- camel_cancel_unref(m->cancel);
+ camel_operation_unref(m->cancel);
}
static struct _mail_msg_op get_message_op = {
@@ -1480,7 +1481,7 @@ mail_get_message(CamelFolder *folder, const char *uid, void (*done) (CamelFolder
m->uid = g_strdup(uid);
m->data = data;
m->done = done;
- m->cancel = camel_cancel_new();
+ m->cancel = camel_operation_new(NULL, NULL);
e_thread_put(thread, (EMsg *)m);
}
diff --git a/mail/mail-ops.h b/mail/mail-ops.h
index 27c7dbcabf..ba2201cfdd 100644
--- a/mail/mail-ops.h
+++ b/mail/mail-ops.h
@@ -26,7 +26,7 @@
#include "camel/camel-folder.h"
#include "camel/camel-filter-driver.h"
#include "camel/camel-mime-message.h"
-#include "camel/camel-session.h"
+#include "camel/camel-operation.h"
#include "filter/filter-context.h"
@@ -98,21 +98,21 @@ int mail_update_subfolders(CamelStore *store, EvolutionStorage *storage,
/* yeah so this is messy, but it does a lot, maybe i can consolidate all user_data's to be the one */
void mail_send_queue(CamelFolder *queue, const char *destination,
FilterContext *fc, const char *type,
- CamelCancel *cancel,
+ CamelOperation *cancel,
CamelFilterGetFolderFunc get_folder, void *get_data,
CamelFilterStatusFunc *status, void *status_data,
void (*done)(char *destination, void *data), void *data);
void mail_fetch_mail(const char *source, int keep,
FilterContext *fc, const char *type,
- CamelCancel *cancel,
+ CamelOperation *cancel,
CamelFilterGetFolderFunc get_folder, void *get_data,
CamelFilterStatusFunc *status, void *status_data,
void (*done)(char *source, void *data), void *data);
void mail_filter_folder(CamelFolder *source_folder, GPtrArray *uids,
FilterContext *fc, const char *type,
- CamelCancel *cancel);
+ CamelOperation *cancel);
/* convenience function for above */
void mail_filter_on_demand(CamelFolder *folder, GPtrArray *uids);
diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c
index b9f1f70316..3e83144e7a 100644
--- a/mail/mail-send-recv.c
+++ b/mail/mail-send-recv.c
@@ -30,7 +30,7 @@
#include "filter/filter-filter.h"
#include "camel/camel-filter-driver.h"
#include "camel/camel-folder.h"
-#include "camel/camel-session.h"
+#include "camel/camel-operation.h"
#include "evolution-storage.h"
@@ -48,6 +48,9 @@
#include <libgnomeui/gnome-dialog.h>
#include <libgnomeui/gnome-window-icon.h>
+
+GHashTable *active_downloads = NULL;
+
/* send/receive email */
/* ********************************************************************** */
@@ -91,7 +94,7 @@ typedef enum {
struct _send_info {
send_info_t type; /* 0 = fetch, 1 = send */
- CamelCancel *cancel;
+ CamelOperation *cancel;
char *uri;
int keep;
send_state_t state;
@@ -105,11 +108,13 @@ static void
receive_cancel(GtkButton *button, struct _send_info *info)
{
if (info->state == SEND_ACTIVE) {
- camel_cancel_cancel(info->cancel);
- gtk_progress_set_format_string((GtkProgress *)info->bar, _("Cancelling ..."));
+ camel_operation_cancel(info->cancel);
+ if (info->bar)
+ gtk_progress_set_format_string((GtkProgress *)info->bar, _("Cancelling ..."));
info->state = SEND_CANCELLED;
}
- gtk_widget_set_sensitive((GtkWidget *)info->stop, FALSE);
+ if (info->stop)
+ gtk_widget_set_sensitive((GtkWidget *)info->stop, FALSE);
}
static void
@@ -129,7 +134,7 @@ free_info_data(void *datain)
while (list) {
struct _send_info *info = list->data;
g_free(info->uri);
- camel_cancel_unref(info->cancel);
+ camel_operation_unref(info->cancel);
list = list->next;
}
@@ -169,6 +174,8 @@ dialogue_clicked(GnomeDialog *gd, int button, struct _send_data *data)
}
}
+static void operation_status(CamelOperation *op, const char *what, int pc, void *data);
+
static struct _send_data *build_dialogue(GSList *sources, CamelFolder *outbox, const char *destination)
{
GnomeDialog *gd;
@@ -206,7 +213,7 @@ static struct _send_data *build_dialogue(GSList *sources, CamelFolder *outbox, c
sources = sources->next;
continue;
}
-
+
info = g_malloc0(sizeof(*info));
/* imap is handled differently */
if (!strncmp(source->url, "imap:", 5))
@@ -233,12 +240,14 @@ static struct _send_data *build_dialogue(GSList *sources, CamelFolder *outbox, c
info->bar = bar;
info->uri = g_strdup(source->url);
info->keep = source->keep_on_server;
- info->cancel = camel_cancel_new();
+ info->cancel = camel_operation_new(operation_status, info);
info->stop = stop;
info->data = data;
info->state = SEND_ACTIVE;
data->active++;
+ g_hash_table_insert(active_downloads, info->uri, info);
+
list = g_list_prepend(list, info);
gtk_signal_connect((GtkObject *)stop, "clicked", receive_cancel, info);
@@ -273,11 +282,13 @@ static struct _send_data *build_dialogue(GSList *sources, CamelFolder *outbox, c
info->bar = bar;
info->uri = g_strdup(destination);
info->keep = FALSE;
- info->cancel = camel_cancel_new();
+ info->cancel = camel_operation_new(NULL, NULL);
info->stop = stop;
info->data = data;
info->state = SEND_ACTIVE;
data->active++;
+
+ g_hash_table_insert(active_downloads, info->uri, info);
list = g_list_prepend(list, info);
@@ -337,8 +348,10 @@ do_show_status(struct _mail_msg *mm)
*o++ = c;
}
*o = 0;
- gtk_progress_set_percentage((GtkProgress *)m->info->bar, (gfloat)(m->pc/100.0));
- gtk_progress_set_format_string((GtkProgress *)m->info->bar, out);
+ if (m->info->bar) {
+ gtk_progress_set_percentage((GtkProgress *)m->info->bar, (gfloat)(m->pc/100.0));
+ gtk_progress_set_format_string((GtkProgress *)m->info->bar, out);
+ }
}
static void
@@ -399,30 +412,64 @@ receive_status (CamelFilterDriver *driver, enum camel_filter_status_t status, in
}
}
+/* for camel operation status */
+static void operation_status(CamelOperation *op, const char *what, int pc, void *data)
+{
+ struct _status_msg *m;
+ struct _send_info *info = data;
+ time_t now;
+
+ /*printf("Operation '%s', percent %d\n");*/
+ switch (pc) {
+ case CAMEL_OPERATION_START:
+ pc = 0;
+ break;
+ case CAMEL_OPERATION_END:
+ pc = 100;
+ break;
+ }
+
+ now = time(0);
+ if (now <= info->update)
+ return;
+ info->update = now;
+
+ m = mail_msg_new(&status_op, NULL, sizeof(*m));
+ m->desc = g_strdup(what);
+ m->pc = pc;
+ m->info = info;
+ e_msgport_put(mail_gui_port, (EMsg *)m);
+}
+
/* when receive/send is complete */
static void
receive_done (char *uri, void *data)
{
struct _send_info *info = data;
- gtk_progress_set_percentage((GtkProgress *)info->bar, (gfloat)1.0);
+ if (info->bar) {
+ gtk_progress_set_percentage((GtkProgress *)info->bar, (gfloat)1.0);
- switch(info->state) {
- case SEND_CANCELLED:
- gtk_progress_set_format_string((GtkProgress *)info->bar, _("Cancelled."));
- break;
- default:
- info->state = SEND_COMPLETE;
- gtk_progress_set_format_string((GtkProgress *)info->bar, _("Complete."));
+ switch(info->state) {
+ case SEND_CANCELLED:
+ gtk_progress_set_format_string((GtkProgress *)info->bar, _("Cancelled."));
+ break;
+ default:
+ info->state = SEND_COMPLETE;
+ gtk_progress_set_format_string((GtkProgress *)info->bar, _("Complete."));
+ }
}
- gtk_widget_set_sensitive((GtkWidget *)info->stop, FALSE);
+ if (info->stop)
+ gtk_widget_set_sensitive((GtkWidget *)info->stop, FALSE);
info->data->active--;
- if (info->data->active == 0) {
+ if (info->data->active == 0 && info->data) {
gnome_dialog_set_sensitive(info->data->gd, 0, TRUE);
gnome_dialog_set_sensitive(info->data->gd, 1, FALSE);
}
+
+ g_hash_table_remove(active_downloads, info->uri);
}
/* same for updating */
@@ -559,3 +606,60 @@ void mail_send_receive(void)
gtk_object_unref((GtkObject *)fc);
}
+#if 0
+/* we setup the download info's in a hashtable, if we later need to build the gui, we insert
+ them in to add them. */
+void mail_receive_uri(const char *uri, int keep)
+{
+ FilterContext *fc;
+ struct _send_info *info;
+
+ info = g_hash_table_lookup(active_downloads);
+ if (info != NULL)
+ return;
+
+ info = g_malloc0(sizeof(*info));
+ /* imap is handled differently */
+ if (!strncmp(source->url, "imap:", 5))
+ info->type = SEND_UPDATE;
+ else
+ info->type = SEND_RECEIVE;
+
+ info->bar = NULL;
+ info->uri = g_strdup(uri);
+ info->keep = keep;
+ info->cancel = camel_operation_new(operation_status, info);
+ info->stop = NULL;
+ info->data = data;
+ info->state = SEND_ACTIVE;
+ data->active++;
+
+ g_hash_table_insert(active_downloads, info);
+
+ fc = mail_load_filter_context();
+ switch(info->type) {
+ case SEND_RECEIVE:
+ mail_fetch_mail(info->uri, info->keep,
+ fc, FILTER_SOURCE_INCOMING,
+ info->cancel,
+ receive_get_folder, info,
+ receive_status, info,
+ receive_done, info);
+ break;
+ case SEND_SEND:
+ /* todo, store the folder in info? */
+ mail_send_queue(outbox_folder, info->uri,
+ fc, FILTER_SOURCE_OUTGOING,
+ info->cancel,
+ receive_get_folder, info,
+ receive_status, info,
+ receive_done, info);
+ break;
+ case SEND_UPDATE:
+ /* FIXME: error reporting? */
+ mail_get_store(info->uri, receive_update_got_store, info);
+ break;
+ }
+ gtk_object_unref((GtkObject *)fc);
+}
+#endif