Changeset 1783
- Timestamp:
- 04/13/07 01:14:48
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/Makefile.am (modified) (1 diff)
- trunk/bindings/python/Makefile.am (modified) (1 diff)
- trunk/bindings/python/tinymail.override (modified) (1 diff)
- trunk/configure.ac (modified) (1 diff)
- trunk/libtinymail-acap (modified) (1 prop)
- trunk/libtinymail-acap/.svnignore (added)
- trunk/libtinymail-acap/tny-acap-account-store.c (modified) (1 diff)
- trunk/libtinymail-gnome-desktop/Makefile.am (modified) (4 diffs)
- trunk/libtinymail-gnome-desktop/tny-gnome-account-store.c (modified) (4 diffs)
- trunk/libtinymail-gnome-desktop/tny-gnome-platform-factory.c (modified) (3 diffs)
- trunk/libtinymail-gpe/Makefile.am (modified) (2 diffs)
- trunk/libtinymail-gpe/tny-gpe-account-store.c (modified) (2 diffs)
- trunk/libtinymail-gpe/tny-gpe-password-dialog.c (deleted)
- trunk/libtinymail-gpe/tny-gpe-password-dialog.h (deleted)
- trunk/libtinymail-gpe/tny-gpe-platform-factory.c (modified) (3 diffs)
- trunk/libtinymail-maemo/Makefile.am (modified) (2 diffs)
- trunk/libtinymail-maemo/tny-maemo-account-store.c (modified) (2 diffs)
- trunk/libtinymail-maemo/tny-maemo-password-dialog.c (deleted)
- trunk/libtinymail-maemo/tny-maemo-password-dialog.h (deleted)
- trunk/libtinymail-maemo/tny-maemo-platform-factory.c (modified) (3 diffs)
- trunk/libtinymail-olpc/Makefile.am (modified) (2 diffs)
- trunk/libtinymail-olpc/tny-olpc-account-store.c (modified) (2 diffs)
- trunk/libtinymail-olpc/tny-olpc-password-dialog.c (deleted)
- trunk/libtinymail-olpc/tny-olpc-password-dialog.h (deleted)
- trunk/libtinymail-olpc/tny-olpc-platform-factory.c (modified) (3 diffs)
- trunk/libtinymail/Makefile.am (modified) (2 diffs)
- trunk/libtinymail/tny-password-getter.c (added)
- trunk/libtinymail/tny-password-getter.h (added)
- trunk/libtinymail/tny-shared.h (modified) (1 diff)
- trunk/libtinymailui-gnome-keyring (added)
- trunk/libtinymailui-gnome-keyring/Makefile.am (added)
- trunk/libtinymailui-gnome-keyring/tny-gnome-keyring-password-getter.c (added)
- trunk/libtinymailui-gnome-keyring/tny-gnome-keyring-password-getter.h (added)
- trunk/libtinymailui-gtk/Makefile.am (modified) (2 diffs)
- trunk/libtinymailui-gtk/tny-gtk-password-dialog.c (moved) (moved from trunk/libtinymail-gnome-desktop/tny-gnome-password-dialog.c) (10 diffs)
- trunk/libtinymailui-gtk/tny-gtk-password-dialog.h (moved) (moved from trunk/libtinymail-gnome-desktop/tny-gnome-password-dialog.h) (2 diffs)
- trunk/libtinymailui/tny-platform-factory.c (modified) (1 diff)
- trunk/libtinymailui/tny-platform-factory.h (modified) (2 diffs)
- trunk/tests/c-demo/tny-demoui-summary-view.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r1782 r1783 2 2 3 3 * Added skeleton for ACAP support 4 * Major modifications to the 'getting of passwords' 5 * Introduction of the TnyPasswordGetter interface 4 6 5 7 * This was a major API change trunk/Makefile.am
r1782 r1783 5 5 6 6 if BUILD_GNOME 7 SUBDIRS += libtinymailui-gnome-keyring 7 8 SUBDIRS += libtinymail-gnomevfs 8 9 endif trunk/bindings/python/Makefile.am
r1683 r1783 115 115 $(top_srcdir)/libtinymail/tny-folder-store-observer.h \ 116 116 $(top_srcdir)/libtinymail/tny-folder-store-change.h \ 117 $(top_srcdir)/libtinymail/tny-folder-stats.h 117 $(top_srcdir)/libtinymail/tny-folder-stats.h \ 118 $(top_srcdir)/libtinymail/tny-password-getter.h 118 119 119 120 tinymail.defs: $(tinymail_h_files) tinymail.defs.extra $(top_srcdir)/bindings/python/filter.py trunk/bindings/python/tinymail.override
r1683 r1783 35 35 #include <tny-folder-store-change.h> 36 36 #include <tny-folder-stats.h> 37 #include <tny-password-getter.h> 38 37 39 38 40 #define NO_IMPORT_PYGOBJECT trunk/configure.ac
r1782 r1783 402 402 libtinymailui-mozembed/Makefile 403 403 libtinymailui-mozembed/libtinymailui-mozembed.pc 404 libtinymailui-gnome-keyring/Makefile 404 405 libtinymail-gnomevfs/Makefile 405 406 libtinymail-gnomevfs/libtinymail-gnomevfs.pc trunk/libtinymail-acap
- Property svn:ignore set to Makefile.in libtinymail-acap-1.0.pc config.h .deps Makefile .libs .svnignore stamp-h3 libtinymail-acap.pc
trunk/libtinymail-acap/tny-acap-account-store.c
r1782 r1783 114 114 add_account_remote (self, TNY_ACCOUNT (account), "transport"); 115 115 116 tny_account_store_add_ store_account (priv->real, account);116 tny_account_store_add_transport_account (priv->real, account); 117 117 118 118 return; trunk/libtinymail-gnome-desktop/Makefile.am
r1014 r1783 14 14 15 15 if BUILD_GNOME 16 INCLUDES += - DGNOME16 INCLUDES += -I$(top_srcdir)/libtinymailui-gnome-keyring -DGNOME 17 17 endif 18 18 … … 21 21 libtinymail_gnome_desktop_1_0_headers = \ 22 22 tny-gnome-account-store.h \ 23 tny-gnome-password-dialog.h \24 23 tny-gnome-device.h \ 25 24 tny-gnome-platform-factory.h … … 30 29 tny-gnome-device-priv.h \ 31 30 tny-gnome-device.c \ 32 tny-gnome-password-dialog.c \33 31 tny-gnome-platform-factory.c 34 32 … … 42 40 libtinymail_gnome_desktop_1_0_la_LDFLAGS = -export-dynamic \ 43 41 -version-info $(LT_VERSION_INFO) $(LIBTOOL_EXPORT_OPTIONS) 42 43 if BUILD_GNOME 44 libtinymail_gnome_desktop_1_0_la_LIBADD += $(top_builddir)/libtinymailui-gnome-keyring/libtinymailui-gnome-keyring.a 45 endif 44 46 45 47 if BUILD_MOZEMBED trunk/libtinymail-gnome-desktop/tny-gnome-account-store.c
r1713 r1783 29 29 30 30 #include <tny-platform-factory.h> 31 #include <tny-password-getter.h> 31 32 #include <tny-gnome-platform-factory.h> 32 33 #include <tny-account-store.h> 33 34 #include <tny-gnome-account-store.h> 34 #include <tny-gnome-password-dialog.h>35 35 #include <tny-account.h> 36 36 #include <tny-store-account.h> … … 49 49 #include <tny-gtk-lockable.h> 50 50 51 #ifdef GNOME52 #include <libgnomeui/gnome-password-dialog.h>53 #include <gnome-keyring.h>54 #endif55 51 56 52 /* "GConf vs. libtinymail-camel" account-store implementation */ … … 74 70 75 71 76 #ifdef GNOME77 72 static gchar* 78 73 per_account_get_pass_func (TnyAccount *account, const gchar *prompt, gboolean *cancel) 79 74 { 80 gchar *retval = NULL; 81 GList *list; 82 GnomeKeyringResult keyringret; 83 gchar *keyring; 84 85 gnome_keyring_get_default_keyring_sync (&keyring); 86 87 keyringret = gnome_keyring_find_network_password_sync ( 88 tny_account_get_user (account), 89 "Mail", tny_account_get_hostname (account), 90 "password", tny_account_get_proto (account), 91 "PLAIN", 0, &list); 92 93 if (keyringret != GNOME_KEYRING_RESULT_OK) 94 { 95 gboolean canc = FALSE; 96 97 GnomePasswordDialog *dialog = GNOME_PASSWORD_DIALOG 98 (gnome_password_dialog_new 99 (_("Enter password"), prompt, 100 tny_account_get_user (account), 101 NULL, TRUE)); 102 103 gnome_password_dialog_set_domain (dialog, "Mail"); 104 gnome_password_dialog_set_remember (dialog, 105 GNOME_PASSWORD_DIALOG_REMEMBER_FOREVER); 106 gnome_password_dialog_set_readonly_username (dialog, TRUE); 107 gnome_password_dialog_set_username (dialog, 108 tny_account_get_user (account)); 109 110 gnome_password_dialog_set_show_username (dialog, FALSE); 111 gnome_password_dialog_set_show_remember (dialog, 112 gnome_keyring_is_available ()); 113 gnome_password_dialog_set_show_domain (dialog, FALSE); 114 gnome_password_dialog_set_show_userpass_buttons (dialog, FALSE); 115 116 canc = gnome_password_dialog_run_and_block (dialog); 117 118 if (canc) 119 { 120 guint32 item_id; 121 GnomePasswordDialogRemember r; 122 123 retval = gnome_password_dialog_get_password (dialog); 124 125 r = gnome_password_dialog_get_remember (dialog); 126 127 if (r == GNOME_PASSWORD_DIALOG_REMEMBER_FOREVER) 128 { 129 gnome_keyring_set_network_password_sync (keyring, 130 tny_account_get_user (account), 131 "Mail", tny_account_get_hostname (account), 132 "password", tny_account_get_proto (account), 133 "PLAIN", 0, retval, &item_id); 134 } 135 } else retval = NULL; 136 137 *cancel = (!canc); 138 139 /* this causes warnings, but should be done afaik */ 140 gtk_object_destroy (GTK_OBJECT (dialog)); 141 142 while (gtk_events_pending ()) 143 gtk_main_iteration (); 144 145 } else { 146 147 GnomeKeyringNetworkPasswordData *pwd_data; 148 pwd_data = list->data; 149 retval = g_strdup (pwd_data->password); 150 151 *cancel = FALSE; 152 153 gnome_keyring_network_password_list_free (list); 154 } 75 TnyPlatformFactory *platfact = tny_gnome_platform_factory_get_instance (); 76 TnyPasswordGetter *pwdgetter; 77 gchar *retval; 78 79 pwdgetter = tny_platform_factory_new_password_getter (platfact); 80 retval = (gchar*) tny_password_getter_get_password (pwdgetter, account, prompt, cancel); 81 g_object_unref (G_OBJECT (pwdgetter)); 155 82 156 83 return retval; 157 84 } 158 85 86 159 87 static void 160 88 per_account_forget_pass_func (TnyAccount *account) 161 89 { 162 GList *list=NULL; 163 GnomeKeyringResult keyringret; 164 gchar *keyring; 165 GnomeKeyringNetworkPasswordData *pwd_data; 166 167 gnome_keyring_get_default_keyring_sync (&keyring); 168 169 keyringret = gnome_keyring_find_network_password_sync ( 170 tny_account_get_user (account), 171 "Mail", tny_account_get_hostname (account), 172 "password", tny_account_get_proto (account), 173 "PLAIN", 0, &list); 174 175 if (keyringret == GNOME_KEYRING_RESULT_OK) 176 { 177 pwd_data = list->data; 178 gnome_keyring_item_delete_sync (keyring, pwd_data->item_id); 179 gnome_keyring_network_password_list_free (list); 180 } 181 return; 182 } 183 184 #else 185 186 static GHashTable *passwords; 187 188 static gchar* 189 per_account_get_pass_func (TnyAccount *account, const gchar *prompt, gboolean *cancel) 190 { 191 gchar *retval = NULL; 192 const gchar *accountid; 193 194 accountid = tny_account_get_id (account); 195 196 if (G_UNLIKELY (!passwords)) 197 passwords = g_hash_table_new (g_str_hash, g_str_equal); 198 199 retval = g_hash_table_lookup (passwords, accountid); 200 201 if (G_UNLIKELY (!retval)) 202 { 203 GtkDialog *dialog = GTK_DIALOG (tny_gnome_password_dialog_new ()); 204 205 tny_gnome_password_dialog_set_prompt (TNY_GNOME_PASSWORD_DIALOG (dialog), prompt); 206 207 if (G_LIKELY (gtk_dialog_run (dialog) == GTK_RESPONSE_OK)) 208 { 209 const gchar *pwd = tny_gnome_password_dialog_get_password 210 (TNY_GNOME_PASSWORD_DIALOG (dialog)); 211 212 retval = g_strdup (pwd); 213 214 mlock (retval, strlen (retval)); 215 216 g_hash_table_insert (passwords, g_strdup (accountid), 217 retval); 218 219 *cancel = FALSE; 220 221 } else { 222 223 *cancel = TRUE; 224 225 } 226 227 gtk_widget_destroy (GTK_WIDGET (dialog)); 228 229 while (gtk_events_pending ()) 230 gtk_main_iteration (); 231 } else { 232 *cancel = FALSE; 233 } 234 235 return retval; 236 } 237 238 239 static void 240 per_account_forget_pass_func (TnyAccount *account) 241 { 242 if (G_LIKELY (passwords)) 243 { 244 const gchar *accountid = tny_account_get_id (account); 245 246 gchar *pwd = g_hash_table_lookup (passwords, accountid); 247 248 if (G_LIKELY (pwd)) 249 { 250 memset (pwd, 0, strlen (pwd)); 251 /* g_free (pwd); uhm, crashed once */ 252 g_hash_table_remove (passwords, accountid); 253 } 254 255 } 256 257 return; 258 } 259 260 #endif 90 TnyPlatformFactory *platfact = tny_gnome_platform_factory_get_instance (); 91 TnyPasswordGetter *pwdgetter; 92 93 pwdgetter = tny_platform_factory_new_password_getter (platfact); 94 tny_password_getter_forget_password (pwdgetter, account); 95 g_object_unref (G_OBJECT (pwdgetter)); 96 97 return; 98 } 261 99 262 100 static gboolean … … 697 535 TnyGnomeAccountStore *self = g_object_new (TNY_TYPE_GNOME_ACCOUNT_STORE, NULL); 698 536 TnyGnomeAccountStorePriv *priv = TNY_GNOME_ACCOUNT_STORE_GET_PRIVATE (self); 537 699 538 priv->session = tny_session_camel_new (TNY_ACCOUNT_STORE (self)); 700 701 539 tny_session_camel_set_ui_locker (priv->session, tny_gtk_lockable_new ()); 702 540 trunk/libtinymail-gnome-desktop/tny-gnome-platform-factory.c
r1736 r1783 32 32 #endif 33 33 34 #ifdef GNOME 35 #include <tny-gnome-keyring-password-getter.h> 36 #else 37 #include <tny-gtk-password-dialog.h> 38 #endif 39 34 40 static GObjectClass *parent_class = NULL; 35 41 … … 65 71 { 66 72 return tny_gnome_device_new (); 73 } 74 75 76 static TnyPasswordGetter* 77 tny_gnome_platform_factory_new_password_getter (TnyPlatformFactory *self) 78 { 79 #ifdef GNOME 80 return tny_gnome_keyring_password_getter_new (); 81 #else 82 return tny_gtk_password_dialog_new (); 83 #endif 67 84 } 68 85 … … 115 132 klass->new_msg_func = tny_gnome_platform_factory_new_msg; 116 133 klass->new_mime_part_func = tny_gnome_platform_factory_new_mime_part; 134 klass->new_password_getter_func = tny_gnome_platform_factory_new_password_getter; 117 135 118 136 return; trunk/libtinymail-gpe/Makefile.am
r1014 r1783 14 14 libtinymail_gpe_1_0_headers = \ 15 15 tny-gpe-account-store.h \ 16 tny-gpe-password-dialog.h \17 16 tny-gpe-device.h \ 18 17 tny-gpe-platform-factory.h … … 23 22 tny-gpe-device-priv.h \ 24 23 tny-gpe-device.c \ 25 tny-gpe-password-dialog.c \26 24 tny-gpe-platform-factory.c 27 25 trunk/libtinymail-gpe/tny-gpe-account-store.c
r1713 r1783 29 29 30 30 #include <tny-platform-factory.h> 31 #include <tny-password-getter.h> 31 32 #include <tny-gpe-platform-factory.h> 32 33 #include <tny-account-store.h> … … 67 68 68 69 69 static GHashTable *passwords;70 71 70 static gchar* 72 71 per_account_get_pass_func (TnyAccount *account, const gchar *prompt, gboolean *cancel) 73 72 { 74 gchar *retval = NULL; 75 const gchar *accountid = tny_account_get_id (account); 76 77 if (G_UNLIKELY (!passwords)) 78 passwords = g_hash_table_new (g_str_hash, g_str_equal); 79 80 retval = g_hash_table_lookup (passwords, accountid); 81 82 if (G_UNLIKELY (!retval)) 83 { 84 GtkDialog *dialog = tny_gpe_password_dialog_new (); 85 86 tny_gpe_password_dialog_set_prompt (TNY_GPE_PASSWORD_DIALOG (dialog), prompt); 87 88 if (G_LIKELY (gtk_dialog_run (dialog) == GTK_RESPONSE_OK)) 89 { 90 const gchar *pwd = tny_gpe_password_dialog_get_password 91 (TNY_GPE_PASSWORD_DIALOG (dialog)); 92 93 retval = g_strdup (pwd); 94 95 mlock (retval, strlen (retval)); 96 97 g_hash_table_insert (passwords, g_strdup (accountid), 98 retval); 99 100 *cancel = FALSE; 101 102 } else { 103 104 *cancel = TRUE; 105 106 } 107 108 gtk_widget_destroy (GTK_WIDGET (dialog)); 109 110 while (gtk_events_pending ()) 111 gtk_main_iteration (); 112 } else { 113 *cancel = FALSE; 114 } 73 TnyPlatformFactory *platfact = tny_gpe_platform_factory_get_instance (); 74 TnyPasswordGetter *pwdgetter; 75 gchar *retval; 76 77 pwdgetter = tny_platform_factory_new_password_getter (platfact); 78 retval = (gchar*) tny_password_getter_get_password (pwdgetter, account, prompt, cancel); 79 g_object_unref (G_OBJECT (pwdgetter)); 115 80 116 81 return retval; 117 82 } 118 83 84 119 85 static void 120 86 per_account_forget_pass_func (TnyAccount *account) 121 87 { 122 TnyGetPassFunc func; 123 if (G_LIKELY (passwords)) 124 { 125 const gchar *accountid = tny_account_get_id (account); 126 127 gchar *pwd = g_hash_table_lookup (passwords, accountid); 128 129 if (G_LIKELY (pwd)) 130 { 131 memset (pwd, 0, strlen (pwd)); 132 /* g_free (pwd); uhm, crashed once */ 133 g_hash_table_remove (passwords, accountid); 134 } 135 136 } 88 TnyPlatformFactory *platfact = tny_gpe_platform_factory_get_instance (); 89 TnyPasswordGetter *pwdgetter; 90 91 pwdgetter = tny_platform_factory_new_password_getter (platfact); 92 tny_password_getter_forget_password (pwdgetter, account); 93 g_object_unref (G_OBJECT (pwdgetter)); 137 94 138 95 return; trunk/libtinymail-gpe/tny-gpe-platform-factory.c
r1700 r1783 23 23 #include <tny-gpe-device.h> 24 24 #include <tny-gtk-msg-view.h> 25 #include <tny-gtk-password-dialog.h> 25 26 #include <tny-camel-mime-part.h> 26 27 #include <tny-camel-msg.h> … … 68 69 } 69 70 71 static TnyPasswordGetter* 72 tny_gpe_platform_factory_new_password_getter (TnyPlatformFactory *self) 73 { 74 return tny_gtk_password_dialog_new (); 75 } 76 70 77 /** 71 78 * tny_gpe_platform_factory_get_instance: … … 102 109 klass->new_msg_func = tny_gpe_platform_factory_new_msg; 103 110 klass->new_mime_part_func = tny_gpe_platform_factory_new_mime_part; 111 klass->new_password_getter_func = tny_gpe_platform_factory_new_password_getter; 104 112 105 113 return; trunk/libtinymail-maemo/Makefile.am
r1508 r1783 15 15 libtinymail_maemo_1_0_headers = \ 16 16 tny-maemo-account-store.h \ 17 tny-maemo-password-dialog.h \18 17 tny-maemo-device.h \ 19 18 tny-maemo-platform-factory.h … … 23 22 tny-maemo-account-store.c \ 24 23 tny-maemo-device.c \ 25 tny-maemo-password-dialog.c \26 24 tny-maemo-platform-factory.c 27 25 trunk/libtinymail-maemo/tny-maemo-account-store.c
r1713 r1783 30 30 31 31 #include <tny-platform-factory.h> 32 #include <tny-password-getter.h> 32 33 #include <tny-maemo-platform-factory.h> 34 33 35 #include <tny-account-store.h> 34 36 #include <tny-maemo-account-store.h> … … 67 69 68 70 69 static GHashTable *passwords;70 71 71 static gchar* 72 72 per_account_get_pass_func (TnyAccount *account, const gchar *prompt, gboolean *cancel) 73 73 { 74 gchar *retval = NULL; 75 const gchar *accountid = tny_account_get_id (account); 76 77 if (G_UNLIKELY (!passwords)) 78 passwords = g_hash_table_new (g_str_hash, g_str_equal); 79 80 retval = g_hash_table_lookup (passwords, accountid); 81 82 if (G_UNLIKELY (!retval)) 83 { 84 GtkDialog *dialog = GTK_DIALOG (tny_maemo_password_dialog_new ()); 85 86 tny_maemo_password_dialog_set_prompt (TNY_MAEMO_PASSWORD_DIALOG (dialog), prompt); 87 88 if (G_LIKELY (gtk_dialog_run (dialog) == GTK_RESPONSE_OK)) 89 { 90 const gchar *pwd = tny_maemo_password_dialog_get_password 91 (TNY_MAEMO_PASSWORD_DIALOG (dialog)); 92 93 retval = g_strdup (pwd); 94 95 mlock (retval, strlen (retval)); 96 97 g_hash_table_insert (passwords, g_strdup (accountid), 98 retval); 99 100 *cancel = FALSE; 101 102 } else { 103 104 *cancel = TRUE; 105 106 } 107 108 gtk_widget_destroy (GTK_WIDGET (dialog)); 109 110 while (gtk_events_pending ()) 111 gtk_main_iteration (); 112 } else { 113 *cancel = FALSE; 114 } 74 TnyPlatformFactory *platfact = tny_maemo_platform_factory_get_instance (); 75 TnyPasswordGetter *pwdgetter; 76 gchar *retval; 77 78 pwdgetter = tny_platform_factory_new_password_getter (platfact); 79 retval = (gchar*) tny_password_getter_get_password (pwdgetter, account, prompt, cancel); 80 g_object_unref (G_OBJECT (pwdgetter)); 115 81 116 82 return retval; 117 83 } 118 84 85 119 86 static void 120 87 per_account_forget_pass_func (TnyAccount *account) 121 88 { 122 TnyGetPassFunc func; 123 124 if (G_LIKELY (passwords)) 125 { 126 const gchar *accountid = tny_account_get_id (account); 127 128 gchar *pwd = g_hash_table_lookup (passwords, accountid); 129 130 if (G_LIKELY (pwd)) 131 { 132 memset (pwd, 0, strlen (pwd)); 133 /* g_free (pwd); uhm, crashed once ?! */ 134 g_hash_table_remove (passwords, accountid); 135 } 136 137 } 89 TnyPlatformFactory *platfact = tny_maemo_platform_factory_get_instance (); 90 TnyPasswordGetter *pwdgetter; 91 92 pwdgetter = tny_platform_factory_new_password_getter (platfact); 93 tny_password_getter_forget_password (pwdgetter, account); 94 g_object_unref (G_OBJECT (pwdgetter)); 138 95 139 96 return; trunk/libtinymail-maemo/tny-maemo-platform-factory.c
r1700 r1783 24 24 #include <tny-maemo-device.h> 25 25 #include <tny-gtk-msg-view.h> 26 #include <tny-gtk-password-dialog.h> 26 27 #include <tny-camel-mime-part.h> 27 28 #include <tny-camel-msg.h> … … 49 50 } 50 51 52 static TnyPasswordGetter* 53 tny_maemo_platform_factory_new_password_getter (TnyPlatformFactory *self) 54 { 55 return tny_gtk_password_dialog_new (); 56 } 51 57 52 58 static TnyAccountStore* … … 104 110 klass->new_msg_func = tny_maemo_platform_factory_new_msg; 105 111 klass->new_mime_part_func = tny_maemo_platform_factory_new_mime_part; 112 klass->new_password_getter_func = tny_maemo_platform_factory_new_password_getter; 106 113 107 114 return; trunk/libtinymail-olpc/Makefile.am
r1014 r1783 14 14 libtinymail_olpc_1_0_headers = \ 15 15 tny-olpc-account-store.h \ 16 tny-olpc-password-dialog.h \17 16 tny-olpc-device.h \ 18 17 tny-olpc-platform-factory.h … … 23 22 tny-olpc-device-priv.h \ 24 23 tny-olpc-device.c \ 25 tny-olpc-password-dialog.c \26 24 tny-olpc-platform-factory.c 27 25 trunk/libtinymail-olpc/tny-olpc-account-store.c
r1754 r1783 28 28 29 29 #include <tny-platform-factory.h> 30 #include <tny-password-getter.h> 30 31 #include <tny-olpc-platform-factory.h> 31 32 32 33 #include <tny-account-store.h> 33 34 #include <tny-olpc-account-store.h> 34 #include <tny-olpc-password-dialog.h>35 35 #include <tny-account.h> 36 36 #include <tny-store-account.h> … … 65 65 66 66 67 static GHashTable *passwords;68 67 69 68 static gchar* 70 69 per_account_get_pass_func (TnyAccount *account, const gchar *prompt, gboolean *cancel) 71 70 { 72 gchar *retval = NULL; 73 const gchar *accountid = tny_account_get_id (account); 74 75 if (G_UNLIKELY (!passwords)) 76 passwords = g_hash_table_new (g_str_hash, g_str_equal); 77 78 retval = g_hash_table_lookup (passwords, accountid); 79 80 if (G_UNLIKELY (!retval)) 81 { 82 GtkDialog *dialog = GTK_DIALOG (tny_olpc_password_dialog_new ()); 83 84 tny_olpc_password_dialog_set_prompt (TNY_OLPC_PASSWORD_DIALOG (dialog), prompt); 85 86 if (G_LIKELY (gtk_dialog_run (dialog) == GTK_RESPONSE_OK)) 87 { 88 const gchar *pwd = tny_olpc_password_dialog_get_password 89 (TNY_OLPC_PASSWORD_DIALOG (dialog)); 90 91 retval = g_strdup (pwd); 92 93 mlock (retval, strlen (retval)); 94 95 g_hash_table_insert (passwords, g_strdup (accountid), 96 retval); 97 98 *cancel = FALSE; 99 100 } else { 101 102 *cancel = TRUE; 103 104 } 105 106 gtk_widget_destroy (GTK_WIDGET (dialog)); 107 108 while (gtk_events_pending ()) 109 gtk_main_iteration (); 110 } else { 111 *cancel = FALSE; 112 } 71 TnyPlatformFactory *platfact = tny_olpc_platform_factory_get_instance (); 72 TnyPasswordGetter *pwdgetter; 73 gchar *retval; 74 75 pwdgetter = tny_platform_factory_new_password_getter (platfact); 76 retval = (gchar*) tny_password_getter_get_password (pwdgetter, account, prompt, cancel); 77 g_object_unref (G_OBJECT (pwdgetter)); 113 78 114 79 return retval; 115 80 } 116 81 82 117 83 static void 118 84 per_account_forget_pass_func (TnyAccount *account) 119 85 { 120 TnyGetPassFunc func; 121 if (G_LIKELY (passwords)) 122 { 123 const gchar *accountid = tny_account_get_id (account); 124 125 gchar *pwd = g_hash_table_lookup (passwords, accountid); 126 127 if (G_LIKELY (pwd)) 128 { 129 memset (pwd, 0, strlen (pwd)); 130 /* g_free (pwd); uhm, crashed once */ 131 g_hash_table_remove (passwords, accountid); 132 } 133 134 } 86 TnyPlatformFactory *platfact = tny_olpc_platform_factory_get_instance (); 87 TnyPasswordGetter *pwdgetter; 88 89 pwdgetter = tny_platform_factory_new_password_getter (platfact); 90 tny_password_getter_forget_password (pwdgetter, account); 91 g_object_unref (G_OBJECT (pwdgetter)); 135 92 136 93 return; trunk/libtinymail-olpc/tny-olpc-platform-factory.c
r1700 r1783 20 20 21 21 #include <tny-olpc-platform-factory.h> 22 23 22 #include <tny-olpc-account-store.h> 24 23 #include <tny-olpc-device.h> 25 24 #include <tny-gtk-msg-view.h> 25 #include <tny-gtk-password-dialog.h> 26 26 #include <tny-camel-mime-part.h> 27 27 #include <tny-camel-msg.h> … … 68 68 } 69 69 70 static TnyPasswordGetter* 71 tny_olpc_platform_factory_new_password_getter (TnyPlatformFactory *self) 72 { 73 return tny_gtk_password_dialog_new (); 74 } 75 70 76 /** 71 77 * tny_olpc_platform_factory_get_instance: … … 104 110 klass->new_msg_func = tny_olpc_platform_factory_new_msg; 105 111 klass->new_mime_part_func = tny_olpc_platform_factory_new_mime_part; 112 klass->new_password_getter_func = tny_olpc_platform_factory_new_password_getter; 106 113 107 114 return; trunk/libtinymail/Makefile.am
r1683 r1783 33 33 tny-msg-remove-strategy.h \ 34 34 tny-msg-receive-strategy.h \ 35 tny-send-queue.h 35 tny-send-queue.h \ 36 tny-password-getter.h 36 37 37 38 libtinymail_1_0_la_SOURCES = \ … … 68 69 tny-msg-remove-strategy.c \ 69 70 tny-msg-receive-strategy.c \ 70 tny-send-queue.c 71 tny-send-queue.c \ 72 tny-password-getter.c 71 73 72 74 libtinymail_1_0_la_LIBADD = $(LIBTINYMAIL_LIBS) trunk/libtinymail/tny-shared.h
r1719 r1783 102 102 typedef struct _TnyFolderStatsClass TnyFolderStatsClass; 103 103 typedef enum _TnyFolderCaps TnyFolderCaps; 104 typedef struct _TnyPasswordGetter TnyPasswordGetter; 105 typedef struct _TnyPasswordGetterIface TnyPasswordGetterIface; 104 106 105 107 G_END_DECLS trunk/libtinymailui-gtk/Makefile.am
r1398 r1783 22 22 tny-gtk-attach-list-model.h \ 23 23 tny-gtk-text-buffer-stream.h \ 24 tny-gtk-header-view.h 24 tny-gtk-header-view.h \ 25 tny-gtk-password-dialog.h 25 26 26 27 libtinymailui_gtk_1_0_la_SOURCES = \ … … 46 47 tny-gtk-account-list-model-iterator-priv.h \ 47 48 tny-gtk-text-buffer-stream.c \ 48 tny-gtk-header-view.c 49 tny-gtk-header-view.c \ 50 tny-gtk-password-dialog.c 49 51 50 52 libtinymailui_gtk_1_0_la_LIBADD = \ trunk/libtinymailui-gtk/tny-gtk-password-dialog.c
r1782 r1783 1 1 /* tinymail - Tiny Mail 2 * Copyright (C) 2006-2007 Philip Van Hoof <pvanhoof@g nome.org>2 * Copyright (C) 2006-2007 Philip Van Hoof <pvanhoof@gtk.org> 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 20 20 /* TODO: Refactory this type to libtinymailui-gtk */ 21 21 #include <config.h> 22 #include <string.h> 23 22 24 #include <glib/gi18n-lib.h> 23 25 24 26 #include <gtk/gtk.h> 25 #include <tny-gnome-password-dialog.h> 27 #include <tny-gtk-password-dialog.h> 28 29 #include <tny-account.h> 26 30 27 31 static GObjectClass *parent_class = NULL; 28 32 29 typedef struct _TnyG nomePasswordDialogPriv TnyGnomePasswordDialogPriv;30 31 struct _TnyG nomePasswordDialogPriv33 typedef struct _TnyGtkPasswordDialogPriv TnyGtkPasswordDialogPriv; 34 35 struct _TnyGtkPasswordDialogPriv 32 36 { 33 37 GtkEntry *pwd_entry; … … 35 39 }; 36 40 37 #define TNY_GNOME_PASSWORD_DIALOG_GET_PRIVATE(o) \ 38 (G_TYPE_INSTANCE_GET_PRIVATE ((o), TNY_TYPE_GNOME_PASSWORD_DIALOG, TnyGnomePasswordDialogPriv)) 39 41 #define TNY_GTK_PASSWORD_DIALOG_GET_PRIVATE(o) \ 42 (G_TYPE_INSTANCE_GET_PRIVATE ((o), TNY_TYPE_GTK_PASSWORD_DIALOG, TnyGtkPasswordDialogPriv)) 43 44 static GHashTable *passwords = NULL; 45 46 47 48 static const gchar* 49 tny_gtk_password_dialog_get_password (TnyPasswordGetter *self, TnyAccount *account, const gchar *prompt, gboolean *cancel) 50 { 51 TnyGtkPasswordDialogPriv *priv = TNY_GTK_PASSWORD_DIALOG_GET_PRIVATE (self); 52
