89
88
g_slice_free (CdmaMenuItemInfo, data);
93
AppletNewAutoConnectionCallback callback;
94
gpointer callback_data;
98
mobile_wizard_done (NMAMobileWizard *wizard,
100
NMAMobileWizardAccessMethod *method,
103
AutoCdmaWizardInfo *info = user_data;
104
NMConnection *connection = NULL;
106
if (!canceled && method) {
110
if (method->devtype != NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) {
111
g_warning ("Unexpected device type (not CDMA).");
116
connection = nm_connection_new ();
118
setting = nm_setting_cdma_new ();
119
g_object_set (setting,
120
NM_SETTING_CDMA_NUMBER, "#777",
121
NM_SETTING_CDMA_USERNAME, method->username,
122
NM_SETTING_CDMA_PASSWORD, method->password,
124
nm_connection_add_setting (connection, setting);
127
setting = nm_setting_serial_new ();
128
g_object_set (setting,
129
NM_SETTING_SERIAL_BAUD, 115200,
130
NM_SETTING_SERIAL_BITS, 8,
131
NM_SETTING_SERIAL_PARITY, 'n',
132
NM_SETTING_SERIAL_STOPBITS, 1,
134
nm_connection_add_setting (connection, setting);
136
nm_connection_add_setting (connection, nm_setting_ppp_new ());
138
setting = nm_setting_connection_new ();
139
id = utils_create_mobile_connection_id (method->provider_name, method->plan_name);
140
uuid = nm_utils_uuid_generate ();
141
g_object_set (setting,
142
NM_SETTING_CONNECTION_ID, id,
143
NM_SETTING_CONNECTION_TYPE, NM_SETTING_CDMA_SETTING_NAME,
144
NM_SETTING_CONNECTION_AUTOCONNECT, FALSE,
145
NM_SETTING_CONNECTION_UUID, uuid,
149
nm_connection_add_setting (connection, setting);
153
(*(info->callback)) (connection, TRUE, canceled, info->callback_data);
156
nma_mobile_wizard_destroy (wizard);
161
do_mobile_wizard (AppletNewAutoConnectionCallback callback,
162
gpointer callback_data)
164
NMAMobileWizard *wizard;
165
AutoCdmaWizardInfo *info;
166
NMAMobileWizardAccessMethod *method;
168
info = g_malloc0 (sizeof (AutoCdmaWizardInfo));
169
info->callback = callback;
170
info->callback_data = callback_data;
172
wizard = nma_mobile_wizard_new (NULL, NULL, NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO, FALSE,
173
mobile_wizard_done, info);
175
nma_mobile_wizard_present (wizard);
179
/* Fall back to something */
180
method = g_malloc0 (sizeof (NMAMobileWizardAccessMethod));
181
method->devtype = NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO;
182
method->provider_name = _("CDMA");
183
mobile_wizard_done (NULL, FALSE, method, info);
190
92
cdma_new_auto_connection (NMDevice *device,
191
93
gpointer dclass_data,
192
94
AppletNewAutoConnectionCallback callback,
193
95
gpointer callback_data)
195
return do_mobile_wizard (callback, callback_data);
97
return mobile_helper_wizard (NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO,
456
366
NMApplet *applet)
458
NMSettingConnection *s_con;
459
GdkPixbuf *pixbuf = NULL;
461
368
CdmaDeviceInfo *info;
464
370
info = g_object_get_data (G_OBJECT (device), "devinfo");
467
id = nm_device_get_iface (NM_DEVICE (device));
469
s_con = nm_connection_get_setting_connection (connection);
470
id = nm_setting_connection_get_id (s_con);
474
case NM_DEVICE_STATE_PREPARE:
475
*tip = g_strdup_printf (_("Preparing mobile broadband connection '%s'..."), id);
477
case NM_DEVICE_STATE_CONFIG:
478
*tip = g_strdup_printf (_("Configuring mobile broadband connection '%s'..."), id);
480
case NM_DEVICE_STATE_NEED_AUTH:
481
*tip = g_strdup_printf (_("User authentication required for mobile broadband connection '%s'..."), id);
483
case NM_DEVICE_STATE_IP_CONFIG:
484
*tip = g_strdup_printf (_("Requesting a network address for '%s'..."), id);
486
case NM_DEVICE_STATE_ACTIVATED:
487
mb_state = cdma_state_to_mb_state (info);
488
pixbuf = mobile_helper_get_status_pixbuf (info->quality,
491
cdma_act_to_mb_act (info),
494
if ((mb_state != MB_STATE_UNKNOWN) && info->quality_valid) {
495
gboolean roaming = (mb_state == MB_STATE_ROAMING);
497
*tip = g_strdup_printf (_("Mobile broadband connection '%s' active: (%d%%%s%s)"),
500
roaming ? _("roaming") : "");
502
*tip = g_strdup_printf (_("Mobile broadband connection '%s' active"), id);
514
GtkEntry *secret_entry;
519
free_cdma_secrets_info (SecretsRequest *req)
521
NMCdmaSecretsInfo *info = (NMCdmaSecretsInfo *) req;
524
gtk_widget_hide (info->dialog);
525
gtk_widget_destroy (info->dialog);
527
g_free (info->secret_name);
531
get_cdma_secrets_cb (GtkDialog *dialog,
535
SecretsRequest *req = user_data;
536
NMCdmaSecretsInfo *info = (NMCdmaSecretsInfo *) req;
537
NMSettingCdma *setting;
538
GError *error = NULL;
540
if (response == GTK_RESPONSE_OK) {
541
setting = nm_connection_get_setting_cdma (req->connection);
543
g_object_set (G_OBJECT (setting),
544
info->secret_name, gtk_entry_get_text (info->secret_entry),
547
error = g_error_new (NM_SECRET_AGENT_ERROR,
548
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
549
"%s.%d (%s): no GSM setting",
550
__FILE__, __LINE__, __func__);
553
error = g_error_new (NM_SECRET_AGENT_ERROR,
554
NM_SECRET_AGENT_ERROR_USER_CANCELED,
555
"%s.%d (%s): canceled",
556
__FILE__, __LINE__, __func__);
559
applet_secrets_request_complete_setting (req, NM_SETTING_CDMA_SETTING_NAME, error);
560
applet_secrets_request_free (req);
561
g_clear_error (&error);
373
return mobile_helper_get_icon (device,
378
cdma_state_to_mb_state (info),
379
cdma_act_to_mb_act (info),
381
info->quality_valid);
565
385
cdma_get_secrets (SecretsRequest *req, GError **error)
567
NMCdmaSecretsInfo *info = (NMCdmaSecretsInfo *) req;
569
GtkEntry *secret_entry = NULL;
571
applet_secrets_request_set_free_func (req, free_cdma_secrets_info);
573
if (!req->hints || !g_strv_length (req->hints)) {
575
NM_SECRET_AGENT_ERROR,
576
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
577
"%s.%d (%s): missing secrets hints.",
578
__FILE__, __LINE__, __func__);
581
info->secret_name = g_strdup (req->hints[0]);
583
if (!strcmp (info->secret_name, NM_SETTING_CDMA_PASSWORD))
584
widget = applet_mobile_password_dialog_new (req->connection, &secret_entry);
587
NM_SECRET_AGENT_ERROR,
588
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
589
"%s.%d (%s): unknown secrets hint '%s'.",
590
__FILE__, __LINE__, __func__, info->secret_name);
593
info->dialog = widget;
594
info->secret_entry = secret_entry;
596
if (!widget || !secret_entry) {
598
NM_SECRET_AGENT_ERROR,
599
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
600
"%s.%d (%s): error asking for CDMA secrets.",
601
__FILE__, __LINE__, __func__);
605
g_signal_connect (widget, "response", G_CALLBACK (get_cdma_secrets_cb), info);
607
gtk_window_set_position (GTK_WINDOW (widget), GTK_WIN_POS_CENTER_ALWAYS);
608
gtk_widget_realize (GTK_WIDGET (widget));
609
gtk_window_present (GTK_WINDOW (widget));
387
return mobile_helper_get_secrets (NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO, req, error);