Changeset 2535

Show
Ignore:
Timestamp:
07/31/07 00:33:39
Author:
pvanhoof
Message:

Cleaning up

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/pvanhoof/sessionwork/ChangeLog

    r2532 r2535  
     12007-07-31  Philip Van Hoof  <pvanhoof@gnome.org> 
     2 
     3        * Cleaning up, coding style fixes 
     4        * Review of TnyCamelFolder and TnyCamelStoreAccount 
     5 
    162007-07-30  Philip Van Hoof  <pvanhoof@gnome.org> 
    27 
  • devel/pvanhoof/sessionwork/libtinymail-camel/tny-camel-account.c

    r2526 r2535  
    13371337        GError *err; 
    13381338        TnyCamelSetOnlineCallback callback; 
     1339 
     1340        GCond* condition; 
     1341        gboolean had_callback; 
     1342        GMutex *mutex; 
     1343 
    13391344} OnSetOnlineInfo; 
    13401345 
     
    13431348{ 
    13441349        OnSetOnlineInfo *info = (OnSetOnlineInfo *) data; 
    1345  
    13461350        if (info->callback) 
    13471351                info->callback (info->account, info->err); 
    1348  
    13491352        return FALSE; 
    13501353} 
     
    13611364        /* Thread reference */ 
    13621365        g_object_unref (info->account); 
    1363         g_slice_free (OnSetOnlineInfo, data); 
    1364  
    1365         return; 
     1366 
     1367        if (info->condition) { 
     1368                g_mutex_lock (info->mutex); 
     1369                g_cond_broadcast (info->condition); 
     1370                info->had_callback = TRUE; 
     1371                g_mutex_unlock (info->mutex); 
     1372        } 
     1373 
     1374        return; 
     1375
     1376 
     1377/** 
     1378 * When using a #GMainLoop this method will execute a callback using 
     1379 * g_idle_add_full.  Note that without a #GMainLoop, the callbacks 
     1380 * could happen in a worker thread (depends on who call it) at an 
     1381 * unknown moment in time (check your locking in this case). 
     1382 */ 
     1383static void 
     1384execute_callback (gint depth,  
     1385                  gint priority, 
     1386                  GSourceFunc idle_func, 
     1387                  gpointer data,  
     1388                  GDestroyNotify destroy_func) 
     1389
     1390        if (depth > 0){ 
     1391                g_idle_add_full (priority, idle_func, data, destroy_func); 
     1392        } else { 
     1393                idle_func (data); 
     1394                destroy_func (data); 
     1395        } 
    13661396} 
    13671397 
     
    13821412        info->callback = (TnyCamelSetOnlineCallback) user_data; 
    13831413 
    1384         g_idle_add_full (G_PRIORITY_HIGH, on_set_online_done_idle_func,  
     1414        info->mutex = g_mutex_new (); 
     1415        info->condition = g_cond_new (); 
     1416        info->had_callback = FALSE; 
     1417 
     1418        execute_callback (/* info->depth */ 10, G_PRIORITY_HIGH,  
     1419                on_set_online_done_idle_func,  
    13851420                info, on_set_online_done_destroy_func); 
     1421 
     1422        /* Wait on the queue for the mainloop callback to be finished */ 
     1423        g_mutex_lock (info->mutex); 
     1424        if (!info->had_callback) 
     1425                g_cond_wait (info->condition, info->mutex); 
     1426        g_mutex_unlock (info->mutex); 
     1427 
     1428        g_mutex_free (info->mutex); 
     1429        g_cond_free (info->condition); 
     1430 
     1431        g_slice_free (OnSetOnlineInfo, info); 
    13861432 
    13871433        return; 
     
    14021448                _tny_camel_store_account_queue_going_online ( 
    14031449                        TNY_CAMEL_STORE_ACCOUNT (self), session, online,  
    1404                         on_set_online_done, (gpointer ) callback); 
     1450                        on_set_online_done, (gpointer) callback); 
    14051451        } 
    14061452 
  • devel/pvanhoof/sessionwork/libtinymail-camel/tny-camel-folder.c

    r2532 r2535  
    515515        gboolean haderr = FALSE; 
    516516 
    517         g_assert (TNY_IS_CAMEL_MSG (msg)); 
    518  
    519         if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), priv->account, err,  
    520                         TNY_FOLDER_ERROR, TNY_FOLDER_ERROR_ADD_MSG)) 
     517        if (!TNY_IS_CAMEL_MSG (msg)) 
     518        { 
     519                g_critical ("You must not use a non-TnyCamelMsg implementation " 
     520                        "of TnyMsg with TnyCamelFolder types. This indicates a " 
     521                        "problem in the software (unsupported operation)\n"); 
     522                g_assert (TNY_IS_CAMEL_MSG (msg)); 
     523        } 
     524 
     525        if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv),  
     526                        priv->account, err, TNY_FOLDER_ERROR,  
     527                        TNY_FOLDER_ERROR_ADD_MSG)) 
    521528                return; 
    522529 
     
    539546                gint a = 0, len = 0, nlen = 0; 
    540547                CamelException ex2 = CAMEL_EXCEPTION_INITIALISER; 
     548 
    541549                len = priv->folder->summary->messages->len; 
    542550                dst_orig_uids = g_ptr_array_sized_new (len); 
    543                 for (a = 0; a < len; a++) { 
    544                         CamelMessageInfo *om = camel_folder_summary_index (priv->folder->summary, a); 
     551 
     552                for (a = 0; a < len; a++)  
     553                { 
     554                        CamelMessageInfo *om =  
     555                                camel_folder_summary_index (priv->folder->summary, a); 
    545556                        if (om && om->uid) 
    546557                                g_ptr_array_add (dst_orig_uids, g_strdup (om->uid)); 
     
    548559                                camel_message_info_free (om); 
    549560                } 
    550          
     561 
    551562                camel_folder_append_message (priv->folder, message, NULL, NULL, &ex); 
    552563                priv->unread_length = camel_folder_get_unread_message_count (priv->folder); 
     
    558569                for (a = 0; a < nlen; a++)  
    559570                { 
    560                         CamelMessageInfo *om = camel_folder_summary_index (priv->folder->summary, a); 
    561                         if (om && om->uid) { 
     571                        CamelMessageInfo *om =  
     572                                camel_folder_summary_index (priv->folder->summary, a); 
     573 
     574                        if (om && om->uid)  
     575                        { 
    562576                                gint b = 0; 
    563577                                gboolean found = FALSE; 
     
    649663        g_assert (TNY_IS_HEADER (header)); 
    650664 
    651         if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), priv->account, err,  
    652                         TNY_FOLDER_ERROR, TNY_FOLDER_ERROR_REMOVE_MSG)) 
     665        if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv),  
     666                        priv->account, err, TNY_FOLDER_ERROR,  
     667                        TNY_FOLDER_ERROR_REMOVE_MSG)) 
    653668                return; 
    654669 
     
    670685        tny_msg_remove_strategy_perform_remove (priv->remove_strat, self, header, err); 
    671686 
    672  
    673687        /* Notify about unread count */ 
    674688        _tny_camel_folder_check_unread_count (TNY_CAMEL_FOLDER (self)); 
     
    796810        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
    797811        priv->cached_length = len; 
    798  
    799812        return; 
    800813} 
     
    806819        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
    807820        priv->local_size = len; 
    808  
    809821        return; 
    810822} 
     
    820832{ 
    821833        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
    822  
    823834        return priv->cached_length; 
    824835} 
     
    835846{ 
    836847        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
    837  
    838848        return TNY_ACCOUNT (g_object_ref (priv->account)); 
    839849} 
     
    852862} 
    853863 
    854 /** 
    855  * When using a #GMainLoop this method will execute a callback using 
     864/* When using a #GMainLoop this method will execute a callback using 
    856865 * g_idle_add_full.  Note that without a #GMainLoop, the callbacks 
    857866 * could happen in a worker thread (depends on who call it) at an 
    858  * unknown moment in time (check your locking in this case). 
    859  */ 
     867 * unknown moment in time (check your locking in this case). */ 
     868 
    860869static void 
    861870execute_callback (gint depth,  
     
    888897        CamelException ex = CAMEL_EXCEPTION_INITIALISER; 
    889898 
    890         if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), priv->account, err,  
    891                         TNY_FOLDER_ERROR, TNY_FOLDER_ERROR_SYNC)) 
     899        if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv),  
     900                        priv->account, err, TNY_FOLDER_ERROR,  
     901                        TNY_FOLDER_ERROR_SYNC)) 
    892902                return; 
    893903 
     
    949959        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
    950960 
     961        /* thread reference */ 
    951962        _tny_camel_folder_unreason (priv); 
    952  
    953         /* thread reference */ 
    954963        g_object_unref (G_OBJECT (self)); 
     964 
    955965        if (info->err) 
    956966                g_error_free (info->err); 
     
    960970        tny_idle_stopper_destroy (info->stopper); 
    961971        info->stopper = NULL; 
    962  
    963972 
    964973        if (info->condition) { 
     
    980989        TnyFolderChange *change = tny_folder_change_new (self); 
    981990 
    982         if (info->callback) 
    983                 info->callback (info->self, info->cancelled, &info->err, info->user_data); 
    984  
    985         tny_idle_stopper_stop (info->stopper); 
    986  
    987991        tny_folder_change_set_new_all_count (change, priv->cached_length); 
    988992        tny_folder_change_set_new_unread_count (change, priv->unread_length); 
     
    990994        g_object_unref (change); 
    991995 
     996        if (info->callback) 
     997                info->callback (info->self, info->cancelled, &info->err, info->user_data); 
     998 
     999        tny_idle_stopper_stop (info->stopper); 
     1000 
    9921001        return FALSE; 
    9931002} 
     
    10271036        { 
    10281037                tny_camel_folder_sync_async_destroyer (info); 
     1038                g_slice_free (SyncFolderInfo, thr_user_data); 
    10291039                g_static_rec_mutex_unlock (priv->folder_lock); 
    10301040                return NULL; 
     
    10711081                          tny_camel_folder_sync_async_destroyer); 
    10721082 
     1083 
    10731084        /* Wait on the queue for the mainloop callback to be finished */ 
    1074  
    10751085        g_mutex_lock (info->mutex); 
    10761086        if (!info->had_callback) 
     
    10901100{ 
    10911101        SyncFolderInfo *info = thr_user_data; 
    1092  
    10931102        g_error_free (info->err); 
    10941103        g_object_unref (info->self); 
    10951104        g_slice_free (SyncFolderInfo, thr_user_data); 
     1105        return; 
    10961106} 
    10971107 
     
    11001110{ 
    11011111        SyncFolderInfo *info = thr_user_data; 
    1102  
    11031112        if (info->callback) 
    11041113                info->callback (info->self, TRUE, &info->err, info->user_data); 
    1105  
    11061114        return FALSE; 
    11071115} 
     1116 
    11081117void  
    11091118tny_camel_folder_sync_async_default (TnyFolder *self, gboolean expunge, TnySyncFolderCallback callback, TnyStatusCallback status_callback, gpointer user_data) 
     
    11631172        gpointer user_data; 
    11641173        gboolean cancelled; 
    1165         /* This stops us from calling a status callback after the operation has  
    1166          * finished. */ 
    11671174        TnyIdleStopper* stopper; 
    11681175        guint depth; 
     
    11781185 
    11791186/** This is the GDestroyNotify callback provided to g_idle_add_full() 
    1180  * for tny_camel_folder_refresh_async_callback(). 
    1181  */ 
     1187 * for tny_camel_folder_refresh_async_callback().*/ 
     1188 
    11821189static void 
    11831190tny_camel_folder_refresh_async_destroyer (gpointer thr_user_data) 
     
    11871194        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
    11881195 
     1196        /* thread reference */ 
    11891197        _tny_camel_folder_unreason (priv); 
    1190  
    1191         /* thread reference */ 
    11921198        g_object_unref (G_OBJECT (self)); 
     1199 
    11931200        if (info->err) 
    11941201                g_error_free (info->err); 
     
    12171224        TnyFolderChange *change = tny_folder_change_new (self); 
    12181225 
    1219         if (info->callback) 
    1220                 info->callback (info->self, info->cancelled, &info->err, info->user_data); 
    1221  
    1222         /* Prevent status callbacks from being called after this 
    1223          * (can happen because the 2 idle callbacks have different priorities) 
    1224          * by causing tny_idle_stopper_is_stopped() to return TRUE. */ 
    1225         tny_idle_stopper_stop (info->stopper); 
    1226  
    12271226        tny_folder_change_set_new_all_count (change, priv->cached_length); 
    12281227        tny_folder_change_set_new_unread_count (change, priv->unread_length); 
     
    12301229        g_object_unref (change); 
    12311230 
     1231        if (info->callback) 
     1232                info->callback (info->self, info->cancelled, &info->err, info->user_data); 
     1233 
     1234        /* Prevent status callbacks from being called after this 
     1235         * (can happen because the 2 idle callbacks have different priorities) 
     1236         * by causing tny_idle_stopper_is_stopped() to return TRUE. */ 
     1237 
     1238        tny_idle_stopper_stop (info->stopper); 
     1239 
    12321240        return FALSE; 
    12331241} 
     
    12671275        { 
    12681276                tny_camel_folder_refresh_async_destroyer (info); 
     1277                g_slice_free (RefreshFolderInfo, info); 
    12691278                g_static_rec_mutex_unlock (priv->folder_lock); 
    12701279                return NULL; 
     
    13341343{ 
    13351344        RefreshFolderInfo *info = thr_user_data; 
    1336  
    13371345        g_error_free (info->err); 
    13381346        g_object_unref (info->self); 
    13391347        g_slice_free (RefreshFolderInfo, thr_user_data); 
     1348        return; 
    13401349} 
    13411350 
     
    13441353{ 
    13451354        RefreshFolderInfo *info = thr_user_data; 
    1346  
    13471355        if (info->callback) 
    13481356                info->callback (info->self, TRUE, &info->err, info->user_data); 
    1349  
    13501357        return FALSE; 
    13511358} 
     
    13651372 * become zero while doing stuff on the instance in the background, don't you? 
    13661373 **/ 
     1374 
    13671375static void 
    13681376tny_camel_folder_refresh_async_default (TnyFolder *self, TnyRefreshFolderCallback callback, TnyStatusCallback status_callback, gpointer user_data) 
     
    14321440        TnyFolderChange *change = NULL; 
    14331441 
    1434         if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), priv->account, err,  
    1435                         TNY_FOLDER_ERROR, TNY_FOLDER_ERROR_REFRESH)) 
     1442        if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv),  
     1443                        priv->account, err, TNY_FOLDER_ERROR,  
     1444                        TNY_FOLDER_ERROR_REFRESH)) 
    14361445                return; 
    14371446 
     
    14451454        } 
    14461455 
    1447         /*_tny_camel_account_start_camel_operation (TNY_CAMEL_ACCOUNT (priv->account),  
    1448                 NULL, NULL, NULL); */ 
    1449  
    14501456        oldlen = priv->cached_length; 
    14511457        oldurlen = priv->unread_length; 
     
    14541460        camel_folder_refresh_info (priv->folder, &ex); 
    14551461        priv->want_changes = TRUE; 
    1456  
    1457         /* _tny_camel_account_stop_camel_operation (TNY_CAMEL_ACCOUNT (priv->account)); */ 
    14581462 
    14591463        priv->cached_length = camel_folder_get_message_count (priv->folder);     
     
    14611465                priv->unread_length = (guint) camel_folder_get_unread_message_count (priv->folder); 
    14621466        update_iter_counts (priv); 
    1463  
    14641467 
    14651468        if (camel_exception_is_set (&ex)) 
     
    15071510 
    15081511        header = _tny_camel_header_new (); 
    1509  
    1510         _tny_camel_header_set_folder (TNY_CAMEL_HEADER (header), TNY_CAMEL_FOLDER (self), priv); 
    1511         _tny_camel_header_set_camel_message_info (TNY_CAMEL_HEADER (header), mi, FALSE); 
    1512  
    1513         tny_list_prepend (headers, (GObject*)header); 
    1514  
    1515         g_object_unref (G_OBJECT (header)); 
     1512        _tny_camel_header_set_folder ((TnyCamelHeader *) header, (TnyCamelFolder *) self, priv); 
     1513        _tny_camel_header_set_camel_message_info ((TnyCamelHeader *) header, mi, FALSE); 
     1514        tny_list_prepend (headers, (GObject*) header); 
     1515        g_object_unref (header); 
    15161516 
    15171517        return; 
     
    15381538                return; 
    15391539 
    1540         /* we reason the folder to make sure it does not 
    1541          * lose all the references and uncache, causing an interlock */ 
    1542         _tny_camel_folder_reason (priv); 
    15431540        g_static_rec_mutex_lock (priv->folder_lock); 
    15441541 
     
    15501547        } 
    15511548 
    1552         g_object_ref (G_OBJECT (headers)); 
    1553  
     1549        /* We reason the folder to make sure it does not lose all the references 
     1550         * and uncache, causing an interlock */ 
     1551        _tny_camel_folder_reason (priv); 
     1552 
     1553        g_object_ref (headers); 
    15541554        ptr = g_slice_new (FldAndPriv); 
    15551555        ptr->self = self; 
     
    15771577        g_slice_free (FldAndPriv, ptr); 
    15781578 
    1579         g_object_unref (G_OBJECT (headers)); 
     1579        g_object_unref (headers); 
     1580 
    15801581        g_static_rec_mutex_unlock (priv->folder_lock); 
    15811582        _tny_camel_folder_unreason (priv); 
     
    16131614{ 
    16141615        GetMsgInfo *info = (GetMsgInfo *) thr_user_data; 
     1616        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (info->self); 
     1617 
     1618        /* thread reference */ 
     1619        _tny_camel_folder_unreason (priv); 
     1620        g_object_unref (info->self); 
     1621 
     1622          if (info->err) 
     1623                g_error_free (info->err); 
     1624 
     1625        _tny_session_stop_operation (info->session); 
     1626 
     1627        tny_idle_stopper_destroy (info->stopper); 
     1628        info->stopper = NULL; 
     1629 
     1630        if (info->condition) { 
     1631                g_mutex_lock (info->mutex); 
     1632                g_cond_broadcast (info->condition); 
     1633                info->had_callback = TRUE; 
     1634                g_mutex_unlock (info->mutex); 
     1635        } 
     1636 
     1637        return; 
     1638} 
     1639 
     1640 
     1641static gboolean 
     1642tny_camel_folder_get_msg_async_callback (gpointer thr_user_data) 
     1643{ 
     1644        GetMsgInfo *info = (GetMsgInfo *) thr_user_data; 
    16151645        TnyFolderChange *change; 
    16161646        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (info->self); 
     
    16251655        } 
    16261656 
    1627         /* thread reference */ 
    1628         _tny_camel_folder_unreason (priv); 
    1629         g_object_unref (info->self); 
    1630  
    1631           if (info->err) 
    1632                 g_error_free (info->err); 
    1633  
    1634         _tny_session_stop_operation (info->session); 
    1635  
    1636         tny_idle_stopper_destroy (info->stopper); 
    1637         info->stopper = NULL; 
    1638  
    1639         if (info->condition) { 
    1640                 g_mutex_lock (info->mutex); 
    1641                 g_cond_broadcast (info->condition); 
    1642                 info->had_callback = TRUE; 
    1643                 g_mutex_unlock (info->mutex); 
    1644         } 
    1645  
    1646         return; 
    1647 } 
    1648  
    1649  
    1650 static gboolean 
    1651 tny_camel_folder_get_msg_async_callback (gpointer thr_user_data) 
    1652 { 
    1653         GetMsgInfo *info = (GetMsgInfo *) thr_user_data; 
    1654  
    16551657        if (info->callback) 
    16561658                info->callback (info->self, info->cancelled, info->msg, &info->err, info->user_data); 
     
    16591661         * (can happen because the 2 idle callbacks have different priorities) 
    16601662         * by causing tny_idle_stopper_is_stopped() to return TRUE. */ 
     1663 
    16611664        tny_idle_stopper_stop (info->stopper); 
    16621665 
     
    16901693        CamelOperation *cancel; 
    16911694 
     1695        /* TNY TODO: Ensure load_folder here */ 
     1696 
    16921697        /* This one doesn't use the _tny_camel_account_start_camel_operation  
    16931698         * infrastructure because it doesn't need to cancel existing operations 
     
    16991704        /* To disable parallel getting of messages while summary is being retreived, 
    17001705         * restore this lock (A) */ 
    1701  
    17021706        /* g_static_rec_mutex_lock (priv->folder_lock); */ 
    17031707 
     
    17061710        camel_operation_start (cancel, (char *) "Getting message"); 
    17071711 
    1708         info->msg = tny_msg_receive_strategy_perform_get_msg (priv->receive_strat, info->self, info->header, &err); 
     1712        info->msg = tny_msg_receive_strategy_perform_get_msg (priv->receive_strat,  
     1713                        info->self, info->header, &err); 
    17091714 
    17101715        info->cancelled = camel_operation_cancel_check (cancel); 
     
    17171722        /* To disable parallel getting of messages while summary is being retreived, 
    17181723         * restore this lock (B) */ 
    1719  
    17201724        /* g_static_rec_mutex_unlock (priv->folder_lock);  */ 
    17211725 
     
    17301734                info->err = NULL; 
    17311735 
     1736        /* thread reference header */ 
    17321737        g_object_unref (info->header); 
    17331738 
     
    17591764{ 
    17601765        GetMsgInfo *info = (GetMsgInfo *) thr_user_data; 
    1761  
    17621766        g_error_free (info->err); 
    17631767        g_object_unref (info->self); 
    17641768        g_slice_free (GetMsgInfo, info); 
     1769        return; 
    17651770} 
    17661771 
     
    17701775 
    17711776        GetMsgInfo *info = (GetMsgInfo *) thr_user_data; 
    1772  
    17731777        if (info->callback) 
    17741778                info->callback (info->self, TRUE, NULL, &info->err, info->user_data); 
    1775  
    17761779        return FALSE; 
    17771780} 
     
    18251828        /* thread reference */ 
    18261829        _tny_camel_folder_reason (priv); 
    1827         g_object_ref (G_OBJECT (info->self)); 
    1828         g_object_ref (G_OBJECT (info->header)); 
     1830        g_object_ref (info->self); 
     1831 
     1832        /* thread reference header */ 
     1833        g_object_ref (info->header); 
    18291834 
    18301835        _tny_camel_queue_launch (TNY_FOLDER_PRIV_GET_MSG_QUEUE (priv),  
     
    18831888        TnyFolderChange *change; 
    18841889 
    1885         if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), priv->account, err,  
    1886                         TNY_FOLDER_ERROR, TNY_FOLDER_ERROR_GET_MSG)) 
     1890        if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv),  
     1891                        priv->account, err, TNY_FOLDER_ERROR,  
     1892                        TNY_FOLDER_ERROR_GET_MSG)) 
    18871893                return NULL; 
    18881894 
     
    19391945        const gchar *uid; 
    19401946 
    1941         if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), priv->account, err,  
    1942                         TNY_FOLDER_ERROR, TNY_FOLDER_ERROR_GET_MSG)) 
     1947        if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv),  
     1948                        priv->account, err, TNY_FOLDER_ERROR,  
     1949                        TNY_FOLDER_ERROR_GET_MSG)) 
    19431950                return NULL; 
    19441951 
     
    20382045{ 
    20392046        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
    2040  
    20412047        return priv->folder_name; 
    20422048} 
     
    22772283                TnyFolderStoreObserver *observer = TNY_FOLDER_STORE_OBSERVER (tny_iterator_get_current (iter)); 
    22782284                tny_folder_store_observer_update (observer, change); 
    2279                 g_object_unref (G_OBJECT (observer)); 
     2285                g_object_unref (observer); 
    22802286                tny_iterator_next (iter); 
    22812287        } 
    2282         g_object_unref (G_OBJECT (iter)); 
     2288        g_object_unref (iter); 
    22832289} 
    22842290 
     
    23052311                                tny_folder_get_name (evt->fol)); 
    23062312 
    2307                         g_object_unref (G_OBJECT (change)); 
     2313                        g_object_unref (change); 
    23082314                } 
    23092315 
     
    23272333                        notify_folder_store_observers_about (evt->str, change); 
    23282334 
    2329                 g_object_unref (G_OBJECT (change)); 
     2335                g_object_unref (change); 
    23302336 
    23312337                tny_debug ("tny_folder_copy: observers notify folder-add %s\n", 
     
    23632369 
    23642370                g_propagate_error (err, nerr); 
    2365                 /* g_error_free (nerr); */ 
    23662371                return retc; 
    23672372        } 
     
    25322537        CpyRecRet *cpyr; 
    25332538 
    2534         if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), priv->account, err,  
    2535                         TNY_FOLDER_ERROR, TNY_FOLDER_ERROR_COPY)) 
     2539        if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv),  
     2540                        priv->account, err, TNY_FOLDER_ERROR,  
     2541                        TNY_FOLDER_ERROR_COPY)) 
    25362542                return NULL; 
    25372543 
     
    25452551 
    25462552        if (nerr != NULL) 
    2547         { 
    25482553                g_propagate_error (err, nerr); 
    2549                 /* g_error_free (nerr); */ 
    2550         } else 
     2554        else 
    25512555                notify_folder_observers_about_copy (adds, rems, del); 
    25522556 
     
    25882592 
    25892593        if (info->err == NULL) 
    2590         { 
    25912594                notify_folder_observers_about_copy (info->adds, info->rems,  
    25922595                        info->delete_originals); 
    2593         } 
    25942596 
    25952597        if (info->new_folder) 
     
    25992601        g_object_unref (info->into); 
    26002602        g_object_unref (info->self); 
    2601         /* _tny_camel_folder_unreason (priv); */ 
    26022603 
    26032604        if (info->err) 
     
    26462647 
    26472648        /* Send back progress data only for these internal operations */ 
     2649 
     2650        if (!what) 
     2651                return; 
     2652 
    26482653        if ((g_ascii_strcasecmp(what, "Renaming folder")) && 
    26492654            (g_ascii_strcasecmp(what, "Moving messages")) && 
     
    26792684        _tny_camel_account_start_camel_operation (TNY_CAMEL_ACCOUNT (priv->account),  
    26802685                                                  tny_camel_folder_copy_async_status,  
    2681                                                   info,  
    2682                                                   "Copying folder"); 
    2683  
    2684         info->adds = NULL; info->rems = NULL; 
     2686                                                  info, "Copying folder"); 
     2687 
     2688        info->adds = NULL;  
     2689        info->rems = NULL; 
    26852690 
    26862691        cpyr = tny_camel_folder_copy_shared (info->self, info->into,  
     
    27002705        info->err = NULL; 
    27012706        if (nerr != NULL) 
    2702         { 
    27032707                g_propagate_error (&info->err, nerr); 
    2704         } 
    27052708 
    27062709        g_static_rec_mutex_unlock (priv->folder_lock); 
     
    27322735{ 
    27332736        CopyFolderInfo *info = (CopyFolderInfo *) thr_user_data; 
    2734  
    27352737        g_free (info->new_name); 
    27362738        g_error_free (info->err); 
     
    27382740        g_object_unref (info->into); 
    27392741        g_slice_free (CopyFolderInfo, info); 
     2742        return; 
    27402743} 
    27412744 
     
    27452748 
    27462749        CopyFolderInfo *info = (CopyFolderInfo *) thr_user_data; 
    2747  
    27482750        if (info->callback) 
    27492751                info->callback (info->self, info->into, TRUE, NULL, &info->err, info->user_data); 
    2750  
    27512752        return FALSE; 
    27522753} 
     
    28012802         * will be the last, and we can only unref self in the last callback: 
    28022803         * This is destroyed in the idle GDestroyNotify callback. */ 
     2804 
    28032805        info->stopper = tny_idle_stopper_new(); 
    28042806 
     
    29182920{ 
    29192921        TransferMsgsInfo *info = thr_user_data; 
    2920  
    29212922        if (info->callback) 
    29222923                info->callback (info->self, info->cancelled, &info->err, info->user_data); 
    2923  
    29242924        /* Prevent status callbacks from being called after this 
    29252925         * (can happen because the 2 idle callbacks have different priorities) 
    29262926         * by causing tny_idle_stopper_is_stopped() to return TRUE. */ 
    29272927        tny_idle_stopper_stop (info->stopper); 
    2928  
    29292928        return FALSE; 
    29302929} 
     
    29502949        g_assert (TNY_IS_FOLDER (folder_dst)); 
    29512950 
    2952         if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), priv->account, err,  
    2953                         TNY_FOLDER_ERROR, TNY_FOLDER_ERROR_TRANSFER_MSGS)) 
     2951        if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv),  
     2952                        priv->account, err, TNY_FOLDER_ERROR,  
     2953                        TNY_FOLDER_ERROR_TRANSFER_MSGS)) 
    29542954                return; 
    29552955 
     
    33233323{ 
    33243324        TransferMsgsInfo *info = thr_user_data; 
    3325  
    33263325        g_error_free (info->err); 
    33273326        g_object_unref (info->new_header_list); 
    33283327        g_object_unref (info->self); 
    33293328        g_slice_free (TransferMsgsInfo, info); 
     3329        return; 
    33303330} 
    33313331 
     
    33343334{ 
    33353335        TransferMsgsInfo *info = thr_user_data; 
    3336  
    33373336        if (info->callback) 
    33383337                info->callback (info->self, TRUE, &info->err, info->user_data); 
    3339  
    33403338        return FALSE; 
    33413339} 
     
    35093507#ifdef DEBUG_EXTRA 
    35103508        g_print ("_tny_camel_folder_unreason (%s) : %d\n",  
    3511                 priv->folder_name?priv->folder_name:"(cleared)", priv->reason_to_live); 
     3509                priv->folder_name?priv->folder_name:"(cleared)",  
     3510                        priv->reason_to_live); 
    35123511#endif 
    35133512 
     
    37713770        _tny_camel_folder_set_all_count (folder, info->total); 
    37723771        _tny_camel_folder_set_local_size (folder, info->local_size); 
     3772 
    37733773        if (!info->name) 
    3774                 g_warning ("Creating invalid folder\n"); 
     3774                g_critical ("Creating invalid folder. This indicates a problem " 
     3775                            "in the software\n"); 
     3776 
    37753777        _tny_camel_folder_set_name (folder, info->name); 
    37763778        _tny_camel_folder_set_iter (folder, info); 
     
    38033805        CamelException subex = CAMEL_EXCEPTION_INITIALISER; 
    38043806 
    3805         if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), priv->account, err,  
    3806                         TNY_FOLDER_STORE_ERROR, TNY_FOLDER_STORE_ERROR_CREATE_FOLDER)) 
     3807        if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv),  
     3808                        priv->account, err, TNY_FOLDER_STORE_ERROR,  
     3809                        TNY_FOLDER_STORE_ERROR_CREATE_FOLDER)) 
    38073810                return NULL; 
    38083811 
     
    39423945        CamelFolderInfo *iter; 
    39433946 
    3944         if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), priv->account, err,  
    3945                         TNY_FOLDER_STORE_ERROR, TNY_FOLDER_STORE_ERROR_GET_FOLDERS)) 
     3947        if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv),  
     3948                        priv->account, err, TNY_FOLDER_STORE_ERROR,  
     3949                        TNY_FOLDER_STORE_ERROR_GET_FOLDERS)) 
    39463950                return; 
    3947  
    39483951 
    39493952        if (!priv->iter && priv->iter_parented) 
     
    40294032        /* thread reference */ 
    40304033        _tny_camel_folder_unreason (priv); 
    4031         g_object_unref (G_OBJECT (info->self)); 
    4032         g_object_unref (G_OBJECT (info->list)); 
     4034        g_object_unref (info->self); 
     4035        g_object_unref (info->list); 
    40334036 
    40344037        if (info->err) 
     
    40514054{ 
    40524055        GetFoldersInfo *info = thr_user_data; 
    4053  
    40544056        if (info->callback) 
    40554057                info->callback (info->self, info->list, &info->err, info->user_data); 
    4056  
    40574058        return FALSE; 
    40584059} 
     
    41034104{ 
    41044105        GetFoldersInfo *info = thr_user_data; 
    4105  
    41064106        g_error_free (info->err); 
    41074107        g_object_unref (info->self); 
    41084108        g_object_unref (info->list); 
    41094109        g_slice_free (GetFoldersInfo, info); 
     4110        return; 
    41104111} 
    41114112 
     
    41144115{ 
    41154116        GetFoldersInfo *info = thr_user_data; 
    4116  
    41174117        if (info->callback) 
    41184118                info->callback (info->self, info->list, &info->err, info->user_data); 
    4119  
    41204119        return FALSE; 
    41214120} 
     
    42004199                if (!load_folder (priv)) 
    42014200                        return NULL; 
    4202          
     4201 
    42034202        retval = priv->folder; 
    42044203        if (retval) 
     
    42164215} 
    42174216 
    4218 typedef struct 
    4219 
     4217typedef struct { 
    42204218        TnyFolder *self; 
    42214219        gint unread; 
     
    42464244                notify_folder_observers_about (self, change); 
    42474245 
    4248  
    42494246        g_object_unref (change); 
    42504247 
     
    42564253{ 
    42574254        PokeStatusInfo *info = (PokeStatusInfo *) data; 
    4258  
    42594255        g_object_unref (info->self); 
    4260  
    42614256        g_slice_free (PokeStatusInfo, info); 
     4257        return; 
    42624258} 
    42634259 
     
    43354331                        /* Thread reference */ 
    43364332                        g_object_ref (self); 
    4337  
    43384333                        _tny_camel_queue_launch (TNY_FOLDER_PRIV_GET_QUEUE (priv),  
    43394334                                tny_camel_folder_poke_status_thread, self); 
     
    43494344 
    43504345 
    4351         if (info) 
     4346        if (info)  
    43524347        { 
    43534348                info->self = TNY_FOLDER (g_object_ref (self)); 
    4354  
    43554349                execute_callback (g_main_depth (), G_PRIORITY_HIGH,  
    43564350                                  tny_camel_folder_poke_status_callback, info,  
    43574351                                  tny_camel_folder_poke_status_destroyer); 
    4358  
    43594352        } 
    43604353 
     
    45234516         * Check for strlen(), because camel produces an empty (non-null)  
    45244517         * uri for POP. */ 
     4518 
    45254519        if (priv->iter && priv->iter->uri && (strlen (priv->iter->uri) > 0)) 
    45264520        { 
     
    45384532        } 
    45394533 
    4540         if (!retval) { /* Strange, a local one?*/ 
     4534        if (!retval) { /* Strange, a local one? */ 
    45414535                g_warning ("tny_folder_get_url_string doe