summaryrefslogtreecommitdiffstats
path: root/drivers/atmodem/atutil.c
diff options
context:
space:
mode:
authorZhenhua Zhang <zhenhua.zhang@intel.com>2009-11-13 00:31:38 +0800
committerDenis Kenzior <denkenz@gmail.com>2009-11-12 11:22:31 -0600
commit20e9ff8551f2efe6d7a68ce1b5cb3e6c510c1365 (patch)
treef960cfec547938030f879c517f1a673123e4e0b2 /drivers/atmodem/atutil.c
parent3003ebd066910ff1a29e49db7176e3cf8d152c4f (diff)
downloadofono-20e9ff8551f2efe6d7a68ce1b5cb3e6c510c1365.tar.bz2
Add parse_clcc into atutil.c
So that it could be shared by atmodem and hfpmodem.
Diffstat (limited to 'drivers/atmodem/atutil.c')
-rw-r--r--drivers/atmodem/atutil.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/drivers/atmodem/atutil.c b/drivers/atmodem/atutil.c
index 687a466f..3a365f47 100644
--- a/drivers/atmodem/atutil.c
+++ b/drivers/atmodem/atutil.c
@@ -110,3 +110,58 @@ void at_util_release_id(unsigned int *id_list, unsigned int id)
*id_list &= ~(1 << id);
}
+GSList *at_util_parse_clcc(GAtResult *result)
+{
+ GAtResultIter iter;
+ GSList *l = NULL;
+ int id, dir, status, type;
+ struct ofono_call *call;
+
+ g_at_result_iter_init(&iter, result);
+
+ while (g_at_result_iter_next(&iter, "+CLCC:")) {
+ const char *str = "";
+ int number_type = 129;
+
+ if (!g_at_result_iter_next_number(&iter, &id))
+ continue;
+
+ if (!g_at_result_iter_next_number(&iter, &dir))
+ continue;
+
+ if (!g_at_result_iter_next_number(&iter, &status))
+ continue;
+
+ if (!g_at_result_iter_next_number(&iter, &type))
+ continue;
+
+ if (!g_at_result_iter_skip_next(&iter))
+ continue;
+
+ if (g_at_result_iter_next_string(&iter, &str))
+ g_at_result_iter_next_number(&iter, &number_type);
+
+ call = g_try_new0(struct ofono_call, 1);
+
+ if (!call)
+ break;
+
+ call->id = id;
+ call->direction = dir;
+ call->status = status;
+ call->type = type;
+ strncpy(call->phone_number.number, str,
+ OFONO_MAX_PHONE_NUMBER_LENGTH);
+ call->phone_number.type = number_type;
+
+ if (strlen(call->phone_number.number) > 0)
+ call->clip_validity = 0;
+ else
+ call->clip_validity = 2;
+
+ l = g_slist_insert_sorted(l, call, at_util_call_compare);
+ }
+
+ return l;
+}
+