2009-07-23 09:20:52 -04:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
|
|
|
|
/*
|
|
|
|
|
* libnm_glib -- Access network status & information from glib applications
|
|
|
|
|
*
|
|
|
|
|
* 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 (C) 2008 Novell, Inc.
|
2010-04-25 22:48:10 -07:00
|
|
|
* Copyright (C) 2009 - 2010 Red Hat, Inc.
|
2009-07-23 09:20:52 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <NetworkManager.h>
|
|
|
|
|
#include <nm-connection.h>
|
|
|
|
|
|
|
|
|
|
#include "nm-marshal.h"
|
2010-07-29 21:28:49 -04:00
|
|
|
#include "nm-dbus-glib-types.h"
|
2009-07-23 09:20:52 -04:00
|
|
|
#include "nm-remote-settings.h"
|
|
|
|
|
#include "nm-settings-bindings.h"
|
2009-08-11 10:33:13 -05:00
|
|
|
#include "nm-remote-connection-private.h"
|
2009-07-23 09:20:52 -04:00
|
|
|
|
2010-08-03 13:23:30 -04:00
|
|
|
G_DEFINE_TYPE (NMRemoteSettings, nm_remote_settings, G_TYPE_OBJECT)
|
2009-07-23 09:20:52 -04:00
|
|
|
|
|
|
|
|
#define NM_REMOTE_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettingsPrivate))
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
DBusGConnection *bus;
|
|
|
|
|
|
|
|
|
|
DBusGProxy *proxy;
|
|
|
|
|
GHashTable *connections;
|
2009-08-11 10:33:13 -05:00
|
|
|
GHashTable *pending; /* Connections we don't have settings for yet */
|
2009-09-22 23:29:02 -07:00
|
|
|
gboolean service_running;
|
2010-07-29 21:28:49 -04:00
|
|
|
|
|
|
|
|
DBusGProxy *props_proxy;
|
2010-07-29 21:58:16 -04:00
|
|
|
NMSettingsPermissions permissions;
|
2010-07-29 21:28:49 -04:00
|
|
|
gboolean have_permissions;
|
|
|
|
|
char *hostname;
|
|
|
|
|
gboolean can_modify;
|
2009-07-23 09:20:52 -04:00
|
|
|
|
|
|
|
|
DBusGProxy *dbus_proxy;
|
|
|
|
|
|
|
|
|
|
guint fetch_id;
|
|
|
|
|
|
|
|
|
|
gboolean disposed;
|
|
|
|
|
} NMRemoteSettingsPrivate;
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_BUS,
|
2009-09-22 23:29:02 -07:00
|
|
|
PROP_SERVICE_RUNNING,
|
2010-08-03 13:23:30 -04:00
|
|
|
PROP_HOSTNAME,
|
|
|
|
|
PROP_CAN_MODIFY,
|
2009-07-23 09:20:52 -04:00
|
|
|
|
|
|
|
|
LAST_PROP
|
|
|
|
|
};
|
|
|
|
|
|
2010-08-03 13:23:30 -04:00
|
|
|
/* Signals */
|
|
|
|
|
enum {
|
|
|
|
|
NEW_CONNECTION,
|
|
|
|
|
CONNECTIONS_READ,
|
|
|
|
|
CHECK_PERMISSIONS,
|
|
|
|
|
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_remote_settings_get_connection_by_path:
|
|
|
|
|
* @settings: the %NMRemoteSettings
|
|
|
|
|
* @path: the D-Bus object path of the remote connection
|
|
|
|
|
*
|
|
|
|
|
* Returns the %NMRemoteConnection representing the connection at @path.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the remote connection object on success, or NULL if the object was
|
|
|
|
|
* not known
|
|
|
|
|
**/
|
|
|
|
|
NMRemoteConnection *
|
|
|
|
|
nm_remote_settings_get_connection_by_path (NMRemoteSettings *settings, const char *path)
|
2009-07-23 09:20:52 -04:00
|
|
|
{
|
2010-08-03 13:23:30 -04:00
|
|
|
g_return_val_if_fail (settings != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL);
|
|
|
|
|
g_return_val_if_fail (path != NULL, NULL);
|
|
|
|
|
|
2009-07-23 09:20:52 -04:00
|
|
|
return g_hash_table_lookup (NM_REMOTE_SETTINGS_GET_PRIVATE (settings)->connections, path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
connection_removed_cb (NMRemoteConnection *remote, gpointer user_data)
|
|
|
|
|
{
|
2009-08-11 10:33:13 -05:00
|
|
|
NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
|
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
|
|
|
|
|
const char *path;
|
|
|
|
|
|
|
|
|
|
path = nm_connection_get_path (NM_CONNECTION (remote));
|
|
|
|
|
g_hash_table_remove (priv->connections, path);
|
|
|
|
|
g_hash_table_remove (priv->pending, path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
connection_init_result_cb (NMRemoteConnection *remote,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
|
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
|
|
|
|
|
guint32 init_result = NM_REMOTE_CONNECTION_INIT_RESULT_UNKNOWN;
|
|
|
|
|
const char *path;
|
|
|
|
|
|
|
|
|
|
/* Disconnect from the init-result signal just to be safe */
|
|
|
|
|
g_signal_handlers_disconnect_matched (remote,
|
|
|
|
|
G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
NULL,
|
|
|
|
|
G_CALLBACK (connection_init_result_cb),
|
|
|
|
|
self);
|
|
|
|
|
|
|
|
|
|
path = nm_connection_get_path (NM_CONNECTION (remote));
|
|
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (remote),
|
|
|
|
|
NM_REMOTE_CONNECTION_INIT_RESULT, &init_result,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
switch (init_result) {
|
|
|
|
|
case NM_REMOTE_CONNECTION_INIT_RESULT_SUCCESS:
|
|
|
|
|
/* ref it when adding to ->connections, since removing it from ->pending
|
|
|
|
|
* will unref it.
|
|
|
|
|
*/
|
|
|
|
|
g_hash_table_insert (priv->connections, g_strdup (path), g_object_ref (remote));
|
|
|
|
|
|
|
|
|
|
/* Finally, let users know of the new connection now that it has all
|
|
|
|
|
* its settings and is valid.
|
|
|
|
|
*/
|
2010-08-03 13:23:30 -04:00
|
|
|
g_signal_emit (self, signals[NEW_CONNECTION], 0, remote);
|
2009-08-11 10:33:13 -05:00
|
|
|
break;
|
|
|
|
|
case NM_REMOTE_CONNECTION_INIT_RESULT_ERROR:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_hash_table_remove (priv->pending, path);
|
2009-09-22 23:44:45 -07:00
|
|
|
|
|
|
|
|
/* Let listeners know that all connections have been found */
|
|
|
|
|
if (!g_hash_table_size (priv->pending))
|
2010-08-03 13:23:30 -04:00
|
|
|
g_signal_emit (self, signals[CONNECTIONS_READ], 0);
|
2009-07-23 09:20:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
new_connection_cb (DBusGProxy *proxy, const char *path, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
|
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
|
|
|
|
|
NMRemoteConnection *connection;
|
|
|
|
|
|
2010-07-28 02:07:53 -04:00
|
|
|
connection = nm_remote_connection_new (priv->bus, path);
|
2009-07-23 09:20:52 -04:00
|
|
|
if (connection) {
|
|
|
|
|
g_signal_connect (connection, "removed",
|
|
|
|
|
G_CALLBACK (connection_removed_cb),
|
|
|
|
|
self);
|
|
|
|
|
|
2009-08-11 10:33:13 -05:00
|
|
|
g_signal_connect (connection, "notify::" NM_REMOTE_CONNECTION_INIT_RESULT,
|
|
|
|
|
G_CALLBACK (connection_init_result_cb),
|
|
|
|
|
self);
|
|
|
|
|
|
|
|
|
|
/* Add the connection to the pending table to wait for it to retrieve
|
|
|
|
|
* it's settings asynchronously over D-Bus. The connection isn't
|
|
|
|
|
* really valid until it has all its settings, so hide it until it does.
|
|
|
|
|
*/
|
|
|
|
|
g_hash_table_insert (priv->pending, g_strdup (path), connection);
|
2009-07-23 09:20:52 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
fetch_connections_done (DBusGProxy *proxy,
|
|
|
|
|
GPtrArray *connections,
|
|
|
|
|
GError *error,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (error) {
|
2010-07-28 02:07:53 -04:00
|
|
|
g_warning ("%s: error fetching connections: (%d) %s.",
|
2009-07-23 09:20:52 -04:00
|
|
|
__func__,
|
|
|
|
|
error->code,
|
|
|
|
|
error->message ? error->message : "(unknown)");
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-22 23:44:45 -07:00
|
|
|
/* Let listeners know we are done getting connections */
|
|
|
|
|
if (connections->len == 0) {
|
2010-08-03 13:23:30 -04:00
|
|
|
g_signal_emit (self, signals[CONNECTIONS_READ], 0);
|
2009-09-22 23:44:45 -07:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-23 09:20:52 -04:00
|
|
|
for (i = 0; connections && (i < connections->len); i++) {
|
|
|
|
|
char *path = g_ptr_array_index (connections, i);
|
|
|
|
|
|
|
|
|
|
new_connection_cb (proxy, path, user_data);
|
|
|
|
|
g_free (path);
|
|
|
|
|
}
|
|
|
|
|
g_ptr_array_free (connections, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
fetch_connections (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
|
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
priv->fetch_id = 0;
|
|
|
|
|
|
2010-08-07 01:07:44 -04:00
|
|
|
org_freedesktop_NetworkManager_Settings_list_connections_async (priv->proxy,
|
|
|
|
|
fetch_connections_done,
|
|
|
|
|
self);
|
2009-07-23 09:20:52 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-03 13:23:30 -04:00
|
|
|
/**
|
|
|
|
|
* nm_remote_settings_list_connections:
|
|
|
|
|
* @settings: the %NMRemoteSettings
|
|
|
|
|
*
|
|
|
|
|
* Returns: all connections in the remote settings service, represented as
|
|
|
|
|
* %NMRemoteConnection instances
|
|
|
|
|
**/
|
|
|
|
|
GSList *
|
|
|
|
|
nm_remote_settings_list_connections (NMRemoteSettings *settings)
|
2009-07-23 09:20:52 -04:00
|
|
|
{
|
2010-08-03 13:23:30 -04:00
|
|
|
NMRemoteSettingsPrivate *priv;
|
2009-07-23 09:20:52 -04:00
|
|
|
GSList *list = NULL;
|
|
|
|
|
GHashTableIter iter;
|
|
|
|
|
gpointer value;
|
|
|
|
|
|
2010-08-03 13:23:30 -04:00
|
|
|
g_return_val_if_fail (settings != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL);
|
|
|
|
|
|
|
|
|
|
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
|
|
|
|
|
2009-07-23 09:20:52 -04:00
|
|
|
g_hash_table_iter_init (&iter, priv->connections);
|
|
|
|
|
while (g_hash_table_iter_next (&iter, NULL, &value))
|
|
|
|
|
list = g_slist_prepend (list, NM_REMOTE_CONNECTION (value));
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2010-08-03 13:23:30 -04:00
|
|
|
NMRemoteSettings *self;
|
|
|
|
|
NMRemoteSettingsAddConnectionFunc callback;
|
2009-07-23 09:20:52 -04:00
|
|
|
gpointer callback_data;
|
|
|
|
|
} AddConnectionInfo;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
add_connection_done (DBusGProxy *proxy,
|
|
|
|
|
GError *error,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
AddConnectionInfo *info = user_data;
|
|
|
|
|
|
|
|
|
|
info->callback (info->self, error, info->callback_data);
|
|
|
|
|
g_free (info);
|
|
|
|
|
}
|
2010-08-03 13:23:30 -04:00
|
|
|
/**
|
|
|
|
|
* nm_remote_settings_add_connection:
|
|
|
|
|
* @settings: the %NMRemoteSettings
|
|
|
|
|
* @connection: the connection to add. Note that this object's settings will be
|
|
|
|
|
* added, not the object itself
|
|
|
|
|
* @callback: callback to be called when the add operation completes
|
|
|
|
|
* @user_data: caller-specific data passed to @callback
|
|
|
|
|
*
|
|
|
|
|
* Requests that the remote settings service add the given settings to a new
|
|
|
|
|
* connection.
|
|
|
|
|
*
|
|
|
|
|
* Returns: TRUE if the request was successful, FALSE if it failed
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_remote_settings_add_connection (NMRemoteSettings *settings,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
NMRemoteSettingsAddConnectionFunc callback,
|
|
|
|
|
gpointer user_data)
|
2009-07-23 09:20:52 -04:00
|
|
|
{
|
2010-08-03 13:23:30 -04:00
|
|
|
NMRemoteSettingsPrivate *priv;
|
2009-07-23 09:20:52 -04:00
|
|
|
AddConnectionInfo *info;
|
|
|
|
|
GHashTable *new_settings;
|
|
|
|
|
|
2010-08-03 13:23:30 -04:00
|
|
|
g_return_val_if_fail (settings != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
|
|
|
|
|
g_return_val_if_fail (connection != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
|
|
|
|
|
g_return_val_if_fail (callback != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
|
|
|
|
|
2009-07-23 09:20:52 -04:00
|
|
|
info = g_malloc0 (sizeof (AddConnectionInfo));
|
|
|
|
|
info->self = settings;
|
|
|
|
|
info->callback = callback;
|
|
|
|
|
info->callback_data = user_data;
|
|
|
|
|
|
2009-08-11 14:12:48 -05:00
|
|
|
new_settings = nm_connection_to_hash (connection);
|
2010-08-07 01:07:44 -04:00
|
|
|
org_freedesktop_NetworkManager_Settings_add_connection_async (priv->proxy,
|
|
|
|
|
new_settings,
|
|
|
|
|
add_connection_done,
|
|
|
|
|
info);
|
2009-07-23 09:20:52 -04:00
|
|
|
g_hash_table_destroy (new_settings);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
remove_connections (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
|
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
|
|
|
|
|
GHashTableIter iter;
|
|
|
|
|
gpointer value;
|
2009-10-20 11:36:47 -07:00
|
|
|
GSList *list = NULL, *list_iter;
|
2009-07-23 09:20:52 -04:00
|
|
|
|
2009-10-20 11:36:47 -07:00
|
|
|
/* Build up the list of connections; we can't emit "removed" during hash
|
|
|
|
|
* table iteration because emission of the "removed" signal may trigger code
|
|
|
|
|
* that explicitly removes the the connection from the hash table somewhere
|
|
|
|
|
* else.
|
|
|
|
|
*/
|
2009-07-23 09:20:52 -04:00
|
|
|
g_hash_table_iter_init (&iter, priv->connections);
|
|
|
|
|
while (g_hash_table_iter_next (&iter, NULL, &value))
|
2009-10-20 11:36:47 -07:00
|
|
|
list = g_slist_prepend (list, NM_REMOTE_CONNECTION (value));
|
|
|
|
|
|
|
|
|
|
for (list_iter = list; list_iter; list_iter = g_slist_next (list_iter))
|
|
|
|
|
g_signal_emit_by_name (NM_REMOTE_CONNECTION (list_iter->data), "removed");
|
|
|
|
|
g_slist_free (list);
|
2009-07-23 09:20:52 -04:00
|
|
|
|
|
|
|
|
g_hash_table_remove_all (priv->connections);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-29 21:28:49 -04:00
|
|
|
typedef struct {
|
2010-08-03 13:23:30 -04:00
|
|
|
NMRemoteSettings *settings;
|
|
|
|
|
NMRemoteSettingsSaveHostnameFunc callback;
|
2010-07-29 21:28:49 -04:00
|
|
|
gpointer callback_data;
|
|
|
|
|
} SaveHostnameInfo;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
save_hostname_cb (DBusGProxy *proxy,
|
|
|
|
|
DBusGProxyCall *call,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
SaveHostnameInfo *info = user_data;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
|
|
|
|
|
info->callback (info->settings, error, info->callback_data);
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-03 13:23:30 -04:00
|
|
|
/**
|
|
|
|
|
* nm_remote_settings_save_hostname:
|
|
|
|
|
* @settings: the %NMRemoteSettings
|
|
|
|
|
* @hostname: the new persistent hostname to set, or NULL to clear any existing
|
|
|
|
|
* persistent hostname
|
|
|
|
|
* @callback: callback to be called when the hostname operation completes
|
|
|
|
|
* @user_data: caller-specific data passed to @callback
|
|
|
|
|
*
|
|
|
|
|
* Requests that the machine's persistent hostname be set to the specified value
|
|
|
|
|
* or cleared.
|
|
|
|
|
*
|
|
|
|
|
* Returns: TRUE if the request was successful, FALSE if it failed
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_remote_settings_save_hostname (NMRemoteSettings *settings,
|
|
|
|
|
const char *hostname,
|
|
|
|
|
NMRemoteSettingsSaveHostnameFunc callback,
|
|
|
|
|
gpointer user_data)
|
2010-07-29 21:28:49 -04:00
|
|
|
{
|
2010-08-03 13:23:30 -04:00
|
|
|
NMRemoteSettingsPrivate *priv;
|
2010-07-29 21:28:49 -04:00
|
|
|
SaveHostnameInfo *info;
|
|
|
|
|
|
2010-08-03 13:23:30 -04:00
|
|
|
g_return_val_if_fail (settings != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
|
|
|
|
|
g_return_val_if_fail (hostname != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (callback != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
|
|
|
|
|
2010-07-29 21:28:49 -04:00
|
|
|
info = g_malloc0 (sizeof (SaveHostnameInfo));
|
|
|
|
|
info->settings = settings;
|
|
|
|
|
info->callback = callback;
|
|
|
|
|
info->callback_data = user_data;
|
|
|
|
|
|
2010-07-29 21:58:16 -04:00
|
|
|
dbus_g_proxy_begin_call (priv->proxy, "SaveHostname",
|
2010-07-29 21:28:49 -04:00
|
|
|
save_hostname_cb,
|
|
|
|
|
info,
|
|
|
|
|
g_free,
|
|
|
|
|
G_TYPE_STRING, hostname ? hostname : "",
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2010-08-03 13:23:30 -04:00
|
|
|
NMRemoteSettings *settings;
|
|
|
|
|
NMRemoteSettingsGetPermissionsFunc callback;
|
2010-07-29 21:28:49 -04:00
|
|
|
gpointer callback_data;
|
|
|
|
|
} GetPermissionsInfo;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_permissions_cb (DBusGProxy *proxy,
|
|
|
|
|
DBusGProxyCall *call,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GetPermissionsInfo *info = user_data;
|
|
|
|
|
NMRemoteSettings *self = NM_REMOTE_SETTINGS (info->settings);
|
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
|
2010-07-29 21:58:16 -04:00
|
|
|
NMSettingsPermissions permissions = NM_SETTINGS_PERMISSION_NONE;
|
2010-07-29 21:28:49 -04:00
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
dbus_g_proxy_end_call (proxy, call, &error,
|
|
|
|
|
G_TYPE_UINT, &permissions,
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
priv->permissions = permissions;
|
|
|
|
|
priv->have_permissions = !error;
|
|
|
|
|
info->callback (info->settings, permissions, error, info->callback_data);
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-03 13:23:30 -04:00
|
|
|
/**
|
|
|
|
|
* nm_remote_settings_get_permissions:
|
|
|
|
|
* @settings: the %NMRemoteSettings
|
|
|
|
|
* @callback: callback to be called when the permissions operation completes
|
|
|
|
|
* @user_data: caller-specific data passed to @callback
|
|
|
|
|
*
|
|
|
|
|
* Requests an indication of the operations the caller is permitted to perform
|
|
|
|
|
* including those that may require authorization.
|
|
|
|
|
*
|
|
|
|
|
* Returns: TRUE if the request was successful, FALSE if it failed
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_remote_settings_get_permissions (NMRemoteSettings *settings,
|
|
|
|
|
NMRemoteSettingsGetPermissionsFunc callback,
|
|
|
|
|
gpointer user_data)
|
2010-07-29 21:28:49 -04:00
|
|
|
{
|
2010-08-03 13:23:30 -04:00
|
|
|
NMRemoteSettingsPrivate *priv;
|
2010-07-29 21:28:49 -04:00
|
|
|
GetPermissionsInfo *info;
|
|
|
|
|
|
2010-08-03 13:23:30 -04:00
|
|
|
g_return_val_if_fail (settings != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
|
|
|
|
|
g_return_val_if_fail (callback != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
|
|
|
|
|
2010-07-29 21:28:49 -04:00
|
|
|
/* Skip D-Bus if we already have permissions */
|
|
|
|
|
if (priv->have_permissions) {
|
|
|
|
|
callback (settings, priv->permissions, NULL, user_data);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Otherwise fetch them from NM */
|
|
|
|
|
info = g_malloc0 (sizeof (GetPermissionsInfo));
|
|
|
|
|
info->settings = settings;
|
|
|
|
|
info->callback = callback;
|
|
|
|
|
info->callback_data = user_data;
|
|
|
|
|
|
2010-07-29 21:58:16 -04:00
|
|
|
dbus_g_proxy_begin_call (priv->proxy, "GetPermissions",
|
2010-07-29 21:28:49 -04:00
|
|
|
get_permissions_cb,
|
|
|
|
|
info,
|
|
|
|
|
g_free,
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-23 09:20:52 -04:00
|
|
|
static void
|
|
|
|
|
name_owner_changed (DBusGProxy *proxy,
|
|
|
|
|
const char *name,
|
|
|
|
|
const char *old_owner,
|
|
|
|
|
const char *new_owner,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
|
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
|
2010-08-06 21:21:24 -04:00
|
|
|
const char *sname = NM_DBUS_SERVICE;
|
2009-07-23 09:20:52 -04:00
|
|
|
|
|
|
|
|
if (!strcmp (name, sname)) {
|
|
|
|
|
if (priv->fetch_id)
|
|
|
|
|
g_source_remove (priv->fetch_id);
|
|
|
|
|
|
2009-09-22 23:29:02 -07:00
|
|
|
if (new_owner && strlen (new_owner) > 0) {
|
2009-07-23 09:20:52 -04:00
|
|
|
priv->fetch_id = g_idle_add (fetch_connections, self);
|
2009-09-22 23:29:02 -07:00
|
|
|
priv->service_running = TRUE;
|
|
|
|
|
} else {
|
2009-07-23 09:20:52 -04:00
|
|
|
priv->fetch_id = g_idle_add (remove_connections, self);
|
2009-09-22 23:29:02 -07:00
|
|
|
priv->service_running = FALSE;
|
|
|
|
|
}
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_REMOTE_SETTINGS_SERVICE_RUNNING);
|
2009-07-23 09:20:52 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-29 21:28:49 -04:00
|
|
|
static void
|
|
|
|
|
check_permissions_cb (DBusGProxy *proxy, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
|
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
/* Permissions need to be re-fetched */
|
|
|
|
|
priv->have_permissions = FALSE;
|
2010-08-03 13:23:30 -04:00
|
|
|
g_signal_emit (self, signals[CHECK_PERMISSIONS], 0);
|
2010-07-29 21:28:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
properties_changed_cb (DBusGProxy *proxy,
|
|
|
|
|
GHashTable *properties,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
|
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
|
|
|
|
|
GHashTableIter iter;
|
|
|
|
|
gpointer key, tmp;
|
|
|
|
|
|
|
|
|
|
g_hash_table_iter_init (&iter, properties);
|
|
|
|
|
while (g_hash_table_iter_next (&iter, &key, &tmp)) {
|
|
|
|
|
GValue *value = tmp;
|
|
|
|
|
|
|
|
|
|
if (!strcmp ((const char *) key, "Hostname")) {
|
|
|
|
|
g_free (priv->hostname);
|
|
|
|
|
priv->hostname = g_value_dup_string (value);
|
2010-08-03 13:23:30 -04:00
|
|
|
g_object_notify (G_OBJECT (self), NM_REMOTE_SETTINGS_HOSTNAME);
|
2010-07-29 21:28:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strcmp ((const char *) key, "CanModify")) {
|
|
|
|
|
priv->can_modify = g_value_get_boolean (value);
|
2010-08-03 13:23:30 -04:00
|
|
|
g_object_notify (G_OBJECT (self), NM_REMOTE_SETTINGS_CAN_MODIFY);
|
2010-07-29 21:28:49 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_all_cb (DBusGProxy *proxy,
|
|
|
|
|
DBusGProxyCall *call,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
|
|
|
|
|
GHashTable *props = NULL;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
if (!dbus_g_proxy_end_call (proxy, call, &error,
|
|
|
|
|
DBUS_TYPE_G_MAP_OF_VARIANT, &props,
|
|
|
|
|
G_TYPE_INVALID)) {
|
|
|
|
|
/* Don't warn when the call times out because the settings service can't
|
|
|
|
|
* be activated or whatever.
|
|
|
|
|
*/
|
|
|
|
|
if (!(error->domain == DBUS_GERROR && error->code == DBUS_GERROR_NO_REPLY)) {
|
|
|
|
|
g_warning ("%s: couldn't retrieve system settings properties: (%d) %s.",
|
|
|
|
|
__func__,
|
|
|
|
|
error ? error->code : -1,
|
|
|
|
|
(error && error->message) ? error->message : "(unknown)");
|
|
|
|
|
}
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
properties_changed_cb (NULL, props, self);
|
|
|
|
|
g_hash_table_destroy (props);
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-23 09:20:52 -04:00
|
|
|
/****************************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_remote_settings_new:
|
|
|
|
|
* @bus: a valid and connected D-Bus connection
|
|
|
|
|
*
|
|
|
|
|
* Creates a new object representing the remote settings service.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the new remote settings object on success, or %NULL on failure
|
|
|
|
|
**/
|
|
|
|
|
NMRemoteSettings *
|
2010-07-28 02:07:53 -04:00
|
|
|
nm_remote_settings_new (DBusGConnection *bus)
|
2009-07-23 09:20:52 -04:00
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (bus != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
return (NMRemoteSettings *) g_object_new (NM_TYPE_REMOTE_SETTINGS,
|
|
|
|
|
NM_REMOTE_SETTINGS_BUS, bus,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_remote_settings_init (NMRemoteSettings *self)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
|
2009-08-11 10:33:13 -05:00
|
|
|
priv->pending = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
|
2009-07-23 09:20:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GObject *
|
|
|
|
|
constructor (GType type,
|
|
|
|
|
guint n_construct_params,
|
|
|
|
|
GObjectConstructParam *construct_params)
|
|
|
|
|
{
|
|
|
|
|
GObject *object;
|
|
|
|
|
NMRemoteSettingsPrivate *priv;
|
2009-09-22 23:29:02 -07:00
|
|
|
GError *error = NULL;
|
2009-07-23 09:20:52 -04:00
|
|
|
|
|
|
|
|
object = G_OBJECT_CLASS (nm_remote_settings_parent_class)->constructor (type, n_construct_params, construct_params);
|
|
|
|
|
if (!object)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
/* D-Bus proxy for clearing connections on NameOwnerChanged */
|
|
|
|
|
priv->dbus_proxy = dbus_g_proxy_new_for_name (priv->bus,
|
|
|
|
|
"org.freedesktop.DBus",
|
|
|
|
|
"/org/freedesktop/DBus",
|
|
|
|
|
"org.freedesktop.DBus");
|
|
|
|
|
g_assert (priv->dbus_proxy);
|
|
|
|
|
|
|
|
|
|
dbus_g_object_register_marshaller (_nm_marshal_VOID__STRING_STRING_STRING,
|
|
|
|
|
G_TYPE_NONE,
|
|
|
|
|
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_add_signal (priv->dbus_proxy, "NameOwnerChanged",
|
|
|
|
|
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_connect_signal (priv->dbus_proxy,
|
|
|
|
|
"NameOwnerChanged",
|
|
|
|
|
G_CALLBACK (name_owner_changed),
|
|
|
|
|
object, NULL);
|
|
|
|
|
|
2009-09-22 23:29:02 -07:00
|
|
|
if (!dbus_g_proxy_call (priv->dbus_proxy, "NameHasOwner", &error,
|
2010-08-06 21:21:24 -04:00
|
|
|
G_TYPE_STRING, NM_DBUS_SERVICE,
|
2009-09-22 23:29:02 -07:00
|
|
|
G_TYPE_INVALID,
|
|
|
|
|
G_TYPE_BOOLEAN, &priv->service_running,
|
|
|
|
|
G_TYPE_INVALID)) {
|
|
|
|
|
g_warning ("%s (NMRemoteSettings) error getting remote settings service status: (%d) %s\n",
|
|
|
|
|
__func__,
|
|
|
|
|
error ? error->code : -1,
|
|
|
|
|
error && error->message ? error->message : "(unknown)");
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
priv->service_running = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-23 09:20:52 -04:00
|
|
|
priv->proxy = dbus_g_proxy_new_for_name (priv->bus,
|
2010-08-06 21:21:24 -04:00
|
|
|
NM_DBUS_SERVICE,
|
2009-07-23 09:20:52 -04:00
|
|
|
NM_DBUS_PATH_SETTINGS,
|
|
|
|
|
NM_DBUS_IFACE_SETTINGS);
|
|
|
|
|
g_assert (priv->proxy);
|
2010-04-25 22:48:10 -07:00
|
|
|
dbus_g_proxy_set_default_timeout (priv->proxy, G_MAXINT);
|
2009-07-23 09:20:52 -04:00
|
|
|
|
|
|
|
|
dbus_g_proxy_add_signal (priv->proxy, "NewConnection",
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_connect_signal (priv->proxy, "NewConnection",
|
|
|
|
|
G_CALLBACK (new_connection_cb),
|
|
|
|
|
object,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
priv->fetch_id = g_idle_add (fetch_connections, object);
|
|
|
|
|
|
2010-07-29 21:28:49 -04:00
|
|
|
|
|
|
|
|
/* D-Bus properties proxy */
|
|
|
|
|
priv->props_proxy = dbus_g_proxy_new_for_name (priv->bus,
|
2010-08-06 21:21:24 -04:00
|
|
|
NM_DBUS_SERVICE,
|
2010-07-29 21:28:49 -04:00
|
|
|
NM_DBUS_PATH_SETTINGS,
|
|
|
|
|
"org.freedesktop.DBus.Properties");
|
|
|
|
|
g_assert (priv->props_proxy);
|
|
|
|
|
|
2010-07-29 21:58:16 -04:00
|
|
|
/* Monitor properties */
|
2010-07-29 21:28:49 -04:00
|
|
|
dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOXED,
|
|
|
|
|
G_TYPE_NONE,
|
|
|
|
|
DBUS_TYPE_G_MAP_OF_VARIANT,
|
|
|
|
|
G_TYPE_INVALID);
|
2010-07-29 21:58:16 -04:00
|
|
|
dbus_g_proxy_add_signal (priv->proxy, "PropertiesChanged",
|
2010-07-29 21:28:49 -04:00
|
|
|
DBUS_TYPE_G_MAP_OF_VARIANT,
|
|
|
|
|
G_TYPE_INVALID);
|
2010-07-29 21:58:16 -04:00
|
|
|
dbus_g_proxy_connect_signal (priv->proxy, "PropertiesChanged",
|
2010-07-29 21:28:49 -04:00
|
|
|
G_CALLBACK (properties_changed_cb),
|
|
|
|
|
object,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
/* Monitor for permissions changes */
|
2010-07-29 21:58:16 -04:00
|
|
|
dbus_g_proxy_add_signal (priv->proxy, "CheckPermissions", G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_connect_signal (priv->proxy, "CheckPermissions",
|
2010-07-29 21:28:49 -04:00
|
|
|
G_CALLBACK (check_permissions_cb),
|
|
|
|
|
object,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
/* Get properties */
|
|
|
|
|
dbus_g_proxy_begin_call (priv->props_proxy, "GetAll",
|
|
|
|
|
get_all_cb,
|
|
|
|
|
object,
|
|
|
|
|
NULL,
|
2010-07-29 21:58:16 -04:00
|
|
|
G_TYPE_STRING, NM_DBUS_IFACE_SETTINGS,
|
2010-07-29 21:28:49 -04:00
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
|
2009-07-23 09:20:52 -04:00
|
|
|
return object;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dispose (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
if (priv->disposed)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
priv->disposed = TRUE;
|
|
|
|
|
|
|
|
|
|
if (priv->fetch_id)
|
|
|
|
|
g_source_remove (priv->fetch_id);
|
|
|
|
|
|
|
|
|
|
if (priv->connections)
|
|
|
|
|
g_hash_table_destroy (priv->connections);
|
|
|
|
|
|
2009-08-11 10:33:13 -05:00
|
|
|
if (priv->pending)
|
|
|
|
|
g_hash_table_destroy (priv->pending);
|
|
|
|
|
|
2010-07-29 21:28:49 -04:00
|
|
|
g_free (priv->hostname);
|
|
|
|
|
|
2009-07-23 09:20:52 -04:00
|
|
|
g_object_unref (priv->dbus_proxy);
|
|
|
|
|
g_object_unref (priv->proxy);
|
2010-07-29 21:28:49 -04:00
|
|
|
g_object_unref (priv->props_proxy);
|
2009-07-23 09:20:52 -04:00
|
|
|
dbus_g_connection_unref (priv->bus);
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (nm_remote_settings_parent_class)->dispose (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_property (GObject *object, guint prop_id,
|
|
|
|
|
const GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_BUS:
|
|
|
|
|
/* Construct only */
|
|
|
|
|
priv->bus = dbus_g_connection_ref ((DBusGConnection *) g_value_get_boxed (value));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_property (GObject *object, guint prop_id,
|
|
|
|
|
GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_BUS:
|
|
|
|
|
g_value_set_boxed (value, priv->bus);
|
|
|
|
|
break;
|
2009-09-22 23:29:02 -07:00
|
|
|
case PROP_SERVICE_RUNNING:
|
|
|
|
|
g_value_set_boolean (value, priv->service_running);
|
|
|
|
|
break;
|
2010-08-03 13:23:30 -04:00
|
|
|
case PROP_HOSTNAME:
|
2010-07-29 21:28:49 -04:00
|
|
|
g_value_set_string (value, priv->hostname);
|
|
|
|
|
break;
|
2010-08-03 13:23:30 -04:00
|
|
|
case PROP_CAN_MODIFY:
|
2010-07-29 21:28:49 -04:00
|
|
|
g_value_set_boolean (value, priv->can_modify);
|
|
|
|
|
break;
|
2009-07-23 09:20:52 -04:00
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
g_type_class_add_private (class, sizeof (NMRemoteSettingsPrivate));
|
|
|
|
|
|
|
|
|
|
/* Virtual methods */
|
|
|
|
|
object_class->constructor = constructor;
|
|
|
|
|
object_class->set_property = set_property;
|
|
|
|
|
object_class->get_property = get_property;
|
|
|
|
|
object_class->dispose = dispose;
|
|
|
|
|
|
|
|
|
|
/* Properties */
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_BUS,
|
|
|
|
|
g_param_spec_boxed (NM_REMOTE_SETTINGS_BUS,
|
|
|
|
|
"DBusGConnection",
|
|
|
|
|
"DBusGConnection",
|
|
|
|
|
DBUS_TYPE_G_CONNECTION,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
2009-09-22 23:29:02 -07:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_SERVICE_RUNNING,
|
|
|
|
|
g_param_spec_boolean (NM_REMOTE_SETTINGS_SERVICE_RUNNING,
|
|
|
|
|
"Service running",
|
|
|
|
|
"Is service running",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READABLE));
|
2010-07-29 21:28:49 -04:00
|
|
|
|
2010-08-03 13:23:30 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_HOSTNAME,
|
|
|
|
|
g_param_spec_string (NM_REMOTE_SETTINGS_HOSTNAME,
|
|
|
|
|
"Hostname",
|
|
|
|
|
"Persistent hostname",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READABLE));
|
2010-07-29 21:28:49 -04:00
|
|
|
|
2010-08-03 13:23:30 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_CAN_MODIFY,
|
|
|
|
|
g_param_spec_boolean (NM_REMOTE_SETTINGS_CAN_MODIFY,
|
|
|
|
|
"CanModify",
|
|
|
|
|
"Can modify anything (hostname, connections, etc)",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READABLE));
|
2010-07-29 21:28:49 -04:00
|
|
|
|
2010-08-03 13:23:30 -04:00
|
|
|
/* Signals */
|
|
|
|
|
signals[NEW_CONNECTION] =
|
|
|
|
|
g_signal_new (NM_REMOTE_SETTINGS_NEW_CONNECTION,
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (NMRemoteSettingsClass, new_connection),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__OBJECT,
|
|
|
|
|
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
|
|
|
|
|
|
|
|
|
signals[CONNECTIONS_READ] =
|
|
|
|
|
g_signal_new (NM_REMOTE_SETTINGS_CONNECTIONS_READ,
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (NMRemoteSettingsClass, connections_read),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
|
|
signals[CHECK_PERMISSIONS] =
|
|
|
|
|
g_signal_new (NM_REMOTE_SETTINGS_CHECK_PERMISSIONS,
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (NMRemoteSettingsClass, check_permissions),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
2009-07-23 09:20:52 -04:00
|
|
|
}
|
|
|
|
|
|