diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 16 | ||||
-rw-r--r-- | mail/folder-browser-factory.c | 3 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 74 | ||||
-rw-r--r-- | mail/mail-ops.c | 199 | ||||
-rw-r--r-- | mail/mail-ops.h | 2 | ||||
-rw-r--r-- | mail/mail-tools.c | 7 | ||||
-rw-r--r-- | mail/mail.h | 3 |
7 files changed, 263 insertions, 41 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 3262a63059..bbd5a267cb 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,19 @@ +2000-09-03 Jeffrey Stedfast <fejj@helixcode.com> + + * folder-browser-factory.c: Change the "Get Mail" toolbar button + to become "Send & Receieve" + + * mail-callbacks.c (send_queued_mail): New callback function for + sending queued mail + (send_receieve_mail): New callback for Send & Receieve that + basically just calls send_queued_mail and then fetch_mail + + * mail-ops.c (cleanup_send_mail): Mod to be able to handle a NULL + composer window + (setup_send_mail): Modified to handle a NULL composer widget + (mail_do_send_queue): New convenience async function to send all + messages in a folder (aka all messages in a queue) + 2000-09-02 Jeffrey Stedfast <fejj@helixcode.com> * mail-tools.c (mail_tool_move_folder_contents): Since POP3 diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c index 134e6a431a..a1ffafbf6e 100644 --- a/mail/folder-browser-factory.c +++ b/mail/folder-browser-factory.c @@ -30,7 +30,8 @@ static GList *control_list = NULL; static GnomeUIInfo gnome_toolbar [] = { - GNOMEUIINFO_ITEM_STOCK (N_("Get mail"), N_("Check for new mail"), fetch_mail, GNOME_STOCK_PIXMAP_MAIL_RCV), + GNOMEUIINFO_ITEM_STOCK (N_("Send & Receive"), N_("Send queued mail and retrieve new mail"), + send_receieve_mail, GNOME_STOCK_PIXMAP_MAIL_RCV), GNOMEUIINFO_ITEM_STOCK (N_("Compose"), N_("Compose a new message"), compose_msg, GNOME_STOCK_PIXMAP_MAIL_NEW), GNOMEUIINFO_SEPARATOR, diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index 70ae463a29..e0338eda5f 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -135,59 +135,105 @@ select_first_unread (CamelObject *object, gpointer event_data, gpointer data) } void -fetch_mail (GtkWidget *button, gpointer user_data) +fetch_mail (GtkWidget *widget, gpointer user_data) { GSList *sources; - + if (!check_configured (FOLDER_BROWSER (user_data))) { GtkWidget *win = gtk_widget_get_ancestor (GTK_WIDGET (user_data), GTK_TYPE_WINDOW); - + gnome_error_dialog_parented ("You have no mail sources " "configured", GTK_WINDOW (win)); return; } - + sources = mail_config_get_sources (); - + if (!sources || !sources->data) { GtkWidget *win = gtk_widget_get_ancestor (GTK_WIDGET (user_data), GTK_TYPE_WINDOW); - + gnome_error_dialog_parented ("You have no mail sources " "configured", GTK_WINDOW (win)); return; } - + while (sources) { MailConfigService *source; - + source = (MailConfigService *) sources->data; sources = sources->next; - + if (!source || !source->url) { g_warning ("Bad source in fetch_mail??"); continue; } - + mail_do_fetch_mail (source->url, source->keep_on_server, NULL, select_first_unread, user_data); } } +void +send_queued_mail (GtkWidget *widget, gpointer user_data) +{ + extern CamelFolder *outbox_folder; + MailConfigService *transport; + + if (!mail_config_is_configured ()) { + GtkWidget *win = gtk_widget_get_ancestor (GTK_WIDGET (user_data), + GTK_TYPE_WINDOW); + + gnome_error_dialog_parented ("You have not set any configuration settings", + GTK_WINDOW (win)); + return; + } + + transport = mail_config_get_transport (); + if (!transport) { + GtkWidget *win = gtk_widget_get_ancestor (GTK_WIDGET (user_data), + GTK_TYPE_WINDOW); + + gnome_error_dialog_parented ("You have not set a transport method", + GTK_WINDOW (win)); + return; + } + + if (!outbox_folder) { + GtkWidget *win = gtk_widget_get_ancestor (GTK_WIDGET (user_data), + GTK_TYPE_WINDOW); + + gnome_error_dialog_parented ("You have no Outbox configured", + GTK_WINDOW (win)); + return; + } + + mail_do_send_queue (outbox_folder, transport->url); + + mail_do_expunge_folder (outbox_folder); +} + +void +send_receieve_mail (GtkWidget *widget, gpointer user_data) +{ + send_queued_mail (widget, user_data); + fetch_mail (widget, user_data); +} + static gboolean ask_confirm_for_empty_subject (EMsgComposer *composer) { GtkWidget *message_box; int button; - + message_box = gnome_message_box_new (_("This message has no subject.\nReally send?"), GNOME_MESSAGE_BOX_QUESTION, GNOME_STOCK_BUTTON_YES, GNOME_STOCK_BUTTON_NO, NULL); - + button = gnome_dialog_run_and_close (GNOME_DIALOG (message_box)); - + if (button == 0) return TRUE; else @@ -198,7 +244,7 @@ static void free_psd (GtkWidget *composer, gpointer user_data) { struct post_send_data *psd = user_data; - + if (psd->folder) camel_object_unref (CAMEL_OBJECT (psd->folder)); if (psd->uid) diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 5b7690ae7f..a856d30435 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -253,51 +253,50 @@ static void setup_send_mail (gpointer in_data, gpointer op_data, CamelException *ex) { send_mail_input_t *input = (send_mail_input_t *) in_data; - + if (!input->xport_uri) { camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, /* doesn't really need i18n */ "No transport URI specified for send_mail operation."); return; } - + if (!CAMEL_IS_MIME_MESSAGE (input->message)) { camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, "No message specified for send_mail operation."); return; } - + /* NOTE THE EARLY EXIT!! */ - + if (input->done_folder == NULL) { camel_object_ref (CAMEL_OBJECT (input->message)); - gtk_object_ref (GTK_OBJECT (input->composer)); - gtk_widget_hide (GTK_WIDGET (input->composer)); + if (input->composer) { + gtk_object_ref (GTK_OBJECT (input->composer)); + gtk_widget_hide (GTK_WIDGET (input->composer)); + } return; } - + if (!CAMEL_IS_FOLDER (input->done_folder)) { camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, "Bad done_folder specified for send_mail operation."); return; } - + if (input->done_uid == NULL) { camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, "No done_uid specified for send_mail operation."); return; } - - if (!GTK_IS_WIDGET (input->composer)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No composer specified for send_mail operation."); - return; - } - + camel_object_ref (CAMEL_OBJECT (input->message)); camel_object_ref (CAMEL_OBJECT (input->done_folder)); - gtk_object_ref (GTK_OBJECT (input->composer)); - gtk_widget_hide (GTK_WIDGET (input->composer)); + + if (input->composer) { + gtk_object_ref (GTK_OBJECT (input->composer)); + gtk_widget_hide (GTK_WIDGET (input->composer)); + } } static void @@ -344,7 +343,7 @@ do_send_mail (gpointer in_data, gpointer op_data, CamelException *ex) /* now to save the message in Sentbox */ if (sentbox_folder) { CamelMessageInfo *info; - + mail_tool_camel_lock_up (); info = g_new0 (CamelMessageInfo, 1); @@ -368,10 +367,12 @@ cleanup_send_mail (gpointer in_data, gpointer op_data, CamelException *ex) g_free (input->xport_uri); g_free (input->done_uid); - if (!camel_exception_is_set (ex)) - gtk_widget_destroy (input->composer); - else - gtk_widget_show (input->composer); + if (input->composer) { + if (!camel_exception_is_set (ex)) + gtk_widget_destroy (input->composer); + else + gtk_widget_show (input->composer); + } } static const mail_operation_spec op_send_mail = { @@ -402,6 +403,160 @@ mail_do_send_mail (const char *xport_uri, mail_operation_queue (&op_send_mail, input, TRUE); } +/* ** SEND MAIL QUEUE ***************************************************** */ + +typedef struct send_queue_input_s +{ + CamelFolder *folder_queue; + gchar *xport_uri; +} +send_queue_input_t; + +static gchar *describe_send_queue (gpointer in_data, gboolean gerund); +static void setup_send_queue (gpointer in_data, gpointer op_data, + CamelException *ex); +static void do_send_queue (gpointer in_data, gpointer op_data, + CamelException *ex); +static void cleanup_send_queue (gpointer in_data, gpointer op_data, + CamelException *ex); + +static gchar * +describe_send_queue (gpointer in_data, gboolean gerund) +{ + /*send_queue_input_t *input = (send_queue_input_t *) in_data;*/ + + if (gerund) { + return g_strdup_printf (_("Sending queue")); + } else { + return g_strdup_printf (_("Send queue")); + } +} + +static void +setup_send_queue (gpointer in_data, gpointer op_data, CamelException *ex) +{ + send_queue_input_t *input = (send_queue_input_t *) in_data; + + if (!input->xport_uri) { + camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, + /* doesn't really need i18n */ + "No transport URI specified for send_queue operation."); + return; + } + + if (!CAMEL_IS_FOLDER (input->folder_queue)) { + camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, + "No queue specified for send_queue operation."); + return; + } + + camel_object_ref (CAMEL_OBJECT (input->folder_queue)); +} + +static void +do_send_queue (gpointer in_data, gpointer op_data, CamelException *ex) +{ + send_queue_input_t *input = (send_queue_input_t *) in_data; + extern CamelFolder *sentbox_folder; + CamelTransport *xport; + GPtrArray *uids; + char *x_mailer; + guint32 set; + int i; + + uids = camel_folder_get_uids (input->folder_queue); + if (!uids) + return; + + x_mailer = g_strdup_printf ("Evolution %s (Developer Preview)", + VERSION); + + for (i = 0; i < uids->len; i++) { + CamelMimeMessage *message; + + mail_tool_camel_lock_up (); + + message = camel_folder_get_message (input->folder_queue, uids->pdata[i], ex); + if (camel_exception_is_set (ex)) + break; + + camel_medium_add_header (CAMEL_MEDIUM (message), "X-Mailer", x_mailer); + + camel_mime_message_set_date (message, CAMEL_MESSAGE_DATE_CURRENT, 0); + + xport = camel_session_get_transport (session, input->xport_uri, ex); + mail_tool_camel_lock_down (); + if (camel_exception_is_set (ex)) + break; + + mail_tool_send_via_transport (xport, CAMEL_MEDIUM (message), ex); + camel_object_unref (CAMEL_OBJECT (xport)); + + if (camel_exception_is_set (ex)) + break; + + mail_tool_camel_lock_up (); + set = camel_folder_get_message_flags (input->folder_queue, + uids->pdata[i]); + camel_folder_set_message_flags (input->folder_queue, + uids->pdata[i], + CAMEL_MESSAGE_DELETED, ~set); + mail_tool_camel_lock_down (); + + /* now to save the message in Sentbox */ + if (sentbox_folder) { + CamelMessageInfo *info; + + mail_tool_camel_lock_up (); + + info = g_new0 (CamelMessageInfo, 1); + info->flags = 0; + camel_folder_append_message (sentbox_folder, message, info, ex); + g_free (info); + + mail_tool_camel_lock_down (); + } + } + + g_free (x_mailer); + + for (i = 0; i < uids->len; i++) + g_free (uids->pdata[i]); + g_ptr_array_free (uids, TRUE); +} + +static void +cleanup_send_queue (gpointer in_data, gpointer op_data, CamelException *ex) +{ + send_queue_input_t *input = (send_queue_input_t *) in_data; + + camel_object_unref (CAMEL_OBJECT (input->folder_queue)); + + g_free (input->xport_uri); +} + +static const mail_operation_spec op_send_queue = { + describe_send_queue, + 0, + setup_send_queue, + do_send_queue, + cleanup_send_queue +}; + +void +mail_do_send_queue (CamelFolder *folder_queue, + const char *xport_uri) +{ + send_queue_input_t *input; + + input = g_new (send_queue_input_t, 1); + input->xport_uri = g_strdup (xport_uri); + input->folder_queue = folder_queue; + + mail_operation_queue (&op_send_queue, input, TRUE); +} + + /* ** APPEND MESSAGE TO FOLDER ******************************************** */ typedef struct append_mail_input_s diff --git a/mail/mail-ops.h b/mail/mail-ops.h index 3d8de04e00..47758a03e7 100644 --- a/mail/mail-ops.h +++ b/mail/mail-ops.h @@ -36,6 +36,8 @@ void mail_do_send_mail (const char *xport_uri, CamelFolder *done_folder, const char *done_uid, guint32 done_flags, GtkWidget *composer); +void mail_do_send_queue (CamelFolder *folder_queue, + const char *xport_uri); void mail_do_append_mail (CamelFolder *folder, CamelMimeMessage *message, CamelMessageInfo *info); diff --git a/mail/mail-tools.c b/mail/mail-tools.c index c6d5dcdf57..c5592625eb 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -374,10 +374,9 @@ mail_tool_move_folder_contents (CamelFolder *source, CamelFolder *dest, gboolean void mail_tool_set_uid_flags (CamelFolder *folder, const char *uid, guint32 mask, guint32 set) { - mail_tool_camel_lock_up(); - camel_folder_set_message_flags (folder, uid, - mask, set); - mail_tool_camel_lock_down(); + mail_tool_camel_lock_up (); + camel_folder_set_message_flags (folder, uid, mask, set); + mail_tool_camel_lock_down (); } gchar * diff --git a/mail/mail.h b/mail/mail.h index 3200754099..4b398a0f4b 100644 --- a/mail/mail.h +++ b/mail/mail.h @@ -54,6 +54,9 @@ char *mail_identify_mime_part (CamelMimePart *part); /* mail-callbacks */ void fetch_mail (GtkWidget *widget, gpointer user_data); +void send_queued_mail (GtkWidget *widget, gpointer user_data); +void send_receieve_mail (GtkWidget *widget, gpointer user_data); + void compose_msg (GtkWidget *widget, gpointer user_data); void send_to_url (const char *url); void forward_msg (GtkWidget *widget, gpointer user_data); |