280
283
do_mobile_wizard (dbus_connect_3g_cb, info);
288
NMConnection *connection;
290
gpointer dclass_data;
292
} DelayedActivationHelper;
294
gboolean delayed_activation_cb(gpointer user_data)
296
DelayedActivationHelper *helper = user_data;
298
if (!NM_IS_DEVICE (helper->device)) {
299
// the device has been unplugged.
303
GsmDeviceInfo *devinfo = g_object_get_data (G_OBJECT (helper->device), "devinfo");
305
if (devinfo->unlock_required == NULL) {
306
// the modem was successfully unlocked
308
applet_menu_item_activate_helper (helper->device,
312
helper->dclass_data);
316
helper->wait_retry -= 1;
317
if (helper->wait_retry == 0) {
324
void gsm_menu_item_activate_unlock_dialog_destroy (GtkWidget *object,
327
GSMMenuItemInfo *info = (GSMMenuItemInfo *) user_data;
328
GsmDeviceInfo *devinfo;
329
DelayedActivationHelper *helper;
332
* The dialog is destroyed. Either the PIN code was successfully
333
* forwarded to ModemManager or the dialog was cancelled.
334
* Unfortunately we don't have any means of determine which is the case.
336
* The solution here is to monitor GsmDeviceInfo::unlock_required. If that
337
* is cleared, then we know that the modem has been activated and we can
338
* continue with the activation.
340
* Because unlock_required is updated upon receiving a property changed
341
* signal we have to give MM some time to deliver the change over D-Bus.
343
* Here we set up a timer which checks the state of the modem three times
344
* with 1 second delay.
346
* If the modem was not successfully activated this delayed activation is
347
* cancelled after three tries/seconds.
350
devinfo = g_object_get_data (G_OBJECT (info->device), "devinfo");
352
helper = g_malloc (sizeof (DelayedActivationHelper));
353
helper->device = info->device;
354
helper->connection = info->connection;
355
helper->applet = info->applet;
356
helper->dclass_data = info;
357
helper->wait_retry = 3;
359
g_timeout_add_full (G_PRIORITY_DEFAULT,
361
(GSourceFunc)delayed_activation_cb,
363
(GDestroyNotify)g_free);
284
367
gsm_menu_item_activate (GtkMenuItem *item, gpointer user_data)
286
369
GSMMenuItemInfo *info = (GSMMenuItemInfo *) user_data;
370
GsmDeviceInfo *devinfo;
372
devinfo = g_object_get_data (G_OBJECT (info->device), "devinfo");
373
if (devinfo->greeter_mode && devinfo->unlock_required != NULL) {
375
/* We need to delay the activation until the modem is unlocked. */
377
unlock_dialog_new(devinfo->device, devinfo);
379
* The dialog gets destroyed if
381
* A) User enters the correct PIN and ModemManager tells nm-applet
382
* that the modem was successfully activated.
384
* The dialog does not get destroyed, however, if the PIN code
385
* is incorrect. The dialog shows an error message and the user can
386
* either enter a new PIN code or Cancel.
388
* All this happens in the dialogs response handler or callback that
389
* handles the PIN activation return value from ModemManager.
390
* See the relevant functions later in this file.
392
* B) The user cancels the dialog.
394
g_signal_connect (devinfo->dialog, "destroy", G_CALLBACK (gsm_menu_item_activate_unlock_dialog_destroy), info);
288
398
applet_menu_item_activate_helper (info->device,
289
399
info->connection,