summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/atmodem/call-forwarding.c23
-rw-r--r--drivers/atmodem/sim.c21
-rw-r--r--drivers/atmodem/voicecall.c80
3 files changed, 60 insertions, 64 deletions
diff --git a/drivers/atmodem/call-forwarding.c b/drivers/atmodem/call-forwarding.c
index cddda569..b152b110 100644
--- a/drivers/atmodem/call-forwarding.c
+++ b/drivers/atmodem/call-forwarding.c
@@ -50,6 +50,7 @@ static void ccfc_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
int num = 0;
struct ofono_cf_condition *list = NULL;
int i;
+ int maxlen;
dump_response("ccfc_query_cb", ok, result);
decode_at_error(&error, g_at_result_final_response(result));
@@ -79,24 +80,26 @@ static void ccfc_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
g_at_result_iter_init(&iter, result);
+ maxlen = OFONO_MAX_PHONE_NUMBER_LENGTH;
+
for (num = 0; g_at_result_iter_next(&iter, "+CCFC:"); num++) {
const char *str;
g_at_result_iter_next_number(&iter, &(list[num].status));
g_at_result_iter_next_number(&iter, &(list[num].cls));
- list[num].phone_number[0] = '\0';
- list[num].number_type = 129;
+ list[num].phone_number.number[0] = '\0';
+ list[num].phone_number.type = 129;
list[num].time = 20;
if (!g_at_result_iter_next_string(&iter, &str))
continue;
- strncpy(list[num].phone_number, str,
- OFONO_MAX_PHONE_NUMBER_LENGTH);
- list[num].phone_number[OFONO_MAX_PHONE_NUMBER_LENGTH] = '\0';
+ strncpy(list[num].phone_number.number, str, maxlen);
+ list[num].phone_number.number[maxlen] = '\0';
- g_at_result_iter_next_number(&iter, &(list[num].number_type));
+ g_at_result_iter_next_number(&iter,
+ &(list[num].phone_number.type));
if (!g_at_result_iter_skip_next(&iter))
continue;
@@ -110,8 +113,8 @@ static void ccfc_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
for (i = 0; i < num; i++)
ofono_debug("ccfc_cb: %d, %d, %s(%d) - %d sec",
list[i].status, list[i].cls,
- list[i].phone_number, list[i].number_type,
- list[i].time);
+ list[i].phone_number.number,
+ list[i].phone_number.type, list[i].time);
out:
cb(&error, num, list, cbd->data);
@@ -227,7 +230,7 @@ static void at_ccfc_activation(struct ofono_modem *modem, int type, int cls,
}
static void at_ccfc_registration(struct ofono_modem *modem, int type, int cls,
- const char *number, int number_type,
+ const struct ofono_phone_number *ph,
int time, ofono_generic_cb_t cb,
void *data)
{
@@ -235,7 +238,7 @@ static void at_ccfc_registration(struct ofono_modem *modem, int type, int cls,
int offset;
offset = sprintf(buf, "AT+CCFC=%d,3,\"%s\",%d,%d", type,
- number, number_type, cls);
+ ph->number, ph->type, cls);
if (type == 2 || type == 4 || type == 5)
sprintf(buf+offset, ",,,%d", time);
diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index 20cf5647..f3a204d0 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -236,8 +236,7 @@ static void at_cnum_cb(gboolean ok, GAtResult *result, gpointer user_data)
GAtResultIter iter;
ofono_numbers_cb_t cb = cbd->cb;
struct ofono_error error;
- struct ofono_own_number *numbers;
- GSList *l = NULL;
+ struct ofono_phone_number *numbers;
int count;
const char *str;
@@ -245,7 +244,7 @@ static void at_cnum_cb(gboolean ok, GAtResult *result, gpointer user_data)
decode_at_error(&error, g_at_result_final_response(result));
if (!ok) {
- cb(&error, NULL, cbd->data);
+ cb(&error, 0, NULL, cbd->data);
return;
}
@@ -254,10 +253,10 @@ static void at_cnum_cb(gboolean ok, GAtResult *result, gpointer user_data)
for (count = 0; g_at_result_iter_next(&iter, "+CNUM:"); count++);
ofono_debug("Got %i elements", count);
- numbers = g_try_new0(struct ofono_own_number, count);
+ numbers = g_try_new0(struct ofono_phone_number, count);
if (!numbers) {
DECLARE_FAILURE(e);
- cb(&e, NULL, cbd->data);
+ cb(&e, 0, NULL, cbd->data);
return;
}
@@ -269,19 +268,15 @@ static void at_cnum_cb(gboolean ok, GAtResult *result, gpointer user_data)
if (!g_at_result_iter_next_string(&iter, &str))
continue;
- g_strlcpy(numbers[count].phone_number, str,
+ g_strlcpy(numbers[count].number, str,
OFONO_MAX_PHONE_NUMBER_LENGTH);
- g_at_result_iter_next_number(&iter,
- &numbers[count].number_type);
-
- l = g_slist_append(l, &numbers[count]);
+ g_at_result_iter_next_number(&iter, &numbers[count].type);
}
- cb(&error, l, cbd->data);
+ cb(&error, count, numbers, cbd->data);
g_free(numbers);
- g_slist_free(l);
}
static void at_read_msisdn(struct ofono_modem *modem, ofono_numbers_cb_t cb,
@@ -303,7 +298,7 @@ error:
{
DECLARE_FAILURE(error);
- cb(&error, NULL, data);
+ cb(&error, 0, NULL, data);
}
}
diff --git a/drivers/atmodem/voicecall.c b/drivers/atmodem/voicecall.c
index e5c8d49f..2be98313 100644
--- a/drivers/atmodem/voicecall.c
+++ b/drivers/atmodem/voicecall.c
@@ -168,8 +168,9 @@ static struct ofono_call *create_call(struct voicecall_data *d, int type,
call->status = status;
if (clip != 2) {
- strncpy(call->phone_number, num, OFONO_MAX_PHONE_NUMBER_LENGTH);
- call->number_type = num_type;
+ strncpy(call->phone_number.number, num,
+ OFONO_MAX_PHONE_NUMBER_LENGTH);
+ call->phone_number.type = num_type;
}
call->clip_validity = clip;
@@ -229,10 +230,11 @@ static GSList *parse_clcc(GAtResult *result)
call->direction = dir;
call->status = status;
call->type = type;
- strncpy(call->phone_number, str, OFONO_MAX_PHONE_NUMBER_LENGTH);
- call->number_type = number_type;
+ strncpy(call->phone_number.number, str,
+ OFONO_MAX_PHONE_NUMBER_LENGTH);
+ call->phone_number.type = number_type;
- if (strlen(call->phone_number) > 0)
+ if (strlen(call->phone_number.number) > 0)
call->clip_validity = 0;
else
call->clip_validity = 2;
@@ -440,7 +442,8 @@ out:
cb(&error, cbd->data);
}
-static void at_dial(struct ofono_modem *modem, const char *number, int number_type,
+static void at_dial(struct ofono_modem *modem,
+ const struct ofono_phone_number *ph,
enum ofono_clir_option clir, enum ofono_cug_option cug,
ofono_generic_cb_t cb, void *data)
{
@@ -451,7 +454,7 @@ static void at_dial(struct ofono_modem *modem, const char *number, int number_ty
if (!cbd)
goto error;
- sprintf(buf, "ATD%s", number);
+ sprintf(buf, "ATD%s", ph->number);
switch (clir) {
case OFONO_CLIR_OPTION_INVOCATION:
@@ -678,13 +681,14 @@ static void at_transfer(struct ofono_modem *modem, ofono_generic_cb_t cb,
at_template("AT+CHLD=4", modem, generic_cb, transfer, cb, data);
}
-static void at_deflect(struct ofono_modem *modem, const char *number,
- int number_type, ofono_generic_cb_t cb, void *data)
+static void at_deflect(struct ofono_modem *modem,
+ const struct ofono_phone_number *ph,
+ ofono_generic_cb_t cb, void *data)
{
char buf[128];
unsigned int incoming_or_waiting = (0x1 << 4) | (0x1 << 5);
- sprintf(buf, "AT+CTFR=%s,%d", number, number_type);
+ sprintf(buf, "AT+CTFR=%s,%d", ph->number, ph->type);
at_template(buf, modem, generic_cb, incoming_or_waiting, cb, data);
}
@@ -861,9 +865,10 @@ static void clip_notify(GAtResult *result, gpointer user_data)
call = l->data;
- strncpy(call->phone_number, num, OFONO_MAX_PHONE_NUMBER_LENGTH);
- call->phone_number[OFONO_MAX_PHONE_NUMBER_LENGTH] = '\0';
- call->number_type = type;
+ strncpy(call->phone_number.number, num,
+ OFONO_MAX_PHONE_NUMBER_LENGTH);
+ call->phone_number.number[OFONO_MAX_PHONE_NUMBER_LENGTH] = '\0';
+ call->phone_number.type = type;
call->clip_validity = validity;
if (call->type == 0)
@@ -993,9 +998,13 @@ static void cssu_notify(GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
GAtResultIter iter;
- int code2, index, num_type, satype;
- const char *num, *subaddr;
- char num_buf[OFONO_MAX_PHONE_NUMBER_LENGTH];
+ int code2;
+ int index = -1;
+ const char *num;
+ struct ofono_phone_number ph;
+
+ ph.number[0] = '\0';
+ ph.type = 129;
dump_response("cssu_notify", TRUE, result);
@@ -1007,32 +1016,21 @@ static void cssu_notify(GAtResult *result, gpointer user_data)
if (!g_at_result_iter_next_number(&iter, &code2))
return;
- if (!g_at_result_iter_next_number(&iter, &index)) {
- index = 0;
- num = NULL;
- num_type = 0;
- subaddr = NULL;
- satype = 0;
- } else if (!g_at_result_iter_next_string(&iter, &num)) {
- num = NULL;
- num_type = 0;
- subaddr = NULL;
- satype = 0;
- } else {
- strncpy(num_buf, num, OFONO_MAX_PHONE_NUMBER_LENGTH);
- num = num_buf;
-
- if (!g_at_result_iter_next_number(&iter, &num_type))
- return;
-
- if (!g_at_result_iter_next_string(&iter, &subaddr)) {
- subaddr = NULL;
- satype = 0;
- } else if (!g_at_result_iter_next_number(&iter, &satype))
- return;
- }
+ /* This field is optional, if we can't read it, try to skip it */
+ if (!g_at_result_iter_next_number(&iter, &index) &&
+ !g_at_result_iter_skip_next(&iter))
+ goto out;
- ofono_cssu_notify(modem, code2, index, num, num_type);
+ if (!g_at_result_iter_next_string(&iter, &num))
+ goto out;
+
+ strncpy(ph.number, num, OFONO_MAX_PHONE_NUMBER_LENGTH);
+
+ if (!g_at_result_iter_next_number(&iter, &ph.type))
+ return;
+
+out:
+ ofono_cssu_notify(modem, code2, index, &ph);
}
static struct ofono_voicecall_ops ops = {