~ubuntu-branches/ubuntu/lucid/network-manager-applet/lucid-updates

« back to all changes in this revision

Viewing changes to src/applet-device-gsm.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack, Alexander Sack, Tony Espy
  • Date: 2009-09-14 11:32:57 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090914113257-47x5o2kfwwm95w3l
Tags: 0.8~a~git.20090913t161448.cc2f6be-0ubuntu1
* upstream snapshot 2009-09-13 16:14:48 (GMT)
  + cc2f6bea12daec5f0caf535a3534f07ade5b5cf2

[ Alexander Sack <asac@ubuntu.com> ]
* build depend on libpolkit-gobject-1-dev instead of libpolkit-dbus-dev
  - update debian/control

[ Tony Espy <espy@ubuntu.com> ]
* adjust patches for upstream code base
  - update debian/patches/20_use_full_vpn_dialog_service_name_path.patch
  - update debian/patches/lp328572_dxteam_connect_text.patch
  - update debian/patches/lp337960_dxteam_notification_icon_names.diff
  - update debian/patches/lp341684_device_sensitive_disconnect_notify.patch
* adjust build and runtime depends due to ABI changes in latest NM
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
405
405
}
406
406
 
407
407
typedef struct {
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;
415
416
} NMGsmInfo;
451
452
}
452
453
 
453
454
static void
 
455
update_cb (NMSettingsConnectionInterface *connection,
 
456
           GError *error,
 
457
           gpointer user_data)
 
458
{
 
459
        if (error) {
 
460
                g_warning ("%s: failed to update connection: (%d) %s",
 
461
                           __func__, error->code, error->message);
 
462
        }
 
463
}
 
464
 
 
465
static void
454
466
get_gsm_secrets_cb (GtkDialog *dialog,
455
 
                                gint response,
456
 
                                gpointer user_data)
 
467
                    gint response,
 
468
                    gpointer user_data)
457
469
{
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);
469
480
 
470
481
        if (response != GTK_RESPONSE_OK) {
471
 
                g_set_error (&err, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_SECRETS_REQUEST_CANCELED,
 
482
                g_set_error (&err,
 
483
                             NM_SETTINGS_INTERFACE_ERROR,
 
484
                             NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
472
485
                             "%s.%d (%s): canceled",
473
486
                             __FILE__, __LINE__, __func__);
474
487
                goto done;
475
488
        }
476
489
 
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));
478
491
 
479
492
        if (!strcmp (info->secret_name, NM_SETTING_GSM_PIN) ||
480
493
            !strcmp (info->secret_name, NM_SETTING_GSM_PUK) ||
483
496
 
484
497
        secrets = nm_setting_to_hash (NM_SETTING (setting));
485
498
        if (!secrets) {
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)));
 
499
                g_set_error (&err,
 
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)));
489
504
                goto done;
490
505
        }
491
506
 
496
511
                                                                    g_free, (GDestroyNotify) g_hash_table_destroy);
497
512
 
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);
501
516
 
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.
505
520
         */
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);
509
523
 
510
524
 done:
511
525
        if (err) {
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);
515
529
        }
516
530
 
517
 
        nm_connection_clear_secrets (info->connection);
 
531
        nm_connection_clear_secrets (NM_CONNECTION (info->connection));
518
532
        destroy_gsm_dialog (info, NULL);
519
533
}
520
534
 
633
647
 
634
648
static gboolean
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,
642
657
                 GError **error)
643
658
{
646
661
        GtkEntry *secret_entry = NULL;
647
662
 
648
663
        if (!hints || !g_strv_length ((char **) hints)) {
649
 
                g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
 
664
                g_set_error (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__);
652
669
                return FALSE;
654
671
 
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);
660
677
        else {
661
 
                g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
 
678
                g_set_error (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]);
664
683
                return FALSE;
665
684
        }
666
685
 
667
686
        if (!widget || !secret_entry) {
668
 
                g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
 
687
                g_set_error (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__);
671
692
                return FALSE;
672
693
        }
673
694
 
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);