diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-07-06 03:38:11 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-07-06 03:38:11 +0800 |
commit | a293a2aa215aea513cf5c88c14f783f224719de8 (patch) | |
tree | ff788022c0f08b5958696dba6a8f13f769b1a94e | |
parent | 915bf644648f4de87c4c2472c368719524456936 (diff) | |
download | gsoc2013-evolution-a293a2aa215aea513cf5c88c14f783f224719de8.tar.gz gsoc2013-evolution-a293a2aa215aea513cf5c88c14f783f224719de8.tar.zst gsoc2013-evolution-a293a2aa215aea513cf5c88c14f783f224719de8.zip |
No longer need to pass a postpone_cb function into the composer
2002-07-05 Jeffrey Stedfast <fejj@ximian.com>
* main.c (main): No longer need to pass a postpone_cb function
into the composer factory_init.
* mail-send-recv.c (get_receive_type): If the provider is a
transport, return SEND_SEND.
* mail-config.c (mail_config_get_default_transport): If the
default account doesn't have a transport, find the first account
that does.
* mail-callbacks.c (append_mail_cleanup): Don't bother freeing the
appended_uid here.
(composer_send_internal): New helper function that does all the
similar work that composer_send_cb and composer_postpone_cb did.
(composer_send_cb): Append the message to Outbox and in the async
callback, queue a message send operation.
(composer_postpone_cb): Removed.
(composer_send_queued_cb): The new async callback for
composer_send_cb(). If the append is successful, queue a message
send operation and destroy the composer otherwise re-show the
composer.
(save_draft_done): g_strdup the appended uid.
(compose_msg): Don't connect to the postpone signal anymore as it
no longer exists.
(send_to_url): Same.
(mail_reply): Here too.
(forward_get_composer): And here.
(redirect_get_composer): Again here.
(do_edit_messages): And finally here.
* mail-ops.c (append_mail_free): Free the appended uid.
svn path=/trunk/; revision=17379
-rw-r--r-- | mail/ChangeLog | 34 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 87 | ||||
-rw-r--r-- | mail/mail-callbacks.h | 1 | ||||
-rw-r--r-- | mail/mail-config.c | 18 | ||||
-rw-r--r-- | mail/mail-ops.c | 3 | ||||
-rw-r--r-- | mail/mail-ops.h | 3 | ||||
-rw-r--r-- | mail/mail-send-recv.c | 67 | ||||
-rw-r--r-- | mail/mail-send-recv.h | 3 | ||||
-rw-r--r-- | mail/main.c | 3 |
9 files changed, 138 insertions, 81 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 09ff19f96d..7aa82051ca 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,37 @@ +2002-07-05 Jeffrey Stedfast <fejj@ximian.com> + + * main.c (main): No longer need to pass a postpone_cb function + into the composer factory_init. + + * mail-send-recv.c (get_receive_type): If the provider is a + transport, return SEND_SEND. + + * mail-config.c (mail_config_get_default_transport): If the + default account doesn't have a transport, find the first account + that does. + + * mail-callbacks.c (append_mail_cleanup): Don't bother freeing the + appended_uid here. + (composer_send_internal): New helper function that does all the + similar work that composer_send_cb and composer_postpone_cb did. + (composer_send_cb): Append the message to Outbox and in the async + callback, queue a message send operation. + (composer_postpone_cb): Removed. + (composer_send_queued_cb): The new async callback for + composer_send_cb(). If the append is successful, queue a message + send operation and destroy the composer otherwise re-show the + composer. + (save_draft_done): g_strdup the appended uid. + (compose_msg): Don't connect to the postpone signal anymore as it + no longer exists. + (send_to_url): Same. + (mail_reply): Here too. + (forward_get_composer): And here. + (redirect_get_composer): Again here. + (do_edit_messages): And finally here. + + * mail-ops.c (append_mail_free): Free the appended uid. + 2002-07-04 Jeffrey Stedfast <fejj@ximian.com> * mail-account-editor-news.[c,h]: Removed. diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index cea971efcb..37de09fde6 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -344,24 +344,29 @@ struct _send_data { }; static void -composer_sent_cb (char *uri, CamelMimeMessage *message, gboolean sent, void *data) +composer_send_queued_cb (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, + int queued, const char *appended_uid, void *data) { struct _send_data *send = data; - if (sent) { + if (queued) { if (send->psd) { camel_folder_set_message_flags (send->psd->folder, send->psd->uid, send->psd->flags, send->psd->set); } gtk_widget_destroy (GTK_WIDGET (send->composer)); + + /* queue a message send */ + mail_send (); } else { e_msg_composer_set_enable_autosave (send->composer, TRUE); gtk_widget_show (GTK_WIDGET (send->composer)); } + camel_message_info_free (info); + gtk_object_unref (GTK_OBJECT (send->composer)); g_free (send); - camel_object_unref (CAMEL_OBJECT (message)); } static CamelMimeMessage * @@ -486,73 +491,31 @@ composer_get_message (EMsgComposer *composer) } void -composer_send_cb (EMsgComposer *composer, gpointer data) +composer_send_cb (EMsgComposer *composer, gpointer user_data) { - const MailConfigService *transport; + extern CamelFolder *outbox_folder; CamelMimeMessage *message; - struct post_send_data *psd = data; + CamelMessageInfo *info; + struct post_send_data *psd = user_data; struct _send_data *send; - if (!mail_config_is_configured ()) { - GtkWidget *dialog; - - dialog = gnome_ok_dialog_parented (_("You must configure an account before you " - "can send this email."), - GTK_WINDOW (composer)); - gnome_dialog_set_close (GNOME_DIALOG (dialog), TRUE); - gtk_widget_show (dialog); - return; - } - message = composer_get_message (composer); if (!message) return; - transport = mail_config_get_default_transport (); - if (!transport) - return; + info = camel_message_info_new (); + info->flags = CAMEL_MESSAGE_SEEN; send = g_malloc (sizeof (*send)); send->psd = psd; send->composer = composer; gtk_object_ref (GTK_OBJECT (composer)); gtk_widget_hide (GTK_WIDGET (composer)); - e_msg_composer_set_enable_autosave (composer, FALSE); - mail_send_mail (transport->url, message, composer_sent_cb, send); -} - -static void -append_mail_cleanup (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, - int ok, char *appended_uid, void *data) -{ - camel_message_info_free (info); - if (appended_uid) - g_free (appended_uid); -} - -void -composer_postpone_cb (EMsgComposer *composer, gpointer data) -{ - extern CamelFolder *outbox_folder; - CamelMimeMessage *message; - CamelMessageInfo *info; - struct post_send_data *psd = data; - - message = composer_get_message (composer); - if (message == NULL) - return; - - info = camel_message_info_new (); - info->flags = CAMEL_MESSAGE_SEEN; - - mail_append_mail (outbox_folder, message, info, append_mail_cleanup, NULL); - camel_object_unref (CAMEL_OBJECT (message)); - - if (psd) - camel_folder_set_message_flags (psd->folder, psd->uid, psd->flags, psd->set); + e_msg_composer_set_enable_autosave (composer, FALSE); - gtk_widget_destroy (GTK_WIDGET (composer)); + mail_append_mail (outbox_folder, message, NULL, composer_send_queued_cb, send); + camel_object_unref (message); } struct _save_draft_info { @@ -562,7 +525,7 @@ struct _save_draft_info { static void save_draft_done (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, int ok, - char *appended_uid, void *data) + const char *appended_uid, void *data) { struct _save_draft_info *sdi = data; char *old_uid; @@ -580,7 +543,7 @@ save_draft_done (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *i if (appended_uid) { gtk_object_set_data_full (GTK_OBJECT (sdi->composer), - "draft_uid", appended_uid, + "draft_uid", g_strdup (appended_uid), (GtkDestroyNotify) g_free); } else { gtk_object_set_data (GTK_OBJECT (sdi->composer), @@ -714,8 +677,6 @@ compose_msg (GtkWidget *widget, gpointer user_data) gtk_signal_connect (GTK_OBJECT (composer), "send", GTK_SIGNAL_FUNC (composer_send_cb), NULL); - gtk_signal_connect (GTK_OBJECT (composer), "postpone", - GTK_SIGNAL_FUNC (composer_postpone_cb), NULL); gtk_signal_connect (GTK_OBJECT (composer), "save-draft", GTK_SIGNAL_FUNC (composer_save_draft_cb), NULL); @@ -740,8 +701,6 @@ send_to_url (const char *url) gtk_signal_connect (GTK_OBJECT (composer), "send", GTK_SIGNAL_FUNC (composer_send_cb), NULL); - gtk_signal_connect (GTK_OBJECT (composer), "postpone", - GTK_SIGNAL_FUNC (composer_postpone_cb), NULL); gtk_signal_connect (GTK_OBJECT (composer), "save-draft", GTK_SIGNAL_FUNC (composer_save_draft_cb), NULL); @@ -1138,8 +1097,6 @@ mail_reply (CamelFolder *folder, CamelMimeMessage *msg, const char *uid, int mod gtk_signal_connect (GTK_OBJECT (composer), "send", GTK_SIGNAL_FUNC (composer_send_cb), psd); - gtk_signal_connect (GTK_OBJECT (composer), "postpone", - GTK_SIGNAL_FUNC (composer_postpone_cb), psd); gtk_signal_connect (GTK_OBJECT (composer), "save-draft", GTK_SIGNAL_FUNC (composer_save_draft_cb), NULL); gtk_signal_connect (GTK_OBJECT (composer), "destroy", @@ -1222,8 +1179,6 @@ forward_get_composer (CamelMimeMessage *message, const char *subject) if (composer) { gtk_signal_connect (GTK_OBJECT (composer), "send", GTK_SIGNAL_FUNC (composer_send_cb), NULL); - gtk_signal_connect (GTK_OBJECT (composer), "postpone", - GTK_SIGNAL_FUNC (composer_postpone_cb), NULL); gtk_signal_connect (GTK_OBJECT (composer), "save-draft", GTK_SIGNAL_FUNC (composer_save_draft_cb), NULL); e_msg_composer_set_headers (composer, account->name, NULL, NULL, NULL, subject); @@ -1383,8 +1338,6 @@ redirect_get_composer (CamelMimeMessage *message) if (composer) { gtk_signal_connect (GTK_OBJECT (composer), "send", GTK_SIGNAL_FUNC (composer_send_cb), NULL); - gtk_signal_connect (GTK_OBJECT (composer), "postpone", - GTK_SIGNAL_FUNC (composer_postpone_cb), NULL); gtk_signal_connect (GTK_OBJECT (composer), "save-draft", GTK_SIGNAL_FUNC (composer_save_draft_cb), NULL); } else { @@ -2092,8 +2045,6 @@ do_edit_messages (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, voi if (composer) { gtk_signal_connect (GTK_OBJECT (composer), "send", composer_send_cb, NULL); - gtk_signal_connect (GTK_OBJECT (composer), "postpone", - composer_postpone_cb, NULL); uid = g_strdup (uids->pdata[i]); gtk_object_set_data_full (GTK_OBJECT (composer), "draft_uid", uid, (GtkDestroyNotify) g_free); diff --git a/mail/mail-callbacks.h b/mail/mail-callbacks.h index 3c453623e0..e1c6ebaeca 100644 --- a/mail/mail-callbacks.h +++ b/mail/mail-callbacks.h @@ -122,7 +122,6 @@ void empty_trash (BonoboUIComponent *uih, void *user_data, const char void mail_reply (CamelFolder *folder, CamelMimeMessage *msg, const char *uid, int mode); void composer_send_cb (EMsgComposer *composer, gpointer data); -void composer_postpone_cb (EMsgComposer *composer, gpointer data); void composer_save_draft_cb (EMsgComposer *composer, int quit, gpointer data); void forward_messages (CamelFolder *folder, GPtrArray *uids, gboolean inline); diff --git a/mail/mail-config.c b/mail/mail-config.c index 58bb0f5ce8..0cef4dc0fa 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -2400,12 +2400,24 @@ const MailConfigService * mail_config_get_default_transport (void) { const MailConfigAccount *account; + const GSList *accounts; account = mail_config_get_default_account (); - if (account) + if (account && account->transport && account->transport->url) return account->transport; - else - return NULL; + + /* return the first account with a transport? */ + accounts = config->accounts; + while (accounts) { + account = accounts->data; + + if (account->transport && account->transport->url) + return account->transport; + + accounts = accounts->next; + } + + return NULL; } GSList * diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 0572f1596d..c43d93a039 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -863,6 +863,7 @@ append_mail_free (struct _mail_msg *mm) camel_object_unref((CamelObject *)m->message); camel_object_unref((CamelObject *)m->folder); + g_free (m->appended_uid); } static struct _mail_msg_op append_mail_op = { @@ -874,7 +875,7 @@ static struct _mail_msg_op append_mail_op = { void mail_append_mail (CamelFolder *folder, CamelMimeMessage *message, CamelMessageInfo *info, - void (*done)(CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, int ok, char *appended_uid, void *data), + void (*done)(CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, int ok, const char *appended_uid, void *data), void *data) { struct _append_msg *m; diff --git a/mail/mail-ops.h b/mail/mail-ops.h index a6631d6559..f471ea1c72 100644 --- a/mail/mail-ops.h +++ b/mail/mail-ops.h @@ -39,7 +39,8 @@ extern "C" { #include "e-util/e-msgport.h" void mail_append_mail (CamelFolder *folder, CamelMimeMessage *message, CamelMessageInfo *info, - void (*done)(CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, int ok, char *appended_uid, void *data), + void (*done)(CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, int ok, + const char *appended_uid, void *data), void *data); void mail_transfer_messages (CamelFolder *source, GPtrArray *uids, diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c index 7b28435b32..c33b165a69 100644 --- a/mail/mail-send-recv.c +++ b/mail/mail-send-recv.c @@ -262,10 +262,16 @@ static send_info_t get_receive_type(const char *url) if (!provider) return SEND_INVALID; - if (provider->flags & CAMEL_PROVIDER_IS_STORAGE) - return SEND_UPDATE; - else - return SEND_RECEIVE; + if (provider->object_types[CAMEL_PROVIDER_STORE]) { + if (provider->flags & CAMEL_PROVIDER_IS_STORAGE) + return SEND_UPDATE; + else + return SEND_RECEIVE; + } else if (provider->object_types[CAMEL_PROVIDER_TRANSPORT]) { + return SEND_SEND; + } + + return SEND_INVALID; } static struct _send_data * @@ -854,3 +860,56 @@ mail_receive_uri (const char *uri, int keep) g_assert_not_reached (); } } + +void +mail_send (void) +{ + extern CamelFolder *outbox_folder; + const MailConfigService *transport; + struct _send_info *info; + struct _send_data *data; + send_info_t type; + + transport = mail_config_get_default_transport (); + if (!transport || !transport->url) + return; + + data = setup_send_data (); + info = g_hash_table_lookup (data->active, transport->url); + if (info != NULL) { + d(printf("send of %s still in progress\n", transport->url)); + return; + } + + d(printf("starting non-interactive send of '%s'\n", transport->url)); + + type = get_receive_type (transport->url); + if (type == SEND_INVALID) { + d(printf ("unsupported provider: '%s'\n", transport->url)); + return; + } + + info = g_malloc0 (sizeof (*info)); + info->type = SEND_SEND; + info->bar = NULL; + info->status = NULL; + info->uri = g_strdup (transport->url); + info->keep = FALSE; + info->cancel = camel_operation_new (operation_status, info); + info->stop = NULL; + info->data = data; + info->state = SEND_ACTIVE; + info->timeout_id = 0; + + d(printf("Adding new info %p\n", info)); + + g_hash_table_insert (data->active, info->uri, info); + + /* todo, store the folder in info? */ + mail_send_queue (outbox_folder, info->uri, + FILTER_SOURCE_OUTGOING, + info->cancel, + receive_get_folder, info, + receive_status, info, + receive_done, info); +} diff --git a/mail/mail-send-recv.h b/mail/mail-send-recv.h index 7d43d610fb..a6db0e5eac 100644 --- a/mail/mail-send-recv.h +++ b/mail/mail-send-recv.h @@ -26,7 +26,7 @@ #ifdef __cplusplus extern "C" { #pragma } -#endif /* __cplusplus }*/ +#endif /* __cplusplus */ #include "mail-config.h" @@ -34,6 +34,7 @@ extern "C" { void mail_send_receive(void); /* receive a single uri */ void mail_receive_uri(const char *uri, int keep); +void mail_send (void); /* setup auto receive stuff */ void mail_autoreceive_setup(void); diff --git a/mail/main.c b/mail/main.c index 5abc160999..fff0b49a45 100644 --- a/mail/main.c +++ b/mail/main.c @@ -141,8 +141,7 @@ main (int argc, char *argv []) gnome_sound_init ("localhost"); component_factory_init (); - evolution_composer_factory_init (composer_send_cb, - composer_postpone_cb); + evolution_composer_factory_init (composer_send_cb, composer_save_draft_cb); if (gdk_threads_mutex) { g_mutex_free (gdk_threads_mutex); |