~ubuntu-branches/ubuntu/utopic/network-manager-applet/utopic-proposed

« back to all changes in this revision

Viewing changes to .pc/lp330608_dxteam_gsm_connect_text.patch/src/applet-device-broadband.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2014-01-06 22:29:40 UTC
  • mfrom: (1.2.35) (0.5.25 sid)
  • Revision ID: package-import@ubuntu.com-20140106222940-kxvsf0nrqhukudst
Tags: 0.9.8.4-1ubuntu1
* Merge changes from Debian, remaining changes:
  - Don't keep a postinst script; we don't need to worry about migration
    from versions prior to 0.9.0.
  - Build-Depend on dh-translations, libappindicator3-dev, docbook-to-man.
  - Different Descriptions for libnm-gtk packages.
  - debian/rules: ship extra icons, use --enable-indicators, export
    translations for Launchpad and fail if any files are missing from
    .install files, or not being installed.
  - debian/rules: use -delete to remove .la/.a files.
  - No notice about netdev group in README.Debian.
  - 11-user-connections.patch: don't use this patch, keep secrets system-wide
    as meant by upstream.
  - 12-force-online.patch: don't use this patch, we deal with the online
    state a different way...
  - lp289466_always_show_tray_icon.patch: always show the tray icon, even
    if NM is not running.
  - lp328572-dxteam-connect-text.patch,
    lp330571_dxteam_wired_connect_text.patch,
    lp330608_dxteam_gsm_connect_text.patch: update notification text to be
    prettier.
  - lp341684_device_sensitive_disconnect_notify.patch: show correct
    notification messages for disconnect events, to be in line with the other
    *connect*text patches.
  - lp460144_correctly_update_notification.patch: cleaner notification
    messages, and allow for messages to be updated instead of cleared.
  - applet-wifi-menu-before-vpn.patch: show Create New and Connect to Hidden
    wifi menu items with the other Wifi items, rather than separated by
    the VPN menus.
  - clear-notification-actions.patch: clear notification actions before
    adding new ones, to not append extra "Don't show this again" buttons.
  - key-certificate-extensions.patch: allow for the extra certificate file
    extension ".key".
  - lp829673_gconf_hide_applet.patch: allow for a gsettings key that disables
    ever showing the applet on the notification area.
  - nm-applet-use-indicator.patch: patch to support showing nm-applet as an
    appindicator in Unity.
  - position_dialogs_to_center_of_the_screen.patch: position dialogs to the
    center of the screen.
  - make_menu_items_insensitive_based_on_permissions.patch,
    hide_policy_items_env_var.patch: provide a method to desensitize or hide
    menu items which are useless given the current policykit policy level of
    the user.
  - applet_adhoc_use_wpa_rsn_part1.patch: enable Ad-Hoc using WPA RSN.
  - lp1048516_dont_req_keyring_in_greeter.patch: don't try to load the
    keyring if the user has no permissions to edit their own connections.
  - lp1048520_delay_pin_dialog_in_greeter.patch: only ask for PIN entry when
    a connection is being established rather than when a modem is detected.
  - rebuild_menu_after_init.patch: force a rebuild of the menu to avoid it
    staying empty on login.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include <nm-device.h>
31
31
#include <nm-device-modem.h>
32
32
#include <nm-utils.h>
33
 
#include <gnome-keyring.h>
34
33
 
35
34
#include "applet.h"
36
35
#include "applet-device-broadband.h"
58
57
 
59
58
        /* Unlock dialog stuff */
60
59
        GtkWidget *dialog;
61
 
        gpointer keyring_id;
 
60
        GCancellable *cancellable;
62
61
} BroadbandDeviceInfo;
63
62
 
64
63
/********************************************************************/
356
355
}
357
356
 
358
357
static void
359
 
keyring_pin_check_cb (GnomeKeyringResult result,
360
 
                      GList *list,
 
358
keyring_pin_check_cb (GObject *source,
 
359
                      GAsyncResult *result,
361
360
                      gpointer user_data)
362
361
{
363
362
        BroadbandDeviceInfo *info = user_data;
364
363
        GList *iter;
365
 
        const char *pin = NULL;
 
364
        GList *list;
 
365
        SecretItem *item;
 
366
        SecretValue *pin = NULL;
 
367
        GHashTable *attributes;
 
368
        GError *error = NULL;
366
369
        const char *simid;
367
370
 
368
 
        info->keyring_id = NULL;
 
371
        list = secret_service_search_finish (NULL, result, &error);
369
372
 
370
 
        if (result != GNOME_KEYRING_RESULT_OK) {
 
373
        if (error != NULL) {
371
374
                /* No saved PIN, just ask the user */
372
375
                unlock_dialog_new (info->device, info);
 
376
                g_error_free (error);
373
377
                return;
374
378
        }
375
379
 
382
386
                for (iter = list;
383
387
                     (pin == NULL) && iter;
384
388
                     iter = g_list_next (iter)) {
385
 
                        GnomeKeyringFound *found = iter->data;
386
 
                        int i;
 
389
                        item = iter->data;
387
390
 
388
391
                        /* Look for a matching "simid" attribute */
389
 
                        for (i = 0; (pin == NULL) && i < found->attributes->len; i++) {
390
 
                                GnomeKeyringAttribute attr = gnome_keyring_attribute_list_index (found->attributes, i);
 
392
                        attributes = secret_item_get_attributes (item);
 
393
                        if (g_strcmp0 (simid, g_hash_table_lookup (attributes, "simid")))
 
394
                                pin = secret_item_get_secret (item);
 
395
                        else
 
396
                                pin = NULL;
 
397
                        g_hash_table_unref (attributes);
391
398
 
392
 
                                if (g_strcmp0 (attr.name, "simid") == 0 &&
393
 
                                    attr.type == GNOME_KEYRING_ATTRIBUTE_TYPE_STRING &&
394
 
                                    g_strcmp0 (attr.value.string, simid) == 0) {
395
 
                                        pin = found->secret;
396
 
                                        break;
397
 
                                }
398
 
                        }
 
399
                        if (pin != NULL)
 
400
                                break;
399
401
                }
400
402
        }
401
403
 
402
404
        if (pin == NULL) {
403
 
                /* Fall back to the first result's PIN */
404
 
                pin = ((GnomeKeyringFound *) list->data)->secret;
 
405
                /* Fall back to the first result's PIN if we have one */
 
406
                if (list)
 
407
                        pin = secret_item_get_secret (list->data);
405
408
                if (pin == NULL) {
406
 
                        /* Should never get here */
407
 
                        g_warn_if_fail (pin != NULL);
408
409
                        unlock_dialog_new (info->device, info);
409
410
                        return;
410
411
                }
411
412
        }
412
413
 
 
414
        /* Send the PIN code to ModemManager */
413
415
        mm_sim_send_pin (info->mm_sim,
414
 
                         pin,
 
416
                         secret_value_get (pin, NULL),
415
417
                         NULL, /* cancellable */
416
418
                         (GAsyncReadyCallback)autounlock_sim_send_pin_ready,
417
419
                         info);
 
420
        secret_value_unref (pin);
418
421
}
419
422
 
420
423
static void
422
425
                     GAsyncResult *res,
423
426
                     BroadbandDeviceInfo *info)
424
427
{
 
428
        GHashTable *attrs;
 
429
 
425
430
        info->mm_sim = mm_modem_get_sim_finish (modem, res, NULL);
426
431
        if (!info->mm_sim)
427
432
                /* Ok, the modem may not need it actually */
434
439
        /* If we have a device ID ask the keyring for any saved SIM-PIN codes */
435
440
        if (mm_modem_get_device_identifier (info->mm_modem) &&
436
441
            mm_modem_get_unlock_required (info->mm_modem) == MM_MODEM_LOCK_SIM_PIN) {
437
 
                g_warn_if_fail (info->keyring_id == NULL);
438
 
                info->keyring_id = gnome_keyring_find_itemsv (GNOME_KEYRING_ITEM_GENERIC_SECRET,
439
 
                                                              keyring_pin_check_cb,
440
 
                                                              info,
441
 
                                                              NULL,
442
 
                                                              "devid",
443
 
                                                              GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
444
 
                                                              mm_modem_get_device_identifier (info->mm_modem),
445
 
                                                              NULL);
446
 
                return;
 
442
                attrs = secret_attributes_build (&mobile_secret_schema, "devid",
 
443
                                                 mm_modem_get_device_identifier (info->mm_modem),
 
444
                                                 NULL);
 
445
                secret_service_search (NULL, &mobile_secret_schema, attrs,
 
446
                                       SECRET_SEARCH_UNLOCK | SECRET_SEARCH_LOAD_SECRETS,
 
447
                                       info->cancellable, keyring_pin_check_cb, info);
 
448
                g_hash_table_unref (attrs);
 
449
        } else {
 
450
                /* Couldn't get a device ID, but unlock required; present dialog */
 
451
                unlock_dialog_new (info->device, info);
447
452
        }
448
453
 
449
454
        /* Couldn't get a device ID, but unlock required; present dialog */
981
986
        if (info->mm_object)
982
987
                g_object_unref (info->mm_object);
983
988
 
984
 
        if (info->keyring_id)
985
 
                gnome_keyring_cancel_request (info->keyring_id);
986
989
        if (info->dialog)
987
990
                unlock_dialog_destroy (info);
 
991
        g_object_unref (info->cancellable);
988
992
 
989
993
        g_slice_free (BroadbandDeviceInfo, info);
990
994
}
1021
1025
        info->device = device;
1022
1026
        info->mm_object = MM_OBJECT (modem_object);
1023
1027
        info->mm_modem = mm_object_get_modem (info->mm_object);
 
1028
        info->cancellable = g_cancellable_new ();
1024
1029
 
1025
1030
        /* Setup signals */
1026
1031