core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API

Previously, we used the generated GDBusInterfaceSkeleton types and glued
them via the NMExportedObject base class to our NM types. We also used
GDBusObjectManagerServer.

Don't do that anymore. The resulting code was more complicated despite (or
because?) using generated classes. It was hard to understand, complex, had
ordering-issues, and had a runtime and memory overhead.

This patch refactors this entirely and uses the lower layer API GDBusConnection
directly. It replaces the generated code, GDBusInterfaceSkeleton, and
GDBusObjectManagerServer. All this is now done by NMDbusObject and NMDBusManager
and static descriptor instances of type GDBusInterfaceInfo.

This adds a net plus of more then 1300 lines of hand written code. I claim
that this implementation is easier to understand. Note that previously we
also required extensive and complex glue code to bind our objects to the
generated skeleton objects. Instead, now glue our objects directly to
GDBusConnection. The result is more immediate and gets rid of layers of
code in between.
Now that the D-Bus glue us more under our control, we can address issus and
bottlenecks better, instead of adding code to bend the generated skeletons
to our needs.

Note that the current implementation now only supports one D-Bus connection.
That was effectively the case already, although there were places (and still are)
where the code pretends it could also support connections from a private socket.
We dropped private socket support mainly because it was unused, untested and
buggy, but also because GDBusObjectManagerServer could not export the same
objects on multiple connections. Now, it would be rather straight forward to
fix that and re-introduce ObjectManager on each private connection. But this
commit doesn't do that yet, and the new code intentionally supports only one
D-Bus connection.
Also, the D-Bus startup was simplified. There is no retry, either nm_dbus_manager_start()
succeeds, or it detects the initrd case. In the initrd case, bus manager never tries to
connect to D-Bus. Since the initrd scenario is not yet used/tested, this is good enough
for the moment. It could be easily extended later, for example with polling whether the
system bus appears (like was done previously). Also, restart of D-Bus daemon isn't
supported either -- just like before.

Note how NMDBusManager now implements the ObjectManager D-Bus interface
directly.

Also, this fixes race issues in the server, by no longer delaying
PropertiesChanged signals. NMExportedObject would collect changed
properties and send the signal out in idle_emit_properties_changed()
on idle. This messes up the ordering of change events w.r.t. other
signals and events on the bus. Note that not only NMExportedObject
messed up the ordering. Also the generated code would hook into
notify() and process change events in and idle handle, exhibiting the
same ordering issue too.
No longer do that. PropertiesChanged signals will be sent right away
by hooking into dispatch_properties_changed(). This means, changing
a property in quick succession will no longer be combined and is
guaranteed to emit signals for each individual state. Quite possibly
we emit now more PropertiesChanged signals then before.
However, we are now able to group a set of changes by using standard
g_object_freeze_notify()/g_object_thaw_notify(). We probably should
make more use of that.

Also, now that our signals are all handled in the right order, we
might find places where we still emit them in the wrong order. But that
is then due to the order in which our GObjects emit signals, not due
to an ill behavior of the D-Bus glue. Possibly we need to identify
such ordering issues and fix them.

Numbers (for contrib/rpm --without debug on x86_64):

- the patch changes the code size of NetworkManager by
  - 2809360 bytes
  + 2537528 bytes (-9.7%)

- Runtime measurements are harder because there is a large variance
  during testing. In other words, the numbers are not reproducible.
  Currently, the implementation performs no caching of GVariants at all,
  but it would be rather simple to add it, if that turns out to be
  useful.
  Anyway, without strong claim, it seems that the new form tends to
  perform slightly better. That would be no surprise.

  $ time (for i in {1..1000}; do nmcli >/dev/null || break; echo -n .;  done)
  - real    1m39.355s
  + real    1m37.432s

  $ time (for i in {1..2000}; do busctl call org.freedesktop.NetworkManager /org/freedesktop org.freedesktop.DBus.ObjectManager GetManagedObjects > /dev/null || break; echo -n .; done)
  - real    0m26.843s
  + real    0m25.281s

- Regarding RSS size, just looking at the processes in similar
  conditions, doesn't give a large difference. On my system they
  consume about 19MB RSS. It seems that the new version has a
  slightly smaller RSS size.
  - 19356 RSS
  + 18660 RSS
This commit is contained in:
Thomas Haller
2018-02-26 13:51:52 +01:00
parent a1f37964f0
commit 297d4985ab
92 changed files with 4610 additions and 3242 deletions

View File

@@ -366,8 +366,6 @@ CLEANFILES += $(DBUS_INTERFACE_DOCS)
$(dispatcher_libnm_dispatcher_core_la_OBJECTS): $(introspection_sources) $(dispatcher_libnm_dispatcher_core_la_OBJECTS): $(introspection_sources)
$(dispatcher_nm_dispatcher_OBJECTS): $(introspection_sources) $(dispatcher_nm_dispatcher_OBJECTS): $(introspection_sources)
$(libnm_libnm_la_OBJECTS): $(introspection_sources) $(libnm_libnm_la_OBJECTS): $(introspection_sources)
$(src_libNetworkManager_la_OBJECTS): $(introspection_sources)
$(src_libNetworkManagerBase_la_OBJECTS): $(introspection_sources)
EXTRA_DIST += \ EXTRA_DIST += \
$(dbusinterfaces_DATA) \ $(dbusinterfaces_DATA) \
@@ -1423,8 +1421,10 @@ src_libNetworkManagerBase_la_SOURCES = \
src/ndisc/nm-ndisc.h \ src/ndisc/nm-ndisc.h \
src/ndisc/nm-ndisc-private.h \ src/ndisc/nm-ndisc-private.h \
\ \
src/nm-exported-object.c \ src/nm-dbus-utils.c \
src/nm-exported-object.h \ src/nm-dbus-utils.h \
src/nm-dbus-object.c \
src/nm-dbus-object.h \
src/nm-ip4-config.c \ src/nm-ip4-config.c \
src/nm-ip4-config.h \ src/nm-ip4-config.h \
src/nm-ip6-config.c \ src/nm-ip6-config.c \
@@ -1452,7 +1452,6 @@ endif
src_libNetworkManagerBase_la_LIBADD = \ src_libNetworkManagerBase_la_LIBADD = \
libnm-core/libnm-core.la \ libnm-core/libnm-core.la \
introspection/libnmdbus.la \
$(GLIB_LIBS) \ $(GLIB_LIBS) \
$(SYSTEMD_JOURNAL_LIBS) \ $(SYSTEMD_JOURNAL_LIBS) \
$(LIBUDEV_LIBS) \ $(LIBUDEV_LIBS) \
@@ -1860,7 +1859,6 @@ src_ppp_libnm_ppp_plugin_la_LDFLAGS = \
-Wl,--version-script="$(srcdir)/src/ppp/nm-ppp-plugin.ver" -Wl,--version-script="$(srcdir)/src/ppp/nm-ppp-plugin.ver"
src_ppp_libnm_ppp_plugin_la_LIBADD = \ src_ppp_libnm_ppp_plugin_la_LIBADD = \
introspection/libnmdbus.la \
$(GLIB_LIBS) $(GLIB_LIBS)
$(src_ppp_libnm_ppp_plugin_la_OBJECTS): $(libnm_core_lib_h_pub_mkenums) $(src_ppp_libnm_ppp_plugin_la_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
@@ -2515,7 +2513,6 @@ src_devices_adsl_libnm_device_plugin_adsl_la_LDFLAGS = \
-Wl,--version-script="$(srcdir)/linker-script-devices.ver" -Wl,--version-script="$(srcdir)/linker-script-devices.ver"
src_devices_adsl_libnm_device_plugin_adsl_la_LIBADD = \ src_devices_adsl_libnm_device_plugin_adsl_la_LIBADD = \
introspection/libnmdbus.la \
$(LIBUDEV_LIBS) $(LIBUDEV_LIBS)
check-local-devices-adsl: src/devices/adsl/libnm-device-plugin-adsl.la check-local-devices-adsl: src/devices/adsl/libnm-device-plugin-adsl.la
@@ -2591,7 +2588,6 @@ src_devices_wwan_libnm_device_plugin_wwan_la_LDFLAGS = \
-Wl,--version-script="$(srcdir)/linker-script-devices.ver" -Wl,--version-script="$(srcdir)/linker-script-devices.ver"
src_devices_wwan_libnm_device_plugin_wwan_la_LIBADD = \ src_devices_wwan_libnm_device_plugin_wwan_la_LIBADD = \
introspection/libnmdbus.la \
src/devices/wwan/libnm-wwan.la \ src/devices/wwan/libnm-wwan.la \
$(GLIB_LIBS) $(GLIB_LIBS)
@@ -2649,7 +2645,6 @@ src_devices_bluetooth_libnm_device_plugin_bluetooth_la_LDFLAGS = \
-Wl,--version-script="$(srcdir)/linker-script-devices.ver" -Wl,--version-script="$(srcdir)/linker-script-devices.ver"
src_devices_bluetooth_libnm_device_plugin_bluetooth_la_LIBADD = \ src_devices_bluetooth_libnm_device_plugin_bluetooth_la_LIBADD = \
introspection/libnmdbus.la \
src/devices/wwan/libnm-wwan.la \ src/devices/wwan/libnm-wwan.la \
$(GLIB_LIBS) $(GLIB_LIBS)
@@ -2690,6 +2685,8 @@ src_devices_wifi_libnm_device_plugin_wifi_la_SOURCES = \
src/devices/wifi/nm-wifi-ap.h \ src/devices/wifi/nm-wifi-ap.h \
src/devices/wifi/nm-wifi-utils.c \ src/devices/wifi/nm-wifi-utils.c \
src/devices/wifi/nm-wifi-utils.h \ src/devices/wifi/nm-wifi-utils.h \
src/devices/wifi/nm-wifi-common.c \
src/devices/wifi/nm-wifi-common.h \
src/devices/wifi/nm-device-olpc-mesh.c \ src/devices/wifi/nm-device-olpc-mesh.c \
src/devices/wifi/nm-device-olpc-mesh.h src/devices/wifi/nm-device-olpc-mesh.h
@@ -2716,7 +2713,6 @@ src_devices_wifi_libnm_device_plugin_wifi_la_LDFLAGS = \
-Wl,--version-script="$(srcdir)/linker-script-devices.ver" -Wl,--version-script="$(srcdir)/linker-script-devices.ver"
src_devices_wifi_libnm_device_plugin_wifi_la_LIBADD = \ src_devices_wifi_libnm_device_plugin_wifi_la_LIBADD = \
introspection/libnmdbus.la \
$(GLIB_LIBS) $(GLIB_LIBS)
check-local-devices-wifi: src/devices/wifi/libnm-device-plugin-wifi.la check-local-devices-wifi: src/devices/wifi/libnm-device-plugin-wifi.la
@@ -2786,7 +2782,6 @@ src_devices_team_libnm_device_plugin_team_la_LDFLAGS = \
-Wl,--version-script="$(srcdir)/linker-script-devices.ver" -Wl,--version-script="$(srcdir)/linker-script-devices.ver"
src_devices_team_libnm_device_plugin_team_la_LIBADD = \ src_devices_team_libnm_device_plugin_team_la_LIBADD = \
introspection/libnmdbus.la \
$(LIBTEAMDCTL_LIBS) \ $(LIBTEAMDCTL_LIBS) \
$(JANSSON_LIBS) \ $(JANSSON_LIBS) \
$(GLIB_LIBS) $(GLIB_LIBS)
@@ -2848,7 +2843,6 @@ src_devices_ovs_libnm_device_plugin_ovs_la_LDFLAGS = \
-Wl,--version-script="$(srcdir)/linker-script-devices.ver" -Wl,--version-script="$(srcdir)/linker-script-devices.ver"
src_devices_ovs_libnm_device_plugin_ovs_la_LIBADD = \ src_devices_ovs_libnm_device_plugin_ovs_la_LIBADD = \
introspection/libnmdbus.la \
$(JANSSON_LIBS) \ $(JANSSON_LIBS) \
$(GLIB_LIBS) $(GLIB_LIBS)

View File

@@ -31,7 +31,6 @@
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "platform/nm-platform.h" #include "platform/nm-platform.h"
#include "nm-exported-object.h"
#include "nm-auth-utils.h" #include "nm-auth-utils.h"
/*****************************************************************************/ /*****************************************************************************/
@@ -880,62 +879,6 @@ nm_utils_match_connection (NMConnection *const*connections,
/*****************************************************************************/ /*****************************************************************************/
/**
* nm_utils_g_value_set_object_path:
* @value: a #GValue, initialized to store an object path
* @object: (allow-none): an #NMExportedObject
*
* Sets @value to @object's object path. If @object is %NULL, or not
* exported, @value is set to "/".
*/
void
nm_utils_g_value_set_object_path (GValue *value, gpointer object)
{
g_return_if_fail (!object || NM_IS_EXPORTED_OBJECT (object));
if (object && nm_exported_object_is_exported (object))
g_value_set_string (value, nm_exported_object_get_path (object));
else
g_value_set_string (value, "/");
}
/**
* nm_utils_g_value_set_object_path_array:
* @value: a #GValue, initialized to store an object path
* @objects: a #GSList of #NMExportedObjects
* @filter_func: (allow-none): function to call on each object in @objects
* @user_data: data to pass to @filter_func
*
* Sets @value to an array of object paths of the objects in @objects.
*/
void
nm_utils_g_value_set_object_path_array (GValue *value,
GSList *objects,
NMUtilsObjectFunc filter_func,
gpointer user_data)
{
char **paths;
guint i;
GSList *iter;
paths = g_new (char *, g_slist_length (objects) + 1);
for (i = 0, iter = objects; iter; iter = iter->next) {
NMExportedObject *object = iter->data;
const char *path;
path = nm_exported_object_get_path (object);
if (!path)
continue;
if (filter_func && !filter_func ((GObject *) object, user_data))
continue;
paths[i++] = g_strdup (path);
}
paths[i] = NULL;
g_value_take_boxed (value, paths);
}
/*****************************************************************************/
int int
nm_match_spec_device_by_pllink (const NMPlatformLink *pllink, nm_match_spec_device_by_pllink (const NMPlatformLink *pllink,
const char *match_device_type, const char *match_device_type,

View File

@@ -48,22 +48,6 @@ NMConnection *nm_utils_match_connection (NMConnection *const*connections,
NMUtilsMatchFilterFunc match_filter_func, NMUtilsMatchFilterFunc match_filter_func,
gpointer match_filter_data); gpointer match_filter_data);
void nm_utils_g_value_set_object_path (GValue *value, gpointer object);
/**
* NMUtilsObjectFunc:
* @object: the object to filter on
* @user_data: data passed to the function from the caller
*
* Returns: %TRUE if the object should be used, %FALSE if not
*/
typedef gboolean (*NMUtilsObjectFunc) (GObject *object, gpointer user_data);
void nm_utils_g_value_set_object_path_array (GValue *value,
GSList *objects,
NMUtilsObjectFunc filter_func,
gpointer user_data);
int nm_match_spec_device_by_pllink (const NMPlatformLink *pllink, int nm_match_spec_device_by_pllink (const NMPlatformLink *pllink,
const char *match_device_type, const char *match_device_type,
const GSList *specs, const GSList *specs,

View File

@@ -4,7 +4,6 @@ sources = files(
) )
deps = [ deps = [
libnmdbus_dep,
libudev_dep, libudev_dep,
nm_dep nm_dep
] ]

View File

@@ -39,8 +39,6 @@
#include "nm-setting-adsl.h" #include "nm-setting-adsl.h"
#include "nm-utils.h" #include "nm-utils.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Adsl.h"
#include "devices/nm-device-logging.h" #include "devices/nm-device-logging.h"
_LOG_DECLARE_SELF (NMDeviceAdsl); _LOG_DECLARE_SELF (NMDeviceAdsl);
@@ -655,10 +653,24 @@ dispose (GObject *object)
G_OBJECT_CLASS (nm_device_adsl_parent_class)->dispose (object); G_OBJECT_CLASS (nm_device_adsl_parent_class)->dispose (object);
} }
static const NMDBusInterfaceInfoExtended interface_info_device_adsl = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_ADSL,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Carrier", "b", NM_DEVICE_CARRIER),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_adsl_class_init (NMDeviceAdslClass *klass) nm_device_adsl_class_init (NMDeviceAdslClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass);
object_class->constructed = constructed; object_class->constructed = constructed;
@@ -666,6 +678,8 @@ nm_device_adsl_class_init (NMDeviceAdslClass *klass)
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property; object_class->set_property = set_property;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_adsl);
parent_class->get_generic_capabilities = get_generic_capabilities; parent_class->get_generic_capabilities = get_generic_capabilities;
parent_class->check_connection_compatible = check_connection_compatible; parent_class->check_connection_compatible = check_connection_compatible;
@@ -682,8 +696,4 @@ nm_device_adsl_class_init (NMDeviceAdslClass *klass)
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_ADSL_SKELETON,
NULL);
} }

View File

@@ -9,7 +9,6 @@ sources = files(
) )
deps = [ deps = [
libnmdbus_dep,
libnm_wwan_dep, libnm_wwan_dep,
nm_dep nm_dep
] ]

View File

@@ -43,8 +43,6 @@
#include "devices/wwan/nm-modem-manager.h" #include "devices/wwan/nm-modem-manager.h"
#include "devices/wwan/nm-modem.h" #include "devices/wwan/nm-modem.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Bluetooth.h"
#include "devices/nm-device-logging.h" #include "devices/nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceBt); _LOG_DECLARE_SELF(NMDeviceBt);
@@ -1152,10 +1150,26 @@ finalize (GObject *object)
G_OBJECT_CLASS (nm_device_bt_parent_class)->finalize (object); G_OBJECT_CLASS (nm_device_bt_parent_class)->finalize (object);
} }
static const NMDBusInterfaceInfoExtended interface_info_device_bluetooth = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_BLUETOOTH,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("HwAddress", "s", NM_DEVICE_HW_ADDRESS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Name", "s", NM_DEVICE_BT_NAME),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("BtCapabilities", "u", NM_DEVICE_BT_CAPABILITIES),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_bt_class_init (NMDeviceBtClass *klass) nm_device_bt_class_init (NMDeviceBtClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
object_class->constructed = constructed; object_class->constructed = constructed;
@@ -1164,6 +1178,8 @@ nm_device_bt_class_init (NMDeviceBtClass *klass)
object_class->dispose = dispose; object_class->dispose = dispose;
object_class->finalize = finalize; object_class->finalize = finalize;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_bluetooth);
device_class->get_generic_capabilities = get_generic_capabilities; device_class->get_generic_capabilities = get_generic_capabilities;
device_class->can_auto_connect = can_auto_connect; device_class->can_auto_connect = can_auto_connect;
device_class->deactivate = deactivate; device_class->deactivate = deactivate;
@@ -1207,8 +1223,4 @@ nm_device_bt_class_init (NMDeviceBtClass *klass)
G_TYPE_NONE, 2, G_TYPE_NONE, 2,
G_TYPE_UINT /*guint32 in_bytes*/, G_TYPE_UINT /*guint32 in_bytes*/,
G_TYPE_UINT /*guint32 out_bytes*/); G_TYPE_UINT /*guint32 out_bytes*/);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_BLUETOOTH_SKELETON,
NULL);
} }

View File

@@ -32,8 +32,6 @@
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "nm-ip4-config.h" #include "nm-ip4-config.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Bond.h"
#include "nm-device-logging.h" #include "nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceBond); _LOG_DECLARE_SELF(NMDeviceBond);
@@ -607,13 +605,31 @@ nm_device_bond_init (NMDeviceBond * self)
nm_assert (nm_device_is_master (NM_DEVICE (self))); nm_assert (nm_device_is_master (NM_DEVICE (self)));
} }
static const NMDBusInterfaceInfoExtended interface_info_device_bond = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_BOND,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("HwAddress", "s", NM_DEVICE_HW_ADDRESS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Carrier", "b", NM_DEVICE_CARRIER),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Slaves", "ao", NM_DEVICE_SLAVES),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_bond_class_init (NMDeviceBondClass *klass) nm_device_bond_class_init (NMDeviceBondClass *klass)
{ {
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_BOND_SETTING_NAME, NM_LINK_TYPE_BOND) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_BOND_SETTING_NAME, NM_LINK_TYPE_BOND)
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_bond);
parent_class->is_master = TRUE; parent_class->is_master = TRUE;
parent_class->get_generic_capabilities = get_generic_capabilities; parent_class->get_generic_capabilities = get_generic_capabilities;
parent_class->check_connection_compatible = check_connection_compatible; parent_class->check_connection_compatible = check_connection_compatible;
@@ -629,10 +645,6 @@ nm_device_bond_class_init (NMDeviceBondClass *klass)
parent_class->release_slave = release_slave; parent_class->release_slave = release_slave;
parent_class->can_reapply_change = can_reapply_change; parent_class->can_reapply_change = can_reapply_change;
parent_class->reapply_connection = reapply_connection; parent_class->reapply_connection = reapply_connection;
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_BOND_SKELETON,
NULL);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@@ -30,8 +30,6 @@
#include "nm-device-factory.h" #include "nm-device-factory.h"
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Bridge.h"
#include "nm-device-logging.h" #include "nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceBridge); _LOG_DECLARE_SELF(NMDeviceBridge);
@@ -488,13 +486,31 @@ nm_device_bridge_init (NMDeviceBridge * self)
nm_assert (nm_device_is_master (NM_DEVICE (self))); nm_assert (nm_device_is_master (NM_DEVICE (self)));
} }
static const NMDBusInterfaceInfoExtended interface_info_device_bridge = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_BRIDGE,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("HwAddress", "s", NM_DEVICE_HW_ADDRESS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Carrier", "b", NM_DEVICE_CARRIER),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Slaves", "ao", NM_DEVICE_SLAVES),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_bridge_class_init (NMDeviceBridgeClass *klass) nm_device_bridge_class_init (NMDeviceBridgeClass *klass)
{ {
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_BRIDGE_SETTING_NAME, NM_LINK_TYPE_BRIDGE) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_BRIDGE_SETTING_NAME, NM_LINK_TYPE_BRIDGE)
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_bridge);
parent_class->is_master = TRUE; parent_class->is_master = TRUE;
parent_class->get_generic_capabilities = get_generic_capabilities; parent_class->get_generic_capabilities = get_generic_capabilities;
parent_class->check_connection_compatible = check_connection_compatible; parent_class->check_connection_compatible = check_connection_compatible;
@@ -511,10 +527,6 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *klass)
parent_class->enslave_slave = enslave_slave; parent_class->enslave_slave = enslave_slave;
parent_class->release_slave = release_slave; parent_class->release_slave = release_slave;
parent_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired; parent_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_BRIDGE_SKELETON,
NULL);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@@ -28,8 +28,6 @@
#include "nm-setting-dummy.h" #include "nm-setting-dummy.h"
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Dummy.h"
#include "nm-device-logging.h" #include "nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceDummy); _LOG_DECLARE_SELF(NMDeviceDummy);
@@ -156,13 +154,29 @@ nm_device_dummy_init (NMDeviceDummy *self)
{ {
} }
static const NMDBusInterfaceInfoExtended interface_info_device_dummy = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_DUMMY,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("HwAddress", "s", NM_DEVICE_HW_ADDRESS),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_dummy_class_init (NMDeviceDummyClass *klass) nm_device_dummy_class_init (NMDeviceDummyClass *klass)
{ {
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_DUMMY) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_DUMMY)
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_dummy);
device_class->connection_type = NM_SETTING_DUMMY_SETTING_NAME; device_class->connection_type = NM_SETTING_DUMMY_SETTING_NAME;
device_class->complete_connection = complete_connection; device_class->complete_connection = complete_connection;
device_class->check_connection_compatible = check_connection_compatible; device_class->check_connection_compatible = check_connection_compatible;
@@ -171,10 +185,6 @@ nm_device_dummy_class_init (NMDeviceDummyClass *klass)
device_class->update_connection = update_connection; device_class->update_connection = update_connection;
device_class->act_stage1_prepare = act_stage1_prepare; device_class->act_stage1_prepare = act_stage1_prepare;
device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired; device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_DUMMY_SKELETON,
NULL);
} }

View File

@@ -28,7 +28,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <libudev.h> #include <libudev.h>
#include "nm-device-private.h" #include "nm-device-private.h"
@@ -52,8 +51,6 @@
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "NetworkManagerUtils.h" #include "NetworkManagerUtils.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Wired.h"
#include "nm-device-logging.h" #include "nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceEthernet); _LOG_DECLARE_SELF(NMDeviceEthernet);
@@ -1714,10 +1711,28 @@ set_property (GObject *object, guint prop_id,
} }
} }
static const NMDBusInterfaceInfoExtended interface_info_device_wired = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_WIRED,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("HwAddress", "s", NM_DEVICE_HW_ADDRESS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("PermHwAddress", "s", NM_DEVICE_PERM_HW_ADDRESS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Speed", "u", NM_DEVICE_ETHERNET_SPEED),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("S390Subchannels", "as", NM_DEVICE_ETHERNET_S390_SUBCHANNELS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Carrier", "b", NM_DEVICE_CARRIER),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_ethernet_class_init (NMDeviceEthernetClass *klass) nm_device_ethernet_class_init (NMDeviceEthernetClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass);
g_type_class_add_private (object_class, sizeof (NMDeviceEthernetPrivate)); g_type_class_add_private (object_class, sizeof (NMDeviceEthernetPrivate));
@@ -1729,6 +1744,8 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass)
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property; object_class->set_property = set_property;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_wired);
parent_class->get_generic_capabilities = get_generic_capabilities; parent_class->get_generic_capabilities = get_generic_capabilities;
parent_class->check_connection_compatible = check_connection_compatible; parent_class->check_connection_compatible = check_connection_compatible;
parent_class->complete_connection = complete_connection; parent_class->complete_connection = complete_connection;
@@ -1762,10 +1779,6 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass)
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_ETHERNET_SKELETON,
NULL);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@@ -26,8 +26,6 @@
#include "platform/nm-platform.h" #include "platform/nm-platform.h"
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Generic.h"
/*****************************************************************************/ /*****************************************************************************/
NM_GOBJECT_PROPERTIES_DEFINE_BASE ( NM_GOBJECT_PROPERTIES_DEFINE_BASE (
@@ -203,10 +201,25 @@ dispose (GObject *object)
G_OBJECT_CLASS (nm_device_generic_parent_class)->dispose (object); G_OBJECT_CLASS (nm_device_generic_parent_class)->dispose (object);
} }
static const NMDBusInterfaceInfoExtended interface_info_device_generic = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_GENERIC,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("HwAddress", "s", NM_DEVICE_HW_ADDRESS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("TypeDescription", "s", NM_DEVICE_GENERIC_TYPE_DESCRIPTION),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_generic_class_init (NMDeviceGenericClass *klass) nm_device_generic_class_init (NMDeviceGenericClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_GENERIC_SETTING_NAME, NM_LINK_TYPE_ANY) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_GENERIC_SETTING_NAME, NM_LINK_TYPE_ANY)
@@ -216,6 +229,8 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass)
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property; object_class->set_property = set_property;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_generic);
parent_class->realize_start_notify = realize_start_notify; parent_class->realize_start_notify = realize_start_notify;
parent_class->get_generic_capabilities = get_generic_capabilities; parent_class->get_generic_capabilities = get_generic_capabilities;
parent_class->get_type_description = get_type_description; parent_class->get_type_description = get_type_description;
@@ -229,8 +244,4 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass)
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_GENERIC_SKELETON,
NULL);
} }

View File

@@ -32,8 +32,6 @@
#include "nm-device-factory.h" #include "nm-device-factory.h"
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Infiniband.h"
#define NM_DEVICE_INFINIBAND_IS_PARTITION "is-partition" #define NM_DEVICE_INFINIBAND_IS_PARTITION "is-partition"
/*****************************************************************************/ /*****************************************************************************/
@@ -368,10 +366,25 @@ nm_device_infiniband_init (NMDeviceInfiniband * self)
{ {
} }
static const NMDBusInterfaceInfoExtended interface_info_device_infiniband = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_INFINIBAND,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("HwAddress", "s", NM_DEVICE_HW_ADDRESS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Carrier", "b", NM_DEVICE_CARRIER),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass) nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_INFINIBAND_SETTING_NAME, NM_LINK_TYPE_INFINIBAND) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_INFINIBAND_SETTING_NAME, NM_LINK_TYPE_INFINIBAND)
@@ -379,6 +392,8 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass)
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property; object_class->set_property = set_property;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_infiniband);
parent_class->create_and_realize = create_and_realize; parent_class->create_and_realize = create_and_realize;
parent_class->unrealize = unrealize; parent_class->unrealize = unrealize;
parent_class->get_generic_capabilities = get_generic_capabilities; parent_class->get_generic_capabilities = get_generic_capabilities;
@@ -396,10 +411,6 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass)
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_INFINIBAND_SKELETON,
NULL);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@@ -37,8 +37,6 @@
#include "nm-act-request.h" #include "nm-act-request.h"
#include "nm-ip4-config.h" #include "nm-ip4-config.h"
#include "introspection/org.freedesktop.NetworkManager.Device.IPTunnel.h"
#include "nm-device-logging.h" #include "nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceIPTunnel); _LOG_DECLARE_SELF(NMDeviceIPTunnel);
@@ -907,10 +905,35 @@ dispose (GObject *object)
G_OBJECT_CLASS (nm_device_ip_tunnel_parent_class)->dispose (object); G_OBJECT_CLASS (nm_device_ip_tunnel_parent_class)->dispose (object);
} }
static const NMDBusInterfaceInfoExtended interface_info_device_ip_tunnel = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_IP_TUNNEL,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Mode", "u", NM_DEVICE_IP_TUNNEL_MODE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Parent", "o", NM_DEVICE_PARENT),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Local", "s", NM_DEVICE_IP_TUNNEL_LOCAL),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Remote", "s", NM_DEVICE_IP_TUNNEL_REMOTE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Ttl", "y", NM_DEVICE_IP_TUNNEL_TTL),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Tos", "y", NM_DEVICE_IP_TUNNEL_TOS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("PathMtuDiscovery", "b", NM_DEVICE_IP_TUNNEL_PATH_MTU_DISCOVERY),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("InputKey", "s", NM_DEVICE_IP_TUNNEL_INPUT_KEY),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("OutputKey", "s", NM_DEVICE_IP_TUNNEL_OUTPUT_KEY),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("EncapsulationLimit", "y", NM_DEVICE_IP_TUNNEL_ENCAPSULATION_LIMIT),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("FlowLabel", "u", NM_DEVICE_IP_TUNNEL_FLOW_LABEL),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Flags", "u", NM_DEVICE_IP_TUNNEL_FLAGS),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass) nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
object_class->constructed = constructed; object_class->constructed = constructed;
@@ -918,6 +941,8 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass)
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property; object_class->set_property = set_property;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_ip_tunnel);
device_class->link_changed = link_changed; device_class->link_changed = link_changed;
device_class->can_reapply_change = can_reapply_change; device_class->can_reapply_change = can_reapply_change;
device_class->complete_connection = complete_connection; device_class->complete_connection = complete_connection;
@@ -1003,10 +1028,6 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass)
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_IPTUNNEL_SKELETON,
NULL);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@@ -43,9 +43,6 @@
#define NM_DEVICE_IP_TUNNEL_FLOW_LABEL "flow-label" #define NM_DEVICE_IP_TUNNEL_FLOW_LABEL "flow-label"
#define NM_DEVICE_IP_TUNNEL_FLAGS "flags" #define NM_DEVICE_IP_TUNNEL_FLAGS "flags"
/* defined in the parent class, but exposed on D-Bus by the subclass. */
#define NM_DEVICE_IP_TUNNEL_PARENT NM_DEVICE_PARENT
typedef struct _NMDeviceIPTunnel NMDeviceIPTunnel; typedef struct _NMDeviceIPTunnel NMDeviceIPTunnel;
typedef struct _NMDeviceIPTunnelClass NMDeviceIPTunnelClass; typedef struct _NMDeviceIPTunnelClass NMDeviceIPTunnelClass;

View File

@@ -33,8 +33,6 @@
#include "supplicant/nm-supplicant-interface.h" #include "supplicant/nm-supplicant-interface.h"
#include "supplicant/nm-supplicant-config.h" #include "supplicant/nm-supplicant-config.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Macsec.h"
#include "nm-device-logging.h" #include "nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceMacsec); _LOG_DECLARE_SELF(NMDeviceMacsec);
@@ -812,10 +810,36 @@ dispose (GObject *object)
G_OBJECT_CLASS (nm_device_macsec_parent_class)->dispose (object); G_OBJECT_CLASS (nm_device_macsec_parent_class)->dispose (object);
} }
static const NMDBusInterfaceInfoExtended interface_info_device_macsec = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_MACSEC,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Parent", "o", NM_DEVICE_PARENT),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Sci", "t", NM_DEVICE_MACSEC_SCI),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("IcvLength", "y", NM_DEVICE_MACSEC_ICV_LENGTH),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("CipherSuite", "t", NM_DEVICE_MACSEC_CIPHER_SUITE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Window", "u", NM_DEVICE_MACSEC_WINDOW),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("EncodingSa", "y", NM_DEVICE_MACSEC_ENCODING_SA),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Validation", "s", NM_DEVICE_MACSEC_VALIDATION),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Encrypt", "b", NM_DEVICE_MACSEC_ENCRYPT),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Protect", "b", NM_DEVICE_MACSEC_PROTECT),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("IncludeSci", "b", NM_DEVICE_MACSEC_INCLUDE_SCI),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Es", "b", NM_DEVICE_MACSEC_ES),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Scb", "b", NM_DEVICE_MACSEC_SCB),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("ReplayProtect", "b", NM_DEVICE_MACSEC_REPLAY_PROTECT),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_macsec_class_init (NMDeviceMacsecClass *klass) nm_device_macsec_class_init (NMDeviceMacsecClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_MACSEC) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_MACSEC)
@@ -823,6 +847,8 @@ nm_device_macsec_class_init (NMDeviceMacsecClass *klass)
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->dispose = dispose; object_class->dispose = dispose;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_macsec);
parent_class->act_stage2_config = act_stage2_config; parent_class->act_stage2_config = act_stage2_config;
parent_class->check_connection_compatible = check_connection_compatible; parent_class->check_connection_compatible = check_connection_compatible;
parent_class->create_and_realize = create_and_realize; parent_class->create_and_realize = create_and_realize;
@@ -886,10 +912,6 @@ nm_device_macsec_class_init (NMDeviceMacsecClass *klass)
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_MACSEC_SKELETON,
NULL);
} }
/*************************************************************/ /*************************************************************/

View File

@@ -43,9 +43,6 @@
#define NM_DEVICE_MACSEC_SCB "scb" #define NM_DEVICE_MACSEC_SCB "scb"
#define NM_DEVICE_MACSEC_REPLAY_PROTECT "replay-protect" #define NM_DEVICE_MACSEC_REPLAY_PROTECT "replay-protect"
/* defined in the parent class, but exposed on D-Bus by the subclass. */
#define NM_DEVICE_MACSEC_PARENT NM_DEVICE_PARENT
typedef struct _NMDeviceMacsec NMDeviceMacsec; typedef struct _NMDeviceMacsec NMDeviceMacsec;
typedef struct _NMDeviceMacsecClass NMDeviceMacsecClass; typedef struct _NMDeviceMacsecClass NMDeviceMacsecClass;

View File

@@ -36,8 +36,6 @@
#include "nm-ip4-config.h" #include "nm-ip4-config.h"
#include "nm-utils.h" #include "nm-utils.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Macvlan.h"
#include "nm-device-logging.h" #include "nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceMacvlan); _LOG_DECLARE_SELF(NMDeviceMacvlan);
@@ -475,10 +473,27 @@ nm_device_macvlan_init (NMDeviceMacvlan *self)
{ {
} }
static const NMDBusInterfaceInfoExtended interface_info_device_macvlan = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_MACVLAN,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Parent", "o", NM_DEVICE_PARENT),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Mode", "s", NM_DEVICE_MACVLAN_MODE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("NoPromisc", "b", NM_DEVICE_MACVLAN_NO_PROMISC),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Tab", "b", NM_DEVICE_MACVLAN_TAP),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass) nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_MACVLAN, NM_LINK_TYPE_MACVTAP) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_MACVLAN, NM_LINK_TYPE_MACVTAP)
@@ -486,6 +501,8 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property; object_class->set_property = set_property;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_macvlan);
device_class->act_stage1_prepare = act_stage1_prepare; device_class->act_stage1_prepare = act_stage1_prepare;
device_class->check_connection_compatible = check_connection_compatible; device_class->check_connection_compatible = check_connection_compatible;
device_class->complete_connection = complete_connection; device_class->complete_connection = complete_connection;
@@ -518,10 +535,6 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_MACVLAN_SKELETON,
NULL);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@@ -34,9 +34,6 @@
#define NM_DEVICE_MACVLAN_NO_PROMISC "no-promisc" #define NM_DEVICE_MACVLAN_NO_PROMISC "no-promisc"
#define NM_DEVICE_MACVLAN_TAP "tap" #define NM_DEVICE_MACVLAN_TAP "tap"
/* defined in the parent class, but exposed on D-Bus by the subclass. */
#define NM_DEVICE_MACVLAN_PARENT NM_DEVICE_PARENT
typedef struct _NMDeviceMacvlan NMDeviceMacvlan; typedef struct _NMDeviceMacvlan NMDeviceMacvlan;
typedef struct _NMDeviceMacvlanClass NMDeviceMacvlanClass; typedef struct _NMDeviceMacvlanClass NMDeviceMacvlanClass;

View File

@@ -26,8 +26,6 @@
#include "ppp/nm-ppp-manager-call.h" #include "ppp/nm-ppp-manager-call.h"
#include "ppp/nm-ppp-status.h" #include "ppp/nm-ppp-status.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Ppp.h"
#include "nm-device-logging.h" #include "nm-device-logging.h"
_LOG_DECLARE_SELF(NMDevicePpp); _LOG_DECLARE_SELF(NMDevicePpp);
@@ -262,26 +260,35 @@ dispose (GObject *object)
G_OBJECT_CLASS (nm_device_ppp_parent_class)->dispose (object); G_OBJECT_CLASS (nm_device_ppp_parent_class)->dispose (object);
} }
static const NMDBusInterfaceInfoExtended interface_info_device_ppp = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_PPP,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_ppp_class_init (NMDevicePppClass *klass) nm_device_ppp_class_init (NMDevicePppClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_PPPOE_SETTING_NAME, NM_LINK_TYPE_PPP) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_PPPOE_SETTING_NAME, NM_LINK_TYPE_PPP)
object_class->dispose = dispose; object_class->dispose = dispose;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_ppp);
parent_class->act_stage2_config = act_stage2_config; parent_class->act_stage2_config = act_stage2_config;
parent_class->act_stage3_ip4_config_start = act_stage3_ip4_config_start; parent_class->act_stage3_ip4_config_start = act_stage3_ip4_config_start;
parent_class->check_connection_compatible = check_connection_compatible; parent_class->check_connection_compatible = check_connection_compatible;
parent_class->create_and_realize = create_and_realize; parent_class->create_and_realize = create_and_realize;
parent_class->deactivate = deactivate; parent_class->deactivate = deactivate;
parent_class->get_generic_capabilities = get_generic_capabilities; parent_class->get_generic_capabilities = get_generic_capabilities;
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_PPP_SKELETON,
NULL);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@@ -34,8 +34,6 @@
#include "nm-setting-tun.h" #include "nm-setting-tun.h"
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Tun.h"
#include "nm-device-logging.h" #include "nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceTun); _LOG_DECLARE_SELF(NMDeviceTun);
@@ -395,10 +393,30 @@ nm_device_tun_init (NMDeviceTun *self)
{ {
} }
static const NMDBusInterfaceInfoExtended interface_info_device_tun = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_TUN,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Owner", "x", NM_DEVICE_TUN_OWNER),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Group", "x", NM_DEVICE_TUN_GROUP),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Mode", "s", NM_DEVICE_TUN_MODE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("NoPi", "b", NM_DEVICE_TUN_NO_PI),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("VnetHdr", "b", NM_DEVICE_TUN_VNET_HDR),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("MultiQueue", "b", NM_DEVICE_TUN_MULTI_QUEUE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("HwAddress", "s", NM_DEVICE_HW_ADDRESS),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_tun_class_init (NMDeviceTunClass *klass) nm_device_tun_class_init (NMDeviceTunClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_TUN, NM_LINK_TYPE_TAP) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_TUN, NM_LINK_TYPE_TAP)
@@ -406,6 +424,8 @@ nm_device_tun_class_init (NMDeviceTunClass *klass)
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property; object_class->set_property = set_property;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_tun);
device_class->connection_type = NM_SETTING_TUN_SETTING_NAME; device_class->connection_type = NM_SETTING_TUN_SETTING_NAME;
device_class->link_changed = link_changed; device_class->link_changed = link_changed;
device_class->complete_connection = complete_connection; device_class->complete_connection = complete_connection;
@@ -449,10 +469,6 @@ nm_device_tun_class_init (NMDeviceTunClass *klass)
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_TUN_SKELETON,
NULL);
} }

View File

@@ -30,8 +30,6 @@
#include "platform/nm-platform.h" #include "platform/nm-platform.h"
#include "nm-device-factory.h" #include "nm-device-factory.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Veth.h"
#include "nm-device-logging.h" #include "nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceVeth); _LOG_DECLARE_SELF(NMDeviceVeth);
@@ -127,7 +125,7 @@ get_property (GObject *object, guint prop_id,
peer = nm_device_parent_get_device (NM_DEVICE (self)); peer = nm_device_parent_get_device (NM_DEVICE (self));
if (peer && !NM_IS_DEVICE_VETH (peer)) if (peer && !NM_IS_DEVICE_VETH (peer))
peer = NULL; peer = NULL;
nm_utils_g_value_set_object_path (value, peer); nm_dbus_utils_g_value_set_object_path (value, peer);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -135,16 +133,32 @@ get_property (GObject *object, guint prop_id,
} }
} }
static const NMDBusInterfaceInfoExtended interface_info_device_veth = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_VETH,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Peer", "o", NM_DEVICE_VETH_PEER),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_veth_class_init (NMDeviceVethClass *klass) nm_device_veth_class_init (NMDeviceVethClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_VETH) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_VETH)
object_class->get_property = get_property; object_class->get_property = get_property;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_veth);
device_class->can_unmanaged_external_down = can_unmanaged_external_down; device_class->can_unmanaged_external_down = can_unmanaged_external_down;
device_class->link_changed = link_changed; device_class->link_changed = link_changed;
device_class->parent_changed_notify = parent_changed_notify; device_class->parent_changed_notify = parent_changed_notify;
@@ -156,10 +170,6 @@ nm_device_veth_class_init (NMDeviceVethClass *klass)
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_VETH_SKELETON,
NULL);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@@ -37,8 +37,6 @@
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "platform/nmp-object.h" #include "platform/nmp-object.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Vlan.h"
#include "nm-device-logging.h" #include "nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceVlan); _LOG_DECLARE_SELF(NMDeviceVlan);
@@ -577,16 +575,35 @@ nm_device_vlan_init (NMDeviceVlan * self)
{ {
} }
static const NMDBusInterfaceInfoExtended interface_info_device_vlan = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_VLAN,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("HwAddress", "s", NM_DEVICE_HW_ADDRESS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Carrier", "b", NM_DEVICE_CARRIER),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Parent", "o", NM_DEVICE_PARENT),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("VlanId", "u", NM_DEVICE_VLAN_ID),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_vlan_class_init (NMDeviceVlanClass *klass) nm_device_vlan_class_init (NMDeviceVlanClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_VLAN_SETTING_NAME, NM_LINK_TYPE_VLAN) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_VLAN_SETTING_NAME, NM_LINK_TYPE_VLAN)
object_class->get_property = get_property; object_class->get_property = get_property;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_vlan);
parent_class->create_and_realize = create_and_realize; parent_class->create_and_realize = create_and_realize;
parent_class->link_changed = link_changed; parent_class->link_changed = link_changed;
parent_class->unrealize_notify = unrealize_notify; parent_class->unrealize_notify = unrealize_notify;
@@ -608,10 +625,6 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
| G_PARAM_STATIC_STRINGS); | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_VLAN_SKELETON,
NULL);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@@ -36,12 +36,8 @@ typedef enum {
NM_VLAN_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/ NM_VLAN_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/
} NMVlanError; } NMVlanError;
/* D-Bus exported properties */
#define NM_DEVICE_VLAN_ID "vlan-id" #define NM_DEVICE_VLAN_ID "vlan-id"
/* defined in the parent class, but exposed on D-Bus by the subclass. */
#define NM_DEVICE_VLAN_PARENT NM_DEVICE_PARENT
typedef struct _NMDeviceVlan NMDeviceVlan; typedef struct _NMDeviceVlan NMDeviceVlan;
typedef struct _NMDeviceVlanClass NMDeviceVlanClass; typedef struct _NMDeviceVlanClass NMDeviceVlanClass;

View File

@@ -35,8 +35,6 @@
#include "nm-act-request.h" #include "nm-act-request.h"
#include "nm-ip4-config.h" #include "nm-ip4-config.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Vxlan.h"
#include "nm-device-logging.h" #include "nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceVxlan); _LOG_DECLARE_SELF(NMDeviceVxlan);
@@ -543,16 +541,48 @@ nm_device_vxlan_init (NMDeviceVxlan *self)
{ {
} }
static const NMDBusInterfaceInfoExtended interface_info_device_vxlan = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_VXLAN,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Parent", "o", NM_DEVICE_PARENT),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("HwAddress", "s", NM_DEVICE_HW_ADDRESS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Id", "u", NM_DEVICE_VXLAN_ID),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Group", "s", NM_DEVICE_VXLAN_GROUP),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Local", "s", NM_DEVICE_VXLAN_LOCAL),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Tos", "y", NM_DEVICE_VXLAN_TOS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Ttl", "y", NM_DEVICE_VXLAN_TTL),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Learning", "b", NM_DEVICE_VXLAN_LEARNING),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Ageing", "u", NM_DEVICE_VXLAN_AGEING),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Limit", "u", NM_DEVICE_VXLAN_LIMIT),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("DstPort", "q", NM_DEVICE_VXLAN_DST_PORT),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("SrcPortMin", "q", NM_DEVICE_VXLAN_SRC_PORT_MIN),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("SrcPortMax", "q", NM_DEVICE_VXLAN_SRC_PORT_MAX),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Proxy", "b", NM_DEVICE_VXLAN_PROXY),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Rsc", "b", NM_DEVICE_VXLAN_RSC),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("L2miss", "b", NM_DEVICE_VXLAN_L2MISS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("L3miss", "b", NM_DEVICE_VXLAN_L3MISS),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_vxlan_class_init (NMDeviceVxlanClass *klass) nm_device_vxlan_class_init (NMDeviceVxlanClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_VXLAN) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_VXLAN)
object_class->get_property = get_property; object_class->get_property = get_property;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_vxlan);
device_class->link_changed = link_changed; device_class->link_changed = link_changed;
device_class->unrealize_notify = unrealize_notify; device_class->unrealize_notify = unrealize_notify;
device_class->connection_type = NM_SETTING_VXLAN_SETTING_NAME; device_class->connection_type = NM_SETTING_VXLAN_SETTING_NAME;
@@ -655,10 +685,6 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass)
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_VXLAN_SKELETON,
NULL);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@@ -46,9 +46,6 @@
#define NM_DEVICE_VXLAN_L2MISS "l2miss" #define NM_DEVICE_VXLAN_L2MISS "l2miss"
#define NM_DEVICE_VXLAN_L3MISS "l3miss" #define NM_DEVICE_VXLAN_L3MISS "l3miss"
/* defined in the parent class, but exposed on D-Bus by the subclass. */
#define NM_DEVICE_VXLAN_PARENT NM_DEVICE_PARENT
typedef struct _NMDeviceVxlan NMDeviceVxlan; typedef struct _NMDeviceVxlan NMDeviceVxlan;
typedef struct _NMDeviceVxlanClass NMDeviceVxlanClass; typedef struct _NMDeviceVxlanClass NMDeviceVxlanClass;

View File

@@ -80,9 +80,6 @@
#include "nm-device-logging.h" #include "nm-device-logging.h"
_LOG_DECLARE_SELF (NMDevice); _LOG_DECLARE_SELF (NMDevice);
#include "introspection/org.freedesktop.NetworkManager.Device.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Statistics.h"
/*****************************************************************************/ /*****************************************************************************/
#define DHCP_RESTART_TIMEOUT 120 #define DHCP_RESTART_TIMEOUT 120
@@ -506,12 +503,15 @@ typedef struct _NMDevicePrivate {
} NMDevicePrivate; } NMDevicePrivate;
G_DEFINE_ABSTRACT_TYPE (NMDevice, nm_device, NM_TYPE_EXPORTED_OBJECT) G_DEFINE_ABSTRACT_TYPE (NMDevice, nm_device, NM_TYPE_DBUS_OBJECT)
#define NM_DEVICE_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR(self, NMDevice, NM_IS_DEVICE) #define NM_DEVICE_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR(self, NMDevice, NM_IS_DEVICE)
/*****************************************************************************/ /*****************************************************************************/
static const NMDBusInterfaceInfoExtended interface_info_device;
static const GDBusSignalInfo signal_info_state_changed;
static void nm_device_set_proxy_config (NMDevice *self, const char *pac_url); static void nm_device_set_proxy_config (NMDevice *self, const char *pac_url);
static gboolean update_ext_ip_config (NMDevice *self, int addr_family, gboolean initial, gboolean intersect_configs); static gboolean update_ext_ip_config (NMDevice *self, int addr_family, gboolean initial, gboolean intersect_configs);
@@ -6067,7 +6067,7 @@ dhcp4_cleanup (NMDevice *self, CleanupType cleanup_type, gboolean release)
} }
if (priv->dhcp4.config) { if (priv->dhcp4.config) {
nm_exported_object_clear_and_unexport (&priv->dhcp4.config); nm_dbus_object_clear_and_unexport (&priv->dhcp4.config);
_notify (self, PROP_DHCP4_CONFIG); _notify (self, PROP_DHCP4_CONFIG);
} }
} }
@@ -6493,7 +6493,7 @@ dhcp4_start (NMDevice *self)
s_ip4 = nm_connection_get_setting_ip4_config (connection); s_ip4 = nm_connection_get_setting_ip4_config (connection);
/* Clear old exported DHCP options */ /* Clear old exported DHCP options */
nm_exported_object_clear_and_unexport (&priv->dhcp4.config); nm_dbus_object_clear_and_unexport (&priv->dhcp4.config);
priv->dhcp4.config = nm_dhcp4_config_new (); priv->dhcp4.config = nm_dhcp4_config_new ();
hwaddr = nm_platform_link_get_address_as_bytes (nm_device_get_platform (self), hwaddr = nm_platform_link_get_address_as_bytes (nm_device_get_platform (self),
@@ -6831,7 +6831,7 @@ dhcp6_cleanup (NMDevice *self, CleanupType cleanup_type, gboolean release)
nm_device_remove_pending_action (self, NM_PENDING_ACTION_DHCP6, FALSE); nm_device_remove_pending_action (self, NM_PENDING_ACTION_DHCP6, FALSE);
if (priv->dhcp6.config) { if (priv->dhcp6.config) {
nm_exported_object_clear_and_unexport (&priv->dhcp6.config); nm_dbus_object_clear_and_unexport (&priv->dhcp6.config);
_notify (self, PROP_DHCP6_CONFIG); _notify (self, PROP_DHCP6_CONFIG);
} }
} }
@@ -7281,7 +7281,7 @@ dhcp6_start (NMDevice *self, gboolean wait_for_ll)
NMConnection *connection; NMConnection *connection;
NMSettingIPConfig *s_ip6; NMSettingIPConfig *s_ip6;
nm_exported_object_clear_and_unexport (&priv->dhcp6.config); nm_dbus_object_clear_and_unexport (&priv->dhcp6.config);
priv->dhcp6.config = nm_dhcp6_config_new (); priv->dhcp6.config = nm_dhcp6_config_new ();
nm_assert (!applied_config_get_current (&priv->dhcp6.ip6_config)); nm_assert (!applied_config_get_current (&priv->dhcp6.ip6_config));
@@ -9256,7 +9256,7 @@ act_request_set (NMDevice *self, NMActRequest *act_request)
if (act_request) { if (act_request) {
priv->act_request_id = g_signal_connect (act_request, priv->act_request_id = g_signal_connect (act_request,
"notify::"NM_EXPORTED_OBJECT_PATH, "notify::"NM_DBUS_OBJECT_PATH,
G_CALLBACK (act_request_set_cb), G_CALLBACK (act_request_set_cb),
self); self);
@@ -9887,25 +9887,33 @@ reapply_cb (NMDevice *self,
} }
static void static void
impl_device_reapply (NMDevice *self, impl_device_reapply (NMDBusObject *obj,
GDBusMethodInvocation *context, const NMDBusInterfaceInfoExtended *interface_info,
GVariant *settings, const NMDBusMethodInfoExtended *method_info,
guint64 version_id, GDBusConnection *dbus_connection,
guint32 flags) const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
NMDevice *self = NM_DEVICE (obj);
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMSettingsConnection *settings_connection; NMSettingsConnection *settings_connection;
NMConnection *connection = NULL; NMConnection *connection = NULL;
GError *error = NULL; GError *error = NULL;
ReapplyData *reapply_data; ReapplyData *reapply_data;
gs_unref_variant GVariant *settings = NULL;
guint64 version_id;
guint32 flags;
g_variant_get (parameters, "(@a{sa{sv}}tu)", &settings, &version_id, &flags);
/* No flags supported as of now. */ /* No flags supported as of now. */
if (flags != 0) { if (flags != 0) {
error = g_error_new_literal (NM_DEVICE_ERROR, error = g_error_new_literal (NM_DEVICE_ERROR,
NM_DEVICE_ERROR_FAILED, NM_DEVICE_ERROR_FAILED,
"Invalid flags specified"); "Invalid flags specified");
nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_REAPPLY, self, FALSE, NULL, context, error->message); nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_REAPPLY, self, FALSE, NULL, invocation, error->message);
g_dbus_method_invocation_take_error (context, error); g_dbus_method_invocation_take_error (invocation, error);
return; return;
} }
@@ -9913,8 +9921,8 @@ impl_device_reapply (NMDevice *self,
error = g_error_new_literal (NM_DEVICE_ERROR, error = g_error_new_literal (NM_DEVICE_ERROR,
NM_DEVICE_ERROR_NOT_ACTIVE, NM_DEVICE_ERROR_NOT_ACTIVE,
"Device is not activated"); "Device is not activated");
nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_REAPPLY, self, FALSE, NULL, context, error->message); nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_REAPPLY, self, FALSE, NULL, invocation, error->message);
g_dbus_method_invocation_take_error (context, error); g_dbus_method_invocation_take_error (invocation, error);
return; return;
} }
@@ -9929,8 +9937,8 @@ impl_device_reapply (NMDevice *self,
&error); &error);
if (!connection) { if (!connection) {
g_prefix_error (&error, "The settings specified are invalid: "); g_prefix_error (&error, "The settings specified are invalid: ");
nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_REAPPLY, self, FALSE, NULL, context, error->message); nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_REAPPLY, self, FALSE, NULL, invocation, error->message);
g_dbus_method_invocation_take_error (context, error); g_dbus_method_invocation_take_error (invocation, error);
return; return;
} }
nm_connection_clear_secrets (connection); nm_connection_clear_secrets (connection);
@@ -9943,9 +9951,8 @@ impl_device_reapply (NMDevice *self,
} else } else
reapply_data = NULL; reapply_data = NULL;
/* Ask the manager to authenticate this request for us */
g_signal_emit (self, signals[AUTH_REQUEST], 0, g_signal_emit (self, signals[AUTH_REQUEST], 0,
context, invocation,
nm_device_get_applied_connection (self), nm_device_get_applied_connection (self),
NM_AUTH_PERMISSION_NETWORK_CONTROL, NM_AUTH_PERMISSION_NETWORK_CONTROL,
TRUE, TRUE,
@@ -10008,36 +10015,40 @@ get_applied_connection_cb (NMDevice *self,
} }
static void static void
impl_device_get_applied_connection (NMDevice *self, impl_device_get_applied_connection (NMDBusObject *obj,
GDBusMethodInvocation *context, const NMDBusInterfaceInfoExtended *interface_info,
guint32 flags) const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
NMDevice *self = NM_DEVICE (obj);
NMConnection *applied_connection; NMConnection *applied_connection;
GError *error = NULL; guint32 flags;
g_return_if_fail (NM_IS_DEVICE (self)); g_variant_get (parameters, "(u)", &flags);
/* No flags supported as of now. */ /* No flags supported as of now. */
if (flags != 0) { if (flags != 0) {
error = g_error_new_literal (NM_DEVICE_ERROR, g_dbus_method_invocation_return_error_literal (invocation,
NM_DEVICE_ERROR_FAILED, NM_DEVICE_ERROR,
"Invalid flags specified"); NM_DEVICE_ERROR_FAILED,
g_dbus_method_invocation_take_error (context, error); "Invalid flags specified");
return; return;
} }
applied_connection = nm_device_get_applied_connection (self); applied_connection = nm_device_get_applied_connection (self);
if (!applied_connection) { if (!applied_connection) {
error = g_error_new_literal (NM_DEVICE_ERROR, g_dbus_method_invocation_return_error_literal (invocation,
NM_DEVICE_ERROR_NOT_ACTIVE, NM_DEVICE_ERROR,
"Device is not activated"); NM_DEVICE_ERROR_NOT_ACTIVE,
g_dbus_method_invocation_take_error (context, error); "Device is not activated");
return; return;
} }
/* Ask the manager to authenticate this request for us */
g_signal_emit (self, signals[AUTH_REQUEST], 0, g_signal_emit (self, signals[AUTH_REQUEST], 0,
context, invocation,
applied_connection, applied_connection,
NM_AUTH_PERMISSION_NETWORK_CONTROL, NM_AUTH_PERMISSION_NETWORK_CONTROL,
TRUE, TRUE,
@@ -10186,25 +10197,31 @@ _clear_queued_act_request (NMDevicePrivate *priv)
} }
static void static void
impl_device_disconnect (NMDevice *self, GDBusMethodInvocation *context) impl_device_disconnect (NMDBusObject *obj,
const NMDBusInterfaceInfoExtended *interface_info,
const NMDBusMethodInfoExtended *method_info,
GDBusConnection *dbus_connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
NMDevice *self = NM_DEVICE (obj);
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMConnection *connection; NMConnection *connection;
GError *error = NULL;
if (NM_DEVICE_GET_PRIVATE (self)->act_request == NULL) { if (!priv->act_request) {
error = g_error_new_literal (NM_DEVICE_ERROR, g_dbus_method_invocation_return_error_literal (invocation,
NM_DEVICE_ERROR_NOT_ACTIVE, NM_DEVICE_ERROR,
"This device is not active"); NM_DEVICE_ERROR_NOT_ACTIVE,
g_dbus_method_invocation_take_error (context, error); "This device is not active");
return; return;
} }
connection = nm_device_get_applied_connection (self); connection = nm_device_get_applied_connection (self);
g_assert (connection); nm_assert (connection);
/* Ask the manager to authenticate this request for us */
g_signal_emit (self, signals[AUTH_REQUEST], 0, g_signal_emit (self, signals[AUTH_REQUEST], 0,
context, invocation,
connection, connection,
NM_AUTH_PERMISSION_NETWORK_CONTROL, NM_AUTH_PERMISSION_NETWORK_CONTROL,
TRUE, TRUE,
@@ -10236,21 +10253,27 @@ delete_cb (NMDevice *self,
} }
static void static void
impl_device_delete (NMDevice *self, GDBusMethodInvocation *context) impl_device_delete (NMDBusObject *obj,
const NMDBusInterfaceInfoExtended *interface_info,
const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
GError *error = NULL; NMDevice *self = NM_DEVICE (obj);
if (!nm_device_is_software (self) || !nm_device_is_real (self)) { if ( !nm_device_is_software (self)
error = g_error_new_literal (NM_DEVICE_ERROR, || !nm_device_is_real (self)) {
NM_DEVICE_ERROR_NOT_SOFTWARE, g_dbus_method_invocation_return_error_literal (invocation,
"This device is not a software device or is not realized"); NM_DEVICE_ERROR,
g_dbus_method_invocation_take_error (context, error); NM_DEVICE_ERROR_NOT_SOFTWARE,
"This device is not a software device or is not realized");
return; return;
} }
/* Ask the manager to authenticate this request for us */
g_signal_emit (self, signals[AUTH_REQUEST], 0, g_signal_emit (self, signals[AUTH_REQUEST], 0,
context, invocation,
NULL, NULL,
NM_AUTH_PERMISSION_NETWORK_CONTROL, NM_AUTH_PERMISSION_NETWORK_CONTROL,
TRUE, TRUE,
@@ -10544,23 +10567,23 @@ nm_device_set_ip4_config (NMDevice *self,
nm_ip4_config_replace (old_config, new_config, &has_changes); nm_ip4_config_replace (old_config, new_config, &has_changes);
if (has_changes) { if (has_changes) {
_LOGD (LOGD_IP4, "ip4-config: update IP4Config instance (%s)", _LOGD (LOGD_IP4, "ip4-config: update IP4Config instance (%s)",
nm_exported_object_get_path (NM_EXPORTED_OBJECT (old_config))); nm_dbus_object_get_path (NM_DBUS_OBJECT (old_config)));
} }
} else { } else {
has_changes = TRUE; has_changes = TRUE;
priv->ip4_config = g_object_ref (new_config); priv->ip4_config = g_object_ref (new_config);
if (success && !nm_exported_object_is_exported (NM_EXPORTED_OBJECT (new_config))) if (success && !nm_dbus_object_is_exported (NM_DBUS_OBJECT (new_config)))
nm_exported_object_export (NM_EXPORTED_OBJECT (new_config)); nm_dbus_object_export (NM_DBUS_OBJECT (new_config));
_LOGD (LOGD_IP4, "ip4-config: set IP4Config instance (%s)", _LOGD (LOGD_IP4, "ip4-config: set IP4Config instance (%s)",
nm_exported_object_get_path (NM_EXPORTED_OBJECT (new_config))); nm_dbus_object_get_path (NM_DBUS_OBJECT (new_config)));
} }
} else if (old_config) { } else if (old_config) {
has_changes = TRUE; has_changes = TRUE;
priv->ip4_config = NULL; priv->ip4_config = NULL;
_LOGD (LOGD_IP4, "ip4-config: clear IP4Config instance (%s)", _LOGD (LOGD_IP4, "ip4-config: clear IP4Config instance (%s)",
nm_exported_object_get_path (NM_EXPORTED_OBJECT (old_config))); nm_dbus_object_get_path (NM_DBUS_OBJECT (old_config)));
/* Device config is invalid if combined config is invalid */ /* Device config is invalid if combined config is invalid */
applied_config_clear (&priv->dev_ip4_config); applied_config_clear (&priv->dev_ip4_config);
} }
@@ -10580,7 +10603,7 @@ nm_device_set_ip4_config (NMDevice *self,
g_signal_emit (self, signals[IP4_CONFIG_CHANGED], 0, priv->ip4_config, old_config); g_signal_emit (self, signals[IP4_CONFIG_CHANGED], 0, priv->ip4_config, old_config);
if (old_config != priv->ip4_config) if (old_config != priv->ip4_config)
nm_exported_object_clear_and_unexport (&old_config); nm_dbus_object_clear_and_unexport (&old_config);
if ( nm_device_sys_iface_state_is_external (self) if ( nm_device_sys_iface_state_is_external (self)
&& (settings_connection = nm_device_get_settings_connection (self)) && (settings_connection = nm_device_get_settings_connection (self))
@@ -10717,24 +10740,24 @@ nm_device_set_ip6_config (NMDevice *self,
nm_ip6_config_replace (old_config, new_config, &has_changes); nm_ip6_config_replace (old_config, new_config, &has_changes);
if (has_changes) { if (has_changes) {
_LOGD (LOGD_IP6, "ip6-config: update IP6Config instance (%s)", _LOGD (LOGD_IP6, "ip6-config: update IP6Config instance (%s)",
nm_exported_object_get_path (NM_EXPORTED_OBJECT (old_config))); nm_dbus_object_get_path (NM_DBUS_OBJECT (old_config)));
} }
} else { } else {
has_changes = TRUE; has_changes = TRUE;
priv->ip6_config = g_object_ref (new_config); priv->ip6_config = g_object_ref (new_config);
if (success && !nm_exported_object_is_exported (NM_EXPORTED_OBJECT (new_config))) if (success && !nm_dbus_object_is_exported (NM_DBUS_OBJECT (new_config)))
nm_exported_object_export (NM_EXPORTED_OBJECT (new_config)); nm_dbus_object_export (NM_DBUS_OBJECT (new_config));
_LOGD (LOGD_IP6, "ip6-config: set IP6Config instance (%s)", _LOGD (LOGD_IP6, "ip6-config: set IP6Config instance (%s)",
nm_exported_object_get_path (NM_EXPORTED_OBJECT (new_config))); nm_dbus_object_get_path (NM_DBUS_OBJECT (new_config)));
} }
} else if (old_config) { } else if (old_config) {
has_changes = TRUE; has_changes = TRUE;
priv->ip6_config = NULL; priv->ip6_config = NULL;
priv->needs_ip6_subnet = FALSE; priv->needs_ip6_subnet = FALSE;
_LOGD (LOGD_IP6, "ip6-config: clear IP6Config instance (%s)", _LOGD (LOGD_IP6, "ip6-config: clear IP6Config instance (%s)",
nm_exported_object_get_path (NM_EXPORTED_OBJECT (old_config))); nm_dbus_object_get_path (NM_DBUS_OBJECT (old_config)));
} }
if (has_changes) { if (has_changes) {
@@ -10745,7 +10768,7 @@ nm_device_set_ip6_config (NMDevice *self,
g_signal_emit (self, signals[IP6_CONFIG_CHANGED], 0, priv->ip6_config, old_config); g_signal_emit (self, signals[IP6_CONFIG_CHANGED], 0, priv->ip6_config, old_config);
if (old_config != priv->ip6_config) if (old_config != priv->ip6_config)
nm_exported_object_clear_and_unexport (&old_config); nm_dbus_object_clear_and_unexport (&old_config);
if ( nm_device_sys_iface_state_is_external (self) if ( nm_device_sys_iface_state_is_external (self)
&& (settings_connection = nm_device_get_settings_connection (self)) && (settings_connection = nm_device_get_settings_connection (self))
@@ -13484,6 +13507,13 @@ _set_state_full (NMDevice *self,
_notify (self, PROP_STATE); _notify (self, PROP_STATE);
_notify (self, PROP_STATE_REASON); _notify (self, PROP_STATE_REASON);
nm_dbus_object_emit_signal (NM_DBUS_OBJECT (self),
&interface_info_device,
&signal_info_state_changed,
"(uuu)",
(guint32) state,
(guint32) old_state,
(guint32) reason);
g_signal_emit (self, signals[STATE_CHANGED], 0, (guint) state, (guint) old_state, (guint) reason); g_signal_emit (self, signals[STATE_CHANGED], 0, (guint) state, (guint) old_state, (guint) reason);
/* Post-process the event after internal notification */ /* Post-process the event after internal notification */
@@ -14997,16 +15027,16 @@ get_property (GObject *object, guint prop_id,
g_value_set_uint (value, priv->mtu); g_value_set_uint (value, priv->mtu);
break; break;
case PROP_IP4_CONFIG: case PROP_IP4_CONFIG:
nm_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->ip4_config : NULL); nm_dbus_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->ip4_config : NULL);
break; break;
case PROP_DHCP4_CONFIG: case PROP_DHCP4_CONFIG:
nm_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->dhcp4.config : NULL); nm_dbus_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->dhcp4.config : NULL);
break; break;
case PROP_IP6_CONFIG: case PROP_IP6_CONFIG:
nm_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->ip6_config : NULL); nm_dbus_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->ip6_config : NULL);
break; break;
case PROP_DHCP6_CONFIG: case PROP_DHCP6_CONFIG:
nm_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->dhcp6.config : NULL); nm_dbus_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->dhcp6.config : NULL);
break; break;
case PROP_STATE: case PROP_STATE:
g_value_set_uint (value, priv->state); g_value_set_uint (value, priv->state);
@@ -15016,7 +15046,7 @@ get_property (GObject *object, guint prop_id,
g_variant_new ("(uu)", priv->state, priv->state_reason)); g_variant_new ("(uu)", priv->state, priv->state_reason));
break; break;
case PROP_ACTIVE_CONNECTION: case PROP_ACTIVE_CONNECTION:
nm_utils_g_value_set_object_path (value, priv->act_request_public ? priv->act_request : NULL); nm_dbus_utils_g_value_set_object_path (value, priv->act_request_public ? priv->act_request : NULL);
break; break;
case PROP_DEVICE_TYPE: case PROP_DEVICE_TYPE:
g_value_set_uint (value, priv->type); g_value_set_uint (value, priv->type);
@@ -15061,7 +15091,7 @@ get_property (GObject *object, guint prop_id,
g_value_set_object (value, nm_device_get_master (self)); g_value_set_object (value, nm_device_get_master (self));
break; break;
case PROP_PARENT: case PROP_PARENT:
nm_utils_g_value_set_object_path (value, priv->parent_device); nm_dbus_utils_g_value_set_object_path (value, priv->parent_device);
break; break;
case PROP_HW_ADDRESS: case PROP_HW_ADDRESS:
g_value_set_string (value, priv->hw_addr); g_value_set_string (value, priv->hw_addr);
@@ -15106,7 +15136,7 @@ get_property (GObject *object, guint prop_id,
if (!NM_DEVICE_GET_PRIVATE (info->slave)->is_enslaved) if (!NM_DEVICE_GET_PRIVATE (info->slave)->is_enslaved)
continue; continue;
path = nm_exported_object_get_path ((NMExportedObject *) info->slave); path = nm_dbus_object_get_path (NM_DBUS_OBJECT (info->slave));
if (path) if (path)
slave_list[i++] = g_strdup (path); slave_list[i++] = g_strdup (path);
} }
@@ -15133,15 +15163,115 @@ get_property (GObject *object, guint prop_id,
} }
} }
static const GDBusSignalInfo signal_info_state_changed = NM_DEFINE_GDBUS_SIGNAL_INFO_INIT (
"StateChanged",
.args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("new_state", "u"),
NM_DEFINE_GDBUS_ARG_INFO ("old_state", "u"),
NM_DEFINE_GDBUS_ARG_INFO ("reason", "u"),
),
);
static const NMDBusInterfaceInfoExtended interface_info_device = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE,
.methods = NM_DEFINE_GDBUS_METHOD_INFOS (
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"Reapply",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("connection", "a{sa{sv}}"),
NM_DEFINE_GDBUS_ARG_INFO ("version_id", "t"),
NM_DEFINE_GDBUS_ARG_INFO ("flags", "u"),
),
),
.handle = impl_device_reapply,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"GetAppliedConnection",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("flags", "u"),
),
.out_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("connection", "a{sa{sv}}"),
NM_DEFINE_GDBUS_ARG_INFO ("version_id", "t"),
),
),
.handle = impl_device_get_applied_connection,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"Disconnect",
),
.handle = impl_device_disconnect,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"Delete",
),
.handle = impl_device_delete,
),
),
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&signal_info_state_changed,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Udi", "s", NM_DEVICE_UDI),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Interface", "s", NM_DEVICE_IFACE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("IpInterface", "s", NM_DEVICE_IP_IFACE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Driver", "s", NM_DEVICE_DRIVER),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("DriverVersion", "s", NM_DEVICE_DRIVER_VERSION),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("FirmwareVersion", "s", NM_DEVICE_FIRMWARE_VERSION),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Capabilities", "u", NM_DEVICE_CAPABILITIES),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Ip4Address", "u", NM_DEVICE_IP4_ADDRESS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("State", "u", NM_DEVICE_STATE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("StateReason", "(uu)", NM_DEVICE_STATE_REASON),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("ActiveConnection", "o", NM_DEVICE_ACTIVE_CONNECTION),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Ip4Config", "o", NM_DEVICE_IP4_CONFIG),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Dhcp4Config", "o", NM_DEVICE_DHCP4_CONFIG),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Ip6Config", "o", NM_DEVICE_IP6_CONFIG),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Dhcp6Config", "o", NM_DEVICE_DHCP6_CONFIG),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READWRITABLE_L ("Managed", "b", NM_DEVICE_MANAGED, NM_AUTH_PERMISSION_NETWORK_CONTROL, NM_AUDIT_OP_DEVICE_MANAGED),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READWRITABLE_L ("Autoconnect", "b", NM_DEVICE_AUTOCONNECT, NM_AUTH_PERMISSION_NETWORK_CONTROL, NM_AUDIT_OP_DEVICE_AUTOCONNECT),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("FirmwareMissing", "b", NM_DEVICE_FIRMWARE_MISSING),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("NmPluginMissing", "b", NM_DEVICE_NM_PLUGIN_MISSING),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("DeviceType", "u", NM_DEVICE_DEVICE_TYPE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("AvailableConnections", "ao", NM_DEVICE_AVAILABLE_CONNECTIONS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("PhysicalPortId", "s", NM_DEVICE_PHYSICAL_PORT_ID),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Mtu", "u", NM_DEVICE_MTU),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Metered", "u", NM_DEVICE_METERED),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("LldpNeighbors", "aa{sv}", NM_DEVICE_LLDP_NEIGHBORS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Real", "b", NM_DEVICE_REAL),
),
),
};
const NMDBusInterfaceInfoExtended nm_interface_info_device_statistics = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_STATISTICS,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READWRITABLE ("RefreshRateMs", "u", NM_DEVICE_STATISTICS_REFRESH_RATE_MS, NM_AUTH_PERMISSION_ENABLE_DISABLE_STATISTICS, NM_AUDIT_OP_STATISTICS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("TxBytes", "t", NM_DEVICE_STATISTICS_TX_BYTES),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("RxBytes", "t", NM_DEVICE_STATISTICS_RX_BYTES),
),
),
};
static void static void
nm_device_class_init (NMDeviceClass *klass) nm_device_class_init (NMDeviceClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
g_type_class_add_private (object_class, sizeof (NMDevicePrivate)); g_type_class_add_private (object_class, sizeof (NMDevicePrivate));
exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/Devices"); dbus_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/Devices");
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device,
&nm_interface_info_device_statistics);
object_class->dispose = dispose; object_class->dispose = dispose;
object_class->finalize = finalize; object_class->finalize = finalize;
@@ -15373,7 +15503,6 @@ nm_device_class_init (NMDeviceClass *klass)
G_PARAM_READABLE | G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
/* Statistics */
obj_properties[PROP_REFRESH_RATE_MS] = obj_properties[PROP_REFRESH_RATE_MS] =
g_param_spec_uint (NM_DEVICE_STATISTICS_REFRESH_RATE_MS, "", "", g_param_spec_uint (NM_DEVICE_STATISTICS_REFRESH_RATE_MS, "", "",
0, UINT32_MAX, 0, 0, UINT32_MAX, 0,
@@ -15390,7 +15519,6 @@ nm_device_class_init (NMDeviceClass *klass)
G_PARAM_READABLE | G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
/* Connectivity */
obj_properties[PROP_CONNECTIVITY] = obj_properties[PROP_CONNECTIVITY] =
g_param_spec_uint (NM_DEVICE_CONNECTIVITY, "", "", g_param_spec_uint (NM_DEVICE_CONNECTIVITY, "", "",
NM_CONNECTIVITY_UNKNOWN, NM_CONNECTIVITY_FULL, NM_CONNECTIVITY_UNKNOWN, NM_CONNECTIVITY_UNKNOWN, NM_CONNECTIVITY_FULL, NM_CONNECTIVITY_UNKNOWN,
@@ -15472,16 +15600,4 @@ nm_device_class_init (NMDeviceClass *klass)
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
0, NULL, NULL, NULL, 0, NULL, NULL, NULL,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_SKELETON,
"Reapply", impl_device_reapply,
"GetAppliedConnection", impl_device_get_applied_connection,
"Disconnect", impl_device_disconnect,
"Delete", impl_device_delete,
NULL);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_STATISTICS_SKELETON,
NULL);
} }

View File

@@ -25,7 +25,7 @@
#include <netinet/in.h> #include <netinet/in.h>
#include "nm-setting-connection.h" #include "nm-setting-connection.h"
#include "nm-exported-object.h" #include "nm-dbus-object.h"
#include "nm-dbus-interface.h" #include "nm-dbus-interface.h"
#include "nm-connection.h" #include "nm-connection.h"
#include "nm-rfkill-manager.h" #include "nm-rfkill-manager.h"
@@ -114,8 +114,7 @@ nm_device_state_reason_check (NMDeviceStateReason reason)
#define NM_DEVICE_PARENT "parent" #define NM_DEVICE_PARENT "parent"
/* the "slaves" property is internal in the parent class, but exposed /* the "slaves" property is internal in the parent class, but exposed
* by the derived classes NMDeviceBond, NMDeviceBridge and NMDeviceTeam. * by the derived classes NMDeviceBond, NMDeviceBridge and NMDeviceTeam. */
* It is thus important that the property name matches. */
#define NM_DEVICE_SLAVES "slaves" /* partially internal */ #define NM_DEVICE_SLAVES "slaves" /* partially internal */
#define NM_DEVICE_TYPE_DESC "type-desc" /* Internal only */ #define NM_DEVICE_TYPE_DESC "type-desc" /* Internal only */
@@ -173,9 +172,7 @@ typedef enum { /*< skip >*/
struct _NMDevicePrivate; struct _NMDevicePrivate;
struct _NMDevice { struct _NMDevice {
NMExportedObject parent; NMDBusObject parent;
/* private */
struct _NMDevicePrivate *_priv; struct _NMDevicePrivate *_priv;
}; };
@@ -191,7 +188,7 @@ typedef enum { /*< skip >*/
} NMDeviceCheckDevAvailableFlags; } NMDeviceCheckDevAvailableFlags;
typedef struct { typedef struct {
NMExportedObjectClass parent; NMDBusObjectClass parent;
const char *default_type_description; const char *default_type_description;

View File

@@ -8,7 +8,6 @@ sources = files(
deps = [ deps = [
jansson_dep, jansson_dep,
libnmdbus_dep,
nm_dep nm_dep
] ]

View File

@@ -28,10 +28,8 @@
#include "nm-setting-connection.h" #include "nm-setting-connection.h"
#include "nm-setting-ovs-bridge.h" #include "nm-setting-ovs-bridge.h"
#include "introspection/org.freedesktop.NetworkManager.Device.OvsBridge.h"
#include "devices/nm-device-logging.h" #include "devices/nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceOvsBridge); _LOG_DECLARE_SELF (NMDeviceOvsBridge);
/*****************************************************************************/ /*****************************************************************************/
@@ -133,11 +131,24 @@ nm_device_ovs_bridge_init (NMDeviceOvsBridge *self)
{ {
} }
static const NMDBusInterfaceInfoExtended interface_info_device_ovs_bridge = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_OVS_BRIDGE,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_ovs_bridge_class_init (NMDeviceOvsBridgeClass *klass) nm_device_ovs_bridge_class_init (NMDeviceOvsBridgeClass *klass)
{ {
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_ovs_bridge);
device_class->connection_type = NM_SETTING_OVS_BRIDGE_SETTING_NAME; device_class->connection_type = NM_SETTING_OVS_BRIDGE_SETTING_NAME;
device_class->is_master = TRUE; device_class->is_master = TRUE;
device_class->get_type_description = get_type_description; device_class->get_type_description = get_type_description;
@@ -149,8 +160,4 @@ nm_device_ovs_bridge_class_init (NMDeviceOvsBridgeClass *klass)
device_class->act_stage3_ip6_config_start = act_stage3_ip6_config_start; device_class->act_stage3_ip6_config_start = act_stage3_ip6_config_start;
device_class->enslave_slave = enslave_slave; device_class->enslave_slave = enslave_slave;
device_class->release_slave = release_slave; device_class->release_slave = release_slave;
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_OVS_BRIDGE_SKELETON,
NULL);
} }

View File

@@ -28,8 +28,6 @@
#include "nm-setting-ovs-interface.h" #include "nm-setting-ovs-interface.h"
#include "nm-setting-ovs-port.h" #include "nm-setting-ovs-port.h"
#include "introspection/org.freedesktop.NetworkManager.Device.OvsInterface.h"
#include "devices/nm-device-logging.h" #include "devices/nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceOvsInterface); _LOG_DECLARE_SELF(NMDeviceOvsInterface);
@@ -185,13 +183,26 @@ nm_device_ovs_interface_init (NMDeviceOvsInterface *self)
{ {
} }
static const NMDBusInterfaceInfoExtended interface_info_device_ovs_interface = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_OVS_INTERFACE,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_ovs_interface_class_init (NMDeviceOvsInterfaceClass *klass) nm_device_ovs_interface_class_init (NMDeviceOvsInterfaceClass *klass)
{ {
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_OPENVSWITCH); NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_OPENVSWITCH);
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_ovs_interface);
device_class->connection_type = NM_SETTING_OVS_INTERFACE_SETTING_NAME; device_class->connection_type = NM_SETTING_OVS_INTERFACE_SETTING_NAME;
device_class->get_type_description = get_type_description; device_class->get_type_description = get_type_description;
device_class->create_and_realize = create_and_realize; device_class->create_and_realize = create_and_realize;
@@ -202,8 +213,4 @@ nm_device_ovs_interface_class_init (NMDeviceOvsInterfaceClass *klass)
device_class->act_stage3_ip4_config_start = act_stage3_ip4_config_start; device_class->act_stage3_ip4_config_start = act_stage3_ip4_config_start;
device_class->act_stage3_ip6_config_start = act_stage3_ip6_config_start; device_class->act_stage3_ip6_config_start = act_stage3_ip6_config_start;
device_class->can_unmanaged_external_down = can_unmanaged_external_down; device_class->can_unmanaged_external_down = can_unmanaged_external_down;
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_OVS_INTERFACE_SKELETON,
NULL);
} }

View File

@@ -28,10 +28,8 @@
#include "nm-setting-ovs-port.h" #include "nm-setting-ovs-port.h"
#include "nm-setting-ovs-port.h" #include "nm-setting-ovs-port.h"
#include "introspection/org.freedesktop.NetworkManager.Device.OvsPort.h"
#include "devices/nm-device-logging.h" #include "devices/nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceOvsPort); _LOG_DECLARE_SELF (NMDeviceOvsPort);
/*****************************************************************************/ /*****************************************************************************/
@@ -180,11 +178,24 @@ nm_device_ovs_port_init (NMDeviceOvsPort *self)
{ {
} }
static const NMDBusInterfaceInfoExtended interface_info_device_ovs_port = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_OVS_PORT,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_ovs_port_class_init (NMDeviceOvsPortClass *klass) nm_device_ovs_port_class_init (NMDeviceOvsPortClass *klass)
{ {
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_ovs_port);
device_class->connection_type = NM_SETTING_OVS_PORT_SETTING_NAME; device_class->connection_type = NM_SETTING_OVS_PORT_SETTING_NAME;
device_class->is_master = TRUE; device_class->is_master = TRUE;
device_class->get_type_description = get_type_description; device_class->get_type_description = get_type_description;
@@ -195,8 +206,4 @@ nm_device_ovs_port_class_init (NMDeviceOvsPortClass *klass)
device_class->act_stage3_ip6_config_start = act_stage3_ip6_config_start; device_class->act_stage3_ip6_config_start = act_stage3_ip6_config_start;
device_class->enslave_slave = enslave_slave; device_class->enslave_slave = enslave_slave;
device_class->release_slave = release_slave; device_class->release_slave = release_slave;
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_OVS_PORT_SKELETON,
NULL);
} }

View File

@@ -5,7 +5,6 @@ sources = files(
deps = [ deps = [
jansson_dep, jansson_dep,
libnmdbus_dep,
libteamdctl_dep, libteamdctl_dep,
nm_dep nm_dep
] ]

View File

@@ -37,8 +37,6 @@
#include "nm-ip4-config.h" #include "nm-ip4-config.h"
#include "nm-dbus-compat.h" #include "nm-dbus-compat.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Team.h"
#include "devices/nm-device-logging.h" #include "devices/nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceTeam); _LOG_DECLARE_SELF(NMDeviceTeam);
@@ -891,10 +889,27 @@ dispose (GObject *object)
G_OBJECT_CLASS (nm_device_team_parent_class)->dispose (object); G_OBJECT_CLASS (nm_device_team_parent_class)->dispose (object);
} }
static const NMDBusInterfaceInfoExtended interface_info_device_team = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_TEAM,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("HwAddress", "s", NM_DEVICE_HW_ADDRESS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Carrier", "b", NM_DEVICE_CARRIER),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Slaves", "ao", NM_DEVICE_SLAVES),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Config", "s", NM_DEVICE_TEAM_CONFIG),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_team_class_init (NMDeviceTeamClass *klass) nm_device_team_class_init (NMDeviceTeamClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_TEAM_SETTING_NAME, NM_LINK_TYPE_TEAM) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_TEAM_SETTING_NAME, NM_LINK_TYPE_TEAM)
@@ -903,6 +918,8 @@ nm_device_team_class_init (NMDeviceTeamClass *klass)
object_class->dispose = dispose; object_class->dispose = dispose;
object_class->get_property = get_property; object_class->get_property = get_property;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_team);
parent_class->is_master = TRUE; parent_class->is_master = TRUE;
parent_class->create_and_realize = create_and_realize; parent_class->create_and_realize = create_and_realize;
parent_class->get_generic_capabilities = get_generic_capabilities; parent_class->get_generic_capabilities = get_generic_capabilities;
@@ -924,8 +941,4 @@ nm_device_team_class_init (NMDeviceTeamClass *klass)
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_TEAM_SKELETON,
NULL);
} }

View File

@@ -5,6 +5,7 @@ common_sources = files(
sources = common_sources + files( sources = common_sources + files(
'nm-wifi-factory.c', 'nm-wifi-factory.c',
'nm-wifi-common.c',
'nm-device-wifi.c', 'nm-device-wifi.c',
'nm-device-olpc-mesh.c' 'nm-device-olpc-mesh.c'
) )
@@ -17,7 +18,6 @@ if enable_iwd
endif endif
deps = [ deps = [
libnmdbus_dep,
nm_dep nm_dep
] ]

View File

@@ -36,12 +36,11 @@
#include "settings/nm-settings-connection.h" #include "settings/nm-settings-connection.h"
#include "settings/nm-settings.h" #include "settings/nm-settings.h"
#include "nm-wifi-utils.h" #include "nm-wifi-utils.h"
#include "nm-wifi-common.h"
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "nm-config.h" #include "nm-config.h"
#include "nm-iwd-manager.h" #include "nm-iwd-manager.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Wireless.h"
#include "devices/nm-device-logging.h" #include "devices/nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceIwd); _LOG_DECLARE_SELF(NMDeviceIwd);
@@ -57,8 +56,6 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceIwd,
); );
enum { enum {
ACCESS_POINT_ADDED,
ACCESS_POINT_REMOVED,
SCANNING_PROHIBITED, SCANNING_PROHIBITED,
LAST_SIGNAL LAST_SIGNAL
@@ -122,30 +119,42 @@ _ap_dump (NMDeviceIwd *self,
nm_wifi_ap_to_string (ap, buf, sizeof (buf), now_s)); nm_wifi_ap_to_string (ap, buf, sizeof (buf), now_s));
} }
static void
_emit_access_point_added_removed (NMDeviceIwd *self,
NMWifiAP *ap,
gboolean is_added /* or else is removed */)
{
nm_dbus_object_emit_signal (NM_DBUS_OBJECT (self),
&nm_interface_info_device_wireless,
is_added
? &nm_signal_info_wireless_access_point_added
: &nm_signal_info_wireless_access_point_removed,
"(o)",
nm_dbus_object_get_path (NM_DBUS_OBJECT (ap)));
}
/* Callers ensure we're not removing current_ap */ /* Callers ensure we're not removing current_ap */
static void static void
ap_add_remove (NMDeviceIwd *self, ap_add_remove (NMDeviceIwd *self,
guint signum, gboolean is_adding, /* or else is removing */
NMWifiAP *ap, NMWifiAP *ap,
gboolean recheck_available_connections) gboolean recheck_available_connections)
{ {
NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE (self); NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE (self);
nm_assert (NM_IN_SET (signum, ACCESS_POINT_ADDED, ACCESS_POINT_REMOVED)); if (is_adding) {
if (signum == ACCESS_POINT_ADDED) {
g_hash_table_insert (priv->aps, g_hash_table_insert (priv->aps,
(gpointer) nm_exported_object_export ((NMExportedObject *) ap), (gpointer) nm_dbus_object_export (NM_DBUS_OBJECT (ap)),
g_object_ref (ap)); g_object_ref (ap));
_ap_dump (self, LOGL_DEBUG, ap, "added", 0); _ap_dump (self, LOGL_DEBUG, ap, "added", 0);
} else } else
_ap_dump (self, LOGL_DEBUG, ap, "removed", 0); _ap_dump (self, LOGL_DEBUG, ap, "removed", 0);
g_signal_emit (self, signals[signum], 0, ap); _emit_access_point_added_removed (self, ap, is_adding);
if (signum == ACCESS_POINT_REMOVED) { if (!is_adding) {
g_hash_table_remove (priv->aps, nm_exported_object_get_path ((NMExportedObject *) ap)); g_hash_table_remove (priv->aps, nm_dbus_object_get_path (NM_DBUS_OBJECT (ap)));
nm_exported_object_unexport ((NMExportedObject *) ap); nm_dbus_object_unexport (NM_DBUS_OBJECT (ap));
g_object_unref (ap); g_object_unref (ap);
} }
@@ -177,7 +186,7 @@ set_current_ap (NMDeviceIwd *self, NMWifiAP *new_ap, gboolean recheck_available_
if (old_ap) { if (old_ap) {
if (nm_wifi_ap_get_fake (old_ap)) if (nm_wifi_ap_get_fake (old_ap))
ap_add_remove (self, ACCESS_POINT_REMOVED, old_ap, recheck_available_connections); ap_add_remove (self, FALSE, old_ap, recheck_available_connections);
g_object_unref (old_ap); g_object_unref (old_ap);
} }
@@ -217,9 +226,9 @@ update_ap_func (gpointer key, gpointer value, gpointer user_data)
_ap_dump (self, LOGL_DEBUG, ap, "removed", 0); _ap_dump (self, LOGL_DEBUG, ap, "removed", 0);
g_signal_emit (self, signals[ACCESS_POINT_REMOVED], 0, ap); _emit_access_point_added_removed (self, ap, FALSE);
nm_exported_object_unexport ((NMExportedObject *) ap); nm_dbus_object_unexport (NM_DBUS_OBJECT (ap));
g_object_unref (ap); g_object_unref (ap);
return TRUE; return TRUE;
@@ -351,7 +360,7 @@ get_ordered_networks_cb (GObject *source, GAsyncResult *res, gpointer user_data)
g_hash_table_iter_init (&ap_iter, priv->new_aps); g_hash_table_iter_init (&ap_iter, priv->new_aps);
while (g_hash_table_iter_next (&ap_iter, NULL, (gpointer) &ap)) { while (g_hash_table_iter_next (&ap_iter, NULL, (gpointer) &ap)) {
ap_add_remove (self, ACCESS_POINT_ADDED, ap, FALSE); ap_add_remove (self, TRUE, ap, FALSE);
changed = TRUE; changed = TRUE;
} }
@@ -853,37 +862,17 @@ can_auto_connect (NMDevice *device,
ap = nm_wifi_aps_find_first_compatible (priv->aps, connection, FALSE); ap = nm_wifi_aps_find_first_compatible (priv->aps, connection, FALSE);
if (ap) { if (ap) {
/* All good; connection is usable */ /* All good; connection is usable */
NM_SET_OUT (specific_object, g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap)))); NM_SET_OUT (specific_object, g_strdup (nm_dbus_object_get_path (NM_DBUS_OBJECT (ap))));
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
static void GHashTable *
impl_device_iwd_get_access_points (NMDeviceIwd *self, _nm_device_iwd_get_aps (NMDeviceIwd *self)
GDBusMethodInvocation *context)
{ {
NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE (self); return NM_DEVICE_IWD_GET_PRIVATE (self)->aps;
gs_free const char **list = NULL;
GVariant *v;
list = nm_wifi_aps_get_sorted_paths (priv->aps, FALSE);
v = g_variant_new_objv (list, -1);
g_dbus_method_invocation_return_value (context, g_variant_new_tuple (&v, 1));
}
static void
impl_device_iwd_get_all_access_points (NMDeviceIwd *self,
GDBusMethodInvocation *context)
{
NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE (self);
gs_free const char **list = NULL;
GVariant *v;
list = nm_wifi_aps_get_sorted_paths (priv->aps, TRUE);
v = g_variant_new_objv (list, -1);
g_dbus_method_invocation_return_value (context, g_variant_new_tuple (&v, 1));
} }
static gboolean static gboolean
@@ -982,10 +971,10 @@ dbus_request_scan_cb (NMDevice *device,
g_dbus_method_invocation_return_value (context, NULL); g_dbus_method_invocation_return_value (context, NULL);
} }
static void void
impl_device_iwd_request_scan (NMDeviceIwd *self, _nm_device_iwd_request_scan (NMDeviceIwd *self,
GDBusMethodInvocation *context, GVariant *options,
GVariant *options) GDBusMethodInvocation *invocation)
{ {
NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE (self); NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE (self);
NMDevice *device = NM_DEVICE (self); NMDevice *device = NM_DEVICE (self);
@@ -994,17 +983,16 @@ impl_device_iwd_request_scan (NMDeviceIwd *self,
|| !priv->dbus_obj || !priv->dbus_obj
|| nm_device_get_state (device) < NM_DEVICE_STATE_DISCONNECTED || nm_device_get_state (device) < NM_DEVICE_STATE_DISCONNECTED
|| nm_device_is_activating (device)) { || nm_device_is_activating (device)) {
g_dbus_method_invocation_return_error_literal (context, g_dbus_method_invocation_return_error_literal (invocation,
NM_DEVICE_ERROR, NM_DEVICE_ERROR,
NM_DEVICE_ERROR_NOT_ALLOWED, NM_DEVICE_ERROR_NOT_ALLOWED,
"Scanning not allowed while unavailable"); "Scanning not allowed while unavailable");
return; return;
} }
/* Ask the manager to authenticate this request for us */
g_signal_emit_by_name (device, g_signal_emit_by_name (device,
NM_DEVICE_AUTH_REQUEST, NM_DEVICE_AUTH_REQUEST,
context, invocation,
NULL, NULL,
NM_AUTH_PERMISSION_NETWORK_CONTROL, NM_AUTH_PERMISSION_NETWORK_CONTROL,
TRUE, TRUE,
@@ -1270,7 +1258,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
*/ */
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req), nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req),
nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap))); nm_dbus_object_get_path (NM_DBUS_OBJECT (ap)));
} }
set_current_ap (self, ap, FALSE); set_current_ap (self, ap, FALSE);
@@ -1575,7 +1563,7 @@ get_property (GObject *object, guint prop_id,
g_value_take_boxed (value, list); g_value_take_boxed (value, list);
break; break;
case PROP_ACTIVE_ACCESS_POINT: case PROP_ACTIVE_ACCESS_POINT:
nm_utils_g_value_set_object_path (value, priv->current_ap); nm_dbus_utils_g_value_set_object_path (value, priv->current_ap);
break; break;
case PROP_SCANNING: case PROP_SCANNING:
g_value_set_boolean (value, priv->scanning); g_value_set_boolean (value, priv->scanning);
@@ -1898,6 +1886,7 @@ static void
nm_device_iwd_class_init (NMDeviceIwdClass *klass) nm_device_iwd_class_init (NMDeviceIwdClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_WIRELESS_SETTING_NAME, NM_LINK_TYPE_WIFI) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_WIRELESS_SETTING_NAME, NM_LINK_TYPE_WIFI)
@@ -1907,6 +1896,8 @@ nm_device_iwd_class_init (NMDeviceIwdClass *klass)
object_class->dispose = dispose; object_class->dispose = dispose;
object_class->finalize = finalize; object_class->finalize = finalize;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&nm_interface_info_device_wireless);
parent_class->can_auto_connect = can_auto_connect; parent_class->can_auto_connect = can_auto_connect;
parent_class->is_available = is_available; parent_class->is_available = is_available;
parent_class->get_autoconnect_allowed = get_autoconnect_allowed; parent_class->get_autoconnect_allowed = get_autoconnect_allowed;
@@ -1970,24 +1961,6 @@ nm_device_iwd_class_init (NMDeviceIwdClass *klass)
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
signals[ACCESS_POINT_ADDED] =
g_signal_new (NM_DEVICE_IWD_ACCESS_POINT_ADDED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 1,
NM_TYPE_WIFI_AP);
signals[ACCESS_POINT_REMOVED] =
g_signal_new (NM_DEVICE_IWD_ACCESS_POINT_REMOVED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 1,
NM_TYPE_WIFI_AP);
signals[SCANNING_PROHIBITED] = signals[SCANNING_PROHIBITED] =
g_signal_new (NM_DEVICE_IWD_SCANNING_PROHIBITED, g_signal_new (NM_DEVICE_IWD_SCANNING_PROHIBITED,
G_OBJECT_CLASS_TYPE (object_class), G_OBJECT_CLASS_TYPE (object_class),
@@ -1995,11 +1968,4 @@ nm_device_iwd_class_init (NMDeviceIwdClass *klass)
G_STRUCT_OFFSET (NMDeviceIwdClass, scanning_prohibited), G_STRUCT_OFFSET (NMDeviceIwdClass, scanning_prohibited),
NULL, NULL, NULL, NULL, NULL, NULL,
G_TYPE_BOOLEAN, 1, G_TYPE_BOOLEAN); G_TYPE_BOOLEAN, 1, G_TYPE_BOOLEAN);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_WIFI_SKELETON,
"GetAccessPoints", impl_device_iwd_get_access_points,
"GetAllAccessPoints", impl_device_iwd_get_all_access_points,
"RequestScan", impl_device_iwd_request_scan,
NULL);
} }

View File

@@ -39,11 +39,6 @@
#define NM_DEVICE_IWD_CAPABILITIES NM_DEVICE_WIFI_CAPABILITIES #define NM_DEVICE_IWD_CAPABILITIES NM_DEVICE_WIFI_CAPABILITIES
#define NM_DEVICE_IWD_SCANNING NM_DEVICE_WIFI_SCANNING #define NM_DEVICE_IWD_SCANNING NM_DEVICE_WIFI_SCANNING
/* signals */
#define NM_DEVICE_IWD_ACCESS_POINT_ADDED NM_DEVICE_WIFI_ACCESS_POINT_ADDED
#define NM_DEVICE_IWD_ACCESS_POINT_REMOVED NM_DEVICE_WIFI_ACCESS_POINT_REMOVED
/* internal signals */
#define NM_DEVICE_IWD_SCANNING_PROHIBITED NM_DEVICE_WIFI_SCANNING_PROHIBITED #define NM_DEVICE_IWD_SCANNING_PROHIBITED NM_DEVICE_WIFI_SCANNING_PROHIBITED
typedef struct _NMDeviceIwd NMDeviceIwd; typedef struct _NMDeviceIwd NMDeviceIwd;
@@ -58,4 +53,10 @@ void nm_device_iwd_set_dbus_object (NMDeviceIwd *device, GDBusObject *object);
gboolean nm_device_iwd_agent_psk_query (NMDeviceIwd *device, gboolean nm_device_iwd_agent_psk_query (NMDeviceIwd *device,
GDBusMethodInvocation *invocation); GDBusMethodInvocation *invocation);
GHashTable *_nm_device_iwd_get_aps (NMDeviceIwd *self);
void _nm_device_iwd_request_scan (NMDeviceIwd *self,
GVariant *options,
GDBusMethodInvocation *invocation);
#endif /* __NETWORKMANAGER_DEVICE_IWD_H__ */ #endif /* __NETWORKMANAGER_DEVICE_IWD_H__ */

View File

@@ -48,11 +48,6 @@
#include "nm-manager.h" #include "nm-manager.h"
#include "platform/nm-platform.h" #include "platform/nm-platform.h"
/* This is a bug; but we can't really change API now... */
#include "nm-vpn-dbus-interface.h"
#include "introspection/org.freedesktop.NetworkManager.Device.OlpcMesh.h"
#include "devices/nm-device-logging.h" #include "devices/nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceOlpcMesh); _LOG_DECLARE_SELF(NMDeviceOlpcMesh);
@@ -440,7 +435,7 @@ get_property (GObject *object, guint prop_id,
switch (prop_id) { switch (prop_id) {
case PROP_COMPANION: case PROP_COMPANION:
nm_utils_g_value_set_object_path (value, priv->companion); nm_dbus_utils_g_value_set_object_path (value, priv->companion);
break; break;
case PROP_ACTIVE_CHANNEL: case PROP_ACTIVE_CHANNEL:
g_value_set_uint (value, nm_platform_mesh_get_channel (nm_device_get_platform (device), nm_device_get_ifindex (device))); g_value_set_uint (value, nm_platform_mesh_get_channel (nm_device_get_platform (device), nm_device_get_ifindex (device)));
@@ -500,10 +495,26 @@ dispose (GObject *object)
G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class)->dispose (object); G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class)->dispose (object);
} }
static const NMDBusInterfaceInfoExtended interface_info_device_olpc_mesh = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_OLPC_MESH,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("HwAddress", "s", NM_DEVICE_HW_ADDRESS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Companion", "o", NM_DEVICE_OLPC_MESH_COMPANION),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("ActiveChannel", "u", NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass) nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_OLPC_MESH_SETTING_NAME, NM_LINK_TYPE_OLPC_MESH) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_OLPC_MESH_SETTING_NAME, NM_LINK_TYPE_OLPC_MESH)
@@ -512,6 +523,8 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass)
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->dispose = dispose; object_class->dispose = dispose;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_olpc_mesh);
parent_class->check_connection_compatible = check_connection_compatible; parent_class->check_connection_compatible = check_connection_compatible;
parent_class->get_autoconnect_allowed = get_autoconnect_allowed; parent_class->get_autoconnect_allowed = get_autoconnect_allowed;
parent_class->complete_connection = complete_connection; parent_class->complete_connection = complete_connection;
@@ -534,9 +547,5 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass)
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_OLPC_MESH_SKELETON,
NULL);
} }

View File

@@ -28,6 +28,7 @@
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include "nm-wifi-ap.h"
#include "nm-common-macros.h" #include "nm-common-macros.h"
#include "devices/nm-device.h" #include "devices/nm-device.h"
#include "devices/nm-device-private.h" #include "devices/nm-device-private.h"
@@ -49,11 +50,10 @@
#include "settings/nm-settings-connection.h" #include "settings/nm-settings-connection.h"
#include "settings/nm-settings.h" #include "settings/nm-settings.h"
#include "nm-wifi-utils.h" #include "nm-wifi-utils.h"
#include "nm-wifi-common.h"
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "nm-config.h" #include "nm-config.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Wireless.h"
#include "devices/nm-device-logging.h" #include "devices/nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceWifi); _LOG_DECLARE_SELF(NMDeviceWifi);
@@ -76,8 +76,6 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceWifi,
); );
enum { enum {
ACCESS_POINT_ADDED,
ACCESS_POINT_REMOVED,
SCANNING_PROHIBITED, SCANNING_PROHIBITED,
LAST_SIGNAL LAST_SIGNAL
@@ -188,7 +186,7 @@ static void request_wireless_scan (NMDeviceWifi *self,
const GPtrArray *ssids); const GPtrArray *ssids);
static void ap_add_remove (NMDeviceWifi *self, static void ap_add_remove (NMDeviceWifi *self,
guint signum, gboolean is_adding,
NMWifiAP *ap, NMWifiAP *ap,
gboolean recheck_available_connections); gboolean recheck_available_connections);
@@ -416,7 +414,7 @@ set_current_ap (NMDeviceWifi *self, NMWifiAP *new_ap, gboolean recheck_available
/* Remove any AP from the internal list if it was created by NM or isn't known to the supplicant */ /* Remove any AP from the internal list if it was created by NM or isn't known to the supplicant */
if (mode == NM_802_11_MODE_ADHOC || mode == NM_802_11_MODE_AP || nm_wifi_ap_get_fake (old_ap)) if (mode == NM_802_11_MODE_ADHOC || mode == NM_802_11_MODE_AP || nm_wifi_ap_get_fake (old_ap))
ap_add_remove (self, ACCESS_POINT_REMOVED, old_ap, recheck_available_connections); ap_add_remove (self, FALSE, old_ap, recheck_available_connections);
g_object_unref (old_ap); g_object_unref (old_ap);
} }
@@ -483,28 +481,31 @@ periodic_update_cb (gpointer user_data)
static void static void
ap_add_remove (NMDeviceWifi *self, ap_add_remove (NMDeviceWifi *self,
guint signum, gboolean is_adding, /* or else removing */
NMWifiAP *ap, NMWifiAP *ap,
gboolean recheck_available_connections) gboolean recheck_available_connections)
{ {
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
nm_assert (NM_IN_SET (signum, ACCESS_POINT_ADDED, ACCESS_POINT_REMOVED)); if (is_adding) {
if (signum == ACCESS_POINT_ADDED) {
g_hash_table_insert (priv->aps, g_hash_table_insert (priv->aps,
(gpointer) nm_exported_object_export ((NMExportedObject *) ap), (gpointer) nm_dbus_object_export (NM_DBUS_OBJECT (ap)),
g_object_ref (ap)); g_object_ref (ap));
_ap_dump (self, LOGL_DEBUG, ap, "added", 0); _ap_dump (self, LOGL_DEBUG, ap, "added", 0);
} else } else
_ap_dump (self, LOGL_DEBUG, ap, "removed", 0); _ap_dump (self, LOGL_DEBUG, ap, "removed", 0);
g_signal_emit (self, signals[signum], 0, ap); nm_dbus_object_emit_signal (NM_DBUS_OBJECT (self),
&nm_interface_info_device_wireless,
is_adding
? &nm_signal_info_wireless_access_point_added
: &nm_signal_info_wireless_access_point_removed,
"(o)",
nm_dbus_object_get_path (NM_DBUS_OBJECT (ap)));
if (signum == ACCESS_POINT_REMOVED) { if (!is_adding) {
g_hash_table_remove (priv->aps, nm_exported_object_get_path ((NMExportedObject *) ap)); g_hash_table_remove (priv->aps, nm_dbus_object_get_path (NM_DBUS_OBJECT (ap)));
nm_exported_object_unexport ((NMExportedObject *) ap); nm_dbus_object_clear_and_unexport (&ap);
g_object_unref (ap);
} }
_notify (self, PROP_ACCESS_POINTS); _notify (self, PROP_ACCESS_POINTS);
@@ -529,7 +530,7 @@ remove_all_aps (NMDeviceWifi *self)
again: again:
g_hash_table_iter_init (&iter, priv->aps); g_hash_table_iter_init (&iter, priv->aps);
if (g_hash_table_iter_next (&iter, NULL, (gpointer) &ap)) { if (g_hash_table_iter_next (&iter, NULL, (gpointer) &ap)) {
ap_add_remove (self, ACCESS_POINT_REMOVED, ap, FALSE); ap_add_remove (self, FALSE, ap, FALSE);
goto again; goto again;
} }
@@ -990,37 +991,17 @@ can_auto_connect (NMDevice *device,
ap = nm_wifi_aps_find_first_compatible (priv->aps, connection, FALSE); ap = nm_wifi_aps_find_first_compatible (priv->aps, connection, FALSE);
if (ap) { if (ap) {
/* All good; connection is usable */ /* All good; connection is usable */
NM_SET_OUT (specific_object, g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap)))); NM_SET_OUT (specific_object, g_strdup (nm_dbus_object_get_path (NM_DBUS_OBJECT (ap))));
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
static void GHashTable *
impl_device_wifi_get_access_points (NMDeviceWifi *self, _nm_device_wifi_get_aps (NMDeviceWifi *self)
GDBusMethodInvocation *context)
{ {
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); return NM_DEVICE_WIFI_GET_PRIVATE (self)->aps;
gs_free const char **list = NULL;
GVariant *v;
list = nm_wifi_aps_get_sorted_paths (priv->aps, FALSE);
v = g_variant_new_objv (list, -1);
g_dbus_method_invocation_return_value (context, g_variant_new_tuple (&v, 1));
}
static void
impl_device_wifi_get_all_access_points (NMDeviceWifi *self,
GDBusMethodInvocation *context)
{
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
gs_free const char **list = NULL;
GVariant *v;
list = nm_wifi_aps_get_sorted_paths (priv->aps, TRUE);
v = g_variant_new_objv (list, -1);
g_dbus_method_invocation_return_value (context, g_variant_new_tuple (&v, 1));
} }
static void static void
@@ -1168,10 +1149,10 @@ dbus_request_scan_cb (NMDevice *device,
g_dbus_method_invocation_return_value (context, NULL); g_dbus_method_invocation_return_value (context, NULL);
} }
static void void
impl_device_wifi_request_scan (NMDeviceWifi *self, _nm_device_wifi_request_scan (NMDeviceWifi *self,
GDBusMethodInvocation *context, GVariant *options,
GVariant *options) GDBusMethodInvocation *invocation)
{ {
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
NMDevice *device = NM_DEVICE (self); NMDevice *device = NM_DEVICE (self);
@@ -1181,7 +1162,7 @@ impl_device_wifi_request_scan (NMDeviceWifi *self,
|| !priv->sup_iface || !priv->sup_iface
|| nm_device_get_state (device) < NM_DEVICE_STATE_DISCONNECTED || nm_device_get_state (device) < NM_DEVICE_STATE_DISCONNECTED
|| nm_device_is_activating (device)) { || nm_device_is_activating (device)) {
g_dbus_method_invocation_return_error_literal (context, g_dbus_method_invocation_return_error_literal (invocation,
NM_DEVICE_ERROR, NM_DEVICE_ERROR,
NM_DEVICE_ERROR_NOT_ALLOWED, NM_DEVICE_ERROR_NOT_ALLOWED,
"Scanning not allowed while unavailable or activating"); "Scanning not allowed while unavailable or activating");
@@ -1189,7 +1170,7 @@ impl_device_wifi_request_scan (NMDeviceWifi *self,
} }
if (nm_supplicant_interface_get_scanning (priv->sup_iface)) { if (nm_supplicant_interface_get_scanning (priv->sup_iface)) {
g_dbus_method_invocation_return_error_literal (context, g_dbus_method_invocation_return_error_literal (invocation,
NM_DEVICE_ERROR, NM_DEVICE_ERROR,
NM_DEVICE_ERROR_NOT_ALLOWED, NM_DEVICE_ERROR_NOT_ALLOWED,
"Scanning not allowed while already scanning"); "Scanning not allowed while already scanning");
@@ -1198,17 +1179,16 @@ impl_device_wifi_request_scan (NMDeviceWifi *self,
last_scan = nm_supplicant_interface_get_last_scan_time (priv->sup_iface); last_scan = nm_supplicant_interface_get_last_scan_time (priv->sup_iface);
if (last_scan && (nm_utils_get_monotonic_timestamp_s () - last_scan) < 10) { if (last_scan && (nm_utils_get_monotonic_timestamp_s () - last_scan) < 10) {
g_dbus_method_invocation_return_error_literal (context, g_dbus_method_invocation_return_error_literal (invocation,
NM_DEVICE_ERROR, NM_DEVICE_ERROR,
NM_DEVICE_ERROR_NOT_ALLOWED, NM_DEVICE_ERROR_NOT_ALLOWED,
"Scanning not allowed immediately following previous scan"); "Scanning not allowed immediately following previous scan");
return; return;
} }
/* Ask the manager to authenticate this request for us */
g_signal_emit_by_name (device, g_signal_emit_by_name (device,
NM_DEVICE_AUTH_REQUEST, NM_DEVICE_AUTH_REQUEST,
context, invocation,
NULL, NULL,
NM_AUTH_PERMISSION_NETWORK_CONTROL, NM_AUTH_PERMISSION_NETWORK_CONTROL,
TRUE, TRUE,
@@ -1605,7 +1585,7 @@ supplicant_iface_bss_updated_cb (NMSupplicantInterface *iface,
} }
} }
ap_add_remove (self, ACCESS_POINT_ADDED, ap, TRUE); ap_add_remove (self, TRUE, ap, TRUE);
} }
/* Update the current AP if the supplicant notified a current BSS change /* Update the current AP if the supplicant notified a current BSS change
@@ -1642,7 +1622,7 @@ supplicant_iface_bss_removed_cb (NMSupplicantInterface *iface,
if (nm_wifi_ap_set_fake (ap, TRUE)) if (nm_wifi_ap_set_fake (ap, TRUE))
_ap_dump (self, LOGL_DEBUG, ap, "updated", 0); _ap_dump (self, LOGL_DEBUG, ap, "updated", 0);
} else { } else {
ap_add_remove (self, ACCESS_POINT_REMOVED, ap, TRUE); ap_add_remove (self, FALSE, ap, TRUE);
schedule_ap_list_dump (self); schedule_ap_list_dump (self);
} }
} }
@@ -2543,7 +2523,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
if (ap) { if (ap) {
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req), nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req),
nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap))); nm_dbus_object_get_path (NM_DBUS_OBJECT (ap)));
goto done; goto done;
} }
@@ -2560,11 +2540,11 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
nm_wifi_ap_set_address (ap, nm_device_get_hw_address (device)); nm_wifi_ap_set_address (ap, nm_device_get_hw_address (device));
g_object_freeze_notify (G_OBJECT (self)); g_object_freeze_notify (G_OBJECT (self));
ap_add_remove (self, ACCESS_POINT_ADDED, ap, TRUE); ap_add_remove (self, TRUE, ap, TRUE);
g_object_thaw_notify (G_OBJECT (self)); g_object_thaw_notify (G_OBJECT (self));
set_current_ap (self, ap, FALSE); set_current_ap (self, ap, FALSE);
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req), nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req),
nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap))); nm_dbus_object_get_path (NM_DBUS_OBJECT (ap)));
return NM_ACT_STAGE_RETURN_SUCCESS; return NM_ACT_STAGE_RETURN_SUCCESS;
done: done:
@@ -2976,7 +2956,7 @@ activation_success_handler (NMDevice *device)
} }
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req), nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req),
nm_exported_object_get_path (NM_EXPORTED_OBJECT (priv->current_ap))); nm_dbus_object_get_path (NM_DBUS_OBJECT (priv->current_ap)));
} }
periodic_update (self); periodic_update (self);
@@ -3174,7 +3154,7 @@ get_property (GObject *object, guint prop_id,
g_value_take_boxed (value, list); g_value_take_boxed (value, list);
break; break;
case PROP_ACTIVE_ACCESS_POINT: case PROP_ACTIVE_ACCESS_POINT:
nm_utils_g_value_set_object_path (value, priv->current_ap); nm_dbus_utils_g_value_set_object_path (value, priv->current_ap);
break; break;
case PROP_SCANNING: case PROP_SCANNING:
g_value_set_boolean (value, priv->is_scanning); g_value_set_boolean (value, priv->is_scanning);
@@ -3280,6 +3260,7 @@ static void
nm_device_wifi_class_init (NMDeviceWifiClass *klass) nm_device_wifi_class_init (NMDeviceWifiClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_WIRELESS_SETTING_NAME, NM_LINK_TYPE_WIFI) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_WIRELESS_SETTING_NAME, NM_LINK_TYPE_WIFI)
@@ -3290,6 +3271,8 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
object_class->dispose = dispose; object_class->dispose = dispose;
object_class->finalize = finalize; object_class->finalize = finalize;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&nm_interface_info_device_wireless);
parent_class->can_auto_connect = can_auto_connect; parent_class->can_auto_connect = can_auto_connect;
parent_class->get_autoconnect_allowed = get_autoconnect_allowed; parent_class->get_autoconnect_allowed = get_autoconnect_allowed;
parent_class->is_available = is_available; parent_class->is_available = is_available;
@@ -3356,24 +3339,6 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
signals[ACCESS_POINT_ADDED] =
g_signal_new (NM_DEVICE_WIFI_ACCESS_POINT_ADDED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 1,
NM_TYPE_WIFI_AP);
signals[ACCESS_POINT_REMOVED] =
g_signal_new (NM_DEVICE_WIFI_ACCESS_POINT_REMOVED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 1,
NM_TYPE_WIFI_AP);
signals[SCANNING_PROHIBITED] = signals[SCANNING_PROHIBITED] =
g_signal_new (NM_DEVICE_WIFI_SCANNING_PROHIBITED, g_signal_new (NM_DEVICE_WIFI_SCANNING_PROHIBITED,
G_OBJECT_CLASS_TYPE (object_class), G_OBJECT_CLASS_TYPE (object_class),
@@ -3381,13 +3346,4 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
G_STRUCT_OFFSET (NMDeviceWifiClass, scanning_prohibited), G_STRUCT_OFFSET (NMDeviceWifiClass, scanning_prohibited),
NULL, NULL, NULL, NULL, NULL, NULL,
G_TYPE_BOOLEAN, 1, G_TYPE_BOOLEAN); G_TYPE_BOOLEAN, 1, G_TYPE_BOOLEAN);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_WIFI_SKELETON,
"GetAccessPoints", impl_device_wifi_get_access_points,
"GetAllAccessPoints", impl_device_wifi_get_all_access_points,
"RequestScan", impl_device_wifi_request_scan,
NULL);
} }

View File

@@ -23,7 +23,6 @@
#define __NETWORKMANAGER_DEVICE_WIFI_H__ #define __NETWORKMANAGER_DEVICE_WIFI_H__
#include "devices/nm-device.h" #include "devices/nm-device.h"
#include "nm-wifi-ap.h"
#define NM_TYPE_DEVICE_WIFI (nm_device_wifi_get_type ()) #define NM_TYPE_DEVICE_WIFI (nm_device_wifi_get_type ())
#define NM_DEVICE_WIFI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_WIFI, NMDeviceWifi)) #define NM_DEVICE_WIFI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_WIFI, NMDeviceWifi))
@@ -39,11 +38,6 @@
#define NM_DEVICE_WIFI_CAPABILITIES "wireless-capabilities" #define NM_DEVICE_WIFI_CAPABILITIES "wireless-capabilities"
#define NM_DEVICE_WIFI_SCANNING "scanning" #define NM_DEVICE_WIFI_SCANNING "scanning"
/* signals */
#define NM_DEVICE_WIFI_ACCESS_POINT_ADDED "access-point-added"
#define NM_DEVICE_WIFI_ACCESS_POINT_REMOVED "access-point-removed"
/* internal signals */
#define NM_DEVICE_WIFI_SCANNING_PROHIBITED "scanning-prohibited" #define NM_DEVICE_WIFI_SCANNING_PROHIBITED "scanning-prohibited"
typedef struct _NMDeviceWifi NMDeviceWifi; typedef struct _NMDeviceWifi NMDeviceWifi;
@@ -53,4 +47,10 @@ GType nm_device_wifi_get_type (void);
NMDevice * nm_device_wifi_new (const char *iface, NMDeviceWifiCapabilities capabilities); NMDevice * nm_device_wifi_new (const char *iface, NMDeviceWifiCapabilities capabilities);
GHashTable *_nm_device_wifi_get_aps (NMDeviceWifi *self);
void _nm_device_wifi_request_scan (NMDeviceWifi *self,
GVariant *options,
GDBusMethodInvocation *invocation);
#endif /* __NETWORKMANAGER_DEVICE_WIFI_H__ */ #endif /* __NETWORKMANAGER_DEVICE_WIFI_H__ */

View File

@@ -21,20 +21,19 @@
#include "nm-default.h" #include "nm-default.h"
#include "nm-wifi-ap.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "nm-wifi-ap.h" #include "nm-setting-wireless.h"
#include "nm-wifi-utils.h" #include "nm-wifi-utils.h"
#include "NetworkManagerUtils.h" #include "NetworkManagerUtils.h"
#include "nm-utils.h" #include "nm-utils.h"
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "platform/nm-platform.h" #include "platform/nm-platform.h"
#include "nm-setting-wireless.h"
#include "introspection/org.freedesktop.NetworkManager.AccessPoint.h"
#define PROTO_WPA "wpa" #define PROTO_WPA "wpa"
#define PROTO_RSN "rsn" #define PROTO_RSN "rsn"
@@ -75,15 +74,15 @@ typedef struct {
} NMWifiAPPrivate; } NMWifiAPPrivate;
struct _NMWifiAP { struct _NMWifiAP {
NMExportedObject parent; NMDBusObject parent;
NMWifiAPPrivate _priv; NMWifiAPPrivate _priv;
}; };
struct _NMWifiAPClass { struct _NMWifiAPClass {
NMExportedObjectClass parent; NMDBusObjectClass parent;
}; };
G_DEFINE_TYPE (NMWifiAP, nm_wifi_ap, NM_TYPE_EXPORTED_OBJECT) G_DEFINE_TYPE (NMWifiAP, nm_wifi_ap, NM_TYPE_DBUS_OBJECT)
#define NM_WIFI_AP_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMWifiAP, NM_IS_WIFI_AP) #define NM_WIFI_AP_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMWifiAP, NM_IS_WIFI_AP)
@@ -105,7 +104,7 @@ nm_wifi_ap_get_id (NMWifiAP *ap)
g_return_val_if_fail (NM_IS_WIFI_AP (ap), 0); g_return_val_if_fail (NM_IS_WIFI_AP (ap), 0);
path = nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap)); path = nm_dbus_object_get_path (NM_DBUS_OBJECT (ap));
g_return_val_if_fail (path, 0); g_return_val_if_fail (path, 0);
nm_assert (g_str_has_prefix (path, NM_DBUS_PATH_ACCESS_POINT"/")); nm_assert (g_str_has_prefix (path, NM_DBUS_PATH_ACCESS_POINT"/"));
@@ -116,13 +115,26 @@ nm_wifi_ap_get_id (NMWifiAP *ap)
return i; return i;
} }
const GByteArray * nm_wifi_ap_get_ssid (const NMWifiAP *ap) const GByteArray *
nm_wifi_ap_get_ssid (const NMWifiAP *ap)
{ {
g_return_val_if_fail (NM_IS_WIFI_AP (ap), NULL); g_return_val_if_fail (NM_IS_WIFI_AP (ap), NULL);
return NM_WIFI_AP_GET_PRIVATE (ap)->ssid; return NM_WIFI_AP_GET_PRIVATE (ap)->ssid;
} }
static GVariant *
nm_wifi_ap_get_ssid_as_variant (const NMWifiAP *self)
{
const NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE (self);
if (priv->ssid) {
return g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
priv->ssid->data, priv->ssid->len, 1);
} else
return g_variant_new_array (G_VARIANT_TYPE_BYTE, NULL, 0);
}
gboolean gboolean
nm_wifi_ap_set_ssid (NMWifiAP *ap, const guint8 *ssid, gsize len) nm_wifi_ap_set_ssid (NMWifiAP *ap, const guint8 *ssid, gsize len)
{ {
@@ -330,7 +342,7 @@ guint32
nm_wifi_ap_get_max_bitrate (NMWifiAP *ap) nm_wifi_ap_get_max_bitrate (NMWifiAP *ap)
{ {
g_return_val_if_fail (NM_IS_WIFI_AP (ap), 0); g_return_val_if_fail (NM_IS_WIFI_AP (ap), 0);
g_return_val_if_fail (nm_exported_object_is_exported (NM_EXPORTED_OBJECT (ap)), 0); g_return_val_if_fail (nm_dbus_object_is_exported (NM_DBUS_OBJECT (ap)), 0);
return NM_WIFI_AP_GET_PRIVATE (ap)->max_bitrate; return NM_WIFI_AP_GET_PRIVATE (ap)->max_bitrate;
} }
@@ -978,7 +990,7 @@ nm_wifi_ap_to_string (const NMWifiAP *self,
if (priv->supplicant_path) if (priv->supplicant_path)
supplicant_id = strrchr (priv->supplicant_path, '/') ?: supplicant_id; supplicant_id = strrchr (priv->supplicant_path, '/') ?: supplicant_id;
export_path = nm_exported_object_get_path (NM_EXPORTED_OBJECT (self)); export_path = nm_dbus_object_get_path (NM_DBUS_OBJECT (self));
if (export_path) if (export_path)
export_path = strrchr (export_path, '/') ?: export_path; export_path = strrchr (export_path, '/') ?: export_path;
else else
@@ -1120,8 +1132,8 @@ static void
get_property (GObject *object, guint prop_id, get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec) GValue *value, GParamSpec *pspec)
{ {
NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE ((NMWifiAP *) object); NMWifiAP *self = NM_WIFI_AP (object);
GVariant *ssid; NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE (self);
switch (prop_id) { switch (prop_id) {
case PROP_FLAGS: case PROP_FLAGS:
@@ -1134,12 +1146,7 @@ get_property (GObject *object, guint prop_id,
g_value_set_uint (value, priv->rsn_flags); g_value_set_uint (value, priv->rsn_flags);
break; break;
case PROP_SSID: case PROP_SSID:
if (priv->ssid) { g_value_take_variant (value, nm_wifi_ap_get_ssid_as_variant (self));
ssid = g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
priv->ssid->data, priv->ssid->len, 1);
} else
ssid = g_variant_new_array (G_VARIANT_TYPE_BYTE, NULL, 0);
g_value_take_variant (value, ssid);
break; break;
case PROP_FREQUENCY: case PROP_FREQUENCY:
g_value_set_uint (value, priv->freq); g_value_set_uint (value, priv->freq);
@@ -1343,6 +1350,28 @@ finalize (GObject *object)
G_OBJECT_CLASS (nm_wifi_ap_parent_class)->finalize (object); G_OBJECT_CLASS (nm_wifi_ap_parent_class)->finalize (object);
} }
static const NMDBusInterfaceInfoExtended interface_info_access_point = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_ACCESS_POINT,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Flags", "u", NM_WIFI_AP_FLAGS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("WpaFlags", "u", NM_WIFI_AP_WPA_FLAGS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("RsnFlags", "u", NM_WIFI_AP_RSN_FLAGS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Ssid", "ay", NM_WIFI_AP_SSID),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Frequency", "u", NM_WIFI_AP_FREQUENCY),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("HwAddress", "s", NM_WIFI_AP_HW_ADDRESS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Mode", "u", NM_WIFI_AP_MODE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("MaxBitrate", "u", NM_WIFI_AP_MAX_BITRATE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Strength", "y", NM_WIFI_AP_STRENGTH),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("LastSeen", "i", NM_WIFI_AP_LAST_SEEN),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_wifi_ap_class_init (NMWifiAPClass *ap_class) nm_wifi_ap_class_init (NMWifiAPClass *ap_class)
{ {
@@ -1360,9 +1389,10 @@ nm_wifi_ap_class_init (NMWifiAPClass *ap_class)
| NM_802_11_AP_SEC_KEY_MGMT_802_1X ) | NM_802_11_AP_SEC_KEY_MGMT_802_1X )
GObjectClass *object_class = G_OBJECT_CLASS (ap_class); GObjectClass *object_class = G_OBJECT_CLASS (ap_class);
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (ap_class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (ap_class);
exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH_ACCESS_POINT); dbus_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH_ACCESS_POINT);
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_access_point);
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->finalize = finalize; object_class->finalize = finalize;
@@ -1425,10 +1455,6 @@ nm_wifi_ap_class_init (NMWifiAPClass *ap_class)
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (ap_class),
NMDBUS_TYPE_ACCESS_POINT_SKELETON,
NULL);
} }
/*****************************************************************************/ /*****************************************************************************/
@@ -1487,7 +1513,7 @@ nm_wifi_aps_get_sorted_paths (GHashTable *aps, gboolean include_without_ssid)
const char *path; const char *path;
/* update @list inplace to hold instead the export-path. */ /* update @list inplace to hold instead the export-path. */
path = nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap)); path = nm_dbus_object_get_path (NM_DBUS_OBJECT (ap));
nm_assert (path); nm_assert (path);
list[j++] = (gpointer) path; list[j++] = (gpointer) path;
} }

View File

@@ -22,7 +22,7 @@
#ifndef __NM_WIFI_AP_H__ #ifndef __NM_WIFI_AP_H__
#define __NM_WIFI_AP_H__ #define __NM_WIFI_AP_H__
#include "nm-exported-object.h" #include "nm-dbus-object.h"
#include "nm-dbus-interface.h" #include "nm-dbus-interface.h"
#include "nm-connection.h" #include "nm-connection.h"

View File

@@ -0,0 +1,188 @@
/*-*- 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.
*
* (C) Copyright 2018 Red Hat, Inc.
*/
#include "nm-default.h"
#include "nm-wifi-common.h"
#include "devices/nm-device.h"
#include "nm-wifi-ap.h"
#include "nm-device-wifi.h"
#if WITH_IWD
#include "nm-device-iwd.h"
#endif
/*****************************************************************************/
static GHashTable *
_dispatch_get_aps (NMDevice *device)
{
#if WITH_IWD
if (NM_IS_DEVICE_IWD (device))
return _nm_device_iwd_get_aps (NM_DEVICE_IWD (device));
#endif
return _nm_device_wifi_get_aps (NM_DEVICE_WIFI (device));
}
static void
_dispatch_request_scan (NMDevice *device,
GVariant *options,
GDBusMethodInvocation *invocation)
{
#if WITH_IWD
if (NM_IS_DEVICE_IWD (device)) {
_nm_device_iwd_request_scan (NM_DEVICE_IWD (device),
options,
invocation);
}
#endif
_nm_device_wifi_request_scan (NM_DEVICE_WIFI (device),
options,
invocation);
}
static void
impl_device_wifi_get_access_points (NMDBusObject *obj,
const NMDBusInterfaceInfoExtended *interface_info,
const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{
gs_free const char **list = NULL;
GVariant *v;
GHashTable *aps;
/* NOTE: this handler is called both for NMDevicwWifi and NMDeviceIwd. */
aps = _dispatch_get_aps (NM_DEVICE (obj));
list = nm_wifi_aps_get_sorted_paths (aps, FALSE);
v = g_variant_new_objv (list, -1);
g_dbus_method_invocation_return_value (invocation,
g_variant_new_tuple (&v, 1));
}
static void
impl_device_wifi_get_all_access_points (NMDBusObject *obj,
const NMDBusInterfaceInfoExtended *interface_info,
const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{
gs_free const char **list = NULL;
GVariant *v;
GHashTable *aps;
/* NOTE: this handler is called both for NMDevicwWifi and NMDeviceIwd. */
aps = _dispatch_get_aps (NM_DEVICE (obj));
list = nm_wifi_aps_get_sorted_paths (aps, TRUE);
v = g_variant_new_objv (list, -1);
g_dbus_method_invocation_return_value (invocation,
g_variant_new_tuple (&v, 1));
}
static void
impl_device_wifi_request_scan (NMDBusObject *obj,
const NMDBusInterfaceInfoExtended *interface_info,
const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{
gs_unref_variant GVariant *options = NULL;
/* NOTE: this handler is called both for NMDevicwWifi and NMDeviceIwd. */
g_variant_get (parameters, "(@a{sv})", &options);
_dispatch_request_scan (NM_DEVICE (obj),
options,
invocation);
}
const GDBusSignalInfo nm_signal_info_wireless_access_point_added = NM_DEFINE_GDBUS_SIGNAL_INFO_INIT (
"AccessPointAdded",
.args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("access_point", "o"),
),
);
const GDBusSignalInfo nm_signal_info_wireless_access_point_removed = NM_DEFINE_GDBUS_SIGNAL_INFO_INIT (
"AccessPointRemoved",
.args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("access_point", "o"),
),
);
const NMDBusInterfaceInfoExtended nm_interface_info_device_wireless = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
.methods = NM_DEFINE_GDBUS_METHOD_INFOS (
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"GetAccessPoints",
.out_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("access_points", "ao"),
),
),
.handle = impl_device_wifi_get_access_points,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"GetAllAccessPoints",
.out_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("access_points", "ao"),
),
),
.handle = impl_device_wifi_get_all_access_points,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"RequestScan",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("options", "a{sv}"),
),
),
.handle = impl_device_wifi_request_scan,
),
),
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
&nm_signal_info_wireless_access_point_added,
&nm_signal_info_wireless_access_point_removed,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("HwAddress", "s", NM_DEVICE_HW_ADDRESS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("PermHwAddress", "s", NM_DEVICE_PERM_HW_ADDRESS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Mode", "u", NM_DEVICE_WIFI_MODE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("BitRate", "u", NM_DEVICE_WIFI_BITRATE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("AccessPoints", "ao", NM_DEVICE_WIFI_ACCESS_POINTS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("ActiveAccessPoint", "o", NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("WirelessCapabilities", "u", NM_DEVICE_WIFI_CAPABILITIES),
),
),
.legacy_property_changed = TRUE,
};

View File

@@ -0,0 +1,32 @@
/* -*- 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.
*
* (C) Copyright 2018 Red Hat, Inc.
*/
#ifndef __NM_WIFI_COMMON_H__
#define __NM_WIFI_COMMON_H__
#include "nm-dbus-utils.h"
/*****************************************************************************/
extern const NMDBusInterfaceInfoExtended nm_interface_info_device_wireless;
extern const GDBusSignalInfo nm_signal_info_wireless_access_point_added;
extern const GDBusSignalInfo nm_signal_info_wireless_access_point_removed;
#endif /* __NM_WIFI_COMMON_H__ */

View File

@@ -46,8 +46,6 @@ sources = files(
'nm-wwan-factory.c' 'nm-wwan-factory.c'
) )
deps += libnmdbus_dep
libnm_device_plugin_wwan = shared_module( libnm_device_plugin_wwan = shared_module(
'nm-device-plugin-wwan', 'nm-device-plugin-wwan',
sources: sources, sources: sources,

View File

@@ -32,8 +32,6 @@
#include "NetworkManagerUtils.h" #include "NetworkManagerUtils.h"
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Modem.h"
#include "devices/nm-device-logging.h" #include "devices/nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceModem); _LOG_DECLARE_SELF(NMDeviceModem);
@@ -741,16 +739,33 @@ dispose (GObject *object)
G_OBJECT_CLASS (nm_device_modem_parent_class)->dispose (object); G_OBJECT_CLASS (nm_device_modem_parent_class)->dispose (object);
} }
static const NMDBusInterfaceInfoExtended interface_info_device_modem = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DEVICE_MODEM,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("ModemCapabilities", "u", NM_DEVICE_MODEM_CAPABILITIES),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("CurrentCapabilities", "u", NM_DEVICE_MODEM_CURRENT_CAPABILITIES),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_device_modem_class_init (NMDeviceModemClass *mclass) nm_device_modem_class_init (NMDeviceModemClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (mclass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDeviceClass *device_class = NM_DEVICE_CLASS (mclass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
object_class->dispose = dispose; object_class->dispose = dispose;
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property; object_class->set_property = set_property;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_modem);
device_class->get_generic_capabilities = get_generic_capabilities; device_class->get_generic_capabilities = get_generic_capabilities;
device_class->get_type_description = get_type_description; device_class->get_type_description = get_type_description;
device_class->check_connection_compatible = check_connection_compatible; device_class->check_connection_compatible = check_connection_compatible;
@@ -793,8 +808,4 @@ nm_device_modem_class_init (NMDeviceModemClass *mclass)
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (mclass),
NMDBUS_TYPE_DEVICE_MODEM_SKELETON,
NULL);
} }

View File

@@ -60,7 +60,7 @@ const NMDhcpClientFactory *const _nm_dhcp_manager_factories[4] = {
/*****************************************************************************/ /*****************************************************************************/
typedef struct { typedef struct {
NMBusManager * dbus_mgr; NMDBusManager * dbus_mgr;
gulong new_conn_id; gulong new_conn_id;
gulong dis_conn_id; gulong dis_conn_id;
GHashTable * connections; GHashTable * connections;
@@ -192,15 +192,17 @@ _method_call (GDBusConnection *connection,
{ {
NMDhcpListener *self = NM_DHCP_LISTENER (user_data); NMDhcpListener *self = NM_DHCP_LISTENER (user_data);
if (!nm_streq0 (interface_name, NM_DHCP_HELPER_SERVER_INTERFACE_NAME)) if ( !nm_streq (interface_name, NM_DHCP_HELPER_SERVER_INTERFACE_NAME)
g_return_if_reached (); || !nm_streq (method_name, NM_DHCP_HELPER_SERVER_METHOD_NOTIFY)) {
if (!nm_streq0 (method_name, NM_DHCP_HELPER_SERVER_METHOD_NOTIFY)) g_dbus_method_invocation_return_error (invocation,
g_return_if_reached (); G_DBUS_ERROR,
if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(a{sv})"))) G_DBUS_ERROR_UNKNOWN_METHOD,
g_return_if_reached (); "Unknown method %s",
method_name);
return;
}
_method_call_handle (self, parameters); _method_call_handle (self, parameters);
g_dbus_method_invocation_return_value (invocation, NULL); g_dbus_method_invocation_return_value (invocation, NULL);
} }
@@ -235,7 +237,7 @@ _dbus_connection_register_object (NMDhcpListener *self,
} }
static void static void
new_connection_cb (NMBusManager *mgr, new_connection_cb (NMDBusManager *mgr,
GDBusConnection *connection, GDBusConnection *connection,
GDBusObjectManager *manager, GDBusObjectManager *manager,
NMDhcpListener *self) NMDhcpListener *self)
@@ -258,7 +260,7 @@ new_connection_cb (NMBusManager *mgr,
} }
static void static void
dis_connection_cb (NMBusManager *mgr, dis_connection_cb (NMDBusManager *mgr,
GDBusConnection *connection, GDBusConnection *connection,
NMDhcpListener *self) NMDhcpListener *self)
{ {
@@ -282,16 +284,16 @@ nm_dhcp_listener_init (NMDhcpListener *self)
/* Maps GDBusConnection :: signal-id */ /* Maps GDBusConnection :: signal-id */
priv->connections = g_hash_table_new (nm_direct_hash, NULL); priv->connections = g_hash_table_new (nm_direct_hash, NULL);
priv->dbus_mgr = nm_bus_manager_get (); priv->dbus_mgr = nm_dbus_manager_get ();
/* Register the socket our DHCP clients will return lease info on */ /* Register the socket our DHCP clients will return lease info on */
nm_bus_manager_private_server_register (priv->dbus_mgr, PRIV_SOCK_PATH, PRIV_SOCK_TAG); nm_dbus_manager_private_server_register (priv->dbus_mgr, PRIV_SOCK_PATH, PRIV_SOCK_TAG);
priv->new_conn_id = g_signal_connect (priv->dbus_mgr, priv->new_conn_id = g_signal_connect (priv->dbus_mgr,
NM_BUS_MANAGER_PRIVATE_CONNECTION_NEW "::" PRIV_SOCK_TAG, NM_DBUS_MANAGER_PRIVATE_CONNECTION_NEW "::" PRIV_SOCK_TAG,
G_CALLBACK (new_connection_cb), G_CALLBACK (new_connection_cb),
self); self);
priv->dis_conn_id = g_signal_connect (priv->dbus_mgr, priv->dis_conn_id = g_signal_connect (priv->dbus_mgr,
NM_BUS_MANAGER_PRIVATE_CONNECTION_DISCONNECTED "::" PRIV_SOCK_TAG, NM_DBUS_MANAGER_PRIVATE_CONNECTION_DISCONNECTED "::" PRIV_SOCK_TAG,
G_CALLBACK (dis_connection_cb), G_CALLBACK (dis_connection_cb),
self); self);
} }

View File

@@ -408,7 +408,7 @@ start_dnsmasq (NMDnsDnsmasq *self)
const char *argv[15]; const char *argv[15];
GPid pid = 0; GPid pid = 0;
guint idx = 0; guint idx = 0;
NMBusManager *dbus_mgr; NMDBusManager *dbus_mgr;
GDBusConnection *connection; GDBusConnection *connection;
if (priv->running) { if (priv->running) {
@@ -460,10 +460,10 @@ start_dnsmasq (NMDnsDnsmasq *self)
return; return;
} }
dbus_mgr = nm_bus_manager_get (); dbus_mgr = nm_dbus_manager_get ();
g_return_if_fail (dbus_mgr); g_return_if_fail (dbus_mgr);
connection = nm_bus_manager_get_connection (dbus_mgr); connection = nm_dbus_manager_get_connection (dbus_mgr);
g_return_if_fail (connection); g_return_if_fail (connection);
priv->dnsmasq_cancellable = g_cancellable_new (); priv->dnsmasq_cancellable = g_cancellable_new ();

View File

@@ -46,6 +46,7 @@
#include "nm-ip6-config.h" #include "nm-ip6-config.h"
#include "NetworkManagerUtils.h" #include "NetworkManagerUtils.h"
#include "nm-config.h" #include "nm-config.h"
#include "nm-dbus-object.h"
#include "devices/nm-device.h" #include "devices/nm-device.h"
#include "nm-manager.h" #include "nm-manager.h"
@@ -54,8 +55,6 @@
#include "nm-dns-systemd-resolved.h" #include "nm-dns-systemd-resolved.h"
#include "nm-dns-unbound.h" #include "nm-dns-unbound.h"
#include "introspection/org.freedesktop.NetworkManager.DnsManager.h"
#define HASH_LEN 20 #define HASH_LEN 20
#ifndef RESOLVCONF_PATH #ifndef RESOLVCONF_PATH
@@ -135,15 +134,15 @@ typedef struct {
} NMDnsManagerPrivate; } NMDnsManagerPrivate;
struct _NMDnsManager { struct _NMDnsManager {
NMExportedObject parent; NMDBusObject parent;
NMDnsManagerPrivate _priv; NMDnsManagerPrivate _priv;
}; };
struct _NMDnsManagerClass { struct _NMDnsManagerClass {
NMExportedObjectClass parent; NMDBusObjectClass parent;
}; };
G_DEFINE_TYPE (NMDnsManager, nm_dns_manager, NM_TYPE_EXPORTED_OBJECT) G_DEFINE_TYPE (NMDnsManager, nm_dns_manager, NM_TYPE_DBUS_OBJECT)
#define NM_DNS_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDnsManager, NM_IS_DNS_MANAGER) #define NM_DNS_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDnsManager, NM_IS_DNS_MANAGER)
@@ -2107,18 +2106,30 @@ finalize (GObject *object)
G_OBJECT_CLASS (nm_dns_manager_parent_class)->finalize (object); G_OBJECT_CLASS (nm_dns_manager_parent_class)->finalize (object);
} }
static const NMDBusInterfaceInfoExtended interface_info_dns_manager = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DNS_MANAGER,
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Mode", "s", NM_DNS_MANAGER_MODE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("RcManager", "s", NM_DNS_MANAGER_RC_MANAGER),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Configuration", "aa{sv}", NM_DNS_MANAGER_CONFIGURATION),
),
),
};
static void static void
nm_dns_manager_class_init (NMDnsManagerClass *klass) nm_dns_manager_class_init (NMDnsManagerClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
object_class->dispose = dispose; object_class->dispose = dispose;
object_class->finalize = finalize; object_class->finalize = finalize;
object_class->get_property = get_property; object_class->get_property = get_property;
exported_object_class->export_path = NM_DBUS_PATH "/DnsManager"; dbus_object_class->export_path = NM_DBUS_PATH "/DnsManager";
exported_object_class->export_on_construction = TRUE; dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_dns_manager);
dbus_object_class->export_on_construction = TRUE;
obj_properties[PROP_MODE] = obj_properties[PROP_MODE] =
g_param_spec_string (NM_DNS_MANAGER_MODE, "", "", g_param_spec_string (NM_DNS_MANAGER_MODE, "", "",
@@ -2148,8 +2159,4 @@ nm_dns_manager_class_init (NMDnsManagerClass *klass)
0, NULL, NULL, 0, NULL, NULL,
g_cclosure_marshal_VOID__VOID, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DNS_MANAGER_SKELETON,
NULL);
} }

View File

@@ -396,15 +396,15 @@ static void
nm_dns_systemd_resolved_init (NMDnsSystemdResolved *self) nm_dns_systemd_resolved_init (NMDnsSystemdResolved *self)
{ {
NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self); NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self);
NMBusManager *dbus_mgr; NMDBusManager *dbus_mgr;
GDBusConnection *connection; GDBusConnection *connection;
c_list_init (&priv->request_queue_lst_head); c_list_init (&priv->request_queue_lst_head);
dbus_mgr = nm_bus_manager_get (); dbus_mgr = nm_dbus_manager_get ();
g_return_if_fail (dbus_mgr); g_return_if_fail (dbus_mgr);
connection = nm_bus_manager_get_connection (dbus_mgr); connection = nm_dbus_manager_get_connection (dbus_mgr);
g_return_if_fail (connection); g_return_if_fail (connection);
priv->init_cancellable = g_cancellable_new (); priv->init_cancellable = g_cancellable_new ();

View File

@@ -48,7 +48,7 @@
#include "settings/nm-settings.h" #include "settings/nm-settings.h"
#include "nm-auth-manager.h" #include "nm-auth-manager.h"
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "nm-exported-object.h" #include "nm-dbus-object.h"
#include "nm-connectivity.h" #include "nm-connectivity.h"
#include "dns/nm-dns-manager.h" #include "dns/nm-dns-manager.h"
#include "systemd/nm-sd.h" #include "systemd/nm-sd.h"
@@ -225,6 +225,7 @@ int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
gboolean success = FALSE; gboolean success = FALSE;
NMManager *manager;
NMConfig *config; NMConfig *config;
GError *error = NULL; GError *error = NULL;
gboolean wrote_pidfile = FALSE; gboolean wrote_pidfile = FALSE;
@@ -236,7 +237,7 @@ main (int argc, char *argv[])
* https://bugzilla.gnome.org/show_bug.cgi?id=674885 */ * https://bugzilla.gnome.org/show_bug.cgi?id=674885 */
g_type_ensure (G_TYPE_SOCKET); g_type_ensure (G_TYPE_SOCKET);
g_type_ensure (G_TYPE_DBUS_CONNECTION); g_type_ensure (G_TYPE_DBUS_CONNECTION);
g_type_ensure (NM_TYPE_BUS_MANAGER); g_type_ensure (NM_TYPE_DBUS_MANAGER);
_nm_utils_is_manager_process = TRUE; _nm_utils_is_manager_process = TRUE;
@@ -394,27 +395,22 @@ main (int argc, char *argv[])
NM_CONFIG_KEYFILE_KEY_MAIN_AUTH_POLKIT, NM_CONFIG_KEYFILE_KEY_MAIN_AUTH_POLKIT,
NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT_BOOL)); NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT_BOOL));
nm_manager_setup (); manager = nm_manager_setup ();
if (!nm_bus_manager_get_connection (nm_bus_manager_get ())) { if (!nm_dbus_manager_start (nm_dbus_manager_get (),
nm_log_warn (LOGD_CORE, "Failed to connect to D-Bus; only private bus is available"); nm_manager_dbus_set_property_handle,
} else { manager))
/* Start our DBus service */ goto done;
if (!nm_bus_manager_start_service (nm_bus_manager_get ())) {
nm_log_err (LOGD_CORE, "failed to start the dbus service.");
goto done;
}
}
#if WITH_CONCHECK #if WITH_CONCHECK
NM_UTILS_KEEP_ALIVE (nm_manager_get (), nm_connectivity_get (), "NMManager-depends-on-NMConnectivity"); NM_UTILS_KEEP_ALIVE (manager, nm_connectivity_get (), "NMManager-depends-on-NMConnectivity");
#endif #endif
nm_dispatcher_init (); nm_dispatcher_init ();
g_signal_connect (nm_manager_get (), NM_MANAGER_CONFIGURE_QUIT, G_CALLBACK (manager_configure_quit), config); g_signal_connect (manager, NM_MANAGER_CONFIGURE_QUIT, G_CALLBACK (manager_configure_quit), config);
if (!nm_manager_start (nm_manager_get (), &error)) { if (!nm_manager_start (manager, &error)) {
nm_log_err (LOGD_CORE, "failed to initialize: %s", error->message); nm_log_err (LOGD_CORE, "failed to initialize: %s", error->message);
goto done; goto done;
} }
@@ -448,11 +444,14 @@ done:
* state here. We don't bother updating the state as devices * state here. We don't bother updating the state as devices
* change during regular operation. If NM is killed with SIGKILL, * change during regular operation. If NM is killed with SIGKILL,
* it misses to update the state. */ * it misses to update the state. */
nm_manager_write_device_state (nm_manager_get ()); nm_manager_write_device_state (manager);
nm_exported_object_class_set_quitting (); /* FIXME: we don't properly shut down on exit. That is a bug.
* NMDBusObject have an assertion that they get unexported before disposing.
* We need this workaround and disable the assertion during our leaky shutdown. */
nm_dbus_object_set_quitting ();
nm_manager_stop (nm_manager_get ()); nm_manager_stop (manager);
nm_config_state_set (config, TRUE, TRUE); nm_config_state_set (config, TRUE, TRUE);

View File

@@ -65,14 +65,14 @@ sources = files(
'main-utils.c', 'main-utils.c',
'NetworkManagerUtils.c', 'NetworkManagerUtils.c',
'nm-core-utils.c', 'nm-core-utils.c',
'nm-exported-object.c', 'nm-dbus-object.c',
'nm-dbus-utils.c',
'nm-ip4-config.c', 'nm-ip4-config.c',
'nm-ip6-config.c', 'nm-ip6-config.c',
'nm-logging.c' 'nm-logging.c'
) )
deps = [ deps = [
libnmdbus_dep,
libsystemd_dep, libsystemd_dep,
libudev_dep, libudev_dep,
nm_core_dep nm_core_dep

View File

@@ -32,8 +32,6 @@
#include "NetworkManagerUtils.h" #include "NetworkManagerUtils.h"
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "introspection/org.freedesktop.NetworkManager.Connection.Active.h"
typedef struct _NMActiveConnectionPrivate { typedef struct _NMActiveConnectionPrivate {
NMSettingsConnection *settings_connection; NMSettingsConnection *settings_connection;
NMConnection *applied_connection; NMConnection *applied_connection;
@@ -103,12 +101,15 @@ enum {
}; };
static guint signals[LAST_SIGNAL] = { 0 }; static guint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_ABSTRACT_TYPE (NMActiveConnection, nm_active_connection, NM_TYPE_EXPORTED_OBJECT) G_DEFINE_ABSTRACT_TYPE (NMActiveConnection, nm_active_connection, NM_TYPE_DBUS_OBJECT)
#define NM_ACTIVE_CONNECTION_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR(self, NMActiveConnection, NM_IS_ACTIVE_CONNECTION) #define NM_ACTIVE_CONNECTION_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR(self, NMActiveConnection, NM_IS_ACTIVE_CONNECTION)
/*****************************************************************************/ /*****************************************************************************/
static const NMDBusInterfaceInfoExtended interface_info_active_connection;
static const GDBusSignalInfo signal_info_state_changed;
static void check_master_ready (NMActiveConnection *self); static void check_master_ready (NMActiveConnection *self);
static void _device_cleanup (NMActiveConnection *self); static void _device_cleanup (NMActiveConnection *self);
static void _settings_connection_notify_flags (NMSettingsConnection *settings_connection, static void _settings_connection_notify_flags (NMSettingsConnection *settings_connection,
@@ -191,8 +192,8 @@ _settings_connection_removed (NMSettingsConnection *connection,
* re-link; in that case we'd just clean the references to the old connection here). * re-link; in that case we'd just clean the references to the old connection here).
* Let's remove ourselves from the bus so that we're not exposed with a dangling * Let's remove ourselves from the bus so that we're not exposed with a dangling
* reference to the setting connection once it's gone. */ * reference to the setting connection once it's gone. */
if (nm_exported_object_is_exported (NM_EXPORTED_OBJECT (self))) if (nm_dbus_object_is_exported (NM_DBUS_OBJECT (self)))
nm_exported_object_unexport (NM_EXPORTED_OBJECT (self)); nm_dbus_object_unexport (NM_DBUS_OBJECT (self));
} }
static void static void
@@ -223,6 +224,18 @@ nm_active_connection_get_state (NMActiveConnection *self)
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->state; return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->state;
} }
static void
emit_state_changed (NMActiveConnection *self, guint state, guint reason)
{
nm_dbus_object_emit_signal (NM_DBUS_OBJECT (self),
&interface_info_active_connection,
&signal_info_state_changed,
"(uu)",
(guint32) state,
(guint32) reason);
g_signal_emit (self, signals[STATE_CHANGED], 0, state, reason);
}
void void
nm_active_connection_set_state (NMActiveConnection *self, nm_active_connection_set_state (NMActiveConnection *self,
NMActiveConnectionState new_state, NMActiveConnectionState new_state,
@@ -253,7 +266,7 @@ nm_active_connection_set_state (NMActiveConnection *self,
old_state = priv->state; old_state = priv->state;
priv->state = new_state; priv->state = new_state;
priv->state_set = TRUE; priv->state_set = TRUE;
g_signal_emit (self, signals[STATE_CHANGED], 0, (guint) new_state, (guint) reason); emit_state_changed (self, new_state, reason);
_notify (self, PROP_STATE); _notify (self, PROP_STATE);
check_master_ready (self); check_master_ready (self);
@@ -451,7 +464,7 @@ nm_active_connection_set_settings_connection (NMActiveConnection *self,
* never changes (once it's set). That has effects for NMVpnConnection and * never changes (once it's set). That has effects for NMVpnConnection and
* NMActivationRequest. * NMActivationRequest.
* For example, we'd have to cancel all pending seret requests. */ * For example, we'd have to cancel all pending seret requests. */
g_return_if_fail (!nm_exported_object_is_exported (NM_EXPORTED_OBJECT (self))); g_return_if_fail (!nm_dbus_object_is_exported (NM_DBUS_OBJECT (self)));
_set_settings_connection (self, connection); _set_settings_connection (self, connection);
@@ -810,7 +823,7 @@ nm_active_connection_set_master (NMActiveConnection *self, NMActiveConnection *m
/* Master is write-once, and must be set before exporting the object */ /* Master is write-once, and must be set before exporting the object */
g_return_if_fail (priv->master == NULL); g_return_if_fail (priv->master == NULL);
g_return_if_fail (!nm_exported_object_is_exported (NM_EXPORTED_OBJECT (self))); g_return_if_fail (!nm_dbus_object_is_exported (NM_DBUS_OBJECT (self)));
if (priv->device) { if (priv->device) {
/* Note, the master ActiveConnection may not yet have a device */ /* Note, the master ActiveConnection may not yet have a device */
g_return_if_fail (priv->device != nm_active_connection_get_device (master)); g_return_if_fail (priv->device != nm_active_connection_get_device (master));
@@ -1171,7 +1184,7 @@ get_property (GObject *object, guint prop_id,
case PROP_DEVICES: case PROP_DEVICES:
devices = g_ptr_array_sized_new (2); devices = g_ptr_array_sized_new (2);
if (priv->device && priv->state < NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) if (priv->device && priv->state < NM_ACTIVE_CONNECTION_STATE_DEACTIVATED)
g_ptr_array_add (devices, g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (priv->device)))); g_ptr_array_add (devices, g_strdup (nm_dbus_object_get_path (NM_DBUS_OBJECT (priv->device))));
g_ptr_array_add (devices, NULL); g_ptr_array_add (devices, NULL);
g_value_take_boxed (value, (char **) g_ptr_array_free (devices, FALSE)); g_value_take_boxed (value, (char **) g_ptr_array_free (devices, FALSE));
break; break;
@@ -1213,7 +1226,7 @@ get_property (GObject *object, guint prop_id,
case PROP_MASTER: case PROP_MASTER:
if (priv->master) if (priv->master)
master_device = nm_active_connection_get_device (priv->master); master_device = nm_active_connection_get_device (priv->master);
nm_utils_g_value_set_object_path (value, master_device); nm_dbus_utils_g_value_set_object_path (value, master_device);
break; break;
case PROP_INT_SUBJECT: case PROP_INT_SUBJECT:
g_value_set_object (value, priv->subject); g_value_set_object (value, priv->subject);
@@ -1389,22 +1402,59 @@ dispose (GObject *object)
G_OBJECT_CLASS (nm_active_connection_parent_class)->dispose (object); G_OBJECT_CLASS (nm_active_connection_parent_class)->dispose (object);
} }
static const GDBusSignalInfo signal_info_state_changed = NM_DEFINE_GDBUS_SIGNAL_INFO_INIT (
"StateChanged",
.args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("state", "u"),
NM_DEFINE_GDBUS_ARG_INFO ("reason", "u"),
),
);
static const NMDBusInterfaceInfoExtended interface_info_active_connection = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
&signal_info_state_changed,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Connection", "o", NM_ACTIVE_CONNECTION_CONNECTION),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("SpecificObject", "o", NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Id", "s", NM_ACTIVE_CONNECTION_ID),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Uuid", "s", NM_ACTIVE_CONNECTION_UUID),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Type", "s", NM_ACTIVE_CONNECTION_TYPE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Devices", "ao", NM_ACTIVE_CONNECTION_DEVICES),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("State", "u", NM_ACTIVE_CONNECTION_STATE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("StateFlags", "u", NM_ACTIVE_CONNECTION_STATE_FLAGS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Default", "b", NM_ACTIVE_CONNECTION_DEFAULT),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Ip4Config", "o", NM_ACTIVE_CONNECTION_IP4_CONFIG),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Dhcp4Config", "o", NM_ACTIVE_CONNECTION_DHCP4_CONFIG),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Default6", "b", NM_ACTIVE_CONNECTION_DEFAULT6),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Ip6Config", "o", NM_ACTIVE_CONNECTION_IP6_CONFIG),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Dhcp6Config", "o", NM_ACTIVE_CONNECTION_DHCP6_CONFIG),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Vpn", "b", NM_ACTIVE_CONNECTION_VPN),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Master", "o", NM_ACTIVE_CONNECTION_MASTER),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_active_connection_class_init (NMActiveConnectionClass *ac_class) nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (ac_class); GObjectClass *object_class = G_OBJECT_CLASS (ac_class);
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (ac_class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (ac_class);
g_type_class_add_private (ac_class, sizeof (NMActiveConnectionPrivate)); g_type_class_add_private (ac_class, sizeof (NMActiveConnectionPrivate));
exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/ActiveConnection"); dbus_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/ActiveConnection");
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_active_connection);
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property; object_class->set_property = set_property;
object_class->constructed = constructed; object_class->constructed = constructed;
object_class->dispose = dispose; object_class->dispose = dispose;
/* D-Bus exported properties */
obj_properties[PROP_CONNECTION] = obj_properties[PROP_CONNECTION] =
g_param_spec_string (NM_ACTIVE_CONNECTION_CONNECTION, "", "", g_param_spec_string (NM_ACTIVE_CONNECTION_CONNECTION, "", "",
NULL, NULL,
@@ -1580,9 +1630,4 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
0, NULL, NULL, NULL, 0, NULL, NULL, NULL,
G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (ac_class),
NMDBUS_TYPE_ACTIVE_CONNECTION_SKELETON,
NULL);
} }

View File

@@ -21,10 +21,9 @@
#ifndef __NETWORKMANAGER_ACTIVE_CONNECTION_H__ #ifndef __NETWORKMANAGER_ACTIVE_CONNECTION_H__
#define __NETWORKMANAGER_ACTIVE_CONNECTION_H__ #define __NETWORKMANAGER_ACTIVE_CONNECTION_H__
#include "nm-exported-object.h"
#include "nm-connection.h"
#include "nm-utils/c-list.h" #include "nm-utils/c-list.h"
#include "nm-connection.h"
#include "nm-dbus-object.h"
#define NM_TYPE_ACTIVE_CONNECTION (nm_active_connection_get_type ()) #define NM_TYPE_ACTIVE_CONNECTION (nm_active_connection_get_type ())
#define NM_ACTIVE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnection)) #define NM_ACTIVE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnection))
@@ -71,7 +70,7 @@
struct _NMActiveConnectionPrivate; struct _NMActiveConnectionPrivate;
struct _NMActiveConnection { struct _NMActiveConnection {
NMExportedObject parent; NMDBusObject parent;
struct _NMActiveConnectionPrivate *_priv; struct _NMActiveConnectionPrivate *_priv;
/* active connection can be tracked in a list by NMManager. This is /* active connection can be tracked in a list by NMManager. This is
@@ -80,7 +79,7 @@ struct _NMActiveConnection {
}; };
typedef struct { typedef struct {
NMExportedObjectClass parent; NMDBusObjectClass parent;
/* re-emits device state changes as a convenience for subclasses for /* re-emits device state changes as a convenience for subclasses for
* device states >= DISCONNECTED. * device states >= DISCONNECTED.

View File

@@ -186,18 +186,18 @@ _new_unix_process (GDBusMethodInvocation *context,
g_return_val_if_fail (context || (connection && message), NULL); g_return_val_if_fail (context || (connection && message), NULL);
if (context) { if (context) {
success = nm_bus_manager_get_caller_info (nm_bus_manager_get (), success = nm_dbus_manager_get_caller_info (nm_dbus_manager_get (),
context, context,
&dbus_sender, &dbus_sender,
&uid, &uid,
&pid); &pid);
} else if (message) { } else if (message) {
success = nm_bus_manager_get_caller_info_from_message (nm_bus_manager_get (), success = nm_dbus_manager_get_caller_info_from_message (nm_dbus_manager_get (),
connection, connection,
message, message,
&dbus_sender, &dbus_sender,
&uid, &uid,
&pid); &pid);
} else } else
g_assert_not_reached (); g_assert_not_reached ();

View File

@@ -26,7 +26,6 @@
#include "nm-connection.h" #include "nm-connection.h"
#include "nm-core-utils.h" #include "nm-core-utils.h"
#include "devices/nm-device.h" #include "devices/nm-device.h"
#include "nm-exported-object.h"
#include "nm-manager.h" #include "nm-manager.h"
#include "nm-utils.h" #include "nm-utils.h"
#include "nm-utils/c-list.h" #include "nm-utils/c-list.h"
@@ -78,7 +77,7 @@ item_destroy (gpointer data)
CheckpointItem *item = data; CheckpointItem *item = data;
c_list_unlink_stale (&item->list); c_list_unlink_stale (&item->list);
nm_exported_object_unexport (NM_EXPORTED_OBJECT (item->checkpoint)); nm_dbus_object_unexport (NM_DBUS_OBJECT (item->checkpoint));
g_object_unref (G_OBJECT (item->checkpoint)); g_object_unref (G_OBJECT (item->checkpoint));
g_slice_free (CheckpointItem, item); g_slice_free (CheckpointItem, item);
} }
@@ -100,7 +99,7 @@ rollback_timeout_cb (NMCheckpointManager *self)
result = nm_checkpoint_rollback (item->checkpoint); result = nm_checkpoint_rollback (item->checkpoint);
if (result) if (result)
g_variant_unref (result); g_variant_unref (result);
path = nm_exported_object_get_path (NM_EXPORTED_OBJECT (item->checkpoint)); path = nm_dbus_object_get_path (NM_DBUS_OBJECT (item->checkpoint));
if (!g_hash_table_remove (self->checkpoints, path)) if (!g_hash_table_remove (self->checkpoints, path))
nm_assert_not_reached(); nm_assert_not_reached();
removed = TRUE; removed = TRUE;
@@ -185,7 +184,7 @@ nm_checkpoint_manager_create (NMCheckpointManager *self,
device = NM_DEVICE (iter->data); device = NM_DEVICE (iter->data);
if (!nm_device_is_real (device)) if (!nm_device_is_real (device))
continue; continue;
device_path = nm_exported_object_get_path (NM_EXPORTED_OBJECT (device)); device_path = nm_dbus_object_get_path (NM_DBUS_OBJECT (device));
if (device_path) if (device_path)
g_ptr_array_add (paths, (gpointer) device_path); g_ptr_array_add (paths, (gpointer) device_path);
} }
@@ -217,7 +216,7 @@ nm_checkpoint_manager_create (NMCheckpointManager *self,
g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_INVALID_ARGUMENTS, g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_INVALID_ARGUMENTS,
"device '%s' is already included in checkpoint %s", "device '%s' is already included in checkpoint %s",
nm_device_get_iface (device), nm_device_get_iface (device),
nm_exported_object_get_path (NM_EXPORTED_OBJECT (checkpoint))); nm_dbus_object_get_path (NM_DBUS_OBJECT (checkpoint)));
return NULL; return NULL;
} }
} }
@@ -230,8 +229,7 @@ nm_checkpoint_manager_create (NMCheckpointManager *self,
if (NM_FLAGS_HAS (flags, NM_CHECKPOINT_CREATE_FLAG_DESTROY_ALL)) if (NM_FLAGS_HAS (flags, NM_CHECKPOINT_CREATE_FLAG_DESTROY_ALL))
g_hash_table_remove_all (self->checkpoints); g_hash_table_remove_all (self->checkpoints);
nm_exported_object_export (NM_EXPORTED_OBJECT (checkpoint)); checkpoint_path = nm_dbus_object_export (NM_DBUS_OBJECT (checkpoint));
checkpoint_path = nm_exported_object_get_path (NM_EXPORTED_OBJECT (checkpoint));
item = g_slice_new0 (CheckpointItem); item = g_slice_new0 (CheckpointItem);
item->checkpoint = checkpoint; item->checkpoint = checkpoint;
@@ -326,7 +324,7 @@ nm_checkpoint_manager_get_checkpoint_paths (NMCheckpointManager *self)
strv = g_new (char *, num + 1); strv = g_new (char *, num + 1);
c_list_for_each_entry (item, &self->list, list) c_list_for_each_entry (item, &self->list, list)
strv[i++] = g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (item->checkpoint))); strv[i++] = g_strdup (nm_dbus_object_get_path (NM_DBUS_OBJECT (item->checkpoint)));
nm_assert (i == num); nm_assert (i == num);
strv[i] = NULL; strv[i] = NULL;

View File

@@ -34,7 +34,6 @@
#include "settings/nm-settings-connection.h" #include "settings/nm-settings-connection.h"
#include "nm-simple-connection.h" #include "nm-simple-connection.h"
#include "nm-utils.h" #include "nm-utils.h"
#include "introspection/org.freedesktop.NetworkManager.Checkpoint.h"
/*****************************************************************************/ /*****************************************************************************/
@@ -68,15 +67,15 @@ typedef struct {
} NMCheckpointPrivate; } NMCheckpointPrivate;
struct _NMCheckpoint { struct _NMCheckpoint {
NMExportedObject parent; NMDBusObject parent;
NMCheckpointPrivate _priv; NMCheckpointPrivate _priv;
}; };
struct _NMCheckpointClass { struct _NMCheckpointClass {
NMExportedObjectClass parent; NMDBusObjectClass parent;
}; };
G_DEFINE_TYPE (NMCheckpoint, nm_checkpoint, NM_TYPE_EXPORTED_OBJECT) G_DEFINE_TYPE (NMCheckpoint, nm_checkpoint, NM_TYPE_DBUS_OBJECT)
#define NM_CHECKPOINT_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMCheckpoint, NM_IS_CHECKPOINT) #define NM_CHECKPOINT_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMCheckpoint, NM_IS_CHECKPOINT)
@@ -183,7 +182,7 @@ nm_checkpoint_rollback (NMCheckpoint *self)
GError *local_error = NULL; GError *local_error = NULL;
GVariantBuilder builder; GVariantBuilder builder;
_LOGI ("rollback of %s", nm_exported_object_get_path ((NMExportedObject *) self)); _LOGI ("rollback of %s", nm_dbus_object_get_path (NM_DBUS_OBJECT (self)));
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{su}")); g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{su}"));
/* Start rolling-back each device */ /* Start rolling-back each device */
@@ -382,7 +381,7 @@ device_checkpoint_create (NMDevice *device,
const char *path; const char *path;
NMActRequest *act_request; NMActRequest *act_request;
path = nm_exported_object_get_path (NM_EXPORTED_OBJECT (device)); path = nm_dbus_object_get_path (NM_DBUS_OBJECT (device));
dev_checkpoint = g_slice_new0 (DeviceCheckpoint); dev_checkpoint = g_slice_new0 (DeviceCheckpoint);
dev_checkpoint->device = g_object_ref (device); dev_checkpoint->device = g_object_ref (device);
@@ -392,7 +391,7 @@ device_checkpoint_create (NMDevice *device,
if (nm_device_get_unmanaged_mask (device, NM_UNMANAGED_USER_EXPLICIT)) { if (nm_device_get_unmanaged_mask (device, NM_UNMANAGED_USER_EXPLICIT)) {
dev_checkpoint->unmanaged_explicit = dev_checkpoint->unmanaged_explicit =
!!nm_device_get_unmanaged_flags (device, NM_UNMANAGED_USER_EXPLICIT); !!nm_device_get_unmanaged_flags (device, NM_UNMANAGED_USER_EXPLICIT);
} else } else
dev_checkpoint->unmanaged_explicit = NM_UNMAN_FLAG_OP_FORGET; dev_checkpoint->unmanaged_explicit = NM_UNMAN_FLAG_OP_FORGET;
@@ -445,7 +444,7 @@ get_property (GObject *object, guint prop_id,
g_hash_table_iter_init (&iter, priv->devices); g_hash_table_iter_init (&iter, priv->devices);
while (g_hash_table_iter_next (&iter, (gpointer *) &device, NULL)) while (g_hash_table_iter_next (&iter, (gpointer *) &device, NULL))
devices = g_slist_append (devices, device); devices = g_slist_append (devices, device);
nm_utils_g_value_set_object_path_array (value, devices, NULL, NULL); nm_dbus_utils_g_value_set_object_path_array (value, devices, NULL, NULL);
break; break;
case PROP_CREATED: case PROP_CREATED:
g_value_set_int64 (value, priv->created); g_value_set_int64 (value, priv->created);
@@ -538,14 +537,29 @@ dispose (GObject *object)
G_OBJECT_CLASS (nm_checkpoint_parent_class)->dispose (object); G_OBJECT_CLASS (nm_checkpoint_parent_class)->dispose (object);
} }
static const NMDBusInterfaceInfoExtended interface_info_checkpoint = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_CHECKPOINT,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Devices", "ao", NM_CHECKPOINT_DEVICES),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Created", "x", NM_CHECKPOINT_CREATED),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("RollbackTimeout", "u", NM_CHECKPOINT_ROLLBACK_TIMEOUT),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_checkpoint_class_init (NMCheckpointClass *checkpoint_class) nm_checkpoint_class_init (NMCheckpointClass *checkpoint_class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (checkpoint_class); GObjectClass *object_class = G_OBJECT_CLASS (checkpoint_class);
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (checkpoint_class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (checkpoint_class);
exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/Checkpoint"); dbus_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/Checkpoint");
exported_object_class->export_on_construction = FALSE; dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_checkpoint);
object_class->dispose = dispose; object_class->dispose = dispose;
object_class->get_property = get_property; object_class->get_property = get_property;
@@ -569,8 +583,4 @@ nm_checkpoint_class_init (NMCheckpointClass *checkpoint_class)
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (checkpoint_class),
NMDBUS_TYPE_CHECKPOINT_SKELETON,
NULL);
} }

View File

@@ -21,7 +21,7 @@
#ifndef __NETWORKMANAGER_CHECKPOINT_H__ #ifndef __NETWORKMANAGER_CHECKPOINT_H__
#define __NETWORKMANAGER_CHECKPOINT_H__ #define __NETWORKMANAGER_CHECKPOINT_H__
#include "nm-exported-object.h" #include "nm-dbus-object.h"
#include "nm-dbus-interface.h" #include "nm-dbus-interface.h"
#define NM_TYPE_CHECKPOINT (nm_checkpoint_get_type ()) #define NM_TYPE_CHECKPOINT (nm_checkpoint_get_type ())

File diff suppressed because it is too large Load Diff

View File

@@ -19,75 +19,89 @@
* Copyright (C) 2006 - 2008 Novell, Inc. * Copyright (C) 2006 - 2008 Novell, Inc.
*/ */
#ifndef __NM_BUS_MANAGER_H__ #ifndef __NM_DBUS_MANAGER_H__
#define __NM_BUS_MANAGER_H__ #define __NM_DBUS_MANAGER_H__
#define NM_TYPE_BUS_MANAGER (nm_bus_manager_get_type ()) #include "nm-dbus-utils.h"
#define NM_BUS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NM_TYPE_BUS_MANAGER, NMBusManager))
#define NM_BUS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NM_TYPE_BUS_MANAGER, NMBusManagerClass))
#define NM_IS_BUS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NM_TYPE_BUS_MANAGER))
#define NM_IS_BUS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NM_TYPE_BUS_MANAGER))
#define NM_BUS_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NM_TYPE_BUS_MANAGER, NMBusManagerClass))
#define NM_BUS_MANAGER_DBUS_CONNECTION_CHANGED "dbus-connection-changed" #define NM_TYPE_DBUS_MANAGER (nm_dbus_manager_get_type ())
#define NM_BUS_MANAGER_PRIVATE_CONNECTION_NEW "private-connection-new" #define NM_DBUS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NM_TYPE_DBUS_MANAGER, NMDBusManager))
#define NM_BUS_MANAGER_PRIVATE_CONNECTION_DISCONNECTED "private-connection-disconnected" #define NM_DBUS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NM_TYPE_DBUS_MANAGER, NMDBusManagerClass))
#define NM_IS_DBUS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NM_TYPE_DBUS_MANAGER))
#define NM_IS_DBUS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NM_TYPE_DBUS_MANAGER))
#define NM_DBUS_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NM_TYPE_DBUS_MANAGER, NMDBusManagerClass))
typedef struct _NMBusManagerClass NMBusManagerClass; #define NM_DBUS_MANAGER_PRIVATE_CONNECTION_NEW "private-connection-new"
#define NM_DBUS_MANAGER_PRIVATE_CONNECTION_DISCONNECTED "private-connection-disconnected"
GType nm_bus_manager_get_type (void); typedef struct _NMDBusManagerClass NMDBusManagerClass;
NMBusManager * nm_bus_manager_get (void); GType nm_dbus_manager_get_type (void);
void nm_bus_manager_setup (NMBusManager *instance);
gboolean nm_bus_manager_start_service (NMBusManager *self); NMDBusManager *nm_dbus_manager_get (void);
GDBusConnection * nm_bus_manager_get_connection (NMBusManager *self); typedef void (*NMDBusManagerSetPropertyHandler) (NMDBusObject *obj,
const NMDBusInterfaceInfoExtended *interface_info,
const NMDBusPropertyInfoExtended *property_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *value,
gpointer user_data);
gboolean nm_bus_manager_get_caller_info (NMBusManager *self, gboolean nm_dbus_manager_start (NMDBusManager *self,
GDBusMethodInvocation *context, NMDBusManagerSetPropertyHandler handler,
char **out_sender, gpointer handler_data);
gulong *out_uid,
gulong *out_pid);
gboolean nm_bus_manager_ensure_uid (NMBusManager *self, GDBusConnection *nm_dbus_manager_get_connection (NMDBusManager *self);
GDBusMethodInvocation *context,
gulong uid,
GQuark error_domain,
int error_code);
const char *nm_bus_manager_connection_get_private_name (NMBusManager *self, NMDBusObject *nm_dbus_manager_lookup_object (NMDBusManager *self, const char *path);
GDBusConnection *connection);
gboolean nm_bus_manager_get_unix_user (NMBusManager *self, void _nm_dbus_manager_obj_export (NMDBusObject *obj);
const char *sender, void _nm_dbus_manager_obj_unexport (NMDBusObject *obj);
gulong *out_uid); void _nm_dbus_manager_obj_notify (NMDBusObject *obj,
guint n_pspecs,
const GParamSpec *const*pspecs);
void _nm_dbus_manager_obj_emit_signal (NMDBusObject *obj,
const NMDBusInterfaceInfoExtended *interface_info,
const GDBusSignalInfo *signal_info,
GVariant *args);
gboolean nm_bus_manager_get_caller_info_from_message (NMBusManager *self, gboolean nm_dbus_manager_get_caller_info (NMDBusManager *self,
GDBusConnection *connection, GDBusMethodInvocation *context,
GDBusMessage *message, char **out_sender,
char **out_sender, gulong *out_uid,
gulong *out_uid, gulong *out_pid);
gulong *out_pid);
void nm_bus_manager_register_object (NMBusManager *self, gboolean nm_dbus_manager_ensure_uid (NMDBusManager *self,
GDBusObjectSkeleton *object); GDBusMethodInvocation *context,
gulong uid,
GQuark error_domain,
int error_code);
void nm_bus_manager_unregister_object (NMBusManager *self, const char *nm_dbus_manager_connection_get_private_name (NMDBusManager *self,
GDBusObjectSkeleton *object); GDBusConnection *connection);
GDBusObjectSkeleton *nm_bus_manager_get_registered_object (NMBusManager *self, gboolean nm_dbus_manager_get_unix_user (NMDBusManager *self,
const char *path); const char *sender,
gulong *out_uid);
void nm_bus_manager_private_server_register (NMBusManager *self, gboolean nm_dbus_manager_get_caller_info_from_message (NMDBusManager *self,
const char *path, GDBusConnection *connection,
const char *tag); GDBusMessage *message,
char **out_sender,
gulong *out_uid,
gulong *out_pid);
GDBusProxy *nm_bus_manager_new_proxy (NMBusManager *self, void nm_dbus_manager_private_server_register (NMDBusManager *self,
GDBusConnection *connection, const char *path,
GType proxy_type, const char *tag);
const char *name,
const char *path,
const char *iface);
#endif /* __NM_BUS_MANAGER_H__ */ GDBusProxy *nm_dbus_manager_new_proxy (NMDBusManager *self,
GDBusConnection *connection,
GType proxy_type,
const char *name,
const char *path,
const char *iface);
#endif /* __NM_DBUS_MANAGER_H__ */

319
src/nm-dbus-object.c Normal file
View File

@@ -0,0 +1,319 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright 2018 Red Hat, Inc.
*/
#include "nm-default.h"
#include "nm-dbus-object.h"
#include "nm-dbus-manager.h"
/*****************************************************************************/
static gboolean quitting = FALSE;
void
nm_dbus_object_set_quitting (void)
{
nm_assert (!quitting);
quitting = TRUE;
}
/*****************************************************************************/
NM_GOBJECT_PROPERTIES_DEFINE (NMDBusObject,
PROP_PATH,
);
G_DEFINE_ABSTRACT_TYPE (NMDBusObject, nm_dbus_object, G_TYPE_OBJECT);
/*****************************************************************************/
#define _NMLOG_DOMAIN LOGD_CORE
#define _NMLOG(level, ...) __NMLOG_DEFAULT_WITH_ADDR (level, _NMLOG_DOMAIN, "dbus-object", __VA_ARGS__)
#define _NMLOG2_DOMAIN LOGD_DBUS_PROPS
#define _NMLOG2(level, ...) __NMLOG_DEFAULT_WITH_ADDR (level, _NMLOG2_DOMAIN, "properties-changed", __VA_ARGS__)
/*****************************************************************************/
static char *
_create_export_path (NMDBusObjectClass *klass)
{
const char *class_export_path, *p;
static GHashTable *prefix_counters;
guint64 *counter;
class_export_path = klass->export_path;
nm_assert (class_export_path);
p = strchr (class_export_path, '%');
if (p) {
if (G_UNLIKELY (!prefix_counters))
prefix_counters = g_hash_table_new (nm_str_hash, g_str_equal);
nm_assert (p[1] == 'l');
nm_assert (p[2] == 'l');
nm_assert (p[3] == 'u');
nm_assert (p[4] == '\0');
counter = g_hash_table_lookup (prefix_counters, class_export_path);
if (!counter) {
counter = g_slice_new0 (guint64);
g_hash_table_insert (prefix_counters, (char *) class_export_path, counter);
}
NM_PRAGMA_WARNING_DISABLE("-Wformat-nonliteral")
return g_strdup_printf (class_export_path, (unsigned long long) (++(*counter)));
NM_PRAGMA_WARNING_REENABLE
}
return g_strdup (class_export_path);
}
/**
* nm_dbus_object_export:
* @self: an #NMDBusObject
*
* Exports @self on all active and future D-Bus connections.
*
* The path to export @self on is taken from its #NMObjectClass's %export_path
* member. If the %export_path contains "%u", then it will be replaced with a
* monotonically increasing integer ID (with each distinct %export_path having
* its own counter). Otherwise, %export_path will be used literally (implying
* that @self must be a singleton).
*
* Returns: the path @self was exported under
*/
const char *
nm_dbus_object_export (NMDBusObject *self)
{
static guint64 id_counter = 0;
g_return_val_if_fail (NM_IS_DBUS_OBJECT (self), NULL);
g_return_val_if_fail (!self->internal.path, self->internal.path);
self->internal.path = _create_export_path (NM_DBUS_OBJECT_GET_CLASS (self));
self->internal.export_version_id = ++id_counter;
_LOGT ("export: \"%s\"", self->internal.path);
_nm_dbus_manager_obj_export (self);
_notify (self, PROP_PATH);
return self->internal.path;
}
/**
* nm_dbus_object_unexport:
* @self: an #NMDBusObject
*
* Unexports @self on all active D-Bus connections (and prevents it from being
* auto-exported on future connections).
*/
void
nm_dbus_object_unexport (NMDBusObject *self)
{
g_return_if_fail (NM_IS_DBUS_OBJECT (self));
g_return_if_fail (self->internal.path);
_LOGT ("unexport: \"%s\"", self->internal.path);
_nm_dbus_manager_obj_unexport (self);
g_clear_pointer (&self->internal.path, g_free);
self->internal.export_version_id = 0;
_notify (self, PROP_PATH);
}
/*****************************************************************************/
void
_nm_dbus_object_clear_and_unexport (NMDBusObject **location)
{
NMDBusObject *self;
g_return_if_fail (location);
if (!*location)
return;
self = g_steal_pointer (location);
g_return_if_fail (NM_IS_DBUS_OBJECT (self));
if (self->internal.path)
nm_dbus_object_unexport (self);
g_object_unref (self);
}
/*****************************************************************************/
void
nm_dbus_object_emit_signal_variant (NMDBusObject *self,
const NMDBusInterfaceInfoExtended *interface_info,
const GDBusSignalInfo *signal_info,
GVariant *args)
{
if (!self->internal.path) {
nm_g_variant_unref_floating (args);
return;
}
_nm_dbus_manager_obj_emit_signal (self, interface_info, signal_info, args);
}
void
nm_dbus_object_emit_signal (NMDBusObject *self,
const NMDBusInterfaceInfoExtended *interface_info,
const GDBusSignalInfo *signal_info,
const char *format,
...)
{
va_list ap;
nm_assert (NM_IS_DBUS_OBJECT (self));
nm_assert (format);
if (!self->internal.path)
return;
va_start (ap, format);
_nm_dbus_manager_obj_emit_signal (self,
interface_info,
signal_info,
g_variant_new_va (format, NULL, &ap));
va_end (ap);
}
/*****************************************************************************/
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMDBusObject *self = NM_DBUS_OBJECT (object);
switch (prop_id) {
case PROP_PATH:
g_value_set_string (value, self->internal.path);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
dispatch_properties_changed (GObject *object,
guint n_pspecs,
GParamSpec **pspecs)
{
NMDBusObject *self = NM_DBUS_OBJECT (object);
if (self->internal.path)
_nm_dbus_manager_obj_notify (self, n_pspecs, (const GParamSpec *const*) pspecs);
G_OBJECT_CLASS (nm_dbus_object_parent_class)->dispatch_properties_changed (object, n_pspecs, pspecs);
}
/*****************************************************************************/
static void
nm_dbus_object_init (NMDBusObject *self)
{
c_list_init (&self->internal.objects_lst);
c_list_init (&self->internal.registration_lst_head);
self->internal.bus_manager = nm_g_object_ref (nm_dbus_manager_get ());
}
static void
constructed (GObject *object)
{
NMDBusObjectClass *klass;
G_OBJECT_CLASS (nm_dbus_object_parent_class)->constructed (object);
klass = NM_DBUS_OBJECT_GET_CLASS (object);
if (klass->export_on_construction)
nm_dbus_object_export ((NMDBusObject *) object);
/* NMDBusObject types should be very careful when overwriting notify().
* It is possible to do, but this is a reminder that it's probably not
* a good idea.
*
* It's not a good idea, because NMDBusObject uses dispatch_properties_changed()
* to emit signals about a bunch of property changes. So, we want to make
* use of g_object_freeze_notify() / g_object_thaw_notify() to combine multiple
* property changes in one signal on D-Bus. Note that notify() is not invoked
* while the signal is frozen, that means, whatever you do inside notify()
* will not make it into the same batch of PropertiesChanged signal. That is
* confusing, and probably not what you want.
*
* Simple solution: don't overwrite notify(). */
nm_assert (!G_OBJECT_CLASS (klass)->notify);
}
static void
dispose (GObject *object)
{
NMDBusObject *self = NM_DBUS_OBJECT (object);
/* Objects should have already been unexported by their owner, unless
* we are quitting, where many objects stick around until exit.
*/
if (!quitting) {
if (self->internal.path) {
g_warn_if_reached ();
nm_dbus_object_unexport (self);
}
} else if (nm_clear_g_free (&self->internal.path)) {
/* FIXME: do a proper, coordinate shutdown, so that no objects stay
* alive nor exported. */
_notify (self, PROP_PATH);
}
G_OBJECT_CLASS (nm_dbus_object_parent_class)->dispose (object);
g_clear_object (&self->internal.bus_manager);
}
static void
nm_dbus_object_class_init (NMDBusObjectClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = constructed;
object_class->dispose = dispose;
object_class->get_property = get_property;
object_class->dispatch_properties_changed = dispatch_properties_changed;
obj_properties[PROP_PATH] =
g_param_spec_string (NM_DBUS_OBJECT_PATH, "", "",
NULL,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
}

157
src/nm-dbus-object.h Normal file
View File

@@ -0,0 +1,157 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright 2018 Red Hat, Inc.
*/
#ifndef __NM_DBUS_OBJECT_H__
#define __NM_DBUS_OBJECT_H__
/*****************************************************************************/
#include "nm-utils/c-list.h"
#include "nm-dbus-utils.h"
/*****************************************************************************/
void nm_dbus_object_set_quitting (void);
/*****************************************************************************/
/* "org.freedesktop.NetworkManager.Device.Statistics" is a special interface,
* because although it has a legacy PropertiesChanged signal, it only notifies
* about properties that actually exist on that interface. That is, because it
* was added with 1.4.0 release, and thus didn't have the broken behavior like
* other legacy interfaces. Those notify about *all* properties, even if they
* are not part of that D-Bus interface. See also "include_in_legacy_property_changed"
* and "legacy_property_changed". */
extern const NMDBusInterfaceInfoExtended nm_interface_info_device_statistics;
/*****************************************************************************/
#define NM_TYPE_DBUS_OBJECT (nm_dbus_object_get_type ())
#define NM_DBUS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DBUS_OBJECT, NMDBusObject))
#define NM_DBUS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DBUS_OBJECT, NMDBusObjectClass))
#define NM_IS_DBUS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DBUS_OBJECT))
#define NM_IS_DBUS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DBUS_OBJECT))
#define NM_DBUS_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DBUS_OBJECT, NMDBusObjectClass))
#define NM_DBUS_OBJECT_PATH "path"
/* NMDBusObject and NMDBusManager cooperate strongly. Hence, there is an
* internal data structure attached to the NMDBusObject accessible to both of them. */
struct _NMDBusObjectInternal {
char *path;
NMDBusManager *bus_manager;
CList objects_lst;
CList registration_lst_head;
/* we perform asynchronous operation on exported objects. For example, we receive
* a Set property call, and asynchronously validate the operation. We must make
* sure that when the authentication is complete, that we are still looking at
* the same (exported) object. In the meantime, the object could have been
* unexported, or even re-exported afterwards. If that happens, we want
* to fail the request. For that, we keep track of a version id. */
guint64 export_version_id;
};
struct _NMDBusObject {
GObject parent;
struct _NMDBusObjectInternal internal;
};
#define NM_DEFINE_DBUS_INTERFACE_INFO(...) \
((NMDBusInterfaceInfo *) (&((const NMDBusInterfaceInfo) { \
__VA_ARGS__ \
})))
typedef struct {
GObjectClass parent;
const char *export_path;
const NMDBusInterfaceInfoExtended *const*interface_infos;
bool export_on_construction;
} NMDBusObjectClass;
GType nm_dbus_object_get_type (void);
static inline NMDBusManager *
nm_dbus_object_get_manager (NMDBusObject *obj)
{
nm_assert (NM_IS_DBUS_OBJECT (obj));
return obj->internal.bus_manager;
}
static inline guint64
nm_dbus_object_get_export_version_id (NMDBusObject *obj)
{
nm_assert (NM_IS_DBUS_OBJECT (obj));
return obj->internal.export_version_id;
}
/**
* nm_dbus_object_get_path:
* @self: an #NMDBusObject
*
* Gets @self's D-Bus path.
*
* Returns: @self's D-Bus path, or %NULL if @self is not exported.
*/
static inline const char *
nm_dbus_object_get_path (NMDBusObject *self)
{
g_return_val_if_fail (NM_IS_DBUS_OBJECT (self), NULL);
return self->internal.path;
}
/**
* nm_dbus_object_is_exported:
* @self: an #NMDBusObject
*
* Checks if @self is exported
*
* Returns: %TRUE if @self is exported
*/
static inline gboolean
nm_dbus_object_is_exported (NMDBusObject *self)
{
return !!nm_dbus_object_get_path (self);
}
const char *nm_dbus_object_export (NMDBusObject *self);
void nm_dbus_object_unexport (NMDBusObject *self);
void _nm_dbus_object_clear_and_unexport (NMDBusObject **location);
#define nm_dbus_object_clear_and_unexport(location) _nm_dbus_object_clear_and_unexport ((NMDBusObject **) (location))
void nm_dbus_object_emit_signal_variant (NMDBusObject *self,
const NMDBusInterfaceInfoExtended *interface_info,
const GDBusSignalInfo *signal_info,
GVariant *args);
void nm_dbus_object_emit_signal (NMDBusObject *self,
const NMDBusInterfaceInfoExtended *interface_info,
const GDBusSignalInfo *signal_info,
const char *format,
...);
#endif /* __NM_DBUS_OBJECT_H__ */

149
src/nm-dbus-utils.c Normal file
View File

@@ -0,0 +1,149 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright 2018 Red Hat, Inc.
*/
#include "nm-default.h"
#include "nm-dbus-utils.h"
#include "nm-dbus-object.h"
/*****************************************************************************/
const GDBusSignalInfo nm_signal_info_property_changed_legacy = NM_DEFINE_GDBUS_SIGNAL_INFO_INIT (
"PropertiesChanged",
.args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("properties", "a{sv}"),
),
);
GDBusPropertyInfo *
nm_dbus_utils_interface_info_lookup_property (const GDBusInterfaceInfo *interface_info,
const char *property_name)
{
guint i;
nm_assert (interface_info);
nm_assert (property_name);
/* there is also g_dbus_interface_info_lookup_property(), however that makes use
* of a global cache. */
if (interface_info->properties) {
for (i = 0; interface_info->properties[i]; i++) {
GDBusPropertyInfo *info = interface_info->properties[i];
if (nm_streq (info->name, property_name))
return info;
}
}
return NULL;
}
GDBusMethodInfo *
nm_dbus_utils_interface_info_lookup_method (const GDBusInterfaceInfo *interface_info,
const char *method_name)
{
guint i;
nm_assert (interface_info);
nm_assert (method_name);
/* there is also g_dbus_interface_info_lookup_property(), however that makes use
* of a global cache. */
if (interface_info->methods) {
for (i = 0; interface_info->methods[i]; i++) {
GDBusMethodInfo *info = interface_info->methods[i];
if (nm_streq (info->name, method_name))
return info;
}
}
return NULL;
}
GVariant *
nm_dbus_utils_get_property (GObject *obj,
const char *signature,
const char *property_name)
{
GParamSpec *pspec;
nm_auto_unset_gvalue GValue value = G_VALUE_INIT;
nm_assert (G_IS_OBJECT (obj));
nm_assert (g_variant_type_string_is_valid (signature));
nm_assert (property_name && property_name[0]);
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (obj), property_name);
if (!pspec)
g_return_val_if_reached (NULL);
g_value_init (&value, pspec->value_type);
g_object_get_property (obj, property_name, &value);
/* returns never-floating variant */
return g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (signature));
}
/*****************************************************************************/
void
nm_dbus_utils_g_value_set_object_path (GValue *value, gpointer object)
{
const char *path;
g_return_if_fail (!object || NM_IS_DBUS_OBJECT (object));
if ( object
&& (path = nm_dbus_object_get_path (object)))
g_value_set_string (value, path);
else
g_value_set_string (value, "/");
}
void
nm_dbus_utils_g_value_set_object_path_array (GValue *value,
GSList *objects,
gboolean (*filter_func) (GObject *object, gpointer user_data),
gpointer user_data)
{
char **paths;
guint i;
GSList *iter;
paths = g_new (char *, g_slist_length (objects) + 1);
for (i = 0, iter = objects; iter; iter = iter->next) {
NMDBusObject *object = iter->data;
const char *path;
path = nm_dbus_object_get_path (object);
if (!path)
continue;
if ( filter_func
&& !filter_func ((GObject *) object, user_data))
continue;
paths[i++] = g_strdup (path);
}
paths[i] = NULL;
g_value_take_boxed (value, paths);
}
/*****************************************************************************/

177
src/nm-dbus-utils.h Normal file
View File

@@ -0,0 +1,177 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright 2018 Red Hat, Inc.
*/
#ifndef __NM_DBUS_UTILS_H__
#define __NM_DBUS_UTILS_H__
/*****************************************************************************/
#define NM_EXPORT_PATH_NUMBERED(basepath) ""basepath"/%llu"
/*****************************************************************************/
struct _NMDBusInterfaceInfoExtended;
struct _NMDBusMethodInfoExtended;
struct _NMDBusPropertyInfoExtendedBase {
GDBusPropertyInfo _parent;
const char *property_name;
/* Whether the properties needs to be notified on the legacy
* PropertyChanged signal. This is only to preserve API, new
* properties should not use this. */
bool include_in_legacy_property_changed;
};
struct _NMDBusPropertyInfoExtendedReadWritable {
struct _NMDBusPropertyInfoExtendedBase _base;
/* this is the polkit permission type for authenticating setting
* the property. */
const char *permission;
/* this is the audit operation type for writing the property. */
const char *audit_op;
};
typedef struct {
union {
GDBusPropertyInfo _parent;
struct _NMDBusPropertyInfoExtendedBase _base;
struct _NMDBusPropertyInfoExtendedReadWritable writable;
/* duplicate the base structure in the union, so that the common fields
* are accessible directly in the parent struct. */
struct {
GDBusPropertyInfo parent;
const char *property_name;
/* Whether the properties needs to be notified on the legacy
* PropertyChanged signal. This is only to preserve API, new
* properties should not use this. */
bool include_in_legacy_property_changed;
};
};
} NMDBusPropertyInfoExtended;
G_STATIC_ASSERT (G_STRUCT_OFFSET (NMDBusPropertyInfoExtended, property_name) == G_STRUCT_OFFSET (struct _NMDBusPropertyInfoExtendedBase, property_name));
G_STATIC_ASSERT (G_STRUCT_OFFSET (NMDBusPropertyInfoExtended, include_in_legacy_property_changed) == G_STRUCT_OFFSET (struct _NMDBusPropertyInfoExtendedBase, include_in_legacy_property_changed));
#define NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_FULL(m_name, m_signature, m_property_name, m_include_in_legacy_property_changed) \
((GDBusPropertyInfo *) &((const struct _NMDBusPropertyInfoExtendedBase) { \
._parent = { \
.ref_count = -1, \
.name = m_name, \
.signature = m_signature, \
.flags = G_DBUS_PROPERTY_INFO_FLAGS_READABLE, \
}, \
.property_name = m_property_name, \
.include_in_legacy_property_changed = m_include_in_legacy_property_changed, \
}))
#define NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE(m_name, m_signature, m_property_name) \
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_FULL (m_name, m_signature, m_property_name, FALSE)
/* define a legacy property. Do not use for new code. */
#define NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L(m_name, m_signature, m_property_name) \
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_FULL (m_name, m_signature, m_property_name, TRUE)
#define NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READWRITABLE_FULL(m_name, m_signature, m_property_name, m_permission, m_audit_op, m_include_in_legacy_property_changed) \
((GDBusPropertyInfo *) &((const struct _NMDBusPropertyInfoExtendedReadWritable) { \
._base = { \
._parent = { \
.ref_count = -1, \
.name = m_name, \
.signature = m_signature, \
.flags = G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE, \
}, \
.property_name = m_property_name, \
.include_in_legacy_property_changed = m_include_in_legacy_property_changed, \
}, \
.permission = m_permission, \
.audit_op = m_audit_op, \
}))
#define NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READWRITABLE(m_name, m_signature, m_property_name, m_permission, m_audit_op) \
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READWRITABLE_FULL (m_name, m_signature, m_property_name, m_permission, m_audit_op, FALSE)
/* define a legacy property. Do not use for new code. */
#define NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READWRITABLE_L(m_name, m_signature, m_property_name, m_permission, m_audit_op) \
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READWRITABLE_FULL (m_name, m_signature, m_property_name, m_permission, m_audit_op, TRUE)
typedef struct _NMDBusMethodInfoExtended {
GDBusMethodInfo parent;
void (*handle) (NMDBusObject *obj,
const struct _NMDBusInterfaceInfoExtended *interface_info,
const struct _NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters);
} NMDBusMethodInfoExtended;
#define NM_DEFINE_DBUS_METHOD_INFO_EXTENDED(parent_, ...) \
((GDBusMethodInfo *) (&((const NMDBusMethodInfoExtended) { \
.parent = parent_, \
__VA_ARGS__ \
})))
typedef struct _NMDBusInterfaceInfoExtended {
GDBusInterfaceInfo parent;
/* Whether the interface has a legacy property changed signal (@nm_signal_info_property_changed_legacy).
* New interfaces should not use this. */
bool legacy_property_changed:1;
} NMDBusInterfaceInfoExtended;
extern const GDBusSignalInfo nm_signal_info_property_changed_legacy;
#define NM_DBUS_INTERFACE_INFOS(...) \
({ \
static const NMDBusInterfaceInfoExtended *const _interface_infos[] = { \
__VA_ARGS__, \
NULL, \
}; \
_interface_infos; \
});
/*****************************************************************************/
GDBusPropertyInfo *nm_dbus_utils_interface_info_lookup_property (const GDBusInterfaceInfo *interface_info,
const char *property_name);
GDBusMethodInfo *nm_dbus_utils_interface_info_lookup_method (const GDBusInterfaceInfo *interface_info,
const char *method_name);
GVariant *nm_dbus_utils_get_property (GObject *obj,
const char *signature,
const char *property_name);
/*****************************************************************************/
void nm_dbus_utils_g_value_set_object_path (GValue *value, gpointer object);
void nm_dbus_utils_g_value_set_object_path_array (GValue *value,
GSList *objects,
gboolean (*filter_func) (GObject *object, gpointer user_data),
gpointer user_data);
#endif /* __NM_DBUS_UTILS_H__ */

View File

@@ -26,9 +26,7 @@
#include "nm-dbus-interface.h" #include "nm-dbus-interface.h"
#include "nm-utils.h" #include "nm-utils.h"
#include "nm-exported-object.h" #include "nm-dbus-object.h"
#include "introspection/org.freedesktop.NetworkManager.DHCP4Config.h"
/*****************************************************************************/ /*****************************************************************************/
@@ -41,15 +39,15 @@ typedef struct {
} NMDhcp4ConfigPrivate; } NMDhcp4ConfigPrivate;
struct _NMDhcp4Config { struct _NMDhcp4Config {
NMExportedObject parent; NMDBusObject parent;
NMDhcp4ConfigPrivate _priv; NMDhcp4ConfigPrivate _priv;
}; };
struct _NMDhcp4ConfigClass { struct _NMDhcp4ConfigClass {
NMExportedObjectClass parent; NMDBusObjectClass parent;
}; };
G_DEFINE_TYPE (NMDhcp4Config, nm_dhcp4_config, NM_TYPE_EXPORTED_OBJECT) G_DEFINE_TYPE (NMDhcp4Config, nm_dhcp4_config, NM_TYPE_DBUS_OBJECT)
#define NM_DHCP4_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDhcp4Config, NM_IS_DHCP4_CONFIG) #define NM_DHCP4_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDhcp4Config, NM_IS_DHCP4_CONFIG)
@@ -147,17 +145,31 @@ finalize (GObject *object)
G_OBJECT_CLASS (nm_dhcp4_config_parent_class)->finalize (object); G_OBJECT_CLASS (nm_dhcp4_config_parent_class)->finalize (object);
} }
static const NMDBusInterfaceInfoExtended interface_info_dhcp4_config = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DHCP4_CONFIG,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Options", "a{sv}", NM_DHCP4_CONFIG_OPTIONS),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_dhcp4_config_class_init (NMDhcp4ConfigClass *config_class) nm_dhcp4_config_class_init (NMDhcp4ConfigClass *config_class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (config_class); GObjectClass *object_class = G_OBJECT_CLASS (config_class);
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (config_class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (config_class);
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->finalize = finalize; object_class->finalize = finalize;
exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/DHCP4Config"); dbus_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/DHCP4Config");
exported_object_class->export_on_construction = TRUE; dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_dhcp4_config);
dbus_object_class->export_on_construction = TRUE;
obj_properties[PROP_OPTIONS] = obj_properties[PROP_OPTIONS] =
g_param_spec_variant (NM_DHCP4_CONFIG_OPTIONS, "", "", g_param_spec_variant (NM_DHCP4_CONFIG_OPTIONS, "", "",
@@ -167,8 +179,4 @@ nm_dhcp4_config_class_init (NMDhcp4ConfigClass *config_class)
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (config_class),
NMDBUS_TYPE_DHCP4_CONFIG_SKELETON,
NULL);
} }

View File

@@ -26,9 +26,7 @@
#include "nm-dbus-interface.h" #include "nm-dbus-interface.h"
#include "nm-utils.h" #include "nm-utils.h"
#include "nm-exported-object.h" #include "nm-dbus-object.h"
#include "introspection/org.freedesktop.NetworkManager.DHCP6Config.h"
/*****************************************************************************/ /*****************************************************************************/
@@ -41,15 +39,15 @@ typedef struct {
} NMDhcp6ConfigPrivate; } NMDhcp6ConfigPrivate;
struct _NMDhcp6Config { struct _NMDhcp6Config {
NMExportedObject parent; NMDBusObject parent;
NMDhcp6ConfigPrivate _priv; NMDhcp6ConfigPrivate _priv;
}; };
struct _NMDhcp6ConfigClass { struct _NMDhcp6ConfigClass {
NMExportedObjectClass parent; NMDBusObjectClass parent;
}; };
G_DEFINE_TYPE (NMDhcp6Config, nm_dhcp6_config, NM_TYPE_EXPORTED_OBJECT) G_DEFINE_TYPE (NMDhcp6Config, nm_dhcp6_config, NM_TYPE_DBUS_OBJECT)
#define NM_DHCP6_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDhcp6Config, NM_IS_DHCP6_CONFIG) #define NM_DHCP6_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDhcp6Config, NM_IS_DHCP6_CONFIG)
@@ -145,17 +143,31 @@ finalize (GObject *object)
G_OBJECT_CLASS (nm_dhcp6_config_parent_class)->finalize (object); G_OBJECT_CLASS (nm_dhcp6_config_parent_class)->finalize (object);
} }
static const NMDBusInterfaceInfoExtended interface_info_dhcp6_config = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DHCP6_CONFIG,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Options", "a{sv}", NM_DHCP6_CONFIG_OPTIONS),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_dhcp6_config_class_init (NMDhcp6ConfigClass *config_class) nm_dhcp6_config_class_init (NMDhcp6ConfigClass *config_class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (config_class); GObjectClass *object_class = G_OBJECT_CLASS (config_class);
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (config_class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (config_class);
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->finalize = finalize; object_class->finalize = finalize;
exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/DHCP6Config"); dbus_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/DHCP6Config");
exported_object_class->export_on_construction = TRUE; dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_dhcp6_config);
dbus_object_class->export_on_construction = TRUE;
obj_properties[PROP_OPTIONS] = obj_properties[PROP_OPTIONS] =
g_param_spec_variant (NM_DHCP6_CONFIG_OPTIONS, "", "", g_param_spec_variant (NM_DHCP6_CONFIG_OPTIONS, "", "",
@@ -165,8 +177,4 @@ nm_dhcp6_config_class_init (NMDhcp6ConfigClass *config_class)
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (config_class),
NMDBUS_TYPE_DHCP6_CONFIG_SKELETON,
NULL);
} }

View File

@@ -284,9 +284,10 @@ fill_device_props (NMDevice *device,
g_variant_new_uint32 (nm_device_get_device_type (device))); g_variant_new_uint32 (nm_device_get_device_type (device)));
g_variant_builder_add (dev_builder, "{sv}", NMD_DEVICE_PROPS_STATE, g_variant_builder_add (dev_builder, "{sv}", NMD_DEVICE_PROPS_STATE,
g_variant_new_uint32 (nm_device_get_state (device))); g_variant_new_uint32 (nm_device_get_state (device)));
if (nm_exported_object_is_exported (NM_EXPORTED_OBJECT (device))) if (nm_dbus_object_is_exported (NM_DBUS_OBJECT (device))) {
g_variant_builder_add (dev_builder, "{sv}", NMD_DEVICE_PROPS_PATH, g_variant_builder_add (dev_builder, "{sv}", NMD_DEVICE_PROPS_PATH,
g_variant_new_object_path (nm_exported_object_get_path (NM_EXPORTED_OBJECT (device)))); g_variant_new_object_path (nm_dbus_object_get_path (NM_DBUS_OBJECT (device))));
}
proxy_config = nm_device_get_proxy_config (device); proxy_config = nm_device_get_proxy_config (device);
if (proxy_config) if (proxy_config)

File diff suppressed because it is too large Load Diff

View File

@@ -1,85 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright 2014 Red Hat, Inc.
*/
#ifndef NM_EXPORTED_OBJECT_H
#define NM_EXPORTED_OBJECT_H
/*****************************************************************************/
#define NM_EXPORT_PATH_NUMBERED(basepath) ""basepath"/%llu"
char *nm_exported_object_skeletonify_method_name (const char *dbus_method_name);
typedef struct {
GType dbus_skeleton_type;
char *method_name;
GCallback impl;
} NMExportedObjectDBusMethodImpl;
GDBusInterfaceSkeleton *nm_exported_object_skeleton_create (GType dbus_skeleton_type,
GObjectClass *object_class,
const NMExportedObjectDBusMethodImpl *methods,
guint methods_len,
GObject *target);
void nm_exported_object_skeleton_release (GDBusInterfaceSkeleton *interface);
/*****************************************************************************/
#define NM_TYPE_EXPORTED_OBJECT (nm_exported_object_get_type ())
#define NM_EXPORTED_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_EXPORTED_OBJECT, NMExportedObject))
#define NM_EXPORTED_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_EXPORTED_OBJECT, NMExportedObjectClass))
#define NM_IS_EXPORTED_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_EXPORTED_OBJECT))
#define NM_IS_EXPORTED_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_EXPORTED_OBJECT))
#define NM_EXPORTED_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_EXPORTED_OBJECT, NMExportedObjectClass))
#define NM_EXPORTED_OBJECT_PATH "path"
struct _NMExportedObjectPrivate;
struct _NMExportedObject {
GDBusObjectSkeleton parent;
struct _NMExportedObjectPrivate *_priv;
};
typedef struct {
GDBusObjectSkeletonClass parent;
const char *export_path;
char export_on_construction;
} NMExportedObjectClass;
GType nm_exported_object_get_type (void);
void nm_exported_object_class_set_quitting (void);
void nm_exported_object_class_add_interface (NMExportedObjectClass *object_class,
GType dbus_skeleton_type,
...) G_GNUC_NULL_TERMINATED;
const char *nm_exported_object_export (NMExportedObject *self);
const char *nm_exported_object_get_path (NMExportedObject *self);
gboolean nm_exported_object_is_exported (NMExportedObject *self);
void nm_exported_object_unexport (NMExportedObject *self);
GDBusInterfaceSkeleton *nm_exported_object_get_interface_by_type (NMExportedObject *self, GType interface_type);
void _nm_exported_object_clear_and_unexport (NMExportedObject **location);
#define nm_exported_object_clear_and_unexport(location) _nm_exported_object_clear_and_unexport ((NMExportedObject **) (location))
#endif /* NM_EXPORTED_OBJECT_H */

View File

@@ -629,21 +629,34 @@ nm_config_get_configure_and_quit (NMConfig *config)
return TRUE; return TRUE;
} }
NMBusManager * NMDBusManager *
nm_bus_manager_get (void) nm_dbus_manager_get (void)
{ {
return GUINT_TO_POINTER (1); return NULL;
} }
void void
nm_bus_manager_register_object (NMBusManager *bus_manager, _nm_dbus_manager_obj_export (NMDBusObject *obj)
GDBusObjectSkeleton *object)
{ {
} }
void void
nm_bus_manager_unregister_object (NMBusManager *bus_manager, _nm_dbus_manager_obj_unexport (NMDBusObject *obj)
GDBusObjectSkeleton *object) {
}
void
_nm_dbus_manager_obj_notify (NMDBusObject *obj,
guint n_pspecs,
const GParamSpec *const*pspecs)
{
}
void
_nm_dbus_manager_obj_emit_signal (NMDBusObject *obj,
const NMDBusInterfaceInfoExtended *interface_info,
const GDBusSignalInfo *signal_info,
GVariant *args)
{ {
} }

View File

@@ -36,8 +36,7 @@
#include "platform/nm-platform-utils.h" #include "platform/nm-platform-utils.h"
#include "NetworkManagerUtils.h" #include "NetworkManagerUtils.h"
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "nm-dbus-object.h"
#include "introspection/org.freedesktop.NetworkManager.IP4Config.h"
/*****************************************************************************/ /*****************************************************************************/
@@ -318,15 +317,15 @@ typedef struct {
} NMIP4ConfigPrivate; } NMIP4ConfigPrivate;
struct _NMIP4Config { struct _NMIP4Config {
NMExportedObject parent; NMDBusObject parent;
NMIP4ConfigPrivate _priv; NMIP4ConfigPrivate _priv;
}; };
struct _NMIP4ConfigClass { struct _NMIP4ConfigClass {
NMExportedObjectClass parent; NMDBusObjectClass parent;
}; };
G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_EXPORTED_OBJECT) G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_DBUS_OBJECT)
#define NM_IP4_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMIP4Config, NM_IS_IP4_CONFIG) #define NM_IP4_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMIP4Config, NM_IS_IP4_CONFIG)
@@ -1954,7 +1953,7 @@ nm_ip4_config_dump (const NMIP4Config *self, const char *detail)
return; return;
} }
str = nm_exported_object_get_path (NM_EXPORTED_OBJECT (self)); str = nm_dbus_object_get_path (NM_DBUS_OBJECT (self));
if (str) if (str)
g_message (" path: %s", str); g_message (" path: %s", str);
@@ -3212,13 +3211,37 @@ finalize (GObject *object)
nm_dedup_multi_index_unref (priv->multi_idx); nm_dedup_multi_index_unref (priv->multi_idx);
} }
static const NMDBusInterfaceInfoExtended interface_info_ip4_config = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_IP4_CONFIG,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Addresses", "aau", NM_IP4_CONFIG_ADDRESSES),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("AddressData", "aa{sv}", NM_IP4_CONFIG_ADDRESS_DATA),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Gateway", "s", NM_IP4_CONFIG_GATEWAY),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Routes", "aau", NM_IP4_CONFIG_ROUTES),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("RouteData", "aa{sv}", NM_IP4_CONFIG_ROUTE_DATA),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Nameservers", "au", NM_IP4_CONFIG_NAMESERVERS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Domains", "as", NM_IP4_CONFIG_DOMAINS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Searches", "as", NM_IP4_CONFIG_SEARCHES),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("DnsOptions", "as", NM_IP4_CONFIG_DNS_OPTIONS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("DnsPriority", "i", NM_IP4_CONFIG_DNS_PRIORITY),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("WinsServers", "au", NM_IP4_CONFIG_WINS_SERVERS),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_ip4_config_class_init (NMIP4ConfigClass *config_class) nm_ip4_config_class_init (NMIP4ConfigClass *config_class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (config_class); GObjectClass *object_class = G_OBJECT_CLASS (config_class);
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (config_class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (config_class);
exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/IP4Config"); dbus_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/IP4Config");
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_ip4_config);
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property; object_class->set_property = set_property;
@@ -3298,8 +3321,4 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class)
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (config_class),
NMDBUS_TYPE_IP4_CONFIG_SKELETON,
NULL);
} }

View File

@@ -23,7 +23,6 @@
#include "nm-setting-connection.h" #include "nm-setting-connection.h"
#include "nm-exported-object.h"
#include "nm-setting-ip4-config.h" #include "nm-setting-ip4-config.h"
#include "nm-utils/nm-dedup-multi.h" #include "nm-utils/nm-dedup-multi.h"

View File

@@ -38,8 +38,7 @@
#include "NetworkManagerUtils.h" #include "NetworkManagerUtils.h"
#include "nm-ip4-config.h" #include "nm-ip4-config.h"
#include "ndisc/nm-ndisc.h" #include "ndisc/nm-ndisc.h"
#include "nm-dbus-object.h"
#include "introspection/org.freedesktop.NetworkManager.IP6Config.h"
/*****************************************************************************/ /*****************************************************************************/
@@ -82,15 +81,15 @@ typedef struct {
} NMIP6ConfigPrivate; } NMIP6ConfigPrivate;
struct _NMIP6Config { struct _NMIP6Config {
NMExportedObject parent; NMDBusObject parent;
NMIP6ConfigPrivate _priv; NMIP6ConfigPrivate _priv;
}; };
struct _NMIP6ConfigClass { struct _NMIP6ConfigClass {
NMExportedObjectClass parent; NMDBusObjectClass parent;
}; };
G_DEFINE_TYPE (NMIP6Config, nm_ip6_config, NM_TYPE_EXPORTED_OBJECT) G_DEFINE_TYPE (NMIP6Config, nm_ip6_config, NM_TYPE_DBUS_OBJECT)
#define NM_IP6_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMIP6Config, NM_IS_IP6_CONFIG) #define NM_IP6_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMIP6Config, NM_IS_IP6_CONFIG)
@@ -1486,7 +1485,7 @@ nm_ip6_config_dump (const NMIP6Config *self, const char *detail)
g_message ("--------- NMIP6Config %p (%s)", self, detail); g_message ("--------- NMIP6Config %p (%s)", self, detail);
str = nm_exported_object_get_path (NM_EXPORTED_OBJECT (self)); str = nm_dbus_object_get_path (NM_DBUS_OBJECT (self));
if (str) if (str)
g_message (" path: %s", str); g_message (" path: %s", str);
@@ -2773,13 +2772,36 @@ finalize (GObject *object)
nm_dedup_multi_index_unref (priv->multi_idx); nm_dedup_multi_index_unref (priv->multi_idx);
} }
static const NMDBusInterfaceInfoExtended interface_info_ip6_config = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_IP6_CONFIG,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Addresses", "a(ayuay)", NM_IP6_CONFIG_ADDRESSES),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("AddressData", "aa{sv}", NM_IP6_CONFIG_ADDRESS_DATA),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Gateway", "s", NM_IP6_CONFIG_GATEWAY),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Routes", "a(ayuayu)", NM_IP6_CONFIG_ROUTES),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("RouteData", "aa{sv}", NM_IP6_CONFIG_ROUTE_DATA),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Nameservers", "aay", NM_IP6_CONFIG_NAMESERVERS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Domains", "as", NM_IP6_CONFIG_DOMAINS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Searches", "as", NM_IP6_CONFIG_SEARCHES),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("DnsOptions", "as", NM_IP6_CONFIG_DNS_OPTIONS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("DnsPriority", "i", NM_IP6_CONFIG_DNS_PRIORITY),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_ip6_config_class_init (NMIP6ConfigClass *config_class) nm_ip6_config_class_init (NMIP6ConfigClass *config_class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (config_class); GObjectClass *object_class = G_OBJECT_CLASS (config_class);
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (config_class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (config_class);
exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/IP6Config"); dbus_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/IP6Config");
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_ip6_config);
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property; object_class->set_property = set_property;
@@ -2853,8 +2875,4 @@ nm_ip6_config_class_init (NMIP6ConfigClass *config_class)
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (config_class),
NMDBUS_TYPE_IP6_CONFIG_SKELETON,
NULL);
} }

View File

@@ -23,7 +23,6 @@
#include <netinet/in.h> #include <netinet/in.h>
#include "nm-exported-object.h"
#include "nm-setting-ip6-config.h" #include "nm-setting-ip6-config.h"
#include "nm-utils/nm-dedup-multi.h" #include "nm-utils/nm-dedup-multi.h"

File diff suppressed because it is too large Load Diff

View File

@@ -22,9 +22,9 @@
#ifndef __NETWORKMANAGER_MANAGER_H__ #ifndef __NETWORKMANAGER_MANAGER_H__
#define __NETWORKMANAGER_MANAGER_H__ #define __NETWORKMANAGER_MANAGER_H__
#include "nm-exported-object.h"
#include "settings/nm-settings-connection.h" #include "settings/nm-settings-connection.h"
#include "nm-utils/c-list.h" #include "nm-utils/c-list.h"
#include "nm-dbus-manager.h"
#define NM_TYPE_MANAGER (nm_manager_get_type ()) #define NM_TYPE_MANAGER (nm_manager_get_type ())
#define NM_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MANAGER, NMManager)) #define NM_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MANAGER, NMManager))
@@ -60,14 +60,11 @@
/* Not exported */ /* Not exported */
#define NM_MANAGER_SLEEPING "sleeping" #define NM_MANAGER_SLEEPING "sleeping"
/* signals */ /* Signals */
#define NM_MANAGER_CHECK_PERMISSIONS "check-permissions"
#define NM_MANAGER_DEVICE_ADDED "device-added" #define NM_MANAGER_DEVICE_ADDED "device-added"
#define NM_MANAGER_DEVICE_REMOVED "device-removed" #define NM_MANAGER_DEVICE_REMOVED "device-removed"
#define NM_MANAGER_STATE_CHANGED "state-changed"
#define NM_MANAGER_USER_PERMISSIONS_CHANGED "user-permissions-changed" #define NM_MANAGER_USER_PERMISSIONS_CHANGED "user-permissions-changed"
/* Internal signals */
#define NM_MANAGER_ACTIVE_CONNECTION_ADDED "active-connection-added" #define NM_MANAGER_ACTIVE_CONNECTION_ADDED "active-connection-added"
#define NM_MANAGER_ACTIVE_CONNECTION_REMOVED "active-connection-removed" #define NM_MANAGER_ACTIVE_CONNECTION_REMOVED "active-connection-removed"
#define NM_MANAGER_CONFIGURE_QUIT "configure-quit" #define NM_MANAGER_CONFIGURE_QUIT "configure-quit"
@@ -153,4 +150,13 @@ gboolean nm_manager_remove_device (NMManager *self,
const char *ifname, const char *ifname,
NMDeviceType device_type); NMDeviceType device_type);
void nm_manager_dbus_set_property_handle (NMDBusObject *obj,
const NMDBusInterfaceInfoExtended *interface_info,
const NMDBusPropertyInfoExtended *property_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *value,
gpointer user_data);
#endif /* __NETWORKMANAGER_MANAGER_H__ */ #endif /* __NETWORKMANAGER_MANAGER_H__ */

View File

@@ -1358,7 +1358,7 @@ process_secondaries (NMPolicy *self,
if (connected) { if (connected) {
_LOGD (LOGD_DEVICE, "secondary connection '%s' succeeded; active path '%s'", _LOGD (LOGD_DEVICE, "secondary connection '%s' succeeded; active path '%s'",
nm_active_connection_get_settings_connection_id (active), nm_active_connection_get_settings_connection_id (active),
nm_exported_object_get_path (NM_EXPORTED_OBJECT (active))); nm_dbus_object_get_path (NM_DBUS_OBJECT (active)));
/* Secondary connection activated */ /* Secondary connection activated */
secondary_data->secondaries = g_slist_remove (secondary_data->secondaries, secondary_active); secondary_data->secondaries = g_slist_remove (secondary_data->secondaries, secondary_active);
@@ -1374,7 +1374,7 @@ process_secondaries (NMPolicy *self,
} else { } else {
_LOGD (LOGD_DEVICE, "secondary connection '%s' failed; active path '%s'", _LOGD (LOGD_DEVICE, "secondary connection '%s' failed; active path '%s'",
nm_active_connection_get_settings_connection_id (active), nm_active_connection_get_settings_connection_id (active),
nm_exported_object_get_path (NM_EXPORTED_OBJECT (active))); nm_dbus_object_get_path (NM_DBUS_OBJECT (active)));
/* Secondary connection failed -> do not watch other connections */ /* Secondary connection failed -> do not watch other connections */
priv->pending_secondaries = g_slist_remove (priv->pending_secondaries, secondary_data); priv->pending_secondaries = g_slist_remove (priv->pending_secondaries, secondary_data);
@@ -1670,7 +1670,7 @@ activate_secondary_connections (NMPolicy *self,
ac = nm_manager_activate_connection (priv->manager, ac = nm_manager_activate_connection (priv->manager,
settings_con, settings_con,
NULL, NULL,
nm_exported_object_get_path (NM_EXPORTED_OBJECT (req)), nm_dbus_object_get_path (NM_DBUS_OBJECT (req)),
device, device,
nm_active_connection_get_subject (NM_ACTIVE_CONNECTION (req)), nm_active_connection_get_subject (NM_ACTIVE_CONNECTION (req)),
NM_ACTIVATION_TYPE_MANAGED, NM_ACTIVATION_TYPE_MANAGED,

View File

@@ -28,13 +28,14 @@
#define _NM_SD_MAX_CLIENT_ID_LEN (sizeof (guint32) + 128) #define _NM_SD_MAX_CLIENT_ID_LEN (sizeof (guint32) + 128)
/* core */ /* core */
typedef struct _NMDBusObject NMDBusObject;
typedef struct _NMExportedObject NMExportedObject; typedef struct _NMExportedObject NMExportedObject;
typedef struct _NMActiveConnection NMActiveConnection; typedef struct _NMActiveConnection NMActiveConnection;
typedef struct _NMAuditManager NMAuditManager; typedef struct _NMAuditManager NMAuditManager;
typedef struct _NMVpnConnection NMVpnConnection; typedef struct _NMVpnConnection NMVpnConnection;
typedef struct _NMActRequest NMActRequest; typedef struct _NMActRequest NMActRequest;
typedef struct _NMAuthSubject NMAuthSubject; typedef struct _NMAuthSubject NMAuthSubject;
typedef struct _NMBusManager NMBusManager; typedef struct _NMDBusManager NMDBusManager;
typedef struct _NMConfig NMConfig; typedef struct _NMConfig NMConfig;
typedef struct _NMConfigData NMConfigData; typedef struct _NMConfigData NMConfigData;
typedef struct _NMArpingManager NMArpingManager; typedef struct _NMArpingManager NMArpingManager;

View File

@@ -22,7 +22,6 @@ nm_pppd_plugin = shared_module(
name = 'nm-ppp-plugin' name = 'nm-ppp-plugin'
deps = [ deps = [
libnmdbus_dep,
nm_dep nm_dep
] ]

View File

@@ -50,13 +50,12 @@
#include "nm-act-request.h" #include "nm-act-request.h"
#include "nm-ip4-config.h" #include "nm-ip4-config.h"
#include "nm-ip6-config.h" #include "nm-ip6-config.h"
#include "nm-dbus-object.h"
#include "nm-pppd-plugin.h" #include "nm-pppd-plugin.h"
#include "nm-ppp-plugin-api.h" #include "nm-ppp-plugin-api.h"
#include "nm-ppp-status.h" #include "nm-ppp-status.h"
#include "introspection/org.freedesktop.NetworkManager.PPP.h"
#define NM_PPPD_PLUGIN PPPD_PLUGIN_DIR "/nm-pppd-plugin.so" #define NM_PPPD_PLUGIN PPPD_PLUGIN_DIR "/nm-pppd-plugin.so"
static NM_CACHED_QUARK_FCN ("ppp-manager-secret-tries", ppp_manager_secret_tries_quark) static NM_CACHED_QUARK_FCN ("ppp-manager-secret-tries", ppp_manager_secret_tries_quark)
@@ -116,17 +115,17 @@ typedef struct {
} NMPPPManagerPrivate; } NMPPPManagerPrivate;
struct _NMPPPManager { struct _NMPPPManager {
NMExportedObject parent; NMDBusObject parent;
NMPPPManagerPrivate _priv; NMPPPManagerPrivate _priv;
}; };
typedef struct { typedef struct {
NMExportedObjectClass parent; NMDBusObjectClass parent;
} NMPPPManagerClass; } NMPPPManagerClass;
G_DEFINE_TYPE (NMPPPManager, nm_ppp_manager, NM_TYPE_EXPORTED_OBJECT) G_DEFINE_TYPE (NMPPPManager, nm_ppp_manager, NM_TYPE_DBUS_OBJECT)
#define NM_PPP_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMPPPManager, NM_IS_PPP_MANAGER) #define NM_PPP_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMPPPManager, NM_IS_PPP_MANAGER, NMDBusObject)
/*****************************************************************************/ /*****************************************************************************/
@@ -332,20 +331,27 @@ ppp_secrets_cb (NMActRequest *req,
* against libnm just to parse this. So instead, let's just send what * against libnm just to parse this. So instead, let's just send what
* it needs. * it needs.
*/ */
g_dbus_method_invocation_return_value ( g_dbus_method_invocation_return_value (priv->pending_secrets_context,
priv->pending_secrets_context, g_variant_new ("(ss)",
g_variant_new ("(ss)", username ? username : "", password ? password : "")); username ?: "",
password ?: ""));
out: out:
priv->pending_secrets_context = NULL; priv->pending_secrets_context = NULL;
priv->secrets_id = NULL; priv->secrets_id = NULL;
priv->secrets_setting_name = NULL; priv->secrets_setting_name = NULL;
} }
static void static void
impl_ppp_manager_need_secrets (NMPPPManager *manager, impl_ppp_manager_need_secrets (NMDBusObject *obj,
GDBusMethodInvocation *context) const NMDBusInterfaceInfoExtended *interface_info,
const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
NMPPPManager *manager = NM_PPP_MANAGER (obj);
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
NMConnection *applied_connection; NMConnection *applied_connection;
const char *username = NULL; const char *username = NULL;
@@ -364,7 +370,7 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager,
/* Use existing secrets from the connection */ /* Use existing secrets from the connection */
if (extract_details_from_connection (applied_connection, NULL, &username, &password, &error)) { if (extract_details_from_connection (applied_connection, NULL, &username, &password, &error)) {
/* Send existing secrets to the PPP plugin */ /* Send existing secrets to the PPP plugin */
priv->pending_secrets_context = context; priv->pending_secrets_context = invocation;
ppp_secrets_cb (priv->act_req, priv->secrets_id, NULL, NULL, manager); ppp_secrets_cb (priv->act_req, priv->secrets_id, NULL, NULL, manager);
} else { } else {
_LOGW ("%s", error->message); _LOGW ("%s", error->message);
@@ -389,30 +395,45 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager,
ppp_secrets_cb, ppp_secrets_cb,
manager); manager);
g_object_set_qdata (G_OBJECT (applied_connection), ppp_manager_secret_tries_quark (), GUINT_TO_POINTER (++tries)); g_object_set_qdata (G_OBJECT (applied_connection), ppp_manager_secret_tries_quark (), GUINT_TO_POINTER (++tries));
priv->pending_secrets_context = context; priv->pending_secrets_context = invocation;
if (hints) if (hints)
g_ptr_array_free (hints, TRUE); g_ptr_array_free (hints, TRUE);
} }
static void static void
impl_ppp_manager_set_state (NMPPPManager *manager, impl_ppp_manager_set_state (NMDBusObject *obj,
GDBusMethodInvocation *context, const NMDBusInterfaceInfoExtended *interface_info,
guint32 state) const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
g_signal_emit (manager, signals[STATE_CHANGED], 0, (guint) state); NMPPPManager *manager = NM_PPP_MANAGER (obj);
guint32 state;
g_dbus_method_invocation_return_value (context, NULL); g_variant_get (parameters, "(u)", &state);
g_signal_emit (manager, signals[STATE_CHANGED], 0, (guint) state);
g_dbus_method_invocation_return_value (invocation, NULL);
} }
static void static void
impl_ppp_manager_set_ifindex (NMPPPManager *manager, impl_ppp_manager_set_ifindex (NMDBusObject *obj,
GDBusMethodInvocation *context, const NMDBusInterfaceInfoExtended *interface_info,
gint32 ifindex) const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
NMPPPManager *manager = NM_PPP_MANAGER (obj);
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
const NMPlatformLink *plink = NULL; const NMPlatformLink *plink = NULL;
nm_auto_nmpobj const NMPObject *obj_keep_alive = NULL; nm_auto_nmpobj const NMPObject *obj_keep_alive = NULL;
gint32 ifindex;
g_variant_get (parameters, "(i)", &ifindex);
_LOGD ("set-ifindex %d", (int) ifindex); _LOGD ("set-ifindex %d", (int) ifindex);
@@ -439,7 +460,7 @@ impl_ppp_manager_set_ifindex (NMPPPManager *manager,
obj_keep_alive = nmp_object_ref (NMP_OBJECT_UP_CAST (plink)); obj_keep_alive = nmp_object_ref (NMP_OBJECT_UP_CAST (plink));
g_signal_emit (manager, signals[IFINDEX_SET], 0, ifindex, plink->name); g_signal_emit (manager, signals[IFINDEX_SET], 0, ifindex, plink->name);
g_dbus_method_invocation_return_value (context, NULL); g_dbus_method_invocation_return_value (invocation, NULL);
} }
static gboolean static gboolean
@@ -469,18 +490,26 @@ set_ip_config_common (NMPPPManager *self,
} }
static void static void
impl_ppp_manager_set_ip4_config (NMPPPManager *manager, impl_ppp_manager_set_ip4_config (NMDBusObject *obj,
GDBusMethodInvocation *context, const NMDBusInterfaceInfoExtended *interface_info,
GVariant *config_dict) const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
NMPPPManager *manager = NM_PPP_MANAGER (obj);
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
gs_unref_object NMIP4Config *config = NULL; gs_unref_object NMIP4Config *config = NULL;
NMPlatformIP4Address address; NMPlatformIP4Address address;
guint32 u32, mtu; guint32 u32, mtu;
GVariantIter *iter; GVariantIter *iter;
gs_unref_variant GVariant *config_dict = NULL;
_LOGI ("(IPv4 Config Get) reply received."); _LOGI ("(IPv4 Config Get) reply received.");
g_variant_get (parameters, "(@a{sv})", &config_dict);
nm_clear_g_source (&priv->ppp_timeout_handler); nm_clear_g_source (&priv->ppp_timeout_handler);
if (!set_ip_config_common (manager, config_dict, &mtu)) if (!set_ip_config_common (manager, config_dict, &mtu))
@@ -538,7 +567,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
g_signal_emit (manager, signals[IP4_CONFIG], 0, config); g_signal_emit (manager, signals[IP4_CONFIG], 0, config);
out: out:
g_dbus_method_invocation_return_value (context, NULL); g_dbus_method_invocation_return_value (invocation, NULL);
} }
/* Converts the named Interface Identifier item to an IPv6 LL address and /* Converts the named Interface Identifier item to an IPv6 LL address and
@@ -571,19 +600,27 @@ iid_value_to_ll6_addr (GVariant *dict,
} }
static void static void
impl_ppp_manager_set_ip6_config (NMPPPManager *manager, impl_ppp_manager_set_ip6_config (NMDBusObject *obj,
GDBusMethodInvocation *context, const NMDBusInterfaceInfoExtended *interface_info,
GVariant *config_dict) const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
NMPPPManager *manager = NM_PPP_MANAGER (obj);
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
gs_unref_object NMIP6Config *config = NULL; gs_unref_object NMIP6Config *config = NULL;
NMPlatformIP6Address addr; NMPlatformIP6Address addr;
struct in6_addr a; struct in6_addr a;
NMUtilsIPv6IfaceId iid = NM_UTILS_IPV6_IFACE_ID_INIT; NMUtilsIPv6IfaceId iid = NM_UTILS_IPV6_IFACE_ID_INIT;
gboolean has_peer = FALSE; gboolean has_peer = FALSE;
gs_unref_variant GVariant *config_dict = NULL;
_LOGI ("(IPv6 Config Get) reply received."); _LOGI ("(IPv6 Config Get) reply received.");
g_variant_get (parameters, "(@a{sv})", &config_dict);
nm_clear_g_source (&priv->ppp_timeout_handler); nm_clear_g_source (&priv->ppp_timeout_handler);
if (!set_ip_config_common (manager, config_dict, NULL)) if (!set_ip_config_common (manager, config_dict, NULL))
@@ -619,7 +656,7 @@ impl_ppp_manager_set_ip6_config (NMPPPManager *manager,
_LOGE ("invalid IPv6 address received!"); _LOGE ("invalid IPv6 address received!");
out: out:
g_dbus_method_invocation_return_value (context, NULL); g_dbus_method_invocation_return_value (invocation, NULL);
} }
/*****************************************************************************/ /*****************************************************************************/
@@ -926,7 +963,7 @@ create_pppd_cmd_line (NMPPPManager *self,
nm_cmd_line_add_int (cmd, 0); nm_cmd_line_add_int (cmd, 0);
nm_cmd_line_add_string (cmd, "ipparam"); nm_cmd_line_add_string (cmd, "ipparam");
nm_cmd_line_add_string (cmd, nm_exported_object_get_path (NM_EXPORTED_OBJECT (self))); nm_cmd_line_add_string (cmd, nm_dbus_object_get_path (NM_DBUS_OBJECT (self)));
nm_cmd_line_add_string (cmd, "plugin"); nm_cmd_line_add_string (cmd, "plugin");
nm_cmd_line_add_string (cmd, NM_PPPD_PLUGIN); nm_cmd_line_add_string (cmd, NM_PPPD_PLUGIN);
@@ -1005,7 +1042,7 @@ _ppp_manager_start (NMPPPManager *manager,
return FALSE; return FALSE;
#endif #endif
nm_exported_object_export (NM_EXPORTED_OBJECT (manager)); nm_dbus_object_export (NM_DBUS_OBJECT (manager));
priv->pid = 0; priv->pid = 0;
@@ -1079,7 +1116,7 @@ out:
nm_cmd_line_destroy (ppp_cmd); nm_cmd_line_destroy (ppp_cmd);
if (priv->pid <= 0) if (priv->pid <= 0)
nm_exported_object_unexport (NM_EXPORTED_OBJECT (manager)); nm_dbus_object_unexport (NM_DBUS_OBJECT (manager));
return priv->pid > 0; return priv->pid > 0;
} }
@@ -1183,7 +1220,7 @@ _ppp_manager_stop_async (NMPPPManager *manager,
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
StopContext *ctx; StopContext *ctx;
nm_exported_object_unexport (NM_EXPORTED_OBJECT (manager)); nm_dbus_object_unexport (NM_DBUS_OBJECT (manager));
ctx = g_slice_new0 (StopContext); ctx = g_slice_new0 (StopContext);
ctx->manager = g_object_ref (manager); ctx->manager = g_object_ref (manager);
@@ -1220,10 +1257,10 @@ _ppp_manager_stop_async (NMPPPManager *manager,
static void static void
_ppp_manager_stop_sync (NMPPPManager *manager) _ppp_manager_stop_sync (NMPPPManager *manager)
{ {
NMExportedObject *exported = NM_EXPORTED_OBJECT (manager); NMDBusObject *dbus = NM_DBUS_OBJECT (manager);
if (nm_exported_object_is_exported (exported)) if (nm_dbus_object_is_exported (dbus))
nm_exported_object_unexport (exported); nm_dbus_object_unexport (dbus);
_ppp_cleanup (manager); _ppp_cleanup (manager);
_ppp_kill (manager); _ppp_kill (manager);
@@ -1293,11 +1330,11 @@ static void
dispose (GObject *object) dispose (GObject *object)
{ {
NMPPPManager *self = (NMPPPManager *) object; NMPPPManager *self = (NMPPPManager *) object;
NMExportedObject *exported = NM_EXPORTED_OBJECT (self); NMDBusObject *dbus = NM_DBUS_OBJECT (self);
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self); NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self);
if (nm_exported_object_is_exported (exported)) if (nm_dbus_object_is_exported (dbus))
nm_exported_object_unexport (exported); nm_dbus_object_unexport (dbus);
_ppp_cleanup (self); _ppp_cleanup (self);
_ppp_kill (self); _ppp_kill (self);
@@ -1317,18 +1354,73 @@ finalize (GObject *object)
G_OBJECT_CLASS (nm_ppp_manager_parent_class)->finalize (object); G_OBJECT_CLASS (nm_ppp_manager_parent_class)->finalize (object);
} }
static const NMDBusInterfaceInfoExtended interface_info_ppp = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_PPP,
.methods = NM_DEFINE_GDBUS_METHOD_INFOS (
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"NeedSecrets",
.out_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("username", "s"),
NM_DEFINE_GDBUS_ARG_INFO ("password", "s"),
),
),
.handle = impl_ppp_manager_need_secrets,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"SetIp4Config",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("config", "a{sv}"),
),
),
.handle = impl_ppp_manager_set_ip4_config,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"SetIp6Config",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("config", "a{sv}"),
),
),
.handle = impl_ppp_manager_set_ip6_config,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"SetState",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("state", "u"),
),
),
.handle = impl_ppp_manager_set_state,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"SetIfindex",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("ifindex", "i"),
),
),
.handle = impl_ppp_manager_set_ifindex,
),
),
),
};
static void static void
nm_ppp_manager_class_init (NMPPPManagerClass *manager_class) nm_ppp_manager_class_init (NMPPPManagerClass *manager_class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (manager_class); GObjectClass *object_class = G_OBJECT_CLASS (manager_class);
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (manager_class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (manager_class);
object_class->dispose = dispose; object_class->dispose = dispose;
object_class->finalize = finalize; object_class->finalize = finalize;
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property; object_class->set_property = set_property;
exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/PPP"); dbus_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/PPP");
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_ppp);
obj_properties[PROP_PARENT_IFACE] = obj_properties[PROP_PARENT_IFACE] =
g_param_spec_string (NM_PPP_MANAGER_PARENT_IFACE, "", "", g_param_spec_string (NM_PPP_MANAGER_PARENT_IFACE, "", "",
@@ -1385,15 +1477,6 @@ nm_ppp_manager_class_init (NMPPPManagerClass *manager_class)
G_TYPE_NONE, 2, G_TYPE_NONE, 2,
G_TYPE_UINT /*guint32 in_bytes*/, G_TYPE_UINT /*guint32 in_bytes*/,
G_TYPE_UINT /*guint32 out_bytes*/); G_TYPE_UINT /*guint32 out_bytes*/);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (manager_class),
NMDBUS_TYPE_PPP_MANAGER_SKELETON,
"NeedSecrets", impl_ppp_manager_need_secrets,
"SetIp4Config", impl_ppp_manager_set_ip4_config,
"SetIp6Config", impl_ppp_manager_set_ip6_config,
"SetState", impl_ppp_manager_set_state,
"SetIfindex", impl_ppp_manager_set_ifindex,
NULL);
} }
NMPPPOps ppp_ops = { NMPPPOps ppp_ops = {

View File

@@ -38,8 +38,6 @@
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "nm-utils/c-list.h" #include "nm-utils/c-list.h"
#include "introspection/org.freedesktop.NetworkManager.AgentManager.h"
/*****************************************************************************/ /*****************************************************************************/
enum { enum {
@@ -67,15 +65,15 @@ typedef struct {
} NMAgentManagerPrivate; } NMAgentManagerPrivate;
struct _NMAgentManager { struct _NMAgentManager {
NMExportedObject parent; NMDBusObject parent;
NMAgentManagerPrivate _priv; NMAgentManagerPrivate _priv;
}; };
struct _NMAgentManagerClass { struct _NMAgentManagerClass {
NMExportedObjectClass parent; NMDBusObjectClass parent;
}; };
G_DEFINE_TYPE (NMAgentManager, nm_agent_manager, NM_TYPE_EXPORTED_OBJECT) G_DEFINE_TYPE (NMAgentManager, nm_agent_manager, NM_TYPE_DBUS_OBJECT)
#define NM_AGENT_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMAgentManager, NM_IS_AGENT_MANAGER) #define NM_AGENT_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMAgentManager, NM_IS_AGENT_MANAGER)
@@ -392,10 +390,10 @@ agent_disconnected_cb (NMSecretAgent *agent, gpointer user_data)
} }
static void static void
impl_agent_manager_register_with_capabilities (NMAgentManager *self, agent_manager_register_with_capabilities (NMAgentManager *self,
GDBusMethodInvocation *context, GDBusMethodInvocation *context,
const char *identifier, const char *identifier,
guint32 capabilities) guint32 capabilities)
{ {
NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE (self); NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE (self);
NMAuthSubject *subject; NMAuthSubject *subject;
@@ -460,45 +458,56 @@ done:
} }
static void static void
impl_agent_manager_register (NMAgentManager *self, impl_agent_manager_register (NMDBusObject *obj,
GDBusMethodInvocation *context, const NMDBusInterfaceInfoExtended *interface_info,
const char *identifier) const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
impl_agent_manager_register_with_capabilities (self, context, identifier, 0); const char *identifier;
g_variant_get (parameters, "(&s)", &identifier);
agent_manager_register_with_capabilities (NM_AGENT_MANAGER (obj), invocation, identifier, 0);
} }
static void static void
impl_agent_manager_unregister (NMAgentManager *self, impl_agent_manager_register_with_capabilities (NMDBusObject *obj,
GDBusMethodInvocation *context) const NMDBusInterfaceInfoExtended *interface_info,
const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
GError *error = NULL; const char *identifier;
char *sender = NULL; guint32 capabilities;
if (!nm_bus_manager_get_caller_info (nm_bus_manager_get (), g_variant_get (parameters, "(&su)", &identifier, &capabilities);
context, agent_manager_register_with_capabilities (NM_AGENT_MANAGER (obj), invocation, identifier, capabilities);
&sender, }
NULL,
NULL)) { static void
error = g_error_new_literal (NM_AGENT_MANAGER_ERROR, impl_agent_manager_unregister (NMDBusObject *obj,
NM_AGENT_MANAGER_ERROR_PERMISSION_DENIED, const NMDBusInterfaceInfoExtended *interface_info,
"Unable to determine request sender."); const NMDBusMethodInfoExtended *method_info,
goto done; GDBusConnection *connection,
} const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{
NMAgentManager *self = NM_AGENT_MANAGER (obj);
/* Found the agent, unregister and remove it */
if (!remove_agent (self, sender)) { if (!remove_agent (self, sender)) {
error = g_error_new_literal (NM_AGENT_MANAGER_ERROR, g_dbus_method_invocation_return_error_literal (invocation,
NM_AGENT_MANAGER_ERROR_NOT_REGISTERED, NM_AGENT_MANAGER_ERROR,
"Caller is not registered as an Agent"); NM_AGENT_MANAGER_ERROR_NOT_REGISTERED,
goto done; "Caller is not registered as an Agent");
return;
} }
g_dbus_method_invocation_return_value (context, NULL); g_dbus_method_invocation_return_value (invocation, NULL);
done:
if (error)
g_dbus_method_invocation_take_error (context, error);
g_free (sender);
} }
/*****************************************************************************/ /*****************************************************************************/
@@ -1586,7 +1595,7 @@ constructed (GObject *object)
priv->auth_mgr = g_object_ref (nm_auth_manager_get ()); priv->auth_mgr = g_object_ref (nm_auth_manager_get ());
priv->session_monitor = g_object_ref (nm_session_monitor_get ()); priv->session_monitor = g_object_ref (nm_session_monitor_get ());
nm_exported_object_export (NM_EXPORTED_OBJECT (object)); nm_dbus_object_export (NM_DBUS_OBJECT (object));
g_signal_connect (priv->auth_mgr, g_signal_connect (priv->auth_mgr,
NM_AUTH_MANAGER_SIGNAL_CHANGED, NM_AUTH_MANAGER_SIGNAL_CHANGED,
@@ -1622,20 +1631,64 @@ cancel_more:
g_clear_object (&priv->auth_mgr); g_clear_object (&priv->auth_mgr);
} }
nm_exported_object_unexport (NM_EXPORTED_OBJECT (object)); nm_dbus_object_unexport (NM_DBUS_OBJECT (object));
g_clear_object (&priv->session_monitor); g_clear_object (&priv->session_monitor);
G_OBJECT_CLASS (nm_agent_manager_parent_class)->dispose (object); G_OBJECT_CLASS (nm_agent_manager_parent_class)->dispose (object);
} }
static const NMDBusInterfaceInfoExtended interface_info_agent_manager = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_AGENT_MANAGER,
.methods = NM_DEFINE_GDBUS_METHOD_INFOS (
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"Register",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("identifier", "s"),
),
),
.handle = impl_agent_manager_register,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"RegisterWithCapabilities",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("identifier", "s"),
NM_DEFINE_GDBUS_ARG_INFO ("capabilities", "u"),
),
),
.handle = impl_agent_manager_register_with_capabilities,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"RegisterWithCapabilities",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("identifier", "s"),
NM_DEFINE_GDBUS_ARG_INFO ("capabilities", "u"),
),
),
.handle = impl_agent_manager_register_with_capabilities,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"Unregister",
),
.handle = impl_agent_manager_unregister,
),
),
),
};
static void static void
nm_agent_manager_class_init (NMAgentManagerClass *agent_manager_class) nm_agent_manager_class_init (NMAgentManagerClass *agent_manager_class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (agent_manager_class); GObjectClass *object_class = G_OBJECT_CLASS (agent_manager_class);
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (agent_manager_class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (agent_manager_class);
exported_object_class->export_path = NM_DBUS_PATH_AGENT_MANAGER; dbus_object_class->export_path = NM_DBUS_PATH_AGENT_MANAGER;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_agent_manager);
object_class->constructed = constructed; object_class->constructed = constructed;
object_class->dispose = dispose; object_class->dispose = dispose;
@@ -1649,11 +1702,4 @@ nm_agent_manager_class_init (NMAgentManagerClass *agent_manager_class)
g_cclosure_marshal_VOID__OBJECT, g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
G_TYPE_OBJECT); G_TYPE_OBJECT);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (agent_manager_class),
NMDBUS_TYPE_AGENT_MANAGER_SKELETON,
"Register", impl_agent_manager_register,
"RegisterWithCapabilities", impl_agent_manager_register_with_capabilities,
"Unregister", impl_agent_manager_unregister,
NULL);
} }

View File

@@ -23,7 +23,7 @@
#include "nm-connection.h" #include "nm-connection.h"
#include "nm-exported-object.h" #include "nm-dbus-object.h"
#include "nm-secret-agent.h" #include "nm-secret-agent.h"
#define NM_TYPE_AGENT_MANAGER (nm_agent_manager_get_type ()) #define NM_TYPE_AGENT_MANAGER (nm_agent_manager_get_type ())

View File

@@ -51,7 +51,7 @@ typedef struct {
NMSecretAgentCapabilities capabilities; NMSecretAgentCapabilities capabilities;
GSList *permissions; GSList *permissions;
GDBusProxy *proxy; GDBusProxy *proxy;
NMBusManager *bus_mgr; NMDBusManager *bus_mgr;
GDBusConnection *connection; GDBusConnection *connection;
CList requests; CList requests;
gulong on_disconnected_id; gulong on_disconnected_id;
@@ -631,7 +631,7 @@ _on_disconnected_cleanup (NMSecretAgentPrivate *priv)
} }
static void static void
_on_disconnected_private_connection (NMBusManager *mgr, _on_disconnected_private_connection (NMDBusManager *mgr,
GDBusConnection *connection, GDBusConnection *connection,
NMSecretAgent *self) NMSecretAgent *self)
{ {
@@ -715,9 +715,9 @@ nm_secret_agent_new (GDBusMethodInvocation *context,
priv = NM_SECRET_AGENT_GET_PRIVATE (self); priv = NM_SECRET_AGENT_GET_PRIVATE (self);
priv->bus_mgr = g_object_ref (nm_bus_manager_get ()); priv->bus_mgr = g_object_ref (nm_dbus_manager_get ());
priv->connection = g_object_ref (connection); priv->connection = g_object_ref (connection);
priv->connection_is_private = !!nm_bus_manager_connection_get_private_name (priv->bus_mgr, connection); priv->connection_is_private = !!nm_dbus_manager_connection_get_private_name (priv->bus_mgr, connection);
_LOGt ("constructed: %s, owner=%s%s%s (%s), private-connection=%d, unique-name=%s%s%s, capabilities=%s", _LOGt ("constructed: %s, owner=%s%s%s (%s), private-connection=%d, unique-name=%s%s%s, capabilities=%s",
(description = _create_description (dbus_owner, identifier, uid)), (description = _create_description (dbus_owner, identifier, uid)),
@@ -734,18 +734,18 @@ nm_secret_agent_new (GDBusMethodInvocation *context,
priv->capabilities = capabilities; priv->capabilities = capabilities;
priv->subject = g_object_ref (subject); priv->subject = g_object_ref (subject);
priv->proxy = nm_bus_manager_new_proxy (priv->bus_mgr, priv->proxy = nm_dbus_manager_new_proxy (priv->bus_mgr,
priv->connection, priv->connection,
G_TYPE_DBUS_PROXY, G_TYPE_DBUS_PROXY,
priv->dbus_owner, priv->dbus_owner,
NM_DBUS_PATH_SECRET_AGENT, NM_DBUS_PATH_SECRET_AGENT,
NM_DBUS_INTERFACE_SECRET_AGENT); NM_DBUS_INTERFACE_SECRET_AGENT);
/* we cannot subscribe to notify::g-name-owner because that doesn't work /* we cannot subscribe to notify::g-name-owner because that doesn't work
* for unique names and it doesn't work for private connections. */ * for unique names and it doesn't work for private connections. */
if (priv->connection_is_private) { if (priv->connection_is_private) {
priv->on_disconnected_id = g_signal_connect (priv->bus_mgr, priv->on_disconnected_id = g_signal_connect (priv->bus_mgr,
NM_BUS_MANAGER_PRIVATE_CONNECTION_DISCONNECTED, NM_DBUS_MANAGER_PRIVATE_CONNECTION_DISCONNECTED,
G_CALLBACK (_on_disconnected_private_connection), G_CALLBACK (_on_disconnected_private_connection),
self); self);
} else { } else {

View File

@@ -39,8 +39,6 @@
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "nm-audit-manager.h" #include "nm-audit-manager.h"
#include "introspection/org.freedesktop.NetworkManager.Settings.Connection.h"
#define SETTINGS_TIMESTAMPS_FILE NMSTATEDIR "/timestamps" #define SETTINGS_TIMESTAMPS_FILE NMSTATEDIR "/timestamps"
#define SETTINGS_SEEN_BSSIDS_FILE NMSTATEDIR "/seen-bssids" #define SETTINGS_SEEN_BSSIDS_FILE NMSTATEDIR "/seen-bssids"
@@ -60,7 +58,6 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMSettingsConnection,
); );
enum { enum {
UPDATED,
REMOVED, REMOVED,
UPDATED_INTERNAL, UPDATED_INTERNAL,
LAST_SIGNAL LAST_SIGNAL
@@ -115,7 +112,7 @@ typedef struct _NMSettingsConnectionPrivate {
} NMSettingsConnectionPrivate; } NMSettingsConnectionPrivate;
G_DEFINE_TYPE_WITH_CODE (NMSettingsConnection, nm_settings_connection, NM_TYPE_EXPORTED_OBJECT, G_DEFINE_TYPE_WITH_CODE (NMSettingsConnection, nm_settings_connection, NM_TYPE_DBUS_OBJECT,
G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION, nm_settings_connection_connection_interface_init) G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION, nm_settings_connection_connection_interface_init)
) )
@@ -146,12 +143,9 @@ G_DEFINE_TYPE_WITH_CODE (NMSettingsConnection, nm_settings_connection, NM_TYPE_E
/*****************************************************************************/ /*****************************************************************************/
static void static const GDBusSignalInfo signal_info_updated;
_emit_updated (NMSettingsConnection *self, gboolean by_user) static const GDBusSignalInfo signal_info_removed;
{ static const NMDBusInterfaceInfoExtended interface_info_settings_connection;
g_signal_emit (self, signals[UPDATED], 0);
g_signal_emit (self, signals[UPDATED_INTERNAL], 0, by_user);
}
/*****************************************************************************/ /*****************************************************************************/
@@ -525,6 +519,16 @@ set_persist_mode (NMSettingsConnection *self, NMSettingsConnectionPersistMode pe
nm_settings_connection_set_flags_full (self, ALL, flags); nm_settings_connection_set_flags_full (self, ALL, flags);
} }
static void
_emit_updated (NMSettingsConnection *self, gboolean by_user)
{
nm_dbus_object_emit_signal (NM_DBUS_OBJECT (self),
&interface_info_settings_connection,
&signal_info_updated,
"()");
g_signal_emit (self, signals[UPDATED_INTERNAL], 0, by_user);
}
static void static void
connection_changed_cb (NMSettingsConnection *self, gpointer unused) connection_changed_cb (NMSettingsConnection *self, gpointer unused)
{ {
@@ -1573,18 +1577,25 @@ get_settings_auth_cb (NMSettingsConnection *self,
} }
static void static void
impl_settings_connection_get_settings (NMSettingsConnection *self, impl_settings_connection_get_settings (NMDBusObject *obj,
GDBusMethodInvocation *context) const NMDBusInterfaceInfoExtended *interface_info,
const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
NMAuthSubject *subject; NMSettingsConnection *self = NM_SETTINGS_CONNECTION (obj);
gs_unref_object NMAuthSubject *subject = NULL;
GError *error = NULL; GError *error = NULL;
subject = _new_auth_subject (context, &error); subject = _new_auth_subject (invocation, &error);
if (subject) { if (!subject) {
auth_start (self, context, subject, NULL, get_settings_auth_cb, NULL); g_dbus_method_invocation_take_error (invocation, error);
g_object_unref (subject); return;
} else }
g_dbus_method_invocation_take_error (context, error);
auth_start (self, invocation, subject, NULL, get_settings_auth_cb, NULL);
} }
typedef struct { typedef struct {
@@ -1897,54 +1908,87 @@ error:
} }
static void static void
impl_settings_connection_update (NMSettingsConnection *self, impl_settings_connection_update (NMDBusObject *obj,
GDBusMethodInvocation *context, const NMDBusInterfaceInfoExtended *interface_info,
GVariant *new_settings) const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
settings_connection_update (self, FALSE, context, new_settings, NM_SETTINGS_UPDATE2_FLAG_TO_DISK); NMSettingsConnection *self = NM_SETTINGS_CONNECTION (obj);
gs_unref_variant GVariant *settings = NULL;
g_variant_get (parameters, "(@a{sa{sv}})", &settings);
settings_connection_update (self, FALSE, invocation, settings, NM_SETTINGS_UPDATE2_FLAG_TO_DISK);
} }
static void static void
impl_settings_connection_update_unsaved (NMSettingsConnection *self, impl_settings_connection_update_unsaved (NMDBusObject *obj,
GDBusMethodInvocation *context, const NMDBusInterfaceInfoExtended *interface_info,
GVariant *new_settings) const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
settings_connection_update (self, FALSE, context, new_settings, NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY); NMSettingsConnection *self = NM_SETTINGS_CONNECTION (obj);
gs_unref_variant GVariant *settings = NULL;
g_variant_get (parameters, "(@a{sa{sv}})", &settings);
settings_connection_update (self, FALSE, invocation, settings, NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY);
} }
static void static void
impl_settings_connection_save (NMSettingsConnection *self, impl_settings_connection_save (NMDBusObject *obj,
GDBusMethodInvocation *context) const NMDBusInterfaceInfoExtended *interface_info,
const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
settings_connection_update (self, FALSE, context, NULL, NM_SETTINGS_UPDATE2_FLAG_TO_DISK); NMSettingsConnection *self = NM_SETTINGS_CONNECTION (obj);
settings_connection_update (self, FALSE, invocation, NULL, NM_SETTINGS_UPDATE2_FLAG_TO_DISK);
} }
static void static void
impl_settings_connection_update2 (NMSettingsConnection *self, impl_settings_connection_update2 (NMDBusObject *obj,
GDBusMethodInvocation *context, const NMDBusInterfaceInfoExtended *interface_info,
GVariant *settings, const NMDBusMethodInfoExtended *method_info,
guint32 flags_u, GDBusConnection *connection,
GVariant *args) const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
NMSettingsConnection *self = NM_SETTINGS_CONNECTION (obj);
gs_unref_variant GVariant *settings = NULL;
gs_unref_variant GVariant *args = NULL;
guint32 flags_u;
GError *error = NULL; GError *error = NULL;
GVariantIter iter; GVariantIter iter;
const char *args_name; const char *args_name;
const NMSettingsUpdate2Flags flags = (NMSettingsUpdate2Flags) flags_u; NMSettingsUpdate2Flags flags;
const NMSettingsUpdate2Flags ALL_PERSIST_MODES = NM_SETTINGS_UPDATE2_FLAG_TO_DISK const NMSettingsUpdate2Flags ALL_PERSIST_MODES = NM_SETTINGS_UPDATE2_FLAG_TO_DISK
| NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY | NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY
| NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_DETACHED | NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_DETACHED
| NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_ONLY; | NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_ONLY;
g_variant_get (parameters, "(@a{sa{sv}}u@a{sv})", &settings, &flags_u, &args);
if (NM_FLAGS_ANY (flags_u, ~((guint32) (ALL_PERSIST_MODES | if (NM_FLAGS_ANY (flags_u, ~((guint32) (ALL_PERSIST_MODES |
NM_SETTINGS_UPDATE2_FLAG_VOLATILE | NM_SETTINGS_UPDATE2_FLAG_VOLATILE |
NM_SETTINGS_UPDATE2_FLAG_BLOCK_AUTOCONNECT)))) { NM_SETTINGS_UPDATE2_FLAG_BLOCK_AUTOCONNECT)))) {
error = g_error_new_literal (NM_SETTINGS_ERROR, error = g_error_new_literal (NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_INVALID_ARGUMENTS, NM_SETTINGS_ERROR_INVALID_ARGUMENTS,
"Unknown flags"); "Unknown flags");
g_dbus_method_invocation_take_error (context, error); g_dbus_method_invocation_take_error (invocation, error);
return; return;
} }
flags = (NMSettingsUpdate2Flags) flags_u;
if ( ( NM_FLAGS_ANY (flags, ALL_PERSIST_MODES) if ( ( NM_FLAGS_ANY (flags, ALL_PERSIST_MODES)
&& !nm_utils_is_power_of_two (flags & ALL_PERSIST_MODES)) && !nm_utils_is_power_of_two (flags & ALL_PERSIST_MODES))
|| ( NM_FLAGS_HAS (flags, NM_SETTINGS_UPDATE2_FLAG_VOLATILE) || ( NM_FLAGS_HAS (flags, NM_SETTINGS_UPDATE2_FLAG_VOLATILE)
@@ -1953,7 +1997,7 @@ impl_settings_connection_update2 (NMSettingsConnection *self,
error = g_error_new_literal (NM_SETTINGS_ERROR, error = g_error_new_literal (NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_INVALID_ARGUMENTS, NM_SETTINGS_ERROR_INVALID_ARGUMENTS,
"Conflicting flags"); "Conflicting flags");
g_dbus_method_invocation_take_error (context, error); g_dbus_method_invocation_take_error (invocation, error);
return; return;
} }
@@ -1961,7 +2005,7 @@ impl_settings_connection_update2 (NMSettingsConnection *self,
error = g_error_new_literal (NM_SETTINGS_ERROR, error = g_error_new_literal (NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_INVALID_ARGUMENTS, NM_SETTINGS_ERROR_INVALID_ARGUMENTS,
"args is of invalid type"); "args is of invalid type");
g_dbus_method_invocation_take_error (context, error); g_dbus_method_invocation_take_error (invocation, error);
return; return;
} }
@@ -1970,13 +2014,13 @@ impl_settings_connection_update2 (NMSettingsConnection *self,
error = g_error_new (NM_SETTINGS_ERROR, error = g_error_new (NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_INVALID_ARGUMENTS, NM_SETTINGS_ERROR_INVALID_ARGUMENTS,
"Unsupported argument '%s'", args_name); "Unsupported argument '%s'", args_name);
g_dbus_method_invocation_take_error (context, error); g_dbus_method_invocation_take_error (invocation, error);
return; return;
} }
settings_connection_update (self, settings_connection_update (self,
TRUE, TRUE,
context, invocation,
settings, settings,
flags); flags);
} }
@@ -2029,26 +2073,30 @@ get_modify_permission_basic (NMSettingsConnection *self)
} }
static void static void
impl_settings_connection_delete (NMSettingsConnection *self, impl_settings_connection_delete (NMDBusObject *obj,
GDBusMethodInvocation *context) const NMDBusInterfaceInfoExtended *interface_info,
const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
NMAuthSubject *subject = NULL; NMSettingsConnection *self = NM_SETTINGS_CONNECTION (obj);
gs_unref_object NMAuthSubject *subject = NULL;
GError *error = NULL; GError *error = NULL;
if (!check_writable (NM_CONNECTION (self), &error)) if (!check_writable (NM_CONNECTION (self), &error))
goto out_err; goto err;
subject = _new_auth_subject (context, &error); subject = _new_auth_subject (invocation, &error);
if (subject) { if (!subject)
auth_start (self, context, subject, get_modify_permission_basic (self), delete_auth_cb, NULL); goto err;
g_object_unref (subject);
} else
goto out_err;
auth_start (self, invocation, subject, get_modify_permission_basic (self), delete_auth_cb, NULL);
return; return;
out_err: err:
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_DELETE, self, FALSE, NULL, subject, error->message); nm_audit_log_connection_op (NM_AUDIT_OP_CONN_DELETE, self, FALSE, NULL, subject, error->message);
g_dbus_method_invocation_take_error (context, error); g_dbus_method_invocation_take_error (invocation, error);
} }
/*****************************************************************************/ /*****************************************************************************/
@@ -2107,24 +2155,33 @@ dbus_get_secrets_auth_cb (NMSettingsConnection *self,
} }
static void static void
impl_settings_connection_get_secrets (NMSettingsConnection *self, impl_settings_connection_get_secrets (NMDBusObject *obj,
GDBusMethodInvocation *context, const NMDBusInterfaceInfoExtended *interface_info,
const gchar *setting_name) const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
NMAuthSubject *subject; NMSettingsConnection *self = NM_SETTINGS_CONNECTION (obj);
gs_unref_object NMAuthSubject *subject = NULL;
GError *error = NULL; GError *error = NULL;
const char *setting_name;
subject = _new_auth_subject (context, &error); subject = _new_auth_subject (invocation, &error);
if (subject) { if (!subject) {
auth_start (self, g_dbus_method_invocation_take_error (invocation, error);
context, return;
subject, }
get_modify_permission_basic (self),
dbus_get_secrets_auth_cb, g_variant_get (parameters, "(&s)", &setting_name);
g_strdup (setting_name));
g_object_unref (subject); auth_start (self,
} else invocation,
g_dbus_method_invocation_take_error (context, error); subject,
get_modify_permission_basic (self),
dbus_get_secrets_auth_cb,
g_strdup (setting_name));
} }
static void static void
@@ -2173,26 +2230,31 @@ dbus_clear_secrets_auth_cb (NMSettingsConnection *self,
} }
static void static void
impl_settings_connection_clear_secrets (NMSettingsConnection *self, impl_settings_connection_clear_secrets (NMDBusObject *obj,
GDBusMethodInvocation *context) const NMDBusInterfaceInfoExtended *interface_info,
const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
NMAuthSubject *subject; NMSettingsConnection *self = NM_SETTINGS_CONNECTION (obj);
gs_unref_object NMAuthSubject *subject = NULL;
GError *error = NULL; GError *error = NULL;
subject = _new_auth_subject (context, &error); subject = _new_auth_subject (invocation, &error);
if (subject) { if (!subject) {
auth_start (self,
context,
subject,
get_modify_permission_basic (self),
dbus_clear_secrets_auth_cb,
NULL);
g_object_unref (subject);
} else {
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_CLEAR_SECRETS, self, nm_audit_log_connection_op (NM_AUDIT_OP_CONN_CLEAR_SECRETS, self,
FALSE, NULL, NULL, error->message); FALSE, NULL, NULL, error->message);
g_dbus_method_invocation_take_error (context, error); g_dbus_method_invocation_take_error (invocation, error);
return;
} }
auth_start (self,
invocation,
subject,
get_modify_permission_basic (self),
dbus_clear_secrets_auth_cb,
NULL);
} }
/*****************************************************************************/ /*****************************************************************************/
@@ -2216,7 +2278,12 @@ nm_settings_connection_signal_remove (NMSettingsConnection *self)
if (priv->removed) if (priv->removed)
return; return;
priv->removed = TRUE; priv->removed = TRUE;
g_signal_emit_by_name (self, NM_SETTINGS_CONNECTION_REMOVED);
nm_dbus_object_emit_signal (NM_DBUS_OBJECT (self),
&interface_info_settings_connection,
&signal_info_removed,
"()");
g_signal_emit (self, signals[REMOVED], 0);
} }
gboolean gboolean
@@ -3010,22 +3077,119 @@ set_property (GObject *object, guint prop_id,
} }
} }
static const GDBusSignalInfo signal_info_updated = NM_DEFINE_GDBUS_SIGNAL_INFO_INIT (
"Updated",
);
static const GDBusSignalInfo signal_info_removed = NM_DEFINE_GDBUS_SIGNAL_INFO_INIT (
"Removed",
);
static const NMDBusInterfaceInfoExtended interface_info_settings_connection = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
.methods = NM_DEFINE_GDBUS_METHOD_INFOS (
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"Update",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("properties", "a{sa{sv}}"),
),
),
.handle = impl_settings_connection_update,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"UpdateUnsaved",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("properties", "a{sa{sv}}"),
),
),
.handle = impl_settings_connection_update_unsaved,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"Delete",
),
.handle = impl_settings_connection_delete,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"GetSettings",
.out_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("settings", "a{sa{sv}}"),
),
),
.handle = impl_settings_connection_get_settings,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"GetSecrets",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("setting_name", "s"),
),
.out_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("secrets", "a{sa{sv}}"),
),
),
.handle = impl_settings_connection_get_secrets,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"ClearSecrets",
),
.handle = impl_settings_connection_clear_secrets,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"Save",
),
.handle = impl_settings_connection_save,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"Update2",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("settings", "a{sa{sv}}"),
NM_DEFINE_GDBUS_ARG_INFO ("flags", "u"),
NM_DEFINE_GDBUS_ARG_INFO ("args", "a{sv}"),
),
.out_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("result", "a{sv}"),
),
),
.handle = impl_settings_connection_update2,
),
),
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
&signal_info_updated,
&signal_info_removed,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Unsaved", "b", NM_SETTINGS_CONNECTION_UNSAVED),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_settings_connection_class_init (NMSettingsConnectionClass *class) nm_settings_connection_class_init (NMSettingsConnectionClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (class); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
g_type_class_add_private (class, sizeof (NMSettingsConnectionPrivate)); g_type_class_add_private (klass, sizeof (NMSettingsConnectionPrivate));
exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH_SETTINGS); dbus_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH_SETTINGS);
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_settings_connection);
object_class->constructed = constructed; object_class->constructed = constructed;
object_class->dispose = dispose; object_class->dispose = dispose;
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property; object_class->set_property = set_property;
class->supports_secrets = supports_secrets; klass->supports_secrets = supports_secrets;
obj_properties[PROP_UNSAVED] = obj_properties[PROP_UNSAVED] =
g_param_spec_boolean (NM_SETTINGS_CONNECTION_UNSAVED, "", "", g_param_spec_boolean (NM_SETTINGS_CONNECTION_UNSAVED, "", "",
@@ -3056,20 +3220,10 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class)
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
signals[UPDATED] =
g_signal_new (NM_SETTINGS_CONNECTION_UPDATED,
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_FIRST,
0,
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/* internal signal, with an argument (gboolean by_user). */ /* internal signal, with an argument (gboolean by_user). */
signals[UPDATED_INTERNAL] = signals[UPDATED_INTERNAL] =
g_signal_new (NM_SETTINGS_CONNECTION_UPDATED_INTERNAL, g_signal_new (NM_SETTINGS_CONNECTION_UPDATED_INTERNAL,
G_TYPE_FROM_CLASS (class), G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
0, NULL, NULL, 0, NULL, NULL,
g_cclosure_marshal_VOID__BOOLEAN, g_cclosure_marshal_VOID__BOOLEAN,
@@ -3077,24 +3231,12 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class)
signals[REMOVED] = signals[REMOVED] =
g_signal_new (NM_SETTINGS_CONNECTION_REMOVED, g_signal_new (NM_SETTINGS_CONNECTION_REMOVED,
G_TYPE_FROM_CLASS (class), G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
0, 0,
NULL, NULL, NULL, NULL,
g_cclosure_marshal_VOID__VOID, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (class),
NMDBUS_TYPE_SETTINGS_CONNECTION_SKELETON,
"Update", impl_settings_connection_update,
"UpdateUnsaved", impl_settings_connection_update_unsaved,
"Delete", impl_settings_connection_delete,
"GetSettings", impl_settings_connection_get_settings,
"GetSecrets", impl_settings_connection_get_secrets,
"ClearSecrets", impl_settings_connection_clear_secrets,
"Save", impl_settings_connection_save,
"Update2", impl_settings_connection_update2,
NULL);
} }
static void static void

View File

@@ -24,7 +24,7 @@
#include <net/ethernet.h> #include <net/ethernet.h>
#include "nm-exported-object.h" #include "nm-dbus-object.h"
#include "nm-connection.h" #include "nm-connection.h"
#define NM_TYPE_SETTINGS_CONNECTION (nm_settings_connection_get_type ()) #define NM_TYPE_SETTINGS_CONNECTION (nm_settings_connection_get_type ())
@@ -34,13 +34,9 @@
#define NM_IS_SETTINGS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTINGS_CONNECTION)) #define NM_IS_SETTINGS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTINGS_CONNECTION))
#define NM_SETTINGS_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTINGS_CONNECTION, NMSettingsConnectionClass)) #define NM_SETTINGS_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTINGS_CONNECTION, NMSettingsConnectionClass))
/* Signals */
#define NM_SETTINGS_CONNECTION_UPDATED "updated"
#define NM_SETTINGS_CONNECTION_REMOVED "removed" #define NM_SETTINGS_CONNECTION_REMOVED "removed"
#define NM_SETTINGS_CONNECTION_GET_SECRETS "get-secrets" #define NM_SETTINGS_CONNECTION_GET_SECRETS "get-secrets"
#define NM_SETTINGS_CONNECTION_CANCEL_SECRETS "cancel-secrets" #define NM_SETTINGS_CONNECTION_CANCEL_SECRETS "cancel-secrets"
/* Internal signals */
#define NM_SETTINGS_CONNECTION_UPDATED_INTERNAL "updated-internal" #define NM_SETTINGS_CONNECTION_UPDATED_INTERNAL "updated-internal"
/* Properties */ /* Properties */
@@ -106,12 +102,12 @@ typedef struct _NMSettingsConnectionClass NMSettingsConnectionClass;
struct _NMSettingsConnectionPrivate; struct _NMSettingsConnectionPrivate;
struct _NMSettingsConnection { struct _NMSettingsConnection {
NMExportedObject parent; NMDBusObject parent;
struct _NMSettingsConnectionPrivate *_priv; struct _NMSettingsConnectionPrivate *_priv;
}; };
struct _NMSettingsConnectionClass { struct _NMSettingsConnectionClass {
NMExportedObjectClass parent; NMDBusObjectClass parent;
gboolean (*commit_changes) (NMSettingsConnection *self, gboolean (*commit_changes) (NMSettingsConnection *self,
NMConnection *new_connection, NMConnection *new_connection,

View File

@@ -62,6 +62,7 @@
#include "nm-utils.h" #include "nm-utils.h"
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "nm-dbus-object.h"
#include "devices/nm-device-ethernet.h" #include "devices/nm-device-ethernet.h"
#include "nm-settings-connection.h" #include "nm-settings-connection.h"
#include "nm-settings-plugin.h" #include "nm-settings-plugin.h"
@@ -77,8 +78,6 @@
#include "nm-dispatcher.h" #include "nm-dispatcher.h"
#include "nm-hostname-manager.h" #include "nm-hostname-manager.h"
#include "introspection/org.freedesktop.NetworkManager.Settings.h"
/*****************************************************************************/ /*****************************************************************************/
#define EXPORT(sym) void * __export_##sym = &sym; #define EXPORT(sym) void * __export_##sym = &sym;
@@ -107,7 +106,6 @@ enum {
CONNECTION_UPDATED, CONNECTION_UPDATED,
CONNECTION_REMOVED, CONNECTION_REMOVED,
CONNECTION_FLAGS_CHANGED, CONNECTION_FLAGS_CHANGED,
NEW_CONNECTION, /* exported, not used internally */
LAST_SIGNAL LAST_SIGNAL
}; };
@@ -135,15 +133,15 @@ typedef struct {
} NMSettingsPrivate; } NMSettingsPrivate;
struct _NMSettings { struct _NMSettings {
NMExportedObject parent; NMDBusObject parent;
NMSettingsPrivate _priv; NMSettingsPrivate _priv;
}; };
struct _NMSettingsClass { struct _NMSettingsClass {
NMExportedObjectClass parent; NMDBusObjectClass parent;
}; };
G_DEFINE_TYPE (NMSettings, nm_settings, NM_TYPE_EXPORTED_OBJECT); G_DEFINE_TYPE (NMSettings, nm_settings, NM_TYPE_DBUS_OBJECT);
#define NM_SETTINGS_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMSettings, NM_IS_SETTINGS) #define NM_SETTINGS_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMSettings, NM_IS_SETTINGS)
@@ -154,6 +152,10 @@ G_DEFINE_TYPE (NMSettings, nm_settings, NM_TYPE_EXPORTED_OBJECT);
/*****************************************************************************/ /*****************************************************************************/
static const NMDBusInterfaceInfoExtended interface_info_settings;
static const GDBusSignalInfo signal_info_new_connection;
static const GDBusSignalInfo signal_info_connection_removed;
static void claim_connection (NMSettings *self, static void claim_connection (NMSettings *self,
NMSettingsConnection *connection); NMSettingsConnection *connection);
@@ -267,11 +269,17 @@ nm_settings_for_each_connection (NMSettings *self,
} }
static void static void
impl_settings_list_connections (NMSettings *self, impl_settings_list_connections (NMDBusObject *obj,
GDBusMethodInvocation *context) const NMDBusInterfaceInfoExtended *interface_info,
const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
NMSettings *self = NM_SETTINGS (obj);
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
GPtrArray *connections; gs_unref_ptrarray GPtrArray *connections = NULL;
GHashTableIter iter; GHashTableIter iter;
gpointer key; gpointer key;
@@ -281,9 +289,8 @@ impl_settings_list_connections (NMSettings *self,
g_ptr_array_add (connections, key); g_ptr_array_add (connections, key);
g_ptr_array_add (connections, NULL); g_ptr_array_add (connections, NULL);
g_dbus_method_invocation_return_value (context, g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(^ao)", connections->pdata)); g_variant_new ("(^ao)", connections->pdata));
g_ptr_array_unref (connections);
} }
NMSettingsConnection * NMSettingsConnection *
@@ -308,14 +315,22 @@ nm_settings_get_connection_by_uuid (NMSettings *self, const char *uuid)
} }
static void static void
impl_settings_get_connection_by_uuid (NMSettings *self, impl_settings_get_connection_by_uuid (NMDBusObject *obj,
GDBusMethodInvocation *context, const NMDBusInterfaceInfoExtended *interface_info,
const char *uuid) const NMDBusMethodInfoExtended *method_info,
GDBusConnection *dbus_connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
NMSettings *self = NM_SETTINGS (obj);
NMSettingsConnection *connection = NULL; NMSettingsConnection *connection = NULL;
NMAuthSubject *subject = NULL; gs_unref_object NMAuthSubject *subject = NULL;
GError *error = NULL; GError *error = NULL;
char *error_desc = NULL; char *error_desc = NULL;
const char *uuid;
g_variant_get (parameters, "(&s)", &uuid);
connection = nm_settings_get_connection_by_uuid (self, uuid); connection = nm_settings_get_connection_by_uuid (self, uuid);
if (!connection) { if (!connection) {
@@ -325,7 +340,7 @@ impl_settings_get_connection_by_uuid (NMSettings *self,
goto error; goto error;
} }
subject = nm_auth_subject_new_unix_process_from_context (context); subject = nm_auth_subject_new_unix_process_from_context (invocation);
if (!subject) { if (!subject) {
error = g_error_new_literal (NM_SETTINGS_ERROR, error = g_error_new_literal (NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_PERMISSION_DENIED, NM_SETTINGS_ERROR_PERMISSION_DENIED,
@@ -343,16 +358,13 @@ impl_settings_get_connection_by_uuid (NMSettings *self,
goto error; goto error;
} }
g_clear_object (&subject); g_dbus_method_invocation_return_value (invocation,
g_dbus_method_invocation_return_value ( g_variant_new ("(o)",
context, nm_connection_get_path (NM_CONNECTION (connection))));
g_variant_new ("(o)", nm_connection_get_path (NM_CONNECTION (connection))));
return; return;
error: error:
g_assert (error); g_dbus_method_invocation_take_error (invocation, error);
g_dbus_method_invocation_take_error (context, error);
g_clear_object (&subject);
} }
/** /**
@@ -500,7 +512,7 @@ nm_settings_get_unmanaged_specs (NMSettings *self)
} }
static NMSettingsPlugin * static NMSettingsPlugin *
get_plugin (NMSettings *self, guint32 capability) get_plugin (NMSettings *self, NMSettingsPluginCapabilities capability)
{ {
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
GSList *iter; GSList *iter;
@@ -815,6 +827,19 @@ connection_flags_changed (NMSettingsConnection *connection,
connection); connection);
} }
static void
_emit_connection_removed (NMSettings *self,
NMSettingsConnection *connection)
{
nm_dbus_object_emit_signal (NM_DBUS_OBJECT (self),
&interface_info_settings,
&signal_info_connection_removed,
"(o)",
nm_connection_get_path (NM_CONNECTION (connection)));
g_signal_emit (self, signals[CONNECTION_REMOVED], 0, connection);
}
static void static void
connection_removed (NMSettingsConnection *connection, gpointer user_data) connection_removed (NMSettingsConnection *connection, gpointer user_data)
{ {
@@ -842,13 +867,12 @@ connection_removed (NMSettingsConnection *connection, gpointer user_data)
g_hash_table_remove (priv->connections, (gpointer) cpath); g_hash_table_remove (priv->connections, (gpointer) cpath);
g_clear_pointer (&priv->connections_cached_list, g_free); g_clear_pointer (&priv->connections_cached_list, g_free);
/* Notify D-Bus */ _emit_connection_removed (self, connection);
g_signal_emit (self, signals[CONNECTION_REMOVED], 0, connection);
/* Re-emit for listeners like NMPolicy */ /* Re-emit for listeners like NMPolicy */
_notify (self, PROP_CONNECTIONS); _notify (self, PROP_CONNECTIONS);
if (nm_exported_object_is_exported (NM_EXPORTED_OBJECT (connection))) if (nm_dbus_object_is_exported (NM_DBUS_OBJECT (connection)))
nm_exported_object_unexport (NM_EXPORTED_OBJECT (connection)); nm_dbus_object_unexport (NM_DBUS_OBJECT (connection));
check_startup_complete (self); check_startup_complete (self);
@@ -968,7 +992,7 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection)
/* Export the connection over D-Bus */ /* Export the connection over D-Bus */
g_warn_if_fail (nm_connection_get_path (NM_CONNECTION (connection)) == NULL); g_warn_if_fail (nm_connection_get_path (NM_CONNECTION (connection)) == NULL);
path = nm_exported_object_export (NM_EXPORTED_OBJECT (connection)); path = nm_dbus_object_export (NM_DBUS_OBJECT (connection));
nm_connection_set_path (NM_CONNECTION (connection), path); nm_connection_set_path (NM_CONNECTION (connection), path);
g_hash_table_insert (priv->connections, g_hash_table_insert (priv->connections,
@@ -982,12 +1006,14 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection)
* have been initially loaded. * have been initially loaded.
*/ */
if (priv->connections_loaded) { if (priv->connections_loaded) {
/* Internal added signal */ nm_dbus_object_emit_signal (NM_DBUS_OBJECT (self),
&interface_info_settings,
&signal_info_new_connection,
"(o)",
nm_connection_get_path (NM_CONNECTION (connection)));
g_signal_emit (self, signals[CONNECTION_ADDED], 0, connection); g_signal_emit (self, signals[CONNECTION_ADDED], 0, connection);
_notify (self, PROP_CONNECTIONS); _notify (self, PROP_CONNECTIONS);
/* Exported D-Bus signal */
g_signal_emit (self, signals[NEW_CONNECTION], 0, connection);
} }
nm_settings_connection_added (connection); nm_settings_connection_added (connection);
@@ -1312,12 +1338,12 @@ done:
} }
static void static void
impl_settings_add_connection_add_cb (NMSettings *self, settings_add_connection_add_cb (NMSettings *self,
NMSettingsConnection *connection, NMSettingsConnection *connection,
GError *error, GError *error,
GDBusMethodInvocation *context, GDBusMethodInvocation *context,
NMAuthSubject *subject, NMAuthSubject *subject,
gpointer user_data) gpointer user_data)
{ {
if (error) { if (error) {
g_dbus_method_invocation_return_gerror (context, error); g_dbus_method_invocation_return_gerror (context, error);
@@ -1332,10 +1358,10 @@ impl_settings_add_connection_add_cb (NMSettings *self,
} }
static void static void
impl_settings_add_connection_helper (NMSettings *self, settings_add_connection_helper (NMSettings *self,
GDBusMethodInvocation *context, GDBusMethodInvocation *context,
GVariant *settings, GVariant *settings,
gboolean save_to_disk) gboolean save_to_disk)
{ {
gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *connection = NULL;
GError *error = NULL; GError *error = NULL;
@@ -1355,77 +1381,111 @@ impl_settings_add_connection_helper (NMSettings *self,
connection, connection,
save_to_disk, save_to_disk,
context, context,
impl_settings_add_connection_add_cb, settings_add_connection_add_cb,
NULL); NULL);
} }
static void static void
impl_settings_add_connection (NMSettings *self, impl_settings_add_connection (NMDBusObject *obj,
GDBusMethodInvocation *context, const NMDBusInterfaceInfoExtended *interface_info,
GVariant *settings) const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
impl_settings_add_connection_helper (self, context, settings, TRUE); NMSettings *self = NM_SETTINGS (obj);
gs_unref_variant GVariant *settings = NULL;
g_variant_get (parameters, "(@a{sa{sv}})", &settings);
settings_add_connection_helper (self, invocation, settings, TRUE);
} }
static void static void
impl_settings_add_connection_unsaved (NMSettings *self, impl_settings_add_connection_unsaved (NMDBusObject *obj,
GDBusMethodInvocation *context, const NMDBusInterfaceInfoExtended *interface_info,
GVariant *settings) const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
impl_settings_add_connection_helper (self, context, settings, FALSE); NMSettings *self = NM_SETTINGS (obj);
gs_unref_variant GVariant *settings = NULL;
g_variant_get (parameters, "(@a{sa{sv}})", &settings);
settings_add_connection_helper (self, invocation, settings, FALSE);
} }
static void static void
impl_settings_load_connections (NMSettings *self, impl_settings_load_connections (NMDBusObject *obj,
GDBusMethodInvocation *context, const NMDBusInterfaceInfoExtended *interface_info,
char **filenames) const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
NMSettings *self = NM_SETTINGS (obj);
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
GPtrArray *failures; gs_unref_ptrarray GPtrArray *failures = NULL;
GSList *iter; GSList *iter;
int i; guint i;
gs_free const char **filenames = NULL;
g_variant_get (parameters, "(^a&s)", &filenames);
/* The permission is already enforced by the D-Bus daemon, but we ensure /* The permission is already enforced by the D-Bus daemon, but we ensure
* that the caller is still alive so that clients are forced to wait and * that the caller is still alive so that clients are forced to wait and
* we'll be able to switch to polkit without breaking behavior. * we'll be able to switch to polkit without breaking behavior.
*/ */
if (!nm_bus_manager_ensure_uid (nm_bus_manager_get (), if (!nm_dbus_manager_ensure_uid (nm_dbus_object_get_manager (obj),
context, invocation,
G_MAXULONG, G_MAXULONG,
NM_SETTINGS_ERROR, NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_PERMISSION_DENIED)) NM_SETTINGS_ERROR_PERMISSION_DENIED))
return; return;
failures = g_ptr_array_new (); if (filenames) {
for (i = 0; filenames[i]; i++) {
for (iter = priv->plugins; iter; iter = g_slist_next (iter)) {
NMSettingsPlugin *plugin = NM_SETTINGS_PLUGIN (iter->data);
for (i = 0; filenames[i]; i++) { if (nm_settings_plugin_load_connection (plugin, filenames[i]))
for (iter = priv->plugins; iter; iter = g_slist_next (iter)) { break;
NMSettingsPlugin *plugin = NM_SETTINGS_PLUGIN (iter->data); }
if (nm_settings_plugin_load_connection (plugin, filenames[i])) if (!iter) {
break; if (!g_path_is_absolute (filenames[i]))
} _LOGW ("connection filename '%s' is not an absolute path", filenames[i]);
if (!failures)
if (!iter) { failures = g_ptr_array_new ();
if (!g_path_is_absolute (filenames[i])) g_ptr_array_add (failures, (char *) filenames[i]);
_LOGW ("connection filename '%s' is not an absolute path", filenames[i]); }
g_ptr_array_add (failures, (char *) filenames[i]);
} }
} }
g_ptr_array_add (failures, NULL); if (failures)
g_dbus_method_invocation_return_value ( g_ptr_array_add (failures, NULL);
context,
g_variant_new ("(b^as)", g_dbus_method_invocation_return_value (invocation,
failures->len == 1, g_variant_new ("(b^as)",
failures->pdata)); (gboolean) (!!failures),
g_ptr_array_unref (failures); failures
? (const char **) failures->pdata
: NM_PTRARRAY_EMPTY (const char *)));
} }
static void static void
impl_settings_reload_connections (NMSettings *self, impl_settings_reload_connections (NMDBusObject *obj,
GDBusMethodInvocation *context) const NMDBusInterfaceInfoExtended *interface_info,
const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
NMSettings *self = NM_SETTINGS (obj);
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
GSList *iter; GSList *iter;
@@ -1433,11 +1493,11 @@ impl_settings_reload_connections (NMSettings *self,
* that the caller is still alive so that clients are forced to wait and * that the caller is still alive so that clients are forced to wait and
* we'll be able to switch to polkit without breaking behavior. * we'll be able to switch to polkit without breaking behavior.
*/ */
if (!nm_bus_manager_ensure_uid (nm_bus_manager_get (), if (!nm_dbus_manager_ensure_uid (nm_dbus_object_get_manager (obj),
context, invocation,
G_MAXULONG, G_MAXULONG,
NM_SETTINGS_ERROR, NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_PERMISSION_DENIED)) NM_SETTINGS_ERROR_PERMISSION_DENIED))
return; return;
for (iter = priv->plugins; iter; iter = g_slist_next (iter)) { for (iter = priv->plugins; iter; iter = g_slist_next (iter)) {
@@ -1446,7 +1506,7 @@ impl_settings_reload_connections (NMSettings *self,
nm_settings_plugin_reload_connections (plugin); nm_settings_plugin_reload_connections (plugin);
} }
g_dbus_method_invocation_return_value (context, g_variant_new ("(b)", TRUE)); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", TRUE));
} }
/*****************************************************************************/ /*****************************************************************************/
@@ -1498,37 +1558,42 @@ pk_hostname_cb (NMAuthChain *chain,
} }
static void static void
impl_settings_save_hostname (NMSettings *self, impl_settings_save_hostname (NMDBusObject *obj,
GDBusMethodInvocation *context, const NMDBusInterfaceInfoExtended *interface_info,
const char *hostname) const NMDBusMethodInfoExtended *method_info,
GDBusConnection *connection,
const char *sender,
GDBusMethodInvocation *invocation,
GVariant *parameters)
{ {
NMSettings *self = NM_SETTINGS (obj);
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
NMAuthChain *chain; NMAuthChain *chain;
GError *error = NULL; const char *hostname;
g_variant_get (parameters, "(&s)", &hostname);
/* Minimal validation of the hostname */ /* Minimal validation of the hostname */
if (!nm_hostname_manager_validate_hostname (hostname)) { if (!nm_hostname_manager_validate_hostname (hostname)) {
error = g_error_new_literal (NM_SETTINGS_ERROR, g_dbus_method_invocation_return_error_literal (invocation,
NM_SETTINGS_ERROR_INVALID_HOSTNAME, NM_SETTINGS_ERROR,
"The hostname was too long or contained invalid characters."); NM_SETTINGS_ERROR_INVALID_HOSTNAME,
goto done; "The hostname was too long or contained invalid characters.");
return;
} }
chain = nm_auth_chain_new_context (context, pk_hostname_cb, self); chain = nm_auth_chain_new_context (invocation, pk_hostname_cb, self);
if (!chain) { if (!chain) {
error = g_error_new_literal (NM_SETTINGS_ERROR, g_dbus_method_invocation_return_error_literal (invocation,
NM_SETTINGS_ERROR_PERMISSION_DENIED, NM_SETTINGS_ERROR,
"Unable to authenticate the request."); NM_SETTINGS_ERROR_PERMISSION_DENIED,
goto done; "Unable to authenticate the request.");
return;
} }
priv->auths = g_slist_append (priv->auths, chain); priv->auths = g_slist_append (priv->auths, chain);
nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_SETTINGS_MODIFY_HOSTNAME, TRUE); nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_SETTINGS_MODIFY_HOSTNAME, TRUE);
nm_auth_chain_set_data (chain, "hostname", g_strdup (hostname), g_free); nm_auth_chain_set_data (chain, "hostname", g_strdup (hostname), g_free);
done:
if (error)
g_dbus_method_invocation_take_error (context, error);
} }
/*****************************************************************************/ /*****************************************************************************/
@@ -1900,13 +1965,123 @@ finalize (GObject *object)
G_OBJECT_CLASS (nm_settings_parent_class)->finalize (object); G_OBJECT_CLASS (nm_settings_parent_class)->finalize (object);
} }
static const GDBusSignalInfo signal_info_new_connection = NM_DEFINE_GDBUS_SIGNAL_INFO_INIT (
"NewConnection",
.args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("connection", "o"),
),
);
static const GDBusSignalInfo signal_info_connection_removed = NM_DEFINE_GDBUS_SIGNAL_INFO_INIT (
"ConnectionRemoved",
.args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("connection", "o"),
),
);
static const NMDBusInterfaceInfoExtended interface_info_settings = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_SETTINGS,
.methods = NM_DEFINE_GDBUS_METHOD_INFOS (
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"ListConnections",
.out_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("connections", "ao"),
),
),
.handle = impl_settings_list_connections,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"GetConnectionByUuid",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("uuid", "s"),
),
.out_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("connection", "o"),
),
),
.handle = impl_settings_get_connection_by_uuid,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"AddConnection",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("connection", "a{sa{sv}}"),
),
.out_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("path", "o"),
),
),
.handle = impl_settings_add_connection,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"AddConnectionUnsaved",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("connection", "a{sa{sv}}"),
),
.out_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("path", "o"),
),
),
.handle = impl_settings_add_connection_unsaved,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"LoadConnections",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("filenames", "as"),
),
.out_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("status", "b"),
NM_DEFINE_GDBUS_ARG_INFO ("failures", "as"),
),
),
.handle = impl_settings_load_connections,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"ReloadConnections",
.out_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("status", "b"),
),
),
.handle = impl_settings_reload_connections,
),
NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
NM_DEFINE_GDBUS_METHOD_INFO_INIT (
"SaveHostname",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("hostname", "s"),
),
),
.handle = impl_settings_save_hostname,
),
),
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
&signal_info_new_connection,
&signal_info_connection_removed,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Connections", "ao", NM_SETTINGS_CONNECTIONS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Hostname", "s", NM_SETTINGS_HOSTNAME),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("CanModify", "b", NM_SETTINGS_CAN_MODIFY),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_settings_class_init (NMSettingsClass *class) nm_settings_class_init (NMSettingsClass *class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (class); GObjectClass *object_class = G_OBJECT_CLASS (class);
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (class);
exported_object_class->export_path = NM_DBUS_PATH_SETTINGS; dbus_object_class->export_path = NM_DBUS_PATH_SETTINGS;
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_settings);
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->dispose = dispose; object_class->dispose = dispose;
@@ -1975,23 +2150,4 @@ nm_settings_class_init (NMSettingsClass *class)
0, NULL, NULL, 0, NULL, NULL,
g_cclosure_marshal_VOID__OBJECT, g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, NM_TYPE_SETTINGS_CONNECTION); G_TYPE_NONE, 1, NM_TYPE_SETTINGS_CONNECTION);
signals[NEW_CONNECTION] =
g_signal_new ("new-connection",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST, 0, NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, NM_TYPE_SETTINGS_CONNECTION);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (class),
NMDBUS_TYPE_SETTINGS_SKELETON,
"ListConnections", impl_settings_list_connections,
"GetConnectionByUuid", impl_settings_get_connection_by_uuid,
"AddConnection", impl_settings_add_connection,
"AddConnectionUnsaved", impl_settings_add_connection_unsaved,
"LoadConnections", impl_settings_load_connections,
"ReloadConnections", impl_settings_reload_connections,
"SaveHostname", impl_settings_save_hostname,
NULL);
} }

View File

@@ -28,8 +28,6 @@
#include "nm-connection.h" #include "nm-connection.h"
#include "nm-exported-object.h"
#define NM_TYPE_SETTINGS (nm_settings_get_type ()) #define NM_TYPE_SETTINGS (nm_settings_get_type ())
#define NM_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS, NMSettings)) #define NM_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS, NMSettings))
#define NM_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTINGS, NMSettingsClass)) #define NM_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTINGS, NMSettingsClass))

View File

@@ -51,7 +51,7 @@ libnm_settings_plugin_ifcfg_rh = shared_module(
sources: sources, sources: sources,
dependencies: deps, dependencies: deps,
c_args: cflags, c_args: cflags,
link_with: [libnmdbus_ifcfg_rh, libnms_ifcfg_rh_core], link_with: [libnms_ifcfg_rh_core],
link_args: ldflags_linker_script_settings, link_args: ldflags_linker_script_settings,
link_depends: linker_script_settings, link_depends: linker_script_settings,
install: true, install: true,

View File

@@ -37,7 +37,6 @@
#include "settings/nm-settings-plugin.h" #include "settings/nm-settings-plugin.h"
#include "nm-config.h" #include "nm-config.h"
#include "NetworkManagerUtils.h" #include "NetworkManagerUtils.h"
#include "nm-exported-object.h"
#include "nms-ifcfg-rh-connection.h" #include "nms-ifcfg-rh-connection.h"
#include "nms-ifcfg-rh-common.h" #include "nms-ifcfg-rh-common.h"
@@ -807,18 +806,18 @@ _method_call (GDBusConnection *connection,
SettingsPluginIfcfg *self = SETTINGS_PLUGIN_IFCFG (user_data); SettingsPluginIfcfg *self = SETTINGS_PLUGIN_IFCFG (user_data);
const char *ifcfg; const char *ifcfg;
if (nm_streq0 (interface_name, IFCFGRH1_IFACE1_NAME)) { if ( !nm_streq (interface_name, IFCFGRH1_IFACE1_NAME)
if (nm_streq0 (method_name, IFCFGRH1_IFACE1_METHOD_GET_IFCFG_DETAILS)) { || !nm_streq (method_name, IFCFGRH1_IFACE1_METHOD_GET_IFCFG_DETAILS)) {
if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(s)"))) g_dbus_method_invocation_return_error (invocation,
g_return_if_reached (); G_DBUS_ERROR,
G_DBUS_ERROR_UNKNOWN_METHOD,
g_variant_get (parameters, "(&s)", &ifcfg); "Unknown method %s",
impl_ifcfgrh_get_ifcfg_details (self, invocation, ifcfg); method_name);
return; return;
}
} }
g_return_if_reached (); g_variant_get (parameters, "(&s)", &ifcfg);
impl_ifcfgrh_get_ifcfg_details (self, invocation, ifcfg);
} }
static GDBusInterfaceInfo *const interface_info = NM_DEFINE_GDBUS_INTERFACE_INFO ( static GDBusInterfaceInfo *const interface_info = NM_DEFINE_GDBUS_INTERFACE_INFO (

View File

@@ -1037,13 +1037,6 @@ main (int argc, char **argv)
{ {
nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT");
/* Initialize the DBus manager singleton explicitly, because it is accessed by
* the class initializer of NMDevice (used by the NMTestDevice stub).
* This way, we skip calling nm_bus_manager_init_bus() which would
* either fail and/or cause unexpected actions in the test.
* */
nm_bus_manager_setup (g_object_new (NM_TYPE_BUS_MANAGER, NULL));
nm_fake_platform_setup (); nm_fake_platform_setup ();
g_test_add_func ("/config/simple", test_config_simple); g_test_add_func ("/config/simple", test_config_simple);

View File

@@ -51,8 +51,6 @@
#include "nm-vpn-manager.h" #include "nm-vpn-manager.h"
#include "dns/nm-dns-manager.h" #include "dns/nm-dns-manager.h"
#include "introspection/org.freedesktop.NetworkManager.VPN.Connection.h"
typedef enum { typedef enum {
/* Only system secrets */ /* Only system secrets */
SECRETS_REQ_SYSTEM = 0, SECRETS_REQ_SYSTEM = 0,
@@ -82,7 +80,6 @@ typedef enum {
} VpnState; } VpnState;
enum { enum {
VPN_STATE_CHANGED,
INTERNAL_STATE_CHANGED, INTERNAL_STATE_CHANGED,
INTERNAL_RETRY_AFTER_FAILURE, INTERNAL_RETRY_AFTER_FAILURE,
@@ -159,19 +156,6 @@ struct _NMVpnConnection {
struct _NMVpnConnectionClass { struct _NMVpnConnectionClass {
NMActiveConnectionClass parent; NMActiveConnectionClass parent;
/* Signals */
void (*vpn_state_changed) (NMVpnConnection *self,
NMVpnConnectionState new_state,
NMActiveConnectionStateReason reason);
/* not exported over D-Bus */
void (*internal_state_changed) (NMVpnConnection *self,
NMVpnConnectionState new_state,
NMVpnConnectionState old_state,
NMActiveConnectionStateReason reason);
void (*internal_failed_retry) (NMVpnConnection *self);
}; };
G_DEFINE_TYPE (NMVpnConnection, nm_vpn_connection, NM_TYPE_ACTIVE_CONNECTION) G_DEFINE_TYPE (NMVpnConnection, nm_vpn_connection, NM_TYPE_ACTIVE_CONNECTION)
@@ -180,6 +164,9 @@ G_DEFINE_TYPE (NMVpnConnection, nm_vpn_connection, NM_TYPE_ACTIVE_CONNECTION)
/*****************************************************************************/ /*****************************************************************************/
static const NMDBusInterfaceInfoExtended interface_info_vpn_connection;
static const GDBusSignalInfo signal_info_vpn_state_changed;
static NMSettingsConnection *_get_settings_connection (NMVpnConnection *self, static NMSettingsConnection *_get_settings_connection (NMVpnConnection *self,
gboolean allow_missing); gboolean allow_missing);
@@ -511,7 +498,12 @@ _set_vpn_state (NMVpnConnection *self,
old_external_state = _state_to_nm_vpn_state (old_vpn_state); old_external_state = _state_to_nm_vpn_state (old_vpn_state);
new_external_state = _state_to_nm_vpn_state (priv->vpn_state); new_external_state = _state_to_nm_vpn_state (priv->vpn_state);
if (new_external_state != old_external_state) { if (new_external_state != old_external_state) {
g_signal_emit (self, signals[VPN_STATE_CHANGED], 0, new_external_state, reason); nm_dbus_object_emit_signal (NM_DBUS_OBJECT (self),
&interface_info_vpn_connection,
&signal_info_vpn_state_changed,
"(uu)",
(guint32) new_external_state,
(guint32) reason);
g_signal_emit (self, signals[INTERNAL_STATE_CHANGED], 0, g_signal_emit (self, signals[INTERNAL_STATE_CHANGED], 0,
new_external_state, new_external_state,
old_external_state, old_external_state,
@@ -1176,8 +1168,8 @@ _cleanup_failed_config (NMVpnConnection *self)
{ {
NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self);
nm_exported_object_clear_and_unexport (&priv->ip4_config); nm_dbus_object_clear_and_unexport (&priv->ip4_config);
nm_exported_object_clear_and_unexport (&priv->ip6_config); nm_dbus_object_clear_and_unexport (&priv->ip6_config);
_LOGW ("VPN connection: did not receive valid IP config information"); _LOGW ("VPN connection: did not receive valid IP config information");
_set_vpn_state (self, STATE_FAILED, NM_ACTIVE_CONNECTION_STATE_REASON_IP_CONFIG_INVALID, FALSE); _set_vpn_state (self, STATE_FAILED, NM_ACTIVE_CONNECTION_STATE_REASON_IP_CONFIG_INVALID, FALSE);
@@ -1394,12 +1386,12 @@ nm_vpn_connection_config_get (NMVpnConnection *self, GVariant *dict)
priv->has_ip4 = FALSE; priv->has_ip4 = FALSE;
if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_HAS_IP4, "b", &b)) if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_HAS_IP4, "b", &b))
priv->has_ip4 = b; priv->has_ip4 = b;
nm_exported_object_clear_and_unexport (&priv->ip4_config); nm_dbus_object_clear_and_unexport (&priv->ip4_config);
priv->has_ip6 = FALSE; priv->has_ip6 = FALSE;
if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_HAS_IP6, "b", &b)) if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_HAS_IP6, "b", &b))
priv->has_ip6 = b; priv->has_ip6 = b;
nm_exported_object_clear_and_unexport (&priv->ip6_config); nm_dbus_object_clear_and_unexport (&priv->ip6_config);
nm_vpn_connection_config_maybe_complete (self, TRUE); nm_vpn_connection_config_maybe_complete (self, TRUE);
} }
@@ -1653,7 +1645,7 @@ nm_vpn_connection_ip4_config_get (NMVpnConnection *self, GVariant *dict)
g_object_unref (config); g_object_unref (config);
} else { } else {
priv->ip4_config = config; priv->ip4_config = config;
nm_exported_object_export (NM_EXPORTED_OBJECT (config)); nm_dbus_object_export (NM_DBUS_OBJECT (config));
g_object_notify ((GObject *) self, NM_ACTIVE_CONNECTION_IP4_CONFIG); g_object_notify ((GObject *) self, NM_ACTIVE_CONNECTION_IP4_CONFIG);
} }
@@ -1842,7 +1834,7 @@ next:
g_object_unref (config); g_object_unref (config);
} else { } else {
priv->ip6_config = config; priv->ip6_config = config;
nm_exported_object_export (NM_EXPORTED_OBJECT (config)); nm_dbus_object_export (NM_DBUS_OBJECT (config));
g_object_notify ((GObject *) self, NM_ACTIVE_CONNECTION_IP6_CONFIG); g_object_notify ((GObject *) self, NM_ACTIVE_CONNECTION_IP6_CONFIG);
} }
@@ -2329,7 +2321,7 @@ nm_vpn_connection_activate (NMVpnConnection *self,
if (nm_vpn_plugin_info_supports_multiple (plugin_info)) { if (nm_vpn_plugin_info_supports_multiple (plugin_info)) {
const char *path; const char *path;
path = nm_exported_object_get_path (NM_EXPORTED_OBJECT (self)); path = nm_dbus_object_get_path (NM_DBUS_OBJECT (self));
if (path) if (path)
path = strrchr (path, '/'); path = strrchr (path, '/');
g_return_if_fail (path); g_return_if_fail (path);
@@ -2779,8 +2771,8 @@ dispose (GObject *object)
nm_clear_g_cancellable (&priv->cancellable); nm_clear_g_cancellable (&priv->cancellable);
g_clear_object (&priv->proxy_config); g_clear_object (&priv->proxy_config);
nm_exported_object_clear_and_unexport (&priv->ip4_config); nm_dbus_object_clear_and_unexport (&priv->ip4_config);
nm_exported_object_clear_and_unexport (&priv->ip6_config); nm_dbus_object_clear_and_unexport (&priv->ip6_config);
g_clear_object (&priv->proxy); g_clear_object (&priv->proxy);
g_clear_object (&priv->plugin_info); g_clear_object (&priv->plugin_info);
@@ -2830,14 +2822,14 @@ get_property (GObject *object, guint prop_id,
g_value_set_string (value, priv->banner ? priv->banner : ""); g_value_set_string (value, priv->banner ? priv->banner : "");
break; break;
case PROP_IP4_CONFIG: case PROP_IP4_CONFIG:
nm_utils_g_value_set_object_path (value, ip_config_valid (priv->vpn_state) ? priv->ip4_config : NULL); nm_dbus_utils_g_value_set_object_path (value, ip_config_valid (priv->vpn_state) ? priv->ip4_config : NULL);
break; break;
case PROP_IP6_CONFIG: case PROP_IP6_CONFIG:
nm_utils_g_value_set_object_path (value, ip_config_valid (priv->vpn_state) ? priv->ip6_config : NULL); nm_dbus_utils_g_value_set_object_path (value, ip_config_valid (priv->vpn_state) ? priv->ip6_config : NULL);
break; break;
case PROP_MASTER: case PROP_MASTER:
parent_dev = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (object)); parent_dev = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (object));
nm_utils_g_value_set_object_path (value, parent_dev); nm_dbus_utils_g_value_set_object_path (value, parent_dev);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -2845,16 +2837,42 @@ get_property (GObject *object, guint prop_id,
} }
} }
static const GDBusSignalInfo signal_info_vpn_state_changed = NM_DEFINE_GDBUS_SIGNAL_INFO_INIT (
"VpnStateChanged",
.args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("state", "u"),
NM_DEFINE_GDBUS_ARG_INFO ("reason", "u"),
),
);
static const NMDBusInterfaceInfoExtended interface_info_vpn_connection = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_VPN_CONNECTION,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
&signal_info_vpn_state_changed,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("VpnState", "u", NM_VPN_CONNECTION_VPN_STATE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Banner", "s", NM_VPN_CONNECTION_BANNER),
),
),
.legacy_property_changed = TRUE,
};
static void static void
nm_vpn_connection_class_init (NMVpnConnectionClass *connection_class) nm_vpn_connection_class_init (NMVpnConnectionClass *connection_class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (connection_class); GObjectClass *object_class = G_OBJECT_CLASS (connection_class);
NMActiveConnectionClass *active_class = NM_ACTIVE_CONNECTION_CLASS (connection_class); NMActiveConnectionClass *active_class = NM_ACTIVE_CONNECTION_CLASS (connection_class);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (connection_class);
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_vpn_connection);
/* virtual methods */
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->dispose = dispose; object_class->dispose = dispose;
object_class->finalize = finalize; object_class->finalize = finalize;
active_class->device_state_changed = device_state_changed; active_class->device_state_changed = device_state_changed;
active_class->device_changed = device_changed; active_class->device_changed = device_changed;
@@ -2881,13 +2899,6 @@ nm_vpn_connection_class_init (NMVpnConnectionClass *connection_class)
g_object_class_override_property (object_class, PROP_IP6_CONFIG, g_object_class_override_property (object_class, PROP_IP6_CONFIG,
NM_ACTIVE_CONNECTION_IP6_CONFIG); NM_ACTIVE_CONNECTION_IP6_CONFIG);
signals[VPN_STATE_CHANGED] =
g_signal_new ("vpn-state-changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
signals[INTERNAL_STATE_CHANGED] = signals[INTERNAL_STATE_CHANGED] =
g_signal_new (NM_VPN_CONNECTION_INTERNAL_STATE_CHANGED, g_signal_new (NM_VPN_CONNECTION_INTERNAL_STATE_CHANGED,
G_OBJECT_CLASS_TYPE (object_class), G_OBJECT_CLASS_TYPE (object_class),
@@ -2901,8 +2912,4 @@ nm_vpn_connection_class_init (NMVpnConnectionClass *connection_class)
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
0, NULL, NULL, NULL, 0, NULL, NULL, NULL,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (connection_class),
NMDBUS_TYPE_VPN_CONNECTION_SKELETON,
NULL);
} }

View File

@@ -42,7 +42,6 @@
#define NM_VPN_CONNECTION_BANNER "banner" #define NM_VPN_CONNECTION_BANNER "banner"
/* Signals */ /* Signals */
/* not exported: includes old reason code */
#define NM_VPN_CONNECTION_INTERNAL_STATE_CHANGED "internal-state-changed" #define NM_VPN_CONNECTION_INTERNAL_STATE_CHANGED "internal-state-changed"
#define NM_VPN_CONNECTION_INTERNAL_RETRY_AFTER_FAILURE "internal-retry-after-failure" #define NM_VPN_CONNECTION_INTERNAL_RETRY_AFTER_FAILURE "internal-retry-after-failure"