~morphis/phablet-extras/ofono-sms-status-report

« back to all changes in this revision

Viewing changes to drivers/ifxmodem/gprs-context.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2012-08-22 19:59:08 UTC
  • mfrom: (1.3.3) (6.1.5 experimental)
  • Revision ID: package-import@ubuntu.com-20120822195908-0bmmk1hlh989bgk6
Tags: 1.9-1ubuntu1
* Merge with Debian experimental; remaining changes:
  - debian/control: explicitly Conflicts with modemmanager: having both
    installed / running at the same time causes issues causes issues with
    both claiming modem devices.
  - debian/patches/02-dont-handle-stacktraces.patch: stop catching stacktraces
    and printing the information internally, so apport can catch and report
    the possible bugs.
  - debian/ofono.postinst: on configure, notify the user that a reboot is
    required (so ofono can get started by upstart). (LP: #600501)
  - debian/rules: pass --no-restart-on-upgrade so ofono isn't automatically
    restarted when upgrades.
  - Adding upstart config / Removing standard init script
  - Adding Apport support
  - Patch for recognizing special Huawei devices with weird serial
  - Override lintian to avoid script-in-etc-init.d... warnings.
  - Update debian/compat to 7
* debian/series: add our patches to debian/patches/series now that the package
  uses quilt.
* debian/patches/02-dont-handle-stacktraces.patch: refreshed.
* debian/ofono-dev.install, debian/ofono.install:
  - Install usr/sbin/dundee and ofono.pc to the proper packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *
3
3
 *  oFono - Open Source Telephony
4
4
 *
5
 
 *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
 
5
 *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
6
6
 *
7
7
 *  This program is free software; you can redistribute it and/or modify
8
8
 *  it under the terms of the GNU General Public License version 2 as
64
64
        char password[OFONO_GPRS_MAX_PASSWORD_LENGTH + 1];
65
65
        GAtRawIP *rawip;
66
66
        enum state state;
 
67
        enum ofono_gprs_proto proto;
67
68
        char address[32];
68
69
        char dns1[32];
69
70
        char dns2[32];
70
 
        union {
71
 
                ofono_gprs_context_cb_t down_cb;        /* Down callback */
72
 
                ofono_gprs_context_up_cb_t up_cb;       /* Up callback */
73
 
        };
 
71
        ofono_gprs_context_cb_t cb;
74
72
        void *cb_data;                                  /* Callback data */
75
73
};
76
74
 
123
121
        gcd->state = STATE_IDLE;
124
122
 
125
123
        if (result == NULL) {
126
 
                CALLBACK_WITH_FAILURE(gcd->up_cb, NULL, 0, NULL, NULL,
127
 
                                                NULL, NULL, gcd->cb_data);
 
124
                CALLBACK_WITH_FAILURE(gcd->cb, gcd->cb_data);
128
125
                return;
129
126
        }
130
127
 
131
128
        decode_at_error(&error, g_at_result_final_response(result));
132
 
        gcd->up_cb(&error, NULL, 0, NULL, NULL, NULL, NULL, gcd->cb_data);
 
129
        gcd->cb(&error, gcd->cb_data);
133
130
}
134
131
 
135
132
static void session_cb(gboolean ok, GAtResult *result, gpointer user_data)
157
154
        if (interface == NULL)
158
155
                interface = "invalid";
159
156
 
160
 
        CALLBACK_WITH_SUCCESS(gcd->up_cb, interface, TRUE, gcd->address,
161
 
                                STATIC_IP_NETMASK, NULL, dns, gcd->cb_data);
162
 
 
163
 
        gcd->up_cb = NULL;
 
157
        ofono_gprs_context_set_interface(gc, interface);
 
158
        ofono_gprs_context_set_ipv4_address(gc, gcd->address, TRUE);
 
159
        ofono_gprs_context_set_ipv4_netmask(gc, STATIC_IP_NETMASK);
 
160
        ofono_gprs_context_set_ipv4_dns_servers(gc, dns);
 
161
 
 
162
        CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
 
163
 
 
164
        gcd->cb = NULL;
164
165
        gcd->cb_data = NULL;
165
166
}
166
167
 
301
302
        if (g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL) == 0)
302
303
                goto error;
303
304
 
304
 
        sprintf(buf, "AT+XDNS=%u,1", gcd->active_context);
 
305
        g_at_chat_send(gcd->chat, "AT+XDNS=?", none_prefix, NULL, NULL, NULL);
 
306
 
 
307
        switch (gcd->proto) {
 
308
        case OFONO_GPRS_PROTO_IP:
 
309
                sprintf(buf, "AT+XDNS=%u,1", gcd->active_context);
 
310
                break;
 
311
        case OFONO_GPRS_PROTO_IPV6:
 
312
                sprintf(buf, "AT+XDNS=%u,2", gcd->active_context);
 
313
                break;
 
314
        case OFONO_GPRS_PROTO_IPV4V6:
 
315
                sprintf(buf, "AT+XDNS=%u,3", gcd->active_context);
 
316
                break;
 
317
        }
 
318
 
305
319
        if (g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL) == 0)
306
320
                goto error;
307
321
 
308
322
        sprintf(buf, "AT+CGACT=1,%u", gcd->active_context);
 
323
 
309
324
        if (g_at_chat_send(gcd->chat, buf, none_prefix,
310
325
                                activate_cb, gc, NULL) > 0)
311
326
                return;
316
331
 
317
332
static void ifx_gprs_activate_primary(struct ofono_gprs_context *gc,
318
333
                                const struct ofono_gprs_primary_context *ctx,
319
 
                                ofono_gprs_context_up_cb_t cb, void *data)
 
334
                                ofono_gprs_context_cb_t cb, void *data)
320
335
{
321
336
        struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
322
337
        char buf[OFONO_GPRS_MAX_APN_LENGTH + 128];
323
 
        int len;
 
338
        int len = 0;
324
339
 
325
340
        DBG("cid %u", ctx->cid);
326
341
 
327
342
        gcd->active_context = ctx->cid;
328
 
        gcd->up_cb = cb;
 
343
        gcd->cb = cb;
329
344
        gcd->cb_data = data;
330
345
        memcpy(gcd->username, ctx->username, sizeof(ctx->username));
331
346
        memcpy(gcd->password, ctx->password, sizeof(ctx->password));
332
347
 
333
348
        gcd->state = STATE_ENABLING;
 
349
        gcd->proto = ctx->proto;
334
350
 
335
 
        len = snprintf(buf, sizeof(buf), "AT+CGDCONT=%u,\"IP\"", ctx->cid);
 
351
        switch (ctx->proto) {
 
352
        case OFONO_GPRS_PROTO_IP:
 
353
                len = snprintf(buf, sizeof(buf), "AT+CGDCONT=%u,\"IP\"",
 
354
                                                                ctx->cid);
 
355
                break;
 
356
        case OFONO_GPRS_PROTO_IPV6:
 
357
                len = snprintf(buf, sizeof(buf), "AT+CGDCONT=%u,\"IPV6\"",
 
358
                                                                ctx->cid);
 
359
                break;
 
360
        case OFONO_GPRS_PROTO_IPV4V6:
 
361
                len = snprintf(buf, sizeof(buf), "AT+CGDCONT=%u,\"IPV4V6\"",
 
362
                                                                ctx->cid);
 
363
                break;
 
364
        }
336
365
 
337
366
        if (ctx->apn)
338
367
                snprintf(buf + len, sizeof(buf) - len - 3,
342
371
                                setup_cb, gc, NULL) > 0)
343
372
                return;
344
373
 
345
 
        CALLBACK_WITH_FAILURE(cb, NULL, 0, NULL, NULL, NULL, NULL, data);
 
374
        CALLBACK_WITH_FAILURE(cb, data);
346
375
}
347
376
 
348
377
static void deactivate_cb(gboolean ok, GAtResult *result, gpointer user_data)
360
389
 
361
390
        g_at_chat_resume(gcd->chat);
362
391
 
363
 
        CALLBACK_WITH_SUCCESS(gcd->down_cb, gcd->cb_data);
 
392
        CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
364
393
}
365
394
 
366
395
static void ifx_gprs_deactivate_primary(struct ofono_gprs_context *gc,
374
403
        DBG("cid %u", cid);
375
404
 
376
405
        gcd->state = STATE_DISABLING;
377
 
        gcd->down_cb = cb;
 
406
        gcd->cb = cb;
378
407
        gcd->cb_data = data;
379
408
 
380
409
        g_at_rawip_shutdown(gcd->rawip);