summaryrefslogtreecommitdiffstats
path: root/audio/headset.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-09-03 17:00:48 +0300
committerJohan Hedberg <johan.hedberg@nokia.com>2008-09-03 17:00:48 +0300
commit2bda864bfb74be61f189d4c0855cf1cd6cd51327 (patch)
treef5c3544956e679dcc6927faadd5003a964cd5b32 /audio/headset.c
parent86340d34bb4786f6a657e74936e2639e6d041504 (diff)
Preliminary support for indicators
Diffstat (limited to 'audio/headset.c')
-rw-r--r--audio/headset.c57
1 files changed, 54 insertions, 3 deletions
diff --git a/audio/headset.c b/audio/headset.c
index 64749053..7edb0d30 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -215,16 +215,67 @@ static int supported_features(struct audio_device *device, const char *buf)
return headset_send(hs, "\r\nOK\r\n");
}
+static char *indicator_ranges(struct indicator *indicators)
+{
+ int i;
+ GString *gstr;
+
+ gstr = g_string_new("\r\n+CIND:");
+
+ for (i = 0; indicators[i].desc != NULL; i++) {
+ if (i == 0)
+ g_string_append_printf(gstr, "(\"%s\",(%s))",
+ indicators[i].desc,
+ indicators[i].range);
+ else
+ g_string_append_printf(gstr, ",(\"%s\",(%s))",
+ indicators[i].desc,
+ indicators[i].range);
+ }
+
+ g_string_append(gstr, "\r\n");
+
+ return g_string_free(gstr, FALSE);
+}
+
+static char *indicator_values(struct indicator *indicators)
+{
+ int i;
+ GString *gstr;
+
+ gstr = g_string_new("\r\n+CIND:");
+
+ for (i = 0; indicators[i].desc != NULL; i++) {
+ if (i == 0)
+ g_string_append_printf(gstr, "%d", indicators[i].val);
+ else
+ g_string_append_printf(gstr, ",%d", indicators[i].val);
+ }
+
+ g_string_append(gstr, "\r\n");
+
+ return g_string_free(gstr, FALSE);
+}
+
static int report_indicators(struct audio_device *device, const char *buf)
{
struct headset *hs = device->headset;
int err;
+ char *str;
+ struct indicator *indicators;
+
+ indicators = telephony_indicators_req();
+ if (!indicators)
+ return headset_send(hs, "\r\nERROR\r\n");
if (buf[7] == '=')
- err = headset_send(hs, "\r\n+CIND:(\"service\",(0,1)),"
- "(\"call\",(0,1)),(\"callsetup\",(0-3))\r\n");
+ str = indicator_ranges(indicators);
else
- err = headset_send(hs, "\r\n+CIND:1,0,0\r\n");
+ str = indicator_values(indicators);
+
+ err = headset_send(hs, str);
+
+ g_free(str);
if (err < 0)
return err;