diff options
author | Saman Mahmoodi <mahmoudi.saman1@gmail.com> | 2021-04-06 15:53:37 +0430 |
---|---|---|
committer | Saman Mahmoudi <mahmoudi.saman1@gmail.com> | 2021-05-03 07:56:38 +0430 |
commit | 10dc6edf1131c8c2b8a028de2a0f3e95709bca6b (patch) | |
tree | a4bcc3b29e1fc818ffcc1ce3c626c81319c85a60 /binding/gdbus/ofono_voicecallmanager.c | |
parent | 8987ae42114a8b15522734e40d117fd061e7bf3b (diff) |
Add new verb as get_callsneedlefish_13.93.0needlefish/13.93.0marlin_12.93.0marlin_12.92.0marlin_12.91.0marlin_12.90.1marlin_12.90.0marlin/12.93.0marlin/12.92.0marlin/12.91.0marlin/12.90.1marlin/12.90.0lamprey_11.92.0lamprey/11.92.013.93.012.93.012.92.012.91.012.90.112.90.011.92.0
get_calls verb return all active call properties.
Bug-AGL: SPEC-3870
Signed-off-by: Saman Mahmoodi <mahmoudi.saman1@gmail.com>
Change-Id: I7355b0ade66fdd84e55936cf63a4a2a62771a912
Diffstat (limited to 'binding/gdbus/ofono_voicecallmanager.c')
-rw-r--r-- | binding/gdbus/ofono_voicecallmanager.c | 48 |
1 files changed, 48 insertions, 0 deletions
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; +} |