Changeset 1784

Show
Ignore:
Timestamp:
04/13/07 02:01:38
Author:
pvanhoof
Message:

Bugfix and major API change

Files:

Legend:

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

    r1783 r1784  
    2323#include <glib.h> 
    2424 
     25#include <tny-password-getter.h> 
    2526#include <tny-account-store.h> 
    2627#include <tny-acap-account-store.h> 
     
    3839{ 
    3940        TnyAccountStore *real; 
     41        TnyPasswordGetter *pwdgetter; 
     42        guint connchanged_signal; 
    4043}; 
    4144 
     
    6972 
    7073 
     74 
     75static void 
     76connection_changed (TnyDevice *device, gboolean online, gpointer user_data) 
     77{ 
     78        TnyAcapAccountStore *self; 
     79 
     80        /* TODO: sync journal! */ 
     81} 
     82 
     83 
    7184static void 
    7285tny_acap_account_store_get_accounts (TnyAccountStore *self, TnyList *list, TnyGetAccountsRequestType types) 
    7386{ 
    7487        TnyAcapAccountStorePriv *priv = TNY_ACAP_ACCOUNT_STORE_GET_PRIVATE (self); 
    75  
    76         /* TODO: if online, sync local with remote */ 
     88        TnyDevice *device = tny_account_store_get_device (priv->real); 
     89 
     90        if (tny_device_is_online (device)) 
     91        { 
     92                gboolean cancel = FALSE; 
     93                const gchar *passw = tny_password_getter_get_password (priv->pwdgetter,  
     94                        "ACAP", _("Give the password for your ACAP server"), &cancel); 
     95 
     96                if (!cancel) 
     97                        g_print ("Using %s as password for ACAP\n", passw); 
     98 
     99                /* TODO: if online, sync local with remote.  
     100                   Don't forget the journal! */ 
     101        } 
     102 
     103        g_object_unref (G_OBJECT (device)); 
    77104 
    78105        tny_account_store_get_accounts (self, list, types); 
     
    94121 
    95122 
     123static void 
     124add_account_journal (TnyAccountStore *self, TnyAccount *account, const gchar *type) 
     125{ 
     126        g_warning ("Not implemented\n"); 
     127 
     128        /* TODO: implement for ACAP */ 
     129 
     130        return; 
     131} 
    96132 
    97133static void 
     
    99135{ 
    100136        TnyAcapAccountStorePriv *priv = TNY_ACAP_ACCOUNT_STORE_GET_PRIVATE (self); 
    101  
    102         add_account_remote (self, TNY_ACCOUNT (account), "store"); 
     137        TnyDevice *device = tny_account_store_get_device (priv->real); 
     138 
     139        if (tny_device_is_online (device)) 
     140                add_account_remote (self, TNY_ACCOUNT (account), "store"); 
     141        else 
     142                add_account_journal (self, TNY_ACCOUNT (account), "store"); 
     143 
     144        g_object_unref (G_OBJECT (device)); 
    103145 
    104146        tny_account_store_add_store_account (priv->real, account); 
     
    111153{ 
    112154        TnyAcapAccountStorePriv *priv = TNY_ACAP_ACCOUNT_STORE_GET_PRIVATE (self); 
    113  
    114         add_account_remote (self, TNY_ACCOUNT (account), "transport"); 
     155        TnyDevice *device = tny_account_store_get_device (priv->real); 
     156 
     157        if (tny_device_is_online (device)) 
     158                add_account_remote (self, TNY_ACCOUNT (account), "transport"); 
     159        else 
     160                add_account_journal (self, TNY_ACCOUNT (account), "transport"); 
     161 
     162        g_object_unref (G_OBJECT (device)); 
    115163 
    116164        tny_account_store_add_transport_account (priv->real, account); 
     
    134182 **/ 
    135183TnyAccountStore* 
    136 tny_acap_account_store_new (TnyAccountStore *real
     184tny_acap_account_store_new (TnyAccountStore *real, TnyPasswordGetter *pwdgetter
    137185{ 
    138186        TnyAcapAccountStore *self = g_object_new (TNY_TYPE_ACAP_ACCOUNT_STORE, NULL); 
    139187        TnyAcapAccountStorePriv *priv = TNY_ACAP_ACCOUNT_STORE_GET_PRIVATE (self); 
     188        TnyDevice *device; 
    140189 
    141190        priv->real = TNY_ACCOUNT_STORE (g_object_ref (G_OBJECT (real)));  
     191        priv->pwdgetter = TNY_PASSWORD_GETTER (g_object_ref (G_OBJECT (pwdgetter)));  
     192 
     193        device = tny_account_store_get_device (priv->real); 
     194        priv->connchanged_signal = g_signal_connect ( 
     195                        G_OBJECT (device), "connection_changed", 
     196                        G_CALLBACK (connection_changed), self); 
     197        g_object_unref (G_OBJECT (device)); 
    142198 
    143199        return TNY_ACCOUNT_STORE (self); 
     
    151207 
    152208        priv->real = NULL; 
     209        priv->pwdgetter; 
    153210 
    154211        return; 
     
    161218{        
    162219        TnyAcapAccountStorePriv *priv = TNY_ACAP_ACCOUNT_STORE_GET_PRIVATE (object); 
    163  
     220        TnyDevice *device; 
     221 
     222        device = tny_account_store_get_device (priv->real); 
     223        g_signal_handler_disconnect (G_OBJECT (device),  
     224                        priv->connchanged_signal); 
     225        g_object_unref (G_OBJECT (device)); 
    164226 
    165227        if (priv->real) 
    166228                g_object_unref (G_OBJECT (priv->real)); 
     229 
     230        if (priv->pwdgetter) 
     231                g_object_unref (G_OBJECT (priv->pwdgetter)); 
    167232 
    168233        (*parent_class->finalize) (object); 
  • trunk/libtinymail-acap/tny-acap-account-store.h

    r1782 r1784  
    4848 
    4949GType tny_acap_account_store_get_type (void); 
    50 TnyAccountStore* tny_acap_account_store_new (TnyAccountStore *real); 
     50TnyAccountStore* tny_acap_account_store_new (TnyAccountStore *real, TnyPasswordGetter *pwdgetter); 
    5151TnyAccountStore* tny_acap_account_store_get_real (TnyAcapAccountStore *self); 
    5252 
  • trunk/libtinymail-gnome-desktop/tny-gnome-account-store.c

    r1783 r1784  
    7878 
    7979        pwdgetter = tny_platform_factory_new_password_getter (platfact); 
    80         retval = (gchar*) tny_password_getter_get_password (pwdgetter, account, prompt, cancel); 
     80        retval = (gchar*) tny_password_getter_get_password (pwdgetter,  
     81                tny_account_get_id (account), prompt, cancel); 
    8182        g_object_unref (G_OBJECT (pwdgetter)); 
    8283 
     
    9293 
    9394        pwdgetter = tny_platform_factory_new_password_getter (platfact); 
    94         tny_password_getter_forget_password (pwdgetter, account); 
     95        tny_password_getter_forget_password (pwdgetter, tny_account_get_id (account)); 
    9596        g_object_unref (G_OBJECT (pwdgetter)); 
    9697 
  • trunk/libtinymail-gpe/tny-gpe-account-store.c

    r1783 r1784  
    7676 
    7777        pwdgetter = tny_platform_factory_new_password_getter (platfact); 
    78         retval = (gchar*) tny_password_getter_get_password (pwdgetter, account, prompt, cancel); 
     78        retval = (gchar*) tny_password_getter_get_password (pwdgetter,  
     79                tny_account_get_id (account), prompt, cancel); 
    7980        g_object_unref (G_OBJECT (pwdgetter)); 
    8081 
     
    9091 
    9192        pwdgetter = tny_platform_factory_new_password_getter (platfact); 
    92         tny_password_getter_forget_password (pwdgetter, account); 
     93        tny_password_getter_forget_password (pwdgetter, tny_account_get_id (account)); 
    9394        g_object_unref (G_OBJECT (pwdgetter)); 
    9495 
  • trunk/libtinymail-maemo/tny-maemo-account-store.c

    r1783 r1784  
    7777 
    7878        pwdgetter = tny_platform_factory_new_password_getter (platfact); 
    79         retval = (gchar*) tny_password_getter_get_password (pwdgetter, account, prompt, cancel); 
     79        retval = (gchar*) tny_password_getter_get_password (pwdgetter,  
     80                tny_account_get_id (account), prompt, cancel); 
    8081        g_object_unref (G_OBJECT (pwdgetter)); 
    8182 
     
    9192 
    9293        pwdgetter = tny_platform_factory_new_password_getter (platfact); 
    93         tny_password_getter_forget_password (pwdgetter, account); 
     94        tny_password_getter_forget_password (pwdgetter, tny_account_get_id (account)); 
    9495        g_object_unref (G_OBJECT (pwdgetter)); 
    9596 
  • trunk/libtinymail-olpc/tny-olpc-account-store.c

    r1783 r1784  
    7474 
    7575        pwdgetter = tny_platform_factory_new_password_getter (platfact); 
    76         retval = (gchar*) tny_password_getter_get_password (pwdgetter, account, prompt, cancel); 
     76        retval = (gchar*) tny_password_getter_get_password (pwdgetter,  
     77                tny_account_get_id (account), prompt, cancel); 
    7778        g_object_unref (G_OBJECT (pwdgetter)); 
    7879 
     
    8889 
    8990        pwdgetter = tny_platform_factory_new_password_getter (platfact); 
    90         tny_password_getter_forget_password (pwdgetter, account); 
     91        tny_password_getter_forget_password (pwdgetter, tny_account_get_id (account)); 
    9192        g_object_unref (G_OBJECT (pwdgetter)); 
    9293 
  • trunk/libtinymail/tny-password-getter.c

    r1783 r1784  
    3838 **/ 
    3939const gchar *  
    40 tny_password_getter_get_password (TnyPasswordGetter *self, TnyAccount *account, const gchar *prompt, gboolean *cancel) 
     40tny_password_getter_get_password (TnyPasswordGetter *self, const gchar *aid, const gchar *prompt, gboolean *cancel) 
    4141{ 
    4242#ifdef DBC /* require */ 
    4343        g_assert (TNY_IS_PASSWORD_GETTER (self)); 
    44         g_assert (TNY_IS_ACCOUNT (account)); 
    4544        g_assert (TNY_PASSWORD_GETTER_GET_IFACE (self)->get_password_func != NULL); 
    4645#endif 
    4746 
    48         return TNY_PASSWORD_GETTER_GET_IFACE (self)->get_password_func (self, account, prompt, cancel); 
     47        return TNY_PASSWORD_GETTER_GET_IFACE (self)->get_password_func (self, aid, prompt, cancel); 
    4948} 
    5049 
     
    5756 **/ 
    5857void  
    59 tny_password_getter_forget_password (TnyPasswordGetter *self, TnyAccount *account
     58tny_password_getter_forget_password (TnyPasswordGetter *self, const gchar *aid
    6059{ 
    6160#ifdef DBC /* require */ 
    6261        g_assert (TNY_IS_PASSWORD_GETTER (self)); 
    63         g_assert (TNY_IS_ACCOUNT (account)); 
    6462        g_assert (TNY_PASSWORD_GETTER_GET_IFACE (self)->forget_password_func != NULL); 
    6563#endif 
    6664 
    67         TNY_PASSWORD_GETTER_GET_IFACE (self)->forget_password_func (self, account); 
     65        TNY_PASSWORD_GETTER_GET_IFACE (self)->forget_password_func (self, aid); 
    6866 
    6967        return; 
  • trunk/libtinymail/tny-password-getter.h

    r1783 r1784  
    4343        GTypeInterface parent; 
    4444 
    45         const gchar* (*get_password_func) (TnyPasswordGetter *self, TnyAccount *account, const gchar *prompt, gboolean *cancel); 
    46         void (*forget_password_func) (TnyPasswordGetter *self, TnyAccount *account); 
     45        const gchar* (*get_password_func) (TnyPasswordGetter *self, const gchar *aid, const gchar *prompt, gboolean *cancel); 
     46        void (*forget_password_func) (TnyPasswordGetter *self, const gchar *aid); 
    4747 
    4848}; 
     
    5151 
    5252 
    53 const gchar* tny_password_getter_get_password (TnyPasswordGetter *self, TnyAccount *account, const gchar *prompt, gboolean *cancel); 
    54 void tny_password_getter_forget_password (TnyPasswordGetter *self, TnyAccount *account); 
     53const gchar* tny_password_getter_get_password (TnyPasswordGetter *self, const gchar *aid, const gchar *prompt, gboolean *cancel); 
     54void tny_password_getter_forget_password (TnyPasswordGetter *self, const gchar *aid); 
    5555 
    5656G_END_DECLS 
  • trunk/libtinymailui-gnome-keyring

    • Property svn:ignore set to libtinymailui-gnome-keyring.a Makefile.in config.h .deps Makefile .libs .svnignore stamp-h3
  • trunk/libtinymailui-gnome-keyring/tny-gnome-keyring-password-getter.c

    r1783 r1784  
    2222#include <glib/gi18n-lib.h> 
    2323 
    24 #include <tny-account.h> 
    25  
    2624#include <tny-gnome-keyring-password-getter.h> 
    2725 
     
    2927 
    3028static const gchar* 
    31 tny_gnome_keyring_password_getter_get_password (TnyPasswordGetter *self, TnyAccount *account, const gchar *prompt, gboolean *cancel) 
     29tny_gnome_keyring_password_getter_get_password (TnyPasswordGetter *self, const gchar *aid, const gchar *prompt, gboolean *cancel) 
    3230{ 
    3331        gchar *retval = NULL; 
     
    3836        gnome_keyring_get_default_keyring_sync (&keyring); 
    3937 
    40         keyringret = gnome_keyring_find_network_password_sync ( 
    41                 tny_account_get_user (account), 
    42                 "Mail", tny_account_get_hostname (account), 
    43                 "password", tny_account_get_proto (account),  
     38        keyringret = gnome_keyring_find_network_password_sync (aid, "Mail",  
     39                aid /* hostname */, 
     40                "password", aid /* proto */,  
    4441                "PLAIN", 0, &list); 
    4542 
     
    5148                                (gnome_password_dialog_new 
    5249                                        (_("Enter password"), prompt, 
    53                                         tny_account_get_user (account),  
     50                                        NULL,  
    5451                                        NULL, TRUE)); 
    5552 
     
    5754                gnome_password_dialog_set_remember (dialog,  
    5855                        GNOME_PASSWORD_DIALOG_REMEMBER_FOREVER); 
     56 
    5957                gnome_password_dialog_set_readonly_username (dialog, TRUE); 
    60                 gnome_password_dialog_set_username (dialog,  
    61                         tny_account_get_user (account)); 
     58                /* gnome_password_dialog_set_username (dialog,  
     59                        tny_account_get_user (account)); */ 
    6260 
    6361                gnome_password_dialog_set_show_username (dialog, FALSE); 
     
    8179                        { 
    8280                                gnome_keyring_set_network_password_sync (keyring, 
    83                                         tny_account_get_user (account)
    84                                         "Mail", tny_account_get_hostname (account)
    85                                         "password", tny_account_get_proto (account),  
     81                                        aid /* user */
     82                                        "Mail", aid /* hostname */
     83                                        "password", aid /* proto */,  
    8684                                        "PLAIN", 0, retval, &item_id); 
    8785                        } 
     
    111109 
    112110static void 
    113 tny_gnome_keyring_password_getter_forget_password (TnyPasswordGetter *self, TnyAccount *account
     111tny_gnome_keyring_password_getter_forget_password (TnyPasswordGetter *self, const gchar *aid
    114112{ 
    115113        GList *list=NULL; 
     
    121119 
    122120        keyringret = gnome_keyring_find_network_password_sync ( 
    123                 tny_account_get_user (account)
    124                 "Mail", tny_account_get_hostname (account)
    125                 "password", tny_account_get_proto (account),  
     121                aid /* user */
     122                "Mail", aid /* hostname */
     123                "password", aid /* proto */,  
    126124                "PLAIN", 0, &list); 
    127125 
  • trunk/libtinymailui-gtk/tny-gtk-password-dialog.c

    r1783 r1784  
    4747 
    4848static const gchar* 
    49 tny_gtk_password_dialog_get_password (TnyPasswordGetter *self, TnyAccount *account, const gchar *prompt, gboolean *cancel) 
     49tny_gtk_password_dialog_get_password (TnyPasswordGetter *self, const gchar *aid, const gchar *prompt, gboolean *cancel) 
    5050{ 
    5151        TnyGtkPasswordDialogPriv *priv = TNY_GTK_PASSWORD_DIALOG_GET_PRIVATE (self); 
    5252        GtkDialog *dialog = (GtkDialog *) self; 
    53         const gchar *accountid
     53        const gchar *accountid = aid
    5454        const gchar *retval = NULL; 
    55  
    56         accountid = tny_account_get_id (account); 
    5755 
    5856        if (G_UNLIKELY (!passwords)) 
     
    8583 
    8684static void  
    87 tny_gtk_password_dialog_forget_password (TnyPasswordGetter *self, TnyAccount *account
     85tny_gtk_password_dialog_forget_password (TnyPasswordGetter *self, const gchar *aid
    8886{ 
    8987        if (G_LIKELY (passwords)) 
    9088        { 
    91                 const gchar *accountid = tny_account_get_id (account)
     89                const gchar *accountid = aid
    9290 
    9391                gchar *pwd = g_hash_table_lookup (passwords, accountid);