summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo F. Padovan <padovan@profusion.mobi>2010-12-06 18:12:41 -0200
committerDenis Kenzior <denkenz@gmail.com>2010-12-16 18:40:18 -0600
commitb01d8f5bf71d4d703749c0b7d8fac0be6d39e14e (patch)
tree523daccf2aab35b0cb10fb61c0c538ba7eff91e5
parent56976583bed22a2e1ac1132bae5c9e57fdc84af9 (diff)
downloadofono-b01d8f5bf71d4d703749c0b7d8fac0be6d39e14e.tar.bz2
atmodem: add CNAP to call-settings
-rw-r--r--drivers/atmodem/call-settings.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/drivers/atmodem/call-settings.c b/drivers/atmodem/call-settings.c
index 7e1b422a..b3e8ea6d 100644
--- a/drivers/atmodem/call-settings.c
+++ b/drivers/atmodem/call-settings.c
@@ -45,6 +45,7 @@ static const char *colp_prefix[] = { "+COLP:", NULL };
static const char *clip_prefix[] = { "+CLIP:", NULL };
static const char *ccwa_prefix[] = { "+CCWA:", NULL };
static const char *colr_prefix[] = { "+COLR:", NULL };
+static const char *cnap_prefix[] = { "+CNAP:", NULL };
static void ccwa_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
@@ -188,6 +189,57 @@ error:
CALLBACK_WITH_FAILURE(cb, -1, data);
}
+static void cnap_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_call_settings_status_cb_t cb = cbd->cb;
+ struct ofono_error error;
+ GAtResultIter iter;
+ int status;
+
+ decode_at_error(&error, g_at_result_final_response(result));
+
+ if (!ok) {
+ cb(&error, -1, cbd->data);
+ return;
+ }
+
+ g_at_result_iter_init(&iter, result);
+
+ if (g_at_result_iter_next(&iter, "+CNAP:") == FALSE)
+ goto error;
+
+ if (g_at_result_iter_next_number(&iter, &status) == FALSE)
+ goto error;
+
+ DBG("network: %d", status);
+
+ cb(&error, status, cbd->data);
+ return;
+
+error:
+ CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+}
+
+static void at_cnap_query(struct ofono_call_settings *cs,
+ ofono_call_settings_status_cb_t cb, void *data)
+{
+ GAtChat *chat = ofono_call_settings_get_data(cs);
+ struct cb_data *cbd = cb_data_new(cb, data);
+
+ if (cbd == NULL)
+ goto error;
+
+ if (g_at_chat_send(chat, "AT+CNAP?", cnap_prefix,
+ cnap_query_cb, cbd, g_free) > 0)
+ return;
+
+error:
+ g_free(cbd);
+
+ CALLBACK_WITH_FAILURE(cb, -1, data);
+}
+
static void colp_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct cb_data *cbd = user_data;
@@ -404,6 +456,7 @@ static struct ofono_call_settings_driver driver = {
.probe = at_call_settings_probe,
.remove = at_call_settings_remove,
.clip_query = at_clip_query,
+ .cnap_query = at_cnap_query,
.colp_query = at_colp_query,
.clir_query = at_clir_query,
.clir_set = at_clir_set,