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

« back to all changes in this revision

Viewing changes to src/applet-device-cdma.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:
403
403
}
404
404
 
405
405
typedef struct {
406
 
        DBusGMethodInvocation *context;
 
406
        NMANewSecretsRequestedFunc callback;
 
407
        gpointer callback_data;
407
408
        NMApplet *applet;
408
 
        NMConnection *connection;
 
409
        NMSettingsConnectionInterface *connection;
409
410
        NMActiveConnection *active_connection;
410
411
        GtkWidget *dialog;
411
412
        GtkEntry *secret_entry;
426
427
}
427
428
 
428
429
static void
 
430
update_cb (NMSettingsConnectionInterface *connection,
 
431
           GError *error,
 
432
           gpointer user_data)
 
433
{
 
434
        if (error) {
 
435
                g_warning ("%s: failed to update connection: (%d) %s",
 
436
                           __func__, error->code, error->message);
 
437
        }
 
438
}
 
439
 
 
440
static void
429
441
get_cdma_secrets_cb (GtkDialog *dialog,
430
442
                     gint response,
431
443
                     gpointer user_data)
432
444
{
433
445
        NMCdmaInfo *info = (NMCdmaInfo *) user_data;
434
 
        NMAGConfConnection *gconf_connection;
435
446
        NMSettingCdma *setting;
436
447
        GHashTable *settings_hash;
437
448
        GHashTable *secrets;
443
454
        g_object_weak_unref (G_OBJECT (info->active_connection), destroy_cdma_dialog, info);
444
455
 
445
456
        if (response != GTK_RESPONSE_OK) {
446
 
                g_set_error (&err, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_SECRETS_REQUEST_CANCELED,
 
457
                g_set_error (&err,
 
458
                             NM_SETTINGS_INTERFACE_ERROR,
 
459
                             NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
447
460
                             "%s.%d (%s): canceled",
448
461
                             __FILE__, __LINE__, __func__);
449
462
                goto done;
450
463
        }
451
464
 
452
 
        setting = NM_SETTING_CDMA (nm_connection_get_setting (info->connection, NM_TYPE_SETTING_CDMA));
 
465
        setting = NM_SETTING_CDMA (nm_connection_get_setting (NM_CONNECTION (info->connection), NM_TYPE_SETTING_CDMA));
453
466
 
454
467
        if (!strcmp (info->secret_name, NM_SETTING_CDMA_PASSWORD)) {
455
468
                g_object_set (setting, 
459
472
 
460
473
        secrets = nm_setting_to_hash (NM_SETTING (setting));
461
474
        if (!secrets) {
462
 
                g_set_error (&err, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
463
 
                                   "%s.%d (%s): failed to hash setting '%s'.",
464
 
                             __FILE__, __LINE__, __func__, nm_setting_get_name (NM_SETTING (setting)));
 
475
                g_set_error (&err,
 
476
                             NM_SETTINGS_INTERFACE_ERROR,
 
477
                             NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
 
478
                             "%s.%d (%s): failed to hash setting '%s'.",
 
479
                             __FILE__, __LINE__, __func__, nm_setting_get_name (NM_SETTING (setting)));
465
480
                goto done;
466
481
        }
467
482
 
472
487
                                                                    g_free, (GDestroyNotify) g_hash_table_destroy);
473
488
 
474
489
        g_hash_table_insert (settings_hash, g_strdup (nm_setting_get_name (NM_SETTING (setting))), secrets);
475
 
        dbus_g_method_return (info->context, settings_hash);
 
490
        info->callback (info->connection, settings_hash, NULL, info->callback_data);
476
491
        g_hash_table_destroy (settings_hash);
477
492
 
478
493
        /* Save the connection back to GConf _after_ hashing it, because
479
494
         * saving to GConf might trigger the GConf change notifiers, resulting
480
495
         * in the connection being read back in from GConf which clears secrets.
481
496
         */
482
 
        gconf_connection = nma_gconf_settings_get_by_connection (info->applet->gconf_settings, info->connection);
483
 
        if (gconf_connection)
484
 
                nma_gconf_connection_save (gconf_connection);
 
497
        if (NMA_IS_GCONF_CONNECTION (info->connection))
 
498
                nm_settings_connection_interface_update (info->connection, update_cb, NULL);
485
499
 
486
500
 done:
487
501
        if (err) {
488
502
                g_warning ("%s", err->message);
489
 
                dbus_g_method_return_error (info->context, err);
 
503
                info->callback (info->connection, NULL, err, info->callback_data);
490
504
                g_error_free (err);
491
505
        }
492
506
 
493
 
        nm_connection_clear_secrets (info->connection);
 
507
        nm_connection_clear_secrets (NM_CONNECTION (info->connection));
494
508
        destroy_cdma_dialog (info, NULL);
495
509
}
496
510
 
549
563
 
550
564
static gboolean
551
565
cdma_get_secrets (NMDevice *device,
552
 
                 NMConnection *connection,
553
 
                 NMActiveConnection *active_connection,
554
 
                 const char *setting_name,
555
 
                 const char **hints,
556
 
                 DBusGMethodInvocation *context,
557
 
                 NMApplet *applet,
558
 
                 GError **error)
 
566
                  NMSettingsConnectionInterface *connection,
 
567
                  NMActiveConnection *active_connection,
 
568
                  const char *setting_name,
 
569
                  const char **hints,
 
570
                  NMANewSecretsRequestedFunc callback,
 
571
                  gpointer callback_data,
 
572
                  NMApplet *applet,
 
573
                  GError **error)
559
574
{
560
575
        NMCdmaInfo *info;
561
576
        GtkWidget *widget;
562
577
        GtkEntry *secret_entry = NULL;
563
578
 
564
579
        if (!hints || !g_strv_length ((char **) hints)) {
565
 
                g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
 
580
                g_set_error (error,
 
581
                             NM_SETTINGS_INTERFACE_ERROR,
 
582
                             NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
566
583
                             "%s.%d (%s): missing secrets hints.",
567
584
                             __FILE__, __LINE__, __func__);
568
585
                return FALSE;
569
586
        }
570
587
 
571
588
        if (!strcmp (hints[0], NM_SETTING_CDMA_PASSWORD))
572
 
                widget = ask_for_password (device, connection, &secret_entry);
 
589
                widget = ask_for_password (device, NM_CONNECTION (connection), &secret_entry);
573
590
        else {
574
 
                g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
 
591
                g_set_error (error,
 
592
                             NM_SETTINGS_INTERFACE_ERROR,
 
593
                             NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
575
594
                             "%s.%d (%s): unknown secrets hint '%s'.",
576
595
                             __FILE__, __LINE__, __func__, hints[0]);
577
596
                return FALSE;
578
597
        }
579
598
 
580
599
        if (!widget || !secret_entry) {
581
 
                g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
 
600
                g_set_error (error,
 
601
                             NM_SETTINGS_INTERFACE_ERROR,
 
602
                             NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
582
603
                             "%s.%d (%s): error asking for CDMA secrets.",
583
604
                             __FILE__, __LINE__, __func__);
584
605
                return FALSE;
585
606
        }
586
607
 
587
608
        info = g_new (NMCdmaInfo, 1);
588
 
        info->context = context;
 
609
        info->callback = callback;
 
610
        info->callback_data = callback_data;
589
611
        info->applet = applet;
590
612
        info->active_connection = active_connection;
591
613
        info->connection = g_object_ref (connection);