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)
return NULL;
}
- g_debug ("Umarshalling hit (%d)", dbus_message_iter_get_arg_type (parent));
-
dbus_message_iter_recurse (parent, &child);
/* msgid */
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;
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,
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);
g_object_unref (msg);
}
+
go_next:
g_object_unref (cur);
tny_iterator_next (iter);
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) {
hits = g_list_concat (hits, res);
}
}
+
+ g_object_unref (account);
+ tny_iterator_next (iter);
}
+ g_object_unref (accounts);
+
return hits;
}
gboolean res;
ModestDBusSearchFlags flags;
GList *hits, *iter;
+ const char *query;
osso_context = osso_initialize ("test_search",
"0.0.1",
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,