Commit Graph

12 Commits

Author SHA1 Message Date
Thomas Haller
6a42e18d53 exported-object: refactor list of interfaces from GSList to an array
NMExportedObject is the center of every D-Bus exported object in
NetworkManager's core. It makes sense to optimize it.

Transform the GSList of interfaces to be a array. The array is still
allocated via the slice allocator (as we expect that there are only few
types in the list). This saves the overhead to allocate a GSList item
for each entry.

Another advantage is that the interfaces list is now strongly typed
instead of an opaque data pointer.
2016-04-01 08:58:18 +02:00
Dan Williams
b023d0754b exported-object: add support for DBus ObjectManager interface
NMExportedObject now derives from GDBusObjectSkeleton, which is what
GDBusObjectManagerServer wants.  The main GDBusConnection and each
private server connection now gets a new GDBusObjectManagerServer,
and exported objects are registered with that instead of individually
exporting each GDBusInterfaceSkeleton.

Previously exported objects were not referenced by the BusManager,
but instead removed from the exports hash via weak references.  The
GDBusObjectManagerServer instead references exported objects, which
can make them live much longer than they did before.

Co-Authored-By: Thomas Haller <thaller@redhat.com>
2015-11-18 15:15:05 +01:00
Thomas Haller
57128494e0 exported-object: split out the creation of interface skeletons
Will be reused for ifcfg-rh plugin, which also has a skeleton,
but will not implement NMExportedObject.
2015-11-10 18:12:12 +01:00
Dan Williams
f9ee20a7b2 core: explicitly unexport objects when we're done with them
Previously most objects were implicitly unexported when they were
destroyed, but since refcounts may make the object live longer than
intended, we should explicitly unexport them when they should no
longer be present on the bus.

This means we can assume that objects will always be un-exported
already when they are destroyed, *except* when quitting where most
objects will live until exit because NM leaves interfaces up and
running on quit.
2015-11-10 18:12:12 +01:00
Thomas Haller
8a8ecc46ca core: fix wrongly exporting object before instance is fully constructed
Exporting the object already in the *_init() function will later
break because the object is not yet fully initialized at that point.

Add a convenient flag so that the NMExportedObject parent implementation
automatically can export itself. This saves the derived class from
overwriting the constructed() method.

Also add an assertion to catch such bugs.
2015-11-10 18:12:12 +01:00
Thomas Haller
a33fc00239 core: refactor setting of D-Bus properties via NMManager
- Also if the target object is the NMManager instance itself,
  re-fetch the manager via nm_bus_manager_get_registered_object().
  This way, we only set the property on the manager, if
  it's also exported according to the bus-manager. Also,
  we don't treat the manager instance special.

- Move fetching the object (nm_bus_manager_get_registered_object())
  from do_set_property_check() to prop_set_auth_done_cb(). Otherwise,
  we fetch the object first, but there is no guarantee that the object
  is still exported after the asynchronous authentication succeeds.
2015-09-16 16:36:46 +02:00
Thomas Haller
a55c87a2c0 core: refactor NMBusManager to hold reference to NMExportedObject directly
Previously, nm_bus_manager_register_object() would take various D-Bus
skeleton objects that were associated with one NMExportedObject.
This was confusing, in that these skeleton objects are all for the
same NMObject but correspond to different D-Bus interfaces.

Also, setting the D-Bus property "Managed" of a Device is broken
because we might retrieve the wrong skeleton.

Now, the NMBusManager has a reference to the exported object directly.
The skeleton interface instances instead are now exposed by the NMExportedObject.
2015-09-16 16:25:02 +02:00
Thomas Haller
30e6c71fad core: forward declare NMExportedObject in "nm-types.h" 2015-09-15 23:12:50 +02:00
Dan Winship
073991f5a8 core: port NMExportedObject to gdbus
Port NMExportedObject to gdbus, and make
nm_exported_object_class_add_interface() deal with generating D-Bus
skeleton objects and attaching signal handlers and property bindings
as needed to properly handle methods, signals, and properties.
2015-08-10 09:41:26 -04:00
Thomas Haller
19c3ea948a all: make use of new header file "nm-default.h" 2015-08-05 15:32:40 +02:00
Dan Winship
c1dd3b6eed core: move D-Bus export/unexport into NMExportedObject
Move D-Bus export/unexport handling into NMExportedObject and remove
type-specific export/get_path methods (export paths are now specified
at the class level, and NMExportedObject handles the counters for all
exported types automatically).

Since all exportable objects now use the same get_path() method, we
can also add some helper methods to simplify get_property()
implementations for object-path and object-path-array properties.
2015-07-24 13:25:47 -04:00
Dan Winship
6fcc1deee0 core: add an NMExportedObject base class
Add NMExportedObject, make it the base class of all D-Bus-exported
types, and move the nm-properties-changed-signal logic into it. (Also,
make NMSettings use the same properties-changed code as everything
else, which it was not previously doing, presumably for historical
reasons).

(This is mostly just shuffling code around at this point, but
NMExportedObject will be more important in the gdbus port, since
gdbus-codegen doesn't do a very good job of supporting objects that
export multiple interfaces [as each NMDevice subclass does, for
example], so we will need more glue/helper code in NMExportedObject
then.)
2015-07-24 13:25:47 -04:00