aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog11
-rw-r--r--mail/mail-callbacks.c66
-rw-r--r--mail/mail-ops.c142
-rw-r--r--mail/mail-ops.h3
-rw-r--r--mail/mail.h1
5 files changed, 197 insertions, 26 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 18420974b5..546389d5ca 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,10 +1,19 @@
2000-09-01 Jeffrey Stedfast <fejj@helixcode.com>
+ * mail-callbacks.c (compose_msg): Attach a callback to the
+ postpone signal
+ (send_to_url): Same
+ (mail_reply): Same
+ (forward_msg): Same
+ (composer_postpone_cb): Callback function for the postpone signal
+
* mail-ops.c (mail_do_setup_outbox): New convenience function to
load the Outbox folder
(mail_do_setup_sentbox): Same, but for Sentbox.
(do_send_mail): Now saves messages in Sentbox if sent successfully
-
+ (mail_do_append_mail): New convenience async function for
+ appending messages to a folder
+
* component-factory.c: Added outbox_folder and sent_folder
(owner_set_cb): Call our new convenience functions to load Outbox
and Sentbox
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index 970221eadf..70ae463a29 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -239,6 +239,35 @@ composer_send_cb (EMsgComposer *composer, gpointer data)
}
}
+void
+composer_postpone_cb (EMsgComposer *composer, gpointer data)
+{
+ /* FIXME: do we want to use post_send_data to set flags and stuff? */
+ extern CamelFolder *outbox_folder;
+ CamelMimeMessage *message;
+ CamelMessageInfo *info;
+ const char *subject;
+
+ /* Get the message */
+ message = e_msg_composer_get_message (composer);
+
+ /* Check for no subject */
+ subject = camel_mime_message_get_subject (message);
+ if (subject == NULL || subject[0] == '\0') {
+ if (!ask_confirm_for_empty_subject (composer)) {
+ camel_object_unref (CAMEL_OBJECT (message));
+ return;
+ }
+ }
+
+ /* Save the message in Outbox */
+ info = g_new0 (CamelMessageInfo, 1);
+ info->flags = 0;
+ mail_do_append_mail (outbox_folder, message, info);
+ g_free (info);
+ gtk_widget_destroy (GTK_WIDGET (composer));
+}
+
static GtkWidget *
create_msg_composer (const char *url)
{
@@ -268,14 +297,17 @@ void
compose_msg (GtkWidget *widget, gpointer user_data)
{
GtkWidget *composer;
-
+
if (!check_send_configuration (FOLDER_BROWSER (user_data)))
return;
-
+
composer = create_msg_composer (NULL);
-
+
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_widget_show (composer);
}
@@ -284,16 +316,19 @@ void
send_to_url (const char *url)
{
GtkWidget *composer;
-
+
/* FIXME: no way to get folder browser? Not without
* big pain in the ass, as far as I can tell */
if (!check_send_configuration (NULL))
return;
-
+
composer = create_msg_composer (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_widget_show (composer);
}
@@ -318,7 +353,9 @@ mail_reply (CamelFolder *folder, CamelMimeMessage *msg, const char *uid, gboolea
composer = mail_generate_reply (msg, to_all);
gtk_signal_connect (GTK_OBJECT (composer), "send",
- GTK_SIGNAL_FUNC (composer_send_cb), psd);
+ 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), "destroy",
GTK_SIGNAL_FUNC (free_psd), psd);
@@ -369,6 +406,8 @@ forward_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);
mail_do_forward_message (cursor_msg,
fb->message_list->folder,
@@ -459,22 +498,23 @@ edit_msg (GtkWidget *widget, gpointer user_data)
FolderBrowser *fb = FOLDER_BROWSER (user_data);
GPtrArray *uids;
extern CamelFolder *drafts_folder;
-
+
if (fb->folder != drafts_folder) {
GtkWidget *message;
-
+
message = gnome_warning_dialog (_("You may only edit messages saved\n"
- "in the Drafts folder."));
+ "in the Drafts folder."));
gnome_dialog_run_and_close (GNOME_DIALOG (message));
return;
}
-
+
if (!check_send_configuration (fb))
return;
-
+
uids = g_ptr_array_new();
message_list_foreach (fb->message_list, enumerate_msg, uids);
-
+
+ /* FIXME: do we need to pass the postpone callback too? */
mail_do_edit_messages (fb->folder, uids, (GtkSignalFunc) composer_send_cb);
}
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 2a41177897..5b7690ae7f 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -344,11 +344,15 @@ 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);
info->flags = 0;
camel_folder_append_message (sentbox_folder, input->message, info, ex);
g_free (info);
+
+ mail_tool_camel_lock_down ();
}
}
@@ -398,6 +402,120 @@ mail_do_send_mail (const char *xport_uri,
mail_operation_queue (&op_send_mail, input, TRUE);
}
+/* ** APPEND MESSAGE TO FOLDER ******************************************** */
+
+typedef struct append_mail_input_s
+{
+ CamelFolder *folder;
+ CamelMimeMessage *message;
+ CamelMessageInfo *info;
+}
+append_mail_input_t;
+
+static gchar *describe_append_mail (gpointer in_data, gboolean gerund);
+static void setup_append_mail (gpointer in_data, gpointer op_data,
+ CamelException *ex);
+static void do_append_mail (gpointer in_data, gpointer op_data,
+ CamelException *ex);
+static void cleanup_append_mail (gpointer in_data, gpointer op_data,
+ CamelException *ex);
+
+static gchar *
+describe_append_mail (gpointer in_data, gboolean gerund)
+{
+ append_mail_input_t *input = (append_mail_input_t *) in_data;
+
+ if (gerund) {
+ if (input->message->subject && input->message->subject[0])
+ return g_strdup_printf (_("Appending \"%s\""),
+ input->message->subject);
+ else
+ return
+ g_strdup (_("Appending a message without a subject"));
+ } else {
+ if (input->message->subject && input->message->subject[0])
+ return g_strdup_printf (_("Appending \"%s\""),
+ input->message->subject);
+ else
+ return g_strdup (_("Appending a message without a subject"));
+ }
+}
+
+static void
+setup_append_mail (gpointer in_data, gpointer op_data, CamelException *ex)
+{
+ append_mail_input_t *input = (append_mail_input_t *) in_data;
+
+ if (!CAMEL_IS_MIME_MESSAGE (input->message)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No message specified for append_mail operation.");
+ return;
+ }
+
+ if (!input->info) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No message info specified for append_mail operation.");
+ return;
+ }
+
+ if (!CAMEL_IS_FOLDER (input->folder)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "Bad done_folder specified for append_mail operation.");
+ return;
+ }
+
+ camel_object_ref (CAMEL_OBJECT (input->message));
+ camel_object_ref (CAMEL_OBJECT (input->folder));
+}
+
+static void
+do_append_mail (gpointer in_data, gpointer op_data, CamelException *ex)
+{
+ append_mail_input_t *input = (append_mail_input_t *) in_data;
+
+ camel_mime_message_set_date (input->message,
+ CAMEL_MESSAGE_DATE_CURRENT, 0);
+
+ mail_tool_camel_lock_up ();
+
+ /* now to save the message in the specified folder */
+ camel_folder_append_message (input->folder, input->message, input->info, ex);
+
+ mail_tool_camel_lock_down ();
+}
+
+static void
+cleanup_append_mail (gpointer in_data, gpointer op_data, CamelException *ex)
+{
+ append_mail_input_t *input = (append_mail_input_t *) in_data;
+
+ camel_object_unref (CAMEL_OBJECT (input->message));
+ camel_object_unref (CAMEL_OBJECT (input->folder));
+}
+
+static const mail_operation_spec op_append_mail = {
+ describe_append_mail,
+ 0,
+ setup_append_mail,
+ do_append_mail,
+ cleanup_append_mail
+};
+
+void
+mail_do_append_mail (CamelFolder *folder,
+ CamelMimeMessage *message,
+ CamelMessageInfo *info)
+{
+ append_mail_input_t *input;
+
+ input = g_new (append_mail_input_t, 1);
+ input->folder = folder;
+ input->message = message;
+ input->info = info;
+
+ mail_operation_queue (&op_append_mail, input, TRUE);
+}
+
/* ** EXPUNGE FOLDER ****************************************************** */
static gchar *describe_expunge_folder (gpointer in_data, gboolean gerund);
@@ -1712,11 +1830,11 @@ typedef struct edit_messages_data_s {
static gchar *describe_edit_messages (gpointer in_data, gboolean gerund);
static void setup_edit_messages (gpointer in_data, gpointer op_data,
- CamelException *ex);
+ CamelException *ex);
static void do_edit_messages (gpointer in_data, gpointer op_data,
- CamelException *ex);
+ CamelException *ex);
static void cleanup_edit_messages (gpointer in_data, gpointer op_data,
- CamelException *ex);
+ CamelException *ex);
static gchar *
describe_edit_messages (gpointer in_data, gboolean gerund)
@@ -1736,20 +1854,20 @@ static void
setup_edit_messages (gpointer in_data, gpointer op_data, CamelException *ex)
{
edit_messages_input_t *input = (edit_messages_input_t *) in_data;
-
+
if (!input->uids) {
camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
/* doesn't need i18n */
"No UIDs specified to edit.");
return;
}
-
+
if (!CAMEL_IS_FOLDER (input->folder)) {
camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
"No folder to fetch the messages from specified.");
return;
}
-
+
camel_object_ref (CAMEL_OBJECT (input->folder));
}
@@ -1758,21 +1876,21 @@ do_edit_messages (gpointer in_data, gpointer op_data, CamelException *ex)
{
edit_messages_input_t *input = (edit_messages_input_t *) in_data;
edit_messages_data_t *data = (edit_messages_data_t *) op_data;
-
+
int i;
-
+
data->messages = g_ptr_array_new ();
-
+
for (i = 0; i < input->uids->len; i++) {
CamelMimeMessage *message;
-
+
mail_tool_camel_lock_up ();
message = camel_folder_get_message (input->folder, input->uids->pdata[i], ex);
mail_tool_camel_lock_down ();
-
+
if (message)
g_ptr_array_add (data->messages, message);
-
+
g_free (input->uids->pdata[i]);
}
}
diff --git a/mail/mail-ops.h b/mail/mail-ops.h
index 1ec7af4e4f..3d8de04e00 100644
--- a/mail/mail-ops.h
+++ b/mail/mail-ops.h
@@ -36,6 +36,9 @@ void mail_do_send_mail (const char *xport_uri,
CamelFolder *done_folder,
const char *done_uid,
guint32 done_flags, GtkWidget *composer);
+void mail_do_append_mail (CamelFolder *folder,
+ CamelMimeMessage *message,
+ CamelMessageInfo *info);
void mail_do_expunge_folder (CamelFolder *folder);
void mail_do_transfer_messages (CamelFolder *source, GPtrArray *uids,
gboolean delete_from_source,
diff --git a/mail/mail.h b/mail/mail.h
index b17107369e..3200754099 100644
--- a/mail/mail.h
+++ b/mail/mail.h
@@ -79,6 +79,7 @@ void configure_folder(BonoboUIHandler *uih, void *user_data, const char *path);
void mail_reply (CamelFolder *folder, CamelMimeMessage *msg, const char *uid, gboolean to_all);
void composer_send_cb (EMsgComposer *composer, gpointer data);
+void composer_postpone_cb (EMsgComposer *composer, gpointer data);
void mail_print_msg (MailDisplay *md);
void run_filter_ondemand (BonoboUIHandler *uih, gpointer user_data, const char *path);