+ /* If there are not more folders, begin to search from the first one */
+ if (helper->pending_calls == 0) {
+ TnyIterator *iter = tny_list_create_iterator (helper->all_folders);
+ TnyFolder *first = TNY_FOLDER (tny_iterator_get_current (iter));
+
+ _search_folder (first, helper);
+
+ g_object_unref (first);
+ g_object_unref (iter);
+ }
+}
+
+static void
+_search_account (TnyAccount *account,
+ SearchHelper *helper)
+{
+ TnyList *folders = tny_simple_list_new ();
+
+ 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,
+ FALSE, modest_search_account_get_folders_cb,
+ NULL, helper);