[network-manager-applet/NMA_0_8] gsm: auto-unlock only when user wants it to happen
- From: Dan Williams <dcbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/NMA_0_8] gsm: auto-unlock only when user wants it to happen
- Date: Fri, 14 Oct 2011 17:29:54 +0000 (UTC)
commit ccad8b5f2b682915ae79137bef7cf43546fc8617
Author: Dan Williams <dcbw redhat com>
Date: Fri Oct 14 12:28:08 2011 -0500
gsm: auto-unlock only when user wants it to happen
Provide a checkbox so the user can decide whether or not to
automatically unlock the modem. Some people don't want to.
src/applet-device-gsm.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
src/applet-dialogs.c | 25 ++++++++++++++++++++++++-
src/applet-dialogs.h | 5 ++++-
src/gsm-unlock.ui | 46 +++++++++++++++++++++++++++++++++-------------
4 files changed, 104 insertions(+), 18 deletions(-)
---
diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
index 66bdb3f..4ce5408 100644
--- a/src/applet-device-gsm.c
+++ b/src/applet-device-gsm.c
@@ -877,6 +877,39 @@ set_pin_in_keyring (const char *devid,
}
static void
+delete_pin_cb (GnomeKeyringResult result, gpointer user_data)
+{
+ /* nothing to do */
+}
+
+static void
+delete_pins_find_cb (GnomeKeyringResult result, GList *list, gpointer user_data)
+{
+ GList *iter;
+
+ if (result == GNOME_KEYRING_RESULT_OK) {
+ for (iter = list; iter; iter = g_list_next (iter)) {
+ GnomeKeyringFound *found = iter->data;
+
+ gnome_keyring_item_delete (found->keyring, found->item_id, delete_pin_cb, NULL, NULL);
+ }
+ }
+}
+
+static void
+delete_pins_in_keyring (const char *devid)
+{
+ gnome_keyring_find_itemsv (GNOME_KEYRING_ITEM_GENERIC_SECRET,
+ delete_pins_find_cb,
+ NULL,
+ NULL,
+ "devid",
+ GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
+ devid,
+ NULL);
+}
+
+static void
unlock_dialog_destroy (GsmDeviceInfo *info)
{
applet_mobile_pin_dialog_destroy (info->dialog);
@@ -891,8 +924,11 @@ unlock_pin_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
const char *dbus_error, *msg = NULL, *code1;
if (dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID)) {
- code1 = applet_mobile_pin_dialog_get_entry1 (info->dialog);
- set_pin_in_keyring (info->devid, info->simid, code1);
+ if (applet_mobile_pin_dialog_get_auto_unlock (info->dialog)) {
+ code1 = applet_mobile_pin_dialog_get_entry1 (info->dialog);
+ set_pin_in_keyring (info->devid, info->simid, code1);
+ } else
+ delete_pins_in_keyring (info->devid);
unlock_dialog_destroy (info);
return;
}
@@ -1047,7 +1083,11 @@ unlock_dialog_new (NMDevice *device, GsmDeviceInfo *info)
}
/* Construct and run the dialog */
- info->dialog = applet_mobile_pin_dialog_new (title, header, desc, show_pass_label);
+ info->dialog = applet_mobile_pin_dialog_new (title,
+ header,
+ desc,
+ show_pass_label,
+ (unlock_code == UNLOCK_CODE_PIN) ? TRUE : FALSE);
g_free (desc);
g_return_if_fail (info->dialog != NULL);
diff --git a/src/applet-dialogs.c b/src/applet-dialogs.c
index 64d01ad..0894daa 100644
--- a/src/applet-dialogs.c
+++ b/src/applet-dialogs.c
@@ -1050,7 +1050,8 @@ GtkWidget *
applet_mobile_pin_dialog_new (const char *title,
const char *header,
const char *desc,
- const char *show_password_label)
+ const char *show_password_label,
+ gboolean show_auto_unlock_checkbox)
{
char *str;
GtkWidget *dialog;
@@ -1099,6 +1100,10 @@ applet_mobile_pin_dialog_new (const char *title,
g_signal_connect (dialog, "delete-event", G_CALLBACK (mpd_cancel_dialog), NULL);
+ widget = GTK_WIDGET (gtk_builder_get_object (builder, "save_checkbutton"));
+ if (show_auto_unlock_checkbox)
+ g_object_set_data (G_OBJECT (widget), "active", GUINT_TO_POINTER (TRUE));
+
mpd_entry_changed (NULL, dialog);
return dialog;
@@ -1135,6 +1140,10 @@ applet_mobile_pin_dialog_present (GtkWidget *dialog, gboolean now)
gtk_widget_hide (widget);
}
+ widget = GTK_WIDGET (gtk_builder_get_object (builder, "save_checkbutton"));
+ if (!g_object_get_data (G_OBJECT (widget), "active"))
+ gtk_widget_hide (widget);
+
/* Need to resize the dialog after hiding widgets */
gtk_window_resize (GTK_WINDOW (dialog), 400, 100);
@@ -1289,6 +1298,20 @@ applet_mobile_pin_dialog_get_entry3 (GtkWidget *dialog)
return mpd_get_entry (dialog, "code3_entry");
}
+gboolean
+applet_mobile_pin_dialog_get_auto_unlock (GtkWidget *dialog)
+{
+ GtkBuilder *builder;
+ GtkWidget *widget;
+
+ g_return_val_if_fail (dialog != NULL, FALSE);
+ builder = g_object_get_data (G_OBJECT (dialog), "builder");
+ g_return_val_if_fail (builder != NULL, FALSE);
+
+ widget = GTK_WIDGET (gtk_builder_get_object (builder, "save_checkbutton"));
+ return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+}
+
void
applet_mobile_pin_dialog_start_spinner (GtkWidget *dialog, const char *text)
{
diff --git a/src/applet-dialogs.h b/src/applet-dialogs.h
index 6f22ba2..1c96468 100644
--- a/src/applet-dialogs.h
+++ b/src/applet-dialogs.h
@@ -42,7 +42,8 @@ GtkWidget *applet_mobile_password_dialog_new (NMDevice *device,
GtkWidget *applet_mobile_pin_dialog_new (const char *title,
const char *header,
const char *desc,
- const char *show_password_label);
+ const char *show_password_label,
+ gboolean show_auto_unlock_checkbox);
void applet_mobile_pin_dialog_present (GtkWidget *dialog, gboolean now);
@@ -68,6 +69,8 @@ const char *applet_mobile_pin_dialog_get_entry3 (GtkWidget *dialog);
void applet_mobile_pin_dialog_match_23 (GtkWidget *dialog, gboolean match);
+gboolean applet_mobile_pin_dialog_get_auto_unlock (GtkWidget *dialog);
+
void applet_mobile_pin_dialog_start_spinner (GtkWidget *dialog, const char *text);
void applet_mobile_pin_dialog_stop_spinner (GtkWidget *dialog, const char *text);
diff --git a/src/gsm-unlock.ui b/src/gsm-unlock.ui
index 8fa20d7..17b3c47 100644
--- a/src/gsm-unlock.ui
+++ b/src/gsm-unlock.ui
@@ -77,7 +77,7 @@
<child>
<object class="GtkTable" id="table14">
<property name="visible">True</property>
- <property name="n_rows">5</property>
+ <property name="n_rows">6</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
@@ -154,6 +154,32 @@
</packing>
</child>
<child>
+ <object class="GtkCheckButton" id="show_password_checkbutton">
+ <property name="label">Show it</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<object class="GtkHBox" id="progress_hbox">
<property name="visible">True</property>
<property name="spacing">6</property>
@@ -185,16 +211,16 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
<property name="y_padding">6</property>
</packing>
</child>
<child>
- <object class="GtkCheckButton" id="show_password_checkbutton">
- <property name="label" translatable="no">Show it</property>
+ <object class="GtkCheckButton" id="save_checkbutton">
+ <property name="label" translatable="yes">Automatically unlock this device</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -203,16 +229,10 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]