Removed 2nd libhildonnotify-dev build dependency from debian/control
[modest] / tests / check_folder-transfer.c
index 80822bb..7278e04 100644 (file)
 #include <tny-folder.h>
 #include <tny-folder-store.h>
 #include <modest-tny-platform-factory.h>
-
+#include <modest-runtime.h>
 
 #include <modest-account-mgr.h>
 #include <modest-mail-operation.h>
+#include <modest-init.h>
 
 static gchar *cachedir=NULL;
 static gboolean move=FALSE;
@@ -59,25 +60,27 @@ find_folders (TnyFolderStore *store, TnyFolderStoreQuery *query,
                return;
 
        folders = tny_simple_list_new ();
-       tny_folder_store_get_folders (store, folders, query, NULL);
+       tny_folder_store_get_folders (store, folders, query, FALSE /*no poke*/, NULL);
        iter = tny_list_create_iterator (folders);
 
        while (!tny_iterator_is_done (iter) && (!*folder_src || !*folder_dst))
        {
                TnyFolderStore *folder = (TnyFolderStore*) tny_iterator_get_current (iter);
-               const gchar *folder_name = NULL;
+               if (folder) {
+                       const gchar *folder_name = NULL;
 
-               folder_name = tny_folder_get_name (TNY_FOLDER (folder));
+                       folder_name = tny_folder_get_name (TNY_FOLDER (folder));
 
-               if (strcmp (folder_name, src_name) == 0)
-                   *folder_src = g_object_ref (folder);
+                       if (strcmp (folder_name, src_name) == 0)
+                           *folder_src = g_object_ref (folder);
                
-               if (!strcmp (folder_name, dst_name))
-                   *folder_dst = g_object_ref (folder);
+                       if (!strcmp (folder_name, dst_name))
+                           *folder_dst = g_object_ref (folder);
 
-               find_folders (folder, query, folder_src, folder_dst);
+                       find_folders (folder, query, folder_src, folder_dst);
            
-               g_object_unref (G_OBJECT (folder));
+                       g_object_unref (G_OBJECT (folder));
+               }
 
                tny_iterator_next (iter);           
        }
@@ -106,15 +109,15 @@ main (int argc, char **argv)
        TnyStoreAccount *account;
        TnyIterator *iter;
        TnyFolder *folder_src = NULL, *folder_dst = NULL;
-       TnyPlatformFactory *fact = NULL;
        ModestAccountMgr *acc_mgr = NULL;
        ModestMailOperation *mail_op = NULL;
-       TnyAccountStore *account_store = NULL;
+       ModestTnyAccountStore *account_store = NULL;
        guint src_num_headers = 0, dst_num_headers = 0;
        GError *err;
     
        g_type_init ();
-
+       g_thread_init (NULL);
+       
        context = g_option_context_new ("Test");
        g_option_context_add_main_entries (context, options, "Modest");
        if (!g_option_context_parse (context, &argc, &argv, &err)) {
@@ -124,9 +127,12 @@ main (int argc, char **argv)
        }
        g_option_context_free (context);
 
-       fact = TNY_PLATFORM_FACTORY (modest_tny_platform_factory_get_instance ());
-       acc_mgr = MODEST_ACCOUNT_MGR (modest_tny_platform_factory_get_modest_account_mgr_instance (fact));
-       account_store = tny_platform_factory_new_account_store (fact);  
+       if (!modest_init (argc, argv)) {
+               return 0;
+       }
+
+       acc_mgr = modest_runtime_get_account_mgr ();
+       account_store = modest_runtime_get_account_store();
 
        if (cachedir)
                g_print ("Using %s as cache directory\n", cachedir);
@@ -139,8 +145,9 @@ main (int argc, char **argv)
        /* Get accounts */
        accounts = tny_simple_list_new ();
 
-       tny_account_store_get_accounts (account_store, accounts,
-             TNY_ACCOUNT_STORE_STORE_ACCOUNTS);
+       tny_account_store_get_accounts (TNY_ACCOUNT_STORE(account_store),
+                                       accounts,
+                                       TNY_ACCOUNT_STORE_STORE_ACCOUNTS);
     
        iter = tny_list_create_iterator (accounts);
        account = (TnyStoreAccount*) tny_iterator_get_current (iter);
@@ -166,16 +173,12 @@ main (int argc, char **argv)
        src_headers = tny_simple_list_new ();
        tny_folder_get_headers (folder_src, src_headers, TRUE, NULL);
 
-       mail_op = modest_mail_operation_new ();
+       mail_op = modest_mail_operation_new (NULL);
                
-       if (move)
-               modest_mail_operation_move_folder (mail_op, 
-                                                  folder_src, 
-                                                  TNY_FOLDER_STORE (folder_dst));
-       else
-               modest_mail_operation_copy_folder (mail_op, 
-                                                  folder_src, 
-                                                  TNY_FOLDER_STORE (folder_dst));
+       modest_mail_operation_xfer_folder (mail_op, 
+                                          folder_src, 
+                                          TNY_FOLDER_STORE (folder_dst), move,
+                                          NULL, NULL);
        
        g_object_unref (G_OBJECT (src_headers));
        g_object_unref (G_OBJECT (mail_op));