diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-05-04 01:42:15 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2011-05-04 01:42:15 +0800 |
commit | 06411bdbbb3e6877c679007c269c84b05713f895 (patch) | |
tree | 784bf00863a407cc099afb393fb84629f3b539a9 /mail | |
parent | 1957378edf2264426c77571bde90c6bfeb7e50ce (diff) | |
download | gsoc2013-evolution-06411bdbbb3e6877c679007c269c84b05713f895.tar gsoc2013-evolution-06411bdbbb3e6877c679007c269c84b05713f895.tar.gz gsoc2013-evolution-06411bdbbb3e6877c679007c269c84b05713f895.tar.bz2 gsoc2013-evolution-06411bdbbb3e6877c679007c269c84b05713f895.tar.lz gsoc2013-evolution-06411bdbbb3e6877c679007c269c84b05713f895.tar.xz gsoc2013-evolution-06411bdbbb3e6877c679007c269c84b05713f895.tar.zst gsoc2013-evolution-06411bdbbb3e6877c679007c269c84b05713f895.zip |
Remove 'from_uri' params from e-msg-composer-utils.c.
Pass CamelFolder objects instead, which are already available at almost
every call site.
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-display.c | 6 | ||||
-rw-r--r-- | mail/e-mail-reader.c | 22 | ||||
-rw-r--r-- | mail/em-composer-utils.c | 95 | ||||
-rw-r--r-- | mail/em-composer-utils.h | 9 |
4 files changed, 65 insertions, 67 deletions
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c index c3ca4d3f10..03d6e1d9ef 100644 --- a/mail/e-mail-display.c +++ b/mail/e-mail-display.c @@ -239,7 +239,6 @@ mail_display_process_mailto (EWebView *web_view, const gchar *mailto_uri) EMailDisplayPrivate *priv; EMFormat *format; CamelFolder *folder = NULL; - const gchar *folder_uri = NULL; EShell *shell; priv = E_MAIL_DISPLAY (web_view)->priv; @@ -250,12 +249,9 @@ mail_display_process_mailto (EWebView *web_view, const gchar *mailto_uri) if (format != NULL && format->folder != NULL) folder = format->folder; - if (folder != NULL) - folder_uri = camel_folder_get_uri (folder); - shell = e_shell_get_default (); em_utils_compose_new_message_with_mailto ( - shell, mailto_uri, folder_uri); + shell, mailto_uri, folder); return TRUE; } diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 9d3ca5c228..ad596bba26 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -689,11 +689,9 @@ action_mail_forward_cb (GtkAction *action, CamelFolder *folder; GtkWindow *window; GPtrArray *uids; - const gchar *folder_uri; backend = e_mail_reader_get_backend (reader); folder = e_mail_reader_get_folder (reader); - folder_uri = e_mail_reader_get_folder_uri (reader); uids = e_mail_reader_get_selected_uids (reader); window = e_mail_reader_get_window (reader); @@ -704,7 +702,7 @@ action_mail_forward_cb (GtkAction *action, if (em_utils_ask_open_many (window, uids->len)) em_utils_forward_messages ( - shell, folder, uids, folder_uri, + shell, folder, uids, e_mail_reader_get_forward_style (reader)); else em_utils_uids_free (uids); @@ -722,11 +720,9 @@ action_mail_forward_attached_cb (GtkAction *action, CamelFolder *folder; GtkWindow *window; GPtrArray *uids; - const gchar *folder_uri; backend = e_mail_reader_get_backend (reader); folder = e_mail_reader_get_folder (reader); - folder_uri = e_mail_reader_get_folder_uri (reader); uids = e_mail_reader_get_selected_uids (reader); window = e_mail_reader_get_window (reader); @@ -737,7 +733,7 @@ action_mail_forward_attached_cb (GtkAction *action, if (em_utils_ask_open_many (window, uids->len)) em_utils_forward_messages ( - shell, folder, uids, folder_uri, + shell, folder, uids, E_MAIL_FORWARD_STYLE_ATTACHED); else em_utils_uids_free (uids); @@ -755,11 +751,9 @@ action_mail_forward_inline_cb (GtkAction *action, CamelFolder *folder; GtkWindow *window; GPtrArray *uids; - const gchar *folder_uri; backend = e_mail_reader_get_backend (reader); folder = e_mail_reader_get_folder (reader); - folder_uri = e_mail_reader_get_folder_uri (reader); uids = e_mail_reader_get_selected_uids (reader); window = e_mail_reader_get_window (reader); @@ -770,7 +764,7 @@ action_mail_forward_inline_cb (GtkAction *action, if (em_utils_ask_open_many (window, uids->len)) em_utils_forward_messages ( - shell, folder, uids, folder_uri, + shell, folder, uids, E_MAIL_FORWARD_STYLE_INLINE); else em_utils_uids_free (uids); @@ -788,11 +782,9 @@ action_mail_forward_quoted_cb (GtkAction *action, CamelFolder *folder; GtkWindow *window; GPtrArray *uids; - const gchar *folder_uri; backend = e_mail_reader_get_backend (reader); folder = e_mail_reader_get_folder (reader); - folder_uri = e_mail_reader_get_folder_uri (reader); uids = e_mail_reader_get_selected_uids (reader); window = e_mail_reader_get_window (reader); @@ -803,7 +795,7 @@ action_mail_forward_quoted_cb (GtkAction *action, if (em_utils_ask_open_many (window, uids->len)) em_utils_forward_messages ( - shell, folder, uids, folder_uri, + shell, folder, uids, E_MAIL_FORWARD_STYLE_QUOTED); else em_utils_uids_free (uids); @@ -933,15 +925,15 @@ action_mail_message_new_cb (GtkAction *action, EShell *shell; EMailBackend *backend; EShellBackend *shell_backend; - const gchar *folder_uri; + CamelFolder *folder; + folder = e_mail_reader_get_folder (reader); backend = e_mail_reader_get_backend (reader); - folder_uri = e_mail_reader_get_folder_uri (reader); shell_backend = E_SHELL_BACKEND (backend); shell = e_shell_backend_get_shell (shell_backend); - em_utils_compose_new_message (shell, folder_uri); + em_utils_compose_new_message (shell, folder); } static void diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index 2d3e7de605..d1f8666d8e 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -87,7 +87,6 @@ struct _ForwardData { EShell *shell; CamelFolder *folder; GPtrArray *uids; - gchar *from_uri; EMailForwardStyle style; }; @@ -121,8 +120,6 @@ forward_data_free (ForwardData *data) if (data->uids != NULL) em_utils_uids_free (data->uids); - g_free (data->from_uri); - g_slice_free (ForwardData, data); } @@ -876,7 +873,7 @@ em_utils_composer_print_cb (EMsgComposer *composer, static EMsgComposer * create_new_composer (EShell *shell, const gchar *subject, - const gchar *from_uri) + CamelFolder *folder) { EMsgComposer *composer; EComposerHeaderTable *table; @@ -886,14 +883,23 @@ create_new_composer (EShell *shell, table = e_msg_composer_get_header_table (composer); - if (from_uri != NULL) { + if (folder != NULL) { + CamelStore *store; + const gchar *uid; + gchar *folder_uri; GList *list; - account = e_get_account_by_source_url (from_uri); + store = camel_folder_get_parent_store (folder); + uid = camel_service_get_uid (CAMEL_SERVICE (store)); + account = e_get_account_by_uid (uid); - list = g_list_prepend (NULL, (gpointer) from_uri); + folder_uri = e_mail_folder_uri_from_folder (folder); + + list = g_list_prepend (NULL, folder_uri); e_composer_header_table_set_post_to_list (table, list); g_list_free (list); + + g_free (folder_uri); } e_composer_header_table_set_account (table, account); @@ -905,40 +911,42 @@ create_new_composer (EShell *shell, /** * em_utils_compose_new_message: * @shell: an #EShell + * @folder: a #CamelFolder, or %NULL * * Opens a new composer window as a child window of @parent's toplevel * window. **/ void em_utils_compose_new_message (EShell *shell, - const gchar *from_uri) + CamelFolder *folder) { - GtkWidget *composer; + EMsgComposer *composer; g_return_if_fail (E_IS_SHELL (shell)); - composer = (GtkWidget *) create_new_composer (shell, "", from_uri); - if (composer == NULL) - return; + if (folder != NULL) + g_return_if_fail (CAMEL_IS_FOLDER (folder)); - composer_set_no_change (E_MSG_COMPOSER (composer)); + composer = create_new_composer (shell, "", folder); + composer_set_no_change (composer); - gtk_widget_show (composer); + gtk_widget_show (GTK_WIDGET (composer)); } /** * em_utils_compose_new_message_with_mailto: * @shell: an #EShell - * @url: mailto url + * @mailto: a mailto URL + * @folder: a #CamelFolder, or %NULL * * Opens a new composer window as a child window of @parent's toplevel - * window. If @url is non-NULL, the composer fields will be filled in - * according to the values in the mailto url. + * window. If @mailto is non-NULL, the composer fields will be filled in + * according to the values in the mailto URL. **/ EMsgComposer * em_utils_compose_new_message_with_mailto (EShell *shell, - const gchar *url, - const gchar *from_uri) + const gchar *mailto, + CamelFolder *folder) { EMsgComposer *composer; EComposerHeaderTable *table; @@ -946,15 +954,26 @@ em_utils_compose_new_message_with_mailto (EShell *shell, g_return_val_if_fail (E_IS_SHELL (shell), NULL); - if (url != NULL) - composer = e_msg_composer_new_from_url (shell, url); + if (folder != NULL) + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL); + + if (mailto != NULL) + composer = e_msg_composer_new_from_url (shell, mailto); else composer = e_msg_composer_new (shell); table = e_msg_composer_get_header_table (composer); - if (from_uri - && (account = e_get_account_by_source_url (from_uri))) + if (folder != NULL) { + CamelStore *store; + const gchar *uid; + + store = camel_folder_get_parent_store (folder); + uid = camel_service_get_uid (CAMEL_SERVICE (store)); + account = e_get_account_by_uid (uid); + } + + if (account != NULL) e_composer_header_table_set_account_name (table, account->name); composer_set_no_change (composer); @@ -1371,14 +1390,11 @@ forward_attached (EShell *shell, GPtrArray *uids, GPtrArray *messages, CamelMimePart *part, - gchar *subject, - const gchar *from_uri) + gchar *subject) { EMsgComposer *composer; - composer = create_new_composer (shell, subject, from_uri); - if (composer == NULL) - return NULL; + composer = create_new_composer (shell, subject, folder); e_msg_composer_attach (composer, part); @@ -1404,7 +1420,7 @@ forward_attached_cb (CamelFolder *folder, if (part) forward_attached ( data->shell, folder, data->uids, - messages, part, subject, data->from_uri); + messages, part, subject); forward_data_free (data); } @@ -1414,8 +1430,7 @@ forward_non_attached (EShell *shell, CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, - EMailForwardStyle style, - const gchar *from_uri) + EMailForwardStyle style) { CamelMimeMessage *message; EMsgComposer *composer = NULL; @@ -1444,7 +1459,7 @@ forward_non_attached (EShell *shell, message, forward, flags, NULL, NULL, &validity_found); if (text) { - composer = create_new_composer (shell, subject, from_uri); + composer = create_new_composer (shell, subject, folder); if (composer) { if (CAMEL_IS_MULTIPART (camel_medium_get_content ((CamelMedium *)message))) @@ -1476,7 +1491,7 @@ forward_non_attached (EShell *shell, * em_utils_forward_message: * @shell: an #EShell * @message: message to be forwarded - * @from_uri: from folder uri + * @folder: a #CamelFolder, or %NULL * @style: the forward style to use * * Forwards a message in the given style. See em_utils_forward_messages() @@ -1485,7 +1500,7 @@ forward_non_attached (EShell *shell, EMsgComposer * em_utils_forward_message (EShell *shell, CamelMimeMessage *message, - const gchar *from_uri, + CamelFolder *folder, EMailForwardStyle style) { GPtrArray *messages; @@ -1506,8 +1521,7 @@ em_utils_forward_message (EShell *shell, subject = mail_tool_generate_forward_subject (message); composer = forward_attached ( - shell, NULL, NULL, messages, - part, subject, from_uri); + shell, NULL, NULL, messages, part, subject); g_object_unref (part); g_free (subject); @@ -1516,13 +1530,13 @@ em_utils_forward_message (EShell *shell, case E_MAIL_FORWARD_STYLE_INLINE: composer = forward_non_attached ( shell, NULL, NULL, messages, - E_MAIL_FORWARD_STYLE_INLINE, from_uri); + E_MAIL_FORWARD_STYLE_INLINE); break; case E_MAIL_FORWARD_STYLE_QUOTED: composer = forward_non_attached ( shell, NULL, NULL, messages, - E_MAIL_FORWARD_STYLE_QUOTED, from_uri); + E_MAIL_FORWARD_STYLE_QUOTED); break; } @@ -1540,8 +1554,7 @@ forward_got_messages_cb (CamelFolder *folder, ForwardData *data = user_data; forward_non_attached ( - data->shell, folder, uids, messages, - data->style, data->from_uri); + data->shell, folder, uids, messages, data->style); forward_data_free (data); } @@ -1573,7 +1586,6 @@ void em_utils_forward_messages (EShell *shell, CamelFolder *folder, GPtrArray *uids, - const gchar *from_uri, EMailForwardStyle style) { ForwardData *data; @@ -1583,7 +1595,6 @@ em_utils_forward_messages (EShell *shell, data = g_slice_new0 (ForwardData); data->shell = g_object_ref (shell); data->uids = em_utils_uids_copy (uids); - data->from_uri = g_strdup (from_uri); data->style = style; switch (style) { diff --git a/mail/em-composer-utils.h b/mail/em-composer-utils.h index bab32c450e..b5a2f8ab84 100644 --- a/mail/em-composer-utils.h +++ b/mail/em-composer-utils.h @@ -32,11 +32,11 @@ G_BEGIN_DECLS void em_utils_compose_new_message (EShell *shell, - const gchar *from_uri); + CamelFolder *folder); EMsgComposer * em_utils_compose_new_message_with_mailto (EShell *shell, - const gchar *url, - const gchar *from_uri); + const gchar *mailto, + CamelFolder *folder); GtkWidget * em_utils_edit_message (EShell *shell, CamelFolder *folder, CamelMimeMessage *message); @@ -46,12 +46,11 @@ void em_utils_edit_messages (EShell *shell, gboolean replace); EMsgComposer * em_utils_forward_message (EShell *shell, CamelMimeMessage *msg, - const gchar *from_uri, + CamelFolder *folder, EMailForwardStyle style); void em_utils_forward_messages (EShell *shell, CamelFolder *folder, GPtrArray *uids, - const gchar *from_uri, EMailForwardStyle style); void em_utils_redirect_message (EShell *shell, CamelMimeMessage *message); |