192
cdma_new_auto_connection (NMDevice *device,
193
gpointer dclass_data,
194
AppletNewAutoConnectionCallback callback,
195
gpointer callback_data)
197
return do_mobile_wizard (callback, callback_data);
201
dbus_3g_add_and_activate_cb (NMClient *client,
202
NMActiveConnection *active,
203
const char *connection_path,
208
g_warning ("Failed to add/activate connection: (%d) %s", error->code, error->message);
217
dbus_connect_3g_cb (NMConnection *connection,
218
gboolean auto_created,
222
Dbus3gInfo *info = user_data;
224
if (canceled == FALSE) {
225
g_return_if_fail (connection != NULL);
227
/* Ask NM to add the new connection and activate it; NM will fill in the
228
* missing details based on the specific object and the device.
230
nm_client_add_and_activate_connection (info->applet->nm_client,
234
dbus_3g_add_and_activate_cb,
238
g_object_unref (info->device);
239
memset (info, 0, sizeof (*info));
244
applet_cdma_connect_network (NMApplet *applet, NMDevice *device)
248
info = g_malloc0 (sizeof (*info));
249
info->applet = applet;
250
info->device = g_object_ref (device);
252
do_mobile_wizard (dbus_connect_3g_cb, info);
192
256
cdma_menu_item_activate (GtkMenuItem *item, gpointer user_data)
488
539
gpointer user_data)
490
NMCdmaInfo *info = (NMCdmaInfo *) user_data;
491
NMSettingCdma *setting;
492
GHashTable *settings_hash;
496
/* Got a user response, clear the NMActiveConnection destroy handler for
497
* this dialog since this function will now take over dialog destruction.
499
g_object_weak_unref (G_OBJECT (info->active_connection), destroy_cdma_dialog, info);
501
if (response != GTK_RESPONSE_OK) {
503
NM_SETTINGS_INTERFACE_ERROR,
504
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
505
"%s.%d (%s): canceled",
506
__FILE__, __LINE__, __func__);
510
setting = NM_SETTING_CDMA (nm_connection_get_setting (NM_CONNECTION (info->connection), NM_TYPE_SETTING_CDMA));
512
if (!strcmp (info->secret_name, NM_SETTING_CDMA_PASSWORD)) {
513
g_object_set (setting,
514
NM_SETTING_CDMA_PASSWORD, gtk_entry_get_text (info->secret_entry),
518
secrets = nm_setting_to_hash (NM_SETTING (setting));
521
NM_SETTINGS_INTERFACE_ERROR,
522
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
523
"%s.%d (%s): failed to hash setting '%s'.",
524
__FILE__, __LINE__, __func__, nm_setting_get_name (NM_SETTING (setting)));
528
/* Returned secrets are a{sa{sv}}; this is the outer a{s...} hash that
529
* will contain all the individual settings hashes.
531
settings_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
532
g_free, (GDestroyNotify) g_hash_table_destroy);
534
g_hash_table_insert (settings_hash, g_strdup (nm_setting_get_name (NM_SETTING (setting))), secrets);
535
info->callback (info->connection, settings_hash, NULL, info->callback_data);
536
g_hash_table_destroy (settings_hash);
538
/* Save the connection back to GConf _after_ hashing it, because
539
* saving to GConf might trigger the GConf change notifiers, resulting
540
* in the connection being read back in from GConf which clears secrets.
542
if (NMA_IS_GCONF_CONNECTION (info->connection))
543
nm_settings_connection_interface_update (info->connection, update_cb, NULL);
547
g_warning ("%s", err->message);
548
info->callback (info->connection, NULL, err, info->callback_data);
552
nm_connection_clear_secrets (NM_CONNECTION (info->connection));
553
destroy_cdma_dialog (info, NULL);
541
SecretsRequest *req = user_data;
542
NMCdmaSecretsInfo *info = (NMCdmaSecretsInfo *) req;
544
GError *error = NULL;
546
if (response == GTK_RESPONSE_OK) {
547
setting = nm_connection_get_setting (req->connection, NM_TYPE_SETTING_CDMA);
549
g_object_set (G_OBJECT (setting),
550
info->secret_name, gtk_entry_get_text (info->secret_entry),
553
error = g_error_new (NM_SECRET_AGENT_ERROR,
554
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
555
"%s.%d (%s): no GSM setting",
556
__FILE__, __LINE__, __func__);
559
error = g_error_new (NM_SECRET_AGENT_ERROR,
560
NM_SECRET_AGENT_ERROR_USER_CANCELED,
561
"%s.%d (%s): canceled",
562
__FILE__, __LINE__, __func__);
565
applet_secrets_request_complete_setting (req, NM_SETTING_CDMA_SETTING_NAME, error);
566
applet_secrets_request_free (req);
567
g_clear_error (&error);
557
cdma_get_secrets (NMDevice *device,
558
NMSettingsConnectionInterface *connection,
559
NMActiveConnection *active_connection,
560
const char *setting_name,
562
NMANewSecretsRequestedFunc callback,
563
gpointer callback_data,
571
cdma_get_secrets (SecretsRequest *req, GError **error)
573
NMCdmaSecretsInfo *info = (NMCdmaSecretsInfo *) req;
568
574
GtkWidget *widget;
569
575
GtkEntry *secret_entry = NULL;
571
if (!hints || !g_strv_length ((char **) hints)) {
577
applet_secrets_request_set_free_func (req, free_cdma_secrets_info);
579
if (!req->hints || !g_strv_length (req->hints)) {
572
580
g_set_error (error,
573
NM_SETTINGS_INTERFACE_ERROR,
574
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
581
NM_SECRET_AGENT_ERROR,
582
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
575
583
"%s.%d (%s): missing secrets hints.",
576
584
__FILE__, __LINE__, __func__);
587
info->secret_name = g_strdup (req->hints[0]);
580
if (!strcmp (hints[0], NM_SETTING_CDMA_PASSWORD))
581
widget = applet_mobile_password_dialog_new (device, NM_CONNECTION (connection), &secret_entry);
589
if (!strcmp (info->secret_name, NM_SETTING_CDMA_PASSWORD))
590
widget = applet_mobile_password_dialog_new (req->connection, &secret_entry);
583
592
g_set_error (error,
584
NM_SETTINGS_INTERFACE_ERROR,
585
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
593
NM_SECRET_AGENT_ERROR,
594
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
586
595
"%s.%d (%s): unknown secrets hint '%s'.",
587
__FILE__, __LINE__, __func__, hints[0]);
596
__FILE__, __LINE__, __func__, info->secret_name);
599
info->dialog = widget;
600
info->secret_entry = secret_entry;
591
602
if (!widget || !secret_entry) {
592
603
g_set_error (error,
593
NM_SETTINGS_INTERFACE_ERROR,
594
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
604
NM_SECRET_AGENT_ERROR,
605
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
595
606
"%s.%d (%s): error asking for CDMA secrets.",
596
607
__FILE__, __LINE__, __func__);
600
info = g_new (NMCdmaInfo, 1);
601
info->callback = callback;
602
info->callback_data = callback_data;
603
info->applet = applet;
604
info->active_connection = active_connection;
605
info->connection = g_object_ref (connection);
606
info->secret_name = g_strdup (hints[0]);
607
info->dialog = widget;
608
info->secret_entry = secret_entry;
610
611
g_signal_connect (widget, "response", G_CALLBACK (get_cdma_secrets_cb), info);
612
/* Attach a destroy notifier to the NMActiveConnection so we can destroy
613
* the dialog when the active connection goes away.
615
g_object_weak_ref (G_OBJECT (active_connection), destroy_cdma_dialog, info);
617
613
gtk_window_set_position (GTK_WINDOW (widget), GTK_WIN_POS_CENTER_ALWAYS);
618
614
gtk_widget_realize (GTK_WIDGET (widget));
619
615
gtk_window_present (GTK_WINDOW (widget));