mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-22 02:35:25 +00:00
libnm: use the o.fd.DBus.ObjectManager API for object management
This speeds up the initial object tree load significantly. Also, it reduces the object management complexity by shifting the duties to GDBusObjectManager. The lifetime of all NMObjects is now managed by the NMClient via the object manager. The NMClient creates the NMObjects for GDBus objects, triggers the initialization and serves as an object registry (replaces the nm-cache). The ObjectManager uses the o.fd.DBus.ObjectManager API to learn of the object creation, removal and property changes. It takes care of the property changes so that we don't have to and lets us always see a consistent object state. Thus at the time we learn of a new object we already know its properties. The NMObject unfortunately can't be made synchronously initializable as the NMRemoteConnection's settings are not managed with standard o.fd.DBus Properties and ObjectManager APIs and thus are not known to the ObjectManager. Thus most of the asynchronous object property changing code in nm-object.c is preserved. The objects notify the properties that reference them of their initialization in from their init_finish() methods, thus the asynchronously created objects are not allowed to fail creation (or the dependees would wait forever). Not a problem -- if a connection can't get its Settings, it's either invisible or being removed (presumably we'd learn of the removal from the object manager soon). The NMObjects can't be created by the object manager itself, since we can't determine the resulting object type in proxy_type() yet (we can't tell from the name and can't access the interface list). Therefore the GDBusObject is coupled with a NMObject later on. Lastly, now that all the objects are managed by the object manager, the NMRemoteSettings and NMManager go away when the daemon is stopped. The complexity of dealing with calls to NMClient that would require any of the resources that these objects manage (connection or device lists, etc.) had to be moved to NMClient. The bright side is that his allows for removal all of the daemon presence tracking from NMObject.
This commit is contained in:
parent
ff3eb24c15
commit
1f5b48a59e
|
@ -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);
|
||||
|
||||
|
|
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue