[gnome-control-center] network: port to the rm-userset branch of NetworkManager



commit c9a7f998180531135725b98389192304aa406584
Author: Richard Hughes <richard hughsie com>
Date:   Mon Feb 21 10:05:22 2011 +0000

    network: port to the rm-userset branch of NetworkManager

 configure.ac                              |    9 +
 panels/Makefile.am                        |    5 +-
 panels/network/Makefile.am                |    7 +-
 panels/network/cc-network-panel.c         |  966 ++++++++++++-------
 panels/network/network.ui                 |    8 +-
 panels/network/nm-access-point.c          |  290 ------
 panels/network/nm-access-point.h          |   73 --
 panels/network/nm-device.c                | 1495 -----------------------------
 panels/network/nm-device.h                |  107 --
 panels/network/panel-cell-renderer-mode.c |    2 +-
 panels/network/panel-common.c             |   93 +--
 panels/network/panel-common.h             |   42 +-
 po/POTFILES.in                            |    2 -
 13 files changed, 647 insertions(+), 2452 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d28ae31..54f7f75 100644
--- a/configure.ac
+++ b/configure.ac
@@ -78,6 +78,7 @@ CANBERRA_REQUIRED_VERSION=0.13
 GDKPIXBUF_REQUIRED_VERSION=2.23.0
 POLKIT_REQUIRED_VERSION=0.97
 GSD_REQUIRED_VERSION=2.91.9
+NETWORK_MANAGER_REQUIRED_VERSION=0.8.992
 
 COMMON_MODULES="gtk+-3.0 >= $GTK_REQUIRED_VERSION
  glib-2.0 >= $GLIB_REQUIRED_VERSION
@@ -118,6 +119,14 @@ PKG_CHECK_MODULES(USER_ACCOUNTS_PANEL, $COMMON_MODULES dbus-glib-1
                   gnome-desktop-3.0
                   gdk-pixbuf-2.0 >= $GDKPIXBUF_REQUIRED_VERSION)
 
+# Check for NetworkManager ~0.9
+PKG_CHECK_MODULES(NETWORK_MANAGER, libnm-glib >= $NETWORK_MANAGER_REQUIRED_VERSION,
+		  [have_networkmanager=yes], have_networkmanager=no)
+if test "x$have_networkmanager" = xno ; then
+        AC_MSG_WARN(*** Network panel will not be built (NetworkManager ~0.9 or newer not found) ***)
+fi
+AM_CONDITIONAL(BUILD_NETWORK, [test x$have_networkmanager = xyes])
+
 # Check for CUPS 1.4 or newer
 AC_PATH_PROG(CUPS_CONFIG, cups-config, no)
 if test "x$CUPS_CONFIG" != "xno"; then
diff --git a/panels/Makefile.am b/panels/Makefile.am
index 4527efe..06f9fdc 100644
--- a/panels/Makefile.am
+++ b/panels/Makefile.am
@@ -7,7 +7,6 @@ SUBDIRS= \
 	media \
 	mouse \
 	region \
-	network \
 	info \
 	sound \
 	keyboard \
@@ -19,4 +18,8 @@ if BUILD_PRINTERS
 SUBDIRS += printers
 endif
 
+if BUILD_NETWORK
+SUBDIRS += network
+endif
+
 -include $(top_srcdir)/git.mk
diff --git a/panels/network/Makefile.am b/panels/network/Makefile.am
index 9416f84..f53036f 100644
--- a/panels/network/Makefile.am
+++ b/panels/network/Makefile.am
@@ -3,6 +3,7 @@ cappletname = network
 INCLUDES = 						\
 	$(PANEL_CFLAGS)					\
 	$(NETWORK_PANEL_CFLAGS)				\
+	$(NETWORK_MANAGER_CFLAGS)			\
 	-DGNOMECC_UI_DIR="\"$(uidir)\""			\
 	-DGNOMELOCALEDIR="\"$(datadir)/locale\""	\
 	-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\""		\
@@ -15,10 +16,6 @@ libnetwork_la_SOURCES =					\
 	network-module.c				\
 	panel-common.c					\
 	panel-common.h					\
-	nm-device.c					\
-	nm-device.h					\
-	nm-access-point.c				\
-	nm-access-point.h				\
 	panel-cell-renderer-mode.c			\
 	panel-cell-renderer-mode.h			\
 	panel-cell-renderer-signal.c			\
@@ -26,7 +23,7 @@ libnetwork_la_SOURCES =					\
 	cc-network-panel.c				\
 	cc-network-panel.h
 
-libnetwork_la_LIBADD = $(PANEL_LIBS) $(NETWORK_PANEL_LIBS)
+libnetwork_la_LIBADD = $(PANEL_LIBS) $(NETWORK_PANEL_LIBS) $(NETWORK_MANAGER_LIBS)
 libnetwork_la_LDFLAGS = $(PANEL_LDFLAGS)
 
 uidir = $(pkgdatadir)/ui
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index 05e92ec..61a8733 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -19,12 +19,24 @@
  */
 
 #include <glib/gi18n.h>
+#include <arpa/inet.h>
+#include <stdlib.h>
 
 #include "cc-network-panel.h"
 
+#include "nm-remote-settings.h"
+#include "nm-client.h"
+#include "nm-device.h"
+#include "nm-device-ethernet.h"
+#include "nm-device-wifi.h"
+#include "nm-utils.h"
+#include "nm-active-connection.h"
+#include "nm-vpn-connection.h"
+#include "nm-setting-ip4-config.h"
+
+#include "panel-common.h"
 #include "panel-cell-renderer-mode.h"
 #include "panel-cell-renderer-signal.h"
-#include "nm-device.h"
 
 G_DEFINE_DYNAMIC_TYPE (CcNetworkPanel, cc_network_panel, CC_TYPE_PANEL)
 
@@ -35,11 +47,10 @@ struct _CcNetworkPanelPrivate
 {
         GCancellable    *cancellable;
         gchar           *current_device;
-        GDBusProxy      *proxy;
         GPtrArray       *devices;
         GSettings       *proxy_settings;
         GtkBuilder      *builder;
-        guint            devices_add_refcount;
+        NMClient        *client;
 };
 
 enum {
@@ -61,8 +72,7 @@ enum {
         PANEL_WIRELESS_COLUMN_LAST
 };
 
-static void     nm_device_refresh_item_ui               (CcNetworkPanel *panel, NmDevice *device);
-static void     panel_refresh_devices                   (CcNetworkPanel *panel);
+static void     nm_device_refresh_item_ui               (CcNetworkPanel *panel, NMDevice *device);
 
 static void
 cc_network_panel_get_property (GObject    *object,
@@ -106,9 +116,9 @@ cc_network_panel_dispose (GObject *object)
                 g_object_unref (priv->builder);
                 priv->builder = NULL;
         }
-        if (priv->proxy != NULL) {
-                g_object_unref (priv->proxy);
-                priv->proxy = NULL;
+        if (priv->client != NULL) {
+                g_object_unref (priv->client);
+                priv->client = NULL;
         }
 
         G_OBJECT_CLASS (cc_network_panel_parent_class)->dispose (object);
@@ -143,9 +153,6 @@ cc_network_panel_class_finalize (CcNetworkPanelClass *klass)
 {
 }
 
-/**
- * panel_settings_changed:
- **/
 static void
 panel_settings_changed (GSettings      *settings,
                         const gchar    *key,
@@ -153,9 +160,6 @@ panel_settings_changed (GSettings      *settings,
 {
 }
 
-/**
- * panel_proxy_mode_combo_setup_widgets:
- **/
 static void
 panel_proxy_mode_combo_setup_widgets (CcNetworkPanel *panel, guint value)
 {
@@ -181,9 +185,6 @@ panel_proxy_mode_combo_setup_widgets (CcNetworkPanel *panel, guint value)
         gtk_widget_set_visible (widget, value == 1);
 }
 
-/**
- * panel_proxy_mode_combo_changed_cb:
- **/
 static void
 panel_proxy_mode_combo_changed_cb (GtkWidget *widget, CcNetworkPanel *panel)
 {
@@ -210,9 +211,6 @@ panel_proxy_mode_combo_changed_cb (GtkWidget *widget, CcNetworkPanel *panel)
         panel_proxy_mode_combo_setup_widgets (panel, value);
 }
 
-/**
- * panel_set_value_for_combo:
- **/
 static void
 panel_set_value_for_combo (CcNetworkPanel *panel, GtkComboBox *combo_box, gint value)
 {
@@ -259,99 +257,200 @@ select_first_device (CcNetworkPanel *panel)
         gtk_tree_path_free (path);
 }
 
-/**
- * nm_device_ready_to_add_cb:
- **/
 static void
-nm_device_ready_to_add_cb (NmDevice *device, CcNetworkPanel *panel)
+panel_device_got_modem_manager_cb (GObject *source_object,
+                                   GAsyncResult *res,
+                                   gpointer user_data)
+{
+        GError *error = NULL;
+        GVariant *result = NULL;
+        GDBusProxy *proxy;
+        NMDevice *device = (NMDevice *) user_data;
+
+        proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
+        if (proxy == NULL) {
+                g_warning ("Error creating ModemManager proxy: %s",
+                           error->message);
+                g_error_free (error);
+                goto out;
+        }
+
+        /* get the IMEI */
+        result = g_dbus_proxy_get_cached_property (proxy,
+                                                   "EquipmentIdentifier");
+
+        /* save */
+        g_object_set_data_full (G_OBJECT (device),
+                                "ControlCenter::EquipmentIdentifier",
+                                g_variant_dup_string (result, NULL),
+                                g_free);
+out:
+        if (result != NULL)
+                g_variant_unref (result);
+        if (proxy != NULL)
+                g_object_unref (proxy);
+        return;
+}
+
+static void
+panel_get_registration_info_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+        gchar *operator_code = NULL;
+        GError *error = NULL;
+        guint registration_status;
+        GVariant *result = NULL;
+        gchar *operator_name = NULL;
+        NMDevice *device = (NMDevice *) user_data;
+
+        result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, &error);
+        if (result == NULL) {
+                g_warning ("Error getting registration info: %s\n",
+                           error->message);
+                g_error_free (error);
+                return;
+        }
+
+        /* get values */
+        g_variant_get (result, "((uss))",
+                       &registration_status,
+                       &operator_code,
+                       &operator_name);
+
+        /* save */
+        g_object_set_data_full (G_OBJECT (device),
+                                "ControlCenter::OperatorName",
+                                g_strdup (operator_name),
+                                g_free);
+
+        g_free (operator_name);
+        g_free (operator_code);
+        g_variant_unref (result);
+}
+
+static void
+panel_device_got_modem_manager_gsm_cb (GObject *source_object,
+                                       GAsyncResult *res,
+                                       gpointer user_data)
+{
+        GError *error = NULL;
+        GVariant *result = NULL;
+        GDBusProxy *proxy;
+        NMDevice *device = (NMDevice *) user_data;
+
+        proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
+        if (proxy == NULL) {
+                g_warning ("Error creating ModemManager GSM proxy: %s\n",
+                           error->message);
+                g_error_free (error);
+                goto out;
+        }
+
+        /* get how we are acessing the data */
+        result = g_dbus_proxy_get_cached_property (proxy,
+                                                   "AccessTechnology");
+
+        /* save */
+        g_object_set_data_full (G_OBJECT (device),
+                                "ControlCenter::AccessTechnology",
+                                g_variant_dup_string (result, NULL),
+                                g_free);
+
+        g_dbus_proxy_call (proxy,
+                           "GetRegistrationInfo",
+                           NULL,
+                           G_DBUS_CALL_FLAGS_NONE,
+                           -1,
+                           NULL,
+                           panel_get_registration_info_cb,
+                           device);
+out:
+        if (proxy != NULL)
+                g_object_unref (proxy);
+        if (result != NULL)
+                g_variant_unref (result);
+        return;
+}
+
+static void
+panel_add_device (CcNetworkPanel *panel, NMDevice *device)
 {
         GtkListStore *liststore_devices;
         GtkTreeIter iter;
         gchar *title = NULL;
+        NMDeviceType type;
         CcNetworkPanelPrivate *priv = panel->priv;
 
         g_debug ("device %s type %i",
-                 nm_device_get_object_path (device),
-                 nm_device_get_kind (device));
+                 nm_device_get_udi (device),
+                 nm_device_get_device_type (device));
+
+        g_ptr_array_add (panel->priv->devices,
+                         g_object_ref (device));
+
+        /* do we have to get additonal data from ModemManager */
+        type = nm_device_get_device_type (device);
+        if (type == NM_DEVICE_TYPE_GSM ||
+            type == NM_DEVICE_TYPE_CDMA) {
+                g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
+                                          G_DBUS_PROXY_FLAGS_NONE,
+                                          NULL,
+                                          "org.freedesktop.ModemManager",
+                                          nm_device_get_udi (device),
+                                          "org.freedesktop.ModemManager.Modem",
+                                          panel->priv->cancellable,
+                                          panel_device_got_modem_manager_cb,
+                                          device);
+                g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
+                                          G_DBUS_PROXY_FLAGS_NONE,
+                                          NULL,
+                                          "org.freedesktop.ModemManager",
+                                          nm_device_get_udi (device),
+                                          "org.freedesktop.ModemManager.Modem.Gsm.Network",
+                                          panel->priv->cancellable,
+                                          panel_device_got_modem_manager_gsm_cb,
+                                          device);
+        }
 
         /* make title a bit bigger */
         title = g_strdup_printf ("<span size=\"large\">%s</span>",
-                                 nm_device_kind_to_localized_string (nm_device_get_kind (device)));
+                                 panel_device_type_to_localized_string (nm_device_get_device_type (device)));
 
         liststore_devices = GTK_LIST_STORE (gtk_builder_get_object (priv->builder,
                                             "liststore_devices"));
         gtk_list_store_append (liststore_devices, &iter);
         gtk_list_store_set (liststore_devices,
                             &iter,
-                            PANEL_DEVICES_COLUMN_ICON, nm_device_kind_to_icon_name (nm_device_get_kind (device)),
-                            PANEL_DEVICES_COLUMN_SORT, nm_device_kind_to_sortable_string (nm_device_get_kind (device)),
+                            PANEL_DEVICES_COLUMN_ICON, panel_device_type_to_icon_name (nm_device_get_device_type (device)),
+                            PANEL_DEVICES_COLUMN_SORT, panel_device_type_to_sortable_string (nm_device_get_device_type (device)),
                             PANEL_DEVICES_COLUMN_TITLE, title,
-                            PANEL_DEVICES_COLUMN_ID, nm_device_get_object_path (device),
+                            PANEL_DEVICES_COLUMN_ID, nm_device_get_udi (device),
                             PANEL_DEVICES_COLUMN_TOOLTIP, NULL,
                             PANEL_DEVICES_COLUMN_COMPOSITE_DEVICE, device,
                             -1);
         g_free (title);
-
-        if (--panel->priv->devices_add_refcount == 0)
-                select_first_device (panel);
-}
-
-/**
- * nm_device_changed_cb:
- **/
-static void
-nm_device_changed_cb (NmDevice *device,
-                      CcNetworkPanel *panel)
-{
-        /* only refresh the selected device */
-        if (g_strcmp0 (panel->priv->current_device,
-                       nm_device_get_object_path (device)) == 0) {
-                nm_device_refresh_item_ui (panel, device);
-        }
-}
-
-/**
- * panel_add_device:
- **/
-static void
-panel_add_device (CcNetworkPanel *panel, const gchar *device_id)
-{
-        NmDevice *device;
-
-        /* create device */
-        device = nm_device_new ();
-        g_signal_connect (device, "ready",
-                          G_CALLBACK (nm_device_ready_to_add_cb), panel);
-        g_signal_connect (device, "changed",
-                          G_CALLBACK (nm_device_changed_cb), panel);
-        nm_device_refresh (device, device_id, panel->priv->cancellable);
-        g_ptr_array_add (panel->priv->devices, device);
-
-        /* get initial device state */
-        panel->priv->devices_add_refcount++;
 }
 
-/**
- * panel_remove_device:
- **/
 static void
-panel_remove_device (CcNetworkPanel *panel, const gchar *device_id)
+panel_remove_device (CcNetworkPanel *panel, NMDevice *device)
 {
         gboolean ret;
         gchar *id_tmp;
         GtkTreeIter iter;
         GtkTreeModel *model;
         guint i;
-        NmDevice *device;
+        NMDevice *device_tmp = NULL;
 
         /* remove device from array */
         for (i=0; i<panel->priv->devices->len; i++) {
-                device = g_ptr_array_index (panel->priv->devices, i);
-                if (g_strcmp0 (nm_device_get_object_path (device), device_id) == 0) {
+                device_tmp = g_ptr_array_index (panel->priv->devices, i);
+                if (g_strcmp0 (nm_device_get_udi (device),
+                               nm_device_get_udi (device_tmp)) == 0) {
                         g_ptr_array_remove_index_fast (panel->priv->devices, i);
                         break;
                 }
         }
+        if (device_tmp == NULL)
+                return;
 
         /* remove device from model */
         model = GTK_TREE_MODEL (gtk_builder_get_object (panel->priv->builder,
@@ -365,7 +464,8 @@ panel_remove_device (CcNetworkPanel *panel, const gchar *device_id)
                 gtk_tree_model_get (model, &iter,
                                     PANEL_DEVICES_COLUMN_ID, &id_tmp,
                                     -1);
-                if (g_strcmp0 (id_tmp, device_id) == 0) {
+                if (g_strcmp0 (id_tmp,
+                               nm_device_get_udi (device_tmp)) == 0) {
                         gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
                         g_free (id_tmp);
                         break;
@@ -374,142 +474,6 @@ panel_remove_device (CcNetworkPanel *panel, const gchar *device_id)
         } while (gtk_tree_model_iter_next (model, &iter));
 }
 
-/**
- * panel_get_devices_cb:
- **/
-static void
-panel_get_devices_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
-        CcNetworkPanel *panel = CC_NETWORK_PANEL (user_data);
-        const gchar *object_path;
-        GError *error = NULL;
-        gsize len;
-        GVariantIter iter;
-        GVariant *child;
-        GVariant *result;
-
-        result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, &error);
-        if (result == NULL) {
-                g_printerr ("Error getting devices: %s\n", error->message);
-                g_error_free (error);
-                return;
-        }
-
-        child = g_variant_get_child_value (result, 0);
-        len = g_variant_iter_init (&iter, child);
-        if (len == 0) {
-                g_warning ("no devices?!");
-                goto out;
-        }
-
-        /* for each entry in the array */
-        while (g_variant_iter_loop (&iter, "o", &object_path)) {
-                g_debug ("adding network device %s", object_path);
-                panel_add_device (panel, object_path);
-        }
-out:
-        g_variant_unref (result);
-        g_variant_unref (child);
-}
-
-/**
- * panel_dbus_manager_signal_cb:
- **/
-static void
-panel_dbus_manager_signal_cb (GDBusProxy *proxy,
-                              gchar *sender_name,
-                              gchar *signal_name,
-                              GVariant *parameters,
-                              gpointer user_data)
-{
-        gchar *object_path = NULL;
-        CcNetworkPanel *panel = CC_NETWORK_PANEL (user_data);
-
-        /* get the new state */
-        if (g_strcmp0 (signal_name, "StateChanged") == 0) {
-                g_debug ("ensure devices are correct");
-
-                /* refresh devices */
-                panel_refresh_devices (panel);
-                goto out;
-        }
-
-        /* device added or removed */
-        if (g_strcmp0 (signal_name, "DeviceAdded") == 0) {
-                g_variant_get (parameters, "(o)", &object_path);
-                panel_add_device (panel, object_path);
-                goto out;
-        }
-
-        /* device added or removed */
-        if (g_strcmp0 (signal_name, "DeviceRemoved") == 0) {
-                g_variant_get (parameters, "(o)", &object_path);
-                panel_remove_device (panel, object_path);
-                goto out;
-        }
-out:
-        g_free (object_path);
-}
-
-/**
- * panel_refresh_devices:
- **/
-static void
-panel_refresh_devices (CcNetworkPanel *panel)
-{
-        GtkListStore *liststore_devices;
-        CcNetworkPanelPrivate *priv = panel->priv;
-
-        /* clear the existing list */
-        liststore_devices = GTK_LIST_STORE (gtk_builder_get_object (priv->builder,
-                                            "liststore_devices"));
-        gtk_list_store_clear (liststore_devices);
-
-        /* get the new state */
-        g_dbus_proxy_call (priv->proxy,
-                           "GetDevices",
-                           NULL,
-                           G_DBUS_CALL_FLAGS_NONE,
-                           -1,
-                           priv->cancellable,
-                           panel_get_devices_cb,
-                           panel);
-
-}
-
-/**
- * panel_got_network_proxy_cb:
- **/
-static void
-panel_got_network_proxy_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
-        GError *error = NULL;
-        CcNetworkPanel *panel = CC_NETWORK_PANEL (user_data);
-        CcNetworkPanelPrivate *priv = panel->priv;
-
-        priv->proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
-        if (priv->proxy == NULL) {
-                g_printerr ("Error creating proxy: %s\n", error->message);
-                g_error_free (error);
-                select_first_device (panel);
-                goto out;
-        }
-
-        /* we want to change the UI in reflection to device events */
-        g_signal_connect (priv->proxy,
-                          "g-signal",
-                          G_CALLBACK (panel_dbus_manager_signal_cb),
-                          user_data);
-
-        /* refresh devices */
-        panel_refresh_devices (panel);
-out:
-        return;
-}
-
-/**
- * panel_add_devices_columns:
- **/
 static void
 panel_add_devices_columns (CcNetworkPanel *panel, GtkTreeView *treeview)
 {
@@ -544,9 +508,6 @@ panel_add_devices_columns (CcNetworkPanel *panel, GtkTreeView *treeview)
         gtk_tree_view_column_set_expand (column, TRUE);
 }
 
-/**
- * panel_set_widget_data:
- **/
 static void
 panel_set_widget_data (CcNetworkPanel *panel,
                        const gchar *sub_pane,
@@ -576,195 +537,331 @@ out:
         g_free (label_id);
 }
 
-/**
- * nm_device_refresh_item_access_points:
- **/
 static void
-nm_device_refresh_item_access_points (CcNetworkPanel *panel, NmDevice *device)
+add_access_point (CcNetworkPanel *panel, NMAccessPoint *ap, NMAccessPoint *active)
 {
         CcNetworkPanelPrivate *priv = panel->priv;
-        GPtrArray *access_points;
+        const GByteArray *ssid;
+        const gchar *ssid_text;
+        const gchar *hw_address;
         GtkListStore *liststore_wireless_network;
         GtkTreeIter treeiter;
         GtkWidget *widget;
-        NmAccessPoint *access_point_tmp;
-        guint i;
 
-        /* add to the model */
+        ssid = nm_access_point_get_ssid (ap);
+        if (ssid == NULL)
+                return;
+        ssid_text = nm_utils_escape_ssid (ssid->data, ssid->len);
+
         liststore_wireless_network = GTK_LIST_STORE (gtk_builder_get_object (priv->builder,
                                                      "liststore_wireless_network"));
-        gtk_list_store_clear (liststore_wireless_network);
-
-        access_points = nm_device_get_access_points (device);
-        for (i=0; i<access_points->len; i++) {
-                access_point_tmp = g_ptr_array_index (access_points, i);
-
-                gtk_list_store_append (liststore_wireless_network, &treeiter);
-                gtk_list_store_set (liststore_wireless_network,
-                                    &treeiter,
-                                    PANEL_WIRELESS_COLUMN_ID, nm_access_point_get_object_path (access_point_tmp),
-                                    PANEL_WIRELESS_COLUMN_TITLE, nm_access_point_get_ssid (access_point_tmp),
-                                    PANEL_WIRELESS_COLUMN_SORT, nm_access_point_get_ssid (access_point_tmp),
-                                    PANEL_WIRELESS_COLUMN_STRENGTH, nm_access_point_get_strength (access_point_tmp),
-                                    PANEL_WIRELESS_COLUMN_MODE, nm_access_point_get_mode (access_point_tmp),
-                                    -1);
 
-                /* is this what we're on already? */
-                if (g_strcmp0 (nm_access_point_get_object_path (access_point_tmp),
-                               nm_device_get_active_access_point (device)) == 0) {
-                        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
-                                                                     "combobox_network_name"));
-                        gtk_combo_box_set_active_iter (GTK_COMBO_BOX (widget), &treeiter);
+        hw_address = nm_access_point_get_hw_address (ap);
+        gtk_list_store_append (liststore_wireless_network, &treeiter);
+        gtk_list_store_set (liststore_wireless_network,
+                            &treeiter,
+                            PANEL_WIRELESS_COLUMN_ID, hw_address,
+                            PANEL_WIRELESS_COLUMN_TITLE, ssid_text,
+                            PANEL_WIRELESS_COLUMN_SORT, ssid_text,
+                            PANEL_WIRELESS_COLUMN_STRENGTH, nm_access_point_get_strength (ap),
+                            PANEL_WIRELESS_COLUMN_MODE, nm_access_point_get_mode (ap),
+                            -1);
+
+        /* is this what we're on already? */
+        if (active == NULL)
+                return;
+        if (g_strcmp0 (hw_address, nm_access_point_get_hw_address (active)) == 0) {
+                widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
+                                                             "combobox_network_name"));
+                gtk_combo_box_set_active_iter (GTK_COMBO_BOX (widget), &treeiter);
+        }
+}
+
+static gchar *
+ip4_address_as_string (guint32 ip)
+{
+        char buf[INET_ADDRSTRLEN+1];
+        struct in_addr tmp_addr;
+
+        memset (&buf, '\0', sizeof (buf));
+        tmp_addr.s_addr = ip;
+
+        if (inet_ntop (AF_INET, &tmp_addr, buf, INET_ADDRSTRLEN)) {
+                return g_strdup (buf);
+        } else {
+                g_warning ("error converting IP4 address 0x%X",
+                           ntohl (tmp_addr.s_addr));
+                return NULL;
+        }
+}
+
+static void
+panel_show_ip4_config (NMIP4Config *cfg)
+{
+        gchar *tmp;
+        const GArray *array;
+        const GPtrArray *ptr_array;
+        GSList *iter;
+        int i;
+
+        for (iter = (GSList *) nm_ip4_config_get_addresses (cfg); iter; iter = g_slist_next (iter)) {
+                NMIP4Address *addr = iter->data;
+                guint32 u;
+
+                tmp = ip4_address_as_string (nm_ip4_address_get_address (addr));
+                g_debug ("IP4 address: %s", tmp);
+                g_free (tmp);
+
+                u = nm_ip4_address_get_prefix (addr);
+                tmp = ip4_address_as_string (nm_utils_ip4_prefix_to_netmask (u));
+                g_debug ("IP4 prefix: %d (%s)", u, tmp);
+                g_free (tmp);
+
+                tmp = ip4_address_as_string (nm_ip4_address_get_gateway (addr));
+                g_debug ("IP4 gateway: %s", tmp);
+                g_free (tmp);
+        }
+
+        array = nm_ip4_config_get_nameservers (cfg);
+        if (array) {
+                g_debug ("IP4 DNS:");
+                for (i = 0; i < array->len; i++) {
+                        tmp = ip4_address_as_string (g_array_index (array, guint32, i));
+                        g_debug ("\t%s", tmp);
+                        g_free (tmp);
+                }
+        }
+
+        ptr_array = nm_ip4_config_get_domains (cfg);
+        if (ptr_array) {
+                g_debug ("IP4 domains:");
+                for (i = 0; i < ptr_array->len; i++)
+                        g_debug ("\t%s", (const char *) g_ptr_array_index (ptr_array, i));
+        }
+
+        array = nm_ip4_config_get_wins_servers (cfg);
+        if (array) {
+                g_debug ("IP4 WINS:");
+                for (i = 0; i < array->len; i++) {
+                        tmp = ip4_address_as_string (g_array_index (array, guint32, i));
+                        g_debug ("\t%s", tmp);
+                        g_free (tmp);
                 }
         }
-        g_ptr_array_unref (access_points);
 }
 
-/**
- * nm_device_refresh_item_ui:
- **/
 static void
-nm_device_refresh_item_ui (CcNetworkPanel *panel, NmDevice *device)
+nm_device_refresh_item_ui (CcNetworkPanel *panel, NMDevice *device)
 {
-        GtkWidget *widget;
-        NmDeviceState state;
         CcNetworkPanelPrivate *priv = panel->priv;
+        const gchar *str;
         const gchar *sub_pane = NULL;
+        const GPtrArray *aps;
+        gchar *str_tmp;
+        GHashTable *options = NULL;
+        GtkListStore *liststore_wireless_network;
+        GtkWidget *widget;
+        guint i;
+        NMAccessPoint *active_ap;
+        NMDeviceState state;
+        NMDeviceType type;
+        NMDHCP4Config *config_dhcp4 = NULL;
+        NMDHCP6Config *config_dhcp6 = NULL;
 
         /* we have a new device */
-        g_debug ("selected device is: %s", nm_device_get_object_path (device));
+        g_debug ("selected device is: %s", nm_device_get_udi (device));
         widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
                                                      "hbox_device_header"));
         gtk_widget_set_visible (widget, TRUE);
 
+        type = nm_device_get_device_type (device);
         g_debug ("device %s type %i",
-                 nm_device_get_object_path (device),
-                 nm_device_get_kind (device));
+                 nm_device_get_udi (device),
+                 type);
 
         /* set device icon */
         widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
                                                      "image_device"));
         gtk_image_set_from_icon_name (GTK_IMAGE (widget),
-                                      nm_device_kind_to_icon_name (nm_device_get_kind (device)),
+                                      panel_device_type_to_icon_name (type),
                                       GTK_ICON_SIZE_DIALOG);
 
         /* set device kind */
         widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
                                                      "label_device"));
         gtk_label_set_label (GTK_LABEL (widget),
-                             nm_device_kind_to_localized_string (nm_device_get_kind (device)));
+                             panel_device_type_to_localized_string (type));
+
 
         /* set device state */
         state = nm_device_get_state (device);
         widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
                                                      "label_status"));
         gtk_label_set_label (GTK_LABEL (widget),
-                             nm_device_state_to_localized_string (state));
+                             panel_device_state_to_localized_string (state));
 
         widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
                                                      "notebook_types"));
-        if (nm_device_get_kind (device) == NM_DEVICE_KIND_ETHERNET) {
+        if (type == NM_DEVICE_TYPE_ETHERNET) {
                 gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), 0);
                 sub_pane = "wired";
-        } else if (nm_device_get_kind (device) == NM_DEVICE_KIND_WIFI) {
+        } else if (type == NM_DEVICE_TYPE_WIFI) {
                 gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), 1);
                 sub_pane = "wireless";
-        } else if (nm_device_get_kind (device) == NM_DEVICE_KIND_GSM ||
-                   nm_device_get_kind (device) == NM_DEVICE_KIND_CDMA) {
+        } else if (type == NM_DEVICE_TYPE_GSM ||
+                   type == NM_DEVICE_TYPE_CDMA) {
                 gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), 4);
                 sub_pane = "mobilebb";
         }
         if (sub_pane == NULL)
                 goto out;
 
-        /* IPv4 address */
-        panel_set_widget_data (panel,
-                               sub_pane,
-                               "ip4",
-                               nm_device_get_ip4_address (device));
-
-        if (nm_device_get_kind (device) == NM_DEVICE_KIND_ETHERNET ||
-            nm_device_get_kind (device) == NM_DEVICE_KIND_WIFI) {
-                /* IPv6 address */
-                panel_set_widget_data (panel,
-                                       sub_pane,
-                                       "ip6",
-                                       nm_device_get_ip6_address (device));
+        /* FIXME? should we need to do something with this? */
+        if (state == NM_DEVICE_STATE_ACTIVATED)
+                panel_show_ip4_config (nm_device_get_ip4_config (device));
 
-                /* IPv4 DNS */
-                panel_set_widget_data (panel,
-                                       sub_pane,
-                                       "dns",
-                                       nm_device_get_ip4_nameserver (device));
+        if (type == NM_DEVICE_TYPE_ETHERNET) {
 
-                /* IPv4 route */
+                /* speed */
+                str_tmp = g_strdup_printf ("%d Mb/sec",
+                                           nm_device_ethernet_get_speed (NM_DEVICE_ETHERNET (device)));
                 panel_set_widget_data (panel,
                                        sub_pane,
-                                       "route",
-                                       nm_device_get_ip4_route (device));
+                                       "speed",
+                                       str_tmp);
+                g_free (str_tmp);
 
-                /* device MAC*/
+                /* device MAC */
+                str = nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (device));
                 panel_set_widget_data (panel,
                                        sub_pane,
                                        "mac",
-                                       nm_device_get_mac_address (device));
+                                       str);
 
-                /* device speed */
+        } else if (type == NM_DEVICE_TYPE_WIFI) {
+
+                /* speed */
+                str_tmp = g_strdup_printf ("%d Mb/s",
+                                           nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (device)));
                 panel_set_widget_data (panel,
                                        sub_pane,
                                        "speed",
-                                       nm_device_get_speed (device));
-        }
-
-        if (nm_device_get_kind (device) == NM_DEVICE_KIND_ETHERNET) {
+                                       str_tmp);
+                g_free (str_tmp);
 
-                /* IPv4 netmask */
+                /* device MAC */
+                str = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (device));
                 panel_set_widget_data (panel,
                                        sub_pane,
-                                       "subnet",
-                                       nm_device_get_ip4_subnet_mask (device));
-        }
+                                       "mac",
+                                       str);
+                /* security */
+                str = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (device));
+                panel_set_widget_data (panel,
+                                       sub_pane,
+                                       "security",
+                                       NULL); /* FIXME */
+
+                /* populate access point dropdown */
+                liststore_wireless_network = GTK_LIST_STORE (gtk_builder_get_object (priv->builder,
+                                                             "liststore_wireless_network"));
+                gtk_list_store_clear (liststore_wireless_network);
+                active_ap = nm_device_wifi_get_active_access_point (NM_DEVICE_WIFI (device));
+                aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device));
+                if (aps == NULL)
+                        return;
+                for (i = 0; i < aps->len; i++) {
+                        add_access_point (panel,
+                                          NM_ACCESS_POINT (g_ptr_array_index (aps, i)),
+                                          active_ap);
+                }
 
-        if (nm_device_get_kind (device) == NM_DEVICE_KIND_GSM ||
-            nm_device_get_kind (device) == NM_DEVICE_KIND_CDMA) {
+        } else if (type == NM_DEVICE_TYPE_GSM ||
+                   type == NM_DEVICE_TYPE_CDMA) {
 
                 /* IMEI */
+                str = g_object_get_data (G_OBJECT (device),
+                                         "ControlCenter::EquipmentIdentifier");
                 panel_set_widget_data (panel,
                                        sub_pane,
                                        "imei",
-                                       nm_device_get_modem_imei (device));
+                                       str);
 
                 /* operator name */
+                str = g_object_get_data (G_OBJECT (device),
+                                         "ControlCenter::OperatorName");
                 panel_set_widget_data (panel,
                                        sub_pane,
                                        "provider",
-                                       nm_device_get_operator_name (device));
+                                       str);
 
-                /* device speed: not sure where to get this data from... */
+                /* device speed */
                 panel_set_widget_data (panel,
                                        sub_pane,
                                        "speed",
                                        NULL);
         }
 
-        /* refresh access point list too */
-        if (nm_device_get_kind (device) == NM_DEVICE_KIND_WIFI) {
-                nm_device_refresh_item_access_points (panel, device);
+        /* get IP4 parameters */
+        config_dhcp4 = nm_device_get_dhcp4_config (device);
+        if (config_dhcp4 != NULL) {
+                g_object_get (G_OBJECT (config_dhcp4),
+                              NM_DHCP4_CONFIG_OPTIONS, &options,
+                              NULL);
+
+                /* IPv4 address */
+                panel_set_widget_data (panel,
+                                       sub_pane,
+                                       "ip4",
+                                       nm_dhcp4_config_get_one_option (config_dhcp4,
+                                                                       "ip_address"));
+
+                /* IPv4 DNS */
+                panel_set_widget_data (panel,
+                                       sub_pane,
+                                       "dns",
+                                       nm_dhcp4_config_get_one_option (config_dhcp4,
+                                                                       "domain_name_servers"));
+
+                /* IPv4 route */
+                panel_set_widget_data (panel,
+                                       sub_pane,
+                                       "route",
+                                       nm_dhcp4_config_get_one_option (config_dhcp4,
+                                                                       "routers"));
+
+                /* IPv4 netmask */
+                if (type == NM_DEVICE_TYPE_ETHERNET) {
+                        panel_set_widget_data (panel,
+                                               sub_pane,
+                                               "subnet",
+                                               nm_dhcp4_config_get_one_option (config_dhcp4,
+                                                                               "subnet_mask"));
+                }
+        }
+
+        /* get IP6 parameters */
+        if (0) config_dhcp6 = nm_device_get_dhcp6_config (device);
+        if (config_dhcp6 != NULL) {
+
+                /* IPv6 address */
+                panel_set_widget_data (panel,
+                                       sub_pane,
+                                       "ip6",
+                                       nm_dhcp6_config_get_one_option (config_dhcp6,
+                                                                       "ip_address"));
         }
 out:
         return;
 }
 
-/**
- * nm_devices_treeview_clicked_cb:
- **/
 static void
 nm_devices_treeview_clicked_cb (GtkTreeSelection *selection, CcNetworkPanel *panel)
 {
         GtkTreeIter iter;
         GtkTreeModel *model;
         GtkWidget *widget;
-        NmDevice *device;
+        NMDevice *device;
         CcNetworkPanelPrivate *priv = panel->priv;
 
         /* will only work in single or browse selection mode! */
@@ -795,7 +892,7 @@ nm_devices_treeview_clicked_cb (GtkTreeSelection *selection, CcNetworkPanel *pan
 
         /* save so we can update */
         g_free (priv->current_device);
-        priv->current_device = g_strdup (nm_device_get_object_path (device));
+        priv->current_device = g_strdup (nm_device_get_udi (device));
 
         /* refresh device */
         nm_device_refresh_item_ui (panel, device);
@@ -803,9 +900,6 @@ out:
         return;
 }
 
-/**
- * panel_add_proxy_device:
- **/
 static void
 panel_add_proxy_device (CcNetworkPanel *panel)
 {
@@ -831,76 +925,192 @@ panel_add_proxy_device (CcNetworkPanel *panel)
         g_free (title);
 }
 
-/**
- * panel_enable_cb:
- **/
 static void
-panel_enable_cb (GObject *source_object,
-                 GAsyncResult *res,
-                 gpointer user_data)
+cc_network_panel_notify_enable_active_cb (GtkSwitch *sw,
+                                          GParamSpec *pspec,
+                                          CcNetworkPanel *panel)
 {
-        GError *error = NULL;
-        GVariant *result;
+        gboolean enable;
 
-        result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, &error);
-        if (result == NULL) {
-                g_printerr ("Error enabling NetworkManager: %s\n",
-                            error->message);
-                g_error_free (error);
-                goto out;
+        /* set enabled state */
+        enable = !gtk_switch_get_active (sw);
+        nm_client_wireless_set_enabled (panel->priv->client, enable);
+}
+
+static void
+active_connections_changed (NMClient *client, GParamSpec *pspec, gpointer user_data)
+{
+        const GPtrArray *connections;
+        int i, j;
+
+        g_debug ("Active connections changed:");
+        connections = nm_client_get_active_connections (client);
+        for (i = 0; connections && (i < connections->len); i++) {
+                NMActiveConnection *connection;
+                const GPtrArray *devices;
+
+                connection = g_ptr_array_index (connections, i);
+                g_debug ("    %s", nm_object_get_path (NM_OBJECT (connection)));
+                devices = nm_active_connection_get_devices (connection);
+                for (j = 0; devices && j < devices->len; j++)
+                        g_debug ("           %s", nm_device_get_udi (g_ptr_array_index (devices, j)));
+                if (NM_IS_VPN_CONNECTION (connection))
+                        g_debug ("           VPN base connection: %s", nm_active_connection_get_specific_object (connection));
         }
-out:
-        if (result != NULL)
-                g_variant_unref (result);
 }
 
-/**
- * cc_network_panel_notify_enable_active_cb:
- **/
 static void
-cc_network_panel_notify_enable_active_cb (GtkSwitch *sw,
-                                          GParamSpec *pspec,
-                                          CcNetworkPanel *panel)
+device_state_notify_changed_cb (NMDevice *device,
+                                GParamSpec *pspec,
+                                gpointer user_data)
 {
-        gboolean enable;
-        CcNetworkPanelPrivate *priv = panel->priv;
+        CcNetworkPanel *panel = CC_NETWORK_PANEL (user_data);
 
-        /* get enabled state */
-        enable = !gtk_switch_get_active (sw);
+        /* only refresh the selected device */
+        if (g_strcmp0 (panel->priv->current_device,
+                       nm_device_get_udi (device)) == 0) {
+                nm_device_refresh_item_ui (panel, device);
+        }
+}
 
-        /* get the new state */
-        g_dbus_proxy_call (priv->proxy,
-                           "Enable",
-                           g_variant_new ("(b)", enable),
-                           G_DBUS_CALL_FLAGS_NONE,
-                           -1,
-                           priv->cancellable,
-                           panel_enable_cb,
-                           panel);
+static void
+device_added_cb (NMClient *client, NMDevice *device, CcNetworkPanel *panel)
+{
+        g_debug ("New device added");
+        panel_add_device (panel, device);
+        g_signal_connect (G_OBJECT (device), "notify::state",
+                          (GCallback) device_state_notify_changed_cb, NULL);
+}
+
+static void
+device_removed_cb (NMClient *client, NMDevice *device, CcNetworkPanel *panel)
+{
+        g_debug ("Device removed");
+        panel_remove_device (panel, device);
+}
+
+static void
+manager_running (NMClient *client, GParamSpec *pspec, gpointer user_data)
+{
+        const GPtrArray *devices;
+        int i;
+        NMDevice *device_tmp;
+        CcNetworkPanel *panel = CC_NETWORK_PANEL (user_data);
+
+        /* TODO: clear all devices we added */
+        if (!nm_client_get_manager_running (client)) {
+                g_debug ("NM disappeared");
+                return;
+        }
+
+        g_debug ("coldplugging devices");
+        devices = nm_client_get_devices (client);
+        if (devices == NULL) {
+                g_debug ("No devices to add");
+                return;
+        }
+        for (i = 0; i < devices->len; i++) {
+                device_tmp = g_ptr_array_index (devices, i);
+                panel_add_device (panel, device_tmp);
+        }
+
+        /* select the first device */
+        select_first_device (panel);
+}
+
+static void
+notify_connections_read_cb (NMRemoteSettings *settings,
+                            GParamSpec *pspec,
+                            gpointer user_data)
+{
+        CcNetworkPanel *panel = CC_NETWORK_PANEL (user_data);
+        GSList *list, *iter;
+
+        list = nm_remote_settings_list_connections (settings);
+        g_debug ("%p has %i remote connections",
+                 panel, g_slist_length (list));
+        for (iter = list; iter; iter = g_slist_next (iter)) {
+                NMConnection *candidate = NM_CONNECTION (iter->data);
+                /* we can't actually test this yet as VPN support in
+                 * NetworkManager 0.9 is currently broken */
+                g_debug ("TODO: add %s", nm_connection_get_path (candidate));
+        }
+}
+
+static gboolean
+panel_check_network_manager_version (CcNetworkPanel *panel)
+{
+        const gchar *message;
+        const gchar *version;
+        gchar **split;
+        GtkWidget *dialog;
+        GtkWindow *window = NULL;
+        guint major = 0;
+        guint micro = 0;
+        guint minor = 0;
+        gboolean ret = TRUE;
+
+        /* parse running version */
+        version = nm_client_get_version (panel->priv->client);
+        if (version != NULL) {
+                split = g_strsplit (version, ".", -1);
+                major = atoi (split[0]);
+                minor = atoi (split[1]);
+                micro = atoi (split[2]);
+        }
+
+        /* is it too new */
+        if (major > 0 || major > 9) {
+
+                /* TRANSLATORS: the user is running a NM that is too new and API compatible */
+                message = _("The running NetworkManager version is not compatible (too new).");
+
+        /* is it new enough */
+        } else if (minor <= 8 && micro < 992) {
+
+                /* TRANSLATORS: the user is running a NM that is too old and API compatible */
+                message = _("The running NetworkManager version is not compatible (too old).");
+        }
+
+        /* nothing to do */
+        if (message == NULL)
+                goto out;
+
+        /* do modal dialog */
+        ret = FALSE;
+        dialog = gtk_message_dialog_new (window,
+                                         GTK_DIALOG_MODAL,
+                                         GTK_MESSAGE_ERROR,
+                                         GTK_BUTTONS_CLOSE,
+                                         "%s",
+                                         message);
+        gtk_dialog_run (GTK_DIALOG (dialog));
+        gtk_widget_destroy (dialog);
+out:
+        g_strfreev (split);
+        return ret;
 }
 
-/**
- * cc_network_panel_init:
- **/
 static void
 cc_network_panel_init (CcNetworkPanel *panel)
 {
-        GError *error;
+        DBusGConnection *bus = NULL;
+        gboolean ret;
+        GError *error = NULL;
         gint value;
         GSettings *settings_tmp;
         GtkAdjustment *adjustment;
         GtkCellRenderer *renderer;
         GtkComboBox *combobox;
+        GtkStyleContext *context;
         GtkTreeSelection *selection;
         GtkTreeSortable *sortable;
         GtkWidget *widget;
-        GtkStyleContext *context;
+        NMRemoteSettings *remote_settings;
 
         panel->priv = NETWORK_PANEL_PRIVATE (panel);
 
         panel->priv->builder = gtk_builder_new ();
-
-        error = NULL;
         gtk_builder_add_from_file (panel->priv->builder,
                                    GNOMECC_UI_DIR "/network.ui",
                                    &error);
@@ -911,18 +1121,7 @@ cc_network_panel_init (CcNetworkPanel *panel)
         }
 
         panel->priv->cancellable = g_cancellable_new ();
-        panel->priv->devices = g_ptr_array_new_with_free_func ((GDestroyNotify )g_object_unref);
-
-        /* get initial icon state */
-        g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
-                                  G_DBUS_PROXY_FLAGS_NONE,
-                                  NULL,
-                                  "org.freedesktop.NetworkManager",
-                                  "/org/freedesktop/NetworkManager",
-                                  "org.freedesktop.NetworkManager",
-                                  panel->priv->cancellable,
-                                  panel_got_network_proxy_cb,
-                                  panel);
+        panel->priv->devices = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
 
         panel->priv->proxy_settings = g_settings_new ("org.gnome.system.proxy");
         g_signal_connect (panel->priv->proxy_settings,
@@ -1049,7 +1248,19 @@ cc_network_panel_init (CcNetworkPanel *panel)
                                         "signal", PANEL_WIRELESS_COLUMN_STRENGTH,
                                         NULL);
 
-        /* disable for now */
+        /* use NetworkManager client */
+        panel->priv->client = nm_client_new ();
+        g_signal_connect (panel->priv->client, "notify::" NM_CLIENT_MANAGER_RUNNING,
+                          G_CALLBACK (manager_running), panel);
+        g_signal_connect (panel->priv->client, "notify::" NM_CLIENT_ACTIVE_CONNECTIONS,
+                          G_CALLBACK (active_connections_changed), panel);
+        g_signal_connect (panel->priv->client, "device-added",
+                          G_CALLBACK (device_added_cb), panel);
+        g_signal_connect (panel->priv->client, "device-removed",
+                          G_CALLBACK (device_removed_cb), panel);
+
+        /* disable for now, until we can remove connections without
+         * segfaulting NM... */
         widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder,
                                                      "add_toolbutton"));
         gtk_widget_set_sensitive (widget, FALSE);
@@ -1061,10 +1272,34 @@ cc_network_panel_init (CcNetworkPanel *panel)
         gtk_widget_set_sensitive (widget, FALSE);
         widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder,
                                                      "switch_flight_mode"));
+        ret = nm_client_wireless_get_enabled (panel->priv->client);
+        gtk_switch_set_active (GTK_SWITCH (widget), !ret);
         g_signal_connect (GTK_SWITCH (widget), "notify::active",
                           G_CALLBACK (cc_network_panel_notify_enable_active_cb),
                           panel);
 
+        /* add remote settings such as VPN settings as virtual devices */
+        bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+        if (bus == NULL) {
+                g_warning ("Error connecting to system D-Bus: %s",
+                           error->message);
+                g_error_free (error);
+        }
+        remote_settings = nm_remote_settings_new (bus);
+        g_signal_connect (remote_settings, "notify::" NM_REMOTE_SETTINGS_CONNECTIONS_READ,
+                          G_CALLBACK (notify_connections_read_cb), panel);
+
+        /* is the user compiling against a new version, but running an
+         * old daemon version? */
+        ret = panel_check_network_manager_version (panel);
+        if (ret) {
+                manager_running (panel->priv->client, NULL, panel);
+        } else {
+                /* just select the proxy settings */
+                select_first_device (panel);
+        }
+
+        /* hide implementation details */
         widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder,
                                                      "notebook_types"));
         gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
@@ -1082,4 +1317,3 @@ cc_network_panel_register (GIOModule *module)
                                         CC_TYPE_NETWORK_PANEL,
                                         "network", 0);
 }
-
diff --git a/panels/network/network.ui b/panels/network/network.ui
index 9b70768..7ce2f3a 100644
--- a/panels/network/network.ui
+++ b/panels/network/network.ui
@@ -245,7 +245,7 @@
                                 <property name="border_width">12</property>
                                 <property name="spacing">6</property>
                                 <child>
-                                  <object class="GtkHBox" id="hbox17">
+                                  <object class="GtkHBox" id="hbox_wired_mac">
                                     <property name="visible">True</property>
                                     <property name="spacing">9</property>
                                     <child>
@@ -579,7 +579,7 @@
                                 <property name="border_width">12</property>
                                 <property name="spacing">6</property>
                                 <child>
-                                  <object class="GtkHBox" id="hbox7">
+                                  <object class="GtkHBox" id="hbox_wireless_mac">
                                     <property name="visible">True</property>
                                     <property name="spacing">9</property>
                                     <child>
@@ -624,7 +624,7 @@
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkHBox" id="hbox8">
+                                  <object class="GtkHBox" id="hbox_wireless_speed">
                                     <property name="visible">True</property>
                                     <property name="spacing">9</property>
                                     <child>
@@ -669,7 +669,7 @@
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkHBox" id="hbox11">
+                                  <object class="GtkHBox" id="hbox_wireless_security">
                                     <property name="visible">True</property>
                                     <property name="spacing">9</property>
                                     <child>
diff --git a/panels/network/panel-cell-renderer-mode.c b/panels/network/panel-cell-renderer-mode.c
index d0cf9cd..c213d21 100644
--- a/panels/network/panel-cell-renderer-mode.c
+++ b/panels/network/panel-cell-renderer-mode.c
@@ -64,7 +64,7 @@ panel_cell_renderer_set_name (PanelCellRendererMode *renderer)
 {
         const gchar *icon_name = NULL;
 
-        if (renderer->mode == NM_ACCESS_POINT_MODE_ADHOC)
+        if (renderer->mode == NM_802_11_MODE_ADHOC)
                 icon_name = "network-workgroup";
 
         g_object_set (renderer, "icon-name", icon_name, NULL);
diff --git a/panels/network/panel-common.c b/panels/network/panel-common.c
index 0123d12..928b0c4 100644
--- a/panels/network/panel-common.c
+++ b/panels/network/panel-common.c
@@ -27,12 +27,11 @@
 
 #include "panel-common.h"
 
-
 /**
  * panel_device_type_to_icon_name:
  **/
 const gchar *
-panel_device_type_to_icon_name (guint type)
+panel_device_type_to_icon_name (NMDeviceType type)
 {
         const gchar *value = NULL;
         switch (type) {
@@ -42,8 +41,8 @@ panel_device_type_to_icon_name (guint type)
         case NM_DEVICE_TYPE_WIFI:
         case NM_DEVICE_TYPE_GSM:
         case NM_DEVICE_TYPE_CDMA:
-        case NM_DEVICE_TYPE_BLUETOOTH:
-        case NM_DEVICE_TYPE_MESH:
+        case NM_DEVICE_TYPE_BT:
+        case NM_DEVICE_TYPE_OLPC_MESH:
                 value = "network-wireless";
                 break;
         default:
@@ -56,7 +55,7 @@ panel_device_type_to_icon_name (guint type)
  * panel_device_type_to_localized_string:
  **/
 const gchar *
-panel_device_type_to_localized_string (guint type)
+panel_device_type_to_localized_string (NMDeviceType type)
 {
         const gchar *value = NULL;
         switch (type) {
@@ -77,15 +76,14 @@ panel_device_type_to_localized_string (guint type)
                 /* TRANSLATORS: device type */
                 value = _("Mobile broadband");
                 break;
-        case NM_DEVICE_TYPE_BLUETOOTH:
+        case NM_DEVICE_TYPE_BT:
                 /* TRANSLATORS: device type */
                 value = _("Bluetooth");
                 break;
-        case NM_DEVICE_TYPE_MESH:
+        case NM_DEVICE_TYPE_OLPC_MESH:
                 /* TRANSLATORS: device type */
                 value = _("Mesh");
                 break;
-
         default:
                 break;
         }
@@ -98,7 +96,7 @@ panel_device_type_to_localized_string (guint type)
  * Try to return order of approximate connection speed.
  **/
 const gchar *
-panel_device_type_to_sortable_string (guint type)
+panel_device_type_to_sortable_string (NMDeviceType type)
 {
         const gchar *value = NULL;
         switch (type) {
@@ -112,10 +110,10 @@ panel_device_type_to_sortable_string (guint type)
         case NM_DEVICE_TYPE_CDMA:
                 value = "3";
                 break;
-        case NM_DEVICE_TYPE_BLUETOOTH:
+        case NM_DEVICE_TYPE_BT:
                 value = "4";
                 break;
-        case NM_DEVICE_TYPE_MESH:
+        case NM_DEVICE_TYPE_OLPC_MESH:
                 value = "5";
                 break;
         default:
@@ -129,7 +127,7 @@ panel_device_type_to_sortable_string (guint type)
  * panel_ap_mode_to_localized_string:
  **/
 const gchar *
-panel_ap_mode_to_localized_string (guint mode)
+panel_ap_mode_to_localized_string (NM80211Mode mode)
 {
         const gchar *value = NULL;
         switch (mode) {
@@ -155,7 +153,7 @@ panel_ap_mode_to_localized_string (guint mode)
  * panel_device_state_to_localized_string:
  **/
 const gchar *
-panel_device_state_to_localized_string (guint type)
+panel_device_state_to_localized_string (NMDeviceState type)
 {
         const gchar *value = NULL;
         switch (type) {
@@ -191,75 +189,26 @@ panel_device_state_to_localized_string (guint type)
                 /* TRANSLATORS: device status */
                 value = _("Getting network address");
                 break;
+        case NM_DEVICE_STATE_IP_CHECK:
+                /* TRANSLATORS: device status */
+                value = _("Checking network address");
+                break;
         case NM_DEVICE_STATE_ACTIVATED:
                 /* TRANSLATORS: device status */
                 value = _("Connected");
                 break;
+        case NM_DEVICE_STATE_DEACTIVATING:
+                /* TRANSLATORS: device status */
+                value = _("Disconnecting");
+                break;
         case NM_DEVICE_STATE_FAILED:
                 /* TRANSLATORS: device status */
                 value = _("Failed to connect");
                 break;
         default:
+                /* TRANSLATORS: device status */
+                value = _("Status unknown (missing)");
                 break;
         }
         return value;
 }
-
-/**
- * panel_ipv4_to_string:
- **/
-gchar *
-panel_ipv4_to_string (GVariant *variant)
-{
-        gchar *ip_str;
-        guint32 ip;
-
-        g_variant_get (variant, "u", &ip);
-        ip_str = g_strdup_printf ("%i.%i.%i.%i",
-                                    ip & 0x000000ff,
-                                   (ip & 0x0000ff00) / 0x100,
-                                   (ip & 0x00ff0000) / 0x10000,
-                                   (ip & 0xff000000) / 0x1000000);
-        return ip_str;
-}
-
-/**
- * panel_ipv6_to_string:
- *
- * Formats an 'ay' variant into a IPv6 address you recognise, e.g.
- * "fe80::21c:bfff:fe81:e8de"
- **/
-gchar *
-panel_ipv6_to_string (GVariant *variant)
-{
-        gchar tmp1;
-        gchar tmp2;
-        guint i = 0;
-        gboolean ret = FALSE;
-        GString *string;
-
-        if (g_variant_n_children (variant) != 16)
-                return NULL;
-
-        string = g_string_new ("");
-        for (i=0; i<16; i+=2) {
-                g_variant_get_child (variant, i+0, "y", &tmp1);
-                g_variant_get_child (variant, i+1, "y", &tmp2);
-                if (tmp1 == 0 && tmp2 == 0) {
-                        if (!ret) {
-                                g_string_append (string, ":");
-                                ret = TRUE;
-                        }
-                } else {
-                        g_string_append_printf (string,
-                                                "%x%x%x%x:",
-                                                (tmp1 & 0xf0) / 16,
-                                                 tmp1 & 0x0f,
-                                                (tmp2 & 0xf0) / 16,
-                                                 tmp2 & 0x0f);
-                        ret = FALSE;
-                }
-        }
-        g_string_set_size (string, string->len - 1);
-        return g_string_free (string, FALSE);
-}
diff --git a/panels/network/panel-common.h b/panels/network/panel-common.h
index c769887..c50f6b3 100644
--- a/panels/network/panel-common.h
+++ b/panels/network/panel-common.h
@@ -23,45 +23,15 @@
 #define PANEL_COMMON_H
 
 #include <glib-object.h>
+#include <NetworkManager.h>
 
 G_BEGIN_DECLS
 
-typedef enum {
-        NM_DEVICE_TYPE_UNKNOWN,
-        NM_DEVICE_TYPE_ETHERNET,
-        NM_DEVICE_TYPE_WIFI,
-        NM_DEVICE_TYPE_GSM,
-        NM_DEVICE_TYPE_CDMA,
-        NM_DEVICE_TYPE_BLUETOOTH,
-        NM_DEVICE_TYPE_MESH
-} NMDeviceType;
-
-typedef enum {
-        NM_DEVICE_STATE_UNKNOWN,
-        NM_DEVICE_STATE_UNMANAGED,
-        NM_DEVICE_STATE_UNAVAILABLE,
-        NM_DEVICE_STATE_DISCONNECTED,
-        NM_DEVICE_STATE_PREPARE,
-        NM_DEVICE_STATE_CONFIG,
-        NM_DEVICE_STATE_NEED_AUTH,
-        NM_DEVICE_STATE_IP_CONFIG,
-        NM_DEVICE_STATE_ACTIVATED,
-        NM_DEVICE_STATE_FAILED
-} NMDeviceState;
-
-typedef enum {
-        NM_802_11_MODE_UNKNOWN = 0,
-        NM_802_11_MODE_ADHOC,
-        NM_802_11_MODE_INFRA
-} NM80211Mode;
-
-const gchar     *panel_device_type_to_icon_name                 (guint type);
-const gchar     *panel_device_type_to_localized_string          (guint type);
-const gchar     *panel_device_type_to_sortable_string           (guint type);
-const gchar     *panel_ap_mode_to_localized_string              (guint mode);
-const gchar     *panel_device_state_to_localized_string         (guint type);
-gchar           *panel_ipv4_to_string                           (GVariant *variant);
-gchar           *panel_ipv6_to_string                           (GVariant *variant);
+const gchar     *panel_device_type_to_icon_name                 (NMDeviceType type);
+const gchar     *panel_device_type_to_localized_string          (NMDeviceType type);
+const gchar     *panel_device_type_to_sortable_string           (NMDeviceType type);
+const gchar     *panel_ap_mode_to_localized_string              (NM80211Mode mode);
+const gchar     *panel_device_state_to_localized_string         (NMDeviceState type);
 
 G_END_DECLS
 
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 9617f1a..e4d3cc6 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -47,8 +47,6 @@ panels/mouse/gnome-mouse-properties.c
 [type: gettext/glade]panels/mouse/gnome-mouse-properties.ui
 panels/mouse/gnome-mouse-panel.desktop.in.in
 panels/network/cc-network-panel.c
-panels/network/nm-device.c
-panels/network/nm-access-point.c
 panels/network/gnome-network-panel.desktop.in.in
 [type: gettext/glade]panels/network/network.ui
 panels/network/panel-common.c



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]