2019-09-10 11:19:01 +02:00
|
|
|
// SPDX-License-Identifier: LGPL-2.1+
|
2014-07-24 08:53:33 -04:00
|
|
|
/*
|
2019-10-01 09:20:35 +02:00
|
|
|
* Copyright (C) 2007 - 2008 Novell, Inc.
|
|
|
|
|
* Copyright (C) 2007 - 2011 Red Hat, Inc.
|
2014-07-24 08:53:33 -04:00
|
|
|
*/
|
|
|
|
|
|
2016-02-19 14:57:48 +01:00
|
|
|
#include "nm-default.h"
|
2014-11-13 10:07:02 -05:00
|
|
|
|
2019-01-31 13:44:13 +01:00
|
|
|
#include "nm-remote-connection.h"
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2016-02-19 14:57:48 +01:00
|
|
|
#include "nm-dbus-interface.h"
|
|
|
|
|
#include "nm-utils.h"
|
|
|
|
|
#include "nm-setting-connection.h"
|
2016-03-23 16:18:25 +01:00
|
|
|
#include "nm-core-internal.h"
|
2014-07-24 08:53:33 -04:00
|
|
|
#include "nm-remote-connection-private.h"
|
|
|
|
|
#include "nm-object-private.h"
|
2014-08-19 09:52:41 -04:00
|
|
|
#include "nm-dbus-helpers.h"
|
2014-09-10 13:51:53 -04:00
|
|
|
|
2016-11-23 13:14:08 +01:00
|
|
|
#include "introspection/org.freedesktop.NetworkManager.Settings.Connection.h"
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2018-06-28 15:44:40 +02:00
|
|
|
/**
|
|
|
|
|
* SECTION:nm-remote-connection
|
|
|
|
|
* @short_description: A connection managed by NetworkManager server
|
|
|
|
|
*
|
|
|
|
|
* A #NMRemoteConnection represents a connection that is exported via
|
|
|
|
|
* NetworkManager D-Bus interface.
|
|
|
|
|
**/
|
|
|
|
|
|
2014-08-13 14:34:29 -04:00
|
|
|
static void nm_remote_connection_connection_iface_init (NMConnectionInterface *iface);
|
2014-07-24 08:53:33 -04:00
|
|
|
static void nm_remote_connection_initable_iface_init (GInitableIface *iface);
|
|
|
|
|
static void nm_remote_connection_async_initable_iface_init (GAsyncInitableIface *iface);
|
2014-08-13 15:00:41 -04:00
|
|
|
static GInitableIface *nm_remote_connection_parent_initable_iface;
|
|
|
|
|
static GAsyncInitableIface *nm_remote_connection_parent_async_initable_iface;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-08-13 15:00:41 -04:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (NMRemoteConnection, nm_remote_connection, NM_TYPE_OBJECT,
|
2014-08-13 14:34:29 -04:00
|
|
|
G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION, nm_remote_connection_connection_iface_init);
|
2014-07-24 08:53:33 -04:00
|
|
|
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, nm_remote_connection_initable_iface_init);
|
|
|
|
|
G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, nm_remote_connection_async_initable_iface_init);
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_UNSAVED,
|
2018-04-05 20:06:03 +02:00
|
|
|
PROP_FLAGS,
|
2018-05-28 09:23:58 +02:00
|
|
|
PROP_FILENAME,
|
2014-07-20 12:42:59 -04:00
|
|
|
PROP_VISIBLE,
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
LAST_PROP
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2014-09-10 13:51:53 -04:00
|
|
|
NMDBusSettingsConnection *proxy;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
gboolean unsaved;
|
2018-04-05 20:06:03 +02:00
|
|
|
guint32 flags;
|
2018-06-21 16:06:01 +02:00
|
|
|
char *filename;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
gboolean visible;
|
|
|
|
|
} NMRemoteConnectionPrivate;
|
|
|
|
|
|
|
|
|
|
#define NM_REMOTE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_REMOTE_CONNECTION, NMRemoteConnectionPrivate))
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2014-07-24 08:53:33 -04:00
|
|
|
|
libnm: add nm_remote_connection_update2()
- only add an async version. I think sync requests are fundamentally flawed
because they mess up the order of D-Bus messages. Hence, also don't
call the function *_async(), like we do for other functions. As there
is only the async form, it doesn't have a suffix.
- Don't accept a NMConnection as @settings argument, but a GVariant.
In general, keep the libnm API closer to the D-Bus API and don't hide
the underlying function with a less powerful form. The user still can
conveniently call the function with
nm_remote_connection_update2 (connection,
nm_connection_to_dbus (NM_CONNECTION (connection),
NM_CONNECTION_SERIALIZE_ALL),
save_to_disk
? NM_SETTINGS_UPDATE2_FLAG_TO_DISK
: NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY,
NULL,
cancellable,
callback,
user_data);
I believe the parts of libnm that invoke D-Bus methods, should be
close to the D-Bus API. Not like nm_remote_connection_commit_changes()
which has no corresponding D-Bus method.
2017-11-30 12:11:18 +01:00
|
|
|
static void
|
|
|
|
|
update2_cb (GObject *proxy, GAsyncResult *result, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GSimpleAsyncResult *simple = user_data;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
GVariant *v;
|
|
|
|
|
|
|
|
|
|
if (nmdbus_settings_connection_call_update2_finish (NMDBUS_SETTINGS_CONNECTION (proxy),
|
|
|
|
|
&v,
|
|
|
|
|
result,
|
2019-09-02 12:28:50 +02:00
|
|
|
&error)) {
|
libnm: add nm_remote_connection_update2()
- only add an async version. I think sync requests are fundamentally flawed
because they mess up the order of D-Bus messages. Hence, also don't
call the function *_async(), like we do for other functions. As there
is only the async form, it doesn't have a suffix.
- Don't accept a NMConnection as @settings argument, but a GVariant.
In general, keep the libnm API closer to the D-Bus API and don't hide
the underlying function with a less powerful form. The user still can
conveniently call the function with
nm_remote_connection_update2 (connection,
nm_connection_to_dbus (NM_CONNECTION (connection),
NM_CONNECTION_SERIALIZE_ALL),
save_to_disk
? NM_SETTINGS_UPDATE2_FLAG_TO_DISK
: NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY,
NULL,
cancellable,
callback,
user_data);
I believe the parts of libnm that invoke D-Bus methods, should be
close to the D-Bus API. Not like nm_remote_connection_commit_changes()
which has no corresponding D-Bus method.
2017-11-30 12:11:18 +01:00
|
|
|
g_simple_async_result_set_op_res_gpointer (simple,
|
|
|
|
|
v,
|
|
|
|
|
(GDestroyNotify) g_variant_unref);
|
2019-09-02 12:28:50 +02:00
|
|
|
} else {
|
libnm: add nm_remote_connection_update2()
- only add an async version. I think sync requests are fundamentally flawed
because they mess up the order of D-Bus messages. Hence, also don't
call the function *_async(), like we do for other functions. As there
is only the async form, it doesn't have a suffix.
- Don't accept a NMConnection as @settings argument, but a GVariant.
In general, keep the libnm API closer to the D-Bus API and don't hide
the underlying function with a less powerful form. The user still can
conveniently call the function with
nm_remote_connection_update2 (connection,
nm_connection_to_dbus (NM_CONNECTION (connection),
NM_CONNECTION_SERIALIZE_ALL),
save_to_disk
? NM_SETTINGS_UPDATE2_FLAG_TO_DISK
: NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY,
NULL,
cancellable,
callback,
user_data);
I believe the parts of libnm that invoke D-Bus methods, should be
close to the D-Bus API. Not like nm_remote_connection_commit_changes()
which has no corresponding D-Bus method.
2017-11-30 12:11:18 +01:00
|
|
|
g_dbus_error_strip_remote_error (error);
|
|
|
|
|
g_simple_async_result_take_error (simple, error);
|
|
|
|
|
}
|
|
|
|
|
g_simple_async_result_complete (simple);
|
|
|
|
|
g_object_unref (simple);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_remote_connection_update2:
|
|
|
|
|
* @connection: the #NMRemoteConnection
|
|
|
|
|
* @settings: (allow-none): optional connection to update the settings.
|
|
|
|
|
* @flags: update-flags
|
|
|
|
|
* @args: (allow-none): optional arguments.
|
|
|
|
|
* @cancellable: a #GCancellable, or %NULL
|
|
|
|
|
* @callback: callback to be called when the commit operation completes
|
|
|
|
|
* @user_data: caller-specific data passed to @callback
|
|
|
|
|
*
|
|
|
|
|
* Asynchronously calls the Update2() D-Bus method.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
nm_remote_connection_update2 (NMRemoteConnection *connection,
|
|
|
|
|
GVariant *settings,
|
|
|
|
|
NMSettingsUpdate2Flags flags,
|
|
|
|
|
GVariant *args,
|
|
|
|
|
GCancellable *cancellable,
|
|
|
|
|
GAsyncReadyCallback callback,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteConnectionPrivate *priv;
|
|
|
|
|
GSimpleAsyncResult *simple;
|
|
|
|
|
GVariantBuilder builder;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_REMOTE_CONNECTION (connection));
|
|
|
|
|
g_return_if_fail (!settings || g_variant_is_of_type (settings, NM_VARIANT_TYPE_CONNECTION));
|
|
|
|
|
g_return_if_fail (!args || g_variant_is_of_type (args, G_VARIANT_TYPE ("a{sv}")));
|
|
|
|
|
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
|
|
|
|
|
|
|
|
|
|
priv = NM_REMOTE_CONNECTION_GET_PRIVATE (connection);
|
|
|
|
|
|
|
|
|
|
simple = g_simple_async_result_new (G_OBJECT (connection), callback, user_data,
|
|
|
|
|
nm_remote_connection_update2);
|
2018-03-05 16:02:24 +01:00
|
|
|
if (cancellable)
|
|
|
|
|
g_simple_async_result_set_check_cancellable (simple, cancellable);
|
libnm: add nm_remote_connection_update2()
- only add an async version. I think sync requests are fundamentally flawed
because they mess up the order of D-Bus messages. Hence, also don't
call the function *_async(), like we do for other functions. As there
is only the async form, it doesn't have a suffix.
- Don't accept a NMConnection as @settings argument, but a GVariant.
In general, keep the libnm API closer to the D-Bus API and don't hide
the underlying function with a less powerful form. The user still can
conveniently call the function with
nm_remote_connection_update2 (connection,
nm_connection_to_dbus (NM_CONNECTION (connection),
NM_CONNECTION_SERIALIZE_ALL),
save_to_disk
? NM_SETTINGS_UPDATE2_FLAG_TO_DISK
: NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY,
NULL,
cancellable,
callback,
user_data);
I believe the parts of libnm that invoke D-Bus methods, should be
close to the D-Bus API. Not like nm_remote_connection_commit_changes()
which has no corresponding D-Bus method.
2017-11-30 12:11:18 +01:00
|
|
|
|
|
|
|
|
if (!settings) {
|
|
|
|
|
g_variant_builder_init (&builder, NM_VARIANT_TYPE_CONNECTION);
|
|
|
|
|
settings = g_variant_builder_end (&builder);
|
|
|
|
|
}
|
|
|
|
|
if (!args) {
|
|
|
|
|
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
|
|
|
|
|
args = g_variant_builder_end (&builder);
|
|
|
|
|
}
|
|
|
|
|
nmdbus_settings_connection_call_update2 (priv->proxy,
|
|
|
|
|
settings,
|
|
|
|
|
flags,
|
|
|
|
|
args,
|
|
|
|
|
cancellable,
|
|
|
|
|
update2_cb,
|
|
|
|
|
simple);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_remote_connection_update2_finish:
|
|
|
|
|
* @connection: the #NMRemoteConnection
|
|
|
|
|
* @result: the result passed to the #GAsyncReadyCallback
|
|
|
|
|
* @error: location for a #GError, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Gets the result of a call to nm_remote_connection_commit_changes_async().
|
|
|
|
|
*
|
|
|
|
|
* Returns: on success, a #GVariant of type "a{sv}" with the result. On failure,
|
|
|
|
|
* %NULL.
|
|
|
|
|
**/
|
|
|
|
|
GVariant *
|
|
|
|
|
nm_remote_connection_update2_finish (NMRemoteConnection *connection,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
GSimpleAsyncResult *simple;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (connection), nm_remote_connection_update2), FALSE);
|
|
|
|
|
|
|
|
|
|
simple = G_SIMPLE_ASYNC_RESULT (result);
|
|
|
|
|
if (g_simple_async_result_propagate_error (simple, error))
|
|
|
|
|
return NULL;
|
|
|
|
|
else
|
|
|
|
|
return g_variant_ref (g_simple_async_result_get_op_res_gpointer (simple));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
/**
|
|
|
|
|
* nm_remote_connection_commit_changes:
|
|
|
|
|
* @connection: the #NMRemoteConnection
|
|
|
|
|
* @save_to_disk: whether to persist the changes to disk
|
|
|
|
|
* @cancellable: a #GCancellable, or %NULL
|
|
|
|
|
* @error: location for a #GError, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Send any local changes to the settings and properties of @connection to
|
|
|
|
|
* NetworkManager. If @save_to_disk is %TRUE, the updated connection will be saved to
|
|
|
|
|
* disk; if %FALSE, then only the in-memory representation will be changed.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE on success, %FALSE on error, in which case @error will be set.
|
libnm: deprecate synchronous/blocking API in libnm
Note that D-Bus is fundamentally asynchronous. Doing blocking calls
on top of D-Bus is odd, especially for libnm's NMClient. That is because
NMClient essentially is a client-side cache of the objects from the D-Bus
interface. This cache should be filled exclusively by (asynchronous) D-Bus
events (PropertiesChanged). So, making a blocking D-Bus call means to wait
for a response and return it, while queuing all messages that are received
in the meantime.
Basically there are three ways how a synchronous API on NMClient could behave:
1) the call just calls g_dbus_connection_call_sync(). This means
that libnm sends a D-Bus request via GDBusConnection, and blockingly
waits for the response. All D-Bus messages that get received in the
meantime are queued in the GMainContext that belongs to NMClient.
That means, none of these D-Bus events are processed until we
iterate the GMainContext after the call returns. The effect is,
that NMClient (and all cached objects in there) are unaffected by
the D-Bus request.
Most of the synchronous API calls in libnm are of this kind.
The problem is that the strict ordering of D-Bus events gets
violated.
For some API this is not an immediate problem. Take for example
nm_device_wifi_request_scan(). The call merely blockingly tells
NetworkManager to start scanning, but since NetworkManager's D-Bus
API does not directly expose any state that tells whether we are
currently scanning, this out of order processing of the D-Bus
request is a small issue.
The problem is more obvious for nm_client_networking_set_enabled().
After calling it, NM_CLIENT_NETWORKING_ENABLED is still unaffected
and unchanged, because the PropertiesChanged signal from D-Bus
is not yet processed.
This means, while you make such a blocking call, NMClient's state
does not change. But usually you perform the synchronous call
to change some state. In this form, the blocking call is not useful,
because NMClient only changes the state after iterating the GMainContext,
and not after the blocking call returns.
2) like 1), but after making the blocking g_dbus_connection_call_sync(),
update the NMClient cache artificially. This is what
nm_manager_check_connectivity() does, to "fix" bgo#784629.
This also has the problem of out-of-order events, but it kinda
solves the problem of not changing the state during the blocking
call. But it does so by hacking the state of the cache. I think
this is really wrong because the state should only be updated from
the ordered stream of D-Bus messages (PropertiesChanged signal and
similar). When libnm decides to modify the state, there may be already
D-Bus messages queued that affect this very state.
3) instead of calling g_dbus_connection_call_sync(), use the
asynchronous g_dbus_connection_call(). If we would use a sepaate
GMainContext for all D-Bus related calls, we could ensure that
while we block for the response, we iterate that internal main context.
This might be nice, because all events are processed in order and
after the blocking call returns, the NMClient state is up to date.
The are problems however: current blocking API does not do this,
so it's a significant change in behavior. Also, it might be
unexpected to the user that during the blocking call the entire
content of NMClient's cache might change and all pointers to the
cache might be invalidated. Also, of course NMClient would invoke
signals for all the changes that happen.
Another problem is that this would be more effort to implement
and it involves a small performance overhead for all D-Bus related
calls (because we have to serialize all events in an internal
GMainContext first and then invoke them on the caller's context).
Also, if the users wants this behavior, they could implement it themself
by running libnm in their own GMainContext. Note that libnm might
have bugs to make that really working, but that should be fixed
instead of adding such synchrnous API behavior.
Read also [1], for why blocking calls are wrong.
[1] https://smcv.pseudorandom.co.uk/2008/11/nonblocking/
So, all possible behaviors for synchronous API have severe behavioural
issues. Mark all this API as deprecated. Also, this serves the purpose of
identifying blocking D-Bus calls in libnm.
Note that "deprecated" here does not really mean that the API is going
to be removed. We don't break API. The user may:
- continue to use this API. It's deprecated, awkward and discouraged,
but if it works, by all means use it.
- use asynchronous API. That's the only sensible way to use D-Bus.
If libnm lacks a certain asynchronous counterpart, it should be
added.
- use GDBusConnection directly. There really isn't anything wrong
with D-Bus or GDBusConnection. This deprecated API is just a wrapper
around g_dbus_connection_call_sync(). You may call it directly
without feeling dirty.
---
The only other remainging API is the synchronous GInitable call for
NMClient. That is an entirely separate beast and not particularly
wrong (from an API point of view).
Note that synchronous API in NMSecretAgentOld, NMVpnPluginOld and
NMVpnServicePlugin as not deprecated here. These types are not part
of the D-Bus cache and while they have similar issues, it's less severe
because they have less state.
2019-09-04 13:58:43 +02:00
|
|
|
*
|
|
|
|
|
* Deprecated: 1.22, use nm_remote_connection_commit_changes_async() or GDBusConnection
|
2014-09-11 16:27:13 -04:00
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_remote_connection_commit_changes (NMRemoteConnection *connection,
|
|
|
|
|
gboolean save_to_disk,
|
|
|
|
|
GCancellable *cancellable,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteConnectionPrivate *priv;
|
2017-11-29 19:46:00 +01:00
|
|
|
gs_unref_variant GVariant *result = NULL;
|
2014-10-15 18:26:32 -04:00
|
|
|
gboolean ret;
|
2017-11-29 19:46:00 +01:00
|
|
|
GVariantBuilder args;
|
2014-09-11 16:27:13 -04:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_CONNECTION (connection), FALSE);
|
|
|
|
|
|
|
|
|
|
priv = NM_REMOTE_CONNECTION_GET_PRIVATE (connection);
|
|
|
|
|
|
2017-11-29 19:46:00 +01:00
|
|
|
g_variant_builder_init (&args, G_VARIANT_TYPE ("a{sv}"));
|
|
|
|
|
ret = nmdbus_settings_connection_call_update2_sync (priv->proxy,
|
|
|
|
|
nm_connection_to_dbus (NM_CONNECTION (connection),
|
|
|
|
|
NM_CONNECTION_SERIALIZE_ALL),
|
|
|
|
|
save_to_disk
|
|
|
|
|
? NM_SETTINGS_UPDATE2_FLAG_TO_DISK
|
|
|
|
|
: NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY,
|
|
|
|
|
g_variant_builder_end (&args),
|
|
|
|
|
&result,
|
|
|
|
|
cancellable,
|
|
|
|
|
error);
|
2014-10-15 18:26:32 -04:00
|
|
|
if (error && *error)
|
|
|
|
|
g_dbus_error_strip_remote_error (*error);
|
|
|
|
|
return ret;
|
2014-09-11 16:27:13 -04:00
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
static void
|
2014-09-11 16:27:13 -04:00
|
|
|
update_cb (GObject *proxy, GAsyncResult *result, gpointer user_data)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
2014-09-11 16:27:13 -04:00
|
|
|
GSimpleAsyncResult *simple = user_data;
|
2014-09-10 13:51:53 -04:00
|
|
|
GError *error = NULL;
|
2017-11-29 19:46:00 +01:00
|
|
|
gs_unref_variant GVariant *v = NULL;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2017-11-29 19:46:00 +01:00
|
|
|
if (nmdbus_settings_connection_call_update2_finish (NMDBUS_SETTINGS_CONNECTION (proxy),
|
|
|
|
|
&v,
|
|
|
|
|
result,
|
|
|
|
|
&error))
|
2014-09-11 16:27:13 -04:00
|
|
|
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
|
2014-10-15 18:26:32 -04:00
|
|
|
else {
|
|
|
|
|
g_dbus_error_strip_remote_error (error);
|
2014-09-11 16:27:13 -04:00
|
|
|
g_simple_async_result_take_error (simple, error);
|
2014-10-15 18:26:32 -04:00
|
|
|
}
|
2014-09-11 16:27:13 -04:00
|
|
|
g_simple_async_result_complete (simple);
|
|
|
|
|
g_object_unref (simple);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-09-11 16:27:13 -04:00
|
|
|
* nm_remote_connection_commit_changes_async:
|
2014-07-24 08:53:33 -04:00
|
|
|
* @connection: the #NMRemoteConnection
|
2014-09-11 16:27:13 -04:00
|
|
|
* @save_to_disk: whether to save the changes to persistent storage
|
|
|
|
|
* @cancellable: a #GCancellable, or %NULL
|
|
|
|
|
* @callback: callback to be called when the commit operation completes
|
|
|
|
|
* @user_data: caller-specific data passed to @callback
|
2014-09-11 16:12:40 -04:00
|
|
|
*
|
2014-09-11 16:27:13 -04:00
|
|
|
* Asynchronously sends any local changes to the settings and properties of
|
|
|
|
|
* @connection to NetworkManager. If @save is %TRUE, the updated connection will
|
|
|
|
|
* be saved to disk; if %FALSE, then only the in-memory representation will be
|
|
|
|
|
* changed.
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
|
|
|
|
void
|
2014-09-11 16:27:13 -04:00
|
|
|
nm_remote_connection_commit_changes_async (NMRemoteConnection *connection,
|
|
|
|
|
gboolean save_to_disk,
|
|
|
|
|
GCancellable *cancellable,
|
|
|
|
|
GAsyncReadyCallback callback,
|
|
|
|
|
gpointer user_data)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
|
|
|
|
NMRemoteConnectionPrivate *priv;
|
2014-09-11 16:27:13 -04:00
|
|
|
GSimpleAsyncResult *simple;
|
2017-11-29 19:46:00 +01:00
|
|
|
GVariantBuilder args;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
g_return_if_fail (NM_IS_REMOTE_CONNECTION (connection));
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
priv = NM_REMOTE_CONNECTION_GET_PRIVATE (connection);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
simple = g_simple_async_result_new (G_OBJECT (connection), callback, user_data,
|
|
|
|
|
nm_remote_connection_commit_changes_async);
|
2018-03-05 16:02:24 +01:00
|
|
|
if (cancellable)
|
|
|
|
|
g_simple_async_result_set_check_cancellable (simple, cancellable);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2017-11-29 19:46:00 +01:00
|
|
|
g_variant_builder_init (&args, G_VARIANT_TYPE ("a{sv}"));
|
|
|
|
|
nmdbus_settings_connection_call_update2 (priv->proxy,
|
|
|
|
|
nm_connection_to_dbus (NM_CONNECTION (connection),
|
|
|
|
|
NM_CONNECTION_SERIALIZE_ALL),
|
|
|
|
|
save_to_disk
|
|
|
|
|
? NM_SETTINGS_UPDATE2_FLAG_TO_DISK
|
|
|
|
|
: NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY,
|
|
|
|
|
g_variant_builder_end (&args),
|
|
|
|
|
cancellable,
|
|
|
|
|
update_cb,
|
|
|
|
|
simple);
|
2014-09-10 13:51:53 -04:00
|
|
|
}
|
|
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
/**
|
|
|
|
|
* nm_remote_connection_commit_changes_finish:
|
|
|
|
|
* @connection: the #NMRemoteConnection
|
|
|
|
|
* @result: the result passed to the #GAsyncReadyCallback
|
|
|
|
|
* @error: location for a #GError, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Gets the result of a call to nm_remote_connection_commit_changes_async().
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE on success, %FALSE on error, in which case @error will be set.
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_remote_connection_commit_changes_finish (NMRemoteConnection *connection,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
GSimpleAsyncResult *simple;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (connection), nm_remote_connection_commit_changes_async), FALSE);
|
|
|
|
|
|
|
|
|
|
simple = G_SIMPLE_ASYNC_RESULT (result);
|
|
|
|
|
if (g_simple_async_result_propagate_error (simple, error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
else
|
|
|
|
|
return g_simple_async_result_get_op_res_gboolean (simple);
|
|
|
|
|
}
|
|
|
|
|
|
libnm: add nm_remote_connection_update2()
- only add an async version. I think sync requests are fundamentally flawed
because they mess up the order of D-Bus messages. Hence, also don't
call the function *_async(), like we do for other functions. As there
is only the async form, it doesn't have a suffix.
- Don't accept a NMConnection as @settings argument, but a GVariant.
In general, keep the libnm API closer to the D-Bus API and don't hide
the underlying function with a less powerful form. The user still can
conveniently call the function with
nm_remote_connection_update2 (connection,
nm_connection_to_dbus (NM_CONNECTION (connection),
NM_CONNECTION_SERIALIZE_ALL),
save_to_disk
? NM_SETTINGS_UPDATE2_FLAG_TO_DISK
: NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY,
NULL,
cancellable,
callback,
user_data);
I believe the parts of libnm that invoke D-Bus methods, should be
close to the D-Bus API. Not like nm_remote_connection_commit_changes()
which has no corresponding D-Bus method.
2017-11-30 12:11:18 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
/**
|
|
|
|
|
* nm_remote_connection_save:
|
|
|
|
|
* @connection: the #NMRemoteConnection
|
|
|
|
|
* @cancellable: a #GCancellable, or %NULL
|
|
|
|
|
* @error: location for a #GError, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Saves the connection to disk if the connection has changes that have not yet
|
|
|
|
|
* been written to disk, or if the connection has never been saved.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE on success, %FALSE on error, in which case @error will be set.
|
libnm: deprecate synchronous/blocking API in libnm
Note that D-Bus is fundamentally asynchronous. Doing blocking calls
on top of D-Bus is odd, especially for libnm's NMClient. That is because
NMClient essentially is a client-side cache of the objects from the D-Bus
interface. This cache should be filled exclusively by (asynchronous) D-Bus
events (PropertiesChanged). So, making a blocking D-Bus call means to wait
for a response and return it, while queuing all messages that are received
in the meantime.
Basically there are three ways how a synchronous API on NMClient could behave:
1) the call just calls g_dbus_connection_call_sync(). This means
that libnm sends a D-Bus request via GDBusConnection, and blockingly
waits for the response. All D-Bus messages that get received in the
meantime are queued in the GMainContext that belongs to NMClient.
That means, none of these D-Bus events are processed until we
iterate the GMainContext after the call returns. The effect is,
that NMClient (and all cached objects in there) are unaffected by
the D-Bus request.
Most of the synchronous API calls in libnm are of this kind.
The problem is that the strict ordering of D-Bus events gets
violated.
For some API this is not an immediate problem. Take for example
nm_device_wifi_request_scan(). The call merely blockingly tells
NetworkManager to start scanning, but since NetworkManager's D-Bus
API does not directly expose any state that tells whether we are
currently scanning, this out of order processing of the D-Bus
request is a small issue.
The problem is more obvious for nm_client_networking_set_enabled().
After calling it, NM_CLIENT_NETWORKING_ENABLED is still unaffected
and unchanged, because the PropertiesChanged signal from D-Bus
is not yet processed.
This means, while you make such a blocking call, NMClient's state
does not change. But usually you perform the synchronous call
to change some state. In this form, the blocking call is not useful,
because NMClient only changes the state after iterating the GMainContext,
and not after the blocking call returns.
2) like 1), but after making the blocking g_dbus_connection_call_sync(),
update the NMClient cache artificially. This is what
nm_manager_check_connectivity() does, to "fix" bgo#784629.
This also has the problem of out-of-order events, but it kinda
solves the problem of not changing the state during the blocking
call. But it does so by hacking the state of the cache. I think
this is really wrong because the state should only be updated from
the ordered stream of D-Bus messages (PropertiesChanged signal and
similar). When libnm decides to modify the state, there may be already
D-Bus messages queued that affect this very state.
3) instead of calling g_dbus_connection_call_sync(), use the
asynchronous g_dbus_connection_call(). If we would use a sepaate
GMainContext for all D-Bus related calls, we could ensure that
while we block for the response, we iterate that internal main context.
This might be nice, because all events are processed in order and
after the blocking call returns, the NMClient state is up to date.
The are problems however: current blocking API does not do this,
so it's a significant change in behavior. Also, it might be
unexpected to the user that during the blocking call the entire
content of NMClient's cache might change and all pointers to the
cache might be invalidated. Also, of course NMClient would invoke
signals for all the changes that happen.
Another problem is that this would be more effort to implement
and it involves a small performance overhead for all D-Bus related
calls (because we have to serialize all events in an internal
GMainContext first and then invoke them on the caller's context).
Also, if the users wants this behavior, they could implement it themself
by running libnm in their own GMainContext. Note that libnm might
have bugs to make that really working, but that should be fixed
instead of adding such synchrnous API behavior.
Read also [1], for why blocking calls are wrong.
[1] https://smcv.pseudorandom.co.uk/2008/11/nonblocking/
So, all possible behaviors for synchronous API have severe behavioural
issues. Mark all this API as deprecated. Also, this serves the purpose of
identifying blocking D-Bus calls in libnm.
Note that "deprecated" here does not really mean that the API is going
to be removed. We don't break API. The user may:
- continue to use this API. It's deprecated, awkward and discouraged,
but if it works, by all means use it.
- use asynchronous API. That's the only sensible way to use D-Bus.
If libnm lacks a certain asynchronous counterpart, it should be
added.
- use GDBusConnection directly. There really isn't anything wrong
with D-Bus or GDBusConnection. This deprecated API is just a wrapper
around g_dbus_connection_call_sync(). You may call it directly
without feeling dirty.
---
The only other remainging API is the synchronous GInitable call for
NMClient. That is an entirely separate beast and not particularly
wrong (from an API point of view).
Note that synchronous API in NMSecretAgentOld, NMVpnPluginOld and
NMVpnServicePlugin as not deprecated here. These types are not part
of the D-Bus cache and while they have similar issues, it's less severe
because they have less state.
2019-09-04 13:58:43 +02:00
|
|
|
*
|
|
|
|
|
* Deprecated: 1.22, use nm_remote_connection_save_async() or GDBusConnection
|
2014-09-11 16:27:13 -04:00
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_remote_connection_save (NMRemoteConnection *connection,
|
|
|
|
|
GCancellable *cancellable,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteConnectionPrivate *priv;
|
2014-10-15 18:26:32 -04:00
|
|
|
gboolean ret;
|
2014-09-11 16:27:13 -04:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_CONNECTION (connection), FALSE);
|
|
|
|
|
|
|
|
|
|
priv = NM_REMOTE_CONNECTION_GET_PRIVATE (connection);
|
|
|
|
|
|
2014-10-15 18:26:32 -04:00
|
|
|
ret = nmdbus_settings_connection_call_save_sync (priv->proxy, cancellable, error);
|
|
|
|
|
if (error && *error)
|
|
|
|
|
g_dbus_error_strip_remote_error (*error);
|
|
|
|
|
return ret;
|
2014-09-11 16:27:13 -04:00
|
|
|
}
|
|
|
|
|
|
2014-09-10 13:51:53 -04:00
|
|
|
static void
|
2014-09-11 16:27:13 -04:00
|
|
|
save_cb (GObject *proxy, GAsyncResult *result, gpointer user_data)
|
2014-09-10 13:51:53 -04:00
|
|
|
{
|
2014-09-11 16:27:13 -04:00
|
|
|
GSimpleAsyncResult *simple = user_data;
|
2014-09-10 13:51:53 -04:00
|
|
|
GError *error = NULL;
|
|
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
if (nmdbus_settings_connection_call_save_finish (NMDBUS_SETTINGS_CONNECTION (proxy),
|
|
|
|
|
result, &error))
|
|
|
|
|
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
|
2014-10-15 18:26:32 -04:00
|
|
|
else {
|
|
|
|
|
g_dbus_error_strip_remote_error (error);
|
2014-09-11 16:27:13 -04:00
|
|
|
g_simple_async_result_take_error (simple, error);
|
2014-10-15 18:26:32 -04:00
|
|
|
}
|
2014-09-11 16:27:13 -04:00
|
|
|
g_simple_async_result_complete (simple);
|
|
|
|
|
g_object_unref (simple);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-09-11 16:27:13 -04:00
|
|
|
* nm_remote_connection_save_async:
|
2014-07-24 08:53:33 -04:00
|
|
|
* @connection: the #NMRemoteConnection
|
2014-09-11 16:27:13 -04:00
|
|
|
* @cancellable: a #GCancellable, or %NULL
|
|
|
|
|
* @callback: callback to be called when the save operation completes
|
|
|
|
|
* @user_data: caller-specific data passed to @callback
|
2014-07-24 08:53:33 -04:00
|
|
|
*
|
|
|
|
|
* Saves the connection to disk if the connection has changes that have not yet
|
|
|
|
|
* been written to disk, or if the connection has never been saved.
|
|
|
|
|
**/
|
|
|
|
|
void
|
2014-09-11 16:27:13 -04:00
|
|
|
nm_remote_connection_save_async (NMRemoteConnection *connection,
|
|
|
|
|
GCancellable *cancellable,
|
|
|
|
|
GAsyncReadyCallback callback,
|
|
|
|
|
gpointer user_data)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
|
|
|
|
NMRemoteConnectionPrivate *priv;
|
2014-09-11 16:27:13 -04:00
|
|
|
GSimpleAsyncResult *simple;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_REMOTE_CONNECTION (connection));
|
|
|
|
|
|
|
|
|
|
priv = NM_REMOTE_CONNECTION_GET_PRIVATE (connection);
|
|
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
simple = g_simple_async_result_new (G_OBJECT (connection), callback, user_data,
|
|
|
|
|
nm_remote_connection_save_async);
|
2018-03-05 16:02:24 +01:00
|
|
|
if (cancellable)
|
|
|
|
|
g_simple_async_result_set_check_cancellable (simple, cancellable);
|
2014-09-11 16:27:13 -04:00
|
|
|
nmdbus_settings_connection_call_save (priv->proxy, cancellable, save_cb, simple);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_remote_connection_save_finish:
|
|
|
|
|
* @connection: the #NMRemoteConnection
|
|
|
|
|
* @result: the result passed to the #GAsyncReadyCallback
|
|
|
|
|
* @error: location for a #GError, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Gets the result of a call to nm_remote_connection_save_async().
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE on success, %FALSE on error, in which case @error will be set.
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_remote_connection_save_finish (NMRemoteConnection *connection,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
GSimpleAsyncResult *simple;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (connection), nm_remote_connection_save_async), FALSE);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
simple = G_SIMPLE_ASYNC_RESULT (result);
|
|
|
|
|
if (g_simple_async_result_propagate_error (simple, error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
else
|
|
|
|
|
return g_simple_async_result_get_op_res_gboolean (simple);
|
2014-09-10 13:51:53 -04:00
|
|
|
}
|
|
|
|
|
|
libnm: add nm_remote_connection_update2()
- only add an async version. I think sync requests are fundamentally flawed
because they mess up the order of D-Bus messages. Hence, also don't
call the function *_async(), like we do for other functions. As there
is only the async form, it doesn't have a suffix.
- Don't accept a NMConnection as @settings argument, but a GVariant.
In general, keep the libnm API closer to the D-Bus API and don't hide
the underlying function with a less powerful form. The user still can
conveniently call the function with
nm_remote_connection_update2 (connection,
nm_connection_to_dbus (NM_CONNECTION (connection),
NM_CONNECTION_SERIALIZE_ALL),
save_to_disk
? NM_SETTINGS_UPDATE2_FLAG_TO_DISK
: NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY,
NULL,
cancellable,
callback,
user_data);
I believe the parts of libnm that invoke D-Bus methods, should be
close to the D-Bus API. Not like nm_remote_connection_commit_changes()
which has no corresponding D-Bus method.
2017-11-30 12:11:18 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
/**
|
|
|
|
|
* nm_remote_connection_delete:
|
|
|
|
|
* @connection: the #NMRemoteConnection
|
|
|
|
|
* @cancellable: a #GCancellable, or %NULL
|
|
|
|
|
* @error: location for a #GError, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Deletes the connection.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE on success, %FALSE on error, in which case @error will be set.
|
libnm: deprecate synchronous/blocking API in libnm
Note that D-Bus is fundamentally asynchronous. Doing blocking calls
on top of D-Bus is odd, especially for libnm's NMClient. That is because
NMClient essentially is a client-side cache of the objects from the D-Bus
interface. This cache should be filled exclusively by (asynchronous) D-Bus
events (PropertiesChanged). So, making a blocking D-Bus call means to wait
for a response and return it, while queuing all messages that are received
in the meantime.
Basically there are three ways how a synchronous API on NMClient could behave:
1) the call just calls g_dbus_connection_call_sync(). This means
that libnm sends a D-Bus request via GDBusConnection, and blockingly
waits for the response. All D-Bus messages that get received in the
meantime are queued in the GMainContext that belongs to NMClient.
That means, none of these D-Bus events are processed until we
iterate the GMainContext after the call returns. The effect is,
that NMClient (and all cached objects in there) are unaffected by
the D-Bus request.
Most of the synchronous API calls in libnm are of this kind.
The problem is that the strict ordering of D-Bus events gets
violated.
For some API this is not an immediate problem. Take for example
nm_device_wifi_request_scan(). The call merely blockingly tells
NetworkManager to start scanning, but since NetworkManager's D-Bus
API does not directly expose any state that tells whether we are
currently scanning, this out of order processing of the D-Bus
request is a small issue.
The problem is more obvious for nm_client_networking_set_enabled().
After calling it, NM_CLIENT_NETWORKING_ENABLED is still unaffected
and unchanged, because the PropertiesChanged signal from D-Bus
is not yet processed.
This means, while you make such a blocking call, NMClient's state
does not change. But usually you perform the synchronous call
to change some state. In this form, the blocking call is not useful,
because NMClient only changes the state after iterating the GMainContext,
and not after the blocking call returns.
2) like 1), but after making the blocking g_dbus_connection_call_sync(),
update the NMClient cache artificially. This is what
nm_manager_check_connectivity() does, to "fix" bgo#784629.
This also has the problem of out-of-order events, but it kinda
solves the problem of not changing the state during the blocking
call. But it does so by hacking the state of the cache. I think
this is really wrong because the state should only be updated from
the ordered stream of D-Bus messages (PropertiesChanged signal and
similar). When libnm decides to modify the state, there may be already
D-Bus messages queued that affect this very state.
3) instead of calling g_dbus_connection_call_sync(), use the
asynchronous g_dbus_connection_call(). If we would use a sepaate
GMainContext for all D-Bus related calls, we could ensure that
while we block for the response, we iterate that internal main context.
This might be nice, because all events are processed in order and
after the blocking call returns, the NMClient state is up to date.
The are problems however: current blocking API does not do this,
so it's a significant change in behavior. Also, it might be
unexpected to the user that during the blocking call the entire
content of NMClient's cache might change and all pointers to the
cache might be invalidated. Also, of course NMClient would invoke
signals for all the changes that happen.
Another problem is that this would be more effort to implement
and it involves a small performance overhead for all D-Bus related
calls (because we have to serialize all events in an internal
GMainContext first and then invoke them on the caller's context).
Also, if the users wants this behavior, they could implement it themself
by running libnm in their own GMainContext. Note that libnm might
have bugs to make that really working, but that should be fixed
instead of adding such synchrnous API behavior.
Read also [1], for why blocking calls are wrong.
[1] https://smcv.pseudorandom.co.uk/2008/11/nonblocking/
So, all possible behaviors for synchronous API have severe behavioural
issues. Mark all this API as deprecated. Also, this serves the purpose of
identifying blocking D-Bus calls in libnm.
Note that "deprecated" here does not really mean that the API is going
to be removed. We don't break API. The user may:
- continue to use this API. It's deprecated, awkward and discouraged,
but if it works, by all means use it.
- use asynchronous API. That's the only sensible way to use D-Bus.
If libnm lacks a certain asynchronous counterpart, it should be
added.
- use GDBusConnection directly. There really isn't anything wrong
with D-Bus or GDBusConnection. This deprecated API is just a wrapper
around g_dbus_connection_call_sync(). You may call it directly
without feeling dirty.
---
The only other remainging API is the synchronous GInitable call for
NMClient. That is an entirely separate beast and not particularly
wrong (from an API point of view).
Note that synchronous API in NMSecretAgentOld, NMVpnPluginOld and
NMVpnServicePlugin as not deprecated here. These types are not part
of the D-Bus cache and while they have similar issues, it's less severe
because they have less state.
2019-09-04 13:58:43 +02:00
|
|
|
*
|
|
|
|
|
* Deprecated: 1.22, use nm_remote_connection_delete_async() or GDBusConnection
|
2014-09-11 16:27:13 -04:00
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_remote_connection_delete (NMRemoteConnection *connection,
|
|
|
|
|
GCancellable *cancellable,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteConnectionPrivate *priv;
|
2014-10-15 18:26:32 -04:00
|
|
|
gboolean ret;
|
2014-09-11 16:27:13 -04:00
|
|
|
|
2014-09-25 17:38:07 +02:00
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_CONNECTION (connection), FALSE);
|
2014-09-11 16:27:13 -04:00
|
|
|
|
|
|
|
|
priv = NM_REMOTE_CONNECTION_GET_PRIVATE (connection);
|
|
|
|
|
|
2014-10-15 18:26:32 -04:00
|
|
|
ret = nmdbus_settings_connection_call_delete_sync (priv->proxy, cancellable, error);
|
|
|
|
|
if (error && *error)
|
|
|
|
|
g_dbus_error_strip_remote_error (*error);
|
|
|
|
|
return ret;
|
2014-09-11 16:27:13 -04:00
|
|
|
}
|
|
|
|
|
|
2014-09-10 13:51:53 -04:00
|
|
|
static void
|
2014-09-11 16:27:13 -04:00
|
|
|
delete_cb (GObject *proxy, GAsyncResult *result, gpointer user_data)
|
2014-09-10 13:51:53 -04:00
|
|
|
{
|
2014-09-11 16:27:13 -04:00
|
|
|
GSimpleAsyncResult *simple = user_data;
|
2014-09-10 13:51:53 -04:00
|
|
|
GError *error = NULL;
|
|
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
if (nmdbus_settings_connection_call_delete_finish (NMDBUS_SETTINGS_CONNECTION (proxy),
|
|
|
|
|
result, &error))
|
|
|
|
|
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
|
2014-10-15 18:26:32 -04:00
|
|
|
else {
|
|
|
|
|
g_dbus_error_strip_remote_error (error);
|
2014-09-11 16:27:13 -04:00
|
|
|
g_simple_async_result_take_error (simple, error);
|
2014-10-15 18:26:32 -04:00
|
|
|
}
|
2014-09-11 16:27:13 -04:00
|
|
|
g_simple_async_result_complete (simple);
|
|
|
|
|
g_object_unref (simple);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-09-11 16:27:13 -04:00
|
|
|
* nm_remote_connection_delete_async:
|
2014-07-24 08:53:33 -04:00
|
|
|
* @connection: the #NMRemoteConnection
|
2014-09-11 16:27:13 -04:00
|
|
|
* @cancellable: a #GCancellable, or %NULL
|
|
|
|
|
* @callback: callback to be called when the delete operation completes
|
|
|
|
|
* @user_data: caller-specific data passed to @callback
|
2014-07-24 08:53:33 -04:00
|
|
|
*
|
2014-09-11 16:27:13 -04:00
|
|
|
* Asynchronously deletes the connection.
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
|
|
|
|
void
|
2014-09-11 16:27:13 -04:00
|
|
|
nm_remote_connection_delete_async (NMRemoteConnection *connection,
|
|
|
|
|
GCancellable *cancellable,
|
|
|
|
|
GAsyncReadyCallback callback,
|
|
|
|
|
gpointer user_data)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
|
|
|
|
NMRemoteConnectionPrivate *priv;
|
2014-09-11 16:27:13 -04:00
|
|
|
GSimpleAsyncResult *simple;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
g_return_if_fail (NM_IS_REMOTE_CONNECTION (connection));
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
priv = NM_REMOTE_CONNECTION_GET_PRIVATE (connection);
|
|
|
|
|
|
|
|
|
|
simple = g_simple_async_result_new (G_OBJECT (connection), callback, user_data,
|
|
|
|
|
nm_remote_connection_delete_async);
|
2018-03-05 16:02:24 +01:00
|
|
|
if (cancellable)
|
|
|
|
|
g_simple_async_result_set_check_cancellable (simple, cancellable);
|
2014-09-11 16:27:13 -04:00
|
|
|
nmdbus_settings_connection_call_delete (priv->proxy, cancellable, delete_cb, simple);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_remote_connection_delete_finish:
|
|
|
|
|
* @connection: the #NMRemoteConnection
|
|
|
|
|
* @result: the result passed to the #GAsyncReadyCallback
|
|
|
|
|
* @error: location for a #GError, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Gets the result of a call to nm_remote_connection_delete_async().
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE on success, %FALSE on error, in which case @error will be set.
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_remote_connection_delete_finish (NMRemoteConnection *connection,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
GSimpleAsyncResult *simple;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (connection), nm_remote_connection_delete_async), FALSE);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
simple = G_SIMPLE_ASYNC_RESULT (result);
|
|
|
|
|
if (g_simple_async_result_propagate_error (simple, error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
else
|
|
|
|
|
return g_simple_async_result_get_op_res_gboolean (simple);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
/**
|
|
|
|
|
* nm_remote_connection_get_secrets:
|
|
|
|
|
* @connection: the #NMRemoteConnection
|
|
|
|
|
* @setting_name: the #NMSetting object name to get secrets for
|
|
|
|
|
* @cancellable: a #GCancellable, or %NULL
|
|
|
|
|
* @error: location for a #GError, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Request the connection's secrets. Note that this is a blocking D-Bus call,
|
|
|
|
|
* not a simple property accessor.
|
|
|
|
|
*
|
|
|
|
|
* Returns: a #GVariant of type %NM_VARIANT_TYPE_CONNECTION containing
|
|
|
|
|
* @connection's secrets, or %NULL on error.
|
libnm: deprecate synchronous/blocking API in libnm
Note that D-Bus is fundamentally asynchronous. Doing blocking calls
on top of D-Bus is odd, especially for libnm's NMClient. That is because
NMClient essentially is a client-side cache of the objects from the D-Bus
interface. This cache should be filled exclusively by (asynchronous) D-Bus
events (PropertiesChanged). So, making a blocking D-Bus call means to wait
for a response and return it, while queuing all messages that are received
in the meantime.
Basically there are three ways how a synchronous API on NMClient could behave:
1) the call just calls g_dbus_connection_call_sync(). This means
that libnm sends a D-Bus request via GDBusConnection, and blockingly
waits for the response. All D-Bus messages that get received in the
meantime are queued in the GMainContext that belongs to NMClient.
That means, none of these D-Bus events are processed until we
iterate the GMainContext after the call returns. The effect is,
that NMClient (and all cached objects in there) are unaffected by
the D-Bus request.
Most of the synchronous API calls in libnm are of this kind.
The problem is that the strict ordering of D-Bus events gets
violated.
For some API this is not an immediate problem. Take for example
nm_device_wifi_request_scan(). The call merely blockingly tells
NetworkManager to start scanning, but since NetworkManager's D-Bus
API does not directly expose any state that tells whether we are
currently scanning, this out of order processing of the D-Bus
request is a small issue.
The problem is more obvious for nm_client_networking_set_enabled().
After calling it, NM_CLIENT_NETWORKING_ENABLED is still unaffected
and unchanged, because the PropertiesChanged signal from D-Bus
is not yet processed.
This means, while you make such a blocking call, NMClient's state
does not change. But usually you perform the synchronous call
to change some state. In this form, the blocking call is not useful,
because NMClient only changes the state after iterating the GMainContext,
and not after the blocking call returns.
2) like 1), but after making the blocking g_dbus_connection_call_sync(),
update the NMClient cache artificially. This is what
nm_manager_check_connectivity() does, to "fix" bgo#784629.
This also has the problem of out-of-order events, but it kinda
solves the problem of not changing the state during the blocking
call. But it does so by hacking the state of the cache. I think
this is really wrong because the state should only be updated from
the ordered stream of D-Bus messages (PropertiesChanged signal and
similar). When libnm decides to modify the state, there may be already
D-Bus messages queued that affect this very state.
3) instead of calling g_dbus_connection_call_sync(), use the
asynchronous g_dbus_connection_call(). If we would use a sepaate
GMainContext for all D-Bus related calls, we could ensure that
while we block for the response, we iterate that internal main context.
This might be nice, because all events are processed in order and
after the blocking call returns, the NMClient state is up to date.
The are problems however: current blocking API does not do this,
so it's a significant change in behavior. Also, it might be
unexpected to the user that during the blocking call the entire
content of NMClient's cache might change and all pointers to the
cache might be invalidated. Also, of course NMClient would invoke
signals for all the changes that happen.
Another problem is that this would be more effort to implement
and it involves a small performance overhead for all D-Bus related
calls (because we have to serialize all events in an internal
GMainContext first and then invoke them on the caller's context).
Also, if the users wants this behavior, they could implement it themself
by running libnm in their own GMainContext. Note that libnm might
have bugs to make that really working, but that should be fixed
instead of adding such synchrnous API behavior.
Read also [1], for why blocking calls are wrong.
[1] https://smcv.pseudorandom.co.uk/2008/11/nonblocking/
So, all possible behaviors for synchronous API have severe behavioural
issues. Mark all this API as deprecated. Also, this serves the purpose of
identifying blocking D-Bus calls in libnm.
Note that "deprecated" here does not really mean that the API is going
to be removed. We don't break API. The user may:
- continue to use this API. It's deprecated, awkward and discouraged,
but if it works, by all means use it.
- use asynchronous API. That's the only sensible way to use D-Bus.
If libnm lacks a certain asynchronous counterpart, it should be
added.
- use GDBusConnection directly. There really isn't anything wrong
with D-Bus or GDBusConnection. This deprecated API is just a wrapper
around g_dbus_connection_call_sync(). You may call it directly
without feeling dirty.
---
The only other remainging API is the synchronous GInitable call for
NMClient. That is an entirely separate beast and not particularly
wrong (from an API point of view).
Note that synchronous API in NMSecretAgentOld, NMVpnPluginOld and
NMVpnServicePlugin as not deprecated here. These types are not part
of the D-Bus cache and while they have similar issues, it's less severe
because they have less state.
2019-09-04 13:58:43 +02:00
|
|
|
*
|
|
|
|
|
* Deprecated: 1.22, use nm_remote_connection_get_secrets_async() or GDBusConnection
|
2014-09-11 16:27:13 -04:00
|
|
|
**/
|
|
|
|
|
GVariant *
|
|
|
|
|
nm_remote_connection_get_secrets (NMRemoteConnection *connection,
|
|
|
|
|
const char *setting_name,
|
|
|
|
|
GCancellable *cancellable,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteConnectionPrivate *priv;
|
|
|
|
|
GVariant *secrets;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_CONNECTION (connection), NULL);
|
|
|
|
|
|
|
|
|
|
priv = NM_REMOTE_CONNECTION_GET_PRIVATE (connection);
|
|
|
|
|
|
|
|
|
|
if (nmdbus_settings_connection_call_get_secrets_sync (priv->proxy,
|
|
|
|
|
setting_name,
|
|
|
|
|
&secrets,
|
|
|
|
|
cancellable, error))
|
|
|
|
|
return secrets;
|
2014-10-15 18:26:32 -04:00
|
|
|
else {
|
|
|
|
|
if (error && *error)
|
|
|
|
|
g_dbus_error_strip_remote_error (*error);
|
2014-09-11 16:27:13 -04:00
|
|
|
return NULL;
|
2014-10-15 18:26:32 -04:00
|
|
|
}
|
2014-09-11 16:27:13 -04:00
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
static void
|
2014-09-11 16:27:13 -04:00
|
|
|
get_secrets_cb (GObject *proxy, GAsyncResult *result, gpointer user_data)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
2014-09-11 16:27:13 -04:00
|
|
|
GSimpleAsyncResult *simple = user_data;
|
2014-09-10 13:51:53 -04:00
|
|
|
GVariant *secrets = NULL;
|
|
|
|
|
GError *error = NULL;
|
2014-08-16 10:09:48 -04:00
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
if (nmdbus_settings_connection_call_get_secrets_finish (NMDBUS_SETTINGS_CONNECTION (proxy),
|
|
|
|
|
&secrets, result, &error))
|
|
|
|
|
g_simple_async_result_set_op_res_gpointer (simple, secrets, (GDestroyNotify) g_variant_unref);
|
2014-10-15 18:26:32 -04:00
|
|
|
else {
|
|
|
|
|
g_dbus_error_strip_remote_error (error);
|
2014-09-11 16:27:13 -04:00
|
|
|
g_simple_async_result_take_error (simple, error);
|
2014-10-15 18:26:32 -04:00
|
|
|
}
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
g_simple_async_result_complete (simple);
|
|
|
|
|
g_object_unref (simple);
|
|
|
|
|
}
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/**
|
2014-09-11 16:27:13 -04:00
|
|
|
* nm_remote_connection_get_secrets_async:
|
2014-07-24 08:53:33 -04:00
|
|
|
* @connection: the #NMRemoteConnection
|
|
|
|
|
* @setting_name: the #NMSetting object name to get secrets for
|
2014-09-11 16:27:13 -04:00
|
|
|
* @cancellable: a #GCancellable, or %NULL
|
|
|
|
|
* @callback: callback to be called when the secret request completes
|
|
|
|
|
* @user_data: caller-specific data passed to @callback
|
2014-07-24 08:53:33 -04:00
|
|
|
*
|
2014-09-11 16:27:13 -04:00
|
|
|
* Asynchronously requests the connection's secrets.
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
|
|
|
|
void
|
2014-09-11 16:27:13 -04:00
|
|
|
nm_remote_connection_get_secrets_async (NMRemoteConnection *connection,
|
|
|
|
|
const char *setting_name,
|
|
|
|
|
GCancellable *cancellable,
|
|
|
|
|
GAsyncReadyCallback callback,
|
|
|
|
|
gpointer user_data)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
|
|
|
|
NMRemoteConnectionPrivate *priv;
|
2014-09-11 16:27:13 -04:00
|
|
|
GSimpleAsyncResult *simple;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
g_return_if_fail (NM_IS_REMOTE_CONNECTION (connection));
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
priv = NM_REMOTE_CONNECTION_GET_PRIVATE (connection);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-09-11 16:27:13 -04:00
|
|
|
simple = g_simple_async_result_new (G_OBJECT (connection), callback, user_data,
|
|
|
|
|
nm_remote_connection_get_secrets_async);
|
2018-03-05 16:02:24 +01:00
|
|
|
if (cancellable)
|
|
|
|
|
g_simple_async_result_set_check_cancellable (simple, cancellable);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-09-10 13:51:53 -04:00
|
|
|
nmdbus_settings_connection_call_get_secrets (priv->proxy,
|
|
|
|
|
setting_name,
|
2014-09-11 16:27:13 -04:00
|
|
|
cancellable,
|
|
|
|
|
get_secrets_cb, simple);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_remote_connection_get_secrets_finish:
|
|
|
|
|
* @connection: the #NMRemoteConnection
|
|
|
|
|
* @result: the result passed to the #GAsyncReadyCallback
|
|
|
|
|
* @error: location for a #GError, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Gets the result of a call to nm_remote_connection_get_secrets_async().
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): a #GVariant of type %NM_VARIANT_TYPE_CONNECTION
|
|
|
|
|
* containing @connection's secrets, or %NULL on error.
|
|
|
|
|
**/
|
|
|
|
|
GVariant *
|
|
|
|
|
nm_remote_connection_get_secrets_finish (NMRemoteConnection *connection,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
GSimpleAsyncResult *simple;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (connection), nm_remote_connection_get_secrets_async), FALSE);
|
|
|
|
|
|
|
|
|
|
simple = G_SIMPLE_ASYNC_RESULT (result);
|
|
|
|
|
if (g_simple_async_result_propagate_error (simple, error))
|
|
|
|
|
return NULL;
|
|
|
|
|
else
|
|
|
|
|
return g_variant_ref (g_simple_async_result_get_op_res_gpointer (simple));
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_remote_connection_get_unsaved:
|
|
|
|
|
* @connection: the #NMRemoteConnection
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the remote connection contains changes that have not
|
|
|
|
|
* been saved to disk, %FALSE if the connection is the same as its on-disk
|
|
|
|
|
* representation.
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_remote_connection_get_unsaved (NMRemoteConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_CONNECTION (connection), FALSE);
|
|
|
|
|
|
|
|
|
|
return NM_REMOTE_CONNECTION_GET_PRIVATE (connection)->unsaved;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-05 20:06:03 +02:00
|
|
|
/**
|
|
|
|
|
* nm_remote_connection_get_flags:
|
|
|
|
|
* @connection: the #NMRemoteConnection
|
|
|
|
|
*
|
|
|
|
|
* Returns: the flags of the connection of type #NMSettingsConnectionFlags.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
NMSettingsConnectionFlags
|
|
|
|
|
nm_remote_connection_get_flags (NMRemoteConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_CONNECTION (connection), FALSE);
|
|
|
|
|
|
|
|
|
|
return (NMSettingsConnectionFlags) NM_REMOTE_CONNECTION_GET_PRIVATE (connection)->flags;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-28 09:23:58 +02:00
|
|
|
/**
|
|
|
|
|
* nm_remote_connection_get_filename:
|
|
|
|
|
* @connection: the #NMRemoteConnection
|
|
|
|
|
*
|
|
|
|
|
* Returns: file that stores the connection in case the connection is file-backed.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_remote_connection_get_filename (NMRemoteConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_CONNECTION (connection), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_REMOTE_CONNECTION_GET_PRIVATE (connection)->filename;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-20 12:42:59 -04:00
|
|
|
/**
|
|
|
|
|
* nm_remote_connection_get_visible:
|
|
|
|
|
* @connection: the #NMRemoteConnection
|
|
|
|
|
*
|
|
|
|
|
* Checks if the connection is visible to the current user. If the
|
|
|
|
|
* connection is not visible then it is essentially useless; it will
|
|
|
|
|
* not contain any settings, and operations such as
|
|
|
|
|
* nm_remote_connection_save() and nm_remote_connection_delete() will
|
|
|
|
|
* always fail. (#NMRemoteSettings will not normally return
|
|
|
|
|
* non-visible connections to callers, but it is possible for a
|
|
|
|
|
* connection's visibility to change after you already have a
|
|
|
|
|
* reference to it.)
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the remote connection is visible to the current
|
|
|
|
|
* user, %FALSE if not.
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_remote_connection_get_visible (NMRemoteConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_CONNECTION (connection), FALSE);
|
|
|
|
|
|
|
|
|
|
return NM_REMOTE_CONNECTION_GET_PRIVATE (connection)->visible;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
static void
|
2014-09-10 13:51:53 -04:00
|
|
|
replace_settings (NMRemoteConnection *self, GVariant *new_settings)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
2016-03-23 16:18:25 +01:00
|
|
|
if (!_nm_connection_replace_settings ((NMConnection *) self,
|
|
|
|
|
new_settings,
|
|
|
|
|
NM_SETTING_PARSE_FLAGS_BEST_EFFORT,
|
|
|
|
|
&error))
|
2014-07-24 08:53:33 -04:00
|
|
|
g_clear_error (&error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2014-09-10 13:51:53 -04:00
|
|
|
updated_get_settings_cb (GObject *proxy,
|
|
|
|
|
GAsyncResult *result,
|
2014-07-24 08:53:33 -04:00
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteConnection *self = user_data;
|
|
|
|
|
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
|
2014-09-10 13:51:53 -04:00
|
|
|
GVariant *new_settings;
|
2014-07-20 12:42:59 -04:00
|
|
|
gboolean visible;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-09-10 13:51:53 -04:00
|
|
|
if (!nmdbus_settings_connection_call_get_settings_finish (priv->proxy, &new_settings,
|
|
|
|
|
result, NULL)) {
|
2014-07-20 12:55:59 -04:00
|
|
|
/* Connection is no longer visible to this user. */
|
2014-08-22 10:14:38 -04:00
|
|
|
nm_connection_clear_settings (NM_CONNECTION (self));
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-07-20 12:42:59 -04:00
|
|
|
visible = FALSE;
|
2014-07-24 08:53:33 -04:00
|
|
|
} else {
|
|
|
|
|
replace_settings (self, new_settings);
|
2014-09-10 13:51:53 -04:00
|
|
|
g_variant_unref (new_settings);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-07-20 12:42:59 -04:00
|
|
|
visible = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (visible != priv->visible) {
|
|
|
|
|
priv->visible = visible;
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_REMOTE_CONNECTION_VISIBLE);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
nm-remote-connection: take a reference to self while calling get_settings
(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)
2015-04-10 16:19:50 +02:00
|
|
|
|
|
|
|
|
g_object_unref (self);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2014-09-10 13:51:53 -04:00
|
|
|
updated_cb (NMDBusSettingsConnection *proxy, gpointer user_data)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
|
|
|
|
NMRemoteConnection *self = NM_REMOTE_CONNECTION (user_data);
|
|
|
|
|
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
/* The connection got updated; request the replacement settings */
|
2014-09-10 13:51:53 -04:00
|
|
|
nmdbus_settings_connection_call_get_settings (priv->proxy,
|
|
|
|
|
NULL,
|
nm-remote-connection: take a reference to self while calling get_settings
(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)
2015-04-10 16:19:50 +02:00
|
|
|
updated_get_settings_cb,
|
|
|
|
|
g_object_ref (self));
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
static void
|
2014-08-13 15:00:41 -04:00
|
|
|
init_dbus (NMObject *object)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
2014-08-13 15:00:41 -04:00
|
|
|
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (object);
|
|
|
|
|
const NMPropertiesInfo property_info[] = {
|
|
|
|
|
{ NM_REMOTE_CONNECTION_UNSAVED, &priv->unsaved },
|
2018-04-05 20:06:03 +02:00
|
|
|
{ NM_REMOTE_CONNECTION_FLAGS, &priv->flags },
|
2018-05-28 09:23:58 +02:00
|
|
|
{ NM_REMOTE_CONNECTION_FILENAME, &priv->filename },
|
2014-08-13 15:00:41 -04:00
|
|
|
{ NULL },
|
|
|
|
|
};
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-08-13 15:00:41 -04:00
|
|
|
NM_OBJECT_CLASS (nm_remote_connection_parent_class)->init_dbus (object);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-08-13 15:00:41 -04:00
|
|
|
_nm_object_register_properties (object,
|
2014-08-18 14:17:52 -04:00
|
|
|
NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
|
2014-08-13 15:00:41 -04:00
|
|
|
property_info);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
|
|
|
|
|
{
|
2014-05-15 14:25:07 -04:00
|
|
|
NMRemoteConnection *self = NM_REMOTE_CONNECTION (initable);
|
2014-07-24 08:53:33 -04:00
|
|
|
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (initable);
|
2014-09-10 13:51:53 -04:00
|
|
|
GVariant *settings;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2016-10-18 16:35:07 +02:00
|
|
|
priv->proxy = NMDBUS_SETTINGS_CONNECTION (_nm_object_get_proxy (NM_OBJECT (initable), NM_DBUS_INTERFACE_SETTINGS_CONNECTION));
|
2017-09-22 11:48:05 +01:00
|
|
|
g_signal_connect_object (priv->proxy, "updated", G_CALLBACK (updated_cb), initable, 0);
|
2014-05-15 14:25:07 -04:00
|
|
|
|
2016-10-18 16:35:07 +02:00
|
|
|
if (nmdbus_settings_connection_call_get_settings_sync (priv->proxy,
|
|
|
|
|
&settings,
|
|
|
|
|
cancellable,
|
|
|
|
|
NULL)) {
|
|
|
|
|
priv->visible = TRUE;
|
|
|
|
|
replace_settings (self, settings);
|
|
|
|
|
g_variant_unref (settings);
|
2014-10-15 18:26:32 -04:00
|
|
|
}
|
2014-09-10 13:51:53 -04:00
|
|
|
|
2016-10-18 16:35:07 +02:00
|
|
|
if (!nm_remote_connection_parent_initable_iface->init (initable, cancellable, error))
|
|
|
|
|
return FALSE;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
NMRemoteConnection *connection;
|
2014-09-10 13:51:53 -04:00
|
|
|
GCancellable *cancellable;
|
2014-07-24 08:53:33 -04:00
|
|
|
GSimpleAsyncResult *result;
|
2016-10-18 16:35:07 +02:00
|
|
|
GAsyncInitable *initable;
|
|
|
|
|
int io_priority;
|
2014-07-24 08:53:33 -04:00
|
|
|
} NMRemoteConnectionInitData;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
init_async_complete (NMRemoteConnectionInitData *init_data, GError *error)
|
|
|
|
|
{
|
|
|
|
|
if (error)
|
|
|
|
|
g_simple_async_result_take_error (init_data->result, error);
|
2014-05-15 14:25:07 -04:00
|
|
|
else
|
2014-07-24 08:53:33 -04:00
|
|
|
g_simple_async_result_set_op_res_gboolean (init_data->result, TRUE);
|
|
|
|
|
|
|
|
|
|
g_simple_async_result_complete (init_data->result);
|
|
|
|
|
g_object_unref (init_data->result);
|
2014-09-10 13:51:53 -04:00
|
|
|
g_clear_object (&init_data->cancellable);
|
2014-07-24 08:53:33 -04:00
|
|
|
g_slice_free (NMRemoteConnectionInitData, init_data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2016-10-18 16:35:07 +02:00
|
|
|
init_async_parent_inited (GObject *source, GAsyncResult *result, gpointer user_data)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
|
|
|
|
NMRemoteConnectionInitData *init_data = user_data;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
2016-10-18 16:35:07 +02:00
|
|
|
init_async_complete (init_data, error);
|
2014-08-13 15:00:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2016-10-18 16:35:07 +02:00
|
|
|
init_get_settings_cb (GObject *proxy,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
gpointer user_data)
|
2014-08-13 15:00:41 -04:00
|
|
|
{
|
|
|
|
|
NMRemoteConnectionInitData *init_data = user_data;
|
2016-10-18 16:35:07 +02:00
|
|
|
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (init_data->initable);
|
|
|
|
|
GVariant *settings;
|
2014-08-13 15:00:41 -04:00
|
|
|
GError *error = NULL;
|
|
|
|
|
|
2016-10-18 16:35:07 +02:00
|
|
|
if (!nmdbus_settings_connection_call_get_settings_finish (priv->proxy, &settings,
|
|
|
|
|
result, &error)) {
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
} else {
|
|
|
|
|
priv->visible = TRUE;
|
|
|
|
|
replace_settings (NM_REMOTE_CONNECTION (init_data->initable), settings);
|
|
|
|
|
g_variant_unref (settings);
|
2014-08-13 15:00:41 -04:00
|
|
|
}
|
|
|
|
|
|
2016-10-18 16:35:07 +02:00
|
|
|
nm_remote_connection_parent_async_initable_iface->
|
|
|
|
|
init_async (init_data->initable, init_data->io_priority, init_data->cancellable, init_async_parent_inited, init_data);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
init_async (GAsyncInitable *initable, int io_priority,
|
|
|
|
|
GCancellable *cancellable, GAsyncReadyCallback callback,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteConnectionInitData *init_data;
|
2016-10-18 16:35:07 +02:00
|
|
|
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (initable);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
init_data = g_slice_new0 (NMRemoteConnectionInitData);
|
2014-09-10 13:51:53 -04:00
|
|
|
init_data->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
|
2014-07-24 08:53:33 -04:00
|
|
|
init_data->result = g_simple_async_result_new (G_OBJECT (initable), callback,
|
|
|
|
|
user_data, init_async);
|
2018-03-05 16:02:24 +01:00
|
|
|
if (cancellable)
|
|
|
|
|
g_simple_async_result_set_check_cancellable (init_data->result, cancellable);
|
2016-10-18 16:35:07 +02:00
|
|
|
init_data->initable = initable;
|
|
|
|
|
init_data->io_priority = io_priority;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2016-10-18 16:35:07 +02:00
|
|
|
priv->proxy = NMDBUS_SETTINGS_CONNECTION (_nm_object_get_proxy (NM_OBJECT (initable),
|
|
|
|
|
NM_DBUS_INTERFACE_SETTINGS_CONNECTION));
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2017-09-22 11:48:05 +01:00
|
|
|
g_signal_connect_object (priv->proxy, "updated",
|
|
|
|
|
G_CALLBACK (updated_cb), initable, 0);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2016-10-18 16:35:07 +02:00
|
|
|
nmdbus_settings_connection_call_get_settings (NM_REMOTE_CONNECTION_GET_PRIVATE (init_data->initable)->proxy,
|
|
|
|
|
init_data->cancellable,
|
|
|
|
|
init_get_settings_cb, init_data);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_remote_connection_init (NMRemoteConnection *self)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_property (GObject *object, guint prop_id,
|
|
|
|
|
GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_UNSAVED:
|
|
|
|
|
g_value_set_boolean (value, NM_REMOTE_CONNECTION_GET_PRIVATE (object)->unsaved);
|
|
|
|
|
break;
|
2018-04-05 20:06:03 +02:00
|
|
|
case PROP_FLAGS:
|
2018-11-15 18:15:28 +01:00
|
|
|
g_value_set_uint (value, NM_REMOTE_CONNECTION_GET_PRIVATE (object)->flags);
|
2018-04-05 20:06:03 +02:00
|
|
|
break;
|
2018-05-28 09:23:58 +02:00
|
|
|
case PROP_FILENAME:
|
|
|
|
|
g_value_set_string (value, NM_REMOTE_CONNECTION_GET_PRIVATE (object)->filename);
|
|
|
|
|
break;
|
2014-07-20 12:42:59 -04:00
|
|
|
case PROP_VISIBLE:
|
|
|
|
|
g_value_set_boolean (value, NM_REMOTE_CONNECTION_GET_PRIVATE (object)->visible);
|
|
|
|
|
break;
|
2014-07-24 08:53:33 -04:00
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2014-08-13 15:00:41 -04:00
|
|
|
constructed (GObject *object)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
2017-03-07 23:47:06 +01:00
|
|
|
G_OBJECT_CLASS (nm_remote_connection_parent_class)->constructed (object);
|
|
|
|
|
|
2014-08-13 15:00:41 -04:00
|
|
|
nm_connection_set_path (NM_CONNECTION (object),
|
|
|
|
|
nm_object_get_path (NM_OBJECT (object)));
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2016-11-14 18:47:56 +01:00
|
|
|
static void
|
|
|
|
|
dispose (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
g_clear_object (&priv->proxy);
|
2018-06-21 16:06:01 +02:00
|
|
|
nm_clear_g_free (&priv->filename);
|
2016-11-14 18:47:56 +01:00
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (nm_remote_connection_parent_class)->dispose (object);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
static void
|
|
|
|
|
nm_remote_connection_class_init (NMRemoteConnectionClass *remote_class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (remote_class);
|
2014-08-13 15:00:41 -04:00
|
|
|
NMObjectClass *nm_object_class = NM_OBJECT_CLASS (remote_class);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
g_type_class_add_private (object_class, sizeof (NMRemoteConnectionPrivate));
|
|
|
|
|
|
|
|
|
|
/* virtual methods */
|
2014-08-13 15:00:41 -04:00
|
|
|
object_class->constructed = constructed;
|
2014-07-24 08:53:33 -04:00
|
|
|
object_class->get_property = get_property;
|
2016-11-14 18:47:56 +01:00
|
|
|
object_class->dispose = dispose;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-08-13 15:00:41 -04:00
|
|
|
nm_object_class->init_dbus = init_dbus;
|
2014-08-13 14:34:29 -04:00
|
|
|
|
2014-08-13 15:00:41 -04:00
|
|
|
/* Properties */
|
2014-07-24 08:53:33 -04:00
|
|
|
/**
|
|
|
|
|
* NMRemoteConnection:unsaved:
|
|
|
|
|
*
|
|
|
|
|
* %TRUE if the remote connection contains changes that have not been saved
|
|
|
|
|
* to disk, %FALSE if the connection is the same as its on-disk representation.
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_UNSAVED,
|
|
|
|
|
g_param_spec_boolean (NM_REMOTE_CONNECTION_UNSAVED, "", "",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
2018-04-05 20:06:03 +02:00
|
|
|
/**
|
|
|
|
|
* NMRemoteConnection:flags:
|
|
|
|
|
*
|
|
|
|
|
* The flags of the connection as unsigned integer. The values
|
|
|
|
|
* correspond to the #NMSettingsConnectionFlags enum.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_FLAGS,
|
|
|
|
|
g_param_spec_uint (NM_REMOTE_CONNECTION_FLAGS, "", "",
|
|
|
|
|
0, G_MAXUINT32, 0,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
2018-05-28 09:23:58 +02:00
|
|
|
/**
|
|
|
|
|
* NMRemoteConnection:filename:
|
|
|
|
|
*
|
|
|
|
|
* File that stores the connection in case the connection is
|
|
|
|
|
* file-backed.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_FILENAME,
|
|
|
|
|
g_param_spec_string (NM_REMOTE_CONNECTION_FILENAME, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
2014-07-20 12:42:59 -04:00
|
|
|
/**
|
|
|
|
|
* NMRemoteConnection:visible:
|
|
|
|
|
*
|
|
|
|
|
* %TRUE if the remote connection is visible to the current user, %FALSE if
|
|
|
|
|
* not. If the connection is not visible then it is essentially useless; it
|
|
|
|
|
* will not contain any settings, and operations such as
|
|
|
|
|
* nm_remote_connection_save() and nm_remote_connection_delete() will always
|
|
|
|
|
* fail. (#NMRemoteSettings will not normally return non-visible connections
|
|
|
|
|
* to callers, but it is possible for a connection's visibility to change
|
|
|
|
|
* after you already have a reference to it.)
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_VISIBLE,
|
|
|
|
|
g_param_spec_boolean (NM_REMOTE_CONNECTION_VISIBLE, "", "",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2014-08-13 14:34:29 -04:00
|
|
|
static void
|
|
|
|
|
nm_remote_connection_connection_iface_init (NMConnectionInterface *iface)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
static void
|
|
|
|
|
nm_remote_connection_initable_iface_init (GInitableIface *iface)
|
|
|
|
|
{
|
2014-08-13 15:00:41 -04:00
|
|
|
nm_remote_connection_parent_initable_iface = g_type_interface_peek_parent (iface);
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
iface->init = init_sync;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_remote_connection_async_initable_iface_init (GAsyncInitableIface *iface)
|
|
|
|
|
{
|
2014-08-13 15:00:41 -04:00
|
|
|
nm_remote_connection_parent_async_initable_iface = g_type_interface_peek_parent (iface);
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
iface->init_async = init_async;
|
|
|
|
|
}
|