summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2011-05-04 22:19:56 -0500
committerDenis Kenzior <denkenz@gmail.com>2011-05-04 22:27:03 -0500
commit2a5f5fe6be3b13a3457343b58ba9d6e4d982c3d2 (patch)
tree94d3d852df09bf673b3befcbe7283137153eaf5c /src
parent1655cb9bd251e52d2180f49b08fb3c69e420217c (diff)
downloadofono-2a5f5fe6be3b13a3457343b58ba9d6e4d982c3d2.tar.bz2
voicecall: Simplify CHLD support generator
In addition, fix ordering and make sure that lower case 'x' is used
Diffstat (limited to 'src')
-rw-r--r--src/voicecall.c65
1 files changed, 19 insertions, 46 deletions
diff --git a/src/voicecall.c b/src/voicecall.c
index 41bda3a2..b20fd360 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -2741,6 +2741,17 @@ static void emulator_clcc_cb(struct ofono_emulator *em,
ofono_emulator_send_final(em, &result);
}
+#define ADD_CHLD_SUPPORT(cond, x) \
+ if (cond) { \
+ if (info[-1] != '=') \
+ *info++ = ','; \
+ \
+ *info++ = x[0]; \
+ \
+ if (x[1]) \
+ *info++ = x[1]; \
+ } \
+
static void emulator_chld_cb(struct ofono_emulator *em,
struct ofono_emulator_request *req, void *userdata)
{
@@ -2830,52 +2841,14 @@ static void emulator_chld_cb(struct ofono_emulator *em,
memcpy(buf, "+CHLD=", 6);
info = buf + 6;
- if (vc->driver->release_all_held && vc->driver->set_udub)
- *info++ = '0';
-
- if (vc->driver->release_all_active) {
- if (info - buf > 6)
- *info++ = ',';
-
- *info++ = '1';
- }
-
- if (vc->driver->hold_all_active) {
- if (info - buf > 6)
- *info++ = ',';
-
- *info++ = '2';
- }
-
- if (vc->driver->create_multiparty) {
- if (info - buf > 6)
- *info++ = ',';
-
- *info++ = '3';
- }
-
- if (vc->driver->transfer) {
- if (info - buf > 6)
- *info++ = ',';
-
- *info++ = '4';
- }
-
- if (vc->driver->release_specific) {
- if (info - buf > 6)
- *info++ = ',';
-
- *info++ = '1';
- *info++ = 'X';
- }
-
- if (vc->driver->private_chat) {
- if (info - buf > 6)
- *info++ = ',';
-
- *info++ = '2';
- *info++ = 'X';
- }
+ ADD_CHLD_SUPPORT(vc->driver->release_all_held &&
+ vc->driver->set_udub, "0")
+ ADD_CHLD_SUPPORT(vc->driver->release_all_active, "1")
+ ADD_CHLD_SUPPORT(vc->driver->release_specific, "1x")
+ ADD_CHLD_SUPPORT(vc->driver->hold_all_active, "2")
+ ADD_CHLD_SUPPORT(vc->driver->private_chat, "2x")
+ ADD_CHLD_SUPPORT(vc->driver->create_multiparty, "3")
+ ADD_CHLD_SUPPORT(vc->driver->transfer, "4")
*info++ = '\0';