summaryrefslogtreecommitdiff
path: root/libnm/nm-remote-connection.c
Commit message (Collapse)AuthorAgeFilesLines
* all: rename the introspection data to use the interface paths in namesLubomir Rintel2016-11-231-1/+1
| | | | | | | | This makes it easier to install the files with proper names. Also, it makes the makefile rules slightly simpler. Lastly, the documentation is now generated into docs/api, which makes it possible to get rid of the awkward relative file names in docbook.
* libnm: avoid leaking the interface proxiesLubomir Rintel2016-11-141-0/+11
| | | | | _nm_object_get_proxy()'s semantics changed with the object-manager branch merge: it now takes a reference.
* libnm: use the o.fd.DBus.ObjectManager API for object managementlr/object-managerLubomir Rintel2016-11-101-59/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* 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: be more accepting for invalid connections from NetworkManagerThomas Haller2016-03-261-6/+5
| | | | | | | | | Relax our error checking which will allow us to try harder to make the best out of whatever NetworkManager sends us. Also, drop the g_warning(). First, now we really don't expect this function to fail. And even in that case, raising a g_warning() from the library is not very friendly to the user of libnm.
* 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: clean-up usage of GErrorThomas Haller2016-03-031-2/+2
| | | | | | | | | | | Functions that take a GError** MUST fill it in on error. There is no need to check whether error is NULL if the function it was passed to had a failing return value. Likewise, a proper GError must have a non-NULL message, so there's no need to double-check that either. Based-on-patch-by: Dan Winship <danw@gnome.org>
* all: cleanup includes and let "nm-default.h" include "config.h"Thomas Haller2016-02-191-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
* Revert "libnm: fix initializing of new connections"Lubomir Rintel2015-10-061-1/+0
| | | | This reverts commit d20bed069c718e161f0a2457c9fb8204fc5c9fac.
* libnm: fix missing case in "nm-remote-connection.c"Thomas Haller2015-09-181-1/+1
| | | | Fixes: d20bed069c718e161f0a2457c9fb8204fc5c9fac
* libnm: fix initializing of new connectionsJiří Klimeš2015-09-181-0/+1
| | | | | | | | | | | | | | | | | | | | | connection_added() can be called before init_get_settings_cb(), and we can't complete the connection until it is visible, else it would be uninitialized. Test case: * have 'em1' interface $ nmcli con add type ethernet con-name myeth ifname em1 autoconnect no (process:9039): libnm-CRITICAL **: nm_connection_get_id: assertion 's_con != NULL' failed Connection '(null)' ((null)) successfully added. $ nmcli con add type ethernet con-name myeth ifname em1X autoconnect no Connection 'myeth' (71159504-c2af-4773-8ca9-a3626aa0da33) successfully added. https://bugzilla.gnome.org/show_bug.cgi?id=754767 https://bugzilla.gnome.org/show_bug.cgi?id=754794 [lkundrak@v3.sk: This is not quite the correct fix, we shouldn't emit NMObject:connection-added for an unfinished object. Nevertheless, let's go with it until we have a better one. Will revert this afterwards. See linked bugs.]
* 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).
* nm-remote-connection: take a reference to self while calling get_settingsLubomir Rintel2015-04-171-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | (process:6888): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GDBusProxy' Program received signal SIGTRAP, Trace/breakpoint trap. g_logv (log_domain=0x3149a3b224 "GLib-GObject", log_level=G_LOG_LEVEL_WARNING, format=<optimized out>, args=args@entry=0x7fffffffda70) at gmessages.c:1046 1046 g_private_set (&g_log_depth, GUINT_TO_POINTER (depth)); (gdb) bt #0 0x0000003148e50c70 in g_logv (log_domain=0x3149a3b224 "GLib-GObject", log_level=G_LOG_LEVEL_WARNING, format=<optimized out>, args=args@entry=0x7fffffffda70) at gmessages.c:1046 #1 0x0000003148e50eaf in g_log (log_domain=log_domain@entry=0x3149a3b224 "GLib-GObject", log_level=log_level@entry=G_LOG_LEVEL_WARNING, format=format@entry=0x3149a42690 "invalid unclassed pointer in cast to '%s'") at gmessages.c:1079 #2 0x0000003149a34171 in g_type_check_instance_cast (type_instance=type_instance@entry=0x6fc530, iface_type=<optimized out>) at gtype.c:4030 #3 0x00007ffff7d6b016 in nmdbus_settings_connection_call_get_settings_finish (proxy=0x6fc530, out_settings=out_settings@entry=0x7fffffffdbb8, res=res@entry=0x6fe150, error=error@entry=0x0) at nmdbus-settings-connection.c:1303 #4 0x00007ffff7ce8813 in updated_get_settings_cb (proxy=<optimized out>, result=0x6fe150, user_data=user_data@entry=0x6fc650) at nm-remote-connection.c:588 #5 0x000000314a27640d in g_simple_async_result_complete (simple=0x6fe150 [GSimpleAsyncResult]) at gsimpleasyncresult.c:763 #6 0x000000314a2df47c in reply_cb (connection=<optimized out>, res=0x6fe0e0, user_data=user_data@entry=0x6fe150) at gdbusproxy.c:2623 #7 0x000000314a27640d in g_simple_async_result_complete (simple=0x6fe0e0 [GSimpleAsyncResult]) at gsimpleasyncresult.c:763 #8 0x000000314a2d48cc in g_dbus_connection_call_done (source=<optimized out>, result=<optimized out>, user_data=user_data@entry=0x7fffec01a320) at gdbusconnection.c:5502 #9 0x000000314a27640d in g_simple_async_result_complete (simple=0x6e5f40 [GSimpleAsyncResult]) at gsimpleasyncresult.c:763 #10 0x000000314a27647c in complete_in_idle_cb (data=0x6e5f40) at gsimpleasyncresult.c:775 #11 0x0000003148e49b6b in g_main_context_dispatch (context=0x687970) at gmain.c:3064 #12 0x0000003148e49b6b in g_main_context_dispatch (context=context@entry=0x687970) at gmain.c:3663 #13 0x0000003148e49f08 in g_main_context_iterate (context=0x687970, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3734 #14 0x0000003148e4a232 in g_main_loop_run (loop=0x687a80) at gmain.c:3928 #15 0x00000000004136a1 in main (argc=<optimized out>, argv=<optimized out>) at nmcli.c:632 (gdb)
* 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: strip GDBus gunk from GErrorsDan Winship2014-10-221-14/+41
| | | | | Call g_dbus_error_strip_remote_error() on all errors returned from gdbus calls. (Blah!)
* libnm: drop unused NMRemoteConnectionErrorDan Winship2014-10-221-17/+0
| | | | | | | | | NMRemoteConnection used to return NM_REMOTE_CONNECTION_ERROR_DISCONNECTED if you tried to operate on a connection that had been disconnected from its D-Bus proxy. But this disappeared in the gdbus port (since gdbus doesn't emit a signal when it happens, so it's harder to notice. And it's not clear why NMRemoteConnection did this when no other class did anyway...).
* libnm: fix compilation for wrong g_return call on void/non-void functionThomas Haller2014-09-251-1/+1
| | | | | Fixes: 41eca3ea490c819c263aa986e1e9bad813dcfe47 Signed-off-by: Thomas Haller <thaller@redhat.com>
* libnm: add some missing sync/async method variantsDan Winship2014-09-251-0/+122
| | | | | | | | | | | | | Add the missing variant in most places in the API where previously there was either only a synchronous version or only an asynchronous version. There is not yet a synchronous nm_client_activate_connection(), nm_client_add_and_activate_connection(), or nm_remote_settings_add_connection(), because the existing async code depends on waiting for other asynchronous events, so making them run synchronously is slightly more complicated. But these APIs can be added later.
* libnm: make sync/async APIs more GLib-likeDan Winship2014-09-251-156/+212
| | | | | | | | | | | | Make synchronous APIs take GCancellables, and make asynchronous APIs use GAsyncReadyCallbacks and have names ending in "_async", with "_finish" functions to retrieve the results. Also, make nm_client_activate_connection_finish(), nm_client_add_and_activate_finish(), and nm_remote_settings_add_connection_finish() be (transfer full) rather than (transfer none), because the refcounting semantics become slightly confusing in some edge cases otherwise.
* libnm: merge saved and unsaved connection methodsDan Winship2014-09-251-54/+25
| | | | | | | | Merge nm_remote_settings_add_connection() and nm_remote_settings_add_connection_unsaved(), and likewise nm_remote_connection_commit_changes() and nm_remote_connection_commit_changes_unsaved(), by adding a boolean flag to each saying whether to save to disk.
* libnm: port to GDBusDan Winship2014-09-181-192/+122
| | | | | | | | | Port libnm-core/libnm to GDBus. The NetworkManager daemon continues to use dbus-glib; the previously-added connection hash/variant conversion methods are now moved to NetworkManagerUtils (along with a few other utilities that are now only needed by the daemon code).
* libnm-core: change connection hash tables to variants in APIDan Winship2014-09-181-6/+28
| | | | | | | | | | In preparation for porting to GDBus, make nm_connection_to_dbus(), etc, represent connections as GVariants of type 'a{sa{sv}}' rather than as GHashTables-of-GHashTables-of-GValues. This means we're constantly converting back and forth internally, but this is just a stepping stone on the way to the full GDBus port, and all of that code will go away again later.
* libnm: rename nm-dbus-helpers-private.h to nm-dbus-helpers.hDan Winship2014-09-181-1/+1
| | | | The .h file should have the same name as the .c file.
* libnm: let NMObject create all D-Bus proxiesDan Winship2014-09-181-3/+5
| | | | | | | | | | | | Add _nm_object_class_add_interface(), for declaring that a class implements a particular interface, and then have NMObject create the corresponding proxies itself. (The subclass can get a copy with _nm_object_get_proxy() if it needs it for something). (In GDBus, creating a proxy is a heavier operation than in dbus-glib, so we'll need to create the proxies asynchronously. Moving the creation to NMObject makes that easier since we can do it as part of the existing init/init_async.)
* libnm: drop NMObject:dbus-connectionDan Winship2014-09-091-3/+1
| | | | | | The only plausible use case for the NMObject:dbus-connection property is for using the session bus in test programs. So just drop it and use an environment variable to decide which bus to use instead.
* libnm-core: clean up nm_connection_replace_settings()'s semanticsDan Winship2014-09-041-5/+1
| | | | | | | | On failure, nm_connection_replace_settings() would leave the connection in an undefined state. Fix it so that either (a) the settings are replaced and the resulting connection is valid and we return TRUE, or (b) the connection is untouched and we return FALSE and an error. (And add a test case for this.)
* libnm-core: rename NMConnection to/from_hash methodsDan Winship2014-09-041-2/+2
| | | | | | | | | | | | Rename nm_connection_to_hash() to nm_connection_to_dbus(), and nm_connection_new_from_hash() to nm_connection_new_from_dbus(). In addition to clarifying that this is specifically the D-Bus serialization format, these names will also work better in the GDBus-based future where the serialization format is GVariant, not GHashTable. Also, move NMSettingHashFlags to nm-connection.h, and rename it NMConnectionSerializationFlags.
* libnm: make NMRemoteConnection an NMObjectDan Winship2014-08-161-142/+50
|
* libnm-core, libnm, core: make NMConnection an interfaceDan Winship2014-08-161-1/+29
| | | | | | | | | | | | | | | | | | | | | | The fact that NMRemoteConnection has to be an NMConnection and therefore can't be an NMObject means that it needs to reimplement bits of NMObject functionality (and likewise NMObject needs some special magic to deal with it). Likewise, we will need a daemon-side equivalent of NMObject as part of the gdbus port, and we would want NMSettingsConnection to be able to inherit from this as well. Solve this problem by making NMConnection into an interface, and having NMRemoteConnection and NMSettingsConnection implement it. (We use some hacks to keep the GHashTable of NMSettings objects inside nm-connection.c rather than having to be implemented by the implementations.) Since NMConnection is no longer an instantiable type, this adds NMSimpleConnection to replace the various non-D-Bus-based uses of NMConnection throughout the code. nm_connection_new() becomes nm_simple_connection_new(), nm_connection_new_from_hash() becomes nm_simple_connection_new_from_hash(), and nm_connection_duplicate() becomes nm_simple_connection_new_clone().
* libnm: get rid of redundant NMRemoteConnection propertiesDan Winship2014-08-161-73/+2
| | | | | | | | | | | | | | | | | | | | | NMRemoteConnection had two DBusGConnection properties (NMRemoteConnection:bus and NMRemoteConnection:dbus-connection) and two D-Bus path properties (NMConnection:path and NMRemoteConnection:dbus-path). The former of each pair were the traditional names, and the latter were added for compatibility with NMObject. In libnm, we can just drop NMRemoteConnection:bus, and use the NMObject-compatible :dbus-connection name instead. For the path properties, we need to rename either NMConnection:path or NMObject:dbus-path. Since NMObject already has "nm_object_get_path()" rather than "nm_object_get_dbus_path()", and it already mistakenly referred to the property as "NMObject:path" in the gtk-docs, it seemed to make sense to rename that one rather than the NMConnection one. (And then, for consistency, rename "nm_object_get_connection()" to "nm_object_get_dbus_connection()" to also match its property.)
* libnm: remove NMRemoteConnection::updated signalDan Winship2014-08-071-27/+1
| | | | | | | | Remove NMRemoteConnection::updated, which since 0.9.10 has been redundant with NMConnection::changed. (We still handle the incoming D-Bus signal, we just don't re-emit it as "updated", since the call to nm_connection_replace_settings() already results in it emitting "changed".)
* libnm: port NMRemoteSettings to NMObjectDan Winship2014-08-071-33/+1
| | | | | | | | | | | | | | | | | | | NMRemoteSettings duplicates a bunch of NMObject's functionality that it doesn't need to. In libnm-glib, it wouldn't have been possible to port NMRemoteSettings to NMObject without breaking ABI, but now in libnm we can do that. As a side effect of this, NMRemoteSettings gains a "connections" property, and "connection-added" and "connection-removed" signals (with the former replacing the old "new-connection" signal). This also removes the "connections-loaded" signal, since the connections will now always be loaded (via the initialization of the "connections" property) during init()/init_async(). Also, this removes NMRemoteConnection's "removed" signal, since it's redundant with the new NMRemoteSettings::connection-removed (and having the signal on NMRemoteSettings instead is more consistent with other objects).
* libnm: add NMRemoteConnection:visible propertyDan Winship2014-08-071-17/+54
| | | | | Rather than having a private "visible" signal, have a public "visible" property.
* libnm: rename NetworkManager.h and NetworkManagerVPN.hDan Winship2014-08-011-1/+1
| | | | | | | "NetworkManager.h"'s name (and non-standard capitalization) suggest that it's some sort of high-level super-important header, but it's really just low-level D-Bus stuff. Rename it to "nm-dbus-interface.h" and likewise "NetworkManagerVPN.h" to "nm-vpn-dbus-interface.h"
* libnm: make the the use of GInitable mandatoryDan Winship2014-08-011-45/+17
| | | | | | | | | | | Remove _nm_object_ensure_inited(), etc; objects that implement GInitable are now mandatory-to-init(). Remove constructor() implementations that sometimes return NULL; do all the relevant checking in init() instead. Make nm_client_new() and nm_remote_settings_new() take a GCancellable and a GError**.
* libnm: remove _new functions from NMObject subclassesDan Winship2014-08-011-23/+0
| | | | | Most NMObjects should not be manually created, they should only be received from NMClient or NMRemoteSettings.
* libnm: consistently use "INTERFACE" rather than "IFACE" in macrosDan Winship2014-08-011-3/+3
| | | | | | Most D-Bus interface name macros used "INTERFACE" in their name (eg, NM_DBUS_INTERFACE), but a few used "IFACE" instead (eg, NM_DBUS_IFACE_SETTINGS). Make them consistent.
* libnm: remove Since tags and NM_AVAILABLE_IN_* attributesDan Winship2014-08-011-8/+0
| | | | Everything currently in libnm has always been there.
* libnm: add libnm/libnm-core (part 1)Dan Winship2014-08-011-0/+963
This commit begins creating the new "libnm", which will replace libnm-util and libnm-glib. The main reason for the libnm-util/libnm-glib split is that the daemon needs to link to libnm-util (to get NMSettings, NMConnection, etc), but can't link to libnm-glib (because it uses many of the same type names as the NetworkManager daemon. eg, NMDevice). So the daemon links to only libnm-util, but basically all clients link to both. With libnm, there will be only a single client-visible library, and NetworkManager will internally link against a private "libnm-core" containing the parts that used to be in libnm-util. (The "libnm-core" parts still need to be in their own directory so that the daemon can see those header files without also seeing the ones in libnm/ that conflict with its own headers.) [This commit just copies the source code from libnm-util/ to libnm-core/, and libnm-glib/ to libnm/: mkdir -p libnm-core/tests/ mkdir -p libnm/tests/ cp libnm-util/*.[ch] libnm-util/nm-version.h.in libnm-core/ rm -f libnm-core/nm-version.h libnm-core/nm-setting-template.[ch] libnm-core/nm-utils-enum-types.[ch] cp libnm-util/tests/*.[ch] libnm-core/tests/ cp libnm-glib/*.[ch] libnm/ rm -f libnm/libnm_glib.[ch] libnm/libnm-glib-test.c libnm/nm-glib-enum-types.[ch] cp libnm-glib/tests/*.[ch] libnm/tests/ ]