Changeset 1730

Show
Ignore:
Timestamp:
03/15/07 17:15:45
Author:
svillar
Message:

Some fixes related to tny_folder_copy and a new functional test

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r1728 r1730  
     12007-03-15  Sergio Villar Senin  <svillar@igalia.com> 
     2 
     3        * tests/funtional: added a functional test to transfer folders 
     4        * libtinymail-camel/tny-camel-session.c: removed the first_switch 
     5        attribute of TnySessionCamel 
     6        * libtinymailui-gtk/tny-gtk-folder-store-tree-model.c: the deleter 
     7        method now returns just after deleting a row 
     8        * libtinymail-camel/tny-camel-folder.c:  
     9        Added some error management code when loading folders 
     10        Added notification code to tny_camel_folder_copy_folder 
     11 
    1122007-03-14  Juerg Billeter 
    213 
  • trunk/libtinymail-camel/tny-camel-folder.c

    r1723 r1730  
    288288                        (store, priv->folder_name, 0, &ex); 
    289289 
    290                 if (priv->folder->folder_flags & CAMEL_FOLDER_IS_READONLY) 
    291                         priv->caps &= ~TNY_FOLDER_CAPS_WRITABLE; 
    292                 else 
    293                         priv->caps |= TNY_FOLDER_CAPS_WRITABLE; 
    294  
    295                 if (priv->folder->folder_flags & CAMEL_FOLDER_HAS_PUSHEMAIL_CAPABILITY) 
    296                         priv->caps |= TNY_FOLDER_CAPS_PUSHEMAIL; 
    297                 else 
    298                         priv->caps &= ~TNY_FOLDER_CAPS_PUSHEMAIL; 
    299  
    300                 /* printf ("LOAD (%s): %d\n", 
    301                                 priv->folder_name?priv->folder_name:"NUL", 
    302                                 (((CamelObject*)priv->folder)->ref_count)); */ 
    303  
    304                 if (!priv->iter || !priv->iter->name || strcmp (priv->iter->full_name, priv->folder_name) != 0) 
    305                 { 
    306                         guint32 flags = CAMEL_STORE_FOLDER_INFO_FAST | CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL; 
    307  
    308                         if (priv->iter && !priv->iter_parented) 
    309                                 camel_folder_info_free  (priv->iter); 
    310  
    311                         priv->iter = camel_store_get_folder_info (store, priv->folder_name, flags, &ex); 
    312                         priv->iter_parented = TRUE; 
     290                if (priv->folder && !camel_exception_is_set (&ex) && CAMEL_IS_FOLDER (priv->folder)) { 
     291 
     292                        if (priv->folder->folder_flags & CAMEL_FOLDER_IS_READONLY) 
     293                                priv->caps &= ~TNY_FOLDER_CAPS_WRITABLE; 
     294                        else 
     295                                priv->caps |= TNY_FOLDER_CAPS_WRITABLE; 
     296 
     297                        if (priv->folder->folder_flags & CAMEL_FOLDER_HAS_PUSHEMAIL_CAPABILITY) 
     298                                priv->caps |= TNY_FOLDER_CAPS_PUSHEMAIL; 
     299                        else 
     300                                priv->caps &= ~TNY_FOLDER_CAPS_PUSHEMAIL; 
     301 
     302                        /* printf ("LOAD (%s): %d\n", 
     303                           priv->folder_name?priv->folder_name:"NUL", 
     304                           (((CamelObject*)priv->folder)->ref_count)); */ 
     305 
     306                        if (!priv->iter || !priv->iter->name || strcmp (priv->iter->full_name, priv->folder_name) != 0) 
     307                                { 
     308                                        guint32 flags = CAMEL_STORE_FOLDER_INFO_FAST | CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL; 
     309 
     310                                        if (priv->iter && !priv->iter_parented) 
     311                                                camel_folder_info_free  (priv->iter); 
     312 
     313                                        priv->iter = camel_store_get_folder_info (store, priv->folder_name, flags, &ex); 
     314                                        priv->iter_parented = TRUE; 
     315                                } 
    313316                } 
    314317 
     
    14301433        gchar *final_name; 
    14311434        TnyFolderStoreChange *change; 
     1435        TnyFolderStore *old_parent;      
    14321436 
    14331437        if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), err,  
     
    15861590        } 
    15871591 
    1588         retval = _tny_camel_folder_new (); 
    1589         fpriv = TNY_CAMEL_FOLDER_GET_PRIVATE (retval); 
     1592        old_parent = tny_folder_get_folder_store (self); 
     1593 
     1594        if (tostore == fromstore && del) { 
     1595                retval = self; 
     1596 
     1597                /* No need to notify the folder if there was not an 
     1598                   actual change in the short (visual) name */ 
     1599                if (strcmp (tny_folder_get_name (self), new_name)) { 
     1600                        TnyFolderChange *change; 
     1601                         
     1602                        change = tny_folder_change_new (self); 
     1603                        tny_folder_change_set_rename (change, new_name); 
     1604                        notify_folder_observers_about (self, change); 
     1605                        g_object_unref (G_OBJECT (change)); 
     1606                } 
     1607        } else { 
     1608                retval = _tny_camel_folder_new (); 
     1609                 
     1610                fpriv = TNY_CAMEL_FOLDER_GET_PRIVATE (retval); 
     1611                camel_object_ref (CAMEL_OBJECT (tostore)); 
     1612                fpriv->store = tostore; 
     1613        } 
     1614 
     1615        /* Notify the deletion before the addition because otherwise 
     1616           we could delete the recently created folder instead of the 
     1617           old one. */ 
     1618        if (del) { 
     1619                TnyFolderStoreChange *change = tny_folder_store_change_new (old_parent); 
     1620                tny_folder_store_change_add_removed_folder (change, self); 
     1621                notify_folder_store_observers_about (old_parent, change); 
     1622                g_object_unref (G_OBJECT (change)); 
     1623        } 
    15901624 
    15911625        _tny_camel_folder_set_folder_info (into, TNY_CAMEL_FOLDER (retval), iter); 
    1592         camel_object_ref (CAMEL_OBJECT (tostore)); 
    1593         fpriv->store = tostore; 
    1594         _tny_camel_folder_set_parent (TNY_CAMEL_FOLDER (retval), into); 
    1595  
    1596         change = tny_folder_store_change_new (TNY_FOLDER_STORE (self)); 
     1626 
     1627        /* Notify addition */ 
     1628        change = tny_folder_store_change_new (into); 
    15971629        tny_folder_store_change_add_created_folder (change, retval); 
    1598         notify_folder_store_observers_about (TNY_FOLDER_STORE (self), change); 
     1630        notify_folder_store_observers_about (into, change); 
    15991631        g_object_unref (G_OBJECT (change)); 
    16001632 
     1633        g_object_unref (G_OBJECT (old_parent)); 
    16011634        camel_object_unref (CAMEL_OBJECT (tostore)); 
    16021635        camel_object_unref (CAMEL_OBJECT (fromstore)); 
  • trunk/libtinymail-camel/tny-session-camel-priv.h

    r1567 r1730  
    66        gpointer device; 
    77        gpointer account_store; 
    8         gboolean interactive, prev_constat, first_switch
     8        gboolean interactive, prev_constat
    99        guint connchanged_signal; 
    1010        GList *current_accounts; 
  • trunk/libtinymail-camel/tny-session-camel.c

    r1567 r1730  
    440440        TnySessionCamelPriv *priv = self->priv; 
    441441 
    442         if (priv->account_store && !priv->first_switch
     442        if (priv->account_store
    443443                g_signal_emit (priv->account_store,  
    444444                        tny_account_store_signals [TNY_ACCOUNT_STORE_ACCOUNTS_RELOADED], 0); 
     
    458458        priv->is_connecting = TRUE; 
    459459 
    460         if (priv->current_accounts && !priv->first_switch &&  
     460        if (priv->current_accounts && 
    461461                priv->prev_constat != info->online && priv->account_store) 
     462 
    462463        { 
    463464                g_list_foreach (priv->current_accounts,  
     
    471472                info, background_connect_destroy); 
    472473 
    473         priv->first_switch = FALSE; 
    474474        priv->prev_constat = info->online; 
    475475 
     
    563563        gchar *base_directory = NULL; 
    564564        gchar *camel_dir = NULL; 
     565        gboolean online; 
    565566        TnySessionCamelPriv *priv = self->priv; 
    566567 
     
    579580        camel_session_construct (session, camel_dir); 
    580581 
    581         /* Avoid the first question in connection_changed */ 
    582         priv->first_switch = tny_device_is_online (device); 
    583         camel_session_set_online ((CamelSession *) session,  
    584                 priv->first_switch);  
     582        online = tny_device_is_online (device); 
     583        camel_session_set_online ((CamelSession *) session, online);  
    585584        priv->camel_dir = camel_dir; 
    586585        g_free (base_directory); 
  • trunk/libtinymailui-gtk/tny-gtk-folder-store-tree-model.c

    r1686 r1730  
    600600deleter (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data1) 
    601601{ 
     602        gboolean retval = FALSE; 
    602603        gint type; 
    603604        GObject *folder = user_data1; 
     
    615616                        &fol, -1); 
    616617 
    617                 if (fol == folder) 
     618                if (fol == folder) { 
    618619                        gtk_tree_store_remove (GTK_TREE_STORE (model), iter); 
     620                        retval = TRUE; 
     621                } 
    619622 
    620623                g_object_unref (G_OBJECT (fol)); 
    621624        } 
    622625 
    623         return FALSE
     626        return retval
    624627} 
    625628 
  • trunk/tests/functional/.svnignore

    r1464 r1730  
    1212.deps 
    1313Makefile 
     14folder-transfer 
  • trunk/tests/functional/Makefile.am

    r1464 r1730  
    1616endif 
    1717 
    18 bin_PROGRAMS = folder-lister folder-lister-async msg-transfer msg-sender anything 
     18bin_PROGRAMS = folder-lister folder-lister-async msg-transfer msg-sender anything folder-transfer 
    1919 
    2020anything_SOURCES = anything.c 
     
    6262        $(top_builddir)/libtinymail-camel/libtinymail-camel-$(API_VERSION).la \ 
    6363        $(top_builddir)/tests/shared/libtestsshared.a 
     64 
     65folder_transfer_SOURCES = folder-transfer.c 
     66folder_transfer_LDADD = \ 
     67        $(TINYMAIL_LIBS) $(LIBTINYMAIL_GNOME_DESKTOP_LIBS) \ 
     68        $(top_builddir)/libtinymail/libtinymail-$(API_VERSION).la \ 
     69        $(top_builddir)/libtinymailui/libtinymailui-$(API_VERSION).la \ 
     70        $(top_builddir)/libtinymailui-gtk/libtinymailui-gtk-$(API_VERSION).la \ 
     71        $(top_builddir)/libtinymail-camel/libtinymail-camel-$(API_VERSION).la \ 
     72        $(top_builddir)/tests/shared/libtestsshared.a