Commit c9a7f998 authored by Richard Hughes's avatar Richard Hughes

network: port to the rm-userset branch of NetworkManager

parent 21683ab8
......@@ -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
......
......@@ -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
......@@ -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
......
This diff is collapsed.
......@@ -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>
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010-2011 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* 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.
*/
#include "config.h"
#include <glib-object.h>
#include <gio/gio.h>
#include <glib/gi18n.h>
#include "nm-access-point.h"
#define NM_ACCESS_POINT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_ACCESS_POINT, NmAccessPointPrivate))
/**
* NmAccessPointPrivate:
*
* Private #NmAccessPoint data
**/
struct _NmAccessPointPrivate
{
GCancellable *cancellable;
NmAccessPointMode mode;
gchar *object_path;
GDBusProxy *proxy;
gchar *ssid;
guint strength;
};
enum {
SIGNAL_CHANGED,
SIGNAL_LAST
};
static guint signals[SIGNAL_LAST] = { 0 };
G_DEFINE_TYPE (NmAccessPoint, nm_access_point, G_TYPE_OBJECT)
/**
* nm_access_point_mode_to_localized_string:
**/
const gchar *
nm_access_point_mode_to_localized_string (NmAccessPointMode mode)
{
const gchar *value = NULL;
switch (mode) {
case NM_ACCESS_POINT_MODE_UNKNOWN:
/* TRANSLATORS: AP type */
value = _("Unknown");
break;
case NM_ACCESS_POINT_MODE_ADHOC:
/* TRANSLATORS: AP type */
value = _("Ad-hoc");
break;
case NM_ACCESS_POINT_MODE_INFRA:
/* TRANSLATORS: AP type */
value = _("Infrastructure");
break;
default:
break;
}
return value;
}
/**
* nm_access_point_get_mode:
**/
NmAccessPointMode
nm_access_point_get_mode (NmAccessPoint *access_point)
{
GVariant *variant;
g_return_val_if_fail (NM_IS_ACCESS_POINT (access_point), 0);
/* get the mode */
variant = g_dbus_proxy_get_cached_property (access_point->priv->proxy,
"Mode");
access_point->priv->mode = g_variant_get_uint32 (variant);
g_variant_unref (variant);
return access_point->priv->mode;
}
/**
* nm_access_point_get_strength:
**/
guint
nm_access_point_get_strength (NmAccessPoint *access_point)
{
GVariant *variant;
g_return_val_if_fail (NM_IS_ACCESS_POINT (access_point), 0);
/* get the strength */
variant = g_dbus_proxy_get_cached_property (access_point->priv->proxy,
"Strength");
access_point->priv->strength = g_variant_get_byte (variant);
g_variant_unref (variant);
return access_point->priv->strength;
}
/**
* nm_access_point_get_object_path:
**/
const gchar *
nm_access_point_get_object_path (NmAccessPoint *access_point)
{
g_return_val_if_fail (NM_IS_ACCESS_POINT (access_point), NULL);
return access_point->priv->object_path;
}
/**
* nm_access_point_get_ssid:
**/
const gchar *
nm_access_point_get_ssid (NmAccessPoint *access_point)
{
gchar tmp;
gsize len;
guint i = 0;
GVariantIter iter;
GVariant *value = NULL;
NmAccessPointPrivate *priv = access_point->priv;
g_return_val_if_fail (NM_IS_ACCESS_POINT (access_point), NULL);
/* clear */
g_free (priv->ssid);
priv->ssid = NULL;
/* get the (non NULL terminated, urgh) SSID */
value = g_dbus_proxy_get_cached_property (priv->proxy, "Ssid");
len = g_variant_iter_init (&iter, value);
if (len == 0) {
g_warning ("invalid ssid?!");
goto out;
}
/* decode each byte */
priv->ssid = g_new0 (gchar, len + 1);
while (g_variant_iter_loop (&iter, "y", &tmp))
priv->ssid[i++] = tmp;
g_debug ("adding access point %s (%i%%) [%i]",
priv->ssid,
priv->strength,
priv->mode);
out:
if (value != NULL)
g_variant_unref (value);
return access_point->priv->ssid;
}
/**
* nm_access_point_emit_changed:
**/
static void
nm_access_point_emit_changed (NmAccessPoint *access_point)
{
g_debug ("NmAccessPoint: emit 'changed' for %s",
access_point->priv->object_path);
g_signal_emit (access_point, signals[SIGNAL_CHANGED], 0);
}
/**
* nm_access_point_got_proxy_cb:
**/
static void
nm_access_point_got_proxy_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GError *error = NULL;
NmAccessPoint *access_point = (NmAccessPoint *) user_data;
NmAccessPointPrivate *priv = access_point->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);
goto out;
}
/* emit changed */
nm_access_point_emit_changed (access_point);
out:
return;
}
/**
* nm_access_point_refresh:
*
* 100% async.
**/
void
nm_access_point_refresh (NmAccessPoint *access_point,
const gchar *object_path,
GCancellable *cancellable)
{
access_point->priv->object_path = g_strdup (object_path);
if (cancellable != NULL)
access_point->priv->cancellable = g_object_ref (cancellable);
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
"org.freedesktop.NetworkManager",
object_path,
"org.freedesktop.NetworkManager.AccessPoint",
access_point->priv->cancellable,
nm_access_point_got_proxy_cb,
access_point);
}
/**
* nm_access_point_finalize:
**/
static void
nm_access_point_finalize (GObject *object)
{
NmAccessPoint *access_point = NM_ACCESS_POINT (object);
NmAccessPointPrivate *priv = access_point->priv;
if (priv->proxy != NULL)
g_object_unref (priv->proxy);
if (priv->cancellable != NULL)
g_object_unref (priv->cancellable);
g_free (priv->ssid);
g_free (priv->object_path);
G_OBJECT_CLASS (nm_access_point_parent_class)->finalize (object);
}
/**
* nm_access_point_class_init:
**/
static void
nm_access_point_class_init (NmAccessPointClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = nm_access_point_finalize;
/**
* NmAccessPoint::changed:
**/
signals[SIGNAL_CHANGED] =
g_signal_new ("changed",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (NmAccessPointClass, changed),
NULL, NULL, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_type_class_add_private (klass, sizeof (NmAccessPointPrivate));
}
/**
* nm_access_point_init:
**/
static void
nm_access_point_init (NmAccessPoint *access_point)
{
access_point->priv = NM_ACCESS_POINT_GET_PRIVATE (access_point);
}
/**
* nm_access_point_new:
**/
NmAccessPoint *
nm_access_point_new (void)
{
NmAccessPoint *access_point;
access_point = g_object_new (NM_TYPE_ACCESS_POINT, NULL);
return NM_ACCESS_POINT (access_point);
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010-2011 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* 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.
*/
#ifndef __NM_ACCESS_POINT_H
#define __NM_ACCESS_POINT_H
#include <glib-object.h>
G_BEGIN_DECLS
#define NM_TYPE_ACCESS_POINT (nm_access_point_get_type ())
#define NM_ACCESS_POINT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NM_TYPE_ACCESS_POINT, NmAccessPoint))
#define NM_ACCESS_POINT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NM_TYPE_ACCESS_POINT, NmAccessPointClass))
#define NM_IS_ACCESS_POINT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NM_TYPE_ACCESS_POINT))
#define NM_IS_ACCESS_POINT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NM_TYPE_ACCESS_POINT))
#define NM_ACCESS_POINT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NM_TYPE_ACCESS_POINT, NmAccessPointClass))
typedef struct _NmAccessPointPrivate NmAccessPointPrivate;
typedef struct _NmAccessPoint NmAccessPoint;
typedef struct _NmAccessPointClass NmAccessPointClass;
struct _NmAccessPoint
{
GObject parent;
NmAccessPointPrivate *priv;
};
struct _NmAccessPointClass
{
GObjectClass parent_class;
void (* changed) (NmAccessPoint *access_point);
};
typedef enum {
NM_ACCESS_POINT_MODE_UNKNOWN,
NM_ACCESS_POINT_MODE_ADHOC,
NM_ACCESS_POINT_MODE_INFRA
} NmAccessPointMode;
GType nm_access_point_get_type (void);
NmAccessPoint *nm_access_point_new (void);
void nm_access_point_refresh (NmAccessPoint *access_point,
const gchar *object_path,
GCancellable *cancellable);
NmAccessPointMode nm_access_point_get_mode (NmAccessPoint *access_point);
guint nm_access_point_get_strength (NmAccessPoint *access_point);
const gchar *nm_access_point_get_ssid (NmAccessPoint *access_point);
const gchar *nm_access_point_get_object_path (NmAccessPoint *access_point);
const gchar *nm_access_point_mode_to_localized_string (NmAccessPointMode mode);
G_END_DECLS
#endif /* __NM_ACCESS_POINT_H */
This diff is collapsed.
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010-2011 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* 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.
*/
#ifndef __NM_DEVICE_H
#define __NM_DEVICE_H
#include <glib-object.h>
G_BEGIN_DECLS
#define NM_TYPE_DEVICE (nm_device_get_type ())
#define NM_DEVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NM_TYPE_DEVICE, NmDevice))
#define NM_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NM_TYPE_DEVICE, NmDeviceClass))
#define NM_IS_DEVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NM_TYPE_DEVICE))
#define NM_IS_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NM_TYPE_DEVICE))
#define NM_DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NM_TYPE_DEVICE, NmDeviceClass))
typedef struct _NmDevicePrivate NmDevicePrivate;
typedef struct _NmDevice NmDevice;
typedef struct _NmDeviceClass NmDeviceClass;
struct _NmDevice
{
GObject parent;
NmDevicePrivate *priv;
};
struct _NmDeviceClass
{
GObjectClass parent_class;
void (* ready) (NmDevice *device);
void (* changed) (NmDevice *device);
};
typedef enum {
NM_DEVICE_KIND_UNKNOWN,
NM_DEVICE_KIND_ETHERNET,
NM_DEVICE_KIND_WIFI,
NM_DEVICE_KIND_GSM,
NM_DEVICE_KIND_CDMA,
NM_DEVICE_KIND_BLUETOOTH,
NM_DEVICE_KIND_MESH
} NmDeviceKind;
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;
GType nm_device_get_type (void);
NmDevice *nm_device_new (void);
void nm_device_refresh (NmDevice *device,
const gchar *object_path,
GCancellable *cancellable);
const gchar *nm_device_get_active_access_point (NmDevice *device);
const gchar *nm_device_get_ip4_address (NmDevice *device);
const gchar *nm_device_get_ip4_nameserver (NmDevice *device);
const gchar *nm_device_get_ip4_route (NmDevice *device);
const gchar *nm_device_get_ip4_subnet_mask (NmDevice *device);
const gchar *nm_device_get_ip6_address (NmDevice *device);
const gchar *nm_device_get_ip6_nameserver (NmDevice *device);
const gchar *nm_device_get_ip6_route (NmDevice *device);
const gchar *nm_device_get_mac_address (NmDevice *device);
const gchar *nm_device_get_modem_imei (NmDevice *device);
const gchar *nm_device_get_object_path (NmDevice *device);
const gchar *nm_device_get_operator_name (NmDevice *device);
const gchar *nm_device_get_speed (NmDevice *device);
NmDeviceState nm_device_get_state (NmDevice *device);
NmDeviceKind nm_device_get_kind (NmDevice *device);
GPtrArray *nm_device_get_access_points (NmDevice *device);
const gchar *nm_device_kind_to_icon_name (NmDeviceKind kind);
const gchar *nm_device_kind_to_localized_string (NmDeviceKind kind);
const gchar *nm_device_kind_to_sortable_string (NmDeviceKind kind);
const gchar *nm_device_state_to_localized_string (NmDeviceState kind);
G_END_DECLS
#endif /* __NM_DEVICE_H */
......@@ -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);
......
......@@ -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) {