Maemo: Added a widget to "unselect" a certificate.
authorTobias Brunner <tobias@strongswan.org>
Thu, 14 Oct 2010 15:01:08 +0000 (17:01 +0200)
committerTobias Brunner <tobias@strongswan.org>
Thu, 14 Oct 2010 15:36:20 +0000 (17:36 +0200)
src/frontends/maemo/src/strongswan-connection.c
src/frontends/maemo/src/strongswan-settings.c

index 977c0f5..c7d0db3 100644 (file)
@@ -248,6 +248,10 @@ strongswan_connection_save_to_key_file (GKeyFile *key_file,
        {
                g_key_file_set_string (key_file, name, "cert", priv->cert);
        }
+       else
+       {
+               g_key_file_remove_key (key_file, name, "cert", NULL);
+       }
        if (priv->user)
        {
                g_key_file_set_string (key_file, name, "user", priv->user);
index 07f58dc..9773590 100644 (file)
@@ -35,17 +35,47 @@ struct {
 } ListDialog = { 0, };
 
 /**
+ * Callback if no certificate should be selected
+ */
+void no_certificate(HildonButton *button, gpointer user_data)
+{
+       gtk_dialog_response (GTK_DIALOG (user_data), GTK_RESPONSE_REJECT);
+}
+
+/**
  * Callback to select a certificate
  */
 void select_cert(HildonButton *button, gpointer user_data)
 {
        GtkWidget *selector = hildon_file_chooser_dialog_new (GTK_WINDOW (user_data), GTK_FILE_CHOOSER_ACTION_OPEN);
+       GtkWidget *nocert = hildon_button_new (HILDON_SIZE_FINGER_HEIGHT |
+                                                                                  HILDON_SIZE_AUTO_WIDTH,
+                                                                                  HILDON_BUTTON_ARRANGEMENT_VERTICAL);
+       hildon_button_set_text (HILDON_BUTTON (nocert),
+                                                       "No certificate",
+                                                       "Use system-wide CA certificates");
+       hildon_button_set_alignment (HILDON_BUTTON (nocert), 0, 0.5, 1, 1);
+       g_signal_connect (nocert, "clicked", G_CALLBACK (no_certificate), selector);
+       hildon_file_chooser_dialog_add_extra (HILDON_FILE_CHOOSER_DIALOG (selector),
+                                                                                 nocert);
        gtk_widget_show_all (selector);
-       if (gtk_dialog_run (GTK_DIALOG (selector)) == GTK_RESPONSE_OK)
+
+       switch (gtk_dialog_run (GTK_DIALOG (selector)))
        {
-               gchar *file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (selector));
-               hildon_button_set_value (button, file);
-               g_free(file);
+               case GTK_RESPONSE_OK:
+               {
+                       gchar *file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (selector));
+                       hildon_button_set_value (button, file);
+                       g_free(file);
+                       break;
+               }
+               case GTK_RESPONSE_REJECT:
+               {
+                       hildon_button_set_value (button, "None");
+                       break;
+               }
+               default:
+                       break;
        }
        gtk_widget_destroy (selector);
 }