2014-07-24 12:53:33 +00:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Copyright 2008 Novell, Inc.
|
|
|
|
* Copyright 2009 - 2012 Red Hat, Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
2014-07-05 20:23:30 +00:00
|
|
|
#include <nm-dbus-interface.h>
|
2014-07-24 12:53:33 +00:00
|
|
|
#include <nm-connection.h>
|
|
|
|
|
|
|
|
#include "nm-remote-settings.h"
|
2014-09-29 14:58:16 +00:00
|
|
|
#include "nm-client.h"
|
2014-10-09 13:12:42 +00:00
|
|
|
#include "nm-remote-connection.h"
|
2014-07-24 12:53:33 +00:00
|
|
|
#include "nm-remote-connection-private.h"
|
|
|
|
#include "nm-object-private.h"
|
2014-08-19 13:52:41 +00:00
|
|
|
#include "nm-dbus-helpers.h"
|
2014-07-24 12:53:33 +00:00
|
|
|
#include "nm-glib-compat.h"
|
|
|
|
#include "nm-object-private.h"
|
2014-08-26 12:31:04 +00:00
|
|
|
#include "nm-core-internal.h"
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-09-10 17:51:53 +00:00
|
|
|
#include "nmdbus-settings.h"
|
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
G_DEFINE_TYPE (NMRemoteSettings, nm_remote_settings, NM_TYPE_OBJECT)
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
#define NM_REMOTE_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettingsPrivate))
|
|
|
|
|
|
|
|
typedef struct {
|
2014-09-10 17:51:53 +00:00
|
|
|
NMDBusSettings *proxy;
|
2014-07-20 16:55:59 +00:00
|
|
|
GPtrArray *all_connections;
|
|
|
|
GPtrArray *visible_connections;
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
/* AddConnectionInfo objects that are waiting for the connection to become initialized */
|
|
|
|
GSList *add_list;
|
|
|
|
|
|
|
|
char *hostname;
|
|
|
|
gboolean can_modify;
|
|
|
|
} NMRemoteSettingsPrivate;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PROP_0,
|
2014-07-20 16:55:59 +00:00
|
|
|
PROP_CONNECTIONS,
|
2014-07-24 12:53:33 +00:00
|
|
|
PROP_HOSTNAME,
|
|
|
|
PROP_CAN_MODIFY,
|
|
|
|
|
|
|
|
LAST_PROP
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Signals */
|
|
|
|
enum {
|
2014-07-20 16:55:59 +00:00
|
|
|
CONNECTION_ADDED,
|
|
|
|
CONNECTION_REMOVED,
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
NMRemoteSettings *self;
|
2014-09-11 20:27:13 +00:00
|
|
|
GSimpleAsyncResult *simple;
|
2014-07-20 16:55:59 +00:00
|
|
|
char *path;
|
2014-09-11 20:12:40 +00:00
|
|
|
gboolean saved;
|
2014-07-24 12:53:33 +00:00
|
|
|
} AddConnectionInfo;
|
|
|
|
|
|
|
|
static AddConnectionInfo *
|
2014-07-20 16:55:59 +00:00
|
|
|
add_connection_info_find (NMRemoteSettings *self, const char *path)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
|
|
|
|
GSList *iter;
|
|
|
|
|
|
|
|
for (iter = priv->add_list; iter; iter = g_slist_next (iter)) {
|
|
|
|
AddConnectionInfo *info = iter->data;
|
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
if (!g_strcmp0 (info->path, path))
|
2014-07-24 12:53:33 +00:00
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
add_connection_info_complete (NMRemoteSettings *self,
|
|
|
|
AddConnectionInfo *info,
|
2014-07-20 16:55:59 +00:00
|
|
|
NMRemoteConnection *connection,
|
2014-07-24 12:53:33 +00:00
|
|
|
GError *error)
|
|
|
|
{
|
2014-09-11 20:27:13 +00:00
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
|
|
|
|
|
2014-07-24 12:53:33 +00:00
|
|
|
g_return_if_fail (info != NULL);
|
|
|
|
|
2014-09-11 20:27:13 +00:00
|
|
|
if (connection) {
|
|
|
|
g_simple_async_result_set_op_res_gpointer (info->simple,
|
|
|
|
g_object_ref (connection),
|
|
|
|
g_object_unref);
|
|
|
|
} else
|
|
|
|
g_simple_async_result_set_from_error (info->simple, error);
|
|
|
|
g_simple_async_result_complete (info->simple);
|
|
|
|
|
|
|
|
g_object_unref (info->simple);
|
|
|
|
priv->add_list = g_slist_remove (priv->add_list, info);
|
|
|
|
|
|
|
|
g_free (info->path);
|
|
|
|
g_slice_free (AddConnectionInfo, info);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
typedef const char * (*ConnectionStringGetter) (NMConnection *);
|
|
|
|
|
|
|
|
static NMRemoteConnection *
|
|
|
|
get_connection_by_string (NMRemoteSettings *settings,
|
|
|
|
const char *string,
|
|
|
|
ConnectionStringGetter get_comparison_string)
|
|
|
|
{
|
|
|
|
NMRemoteSettingsPrivate *priv;
|
|
|
|
NMConnection *candidate;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!_nm_object_get_nm_running (NM_OBJECT (settings)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
|
|
|
|
|
|
|
for (i = 0; i < priv->visible_connections->len; i++) {
|
|
|
|
candidate = priv->visible_connections->pdata[i];
|
|
|
|
if (!g_strcmp0 (string, get_comparison_string (candidate)))
|
|
|
|
return NM_REMOTE_CONNECTION (candidate);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-07-24 12:53:33 +00:00
|
|
|
NMRemoteConnection *
|
|
|
|
nm_remote_settings_get_connection_by_id (NMRemoteSettings *settings, const char *id)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL);
|
|
|
|
g_return_val_if_fail (id != NULL, NULL);
|
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
return get_connection_by_string (settings, id, nm_connection_get_id);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NMRemoteConnection *
|
|
|
|
nm_remote_settings_get_connection_by_path (NMRemoteSettings *settings, const char *path)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL);
|
|
|
|
g_return_val_if_fail (path != NULL, NULL);
|
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
return get_connection_by_string (settings, path, nm_connection_get_path);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NMRemoteConnection *
|
|
|
|
nm_remote_settings_get_connection_by_uuid (NMRemoteSettings *settings, const char *uuid)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL);
|
|
|
|
g_return_val_if_fail (uuid != NULL, NULL);
|
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
return get_connection_by_string (settings, uuid, nm_connection_get_uuid);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-07-20 16:55:59 +00:00
|
|
|
connection_visible_changed (GObject *object,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
gpointer user_data)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
2014-07-20 16:55:59 +00:00
|
|
|
NMRemoteConnection *connection = NM_REMOTE_CONNECTION (object);
|
2014-07-24 12:53:33 +00:00
|
|
|
NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
|
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
if (nm_remote_connection_get_visible (connection))
|
|
|
|
g_signal_emit (self, signals[CONNECTION_ADDED], 0, connection);
|
|
|
|
else
|
|
|
|
g_signal_emit (self, signals[CONNECTION_REMOVED], 0, connection);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-07-20 16:55:59 +00:00
|
|
|
cleanup_connection (NMRemoteSettings *self,
|
|
|
|
NMRemoteConnection *remote)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
2014-07-20 16:55:59 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (remote, G_CALLBACK (connection_visible_changed), self);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-07-20 16:55:59 +00:00
|
|
|
connection_removed (NMRemoteSettings *self,
|
|
|
|
NMRemoteConnection *remote)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
|
2014-07-20 16:55:59 +00:00
|
|
|
gboolean still_exists = FALSE;
|
|
|
|
int i;
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
/* Check if the connection was actually removed or if it just turned invisible. */
|
2014-08-26 12:31:04 +00:00
|
|
|
for (i = 0; i < priv->all_connections->len; i++) {
|
|
|
|
if (remote == priv->all_connections->pdata[i]) {
|
|
|
|
still_exists = TRUE;
|
|
|
|
break;
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
}
|
2014-07-20 16:55:59 +00:00
|
|
|
|
|
|
|
if (!still_exists)
|
|
|
|
cleanup_connection (self, remote);
|
|
|
|
|
|
|
|
/* Allow the signal to propagate if and only if @remote was in visible_connections */
|
|
|
|
if (!g_ptr_array_remove (priv->visible_connections, remote))
|
|
|
|
g_signal_stop_emission (self, signals[CONNECTION_REMOVED], 0);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-07-20 16:55:59 +00:00
|
|
|
connection_added (NMRemoteSettings *self,
|
|
|
|
NMRemoteConnection *remote)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
|
|
|
|
AddConnectionInfo *addinfo;
|
|
|
|
const char *path;
|
|
|
|
|
2014-08-05 13:37:23 +00:00
|
|
|
if (!g_signal_handler_find (remote, G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL,
|
|
|
|
G_CALLBACK (connection_visible_changed), self)) {
|
2014-07-20 16:55:59 +00:00
|
|
|
g_signal_connect (remote,
|
|
|
|
"notify::" NM_REMOTE_CONNECTION_VISIBLE,
|
|
|
|
G_CALLBACK (connection_visible_changed),
|
|
|
|
self);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
if (nm_remote_connection_get_visible (remote))
|
|
|
|
g_ptr_array_add (priv->visible_connections, remote);
|
|
|
|
else
|
|
|
|
g_signal_stop_emission (self, signals[CONNECTION_ADDED], 0);
|
2014-05-15 18:25:07 +00:00
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
path = nm_connection_get_path (NM_CONNECTION (remote));
|
|
|
|
addinfo = add_connection_info_find (self, path);
|
|
|
|
if (addinfo)
|
|
|
|
add_connection_info_complete (self, addinfo, remote, NULL);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-07-20 16:55:59 +00:00
|
|
|
object_creation_failed (NMObject *object, GError *error, char *failed_path)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
2014-07-20 16:55:59 +00:00
|
|
|
NMRemoteSettings *self = NM_REMOTE_SETTINGS (object);
|
|
|
|
AddConnectionInfo *addinfo;
|
|
|
|
GError *add_error;
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
addinfo = add_connection_info_find (self, failed_path);
|
|
|
|
if (addinfo) {
|
2014-09-29 14:58:16 +00:00
|
|
|
add_error = g_error_new_literal (NM_CLIENT_ERROR,
|
|
|
|
NM_CLIENT_ERROR_CONNECTION_REMOVED,
|
2014-07-20 16:55:59 +00:00
|
|
|
"Connection removed before it was initialized");
|
|
|
|
add_connection_info_complete (self, addinfo, NULL, add_error);
|
|
|
|
g_error_free (add_error);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GSList *
|
|
|
|
nm_remote_settings_list_connections (NMRemoteSettings *settings)
|
|
|
|
{
|
|
|
|
NMRemoteSettingsPrivate *priv;
|
|
|
|
GSList *list = NULL;
|
2014-07-20 16:55:59 +00:00
|
|
|
int i;
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL);
|
|
|
|
|
|
|
|
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
if (_nm_object_get_nm_running (NM_OBJECT (settings))) {
|
|
|
|
for (i = 0; i < priv->visible_connections->len; i++)
|
|
|
|
list = g_slist_prepend (list, priv->visible_connections->pdata[i]);
|
|
|
|
list = g_slist_reverse (list);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-10 17:51:53 +00:00
|
|
|
add_connection_done (GObject *proxy, GAsyncResult *result, gpointer user_data)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
|
|
|
AddConnectionInfo *info = user_data;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
2014-09-11 20:12:40 +00:00
|
|
|
if (info->saved) {
|
|
|
|
nmdbus_settings_call_add_connection_finish (NMDBUS_SETTINGS (proxy),
|
|
|
|
&info->path,
|
|
|
|
result, &error);
|
2014-09-10 17:51:53 +00:00
|
|
|
} else {
|
2014-09-11 20:12:40 +00:00
|
|
|
nmdbus_settings_call_add_connection_unsaved_finish (NMDBUS_SETTINGS (proxy),
|
|
|
|
&info->path,
|
|
|
|
result, &error);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error) {
|
2014-10-15 22:26:32 +00:00
|
|
|
g_dbus_error_strip_remote_error (error);
|
2014-07-20 16:55:59 +00:00
|
|
|
add_connection_info_complete (info->self, info, NULL, error);
|
2014-09-10 17:51:53 +00:00
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
2014-09-11 20:12:40 +00:00
|
|
|
|
|
|
|
/* On success, we still have to wait until the connection is fully
|
|
|
|
* initialized before calling the callback.
|
|
|
|
*/
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
2014-09-11 20:27:13 +00:00
|
|
|
void
|
|
|
|
nm_remote_settings_add_connection_async (NMRemoteSettings *settings,
|
|
|
|
NMConnection *connection,
|
|
|
|
gboolean save_to_disk,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GAsyncReadyCallback callback,
|
|
|
|
gpointer user_data)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
|
|
|
NMRemoteSettingsPrivate *priv;
|
|
|
|
AddConnectionInfo *info;
|
2014-09-10 17:51:53 +00:00
|
|
|
GVariant *new_settings;
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-09-25 15:38:07 +00:00
|
|
|
g_return_if_fail (NM_IS_REMOTE_SETTINGS (settings));
|
|
|
|
g_return_if_fail (NM_IS_CONNECTION (connection));
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
|
|
|
|
2014-09-11 20:27:13 +00:00
|
|
|
info = g_slice_new0 (AddConnectionInfo);
|
2014-07-24 12:53:33 +00:00
|
|
|
info->self = settings;
|
2014-09-11 20:27:13 +00:00
|
|
|
info->simple = g_simple_async_result_new (G_OBJECT (settings), callback, user_data,
|
|
|
|
nm_remote_settings_add_connection_async);
|
2014-09-11 20:12:40 +00:00
|
|
|
info->saved = save_to_disk;
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-09-10 17:51:53 +00:00
|
|
|
new_settings = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL);
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-09-11 20:12:40 +00:00
|
|
|
if (save_to_disk) {
|
|
|
|
nmdbus_settings_call_add_connection (priv->proxy,
|
|
|
|
new_settings,
|
|
|
|
NULL,
|
|
|
|
add_connection_done, info);
|
|
|
|
} else {
|
|
|
|
nmdbus_settings_call_add_connection_unsaved (priv->proxy,
|
|
|
|
new_settings,
|
|
|
|
NULL,
|
|
|
|
add_connection_done, info);
|
|
|
|
}
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
priv->add_list = g_slist_append (priv->add_list, info);
|
|
|
|
}
|
|
|
|
|
2014-09-11 20:27:13 +00:00
|
|
|
NMRemoteConnection *
|
|
|
|
nm_remote_settings_add_connection_finish (NMRemoteSettings *settings,
|
|
|
|
GAsyncResult *result,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
GSimpleAsyncResult *simple;
|
|
|
|
|
|
|
|
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (settings), nm_remote_settings_add_connection_async), NULL);
|
|
|
|
|
|
|
|
simple = G_SIMPLE_ASYNC_RESULT (result);
|
|
|
|
if (g_simple_async_result_propagate_error (simple, error))
|
|
|
|
return NULL;
|
|
|
|
else
|
|
|
|
return g_object_ref (g_simple_async_result_get_op_res_gpointer (simple));
|
|
|
|
}
|
2014-09-11 20:12:40 +00:00
|
|
|
|
2014-07-24 12:53:33 +00:00
|
|
|
gboolean
|
|
|
|
nm_remote_settings_load_connections (NMRemoteSettings *settings,
|
|
|
|
char **filenames,
|
|
|
|
char ***failures,
|
2014-09-11 20:27:13 +00:00
|
|
|
GCancellable *cancellable,
|
2014-07-24 12:53:33 +00:00
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
NMRemoteSettingsPrivate *priv;
|
2014-09-10 17:51:53 +00:00
|
|
|
gboolean success;
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
|
|
|
|
g_return_val_if_fail (filenames != NULL, FALSE);
|
|
|
|
|
|
|
|
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
|
|
|
|
2014-09-10 17:51:53 +00:00
|
|
|
if (!nmdbus_settings_call_load_connections_sync (priv->proxy,
|
|
|
|
(const char * const *) filenames,
|
|
|
|
&success,
|
|
|
|
failures,
|
2014-10-15 22:26:32 +00:00
|
|
|
cancellable, error)) {
|
|
|
|
if (error && *error)
|
|
|
|
g_dbus_error_strip_remote_error (*error);
|
2014-09-10 17:51:53 +00:00
|
|
|
success = FALSE;
|
2014-10-15 22:26:32 +00:00
|
|
|
}
|
2014-09-10 17:51:53 +00:00
|
|
|
return success;
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
2014-09-11 20:27:13 +00:00
|
|
|
static void
|
|
|
|
load_connections_cb (GObject *proxy, GAsyncResult *result, gpointer user_data)
|
|
|
|
{
|
|
|
|
GSimpleAsyncResult *simple = user_data;
|
|
|
|
GError *error = NULL;
|
|
|
|
gboolean success;
|
|
|
|
char **failures = NULL;
|
|
|
|
|
|
|
|
if (nmdbus_settings_call_load_connections_finish (NMDBUS_SETTINGS (proxy),
|
|
|
|
&success, &failures,
|
|
|
|
result, &error))
|
|
|
|
g_simple_async_result_set_op_res_gpointer (simple, failures, (GDestroyNotify) g_strfreev);
|
2014-10-15 22:26:32 +00:00
|
|
|
else {
|
|
|
|
g_dbus_error_strip_remote_error (error);
|
2014-09-11 20:27:13 +00:00
|
|
|
g_simple_async_result_take_error (simple, error);
|
2014-10-15 22:26:32 +00:00
|
|
|
}
|
2014-09-11 20:27:13 +00:00
|
|
|
|
|
|
|
g_simple_async_result_complete (simple);
|
|
|
|
g_object_unref (simple);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nm_remote_settings_load_connections_async (NMRemoteSettings *settings,
|
|
|
|
char **filenames,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GAsyncReadyCallback callback,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
NMRemoteSettingsPrivate *priv;
|
|
|
|
GSimpleAsyncResult *simple;
|
|
|
|
|
2014-09-25 15:38:07 +00:00
|
|
|
g_return_if_fail (NM_IS_REMOTE_SETTINGS (settings));
|
|
|
|
g_return_if_fail (filenames != NULL);
|
2014-09-11 20:27:13 +00:00
|
|
|
|
|
|
|
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
|
|
|
|
|
|
|
simple = g_simple_async_result_new (G_OBJECT (settings), callback, user_data,
|
|
|
|
nm_remote_settings_load_connections_async);
|
|
|
|
|
|
|
|
nmdbus_settings_call_load_connections (priv->proxy,
|
|
|
|
(const char * const *) filenames,
|
|
|
|
cancellable, load_connections_cb, simple);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
nm_remote_settings_load_connections_finish (NMRemoteSettings *settings,
|
|
|
|
char ***failures,
|
|
|
|
GAsyncResult *result,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
GSimpleAsyncResult *simple;
|
|
|
|
|
|
|
|
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (settings), nm_remote_settings_load_connections_async), FALSE);
|
|
|
|
|
|
|
|
simple = G_SIMPLE_ASYNC_RESULT (result);
|
|
|
|
if (g_simple_async_result_propagate_error (simple, error))
|
|
|
|
return FALSE;
|
|
|
|
else {
|
|
|
|
*failures = g_strdupv (g_simple_async_result_get_op_res_gpointer (simple));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-24 12:53:33 +00:00
|
|
|
gboolean
|
|
|
|
nm_remote_settings_reload_connections (NMRemoteSettings *settings,
|
2014-09-11 20:27:13 +00:00
|
|
|
GCancellable *cancellable,
|
2014-07-24 12:53:33 +00:00
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
NMRemoteSettingsPrivate *priv;
|
|
|
|
gboolean success;
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
|
|
|
|
|
|
|
|
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
|
|
|
|
2014-09-10 17:51:53 +00:00
|
|
|
if (!nmdbus_settings_call_reload_connections_sync (priv->proxy, &success,
|
2014-10-15 22:26:32 +00:00
|
|
|
cancellable, error)) {
|
|
|
|
if (error && *error)
|
|
|
|
g_dbus_error_strip_remote_error (*error);
|
2014-09-10 17:51:53 +00:00
|
|
|
success = FALSE;
|
2014-10-15 22:26:32 +00:00
|
|
|
}
|
2014-09-10 17:51:53 +00:00
|
|
|
|
2014-07-24 12:53:33 +00:00
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2014-09-11 20:27:13 +00:00
|
|
|
static void
|
|
|
|
reload_connections_cb (GObject *proxy, GAsyncResult *result, gpointer user_data)
|
|
|
|
{
|
|
|
|
GSimpleAsyncResult *simple = user_data;
|
|
|
|
gboolean success;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
if (nmdbus_settings_call_reload_connections_finish (NMDBUS_SETTINGS (proxy),
|
|
|
|
&success,
|
|
|
|
result, &error))
|
|
|
|
g_simple_async_result_set_op_res_gboolean (simple, success);
|
2014-10-15 22:26:32 +00:00
|
|
|
else {
|
|
|
|
g_dbus_error_strip_remote_error (error);
|
2014-09-11 20:27:13 +00:00
|
|
|
g_simple_async_result_take_error (simple, error);
|
2014-10-15 22:26:32 +00:00
|
|
|
}
|
2014-09-11 20:27:13 +00:00
|
|
|
|
|
|
|
g_simple_async_result_complete (simple);
|
|
|
|
g_object_unref (simple);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nm_remote_settings_reload_connections_async (NMRemoteSettings *settings,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GAsyncReadyCallback callback,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
NMRemoteSettingsPrivate *priv;
|
|
|
|
GSimpleAsyncResult *simple;
|
|
|
|
|
2014-09-25 15:38:07 +00:00
|
|
|
g_return_if_fail (NM_IS_REMOTE_SETTINGS (settings));
|
2014-09-11 20:27:13 +00:00
|
|
|
|
|
|
|
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
|
|
|
|
|
|
|
simple = g_simple_async_result_new (G_OBJECT (settings), callback, user_data,
|
|
|
|
nm_remote_settings_reload_connections_async);
|
|
|
|
|
|
|
|
nmdbus_settings_call_reload_connections (priv->proxy, cancellable,
|
|
|
|
reload_connections_cb, simple);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
nm_remote_settings_reload_connections_finish (NMRemoteSettings *settings,
|
|
|
|
GAsyncResult *result,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
GSimpleAsyncResult *simple;
|
|
|
|
|
|
|
|
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (settings), nm_remote_settings_reload_connections_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);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
nm_remote_settings_save_hostname (NMRemoteSettings *settings,
|
|
|
|
const char *hostname,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
NMRemoteSettingsPrivate *priv;
|
2014-10-15 22:26:32 +00:00
|
|
|
gboolean ret;
|
|
|
|
|
2014-09-11 20:27:13 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
|
|
|
|
|
|
|
|
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
|
|
|
|
2014-10-15 22:26:32 +00:00
|
|
|
ret = nmdbus_settings_call_save_hostname_sync (priv->proxy,
|
|
|
|
hostname ? hostname : "",
|
|
|
|
cancellable, error);
|
|
|
|
if (error && *error)
|
|
|
|
g_dbus_error_strip_remote_error (*error);
|
|
|
|
return ret;
|
2014-09-11 20:27:13 +00:00
|
|
|
}
|
|
|
|
|
2014-07-24 12:53:33 +00:00
|
|
|
static void
|
2014-09-10 17:51:53 +00:00
|
|
|
save_hostname_cb (GObject *proxy,
|
|
|
|
GAsyncResult *result,
|
2014-07-24 12:53:33 +00:00
|
|
|
gpointer user_data)
|
|
|
|
{
|
2014-09-11 20:27:13 +00:00
|
|
|
GSimpleAsyncResult *simple = user_data;
|
2014-07-24 12:53:33 +00:00
|
|
|
GError *error = NULL;
|
|
|
|
|
2014-09-11 20:27:13 +00:00
|
|
|
if (nmdbus_settings_call_save_hostname_finish (NMDBUS_SETTINGS (proxy), result, &error))
|
|
|
|
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
|
2014-10-15 22:26:32 +00:00
|
|
|
else {
|
|
|
|
g_dbus_error_strip_remote_error (error);
|
2014-09-11 20:27:13 +00:00
|
|
|
g_simple_async_result_take_error (simple, error);
|
2014-10-15 22:26:32 +00:00
|
|
|
}
|
2014-09-11 20:27:13 +00:00
|
|
|
g_simple_async_result_complete (simple);
|
|
|
|
g_object_unref (simple);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
2014-09-11 20:27:13 +00:00
|
|
|
void
|
|
|
|
nm_remote_settings_save_hostname_async (NMRemoteSettings *settings,
|
|
|
|
const char *hostname,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GAsyncReadyCallback callback,
|
|
|
|
gpointer user_data)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
|
|
|
NMRemoteSettingsPrivate *priv;
|
2014-09-11 20:27:13 +00:00
|
|
|
GSimpleAsyncResult *simple;
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-09-25 15:38:07 +00:00
|
|
|
g_return_if_fail (NM_IS_REMOTE_SETTINGS (settings));
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
|
|
|
|
2014-09-11 20:27:13 +00:00
|
|
|
simple = g_simple_async_result_new (G_OBJECT (settings), callback, user_data,
|
|
|
|
nm_remote_settings_save_hostname_async);
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-09-10 17:51:53 +00:00
|
|
|
nmdbus_settings_call_save_hostname (priv->proxy,
|
|
|
|
hostname ? hostname : "",
|
2014-09-11 20:27:13 +00:00
|
|
|
cancellable, save_hostname_cb, simple);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
nm_remote_settings_save_hostname_finish (NMRemoteSettings *settings,
|
|
|
|
GAsyncResult *result,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
GSimpleAsyncResult *simple;
|
|
|
|
|
|
|
|
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (settings), nm_remote_settings_save_hostname_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);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-07-20 16:55:59 +00:00
|
|
|
updated_properties (GObject *object, GAsyncResult *result, gpointer user_data)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
2014-07-20 16:55:59 +00:00
|
|
|
GError *error = NULL;
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
if (!_nm_object_reload_properties_finish (NM_OBJECT (object), result, &error)) {
|
|
|
|
g_warning ("%s: error reading NMRemoteSettings properties: %s", __func__, error->message);
|
|
|
|
g_error_free (error);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-07-20 16:55:59 +00:00
|
|
|
nm_running_changed (GObject *object,
|
|
|
|
GParamSpec *pspec,
|
2014-07-24 12:53:33 +00:00
|
|
|
gpointer user_data)
|
|
|
|
{
|
2014-07-20 16:55:59 +00:00
|
|
|
NMRemoteSettings *self = NM_REMOTE_SETTINGS (object);
|
2014-07-24 12:53:33 +00:00
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
|
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
g_object_freeze_notify (object);
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
if (!_nm_object_get_nm_running (NM_OBJECT (self))) {
|
2014-08-26 12:31:04 +00:00
|
|
|
GPtrArray *connections;
|
|
|
|
int i;
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-08-26 12:31:04 +00:00
|
|
|
/* Clear connections */
|
|
|
|
connections = priv->all_connections;
|
|
|
|
priv->all_connections = g_ptr_array_new ();
|
|
|
|
for (i = 0; i < connections->len; i++)
|
|
|
|
g_signal_emit (self, signals[CONNECTION_REMOVED], 0, connections->pdata[i]);
|
|
|
|
g_ptr_array_unref (connections);
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
/* Clear properties */
|
|
|
|
if (priv->hostname) {
|
2014-07-24 12:53:33 +00:00
|
|
|
g_free (priv->hostname);
|
|
|
|
priv->hostname = NULL;
|
|
|
|
g_object_notify (G_OBJECT (self), NM_REMOTE_SETTINGS_HOSTNAME);
|
2014-07-20 16:55:59 +00:00
|
|
|
}
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
if (priv->can_modify) {
|
2014-07-24 12:53:33 +00:00
|
|
|
priv->can_modify = FALSE;
|
|
|
|
g_object_notify (G_OBJECT (self), NM_REMOTE_SETTINGS_CAN_MODIFY);
|
|
|
|
}
|
2014-07-20 16:55:59 +00:00
|
|
|
|
|
|
|
_nm_object_suppress_property_updates (NM_OBJECT (self), TRUE);
|
|
|
|
} else {
|
|
|
|
_nm_object_suppress_property_updates (NM_OBJECT (self), FALSE);
|
|
|
|
_nm_object_reload_properties_async (NM_OBJECT (self), updated_properties, self);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
2014-07-20 16:55:59 +00:00
|
|
|
|
|
|
|
g_object_thaw_notify (object);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************/
|
|
|
|
|
|
|
|
static void
|
|
|
|
nm_remote_settings_init (NMRemoteSettings *self)
|
|
|
|
{
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
|
|
|
|
|
2014-10-07 01:16:00 +00:00
|
|
|
priv->all_connections = g_ptr_array_new ();
|
2014-07-20 16:55:59 +00:00
|
|
|
priv->visible_connections = g_ptr_array_new ();
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-07-20 16:55:59 +00:00
|
|
|
init_dbus (NMObject *object)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
2014-07-20 16:55:59 +00:00
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (object);
|
|
|
|
const NMPropertiesInfo property_info[] = {
|
|
|
|
{ NM_REMOTE_SETTINGS_CONNECTIONS, &priv->all_connections, NULL, NM_TYPE_REMOTE_CONNECTION, "connection" },
|
|
|
|
{ NM_REMOTE_SETTINGS_HOSTNAME, &priv->hostname },
|
|
|
|
{ NM_REMOTE_SETTINGS_CAN_MODIFY, &priv->can_modify },
|
|
|
|
{ NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
NM_OBJECT_CLASS (nm_remote_settings_parent_class)->init_dbus (object);
|
|
|
|
|
2014-09-10 17:51:53 +00:00
|
|
|
priv->proxy = NMDBUS_SETTINGS (_nm_object_get_proxy (object, NM_DBUS_INTERFACE_SETTINGS));
|
2014-07-20 16:55:59 +00:00
|
|
|
_nm_object_register_properties (object,
|
2014-08-18 18:17:52 +00:00
|
|
|
NM_DBUS_INTERFACE_SETTINGS,
|
2014-07-20 16:55:59 +00:00
|
|
|
property_info);
|
|
|
|
|
|
|
|
g_signal_connect (object, "notify::" NM_OBJECT_NM_RUNNING,
|
|
|
|
G_CALLBACK (nm_running_changed), NULL);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
static GObject *
|
|
|
|
constructor (GType type,
|
|
|
|
guint n_construct_params,
|
|
|
|
GObjectConstructParam *construct_params)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
2014-07-20 16:55:59 +00:00
|
|
|
guint i;
|
|
|
|
const char *dbus_path;
|
|
|
|
|
|
|
|
/* Fill in the right D-Bus path if none was specified */
|
|
|
|
for (i = 0; i < n_construct_params; i++) {
|
2014-08-13 21:43:10 +00:00
|
|
|
if (strcmp (construct_params[i].pspec->name, NM_OBJECT_PATH) == 0) {
|
2014-07-20 16:55:59 +00:00
|
|
|
dbus_path = g_value_get_string (construct_params[i].value);
|
|
|
|
if (dbus_path == NULL) {
|
|
|
|
g_value_set_static_string (construct_params[i].value, NM_DBUS_PATH_SETTINGS);
|
|
|
|
} else {
|
|
|
|
if (!g_variant_is_object_path (dbus_path)) {
|
|
|
|
g_warning ("Passed D-Bus object path '%s' is invalid; using default '%s' instead",
|
|
|
|
dbus_path, NM_DBUS_PATH);
|
|
|
|
g_value_set_static_string (construct_params[i].value, NM_DBUS_PATH_SETTINGS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
return G_OBJECT_CLASS (nm_remote_settings_parent_class)->constructor (type,
|
|
|
|
n_construct_params,
|
|
|
|
construct_params);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dispose (GObject *object)
|
|
|
|
{
|
|
|
|
NMRemoteSettings *self = NM_REMOTE_SETTINGS (object);
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
|
2014-08-26 12:31:04 +00:00
|
|
|
int i;
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
if (priv->all_connections) {
|
2014-08-26 12:31:04 +00:00
|
|
|
for (i = 0; i < priv->all_connections->len; i++)
|
2014-07-20 16:55:59 +00:00
|
|
|
cleanup_connection (self, priv->all_connections->pdata[i]);
|
|
|
|
g_clear_pointer (&priv->all_connections, g_ptr_array_unref);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
2014-08-26 12:31:04 +00:00
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
g_clear_pointer (&priv->visible_connections, g_ptr_array_unref);
|
|
|
|
g_clear_pointer (&priv->hostname, g_free);
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (nm_remote_settings_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
get_property (GObject *object, guint prop_id,
|
|
|
|
GValue *value, GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2014-07-20 16:55:59 +00:00
|
|
|
case PROP_CONNECTIONS:
|
2014-08-26 12:31:04 +00:00
|
|
|
g_value_take_boxed (value, _nm_utils_copy_object_array (priv->visible_connections));
|
2014-07-24 12:53:33 +00:00
|
|
|
break;
|
|
|
|
case PROP_HOSTNAME:
|
|
|
|
g_value_set_string (value, priv->hostname);
|
|
|
|
break;
|
|
|
|
case PROP_CAN_MODIFY:
|
|
|
|
g_value_set_boolean (value, priv->can_modify);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nm_remote_settings_class_init (NMRemoteSettingsClass *class)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
2014-07-20 16:55:59 +00:00
|
|
|
NMObjectClass *nm_object_class = NM_OBJECT_CLASS (class);
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
g_type_class_add_private (class, sizeof (NMRemoteSettingsPrivate));
|
|
|
|
|
2014-08-18 18:17:52 +00:00
|
|
|
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_SETTINGS);
|
2014-09-10 17:51:53 +00:00
|
|
|
_nm_dbus_register_proxy_type (NM_DBUS_INTERFACE_SETTINGS, NMDBUS_TYPE_SETTINGS_PROXY);
|
2014-08-18 18:17:52 +00:00
|
|
|
|
2014-07-24 12:53:33 +00:00
|
|
|
/* Virtual methods */
|
2014-07-20 16:55:59 +00:00
|
|
|
object_class->constructor = constructor;
|
2014-07-24 12:53:33 +00:00
|
|
|
object_class->get_property = get_property;
|
|
|
|
object_class->dispose = dispose;
|
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
nm_object_class->init_dbus = init_dbus;
|
|
|
|
nm_object_class->object_creation_failed = object_creation_failed;
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
class->connection_added = connection_added;
|
|
|
|
class->connection_removed = connection_removed;
|
|
|
|
|
|
|
|
/* Properties */
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_CONNECTIONS,
|
|
|
|
g_param_spec_boxed (NM_REMOTE_SETTINGS_CONNECTIONS, "", "",
|
2014-08-26 12:31:04 +00:00
|
|
|
G_TYPE_PTR_ARRAY,
|
2014-07-20 16:55:59 +00:00
|
|
|
G_PARAM_READABLE |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2014-07-24 12:53:33 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_HOSTNAME,
|
|
|
|
g_param_spec_string (NM_REMOTE_SETTINGS_HOSTNAME, "", "",
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_CAN_MODIFY,
|
|
|
|
g_param_spec_boolean (NM_REMOTE_SETTINGS_CAN_MODIFY, "", "",
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
/* Signals */
|
2014-07-20 16:55:59 +00:00
|
|
|
signals[CONNECTION_ADDED] =
|
|
|
|
g_signal_new (NM_REMOTE_SETTINGS_CONNECTION_ADDED,
|
2014-07-24 12:53:33 +00:00
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
2014-07-20 16:55:59 +00:00
|
|
|
G_STRUCT_OFFSET (NMRemoteSettingsClass, connection_added),
|
2014-07-24 12:53:33 +00:00
|
|
|
NULL, NULL, NULL,
|
2014-07-20 16:55:59 +00:00
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
NM_TYPE_REMOTE_CONNECTION);
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-07-20 16:55:59 +00:00
|
|
|
signals[CONNECTION_REMOVED] =
|
|
|
|
g_signal_new (NM_REMOTE_SETTINGS_CONNECTION_REMOVED,
|
2014-07-24 12:53:33 +00:00
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
2014-07-20 16:55:59 +00:00
|
|
|
G_STRUCT_OFFSET (NMRemoteSettingsClass, connection_removed),
|
2014-07-24 12:53:33 +00:00
|
|
|
NULL, NULL, NULL,
|
2014-07-20 16:55:59 +00:00
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
NM_TYPE_REMOTE_CONNECTION);
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|