Fixed some compilation errors
[modest] / src / modest-tny-account-store.c
index a5ae4a3..f3384e0 100644 (file)
@@ -65,6 +65,7 @@ static void    modest_tny_account_store_init          (gpointer g, gpointer ifac
 /* list my signals */
 enum {
        ACCOUNT_UPDATE_SIGNAL,
+       PASSWORD_REQUESTED_SIGNAL,
        LAST_SIGNAL
 };
 
@@ -85,12 +86,6 @@ struct _ModestTnyAccountStorePrivate {
                                                       MODEST_TYPE_TNY_ACCOUNT_STORE, \
                                                       ModestTnyAccountStorePrivate))
 
-static void    on_password_requested        (ModestTnyAccountStore *account_store, 
-                                            const gchar* account_name,
-                                            gchar **password, 
-                                            gboolean *cancel, 
-                                            gboolean *remember);
-
 /* globals */
 static GObjectClass *parent_class = NULL;
 
@@ -142,14 +137,24 @@ modest_tny_account_store_class_init (ModestTnyAccountStoreClass *klass)
        g_type_class_add_private (gobject_class,
                                  sizeof(ModestTnyAccountStorePrivate));
 
-       signals[ACCOUNT_UPDATE_SIGNAL] =
+        signals[ACCOUNT_UPDATE_SIGNAL] =
                g_signal_new ("account_update",
                              G_TYPE_FROM_CLASS (gobject_class),
                              G_SIGNAL_RUN_FIRST,
                              G_STRUCT_OFFSET(ModestTnyAccountStoreClass, account_update),
                              NULL, NULL,
                              g_cclosure_marshal_VOID__STRING,
-                             G_TYPE_NONE, 1, G_TYPE_STRING);   
+                             G_TYPE_NONE, 1, G_TYPE_STRING);
+        
+        signals[PASSWORD_REQUESTED_SIGNAL] =
+                g_signal_new ("password_requested",
+                              G_TYPE_FROM_CLASS (gobject_class),
+                              G_SIGNAL_RUN_FIRST,
+                              G_STRUCT_OFFSET(ModestTnyAccountStoreClass, password_requested),
+                              NULL, NULL,
+                              modest_marshal_VOID__STRING_POINTER_POINTER_POINTER,
+                              G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER,
+                              G_TYPE_POINTER);
 }
 
 
@@ -230,60 +235,6 @@ get_account_store_for_account (TnyAccount *account)
                                                           "account_store"));
 }
 
-
-static void
-on_password_requested (ModestTnyAccountStore *account_store, 
-                      const gchar* account_name,
-                      gchar **password, 
-                      gboolean *cancel, 
-                      gboolean *remember)
-{
-       gchar *txt;
-       GtkWidget *dialog, *entry, *remember_pass_check;
-
-       dialog = gtk_dialog_new_with_buttons (_("Password requested"),
-                                             NULL,
-                                             GTK_DIALOG_MODAL,
-                                             GTK_STOCK_CANCEL,
-                                             GTK_RESPONSE_REJECT,
-                                             GTK_STOCK_OK,
-                                             GTK_RESPONSE_ACCEPT,
-                                             NULL);
-
-       txt = g_strdup_printf (_("Please enter your password for %s"), account_name);
-       gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), gtk_label_new(txt),
-                           FALSE, FALSE, 0);
-       g_free (txt);
-
-       entry = gtk_entry_new_with_max_length (40);
-       gtk_entry_set_visibility (GTK_ENTRY(entry), FALSE);
-       gtk_entry_set_invisible_char (GTK_ENTRY(entry), 0x2022); /* bullet unichar */
-       
-       gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), entry,
-                           TRUE, FALSE, 0);    
-
-       remember_pass_check = gtk_check_button_new_with_label (_("Remember password"));
-       gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), remember_pass_check,
-                           TRUE, FALSE, 0);
-
-       gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
-       
-       if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
-               *password = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry)));
-               *cancel   = FALSE;
-       } else {
-               *password = NULL;
-               *cancel   = TRUE;
-       }
-
-       if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (remember_pass_check)))
-               *remember = TRUE;
-       else
-               *remember = FALSE;
-
-       gtk_widget_destroy (dialog);
-}
-
 static gchar*
 get_password (TnyAccount *account, const gchar *prompt, gboolean *cancel)
 {
@@ -312,8 +263,7 @@ get_password (TnyAccount *account, const gchar *prompt, gboolean *cancel)
        /* if the password is not already there, try ModestConf */
        if (!already_asked) {
                pwd  = modest_account_mgr_get_string (priv->account_mgr,
-                                                     key, MODEST_ACCOUNT_PASSWORD,
-                                                     TRUE, NULL);
+                                                     key, MODEST_ACCOUNT_PASSWORD,TRUE);
                g_hash_table_insert (priv->password_hash, g_strdup (key), g_strdup (pwd));
        }
 
@@ -322,17 +272,17 @@ get_password (TnyAccount *account, const gchar *prompt, gboolean *cancel)
 
                /* we don't have it yet. Get the password from the user */
                const gchar* name = tny_account_get_name (account);
-               gboolean remember;
+               gboolean remember = FALSE;
                pwd = NULL;
-
-               on_password_requested (self, name, &pwd, cancel, &remember);
-
+               
+               g_signal_emit (G_OBJECT(self), signals[PASSWORD_REQUESTED_SIGNAL], 0,
+                              name, &pwd, cancel, &remember);
+               
                if (!*cancel) {
                        if (remember)
-                               modest_account_mgr_set_string (priv->account_mgr,
-                                                              key, MODEST_ACCOUNT_PASSWORD,
-                                                              pwd,
-                                                              TRUE, NULL);
+                               modest_account_mgr_set_string (priv->account_mgr,key,
+                                                              MODEST_ACCOUNT_PASSWORD,
+                                                              pwd, TRUE);
                        /* We need to dup the string even knowing that
                           it's already a dup of the contents of an
                           entry, because it if it's wrong, then camel
@@ -345,7 +295,7 @@ get_password (TnyAccount *account, const gchar *prompt, gboolean *cancel)
                }
        } else
                *cancel = FALSE;
-
        return pwd;
 }
 
@@ -374,8 +324,7 @@ forget_password (TnyAccount *account)
 
        /* Remove from configuration system */
        modest_account_mgr_unset (priv->account_mgr,
-                                 key, MODEST_ACCOUNT_PASSWORD,
-                                 TRUE, NULL);
+                                 key, MODEST_ACCOUNT_PASSWORD, TRUE);
 }
 
 
@@ -389,7 +338,7 @@ modest_tny_account_store_finalize (GObject *obj)
        priv->cache_dir = NULL;
 
        if (priv->device) {
-               g_object_unref (priv->device);
+               g_object_unref (G_OBJECT(priv->device));
                priv->device = NULL;
        }
        
@@ -399,21 +348,22 @@ modest_tny_account_store_finalize (GObject *obj)
        }
 
        if (priv->account_mgr) {
-               g_object_unref (priv->account_mgr);
+               g_object_unref (G_OBJECT(priv->account_mgr));
                priv->account_mgr = NULL;
        }
-       
-       if (priv->session) {
-               camel_object_unref (CAMEL_OBJECT(priv->session));
-               priv->session = NULL;
-       }
-       
+
        /* this includes the local folder */
        account_list_free (priv->store_accounts);
        priv->store_accounts = NULL;
        
        account_list_free (priv->transport_accounts);
        priv->transport_accounts = NULL;
+
+       if (priv->session) {
+               camel_object_unref (CAMEL_OBJECT(priv->session));
+               priv->session = NULL;
+       }
+       
        
        G_OBJECT_CLASS(parent_class)->finalize (obj);
 }
@@ -483,7 +433,7 @@ get_accounts  (TnyAccountStore *self, TnyList *list, TnyAccountType type)
        
        priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
  
-       account_names = modest_account_mgr_account_names (priv->account_mgr, NULL);
+       account_names = modest_account_mgr_account_names (priv->account_mgr);
        
        for (cursor = account_names; cursor; cursor = cursor->next) {