Changeset 850

Show
Ignore:
Timestamp:
08/31/06 12:00:12
Author:
pvanhoof
Message:

Refactored the TnyCamelStoreAccount type

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r849 r850  
    44        and get_folders_async methods virtual ones that can be 
    55        overridden 
     6 
     7        * Refactored TnyCamelStoreAccount into three types: 
     8        TnyCamelIMAPStoreAccount, TnyCamelNNTPStoreAccount and 
     9        TnyCamelPOPStoreAccount (todo: the folders and implementing 
     10        custom get_folders and get_folders_async methods for NNTP 
     11        and POP) 
     12 
     13        * This was a major API change 
    614 
    7152006-08-30  Thomas Hisch <t.hisch@gmail.com> 
  • trunk/libtinymail-camel/Makefile.am

    r843 r850  
    1313        tny-camel-account.h                     \ 
    1414        tny-camel-store-account.h               \ 
     15        tny-camel-imap-store-account.h          \ 
     16        tny-camel-nntp-store-account.h          \ 
     17        tny-camel-pop-store-account.h           \ 
    1518        tny-camel-transport-account.h           \ 
    1619        tny-camel-stream.h                      \ 
     
    3639        tny-camel-account.c                     \ 
    3740        tny-camel-store-account.c               \ 
     41        tny-camel-imap-store-account.c          \ 
     42        tny-camel-nntp-store-account.c          \ 
     43        tny-camel-pop-store-account.c           \ 
    3844        tny-camel-transport-account.c           \ 
    3945        tny-camel-stream.c                      \ 
  • trunk/libtinymail-camel/tny-camel-folder.c

    r849 r850  
    893893tny_camel_folder_remove_folder (TnyFolderStoreIface *self, TnyFolderIface *folder) 
    894894{ 
     895        TNY_CAMEL_FOLDER_GET_CLASS (self)->remove_folder_func (self, folder); 
     896} 
     897 
     898static void  
     899tny_camel_folder_remove_folder_default (TnyFolderStoreIface *self, TnyFolderIface *folder) 
     900{ 
    895901        /* TODO */ 
    896902     
     
    902908static TnyFolderIface* 
    903909tny_camel_folder_create_folder (TnyFolderStoreIface *self, const gchar *name) 
     910{ 
     911        return TNY_CAMEL_FOLDER_GET_CLASS (self)->create_folder_func (self, name); 
     912} 
     913 
     914 
     915static TnyFolderIface* 
     916tny_camel_folder_create_folder_default (TnyFolderStoreIface *self, const gchar *name) 
    904917{ 
    905918        /* TODO */ 
     
    11381151        class->get_folders_async_func = tny_camel_folder_get_folders_async_default; 
    11391152        class->get_folders_func = tny_camel_folder_get_folders_default; 
     1153        class->create_folder_func = tny_camel_folder_create_folder_default; 
     1154        class->remove_folder_func = tny_camel_folder_remove_folder_default; 
    11401155     
    11411156        g_type_class_add_private (object_class, sizeof (TnyCamelFolderPriv)); 
  • trunk/libtinymail-camel/tny-camel-folder.h

    r849 r850  
    5353        void (*get_folders_async_func) (TnyFolderStoreIface *self, TnyListIface *list, TnyGetFoldersCallback callback, TnyFolderStoreQuery *query, gpointer user_data); 
    5454        void (*get_folders_func) (TnyFolderStoreIface *self, TnyListIface *list, TnyFolderStoreQuery *query); 
    55  
     55        void (*remove_folder_func) (TnyFolderStoreIface *self, TnyFolderIface *folder); 
     56        TnyFolderIface* (*create_folder_func) (TnyFolderStoreIface *self, const gchar *name); 
    5657}; 
    5758 
  • trunk/libtinymail-camel/tny-camel-store-account.c

    r849 r850  
    285285tny_camel_store_account_remove_folder (TnyFolderStoreIface *self, TnyFolderIface *folder) 
    286286{ 
     287        TNY_CAMEL_STORE_ACCOUNT_GET_CLASS (self)->remove_folder_func (self, folder); 
     288} 
     289 
     290static void  
     291tny_camel_store_account_remove_folder_default (TnyFolderStoreIface *self, TnyFolderIface *folder) 
     292{ 
    287293        /* TODO */ 
    288294     
     
    294300static TnyFolderIface* 
    295301tny_camel_store_account_create_folder (TnyFolderStoreIface *self, const gchar *name) 
     302{ 
     303        return TNY_CAMEL_STORE_ACCOUNT_GET_CLASS (self)->create_folder_func (self, name); 
     304} 
     305 
     306 
     307static TnyFolderIface* 
     308tny_camel_store_account_create_folder_default (TnyFolderStoreIface *self, const gchar *name) 
    296309{ 
    297310        /* TODO */ 
     
    507520        class->get_folders_async_func = tny_camel_store_account_get_folders_async_default; 
    508521        class->get_folders_func = tny_camel_store_account_get_folders_default; 
     522        class->create_folder_func = tny_camel_store_account_create_folder_default; 
     523        class->remove_folder_func = tny_camel_store_account_remove_folder_default; 
    509524     
    510525        g_type_class_add_private (object_class, sizeof (TnyCamelStoreAccountPriv)); 
  • trunk/libtinymail-camel/tny-camel-store-account.h

    r849 r850  
    5151        void (*get_folders_async_func) (TnyFolderStoreIface *self, TnyListIface *list, TnyGetFoldersCallback callback, TnyFolderStoreQuery *query, gpointer user_data); 
    5252        void (*get_folders_func) (TnyFolderStoreIface *self, TnyListIface *list, TnyFolderStoreQuery *query); 
    53  
     53        void (*remove_folder_func) (TnyFolderStoreIface *self, TnyFolderIface *folder); 
     54        TnyFolderIface* (*create_folder_func) (TnyFolderStoreIface *self, const gchar *name); 
    5455}; 
    5556 
  • trunk/libtinymail-gnome-desktop/tny-account-store.c

    r843 r850  
    4040#include <tny-camel-account.h> 
    4141#include <tny-camel-store-account.h> 
     42#include <tny-camel-imap-store-account.h> 
     43#include <tny-camel-nntp-store-account.h> 
     44#include <tny-camel-pop-store-account.h> 
    4245#include <tny-camel-transport-account.h> 
    4346#include <tny-device.h> 
     
    4952#endif 
    5053 
    51 /* "GConf vs. Camel" account implementation */ 
     54/* "GConf vs. libtinymail-camel" account-store implementation */ 
    5255 
    5356static GObjectClass *parent_class = NULL; 
     
    363366                g_free (key); 
    364367 
     368             
    365369                key = g_strdup_printf ("/apps/tinymail/accounts/%d/type", i); 
    366370                type = gconf_client_get_string (priv->client,  
    367371                        (const gchar*) key, NULL); 
    368372                g_free (key); 
    369  
     373             
     374                key = g_strdup_printf ("/apps/tinymail/accounts/%d/proto", i); 
     375                proto = gconf_client_get_string (priv->client,  
     376                        (const gchar*) key, NULL); 
     377                g_free (key); 
     378             
     379             
    370380                if (type && G_LIKELY (!g_ascii_strncasecmp (type, "transport", 9))) 
    371381                { 
    372382                        if (types == TNY_ACCOUNT_STORE_IFACE_BOTH || types == TNY_ACCOUNT_STORE_IFACE_TRANSPORT_ACCOUNTS) 
    373383                                account = TNY_ACCOUNT_IFACE (tny_camel_transport_account_new ()); 
    374                 } else { 
    375  
    376                         if (types == TNY_ACCOUNT_STORE_IFACE_BOTH || types == TNY_ACCOUNT_STORE_IFACE_STORE_ACCOUNTS) 
    377                                 account = TNY_ACCOUNT_IFACE (tny_camel_store_account_new ()); 
     384                } else if (type && types == TNY_ACCOUNT_STORE_IFACE_BOTH || types == TNY_ACCOUNT_STORE_IFACE_STORE_ACCOUNTS) 
     385                {                
     386                        if (!g_ascii_strncasecmp (proto, "imap", 4)) 
     387                                account = TNY_ACCOUNT_IFACE (tny_camel_imap_store_account_new ()); 
     388                        else if (!g_ascii_strncasecmp (proto, "nntp", 4)) 
     389                                account = TNY_ACCOUNT_IFACE (tny_camel_nntp_store_account_new ()); 
     390                        else if (!g_ascii_strncasecmp (proto, "pop", 4)) 
     391                                account = TNY_ACCOUNT_IFACE (tny_camel_pop_store_account_new ()); 
     392                        else    /* Unknown, create a generic one? */ 
     393                                account = TNY_ACCOUNT_IFACE (tny_camel_store_account_new ()); 
    378394                } 
    379395 
     
    384400                { 
    385401                        tny_camel_account_set_session (TNY_CAMEL_ACCOUNT (account), priv->session); 
    386  
    387                         key = g_strdup_printf ("/apps/tinymail/accounts/%d/proto", i); 
    388                         proto = gconf_client_get_string (priv->client,  
    389                                 (const gchar*) key, NULL); 
    390                         g_free (key); 
    391402                        tny_account_iface_set_proto (TNY_ACCOUNT_IFACE (account), proto); 
    392403 
  • trunk/libtinymail-gpe/tny-account-store.c

    r848 r850  
    253253                g_free (key); 
    254254 
     255                key = g_strdup_printf ("/apps/tinymail/accounts/%d/proto", i); 
     256                proto = gconf_client_get_string (priv->client,  
     257                        (const gchar*) key, NULL); 
     258                g_free (key); 
     259             
     260             
    255261                if (type && G_LIKELY (!g_ascii_strncasecmp (type, "transport", 9))) 
    256262                { 
    257263                        if (types == TNY_ACCOUNT_STORE_IFACE_BOTH || types == TNY_ACCOUNT_STORE_IFACE_TRANSPORT_ACCOUNTS) 
    258264                                account = TNY_ACCOUNT_IFACE (tny_camel_transport_account_new ()); 
    259                 } else { 
    260  
    261                         if (types == TNY_ACCOUNT_STORE_IFACE_BOTH || types == TNY_ACCOUNT_STORE_IFACE_STORE_ACCOUNTS) 
    262                                 account = TNY_ACCOUNT_IFACE (tny_camel_store_account_new ()); 
     265                } else if (type && types == TNY_ACCOUNT_STORE_IFACE_BOTH || types == TNY_ACCOUNT_STORE_IFACE_STORE_ACCOUNTS) 
     266                {                
     267                        if (!g_ascii_strncasecmp (proto, "imap", 4)) 
     268                                account = TNY_ACCOUNT_IFACE (tny_camel_imap_store_account_new ()); 
     269                        else if (!g_ascii_strncasecmp (proto, "nntp", 4)) 
     270                                account = TNY_ACCOUNT_IFACE (tny_camel_nntp_store_account_new ()); 
     271                        else if (!g_ascii_strncasecmp (proto, "pop", 4)) 
     272                                account = TNY_ACCOUNT_IFACE (tny_camel_pop_store_account_new ()); 
     273                        else    /* Unknown, create a generic one? */ 
     274                                account = TNY_ACCOUNT_IFACE (tny_camel_store_account_new ()); 
    263275                } 
    264  
     276             
    265277                if (type) 
    266278                        g_free (type); 
     
    269281                { 
    270282                        tny_camel_account_set_session (TNY_CAMEL_ACCOUNT (account), priv->session); 
    271  
    272                         key = g_strdup_printf ("/apps/tinymail/accounts/%d/proto", i); 
    273                         proto = gconf_client_get_string (priv->client,  
    274                                 (const gchar*) key, NULL); 
    275                         g_free (key); 
    276283                        tny_account_iface_set_proto (TNY_ACCOUNT_IFACE (account), proto); 
    277284 
  • trunk/libtinymail-maemo/tny-account-store.c

    r848 r850  
    254254                g_free (key); 
    255255 
     256                key = g_strdup_printf ("/apps/tinymail/accounts/%d/proto", i); 
     257                proto = gconf_client_get_string (priv->client,  
     258                        (const gchar*) key, NULL); 
     259                g_free (key); 
     260             
     261             
    256262                if (type && G_LIKELY (!g_ascii_strncasecmp (type, "transport", 9))) 
    257263                { 
    258264                        if (types == TNY_ACCOUNT_STORE_IFACE_BOTH || types == TNY_ACCOUNT_STORE_IFACE_TRANSPORT_ACCOUNTS) 
    259265                                account = TNY_ACCOUNT_IFACE (tny_camel_transport_account_new ()); 
    260                 } else { 
    261  
    262                         if (types == TNY_ACCOUNT_STORE_IFACE_BOTH ||  types == TNY_ACCOUNT_STORE_IFACE_STORE_ACCOUNTS) 
    263                                 account = TNY_ACCOUNT_IFACE (tny_camel_store_account_new ()); 
     266                } else if (type && types == TNY_ACCOUNT_STORE_IFACE_BOTH || types == TNY_ACCOUNT_STORE_IFACE_STORE_ACCOUNTS) 
     267                {                
     268                        if (!g_ascii_strncasecmp (proto, "imap", 4)) 
     269                                account = TNY_ACCOUNT_IFACE (tny_camel_imap_store_account_new ()); 
     270                        else if (!g_ascii_strncasecmp (proto, "nntp", 4)) 
     271                                account = TNY_ACCOUNT_IFACE (tny_camel_nntp_store_account_new ()); 
     272                        else if (!g_ascii_strncasecmp (proto, "pop", 4)) 
     273                                account = TNY_ACCOUNT_IFACE (tny_camel_pop_store_account_new ()); 
     274                        else    /* Unknown, create a generic one? */ 
     275                                account = TNY_ACCOUNT_IFACE (tny_camel_store_account_new ()); 
    264276                } 
    265277                 
     
    270282                { 
    271283                        tny_camel_account_set_session (TNY_CAMEL_ACCOUNT (account), priv->session); 
    272  
    273  
    274                         key = g_strdup_printf ("/apps/tinymail/accounts/%d/proto", i); 
    275                         proto = gconf_client_get_string (priv->client,  
    276                                 (const gchar*) key, NULL); 
    277                         g_free (key); 
    278284                        tny_account_iface_set_proto (TNY_ACCOUNT_IFACE (account), proto); 
    279285 
  • trunk/libtinymail-olpc/tny-account-store.c

    r848 r850  
    211211 
    212212                type = g_key_file_get_value (keyfile, "tinymail", "type", NULL); 
    213  
     213                proto = g_key_file_get_value (keyfile, "tinymail", "proto", NULL); 
     214             
    214215                if (type && G_LIKELY (!g_ascii_strncasecmp (type, "transport", 9))) 
    215216                { 
    216217                        if (types == TNY_ACCOUNT_STORE_IFACE_BOTH || types == TNY_ACCOUNT_STORE_IFACE_TRANSPORT_ACCOUNTS) 
    217218                                account = TNY_ACCOUNT_IFACE (tny_camel_transport_account_new ()); 
    218                 } else { 
    219  
    220                         if (types == TNY_ACCOUNT_STORE_IFACE_BOTH || types == TNY_ACCOUNT_STORE_IFACE_STORE_ACCOUNTS) 
    221                                 account = TNY_ACCOUNT_IFACE (tny_camel_store_account_new ()); 
     219                } else if (type && types == TNY_ACCOUNT_STORE_IFACE_BOTH || types == TNY_ACCOUNT_STORE_IFACE_STORE_ACCOUNTS) 
     220                {                
     221                        if (!g_ascii_strncasecmp (proto, "imap", 4)) 
     222                                account = TNY_ACCOUNT_IFACE (tny_camel_imap_store_account_new ()); 
     223                        else if (!g_ascii_strncasecmp (proto, "nntp", 4)) 
     224                                account = TNY_ACCOUNT_IFACE (tny_camel_nntp_store_account_new ()); 
     225                        else if (!g_ascii_strncasecmp (proto, "pop", 4)) 
     226                                account = TNY_ACCOUNT_IFACE (tny_camel_pop_store_account_new ()); 
     227                        else    /* Unknown, create a generic one? */ 
     228                                account = TNY_ACCOUNT_IFACE (tny_camel_store_account_new ()); 
    222229                } 
    223230 
     
    231238 
    232239                        tny_camel_account_set_session (TNY_CAMEL_ACCOUNT (account), priv->session); 
    233  
    234                         proto = g_key_file_get_value (keyfile, "tinymail", "proto", NULL); 
    235240                        tny_account_iface_set_proto (TNY_ACCOUNT_IFACE (account), proto); 
    236241