1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License along
15
* with this program; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
* (C) Copyright 2008 Novell, Inc.
19
* (C) Copyright 2008 - 2009 Red Hat, Inc.
25
#include <dbus/dbus.h>
26
#include <dbus/dbus-glib.h>
27
#include <dbus/dbus-glib-lowlevel.h>
28
#include <gnome-keyring.h>
30
#include <nm-setting-connection.h>
31
#include <nm-setting-vpn.h>
32
#include <nm-setting-8021x.h>
34
#include "nma-gconf-connection.h"
35
#include "gconf-helpers.h"
38
#include "nma-marshal.h"
39
#include "nm-settings-interface.h"
41
static NMSettingsConnectionInterface *parent_settings_connection_iface;
43
static void settings_connection_interface_init (NMSettingsConnectionInterface *class);
45
G_DEFINE_TYPE_EXTENDED (NMAGConfConnection, nma_gconf_connection, NM_TYPE_EXPORTED_CONNECTION, 0,
46
G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE,
47
settings_connection_interface_init))
49
#define NMA_GCONF_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NMA_TYPE_GCONF_CONNECTION, NMAGConfConnectionPrivate))
56
} NMAGConfConnectionPrivate;
67
NEW_SECRETS_REQUESTED,
72
static guint signals[LAST_SIGNAL] = { 0 };
75
nma_gconf_connection_new (GConfClient *client, const char *conf_dir)
77
NMConnection *connection;
78
NMAGConfConnection *gconf_connection;
80
g_return_val_if_fail (GCONF_IS_CLIENT (client), NULL);
81
g_return_val_if_fail (conf_dir != NULL, NULL);
83
/* retrieve GConf data */
84
connection = nm_gconf_read_connection (client, conf_dir);
86
gconf_connection = nma_gconf_connection_new_from_connection (client, conf_dir, connection);
87
g_object_unref (connection);
89
nm_warning ("No connection read from GConf at %s.", conf_dir);
90
gconf_connection = NULL;
93
return gconf_connection;
97
nma_gconf_connection_new_from_connection (GConfClient *client,
99
NMConnection *connection)
102
NMAGConfConnection *self;
103
GError *error = NULL;
105
GHashTable *settings;
107
g_return_val_if_fail (GCONF_IS_CLIENT (client), NULL);
108
g_return_val_if_fail (conf_dir != NULL, NULL);
109
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
111
/* Ensure the connection is valid first */
112
success = nm_connection_verify (connection, &error);
114
g_warning ("Invalid connection %s: '%s' / '%s' invalid: %d",
116
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
117
(error && error->message) ? error->message : "(unknown)",
118
error ? error->code : -1);
119
g_clear_error (&error);
123
object = g_object_new (NMA_TYPE_GCONF_CONNECTION,
124
NMA_GCONF_CONNECTION_CLIENT, client,
125
NMA_GCONF_CONNECTION_DIR, conf_dir,
126
NM_CONNECTION_SCOPE, NM_CONNECTION_SCOPE_USER,
131
self = NMA_GCONF_CONNECTION (object);
133
/* Fill certs so that the nm_connection_replace_settings verification works */
134
settings = nm_connection_to_hash (connection);
135
success = nm_connection_replace_settings (NM_CONNECTION (self), settings, NULL);
136
g_hash_table_destroy (settings);
138
/* Already verified the settings above, they had better be OK */
145
nma_gconf_connection_get_gconf_path (NMAGConfConnection *self)
147
g_return_val_if_fail (NMA_IS_GCONF_CONNECTION (self), NULL);
149
return NMA_GCONF_CONNECTION_GET_PRIVATE (self)->dir;
153
add_vpn_user_name (NMConnection *connection)
156
const char *user_name;
158
/* Insert the default VPN username when NM gets the connection; it doesn't
159
* get stored in GConf since it's always available and could change at any
160
* time, so it's inserted on-the-fly.
162
s_vpn = NM_SETTING_VPN (nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN));
164
user_name = g_get_user_name ();
165
g_assert (g_utf8_validate (user_name, -1, NULL));
166
g_object_set (s_vpn, NM_SETTING_VPN_USER_NAME, user_name, NULL);
171
nma_gconf_connection_gconf_changed (NMAGConfConnection *self)
173
NMAGConfConnectionPrivate *priv = NMA_GCONF_CONNECTION_GET_PRIVATE (self);
175
GHashTable *new_settings;
176
GError *error = NULL;
179
new = nm_gconf_read_connection (priv->client, priv->dir);
181
g_warning ("No connection read from GConf at %s.", priv->dir);
185
success = nm_connection_verify (new, &error);
187
g_warning ("%s: Invalid connection %s: '%s' / '%s' invalid: %d",
189
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
190
error->message, error->code);
191
g_object_unref (new);
195
/* Ignore the GConf update if nothing changed */
196
if (nm_connection_compare (NM_CONNECTION (self), new, NM_SETTING_COMPARE_FLAG_EXACT)) {
197
g_object_unref (new);
201
new_settings = nm_connection_to_hash (new);
202
success = nm_connection_replace_settings (NM_CONNECTION (self), new_settings, &error);
203
g_hash_table_destroy (new_settings);
204
g_object_unref (new);
207
g_warning ("%s: '%s' / '%s' invalid: %d",
209
error ? g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)) : "(none)",
210
(error && error->message) ? error->message : "(none)",
211
error ? error->code : -1);
215
add_vpn_user_name (NM_CONNECTION (self));
217
nm_settings_connection_interface_emit_updated (NM_SETTINGS_CONNECTION_INTERFACE (self));
221
g_clear_error (&error);
222
g_signal_emit_by_name (self, NM_SETTINGS_CONNECTION_INTERFACE_REMOVED);
226
/******************************************************/
229
string_to_gvalue (const char *str)
233
val = g_slice_new0 (GValue);
234
g_value_init (val, G_TYPE_STRING);
235
g_value_set_string (val, str);
240
#define FILE_TAG "file://"
243
path_to_gvalue (const char *path)
248
array = g_byte_array_sized_new (strlen (FILE_TAG) + strlen (path) + 1);
249
g_byte_array_append (array, (guint8 *) FILE_TAG, strlen (FILE_TAG));
250
g_byte_array_append (array, (guint8 *) path, strlen (path) + 1); /* +1 for the trailing NULL */
252
val = g_slice_new0 (GValue);
253
g_value_init (val, DBUS_TYPE_G_UCHAR_ARRAY);
254
g_value_take_boxed (val, array);
260
destroy_gvalue (gpointer data)
262
GValue *value = (GValue *) data;
264
g_value_unset (value);
265
g_slice_free (GValue, value);
269
nma_gconf_connection_get_keyring_items (NMAGConfConnection *self,
270
const char *setting_name,
273
NMAGConfConnectionPrivate *priv;
274
NMSettingConnection *s_con;
276
GList *found_list = NULL;
277
GnomeKeyringResult ret;
279
const char *connection_name;
282
g_return_val_if_fail (self != NULL, NULL);
283
g_return_val_if_fail (setting_name != NULL, NULL);
284
g_return_val_if_fail (error != NULL, NULL);
285
g_return_val_if_fail (*error == NULL, NULL);
287
priv = NMA_GCONF_CONNECTION_GET_PRIVATE (self);
289
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (NM_CONNECTION (self), NM_TYPE_SETTING_CONNECTION));
292
connection_name = nm_setting_connection_get_id (s_con);
293
g_assert (connection_name);
295
pre_keyring_callback ();
297
ret = gnome_keyring_find_itemsv_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET,
300
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
301
nm_setting_connection_get_uuid (s_con),
303
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
306
if ((ret != GNOME_KEYRING_RESULT_OK) || (g_list_length (found_list) == 0))
309
secrets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, destroy_gvalue);
311
for (iter = found_list; iter != NULL; iter = g_list_next (iter)) {
312
GnomeKeyringFound *found = (GnomeKeyringFound *) iter->data;
314
const char *key_name = NULL;
316
for (i = 0; i < found->attributes->len; i++) {
317
GnomeKeyringAttribute *attr;
319
attr = &(gnome_keyring_attribute_list_index (found->attributes, i));
320
if ( (strcmp (attr->name, KEYRING_SK_TAG) == 0)
321
&& (attr->type == GNOME_KEYRING_ATTRIBUTE_TYPE_STRING)) {
322
key_name = attr->value.string;
327
if (key_name == NULL) {
329
NM_SETTINGS_INTERFACE_ERROR,
330
NM_SETTINGS_INTERFACE_ERROR_SECRETS_UNAVAILABLE,
331
"%s.%d - Internal error; keyring item '%s/%s' didn't "
332
"have a 'setting-key' attribute.",
333
__FILE__, __LINE__, connection_name, setting_name);
337
g_hash_table_insert (secrets,
339
string_to_gvalue (found->secret));
342
/* The phase1 and phase2 private key are still marked as 'secret' for
343
* backwards compat, but since they don't get stored in the keyring since
344
* they aren't really secret (because we now use paths everywhere and not
345
* the decrypted private key like 0.7.x). So we need to grab them out of
346
* GConf and add them to the returned secret hash.
348
/* Private key path */
350
if (nm_gconf_get_string_helper (priv->client,
352
NM_SETTING_802_1X_PRIVATE_KEY,
353
NM_SETTING_802_1X_SETTING_NAME,
355
g_hash_table_insert (secrets,
356
g_strdup (NM_SETTING_802_1X_PRIVATE_KEY),
357
path_to_gvalue (path));
361
/* Phase2 private key path */
363
if (nm_gconf_get_string_helper (priv->client,
365
NM_SETTING_802_1X_PHASE2_PRIVATE_KEY,
366
NM_SETTING_802_1X_SETTING_NAME,
368
g_hash_table_insert (secrets,
369
g_strdup (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY),
370
path_to_gvalue (path));
375
nm_warning ("%s: error reading secrets: (%d) %s", __func__,
376
(*error)->code, (*error)->message);
377
g_hash_table_destroy (secrets);
381
gnome_keyring_found_list_free (found_list);
386
delete_done (GnomeKeyringResult result, gpointer user_data)
391
clear_keyring_items (NMAGConfConnection *self)
393
NMSettingConnection *s_con;
395
GList *found_list = NULL;
396
GnomeKeyringResult ret;
399
g_return_if_fail (self != NULL);
401
s_con = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (self), NM_TYPE_SETTING_CONNECTION);
402
g_return_if_fail (s_con != NULL);
404
uuid = nm_setting_connection_get_uuid (s_con);
405
g_return_if_fail (uuid != NULL);
407
pre_keyring_callback ();
409
ret = gnome_keyring_find_itemsv_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET,
412
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
415
if (ret == GNOME_KEYRING_RESULT_OK) {
416
for (iter = found_list; iter != NULL; iter = g_list_next (iter)) {
417
GnomeKeyringFound *found = (GnomeKeyringFound *) iter->data;
419
gnome_keyring_item_delete (found->keyring,
425
gnome_keyring_found_list_free (found_list);
430
nma_gconf_connection_update (NMAGConfConnection *self,
431
gboolean ignore_secrets)
433
NMAGConfConnectionPrivate *priv = NMA_GCONF_CONNECTION_GET_PRIVATE (self);
435
nm_gconf_write_connection (NM_CONNECTION (self),
439
gconf_client_notify (priv->client, priv->dir);
440
gconf_client_suggest_sync (priv->client, NULL);
443
/******************************************************/
446
is_otp_always_ask (NMConnection *connection)
448
NMSetting8021x *s_8021x;
449
NMSettingConnection *s_con;
450
const char *uuid, *eap_method, *phase2;
452
s_8021x = (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
454
gboolean can_always_ask = FALSE;
456
/* Check if PEAP or TTLS is used */
457
eap_method = nm_setting_802_1x_get_eap_method (s_8021x, 0);
458
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
459
if (!strcmp (eap_method, "peap"))
460
can_always_ask = TRUE;
461
else if (!strcmp (eap_method, "ttls")) {
462
/* Now make sure the phase2 method isn't TLS */
463
phase2 = nm_setting_802_1x_get_phase2_auth (s_8021x);
464
if (phase2 && strcmp (phase2, "tls"))
465
can_always_ask = TRUE;
467
phase2 = nm_setting_802_1x_get_phase2_autheap (s_8021x);
468
if (phase2 && strcmp (phase2, "tls"))
469
can_always_ask = TRUE;
473
if (can_always_ask) {
474
uuid = nm_setting_connection_get_uuid (s_con);
475
if (nm_gconf_get_8021x_password_always_ask (uuid))
483
update (NMSettingsConnectionInterface *connection,
484
NMSettingsConnectionInterfaceUpdateFunc callback,
489
always_ask = is_otp_always_ask (NM_CONNECTION (connection));
491
/* It's assumed that secrets are included in the new connection data.
492
* However, update the secrets only if "always ask" is not set.
494
nma_gconf_connection_update (NMA_GCONF_CONNECTION (connection), always_ask);
496
return parent_settings_connection_iface->update (connection, callback, user_data);
500
do_delete (NMSettingsConnectionInterface *connection,
501
NMSettingsConnectionInterfaceDeleteFunc callback,
504
NMAGConfConnectionPrivate *priv = NMA_GCONF_CONNECTION_GET_PRIVATE (connection);
506
GError *error = NULL;
508
/* Clean up keyring keys */
509
clear_keyring_items (NMA_GCONF_CONNECTION (connection));
511
success = gconf_client_recursive_unset (priv->client, priv->dir, 0, &error);
513
callback (connection, error, user_data);
514
g_error_free (error);
517
gconf_client_suggest_sync (priv->client, NULL);
519
return parent_settings_connection_iface->delete (connection, callback, user_data);
523
internal_get_secrets (NMSettingsConnectionInterface *connection,
524
const char *setting_name,
526
gboolean request_new,
528
NMANewSecretsRequestedFunc callback,
529
gpointer callback_data,
532
NMAGConfConnection *self = NMA_GCONF_CONNECTION (connection);
533
GHashTable *settings = NULL;
534
GHashTable *secrets = NULL;
535
NMSettingConnection *s_con;
537
const char *connection_id;
538
const char *connection_type;
540
setting = nm_connection_get_setting_by_name (NM_CONNECTION (self), setting_name);
543
NM_SETTINGS_INTERFACE_ERROR,
544
NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
545
"%s.%d - Connection didn't have requested setting '%s'.",
546
__FILE__, __LINE__, setting_name);
550
s_con = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (self), NM_TYPE_SETTING_CONNECTION);
552
connection_id = nm_setting_connection_get_id (s_con);
553
connection_type = nm_setting_connection_get_connection_type (s_con);
555
if (!s_con || !connection_id || !strlen (connection_id) || !connection_type) {
557
NM_SETTINGS_INTERFACE_ERROR,
558
NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
559
"%s.%d - Connection didn't have required '"
560
NM_SETTING_CONNECTION_SETTING_NAME
561
"' setting , or the connection name was invalid.",
566
/* Only try to get new secrets for D-Bus requests */
568
secrets = nma_gconf_connection_get_keyring_items (self, setting_name, error);
569
if (!secrets && error && *error)
572
/* VPN passwords are handled by the VPN plugin's auth dialog */
573
if (!strcmp (connection_type, NM_SETTING_VPN_SETTING_NAME))
577
nm_info ("New secrets for %s/%s requested; ask the user",
578
connection_id, setting_name);
579
nm_connection_clear_secrets (NM_CONNECTION (self));
583
/* OTP connections marked as always ask */
584
if (is_otp_always_ask (NM_CONNECTION (self)))
587
secrets = nma_gconf_connection_get_keyring_items (self, setting_name, error);
592
nm_info ("No keyring secrets found for %s/%s; asking user.",
593
connection_id, setting_name);
597
if (g_hash_table_size (secrets) == 0) {
598
g_hash_table_destroy (secrets);
599
nm_warning ("%s.%d - Secrets were found for setting '%s' but none"
600
" were valid.", __FILE__, __LINE__, setting_name);
604
/* If there were hints, and none of the hints were returned by the keyring,
605
* get some new secrets.
607
if (hints && g_strv_length ((char **) hints)) {
610
gboolean found = FALSE;
612
g_hash_table_iter_init (&iter, secrets);
613
while (g_hash_table_iter_next (&iter, &key, &value) && !found) {
614
const char **hint = hints;
616
while (!found && *hint) {
617
if (!strcmp (*hint, (const char *) key) && value && G_IS_VALUE (value)) {
626
g_hash_table_destroy (secrets);
632
/* Returned secrets are a{sa{sv}}; this is the outer a{s...} hash that
633
* will contain all the individual settings hashes.
635
settings = g_hash_table_new_full (g_str_hash, g_str_equal,
637
(GDestroyNotify) g_hash_table_destroy);
639
g_hash_table_insert (settings, g_strdup (setting_name), secrets);
640
callback (NM_SETTINGS_CONNECTION_INTERFACE (self), settings, NULL, callback_data);
641
g_hash_table_destroy (settings);
646
signals[NEW_SECRETS_REQUESTED],
657
NMSettingsConnectionInterfaceGetSecretsFunc callback;
658
gpointer callback_data;
662
get_secrets_cb (NMSettingsConnectionInterface *connection,
663
GHashTable *settings,
667
GetSecretsInfo *info = user_data;
669
info->callback (NM_SETTINGS_CONNECTION_INTERFACE (connection), settings, error, info->callback_data);
674
get_secrets (NMSettingsConnectionInterface *connection,
675
const char *setting_name,
677
gboolean request_new,
678
NMSettingsConnectionInterfaceGetSecretsFunc callback,
681
GetSecretsInfo *info;
682
GError *error = NULL;
684
info = g_malloc0 (sizeof (GetSecretsInfo));
685
info->callback = callback;
686
info->callback_data = user_data;
688
if (!internal_get_secrets (connection,
696
callback (NM_SETTINGS_CONNECTION_INTERFACE (connection), NULL, error, user_data);
697
g_error_free (error);
705
/******************************************************/
708
is_dbus_request_authorized (DBusGMethodInvocation *context,
712
DBusGConnection *bus = NULL;
713
DBusConnection *connection = NULL;
715
gulong sender_uid = G_MAXULONG;
716
DBusError dbus_error;
717
gboolean success = FALSE;
719
sender = dbus_g_method_get_sender (context);
721
g_set_error (error, NM_SETTINGS_INTERFACE_ERROR,
722
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
723
"%s", "Could not determine D-Bus requestor");
727
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
729
g_set_error (error, NM_SETTINGS_INTERFACE_ERROR,
730
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
731
"%s", "Could not get the system bus");
734
connection = dbus_g_connection_get_connection (bus);
736
g_set_error (error, NM_SETTINGS_INTERFACE_ERROR,
737
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
738
"%s", "Could not get the D-Bus system bus");
742
dbus_error_init (&dbus_error);
743
sender_uid = dbus_bus_get_unix_user (connection, sender, &dbus_error);
744
if (dbus_error_is_set (&dbus_error)) {
745
dbus_error_free (&dbus_error);
746
g_set_error (error, NM_SETTINGS_INTERFACE_ERROR,
747
NM_SETTINGS_INTERFACE_ERROR_PERMISSION_DENIED,
748
"%s", "Could not determine the Unix user ID of the requestor");
752
/* And finally, the actual UID check */
753
if ( (allow_user && (sender_uid == geteuid()))
754
|| (sender_uid == 0))
757
g_set_error (error, NM_SETTINGS_INTERFACE_ERROR,
758
NM_SETTINGS_INTERFACE_ERROR_PERMISSION_DENIED,
759
"%s", "Requestor UID does not match the UID of the user settings service");
764
dbus_g_connection_unref (bus);
770
con_update_cb (NMSettingsConnectionInterface *connection,
774
DBusGMethodInvocation *context = user_data;
777
dbus_g_method_return_error (context, error);
779
dbus_g_method_return (context);
783
dbus_update (NMExportedConnection *exported,
784
GHashTable *new_settings,
785
DBusGMethodInvocation *context)
787
NMAGConfConnection *self = NMA_GCONF_CONNECTION (exported);
789
gboolean success = FALSE;
790
GError *error = NULL;
792
/* Restrict Update to execution by the current user and root for DBus invocation */
793
if (!is_dbus_request_authorized (context, TRUE, &error)) {
794
dbus_g_method_return_error (context, error);
795
g_error_free (error);
799
new = nm_connection_new_from_hash (new_settings, &error);
801
dbus_g_method_return_error (context, error);
802
g_error_free (error);
805
g_object_unref (new);
807
success = nm_connection_replace_settings (NM_CONNECTION (self), new_settings, NULL);
808
/* Settings better be valid; we verified them above */
811
nm_settings_connection_interface_update (NM_SETTINGS_CONNECTION_INTERFACE (self),
817
con_delete_cb (NMSettingsConnectionInterface *connection,
821
DBusGMethodInvocation *context = user_data;
824
dbus_g_method_return_error (context, error);
826
dbus_g_method_return (context);
830
dbus_delete (NMExportedConnection *exported,
831
DBusGMethodInvocation *context)
833
NMAGConfConnection *self = NMA_GCONF_CONNECTION (exported);
834
GError *error = NULL;
836
/* Restrict Update to execution by the current user and root for DBus invocation */
837
if (!is_dbus_request_authorized (context, TRUE, &error)) {
838
dbus_g_method_return_error (context, error);
839
g_error_free (error);
843
nm_settings_connection_interface_delete (NM_SETTINGS_CONNECTION_INTERFACE (self),
849
dbus_get_secrets_cb (NMSettingsConnectionInterface *connection,
850
GHashTable *settings,
854
DBusGMethodInvocation *context = user_data;
857
dbus_g_method_return_error (context, error);
859
dbus_g_method_return (context, settings);
863
dbus_get_secrets (NMExportedConnection *connection,
864
const gchar *setting_name,
866
gboolean request_new,
867
DBusGMethodInvocation *context)
869
GError *error = NULL;
871
/* Restrict GetSecrets to execution by root for DBus invocation */
872
if (!is_dbus_request_authorized (context, FALSE, &error)) {
873
dbus_g_method_return_error (context, error);
874
g_error_free (error);
878
if (!internal_get_secrets (NM_SETTINGS_CONNECTION_INTERFACE (connection),
886
dbus_g_method_return_error (context, error);
887
g_error_free (error);
892
dbus_get_settings (NMExportedConnection *connection, GError **error)
894
add_vpn_user_name (NM_CONNECTION (connection));
896
return NM_EXPORTED_CONNECTION_CLASS (nma_gconf_connection_parent_class)->get_settings (connection, error);
899
/************************************************************/
902
settings_connection_interface_init (NMSettingsConnectionInterface *iface)
904
parent_settings_connection_iface = g_type_interface_peek_parent (iface);
906
iface->update = update;
907
iface->delete = do_delete;
908
iface->get_secrets = get_secrets;
912
nma_gconf_connection_init (NMAGConfConnection *connection)
917
constructor (GType type,
918
guint n_construct_params,
919
GObjectConstructParam *construct_params)
922
NMAGConfConnectionPrivate *priv;
924
object = G_OBJECT_CLASS (nma_gconf_connection_parent_class)->constructor (type, n_construct_params, construct_params);
929
priv = NMA_GCONF_CONNECTION_GET_PRIVATE (object);
932
nm_warning ("GConfClient not provided.");
933
g_object_unref (object);
938
nm_warning ("GConf directory not provided.");
939
g_object_unref (object);
947
dispose (GObject *object)
949
NMAGConfConnectionPrivate *priv = NMA_GCONF_CONNECTION_GET_PRIVATE (object);
953
priv->disposed = TRUE;
955
g_object_unref (priv->client);
957
G_OBJECT_CLASS (nma_gconf_connection_parent_class)->dispose (object);
961
finalize (GObject *object)
963
NMAGConfConnectionPrivate *priv = NMA_GCONF_CONNECTION_GET_PRIVATE (object);
967
G_OBJECT_CLASS (nma_gconf_connection_parent_class)->finalize (object);
971
set_property (GObject *object, guint prop_id,
972
const GValue *value, GParamSpec *pspec)
974
NMAGConfConnectionPrivate *priv = NMA_GCONF_CONNECTION_GET_PRIVATE (object);
979
priv->client = GCONF_CLIENT (g_value_dup_object (value));
983
priv->dir = g_value_dup_string (value);
986
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
992
get_property (GObject *object, guint prop_id,
993
GValue *value, GParamSpec *pspec)
995
NMAGConfConnectionPrivate *priv = NMA_GCONF_CONNECTION_GET_PRIVATE (object);
999
g_value_set_object (value, priv->client);
1002
g_value_set_string (value, priv->dir);
1005
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1011
nma_gconf_connection_class_init (NMAGConfConnectionClass *class)
1013
GObjectClass *object_class = G_OBJECT_CLASS (class);
1014
NMExportedConnectionClass *ec_class = NM_EXPORTED_CONNECTION_CLASS (class);
1016
g_type_class_add_private (class, sizeof (NMAGConfConnectionPrivate));
1018
/* Virtual methods */
1019
object_class->constructor = constructor;
1020
object_class->set_property = set_property;
1021
object_class->get_property = get_property;
1022
object_class->dispose = dispose;
1023
object_class->finalize = finalize;
1025
ec_class->update = dbus_update;
1026
ec_class->delete = dbus_delete;
1027
ec_class->get_secrets = dbus_get_secrets;
1028
ec_class->get_settings = dbus_get_settings;
1031
g_object_class_install_property
1032
(object_class, PROP_CLIENT,
1033
g_param_spec_object (NMA_GCONF_CONNECTION_CLIENT,
1037
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
1039
g_object_class_install_property
1040
(object_class, PROP_DIR,
1041
g_param_spec_string (NMA_GCONF_CONNECTION_DIR,
1045
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
1048
signals[NEW_SECRETS_REQUESTED] =
1049
g_signal_new ("new-secrets-requested",
1050
G_OBJECT_CLASS_TYPE (object_class),
1052
G_STRUCT_OFFSET (NMAGConfConnectionClass, new_secrets_requested),
1054
nma_marshal_VOID__STRING_POINTER_BOOLEAN_POINTER_POINTER,
1056
G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN, G_TYPE_POINTER, G_TYPE_POINTER);