X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fdbus_api%2Fmodest-dbus-callbacks.c;h=c1a8f113b966acc34fb7cf6b48746100b6125807;hp=92a89cc81c849f209e19c4eaf7bcec46b62f9c39;hb=55358d5653f2971053b40b5bc8d58255f3790a6e;hpb=332797a7ecc90997695e3189756de027bc1e4953 diff --git a/src/dbus_api/modest-dbus-callbacks.c b/src/dbus_api/modest-dbus-callbacks.c index 92a89cc..c1a8f11 100644 --- a/src/dbus_api/modest-dbus-callbacks.c +++ b/src/dbus_api/modest-dbus-callbacks.c @@ -1531,8 +1531,17 @@ on_idle_show_memory_low (gpointer user_data) static gboolean on_idle_present_modal (gpointer user_data) { + GtkWindow *current, *transient; gdk_threads_enter (); - gtk_window_present (user_data); + current = (GtkWindow *) user_data; + while (GTK_IS_DIALOG (current)) { + transient = gtk_window_get_transient_for (GTK_WINDOW (current)); + if (transient == NULL) + break; + else + current = transient; + } + gtk_window_present (current); gdk_threads_leave (); return FALSE; @@ -1643,6 +1652,8 @@ modest_dbus_req_handler(const gchar * interface, const gchar * method, DBUS_STRUCT_BEGIN_CHAR_AS_STRING \ DBUS_TYPE_STRING_AS_STRING \ DBUS_TYPE_STRING_AS_STRING \ + DBUS_TYPE_STRING_AS_STRING \ + DBUS_TYPE_INT64_AS_STRING \ DBUS_TYPE_ARRAY_AS_STRING \ ACCOUNT_HIT_DBUS_TYPE \ DBUS_STRUCT_END_CHAR_AS_STRING @@ -1902,7 +1913,9 @@ typedef struct { typedef struct { gchar *account_id; gchar *account_name; + gchar *store_protocol; gchar *mailbox_id; + gint unread_count; GList *header_list; } AccountHits; @@ -1926,6 +1939,8 @@ static void return_results (GetUnreadMessagesHelper *helper) AccountHits *ah = (AccountHits *) node->data; const char *account_id; const char *account_name; + const char *store_protocol; + gint64 unread_count; DBusMessageIter ah_struct_iter; DBusMessageIter sh_array_iter; GList *result_node; @@ -1936,12 +1951,20 @@ static void return_results (GetUnreadMessagesHelper *helper) &ah_struct_iter); account_id = ah->account_id; account_name = ah->account_name; + store_protocol = ah->store_protocol; + unread_count = ah->unread_count; dbus_message_iter_append_basic (&ah_struct_iter, DBUS_TYPE_STRING, &account_id); dbus_message_iter_append_basic (&ah_struct_iter, DBUS_TYPE_STRING, &account_name); + dbus_message_iter_append_basic (&ah_struct_iter, + DBUS_TYPE_STRING, + &store_protocol); + dbus_message_iter_append_basic (&ah_struct_iter, + DBUS_TYPE_INT64, + &unread_count); dbus_message_iter_open_container (&ah_struct_iter, DBUS_TYPE_ARRAY, @@ -1975,6 +1998,7 @@ static void return_results (GetUnreadMessagesHelper *helper) &ah_struct_iter); g_free (ah->account_id); g_free (ah->account_name); + g_free (ah->store_protocol); g_list_free (ah->header_list); } @@ -2012,11 +2036,16 @@ static void get_unread_messages_get_headers_cb (TnyFolder *self, AccountHits *account_hits; const gchar *folder_id; const gchar *bar; + ModestProtocolType store_protocol_type; + ModestProtocol *store_protocol; + gint unread_count; + ModestProtocolRegistry *registry; acc_iterator = tny_list_create_iterator (helper->accounts_list); account = TNY_ACCOUNT (tny_iterator_get_current (acc_iterator)); headers_iterator = tny_list_create_iterator (headers); + unread_count = 0; while (!tny_iterator_is_done (headers_iterator)) { TnyHeader *header; TnyHeaderFlags flags; @@ -2024,7 +2053,8 @@ static void get_unread_messages_get_headers_cb (TnyFolder *self, header = TNY_HEADER (tny_iterator_get_current (headers_iterator)); flags = tny_header_get_flags (header); if (!(flags & TNY_HEADER_FLAG_SEEN)) { - result_list = g_list_insert_sorted (result_list, g_object_ref (header), (GCompareFunc) headers_cmp); + unread_count++; + result_list = g_list_insert_sorted (result_list, g_object_ref (header), (GCompareFunc) headers_cmp); if (members_count == helper->unread_msgs_count) { g_object_unref (result_list->data); result_list = g_list_delete_link (result_list, result_list); @@ -2038,11 +2068,22 @@ static void get_unread_messages_get_headers_cb (TnyFolder *self, } g_object_unref (headers_iterator); + registry = modest_runtime_get_protocol_registry (); + store_protocol_type = modest_tny_account_get_protocol_type (account); + + /* Get the number of unread messages for plug-in based accounts */ + if (modest_protocol_registry_protocol_type_is_provider (registry, store_protocol_type)) { + unread_count = tny_folder_get_unread_count (self); + } + account_hits = g_slice_new (AccountHits); account_hits->account_id = g_strdup (modest_tny_account_get_parent_modest_account_name_for_server_account (account)); account_hits->account_name = g_strdup (tny_account_get_name (account)); + store_protocol = modest_protocol_registry_get_protocol_by_type (registry, store_protocol_type); + account_hits->store_protocol = g_strdup (modest_protocol_get_name (store_protocol)); account_hits->header_list = result_list; account_hits->mailbox_id = NULL; + account_hits->unread_count = unread_count; folder_id = tny_folder_get_id (self); bar = g_strstr_len (folder_id, -1, "/");