-static TnyFolder *
-find_inbox (TnyFolderStore *fs)
-{
- TnyList *folders;
- GError *err = NULL;
- TnyFolder *folder = NULL;
- folders = TNY_LIST (tny_simple_list_new ());
-
- tny_folder_store_get_folders (fs, folders, NULL, FALSE, &err);
- if (err == NULL) {
- TnyIterator *iterator;
-
- for (iterator = tny_list_create_iterator (folders);
- !tny_iterator_is_done (iterator);
- tny_iterator_next (iterator)) {
- TnyFolder *current;
-
- current = TNY_FOLDER (tny_iterator_get_current (iterator));
- if (tny_folder_get_folder_type (current) == TNY_FOLDER_TYPE_INBOX) {
- folder = current;
- break;
- }
- g_object_unref (current);
- }
- g_object_unref (iterator);
- }
- g_object_unref (folders);
-
- return folder;
-}
-
-static TnyList *
-get_inboxes (TnyAccount *account)
-{
- ModestProtocolType store_protocol;
- TnyList *result;
- gboolean mailboxes_protocol;
-
- result= TNY_LIST (tny_simple_list_new ());
- store_protocol = modest_account_mgr_get_store_protocol (modest_runtime_get_account_mgr (),
- tny_account_get_id (account));
- mailboxes_protocol =
- modest_protocol_registry_protocol_type_has_tag (modest_runtime_get_protocol_registry (),
- store_protocol,
- MODEST_PROTOCOL_REGISTRY_MULTI_MAILBOX_PROVIDER_PROTOCOLS);
- if (mailboxes_protocol) {
- /* Currently we disable the support for obtaining the results of multimailbox accounts */
-#ifndef DISABLE_GET_UNREAD_MSGS_FOR_MULTI_MAILBOX
- TnyList *mailboxes;
- GError *err = NULL;
- mailboxes = TNY_LIST (tny_simple_list_new ());
-
- tny_folder_store_get_folders (TNY_FOLDER_STORE (account), mailboxes, NULL, FALSE, &err);
- if (err == NULL) {
- TnyIterator *iterator;
-
- for (iterator = tny_list_create_iterator (mailboxes);
- !tny_iterator_is_done (iterator);
- tny_iterator_next (iterator)) {
- TnyFolder *mailbox;
- TnyFolder *inbox;
-
- mailbox = TNY_FOLDER (tny_iterator_get_current (iterator));
- inbox = find_inbox (TNY_FOLDER_STORE (mailbox));
- if (inbox) {
- tny_list_prepend (result, G_OBJECT (inbox));
- g_object_unref (inbox);
- }
- g_object_unref (mailbox);
- }
- g_object_unref (iterator);
- }
- g_object_unref (mailboxes);
-#endif
- } else {
- TnyFolder *inbox;
- inbox = find_inbox (TNY_FOLDER_STORE (account));
- if (inbox) {
- tny_list_prepend (result, G_OBJECT (inbox));
- g_object_unref (inbox);
- }
- }
-
- return result;
-}
-