~ubuntu-branches/ubuntu/vivid/modemmanager/vivid-proposed

« back to all changes in this revision

Viewing changes to plugins/mm-modem-mbm.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2011-06-16 17:12:41 UTC
  • mfrom: (16.1.1 oneiric)
  • Revision ID: james.westby@ubuntu.com-20110616171241-k8vgsdmbpsvx467q
Tags: 0.4.997-1
* debian/watch: Switch to .bz2 tarballs.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
177
177
{
178
178
    MMCallbackInfo *info = (MMCallbackInfo *) user_data;
179
179
 
 
180
    /* If the modem has already been removed, return without
 
181
     * scheduling callback */
 
182
    if (mm_callback_info_check_modem_removed (info))
 
183
        return;
 
184
 
180
185
    if (error)
181
186
        info->error = g_error_copy (error);
182
187
 
257
262
    MMCallbackInfo *info = (MMCallbackInfo *) user_data;
258
263
    gboolean parsed = FALSE;
259
264
 
 
265
    /* If the modem has already been removed, return without
 
266
     * scheduling callback */
 
267
    if (mm_callback_info_check_modem_removed (info))
 
268
        return;
 
269
 
260
270
    if (error)
261
271
        info->error = g_error_copy (error);
262
272
    else if (!g_str_has_prefix (response->str, "CFUN: ")) {
351
361
{
352
362
    MMCallbackInfo *info = (MMCallbackInfo *) user_data;
353
363
 
 
364
    /* If the modem has already been removed, return without
 
365
     * scheduling callback */
 
366
    if (mm_callback_info_check_modem_removed (info))
 
367
        return;
 
368
 
354
369
    /* Start unsolicited signal strength and access technology responses */
355
370
    mm_at_serial_port_queue_command (port, "*ERINFO=1", 3, NULL, NULL);
356
371
 
359
374
 
360
375
static void
361
376
mbm_enap0_done (MMAtSerialPort *port,
362
 
               GString *response,
363
 
               GError *error,
364
 
               gpointer user_data)
 
377
                GString *response,
 
378
                GError *error,
 
379
                gpointer user_data)
365
380
{
366
381
    MMCallbackInfo *info = user_data;
367
 
    MMModemMbmPrivate *priv = MM_MODEM_MBM_GET_PRIVATE (info->modem);
 
382
    MMModemMbmPrivate *priv;
368
383
    char *command;
369
384
 
 
385
    /* If the modem has already been removed, return without
 
386
     * scheduling callback */
 
387
    if (mm_callback_info_check_modem_removed (info))
 
388
        return;
 
389
 
 
390
    priv = MM_MODEM_MBM_GET_PRIVATE (info->modem);
 
391
 
370
392
    if (!priv->network_mode)
371
393
        priv->network_mode = MBM_NETWORK_MODE_ANY;
372
394
 
382
404
               gpointer user_data)
383
405
{
384
406
    MMCallbackInfo *info = user_data;
385
 
    MMModemMbmPrivate *priv = MM_MODEM_MBM_GET_PRIVATE (info->modem);
 
407
    MMModemMbmPrivate *priv;
 
408
 
 
409
    /* If the modem has already been removed, return without
 
410
     * scheduling callback */
 
411
    if (mm_callback_info_check_modem_removed (info))
 
412
        return;
 
413
 
 
414
    priv = MM_MODEM_MBM_GET_PRIVATE (info->modem);
386
415
 
387
416
    if (error) {
388
417
        mm_generic_gsm_enable_complete (MM_GENERIC_GSM (info->modem), error, info);
408
437
                gpointer user_data)
409
438
{
410
439
    MMCallbackInfo *info = user_data;
411
 
    MMModemMbmPrivate *priv = MM_MODEM_MBM_GET_PRIVATE (info->modem);
 
440
 
 
441
    /* If the modem has already been removed, return without
 
442
     * scheduling callback */
 
443
    if (mm_callback_info_check_modem_removed (info))
 
444
        return;
412
445
 
413
446
    if (g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT))
414
447
        mm_warn ("timed out waiting for EMRDY response.");
415
 
    else
 
448
    else {
 
449
        MMModemMbmPrivate *priv = MM_MODEM_MBM_GET_PRIVATE (info->modem);
 
450
 
416
451
        priv->have_emrdy = TRUE;
 
452
    }
417
453
 
418
454
    do_init (port, info);
419
455
}
437
473
        mm_at_serial_port_queue_command (primary, "*EMRDY?", 5, mbm_emrdy_done, info);
438
474
}
439
475
 
440
 
typedef struct {
441
 
    MMModem *modem;
442
 
    MMModemFn callback;
443
 
    gpointer user_data;
444
 
} DisableInfo;
 
476
/*****************************************************************************/
445
477
 
446
478
static void
447
479
disable_unsolicited_done (MMAtSerialPort *port,
450
482
                          gpointer user_data)
451
483
 
452
484
{
453
 
    MMModem *parent_modem_iface;
454
 
    DisableInfo *info = user_data;
455
 
 
456
 
    parent_modem_iface = g_type_interface_peek_parent (MM_MODEM_GET_INTERFACE (info->modem));
457
 
    parent_modem_iface->disable (info->modem, info->callback, info->user_data);
458
 
    g_free (info);
 
485
    MMCallbackInfo *info = (MMCallbackInfo *) user_data;
 
486
 
 
487
    /* If the modem has already been removed, return without
 
488
     * scheduling callback */
 
489
    if (mm_callback_info_check_modem_removed (info))
 
490
        return;
 
491
 
 
492
    /* Ignore all errors */
 
493
    mm_callback_info_schedule (info);
 
494
}
 
495
 
 
496
static void
 
497
invoke_call_parent_disable_fn (MMCallbackInfo *info)
 
498
{
 
499
    /* Note: we won't call the parent disable if info->modem is no longer
 
500
     * valid. The invoke is called always once the info gets scheduled, which
 
501
     * may happen during removed modem detection. */
 
502
    if (info->modem) {
 
503
        MMModem *parent_modem_iface;
 
504
 
 
505
        parent_modem_iface = g_type_interface_peek_parent (MM_MODEM_GET_INTERFACE (info->modem));
 
506
        parent_modem_iface->disable (info->modem, (MMModemFn)info->callback, info->user_data);
 
507
    }
459
508
}
460
509
 
461
510
static void
464
513
         gpointer user_data)
465
514
{
466
515
    MMAtSerialPort *primary;
467
 
    DisableInfo *info;
 
516
    MMCallbackInfo *info;
468
517
 
469
 
    info = g_malloc0 (sizeof (DisableInfo));
470
 
    info->callback = callback;
471
 
    info->user_data = user_data;
472
 
    info->modem = modem;
 
518
    info = mm_callback_info_new_full (modem,
 
519
                                      invoke_call_parent_disable_fn,
 
520
                                      (GCallback)callback,
 
521
                                      user_data);
473
522
 
474
523
    primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
475
524
    g_assert (primary);
536
585
{
537
586
    MMCallbackInfo *info = (MMCallbackInfo *) user_data;
538
587
 
 
588
    /* If the modem has already been removed, return without
 
589
     * scheduling callback */
 
590
    if (mm_callback_info_check_modem_removed (info))
 
591
        return;
 
592
 
539
593
    mm_serial_port_close (MM_SERIAL_PORT (port));
540
594
    mm_callback_info_schedule (info);
541
595
}
659
713
 
660
714
    g_assert (info);
661
715
 
 
716
    /* If the modem has already been removed, return without
 
717
     * scheduling callback */
 
718
    if (mm_callback_info_check_modem_removed (info))
 
719
        return;
 
720
 
662
721
    count = GPOINTER_TO_UINT (mm_callback_info_get_data (info, "mbm-enap-poll-count"));
663
722
 
664
723
    if (sscanf (response->str, "*ENAP: %d", &state) == 1 && state == 1) {
702
761
    MMCallbackInfo *info = (MMCallbackInfo *) user_data;
703
762
    guint tid;
704
763
 
 
764
    /* If the modem has already been removed, return without
 
765
     * scheduling callback */
 
766
    if (mm_callback_info_check_modem_removed (info))
 
767
        return;
 
768
 
705
769
    if (error) {
706
770
        mm_generic_gsm_connect_complete (MM_GENERIC_GSM (info->modem), error, info);
707
771
        return;
796
860
    const char *pin_type;
797
861
    int attempts_left = 0;
798
862
 
 
863
    /* If the modem has already been removed, return without
 
864
     * scheduling callback */
 
865
    if (mm_callback_info_check_modem_removed (info))
 
866
        return;
 
867
 
799
868
    if (error) {
800
869
        info->error = g_error_copy (error);
801
870
        goto done;