From 89557dcfee7bb9f7ca7dddfe559e89dc7b2a93df Mon Sep 17 00:00:00 2001 From: Chenthill Palanisamy Date: Tue, 23 Nov 2010 01:58:24 +0530 Subject: Migrate the local store from mbox to maildir format --- mail/em-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 779e1a79e0..0753a75947 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1513,7 +1513,7 @@ gchar *em_uri_to_camel (const gchar *euri) if (strcmp(eurl->user, "vfolder") == 0) curl = camel_url_new("vfolder:", NULL); else - curl = camel_url_new("mbox:", NULL); + curl = camel_url_new("maildir:", NULL); base = g_strdup_printf("%s/mail/%s", e_get_user_data_dir(), eurl->user); #ifdef G_OS_WIN32 -- cgit v1.2.3 From d7ff1792f791b606817eb2bf8e35c1de0e4a35da Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 1 Feb 2011 18:09:00 +0100 Subject: Bug #635144 - Using external editor duplicates signature --- mail/em-utils.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 0753a75947..ad75c4829f 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1266,7 +1266,6 @@ em_utils_get_proxy_uri (const gchar *pUri) * @message: * @credits: * @flags: EMFormatQuote flags - * @len: * @source: * @append: Text to append, can be NULL. * @validity_found: if not NULL, then here will be set what validities @@ -1276,13 +1275,12 @@ em_utils_get_proxy_uri (const gchar *pUri) * Convert a message to html, quoting if the @credits attribution * string is given. * - * Return value: The html version. + * Return value: The html version as a NULL terminated string. **/ gchar * em_utils_message_to_html (CamelMimeMessage *message, const gchar *credits, guint32 flags, - gssize *len, EMFormat *source, const gchar *append, guint32 *validity_found) @@ -1290,7 +1288,6 @@ em_utils_message_to_html (CamelMimeMessage *message, EMFormatQuote *emfq; CamelStream *mem; GByteArray *buf; - gchar *text; buf = g_byte_array_new (); mem = camel_stream_mem_new (); @@ -1324,12 +1321,7 @@ em_utils_message_to_html (CamelMimeMessage *message, camel_stream_write(mem, "", 1, NULL, NULL); g_object_unref (mem); - text = (gchar *)buf->data; - if (len) - *len = buf->len-1; - g_byte_array_free (buf, FALSE); - - return text; + return (gchar *) g_byte_array_free (buf, FALSE); } /* ********************************************************************** */ -- cgit v1.2.3 From 3c6cc7e1a7b2cf2af50c4d7372ae95d4f2ca690c Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 15 Feb 2011 19:19:41 +0100 Subject: Slightly nicer EAlertDialog after move to gtk3 --- mail/em-utils.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index ad75c4829f..cea8871887 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -151,9 +151,8 @@ em_utils_prompt_user (GtkWindow *parent, if (promptkey) { check = gtk_check_button_new_with_mnemonic (_("_Do not show this message again")); - gtk_container_set_border_width ((GtkContainer *)check, 12); container = gtk_dialog_get_content_area (GTK_DIALOG (mbox)); - gtk_box_pack_start (GTK_BOX (container), check, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (container), check, FALSE, FALSE, 0); gtk_widget_show (check); } -- cgit v1.2.3 From d15d6e8e4144e852788334e5fdaea5180ff48725 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 16 Feb 2011 16:30:35 +0100 Subject: Bug #638391 - Always passing NULL to emu_addr_cancel_book() --- mail/em-utils.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index cea8871887..2fdee28270 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1580,12 +1580,16 @@ emu_addr_setup (gpointer user_data) static void emu_addr_cancel_book (gpointer data) { - EBook *book = data; + EBook **pbook = data; GError *err = NULL; - /* we dunna care if this fails, its just the best we can try */ - e_book_cancel (book, &err); - g_clear_error (&err); + g_return_if_fail (pbook != NULL); + + if (*pbook) { + /* we dunna care if this fails, its just the best we can try */ + e_book_cancel (*pbook, &err); + g_clear_error (&err); + } } static void @@ -1750,7 +1754,7 @@ search_address_in_addressbooks (const gchar *address, gboolean local_only, gbool d(printf(" checking '%s'\n", e_source_get_uri(source))); - hook_book = mail_cancel_hook_add (emu_addr_cancel_book, book); + hook_book = mail_cancel_hook_add (emu_addr_cancel_book, &book); hook_stop = mail_cancel_hook_add (emu_addr_cancel_stop, &stop); book = g_hash_table_lookup (emu_books_hash, e_source_peek_uid (source)); -- cgit v1.2.3 From eac4adfbf61b7f090db0713dbdaa5f4dd081e751 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 3 Mar 2011 14:11:41 +0100 Subject: Bug #643218 - Local delivery doesn't deliver after maildir migration --- mail/em-utils.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 2fdee28270..09692f0b1b 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -2353,3 +2353,27 @@ emu_restore_folder_tree_state (EMFolderTree *folder_tree) g_key_file_free (key_file); } + +/* checks whether uri points to a local mbox file and returns TRUE if yes. */ +gboolean +em_utils_is_local_delivery_mbox_file (const gchar *uri) +{ + g_return_val_if_fail (uri != NULL, FALSE); + + if (g_str_has_prefix (uri, "mbox:///")) { + CamelURL *curl; + + curl = camel_url_new (uri, NULL); + if (curl) { + if (curl->path + && g_file_test (curl->path, G_FILE_TEST_EXISTS) + && !g_file_test (curl->path, G_FILE_TEST_IS_DIR)) { + camel_url_free (curl); + return TRUE; + } + camel_url_free (curl); + } + } + + return FALSE; +} -- cgit v1.2.3 From 7aacf983b32ecac26bc9707697da622b3ef164a3 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 5 Mar 2011 12:33:49 -0500 Subject: Coding style and whitespace cleanup. --- mail/em-utils.c | 151 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 110 insertions(+), 41 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 09692f0b1b..15008abd51 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -317,21 +317,28 @@ em_utils_edit_filters (GtkWidget *parent, em_filter_source_element_names[1].name = _("Outgoing"); } - filter_editor = (GtkWidget *) em_filter_editor_new (fc, em_filter_source_element_names); + filter_editor = (GtkWidget *) em_filter_editor_new ( + fc, em_filter_source_element_names); if (parent != NULL) gtk_window_set_transient_for ( GTK_WINDOW (filter_editor), GTK_WINDOW (parent)); - gtk_window_set_title (GTK_WINDOW (filter_editor), _("Message Filters")); - g_object_set_data_full ((GObject *) filter_editor, "context", fc, (GDestroyNotify) g_object_unref); - g_signal_connect (filter_editor, "response", G_CALLBACK (em_filter_editor_response), NULL); + gtk_window_set_title ( + GTK_WINDOW (filter_editor), _("Message Filters")); + g_object_set_data_full ( + G_OBJECT (filter_editor), "context", fc, + (GDestroyNotify) g_object_unref); + g_signal_connect ( + filter_editor, "response", + G_CALLBACK (em_filter_editor_response), NULL); gtk_widget_show (GTK_WIDGET (filter_editor)); } /* * Picked this from e-d-s/libedataserver/e-data. - * But it allows more characters to occur in filenames, especially when saving attachment. + * But it allows more characters to occur in filenames, especially + * when saving attachment. */ void em_filename_make_safe (gchar *string) @@ -491,7 +498,9 @@ exit: * @folder and @uids. **/ void -em_utils_flag_for_followup_clear (GtkWindow *parent, CamelFolder *folder, GPtrArray *uids) +em_utils_flag_for_followup_clear (GtkWindow *parent, + CamelFolder *folder, + GPtrArray *uids) { gint i; @@ -527,7 +536,9 @@ em_utils_flag_for_followup_clear (GtkWindow *parent, CamelFolder *folder, GPtrAr * Flag-for-Followup. **/ void -em_utils_flag_for_followup_completed (GtkWindow *parent, CamelFolder *folder, GPtrArray *uids) +em_utils_flag_for_followup_completed (GtkWindow *parent, + CamelFolder *folder, + GPtrArray *uids) { gchar *now; gint i; @@ -558,10 +569,13 @@ em_utils_flag_for_followup_completed (GtkWindow *parent, CamelFolder *folder, GP em_utils_uids_free (uids); } -/* This kind of sucks, because for various reasons most callers need to run synchronously - in the gui thread, however this could take a long, blocking time, to run */ +/* This kind of sucks, because for various reasons most callers need to run + * synchronously in the gui thread, however this could take a long, blocking + * time to run. */ static gint -em_utils_write_messages_to_stream (CamelFolder *folder, GPtrArray *uids, CamelStream *stream) +em_utils_write_messages_to_stream (CamelFolder *folder, + GPtrArray *uids, + CamelStream *stream) { CamelStream *filtered_stream; CamelMimeFilter *from_filter; @@ -585,13 +599,17 @@ em_utils_write_messages_to_stream (CamelFolder *folder, GPtrArray *uids, CamelSt break; } - /* we need to flush after each stream write since we are writing to the same stream */ + /* We need to flush after each stream write since we are + * writing to the same stream. */ from = camel_mime_message_build_mbox_from (message); if (camel_stream_write_string (stream, from, NULL, NULL) == -1 || camel_stream_flush (stream, NULL, NULL) == -1 - || camel_data_wrapper_write_to_stream_sync ((CamelDataWrapper *)message, (CamelStream *)filtered_stream, NULL, NULL) == -1 - || camel_stream_flush ((CamelStream *)filtered_stream, NULL, NULL) == -1) + || camel_data_wrapper_write_to_stream_sync ( + (CamelDataWrapper *) message, (CamelStream *) + filtered_stream, NULL, NULL) == -1 + || camel_stream_flush ( + (CamelStream *) filtered_stream, NULL, NULL) == -1) res = -1; g_free (from); @@ -606,10 +624,12 @@ em_utils_write_messages_to_stream (CamelFolder *folder, GPtrArray *uids, CamelSt return res; } -/* This kind of sucks, because for various reasons most callers need to run synchronously - in the gui thread, however this could take a long, blocking time, to run */ +/* This kind of sucks, because for various reasons most callers need to run + * synchronously in the gui thread, however this could take a long, blocking + * time to run. */ static gint -em_utils_read_messages_from_stream (CamelFolder *folder, CamelStream *stream) +em_utils_read_messages_from_stream (CamelFolder *folder, + CamelStream *stream) { CamelMimeParser *mp = camel_mime_parser_new (); gboolean success = TRUE; @@ -854,7 +874,9 @@ em_utils_selection_get_uidlist (GtkSelectionData *selection_data, * up when the application quits. **/ void -em_utils_selection_set_urilist (GtkSelectionData *data, CamelFolder *folder, GPtrArray *uids) +em_utils_selection_set_urilist (GtkSelectionData *data, + CamelFolder *folder, + GPtrArray *uids) { gchar *tmpdir; CamelStream *fstream; @@ -1301,7 +1323,8 @@ em_utils_message_to_html (CamelMimeMessage *message, /* FIXME: we should be getting this from the current view, not the global setting. */ gconf = gconf_client_get_default (); - charset = gconf_client_get_string (gconf, "/apps/evolution/mail/display/charset", NULL); + charset = gconf_client_get_string ( + gconf, "/apps/evolution/mail/display/charset", NULL); em_format_set_default_charset ((EMFormat *) emfq, charset); g_object_unref (gconf); g_free (charset); @@ -1367,7 +1390,9 @@ em_utils_empty_trash (GtkWidget *parent, g_return_if_fail (E_IS_MAIL_SESSION (session)); - if (!em_utils_prompt_user((GtkWindow *) parent, "/apps/evolution/mail/prompts/empty_trash", "mail:ask-empty-trash", NULL)) + if (!em_utils_prompt_user ((GtkWindow *) parent, + "/apps/evolution/mail/prompts/empty_trash", + "mail:ask-empty-trash", NULL)) return; accounts = e_get_account_list (); @@ -1647,11 +1672,15 @@ try_open_e_book (EBook *book, gboolean only_if_exists, GError **error) if (!e_book_open_async (book, only_if_exists, try_open_e_book_cb, &data)) { e_flag_free (flag); g_clear_error (error); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_OTHER_ERROR, "Failed to call e_book_open_async."); + g_set_error ( + error, E_BOOK_ERROR, + E_BOOK_ERROR_OTHER_ERROR, + "Failed to call e_book_open_async."); return FALSE; } - while (canceled = camel_operation_cancel_check (NULL), !canceled && !e_flag_is_set (flag)) { + while (canceled = camel_operation_cancel_check (NULL), + !canceled && !e_flag_is_set (flag)) { GTimeVal wait; g_get_current_time (&wait); @@ -1662,9 +1691,13 @@ try_open_e_book (EBook *book, gboolean only_if_exists, GError **error) if (canceled) { g_clear_error (error); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED, "Operation has been canceled."); - /* if the operation is cancelled sucessfully set the flag else wait. file, groupwise,.. backend's operations - are not cancellable */ + g_set_error ( + error, E_BOOK_ERROR, + E_BOOK_ERROR_CANCELLED, + "Operation has been canceled."); + /* if the operation is cancelled sucessfully set the flag + * else wait. file, groupwise,.. backend's operations + * are not cancellable */ if (e_book_cancel_async_op (book, NULL)) e_flag_set (flag); } @@ -1678,13 +1711,26 @@ try_open_e_book (EBook *book, gboolean only_if_exists, GError **error) #define NOT_FOUND_BOOK (GINT_TO_POINTER (1)) G_LOCK_DEFINE_STATIC (contact_cache); -static GHashTable *contact_cache = NULL; /* key is lowercased contact email; value is EBook pointer (just for comparison) where it comes from */ -static GHashTable *emu_books_hash = NULL; /* key is source ID; value is pointer to EBook */ -static GHashTable *emu_broken_books_hash = NULL; /* key is source ID; value is same pointer as key; this is hash of broken books, which failed to open for some reason */ + +/* key is lowercased contact email; value is EBook pointer + * (just for comparison) where it comes from */ +static GHashTable *contact_cache = NULL; + +/* key is source ID; value is pointer to EBook */ +static GHashTable *emu_books_hash = NULL; + +/* key is source ID; value is same pointer as key; this is hash of + * broken books, which failed to open for some reason */ +static GHashTable *emu_broken_books_hash = NULL; + static ESourceList *emu_books_source_list = NULL; static gboolean -search_address_in_addressbooks (const gchar *address, gboolean local_only, gboolean (*check_contact) (EContact *contact, gpointer user_data), gpointer user_data) +search_address_in_addressbooks (const gchar *address, + gboolean local_only, + gboolean (*check_contact) (EContact *contact, + gpointer user_data), + gpointer user_data) { gboolean found = FALSE, stop = FALSE, found_any = FALSE; gchar *lowercase_addr; @@ -1698,10 +1744,15 @@ search_address_in_addressbooks (const gchar *address, gboolean local_only, gbool G_LOCK (contact_cache); if (!emu_books_source_list) { - mail_call_main (MAIL_CALL_p_p, (MailMainFunc)emu_addr_setup, &emu_books_source_list); - emu_books_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); - emu_broken_books_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - contact_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + mail_call_main ( + MAIL_CALL_p_p, (MailMainFunc) + emu_addr_setup, &emu_books_source_list); + emu_books_hash = g_hash_table_new_full ( + g_str_hash, g_str_equal, g_free, g_object_unref); + emu_broken_books_hash = g_hash_table_new_full ( + g_str_hash, g_str_equal, g_free, NULL); + contact_cache = g_hash_table_new_full ( + g_str_hash, g_str_equal, g_free, NULL); } if (!emu_books_source_list) { @@ -1725,7 +1776,9 @@ search_address_in_addressbooks (const gchar *address, gboolean local_only, gbool if (!group) continue; - if (local_only && !(e_source_group_peek_base_uri (group) && g_str_has_prefix (e_source_group_peek_base_uri (group), "local:"))) + if (local_only && !(e_source_group_peek_base_uri (group) && + g_str_has_prefix ( + e_source_group_peek_base_uri (group), "local:"))) continue; for (s = e_source_group_peek_sources (group); s; s = g_slist_next (s)) { @@ -1747,8 +1800,10 @@ search_address_in_addressbooks (const gchar *address, gboolean local_only, gbool GError *err = NULL; /* failed to load this book last time, skip it now */ - if (g_hash_table_lookup (emu_broken_books_hash, e_source_peek_uid (source)) != NULL) { - d(printf ("%s: skipping broken book '%s'\n", G_STRFUNC, e_source_peek_name (source))); + if (g_hash_table_lookup (emu_broken_books_hash, + e_source_peek_uid (source)) != NULL) { + d(printf ("%s: skipping broken book '%s'\n", + G_STRFUNC, e_source_peek_name (source))); continue; } @@ -1769,7 +1824,10 @@ search_address_in_addressbooks (const gchar *address, gboolean local_only, gbool g_hash_table_insert (emu_broken_books_hash, source_uid, source_uid); - g_warning ("%s: Unable to create addressbook '%s': %s", G_STRFUNC, e_source_peek_name (source), err->message); + g_warning ( + "%s: Unable to create addressbook '%s': %s", + G_STRFUNC, e_source_peek_name (source), + err->message); } g_clear_error (&err); } else if (!stop && !try_open_e_book (book, TRUE, &err)) { @@ -1783,7 +1841,10 @@ search_address_in_addressbooks (const gchar *address, gboolean local_only, gbool g_hash_table_insert (emu_broken_books_hash, source_uid, source_uid); - g_warning ("%s: Unable to open addressbook '%s': %s", G_STRFUNC, e_source_peek_name (source), err->message); + g_warning ( + "%s: Unable to open addressbook '%s': %s", + G_STRFUNC, e_source_peek_name (source), + err->message); } g_clear_error (&err); } @@ -1820,7 +1881,10 @@ search_address_in_addressbooks (const gchar *address, gboolean local_only, gbool g_hash_table_insert (emu_broken_books_hash, source_uid, source_uid); - g_warning ("%s: Can't get contacts from '%s': %s", G_STRFUNC, e_source_peek_name (source), err->message); + g_warning ( + "%s: Can't get contacts from '%s': %s", + G_STRFUNC, e_source_peek_name (source), + err->message); } g_clear_error (&err); } @@ -1937,7 +2001,8 @@ em_utils_contact_photo (CamelInternetAddress *cia, gboolean local_only) } /* !p means the address had not been found in the cache */ - if (!p && search_address_in_addressbooks (addr, local_only, extract_photo_data, &photo)) { + if (!p && search_address_in_addressbooks ( + addr, local_only, extract_photo_data, &photo)) { PhotoInfo *pi; if (photo && photo->type != E_CONTACT_PHOTO_TYPE_INLINED) { @@ -2034,7 +2099,8 @@ emu_remove_from_mail_cache_1 (const gchar *address) g_slist_free (l); } -/* frees all data created by call of em_utils_in_addressbook or em_utils_contact_photo */ +/* frees all data created by call of em_utils_in_addressbook() or + * em_utils_contact_photo() */ void emu_free_mail_cache (void) { @@ -2190,7 +2256,10 @@ em_utils_generate_account_hash (void) } if (!acnt) - g_hash_table_insert (account_hash, (gchar *) account->id->address, (gpointer) account); + g_hash_table_insert ( + account_hash, (gchar *) + account->id->address, + (gpointer) account); } e_iterator_next (iter); -- cgit v1.2.3 From eccfd921ed7a7017cf3b893c9146c4ee0438d86b Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 24 Mar 2011 16:47:53 -0400 Subject: Fix alignment of extra widgets in EAlertDialogs. Add e_alert_dialog_get_content_area(), which returns the GtkVBox containing the primary and secondary labels. Use this instead of gtk_dialog_get_content_area() to maintain the dialog's left margin beneath the image. --- mail/em-utils.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 15008abd51..e674c61528 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -128,7 +128,8 @@ em_utils_prompt_user (GtkWindow *parent, const gchar *tag, ...) { - GtkWidget *mbox, *check = NULL; + GtkWidget *dialog; + GtkWidget *check = NULL; GtkWidget *container; va_list ap; gint button; @@ -146,24 +147,27 @@ em_utils_prompt_user (GtkWindow *parent, alert = e_alert_new_valist (tag, ap); va_end (ap); - mbox = e_alert_dialog_new (parent, alert); + dialog = e_alert_dialog_new (parent, alert); g_object_unref (alert); + container = e_alert_dialog_get_content_area (E_ALERT_DIALOG (dialog)); + if (promptkey) { - check = gtk_check_button_new_with_mnemonic (_("_Do not show this message again")); - container = gtk_dialog_get_content_area (GTK_DIALOG (mbox)); - gtk_box_pack_start (GTK_BOX (container), check, FALSE, FALSE, 0); + check = gtk_check_button_new_with_mnemonic ( + _("_Do not show this message again")); + gtk_box_pack_start ( + GTK_BOX (container), check, FALSE, FALSE, 0); gtk_widget_show (check); } - button = gtk_dialog_run ((GtkDialog *) mbox); + button = gtk_dialog_run (GTK_DIALOG (dialog)); if (promptkey) gconf_client_set_bool ( client, promptkey, !gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON (check)), NULL); - gtk_widget_destroy (mbox); + gtk_widget_destroy (dialog); g_object_unref (client); -- cgit v1.2.3 From f31b492945408f038ae16a099900631ae9714912 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 17 Apr 2011 13:13:55 -0400 Subject: Adapt to sealed up CamelService. --- mail/em-utils.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index e674c61528..7ebe28c11e 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -2203,12 +2203,14 @@ guess_account_from_folder (CamelFolder *folder) CamelService *service; CamelStore *parent_store; EAccount *account; + CamelURL *url; gchar *source_url; parent_store = camel_folder_get_parent_store (folder); service = CAMEL_SERVICE (parent_store); - source_url = camel_url_to_string (service->url, CAMEL_URL_HIDE_ALL); + url = camel_service_get_camel_url (service); + source_url = camel_url_to_string (url, CAMEL_URL_HIDE_ALL); account = e_get_account_by_source_url (source_url); g_free (source_url); -- cgit v1.2.3 From 0be9b1f878c2f54a0c7f2f5024125813022d81b1 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 20 Apr 2011 19:06:35 -0400 Subject: Adapt to CamelService changes. --- mail/em-utils.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 7ebe28c11e..cee383b467 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -2429,26 +2429,14 @@ emu_restore_folder_tree_state (EMFolderTree *folder_tree) g_key_file_free (key_file); } -/* checks whether uri points to a local mbox file and returns TRUE if yes. */ +/* Returns TRUE if CamelURL points to a local mbox file. */ gboolean -em_utils_is_local_delivery_mbox_file (const gchar *uri) +em_utils_is_local_delivery_mbox_file (CamelURL *url) { - g_return_val_if_fail (uri != NULL, FALSE); - - if (g_str_has_prefix (uri, "mbox:///")) { - CamelURL *curl; - - curl = camel_url_new (uri, NULL); - if (curl) { - if (curl->path - && g_file_test (curl->path, G_FILE_TEST_EXISTS) - && !g_file_test (curl->path, G_FILE_TEST_IS_DIR)) { - camel_url_free (curl); - return TRUE; - } - camel_url_free (curl); - } - } + g_return_val_if_fail (url != NULL, FALSE); - return FALSE; + return g_str_has_prefix (url->protocol, "mbox:") && + (url->path != NULL) && + g_file_test (url->path, G_FILE_TEST_EXISTS) && + !g_file_test (url->path, G_FILE_TEST_IS_DIR); } -- cgit v1.2.3 From b35467f9a3f759aee84e3f4f5759856ac3f40799 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 3 May 2011 06:46:38 -0400 Subject: em-utils.c: Coding style cleanups. --- mail/em-utils.c | 137 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 71 insertions(+), 66 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index cee383b467..13b55eddae 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -989,7 +989,8 @@ em_utils_selection_get_urilist (GtkSelectionData *selection_data, g_strfreev (uris); } -/** em_utils_folder_is_templates: +/** + * em_utils_folder_is_templates: * @folder: folder * @uri: uri for this folder, if known * @@ -1003,9 +1004,9 @@ em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri) { CamelFolder *local_templates_folder; CamelStore *parent_store; - EAccountList *accounts; + EAccountList *account_list; EAccount *account; - EIterator *iter; + EIterator *iterator; gint is = FALSE; gchar *templates_uri; @@ -1020,10 +1021,11 @@ em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri) parent_store = camel_folder_get_parent_store (folder); - accounts = e_get_account_list (); - iter = e_list_get_iterator ((EList *)accounts); - while (e_iterator_is_valid (iter)) { - account = (EAccount *)e_iterator_get (iter); + account_list = e_get_account_list (); + iterator = e_list_get_iterator (E_LIST (account_list)); + + while (e_iterator_is_valid (iterator)) { + account = (EAccount *)e_iterator_get (iterator); if (account->templates_folder_uri) { templates_uri = em_uri_to_camel (account->templates_folder_uri); @@ -1035,10 +1037,10 @@ em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri) g_free (templates_uri); } - e_iterator_next (iter); + e_iterator_next (iterator); } - g_object_unref (iter); + g_object_unref (iterator); return is; } @@ -1057,9 +1059,9 @@ em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri) { CamelFolder *local_drafts_folder; CamelStore *parent_store; - EAccountList *accounts; + EAccountList *account_list; EAccount *account; - EIterator *iter; + EIterator *iterator; gint is = FALSE; gchar *drafts_uri; @@ -1074,10 +1076,11 @@ em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri) parent_store = camel_folder_get_parent_store (folder); - accounts = e_get_account_list (); - iter = e_list_get_iterator ((EList *)accounts); - while (e_iterator_is_valid (iter)) { - account = (EAccount *)e_iterator_get (iter); + account_list = e_get_account_list (); + iterator = e_list_get_iterator (E_LIST (account_list)); + + while (e_iterator_is_valid (iterator)) { + account = (EAccount *)e_iterator_get (iterator); if (account->drafts_folder_uri) { drafts_uri = em_uri_to_camel (account->drafts_folder_uri); @@ -1089,10 +1092,10 @@ em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri) g_free (drafts_uri); } - e_iterator_next (iter); + e_iterator_next (iterator); } - g_object_unref (iter); + g_object_unref (iterator); return is; } @@ -1111,9 +1114,9 @@ em_utils_folder_is_sent (CamelFolder *folder, const gchar *uri) { CamelFolder *local_sent_folder; CamelStore *parent_store; - EAccountList *accounts; + EAccountList *account_list; EAccount *account; - EIterator *iter; + EIterator *iterator; gint is = FALSE; gchar *sent_uri; @@ -1127,10 +1130,11 @@ em_utils_folder_is_sent (CamelFolder *folder, const gchar *uri) parent_store = camel_folder_get_parent_store (folder); - accounts = e_get_account_list (); - iter = e_list_get_iterator ((EList *)accounts); - while (e_iterator_is_valid (iter)) { - account = (EAccount *)e_iterator_get (iter); + account_list = e_get_account_list (); + iterator = e_list_get_iterator (E_LIST (account_list)); + + while (e_iterator_is_valid (iterator)) { + account = (EAccount *)e_iterator_get (iterator); if (account->sent_folder_uri) { sent_uri = em_uri_to_camel (account->sent_folder_uri); @@ -1142,10 +1146,10 @@ em_utils_folder_is_sent (CamelFolder *folder, const gchar *uri) g_free (sent_uri); } - e_iterator_next (iter); + e_iterator_next (iterator); } - g_object_unref (iter); + g_object_unref (iterator); return is; } @@ -1388,9 +1392,9 @@ em_utils_empty_trash (GtkWidget *parent, EMailSession *session) { CamelProvider *provider; - EAccountList *accounts; + EAccountList *account_list; EAccount *account; - EIterator *iter; + EIterator *iterator; g_return_if_fail (E_IS_MAIL_SESSION (session)); @@ -1399,10 +1403,11 @@ em_utils_empty_trash (GtkWidget *parent, "mail:ask-empty-trash", NULL)) return; - accounts = e_get_account_list (); - iter = e_list_get_iterator ((EList *) accounts); - while (e_iterator_is_valid (iter)) { - account = (EAccount *) e_iterator_get (iter); + account_list = e_get_account_list (); + iterator = e_list_get_iterator (E_LIST (account_list)); + + while (e_iterator_is_valid (iterator)) { + account = (EAccount *) e_iterator_get (iterator); /* make sure this is a valid source */ if (account->enabled && account->source->url) { @@ -1415,10 +1420,10 @@ em_utils_empty_trash (GtkWidget *parent, } } - e_iterator_next (iter); + e_iterator_next (iterator); } - g_object_unref (iter); + g_object_unref (iterator); /* Now empty the local trash folder */ mail_empty_trash (session, NULL, NULL, NULL); @@ -1506,7 +1511,7 @@ gchar *em_uri_from_camel (const gchar *curi) gchar *em_uri_to_camel (const gchar *euri) { - EAccountList *accounts; + EAccountList *account_list; const EAccount *account; EAccountService *service; CamelProvider *provider; @@ -1560,8 +1565,8 @@ gchar *em_uri_to_camel (const gchar *euri) uid = g_strdup (eurl->host); } - accounts = e_get_account_list (); - account = e_account_list_find (accounts, E_ACCOUNT_FIND_UID, uid); + account_list = e_get_account_list (); + account = e_account_list_find (account_list, E_ACCOUNT_FIND_UID, uid); g_free (uid); if (account == NULL) { @@ -2144,26 +2149,24 @@ emu_free_mail_cache (void) void em_utils_clear_get_password_canceled_accounts_flag (void) { - EAccountList *accounts; - - accounts = e_get_account_list (); - if (accounts) { - EIterator *iter; + EAccountList *account_list; + EIterator *iterator; - for (iter = e_list_get_iterator ((EList *) accounts); - e_iterator_is_valid (iter); - e_iterator_next (iter)) { - EAccount *account = (EAccount *) e_iterator_get (iter); + account_list = e_get_account_list (); - if (account && account->source) - account->source->get_password_canceled = FALSE; + for (iterator = e_list_get_iterator (E_LIST (account_list)); + e_iterator_is_valid (iterator); + e_iterator_next (iterator)) { + EAccount *account = (EAccount *) e_iterator_get (iterator); - if (account && account->transport) - account->transport->get_password_canceled = FALSE; - } + if (account && account->source) + account->source->get_password_canceled = FALSE; - g_object_unref (iter); + if (account && account->transport) + account->transport->get_password_canceled = FALSE; } + + g_object_unref (iterator); } gchar * @@ -2234,17 +2237,18 @@ em_utils_generate_account_hash (void) { GHashTable *account_hash; EAccount *account, *def; - EAccountList *accounts; - EIterator *iter; + EAccountList *account_list; + EIterator *iterator; - accounts = e_get_account_list (); + account_list = e_get_account_list (); account_hash = g_hash_table_new (camel_strcase_hash, camel_strcase_equal); def = e_get_default_account (); - iter = e_list_get_iterator ((EList *) accounts); - while (e_iterator_is_valid (iter)) { - account = (EAccount *) e_iterator_get (iter); + iterator = e_list_get_iterator (E_LIST (account_list)); + + while (e_iterator_is_valid (iterator)) { + account = (EAccount *) e_iterator_get (iterator); if (account->id->address) { EAccount *acnt; @@ -2268,10 +2272,10 @@ em_utils_generate_account_hash (void) (gpointer) account); } - e_iterator_next (iter); + e_iterator_next (iterator); } - g_object_unref (iter); + g_object_unref (iterator); /* The default account has to be there if none of the enabled accounts are present */ if (g_hash_table_size (account_hash) == 0 && def && def->id->address) @@ -2314,7 +2318,7 @@ em_utils_guess_account_with_recipients (CamelMimeMessage *message, EAccount *account = NULL; EAccountList *account_list; GHashTable *recipients; - EIterator *iter; + EIterator *iterator; CamelInternetAddress *addr; const gchar *type; const gchar *key; @@ -2372,10 +2376,11 @@ second_preference: * address appears in the list to To: or Cc: recipients. */ account_list = e_get_account_list (); - iter = e_list_get_iterator (E_LIST (account_list)); - while (e_iterator_is_valid (iter)) { - account = (EAccount *) e_iterator_get (iter); - e_iterator_next (iter); + iterator = e_list_get_iterator (E_LIST (account_list)); + + while (e_iterator_is_valid (iterator)) { + account = (EAccount *) e_iterator_get (iterator); + e_iterator_next (iterator); if (account == NULL || !account->enabled) continue; @@ -2384,11 +2389,11 @@ second_preference: continue; if (g_hash_table_lookup (recipients, key) != NULL) { - g_object_unref (iter); + g_object_unref (iterator); goto exit; } } - g_object_unref (iter); + g_object_unref (iterator); /* Last Preference: Defer to em_utils_guess_account(). */ account = em_utils_guess_account (message, folder); -- cgit v1.2.3 From 59958c9906eade7264d8564e5448c2b1bea2503d Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 3 May 2011 07:06:10 -0400 Subject: Replace camel_store_folder_uri_equal() with e_mail_folder_uri_equal(). --- mail/em-utils.c | 82 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 38 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 13b55eddae..ecd787c63b 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -70,6 +70,7 @@ #include "em-utils.h" #include "em-composer-utils.h" #include "em-format-quote.h" +#include "e-mail-folder-utils.h" #include "e-mail-local.h" #include "e-mail-session.h" @@ -230,7 +231,7 @@ em_utils_check_user_can_send_mail (void) account_list = e_get_account_list (); - if (e_list_length ((EList *) account_list) == 0) + if (e_list_length (E_LIST (account_list)) == 0) return FALSE; if (!(account = e_get_default_account ())) @@ -1003,11 +1004,12 @@ gboolean em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri) { CamelFolder *local_templates_folder; - CamelStore *parent_store; + CamelSession *session; + CamelStore *store; EAccountList *account_list; EAccount *account; EIterator *iterator; - gint is = FALSE; + gint is_templates = FALSE; gchar *templates_uri; local_templates_folder = @@ -1019,21 +1021,20 @@ em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri) if (folder == NULL || uri == NULL) return FALSE; - parent_store = camel_folder_get_parent_store (folder); + store = camel_folder_get_parent_store (folder); + session = camel_service_get_session (CAMEL_SERVICE (store)); account_list = e_get_account_list (); iterator = e_list_get_iterator (E_LIST (account_list)); - while (e_iterator_is_valid (iterator)) { + while (!is_templates && e_iterator_is_valid (iterator)) { account = (EAccount *)e_iterator_get (iterator); if (account->templates_folder_uri) { - templates_uri = em_uri_to_camel (account->templates_folder_uri); - if (camel_store_folder_uri_equal (parent_store, templates_uri, uri)) { - g_free (templates_uri); - is = TRUE; - break; - } + templates_uri = em_uri_to_camel ( + account->templates_folder_uri); + is_templates = e_mail_folder_uri_equal ( + session, templates_uri, uri); g_free (templates_uri); } @@ -1042,7 +1043,7 @@ em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri) g_object_unref (iterator); - return is; + return is_templates; } /** @@ -1058,11 +1059,12 @@ gboolean em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri) { CamelFolder *local_drafts_folder; - CamelStore *parent_store; + CamelSession *session; + CamelStore *store; EAccountList *account_list; EAccount *account; EIterator *iterator; - gint is = FALSE; + gint is_drafts = FALSE; gchar *drafts_uri; local_drafts_folder = @@ -1074,21 +1076,20 @@ em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri) if (folder == NULL || uri == NULL) return FALSE; - parent_store = camel_folder_get_parent_store (folder); + store = camel_folder_get_parent_store (folder); + session = camel_service_get_session (CAMEL_SERVICE (store)); account_list = e_get_account_list (); iterator = e_list_get_iterator (E_LIST (account_list)); - while (e_iterator_is_valid (iterator)) { + while (!is_drafts && e_iterator_is_valid (iterator)) { account = (EAccount *)e_iterator_get (iterator); if (account->drafts_folder_uri) { - drafts_uri = em_uri_to_camel (account->drafts_folder_uri); - if (camel_store_folder_uri_equal (parent_store, drafts_uri, uri)) { - g_free (drafts_uri); - is = TRUE; - break; - } + drafts_uri = em_uri_to_camel ( + account->drafts_folder_uri); + is_drafts = e_mail_folder_uri_equal ( + session, drafts_uri, uri); g_free (drafts_uri); } @@ -1097,7 +1098,7 @@ em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri) g_object_unref (iterator); - return is; + return is_drafts; } /** @@ -1113,14 +1114,16 @@ gboolean em_utils_folder_is_sent (CamelFolder *folder, const gchar *uri) { CamelFolder *local_sent_folder; - CamelStore *parent_store; + CamelSession *session; + CamelStore *store; EAccountList *account_list; EAccount *account; EIterator *iterator; - gint is = FALSE; + gint is_sent = FALSE; gchar *sent_uri; - local_sent_folder = e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_SENT); + local_sent_folder = + e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_SENT); if (folder == local_sent_folder) return TRUE; @@ -1128,21 +1131,20 @@ em_utils_folder_is_sent (CamelFolder *folder, const gchar *uri) if (folder == NULL || uri == NULL) return FALSE; - parent_store = camel_folder_get_parent_store (folder); + store = camel_folder_get_parent_store (folder); + session = camel_service_get_session (CAMEL_SERVICE (store)); account_list = e_get_account_list (); iterator = e_list_get_iterator (E_LIST (account_list)); - while (e_iterator_is_valid (iterator)) { + while (!is_sent && e_iterator_is_valid (iterator)) { account = (EAccount *)e_iterator_get (iterator); if (account->sent_folder_uri) { - sent_uri = em_uri_to_camel (account->sent_folder_uri); - if (camel_store_folder_uri_equal (parent_store, sent_uri, uri)) { - g_free (sent_uri); - is = TRUE; - break; - } + sent_uri = em_uri_to_camel ( + account->sent_folder_uri); + is_sent = e_mail_folder_uri_equal ( + session, sent_uri, uri); g_free (sent_uri); } @@ -1151,7 +1153,7 @@ em_utils_folder_is_sent (CamelFolder *folder, const gchar *uri) g_object_unref (iterator); - return is; + return is_sent; } /** @@ -1167,6 +1169,8 @@ gboolean em_utils_folder_is_outbox (CamelFolder *folder, const gchar *uri) { CamelFolder *local_outbox_folder; + CamelSession *session; + CamelStore *store; const gchar *local_outbox_folder_uri; local_outbox_folder = @@ -1180,9 +1184,11 @@ em_utils_folder_is_outbox (CamelFolder *folder, const gchar *uri) if (uri == NULL) return FALSE; - return camel_store_folder_uri_equal ( - camel_folder_get_parent_store (local_outbox_folder), - local_outbox_folder_uri, uri); + store = camel_folder_get_parent_store (local_outbox_folder); + session = camel_service_get_session (CAMEL_SERVICE (store)); + + return e_mail_folder_uri_equal ( + session, local_outbox_folder_uri, uri); } /* ********************************************************************** */ -- cgit v1.2.3 From 390555c6a4ff70c6200942b60e51ce8fd444674f Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 3 May 2011 07:50:40 -0400 Subject: em-utils.c: More coding style cleanups. --- mail/em-utils.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index ecd787c63b..448dcf8320 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1007,10 +1007,8 @@ em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri) CamelSession *session; CamelStore *store; EAccountList *account_list; - EAccount *account; EIterator *iterator; gint is_templates = FALSE; - gchar *templates_uri; local_templates_folder = e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_TEMPLATES); @@ -1028,9 +1026,14 @@ em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri) iterator = e_list_get_iterator (E_LIST (account_list)); while (!is_templates && e_iterator_is_valid (iterator)) { - account = (EAccount *)e_iterator_get (iterator); + EAccount *account; + + /* XXX EIterator misuses const. */ + account = (EAccount *) e_iterator_get (iterator); if (account->templates_folder_uri) { + gchar *templates_uri; + templates_uri = em_uri_to_camel ( account->templates_folder_uri); is_templates = e_mail_folder_uri_equal ( @@ -1062,10 +1065,8 @@ em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri) CamelSession *session; CamelStore *store; EAccountList *account_list; - EAccount *account; EIterator *iterator; gint is_drafts = FALSE; - gchar *drafts_uri; local_drafts_folder = e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_DRAFTS); @@ -1083,9 +1084,14 @@ em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri) iterator = e_list_get_iterator (E_LIST (account_list)); while (!is_drafts && e_iterator_is_valid (iterator)) { - account = (EAccount *)e_iterator_get (iterator); + EAccount *account; + + /* XXX EIterator misuses const. */ + account = (EAccount *) e_iterator_get (iterator); if (account->drafts_folder_uri) { + gchar *drafts_uri; + drafts_uri = em_uri_to_camel ( account->drafts_folder_uri); is_drafts = e_mail_folder_uri_equal ( @@ -1117,10 +1123,8 @@ em_utils_folder_is_sent (CamelFolder *folder, const gchar *uri) CamelSession *session; CamelStore *store; EAccountList *account_list; - EAccount *account; EIterator *iterator; gint is_sent = FALSE; - gchar *sent_uri; local_sent_folder = e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_SENT); @@ -1138,9 +1142,14 @@ em_utils_folder_is_sent (CamelFolder *folder, const gchar *uri) iterator = e_list_get_iterator (E_LIST (account_list)); while (!is_sent && e_iterator_is_valid (iterator)) { + EAccount *account; + + /* XXX EIterator misuses const. */ account = (EAccount *)e_iterator_get (iterator); if (account->sent_folder_uri) { + gchar *sent_uri; + sent_uri = em_uri_to_camel ( account->sent_folder_uri); is_sent = e_mail_folder_uri_equal ( -- cgit v1.2.3 From 0341ec5c9eb1394b9de36d53150916c98340861a Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 3 May 2011 07:51:45 -0400 Subject: em-utils.c: Simplify guess_account_from_folder(). --- mail/em-utils.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 448dcf8320..676a0f69db 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -2218,21 +2218,13 @@ em_utils_url_unescape_amp (const gchar *url) static EAccount * guess_account_from_folder (CamelFolder *folder) { - CamelService *service; - CamelStore *parent_store; - EAccount *account; - CamelURL *url; - gchar *source_url; - - parent_store = camel_folder_get_parent_store (folder); - service = CAMEL_SERVICE (parent_store); + CamelStore *store; + const gchar *uid; - url = camel_service_get_camel_url (service); - source_url = camel_url_to_string (url, CAMEL_URL_HIDE_ALL); - account = e_get_account_by_source_url (source_url); - g_free (source_url); + store = camel_folder_get_parent_store (folder); + uid = camel_service_get_uid (CAMEL_SERVICE (store)); - return account; + return e_get_account_by_uid (uid); } static EAccount * -- cgit v1.2.3 From 9cf4104e04ae93c5b1dcb7a5d41accb507cf0199 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 3 May 2011 08:59:35 -0400 Subject: Drop 'folder_uri' param from em_utils_folder_is_drafts(). --- mail/em-utils.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 676a0f69db..ba496dcae9 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1051,22 +1051,24 @@ em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri) /** * em_utils_folder_is_drafts: - * @folder: folder - * @uri: uri for this folder, if known + * @folder: a #CamelFolder * * Decides if @folder is a Drafts folder. * * Returns %TRUE if this is a Drafts folder or %FALSE otherwise. **/ gboolean -em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri) +em_utils_folder_is_drafts (CamelFolder *folder) { CamelFolder *local_drafts_folder; CamelSession *session; CamelStore *store; EAccountList *account_list; EIterator *iterator; - gint is_drafts = FALSE; + gchar *folder_uri; + gboolean is_drafts = FALSE; + + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); local_drafts_folder = e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_DRAFTS); @@ -1074,8 +1076,7 @@ em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri) if (folder == local_drafts_folder) return TRUE; - if (folder == NULL || uri == NULL) - return FALSE; + folder_uri = e_mail_folder_uri_from_folder (folder); store = camel_folder_get_parent_store (folder); session = camel_service_get_session (CAMEL_SERVICE (store)); @@ -1095,7 +1096,7 @@ em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri) drafts_uri = em_uri_to_camel ( account->drafts_folder_uri); is_drafts = e_mail_folder_uri_equal ( - session, drafts_uri, uri); + session, drafts_uri, folder_uri); g_free (drafts_uri); } @@ -1103,6 +1104,7 @@ em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri) } g_object_unref (iterator); + g_free (folder_uri); return is_drafts; } -- cgit v1.2.3 From 7ddf79d7ce01de060de6046a01b7f53f6da78ecc Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 3 May 2011 09:07:26 -0400 Subject: Drop 'folder_uri' param from em_utils_folder_is_templates(). --- mail/em-utils.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index ba496dcae9..86b6b812b1 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -992,23 +992,25 @@ em_utils_selection_get_urilist (GtkSelectionData *selection_data, /** * em_utils_folder_is_templates: - * @folder: folder - * @uri: uri for this folder, if known + * @folder: a #CamelFolder * * Decides if @folder is a Templates folder. * - * Returns %TRUE if this is a Drafts folder or %FALSE otherwise. + * Returns %TRUE if this is a Templates folder or %FALSE otherwise. **/ gboolean -em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri) +em_utils_folder_is_templates (CamelFolder *folder) { CamelFolder *local_templates_folder; CamelSession *session; CamelStore *store; EAccountList *account_list; EIterator *iterator; - gint is_templates = FALSE; + gchar *folder_uri; + gboolean is_templates = FALSE; + + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); local_templates_folder = e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_TEMPLATES); @@ -1016,8 +1018,7 @@ em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri) if (folder == local_templates_folder) return TRUE; - if (folder == NULL || uri == NULL) - return FALSE; + folder_uri = e_mail_folder_uri_from_folder (folder); store = camel_folder_get_parent_store (folder); session = camel_service_get_session (CAMEL_SERVICE (store)); @@ -1037,7 +1038,7 @@ em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri) templates_uri = em_uri_to_camel ( account->templates_folder_uri); is_templates = e_mail_folder_uri_equal ( - session, templates_uri, uri); + session, templates_uri, folder_uri); g_free (templates_uri); } @@ -1045,6 +1046,7 @@ em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri) } g_object_unref (iterator); + g_free (folder_uri); return is_templates; } -- cgit v1.2.3 From bbf5ce3869dbdf1c277ee9d10b07e91fd775502b Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 3 May 2011 09:16:49 -0400 Subject: Drop 'folder_uri' param from em_utils_folder_is_sent(). --- mail/em-utils.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 86b6b812b1..5c8082d6e2 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1113,22 +1113,24 @@ em_utils_folder_is_drafts (CamelFolder *folder) /** * em_utils_folder_is_sent: - * @folder: folder - * @uri: uri for this folder, if known + * @folder: a #CamelFolder * - * Decides if @folder is a Sent folder + * Decides if @folder is a Sent folder. * * Returns %TRUE if this is a Sent folder or %FALSE otherwise. **/ gboolean -em_utils_folder_is_sent (CamelFolder *folder, const gchar *uri) +em_utils_folder_is_sent (CamelFolder *folder) { CamelFolder *local_sent_folder; CamelSession *session; CamelStore *store; EAccountList *account_list; EIterator *iterator; - gint is_sent = FALSE; + gchar *folder_uri; + gboolean is_sent = FALSE; + + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); local_sent_folder = e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_SENT); @@ -1136,8 +1138,7 @@ em_utils_folder_is_sent (CamelFolder *folder, const gchar *uri) if (folder == local_sent_folder) return TRUE; - if (folder == NULL || uri == NULL) - return FALSE; + folder_uri = e_mail_folder_uri_from_folder (folder); store = camel_folder_get_parent_store (folder); session = camel_service_get_session (CAMEL_SERVICE (store)); @@ -1157,7 +1158,7 @@ em_utils_folder_is_sent (CamelFolder *folder, const gchar *uri) sent_uri = em_uri_to_camel ( account->sent_folder_uri); is_sent = e_mail_folder_uri_equal ( - session, sent_uri, uri); + session, sent_uri, folder_uri); g_free (sent_uri); } @@ -1165,6 +1166,7 @@ em_utils_folder_is_sent (CamelFolder *folder, const gchar *uri) } g_object_unref (iterator); + g_free (folder_uri); return is_sent; } -- cgit v1.2.3 From fc1034551ed2daf3040851e818b2798c3c58f4f9 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 3 May 2011 09:40:49 -0400 Subject: Drop 'folder_uri' param from em_utils_folder_is_outbox(). --- mail/em-utils.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 5c8082d6e2..61b5baabc1 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1173,37 +1173,23 @@ em_utils_folder_is_sent (CamelFolder *folder) /** * em_utils_folder_is_outbox: - * @folder: folder - * @uri: uri for this folder, if known + * @folder: a #CamelFolder * - * Decides if @folder is an Outbox folder + * Decides if @folder is an Outbox folder. * * Returns %TRUE if this is an Outbox folder or %FALSE otherwise. **/ gboolean -em_utils_folder_is_outbox (CamelFolder *folder, const gchar *uri) +em_utils_folder_is_outbox (CamelFolder *folder) { CamelFolder *local_outbox_folder; - CamelSession *session; - CamelStore *store; - const gchar *local_outbox_folder_uri; + + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); local_outbox_folder = e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_OUTBOX); - local_outbox_folder_uri = - e_mail_local_get_folder_uri (E_MAIL_LOCAL_FOLDER_OUTBOX); - - if (folder == local_outbox_folder) - return TRUE; - - if (uri == NULL) - return FALSE; - - store = camel_folder_get_parent_store (local_outbox_folder); - session = camel_service_get_session (CAMEL_SERVICE (store)); - return e_mail_folder_uri_equal ( - session, local_outbox_folder_uri, uri); + return (folder == local_outbox_folder); } /* ********************************************************************** */ -- cgit v1.2.3 From 03813da62833a21a78eb18537d5ce8247293ceb4 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 3 May 2011 14:59:38 -0400 Subject: Drop 'folder_uri' member from MessageList. --- mail/em-utils.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 61b5baabc1..9b21fda7ad 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -771,25 +771,27 @@ em_utils_selection_get_message (GtkSelectionData *selection_data, /** * em_utils_selection_set_uidlist: * @selection_data: selection data - * @uri: + * @folder: * @uids: * * Sets a "x-uid-list" format selection data. - * - * FIXME: be nice if this could take a folder argument rather than uri **/ void em_utils_selection_set_uidlist (GtkSelectionData *selection_data, - const gchar *uri, + CamelFolder *folder, GPtrArray *uids) { GByteArray *array = g_byte_array_new (); GdkAtom target; + gchar *folder_uri; gint i; /* format: "uri\0uid1\0uid2\0uid3\0...\0uidn\0" */ - g_byte_array_append (array, (guchar *)uri, strlen (uri)+1); + folder_uri = e_mail_folder_uri_from_folder (folder); + + g_byte_array_append ( + array, (guchar *) folder_uri, strlen (folder_uri) + 1); for (i=0; ilen; i++) g_byte_array_append (array, uids->pdata[i], strlen (uids->pdata[i])+1); @@ -798,6 +800,8 @@ em_utils_selection_set_uidlist (GtkSelectionData *selection_data, gtk_selection_data_set ( selection_data, target, 8, array->data, array->len); g_byte_array_free (array, TRUE); + + g_free (folder_uri); } /** -- cgit v1.2.3 From b1f79dd8d6b78a009a5edd5dfc1597fa2bad7875 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 5 May 2011 13:22:46 +0200 Subject: Bug #627952 - 'Local delivery' mbox's aren't read properly --- mail/em-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 9b21fda7ad..c20649c782 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -2443,7 +2443,7 @@ em_utils_is_local_delivery_mbox_file (CamelURL *url) { g_return_val_if_fail (url != NULL, FALSE); - return g_str_has_prefix (url->protocol, "mbox:") && + return g_str_equal (url->protocol, "mbox") && (url->path != NULL) && g_file_test (url->path, G_FILE_TEST_EXISTS) && !g_file_test (url->path, G_FILE_TEST_IS_DIR); -- cgit v1.2.3 From 9f31ae4e29b72a85f41c886762533436c2618bb1 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 5 May 2011 14:02:48 -0400 Subject: Simplify em_utils_folder_is_templates(). e_mail_folder_uri_equal() uses e_mail_folder_uri_parse() to parse both URIs, so we can just hand it an 'email://' URI directly. --- mail/em-utils.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index c20649c782..1cb1d62492 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1036,15 +1036,10 @@ em_utils_folder_is_templates (CamelFolder *folder) /* XXX EIterator misuses const. */ account = (EAccount *) e_iterator_get (iterator); - if (account->templates_folder_uri) { - gchar *templates_uri; - - templates_uri = em_uri_to_camel ( - account->templates_folder_uri); + if (account->templates_folder_uri != NULL) is_templates = e_mail_folder_uri_equal ( - session, templates_uri, folder_uri); - g_free (templates_uri); - } + session, folder_uri, + account->templates_folder_uri); e_iterator_next (iterator); } -- cgit v1.2.3 From a7b7c8e963e7eba7ba7d1d804652a3b24c401572 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 5 May 2011 14:06:14 -0400 Subject: Simplify em_utils_folder_is_drafts(). e_mail_folder_uri_equal() uses e_mail_folder_uri_parse() to parse both URIs, so we can just hand it an 'email://' URI directly. --- mail/em-utils.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 1cb1d62492..7efa1df32c 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1091,15 +1091,10 @@ em_utils_folder_is_drafts (CamelFolder *folder) /* XXX EIterator misuses const. */ account = (EAccount *) e_iterator_get (iterator); - if (account->drafts_folder_uri) { - gchar *drafts_uri; - - drafts_uri = em_uri_to_camel ( - account->drafts_folder_uri); + if (account->drafts_folder_uri != NULL) is_drafts = e_mail_folder_uri_equal ( - session, drafts_uri, folder_uri); - g_free (drafts_uri); - } + session, folder_uri, + account->drafts_folder_uri); e_iterator_next (iterator); } -- cgit v1.2.3 From d5d1b84135d21f739d074d174e28541fcd3a0fc8 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 5 May 2011 14:07:33 -0400 Subject: Simplify em_utils_folder_is_sent(). e_mail_folder_uri_equal() uses e_mail_folder_uri_parse() to parse both URIs, so we can just hand it an 'email://' URI directly. --- mail/em-utils.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 7efa1df32c..14a8706c21 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1144,17 +1144,12 @@ em_utils_folder_is_sent (CamelFolder *folder) EAccount *account; /* XXX EIterator misuses const. */ - account = (EAccount *)e_iterator_get (iterator); - - if (account->sent_folder_uri) { - gchar *sent_uri; + account = (EAccount *) e_iterator_get (iterator); - sent_uri = em_uri_to_camel ( - account->sent_folder_uri); + if (account->sent_folder_uri != NULL) is_sent = e_mail_folder_uri_equal ( - session, sent_uri, folder_uri); - g_free (sent_uri); - } + session, folder_uri, + account->sent_folder_uri); e_iterator_next (iterator); } -- cgit v1.2.3 From d974246473c9e511c01658f2c3f618755d6a514a Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 5 May 2011 18:38:31 -0400 Subject: Remove em_uri_from_camel() and em_uri_to_camel(). Functions are no longer used, or wanted. --- mail/em-utils.c | 142 -------------------------------------------------------- 1 file changed, 142 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 14a8706c21..81a702ce6b 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1450,148 +1450,6 @@ em_utils_folder_name_from_uri (const gchar *uri) return folder_name; } -/* email: uri's are based on the account, with special cases for local - * stores, vfolder and local mail. - * e.g. - * imap account imap://user@host/ -> email://accountid@accountid.host/ - * vfolder vfolder:/storage/path#folder -> email://vfolder@local/folder - * local local:/storage/path#folder -> email://local@local/folder - */ - -gchar *em_uri_from_camel (const gchar *curi) -{ - CamelURL *curl; - EAccount *account; - const gchar *uid, *path; - gchar *euri, *tmp; - CamelProvider *provider; - - /* Easiest solution to code that shouldnt be calling us */ - if (!strncmp(curi, "email:", 6)) - return g_strdup (curi); - - provider = camel_provider_get (curi, NULL); - if (provider == NULL) { - d(printf("em uri from camel failed '%s'\n", curi)); - return g_strdup (curi); - } - - curl = camel_url_new (curi, NULL); - if (curl == NULL) - return g_strdup (curi); - - if (strcmp(curl->protocol, "vfolder") == 0) - uid = "vfolder@local"; - else if ((account = e_get_account_by_source_url (curi)) == NULL) - uid = "local@local"; - else - uid = account->uid; - path = (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH)?curl->fragment:curl->path; - if (path) { - if (path[0] == '/') - path++; - - tmp = camel_url_encode(path, ";?"); - euri = g_strdup_printf("email://%s/%s", uid, tmp); - g_free (tmp); - } else { - euri = g_strdup_printf("email://%s/", uid); - } - - d(printf("em uri from camel '%s' -> '%s'\n", curi, euri)); - - camel_url_free (curl); - - return euri; -} - -gchar *em_uri_to_camel (const gchar *euri) -{ - EAccountList *account_list; - const EAccount *account; - EAccountService *service; - CamelProvider *provider; - CamelURL *eurl, *curl; - gchar *uid, *curi; - - if (strncmp(euri, "email:", 6) != 0) { - d(printf("em uri to camel not euri '%s'\n", euri)); - return g_strdup (euri); - } - - eurl = camel_url_new (euri, NULL); - if (eurl == NULL) - return g_strdup (euri); - - g_return_val_if_fail (eurl->host != NULL, g_strdup (euri)); - - if (eurl->user != NULL) { - /* Sigh, shoul'dve used mbox@local for mailboxes, not local@local */ - if (strcmp(eurl->host, "local") == 0 - && (strcmp(eurl->user, "local") == 0 || strcmp(eurl->user, "vfolder") == 0)) { - gchar *base; - - if (strcmp(eurl->user, "vfolder") == 0) - curl = camel_url_new("vfolder:", NULL); - else - curl = camel_url_new("maildir:", NULL); - - base = g_strdup_printf("%s/mail/%s", e_get_user_data_dir(), eurl->user); -#ifdef G_OS_WIN32 - /* Turn backslashes into slashes to avoid URI encoding */ - { - gchar *p = base; - while ((p = strchr (p, '\\'))) - *p++ = '/'; - } -#endif - camel_url_set_path (curl, base); - g_free (base); - camel_url_set_fragment (curl, eurl->path[0]=='/'?eurl->path+1:eurl->path); - curi = camel_url_to_string (curl, 0); - camel_url_free (curl); - camel_url_free (eurl); - - d(printf("em uri to camel local '%s' -> '%s'\n", euri, curi)); - return curi; - } - - uid = g_strdup_printf("%s@%s", eurl->user, eurl->host); - } else { - uid = g_strdup (eurl->host); - } - - account_list = e_get_account_list (); - account = e_account_list_find (account_list, E_ACCOUNT_FIND_UID, uid); - g_free (uid); - - if (account == NULL) { - camel_url_free (eurl); - d(printf("em uri to camel no account '%s' -> '%s'\n", euri, euri)); - return g_strdup (euri); - } - - service = account->source; - provider = camel_provider_get (service->url, NULL); - if (provider == NULL) - return g_strdup (euri); - - curl = camel_url_new (service->url, NULL); - if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) - camel_url_set_fragment (curl, eurl->path[0]=='/'?eurl->path+1:eurl->path); - else - camel_url_set_path (curl, eurl->path); - - curi = camel_url_to_string (curl, 0); - - camel_url_free (eurl); - camel_url_free (curl); - - d(printf("em uri to camel '%s' -> '%s'\n", euri, curi)); - - return curi; -} - /* ********************************************************************** */ /* runs sync, in main thread */ -- cgit v1.2.3 From df96db8f36adee8760fc728ee512391638170ab0 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 6 May 2011 11:31:29 -0400 Subject: Adapt to X-Evolution-Source headers storing UIDs. --- mail/em-utils.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 81a702ce6b..07957ec456 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -2069,13 +2069,11 @@ guess_account_from_folder (CamelFolder *folder) static EAccount * guess_account_from_message (CamelMimeMessage *message) { - const gchar *source_url; + const gchar *uid; - source_url = camel_mime_message_get_source (message); - if (source_url == NULL) - return NULL; + uid = camel_mime_message_get_source (message); - return e_get_account_by_source_url (source_url); + return (uid != NULL) ? e_get_account_by_uid (uid) : NULL; } GHashTable * -- cgit v1.2.3 From 30fe010cffa6f290170147ea9a8b617d04fab39d Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 7 May 2011 11:15:51 -0400 Subject: Adapt to CamelFolder:name -> display-name. --- mail/em-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 07957ec456..2bc8831ad4 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -911,7 +911,7 @@ em_utils_selection_set_urilist (GtkSelectionData *data, /* Drop filename for messages from a mailbox */ file = g_strdup_printf ( _("Messages from %s"), - camel_folder_get_name (folder)); + camel_folder_get_display_name (folder)); } e_filename_make_safe (file); -- cgit v1.2.3 From 578214584caa7805edca09b27e2306dc31d80fb6 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 7 May 2011 12:22:36 -0400 Subject: Whitespace and coding style cleanups. --- mail/em-utils.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 2bc8831ad4..aef894a9e1 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1325,7 +1325,8 @@ em_utils_message_to_html (CamelMimeMessage *message, GConfClient *gconf; gchar *charset; - /* FIXME: we should be getting this from the current view, not the global setting. */ + /* FIXME We should be getting this from the + * current view, not the global setting. */ gconf = gconf_client_get_default (); charset = gconf_client_get_string ( gconf, "/apps/evolution/mail/display/charset", NULL); @@ -1633,7 +1634,8 @@ search_address_in_addressbooks (const gchar *address, query = e_book_query_field_test (E_CONTACT_EMAIL, E_BOOK_QUERY_IS, address); - for (g = e_source_list_peek_groups (emu_books_source_list); g; g = g_slist_next (g)) { + for (g = e_source_list_peek_groups (emu_books_source_list); + g; g = g_slist_next (g)) { ESourceGroup *group = g->data; if (!group) @@ -1738,7 +1740,8 @@ search_address_in_addressbooks (const gchar *address, g_list_free (contacts); } } else if (book) { - stop = stop || (err && g_error_matches (err, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)); + stop = stop || (err && g_error_matches ( + err, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)); if (err && !stop) { gchar *source_uid = g_strdup (e_source_peek_uid (source)); @@ -1760,7 +1763,9 @@ search_address_in_addressbooks (const gchar *address, if (stop && !cached_book && book) { g_object_unref (book); } else if (!stop && book && !cached_book) { - g_hash_table_insert (emu_books_hash, g_strdup (e_source_peek_uid (source)), book); + g_hash_table_insert ( + emu_books_hash, g_strdup ( + e_source_peek_uid (source)), book); } } -- cgit v1.2.3 From 54da4fc09cf226fdb59b9f0c70555e2e57dc1f91 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 8 May 2011 13:24:42 -0400 Subject: Coding style cleanups. --- mail/em-utils.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index aef894a9e1..67ee603038 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -313,7 +313,7 @@ em_utils_edit_filters (GtkWidget *parent, if (((ERuleContext *) fc)->error) { e_mail_backend_submit_alert ( backend, "mail:filter-load-error", - ((ERuleContext *)fc)->error, NULL); + ((ERuleContext *) fc)->error, NULL); return; } @@ -649,7 +649,7 @@ em_utils_read_messages_from_stream (CamelFolder *folder, /* NB: de-from filter, once written */ msg = camel_mime_message_new (); if (!camel_mime_part_construct_from_parser_sync ( - (CamelMimePart *)msg, mp, NULL, NULL)) { + (CamelMimePart *) msg, mp, NULL, NULL)) { g_object_unref (msg); break; } @@ -757,10 +757,10 @@ em_utils_selection_get_message (GtkSelectionData *selection_data, return; stream = (CamelStream *) - camel_stream_mem_new_with_buffer ((gchar *)data, length); + camel_stream_mem_new_with_buffer ((gchar *) data, length); msg = camel_mime_message_new (); if (camel_data_wrapper_construct_from_stream_sync ( - (CamelDataWrapper *)msg, stream, NULL, NULL)) + (CamelDataWrapper *) msg, stream, NULL, NULL)) /* FIXME camel_folder_append_message_sync() may block. */ camel_folder_append_message_sync ( folder, msg, NULL, NULL, NULL, NULL); @@ -936,7 +936,7 @@ em_utils_selection_set_urilist (GtkSelectionData *data, GdkAtom target; target = gtk_selection_data_get_target (data); - gtk_selection_data_set (data, target, 8, (guchar *)uri_crlf, strlen (uri_crlf)); + gtk_selection_data_set (data, target, 8, (guchar *) uri_crlf, strlen (uri_crlf)); g_free (uri_crlf); } @@ -1275,7 +1275,7 @@ em_utils_get_proxy_uri (const gchar *pUri) g_static_mutex_lock (&emu_proxy_lock); if (!emu_proxy) { - mail_call_main (MAIL_CALL_p_p, (MailMainFunc)emu_proxy_setup, NULL); + mail_call_main (MAIL_CALL_p_p, (MailMainFunc) emu_proxy_setup, NULL); } if (e_proxy_require_proxy_for_uri (emu_proxy, pUri)) @@ -1500,7 +1500,7 @@ struct TryOpenEBookStruct { static void try_open_e_book_cb (EBook *book, const GError *error, gpointer closure) { - struct TryOpenEBookStruct *data = (struct TryOpenEBookStruct *)closure; + struct TryOpenEBookStruct *data = (struct TryOpenEBookStruct *) closure; if (!data) return; @@ -1736,7 +1736,7 @@ search_address_in_addressbooks (const gchar *address, found = TRUE; } - g_list_foreach (contacts, (GFunc)g_object_unref, NULL); + g_list_foreach (contacts, (GFunc) g_object_unref, NULL); g_list_free (contacts); } } else if (book) { -- cgit v1.2.3 From 1a75a7d808c45cbc2c3c4b0cc6b750ef4002ed8e Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 12 May 2011 19:00:09 -0400 Subject: Miscellaneous cleanups. --- mail/em-utils.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 67ee603038..a9027e0fa2 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -444,8 +444,10 @@ em_utils_flag_for_followup (EMailReader *reader, /* special-case... */ if (uids->len == 1) { CamelMessageInfo *info; + const gchar *message_uid; - info = camel_folder_get_message_info (folder, uids->pdata[0]); + message_uid = g_ptr_array_index (uids, 0); + info = camel_folder_get_message_info (folder, message_uid); if (info) { tags = (CamelTag *) camel_message_info_user_tags (info); @@ -899,7 +901,10 @@ em_utils_selection_set_urilist (GtkSelectionData *data, /* Try to get the drop filename from the message or folder */ if (uids->len == 1) { - info = camel_folder_get_message_info (folder, uids->pdata[0]); + const gchar *message_uid; + + message_uid = g_ptr_array_index (uids, 0); + info = camel_folder_get_message_info (folder, message_uid); if (info) { file = g_strdup (camel_message_info_subject (info)); camel_folder_free_message_info (folder, info); -- cgit v1.2.3 From 5146ff4c535f443fe25290eb96631e91ad44c8ef Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 21 May 2011 10:02:58 -0400 Subject: Coding style and whitespace cleanup. --- mail/em-utils.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index a9027e0fa2..c832c898c6 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -941,7 +941,9 @@ em_utils_selection_set_urilist (GtkSelectionData *data, GdkAtom target; target = gtk_selection_data_get_target (data); - gtk_selection_data_set (data, target, 8, (guchar *) uri_crlf, strlen (uri_crlf)); + gtk_selection_data_set ( + data, target, 8, (guchar *) + uri_crlf, strlen (uri_crlf)); g_free (uri_crlf); } @@ -2107,15 +2109,17 @@ em_utils_generate_account_hash (void) if (account->id->address) { EAccount *acnt; - /* Accounts with identical email addresses that are enabled - * take precedence over the accounts that aren't. If all - * accounts with matching email addresses are disabled, then - * the first one in the list takes precedence. The default - * account always takes precedence no matter what. - */ - acnt = g_hash_table_lookup (account_hash, account->id->address); + /* Accounts with identical email addresses that are + * enabled take precedence over the accounts that + * aren't. If all accounts with matching email + * addresses are disabled, then the first one in + * the list takes precedence. The default account + * always takes precedence no matter what. */ + acnt = g_hash_table_lookup ( + account_hash, account->id->address); if (acnt && acnt != def && !acnt->enabled && account->enabled) { - g_hash_table_remove (account_hash, acnt->id->address); + g_hash_table_remove ( + account_hash, acnt->id->address); acnt = NULL; } @@ -2131,9 +2135,13 @@ em_utils_generate_account_hash (void) g_object_unref (iterator); - /* The default account has to be there if none of the enabled accounts are present */ + /* The default account has to be there if none + * of the enabled accounts are present. */ if (g_hash_table_size (account_hash) == 0 && def && def->id->address) - g_hash_table_insert (account_hash, (gchar *) def->id->address, (gpointer) def); + g_hash_table_insert ( + account_hash, (gchar *) + def->id->address, + (gpointer) def); return account_hash; } -- cgit v1.2.3 From 7050475f84247fb15e24aa1bb31502106c18815d Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 23 May 2011 17:09:24 -0400 Subject: EMFolderTree: Store an EMailBackend instead of an EMailSession. All this so EMFolderTree can submit EActivity instances for async ops. You can obtain an EMailSession from an EMailBackend, but not vice versa. Creates lots of pretty ripples in the mail code, but ultimately reduces complexity. So it's a code cleanup of sorts. --- mail/em-utils.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index c832c898c6..f7f957ba82 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -291,7 +291,6 @@ em_utils_edit_filters (GtkWidget *parent, const gchar *config_dir; gchar *user, *system; EMFilterContext *fc; - EMailSession *session; g_return_if_fail (E_IS_MAIL_BACKEND (backend)); @@ -301,9 +300,8 @@ em_utils_edit_filters (GtkWidget *parent, } config_dir = mail_session_get_config_dir (); - session = e_mail_backend_get_session (backend); - fc = em_filter_context_new (session); + fc = em_filter_context_new (backend); user = g_build_filename (config_dir, "filters.xml", NULL); system = g_build_filename (EVOLUTION_PRIVDATADIR, "filtertypes.xml", NULL); e_rule_context_load ((ERuleContext *) fc, system, user); -- cgit v1.2.3 From 7132d0f0c2b8494b3962792cd77ce3fcb5313687 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 28 May 2011 10:18:56 -0400 Subject: Including directly is rarely needed. --- mail/em-utils.c | 1 - 1 file changed, 1 deletion(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index f7f957ba82..9e8dec8547 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -31,7 +31,6 @@ #include #include -#include #include #ifdef G_OS_WIN32 -- cgit v1.2.3 From 8055965328e7bb59c0cc23d3030b89025999f5aa Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 29 May 2011 13:50:16 -0400 Subject: Remove em_utils_folder_name_from_uri(). --- mail/em-utils.c | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 9e8dec8547..73c4d9be61 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1430,31 +1430,6 @@ em_utils_empty_trash (GtkWidget *parent, mail_empty_trash (session, NULL, NULL, NULL); } -gchar * -em_utils_folder_name_from_uri (const gchar *uri) -{ - CamelURL *url; - gchar *folder_name = NULL; - - if (uri == NULL || (url = camel_url_new (uri, NULL)) == NULL) - return NULL; - - if (url->fragment) - folder_name = url->fragment; - else if (url->path) - folder_name = url->path + 1; - - if (folder_name == NULL) { - camel_url_free (url); - return NULL; - } - - folder_name = g_strdup (folder_name); - camel_url_free (url); - - return folder_name; -} - /* ********************************************************************** */ /* runs sync, in main thread */ -- cgit v1.2.3 From e7954c3f251aabbf95d099159709c8c66dfedc44 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 4 Jun 2011 15:53:10 -0500 Subject: Coding style and whitespace cleanups. --- mail/em-utils.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 73c4d9be61..7d11f5e9bf 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1661,16 +1661,24 @@ search_address_in_addressbooks (const gchar *address, book = e_book_new (source, &err); if (book == NULL) { - if (err && g_error_matches (err, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) { + if (err && g_error_matches ( + err, E_BOOK_ERROR, + E_BOOK_ERROR_CANCELLED)) { stop = TRUE; } else if (err) { - gchar *source_uid = g_strdup (e_source_peek_uid (source)); + gchar *source_uid; - g_hash_table_insert (emu_broken_books_hash, source_uid, source_uid); + source_uid = g_strdup ( + e_source_peek_uid (source)); + + g_hash_table_insert ( + emu_broken_books_hash, + source_uid, source_uid); g_warning ( "%s: Unable to create addressbook '%s': %s", - G_STRFUNC, e_source_peek_name (source), + G_STRFUNC, + e_source_peek_name (source), err->message); } g_clear_error (&err); @@ -1678,16 +1686,24 @@ search_address_in_addressbooks (const gchar *address, g_object_unref (book); book = NULL; - if (err && g_error_matches (err, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) { + if (err && g_error_matches ( + err, E_BOOK_ERROR, + E_BOOK_ERROR_CANCELLED)) { stop = TRUE; } else if (err) { - gchar *source_uid = g_strdup (e_source_peek_uid (source)); + gchar *source_uid; + + source_uid = g_strdup ( + e_source_peek_uid (source)); - g_hash_table_insert (emu_broken_books_hash, source_uid, source_uid); + g_hash_table_insert ( + emu_broken_books_hash, + source_uid, source_uid); g_warning ( "%s: Unable to open addressbook '%s': %s", - G_STRFUNC, e_source_peek_name (source), + G_STRFUNC, + e_source_peek_name (source), err->message); } g_clear_error (&err); @@ -1699,7 +1715,10 @@ search_address_in_addressbooks (const gchar *address, if (book && !stop && e_book_get_contacts (book, query, &contacts, &err)) { if (contacts != NULL) { if (!found_any) { - g_hash_table_insert (contact_cache, g_strdup (lowercase_addr), book); + g_hash_table_insert ( + contact_cache, + g_strdup (lowercase_addr), + book); } found_any = TRUE; -- cgit v1.2.3 From 84339b3be5a771406fcd5898bbd21dc1c5b98c82 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 14 Jun 2011 08:54:20 +0200 Subject: Do not use deprecated EBook/ECal API --- mail/em-utils.c | 138 ++++++++++++++++++++++++++------------------------------ 1 file changed, 63 insertions(+), 75 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 7d11f5e9bf..db6bd958f9 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -41,7 +41,8 @@ #undef interface #endif -#include +#include +#include #include "em-filter-editor.h" @@ -1439,35 +1440,30 @@ emu_addr_setup (gpointer user_data) GError *err = NULL; ESourceList **psource_list = user_data; - if (!e_book_get_addressbooks (psource_list, &err)) + if (!e_book_client_get_sources (psource_list, &err)) g_error_free (err); return NULL; } static void -emu_addr_cancel_book (gpointer data) +emu_addr_cancel_stop (gpointer data) { - EBook **pbook = data; - GError *err = NULL; + gboolean *stop = data; - g_return_if_fail (pbook != NULL); + g_return_if_fail (stop != NULL); - if (*pbook) { - /* we dunna care if this fails, its just the best we can try */ - e_book_cancel (*pbook, &err); - g_clear_error (&err); - } + *stop = TRUE; } static void -emu_addr_cancel_stop (gpointer data) +emu_addr_cancel_cancellable (gpointer data) { - gboolean *stop = data; + GCancellable *cancellable = data; - g_return_if_fail (stop != NULL); + g_return_if_fail (cancellable != NULL); - *stop = TRUE; + g_cancellable_cancel (cancellable); } struct TryOpenEBookStruct { @@ -1477,32 +1473,36 @@ struct TryOpenEBookStruct { }; static void -try_open_e_book_cb (EBook *book, const GError *error, gpointer closure) +try_open_book_client_cb (GObject *source_object, GAsyncResult *result, gpointer closure) { + EBookClient *book_client = E_BOOK_CLIENT (source_object); struct TryOpenEBookStruct *data = (struct TryOpenEBookStruct *) closure; + GError *error = NULL; if (!data) return; + e_client_open_finish (E_CLIENT (book_client), result, &error); + data->result = error == NULL; if (!data->result) { g_clear_error (data->error); - g_propagate_error (data->error, g_error_copy (error)); + g_propagate_error (data->error, error); } e_flag_set (data->flag); } -/** - * try_open_e_book: +/* + * try_open_book_client: * Tries to open address book asynchronously, but acts as synchronous. * The advantage is it checks periodically whether the camel_operation * has been canceled or not, and if so, then stops immediately, with - * result FALSE. Otherwise returns same as e_book_open - **/ + * result FALSE. Otherwise returns same as e_client_open() + */ static gboolean -try_open_e_book (EBook *book, gboolean only_if_exists, GError **error) +try_open_book_client (EBookClient *book_client, gboolean only_if_exists, GCancellable *cancellable, GError **error) { struct TryOpenEBookStruct data; gboolean canceled = FALSE; @@ -1512,15 +1512,7 @@ try_open_e_book (EBook *book, gboolean only_if_exists, GError **error) data.flag = flag; data.result = FALSE; - if (!e_book_open_async (book, only_if_exists, try_open_e_book_cb, &data)) { - e_flag_free (flag); - g_clear_error (error); - g_set_error ( - error, E_BOOK_ERROR, - E_BOOK_ERROR_OTHER_ERROR, - "Failed to call e_book_open_async."); - return FALSE; - } + e_client_open (E_CLIENT (book_client), only_if_exists, cancellable, try_open_book_client_cb, &data); while (canceled = camel_operation_cancel_check (NULL), !canceled && !e_flag_is_set (flag)) { @@ -1533,16 +1525,10 @@ try_open_e_book (EBook *book, gboolean only_if_exists, GError **error) } if (canceled) { + g_cancellable_cancel (cancellable); + g_clear_error (error); - g_set_error ( - error, E_BOOK_ERROR, - E_BOOK_ERROR_CANCELLED, - "Operation has been canceled."); - /* if the operation is cancelled sucessfully set the flag - * else wait. file, groupwise,.. backend's operations - * are not cancellable */ - if (e_book_cancel_async_op (book, NULL)) - e_flag_set (flag); + g_propagate_error (error, e_client_error_create (E_CLIENT_ERROR_CANCELLED, NULL)); } e_flag_wait (flag); @@ -1578,8 +1564,11 @@ search_address_in_addressbooks (const gchar *address, gboolean found = FALSE, stop = FALSE, found_any = FALSE; gchar *lowercase_addr; gpointer ptr; - EBookQuery *query; + EBookQuery *book_query; + gchar *query; GSList *s, *g, *addr_sources = NULL; + GHook *hook_cancellable; + GCancellable *cancellable; if (!address || !*address) return FALSE; @@ -1611,7 +1600,9 @@ search_address_in_addressbooks (const gchar *address, return ptr != NOT_FOUND_BOOK; } - query = e_book_query_field_test (E_CONTACT_EMAIL, E_BOOK_QUERY_IS, address); + book_query = e_book_query_field_test (E_CONTACT_EMAIL, E_BOOK_QUERY_IS, address); + query = e_book_query_to_string (book_query); + e_book_query_unref (book_query); for (g = e_source_list_peek_groups (emu_books_source_list); g; g = g_slist_next (g)) { @@ -1635,11 +1626,14 @@ search_address_in_addressbooks (const gchar *address, } } + cancellable = g_cancellable_new (); + hook_cancellable = mail_cancel_hook_add (emu_addr_cancel_cancellable, cancellable); + for (s = addr_sources; !stop && !found && s; s = g_slist_next (s)) { ESource *source = s->data; - GList *contacts; - EBook *book = NULL; - GHook *hook_book, *hook_stop; + GSList *contacts; + EBookClient *book_client = NULL; + GHook *hook_stop; gboolean cached_book = FALSE; GError *err = NULL; @@ -1653,17 +1647,14 @@ search_address_in_addressbooks (const gchar *address, d(printf(" checking '%s'\n", e_source_get_uri(source))); - hook_book = mail_cancel_hook_add (emu_addr_cancel_book, &book); hook_stop = mail_cancel_hook_add (emu_addr_cancel_stop, &stop); - book = g_hash_table_lookup (emu_books_hash, e_source_peek_uid (source)); - if (!book) { - book = e_book_new (source, &err); + book_client = g_hash_table_lookup (emu_books_hash, e_source_peek_uid (source)); + if (!book_client) { + book_client = e_book_client_new (source, &err); - if (book == NULL) { - if (err && g_error_matches ( - err, E_BOOK_ERROR, - E_BOOK_ERROR_CANCELLED)) { + if (book_client == NULL) { + if (err && g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) { stop = TRUE; } else if (err) { gchar *source_uid; @@ -1682,13 +1673,11 @@ search_address_in_addressbooks (const gchar *address, err->message); } g_clear_error (&err); - } else if (!stop && !try_open_e_book (book, TRUE, &err)) { - g_object_unref (book); - book = NULL; + } else if (!stop && !try_open_book_client (book_client, TRUE, cancellable, &err)) { + g_object_unref (book_client); + book_client = NULL; - if (err && g_error_matches ( - err, E_BOOK_ERROR, - E_BOOK_ERROR_CANCELLED)) { + if (err && g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) { stop = TRUE; } else if (err) { gchar *source_uid; @@ -1712,18 +1701,15 @@ search_address_in_addressbooks (const gchar *address, cached_book = TRUE; } - if (book && !stop && e_book_get_contacts (book, query, &contacts, &err)) { + if (book_client && !stop && e_book_client_get_contacts_sync (book_client, query, &contacts, cancellable, &err)) { if (contacts != NULL) { if (!found_any) { - g_hash_table_insert ( - contact_cache, - g_strdup (lowercase_addr), - book); + g_hash_table_insert (contact_cache, g_strdup (lowercase_addr), book_client); } found_any = TRUE; if (check_contact) { - GList *l; + GSList *l; for (l = contacts; l && !found; l = l->next) { EContact *contact = l->data; @@ -1734,12 +1720,12 @@ search_address_in_addressbooks (const gchar *address, found = TRUE; } - g_list_foreach (contacts, (GFunc) g_object_unref, NULL); - g_list_free (contacts); + g_slist_foreach (contacts, (GFunc) g_object_unref, NULL); + g_slist_free (contacts); } - } else if (book) { + } else if (book_client) { stop = stop || (err && g_error_matches ( - err, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)); + err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)); if (err && !stop) { gchar *source_uid = g_strdup (e_source_peek_uid (source)); @@ -1753,24 +1739,26 @@ search_address_in_addressbooks (const gchar *address, g_clear_error (&err); } - mail_cancel_hook_remove (hook_book); mail_cancel_hook_remove (hook_stop); stop = stop || camel_operation_cancel_check (NULL); - if (stop && !cached_book && book) { - g_object_unref (book); - } else if (!stop && book && !cached_book) { + if (stop && !cached_book && book_client) { + g_object_unref (book_client); + } else if (!stop && book_client && !cached_book) { g_hash_table_insert ( emu_books_hash, g_strdup ( - e_source_peek_uid (source)), book); + e_source_peek_uid (source)), book_client); } } + mail_cancel_hook_remove (hook_cancellable); + g_object_unref (cancellable); + g_slist_foreach (addr_sources, (GFunc) g_object_unref, NULL); g_slist_free (addr_sources); - e_book_query_unref (query); + g_free (query); if (!found_any) { g_hash_table_insert (contact_cache, lowercase_addr, NOT_FOUND_BOOK); -- cgit v1.2.3 From adc1173159d4d5d953340f8f3c813681007de524 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 27 Jun 2011 18:04:57 +0200 Subject: Check for cancelled GIO operation error code too --- mail/em-utils.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index db6bd958f9..3239b87214 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1654,7 +1654,8 @@ search_address_in_addressbooks (const gchar *address, book_client = e_book_client_new (source, &err); if (book_client == NULL) { - if (err && g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) { + if (err && (g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || + g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))) { stop = TRUE; } else if (err) { gchar *source_uid; @@ -1677,7 +1678,8 @@ search_address_in_addressbooks (const gchar *address, g_object_unref (book_client); book_client = NULL; - if (err && g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) { + if (err && (g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || + g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))) { stop = TRUE; } else if (err) { gchar *source_uid; @@ -1724,8 +1726,9 @@ search_address_in_addressbooks (const gchar *address, g_slist_free (contacts); } } else if (book_client) { - stop = stop || (err && g_error_matches ( - err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)); + stop = stop || (err && + (g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || + g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))); if (err && !stop) { gchar *source_uid = g_strdup (e_source_peek_uid (source)); -- cgit v1.2.3 From a57097559c1c3985a20af5be9be50e489ddee001 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 1 Jul 2011 20:01:45 +0200 Subject: Bug #650671 - Service connect/disconnect not cancelled properly --- mail/em-utils.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 3239b87214..a106a0ce04 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -2289,3 +2289,52 @@ em_utils_is_local_delivery_mbox_file (CamelURL *url) g_file_test (url->path, G_FILE_TEST_EXISTS) && !g_file_test (url->path, G_FILE_TEST_IS_DIR); } + +static void +cancel_service_connect_cb (GCancellable *cancellable, CamelService *service) +{ + g_return_if_fail (service != NULL); + g_return_if_fail (CAMEL_IS_SERVICE (service)); + + camel_service_cancel_connect (service); +} + +gboolean +em_utils_connect_service_sync (CamelService *service, GCancellable *cancellable, GError **error) +{ + gboolean res; + gulong handler_id = 0; + + g_return_val_if_fail (service != NULL, FALSE); + g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE); + + if (cancellable) + handler_id = g_cancellable_connect (cancellable, G_CALLBACK (cancel_service_connect_cb), service, NULL); + + res = camel_service_connect_sync (service, error); + + if (handler_id) + g_cancellable_disconnect (cancellable, handler_id); + + return res; +} + +gboolean +em_utils_disconnect_service_sync (CamelService *service, gboolean clean, GCancellable *cancellable, GError **error) +{ + gboolean res; + gulong handler_id = 0; + + g_return_val_if_fail (service != NULL, FALSE); + g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE); + + if (cancellable) + handler_id = g_cancellable_connect (cancellable, G_CALLBACK (cancel_service_connect_cb), service, NULL); + + res = camel_service_disconnect_sync (service, clean, error); + + if (handler_id) + g_cancellable_disconnect (cancellable, handler_id); + + return res; +} -- cgit v1.2.3 From ae9db3ed236b0c734fd12c8dc8c99764626bf0b8 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 1 Jul 2011 00:07:26 -0400 Subject: Coding style and whitespace cleanup. --- mail/em-utils.c | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index a106a0ce04..33e664976b 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1473,7 +1473,9 @@ struct TryOpenEBookStruct { }; static void -try_open_book_client_cb (GObject *source_object, GAsyncResult *result, gpointer closure) +try_open_book_client_cb (GObject *source_object, + GAsyncResult *result, + gpointer closure) { EBookClient *book_client = E_BOOK_CLIENT (source_object); struct TryOpenEBookStruct *data = (struct TryOpenEBookStruct *) closure; @@ -1502,7 +1504,10 @@ try_open_book_client_cb (GObject *source_object, GAsyncResult *result, gpointer * result FALSE. Otherwise returns same as e_client_open() */ static gboolean -try_open_book_client (EBookClient *book_client, gboolean only_if_exists, GCancellable *cancellable, GError **error) +try_open_book_client (EBookClient *book_client, + gboolean only_if_exists, + GCancellable *cancellable, + GError **error) { struct TryOpenEBookStruct data; gboolean canceled = FALSE; @@ -1512,7 +1517,9 @@ try_open_book_client (EBookClient *book_client, gboolean only_if_exists, GCancel data.flag = flag; data.result = FALSE; - e_client_open (E_CLIENT (book_client), only_if_exists, cancellable, try_open_book_client_cb, &data); + e_client_open ( + E_CLIENT (book_client), only_if_exists, + cancellable, try_open_book_client_cb, &data); while (canceled = camel_operation_cancel_check (NULL), !canceled && !e_flag_is_set (flag)) { @@ -1528,7 +1535,9 @@ try_open_book_client (EBookClient *book_client, gboolean only_if_exists, GCancel g_cancellable_cancel (cancellable); g_clear_error (error); - g_propagate_error (error, e_client_error_create (E_CLIENT_ERROR_CANCELLED, NULL)); + g_propagate_error ( + error, e_client_error_create ( + E_CLIENT_ERROR_CANCELLED, NULL)); } e_flag_wait (flag); @@ -2291,25 +2300,29 @@ em_utils_is_local_delivery_mbox_file (CamelURL *url) } static void -cancel_service_connect_cb (GCancellable *cancellable, CamelService *service) +cancel_service_connect_cb (GCancellable *cancellable, + CamelService *service) { - g_return_if_fail (service != NULL); g_return_if_fail (CAMEL_IS_SERVICE (service)); camel_service_cancel_connect (service); } gboolean -em_utils_connect_service_sync (CamelService *service, GCancellable *cancellable, GError **error) +em_utils_connect_service_sync (CamelService *service, + GCancellable *cancellable, + GError **error) { gboolean res; gulong handler_id = 0; - g_return_val_if_fail (service != NULL, FALSE); g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE); - if (cancellable) - handler_id = g_cancellable_connect (cancellable, G_CALLBACK (cancel_service_connect_cb), service, NULL); + if (cancellable != NULL) + handler_id = g_cancellable_connect ( + cancellable, + G_CALLBACK (cancel_service_connect_cb), + service, NULL); res = camel_service_connect_sync (service, error); @@ -2320,16 +2333,21 @@ em_utils_connect_service_sync (CamelService *service, GCancellable *cancellable, } gboolean -em_utils_disconnect_service_sync (CamelService *service, gboolean clean, GCancellable *cancellable, GError **error) +em_utils_disconnect_service_sync (CamelService *service, + gboolean clean, + GCancellable *cancellable, + GError **error) { gboolean res; gulong handler_id = 0; - g_return_val_if_fail (service != NULL, FALSE); g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE); - if (cancellable) - handler_id = g_cancellable_connect (cancellable, G_CALLBACK (cancel_service_connect_cb), service, NULL); + if (cancellable != NULL) + handler_id = g_cancellable_connect ( + cancellable, + G_CALLBACK (cancel_service_connect_cb), + service, NULL); res = camel_service_disconnect_sync (service, clean, error); -- cgit v1.2.3 From db1a2dd8aad57fb222daa6f82838b33a26f8e742 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 30 Aug 2011 19:05:30 -0400 Subject: Miscellaneous cleanups. Reducing diff noise with the account-mgmt branch. Trying to erode our dependency on EAccount as much as possible, or at least isolate its usage, to make things easier for me on the branch. --- mail/em-utils.c | 64 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 28 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 33e664976b..3b42e9b200 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1361,13 +1361,15 @@ em_utils_message_to_html (CamelMimeMessage *message, /** * em_utils_expunge_folder: * @parent: parent window - * @session: #EMailSession + * @backend: #EMailBackend * @folder: folder to expunge * * Expunges @folder. **/ void -em_utils_expunge_folder (GtkWidget *parent, EMailSession *session, CamelFolder *folder) +em_utils_expunge_folder (GtkWidget *parent, + EMailBackend *backend, + CamelFolder *folder) { const gchar *description; @@ -1379,56 +1381,62 @@ em_utils_expunge_folder (GtkWidget *parent, EMailSession *session, CamelFolder * "mail:ask-expunge", description, NULL)) return; - mail_expunge_folder (session, folder, NULL, NULL); + mail_expunge_folder (backend, folder); } /** * em_utils_empty_trash: * @parent: parent window - * @session: an #EMailSession + * @backend: an #EMailBackend * * Empties all Trash folders. **/ void em_utils_empty_trash (GtkWidget *parent, - EMailSession *session) + EMailBackend *backend) { - CamelProvider *provider; - EAccountList *account_list; - EAccount *account; - EIterator *iterator; + EMailSession *session; + GList *list, *iter; - g_return_if_fail (E_IS_MAIL_SESSION (session)); + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); if (!em_utils_prompt_user ((GtkWindow *) parent, "/apps/evolution/mail/prompts/empty_trash", "mail:ask-empty-trash", NULL)) return; - account_list = e_get_account_list (); - iterator = e_list_get_iterator (E_LIST (account_list)); + session = e_mail_backend_get_session (backend); + list = camel_session_list_services (CAMEL_SESSION (session)); - while (e_iterator_is_valid (iterator)) { - account = (EAccount *) e_iterator_get (iterator); + for (iter = list; iter != NULL; iter = g_list_next (iter)) { + EAccount *account; + CamelProvider *provider; + CamelService *service; + const gchar *uid; - /* make sure this is a valid source */ - if (account->enabled && account->source->url) { - provider = camel_provider_get (account->source->url, NULL); - if (provider) { - /* make sure this store is a remote store */ - if (provider->flags & CAMEL_PROVIDER_IS_STORAGE) { - mail_empty_trash (session, account, NULL, NULL); - } - } + service = CAMEL_SERVICE (iter->data); + provider = camel_service_get_provider (service); + uid = camel_service_get_uid (service); + + if (!CAMEL_IS_STORE (service)) + continue; + + if ((provider->flags & CAMEL_PROVIDER_IS_STORAGE) == 0) + continue; + + account = e_get_account_by_uid (uid); + + /* The local store has no corresponding + * EAccount, so skip the enabled check. */ + if (account != NULL) { + if (!account->enabled) + continue; } - e_iterator_next (iterator); + mail_empty_trash (backend, CAMEL_STORE (service)); } - g_object_unref (iterator); - - /* Now empty the local trash folder */ - mail_empty_trash (session, NULL, NULL, NULL); + g_list_free (list); } /* ********************************************************************** */ -- cgit v1.2.3 From 777c1cbd40eb63365f2c28e38f6a93beb2d1c9d1 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 16 Aug 2011 11:25:56 -0400 Subject: Coding style and whitespace cleanup. --- mail/em-utils.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 3b42e9b200..968165385a 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -249,7 +249,9 @@ em_utils_check_user_can_send_mail (void) static GtkWidget *filter_editor = NULL; static void -em_filter_editor_response (GtkWidget *dialog, gint button, gpointer user_data) +em_filter_editor_response (GtkWidget *dialog, + gint button, + gpointer user_data) { EMFilterContext *fc; @@ -366,7 +368,7 @@ em_filename_make_safe (gchar *string) * written? */ if (!g_unichar_isprint (c) || ( c < 0xff && strchr (unsafe_chars, c&0xff ))) { - while (tslen; i++) { + for (i = 0; i < uids->len; i++) { CamelMimeMessage *message; gchar *from; @@ -793,8 +795,8 @@ em_utils_selection_set_uidlist (GtkSelectionData *selection_data, g_byte_array_append ( array, (guchar *) folder_uri, strlen (folder_uri) + 1); - for (i=0; ilen; i++) - g_byte_array_append (array, uids->pdata[i], strlen (uids->pdata[i])+1); + for (i = 0; i < uids->len; i++) + g_byte_array_append (array, uids->pdata[i], strlen (uids->pdata[i]) + 1); target = gtk_selection_data_get_target (selection_data); gtk_selection_data_set ( @@ -849,7 +851,7 @@ em_utils_selection_get_uidlist (GtkSelectionData *selection_data, inptr++; if (start > (gchar *) data) - g_ptr_array_add (uids, g_strndup (start, inptr-start)); + g_ptr_array_add (uids, g_strndup (start, inptr - start)); inptr++; } @@ -975,7 +977,7 @@ em_utils_selection_get_urilist (GtkSelectionData *selection_data, uris = gtk_selection_data_get_uris (selection_data); - for (i=0;res == 0 && uris[i];i++) { + for (i = 0; res == 0 && uris[i]; i++) { g_strstrip (uris[i]); if (uris[i][0] == '#') continue; @@ -1793,7 +1795,8 @@ search_address_in_addressbooks (const gchar *address, } gboolean -em_utils_in_addressbook (CamelInternetAddress *iaddr, gboolean local_only) +em_utils_in_addressbook (CamelInternetAddress *iaddr, + gboolean local_only) { const gchar *addr; @@ -1805,7 +1808,8 @@ em_utils_in_addressbook (CamelInternetAddress *iaddr, gboolean local_only) } static gboolean -extract_photo_data (EContact *contact, gpointer user_data) +extract_photo_data (EContact *contact, + gpointer user_data) { EContactPhoto **photo = user_data; @@ -1841,7 +1845,8 @@ G_LOCK_DEFINE_STATIC (photos_cache); static GSList *photos_cache = NULL; /* list of PhotoInfo-s */ CamelMimePart * -em_utils_contact_photo (CamelInternetAddress *cia, gboolean local_only) +em_utils_contact_photo (CamelInternetAddress *cia, + gboolean local_only) { const gchar *addr = NULL; CamelMimePart *part = NULL; @@ -1914,8 +1919,8 @@ em_utils_contact_photo (CamelInternetAddress *cia, gboolean local_only) return part; } -/* list of email addresses (strings) to remove from local cache of photos and contacts, - but only if the photo doesn't exist or is an not-found contact */ +/* list of email addresses (strings) to remove from local cache of photos and + * contacts, but only if the photo doesn't exist or is an not-found contact */ void emu_remove_from_mail_cache (const GSList *addresses) { -- cgit v1.2.3 From d230dd72bb6aff738974ccaa91bfad5d321e9c0c Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 26 Sep 2011 11:45:59 +0200 Subject: Bug #351025 - Make the order of the mail accounts configurable --- mail/em-utils.c | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 968165385a..5ff93887a2 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -84,6 +84,8 @@ extern const gchar *shell_builtin_backend; #define d(x) +static void free_account_sort_order_cache (void); + gboolean em_utils_ask_open_many (GtkWindow *parent, gint how_many) @@ -2014,6 +2016,8 @@ emu_free_mail_cache (void) photos_cache = NULL; G_UNLOCK (photos_cache); + + free_account_sort_order_cache (); } void @@ -2369,3 +2373,167 @@ em_utils_disconnect_service_sync (CamelService *service, return res; } + +G_LOCK_DEFINE_STATIC (accounts_sort_order_cache); +static GHashTable *accounts_sort_order_cache = NULL; /* account_uid string to sort order uint */ + +static void +free_account_sort_order_cache (void) +{ + G_LOCK (accounts_sort_order_cache); + + if (accounts_sort_order_cache) { + g_hash_table_destroy (accounts_sort_order_cache); + accounts_sort_order_cache = NULL; + } + + G_UNLOCK (accounts_sort_order_cache); +} + +static void +fill_accounts_sort_order_cache (EMailBackend *backend, gboolean force_reload) +{ + GSList *account_uids; + + G_LOCK (accounts_sort_order_cache); + + if (!force_reload && accounts_sort_order_cache) { + G_UNLOCK (accounts_sort_order_cache); + return; + } + + if (!accounts_sort_order_cache) + accounts_sort_order_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + else + g_hash_table_remove_all (accounts_sort_order_cache); + + account_uids = em_utils_load_accounts_sort_order (backend); + if (account_uids) { + GSList *iter; + guint index; + + for (index = 1, iter = account_uids; iter; index++, iter = iter->next) { + if (iter->data) + g_hash_table_insert (accounts_sort_order_cache, iter->data, GUINT_TO_POINTER (index)); + } + + /* items are stolen into the cache */ + /* g_slist_foreach (account_uids, (GFunc) g_free, NULL); */ + g_slist_free (account_uids); + } + + G_UNLOCK (accounts_sort_order_cache); +} + +static gchar * +emu_get_sort_order_filename (EMailBackend *backend) +{ + g_return_val_if_fail (backend != NULL, NULL); + + return g_build_filename ( + e_shell_backend_get_config_dir (E_SHELL_BACKEND (backend)), + "sortorder.ini", NULL); +} + +static GKeyFile * +emu_get_sort_order_key_file (EMailBackend *backend) +{ + gchar *filename; + GKeyFile *key_file; + + g_return_val_if_fail (backend != NULL, NULL); + + filename = emu_get_sort_order_filename (backend); + g_return_val_if_fail (filename != NULL, NULL); + + key_file = g_key_file_new (); + g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, NULL); + + g_free (filename); + + return key_file; +} + +void +em_utils_save_accounts_sort_order (EMailBackend *backend, const GSList *account_uids) +{ + gchar *filename; + GKeyFile *key_file; + gint ii; + gchar key[32]; + gchar *content; + gsize length = 0; + + key_file = emu_get_sort_order_key_file (backend); + g_return_if_fail (key_file != NULL); + + filename = emu_get_sort_order_filename (backend); + g_return_if_fail (filename != NULL); + + g_key_file_remove_group (key_file, "accounts", NULL); + + for (ii = 0; account_uids; ii++, account_uids = account_uids->next) { + sprintf (key, "%d", ii); + + g_key_file_set_string (key_file, "accounts", key, account_uids->data); + } + + content = g_key_file_to_data (key_file, &length, NULL); + if (content) + g_file_set_contents (filename, content, length, NULL); + + g_free (content); + g_free (filename); + g_key_file_free (key_file); + + fill_accounts_sort_order_cache (backend, TRUE); + e_mail_backend_account_sort_order_changed (backend); +} + +GSList * +em_utils_load_accounts_sort_order (EMailBackend *backend) +{ + GKeyFile *key_file; + GSList *account_uids = NULL; + gchar key[32]; + gchar *value; + gint ii; + + key_file = emu_get_sort_order_key_file (backend); + g_return_val_if_fail (key_file != NULL, NULL); + + ii = 0; + do { + sprintf (key, "%d", ii); + ii++; + + value = g_key_file_get_string (key_file, "accounts", key, NULL); + if (!value) + break; + + account_uids = g_slist_prepend (account_uids, value); + } while (*key); + + g_key_file_free (key_file); + + return g_slist_reverse (account_uids); +} + +guint +em_utils_get_account_sort_order (EMailBackend *backend, const gchar *account_uid) +{ + guint res; + + g_return_val_if_fail (backend != NULL, 0); + g_return_val_if_fail (account_uid != NULL, 0); + + fill_accounts_sort_order_cache (backend, FALSE); + + G_LOCK (accounts_sort_order_cache); + + res = GPOINTER_TO_UINT (g_hash_table_lookup (accounts_sort_order_cache, account_uid)); + + G_UNLOCK (accounts_sort_order_cache); + + return res; +} -- cgit v1.2.3 From 5efdc804e452ab547cc2a1d04c8d7173a2c9b6d5 Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Fri, 14 Oct 2011 13:46:33 +0200 Subject: Make e_utils_prompt_user and callers use GSettings keys --- mail/em-utils.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index 67978884d0..ed57335f17 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -105,7 +105,7 @@ em_utils_ask_open_many (GtkWindow *parent, "Are you sure you want to open %d messages at once?", how_many), how_many); proceed = em_utils_prompt_user ( - parent, "/apps/evolution/mail/prompts/open_many", + parent, "prompt-on-open-many", "mail:ask-open-many", string, NULL); g_free (string); @@ -115,7 +115,7 @@ em_utils_ask_open_many (GtkWindow *parent, /** * em_utils_prompt_user: * @parent: parent window - * @promptkey: gconf key to check if we should prompt the user or not. + * @promptkey: settings key to check if we should prompt the user or not. * @tag: e_alert tag. * * Convenience function to query the user with a Yes/No dialog and a @@ -136,13 +136,13 @@ em_utils_prompt_user (GtkWindow *parent, GtkWidget *container; va_list ap; gint button; - GConfClient *client; + GSettings *settings; EAlert *alert = NULL; - client = gconf_client_get_default (); + settings = g_settings_new ("org.gnome.evolution.mail"); - if (promptkey && !gconf_client_get_bool (client, promptkey, NULL)) { - g_object_unref (client); + if (promptkey && !g_settings_get_boolean (settings, promptkey)) { + g_object_unref (settings); return TRUE; } @@ -165,14 +165,13 @@ em_utils_prompt_user (GtkWindow *parent, button = gtk_dialog_run (GTK_DIALOG (dialog)); if (promptkey) - gconf_client_set_bool ( - client, promptkey, - !gtk_toggle_button_get_active ( - GTK_TOGGLE_BUTTON (check)), NULL); + g_settings_set_boolean (settings, promptkey, + !gtk_toggle_button_get_active ( + GTK_TOGGLE_BUTTON (check))); gtk_widget_destroy (dialog); - g_object_unref (client); + g_object_unref (settings); return button == GTK_RESPONSE_YES; } @@ -1256,16 +1255,15 @@ em_utils_message_to_html (CamelMimeMessage *message, ((EMFormat *) emfq)->composer = TRUE; if (!source) { - GConfClient *gconf; + GSettings *settings; gchar *charset; /* FIXME We should be getting this from the * current view, not the global setting. */ - gconf = gconf_client_get_default (); - charset = gconf_client_get_string ( - gconf, "/apps/evolution/mail/display/charset", NULL); + settings = g_settings_new ("org.gnome.evolution.mail"); + charset = g_settings_get_string (settings, "charset"); em_format_set_default_charset ((EMFormat *) emfq, charset); - g_object_unref (gconf); + g_object_unref (settings); g_free (charset); } @@ -1306,7 +1304,7 @@ em_utils_expunge_folder (GtkWidget *parent, if (!em_utils_prompt_user ( GTK_WINDOW (parent), - "/apps/evolution/mail/prompts/expunge", + "prompt-on-expunge", "mail:ask-expunge", description, NULL)) return; @@ -1330,7 +1328,7 @@ em_utils_empty_trash (GtkWidget *parent, g_return_if_fail (E_IS_MAIL_BACKEND (backend)); if (!em_utils_prompt_user ((GtkWindow *) parent, - "/apps/evolution/mail/prompts/empty_trash", + "prompt-on-empty-trash", "mail:ask-empty-trash", NULL)) return; -- cgit v1.2.3 From 0c83b9b25d967ce6d6793ef851e86bc272a2f129 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 18 Nov 2011 09:09:48 -0500 Subject: Miscellaneous cleanups. --- mail/em-utils.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'mail/em-utils.c') diff --git a/mail/em-utils.c b/mail/em-utils.c index a3be92d4c0..c15f8b67b5 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -165,9 +165,10 @@ em_utils_prompt_user (GtkWindow *parent, button = gtk_dialog_run (GTK_DIALOG (dialog)); if (promptkey) - g_settings_set_boolean (settings, promptkey, - !gtk_toggle_button_get_active ( - GTK_TOGGLE_BUTTON (check))); + g_settings_set_boolean ( + settings, promptkey, + !gtk_toggle_button_get_active ( + GTK_TOGGLE_BUTTON (check))); gtk_widget_destroy (dialog); -- cgit v1.2.3