mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-12 14:40:40 +01:00
merge: branch 'lr/object-manager'
https://bugzilla.gnome.org/show_bug.cgi?id=771191
This commit is contained in:
commit
b9f9864bc4
45 changed files with 1159 additions and 1919 deletions
|
|
@ -228,7 +228,9 @@ nodist_introspection_libnmdbus_la_SOURCES = \
|
|||
introspection/nmdbus-vpn-connection.c \
|
||||
introspection/nmdbus-vpn-connection.h \
|
||||
introspection/nmdbus-vpn-plugin.c \
|
||||
introspection/nmdbus-vpn-plugin.h
|
||||
introspection/nmdbus-vpn-plugin.h \
|
||||
introspection/nmdbus-wimax-nsp.c \
|
||||
introspection/nmdbus-wimax-nsp.h
|
||||
|
||||
DBUS_INTERFACE_DOCS = \
|
||||
introspection/nmdbus-access-point-org.freedesktop.NetworkManager.AccessPoint.xml \
|
||||
|
|
@ -668,7 +670,6 @@ libnm_libnm_la_private_headers = \
|
|||
libnm/nm-ip4-config.h \
|
||||
libnm/nm-ip6-config.h \
|
||||
libnm/nm-manager.h \
|
||||
libnm/nm-object-cache.h \
|
||||
libnm/nm-object-private.h \
|
||||
libnm/nm-remote-connection-private.h \
|
||||
libnm/nm-remote-settings.h
|
||||
|
|
@ -704,7 +705,6 @@ libnm_libnm_la_sources = \
|
|||
libnm/nm-ip4-config.c \
|
||||
libnm/nm-ip6-config.c \
|
||||
libnm/nm-manager.c \
|
||||
libnm/nm-object-cache.c \
|
||||
libnm/nm-object.c \
|
||||
libnm/nm-remote-connection.c \
|
||||
libnm/nm-remote-settings.c \
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ IGNORE_HFILES= \
|
|||
nm-ip4-config.h \
|
||||
nm-ip6-config.h \
|
||||
nm-manager.h \
|
||||
nm-object-cache.h \
|
||||
nm-object-private.h \
|
||||
nm-property-compare.h \
|
||||
nm-remote-connection-private.h \
|
||||
|
|
|
|||
|
|
@ -485,8 +485,6 @@ nm_access_point_class_init (NMAccessPointClass *ap_class)
|
|||
|
||||
g_type_class_add_private (ap_class, sizeof (NMAccessPointPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_ACCESS_POINT);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->get_property = get_property;
|
||||
object_class->finalize = finalize;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
#include "nm-object-private.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-device.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-connection.h"
|
||||
#include "nm-vpn-connection.h"
|
||||
#include "nm-dbus-helpers.h"
|
||||
|
|
@ -38,14 +37,7 @@
|
|||
#include "nm-ip6-config.h"
|
||||
#include "nm-remote-connection.h"
|
||||
|
||||
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,
|
||||
_nm_active_connection_decide_type,
|
||||
NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
|
||||
"Vpn");
|
||||
)
|
||||
G_DEFINE_TYPE (NMActiveConnection, nm_active_connection, NM_TYPE_OBJECT);
|
||||
|
||||
#define NM_ACTIVE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionPrivate))
|
||||
|
||||
|
|
@ -88,16 +80,6 @@ enum {
|
|||
LAST_PROP
|
||||
};
|
||||
|
||||
static GType
|
||||
_nm_active_connection_decide_type (GVariant *value)
|
||||
{
|
||||
/* @value is the value of the o.fd.NM.ActiveConnection property "VPN" */
|
||||
if (g_variant_get_boolean (value))
|
||||
return NM_TYPE_VPN_CONNECTION;
|
||||
else
|
||||
return NM_TYPE_ACTIVE_CONNECTION;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_active_connection_get_connection:
|
||||
* @connection: a #NMActiveConnection
|
||||
|
|
@ -519,8 +501,6 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class)
|
|||
|
||||
g_type_class_add_private (ap_class, sizeof (NMActiveConnectionPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_ACTIVE_CONNECTION);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->get_property = get_property;
|
||||
object_class->dispose = dispose;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -98,24 +98,6 @@ _nm_dbus_is_connection_private (GDBusConnection *connection)
|
|||
return g_dbus_connection_get_unique_name (connection) == NULL;
|
||||
}
|
||||
|
||||
static GHashTable *proxy_types;
|
||||
|
||||
#undef _nm_dbus_register_proxy_type
|
||||
void
|
||||
_nm_dbus_register_proxy_type (const char *interface,
|
||||
GType proxy_type)
|
||||
{
|
||||
if (!proxy_types)
|
||||
proxy_types = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
g_assert (g_hash_table_lookup (proxy_types, interface) == NULL);
|
||||
g_hash_table_insert (proxy_types, (char *) interface, GSIZE_TO_POINTER (proxy_type));
|
||||
}
|
||||
|
||||
/* We don't (currently) use GDBus's property-handling code */
|
||||
#define NM_DBUS_PROXY_FLAGS (G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | \
|
||||
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START)
|
||||
|
||||
/* D-Bus has an upper limit on number of Match rules and it's rather easy
|
||||
* to hit as the proxy likes to add one for each object. Let's remove the Match
|
||||
* rule the proxy added and ensure a less granular rule is present instead.
|
||||
|
|
@ -126,15 +108,13 @@ _nm_dbus_register_proxy_type (const char *interface,
|
|||
* Ideally, we should be able to tell glib not to hook its rules:
|
||||
* https://bugzilla.gnome.org/show_bug.cgi?id=758749
|
||||
*/
|
||||
static void
|
||||
void
|
||||
_nm_dbus_proxy_replace_match (GDBusProxy *proxy)
|
||||
{
|
||||
GDBusConnection *connection = g_dbus_proxy_get_connection (proxy);
|
||||
static unsigned match_counter = 1024;
|
||||
gchar *match;
|
||||
|
||||
nm_assert (!g_strcmp0 (g_dbus_proxy_get_name (proxy), NM_DBUS_SERVICE));
|
||||
|
||||
if (match_counter == 1) {
|
||||
/* If we hit the low matches watermark, install a
|
||||
* less granular one. */
|
||||
|
|
@ -177,83 +157,6 @@ _nm_dbus_proxy_replace_match (GDBusProxy *proxy)
|
|||
g_free (match);
|
||||
}
|
||||
|
||||
GDBusProxy *
|
||||
_nm_dbus_new_proxy_for_connection (GDBusConnection *connection,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
GDBusProxy *proxy;
|
||||
GType proxy_type;
|
||||
const char *name;
|
||||
|
||||
proxy_type = GPOINTER_TO_SIZE (g_hash_table_lookup (proxy_types, interface));
|
||||
if (!proxy_type)
|
||||
proxy_type = G_TYPE_DBUS_PROXY;
|
||||
|
||||
if (_nm_dbus_is_connection_private (connection))
|
||||
name = NULL;
|
||||
else
|
||||
name = NM_DBUS_SERVICE;
|
||||
|
||||
proxy = g_initable_new (proxy_type, cancellable, error,
|
||||
"g-connection", connection,
|
||||
"g-flags", NM_DBUS_PROXY_FLAGS,
|
||||
"g-name", name,
|
||||
"g-object-path", path,
|
||||
"g-interface-name", interface,
|
||||
NULL);
|
||||
_nm_dbus_proxy_replace_match (proxy);
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
||||
void
|
||||
_nm_dbus_new_proxy_for_connection_async (GDBusConnection *connection,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GType proxy_type;
|
||||
const char *name;
|
||||
|
||||
proxy_type = GPOINTER_TO_SIZE (g_hash_table_lookup (proxy_types, interface));
|
||||
if (!proxy_type)
|
||||
proxy_type = G_TYPE_DBUS_PROXY;
|
||||
|
||||
if (_nm_dbus_is_connection_private (connection))
|
||||
name = NULL;
|
||||
else
|
||||
name = NM_DBUS_SERVICE;
|
||||
|
||||
g_async_initable_new_async (proxy_type, G_PRIORITY_DEFAULT,
|
||||
cancellable, callback, user_data,
|
||||
"g-connection", connection,
|
||||
"g-flags", NM_DBUS_PROXY_FLAGS,
|
||||
"g-name", name,
|
||||
"g-object-path", path,
|
||||
"g-interface-name", interface,
|
||||
NULL);
|
||||
}
|
||||
|
||||
GDBusProxy *
|
||||
_nm_dbus_new_proxy_for_connection_finish (GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
GObject *source;
|
||||
GDBusProxy *proxy;
|
||||
|
||||
source = g_async_result_get_source_object (result);
|
||||
proxy = G_DBUS_PROXY (g_async_initable_new_finish (G_ASYNC_INITABLE (source), result, error));
|
||||
g_object_unref (source);
|
||||
_nm_dbus_proxy_replace_match (proxy);
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
||||
/* Binds the properties on a generated server-side GDBus object to the
|
||||
* corresponding properties on the public object.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -36,26 +36,7 @@ GDBusConnection *_nm_dbus_new_connection_finish (GAsyncResult *result,
|
|||
|
||||
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) \
|
||||
|
||||
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 (GDBusConnection *connection,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
GDBusProxy *_nm_dbus_new_proxy_for_connection_finish (GAsyncResult *result,
|
||||
GError **error);
|
||||
void _nm_dbus_proxy_replace_match (GDBusProxy *proxy);
|
||||
|
||||
void _nm_dbus_bind_properties (gpointer object,
|
||||
gpointer skeleton);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-object-private.h"
|
||||
|
||||
#include "nm-setting-adsl.h"
|
||||
|
|
@ -89,7 +88,6 @@ get_setting_type (NMDevice *device)
|
|||
static void
|
||||
nm_device_adsl_init (NMDeviceAdsl *device)
|
||||
{
|
||||
_nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_ADSL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -135,8 +133,6 @@ nm_device_adsl_class_init (NMDeviceAdslClass *adsl_class)
|
|||
|
||||
g_type_class_add_private (object_class, sizeof (NMDeviceAdslPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE_ADSL);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->get_property = get_property;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include "nm-utils.h"
|
||||
|
||||
#include "nm-device-bond.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-object-private.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
|
|
@ -137,8 +136,6 @@ nm_device_bond_init (NMDeviceBond *device)
|
|||
{
|
||||
NMDeviceBondPrivate *priv = NM_DEVICE_BOND_GET_PRIVATE (device);
|
||||
|
||||
_nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_BOND);
|
||||
|
||||
priv->slaves = g_ptr_array_new ();
|
||||
}
|
||||
|
||||
|
|
@ -213,8 +210,6 @@ nm_device_bond_class_init (NMDeviceBondClass *bond_class)
|
|||
|
||||
g_type_class_add_private (bond_class, sizeof (NMDeviceBondPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE_BOND);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include "nm-utils.h"
|
||||
|
||||
#include "nm-device-bridge.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-object-private.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
|
|
@ -137,8 +136,6 @@ nm_device_bridge_init (NMDeviceBridge *device)
|
|||
{
|
||||
NMDeviceBridgePrivate *priv = NM_DEVICE_BRIDGE_GET_PRIVATE (device);
|
||||
|
||||
_nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_BRIDGE);
|
||||
|
||||
priv->slaves = g_ptr_array_new ();
|
||||
}
|
||||
|
||||
|
|
@ -213,8 +210,6 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *bridge_class)
|
|||
|
||||
g_type_class_add_private (bridge_class, sizeof (NMDeviceBridgePrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE_BRIDGE);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
#include "nm-utils.h"
|
||||
|
||||
#include "nm-device-bt.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-object-private.h"
|
||||
#include "nm-enum-types.h"
|
||||
|
||||
|
|
@ -183,7 +182,6 @@ get_hw_address (NMDevice *device)
|
|||
static void
|
||||
nm_device_bt_init (NMDeviceBt *device)
|
||||
{
|
||||
_nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_BT);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -248,8 +246,6 @@ nm_device_bt_class_init (NMDeviceBtClass *bt_class)
|
|||
|
||||
g_type_class_add_private (bt_class, sizeof (NMDeviceBtPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE_BLUETOOTH);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
#include "nm-utils.h"
|
||||
|
||||
#include "nm-device-ethernet.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-object-private.h"
|
||||
|
||||
G_DEFINE_TYPE (NMDeviceEthernet, nm_device_ethernet, NM_TYPE_DEVICE)
|
||||
|
|
@ -282,7 +281,6 @@ get_hw_address (NMDevice *device)
|
|||
static void
|
||||
nm_device_ethernet_init (NMDeviceEthernet *device)
|
||||
{
|
||||
_nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_ETHERNET);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -357,8 +355,6 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *eth_class)
|
|||
|
||||
g_type_class_add_private (eth_class, sizeof (NMDeviceEthernetPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE_WIRED);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "nm-device-generic.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-object-private.h"
|
||||
#include "nm-setting-generic.h"
|
||||
#include "nm-setting-connection.h"
|
||||
|
|
@ -113,7 +112,6 @@ get_setting_type (NMDevice *device)
|
|||
static void
|
||||
nm_device_generic_init (NMDeviceGeneric *device)
|
||||
{
|
||||
_nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_GENERIC);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -175,8 +173,6 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass)
|
|||
|
||||
g_type_class_add_private (klass, sizeof (NMDeviceGenericPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE_GENERIC);
|
||||
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include "nm-utils.h"
|
||||
|
||||
#include "nm-device-infiniband.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-object-private.h"
|
||||
|
||||
G_DEFINE_TYPE (NMDeviceInfiniband, nm_device_infiniband, NM_TYPE_DEVICE)
|
||||
|
|
@ -132,7 +131,6 @@ get_hw_address (NMDevice *device)
|
|||
static void
|
||||
nm_device_infiniband_init (NMDeviceInfiniband *device)
|
||||
{
|
||||
_nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_INFINIBAND);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -192,8 +190,6 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *ib_class)
|
|||
|
||||
g_type_class_add_private (ib_class, sizeof (NMDeviceInfinibandPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE_INFINIBAND);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include "nm-utils.h"
|
||||
|
||||
#include "nm-device-ip-tunnel.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-object-private.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
|
|
@ -269,7 +268,6 @@ get_setting_type (NMDevice *device)
|
|||
static void
|
||||
nm_device_ip_tunnel_init (NMDeviceIPTunnel *device)
|
||||
{
|
||||
_nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_IP_TUNNEL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -369,8 +367,6 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *bond_class)
|
|||
|
||||
g_type_class_add_private (bond_class, sizeof (NMDeviceIPTunnelPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE_IP_TUNNEL);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
#include "nm-utils.h"
|
||||
|
||||
#include "nm-device-macvlan.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-object-private.h"
|
||||
|
||||
G_DEFINE_TYPE (NMDeviceMacvlan, nm_device_macvlan, NM_TYPE_DEVICE)
|
||||
|
|
@ -186,7 +185,6 @@ get_setting_type (NMDevice *device)
|
|||
static void
|
||||
nm_device_macvlan_init (NMDeviceMacvlan *device)
|
||||
{
|
||||
_nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_MACVLAN);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -260,8 +258,6 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *gre_class)
|
|||
|
||||
g_type_class_add_private (gre_class, sizeof (NMDeviceMacvlanPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE_MACVLAN);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
#include "nm-setting-cdma.h"
|
||||
|
||||
#include "nm-device-modem.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-object-private.h"
|
||||
#include "nm-enum-types.h"
|
||||
|
||||
|
|
@ -158,7 +157,6 @@ get_setting_type (NMDevice *device)
|
|||
static void
|
||||
nm_device_modem_init (NMDeviceModem *device)
|
||||
{
|
||||
_nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_MODEM);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -208,8 +206,6 @@ nm_device_modem_class_init (NMDeviceModemClass *modem_class)
|
|||
|
||||
g_type_class_add_private (modem_class, sizeof (NMDeviceModemPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE_MODEM);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->get_property = get_property;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#include "nm-setting-olpc-mesh.h"
|
||||
|
||||
#include "nm-device-olpc-mesh.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-object-private.h"
|
||||
#include "nm-device-wifi.h"
|
||||
|
||||
|
|
@ -130,7 +129,6 @@ get_setting_type (NMDevice *device)
|
|||
static void
|
||||
nm_device_olpc_mesh_init (NMDeviceOlpcMesh *device)
|
||||
{
|
||||
_nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_OLPC_MESH);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -204,8 +202,6 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *olpc_mesh_class)
|
|||
|
||||
g_type_class_add_private (olpc_mesh_class, sizeof (NMDeviceOlpcMeshPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE_OLPC_MESH);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2007 - 2012 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NM_DEVICE_PRIVATE_H__
|
||||
#define __NM_DEVICE_PRIVATE_H__
|
||||
|
||||
void _nm_device_set_device_type (NMDevice *device, NMDeviceType dtype);
|
||||
|
||||
#endif /* __NM_DEVICE_PRIVATE_H__ */
|
||||
|
|
@ -27,7 +27,6 @@
|
|||
#include "nm-utils.h"
|
||||
|
||||
#include "nm-device-team.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-object-private.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
|
|
@ -158,8 +157,6 @@ nm_device_team_init (NMDeviceTeam *device)
|
|||
{
|
||||
NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (device);
|
||||
|
||||
_nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_TEAM);
|
||||
|
||||
priv->slaves = g_ptr_array_new ();
|
||||
}
|
||||
|
||||
|
|
@ -239,8 +236,6 @@ nm_device_team_class_init (NMDeviceTeamClass *team_class)
|
|||
|
||||
g_type_class_add_private (team_class, sizeof (NMDeviceTeamPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE_TEAM);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
#include "nm-utils.h"
|
||||
|
||||
#include "nm-device-tun.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-object-private.h"
|
||||
|
||||
G_DEFINE_TYPE (NMDeviceTun, nm_device_tun, NM_TYPE_DEVICE)
|
||||
|
|
@ -239,7 +238,6 @@ get_hw_address (NMDevice *device)
|
|||
static void
|
||||
nm_device_tun_init (NMDeviceTun *device)
|
||||
{
|
||||
_nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_TUN);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -320,8 +318,6 @@ nm_device_tun_class_init (NMDeviceTunClass *gre_class)
|
|||
|
||||
g_type_class_add_private (gre_class, sizeof (NMDeviceTunPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE_TUN);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
#include "nm-utils.h"
|
||||
|
||||
#include "nm-device-vlan.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-object-private.h"
|
||||
|
||||
G_DEFINE_TYPE (NMDeviceVlan, nm_device_vlan, NM_TYPE_DEVICE)
|
||||
|
|
@ -172,7 +171,6 @@ get_hw_address (NMDevice *device)
|
|||
static void
|
||||
nm_device_vlan_init (NMDeviceVlan *device)
|
||||
{
|
||||
_nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_VLAN);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -241,8 +239,6 @@ nm_device_vlan_class_init (NMDeviceVlanClass *vlan_class)
|
|||
|
||||
g_type_class_add_private (vlan_class, sizeof (NMDeviceVlanPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE_VLAN);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include "nm-utils.h"
|
||||
|
||||
#include "nm-device-vxlan.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-object-private.h"
|
||||
|
||||
G_DEFINE_TYPE (NMDeviceVxlan, nm_device_vxlan, NM_TYPE_DEVICE)
|
||||
|
|
@ -415,7 +414,6 @@ get_hw_address (NMDevice *device)
|
|||
static void
|
||||
nm_device_vxlan_init (NMDeviceVxlan *device)
|
||||
{
|
||||
_nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_VXLAN);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -542,8 +540,6 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *vxlan_class)
|
|||
|
||||
g_type_class_add_private (vxlan_class, sizeof (NMDeviceVxlanPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE_VXLAN);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
|
|
|
|||
|
|
@ -31,9 +31,7 @@
|
|||
#include "nm-utils.h"
|
||||
|
||||
#include "nm-access-point.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-object-private.h"
|
||||
#include "nm-object-cache.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-dbus-helpers.h"
|
||||
|
||||
|
|
@ -660,8 +658,6 @@ nm_device_wifi_init (NMDeviceWifi *device)
|
|||
{
|
||||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device);
|
||||
|
||||
_nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_WIFI);
|
||||
|
||||
g_signal_connect (device,
|
||||
"notify::" NM_DEVICE_STATE,
|
||||
G_CALLBACK (state_changed_cb),
|
||||
|
|
@ -797,10 +793,6 @@ 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;
|
||||
object_class->dispose = dispose;
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@
|
|||
#include "nm-device-wimax.h"
|
||||
#include "nm-wimax-nsp.h"
|
||||
#include "nm-object-private.h"
|
||||
#include "nm-object-cache.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-device-private.h"
|
||||
|
||||
G_DEFINE_TYPE (NMDeviceWimax, nm_device_wimax, NM_TYPE_DEVICE)
|
||||
|
||||
|
|
@ -355,8 +353,6 @@ get_hw_address (NMDevice *device)
|
|||
static void
|
||||
nm_device_wimax_init (NMDeviceWimax *device)
|
||||
{
|
||||
_nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_WIMAX);
|
||||
|
||||
g_signal_connect (device,
|
||||
"notify::" NM_DEVICE_STATE,
|
||||
G_CALLBACK (state_changed_cb),
|
||||
|
|
@ -531,8 +527,6 @@ nm_device_wimax_class_init (NMDeviceWimaxClass *wimax_class)
|
|||
|
||||
g_type_class_add_private (wimax_class, sizeof (NMDeviceWimaxPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE_WIMAX);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->get_property = get_property;
|
||||
object_class->dispose = dispose;
|
||||
|
|
|
|||
|
|
@ -28,29 +28,12 @@
|
|||
|
||||
#include "nm-dbus-interface.h"
|
||||
#include "nm-active-connection.h"
|
||||
#include "nm-device-ethernet.h"
|
||||
#include "nm-device-adsl.h"
|
||||
#include "nm-device-wifi.h"
|
||||
#include "nm-device-modem.h"
|
||||
#include "nm-device-bt.h"
|
||||
#include "nm-device-olpc-mesh.h"
|
||||
#include "nm-device-wimax.h"
|
||||
#include "nm-device-infiniband.h"
|
||||
#include "nm-device-bond.h"
|
||||
#include "nm-device-team.h"
|
||||
#include "nm-device-bridge.h"
|
||||
#include "nm-device-vlan.h"
|
||||
#include "nm-device-vxlan.h"
|
||||
#include "nm-device-generic.h"
|
||||
#include "nm-device-ip-tunnel.h"
|
||||
#include "nm-device-macvlan.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-dhcp4-config.h"
|
||||
#include "nm-dhcp6-config.h"
|
||||
#include "nm-ip4-config.h"
|
||||
#include "nm-ip6-config.h"
|
||||
#include "nm-object-private.h"
|
||||
#include "nm-object-cache.h"
|
||||
#include "nm-remote-connection.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-utils.h"
|
||||
|
|
@ -60,16 +43,10 @@
|
|||
|
||||
#include "nmdbus-device.h"
|
||||
|
||||
static GType _nm_device_decide_type (GVariant *value);
|
||||
static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error);
|
||||
static NMLldpNeighbor *nm_lldp_neighbor_dup (NMLldpNeighbor *neighbor);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMDevice, nm_device, NM_TYPE_OBJECT,
|
||||
_nm_object_register_type_func (g_define_type_id,
|
||||
_nm_device_decide_type,
|
||||
NM_DBUS_INTERFACE_DEVICE,
|
||||
"DeviceType");
|
||||
)
|
||||
G_DEFINE_ABSTRACT_TYPE (NMDevice, nm_device, NM_TYPE_OBJECT);
|
||||
|
||||
#define NM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE, NMDevicePrivate))
|
||||
|
||||
|
|
@ -213,11 +190,7 @@ demarshal_lldp_neighbors (NMObject *object, GParamSpec *pspec, GVariant *value,
|
|||
}
|
||||
|
||||
static void
|
||||
device_state_changed (NMDBusDevice *proxy,
|
||||
guint new_state,
|
||||
guint old_state,
|
||||
guint reason,
|
||||
gpointer user_data);
|
||||
device_state_reason_changed (GObject *object, GParamSpec *pspec, gpointer user_data);
|
||||
|
||||
static void
|
||||
init_dbus (NMObject *object)
|
||||
|
|
@ -263,136 +236,19 @@ init_dbus (NMObject *object)
|
|||
NM_DBUS_INTERFACE_DEVICE,
|
||||
property_info);
|
||||
|
||||
g_signal_connect (priv->proxy, "state-changed",
|
||||
G_CALLBACK (device_state_changed), object);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
NMDeviceState old_state;
|
||||
NMDeviceState new_state;
|
||||
NMDeviceStateReason reason;
|
||||
} StateChangeData;
|
||||
|
||||
static void
|
||||
device_state_change_reloaded (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMDevice *self = NM_DEVICE (object);
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
StateChangeData *data = user_data;
|
||||
NMDeviceState old_state = data->old_state;
|
||||
NMDeviceState new_state = data->new_state;
|
||||
NMDeviceStateReason reason = data->reason;
|
||||
|
||||
g_slice_free (StateChangeData, data);
|
||||
|
||||
_nm_object_reload_properties_finish (NM_OBJECT (object), result, NULL);
|
||||
|
||||
/* If the device changes state several times in rapid succession, then we'll
|
||||
* queue several reload_properties() calls, and there's no guarantee that
|
||||
* they'll finish in the right order. In that case, only emit the signal
|
||||
* for the last one.
|
||||
*/
|
||||
if (priv->last_seen_state != new_state)
|
||||
return;
|
||||
|
||||
/* Ensure that nm_device_get_state() will return the right value even if
|
||||
* we haven't processed the corresponding PropertiesChanged yet.
|
||||
*/
|
||||
priv->state = new_state;
|
||||
|
||||
g_signal_emit (self, signals[STATE_CHANGED], 0,
|
||||
new_state, old_state, reason);
|
||||
g_signal_connect (priv->proxy, "notify::state-reason",
|
||||
G_CALLBACK (device_state_reason_changed), object);
|
||||
}
|
||||
|
||||
static void
|
||||
device_state_changed (NMDBusDevice *proxy,
|
||||
guint new_state,
|
||||
guint old_state,
|
||||
guint reason,
|
||||
gpointer user_data)
|
||||
device_state_reason_changed (GObject *object, GParamSpec *pspec, gpointer user_data)
|
||||
{
|
||||
NMDevice *self = NM_DEVICE (user_data);
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
StateChangeData *data;
|
||||
|
||||
if (old_state == new_state)
|
||||
return;
|
||||
|
||||
/* Our object-valued properties (eg, ip4_config) will still
|
||||
* have their old values at this point, because NMObject is
|
||||
* in the process of asynchronously reading the new values.
|
||||
* Wait for that to finish before emitting the signal.
|
||||
*/
|
||||
priv->last_seen_state = new_state;
|
||||
|
||||
data = g_slice_new (StateChangeData);
|
||||
data->old_state = old_state;
|
||||
data->new_state = new_state;
|
||||
data->reason = reason;
|
||||
_nm_object_reload_properties_async (NM_OBJECT (user_data),
|
||||
NULL,
|
||||
device_state_change_reloaded,
|
||||
data);
|
||||
}
|
||||
|
||||
static GType
|
||||
_nm_device_gtype_from_dtype (NMDeviceType dtype)
|
||||
{
|
||||
switch (dtype) {
|
||||
case NM_DEVICE_TYPE_VETH:
|
||||
case NM_DEVICE_TYPE_ETHERNET:
|
||||
return NM_TYPE_DEVICE_ETHERNET;
|
||||
case NM_DEVICE_TYPE_WIFI:
|
||||
return NM_TYPE_DEVICE_WIFI;
|
||||
case NM_DEVICE_TYPE_MODEM:
|
||||
return NM_TYPE_DEVICE_MODEM;
|
||||
case NM_DEVICE_TYPE_BT:
|
||||
return NM_TYPE_DEVICE_BT;
|
||||
case NM_DEVICE_TYPE_ADSL:
|
||||
return NM_TYPE_DEVICE_ADSL;
|
||||
case NM_DEVICE_TYPE_OLPC_MESH:
|
||||
return NM_TYPE_DEVICE_OLPC_MESH;
|
||||
case NM_DEVICE_TYPE_WIMAX:
|
||||
return NM_TYPE_DEVICE_WIMAX;
|
||||
case NM_DEVICE_TYPE_INFINIBAND:
|
||||
return NM_TYPE_DEVICE_INFINIBAND;
|
||||
case NM_DEVICE_TYPE_BOND:
|
||||
return NM_TYPE_DEVICE_BOND;
|
||||
case NM_DEVICE_TYPE_TEAM:
|
||||
return NM_TYPE_DEVICE_TEAM;
|
||||
case NM_DEVICE_TYPE_BRIDGE:
|
||||
return NM_TYPE_DEVICE_BRIDGE;
|
||||
case NM_DEVICE_TYPE_VLAN:
|
||||
return NM_TYPE_DEVICE_VLAN;
|
||||
case NM_DEVICE_TYPE_GENERIC:
|
||||
return NM_TYPE_DEVICE_GENERIC;
|
||||
case NM_DEVICE_TYPE_TUN:
|
||||
return NM_TYPE_DEVICE_TUN;
|
||||
case NM_DEVICE_TYPE_IP_TUNNEL:
|
||||
return NM_TYPE_DEVICE_IP_TUNNEL;
|
||||
case NM_DEVICE_TYPE_MACVLAN:
|
||||
return NM_TYPE_DEVICE_MACVLAN;
|
||||
case NM_DEVICE_TYPE_VXLAN:
|
||||
return NM_TYPE_DEVICE_VXLAN;
|
||||
default:
|
||||
g_warning ("Unknown device type %d", dtype);
|
||||
return G_TYPE_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
constructed (GObject *object)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
|
||||
|
||||
G_OBJECT_CLASS (nm_device_parent_class)->constructed (object);
|
||||
|
||||
/* Catch failure of subclasses to call _nm_device_set_device_type() */
|
||||
g_warn_if_fail (priv->device_type != NM_DEVICE_TYPE_UNKNOWN);
|
||||
/* Catch a subclass setting the wrong type */
|
||||
g_warn_if_fail (G_OBJECT_TYPE (object) == _nm_device_gtype_from_dtype (priv->device_type));
|
||||
g_signal_emit (self, signals[STATE_CHANGED], 0,
|
||||
priv->state, priv->last_seen_state, priv->reason);
|
||||
priv->last_seen_state = priv->state;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -571,11 +427,7 @@ nm_device_class_init (NMDeviceClass *device_class)
|
|||
|
||||
g_type_class_add_private (device_class, sizeof (NMDevicePrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE);
|
||||
_nm_dbus_register_proxy_type (NM_DBUS_INTERFACE_DEVICE, NMDBUS_TYPE_DEVICE_PROXY);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->constructed = constructed;
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->dispose = dispose;
|
||||
|
|
@ -953,35 +805,6 @@ nm_device_class_init (NMDeviceClass *device_class)
|
|||
G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
|
||||
}
|
||||
|
||||
/**
|
||||
* _nm_device_set_device_type:
|
||||
* @device: the device
|
||||
* @dtype: the NM device type
|
||||
*
|
||||
* Sets the NM device type if it wasn't set during construction. INTERNAL
|
||||
* ONLY METHOD.
|
||||
**/
|
||||
void
|
||||
_nm_device_set_device_type (NMDevice *device, NMDeviceType dtype)
|
||||
{
|
||||
NMDevicePrivate *priv;
|
||||
|
||||
g_return_if_fail (device != NULL);
|
||||
g_return_if_fail (dtype != NM_DEVICE_TYPE_UNKNOWN);
|
||||
|
||||
priv = NM_DEVICE_GET_PRIVATE (device);
|
||||
if (priv->device_type == NM_DEVICE_TYPE_UNKNOWN)
|
||||
priv->device_type = dtype;
|
||||
else
|
||||
g_warn_if_fail (dtype == priv->device_type);
|
||||
}
|
||||
|
||||
static GType
|
||||
_nm_device_decide_type (GVariant *value)
|
||||
{
|
||||
return _nm_device_gtype_from_dtype (g_variant_get_uint32 (value));
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_get_iface:
|
||||
* @device: a #NMDevice
|
||||
|
|
|
|||
|
|
@ -33,7 +33,4 @@ nm_dhcp4_config_init (NMDhcp4Config *config)
|
|||
static void
|
||||
nm_dhcp4_config_class_init (NMDhcp4ConfigClass *config_class)
|
||||
{
|
||||
NMObjectClass *nm_object_class = NM_OBJECT_CLASS (config_class);
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DHCP4_CONFIG);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,4 @@ nm_dhcp6_config_init (NMDhcp6Config *config)
|
|||
static void
|
||||
nm_dhcp6_config_class_init (NMDhcp6ConfigClass *config_class)
|
||||
{
|
||||
NMObjectClass *nm_object_class = NM_OBJECT_CLASS (config_class);
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DHCP6_CONFIG);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,4 @@ nm_ip4_config_init (NMIP4Config *config)
|
|||
static void
|
||||
nm_ip4_config_class_init (NMIP4ConfigClass *config_class)
|
||||
{
|
||||
NMObjectClass *nm_object_class = NM_OBJECT_CLASS (config_class);
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_IP4_CONFIG);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,4 @@ nm_ip6_config_init (NMIP6Config *config)
|
|||
static void
|
||||
nm_ip6_config_class_init (NMIP6ConfigClass *config_class)
|
||||
{
|
||||
NMObjectClass *nm_object_class = NM_OBJECT_CLASS (config_class);
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_IP6_CONFIG);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,12 +29,10 @@
|
|||
#include "nm-common-macros.h"
|
||||
#include "nm-device-ethernet.h"
|
||||
#include "nm-device-wifi.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-object-private.h"
|
||||
#include "nm-active-connection.h"
|
||||
#include "nm-vpn-connection.h"
|
||||
#include "nm-object-cache.h"
|
||||
#include "nm-dbus-helpers.h"
|
||||
|
||||
#include "nmdbus-manager.h"
|
||||
|
|
@ -91,7 +89,6 @@ enum {
|
|||
PROP_VERSION,
|
||||
PROP_STATE,
|
||||
PROP_STARTUP,
|
||||
PROP_NM_RUNNING,
|
||||
PROP_NETWORKING_ENABLED,
|
||||
PROP_WIRELESS_ENABLED,
|
||||
PROP_WIRELESS_HARDWARE_ENABLED,
|
||||
|
|
@ -124,10 +121,6 @@ enum {
|
|||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static void nm_running_changed_cb (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -401,14 +394,6 @@ nm_manager_get_startup (NMManager *manager)
|
|||
return NM_MANAGER_GET_PRIVATE (manager)->startup;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_manager_get_nm_running (NMManager *manager)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_MANAGER (manager), FALSE);
|
||||
|
||||
return _nm_object_get_nm_running (NM_OBJECT (manager));
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_manager_networking_get_enabled (NMManager *manager)
|
||||
{
|
||||
|
|
@ -758,8 +743,6 @@ typedef struct {
|
|||
char *new_connection_path;
|
||||
} ActivateInfo;
|
||||
|
||||
static void active_removed (NMObject *object, NMActiveConnection *active, gpointer user_data);
|
||||
|
||||
static void
|
||||
activate_info_complete (ActivateInfo *info,
|
||||
NMActiveConnection *active,
|
||||
|
|
@ -767,7 +750,6 @@ activate_info_complete (ActivateInfo *info,
|
|||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (info->manager);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (info->manager, G_CALLBACK (active_removed), info);
|
||||
if (active)
|
||||
g_simple_async_result_set_op_res_gpointer (info->simple, g_object_ref (active), g_object_unref);
|
||||
else
|
||||
|
|
@ -812,6 +794,10 @@ recheck_pending_activations (NMManager *self)
|
|||
NMActiveConnection *candidate;
|
||||
const GPtrArray *devices;
|
||||
NMDevice *device;
|
||||
GDBusObjectManager *object_manager = NULL;
|
||||
GError *error;
|
||||
|
||||
object_manager = _nm_object_get_dbus_object_manager (NM_OBJECT (self));
|
||||
|
||||
/* For each pending activation, look for an active connection that has the
|
||||
* pending activation's object path, where the active connection and its
|
||||
|
|
@ -820,9 +806,25 @@ recheck_pending_activations (NMManager *self)
|
|||
*/
|
||||
for (iter = priv->pending_activations; iter; iter = next) {
|
||||
ActivateInfo *info = iter->data;
|
||||
gs_unref_object GDBusObject *dbus_obj = NULL;
|
||||
|
||||
next = g_slist_next (iter);
|
||||
|
||||
if (!info->active_path)
|
||||
continue;
|
||||
|
||||
/* Check that the object manager still knows about the object.
|
||||
* It could be that it vanished before we even learned its name. */
|
||||
dbus_obj = g_dbus_object_manager_get_object (object_manager, info->active_path);
|
||||
if (!dbus_obj) {
|
||||
error = g_error_new_literal (NM_CLIENT_ERROR,
|
||||
NM_CLIENT_ERROR_OBJECT_CREATION_FAILED,
|
||||
_("Active connection removed before it was initialized"));
|
||||
activate_info_complete (info, NULL, error);
|
||||
g_clear_error (&error);
|
||||
break;
|
||||
}
|
||||
|
||||
candidate = find_active_connection_by_path (self, info->active_path);
|
||||
if (!candidate)
|
||||
continue;
|
||||
|
|
@ -857,22 +859,6 @@ activation_cancelled (GCancellable *cancellable,
|
|||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
static void
|
||||
active_removed (NMObject *object, NMActiveConnection *active, gpointer user_data)
|
||||
{
|
||||
ActivateInfo *info = user_data;
|
||||
GError *error = NULL;
|
||||
|
||||
if (strcmp (info->active_path, nm_object_get_path (NM_OBJECT (active))))
|
||||
return;
|
||||
|
||||
error = g_error_new_literal (NM_CLIENT_ERROR,
|
||||
NM_CLIENT_ERROR_FAILED,
|
||||
_("Active connection could not be attached to the device"));
|
||||
activate_info_complete (info, NULL, error);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
static void
|
||||
activate_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
|
|
@ -889,9 +875,6 @@ activate_cb (GObject *object,
|
|||
G_CALLBACK (activation_cancelled), info);
|
||||
}
|
||||
|
||||
g_signal_connect (info->manager, "active-connection-removed",
|
||||
G_CALLBACK (active_removed), info);
|
||||
|
||||
recheck_pending_activations (info->manager);
|
||||
} else {
|
||||
g_dbus_error_strip_remote_error (error);
|
||||
|
|
@ -968,9 +951,6 @@ add_activate_cb (GObject *object,
|
|||
G_CALLBACK (activation_cancelled), info);
|
||||
}
|
||||
|
||||
g_signal_connect (info->manager, "active-connection-removed",
|
||||
G_CALLBACK (active_removed), info);
|
||||
|
||||
recheck_pending_activations (info->manager);
|
||||
} else {
|
||||
g_dbus_error_strip_remote_error (error);
|
||||
|
|
@ -1076,33 +1056,7 @@ static void
|
|||
active_connection_removed (NMManager *self, NMActiveConnection *ac)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (ac, G_CALLBACK (ac_devices_changed), self);
|
||||
}
|
||||
|
||||
static void
|
||||
object_creation_failed (NMObject *object, const char *failed_path)
|
||||
{
|
||||
NMManager *self = NM_MANAGER (object);
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
||||
GError *error;
|
||||
GSList *iter;
|
||||
|
||||
/* A newly activated connection failed due to some immediate error
|
||||
* and disappeared from active connection list. Make sure the
|
||||
* callback gets called.
|
||||
*/
|
||||
error = g_error_new_literal (NM_CLIENT_ERROR,
|
||||
NM_CLIENT_ERROR_OBJECT_CREATION_FAILED,
|
||||
_("Active connection removed before it was initialized"));
|
||||
|
||||
for (iter = priv->pending_activations; iter; iter = iter->next) {
|
||||
ActivateInfo *info = iter->data;
|
||||
|
||||
if (g_strcmp0 (failed_path, info->active_path) == 0) {
|
||||
activate_info_complete (info, NULL, error);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
recheck_pending_activations (self);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
@ -1187,145 +1141,19 @@ nm_manager_deactivate_connection_finish (NMManager *manager,
|
|||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
free_devices (NMManager *manager, gboolean in_dispose)
|
||||
free_active_connections (NMManager *manager)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||
gs_unref_ptrarray GPtrArray *real_devices = NULL;
|
||||
gs_unref_ptrarray GPtrArray *all_devices = NULL;
|
||||
GPtrArray *devices = NULL;
|
||||
guint i, j;
|
||||
|
||||
real_devices = priv->devices;
|
||||
all_devices = priv->all_devices;
|
||||
|
||||
if (in_dispose) {
|
||||
priv->devices = NULL;
|
||||
priv->all_devices = NULL;
|
||||
} else {
|
||||
priv->devices = g_ptr_array_new_with_free_func (g_object_unref);
|
||||
priv->all_devices = g_ptr_array_new_with_free_func (g_object_unref);
|
||||
}
|
||||
|
||||
if (all_devices && all_devices->len > 0)
|
||||
devices = all_devices;
|
||||
else if (real_devices && real_devices->len > 0)
|
||||
devices = real_devices;
|
||||
|
||||
if (real_devices && devices != real_devices) {
|
||||
for (i = 0; i < real_devices->len; i++) {
|
||||
NMDevice *d = real_devices->pdata[i];
|
||||
|
||||
if (all_devices) {
|
||||
for (j = 0; j < all_devices->len; j++) {
|
||||
if (d == all_devices->pdata[j])
|
||||
goto next;
|
||||
}
|
||||
}
|
||||
if (in_dispose)
|
||||
device_removed (manager, d);
|
||||
else
|
||||
g_signal_emit (manager, signals[DEVICE_REMOVED], 0, d);
|
||||
next:
|
||||
;
|
||||
}
|
||||
}
|
||||
if (devices) {
|
||||
for (i = 0; i < devices->len; i++) {
|
||||
NMDevice *d = devices->pdata[i];
|
||||
|
||||
if (in_dispose)
|
||||
device_removed (manager, d);
|
||||
else
|
||||
g_signal_emit (manager, signals[DEVICE_REMOVED], 0, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
free_active_connections (NMManager *manager, gboolean in_dispose)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||
GPtrArray *active_connections;
|
||||
NMActiveConnection *active_connection;
|
||||
int i;
|
||||
|
||||
if (!priv->active_connections)
|
||||
return;
|
||||
|
||||
active_connections = priv->active_connections;
|
||||
if (in_dispose)
|
||||
priv->active_connections = NULL;
|
||||
else
|
||||
priv->active_connections = g_ptr_array_new ();
|
||||
|
||||
for (i = 0; i < active_connections->len; i++) {
|
||||
active_connection = active_connections->pdata[i];
|
||||
g_signal_emit (manager, signals[ACTIVE_CONNECTION_REMOVED], 0, active_connection);
|
||||
/* Break circular refs */
|
||||
g_object_run_dispose (G_OBJECT (active_connection));
|
||||
}
|
||||
g_ptr_array_unref (active_connections);
|
||||
|
||||
if (!in_dispose)
|
||||
g_object_notify (G_OBJECT (manager), NM_MANAGER_ACTIVE_CONNECTIONS);
|
||||
}
|
||||
|
||||
static void
|
||||
updated_properties (GObject *object, GAsyncResult *result, gpointer user_data)
|
||||
{
|
||||
NMManager *manager = NM_MANAGER (user_data);
|
||||
GError *error = NULL;
|
||||
|
||||
if (!_nm_object_reload_properties_finish (NM_OBJECT (object), result, &error)) {
|
||||
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
g_warning ("%s: error reading NMManager properties: %s", __func__, error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
_nm_object_queue_notify (NM_OBJECT (manager), NM_MANAGER_NM_RUNNING);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_running_changed_cb (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMManager *manager = NM_MANAGER (object);
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||
|
||||
if (!nm_manager_get_nm_running (manager)) {
|
||||
nm_clear_g_cancellable (&priv->props_cancellable);
|
||||
|
||||
priv->state = NM_STATE_UNKNOWN;
|
||||
priv->startup = FALSE;
|
||||
_nm_object_queue_notify (NM_OBJECT (manager), NM_MANAGER_NM_RUNNING);
|
||||
_nm_object_suppress_property_updates (NM_OBJECT (manager), TRUE);
|
||||
poke_wireless_devices_with_rf_status (manager);
|
||||
free_devices (manager, FALSE);
|
||||
free_active_connections (manager, FALSE);
|
||||
update_permissions (manager, NULL);
|
||||
priv->wireless_enabled = FALSE;
|
||||
priv->wireless_hw_enabled = FALSE;
|
||||
priv->wwan_enabled = FALSE;
|
||||
priv->wwan_hw_enabled = FALSE;
|
||||
priv->wimax_enabled = FALSE;
|
||||
priv->wimax_hw_enabled = FALSE;
|
||||
g_free (priv->version);
|
||||
priv->version = NULL;
|
||||
|
||||
/* Clear object cache to ensure bad refcounting by managers doesn't
|
||||
* keep objects in the cache.
|
||||
*/
|
||||
_nm_object_cache_clear ();
|
||||
} else {
|
||||
_nm_object_suppress_property_updates (NM_OBJECT (manager), FALSE);
|
||||
|
||||
nm_clear_g_cancellable (&priv->props_cancellable);
|
||||
priv->props_cancellable = g_cancellable_new ();
|
||||
_nm_object_reload_properties_async (NM_OBJECT (manager), priv->props_cancellable, updated_properties, manager);
|
||||
|
||||
manager_recheck_permissions (priv->manager_proxy, manager);
|
||||
}
|
||||
/* Break circular refs */
|
||||
for (i = 0; i < priv->active_connections->len; i++)
|
||||
g_object_run_dispose (G_OBJECT (priv->active_connections->pdata[i]));
|
||||
g_ptr_array_unref (priv->active_connections);
|
||||
priv->active_connections = NULL;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -1335,9 +1163,6 @@ constructed (GObject *object)
|
|||
{
|
||||
G_OBJECT_CLASS (nm_manager_parent_class)->constructed (object);
|
||||
|
||||
g_signal_connect (object, "notify::" NM_OBJECT_NM_RUNNING,
|
||||
G_CALLBACK (nm_running_changed_cb), NULL);
|
||||
|
||||
g_signal_connect (object, "notify::" NM_MANAGER_WIRELESS_ENABLED,
|
||||
G_CALLBACK (wireless_enabled_cb), NULL);
|
||||
}
|
||||
|
|
@ -1350,8 +1175,7 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
|
|||
if (!nm_manager_parent_initable_iface->init (initable, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if ( nm_manager_get_nm_running (manager)
|
||||
&& !get_permissions_sync (manager, error))
|
||||
if (!get_permissions_sync (manager, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
|
|
@ -1402,11 +1226,6 @@ init_async_parent_inited (GObject *source, GAsyncResult *result, gpointer user_d
|
|||
return;
|
||||
}
|
||||
|
||||
if (!nm_manager_get_nm_running (init_data->manager)) {
|
||||
init_async_complete (init_data);
|
||||
return;
|
||||
}
|
||||
|
||||
nmdbus_manager_call_get_permissions (priv->manager_proxy,
|
||||
init_data->cancellable,
|
||||
init_async_got_permissions, init_data);
|
||||
|
|
@ -1452,8 +1271,17 @@ dispose (GObject *object)
|
|||
g_clear_object (&priv->perm_call_cancellable);
|
||||
}
|
||||
|
||||
free_devices (manager, TRUE);
|
||||
free_active_connections (manager, TRUE);
|
||||
|
||||
if (priv->devices) {
|
||||
g_ptr_array_unref (priv->devices);
|
||||
priv->devices = NULL;
|
||||
}
|
||||
if (priv->all_devices) {
|
||||
g_ptr_array_unref (priv->all_devices);
|
||||
priv->all_devices = NULL;
|
||||
}
|
||||
|
||||
free_active_connections (manager);
|
||||
g_clear_object (&priv->primary_connection);
|
||||
g_clear_object (&priv->activating_connection);
|
||||
|
||||
|
|
@ -1539,9 +1367,6 @@ get_property (GObject *object,
|
|||
case PROP_STARTUP:
|
||||
g_value_set_boolean (value, nm_manager_get_startup (self));
|
||||
break;
|
||||
case PROP_NM_RUNNING:
|
||||
g_value_set_boolean (value, nm_manager_get_nm_running (self));
|
||||
break;
|
||||
case PROP_NETWORKING_ENABLED:
|
||||
g_value_set_boolean (value, nm_manager_networking_get_enabled (self));
|
||||
break;
|
||||
|
|
@ -1598,9 +1423,6 @@ nm_manager_class_init (NMManagerClass *manager_class)
|
|||
|
||||
g_type_class_add_private (manager_class, sizeof (NMManagerPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE);
|
||||
_nm_dbus_register_proxy_type (NM_DBUS_INTERFACE, NMDBUS_TYPE_MANAGER_PROXY);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->constructed = constructed;
|
||||
object_class->set_property = set_property;
|
||||
|
|
@ -1609,7 +1431,6 @@ nm_manager_class_init (NMManagerClass *manager_class)
|
|||
object_class->finalize = finalize;
|
||||
|
||||
nm_object_class->init_dbus = init_dbus;
|
||||
nm_object_class->object_creation_failed = object_creation_failed;
|
||||
|
||||
manager_class->device_added = device_added;
|
||||
manager_class->device_removed = device_removed;
|
||||
|
|
@ -1637,12 +1458,6 @@ nm_manager_class_init (NMManagerClass *manager_class)
|
|||
FALSE,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_NM_RUNNING,
|
||||
g_param_spec_boolean (NM_MANAGER_NM_RUNNING, "", "",
|
||||
FALSE,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_NETWORKING_ENABLED,
|
||||
g_param_spec_boolean (NM_MANAGER_NETWORKING_ENABLED, "", "",
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ G_BEGIN_DECLS
|
|||
#define NM_MANAGER_VERSION "version"
|
||||
#define NM_MANAGER_STATE "state"
|
||||
#define NM_MANAGER_STARTUP "startup"
|
||||
#define NM_MANAGER_NM_RUNNING "nm-running"
|
||||
#define NM_MANAGER_NETWORKING_ENABLED "networking-enabled"
|
||||
#define NM_MANAGER_WIRELESS_ENABLED "wireless-enabled"
|
||||
#define NM_MANAGER_WIRELESS_HARDWARE_ENABLED "wireless-hardware-enabled"
|
||||
|
|
@ -80,7 +79,6 @@ GType nm_manager_get_type (void);
|
|||
const char *nm_manager_get_version (NMManager *manager);
|
||||
NMState nm_manager_get_state (NMManager *manager);
|
||||
gboolean nm_manager_get_startup (NMManager *manager);
|
||||
gboolean nm_manager_get_nm_running (NMManager *manager);
|
||||
|
||||
gboolean nm_manager_networking_get_enabled (NMManager *manager);
|
||||
gboolean nm_manager_networking_set_enabled (NMManager *manager,
|
||||
|
|
|
|||
|
|
@ -1,90 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2008 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "nm-object-cache.h"
|
||||
#include "nm-object.h"
|
||||
|
||||
static GHashTable *cache = NULL;
|
||||
|
||||
static void
|
||||
_init_cache (void)
|
||||
{
|
||||
if (G_UNLIKELY (cache == NULL))
|
||||
cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_nm_object_cache_remove_by_path (char *path)
|
||||
{
|
||||
_init_cache ();
|
||||
g_hash_table_remove (cache, path);
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
void
|
||||
_nm_object_cache_add (NMObject *object)
|
||||
{
|
||||
char *path;
|
||||
|
||||
_init_cache ();
|
||||
path = g_strdup (nm_object_get_path (object));
|
||||
g_hash_table_insert (cache, path, object);
|
||||
g_object_set_data_full (G_OBJECT (object), "nm-object-cache-tag",
|
||||
g_strdup (path), (GDestroyNotify) _nm_object_cache_remove_by_path);
|
||||
}
|
||||
|
||||
NMObject *
|
||||
_nm_object_cache_get (const char *path)
|
||||
{
|
||||
NMObject *object;
|
||||
|
||||
_init_cache ();
|
||||
object = g_hash_table_lookup (cache, path);
|
||||
return object ? g_object_ref (object) : NULL;
|
||||
}
|
||||
|
||||
void
|
||||
_nm_object_cache_clear (void)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
GObject *obj;
|
||||
const char *path;
|
||||
char *foo;
|
||||
|
||||
if (!cache)
|
||||
return;
|
||||
|
||||
g_hash_table_iter_init (&iter, cache);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer) &path, (gpointer) &obj)) {
|
||||
/* Remove the callback so that if the object isn't yet released
|
||||
* by a client, when it does finally get unrefed, it won't trigger
|
||||
* the cache removal for a new object with the same path as the
|
||||
* one being released.
|
||||
*/
|
||||
foo = g_object_steal_data (obj, "nm-object-cache-tag");
|
||||
g_free (foo);
|
||||
|
||||
g_hash_table_iter_remove (&iter);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2008 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NM_OBJECT_CACHE_H__
|
||||
#define __NM_OBJECT_CACHE_H__
|
||||
|
||||
#include "nm-object.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* Returns referenced object from the cache */
|
||||
NMObject *_nm_object_cache_get (const char *path);
|
||||
void _nm_object_cache_add (NMObject *object);
|
||||
void _nm_object_cache_clear (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NM_OBJECT_CACHE_H__ */
|
||||
|
|
@ -39,43 +39,20 @@ void _nm_object_register_properties (NMObject *object,
|
|||
const char *interface,
|
||||
const NMPropertiesInfo *info);
|
||||
|
||||
void _nm_object_reload_properties_async (NMObject *object,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean _nm_object_reload_properties_finish (NMObject *object,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
void _nm_object_queue_notify (NMObject *object, const char *property);
|
||||
|
||||
void _nm_object_suppress_property_updates (NMObject *object, gboolean suppress);
|
||||
GDBusObjectManager *_nm_object_get_dbus_object_manager (NMObject *object);
|
||||
|
||||
GQuark _nm_object_obj_nm_quark (void);
|
||||
|
||||
/* DBus property accessors */
|
||||
|
||||
void _nm_object_reload_property (NMObject *object,
|
||||
const char *interface,
|
||||
const char *prop_name);
|
||||
|
||||
void _nm_object_set_property (NMObject *object,
|
||||
const char *interface,
|
||||
const char *prop_name,
|
||||
const char *format_string,
|
||||
...);
|
||||
|
||||
/* object demarshalling support */
|
||||
typedef GType (*NMObjectDecideTypeFunc) (GVariant *);
|
||||
|
||||
void _nm_object_register_type_func (GType base_type,
|
||||
NMObjectDecideTypeFunc type_func,
|
||||
const char *interface,
|
||||
const char *property);
|
||||
|
||||
#define NM_OBJECT_NM_RUNNING "nm-running-internal"
|
||||
gboolean _nm_object_get_nm_running (NMObject *self);
|
||||
|
||||
void _nm_object_class_add_interface (NMObjectClass *object_class,
|
||||
const char *interface);
|
||||
GDBusProxy *_nm_object_get_proxy (NMObject *object,
|
||||
const char *interface);
|
||||
|
||||
|
|
|
|||
1059
libnm/nm-object.c
1059
libnm/nm-object.c
File diff suppressed because it is too large
Load diff
|
|
@ -39,6 +39,8 @@ G_BEGIN_DECLS
|
|||
|
||||
#define NM_OBJECT_PATH "path"
|
||||
#define NM_OBJECT_DBUS_CONNECTION "dbus-connection"
|
||||
#define NM_OBJECT_DBUS_OBJECT "dbus-object"
|
||||
#define NM_OBJECT_DBUS_OBJECT_MANAGER "dbus-object-manager"
|
||||
|
||||
/**
|
||||
* NMObject:
|
||||
|
|
|
|||
|
|
@ -628,15 +628,9 @@ init_dbus (NMObject *object)
|
|||
|
||||
NM_OBJECT_CLASS (nm_remote_connection_parent_class)->init_dbus (object);
|
||||
|
||||
priv->proxy = NMDBUS_SETTINGS_CONNECTION (_nm_object_get_proxy (object, NM_DBUS_INTERFACE_SETTINGS_CONNECTION));
|
||||
g_assert (priv->proxy);
|
||||
|
||||
_nm_object_register_properties (object,
|
||||
NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
|
||||
property_info);
|
||||
|
||||
g_signal_connect (priv->proxy, "updated",
|
||||
G_CALLBACK (updated_cb), object);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -646,20 +640,20 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
|
|||
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (initable);
|
||||
GVariant *settings;
|
||||
|
||||
if (!nm_remote_connection_parent_initable_iface->init (initable, cancellable, error))
|
||||
return FALSE;
|
||||
priv->proxy = NMDBUS_SETTINGS_CONNECTION (_nm_object_get_proxy (NM_OBJECT (initable), NM_DBUS_INTERFACE_SETTINGS_CONNECTION));
|
||||
g_signal_connect (priv->proxy, "updated", G_CALLBACK (updated_cb), initable);
|
||||
|
||||
if (!nmdbus_settings_connection_call_get_settings_sync (priv->proxy,
|
||||
&settings,
|
||||
cancellable, error)) {
|
||||
if (error && *error)
|
||||
g_dbus_error_strip_remote_error (*error);
|
||||
return FALSE;
|
||||
if (nmdbus_settings_connection_call_get_settings_sync (priv->proxy,
|
||||
&settings,
|
||||
cancellable,
|
||||
NULL)) {
|
||||
priv->visible = TRUE;
|
||||
replace_settings (self, settings);
|
||||
g_variant_unref (settings);
|
||||
}
|
||||
|
||||
priv->visible = TRUE;
|
||||
replace_settings (self, settings);
|
||||
g_variant_unref (settings);
|
||||
if (!nm_remote_connection_parent_initable_iface->init (initable, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -668,6 +662,8 @@ typedef struct {
|
|||
NMRemoteConnection *connection;
|
||||
GCancellable *cancellable;
|
||||
GSimpleAsyncResult *result;
|
||||
GAsyncInitable *initable;
|
||||
int io_priority;
|
||||
} NMRemoteConnectionInitData;
|
||||
|
||||
static void
|
||||
|
|
@ -684,45 +680,36 @@ init_async_complete (NMRemoteConnectionInitData *init_data, GError *error)
|
|||
g_slice_free (NMRemoteConnectionInitData, init_data);
|
||||
}
|
||||
|
||||
static void
|
||||
init_async_parent_inited (GObject *source, GAsyncResult *result, gpointer user_data)
|
||||
{
|
||||
NMRemoteConnectionInitData *init_data = user_data;
|
||||
GError *error = NULL;
|
||||
|
||||
init_async_complete (init_data, error);
|
||||
}
|
||||
|
||||
static void
|
||||
init_get_settings_cb (GObject *proxy,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMRemoteConnectionInitData *init_data = user_data;
|
||||
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (init_data->connection);
|
||||
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (init_data->initable);
|
||||
GVariant *settings;
|
||||
GError *error = NULL;
|
||||
|
||||
if (!nmdbus_settings_connection_call_get_settings_finish (priv->proxy, &settings,
|
||||
result, &error)) {
|
||||
g_dbus_error_strip_remote_error (error);
|
||||
init_async_complete (init_data, error);
|
||||
return;
|
||||
g_error_free (error);
|
||||
} else {
|
||||
priv->visible = TRUE;
|
||||
replace_settings (NM_REMOTE_CONNECTION (init_data->initable), settings);
|
||||
g_variant_unref (settings);
|
||||
}
|
||||
|
||||
priv->visible = TRUE;
|
||||
replace_settings (init_data->connection, settings);
|
||||
g_variant_unref (settings);
|
||||
|
||||
init_async_complete (init_data, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
init_async_parent_inited (GObject *source, GAsyncResult *result, gpointer user_data)
|
||||
{
|
||||
NMRemoteConnectionInitData *init_data = user_data;
|
||||
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (init_data->connection);
|
||||
GError *error = NULL;
|
||||
|
||||
if (!nm_remote_connection_parent_async_initable_iface->init_finish (G_ASYNC_INITABLE (source), result, &error)) {
|
||||
init_async_complete (init_data, error);
|
||||
return;
|
||||
}
|
||||
|
||||
nmdbus_settings_connection_call_get_settings (priv->proxy,
|
||||
init_data->cancellable,
|
||||
init_get_settings_cb, init_data);
|
||||
nm_remote_connection_parent_async_initable_iface->
|
||||
init_async (init_data->initable, init_data->io_priority, init_data->cancellable, init_async_parent_inited, init_data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -731,26 +718,24 @@ init_async (GAsyncInitable *initable, int io_priority,
|
|||
gpointer user_data)
|
||||
{
|
||||
NMRemoteConnectionInitData *init_data;
|
||||
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (initable);
|
||||
|
||||
init_data = g_slice_new0 (NMRemoteConnectionInitData);
|
||||
init_data->connection = NM_REMOTE_CONNECTION (initable);
|
||||
init_data->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
|
||||
init_data->result = g_simple_async_result_new (G_OBJECT (initable), callback,
|
||||
user_data, init_async);
|
||||
init_data->initable = initable;
|
||||
init_data->io_priority = io_priority;
|
||||
|
||||
nm_remote_connection_parent_async_initable_iface->
|
||||
init_async (initable, io_priority, cancellable, init_async_parent_inited, init_data);
|
||||
}
|
||||
priv->proxy = NMDBUS_SETTINGS_CONNECTION (_nm_object_get_proxy (NM_OBJECT (initable),
|
||||
NM_DBUS_INTERFACE_SETTINGS_CONNECTION));
|
||||
|
||||
static gboolean
|
||||
init_finish (GAsyncInitable *initable, GAsyncResult *result, GError **error)
|
||||
{
|
||||
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
|
||||
g_signal_connect (priv->proxy, "updated",
|
||||
G_CALLBACK (updated_cb), initable);
|
||||
|
||||
if (g_simple_async_result_propagate_error (simple, error))
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
nmdbus_settings_connection_call_get_settings (NM_REMOTE_CONNECTION_GET_PRIVATE (init_data->initable)->proxy,
|
||||
init_data->cancellable,
|
||||
init_get_settings_cb, init_data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -790,10 +775,6 @@ nm_remote_connection_class_init (NMRemoteConnectionClass *remote_class)
|
|||
|
||||
g_type_class_add_private (object_class, sizeof (NMRemoteConnectionPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_SETTINGS_CONNECTION);
|
||||
_nm_dbus_register_proxy_type (NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
|
||||
NMDBUS_TYPE_SETTINGS_CONNECTION_PROXY);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->constructed = constructed;
|
||||
object_class->get_property = get_property;
|
||||
|
|
@ -852,5 +833,4 @@ nm_remote_connection_async_initable_iface_init (GAsyncInitableIface *iface)
|
|||
nm_remote_connection_parent_async_initable_iface = g_type_interface_peek_parent (iface);
|
||||
|
||||
iface->init_async = init_async;
|
||||
iface->init_finish = init_finish;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
#include "nm-remote-connection-private.h"
|
||||
#include "nm-object-private.h"
|
||||
#include "nm-dbus-helpers.h"
|
||||
#include "nm-object-private.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
#include "nmdbus-settings.h"
|
||||
|
|
@ -46,7 +45,6 @@ typedef struct {
|
|||
NMDBusSettings *proxy;
|
||||
GPtrArray *all_connections;
|
||||
GPtrArray *visible_connections;
|
||||
GCancellable *props_cancellable;
|
||||
|
||||
/* AddConnectionInfo objects that are waiting for the connection to become initialized */
|
||||
GSList *add_list;
|
||||
|
|
@ -134,9 +132,6 @@ get_connection_by_string (NMRemoteSettings *settings,
|
|||
NMConnection *candidate;
|
||||
int i;
|
||||
|
||||
if (!_nm_object_get_nm_running (NM_OBJECT (settings)))
|
||||
return NULL;
|
||||
|
||||
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
||||
|
||||
for (i = 0; i < priv->visible_connections->len; i++) {
|
||||
|
|
@ -601,65 +596,6 @@ nm_remote_settings_save_hostname_finish (NMRemoteSettings *settings,
|
|||
return g_simple_async_result_get_op_res_gboolean (simple);
|
||||
}
|
||||
|
||||
static void
|
||||
updated_properties (GObject *object, GAsyncResult *result, gpointer user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!_nm_object_reload_properties_finish (NM_OBJECT (object), result, &error)) {
|
||||
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
g_warning ("%s: error reading NMRemoteSettings properties: %s", __func__, error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nm_running_changed (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMRemoteSettings *self = NM_REMOTE_SETTINGS (object);
|
||||
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
|
||||
|
||||
g_object_freeze_notify (object);
|
||||
|
||||
if (!_nm_object_get_nm_running (NM_OBJECT (self))) {
|
||||
GPtrArray *connections;
|
||||
int i;
|
||||
|
||||
nm_clear_g_cancellable (&priv->props_cancellable);
|
||||
|
||||
/* Clear connections */
|
||||
connections = priv->all_connections;
|
||||
priv->all_connections = g_ptr_array_new ();
|
||||
for (i = 0; i < connections->len; i++)
|
||||
g_signal_emit (self, signals[CONNECTION_REMOVED], 0, connections->pdata[i]);
|
||||
g_ptr_array_unref (connections);
|
||||
|
||||
/* Clear properties */
|
||||
if (priv->hostname) {
|
||||
g_free (priv->hostname);
|
||||
priv->hostname = NULL;
|
||||
g_object_notify (G_OBJECT (self), NM_REMOTE_SETTINGS_HOSTNAME);
|
||||
}
|
||||
|
||||
if (priv->can_modify) {
|
||||
priv->can_modify = FALSE;
|
||||
g_object_notify (G_OBJECT (self), NM_REMOTE_SETTINGS_CAN_MODIFY);
|
||||
}
|
||||
|
||||
_nm_object_suppress_property_updates (NM_OBJECT (self), TRUE);
|
||||
} else {
|
||||
_nm_object_suppress_property_updates (NM_OBJECT (self), FALSE);
|
||||
|
||||
nm_clear_g_cancellable (&priv->props_cancellable);
|
||||
priv->props_cancellable = g_cancellable_new ();
|
||||
_nm_object_reload_properties_async (NM_OBJECT (self), priv->props_cancellable, updated_properties, self);
|
||||
}
|
||||
|
||||
g_object_thaw_notify (object);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -688,9 +624,6 @@ init_dbus (NMObject *object)
|
|||
_nm_object_register_properties (object,
|
||||
NM_DBUS_INTERFACE_SETTINGS,
|
||||
property_info);
|
||||
|
||||
g_signal_connect (object, "notify::" NM_OBJECT_NM_RUNNING,
|
||||
G_CALLBACK (nm_running_changed), object);
|
||||
}
|
||||
|
||||
static GObject *
|
||||
|
|
@ -736,8 +669,6 @@ dispose (GObject *object)
|
|||
g_clear_pointer (&priv->all_connections, g_ptr_array_unref);
|
||||
}
|
||||
|
||||
g_signal_handlers_disconnect_by_func (object, G_CALLBACK (nm_running_changed), self);
|
||||
|
||||
g_clear_pointer (&priv->visible_connections, g_ptr_array_unref);
|
||||
g_clear_pointer (&priv->hostname, g_free);
|
||||
|
||||
|
|
@ -774,9 +705,6 @@ nm_remote_settings_class_init (NMRemoteSettingsClass *class)
|
|||
|
||||
g_type_class_add_private (class, sizeof (NMRemoteSettingsPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_SETTINGS);
|
||||
_nm_dbus_register_proxy_type (NM_DBUS_INTERFACE_SETTINGS, NMDBUS_TYPE_SETTINGS_PROXY);
|
||||
|
||||
/* Virtual methods */
|
||||
object_class->constructor = constructor;
|
||||
object_class->get_property = get_property;
|
||||
|
|
|
|||
|
|
@ -1047,19 +1047,20 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
|
|||
{
|
||||
NMSecretAgentOld *self = NM_SECRET_AGENT_OLD (initable);
|
||||
NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (self);
|
||||
GDBusProxy *proxy;
|
||||
|
||||
priv->bus = _nm_dbus_new_connection (cancellable, error);
|
||||
if (!priv->bus)
|
||||
return FALSE;
|
||||
|
||||
proxy = _nm_dbus_new_proxy_for_connection (priv->bus,
|
||||
NM_DBUS_PATH_AGENT_MANAGER,
|
||||
NM_DBUS_INTERFACE_AGENT_MANAGER,
|
||||
cancellable, error);
|
||||
if (!proxy)
|
||||
priv->manager_proxy = nmdbus_agent_manager_proxy_new_sync (priv->bus,
|
||||
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES
|
||||
| G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
|
||||
NM_DBUS_SERVICE,
|
||||
NM_DBUS_PATH_AGENT_MANAGER,
|
||||
cancellable,
|
||||
error);
|
||||
if (!priv->manager_proxy)
|
||||
return FALSE;
|
||||
priv->manager_proxy = NMDBUS_AGENT_MANAGER (proxy);
|
||||
|
||||
init_common (self);
|
||||
|
||||
|
|
@ -1106,15 +1107,13 @@ init_async_got_proxy (GObject *object, GAsyncResult *result, gpointer user_data)
|
|||
{
|
||||
NMSecretAgentOldInitData *init_data = user_data;
|
||||
NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (init_data->self);
|
||||
GDBusProxy *proxy;
|
||||
GError *error = NULL;
|
||||
|
||||
proxy = _nm_dbus_new_proxy_for_connection_finish (result, &error);
|
||||
if (!proxy) {
|
||||
priv->manager_proxy = nmdbus_agent_manager_proxy_new_finish (result, &error);
|
||||
if (!priv->manager_proxy) {
|
||||
init_async_complete (init_data, error);
|
||||
return;
|
||||
}
|
||||
priv->manager_proxy = NMDBUS_AGENT_MANAGER (proxy);
|
||||
|
||||
init_common (init_data->self);
|
||||
|
||||
|
|
@ -1138,11 +1137,13 @@ init_async_got_bus (GObject *initable, GAsyncResult *result, gpointer user_data)
|
|||
return;
|
||||
}
|
||||
|
||||
_nm_dbus_new_proxy_for_connection_async (priv->bus,
|
||||
NM_DBUS_PATH_AGENT_MANAGER,
|
||||
NM_DBUS_INTERFACE_AGENT_MANAGER,
|
||||
init_data->cancellable,
|
||||
init_async_got_proxy, init_data);
|
||||
nmdbus_agent_manager_proxy_new (priv->bus,
|
||||
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES
|
||||
| G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
|
||||
NM_DBUS_INTERFACE_AGENT_MANAGER,
|
||||
NM_DBUS_PATH_AGENT_MANAGER,
|
||||
init_data->cancellable,
|
||||
init_async_got_proxy, init_data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1340,9 +1341,6 @@ nm_secret_agent_old_class_init (NMSecretAgentOldClass *class)
|
|||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
_nm_dbus_register_proxy_type (NM_DBUS_INTERFACE_AGENT_MANAGER,
|
||||
NMDBUS_TYPE_AGENT_MANAGER_PROXY);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -185,10 +185,6 @@ nm_vpn_connection_class_init (NMVpnConnectionClass *connection_class)
|
|||
|
||||
g_type_class_add_private (connection_class, sizeof (NMVpnConnectionPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_VPN_CONNECTION);
|
||||
_nm_dbus_register_proxy_type (NM_DBUS_INTERFACE_VPN_CONNECTION,
|
||||
NMDBUS_TYPE_VPN_CONNECTION_PROXY);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->get_property = get_property;
|
||||
object_class->finalize = finalize;
|
||||
|
|
|
|||
|
|
@ -239,8 +239,6 @@ nm_wimax_nsp_class_init (NMWimaxNspClass *nsp_class)
|
|||
|
||||
g_type_class_add_private (nsp_class, sizeof (NMWimaxNspPrivate));
|
||||
|
||||
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_WIMAX_NSP);
|
||||
|
||||
/* virtual methods */
|
||||
object_class->get_property = get_property;
|
||||
object_class->finalize = finalize;
|
||||
|
|
|
|||
|
|
@ -336,9 +336,10 @@ test_remove_connection (void)
|
|||
do {
|
||||
now = time (NULL);
|
||||
g_main_context_iteration (NULL, FALSE);
|
||||
} while ((done == FALSE) && (now - start < 5));
|
||||
if (done && !remote)
|
||||
break;
|
||||
} while (now - start < 5);
|
||||
g_assert (done == TRUE);
|
||||
|
||||
g_assert (!remote);
|
||||
|
||||
/* Ensure NMClient no longer has the connection */
|
||||
|
|
|
|||
|
|
@ -599,6 +599,12 @@ test_secret_agent_auto_register (void)
|
|||
g_assert_no_error (error);
|
||||
g_assert (nm_secret_agent_old_get_registered (agent));
|
||||
|
||||
/* The GLib ObjectManager doesn't like when we drop the service
|
||||
* in between it sees the service disappear and the call to
|
||||
* GetManagedObjects. Give it a chance to do its business.
|
||||
* Arguably a bug. */
|
||||
g_main_context_iteration (NULL, FALSE);
|
||||
|
||||
/* Shut down test service */
|
||||
nmtstc_service_cleanup (sinfo);
|
||||
g_main_loop_run (loop);
|
||||
|
|
@ -609,6 +615,9 @@ test_secret_agent_auto_register (void)
|
|||
g_main_loop_run (loop);
|
||||
g_assert (nm_secret_agent_old_get_registered (agent));
|
||||
|
||||
/* Let ObjectManager initialize (see above). */
|
||||
g_main_context_iteration (NULL, FALSE);
|
||||
|
||||
/* Shut down test service again */
|
||||
nmtstc_service_cleanup (sinfo);
|
||||
g_main_loop_run (loop);
|
||||
|
|
|
|||
|
|
@ -92,9 +92,15 @@ class ExportedObj(dbus.service.Object):
|
|||
dbus.service.Object.__init__(self, bus, object_path)
|
||||
self._bus = bus
|
||||
self.path = object_path
|
||||
self.__dbus_ifaces = {}
|
||||
self.__ensure_dbus_ifaces()
|
||||
object_manager.add_object(self)
|
||||
|
||||
def __ensure_dbus_ifaces(self):
|
||||
if not hasattr(self, '_ExportedObj__dbus_ifaces'):
|
||||
self.__dbus_ifaces = {}
|
||||
|
||||
def add_dbus_interface(self, dbus_iface, get_props_func, prop_changed_func):
|
||||
self.__ensure_dbus_ifaces()
|
||||
self.__dbus_ifaces[dbus_iface] = ExportedObj.DBusInterface(dbus_iface, get_props_func, prop_changed_func)
|
||||
|
||||
def __dbus_interface_get(self, dbus_iface):
|
||||
|
|
@ -113,6 +119,11 @@ class ExportedObj(dbus.service.Object):
|
|||
def _dbus_property_notify(self, dbus_iface, propname):
|
||||
prop = self._dbus_property_get(dbus_iface, propname)
|
||||
self.__dbus_interface_get(dbus_iface).prop_changed_func(self, { propname: prop })
|
||||
ExportedObj.PropertiesChanged(self, dbus_iface, { propname: prop }, [])
|
||||
|
||||
@dbus.service.signal(dbus.PROPERTIES_IFACE, signature='sa{sv}as')
|
||||
def PropertiesChanged(self, iface, changed, invalidated):
|
||||
pass
|
||||
|
||||
@dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE, in_signature='s', out_signature='a{sv}')
|
||||
def GetAll(self, dbus_iface):
|
||||
|
|
@ -122,6 +133,16 @@ class ExportedObj(dbus.service.Object):
|
|||
def Get(self, dbus_iface, name):
|
||||
return self._dbus_property_get(dbus_iface, name)
|
||||
|
||||
def get_managed_ifaces(self):
|
||||
my_ifaces = {}
|
||||
for iface in self.__dbus_ifaces:
|
||||
my_ifaces[iface] = self.__dbus_ifaces[iface].get_props_func()
|
||||
return self.path, my_ifaces
|
||||
|
||||
def remove_from_connection(self):
|
||||
object_manager.remove_object(self)
|
||||
dbus.service.Object.remove_from_connection(self)
|
||||
|
||||
###################################################################
|
||||
IFACE_DEVICE = 'org.freedesktop.NetworkManager.Device'
|
||||
|
||||
|
|
@ -148,8 +169,6 @@ class Device(ExportedObj):
|
|||
def __init__(self, bus, iface, devtype):
|
||||
object_path = "/org/freedesktop/NetworkManager/Devices/%d" % Device.counter
|
||||
Device.counter = Device.counter + 1
|
||||
ExportedObj.__init__(self, bus, object_path)
|
||||
self.add_dbus_interface(IFACE_DEVICE, self.__get_props, Device.PropertiesChanged)
|
||||
|
||||
self.iface = iface
|
||||
self.udi = "/sys/devices/virtual/%s" % iface
|
||||
|
|
@ -162,6 +181,9 @@ class Device(ExportedObj):
|
|||
self.dhcp6_config = None
|
||||
self.available_connections = []
|
||||
|
||||
self.add_dbus_interface(IFACE_DEVICE, self.__get_props, Device.PropertiesChanged)
|
||||
ExportedObj.__init__(self, bus, object_path)
|
||||
|
||||
# Properties interface
|
||||
def __get_props(self):
|
||||
props = {}
|
||||
|
|
@ -221,8 +243,6 @@ PE_S390_SUBCHANNELS = "S390Subchannels"
|
|||
|
||||
class WiredDevice(Device):
|
||||
def __init__(self, bus, iface, mac, subchannels):
|
||||
Device.__init__(self, bus, iface, NM_DEVICE_TYPE_ETHERNET)
|
||||
self.add_dbus_interface(IFACE_WIRED, self.__get_props, WiredDevice.PropertiesChanged)
|
||||
|
||||
if mac is None:
|
||||
self.mac = random_mac()
|
||||
|
|
@ -231,6 +251,9 @@ class WiredDevice(Device):
|
|||
self.carrier = False
|
||||
self.s390_subchannels = subchannels
|
||||
|
||||
self.add_dbus_interface(IFACE_WIRED, self.__get_props, WiredDevice.PropertiesChanged)
|
||||
Device.__init__(self, bus, iface, NM_DEVICE_TYPE_ETHERNET)
|
||||
|
||||
# Properties interface
|
||||
def __get_props(self):
|
||||
props = {}
|
||||
|
|
@ -257,19 +280,19 @@ PV_VLAN_ID = "VlanId"
|
|||
|
||||
class VlanDevice(Device):
|
||||
def __init__(self, bus, iface):
|
||||
Device.__init__(self, bus, iface, NM_DEVICE_TYPE_VLAN)
|
||||
self.add_dbus_interface(IFACE_VLAN, self.__get_props, VlanDevice.PropertiesChanged)
|
||||
|
||||
self.mac = random_mac()
|
||||
self.carrier = False
|
||||
self.vlan_id = 1
|
||||
|
||||
self.add_dbus_interface(IFACE_VLAN, self.__get_props, VlanDevice.PropertiesChanged)
|
||||
Device.__init__(self, bus, iface, NM_DEVICE_TYPE_VLAN)
|
||||
|
||||
# Properties interface
|
||||
def __get_props(self):
|
||||
props = {}
|
||||
props[PV_HW_ADDRESS] = self.mac
|
||||
props[PV_CARRIER] = self.carrier
|
||||
props[PV_VLAN_ID] = self.vlan_id
|
||||
props[PV_VLAN_ID] = dbus.UInt32(self.vlan_id)
|
||||
return props
|
||||
|
||||
@dbus.service.signal(IFACE_VLAN, signature='a{sv}')
|
||||
|
|
@ -295,8 +318,6 @@ class WifiAp(ExportedObj):
|
|||
def __init__(self, bus, ssid, mac, flags, wpaf, rsnf, freq):
|
||||
path = "/org/freedesktop/NetworkManager/AccessPoint/%d" % WifiAp.counter
|
||||
WifiAp.counter = WifiAp.counter + 1
|
||||
ExportedObj.__init__(self, bus, path)
|
||||
self.add_dbus_interface(IFACE_WIFI_AP, self.__get_props, WifiAp.PropertiesChanged)
|
||||
|
||||
self.ssid = ssid
|
||||
if mac:
|
||||
|
|
@ -310,6 +331,9 @@ class WifiAp(ExportedObj):
|
|||
self.strength = random.randint(0, 100)
|
||||
self.strength_id = GLib.timeout_add_seconds(10, self.strength_cb, None)
|
||||
|
||||
self.add_dbus_interface(IFACE_WIFI_AP, self.__get_props, WifiAp.PropertiesChanged)
|
||||
ExportedObj.__init__(self, bus, path)
|
||||
|
||||
def __del__(self):
|
||||
if self.strength_id > 0:
|
||||
GLib.source_remove(self.strength_id)
|
||||
|
|
@ -357,13 +381,13 @@ PW_WIRELESS_CAPABILITIES = "WirelessCapabilities"
|
|||
|
||||
class WifiDevice(Device):
|
||||
def __init__(self, bus, iface):
|
||||
Device.__init__(self, bus, iface, NM_DEVICE_TYPE_WIFI)
|
||||
self.add_dbus_interface(IFACE_WIFI, self.__get_props, WifiDevice.PropertiesChanged)
|
||||
|
||||
self.mac = random_mac()
|
||||
self.aps = []
|
||||
self.active_ap = None
|
||||
|
||||
self.add_dbus_interface(IFACE_WIFI, self.__get_props, WifiDevice.PropertiesChanged)
|
||||
Device.__init__(self, bus, iface, NM_DEVICE_TYPE_WIFI)
|
||||
|
||||
# methods
|
||||
@dbus.service.method(dbus_interface=IFACE_WIFI, in_signature='', out_signature='ao')
|
||||
def GetAccessPoints(self):
|
||||
|
|
@ -443,13 +467,14 @@ class WimaxNsp(ExportedObj):
|
|||
def __init__(self, bus, name):
|
||||
path = "/org/freedesktop/NetworkManager/Nsp/%d" % WimaxNsp.counter
|
||||
WimaxNsp.counter = WimaxNsp.counter + 1
|
||||
ExportedObj.__init__(self, bus, path)
|
||||
self.add_dbus_interface(IFACE_WIMAX_NSP, self.__get_props, WimaxNsp.PropertiesChanged)
|
||||
|
||||
self.name = name
|
||||
self.strength = random.randint(0, 100)
|
||||
self.strength_id = GLib.timeout_add_seconds(10, self.strength_cb, None)
|
||||
|
||||
self.add_dbus_interface(IFACE_WIMAX_NSP, self.__get_props, WimaxNsp.PropertiesChanged)
|
||||
ExportedObj.__init__(self, bus, path)
|
||||
|
||||
def __del__(self):
|
||||
if self.strength_id > 0:
|
||||
GLib.source_remove(self.strength_id)
|
||||
|
|
@ -492,14 +517,14 @@ PX_ACTIVE_NSP = "ActiveNsp"
|
|||
|
||||
class WimaxDevice(Device):
|
||||
def __init__(self, bus, iface):
|
||||
Device.__init__(self, bus, iface, NM_DEVICE_TYPE_WIMAX)
|
||||
self.add_dbus_interface(IFACE_WIMAX, self.__get_props, WimaxDevice.PropertiesChanged)
|
||||
|
||||
self.mac = random_mac()
|
||||
self.bsid = random_mac()
|
||||
self.nsps = []
|
||||
self.active_nsp = None
|
||||
|
||||
self.add_dbus_interface(IFACE_WIMAX, self.__get_props, WimaxDevice.PropertiesChanged)
|
||||
Device.__init__(self, bus, iface, NM_DEVICE_TYPE_WIMAX)
|
||||
|
||||
# methods
|
||||
@dbus.service.method(dbus_interface=IFACE_WIMAX, in_signature='', out_signature='ao')
|
||||
def GetNspList(self):
|
||||
|
|
@ -582,8 +607,6 @@ class ActiveConnection(ExportedObj):
|
|||
def __init__(self, bus, device, connection, specific_object):
|
||||
object_path = "/org/freedesktop/NetworkManager/ActiveConnection/%d" % ActiveConnection.counter
|
||||
ActiveConnection.counter = ActiveConnection.counter + 1
|
||||
ExportedObj.__init__(self, bus, object_path)
|
||||
self.add_dbus_interface(IFACE_ACTIVE_CONNECTION, self.__get_props, ActiveConnection.PropertiesChanged)
|
||||
|
||||
self.device = device
|
||||
self.conn = connection
|
||||
|
|
@ -598,6 +621,9 @@ class ActiveConnection(ExportedObj):
|
|||
self.vpn = False
|
||||
self.master = None
|
||||
|
||||
self.add_dbus_interface(IFACE_ACTIVE_CONNECTION, self.__get_props, ActiveConnection.PropertiesChanged)
|
||||
ExportedObj.__init__(self, bus, object_path)
|
||||
|
||||
# Properties interface
|
||||
def __get_props(self):
|
||||
props = {}
|
||||
|
|
@ -659,9 +685,6 @@ def set_device_ac_cb(device, ac):
|
|||
|
||||
class NetworkManager(ExportedObj):
|
||||
def __init__(self, bus, object_path):
|
||||
ExportedObj.__init__(self, bus, object_path)
|
||||
self.add_dbus_interface(IFACE_NM, self.__get_props, NetworkManager.PropertiesChanged)
|
||||
|
||||
self._bus = bus;
|
||||
self.devices = []
|
||||
self.active_connections = []
|
||||
|
|
@ -670,6 +693,9 @@ class NetworkManager(ExportedObj):
|
|||
self.state = NM_STATE_DISCONNECTED
|
||||
self.connectivity = 1
|
||||
|
||||
self.add_dbus_interface(IFACE_NM, self.__get_props, NetworkManager.PropertiesChanged)
|
||||
ExportedObj.__init__(self, bus, object_path)
|
||||
|
||||
@dbus.service.signal(IFACE_NM, signature='u')
|
||||
def StateChanged(self, new_state):
|
||||
pass
|
||||
|
|
@ -736,6 +762,7 @@ class NetworkManager(ExportedObj):
|
|||
|
||||
if s_con['id'] == 'object-creation-failed-test':
|
||||
self.active_connections.remove(ac)
|
||||
self.__notify(PM_ACTIVE_CONNECTIONS)
|
||||
ac.remove_from_connection()
|
||||
else:
|
||||
GLib.timeout_add(50, set_device_ac_cb, device, ac)
|
||||
|
|
@ -930,6 +957,11 @@ class NetworkManager(ExportedObj):
|
|||
def UpdateConnection(self, path, connection, verify_connection):
|
||||
return settings.update_connection(connection, path, verify_connection)
|
||||
|
||||
@dbus.service.method(dbus_interface=IFACE_TEST, in_signature='', out_signature='')
|
||||
def Restart(self):
|
||||
bus.release_name("org.freedesktop.NetworkManager")
|
||||
bus.request_name("org.freedesktop.NetworkManager")
|
||||
|
||||
|
||||
###################################################################
|
||||
IFACE_CONNECTION = 'org.freedesktop.NetworkManager.Settings.Connection'
|
||||
|
|
@ -946,7 +978,7 @@ class InvalidSettingException(dbus.DBusException):
|
|||
class MissingSettingException(dbus.DBusException):
|
||||
_dbus_error_name = IFACE_CONNECTION + '.MissingSetting'
|
||||
|
||||
class Connection(dbus.service.Object):
|
||||
class Connection(ExportedObj):
|
||||
def __init__(self, bus, object_path, settings, remove_func, verify_connection=True):
|
||||
|
||||
if self.get_uuid(settings) is None:
|
||||
|
|
@ -955,8 +987,6 @@ class Connection(dbus.service.Object):
|
|||
settings['connection']['uuid'] = uuid.uuid4()
|
||||
self.verify(settings, verify_strict=verify_connection)
|
||||
|
||||
dbus.service.Object.__init__(self, bus, object_path)
|
||||
|
||||
self.path = object_path
|
||||
self.settings = settings
|
||||
self.remove_func = remove_func
|
||||
|
|
@ -964,6 +994,9 @@ class Connection(dbus.service.Object):
|
|||
self.props = {}
|
||||
self.props['Unsaved'] = False
|
||||
|
||||
self.add_dbus_interface(IFACE_CONNECTION, self.__get_props, None)
|
||||
ExportedObj.__init__(self, bus, object_path)
|
||||
|
||||
def get_uuid(self, settings=None):
|
||||
if settings is None:
|
||||
settings = self.settings
|
||||
|
|
@ -1003,20 +1036,11 @@ class Connection(dbus.service.Object):
|
|||
self.settings = settings;
|
||||
self.Updated()
|
||||
|
||||
# Properties interface
|
||||
@dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE, in_signature='s', out_signature='a{sv}')
|
||||
def GetAll(self, iface):
|
||||
if iface != IFACE_CONNECTION:
|
||||
raise UnknownInterfaceException()
|
||||
def __get_props(self):
|
||||
return self.props
|
||||
|
||||
@dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE, in_signature='ss', out_signature='v')
|
||||
def Get(self, iface, name):
|
||||
if iface != IFACE_CONNECTION:
|
||||
raise UnknownInterfaceException()
|
||||
if not name in self.props.keys():
|
||||
raise UnknownPropertyException()
|
||||
return self.props[name]
|
||||
def __notify(self, propname):
|
||||
self._dbus_property_notify(IFACE_CONNECTION, propname)
|
||||
|
||||
# Connection methods
|
||||
@dbus.service.method(dbus_interface=IFACE_CONNECTION, in_signature='', out_signature='a{sa{sv}}')
|
||||
|
|
@ -1054,9 +1078,8 @@ IFACE_SETTINGS = 'org.freedesktop.NetworkManager.Settings'
|
|||
class InvalidHostnameException(dbus.DBusException):
|
||||
_dbus_error_name = IFACE_SETTINGS + '.InvalidHostname'
|
||||
|
||||
class Settings(dbus.service.Object):
|
||||
class Settings(ExportedObj):
|
||||
def __init__(self, bus, object_path):
|
||||
dbus.service.Object.__init__(self, bus, object_path)
|
||||
self.connections = {}
|
||||
self.bus = bus
|
||||
self.counter = 1
|
||||
|
|
@ -1066,6 +1089,9 @@ class Settings(dbus.service.Object):
|
|||
self.props['CanModify'] = True
|
||||
self.props['Connections'] = dbus.Array([], 'o')
|
||||
|
||||
self.add_dbus_interface(IFACE_SETTINGS, self.__get_props, Settings.PropertiesChanged)
|
||||
ExportedObj.__init__(self, bus, object_path)
|
||||
|
||||
def auto_remove_next_connection(self):
|
||||
self.remove_next_connection = True;
|
||||
|
||||
|
|
@ -1092,7 +1118,7 @@ class Settings(dbus.service.Object):
|
|||
self.connections[path] = con
|
||||
self.props['Connections'] = dbus.Array(self.connections.keys(), 'o')
|
||||
self.NewConnection(path)
|
||||
self.PropertiesChanged({ 'connections': self.props['Connections'] })
|
||||
self.__notify('Connections')
|
||||
|
||||
if self.remove_next_connection:
|
||||
self.remove_next_connection = False
|
||||
|
|
@ -1111,7 +1137,7 @@ class Settings(dbus.service.Object):
|
|||
def delete_connection(self, connection):
|
||||
del self.connections[connection.path]
|
||||
self.props['Connections'] = dbus.Array(self.connections.keys(), 'o')
|
||||
self.PropertiesChanged({ 'connections': self.props['Connections'] })
|
||||
self.__notify('Connections')
|
||||
|
||||
@dbus.service.method(dbus_interface=IFACE_SETTINGS, in_signature='s', out_signature='')
|
||||
def SaveHostname(self, hostname):
|
||||
|
|
@ -1119,21 +1145,13 @@ class Settings(dbus.service.Object):
|
|||
if hostname.find('.') == -1:
|
||||
raise InvalidHostnameException()
|
||||
self.props['Hostname'] = hostname
|
||||
self.PropertiesChanged({ 'hostname': hostname })
|
||||
self.__notify('Hostname')
|
||||
|
||||
@dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE, in_signature='s', out_signature='a{sv}')
|
||||
def GetAll(self, iface):
|
||||
if iface != IFACE_SETTINGS:
|
||||
raise UnknownInterfaceException()
|
||||
def __get_props(self):
|
||||
return self.props
|
||||
|
||||
@dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE, in_signature='ss', out_signature='v')
|
||||
def Get(self, iface, name):
|
||||
if iface != IFACE_SETTINGS:
|
||||
raise UnknownInterfaceException()
|
||||
if not name in self.props.keys():
|
||||
raise UnknownPropertyException()
|
||||
return self.props[name]
|
||||
def __notify(self, propname):
|
||||
self._dbus_property_notify(IFACE_SETTINGS, propname)
|
||||
|
||||
@dbus.service.signal(IFACE_SETTINGS, signature='o')
|
||||
def NewConnection(self, path):
|
||||
|
|
@ -1206,6 +1224,45 @@ class AgentManager(dbus.service.Object):
|
|||
continue
|
||||
return secrets
|
||||
|
||||
###################################################################
|
||||
IFACE_OBJECT_MANAGER = 'org.freedesktop.DBus.ObjectManager'
|
||||
|
||||
PATH_OBJECT_MANAGER = '/org/freedesktop'
|
||||
|
||||
class ObjectManager(dbus.service.Object):
|
||||
def __init__(self, bus, object_path):
|
||||
dbus.service.Object.__init__(self, bus, object_path)
|
||||
self.objs = []
|
||||
self.bus = bus
|
||||
|
||||
@dbus.service.method(dbus_interface=IFACE_OBJECT_MANAGER,
|
||||
in_signature='', out_signature='a{oa{sa{sv}}}',
|
||||
sender_keyword='sender')
|
||||
def GetManagedObjects(self, sender=None):
|
||||
managed_objects = {}
|
||||
for obj in self.objs:
|
||||
name, ifaces = obj.get_managed_ifaces()
|
||||
managed_objects[name] = ifaces
|
||||
return managed_objects
|
||||
|
||||
def add_object(self, obj):
|
||||
self.objs.append(obj)
|
||||
name, ifaces = obj.get_managed_ifaces()
|
||||
self.InterfacesAdded(name, ifaces)
|
||||
|
||||
def remove_object(self, obj):
|
||||
self.objs.remove(obj)
|
||||
name, ifaces = obj.get_managed_ifaces()
|
||||
self.InterfacesRemoved(name, ifaces.keys())
|
||||
|
||||
@dbus.service.signal(IFACE_OBJECT_MANAGER, signature='oa{sa{sv}}')
|
||||
def InterfacesAdded(self, name, ifaces):
|
||||
pass
|
||||
|
||||
@dbus.service.signal(IFACE_OBJECT_MANAGER, signature='oas')
|
||||
def InterfacesRemoved(self, name, ifaces):
|
||||
pass
|
||||
|
||||
###################################################################
|
||||
|
||||
def stdin_cb(io, condition):
|
||||
|
|
@ -1219,9 +1276,10 @@ def main():
|
|||
|
||||
random.seed()
|
||||
|
||||
bus = dbus.SessionBus()
|
||||
global manager, settings, agent_manager, object_manager, bus
|
||||
|
||||
global manager, settings, agent_manager
|
||||
bus = dbus.SessionBus()
|
||||
object_manager = ObjectManager(bus, "/org/freedesktop")
|
||||
manager = NetworkManager(bus, "/org/freedesktop/NetworkManager")
|
||||
settings = Settings(bus, "/org/freedesktop/NetworkManager/Settings")
|
||||
agent_manager = AgentManager(bus, "/org/freedesktop/NetworkManager/AgentManager")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue