430
update_cb (NMSettingsConnectionInterface *connection,
435
g_warning ("%s: failed to update connection: (%d) %s",
436
__func__, error->code, error->message);
429
441
get_cdma_secrets_cb (GtkDialog *dialog,
431
443
gpointer user_data)
433
445
NMCdmaInfo *info = (NMCdmaInfo *) user_data;
434
NMAGConfConnection *gconf_connection;
435
446
NMSettingCdma *setting;
436
447
GHashTable *settings_hash;
437
448
GHashTable *secrets;
443
454
g_object_weak_unref (G_OBJECT (info->active_connection), destroy_cdma_dialog, info);
445
456
if (response != GTK_RESPONSE_OK) {
446
g_set_error (&err, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_SECRETS_REQUEST_CANCELED,
458
NM_SETTINGS_INTERFACE_ERROR,
459
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
447
460
"%s.%d (%s): canceled",
448
461
__FILE__, __LINE__, __func__);
452
setting = NM_SETTING_CDMA (nm_connection_get_setting (info->connection, NM_TYPE_SETTING_CDMA));
465
setting = NM_SETTING_CDMA (nm_connection_get_setting (NM_CONNECTION (info->connection), NM_TYPE_SETTING_CDMA));
454
467
if (!strcmp (info->secret_name, NM_SETTING_CDMA_PASSWORD)) {
455
468
g_object_set (setting,
460
473
secrets = nm_setting_to_hash (NM_SETTING (setting));
462
g_set_error (&err, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
463
"%s.%d (%s): failed to hash setting '%s'.",
464
__FILE__, __LINE__, __func__, nm_setting_get_name (NM_SETTING (setting)));
476
NM_SETTINGS_INTERFACE_ERROR,
477
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
478
"%s.%d (%s): failed to hash setting '%s'.",
479
__FILE__, __LINE__, __func__, nm_setting_get_name (NM_SETTING (setting)));
472
487
g_free, (GDestroyNotify) g_hash_table_destroy);
474
489
g_hash_table_insert (settings_hash, g_strdup (nm_setting_get_name (NM_SETTING (setting))), secrets);
475
dbus_g_method_return (info->context, settings_hash);
490
info->callback (info->connection, settings_hash, NULL, info->callback_data);
476
491
g_hash_table_destroy (settings_hash);
478
493
/* Save the connection back to GConf _after_ hashing it, because
479
494
* saving to GConf might trigger the GConf change notifiers, resulting
480
495
* in the connection being read back in from GConf which clears secrets.
482
gconf_connection = nma_gconf_settings_get_by_connection (info->applet->gconf_settings, info->connection);
483
if (gconf_connection)
484
nma_gconf_connection_save (gconf_connection);
497
if (NMA_IS_GCONF_CONNECTION (info->connection))
498
nm_settings_connection_interface_update (info->connection, update_cb, NULL);
488
502
g_warning ("%s", err->message);
489
dbus_g_method_return_error (info->context, err);
503
info->callback (info->connection, NULL, err, info->callback_data);
490
504
g_error_free (err);
493
nm_connection_clear_secrets (info->connection);
507
nm_connection_clear_secrets (NM_CONNECTION (info->connection));
494
508
destroy_cdma_dialog (info, NULL);
551
565
cdma_get_secrets (NMDevice *device,
552
NMConnection *connection,
553
NMActiveConnection *active_connection,
554
const char *setting_name,
556
DBusGMethodInvocation *context,
566
NMSettingsConnectionInterface *connection,
567
NMActiveConnection *active_connection,
568
const char *setting_name,
570
NMANewSecretsRequestedFunc callback,
571
gpointer callback_data,
560
575
NMCdmaInfo *info;
561
576
GtkWidget *widget;
562
577
GtkEntry *secret_entry = NULL;
564
579
if (!hints || !g_strv_length ((char **) hints)) {
565
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
581
NM_SETTINGS_INTERFACE_ERROR,
582
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
566
583
"%s.%d (%s): missing secrets hints.",
567
584
__FILE__, __LINE__, __func__);
571
588
if (!strcmp (hints[0], NM_SETTING_CDMA_PASSWORD))
572
widget = ask_for_password (device, connection, &secret_entry);
589
widget = ask_for_password (device, NM_CONNECTION (connection), &secret_entry);
574
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
592
NM_SETTINGS_INTERFACE_ERROR,
593
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
575
594
"%s.%d (%s): unknown secrets hint '%s'.",
576
595
__FILE__, __LINE__, __func__, hints[0]);
580
599
if (!widget || !secret_entry) {
581
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
601
NM_SETTINGS_INTERFACE_ERROR,
602
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
582
603
"%s.%d (%s): error asking for CDMA secrets.",
583
604
__FILE__, __LINE__, __func__);
587
608
info = g_new (NMCdmaInfo, 1);
588
info->context = context;
609
info->callback = callback;
610
info->callback_data = callback_data;
589
611
info->applet = applet;
590
612
info->active_connection = active_connection;
591
613
info->connection = g_object_ref (connection);