~indicator-network-developers/ofono/trunk.packaging

« back to all changes in this revision

Viewing changes to drivers/huaweimodem/voicecall.c

  • Committer: Kalle Valo
  • Date: 2011-02-21 07:46:07 UTC
  • mfrom: (2738.1.2125)
  • Revision ID: kalle.valo@canonical.com-20110221074607-u4rocuj2p75kpht9
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include "gatchat.h"
39
39
#include "gatresult.h"
40
40
 
 
41
#include "common.h"
41
42
#include "huaweimodem.h"
42
43
 
43
44
static const char *none_prefix[] = { NULL };
56
57
        struct ofono_call *call;
57
58
 
58
59
        /* Generate a call structure for the waiting call */
59
 
        call = g_try_new0(struct ofono_call, 1);
 
60
        call = g_try_new(struct ofono_call, 1);
60
61
        if (call == NULL)
61
62
                return NULL;
62
63
 
 
64
        ofono_call_init(call);
 
65
 
63
66
        call->id = id;
64
67
        call->type = type;
65
68
        call->direction = direction;
99
102
        struct voicecall_data *vd = ofono_voicecall_get_data(vc);
100
103
        struct cb_data *cbd = cb_data_new(cb, data);
101
104
 
102
 
        if (cbd == NULL)
103
 
                goto error;
104
 
 
105
105
        if (g_at_chat_send(vd->chat, cmd, none_prefix,
106
106
                                huawei_generic_cb, cbd, g_free) > 0)
107
107
                return;
108
108
 
109
 
error:
110
109
        g_free(cbd);
111
110
 
112
111
        CALLBACK_WITH_FAILURE(cb, data);
115
114
static void huawei_dial(struct ofono_voicecall *vc,
116
115
                                const struct ofono_phone_number *ph,
117
116
                                enum ofono_clir_option clir,
118
 
                                enum ofono_cug_option cug,
119
117
                                ofono_voicecall_cb_t cb, void *data)
120
118
{
121
119
        char buf[256];
136
134
                break;
137
135
        }
138
136
 
139
 
        switch (cug) {
140
 
        case OFONO_CUG_OPTION_INVOCATION:
141
 
                strcat(buf, "G");
142
 
                break;
143
 
        default:
144
 
                break;
145
 
        }
146
 
 
147
137
        strcat(buf, ";");
148
138
 
149
139
        huawei_template(vc, buf, cb, data);
181
171
        int id;
182
172
 
183
173
        /* CRING can repeat, ignore if we already have an incoming call */
184
 
        if (g_slist_find_custom(vd->calls, GINT_TO_POINTER(4),
185
 
                                        at_util_call_compare_by_status))
 
174
        if (g_slist_find_custom(vd->calls,
 
175
                                GINT_TO_POINTER(CALL_STATUS_INCOMING),
 
176
                                at_util_call_compare_by_status))
186
177
                return;
187
178
 
188
179
        g_at_result_iter_init(&iter, result);
203
194
        id = ofono_voicecall_get_next_callid(vc);
204
195
 
205
196
        /* Generate an incoming call */
206
 
        create_call(vc, type, 1, 4, NULL, 128, 2, id);
 
197
        create_call(vc, type, 1, CALL_STATUS_INCOMING, NULL, 128, 2, id);
207
198
 
208
199
        /* Assume the CLIP always arrives, and we signal the call there */
209
200
        DBG("%d", type);
219
210
        GSList *l;
220
211
        struct ofono_call *call;
221
212
 
222
 
        l = g_slist_find_custom(vd->calls, GINT_TO_POINTER(4),
223
 
                                        at_util_call_compare_by_status);
 
213
        l = g_slist_find_custom(vd->calls,
 
214
                                GINT_TO_POINTER(CALL_STATUS_INCOMING),
 
215
                                at_util_call_compare_by_status);
224
216
        if (l == NULL) {
225
217
                ofono_error("CLIP for unknown call");
226
218
                return;
318
310
 
319
311
        ofono_info("Call origin: id %d type %d", call_id, call_type);
320
312
 
321
 
        call = create_call(vc, call_type, 0, 2, NULL, 128, 2, call_id);
 
313
        call = create_call(vc, call_type, 0, CALL_STATUS_DIALING, NULL, 128, 2,
 
314
                            call_id);
322
315
        if (call == NULL) {
323
316
                ofono_error("Unable to malloc, call tracking will fail!");
324
317
                return;
356
349
 
357
350
        /* Set call to alerting */
358
351
        call = l->data;
359
 
        call->status = 3;
 
352
        call->status = CALL_STATUS_ALERTING;
360
353
 
361
354
        if (call->type == 0)
362
355
                ofono_voicecall_notify(vc, call);
393
386
 
394
387
        /* Set call to active */
395
388
        call = l->data;
396
 
        call->status = 0;
 
389
        call->status = CALL_STATUS_ACTIVE;
397
390
 
398
391
        if (call->type == 0)
399
392
                ofono_voicecall_notify(vc, call);