Changeset 1712

Show
Ignore:
Timestamp:
03/08/07 02:48:04
Author:
pvanhoof
Message:

Making it work

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libtinymail-camel/tny-camel-account.c

    r1665 r1712  
    216216        TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
    217217        GThread *thread; 
     218        GError *err = NULL; 
    218219 
    219220        g_mutex_lock (priv->cancel_lock); 
     
    221222        /* I know this isn't polite. But it works ;-) */ 
    222223        /* camel_operation_cancel (NULL); */ 
    223         thread = g_thread_create (camel_cancel_hack_thread, NULL, TRUE, NULL); 
    224         g_thread_join (thread); 
     224        thread = g_thread_create (camel_cancel_hack_thread, NULL, TRUE, &err); 
     225        if (err == NULL) 
     226                g_thread_join (thread); 
     227        else 
     228                g_error_free (err); 
    225229 
    226230        if (priv->cancel) 
     
    781785                        camel_disco_store_set_status (CAMEL_DISCO_STORE (priv->service), 
    782786                                                                                  CAMEL_DISCO_STORE_ONLINE, &ex); 
     787                        if (!camel_exception_is_set (&ex)) 
     788                                camel_service_connect (CAMEL_SERVICE (priv->service), &ex); 
     789 
    783790                        goto done; 
    784791                } else if (camel_disco_store_can_work_offline (CAMEL_DISCO_STORE (priv->service))) { 
  • trunk/libtinymail-camel/tny-camel-folder.c

    r1706 r1712  
    970970        } 
    971971 
    972         _tny_camel_account_start_camel_operation (TNY_CAMEL_ACCOUNT (priv->account),  
    973                 NULL, NULL, NULL); 
     972        /*_tny_camel_account_start_camel_operation (TNY_CAMEL_ACCOUNT (priv->account),  
     973                NULL, NULL, NULL); */ 
    974974 
    975975        oldlen = priv->cached_length; 
     
    980980        priv->want_changes = TRUE; 
    981981 
    982         _tny_camel_account_stop_camel_operation (TNY_CAMEL_ACCOUNT (priv->account)); 
     982        /* _tny_camel_account_stop_camel_operation (TNY_CAMEL_ACCOUNT (priv->account)); */ 
    983983 
    984984        priv->cached_length = camel_folder_get_message_count (priv->folder);     
  • trunk/tests/functional/folder-lister.c

    r1437 r1712  
    8686        TnyStoreAccount *account; 
    8787        TnyIterator *iter; 
    88      
     88        gint i; 
     89 
    8990        free (malloc (10)); 
    90      
     91 
    9192        g_type_init (); 
    9293 
    93       context = g_option_context_new ("- The tinymail functional tester"); 
     94      context = g_option_context_new ("- The tinymail functional tester"); 
    9495        g_option_context_add_main_entries (context, options, "tinymail"); 
    95       g_option_context_parse (context, &argc, &argv, NULL); 
     96      g_option_context_parse (context, &argc, &argv, NULL); 
    9697 
    9798        account_store = tny_test_account_store_new (online, cachedir); 
     
    101102 
    102103        g_option_context_free (context); 
    103      
    104104        accounts = tny_simple_list_new (); 
    105105 
    106106        tny_account_store_get_accounts (account_store, accounts,  
    107               TNY_ACCOUNT_STORE_STORE_ACCOUNTS); 
     107               TNY_ACCOUNT_STORE_STORE_ACCOUNTS); 
    108108        g_object_unref (G_OBJECT (account_store)); 
    109      
    110109        iter = tny_list_create_iterator (accounts); 
    111110        account = (TnyStoreAccount*) tny_iterator_get_current (iter); 
    112111 
    113         recursion_level = 0;         
    114         recurse_folders (TNY_FOLDER_STORE (account), NULL); 
    115      
     112        recursion_level = 0; 
     113        for (i=0; i<1; i++)  
     114                recurse_folders (TNY_FOLDER_STORE (account), NULL); 
     115 
    116116        g_object_unref (G_OBJECT (account)); 
    117117        g_object_unref (G_OBJECT (iter)); 
    118118        g_object_unref (G_OBJECT (accounts)); 
    119      
     119 
    120120        return 0; 
    121121} 
  • trunk/tests/memory/memory-test.c

    r1711 r1712  
    3434#include <tny-camel-header-priv.h> 
    3535 
    36 typedef void (*performer) (TnyFolder *folder); 
     36typedef void (*performer_t) (TnyFolder *folder); 
     37static gint recursion_level=0; 
     38static gchar *cachedir=NULL; 
     39static gboolean online=FALSE, justget=FALSE; 
    3740 
    3841static void 
    3942do_get_folder (TnyFolder *folder) 
    40 {    
     43{ 
    4144        g_print ("Getting headers of %s ...\n", tny_folder_get_id (folder)); 
    4245        tny_folder_refresh (folder, NULL); 
     
    5053        gint length, bytes; 
    5154        gdouble kbytes, mbytes; 
    52      
     55 
    5356        g_print ("Loading headers for %s ...\n", tny_folder_get_id (folder)); 
    5457        tny_folder_get_headers (folder, headers, FALSE, NULL); 
    5558        length=tny_list_get_length (headers); 
    5659         
    57       bytes = (sizeof (TnyCamelHeader) + sizeof (CamelMessageInfo) +  
     60      bytes = (sizeof (TnyCamelHeader) + sizeof (CamelMessageInfo) +  
    5861                 sizeof (CamelMessageInfoBase) +  
    5962                 sizeof (CamelMessageContentInfo)); 
    60      
     63 
    6164        kbytes = ((gdouble)bytes) / 1024; 
    62       mbytes = kbytes / 1024; 
    63      
     65      mbytes = kbytes / 1024; 
     66 
    6467        g_print ("Loaded %d headers\n\n", length); 
    6568 
    66       g_print ("\tsizeof (TnyHeader) = %d - accounts for %d bytes (~%.2lfK)\n", sizeof (TnyCamelHeader), length * sizeof (TnyCamelHeader), ((gdouble)length * sizeof (TnyCamelHeader))/1024); 
     69      g_print ("\tsizeof (TnyHeader) = %d - accounts for %d bytes (~%.2lfK)\n", sizeof (TnyCamelHeader), length * sizeof (TnyCamelHeader), ((gdouble)length * sizeof (TnyCamelHeader))/1024); 
    6770        g_print ("\tsizeof (CamelMessageInfo) = %d - accounts for %d bytes (~%.2lfK)\n", sizeof (CamelMessageInfo), length * sizeof (CamelMessageInfo), ((gdouble)length * sizeof (CamelMessageInfo))/1024); 
    6871        g_print ("\tsizeof (CamelMessageInfoBase) = %d - accounts for %d bytes (~%.2lfK)\n", sizeof (CamelMessageInfoBase), length * sizeof (CamelMessageInfoBase), ((gdouble)length * sizeof (CamelMessageInfoBase))/1024); 
     
    7174        g_print ("\nThis means that (at least) %d bytes or ~%.2lfK or ~%.2lfM are needed for this folder\n", bytes, kbytes, mbytes); 
    7275 
    73       g_print ("Sleeping to allow your valgrind to see this...\n"); 
     76      g_print ("Sleeping to allow your valgrind to see this...\n"); 
    7477        sleep (5); 
    7578        g_print ("Unloading headers ...\n"); 
    7679        g_object_unref (G_OBJECT (headers)); 
    77               g_print ("Sleeping to allow your valgrind to see this...\n"); 
     80              g_print ("Sleeping to allow your valgrind to see this...\n"); 
    7881        sleep (5); 
    7982} 
    80  
    81  
    82 static void 
    83 recurse_folders (TnyFolderStore *store, TnyFolderStoreQuery *query, const gchar *folname, performer func) 
    84 { 
    85         TnyIterator *iter; 
    86         TnyList *folders = tny_simple_list_new (); 
    87  
    88         tny_folder_store_get_folders (store, folders, query, NULL); 
    89         iter = tny_list_create_iterator (folders); 
    90  
    91         while (!tny_iterator_is_done (iter)) 
    92         { 
    93                 TnyFolderStore *folder = (TnyFolderStore*) tny_iterator_get_current (iter); 
    94 printf ("%s\n", folname); 
    95                 if (!strcmp (tny_folder_get_id (TNY_FOLDER (folder)), folname)) 
    96                         func (TNY_FOLDER (folder)); 
    97              
    98                 recurse_folders (folder, query, folname, func); 
    99              
    100                 g_object_unref (G_OBJECT (folder)); 
    101  
    102                 tny_iterator_next (iter);            
    103         } 
    104  
    105          g_object_unref (G_OBJECT (iter)); 
    106          g_object_unref (G_OBJECT (folders)); 
    107 } 
    108  
    109  
    110 static gchar *cachedir=NULL; 
    111 static gboolean online=FALSE; 
    11283 
    11384static const GOptionEntry options[] =  
     
    11687                "Cache directory", NULL }, 
    11788        { "online", 'o', 0, G_OPTION_ARG_NONE, &online, 
    118                 "Online or offline", NULL },     
     89                "Online or offline", NULL }, 
     90        { "justget", 'j', 0, G_OPTION_ARG_NONE, &justget, 
     91                "Just get the messages", NULL }, 
     92 
    11993        { NULL } 
    12094}; 
     
    126100        TnyAccountStore *account_store; 
    127101        TnyList *accounts; 
     102        TnyFolderStoreQuery *query; 
    128103        TnyStoreAccount *account; 
    129         TnyIterator *aiter; 
    130         TnyList *folders; 
    131         gint i=0; 
    132         gchar *folderids[12] = { 
    133             "INBOX/100", "INBOX/200","INBOX/500","INBOX/700", 
    134             "INBOX/1000", "INBOX/2000","INBOX/3000","INBOX/5000", "INBOX/10000", 
    135             "INBOX/30000", "INBOX/40000","INBOX/50000" }; 
    136      
    137         free (malloc (10)); 
    138      
     104        TnyIterator *iter, *topiter; 
     105        TnyList *folders, *topfolders; 
     106        TnyFolder *inbox; 
     107 
     108        free (malloc (10)); 
    139109        g_type_init (); 
    140110 
    141         context = g_option_context_new ("- The tinymail memory tester"); 
     111        context = g_option_context_new ("- The tinymail functional tester"); 
    142112        g_option_context_add_main_entries (context, options, "tinymail"); 
    143  
    144      
    145113        g_option_context_parse (context, &argc, &argv, NULL); 
    146114 
     
    151119 
    152120        g_option_context_free (context); 
     121        accounts = tny_simple_list_new (); 
    153122 
    154         accounts = tny_simple_list_new (); 
    155              
    156123        tny_account_store_get_accounts (account_store, accounts,  
    157124                TNY_ACCOUNT_STORE_STORE_ACCOUNTS); 
     125        g_object_unref (G_OBJECT (account_store)); 
     126        iter = tny_list_create_iterator (accounts); 
     127        account = (TnyStoreAccount*) tny_iterator_get_current (iter); 
    158128 
    159         aiter = tny_list_create_iterator (accounts); 
    160         tny_iterator_first (aiter); 
    161         account = TNY_STORE_ACCOUNT (tny_iterator_get_current (aiter)); 
    162      
    163         if (online) 
    164                 for (i=0; i<12; i++) 
    165                         recurse_folders (TNY_FOLDER_STORE (account), NULL, folderids[i], do_get_folder); 
     129        topfolders = tny_simple_list_new (); 
     130        folders = tny_simple_list_new (); 
    166131 
    167         for (i=0; i<12; i++) 
    168                 recurse_folders (TNY_FOLDER_STORE (account), NULL, folderids[i], do_test_folder); 
    169      
    170 err: 
     132        tny_folder_store_get_folders (TNY_FOLDER_STORE (account), topfolders, NULL, NULL); 
     133        topiter = tny_list_create_iterator (topfolders); 
     134        inbox = TNY_FOLDER (tny_iterator_get_current (topiter)); 
     135 
     136        tny_folder_store_get_folders (TNY_FOLDER_STORE (inbox), folders, NULL, NULL); 
     137        iter = tny_list_create_iterator (folders); 
     138 
     139        while (!tny_iterator_is_done (iter)) 
     140        { 
     141                TnyFolder *folder = (TnyFolder*) tny_iterator_get_current (iter); 
     142 
     143                printf ("NAME=%s\n", tny_folder_get_name (folder)); 
     144 
     145                if (online) 
     146                        do_get_folder (folder); 
     147                if (!justget) 
     148                        do_test_folder (folder); 
     149                g_object_unref (G_OBJECT (folder)); 
     150                tny_iterator_next (iter); 
     151        } 
     152 
     153        g_object_unref (G_OBJECT (iter)); 
     154        g_object_unref (G_OBJECT (folders)); 
     155 
     156        g_object_unref (G_OBJECT (inbox)); 
     157        g_object_unref (G_OBJECT (topiter)); 
     158        g_object_unref (G_OBJECT (topfolders)); 
     159 
    171160        g_object_unref (G_OBJECT (account)); 
    172         g_object_unref (G_OBJECT (aiter)); 
    173161        g_object_unref (G_OBJECT (accounts)); 
    174      
     162 
    175163        return 0; 
    176164} 
    177165 
     166