408
DBusGMethodInvocation *context;
408
NMANewSecretsRequestedFunc callback;
409
gpointer callback_data;
409
410
NMApplet *applet;
410
411
NMActiveConnection *active_connection;
411
412
GtkWidget *dialog;
412
NMConnection *connection;
413
NMSettingsConnectionInterface *connection;
413
414
GtkEntry *secret_entry;
414
415
char *secret_name;
455
update_cb (NMSettingsConnectionInterface *connection,
460
g_warning ("%s: failed to update connection: (%d) %s",
461
__func__, error->code, error->message);
454
466
get_gsm_secrets_cb (GtkDialog *dialog,
458
470
NMGsmInfo *info = (NMGsmInfo *) user_data;
459
NMAGConfConnection *gconf_connection;
460
471
NMSettingGsm *setting;
461
472
GHashTable *settings_hash;
462
473
GHashTable *secrets;
468
479
g_object_weak_unref (G_OBJECT (info->active_connection), destroy_gsm_dialog, info);
470
481
if (response != GTK_RESPONSE_OK) {
471
g_set_error (&err, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_SECRETS_REQUEST_CANCELED,
483
NM_SETTINGS_INTERFACE_ERROR,
484
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
472
485
"%s.%d (%s): canceled",
473
486
__FILE__, __LINE__, __func__);
477
setting = NM_SETTING_GSM (nm_connection_get_setting (info->connection, NM_TYPE_SETTING_GSM));
490
setting = NM_SETTING_GSM (nm_connection_get_setting (NM_CONNECTION (info->connection), NM_TYPE_SETTING_GSM));
479
492
if (!strcmp (info->secret_name, NM_SETTING_GSM_PIN) ||
480
493
!strcmp (info->secret_name, NM_SETTING_GSM_PUK) ||
484
497
secrets = nm_setting_to_hash (NM_SETTING (setting));
486
g_set_error (&err, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
487
"%s.%d (%s): failed to hash setting '%s'.",
488
__FILE__, __LINE__, __func__, nm_setting_get_name (NM_SETTING (setting)));
500
NM_SETTINGS_INTERFACE_ERROR,
501
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
502
"%s.%d (%s): failed to hash setting '%s'.",
503
__FILE__, __LINE__, __func__, nm_setting_get_name (NM_SETTING (setting)));
496
511
g_free, (GDestroyNotify) g_hash_table_destroy);
498
513
g_hash_table_insert (settings_hash, g_strdup (nm_setting_get_name (NM_SETTING (setting))), secrets);
499
dbus_g_method_return (info->context, settings_hash);
514
info->callback (info->connection, settings_hash, NULL, info->callback_data);
500
515
g_hash_table_destroy (settings_hash);
502
517
/* Save the connection back to GConf _after_ hashing it, because
503
518
* saving to GConf might trigger the GConf change notifiers, resulting
504
519
* in the connection being read back in from GConf which clears secrets.
506
gconf_connection = nma_gconf_settings_get_by_connection (info->applet->gconf_settings, info->connection);
507
if (gconf_connection)
508
nma_gconf_connection_save (gconf_connection);
521
if (NMA_IS_GCONF_CONNECTION (info->connection))
522
nm_settings_connection_interface_update (info->connection, update_cb, NULL);
512
526
g_warning ("%s", err->message);
513
dbus_g_method_return_error (info->context, err);
527
info->callback (info->connection, NULL, err, info->callback_data);
514
528
g_error_free (err);
517
nm_connection_clear_secrets (info->connection);
531
nm_connection_clear_secrets (NM_CONNECTION (info->connection));
518
532
destroy_gsm_dialog (info, NULL);
635
649
gsm_get_secrets (NMDevice *device,
636
NMConnection *connection,
650
NMSettingsConnectionInterface *connection,
637
651
NMActiveConnection *active_connection,
638
652
const char *setting_name,
639
653
const char **hints,
640
DBusGMethodInvocation *context,
654
NMANewSecretsRequestedFunc callback,
655
gpointer callback_data,
641
656
NMApplet *applet,
646
661
GtkEntry *secret_entry = NULL;
648
663
if (!hints || !g_strv_length ((char **) hints)) {
649
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
665
NM_SETTINGS_INTERFACE_ERROR,
666
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
650
667
"%s.%d (%s): missing secrets hints.",
651
668
__FILE__, __LINE__, __func__);
655
672
if ( !strcmp (hints[0], NM_SETTING_GSM_PIN)
656
673
|| !strcmp (hints[0], NM_SETTING_GSM_PUK))
657
widget = ask_for_pin_puk (device, connection, hints[0], &secret_entry);
674
widget = ask_for_pin_puk (device, NM_CONNECTION (connection), hints[0], &secret_entry);
658
675
else if (!strcmp (hints[0], NM_SETTING_GSM_PASSWORD))
659
widget = ask_for_password (device, connection, &secret_entry);
676
widget = ask_for_password (device, NM_CONNECTION (connection), &secret_entry);
661
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
679
NM_SETTINGS_INTERFACE_ERROR,
680
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
662
681
"%s.%d (%s): unknown secrets hint '%s'.",
663
682
__FILE__, __LINE__, __func__, hints[0]);
667
686
if (!widget || !secret_entry) {
668
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
688
NM_SETTINGS_INTERFACE_ERROR,
689
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
669
690
"%s.%d (%s): error asking for GSM secrets.",
670
691
__FILE__, __LINE__, __func__);
674
info = g_new (NMGsmInfo, 1);
675
info->context = context;
695
info = g_malloc0 (sizeof (NMGsmInfo));
696
info->callback = callback;
697
info->callback_data = callback_data;
676
698
info->applet = applet;
677
699
info->active_connection = active_connection;
678
700
info->connection = g_object_ref (connection);