summaryrefslogtreecommitdiff
path: root/libnm/nm-object.c
Commit message (Collapse)AuthorAgeFilesLines
* all: use the elvis operator wherever possibleLubomir Rintel2018-05-101-1/+1
| | | | | | | | | | | | | | | | | | | | | Coccinelle: @@ expression a, b; @@ -a ? a : b +a ?: b Applied with: spatch --sp-file ternary.cocci --in-place --smpl-spacing --dir . With some manual adjustments on spots that Cocci didn't catch for reasons unknown. Thanks to the marvelous effort of the GNU compiler developer we can now spare a couple of bits that could be used for more important things, like this commit message. Standards commitees yet have to catch up.
* shared: drop duplicate c-list.h headerBeniamino Galvani2018-04-181-1/+1
| | | | Use the one from the project just imported.
* Add calls to g_simple_async_result_set_check_cancellableBenjamin Berg2018-03-081-0/+2
| | | | | | | | | | | | | | If an operation is cancelled through the GCancellable, then the idiom is that the operation is always cancelled, even if it has finished successfully. To ensure this is the case, add calls to g_simple_async_result_set_check_cancellable everywhere. Without this, e.g. gnome-control-center will crash when switching away from the power panel quickly, as the NMClient creation finishes asynchronously and g-c-c assume that G_IO_ERROR_CANCELLED is returned to ensure it doesn't access the now invalid user_data parameter. https://bugzilla.gnome.org/show_bug.cgi?id=794088
* trivial: avoid XXX tag and replace by NOTE or FIXMEThomas Haller2018-01-231-2/+3
| | | | | | | | XXX was used to either raise attention (NOTE) or to indicate that this is ugly code that should be fixed (FIXME). The usage was inconsistent. Let's avoid XXX and use either NOTE or FIXME.
* c-list: re-import latest version of c-list.h from upstreamThomas Haller2017-11-281-3/+3
| | | | | | | | | | | | Most notably, it renames c_list_unlink_init() -> c_list_unlink() c_list_unlink() -> c_list_unlink_stale() $ sed -e 's/\<c_list_unlink\>/c_list_unlink_old/g' \ -e 's/\<c_list_unlink_init\>/c_list_unlink/g' \ -e 's/\<c_list_unlink_old\>/c_list_unlink_stale/g' \ $(git grep -l c_list_unlink -- ':(exclude)shared/nm-utils/c-list.h') \ -i
* all: use nm_str_hash() instead of g_str_hash()Thomas Haller2017-11-161-1/+1
| | | | | | We also do this for libnm and libnm-core, where it causes visible changes in behavior. But if somebody would rely on the hashing implementation for hash tables, it would be seriously flawed.
* libnm: don't invert order in array propertiesBeniamino Galvani2017-11-091-1/+1
| | | | | | | The order of elements in array properties was inverted when reconstructing the array. Keep the original order from D-Bus. (cherry picked from commit c90118ff602114f6c86ff916bc036c8d917f93c4)
* libnm: remove property getter for NMObject's "dbus-object" and ↵Thomas Haller2017-06-191-8/+2
| | | | | | | | | | "dbus-object-manager" These properties are internal and shall not be publicly accessible. Remove the getter. We may later no longer use GDBusObjectManager. It should be an implementation detail, not exposed in the public API of NMObject.
* libnm: cleanup argument types for init_if() functionThomas Haller2017-05-271-3/+4
| | | | | | We use init_if() as handler for g_list_foreach(). Since we already cast the function pointer because it doesn't have (GFunc) signature, we can just as well use the correct types right away.
* libnm: fix type for "notify_id" source id in "nm-object.c"Thomas Haller2017-05-111-1/+1
|
* libnm: remove unused code reload_results and reload_error from "nm-object.c"Thomas Haller2017-05-111-24/+0
| | | | Fixes: 1f5b48a59eb46c40cb10bf4381b2b21a19a9f471
* libnm: use CList instead of GSList for pending in "nm-object.c"Thomas Haller2017-05-111-13/+18
|
* libnm: use CList instead of GSList for notify_items in "nm-object.c"Thomas Haller2017-05-111-16/+26
|
* fixup! libnm/active-connection: track reason for state changesLubomir Rintel2017-03-171-1/+6
|
* all/trivial: unify construct-only property commentsThomas Haller2017-03-081-2/+2
| | | | | | | Unify marking GObject properties that are G_PARAM_CONSTRUCT_ONLY with a comment /* construct-only */
* libnm: add assertion to NMObject that a dbus-object is setThomas Haller2017-03-081-0/+2
| | | | | | | | | The libnm cache types don't have public _new() functions. However, such types can be easily created using g_object_new() directly from user code. Such a usage is not supported. Add an assertion that a valid dbus-object is present.
* cli: support dummy connectionsBeniamino Galvani2017-02-221-1/+1
|
* libnm: disconnect signal from D-Bus proxies on disposeBeniamino Galvani2017-02-181-1/+15
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=778615
* all: use NM_CACHED_QUARK_FCN() instead of G_DEFINE_QUARK()Thomas Haller2017-02-101-1/+1
| | | | | | | | | | | | | | | | | | I think NM_CACHED_QUARK_FCN() is better because: - the implementation is in our hand, meaning it is clear that putting a "static" before NM_CACHED_QUARK_FCN() is guaranteed to work -- without relying on G_DEFINE_QUARK() to be defined in a way that this works (in fact, we currently never do that and instead make all functions non-static). - it does not construct function names by appending "_quark". Thus you can grep for the entire function name and finding the place where it is implemented. - same with the stings, where the new macro doesn't stringify the argument, which is less surpising. Again, now you can grep for the string including the double quoting. (yes, I really use grep to understand the source-code)
* libnm/object: lower the severity of the dangling object warningLubomir Rintel2017-01-191-1/+12
| | | | | | | The user can't do much about it and we can recover. This is a temporary measure to avoid unnecessarily bothering the user. (cherry picked from commit 7fec0755c9072dc37140a7b63b491ed02a3539cd)
* libnm: avoid leaking the interface proxiesLubomir Rintel2016-11-141-1/+5
| | | | | _nm_object_get_proxy()'s semantics changed with the object-manager branch merge: it now takes a reference.
* libnm/nm-object: gracefully skip unknown objectsLubomir Rintel2016-11-111-10/+7
| | | | | | | They indicate a server bug (a dangling path of an object that does not exist). The best we can do probably is to just ignore them and warn. Based-on-patch-by: Dan Williams <dcbw@redhat.com>
* libnm: use the o.fd.DBus.ObjectManager API for object managementlr/object-managerLubomir Rintel2016-11-101-715/+150
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This speeds up the initial object tree load significantly. Also, it reduces the object management complexity by shifting the duties to GDBusObjectManager. The lifetime of all NMObjects is now managed by the NMClient via the object manager. The NMClient creates the NMObjects for GDBus objects, triggers the initialization and serves as an object registry (replaces the nm-cache). The ObjectManager uses the o.fd.DBus.ObjectManager API to learn of the object creation, removal and property changes. It takes care of the property changes so that we don't have to and lets us always see a consistent object state. Thus at the time we learn of a new object we already know its properties. The NMObject unfortunately can't be made synchronously initializable as the NMRemoteConnection's settings are not managed with standard o.fd.DBus Properties and ObjectManager APIs and thus are not known to the ObjectManager. Thus most of the asynchronous object property changing code in nm-object.c is preserved. The objects notify the properties that reference them of their initialization in from their init_finish() methods, thus the asynchronously created objects are not allowed to fail creation (or the dependees would wait forever). Not a problem -- if a connection can't get its Settings, it's either invisible or being removed (presumably we'd learn of the removal from the object manager soon). The NMObjects can't be created by the object manager itself, since we can't determine the resulting object type in proxy_type() yet (we can't tell from the name and can't access the interface list). Therefore the GDBusObject is coupled with a NMObject later on. Lastly, now that all the objects are managed by the object manager, the NMRemoteSettings and NMManager go away when the daemon is stopped. The complexity of dealing with calls to NMClient that would require any of the resources that these objects manage (connection or device lists, etc.) had to be moved to NMClient. The bright side is that his allows for removal all of the daemon presence tracking from NMObject.
* libnm: order the property updatesLubomir Rintel2016-11-101-94/+102
| | | | | | | | | | Don't let a later property update finish than the sooner one. This wouldn't happen most of time, apart from a special case when the latter update of a object array property is to an empty list. In that case the latter update would complete sooner and when the earlier update finishes the list would contain objects which are supposed to be gone already.
* nm-object: initialize the object buffer to zeroLubomir Rintel2016-11-101-1/+1
|
* all: modify line separator comments to be 80 chars wideThomas Haller2016-10-031-3/+3
| | | | sed 's#^/\*\{5\}\*\+/$#/*****************************************************************************/#' $(git grep -l '\*\{5\}' | grep '\.[hc]$') -i
* libnm: make waiting objects fail when an object initialization failsBeniamino Galvani2016-09-091-5/+18
| | | | | | Previously, when the load of an object failed and there were other objects waiting for it, those objects would remain waiting forever. Make them fail as well.
* nm-object: delay object property completion until the objects are initializedLubomir Rintel2016-03-141-45/+78
| | | | | | | | | | We don't want to update the properties until the objects referred are complete. Otherwise the clients get confused. Very confused: https://bugzilla.redhat.com/show_bug.cgi?id=1313866 We already delay the notification signals. Let's replace that with delaying the actual ObjectCreatedData processing instead.
* nm-object: don't leak the properties on changed signalsLubomir Rintel2016-03-081-1/+3
| | | | https://bugzilla.redhat.com/show_bug.cgi?id=1314976
* all: don't include error->code in log messagesThomas Haller2016-03-031-2/+1
| | | | | | | | | GError codes are only unique per domain, so logging the code without also indicating the domain is not helpful. And anyway, if the error messages are not distinctive enough to tell the whole story then we should fix the error messages. Based-on-patch-by: Dan Winship <danw@gnome.org>
* all: cleanup includes and let "nm-default.h" include "config.h"Thomas Haller2016-02-191-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | - All internal source files (except "examples", which are not internal) should include "config.h" first. As also all internal source files should include "nm-default.h", let "config.h" be included by "nm-default.h" and include "nm-default.h" as first in every source file. We already wanted to include "nm-default.h" before other headers because it might contains some fixes (like "nm-glib.h" compatibility) that is required first. - After including "nm-default.h", we optinally allow for including the corresponding header file for the source file at hand. The idea is to ensure that each header file is self contained. - Don't include "config.h" or "nm-default.h" in any header file (except "nm-sd-adapt.h"). Public headers anyway must not include these headers, and internal headers are never included after "nm-default.h", as of the first previous point. - Include all internal headers with quotes instead of angle brackets. In practice it doesn't matter, because in our public headers we must include other headers with angle brackets. As we use our public headers also to compile our interal source files, effectively the result must be the same. Still do it for consistency. - Except for <config.h> itself. Include it with angle brackets as suggested by https://www.gnu.org/software/autoconf/manual/autoconf.html#Configuration-Headers
* build: cleanup default includesThomas Haller2016-02-121-4/+5
| | | | | | | | | | | | | | | | | | | - "gsystem-local-alloc.h" and <gio/gio.h> are already included via "nm-default.h". No need to include them separately. - include "nm-macros-internal.h" via "nm-default.h" and drop all explict includes. - in the modified files, ensure that we always include "config.h" and "nm-default.h" first. As second, include the header file for the current source file (if applicable). Then follow external includes and finally internal nm includes. - include nm headers inside source code files with quotes - internal header files don't need to include default headers. They can savely assume that "nm-default.h" is already included and with it glib, nm-glib.h, nm-macros-internal.h, etc.
* core,libnm: use nm_clear_g_source() where possibleBeniamino Galvani2016-01-061-4/+1
| | | | | | | | | | | | | | | | | | Replacement was done with commands: spatch --sp-file nm_clear_g_source.cocci --in-place --smpl-spacing --dir src spatch --sp-file nm_clear_g_source.cocci --in-place --smpl-spacing --dir libnm where nm_clear_g_source.cocci contains: @@ expression e; @@ - if (e) { - g_source_remove (e); - e = 0; - } + nm_clear_g_source (&e);
* libnm,nm-object: only send "notify" signal when the object property actually ↵Lubomir Rintel2015-12-051-25/+65
| | | | changed
* libnm: avoid notifying for objects until they're async-initedLubomir Rintel2015-10-061-0/+38
| | | | | | | | | | | | | | | Otherwise the uninitializeded objects could be prematurely signalled if their paths are seen twice in quick succession. This happens when you have ethernet hardware and add an ethernet connection -- it's immediatelly added to AvialableConnections and the property reload signals the object addition before the NMRemoteSettings's GetSettings() finishes: # nmcli c add type ethernet autoconnect no ifname '*' (process:4610): libnm-CRITICAL **: nm_connection_get_id: assertion 's_con != NULL' failed Connection '(null)' ((null)) successfully added. # https://bugzilla.gnome.org/show_bug.cgi?id=754794
* libnm: use nm_clear_g_source() in nm-object.cThomas Haller2015-10-031-4/+2
|
* Revert "libnm: don't add objects to cache until they're async-inited"Thomas Haller2015-09-151-5/+1
| | | | | | Reverting, because patch breaks tests for "libnm/tests". This reverts commit 88f0d646d5089dfc8df9b03750ade72e921803eb.
* libnm: don't add objects to cache until they're async-initedLubomir Rintel2015-09-151-1/+5
| | | | | | | | | | | | | | | Otherwise the uninitializeded objects could be prematurely signalled if their paths are seen twice in quick succession. This happens when you have ethernet hardware and add an ethernet connection -- it's immediatelly added to AvialableConnections and the property reload signals the object addition before the NMRemoteSettings's GetSettings() finishes: # nmcli c add type ethernet autoconnect no ifname '*' (process:4610): libnm-CRITICAL **: nm_connection_get_id: assertion 's_con != NULL' failed Connection '(null)' ((null)) successfully added. # https://bugzilla.gnome.org/show_bug.cgi?id=754794
* all: drop includes to <glib/gi18n.h> for "nm-default.h"Dan Winship2015-08-051-1/+0
| | | | | | | The localization headers are now included via "nm-default.h". Also fixes several places, where we wrongly included <glib/gi18n-lib.h> instead of <glib/gi18n.h>. For example under "clients/" directory.
* all: make use of new header file "nm-default.h"Thomas Haller2015-08-051-1/+1
|
* all: rename nm-glib-compat.h to nm-glib.h, use everywhereDan Winship2015-07-241-2/+1
| | | | | | | | | | | | | | | | Rather than randomly including one or more of <glib.h>, <glib-object.h>, and <gio/gio.h> everywhere (and forgetting to include "nm-glib-compat.h" most of the time), rename nm-glib-compat.h to nm-glib.h, include <gio/gio.h> from there, and then change all .c files in NM to include "nm-glib.h" rather than including the glib headers directly. (Public headers files still have to include the real glib headers, since nm-glib.h isn't installed...) Also, remove glib includes from header files that are already including a base object header file (which must itself already include the glib headers).
* libnm, core: use typechecked proxy_call methodsDan Winship2015-04-031-14/+19
|
* libnm, core: use _nm_dbus_signal_connect()Dan Winship2015-04-031-14/+6
|
* trivial: do an assignment before the conditional instead of in both branchesThomas Haller2015-03-161-3/+2
| | | | | | | [lkundrak@v3.sk: An improvement suggested in bugzilla, but I failed to apply it to the commit.] https://bugzilla.redhat.com/show_bug.cgi?id=1079353
* libnm,nm-object: fix tracing of object removalLubomir Rintel2015-03-161-15/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a new connection is activated and presently active connection goes away, the active-connection-removed signal is not emitted for the old connection. This is what happens: 1.) Initially, nm-manager::active-connections = [ActiveConnection/old] 2.) First PropertyChange is signalled for the new connection addition: nm-manager::active-connections = [ActiveConnection/old,ActiveConnection/new] This triggers load of ActiveConnection/new object. 3.) Another PropertyChange is signalled for the old connection removal: nm-manager::active-connections = [ActiveConnection/new] This removes the ActiveConnection/old object from nm-manager::active-connections and enqueues active-connection-removed signal. The signal is not emmitted as there's a reload from 2.) in progress. 4.) ActiveConnection/new reload finished object_property_complete() compares [ActiveConnection/old,ActiveConnection/new] from its odata to current nm-manager::active-connections and incorrectly concludes that ActiveConnection/old was just added and removes the enqueued active-connection-removed signal. This patch fixes the issue by remembering the original nm-manager::active-connections property value at 2.). [thaller@redhat.com: fixed an integer overflow and odata->array unreffing] https://bugzilla.redhat.com/show_bug.cgi?id=1079353
* libnm: check pspec before accessing it in handle_property_changed()Jiří Klimeš2014-12-051-1/+1
| | | | | | | | Fixes: 1f8ec6122e5ae950da7eb3e6b145609f08685c71 Coverity: libnm/nm-object.c:926: var_deref_op: Dereferencing null pointer "pspec". libnm/nm-object.c:924: var_deref_op: Dereferencing null pointer "pspec".
* libnm*: fix library gettext usageDan Winship2014-11-131-1/+1
| | | | | | | | | | | | | | | | | Libraries need to include <gi18n-lib.h>, not <gi18n.h>, so that _() will get defined to "dgettext (GETTEXT_DOMAIN, string)" rather than "gettext (string)" (which will use the program's default domain, which works fine for programs in the NetworkManager tree, but not for external users). Likewise, we need to call bindtextdomain() so that gettext can find the translations if the library is installed in a different prefix from the program using it (and bind_textdomain_codeset(), so it will know the translations are in UTF-8 even if the locale isn't). (The fact that no one noticed this was broken before is because the libraries didn't really start returning useful translated strings much until 0.9.10, and none of the out-of-tree clients have been updated to actually show those strings to users yet.)
* all: consistently include config.hDan Winship2014-11-131-0/+2
| | | | | | | | | | | config.h should be included from every .c file, and it should be included before any other include. Fix that. (As a side effect of how I did this, this also changes us to consistently use "config.h" rather than <config.h>. To the extent that it matters [which is not much], quotes are more correct anyway, since we're talking about a file in our own build tree, not a system include.)
* libnm-core: emit added/removed signals before property change notificationsDan Williams2014-11-071-9/+12
| | | | | | | | | | | | | | | | | | | Because internal objects do some processing/setup in the various _added class signal handlers, they need to be emitted before property change notifications. Otherwise it leads to situations where external objects that listen to NMClient property changes will be called before internal processing has been completed. Specifically, NMRemoteSettings uses connection_added() to check connection visibility and assign the new connection to one of two internal arrays. If a client got a property notification for NMClient::connections before NMRemoteSettings can process the new connection, then nm_client_get_connections() will return an empty array because NMRemoteSettings hasn't had the chance to add the new connection to priv->visible yet, which is done in NMRemoteSettings::connection_added(). Fixes:Beaker:NetworkManager_Test240_nmtui_general_realtime_refresh_edit_screen
* trivial: make _nm_object_reload_properties() private to nm-object.cDan Williams2014-11-061-1/+1
|