Add store protocol to the data obtained in DBUS GetUnreadMessages
[modest] / src / dbus_api / modest-dbus-callbacks.c
index d743e96..62669a3 100644 (file)
@@ -1643,6 +1643,7 @@ 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_ARRAY_AS_STRING \
        ACCOUNT_HIT_DBUS_TYPE \
        DBUS_STRUCT_END_CHAR_AS_STRING
@@ -1902,6 +1903,7 @@ typedef struct {
 typedef struct {
        gchar *account_id;
        gchar *account_name;
+       gchar *store_protocol;
        gchar *mailbox_id;
        GList *header_list;
 } AccountHits;
@@ -1926,6 +1928,7 @@ static void return_results (GetUnreadMessagesHelper *helper)
                        AccountHits *ah = (AccountHits *) node->data;
                        const char *account_id;
                        const char *account_name;
+                       const char *store_protocol;
                        DBusMessageIter ah_struct_iter;
                        DBusMessageIter sh_array_iter;
                        GList *result_node;
@@ -1936,12 +1939,16 @@ static void return_results (GetUnreadMessagesHelper *helper)
                                                          &ah_struct_iter);
                        account_id = ah->account_id;
                        account_name = ah->account_name;
+                       store_protocol = ah->store_protocol;
                        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_open_container (&ah_struct_iter,
                                                          DBUS_TYPE_ARRAY,
@@ -1975,6 +1982,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,6 +2020,8 @@ 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;
 
        acc_iterator = tny_list_create_iterator (helper->accounts_list);
        account = TNY_ACCOUNT (tny_iterator_get_current (acc_iterator));
@@ -2041,6 +2051,10 @@ static void get_unread_messages_get_headers_cb (TnyFolder *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_type = modest_tny_account_get_protocol_type (account);
+       store_protocol = modest_protocol_registry_get_protocol_by_type (modest_runtime_get_protocol_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;