~ubuntu-branches/ubuntu/precise/network-manager/precise

« back to all changes in this revision

Viewing changes to src/modem-manager/nm-modem-gsm.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2012-02-09 16:45:41 UTC
  • mfrom: (1.1.53)
  • Revision ID: package-import@ubuntu.com-20120209164541-4h90zknlsfdb7x35
Tags: 0.9.2.0+git201202091925.c721477-0ubuntu1
* upstream snapshot 2012-02-09 19:25:59 (GMT)
  + c721477d11d4fe144111d6d2eec8f93f2e9186c9
* debian/patches/avoid-periodic-disk-wakeups.patch: refreshed.
* debian/patches/nl3-default-ip6-route.patch: refreshed.
* debian/libnm-glib4.symbols: add symbols:
  + nm_active_connection_get_master@Base
  + nm_client_new_async@Base
  + nm_client_new_finish@Base
  + nm_remote_settings_new_async@Base
  + nm_remote_settings_new_finish@Base
  + nm_device_get_state_reason@Base
* debian/libnm-util2.symbols: add symbols:
  + nm_setting_802_1x_get_pac_file@Base
  + nm_setting_infiniband_get_transport_mode@Base

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "nm-device-private.h"
31
31
#include "nm-setting-connection.h"
32
32
#include "nm-setting-gsm.h"
 
33
#include "nm-setting-ppp.h"
33
34
#include "nm-modem-types.h"
34
35
#include "nm-logging.h"
35
36
#include "NetworkManagerUtils.h"
70
71
 
71
72
        GHashTable *connect_properties;
72
73
        guint32 pin_tries;
 
74
 
 
75
        guint enable_delay_id;
73
76
} NMModemGsmPrivate;
74
77
 
75
78
 
247
250
 
248
251
static void stage1_enable_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data);
249
252
 
250
 
static void
 
253
/* do_enable() is used as a GSourceFunc, hence the gboolean return */
 
254
static gboolean
251
255
do_enable (NMModemGsm *self)
252
256
{
253
257
        DBusGProxy *proxy;
254
258
 
255
 
        g_return_if_fail (self != NULL);
256
 
        g_return_if_fail (NM_IS_MODEM_GSM (self));
 
259
        g_return_val_if_fail (self != NULL, FALSE);
 
260
        g_return_val_if_fail (NM_IS_MODEM_GSM (self), FALSE);
257
261
 
 
262
        NM_MODEM_GSM_GET_PRIVATE (self)->enable_delay_id = 0;
258
263
        proxy = nm_modem_get_proxy (NM_MODEM (self), MM_DBUS_INTERFACE_MODEM);
259
264
        dbus_g_proxy_begin_call_with_timeout (proxy,
260
265
                                              "Enable", stage1_enable_done,
261
266
                                              self, NULL, 20000,
262
267
                                              G_TYPE_BOOLEAN, TRUE,
263
268
                                              G_TYPE_INVALID);
 
269
        return FALSE;
264
270
}
265
271
 
266
272
static void
267
273
stage1_pin_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
268
274
{
269
275
        NMModemGsm *self = NM_MODEM_GSM (user_data);
 
276
        NMModemGsmPrivate *priv = NM_MODEM_GSM_GET_PRIVATE (self);
270
277
        NMDeviceStateReason reason;
271
278
        GError *error = NULL;
272
279
 
273
280
        if (dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)) {
274
 
                /* Success; go back and try the enable again */
275
 
                do_enable (self);
 
281
                /* Success; try to enable the modem again.  Wait a few seconds to ensure
 
282
                 * that ModemManager is ready for the enable right after the unlock.
 
283
                 */
 
284
                if (priv->enable_delay_id == 0)
 
285
                        priv->enable_delay_id = g_timeout_add_seconds (4, (GSourceFunc) do_enable, self);
276
286
        } else {
277
287
                nm_log_warn (LOGD_MB, "GSM PIN unlock failed: (%d) %s",
278
288
                             error ? error->code : -1,
501
511
                          GError **error)
502
512
{
503
513
        NMSettingGsm *s_gsm;
 
514
        NMSettingPPP *s_ppp;
504
515
 
505
516
        s_gsm = nm_connection_get_setting_gsm (connection);
506
517
        if (!s_gsm || !nm_setting_gsm_get_apn (s_gsm)) {
515
526
        if (!nm_setting_gsm_get_number (s_gsm))
516
527
                g_object_set (G_OBJECT (s_gsm), NM_SETTING_GSM_NUMBER, "*99#", NULL);
517
528
 
 
529
        s_ppp = nm_connection_get_setting_ppp (connection);
 
530
        if (!s_ppp) {
 
531
                s_ppp = (NMSettingPPP *) nm_setting_ppp_new ();
 
532
                g_object_set (G_OBJECT (s_ppp),
 
533
                              NM_SETTING_PPP_LCP_ECHO_FAILURE, 5,
 
534
                              NM_SETTING_PPP_LCP_ECHO_INTERVAL, 30,
 
535
                              NULL);
 
536
                nm_connection_add_setting (connection, NM_SETTING (s_ppp));
 
537
        }
 
538
 
518
539
        nm_utils_complete_generic (connection,
519
540
                                   NM_SETTING_GSM_SETTING_NAME,
520
541
                                   existing_connections,
566
587
 
567
588
        priv->pin_tries = 0;
568
589
 
 
590
        if (priv->enable_delay_id)
 
591
                g_source_remove (priv->enable_delay_id);
 
592
 
569
593
        NM_MODEM_CLASS (nm_modem_gsm_parent_class)->deactivate (modem, device); 
570
594
}
571
595
 
585
609
 
586
610
        if (priv->connect_properties)
587
611
                g_hash_table_destroy (priv->connect_properties);
 
612
        if (priv->enable_delay_id)
 
613
                g_source_remove (priv->enable_delay_id);
588
614
 
589
615
        G_OBJECT_CLASS (nm_modem_gsm_parent_class)->dispose (object);
590
616
}