+ g_debug ("%s: Searching account %s", __FUNCTION__, tny_account_get_name (account));
+
+ /* Add a "reference" to the folder total. This allows the code
+ not to finalize the helper if an account is fully refreshed
+ before we get the folders of the others */
+ helper->pending_calls++;
+
+ /* Get folders */
+ tny_folder_store_get_folders_async (TNY_FOLDER_STORE (account), folders, NULL,
+ modest_search_account_get_folders_cb,
+ NULL, helper);
+}
+
+void
+modest_search_account (TnyAccount *account,
+ ModestSearch *search,
+ ModestSearchCallback callback,
+ gpointer user_data)
+{
+ SearchHelper *helper;
+
+ /* Create the helper */
+ helper = create_helper (callback, search, user_data);
+
+ /* Search */
+ _search_account (account, helper);
+}
+
+void
+modest_search_all_accounts (ModestSearch *search,
+ ModestSearchCallback callback,
+ gpointer user_data)
+{
+ ModestTnyAccountStore *astore;
+ TnyList *accounts;
+ TnyIterator *iter;
+ GList *hits;
+ SearchHelper *helper;
+
+ hits = NULL;
+ astore = modest_runtime_get_account_store ();
+
+ accounts = tny_simple_list_new ();
+ tny_account_store_get_accounts (TNY_ACCOUNT_STORE (astore),
+ accounts,
+ TNY_ACCOUNT_STORE_STORE_ACCOUNTS);
+
+ /* Create the helper */
+ helper = create_helper (callback, search, user_data);
+
+ /* Search through all accounts */
+ iter = tny_list_create_iterator (accounts);
+ while (!tny_iterator_is_done (iter)) {
+ TnyAccount *account = NULL;
+
+ account = TNY_ACCOUNT (tny_iterator_get_current (iter));
+ _search_account (account, helper);
+ g_object_unref (account);
+
+ tny_iterator_next (iter);
+ }