aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-callbacks.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-07-06 03:38:11 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-07-06 03:38:11 +0800
commita293a2aa215aea513cf5c88c14f783f224719de8 (patch)
treeff788022c0f08b5958696dba6a8f13f769b1a94e /mail/mail-callbacks.c
parent915bf644648f4de87c4c2472c368719524456936 (diff)
downloadgsoc2013-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
Diffstat (limited to 'mail/mail-callbacks.c')
-rw-r--r--mail/mail-callbacks.c87
1 files changed, 19 insertions, 68 deletions
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);