2007-06-03 Christian Kellner <ckellner@openismus.com>
authorChristian Kellner <ckellner@openismus.com>
Sat, 2 Jun 2007 23:14:17 +0000 (23:14 +0000)
committerChristian Kellner <ckellner@openismus.com>
Sat, 2 Jun 2007 23:14:17 +0000 (23:14 +0000)
* libmodest-dbus-client/libmodest-dbus-client.c:
Removed debugging spew.

* src/dbus_api/modest-dbus-callbacks.c:
Added debugging info.

* src/modest-search.c:
(modest_search_all_accounts):
Use tny_account_store_get_accounts () on the account store
to get all accounts which is the way to get all accounts.

* tests/dbus_api/test_search.c: (main):
Make it possible to supply the search term on the command line.

pmo-trunk-r2050

ChangeLog2
libmodest-dbus-client/libmodest-dbus-client.c
src/dbus_api/modest-dbus-callbacks.c
src/modest-search.c
tests/dbus_api/test_search.c

index 7773326..d18610e 100644 (file)
@@ -1,6 +1,22 @@
 2007-06-03  Christian Kellner  <ckellner@openismus.com>
 
        * libmodest-dbus-client/libmodest-dbus-client.c:
+       Removed debugging spew.
+
+       * src/dbus_api/modest-dbus-callbacks.c:
+       Added debugging info.
+
+       * src/modest-search.c: 
+       (modest_search_all_accounts):
+       Use tny_account_store_get_accounts () on the account store
+       to get all accounts which is the way to get all accounts.
+
+       * tests/dbus_api/test_search.c: (main):
+       Make it possible to supply the search term on the command line.
+
+2007-06-03  Christian Kellner  <ckellner@openismus.com>
+
+       * libmodest-dbus-client/libmodest-dbus-client.c:
        * libmodest-dbus-client/libmodest-dbus-client.h:
        Implement searching for mesages over raw dbus. (Client side)
        
index 709b3bb..0e96687 100644 (file)
@@ -259,8 +259,6 @@ dbus_message_iter_get_search_hit (DBusMessageIter *parent)
                return NULL;
        }
 
-       g_debug ("Umarshalling hit (%d)", dbus_message_iter_get_arg_type (parent));
-
        dbus_message_iter_recurse (parent, &child);
        
        /* msgid  */
@@ -509,9 +507,7 @@ libmodest_dbus_client_search (osso_context_t          *osso_ctx,
        dbus_message_iter_init (reply, &iter);
        arg_type = dbus_message_iter_get_arg_type (&iter);
        
-       g_debug ("iter type: %d", arg_type);
        dbus_message_iter_recurse (&iter, &child);
-       g_debug ("recursed");
 
        do {
                ModestSearchHit *hit;
@@ -526,7 +522,8 @@ libmodest_dbus_client_search (osso_context_t          *osso_ctx,
 
        dbus_message_unref (reply);
 
-       g_debug ("Done unmarshalling message");
+
+       /* TODO: This is from osso source, do we need it? */
 #if 0
        /* Tell TaskNavigator to show "launch banner" */
        msg = dbus_message_new_method_call (TASK_NAV_SERVICE,
index 9ef5ed9..63b6f99 100644 (file)
@@ -894,6 +894,8 @@ modest_dbus_req_filter (DBusConnection *con,
                search.flags |= MODEST_SEARCH_USE_OGS;
 #endif
 
+               g_debug ("Starting search for %s", search.query);
+
                hits = modest_search_all_accounts (&search);
 
                reply = dbus_message_new_method_return (message);
index d8cf19c..958dce8 100644 (file)
@@ -341,6 +341,7 @@ modest_search_folder (TnyFolder *folder, ModestSearch *search)
                        g_object_unref (msg);
 
                }
+
 go_next:
                g_object_unref (cur);
                tny_iterator_next (iter);
@@ -403,34 +404,28 @@ modest_search_account (TnyAccount *account, ModestSearch *search)
 GList *
 modest_search_all_accounts (ModestSearch *search)
 {
-       ModestAccountMgr      *account_mgr;
        ModestTnyAccountStore *astore;
-       GSList                *accounts;
-       GSList                *iter;
+       TnyList               *accounts;
+       TnyIterator           *iter;
        GList                 *hits;
 
-       account_mgr = modest_runtime_get_account_mgr ();
-
-       accounts = modest_account_mgr_account_names (account_mgr, FALSE);
-       astore = modest_runtime_get_account_store ();
        hits = NULL;
+       astore = modest_runtime_get_account_store ();
 
-       for (iter = accounts; iter; iter = iter->next) {
-               GList      *res;
-               const char *ac_name;
-               TnyAccount *account = NULL;
+       accounts = tny_simple_list_new ();
+       tny_account_store_get_accounts (TNY_ACCOUNT_STORE (astore),
+                                       accounts,
+                                       TNY_ACCOUNT_STORE_STORE_ACCOUNTS);
 
-               ac_name = (const char *) iter->data;
+       iter = tny_list_create_iterator (accounts);
+       while (!tny_iterator_is_done (iter)) {
+               TnyAccount *account;
+               GList      *res;
 
-               account = modest_tny_account_store_get_tny_account_by_account (astore,
-                                                                              ac_name,
-                                                                              TNY_ACCOUNT_TYPE_STORE);
+               account = TNY_ACCOUNT (tny_iterator_get_current (iter));
 
-               if (account == NULL) {
-                       g_warning ("Could not get account for %s", ac_name);
-                       continue;
-               }
-               
+               g_debug ("Searching account %s",
+                        tny_account_get_name (account));
                res = modest_search_account (account, search);
                
                if (res != NULL) {
@@ -441,8 +436,13 @@ modest_search_all_accounts (ModestSearch *search)
                                hits = g_list_concat (hits, res);
                        }
                }
+
+               g_object_unref (account);
+               tny_iterator_next (iter);
        }
 
+       g_object_unref (accounts);
+
        return hits;
 }
 
index 414231b..13c3322 100644 (file)
@@ -8,6 +8,7 @@ int main (int argc, char *argv[])
        gboolean res;
        ModestDBusSearchFlags flags;
        GList *hits, *iter;
+       const char *query;
 
        osso_context = osso_initialize ("test_search",
                                        "0.0.1",
@@ -24,10 +25,16 @@ int main (int argc, char *argv[])
        hits = NULL;
        flags = MODEST_DBUS_SEARCH_SUBJECT | MODEST_DBUS_SEARCH_BODY;
 
-       g_print ("Starting search ...\n");
+       if (argc == 2) {
+               query = argv[1];
+       } else {
+               query = "no";
+       }
+
+       g_print ("Starting search (%s)...\n", query);
 
        res = libmodest_dbus_client_search (osso_context,
-                                           "no",
+                                           query,
                                            "",
                                            0,
                                            0,