~ubuntu-branches/ubuntu/oneiric/modemmanager/oneiric-proposed

« back to all changes in this revision

Viewing changes to src/mm-generic-cdma.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2009-09-14 11:38:05 UTC
  • mto: (9.1.1 lucid)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20090914113805-r11ex2l2jdekhzgs
Tags: upstream-0.2.git.20090909t142854.64b7be7
ImportĀ upstreamĀ versionĀ 0.2.git.20090909t142854.64b7be7

Show diffs side-by-side

added added

removed removed

Lines of Context:
218
218
}
219
219
 
220
220
static void
221
 
flash_done (MMSerialPort *port, gpointer user_data)
 
221
flash_done (MMSerialPort *port, GError *error, gpointer user_data)
222
222
{
 
223
    MMCallbackInfo *info = (MMCallbackInfo *) user_data;
 
224
 
 
225
    if (error) {
 
226
        /* Flash failed for some reason */
 
227
        info->error = g_error_copy (error);
 
228
        mm_callback_info_schedule (info);
 
229
        return;
 
230
    }
 
231
 
223
232
    mm_serial_port_queue_command (port, "Z E0 V1 X4 &C1", 3, init_done, user_data);
224
233
}
225
234
 
240
249
        return;
241
250
    }
242
251
 
243
 
    if (mm_serial_port_open (priv->primary, &info->error))
244
 
        mm_serial_port_flash (priv->primary, 100, flash_done, info);
 
252
    if (!mm_serial_port_open (priv->primary, &info->error)) {
 
253
        g_assert (info->error);
 
254
        mm_callback_info_schedule (info);
 
255
        return;
 
256
    }
245
257
 
246
 
    if (info->error)
247
 
        mm_callback_info_schedule (info);
 
258
    mm_serial_port_flash (priv->primary, 100, flash_done, info);
248
259
}
249
260
 
250
261
static void
283
294
}
284
295
 
285
296
static void
286
 
disconnect_flash_done (MMSerialPort *port, gpointer user_data)
 
297
disconnect_flash_done (MMSerialPort *port,
 
298
                       GError *error,
 
299
                       gpointer user_data)
287
300
{
288
301
    MMCallbackInfo *info = (MMCallbackInfo *) user_data;
289
 
    MMGenericCdmaPrivate *priv;
290
 
 
291
 
    priv = MM_GENERIC_CDMA_GET_PRIVATE (info->modem);
 
302
    MMGenericCdmaPrivate *priv = MM_GENERIC_CDMA_GET_PRIVATE (info->modem);
 
303
 
 
304
    if (error) {
 
305
        info->error = g_error_copy (error);
 
306
        mm_callback_info_schedule (info);
 
307
        return;
 
308
    }
 
309
 
292
310
    mm_port_set_connected (priv->data, FALSE);
293
311
    mm_callback_info_schedule (info);
294
312
}
518
536
    char *reply = response->str;
519
537
    int class = 0, sid = 99999, num;
520
538
    unsigned char band = 'Z';
 
539
    gboolean success = FALSE;
521
540
 
522
541
    if (error) {
523
542
        info->error = g_error_copy (error);
527
546
    if (strstr (reply, "+CSS: "))
528
547
        reply += 6;
529
548
 
530
 
    num = sscanf (reply, "%d , %c , %d", &class, &band, &sid);
531
 
    if (num == 3) {
532
 
        /* Normalize */
533
 
        class = CLAMP (class, 0, 4);
534
 
        band = CLAMP (band, 'A', 'Z');
 
549
    num = sscanf (reply, "? , %d", &sid);
 
550
    if (num == 1) {
 
551
        /* UTStarcom modem that uses IS-707-A format */
 
552
        success = TRUE;
 
553
    } else {
 
554
        num = sscanf (reply, "%d , %c , %d", &class, &band, &sid);
 
555
        if (num == 3) {
 
556
            /* Modem uses IS-707-A-2 format */
 
557
 
 
558
            /* Normalize */
 
559
            class = CLAMP (class, 0, 4);
 
560
            band = CLAMP (band, 'A', 'Z');
 
561
            success = TRUE;
 
562
        }
 
563
    }
 
564
 
 
565
    if (success) {
 
566
        /* 99999 means unknown/no service */
535
567
        if (sid < 0 || sid > 32767)
536
568
            sid = 99999;
537
569
 
538
 
        /* 99 means unknown/no service */
539
 
        if (sid == 99999) {
 
570
        if (sid == 0 || sid == 99999) {
540
571
            info->error = g_error_new_literal (MM_MOBILE_ERROR,
541
 
                                                MM_MOBILE_ERROR_NO_NETWORK,
542
 
                                                "No service");
 
572
                                               MM_MOBILE_ERROR_NO_NETWORK,
 
573
                                               "No service");
543
574
        } else {
544
575
            mm_callback_info_set_data (info, "class", GUINT_TO_POINTER (class), NULL);
545
576
            mm_callback_info_set_data (info, "band", GUINT_TO_POINTER ((guint32) band), NULL);
546
577
            mm_callback_info_set_data (info, "sid", GUINT_TO_POINTER (sid), NULL);
547
578
        }
548
 
    } else
 
579
    } else {
549
580
        info->error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
550
581
                                           "Could not parse Serving System results.");
 
582
    }
551
583
 
552
584
 out:
553
585
    mm_callback_info_schedule (info);