[network-manager-netbook] Implement PIN request functionality
- From: Tambet Ingo <tambeti src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-netbook] Implement PIN request functionality
- Date: Tue, 2 Mar 2010 20:34:40 +0000 (UTC)
commit 0ad2ba4fa044d3cac05a482b375c2cd1bc768de2
Author: Tambet Ingo <tambet gmail com>
Date: Tue Mar 2 16:29:26 2010 -0400
Implement PIN request functionality
It's pretty sweet.
libnm-gtk/Makefile.am | 2 +
libnm-gtk/nm-gsm-pin-request-item.c | 160 +++++++++++++++++++++++++++++++++
libnm-gtk/nm-gsm-pin-request-item.h | 56 ++++++++++++
libnm-gtk/nm-gsm-provider.c | 41 ++++++++-
src/Makefile.am | 2 +
src/nmn-gsm-pin-request-renderer.c | 167 +++++++++++++++++++++++++++++++++++
src/nmn-gsm-pin-request-renderer.h | 45 ++++++++++
src/nmn-list.c | 10 ++-
src/nmn-model.c | 3 +-
9 files changed, 479 insertions(+), 7 deletions(-)
---
diff --git a/libnm-gtk/Makefile.am b/libnm-gtk/Makefile.am
index 7bfc5a8..873366d 100644
--- a/libnm-gtk/Makefile.am
+++ b/libnm-gtk/Makefile.am
@@ -37,6 +37,7 @@ noinst_HEADERS = \
nm-gconf-connection.h \
nm-gconf-settings.h \
nm-gsm-item.h \
+ nm-gsm-pin-request-item.h \
nm-gsm-provider.h \
nm-item-provider.h \
nm-list-item.h \
@@ -71,6 +72,7 @@ libnm_gtk_la_SOURCES = \
nm-gconf-connection.c \
nm-gconf-settings.c \
nm-gsm-item.c \
+ nm-gsm-pin-request-item.c \
nm-gsm-provider.c \
nm-icon-cache.c \
nm-icon-cache.h \
diff --git a/libnm-gtk/nm-gsm-pin-request-item.c b/libnm-gtk/nm-gsm-pin-request-item.c
new file mode 100644
index 0000000..606f064
--- /dev/null
+++ b/libnm-gtk/nm-gsm-pin-request-item.c
@@ -0,0 +1,160 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * (C) Copyright 2009 Novell, Inc.
+ */
+
+#include <glib/gi18n.h>
+#include <nm-setting-8021x.h>
+#include "nm-gsm-pin-request-item.h"
+#include "libnm-gtk-gsm-device.h"
+
+G_DEFINE_TYPE (NMGsmPinRequestItem, nm_gsm_pin_request_item, NM_TYPE_LIST_ITEM)
+
+enum {
+ UNLOCKED,
+
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), NM_TYPE_GSM_PIN_REQUEST_ITEM, NMGsmPinRequestItemPrivate))
+
+typedef struct {
+ NMGsmDevice *device;
+} NMGsmPinRequestItemPrivate;
+
+
+NMListItem *
+nm_gsm_pin_request_item_new (NMGsmDevice *device)
+{
+ NMListItem *item;
+
+ g_return_val_if_fail (NM_IS_GSM_DEVICE (device), NULL);
+
+ item = (NMListItem *) g_object_new (NM_TYPE_GSM_PIN_REQUEST_ITEM,
+ NM_LIST_ITEM_TYPE_NAME, _("3G"),
+ NULL);
+
+ if (item)
+ GET_PRIVATE (item)->device = g_object_ref (device);
+
+ return item;
+}
+
+static void
+pin_disabled (GObject *obj, GAsyncResult *result, gpointer user_data)
+{
+ NMGsmPinRequestItem *self = NM_GSM_PIN_REQUEST_ITEM (user_data);
+ GError *error = NULL;
+ gboolean success;
+
+ success = nm_gsm_device_enable_pin_finish (NM_GSM_DEVICE (obj), result, &error);
+ if (error) {
+ g_warning ("PIN disable failed: %s", error->message);
+ g_clear_error (&error);
+ } else {
+ g_message ("PIN disabled successfully");
+ g_signal_emit (self, signals[UNLOCKED], 0);
+ }
+}
+
+static void
+pin_unlocked (GObject *obj, GAsyncResult *result, gpointer user_data)
+{
+ NMGsmPinRequestItem *self = NM_GSM_PIN_REQUEST_ITEM (user_data);
+ GError *error = NULL;
+ gboolean success;
+
+ success = nm_gsm_device_send_pin_finish (NM_GSM_DEVICE (obj), result, &error);
+ if (error) {
+ g_warning ("PIN unlocking failed: %s", error->message);
+ g_clear_error (&error);
+ } else {
+ g_message ("PIN unlocked successfully");
+ g_signal_emit (self, signals[UNLOCKED], 0);
+ }
+}
+
+void
+nm_gsm_pin_request_item_unlock (NMGsmPinRequestItem *self,
+ const char *pin,
+ gboolean disable_pin)
+{
+ NMGsmPinRequestItemPrivate *priv = GET_PRIVATE (self);
+
+ g_return_if_fail (NM_IS_GSM_PIN_REQUEST_ITEM (self));
+ g_return_if_fail (pin != NULL);
+
+ if (disable_pin)
+ nm_gsm_device_enable_pin (priv->device, pin, FALSE, pin_disabled, self);
+ else
+ nm_gsm_device_send_pin (priv->device, pin, pin_unlocked, self);
+}
+
+static int
+priority (NMListItem *item)
+{
+ return NM_LIST_ITEM_PRIORITY_DEV_GSM + NM_LIST_ITEM_CLASS (nm_gsm_pin_request_item_parent_class)->priority (item);
+}
+
+/*****************************************************************************/
+
+static void
+nm_gsm_pin_request_item_init (NMGsmPinRequestItem *self)
+{
+ g_object_set (self,
+ NM_LIST_ITEM_NAME, _("Locked GSM device"),
+ NM_LIST_ITEM_ICON, "nm-device-wwan",
+ NM_LIST_ITEM_SHOW_DELETE, FALSE,
+ NULL);
+}
+
+static void
+dispose (GObject *object)
+{
+ NMGsmPinRequestItemPrivate *priv = GET_PRIVATE (object);
+
+ if (priv->device) {
+ g_object_unref (priv->device);
+ priv->device = NULL;
+ }
+
+ G_OBJECT_CLASS (nm_gsm_pin_request_item_parent_class)->dispose (object);
+}
+
+static void
+nm_gsm_pin_request_item_class_init (NMGsmPinRequestItemClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ NMListItemClass *list_class = NM_LIST_ITEM_CLASS (klass);
+
+ g_type_class_add_private (object_class, sizeof (NMGsmPinRequestItemPrivate));
+
+ object_class->dispose = dispose;
+ list_class->priority = priority;
+
+ /* Signals */
+ signals[UNLOCKED] =
+ g_signal_new ("unlocked",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (NMGsmPinRequestItemClass, unlocked),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+}
diff --git a/libnm-gtk/nm-gsm-pin-request-item.h b/libnm-gtk/nm-gsm-pin-request-item.h
new file mode 100644
index 0000000..f9ecb4e
--- /dev/null
+++ b/libnm-gtk/nm-gsm-pin-request-item.h
@@ -0,0 +1,56 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * (C) Copyright 2009 Novell, Inc.
+ */
+
+#ifndef NM_GSM_PIN_REQUEST_ITEM_H
+#define NM_GSM_PIN_REQUEST_ITEM_H
+
+#include <glib-object.h>
+#include <nm-gsm-device.h>
+#include <nm-list-item.h>
+
+G_BEGIN_DECLS
+
+#define NM_TYPE_GSM_PIN_REQUEST_ITEM (nm_gsm_pin_request_item_get_type ())
+#define NM_GSM_PIN_REQUEST_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_GSM_PIN_REQUEST_ITEM, NMGsmPinRequestItem))
+#define NM_GSM_PIN_REQUEST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_GSM_PIN_REQUEST_ITEM, NMGsmPinRequestItemClass))
+#define NM_IS_GSM_PIN_REQUEST_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_GSM_PIN_REQUEST_ITEM))
+#define NM_IS_GSM_PIN_REQUEST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_GSM_PIN_REQUEST_ITEM))
+#define NM_GSM_PIN_REQUEST_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_GSM_PIN_REQUEST_ITEM, NMGsmPinRequestItemClass))
+
+typedef struct {
+ NMListItem parent;
+} NMGsmPinRequestItem;
+
+typedef struct {
+ NMListItemClass parent_class;
+
+ /* Signals */
+ void (*unlocked) (NMGsmPinRequestItem *self);
+} NMGsmPinRequestItemClass;
+
+GType nm_gsm_pin_request_item_get_type (void);
+
+NMListItem *nm_gsm_pin_request_item_new (NMGsmDevice *device);
+void nm_gsm_pin_request_item_unlock (NMGsmPinRequestItem *self,
+ const char *pin,
+ gboolean disable_pin);
+
+G_END_DECLS
+
+#endif /* NM_GSM_PIN_REQUEST_ITEM_H */
diff --git a/libnm-gtk/nm-gsm-provider.c b/libnm-gtk/nm-gsm-provider.c
index d78cc1a..d046ab1 100644
--- a/libnm-gtk/nm-gsm-provider.c
+++ b/libnm-gtk/nm-gsm-provider.c
@@ -35,12 +35,16 @@
#include "gconf-helpers.h"
#include "utils.h"
+#define MM_MODEM_ERROR "org.freedesktop.ModemManager.Modem.Gsm"
+#define MM_MODEM_ERROR_SIM_PIN MM_MODEM_ERROR ".SimPinRequired"
+
G_DEFINE_TYPE (NMGsmProvider, nm_gsm_provider, NM_TYPE_DEVICE_PROVIDER)
#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), NM_TYPE_GSM_PROVIDER, NMGsmProviderPrivate))
typedef struct {
gboolean usable;
+ gboolean pin_needed;
} NMGsmProviderPrivate;
NMItemProvider *
@@ -238,22 +242,51 @@ modem_became_usable (NMGsmProvider *self)
}
static void
+pin_unlocked (NMGsmPinRequestItem *req_item,
+ gpointer user_data)
+{
+ NMGsmProvider *self = NM_GSM_PROVIDER (user_data);
+ NMGsmProviderPrivate *priv = GET_PRIVATE (self);
+
+ nm_list_item_request_remove (NM_LIST_ITEM (req_item));
+ priv->pin_needed = FALSE;
+ modem_became_usable (self);
+}
+
+static void
modem_enabled (GObject *obj, GAsyncResult *result, gpointer user_data)
{
NMGsmDevice *device = NM_GSM_DEVICE (obj);
NMGsmProvider *self = NM_GSM_PROVIDER (user_data);
+ NMGsmProviderPrivate *priv = GET_PRIVATE (self);
GError *error = NULL;
gboolean success;
success = nm_gsm_device_enable_finish (device, result, &error);
if (error) {
- g_warning ("Modem enable failed: %s", error->message);
+ /* FIXME: The first condition only should work, but for some reason, doesn't */
+ if (dbus_g_error_has_name (error, MM_MODEM_ERROR_SIM_PIN) ||
+ !g_strcmp0 (error->message, "SIM PIN required")) {
+
+ g_debug ("PIN needed");
+ priv->pin_needed = TRUE;
+ } else
+ g_warning ("Modem enable failed: %s", error->message);
+
g_clear_error (&error);
- } else {
+ } else
g_debug ("Modem enabled successfully");
- }
- modem_became_usable (self);
+ if (success)
+ modem_became_usable (self);
+ else if (priv->pin_needed) {
+ NMListItem *item;
+
+ /* Add a PIN request item */
+ item = nm_gsm_pin_request_item_new (device);
+ g_signal_connect (item, "unlocked", G_CALLBACK (pin_unlocked), self);
+ nm_item_provider_item_added (NM_ITEM_PROVIDER (self), item);
+ }
}
static gboolean
diff --git a/src/Makefile.am b/src/Makefile.am
index 52caac7..fe7cab1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,6 +25,8 @@ network_manager_netbook_SOURCES = \
nmn-applet.h \
nmn-connection-details.c \
nmn-connection-details.h \
+ nmn-gsm-pin-request-renderer.c \
+ nmn-gsm-pin-request-renderer.h \
nmn-item-renderer.c \
nmn-item-renderer.h \
nmn-list.c \
diff --git a/src/nmn-gsm-pin-request-renderer.c b/src/nmn-gsm-pin-request-renderer.c
new file mode 100644
index 0000000..fe4a300
--- /dev/null
+++ b/src/nmn-gsm-pin-request-renderer.c
@@ -0,0 +1,167 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * (C) Copyright 2009 Novell, Inc.
+ */
+
+#include <string.h>
+#include <glib/gi18n.h>
+#include "nmn-gsm-pin-request-renderer.h"
+#include "nm-gsm-pin-request-item.h"
+#include "nm-icon-cache.h"
+#include "nm-connection-item.h"
+#include "nm-device-item.h"
+#include "nmn-connection-details.h"
+#include "utils.h"
+
+G_DEFINE_TYPE (NmnGsmPinRequestRenderer, nmn_gsm_pin_request_renderer, NMN_TYPE_ITEM_RENDERER)
+
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), NMN_TYPE_GSM_PIN_REQUEST_RENDERER, NmnGsmPinRequestRendererPrivate))
+
+typedef struct {
+ NMListItem *item;
+
+ GtkWidget *box_to_hide;
+ GtkWidget *entry;
+ GtkWidget *unlock_button;
+ GtkWidget *disable_pin;
+} NmnGsmPinRequestRendererPrivate;
+
+GtkWidget *
+nmn_gsm_pin_request_renderer_new (void)
+{
+ return (GtkWidget *) g_object_new (NMN_TYPE_GSM_PIN_REQUEST_RENDERER, NULL);
+}
+
+static void
+unlock (NmnGsmPinRequestRenderer *self)
+{
+ NmnGsmPinRequestRendererPrivate *priv = GET_PRIVATE (self);
+ NMListItem *item;
+ const char *text;
+ gboolean disable_pin;
+
+ text = gtk_entry_get_text (GTK_ENTRY (priv->entry));
+ disable_pin = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->disable_pin));
+
+ item = nmn_item_renderer_get_item (NMN_ITEM_RENDERER (self));
+ nm_gsm_pin_request_item_unlock (NM_GSM_PIN_REQUEST_ITEM (item), text, disable_pin);
+}
+
+static void
+sensitize_widgets (NmnGsmPinRequestRenderer *self)
+{
+ NmnGsmPinRequestRendererPrivate *priv = GET_PRIVATE (self);
+ const char *text;
+ gboolean sensitive;
+
+ text = gtk_entry_get_text (GTK_ENTRY (priv->entry));
+ if (text && strlen (text) > 0)
+ sensitive = TRUE;
+ else
+ sensitive = FALSE;
+
+ gtk_widget_set_sensitive (priv->unlock_button, sensitive);
+ gtk_widget_set_sensitive (priv->disable_pin, sensitive);
+}
+
+static void
+init_widgets (NmnGsmPinRequestRenderer *self)
+{
+ NmnGsmPinRequestRendererPrivate *priv = GET_PRIVATE (self);
+ GtkWidget *hbox;
+ GtkWidget *vbox;
+ GtkWidget *w;
+ char *str;
+ NMListItem *item;
+
+ item = nmn_item_renderer_get_item (NMN_ITEM_RENDERER (self));
+
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
+ gtk_container_add (GTK_CONTAINER (self), hbox);
+
+ w = gtk_image_new_from_pixbuf (nm_icon_cache_get (nm_list_item_get_icon (item)));
+ gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
+
+ w = gtk_label_new ("");
+ gtk_label_set_use_markup (GTK_LABEL (w), TRUE);
+ str = g_strdup_printf ("<big><b>%s</b></big>", nm_list_item_get_name (item));
+ gtk_label_set_markup (GTK_LABEL (w), str);
+ g_free (str);
+ gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+ priv->box_to_hide = hbox;
+
+ w = gtk_entry_new ();
+ gtk_entry_set_visibility (GTK_ENTRY (w), FALSE);
+ gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
+ priv->entry = w;
+ g_signal_connect_swapped (w, "activate", G_CALLBACK (unlock), self);
+ g_signal_connect_swapped (w, "changed", G_CALLBACK (sensitize_widgets), self);
+
+ w = gtk_button_new_with_label ("Unlock");
+ gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
+ priv->unlock_button = w;
+ g_signal_connect_swapped (w, "clicked", G_CALLBACK (unlock), self);
+
+ w = gtk_check_button_new_with_label ("Disable PIN");
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), TRUE);
+ gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
+ priv->disable_pin = w;
+
+ gtk_widget_show_all (GTK_WIDGET (self));
+}
+
+static void
+renderer_background_updated (NmnItemRenderer *item_renderer,
+ gboolean prelight)
+{
+ NmnGsmPinRequestRendererPrivate *priv = GET_PRIVATE (item_renderer);
+
+ g_object_set (priv->box_to_hide, "visible", prelight, NULL);
+}
+
+static void
+renderer_item_changed (NmnItemRenderer *item_renderer)
+{
+ init_widgets (NMN_GSM_PIN_REQUEST_RENDERER (item_renderer));
+ renderer_background_updated (item_renderer, nmn_item_renderer_is_prelight (item_renderer));
+ sensitize_widgets (NMN_GSM_PIN_REQUEST_RENDERER (item_renderer));
+}
+
+static void
+nmn_gsm_pin_request_renderer_init (NmnGsmPinRequestRenderer *item)
+{
+}
+
+static void
+nmn_gsm_pin_request_renderer_class_init (NmnGsmPinRequestRendererClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ NmnItemRendererClass *renderer_class = NMN_ITEM_RENDERER_CLASS (class);
+
+ g_type_class_add_private (object_class, sizeof (NmnGsmPinRequestRendererPrivate));
+
+ renderer_class->background_updated = renderer_background_updated;
+ renderer_class->item_changed = renderer_item_changed;
+}
diff --git a/src/nmn-gsm-pin-request-renderer.h b/src/nmn-gsm-pin-request-renderer.h
new file mode 100644
index 0000000..4351d0f
--- /dev/null
+++ b/src/nmn-gsm-pin-request-renderer.h
@@ -0,0 +1,45 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * (C) Copyright 2009 Novell, Inc.
+ */
+
+#ifndef NMN_GSM_PIN_REQUEST_RENDERER_H
+#define NMN_GSM_PIN_REQUEST_RENDERER_H
+
+#include <gtk/gtk.h>
+#include <nmn-item-renderer.h>
+
+#define NMN_TYPE_GSM_PIN_REQUEST_RENDERER (nmn_gsm_pin_request_renderer_get_type ())
+#define NMN_GSM_PIN_REQUEST_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMN_TYPE_GSM_PIN_REQUEST_RENDERER, NmnGsmPinRequestRenderer))
+#define NMN_GSM_PIN_REQUEST_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMN_TYPE_GSM_PIN_REQUEST_RENDERER, NmnGsmPinRequestRendererClass))
+#define NMN_IS_GSM_PIN_REQUEST_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMN_TYPE_GSM_PIN_REQUEST_RENDERER))
+#define NMN_IS_GSM_PIN_REQUEST_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NMN_TYPE_GSM_PIN_REQUEST_RENDERER))
+#define NMN_GSM_PIN_REQUEST_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMN_TYPE_GSM_PIN_REQUEST_RENDERER, NmnPinRequestRendererClass))
+
+typedef struct {
+ NmnItemRenderer parent;
+} NmnGsmPinRequestRenderer;
+
+typedef struct {
+ NmnItemRendererClass parent;
+} NmnGsmPinRequestRendererClass;
+
+GType nmn_gsm_pin_request_renderer_get_type (void);
+
+GtkWidget *nmn_gsm_pin_request_renderer_new (void);
+
+#endif /* NMN_ITEM_RENDERER_H */
diff --git a/src/nmn-list.c b/src/nmn-list.c
index 9c6b9c9..8340c33 100644
--- a/src/nmn-list.c
+++ b/src/nmn-list.c
@@ -21,9 +21,11 @@
#include <glib/gi18n.h>
#include <nm-list-model.h>
#include <nm-list-item.h>
+#include <nm-gsm-pin-request-item.h>
#include "nmn-list.h"
#include "nmn-model.h"
#include "nmn-network-renderer.h"
+#include "nmn-gsm-pin-request-renderer.h"
G_DEFINE_TYPE (NmnList, nmn_list, GTK_TYPE_VBOX)
@@ -271,9 +273,13 @@ model_row_inserted (GtkTreeModel *model,
index = gtk_tree_path_get_indices (path)[0];
gtk_tree_model_get (model, iter, NM_LIST_MODEL_COL_ITEM, &item, -1);
- g_debug ("Inserted row, has item %p", item);
+ g_debug ("Inserted row, has item %p (%s)", item, G_OBJECT_TYPE_NAME (item));
+
+ if (item && NM_IS_GSM_PIN_REQUEST_ITEM (item))
+ renderer = (NmnItemRenderer *) nmn_gsm_pin_request_renderer_new ();
+ else
+ renderer = (NmnItemRenderer *) nmn_network_renderer_new ();
- renderer = (NmnItemRenderer *) nmn_network_renderer_new ();
renderer->index = index;
if (gtk_tree_model_get_flags (model) & GTK_TREE_MODEL_ITERS_PERSIST)
diff --git a/src/nmn-model.c b/src/nmn-model.c
index 957f4f4..d9318f3 100644
--- a/src/nmn-model.c
+++ b/src/nmn-model.c
@@ -25,6 +25,7 @@
#include "nm-ethernet-item.h"
#include "nm-wifi-item.h"
#include "nm-gsm-item.h"
+#include "nm-gsm-pin-request-item.h"
#include "nm-cdma-item.h"
#include "nm-bt-item.h"
@@ -373,7 +374,7 @@ model_row_visible_func (GtkTreeModel *model,
visible = priv->wifi_active;
else if (NM_IS_ETHERNET_ITEM (item))
visible = priv->ethernet_active;
- else if (NM_IS_GSM_ITEM (item))
+ else if (NM_IS_GSM_ITEM (item) || NM_IS_GSM_PIN_REQUEST_ITEM (item))
visible = priv->modems_active;
else if (NM_IS_CDMA_ITEM (item))
visible = priv->modems_active;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]