Commit graph

80 commits

Author SHA1 Message Date
Dan Winship 5afcee4693 libnm-glib: simplify property getter methods
Rather than having every property getter method have code to fetch
that specific property's value, just call the new
_nm_object_ensure_inited() (which makes sure that we've read all the
property values on the object at least once), and then return the
cached value. (After we've read the initial property values, the
PropertiesChanged signal handler will ensure that the values are kept
up to date, so we can always just return cached property values after
that point.)

This then lets us get rid of _nm_object_get_property() and its
wrappers.
2012-02-03 10:33:43 -06:00
Dan Winship 2e48cc092c libnm-glib: simplify and genericize property declaration
Rename _nm_object_handle_properties_changed(), etc, to be about
properties in general, rather than just property changes.

Interpret func==NULL in NMPropertiesInfo as meaning "use
_nm_object_demarshal_generic", and then reorder the fields so that you
can just leave that field out in the declarations when it's NULL.

Add a way to register properties that exist in D-Bus but aren't
tracked by the NMObjects, and use that for NMDevice's D-Bus Ip4Address
property, replacing the existing hack.

Also add a few other missing properties noticed along the way.
2012-02-03 10:33:43 -06:00
Dan Williams d8437ffaf1 core: fix deprecated usage of g_value_[get|set]_char() (bgo #662694) 2011-10-28 11:35:59 -05:00
Tomeu Vizoso 77e9cd53a8 libnm-glib: allow to constuct NMObject with NULL bus 2011-08-16 17:21:07 -05:00
Tomeu Vizoso dd175e3bf7 libnm-glib: warn early if an object is tried to be instantiated without a path 2011-08-16 17:20:49 -05:00
Dan Williams 8afce8590a libnm-glib: handle NULL object paths generically
Since D-Bus doesn't allow NULL or zero-length object paths, NM
uses "/" as a placeholder here.  Make sure the generic marshalling
code handles that so we don't have to do it in multiple places and
simplify handling of NULL objects somewhat.
2011-05-26 19:19:32 -05:00
Dan Williams df511f74f7 build: use -Wundef and fix up cases where stuff wasn't defined (bgo #647157) 2011-04-14 13:19:12 -05:00
Dan Williams c17721b360 libnm-glib: allow manual processing of properties changed events
Mostly for handling the GetAll response.
2011-02-16 15:04:39 -06:00
Jiří Klimeš d6905a8d66 libnm-glib: add GError parameter to _nm_object_get_... functions
It allows us to get the error back and have control over printing
the error.
2011-02-15 17:34:11 +01:00
Giovanni Campagna 3ebecd2a29 introspection: add GObject introspection support (bgo #637032)
Add the necessary annotations (the mininum required, that is those
on return values. NULL parameters or container types may require
more), and the Autotools stuff to get a NetworkManager GIR for
libnm-util and a NMClient for libnm-glib.
2011-01-21 14:46:09 -06:00
Jiří Klimeš 9f2b48ef08 libnm-glib: call D-Bus with a timeout when Set()ting properties
The caller needs to be authenticated, so wait a bit to be sure
it didn't quit too quickly.
2010-10-15 09:41:34 +02:00
Dan Williams 4eea398b06 libnm-glib: fix invalid memory access during property notification
If an NMObject listened to property change notifications from
other NMObjects and then in response to that queued up other
property changes of it's own, those would get added to the
property change list that was being iterated through already.
Each name in the change list is freed after being notified,
but the change list itself is actually freed when all
properties have been notified.  So an object that queues up
another change notification ends up in _nm_object_queue_notify()
which iterates the change list where half of the data elements
are already freed...
2010-06-30 11:51:40 -07:00
Dan Williams c9d2d977dd libnm-glib: tighter warning print checks
Should be checking for dbus-glib errors of the right type,
instead of any error code (dbus-glib or not) that happens to be
4.
2009-10-20 12:10:30 -07:00
Dan Williams 3d194df94a libnm-glib: warning cleanups 2009-10-20 11:48:23 -07:00
Dan Williams 7118676968 2008-11-14 Dan Williams <dcbw@redhat.com>
Relicense libnm-glib to LGPLv2+ with agreement from contributors



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4285 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-11-14 17:41:16 +00:00
Michael Biebl d7940bcb9b Rename private nm_* functions to _nm_*
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4012 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-08-26 09:34:31 +00:00
Tambet Ingo 0f534a9f8f 2008-08-12 Tambet Ingo <tambet@gmail.com>
Start documenting libnm-glib public API using gtk-doc.

	* libnm-glib/nm-serial-device.c:
	* libnm-glib/nm-object.c:
	* libnm-glib/nm-gsm-device.c:
	* libnm-glib/nm-device.c:
	* libnm-glib/nm-device-wifi.c:
	* libnm-glib/nm-device-ethernet.c:
	* libnm-glib/nm-client.c:
	* libnm-glib/nm-cdma-device.c: Document the public API.

	* docs/libnm-glib/libnm-glib.types: Implement.

	* docs/libnm-glib/Makefile.am: Implement.

	* autogen.sh:
	* configure.in:
	* Makefile.am: Add gtk-doc support.


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3932 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-08-12 08:05:21 +00:00
Dan Williams 291019fb79 Quiet warning about unhandled property for now
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3867 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-07-28 14:04:31 +00:00
Dan Williams c01b4c9e2e 2008-03-27 Dan Williams <dcbw@redhat.com>
* nm-object.c
		- (nm_object_queue_notify): don't notify multiple times for the same
			property

	* nm-object-private.h
		- (handle_ptr_array_return): return NULL if the given array is NULL or
			if it has zero elements

	* nm-ip4-config.c
		- (finalize): use g_ptr_array_foreach() when freeing domains
		- (nm_ip4_config_get_domains): use handle_ptr_array_return()

	* nm-active-connection.c
		- (nm_active_connection_get_devices): use handle_ptr_array_return()

	* nm-device-802-11-wireless.c
	  nm-device-802-11-wireless.h
		- (nm_device_802_11_wireless_get_access_points): return const; use
			handle_ptr_array_return()

	* nm-types.c
		- (nm_object_array_demarshal): always create an array, even of length
			zero, to distinguish between "NM returned no items" and "haven't
			asked NM yet"

	* nm-client.c
		- (dispose): free active connections too
		- (proxy_name_owner_changed): free active connections too when NM goes
			away
		- (nm_client_get_devices): return const; use handle_ptr_array_return()
		- (nm_client_get_active_connections): use handle_ptr_array_return()



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3506 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-27 14:10:43 +00:00
Dan Williams 9a163be59a 2008-03-25 Dan Williams <dcbw@redhat.com>
* libnm-glib/nm-object.c
	  libnm-glib/nm-object-private.h
		- (nm_object_queue_notify): add helper to batch & postpone GObject notify
			signals to an idle handler
		- (nm_object_get_property): add a timeout to the D-Bus method call



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3501 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-25 11:34:33 +00:00
Dan Williams 007351657f 2008-03-24 Dan Williams <dcbw@redhat.com>
Massive fixup of libnm-glib to:
	a) have all objects (with the exception of VPN) cache their properties and
		update them asynchronously on PropertiesChanged signals from NM
	b) return internal const data for most attributes/properties instead of
		allocated values that the caller must free
	c) cache wrapped objects such that a given D-Bus path will always map to the
		same GObject returned by libnm-glib
	d) remove a few signals and move them to GObject property notifications
	e) match recent NM D-Bus API changes for activation/deactivation
	f) remove some private functions from libnm-glib headers



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3491 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-24 15:17:30 +00:00
Dan Williams eda2d662cd 2007-12-07 Dan Williams <dcbw@redhat.com>
Noticed by Christian Persch <chpe@gnome.org>

	Always chain up to parent object in dispose and finalize handlers.
		(gnome.org #433112)



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3154 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-12-07 15:32:45 +00:00
Dan Williams 6076621fd0 2007-11-26 Dan Williams <dcbw@redhat.com>
* Fix warnings so everything compiles with --enable-more-warnings



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3108 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-11-26 16:59:47 +00:00
Dan Williams 89e6709b20 More descriptive error message
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3052 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-10-29 15:32:35 +00:00
Tambet Ingo 86306041af 2007-10-12 Tambet Ingo <tambet@gmail.com>
Rework the "properties-changed" signal listening implementation.
        Add a generic implementation to NMObject class that listens for
        the signal and calls property setters of the target NMObject.

        * libnm-glib/nm-object.c (nm_object_handle_properties_changed):
        * Implement.

        * libnm-glib/nm-device-802-11-wireless.c: Move the GObject
        * consturction
        code to the end of file so that all the static functions are
available
        without extra declarations.
        Remove the "properties-changed" signal handling and use the
framework from
        NMObject.
        Implement property setters for properties that change with 
        "properties-changed" signal.

        * libnm-glib/nm-access-point.c: Ditto.



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2972 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-10-12 10:18:46 +00:00
Dan Williams c5d0e07d00 2007-09-06 Dan Williams <dcbw@redhat.com>
* libnm-glib/nm-object.c
		- (nm_object_get_string_property, nm_object_get_object_path_property,
		   nm_object_get_int_property, nm_object_get_uint_property,
		   nm_object_get_boolean_property, nm_object_get_byte_property,
		   nm_object_get_double_property, nm_object_get_byte_array_property):
			clear GValues after copying their contents, fixes memory leaks
			after every property access because dbus-glib copies the values
			from the DBusMessage into the GValue already.



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2767 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-09-06 19:17:44 +00:00
Dan Williams a6346fac4a Fix some warnings and other errors
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2755 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-08-30 21:54:56 +00:00
Tambet Ingo 6a68d79c08 2007-08-09 Tambet Ingo <tambet@gmail.com>
[Based on patch by Helmut Schaa <hschaa@suse.de>]

        * libnm-glib/nm-client.h:
        * libnm-glib/nm-object.h:
        * libnm-glib/nm-vpn-connection.h:
        * libnm-glib/nm-settings.h:
        * libnm-glib/nm-device.h:
        * libnm-glib/nm-ip4-config.h:
        * libnm-glib/nm-access-point.h:
        * libnm-glib/nm-device-802-3-ethernet.h:
        * libnm-util/nm-setting.h: 
        * libnm-util/nm-connection.h: Add G_BEGIN_DECLS / G_END_DECLS to
        * support C++.

        * libnm-glib/nm-object.c (nm_object_get_byte_property):
        * Implement.

        * libnm-glib/nm-access-point.c: Strength has type char.

        * gnome/vpn-properties/Makefile.am: Remove
        * GNOME_DISABLE_DEPRECTATED for now
        to fix build. GnomeDruid is deprecated in recent libgnomeui.

        * introspection/nm-access-point.xml: Strength property is char,
        * not int.

        * src/NetworkManagerAP.c (set_property): Set strength from char.
        (get_property): Handle hidden APs (with empty SSID).
        Get strength value from char.
        (nm_ap_class_init): Strength property has char type.



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2659 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-08-09 09:19:57 +00:00
Dan Williams f4540f0412 2007-06-27 Dan Williams <dcbw@redhat.com>
* Make SSIDs GByteArrays everywhere
	* Rename "essid" -> "ssid" everywhere that's appropriate
	* Refcount activation_ap member of the 802.11 wireless device class



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2620 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-06-27 16:18:52 +00:00
Tambet Ingo 8c33f85a90 2007-06-27 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-object.[ch]: Add these to the SVN, oops.



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2619 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-06-27 14:02:16 +00:00