Commit 6793a32a authored by Dan Winship's avatar Dan Winship

libnm: port to GDBus

Port libnm-core/libnm to GDBus.

The NetworkManager daemon continues to use dbus-glib; the
previously-added connection hash/variant conversion methods are now
moved to NetworkManagerUtils (along with a few other utilities that
are now only needed by the daemon code).
parent 16871ebc
......@@ -133,6 +133,8 @@ valgrind-*.log
/initscript/*/[Nn]etwork[Mm]anager
/introspection/all.xml
/introspection/nmdbus-*.c
/introspection/nmdbus-*.h
/libgsystem/
......
......@@ -3,11 +3,11 @@ include $(GLIB_MAKEFILE)
SUBDIRS = \
. \
include \
introspection \
libnm-core \
libnm \
libnm-util \
libnm-glib \
introspection \
src \
callouts \
clients \
......
......@@ -49,8 +49,7 @@ nm_dispatcher_LDADD = \
libnmdbus-dispatcher.la \
$(GLIB_LIBS)
# We have to build the gdbus generated code separately, without
# -DGLIB_VERSION_MAX_ALLOWED, due to a bug in GLib 2.38
# See note about gdbus-codegen in introspection/Makefile.am
noinst_LTLIBRARIES += libnmdbus-dispatcher.la
......
......@@ -5,7 +5,6 @@ AM_CPPFLAGS = \
-I${top_builddir}/libnm-core \
-I${top_srcdir}/libnm \
-I${top_builddir}/libnm \
$(DBUS_CFLAGS) \
$(GLIB_CFLAGS) \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
-DNMLOCALEDIR=\"$(datadir)/locale\"
......@@ -19,5 +18,4 @@ nm_online_CPPFLAGS = \
nm_online_LDADD = \
$(top_builddir)/libnm/libnm.la \
$(DBUS_LIBS) \
$(GLIB_LIBS)
......@@ -9,7 +9,6 @@ AM_CPPFLAGS = \
-I${top_builddir}/libnm-core \
-I${top_srcdir}/libnm \
-I${top_builddir}/libnm \
$(DBUS_CFLAGS) \
$(GLIB_CFLAGS) \
-DG_LOG_DOMAIN=\""nmcli"\" \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
......@@ -32,7 +31,6 @@ nmcli_SOURCES = \
utils.h
nmcli_LDADD = \
$(DBUS_LIBS) \
$(GLIB_LIBS) \
$(READLINE_LIBS) \
$(top_builddir)/libnm/libnm.la
......
......@@ -677,7 +677,7 @@ do_general (NmCli *nmc, int argc, char **argv)
nmc->get_client (nmc); /* create NMClient */
nm_client_set_logging (nmc->client, level, domains, &error);
if (error) {
if (g_error_matches (error, DBUS_GERROR, DBUS_GERROR_ACCESS_DENIED))
if (g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_AUTH_FAILED))
g_string_printf (nmc->return_text, _("Error: access denied to set logging; %s"), error->message);
else
g_string_printf (nmc->return_text, _("Error: %s"), error->message);
......
......@@ -12,7 +12,6 @@ AM_CPPFLAGS= \
-I$(srcdir)/newt \
$(GLIB_CFLAGS) \
$(NEWT_CFLAGS) \
$(DBUS_CFLAGS) \
$(GUDEV_CFLAGS) \
-DG_LOG_DOMAIN=\""nmtui"\" \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
......@@ -121,7 +120,6 @@ nmtui_LDADD = \
$(top_builddir)/libnm/libnm.la \
$(builddir)/newt/libnmt-newt.a \
$(GUDEV_LIBS) \
$(DBUS_LIBS) \
$(NEWT_LIBS) \
$(GLIB_LIBS) \
$(NULL)
......
......@@ -38,11 +38,9 @@ IGNORE_HFILES= \
nm-object-private.h \
nm-param-spec-dbus.h \
nm-remote-connection-private.h \
nm-secret-agent-glue.h \
nm-setting-private.h \
nm-types-private.h \
nm-utils-private.h \
nm-vpn-plugin-glue.h
nm-utils-private.h
# Images to copy into HTML directory.
HTML_IMAGES = libnm.png
......
......@@ -4,7 +4,6 @@ AM_CPPFLAGS = \
-I${top_builddir}/libnm-core \
-I${top_srcdir}/libnm \
-I${top_builddir}/libnm \
$(DBUS_CFLAGS) \
$(GLIB_CFLAGS)
noinst_PROGRAMS = \
......@@ -25,7 +24,6 @@ add_connection_gdbus_LDADD = \
add_connection_libnm_SOURCES = add-connection-libnm.c
add_connection_libnm_LDADD = \
$(top_builddir)/libnm/libnm.la \
$(DBUS_LIBS) \
$(GLIB_LIBS)
get_active_connections_gdbus_SOURCES = get-active-connections-gdbus.c
......@@ -35,7 +33,6 @@ get_active_connections_gdbus_LDADD = \
get_ap_info_libnm_SOURCES = get-ap-info-libnm.c
get_ap_info_libnm_LDADD = \
$(top_builddir)/libnm/libnm.la \
$(DBUS_LIBS) \
$(GLIB_LIBS)
list_connections_gdbus_SOURCES = list-connections-gdbus.c
......@@ -45,7 +42,6 @@ list_connections_gdbus_LDADD = \
list_connections_libnm_SOURCES = list-connections-libnm.c
list_connections_libnm_LDADD = \
$(top_builddir)/libnm/libnm.la \
$(DBUS_LIBS) \
$(GLIB_LIBS)
monitor_nm_running_gdbus_SOURCES = monitor-nm-running-gdbus.c
......
noinst_LTLIBRARIES = \
libnmdbus.la
# gdbus-codegen 2.38 will emit code that requires glib 2.38, which
# will then cause availability warnings if we define
# GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32.
#
# This is fixed in GLib 2.40 (it emits code that takes
# GLIB_VERSION_MAX_ALLOWED into account), so this workaround can go
# away when we depend on that.
AM_CPPFLAGS = $(filter-out -DGLIB_VERSION_MAX_ALLOWED%,$(GLIB_CFLAGS))
nodist_libnmdbus_la_SOURCES = \
nmdbus-access-point.c \
nmdbus-access-point.h \
nmdbus-active-connection.c \
nmdbus-active-connection.h \
nmdbus-agent-manager.c \
nmdbus-agent-manager.h \
nmdbus-device-bond.c \
nmdbus-device-bond.h \
nmdbus-device-bridge.c \
nmdbus-device-bridge.h \
nmdbus-device-bt.c \
nmdbus-device-bt.h \
nmdbus-device-ethernet.c \
nmdbus-device-ethernet.h \
nmdbus-device.c \
nmdbus-device.h \
nmdbus-device-generic.c \
nmdbus-device-generic.h \
nmdbus-device-gre.c \
nmdbus-device-gre.h \
nmdbus-device-infiniband.c \
nmdbus-device-infiniband.h \
nmdbus-device-macvlan.c \
nmdbus-device-macvlan.h \
nmdbus-device-tun.c \
nmdbus-device-tun.h \
nmdbus-device-veth.c \
nmdbus-device-veth.h \
nmdbus-device-vlan.c \
nmdbus-device-vlan.h \
nmdbus-device-vxlan.c \
nmdbus-device-vxlan.h \
nmdbus-device-wifi.c \
nmdbus-device-wifi.h \
nmdbus-device-wimax.c \
nmdbus-device-wimax.h \
nmdbus-dhcp4-config.c \
nmdbus-dhcp4-config.h \
nmdbus-dhcp6-config.c \
nmdbus-dhcp6-config.h \
nmdbus-ip4-config.c \
nmdbus-ip4-config.h \
nmdbus-ip6-config.c \
nmdbus-ip6-config.h \
nmdbus-manager.c \
nmdbus-manager.h \
nmdbus-ppp-manager.c \
nmdbus-ppp-manager.h \
nmdbus-secret-agent.c \
nmdbus-secret-agent.h \
nmdbus-settings-connection.c \
nmdbus-settings-connection.h \
nmdbus-settings.c \
nmdbus-settings.h \
nmdbus-vpn-connection.c \
nmdbus-vpn-connection.h \
nmdbus-vpn-plugin.c \
nmdbus-vpn-plugin.h
define _make_nmdbus_rule
$(1): $(patsubst nmdbus-%.c,nm-%.xml,$(1))
$$(AM_V_GEN) gdbus-codegen \
--generate-c-code $$(basename $$@) \
--c-namespace NMDBus \
--interface-prefix org.freedesktop.NetworkManager \
$$<
$(basename $(1)).h: $(1)
@true
endef
$(foreach f,$(filter %.c,$(nodist_libnmdbus_la_SOURCES)),$(eval $(call _make_nmdbus_rule,$f)))
CLEANFILES = $(nodist_libnmdbus_la_SOURCES)
EXTRA_DIST = \
all.xml.in \
generic-types.xml \
......
......@@ -2,6 +2,7 @@
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.freedesktop.NetworkManager.Device.Wired">
<annotation name="org.gtk.GDBus.C.Name" value="DeviceEthernet"/>
<property name="HwAddress" type="s" access="read">
<tp:docstring>
......
......@@ -2,6 +2,8 @@
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.freedesktop.NetworkManager.Device.Wireless">
<annotation name="org.gtk.GDBus.C.Name" value="DeviceWifi"/>
<method name="GetAccessPoints">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_get_access_points"/>
<arg name="access_points" type="ao" direction="out">
......
......@@ -2,6 +2,8 @@
<node name="/org/freedesktop/NetworkManager" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.freedesktop.NetworkManager">
<annotation name="org.gtk.GDBus.C.Name" value="Manager"/>
<method name="GetDevices">
<tp:docstring>
Get the list of network devices.
......
......@@ -2,6 +2,8 @@
<node name="/">
<interface name="org.freedesktop.NetworkManager.PPP">
<annotation name="org.gtk.GDBus.C.Name" value="PPP_Manager"/>
<method name="NeedSecrets">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_ppp_manager_need_secrets"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
......
......@@ -2,6 +2,8 @@
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.freedesktop.NetworkManager.VPN.Connection">
<annotation name="org.gtk.GDBus.C.Name" value="VpnConnection"/>
<tp:docstring>
Represents an active connection to a Virtual Private Network.
</tp:docstring>
......
......@@ -2,6 +2,8 @@
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.freedesktop.NetworkManager.VPN.Plugin">
<annotation name="org.gtk.GDBus.C.Name" value="VpnPlugin"/>
<tp:docstring>
This interface is provided by plugins providing VPN services to the NetworkManager daemon.
</tp:docstring>
......
......@@ -7,8 +7,7 @@ AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\""libnm"\" \
-DNETWORKMANAGER_COMPILATION \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS)
$(GLIB_CFLAGS)
noinst_LTLIBRARIES = libnm-core.la
......@@ -30,7 +29,6 @@ GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM
libnm_core_la_LIBADD = \
$(GLIB_LIBS) \
$(DBUS_LIBS) \
$(UUID_LIBS)
if WITH_GNUTLS
......
......@@ -78,9 +78,4 @@ GPtrArray *_nm_utils_copy_array (const GPtrArray *array,
GDestroyNotify free_func);
GPtrArray *_nm_utils_copy_object_array (const GPtrArray *array);
/* compat */
GVariant *_nm_utils_connection_hash_to_dict (GHashTable *hash);
GHashTable *_nm_utils_connection_dict_to_hash (GVariant *dict);
#endif
......@@ -29,9 +29,6 @@ gboolean _nm_utils_string_in_list (const char *str,
gboolean _nm_utils_string_slist_validate (GSList *list,
const char **valid_values);
gboolean _nm_utils_gvalue_array_validate (GValueArray *elements,
guint n_expected, ...);
/* D-Bus transform funcs */
GVariant * _nm_utils_hwaddr_to_dbus (const GValue *prop_value);
......
This diff is collapsed.
......@@ -49,8 +49,6 @@ gboolean nm_utils_same_ssid (const guint8 *ssid1, gsize len1,
gboolean ignore_trailing_null);
char * nm_utils_ssid_to_utf8 (const guint8 *ssid, gsize len);
GHashTable *nm_utils_gvalue_hash_dup (GHashTable *hash);
/**
* NMUtilsSecurityType:
* @NMU_SEC_INVALID: unknown or invalid security, placeholder and not used
......@@ -95,12 +93,6 @@ gboolean nm_utils_ap_mode_security_valid (NMUtilsSecurityType type,
gboolean nm_utils_wep_key_valid (const char *key, NMWepKeyType wep_type);
gboolean nm_utils_wpa_psk_valid (const char *psk);
GSList *nm_utils_ip4_addresses_from_gvalue (const GValue *value);
void nm_utils_ip4_addresses_to_gvalue (GSList *list, GValue *value);
GSList *nm_utils_ip4_routes_from_gvalue (const GValue *value);
void nm_utils_ip4_routes_to_gvalue (GSList *list, GValue *value);
GVariant *nm_utils_ip4_dns_to_variant (char **dns);
char **nm_utils_ip4_dns_from_variant (GVariant *value);
GVariant *nm_utils_ip4_addresses_to_variant (GPtrArray *addresses);
......@@ -112,15 +104,6 @@ guint32 nm_utils_ip4_netmask_to_prefix (guint32 netmask);
guint32 nm_utils_ip4_prefix_to_netmask (guint32 prefix);
guint32 nm_utils_ip4_get_default_prefix (guint32 ip);
GSList *nm_utils_ip6_addresses_from_gvalue (const GValue *value);
void nm_utils_ip6_addresses_to_gvalue (GSList *list, GValue *value);
GSList *nm_utils_ip6_routes_from_gvalue (const GValue *value);
void nm_utils_ip6_routes_to_gvalue (GSList *list, GValue *value);
GSList *nm_utils_ip6_dns_from_gvalue (const GValue *value);
void nm_utils_ip6_dns_to_gvalue (GSList *list, GValue *value);
GVariant *nm_utils_ip6_dns_to_variant (char **dns);
char **nm_utils_ip6_dns_from_variant (GVariant *value);
GVariant *nm_utils_ip6_addresses_to_variant (GPtrArray *addresses);
......
......@@ -4,6 +4,7 @@ SUBDIRS = . tests
AM_CPPFLAGS = \
-I$(top_srcdir)/include \
-I$(top_builddir)/introspection \
-I$(top_srcdir)/libnm-core \
-I$(top_builddir)/libnm-core \
-I$(top_srcdir)/libnm \
......@@ -12,7 +13,6 @@ AM_CPPFLAGS = \
-DNETWORKMANAGER_COMPILATION \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS) \
$(GUDEV_CFLAGS) \
-DNMRUNDIR=\"$(nmrundir)\"
......@@ -104,25 +104,15 @@ libnm_la_SOURCES = \
$(libnm_la_csources) \
$(libnm_la_private_headers)
nm-secret-agent-glue.h: $(top_srcdir)/introspection/nm-secret-agent.xml
$(AM_V_GEN) dbus-binding-tool --prefix=nm_secret_agent --mode=glib-server --output=$@ $<
nm-vpn-plugin-glue.h: $(top_srcdir)/introspection/nm-vpn-plugin.xml
$(AM_V_GEN) dbus-binding-tool --prefix=nm_vpn_plugin --mode=glib-server --output=$@ $<
GLIB_GENERATED = nm-enum-types.h nm-enum-types.c
nm_enum_types_sources = $(libnminclude_HEADERS)
GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM --fhead '\#include <nm-core-enum-types.h>\n'
GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM
BUILT_SOURCES = \
nm-vpn-plugin-glue.h \
nm-secret-agent-glue.h
libnm_la_LIBADD = \
$(top_builddir)/libnm-core/libnm-core.la \
$(top_builddir)/introspection/libnmdbus.la \
$(GLIB_LIBS) \
$(DBUS_LIBS) \
$(UUID_LIBS) \
$(GUDEV_LIBS)
......@@ -133,7 +123,7 @@ libnm_la_LDFLAGS = -Wl,--version-script=$(SYMBOL_VIS_FILE) \
###
BUILT_SOURCES += $(GLIB_GENERATED)
BUILT_SOURCES = $(GLIB_GENERATED)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libnm.pc
......@@ -160,8 +150,8 @@ introspection_sources = \
$(libnm_la_csources)
NM-1.0.gir: libnm.la
NM_1_0_gir_INCLUDES = Gio-2.0 DBusGLib-1.0
NM_1_0_gir_PACKAGES = gio-2.0 dbus-glib-1 gudev-1.0
NM_1_0_gir_INCLUDES = Gio-2.0
NM_1_0_gir_PACKAGES = gio-2.0 gudev-1.0
NM_1_0_gir_EXPORT_PACKAGES = libnm
NM_1_0_gir_CFLAGS = $(AM_CPPFLAGS)
NM_1_0_gir_LIBS = libnm.la
......
......@@ -866,7 +866,6 @@ global:
nm_utils_deinit;
nm_utils_escape_ssid;
nm_utils_file_is_pkcs12;
nm_utils_gvalue_hash_dup;
nm_utils_hex2byte;
nm_utils_hexstr2bin;
nm_utils_hwaddr_atoba;
......@@ -879,30 +878,20 @@ global:
nm_utils_inet4_ntop;
nm_utils_inet6_ntop;
nm_utils_init;
nm_utils_ip4_addresses_from_gvalue;
nm_utils_ip4_addresses_from_variant;
nm_utils_ip4_addresses_to_gvalue;
nm_utils_ip4_addresses_to_variant;
nm_utils_ip4_dns_from_variant;
nm_utils_ip4_dns_to_variant;
nm_utils_ip4_get_default_prefix;
nm_utils_ip4_netmask_to_prefix;
nm_utils_ip4_prefix_to_netmask;
nm_utils_ip4_routes_from_gvalue;
nm_utils_ip4_routes_from_variant;
nm_utils_ip4_routes_to_gvalue;
nm_utils_ip4_routes_to_variant;
nm_utils_ip6_addresses_from_gvalue;
nm_utils_ip6_addresses_from_variant;
nm_utils_ip6_addresses_to_gvalue;
nm_utils_ip6_addresses_to_variant;
nm_utils_ip6_dns_from_gvalue;
nm_utils_ip6_dns_from_variant;
nm_utils_ip6_dns_to_gvalue;
nm_utils_ip6_dns_to_variant;
nm_utils_ip6_routes_from_gvalue;
nm_utils_ip6_routes_from_variant;
nm_utils_ip6_routes_to_gvalue;
nm_utils_ip6_routes_to_variant;
nm_utils_is_empty_ssid;
nm_utils_is_uuid;
......
......@@ -32,7 +32,7 @@
#include "nm-glib-compat.h"
#include "nm-dbus-helpers.h"
static GType _nm_active_connection_decide_type (GValue *value);
static GType _nm_active_connection_decide_type (GVariant *value);
G_DEFINE_TYPE_WITH_CODE (NMActiveConnection, nm_active_connection, NM_TYPE_OBJECT,
_nm_object_register_type_func (g_define_type_id,
......@@ -83,10 +83,10 @@ enum {
};
static GType
_nm_active_connection_decide_type (GValue *value)
_nm_active_connection_decide_type (GVariant *value)
{
/* @value is the value of the o.fd.NM.ActiveConnection property "VPN" */
if (g_value_get_boolean (value))
if (g_variant_get_boolean (value))
return NM_TYPE_VPN_CONNECTION;
else
return NM_TYPE_ACTIVE_CONNECTION;
......
This diff is collapsed.
This diff is collapsed.
......@@ -22,36 +22,61 @@
#define __NM_DBUS_HELPERS_PRIVATE_H__
#include <gio/gio.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib-lowlevel.h>
DBusGConnection *_nm_dbus_new_connection (GCancellable *cancellable,
/* Copied from dbus/dbus-shared.h */
#define DBUS_SERVICE_DBUS "org.freedesktop.DBus"
#define DBUS_PATH_DBUS "/org/freedesktop/DBus"
#define DBUS_PATH_LOCAL "/org/freedesktop/DBus/Local"
#define DBUS_INTERFACE_DBUS "org.freedesktop.DBus"
#define DBUS_INTERFACE_INTROSPECTABLE "org.freedesktop.DBus.Introspectable"
#define DBUS_INTERFACE_PROPERTIES "org.freedesktop.DBus.Properties"
#define DBUS_INTERFACE_PEER "org.freedesktop.DBus.Peer"
GBusType _nm_dbus_bus_type (void);
GDBusConnection *_nm_dbus_new_connection (GCancellable *cancellable,
GError **error);
void _nm_dbus_new_connection_async (GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
DBusGConnection *_nm_dbus_new_connection_finish (GAsyncResult *result,
GDBusConnection *_nm_dbus_new_connection_finish (GAsyncResult *result,
GError **error);
gboolean _nm_dbus_is_connection_private (DBusGConnection *connection);
gboolean _nm_dbus_is_connection_private (GDBusConnection *connection);
void _nm_dbus_register_proxy_type (const char *interface,
GType proxy_type);
/* Guarantee that @interface is a static string */
#define _nm_dbus_register_proxy_type(interface, proxy_type) \
_nm_dbus_register_proxy_type (interface "", proxy_type) \
DBusGProxy *_nm_dbus_new_proxy_for_connection (DBusGConnection *connection,
GDBusProxy *_nm_dbus_new_proxy_for_connection (GDBusConnection *connection,
const char *path,
const char *interface,
GCancellable *cancellable,
GError **error);
void _nm_dbus_new_proxy_for_connection_async (DBusGConnection *connection,
void _nm_dbus_new_proxy_for_connection_async (GDBusConnection *connection,
const char *path,
const char *interface,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
DBusGProxy *_nm_dbus_new_proxy_for_connection_finish (GAsyncResult *result,
GDBusProxy *_nm_dbus_new_proxy_for_connection_finish (GAsyncResult *result,
GError **error);
void _nm_dbus_register_error_domain (GQuark domain,
const char *interface,
GType enum_type);
void _nm_dbus_bind_properties (gpointer object,
gpointer skeleton);
void _nm_dbus_bind_methods (gpointer object,
gpointer skeleton,
...) G_GNUC_NULL_TERMINATED;
#endif /* __NM_DBUS_HELPERS_PRIVATE_H__ */
......@@ -33,8 +33,10 @@
#include "nm-device-private.h"
#include "nm-object-private.h"
#include "nm-object-cache.h"
#include "nm-dbus-glib-types.h"
#include "nm-core-internal.h"
#include "nm-dbus-helpers.h"
#include "nmdbus-device-wifi.h"
G_DEFINE_TYPE (NMDeviceWifi, nm_device_wifi, NM_TYPE_DEVICE)
......@@ -45,12 +47,13 @@ static void state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user
typedef struct {
NMDeviceWifi *device;
GCancellable *cancellable;
NMDeviceWifiRequestScanFn callback;
gpointer user_data;
} RequestScanInfo;
typedef struct {
DBusGProxy *proxy;
NMDBusDeviceWifi *proxy;
char *hw_address;
char *perm_hw_address;
......@@ -60,7 +63,6 @@ typedef struct {
NMDeviceWifiCapabilities wireless_caps;
GPtrArray *aps;
DBusGProxyCall *scan_call;
RequestScanInfo *scan_info;
} NMDeviceWifiPrivate;
......@@ -286,24 +288,27 @@ nm_device_wifi_get_access_point_by_path (NMDeviceWifi *device,
}
static void
request_scan_cb (DBusGProxy *proxy,
DBusGProxyCall *call,
request_scan_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
RequestScanInfo *info = user_data;
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (info->device);
GError *error = NULL;
dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
if (info->callback) {
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (info->device);
GError *error = NULL;
nmdbus_device_wifi_call_request_scan_finish (NMDBUS_DEVICE_WIFI (source),
result, &error);
if (info->callback)
info->callback (info->device, error, info->user_data);
g_clear_error (&error);
g_slice_free (RequestScanInfo, info);
g_clear_error (&error);
priv->scan_info = NULL;
}
priv->scan_call = NULL;
priv->scan_info = NULL;
g_clear_object (&info->cancellable);
g_slice_free (RequestScanInfo, info);
}
/**
......@@ -322,29 +327,25 @@ nm_device_wifi_request_scan_simple (NMDeviceWifi *device,
gpointer user_data)
{
RequestScanInfo *info;
GHashTable *options;
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device);
g_return_if_fail (NM_IS_DEVICE_WIFI (device));
/* If a scan is in progress, just return */
if (priv->scan_call)
if (priv->scan_info)
return;
options = g_hash_table_new (g_str_hash, g_str_equal);
info = g_slice_new0 (RequestScanInfo);
info->device = device;
info->cancellable = g_cancellable_new ();
info->callback = callback;
info->user_data = user_data;
priv->scan_info = info;
priv->scan_call = dbus_g_proxy_begin_call (NM_DEVICE_WIFI_GET_PRIVATE (device)->proxy, "RequestScan",
request_scan_cb, info, NULL,
DBUS_TYPE_G_MAP_OF_VARIANT, options,
G_TYPE_INVALID);
g_hash_table_unref (options);
nmdbus_device_wifi_call_request_scan (NM_DEVICE_WIFI_GET_PRIVATE (device)->proxy,
g_variant_new_array (G_VARIANT_TYPE_VARDICT, NULL, 0),
info->cancellable,
request_scan_cb, info);
}
static void
......@@ -594,7 +595,7 @@ init_dbus (NMObject *object)
NM_OBJECT_CLASS (nm_device_wifi_parent_class)->init_dbus (object);
priv->proxy = _nm_object_get_proxy (object, NM_DBUS_INTERFACE_DEVICE_WIRELESS);
priv->proxy = NMDBUS_DEVICE_WIFI (_nm_object_get_proxy (object, NM_DBUS_INTERFACE_DEVICE_WIRELESS));
_nm_object_register_properties (object,
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
property_info);
......@@ -621,19 +622,22 @@ dispose (GObject *object)
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (object);
GError *error = NULL;
if (priv->scan_call) {
g_set_error_literal (&error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_UNKNOWN,
"Wi-Fi device was destroyed");
if (priv->scan_info) {
if (priv->scan_info->callback)
priv->scan_info->callback (NULL, error, priv->scan_info->user_data);
g_slice_free (RequestScanInfo, priv->scan_info);
priv->scan_info = NULL;
if (priv->scan_info) {
RequestScanInfo *scan_info;
scan_info = priv->scan_info;
priv->scan_info = NULL;
if (scan_info->callback) {
g_set_error_literal (&error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_UNKNOWN,
"Wi-Fi device was destroyed");
scan_info->callback (NULL, error, scan_info->user_data);
scan_info->callback = NULL;
g_clear_error (&error);
}
g_clear_error (&error);
dbus_g_proxy_cancel_call (priv->proxy, priv->scan_call);
priv->scan_call = NULL;
g_cancellable_cancel (scan_info->cancellable);
/* request_scan_cb() will free scan_info */
}
if (priv->aps)
......@@ -663,6 +667,8 @@ nm_device_wifi_class_init (NMDeviceWifiClass *wifi_class)
g_type_class_add_private (wifi_class, sizeof (NMDeviceWifiPrivate));
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE_WIRELESS);
_nm_dbus_register_proxy_type (NM_DBUS_INTERFACE_DEVICE_WIRELESS,
NMDBUS_TYPE_DEVICE_WIFI_PROXY);
/* virtual methods */
object_class->get_property = get_property;
......
......@@ -31,7 +31,6 @@
#include "nm-device-wimax.h"
#include "nm-object-private.h"
#include "nm-object-cache.h"
#include "nm-dbus-glib-types.h"
#include "nm-core-internal.h"
#include "nm-device-private.h"
......
......@@ -44,12 +44,13 @@
#include "nm-object-cache.h"
#include "nm-remote-connection.h"
#include "nm-core-internal.h"
#include "nm-dbus-glib-types.h"
#include "nm-glib-compat.h"
#include "nm-utils.h"
#include "nm-dbus-helpers.h"
static GType _nm_device_decide_type (GValue *value);
#include "nmdbus-device.h"