|
Packit Service |
87a54e |
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
Packit |
5756e2 |
/*
|
|
Packit |
5756e2 |
* Copyright (C) 2007 - 2008 Novell, Inc.
|
|
Packit |
5756e2 |
* Copyright (C) 2007 - 2011 Red Hat, Inc.
|
|
Packit |
5756e2 |
*/
|
|
Packit |
5756e2 |
|
|
Packit Service |
2bceb2 |
#include "libnm/nm-default-libnm.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "nm-remote-connection.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "nm-glib-aux/nm-dbus-aux.h"
|
|
Packit |
5756e2 |
#include "nm-dbus-interface.h"
|
|
Packit |
5756e2 |
#include "nm-utils.h"
|
|
Packit |
5756e2 |
#include "nm-setting-connection.h"
|
|
Packit |
5756e2 |
#include "nm-core-internal.h"
|
|
Packit |
5756e2 |
#include "nm-remote-connection-private.h"
|
|
Packit |
5756e2 |
#include "nm-object-private.h"
|
|
Packit |
5756e2 |
#include "nm-dbus-helpers.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* SECTION:nm-remote-connection
|
|
Packit |
5756e2 |
* @short_description: A connection managed by NetworkManager server
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* A #NMRemoteConnection represents a connection that is exported via
|
|
Packit |
5756e2 |
* NetworkManager D-Bus interface.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
NM_GOBJECT_PROPERTIES_DEFINE(NMRemoteConnection,
|
|
Packit Service |
a1bd4f |
PROP_UNSAVED,
|
|
Packit Service |
a1bd4f |
PROP_FLAGS,
|
|
Packit Service |
a1bd4f |
PROP_FILENAME,
|
|
Packit Service |
a1bd4f |
PROP_VISIBLE, );
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
typedef struct {
|
|
Packit Service |
a1bd4f |
GCancellable *get_settings_cancellable;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
char * filename;
|
|
Packit Service |
a1bd4f |
guint32 flags;
|
|
Packit Service |
a1bd4f |
bool unsaved;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
bool visible : 1;
|
|
Packit Service |
a1bd4f |
bool is_initialized : 1;
|
|
Packit |
5756e2 |
} NMRemoteConnectionPrivate;
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
struct _NMRemoteConnection {
|
|
Packit Service |
a1bd4f |
NMObject parent;
|
|
Packit Service |
a1bd4f |
NMRemoteConnectionPrivate _priv;
|
|
Packit |
5756e2 |
};
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
struct _NMRemoteConnectionClass {
|
|
Packit Service |
a1bd4f |
NMObjectClass parent_class;
|
|
Packit |
5756e2 |
};
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
static void nm_remote_connection_connection_iface_init(NMConnectionInterface *iface);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
G_DEFINE_TYPE_WITH_CODE(NMRemoteConnection,
|
|
Packit Service |
a1bd4f |
nm_remote_connection,
|
|
Packit Service |
a1bd4f |
NM_TYPE_OBJECT,
|
|
Packit Service |
a1bd4f |
G_IMPLEMENT_INTERFACE(NM_TYPE_CONNECTION,
|
|
Packit Service |
a1bd4f |
nm_remote_connection_connection_iface_init);)
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
#define NM_REMOTE_CONNECTION_GET_PRIVATE(self) \
|
|
Packit Service |
a1bd4f |
_NM_GET_PRIVATE(self, NMRemoteConnection, NM_IS_REMOTE_CONNECTION, NMObject)
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_remote_connection_update2:
|
|
Packit |
5756e2 |
* @connection: the #NMRemoteConnection
|
|
Packit |
5756e2 |
* @settings: (allow-none): optional connection to update the settings.
|
|
Packit |
5756e2 |
* @flags: update-flags
|
|
Packit |
5756e2 |
* @args: (allow-none): optional arguments.
|
|
Packit |
5756e2 |
* @cancellable: a #GCancellable, or %NULL
|
|
Packit |
5756e2 |
* @callback: callback to be called when the commit operation completes
|
|
Packit |
5756e2 |
* @user_data: caller-specific data passed to @callback
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Asynchronously calls the Update2() D-Bus method.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Since: 1.12
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
void
|
|
Packit Service |
a1bd4f |
nm_remote_connection_update2(NMRemoteConnection * connection,
|
|
Packit Service |
a1bd4f |
GVariant * settings,
|
|
Packit Service |
a1bd4f |
NMSettingsUpdate2Flags flags,
|
|
Packit Service |
a1bd4f |
GVariant * args,
|
|
Packit Service |
a1bd4f |
GCancellable * cancellable,
|
|
Packit Service |
a1bd4f |
GAsyncReadyCallback callback,
|
|
Packit Service |
a1bd4f |
gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_if_fail(NM_IS_REMOTE_CONNECTION(connection));
|
|
Packit Service |
a1bd4f |
g_return_if_fail(!settings || g_variant_is_of_type(settings, NM_VARIANT_TYPE_CONNECTION));
|
|
Packit Service |
a1bd4f |
g_return_if_fail(!args || g_variant_is_of_type(args, G_VARIANT_TYPE("a{sv}")));
|
|
Packit Service |
a1bd4f |
g_return_if_fail(!cancellable || G_IS_CANCELLABLE(cancellable));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (!settings)
|
|
Packit Service |
a1bd4f |
settings = g_variant_new_array(G_VARIANT_TYPE("{sa{sv}}"), NULL, 0);
|
|
Packit Service |
a1bd4f |
if (!args)
|
|
Packit Service |
a1bd4f |
args = g_variant_new_array(G_VARIANT_TYPE("{sv}"), NULL, 0);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
_nm_client_dbus_call(_nm_object_get_client(connection),
|
|
Packit Service |
a1bd4f |
connection,
|
|
Packit Service |
a1bd4f |
nm_remote_connection_update2,
|
|
Packit Service |
a1bd4f |
cancellable,
|
|
Packit Service |
a1bd4f |
callback,
|
|
Packit Service |
a1bd4f |
user_data,
|
|
Packit Service |
a1bd4f |
_nm_object_get_path(connection),
|
|
Packit Service |
a1bd4f |
NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
|
|
Packit Service |
a1bd4f |
"Update2",
|
|
Packit Service |
a1bd4f |
g_variant_new("(@a{sa{sv}}u@a{sv})", settings, (guint32) flags, args),
|
|
Packit Service |
a1bd4f |
G_VARIANT_TYPE("(a{sv})"),
|
|
Packit Service |
a1bd4f |
G_DBUS_CALL_FLAGS_NONE,
|
|
Packit Service |
a1bd4f |
NM_DBUS_DEFAULT_TIMEOUT_MSEC,
|
|
Packit Service |
a1bd4f |
nm_dbus_connection_call_finish_variant_strip_dbus_error_cb);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_remote_connection_update2_finish:
|
|
Packit |
5756e2 |
* @connection: the #NMRemoteConnection
|
|
Packit |
5756e2 |
* @result: the result passed to the #GAsyncReadyCallback
|
|
Packit |
5756e2 |
* @error: location for a #GError, or %NULL
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Gets the result of a call to nm_remote_connection_commit_changes_async().
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: (transfer full): on success, a #GVariant of type "a{sv}" with the result. On failure,
|
|
Packit |
5756e2 |
* %NULL.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
GVariant *
|
|
Packit Service |
a1bd4f |
nm_remote_connection_update2_finish(NMRemoteConnection *connection,
|
|
Packit Service |
a1bd4f |
GAsyncResult * result,
|
|
Packit Service |
a1bd4f |
GError ** error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
gs_unref_variant GVariant *ret = NULL;
|
|
Packit Service |
a1bd4f |
GVariant * v_result;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_REMOTE_CONNECTION(connection), NULL);
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(nm_g_task_is_valid(result, connection, nm_remote_connection_update2),
|
|
Packit Service |
a1bd4f |
NULL);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
ret = g_task_propagate_pointer(G_TASK(result), error);
|
|
Packit Service |
a1bd4f |
if (!ret)
|
|
Packit Service |
a1bd4f |
return NULL;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_variant_get(ret, "(@a{sv})", &v_result);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return v_result;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_remote_connection_commit_changes:
|
|
Packit |
5756e2 |
* @connection: the #NMRemoteConnection
|
|
Packit |
5756e2 |
* @save_to_disk: whether to persist the changes to disk
|
|
Packit |
5756e2 |
* @cancellable: a #GCancellable, or %NULL
|
|
Packit |
5756e2 |
* @error: location for a #GError, or %NULL
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Send any local changes to the settings and properties of @connection to
|
|
Packit |
5756e2 |
* NetworkManager. If @save_to_disk is %TRUE, the updated connection will be saved to
|
|
Packit |
5756e2 |
* disk; if %FALSE, then only the in-memory representation will be changed.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: %TRUE on success, %FALSE on error, in which case @error will be set.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Deprecated: 1.22: Use nm_remote_connection_commit_changes_async() or GDBusConnection.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
gboolean
|
|
Packit Service |
a1bd4f |
nm_remote_connection_commit_changes(NMRemoteConnection *connection,
|
|
Packit Service |
a1bd4f |
gboolean save_to_disk,
|
|
Packit Service |
a1bd4f |
GCancellable * cancellable,
|
|
Packit Service |
a1bd4f |
GError ** error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
gs_unref_variant GVariant *ret = NULL;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_REMOTE_CONNECTION(connection), FALSE);
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(!cancellable || G_IS_CANCELLABLE(cancellable), FALSE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
ret = _nm_client_dbus_call_sync(
|
|
Packit Service |
a1bd4f |
_nm_object_get_client(connection),
|
|
Packit Service |
a1bd4f |
cancellable,
|
|
Packit Service |
a1bd4f |
_nm_object_get_path(connection),
|
|
Packit Service |
a1bd4f |
NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
|
|
Packit Service |
a1bd4f |
"Update2",
|
|
Packit Service |
a1bd4f |
g_variant_new("(@a{sa{sv}}u@a{sv})",
|
|
Packit Service |
a1bd4f |
nm_connection_to_dbus(NM_CONNECTION(connection), NM_CONNECTION_SERIALIZE_ALL),
|
|
Packit Service |
a1bd4f |
(guint32)(save_to_disk ? NM_SETTINGS_UPDATE2_FLAG_TO_DISK
|
|
Packit Service |
a1bd4f |
: NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY),
|
|
Packit Service |
a1bd4f |
g_variant_new_array(G_VARIANT_TYPE("{sv}"), NULL, 0)),
|
|
Packit Service |
a1bd4f |
G_VARIANT_TYPE("(a{sv})"),
|
|
Packit Service |
a1bd4f |
G_DBUS_CALL_FLAGS_NONE,
|
|
Packit Service |
a1bd4f |
NM_DBUS_DEFAULT_TIMEOUT_MSEC,
|
|
Packit Service |
a1bd4f |
TRUE,
|
|
Packit Service |
a1bd4f |
error);
|
|
Packit Service |
a1bd4f |
if (!ret)
|
|
Packit Service |
a1bd4f |
return FALSE;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
return TRUE;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_remote_connection_commit_changes_async:
|
|
Packit |
5756e2 |
* @connection: the #NMRemoteConnection
|
|
Packit |
5756e2 |
* @save_to_disk: whether to save the changes to persistent storage
|
|
Packit |
5756e2 |
* @cancellable: a #GCancellable, or %NULL
|
|
Packit |
5756e2 |
* @callback: callback to be called when the commit operation completes
|
|
Packit |
5756e2 |
* @user_data: caller-specific data passed to @callback
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Asynchronously sends any local changes to the settings and properties of
|
|
Packit |
5756e2 |
* @connection to NetworkManager. If @save is %TRUE, the updated connection will
|
|
Packit |
5756e2 |
* be saved to disk; if %FALSE, then only the in-memory representation will be
|
|
Packit |
5756e2 |
* changed.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
void
|
|
Packit Service |
a1bd4f |
nm_remote_connection_commit_changes_async(NMRemoteConnection *connection,
|
|
Packit Service |
a1bd4f |
gboolean save_to_disk,
|
|
Packit Service |
a1bd4f |
GCancellable * cancellable,
|
|
Packit Service |
a1bd4f |
GAsyncReadyCallback callback,
|
|
Packit Service |
a1bd4f |
gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_if_fail(NM_IS_REMOTE_CONNECTION(connection));
|
|
Packit Service |
a1bd4f |
g_return_if_fail(!cancellable || G_IS_CANCELLABLE(cancellable));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nm_remote_connection_update2(
|
|
Packit Service |
a1bd4f |
connection,
|
|
Packit Service |
a1bd4f |
nm_connection_to_dbus(NM_CONNECTION(connection), NM_CONNECTION_SERIALIZE_ALL),
|
|
Packit Service |
a1bd4f |
save_to_disk ? NM_SETTINGS_UPDATE2_FLAG_TO_DISK : NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
cancellable,
|
|
Packit Service |
a1bd4f |
callback,
|
|
Packit Service |
a1bd4f |
user_data);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_remote_connection_commit_changes_finish:
|
|
Packit |
5756e2 |
* @connection: the #NMRemoteConnection
|
|
Packit |
5756e2 |
* @result: the result passed to the #GAsyncReadyCallback
|
|
Packit |
5756e2 |
* @error: location for a #GError, or %NULL
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Gets the result of a call to nm_remote_connection_commit_changes_async().
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: %TRUE on success, %FALSE on error, in which case @error will be set.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
gboolean
|
|
Packit Service |
a1bd4f |
nm_remote_connection_commit_changes_finish(NMRemoteConnection *connection,
|
|
Packit Service |
a1bd4f |
GAsyncResult * result,
|
|
Packit Service |
a1bd4f |
GError ** error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
gs_unref_variant GVariant *v_result = NULL;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
v_result = nm_remote_connection_update2_finish(connection, result, error);
|
|
Packit Service |
a1bd4f |
return !!v_result;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_remote_connection_save:
|
|
Packit |
5756e2 |
* @connection: the #NMRemoteConnection
|
|
Packit |
5756e2 |
* @cancellable: a #GCancellable, or %NULL
|
|
Packit |
5756e2 |
* @error: location for a #GError, or %NULL
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Saves the connection to disk if the connection has changes that have not yet
|
|
Packit |
5756e2 |
* been written to disk, or if the connection has never been saved.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: %TRUE on success, %FALSE on error, in which case @error will be set.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Deprecated: 1.22: Use nm_remote_connection_save_async() or GDBusConnection.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
gboolean
|
|
Packit Service |
a1bd4f |
nm_remote_connection_save(NMRemoteConnection *connection, GCancellable *cancellable, GError **error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_REMOTE_CONNECTION(connection), FALSE);
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(!cancellable || G_IS_CANCELLABLE(cancellable), FALSE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
return _nm_client_dbus_call_sync_void(_nm_object_get_client(connection),
|
|
Packit Service |
a1bd4f |
cancellable,
|
|
Packit Service |
a1bd4f |
_nm_object_get_path(connection),
|
|
Packit Service |
a1bd4f |
NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
|
|
Packit Service |
a1bd4f |
"Save",
|
|
Packit Service |
a1bd4f |
g_variant_new("()"),
|
|
Packit Service |
a1bd4f |
G_DBUS_CALL_FLAGS_NONE,
|
|
Packit Service |
a1bd4f |
NM_DBUS_DEFAULT_TIMEOUT_MSEC,
|
|
Packit Service |
a1bd4f |
TRUE,
|
|
Packit Service |
a1bd4f |
error);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_remote_connection_save_async:
|
|
Packit |
5756e2 |
* @connection: the #NMRemoteConnection
|
|
Packit |
5756e2 |
* @cancellable: a #GCancellable, or %NULL
|
|
Packit |
5756e2 |
* @callback: callback to be called when the save operation completes
|
|
Packit |
5756e2 |
* @user_data: caller-specific data passed to @callback
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Saves the connection to disk if the connection has changes that have not yet
|
|
Packit |
5756e2 |
* been written to disk, or if the connection has never been saved.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
void
|
|
Packit Service |
a1bd4f |
nm_remote_connection_save_async(NMRemoteConnection *connection,
|
|
Packit Service |
a1bd4f |
GCancellable * cancellable,
|
|
Packit Service |
a1bd4f |
GAsyncReadyCallback callback,
|
|
Packit Service |
a1bd4f |
gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_if_fail(NM_IS_REMOTE_CONNECTION(connection));
|
|
Packit Service |
a1bd4f |
g_return_if_fail(!cancellable || G_IS_CANCELLABLE(cancellable));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
_nm_client_dbus_call(_nm_object_get_client(connection),
|
|
Packit Service |
a1bd4f |
connection,
|
|
Packit Service |
a1bd4f |
nm_remote_connection_save_async,
|
|
Packit Service |
a1bd4f |
cancellable,
|
|
Packit Service |
a1bd4f |
callback,
|
|
Packit Service |
a1bd4f |
user_data,
|
|
Packit Service |
a1bd4f |
_nm_object_get_path(connection),
|
|
Packit Service |
a1bd4f |
NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
|
|
Packit Service |
a1bd4f |
"Save",
|
|
Packit Service |
a1bd4f |
g_variant_new("()"),
|
|
Packit Service |
a1bd4f |
G_VARIANT_TYPE("()"),
|
|
Packit Service |
a1bd4f |
G_DBUS_CALL_FLAGS_NONE,
|
|
Packit Service |
a1bd4f |
NM_DBUS_DEFAULT_TIMEOUT_MSEC,
|
|
Packit Service |
a1bd4f |
nm_dbus_connection_call_finish_void_strip_dbus_error_cb);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_remote_connection_save_finish:
|
|
Packit |
5756e2 |
* @connection: the #NMRemoteConnection
|
|
Packit |
5756e2 |
* @result: the result passed to the #GAsyncReadyCallback
|
|
Packit |
5756e2 |
* @error: location for a #GError, or %NULL
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Gets the result of a call to nm_remote_connection_save_async().
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: %TRUE on success, %FALSE on error, in which case @error will be set.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
gboolean
|
|
Packit Service |
a1bd4f |
nm_remote_connection_save_finish(NMRemoteConnection *connection,
|
|
Packit Service |
a1bd4f |
GAsyncResult * result,
|
|
Packit Service |
a1bd4f |
GError ** error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_REMOTE_CONNECTION(connection), FALSE);
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(nm_g_task_is_valid(result, connection, nm_remote_connection_save_async),
|
|
Packit Service |
a1bd4f |
FALSE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return g_task_propagate_boolean(G_TASK(result), error);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_remote_connection_delete:
|
|
Packit |
5756e2 |
* @connection: the #NMRemoteConnection
|
|
Packit |
5756e2 |
* @cancellable: a #GCancellable, or %NULL
|
|
Packit |
5756e2 |
* @error: location for a #GError, or %NULL
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Deletes the connection.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: %TRUE on success, %FALSE on error, in which case @error will be set.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Deprecated: 1.22: Use nm_remote_connection_delete_async() or GDBusConnection.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
gboolean
|
|
Packit Service |
a1bd4f |
nm_remote_connection_delete(NMRemoteConnection *connection,
|
|
Packit Service |
a1bd4f |
GCancellable * cancellable,
|
|
Packit Service |
a1bd4f |
GError ** error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_REMOTE_CONNECTION(connection), FALSE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
return _nm_client_dbus_call_sync_void(_nm_object_get_client(connection),
|
|
Packit Service |
a1bd4f |
cancellable,
|
|
Packit Service |
a1bd4f |
_nm_object_get_path(connection),
|
|
Packit Service |
a1bd4f |
NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
|
|
Packit Service |
a1bd4f |
"Delete",
|
|
Packit Service |
a1bd4f |
g_variant_new("()"),
|
|
Packit Service |
a1bd4f |
G_DBUS_CALL_FLAGS_NONE,
|
|
Packit Service |
a1bd4f |
NM_DBUS_DEFAULT_TIMEOUT_MSEC,
|
|
Packit Service |
a1bd4f |
TRUE,
|
|
Packit Service |
a1bd4f |
error);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_remote_connection_delete_async:
|
|
Packit |
5756e2 |
* @connection: the #NMRemoteConnection
|
|
Packit |
5756e2 |
* @cancellable: a #GCancellable, or %NULL
|
|
Packit |
5756e2 |
* @callback: callback to be called when the delete operation completes
|
|
Packit |
5756e2 |
* @user_data: caller-specific data passed to @callback
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Asynchronously deletes the connection.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
void
|
|
Packit Service |
a1bd4f |
nm_remote_connection_delete_async(NMRemoteConnection *connection,
|
|
Packit Service |
a1bd4f |
GCancellable * cancellable,
|
|
Packit Service |
a1bd4f |
GAsyncReadyCallback callback,
|
|
Packit Service |
a1bd4f |
gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_if_fail(NM_IS_REMOTE_CONNECTION(connection));
|
|
Packit Service |
a1bd4f |
g_return_if_fail(!cancellable || G_IS_CANCELLABLE(cancellable));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
_nm_client_dbus_call(_nm_object_get_client(connection),
|
|
Packit Service |
a1bd4f |
connection,
|
|
Packit Service |
a1bd4f |
nm_remote_connection_delete_async,
|
|
Packit Service |
a1bd4f |
cancellable,
|
|
Packit Service |
a1bd4f |
callback,
|
|
Packit Service |
a1bd4f |
user_data,
|
|
Packit Service |
a1bd4f |
_nm_object_get_path(connection),
|
|
Packit Service |
a1bd4f |
NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
|
|
Packit Service |
a1bd4f |
"Delete",
|
|
Packit Service |
a1bd4f |
g_variant_new("()"),
|
|
Packit Service |
a1bd4f |
G_VARIANT_TYPE("()"),
|
|
Packit Service |
a1bd4f |
G_DBUS_CALL_FLAGS_NONE,
|
|
Packit Service |
a1bd4f |
NM_DBUS_DEFAULT_TIMEOUT_MSEC,
|
|
Packit Service |
a1bd4f |
nm_dbus_connection_call_finish_void_strip_dbus_error_cb);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_remote_connection_delete_finish:
|
|
Packit |
5756e2 |
* @connection: the #NMRemoteConnection
|
|
Packit |
5756e2 |
* @result: the result passed to the #GAsyncReadyCallback
|
|
Packit |
5756e2 |
* @error: location for a #GError, or %NULL
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Gets the result of a call to nm_remote_connection_delete_async().
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: %TRUE on success, %FALSE on error, in which case @error will be set.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
gboolean
|
|
Packit Service |
a1bd4f |
nm_remote_connection_delete_finish(NMRemoteConnection *connection,
|
|
Packit Service |
a1bd4f |
GAsyncResult * result,
|
|
Packit Service |
a1bd4f |
GError ** error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_REMOTE_CONNECTION(connection), FALSE);
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(nm_g_task_is_valid(result, connection, nm_remote_connection_delete_async),
|
|
Packit Service |
a1bd4f |
FALSE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return g_task_propagate_boolean(G_TASK(result), error);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_remote_connection_get_secrets:
|
|
Packit |
5756e2 |
* @connection: the #NMRemoteConnection
|
|
Packit |
5756e2 |
* @setting_name: the #NMSetting object name to get secrets for
|
|
Packit |
5756e2 |
* @cancellable: a #GCancellable, or %NULL
|
|
Packit |
5756e2 |
* @error: location for a #GError, or %NULL
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Request the connection's secrets. Note that this is a blocking D-Bus call,
|
|
Packit |
5756e2 |
* not a simple property accessor.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: (transfer full): a #GVariant of type %NM_VARIANT_TYPE_CONNECTION containing
|
|
Packit |
5756e2 |
* @connection's secrets, or %NULL on error.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Deprecated: 1.22: Use nm_remote_connection_get_secrets_async() or GDBusConnection.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
GVariant *
|
|
Packit Service |
a1bd4f |
nm_remote_connection_get_secrets(NMRemoteConnection *connection,
|
|
Packit Service |
a1bd4f |
const char * setting_name,
|
|
Packit Service |
a1bd4f |
GCancellable * cancellable,
|
|
Packit Service |
a1bd4f |
GError ** error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
gs_unref_variant GVariant *ret = NULL;
|
|
Packit Service |
a1bd4f |
GVariant * secrets;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_REMOTE_CONNECTION(connection), NULL);
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(setting_name, NULL);
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(!cancellable || G_IS_CANCELLABLE(cancellable), NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
ret = _nm_client_dbus_call_sync(_nm_object_get_client(connection),
|
|
Packit Service |
a1bd4f |
cancellable,
|
|
Packit Service |
a1bd4f |
_nm_object_get_path(connection),
|
|
Packit Service |
a1bd4f |
NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
|
|
Packit Service |
a1bd4f |
"GetSecrets",
|
|
Packit Service |
a1bd4f |
g_variant_new("(s)", setting_name),
|
|
Packit Service |
a1bd4f |
G_VARIANT_TYPE("(a{sa{sv}})"),
|
|
Packit Service |
a1bd4f |
G_DBUS_CALL_FLAGS_NONE,
|
|
Packit Service |
a1bd4f |
NM_DBUS_DEFAULT_TIMEOUT_MSEC,
|
|
Packit Service |
a1bd4f |
TRUE,
|
|
Packit Service |
a1bd4f |
error);
|
|
Packit Service |
a1bd4f |
if (!ret)
|
|
Packit Service |
a1bd4f |
return NULL;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_variant_get(ret, "(@a{sa{sv}})", &secrets);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
return secrets;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_remote_connection_get_secrets_async:
|
|
Packit |
5756e2 |
* @connection: the #NMRemoteConnection
|
|
Packit |
5756e2 |
* @setting_name: the #NMSetting object name to get secrets for
|
|
Packit |
5756e2 |
* @cancellable: a #GCancellable, or %NULL
|
|
Packit |
5756e2 |
* @callback: callback to be called when the secret request completes
|
|
Packit |
5756e2 |
* @user_data: caller-specific data passed to @callback
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Asynchronously requests the connection's secrets.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
void
|
|
Packit Service |
a1bd4f |
nm_remote_connection_get_secrets_async(NMRemoteConnection *connection,
|
|
Packit Service |
a1bd4f |
const char * setting_name,
|
|
Packit Service |
a1bd4f |
GCancellable * cancellable,
|
|
Packit Service |
a1bd4f |
GAsyncReadyCallback callback,
|
|
Packit Service |
a1bd4f |
gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_if_fail(NM_IS_REMOTE_CONNECTION(connection));
|
|
Packit Service |
a1bd4f |
g_return_if_fail(setting_name);
|
|
Packit Service |
a1bd4f |
g_return_if_fail(!cancellable || G_IS_CANCELLABLE(cancellable));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
_nm_client_dbus_call(_nm_object_get_client(connection),
|
|
Packit Service |
a1bd4f |
connection,
|
|
Packit Service |
a1bd4f |
nm_remote_connection_get_secrets_async,
|
|
Packit Service |
a1bd4f |
cancellable,
|
|
Packit Service |
a1bd4f |
callback,
|
|
Packit Service |
a1bd4f |
user_data,
|
|
Packit Service |
a1bd4f |
_nm_object_get_path(connection),
|
|
Packit Service |
a1bd4f |
NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
|
|
Packit Service |
a1bd4f |
"GetSecrets",
|
|
Packit Service |
a1bd4f |
g_variant_new("(s)", setting_name),
|
|
Packit Service |
a1bd4f |
G_VARIANT_TYPE("(a{sa{sv}})"),
|
|
Packit Service |
a1bd4f |
G_DBUS_CALL_FLAGS_NONE,
|
|
Packit Service |
a1bd4f |
NM_DBUS_DEFAULT_TIMEOUT_MSEC,
|
|
Packit Service |
a1bd4f |
nm_dbus_connection_call_finish_variant_strip_dbus_error_cb);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_remote_connection_get_secrets_finish:
|
|
Packit |
5756e2 |
* @connection: the #NMRemoteConnection
|
|
Packit |
5756e2 |
* @result: the result passed to the #GAsyncReadyCallback
|
|
Packit |
5756e2 |
* @error: location for a #GError, or %NULL
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Gets the result of a call to nm_remote_connection_get_secrets_async().
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: (transfer full): a #GVariant of type %NM_VARIANT_TYPE_CONNECTION
|
|
Packit |
5756e2 |
* containing @connection's secrets, or %NULL on error.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
GVariant *
|
|
Packit Service |
a1bd4f |
nm_remote_connection_get_secrets_finish(NMRemoteConnection *connection,
|
|
Packit Service |
a1bd4f |
GAsyncResult * result,
|
|
Packit Service |
a1bd4f |
GError ** error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
gs_unref_variant GVariant *ret = NULL;
|
|
Packit Service |
a1bd4f |
GVariant * secrets;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_REMOTE_CONNECTION(connection), NULL);
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(
|
|
Packit Service |
a1bd4f |
nm_g_task_is_valid(result, connection, nm_remote_connection_get_secrets_async),
|
|
Packit Service |
a1bd4f |
FALSE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
ret = g_task_propagate_pointer(G_TASK(result), error);
|
|
Packit Service |
a1bd4f |
if (!ret)
|
|
Packit Service |
a1bd4f |
return NULL;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_variant_get(ret, "(@a{sa{sv}})", &secrets);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return secrets;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_remote_connection_get_unsaved:
|
|
Packit |
5756e2 |
* @connection: the #NMRemoteConnection
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: %TRUE if the remote connection contains changes that have not
|
|
Packit |
5756e2 |
* been saved to disk, %FALSE if the connection is the same as its on-disk
|
|
Packit |
5756e2 |
* representation.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
gboolean
|
|
Packit Service |
a1bd4f |
nm_remote_connection_get_unsaved(NMRemoteConnection *connection)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_REMOTE_CONNECTION(connection), FALSE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return NM_REMOTE_CONNECTION_GET_PRIVATE(connection)->unsaved;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_remote_connection_get_flags:
|
|
Packit |
5756e2 |
* @connection: the #NMRemoteConnection
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: the flags of the connection of type #NMSettingsConnectionFlags.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Since: 1.12
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
NMSettingsConnectionFlags
|
|
Packit Service |
a1bd4f |
nm_remote_connection_get_flags(NMRemoteConnection *connection)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_REMOTE_CONNECTION(connection), FALSE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return (NMSettingsConnectionFlags) NM_REMOTE_CONNECTION_GET_PRIVATE(connection)->flags;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_remote_connection_get_filename:
|
|
Packit |
5756e2 |
* @connection: the #NMRemoteConnection
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: file that stores the connection in case the connection is file-backed.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Since: 1.12
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
const char *
|
|
Packit Service |
a1bd4f |
nm_remote_connection_get_filename(NMRemoteConnection *connection)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_REMOTE_CONNECTION(connection), NULL);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return NM_REMOTE_CONNECTION_GET_PRIVATE(connection)->filename;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_remote_connection_get_visible:
|
|
Packit |
5756e2 |
* @connection: the #NMRemoteConnection
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Checks if the connection is visible to the current user. If the
|
|
Packit |
5756e2 |
* connection is not visible then it is essentially useless; it will
|
|
Packit |
5756e2 |
* not contain any settings, and operations such as
|
|
Packit |
5756e2 |
* nm_remote_connection_save() and nm_remote_connection_delete() will
|
|
Packit |
5756e2 |
* always fail. (#NMRemoteSettings will not normally return
|
|
Packit |
5756e2 |
* non-visible connections to callers, but it is possible for a
|
|
Packit |
5756e2 |
* connection's visibility to change after you already have a
|
|
Packit |
5756e2 |
* reference to it.)
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: %TRUE if the remote connection is visible to the current
|
|
Packit |
5756e2 |
* user, %FALSE if not.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
gboolean
|
|
Packit Service |
a1bd4f |
nm_remote_connection_get_visible(NMRemoteConnection *connection)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_REMOTE_CONNECTION(connection), FALSE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return NM_REMOTE_CONNECTION_GET_PRIVATE(connection)->visible;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
GCancellable *
|
|
Packit Service |
a1bd4f |
_nm_remote_settings_get_settings_prepare(NMRemoteConnection *self)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE(self);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
nm_clear_g_cancellable(&priv->get_settings_cancellable);
|
|
Packit Service |
a1bd4f |
priv->get_settings_cancellable = g_cancellable_new();
|
|
Packit Service |
a1bd4f |
return priv->get_settings_cancellable;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
void
|
|
Packit Service |
a1bd4f |
_nm_remote_settings_get_settings_commit(NMRemoteConnection *self, GVariant *settings)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE(self);
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit Service |
a1bd4f |
gboolean visible = FALSE;
|
|
Packit Service |
a1bd4f |
gboolean changed = FALSE;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_clear_object(&priv->get_settings_cancellable);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (!priv->is_initialized) {
|
|
Packit Service |
a1bd4f |
changed = TRUE;
|
|
Packit Service |
a1bd4f |
priv->is_initialized = TRUE;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (settings) {
|
|
Packit Service |
a1bd4f |
if (!_nm_connection_replace_settings((NMConnection *) self,
|
|
Packit Service |
a1bd4f |
settings,
|
|
Packit Service |
a1bd4f |
NM_SETTING_PARSE_FLAGS_BEST_EFFORT,
|
|
Packit Service |
a1bd4f |
&error)) {
|
|
Packit Service |
a1bd4f |
NML_NMCLIENT_LOG_E(_nm_object_get_client(self),
|
|
Packit Service |
a1bd4f |
"[%s] failure to update settings: %s",
|
|
Packit Service |
a1bd4f |
_nm_object_get_path(self),
|
|
Packit Service |
a1bd4f |
error->message);
|
|
Packit Service |
a1bd4f |
g_clear_error(&error);
|
|
Packit Service |
a1bd4f |
} else
|
|
Packit Service |
a1bd4f |
visible = TRUE;
|
|
Packit Service |
a1bd4f |
} else
|
|
Packit Service |
a1bd4f |
nm_connection_clear_settings(NM_CONNECTION(self));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (priv->visible != visible) {
|
|
Packit Service |
a1bd4f |
priv->visible = visible;
|
|
Packit Service |
a1bd4f |
_nm_client_queue_notify_object(_nm_object_get_client(self),
|
|
Packit Service |
a1bd4f |
self,
|
|
Packit Service |
a1bd4f |
obj_properties[PROP_VISIBLE]);
|
|
Packit Service |
a1bd4f |
changed = TRUE;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (changed)
|
|
Packit Service |
a1bd4f |
_nm_client_notify_object_changed(_nm_object_get_client(self), _nm_object_get_dbobj(self));
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
is_ready(NMObject *nmobj)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE(nmobj);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
if (!priv->is_initialized)
|
|
Packit Service |
a1bd4f |
return FALSE;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return NM_OBJECT_CLASS(nm_remote_connection_parent_class)->is_ready(nmobj);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
register_client(NMObject *nmobj, NMClient *client, NMLDBusObject *dbobj)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NM_OBJECT_CLASS(nm_remote_connection_parent_class)->register_client(nmobj, client, dbobj);
|
|
Packit Service |
a1bd4f |
nm_connection_set_path(NM_CONNECTION(nmobj), dbobj->dbus_path->str);
|
|
Packit Service |
a1bd4f |
_nm_client_get_settings_call(client, dbobj);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
unregister_client(NMObject *nmobj, NMClient *client, NMLDBusObject *dbobj)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
nm_clear_g_cancellable(&NM_REMOTE_CONNECTION_GET_PRIVATE(nmobj)->get_settings_cancellable);
|
|
Packit Service |
a1bd4f |
NM_OBJECT_CLASS(nm_remote_connection_parent_class)->unregister_client(nmobj, client, dbobj);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
switch (prop_id) {
|
|
Packit Service |
a1bd4f |
case PROP_UNSAVED:
|
|
Packit Service |
a1bd4f |
g_value_set_boolean(value, NM_REMOTE_CONNECTION_GET_PRIVATE(object)->unsaved);
|
|
Packit Service |
a1bd4f |
break;
|
|
Packit Service |
a1bd4f |
case PROP_FLAGS:
|
|
Packit Service |
a1bd4f |
g_value_set_uint(value, NM_REMOTE_CONNECTION_GET_PRIVATE(object)->flags);
|
|
Packit Service |
a1bd4f |
break;
|
|
Packit Service |
a1bd4f |
case PROP_FILENAME:
|
|
Packit Service |
a1bd4f |
g_value_set_string(value, NM_REMOTE_CONNECTION_GET_PRIVATE(object)->filename);
|
|
Packit Service |
a1bd4f |
break;
|
|
Packit Service |
a1bd4f |
case PROP_VISIBLE:
|
|
Packit Service |
a1bd4f |
g_value_set_boolean(value, NM_REMOTE_CONNECTION_GET_PRIVATE(object)->visible);
|
|
Packit Service |
a1bd4f |
break;
|
|
Packit Service |
a1bd4f |
default:
|
|
Packit Service |
a1bd4f |
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
|
Packit Service |
a1bd4f |
break;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
nm_remote_connection_init(NMRemoteConnection *self)
|
|
Packit Service |
a1bd4f |
{}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
dispose(GObject *object)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE(object);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
nm_clear_g_free(&priv->filename);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
G_OBJECT_CLASS(nm_remote_connection_parent_class)->dispose(object);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
const NMLDBusMetaIface _nml_dbus_meta_iface_nm_settings_connection = NML_DBUS_META_IFACE_INIT_PROP(
|
|
Packit Service |
a1bd4f |
NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
|
|
Packit Service |
a1bd4f |
nm_remote_connection_get_type,
|
|
Packit Service |
a1bd4f |
NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30,
|
|
Packit Service |
a1bd4f |
NML_DBUS_META_IFACE_DBUS_PROPERTIES(
|
|
Packit Service |
a1bd4f |
NML_DBUS_META_PROPERTY_INIT_S("Filename",
|
|
Packit Service |
a1bd4f |
PROP_FILENAME,
|
|
Packit Service |
a1bd4f |
NMRemoteConnection,
|
|
Packit Service |
a1bd4f |
_priv.filename),
|
|
Packit Service |
a1bd4f |
NML_DBUS_META_PROPERTY_INIT_U("Flags", PROP_FLAGS, NMRemoteConnection, _priv.flags),
|
|
Packit Service |
a1bd4f |
NML_DBUS_META_PROPERTY_INIT_B("Unsaved",
|
|
Packit Service |
a1bd4f |
PROP_UNSAVED,
|
|
Packit Service |
a1bd4f |
NMRemoteConnection,
|
|
Packit Service |
a1bd4f |
_priv.unsaved), ), );
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
nm_remote_connection_class_init(NMRemoteConnectionClass *klass)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
GObjectClass * object_class = G_OBJECT_CLASS(klass);
|
|
Packit Service |
a1bd4f |
NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
object_class->get_property = get_property;
|
|
Packit Service |
a1bd4f |
object_class->dispose = dispose;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nm_object_class->is_ready = is_ready;
|
|
Packit Service |
a1bd4f |
nm_object_class->register_client = register_client;
|
|
Packit Service |
a1bd4f |
nm_object_class->unregister_client = unregister_client;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**
|
|
Packit Service |
a1bd4f |
* NMRemoteConnection:unsaved:
|
|
Packit Service |
a1bd4f |
*
|
|
Packit Service |
a1bd4f |
* %TRUE if the remote connection contains changes that have not been saved
|
|
Packit Service |
a1bd4f |
* to disk, %FALSE if the connection is the same as its on-disk representation.
|
|
Packit Service |
a1bd4f |
**/
|
|
Packit Service |
a1bd4f |
obj_properties[PROP_UNSAVED] = g_param_spec_boolean(NM_REMOTE_CONNECTION_UNSAVED,
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
FALSE,
|
|
Packit Service |
a1bd4f |
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**
|
|
Packit Service |
a1bd4f |
* NMRemoteConnection:flags:
|
|
Packit Service |
a1bd4f |
*
|
|
Packit Service |
a1bd4f |
* The flags of the connection as unsigned integer. The values
|
|
Packit Service |
a1bd4f |
* correspond to the #NMSettingsConnectionFlags enum.
|
|
Packit Service |
a1bd4f |
*
|
|
Packit Service |
a1bd4f |
* Since: 1.12
|
|
Packit Service |
a1bd4f |
**/
|
|
Packit Service |
a1bd4f |
obj_properties[PROP_FLAGS] = g_param_spec_uint(NM_REMOTE_CONNECTION_FLAGS,
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
0,
|
|
Packit Service |
a1bd4f |
G_MAXUINT32,
|
|
Packit Service |
a1bd4f |
0,
|
|
Packit Service |
a1bd4f |
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**
|
|
Packit Service |
a1bd4f |
* NMRemoteConnection:filename:
|
|
Packit Service |
a1bd4f |
*
|
|
Packit Service |
a1bd4f |
* File that stores the connection in case the connection is
|
|
Packit Service |
a1bd4f |
* file-backed.
|
|
Packit Service |
a1bd4f |
*
|
|
Packit Service |
a1bd4f |
* Since: 1.12
|
|
Packit Service |
a1bd4f |
**/
|
|
Packit Service |
a1bd4f |
obj_properties[PROP_FILENAME] = g_param_spec_string(NM_REMOTE_CONNECTION_FILENAME,
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**
|
|
Packit Service |
a1bd4f |
* NMRemoteConnection:visible:
|
|
Packit Service |
a1bd4f |
*
|
|
Packit Service |
a1bd4f |
* %TRUE if the remote connection is visible to the current user, %FALSE if
|
|
Packit Service |
a1bd4f |
* not. If the connection is not visible then it is essentially useless; it
|
|
Packit Service |
a1bd4f |
* will not contain any settings, and operations such as
|
|
Packit Service |
a1bd4f |
* nm_remote_connection_save() and nm_remote_connection_delete() will always
|
|
Packit Service |
a1bd4f |
* fail. (#NMRemoteSettings will not normally return non-visible connections
|
|
Packit Service |
a1bd4f |
* to callers, but it is possible for a connection's visibility to change
|
|
Packit Service |
a1bd4f |
* after you already have a reference to it.)
|
|
Packit Service |
a1bd4f |
**/
|
|
Packit Service |
a1bd4f |
obj_properties[PROP_VISIBLE] = g_param_spec_boolean(NM_REMOTE_CONNECTION_VISIBLE,
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
FALSE,
|
|
Packit Service |
a1bd4f |
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
_nml_dbus_meta_class_init_with_properties(object_class,
|
|
Packit Service |
a1bd4f |
&_nml_dbus_meta_iface_nm_settings_connection);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
nm_remote_connection_connection_iface_init(NMConnectionInterface *iface)
|
|
Packit Service |
a1bd4f |
{}
|