diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 33 | ||||
-rw-r--r-- | mail/folder-browser-ui.c | 3 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 155 | ||||
-rw-r--r-- | mail/mail-callbacks.h | 6 | ||||
-rw-r--r-- | mail/mail-config.c | 9 | ||||
-rw-r--r-- | mail/mail-tools.c | 23 | ||||
-rw-r--r-- | mail/mail-tools.h | 24 |
7 files changed, 200 insertions, 53 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index d27fd4af88..e44ae3905f 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,31 @@ +2002-07-24 Jeffrey Stedfast <fejj@ximian.com> + + * mail-config.c (mail_config_folder_to_safe_url): Use + mail_tools_folder_to_url(). + + * mail-tools.c (mail_tools_folder_to_url): New convenience + function to take a CamelFolder and return the URL associated with + it. + + * mail-callbacks.c (composer_get_message): Pass in a 'post' + argument so we know whether or not we can ignore a NULL set of + recipients. + (composer_send_cb): Default send->send to TRUE unless we are in + Post-To mode, in which case set send->send to FALSE (since we'll + have nothing to send). Also, if we are in Post-To mode, append to + the folder the user wants to post to rather than appending to + Outbox. + (composer_send_queued_cb): Only queue a send thread if send->send + is TRUE (ie, the composer was not in Post mode - if it was in Post + mode, then the message post has already been saved in the correct + folder so there is nothing to do). + (post_message): New function to create an empty composer widget in + Post mode. + (post_reply): New function that calls mail_reply with the new mode + of REPLY_POST. + (mail_generate_reply): If the mode is REPLY_POST, create a Post + composer widget otherwise create a normal composer widget. + 2002-07-25 Jeffrey Stedfast <fejj@ximian.com> * mail-ops.c (mail_execute_shell_command): Update to take argc and @@ -70,8 +98,9 @@ 2002-07-23 Jeffrey Stedfast <fejj@ximian.com> - * message-tag-followup.c (message_tag_followup_decode): Don't use - strncmp here or reply-all will match reply. + * message-tag-followup.c (message_tag_followup_decode): Don't pass + the length of the tag name into strncmp, instead use the length up + to the first ':' in the value string. 2002-07-22 Peter Williams <peterw@ximian.com> diff --git a/mail/folder-browser-ui.c b/mail/folder-browser-ui.c index 7ba0056980..c26997453e 100644 --- a/mail/folder-browser-ui.c +++ b/mail/folder-browser-ui.c @@ -59,6 +59,7 @@ static BonoboUIVerb message_verbs [] = { BONOBO_UI_UNSAFE_VERB ("MessageFollowUpFlag", flag_for_followup), BONOBO_UI_UNSAFE_VERB ("MessageMove", move_msg), BONOBO_UI_UNSAFE_VERB ("MessageOpen", open_message), + BONOBO_UI_UNSAFE_VERB ("MessagePostReply", post_reply), BONOBO_UI_UNSAFE_VERB ("MessageReplyAll", reply_to_all), BONOBO_UI_UNSAFE_VERB ("MessageReplyList", reply_to_list), BONOBO_UI_UNSAFE_VERB ("MessageReplySender", reply_to_sender), @@ -108,6 +109,7 @@ static BonoboUIVerb global_verbs [] = { BONOBO_UI_UNSAFE_VERB ("EmptyTrash", empty_trash), BONOBO_UI_UNSAFE_VERB ("ForgetPasswords", mail_session_forget_passwords), BONOBO_UI_UNSAFE_VERB ("MailCompose", compose_msg), + BONOBO_UI_UNSAFE_VERB ("MailPost", post_message), BONOBO_UI_UNSAFE_VERB ("MailStop", stop_threads), BONOBO_UI_UNSAFE_VERB ("ToolsFilters", filter_edit), BONOBO_UI_UNSAFE_VERB ("ToolsSubscriptions", manage_subscriptions), @@ -202,6 +204,7 @@ struct _UINode default_ui_nodes[] = { { "MessageResend", IS_SENT_FOLDER | SELECTION_SINGLE }, /* actions that work on exactly 1 message */ + { "MessagePostReply", IS_ANY_FOLDER | SELECTION_SINGLE }, { "MessageReplyAll", IS_ANY_FOLDER | SELECTION_SINGLE }, { "MessageReplyList", IS_ANY_FOLDER | SELECTION_SINGLE }, { "MessageReplySender", IS_ANY_FOLDER | SELECTION_SINGLE }, diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index 6e3cbb88a5..c2f63a5202 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -343,6 +343,7 @@ free_psd (GtkWidget *composer, gpointer user_data) struct _send_data { EMsgComposer *composer; struct post_send_data *psd; + gboolean send; }; static void @@ -358,7 +359,7 @@ composer_send_queued_cb (CamelFolder *folder, CamelMimeMessage *msg, CamelMessag } gtk_widget_destroy (GTK_WIDGET (send->composer)); - if (camel_session_is_online (session)) { + if (send->send && camel_session_is_online (session)) { /* queue a message send */ mail_send (); } @@ -374,7 +375,7 @@ composer_send_queued_cb (CamelFolder *folder, CamelMimeMessage *msg, CamelMessag } static CamelMimeMessage * -composer_get_message (EMsgComposer *composer, gboolean save_html_object_data) +composer_get_message (EMsgComposer *composer, gboolean post, gboolean save_html_object_data) { const MailConfigAccount *account; CamelMimeMessage *message = NULL; @@ -389,17 +390,17 @@ composer_get_message (EMsgComposer *composer, gboolean save_html_object_data) (e.g. to get a passphrase to sign a message) */ /* get the message recipients */ - recipients = e_msg_composer_get_recipients(composer); + recipients = e_msg_composer_get_recipients (composer); /* see which ones are visible/present, etc */ if (recipients) { - for (i=0; recipients[i] != NULL;i++) { - const char *addr = e_destination_get_address(recipients[i]); + for (i = 0; recipients[i] != NULL; i++) { + const char *addr = e_destination_get_address (recipients[i]); if (addr && addr[0]) { num++; - if (e_destination_is_evolution_list(recipients[i]) - && !e_destination_list_show_addresses(recipients[i])) { + if (e_destination_is_evolution_list (recipients[i]) + && !e_destination_list_show_addresses (recipients[i])) { hidden++; } else { shown++; @@ -408,10 +409,10 @@ composer_get_message (EMsgComposer *composer, gboolean save_html_object_data) } } - recipients_bcc = e_msg_composer_get_bcc(composer); + recipients_bcc = e_msg_composer_get_bcc (composer); if (recipients_bcc) { - for (i=0; recipients_bcc[i] != NULL;i++) { - const char *addr = e_destination_get_address(recipients_bcc[i]); + for (i = 0; recipients_bcc[i] != NULL; i++) { + const char *addr = e_destination_get_address (recipients_bcc[i]); if (addr && addr[0]) num_bcc++; @@ -420,7 +421,7 @@ composer_get_message (EMsgComposer *composer, gboolean save_html_object_data) } /* I'm sensing a lack of love, er, I mean recipients. */ - if (num == 0) { + if (num == 0 && !post) { GtkWidget *message_box; message_box = gnome_message_box_new (_("You must specify recipients in order to " @@ -433,7 +434,7 @@ composer_get_message (EMsgComposer *composer, gboolean save_html_object_data) goto finished; } - if (num == num_bcc || shown == 0) { + if (num > 0 && (num == num_bcc || shown == 0)) { /* this means that the only recipients are Bcc's */ if (!ask_confirm_for_only_bcc (composer, shown == 0)) goto finished; @@ -442,13 +443,15 @@ composer_get_message (EMsgComposer *composer, gboolean save_html_object_data) /* Only show this warning if our default is to send html. If it isn't, we've manually switched into html mode in the composer and (presumably) had a good reason for doing this. */ - if (e_msg_composer_get_send_html (composer) - && mail_config_get_send_html () + if (e_msg_composer_get_send_html (composer) && mail_config_get_send_html () && mail_config_get_confirm_unwanted_html ()) { gboolean html_problem = FALSE; - for (i = 0; recipients[i] != NULL && !html_problem; ++i) { - if (!e_destination_get_html_mail_pref (recipients[i])) - html_problem = TRUE; + + if (recipients) { + for (i = 0; recipients[i] != NULL && !html_problem; ++i) { + if (!e_destination_get_html_mail_pref (recipients[i])) + html_problem = TRUE; + } } if (html_problem) { @@ -485,41 +488,79 @@ composer_get_message (EMsgComposer *composer, gboolean save_html_object_data) } /* Get the message recipients and 'touch' them, boosting their use scores */ - e_destination_touchv (recipients); + if (recipients) + e_destination_touchv (recipients); finished: - e_destination_freev (recipients); + if (recipients) + e_destination_freev (recipients); return message; } +static void +got_post_folder (char *uri, CamelFolder *folder, void *data) +{ + CamelFolder **fp = data; + + *fp = folder; + + if (folder) + camel_object_ref (CAMEL_OBJECT (folder)); +} + void composer_send_cb (EMsgComposer *composer, gpointer user_data) { + struct post_send_data *psd = user_data; extern CamelFolder *outbox_folder; CamelMimeMessage *message; CamelMessageInfo *info; - struct post_send_data *psd = user_data; struct _send_data *send; + gboolean post = FALSE; + CamelFolder *folder; + XEvolution *xev; + char *url; - message = composer_get_message (composer, FALSE); + url = e_msg_composer_hdrs_get_post_to ((EMsgComposerHdrs *) composer->hdrs); + if (url != NULL) { + post = TRUE; + mail_msg_wait (mail_get_folder (url, 0, got_post_folder, &folder, mail_thread_new)); + } else { + folder = outbox_folder; + camel_object_ref (folder); + } + + message = composer_get_message (composer, post, FALSE); if (!message) return; + if (post) { + /* Remove the X-Evolution* headers if we are in Post-To mode */ + xev = mail_tool_remove_xevolution_headers (message); + mail_tool_destroy_xevolution (xev); + } + info = camel_message_info_new (); info->flags = CAMEL_MESSAGE_SEEN; send = g_malloc (sizeof (*send)); send->psd = psd; + send->send = !post; send->composer = composer; gtk_object_ref (GTK_OBJECT (composer)); gtk_widget_hide (GTK_WIDGET (composer)); e_msg_composer_set_enable_autosave (composer, FALSE); - mail_append_mail (outbox_folder, message, info, composer_send_queued_cb, send); + if (post) { + + } + + mail_append_mail (folder, message, info, composer_send_queued_cb, send); camel_object_unref (message); + camel_object_unref (folder); } struct _save_draft_info { @@ -640,7 +681,7 @@ composer_save_draft_cb (EMsgComposer *composer, int quit, gpointer user_data) } static GtkWidget * -create_msg_composer (const MailConfigAccount *account, const char *url) +create_msg_composer (const MailConfigAccount *account, gboolean post, const char *url) { EMsgComposer *composer; gboolean send_html; @@ -654,7 +695,12 @@ create_msg_composer (const MailConfigAccount *account, const char *url) send_html = mail_config_get_send_html (); - composer = url ? e_msg_composer_new_from_url (url) : e_msg_composer_new (); + if (post) + composer = e_msg_composer_new_post (); + else if (url) + composer = e_msg_composer_new_from_url (url); + else + composer = e_msg_composer_new (); if (composer) { e_msg_composer_hdrs_set_from_account (E_MSG_COMPOSER_HDRS (composer->hdrs), account->name); @@ -679,7 +725,7 @@ compose_msg (GtkWidget *widget, gpointer user_data) /* Figure out which account we want to initially compose from */ account = mail_config_get_account_by_source_url (fb->uri); - composer = create_msg_composer (account, NULL); + composer = create_msg_composer (account, FALSE, NULL); if (!composer) return; @@ -703,7 +749,7 @@ send_to_url (const char *url) return; /* Tell create_msg_composer to use the default email profile */ - composer = create_msg_composer (NULL, url); + composer = create_msg_composer (NULL, FALSE, url); if (!composer) return; @@ -836,8 +882,18 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char EMsgComposer *composer; CamelMimePart *part; time_t date; + char *url; + + if (mode == REPLY_POST) { + composer = e_msg_composer_new_post (); + if (composer != NULL) { + url = mail_tools_folder_to_url (folder); + e_msg_composer_hdrs_set_post_to ((EMsgComposerHdrs *) composer->hdrs, url); + g_free (url); + } + } else + composer = e_msg_composer_new (); - composer = e_msg_composer_new (); if (!composer) return NULL; @@ -1007,7 +1063,7 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char } /* Set the subject of the new message. */ - subject = (char *)camel_mime_message_get_subject (message); + subject = (char *) camel_mime_message_get_subject (message); if (!subject) subject = g_strdup (""); else { @@ -1083,7 +1139,7 @@ mail_reply (CamelFolder *folder, CamelMimeMessage *msg, const char *uid, int mod EMsgComposer *composer; struct post_send_data *psd; - g_return_if_fail (folder != NULL); + g_return_if_fail (CAMEL_IS_FOLDER (folder)); g_return_if_fail (uid != NULL); if (!msg) { @@ -1310,6 +1366,45 @@ forward (GtkWidget *widget, gpointer user_data) forward_message (user_data, style); } + +void +post_message (GtkWidget *widget, gpointer user_data) +{ + FolderBrowser *fb = FOLDER_BROWSER (user_data); + GtkWidget *composer; + char *url; + + if (FOLDER_BROWSER_IS_DESTROYED (fb) || !check_send_configuration (fb)) + return; + + composer = create_msg_composer (NULL, TRUE, NULL); + if (!composer) + return; + + url = mail_tools_folder_to_url (fb->folder); + e_msg_composer_hdrs_set_post_to ((EMsgComposerHdrs *) ((EMsgComposer *) composer)->hdrs, url); + g_free (url); + + gtk_signal_connect (GTK_OBJECT (composer), "send", + GTK_SIGNAL_FUNC (composer_send_cb), NULL); + gtk_signal_connect (GTK_OBJECT (composer), "save-draft", + GTK_SIGNAL_FUNC (composer_save_draft_cb), NULL); + + gtk_widget_show (composer); +} + +void +post_reply (GtkWidget *widget, gpointer user_data) +{ + FolderBrowser *fb = FOLDER_BROWSER (user_data); + + if (FOLDER_BROWSER_IS_DESTROYED (fb) || !check_send_configuration (fb)) + return; + + mail_reply (fb->folder, NULL, fb->message_list->cursor_uid, REPLY_POST); +} + + static EMsgComposer * redirect_get_composer (CamelMimeMessage *message) { @@ -1318,7 +1413,7 @@ redirect_get_composer (CamelMimeMessage *message) const GSList *accounts = NULL; EMsgComposer *composer; - g_return_val_if_fail (message != NULL, NULL); + g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL); accounts = mail_config_get_accounts (); to_addrs = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO); diff --git a/mail/mail-callbacks.h b/mail/mail-callbacks.h index e1c6ebaeca..b293edc7bb 100644 --- a/mail/mail-callbacks.h +++ b/mail/mail-callbacks.h @@ -31,13 +31,14 @@ #ifdef __cplusplus extern "C" { #pragma } -#endif /* __cplusplus }*/ +#endif /* __cplusplus */ /* these are the possible modes for replying */ enum { REPLY_SENDER, REPLY_LIST, REPLY_ALL, + REPLY_POST, REPLY_NO_QUOTE = 0x80 /* dont quote reply */ }; @@ -54,6 +55,9 @@ void forward_quoted (GtkWidget *widget, gpointer user_data); void forward_attached (GtkWidget *widget, gpointer user_data); void forward (GtkWidget *widget, gpointer user_data); +void post_message (GtkWidget *widget, gpointer user_data); +void post_reply (GtkWidget *widget, gpointer user_data); + void redirect (GtkWidget *widget, gpointer user_data); void reply_to_sender (GtkWidget *widget, gpointer user_data); diff --git a/mail/mail-config.c b/mail/mail-config.c index a6b47e92ad..b95bdc6c32 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -2506,14 +2506,11 @@ mail_config_service_set_save_passwd (MailConfigService *service, gboolean save_p char * mail_config_folder_to_safe_url (CamelFolder *folder) { - CamelService *service = CAMEL_SERVICE (folder->parent_store); - char *service_url, *url; - - service_url = camel_url_to_string (service->url, CAMEL_URL_HIDE_ALL); - url = g_strdup_printf ("%s/%s", service_url, folder->full_name); - g_free (service_url); + char *url; + url = mail_tools_folder_to_url (folder); e_filename_make_safe (url); + return url; } diff --git a/mail/mail-tools.c b/mail/mail-tools.c index 2b4061ed63..c2e4d33e06 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -448,3 +448,26 @@ mail_tools_x_evolution_message_parse (char *in, unsigned int inlen, GPtrArray ** return folder; } + + +char * +mail_tools_folder_to_url (CamelFolder *folder) +{ + char *service_url, *url; + const char *full_name; + CamelService *service; + + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL); + + full_name = folder->full_name; + while (*full_name == '/') + full_name++; + + service = (CamelService *) folder->parent_store; + service_url = camel_url_to_string (service->url, CAMEL_URL_HIDE_ALL); + url = g_strdup_printf ("%s%s%s", service_url, service_url[strlen (service_url)-1] != '/' ? "/" : "", + full_name); + g_free (service_url); + + return url; +} diff --git a/mail/mail-tools.h b/mail/mail-tools.h index 02565b7036..86f1bc6e42 100644 --- a/mail/mail-tools.h +++ b/mail/mail-tools.h @@ -40,39 +40,33 @@ typedef struct _xevolution { CamelFolder *mail_tool_get_local_inbox (CamelException *ex); /* Get the "inbox" for a url (uses global session) */ -CamelFolder *mail_tool_get_inbox (const gchar *url, CamelException *ex); +CamelFolder *mail_tool_get_inbox (const char *url, CamelException *ex); /* Get the "trash" for a url (uses global session) */ -CamelFolder *mail_tool_get_trash (const gchar *url, int connect, CamelException *ex); +CamelFolder *mail_tool_get_trash (const char *url, int connect, CamelException *ex); /* Does a camel_movemail into the local movemail folder * and returns the path to the new movemail folder that was created. which shoudl be freed later */ -char * -mail_tool_do_movemail (const gchar *source_url, CamelException *ex); +char *mail_tool_do_movemail (const char *source_url, CamelException *ex); /* Transfers all the messages from source into dest; * source is emptied and synced. */ -void -mail_tool_move_folder_contents (CamelFolder *source, CamelFolder *dest, gboolean use_cache, CamelException *ex); +void mail_tool_move_folder_contents (CamelFolder *source, CamelFolder *dest, gboolean use_cache, CamelException *ex); XEvolution *mail_tool_remove_xevolution_headers (CamelMimeMessage *message); void mail_tool_restore_xevolution_headers (CamelMimeMessage *message, XEvolution *xev); void mail_tool_destroy_xevolution (XEvolution *xev); /* Generates the subject for a message forwarding @msg */ -gchar * -mail_tool_generate_forward_subject (CamelMimeMessage *msg); +gchar *mail_tool_generate_forward_subject (CamelMimeMessage *msg); /* Make a message into an attachment */ -CamelMimePart * -mail_tool_make_message_attachment (CamelMimeMessage *message); +CamelMimePart *mail_tool_make_message_attachment (CamelMimeMessage *message); /* Parse the ui into a real CamelFolder any way we know how. */ -CamelFolder * -mail_tool_uri_to_folder (const char *uri, guint32 flags, CamelException *ex); +CamelFolder *mail_tool_uri_to_folder (const char *uri, guint32 flags, CamelException *ex); -GHashTable * -mail_lookup_url_table (CamelMimeMessage *mime_message); +GHashTable *mail_lookup_url_table (CamelMimeMessage *mime_message); gchar *mail_tool_quote_message (CamelMimeMessage *message, const char *fmt, ...); @@ -80,4 +74,6 @@ gchar *mail_tool_forward_message (CamelMimeMessage *message, gboolean quoted); CamelFolder *mail_tools_x_evolution_message_parse (char *in, unsigned int inlen, GPtrArray **uids); +char *mail_tools_folder_to_url (CamelFolder *folder); + #endif |