2 * Copyright (C) 2017 Konsulko Group
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <afb/afb-binding.h>
24 #include "ofono_voicecall_interface.h"
26 const struct afb_binding_interface *interface;
28 static void property_changed(OrgOfonoVoiceCall *voice_call,
35 if (!strcmp(property, "State")) {
36 vvalue = g_variant_get_variant(value);
37 state = g_variant_get_string(vvalue, NULL);
38 g_signal_emit_by_name(voice_call, "call-state-changed", state);
42 OrgOfonoVoiceCall *ofono_voicecall_new(const struct afb_binding_interface *iface,
44 void (*call_state_changed)(OrgOfonoVoiceCall *,gchar *))
46 OrgOfonoVoiceCall *voice_call;
49 voice_call = org_ofono_voice_call_proxy_new_for_bus_sync(
50 G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE,
51 "org.ofono", op, NULL, NULL);
54 g_signal_new("call-state-changed",
60 g_cclosure_marshal_generic,
65 if (g_signal_connect(G_OBJECT(voice_call), "call-state-changed", G_CALLBACK(call_state_changed), NULL) <= 0) {
66 ERROR(interface, "Failed to connect to signal call-state-changed\n");
69 if (g_signal_connect(voice_call, "property-changed", G_CALLBACK(property_changed), NULL) <= 0) {
70 ERROR(interface, "Failed to connect to signal call-added\n");
77 void ofono_voicecall_free(OrgOfonoVoiceCall *voice_call)
79 g_object_unref(G_OBJECT(voice_call));
82 void ofono_voicecall_hangup(OrgOfonoVoiceCall *voice_call)
86 org_ofono_voice_call_call_hangup_sync(voice_call, NULL, &error);
89 void ofono_voicecall_answer(OrgOfonoVoiceCall *voice_call)
93 org_ofono_voice_call_call_answer_sync(voice_call, NULL, &error);