aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaman Mahmoodi <mahmoudi.saman1@gmail.com>2021-04-06 15:53:37 +0430
committerSaman Mahmoudi <mahmoudi.saman1@gmail.com>2021-05-03 07:56:38 +0430
commit10dc6edf1131c8c2b8a028de2a0f3e95709bca6b (patch)
treea4bcc3b29e1fc818ffcc1ce3c626c81319c85a60
parent8987ae42114a8b15522734e40d117fd061e7bf3b (diff)
get_calls verb return all active call properties. Bug-AGL: SPEC-3870 Signed-off-by: Saman Mahmoodi <mahmoudi.saman1@gmail.com> Change-Id: I7355b0ade66fdd84e55936cf63a4a2a62771a912
-rw-r--r--README.md1
-rw-r--r--binding/gdbus/ofono_voicecallmanager.c48
-rw-r--r--binding/gdbus/ofono_voicecallmanager.h1
-rw-r--r--binding/telephony-binding.c13
4 files changed, 63 insertions, 0 deletions
diff --git a/README.md b/README.md
index 5fab4b8..679ce55 100644
--- a/README.md
+++ b/README.md
@@ -21,6 +21,7 @@ Telephony service allows respective clients access to the Handsfree Profile via
| hangup_multiparty | Hangs up the multi-party call | |
| create_multiparty | Joins active and held calls together into a multi-party call | |
| swap_calls | Swaps Active and Held calls | |
+| get_calls | get active call properties | *Response:* {"active calls": [ {"Object Path": "/hfp/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/voicecall01", "State": "dialing", "LineIdentification": "123456789", "Name": "", "Multiparty": false, "RemoteHeld": false, "RemoteMultiparty": false, "Emergency": false } ] } |
| get_battery_level | getting battery level of connected phone device | |
| get_network_registration | getting network registration of connected phone device | *Response:* {"Status": "registered","Mode": "auto-only","Name": "Irancell","Strength": 20} |
diff --git a/binding/gdbus/ofono_voicecallmanager.c b/binding/gdbus/ofono_voicecallmanager.c
index 78924dc..8118f1f 100644
--- a/binding/gdbus/ofono_voicecallmanager.c
+++ b/binding/gdbus/ofono_voicecallmanager.c
@@ -276,3 +276,51 @@ gboolean ofono_voicecallmanager_swap_calls(OrgOfonoVoiceCallManager *manager)
return (error == NULL);
}
+
+json_object* ofono_voicecallmanager_get_calls(OrgOfonoVoiceCallManager *manager)
+{
+ GError *error = NULL;
+ gboolean res;
+ GVariant *reply = NULL;
+ g_autoptr(GVariantIter) iter1 = NULL;
+ g_autoptr(GVariantIter) iter2 = NULL;
+ GVariant *value = NULL;
+ const gchar *key1 = NULL;
+ const gchar *key2 = NULL;
+ json_object *jprop = NULL;
+ if (!manager) {
+ AFB_ERROR("Ofono VoiceCallmanager uninitialized\n");
+ return NULL;
+ }
+
+ res = org_ofono_voice_call_manager_call_get_calls_sync(manager, &reply, NULL, &error);
+
+ json_object *jarray = json_object_new_array();
+ json_object *jresp = json_object_new_object();
+ json_object_object_add(jresp, "active calls", jarray);
+
+ if (res) {
+ g_variant_get(reply, "a(oa{sv})", &iter1);
+ jprop = json_object_new_object();
+ while (g_variant_iter_loop(iter1, "(&oa{sv})", &key1, &iter2)) {
+ json_object_object_add(jprop, "Object Path", json_object_new_string(key1));
+ while (g_variant_iter_loop(iter2, "{&sv}", &key2, &value)) {
+ const char* type = g_variant_get_type_string(value);
+ switch (*type) {
+ case 'o':
+ case 's':
+ json_object_object_add(jprop,key2, json_object_new_string(g_variant_get_string(value, NULL)));
+ break;
+ case 'b':
+ json_object_object_add(jprop,key2,json_object_new_boolean(g_variant_get_boolean(value)));
+ break;
+ default:
+ break;
+ }
+ }
+ json_object_array_add(jarray, jprop);
+ }
+ g_variant_unref(reply);
+ }
+ return jresp;
+}
diff --git a/binding/gdbus/ofono_voicecallmanager.h b/binding/gdbus/ofono_voicecallmanager.h
index df058a2..770c409 100644
--- a/binding/gdbus/ofono_voicecallmanager.h
+++ b/binding/gdbus/ofono_voicecallmanager.h
@@ -34,3 +34,4 @@ gboolean ofono_voicecallmanager_hold_and_answer(OrgOfonoVoiceCallManager *);
gboolean ofono_voicecallmanager_release_and_answer(OrgOfonoVoiceCallManager *);
gboolean ofono_voicecallmanager_swap_calls(OrgOfonoVoiceCallManager *);
gchar **ofono_voicecallmanager_create_multiparty(OrgOfonoVoiceCallManager *);
+json_object *ofono_voicecallmanager_get_calls(OrgOfonoVoiceCallManager *);
diff --git a/binding/telephony-binding.c b/binding/telephony-binding.c
index 9e47c76..e764601 100644
--- a/binding/telephony-binding.c
+++ b/binding/telephony-binding.c
@@ -232,6 +232,15 @@ static void swap_calls(afb_req_t request)
}
}
+static void get_calls(afb_req_t request)
+{
+ json_object *result = ofono_voicecallmanager_get_calls(vcm);
+ if (!result)
+ afb_req_fail(request, "failed", "Can not find any active voice calls");
+ else
+ afb_req_success(request, result, NULL);
+}
+
static void get_battery_level(afb_req_t request)
{
const gchar *device;
@@ -638,6 +647,10 @@ static const afb_verb_t verbs[]= {
.callback = release_and_answer,
},
{
+ .verb = "get_calls",
+ .callback = get_calls,
+ },
+ {
.verb = "get_battery_level",
.callback = get_battery_level,
},