2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Sung Joon Won <sungjoon.won@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
26 #include <device/display.h>
27 #include <device/power.h>
29 #include "call-manager.h"
30 #include "call-manager-extension.h"
31 #include "call-manager-common.h"
33 static int __cm_fetch_call_data(GVariantIter *iter, cm_call_data_t **call_data);
34 static void __cm_on_signal_recv(GDBusConnection *conn, const gchar *name,
35 const gchar *path, const gchar *interface, const gchar *sig,
36 GVariant *param, gpointer user_data);
37 static int __cm_set_cb(cm_client_h handle, char *signal, void *cb, void *user_data);
38 static int __cm_unset_cb(cm_client_h handle, char *signal);
39 static void __cm_set_LCDtimeout_cb(GObject *source_object, GAsyncResult *res, gpointer user_data);
42 static void __cm_set_LCDtimeout_cb(GObject *source_object, GAsyncResult *res, gpointer user_data)
45 GDBusConnection *conn = NULL;
47 GVariant *dbus_result = NULL;
49 conn = G_DBUS_CONNECTION(source_object);
50 dbus_result = g_dbus_connection_call_finish(conn, res, &error);
52 err("Failed: %s", error->message);
56 g_variant_get(dbus_result, "(i)", &result);
58 dbg("result : %d", result);
62 static int __cm_fetch_call_data(GVariantIter *iter, cm_call_data_t **call_data)
64 cm_call_data_t *tmp_call_data = NULL;
67 CM_RETURN_VAL_IF_FAIL(iter, -1);
68 CM_RETURN_VAL_IF_FAIL(call_data, -1);
70 tmp_call_data = (cm_call_data_t*)calloc(1, sizeof(cm_call_data_t));
71 CM_RETURN_VAL_IF_FAIL(tmp_call_data, -1);
73 while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
74 if (!g_strcmp0(key, "call_id")) {
75 tmp_call_data->call_id = g_variant_get_uint32(value);
76 } else if (!g_strcmp0(key, "call_direction")) {
77 tmp_call_data->call_direction = (int)g_variant_get_int32(value);
78 } else if (!g_strcmp0(key, "call_number")) {
79 tmp_call_data->call_number = g_strdup(g_variant_get_string(value, 0));
80 } else if (!g_strcmp0(key, "calling_name")) {
81 tmp_call_data->calling_name = g_strdup(g_variant_get_string(value, 0));
82 } else if (!g_strcmp0(key, "call_type")) {
83 tmp_call_data->call_type = (int)g_variant_get_int32(value);
84 } else if (!g_strcmp0(key, "call_state")) {
85 tmp_call_data->call_state = (int)g_variant_get_int32(value);
86 } else if (!g_strcmp0(key, "member_count")) {
87 tmp_call_data->member_count = (int)g_variant_get_int32(value);
88 } else if (!g_strcmp0(key, "is_ecc")) {
89 tmp_call_data->is_ecc = (int)g_variant_get_boolean(value);
90 } else if (!g_strcmp0(key, "is_voicemail_number")) {
91 tmp_call_data->is_voicemail_number = (int)g_variant_get_boolean(value);
92 } else if (!g_strcmp0(key, "person_id")) {
93 tmp_call_data->person_id = g_variant_get_uint32(value);
94 } else if (!g_strcmp0(key, "start_time")) {
95 tmp_call_data->start_time = g_variant_get_int64(value);
96 } else if (!g_strcmp0(key, "name_mode")) {
97 tmp_call_data->name_mode = g_variant_get_int32(value);
101 dbg("\n\n <<<<<<<<< CallData Info in Library START >>>>>>>>>> \n");
102 dbg("call_id : %d, ", tmp_call_data->call_id);
103 dbg("call_direction : %d, ", tmp_call_data->call_direction);
104 if (tmp_call_data->call_number) {
105 dbg("call_number : %s, ", tmp_call_data->call_number);
107 if (tmp_call_data->calling_name) {
108 dbg("calling_name : %s, ", tmp_call_data->calling_name);
110 dbg("call_type : %d, ", tmp_call_data->call_type);
111 dbg("call_state : %d, ", tmp_call_data->call_state);
112 dbg("member count : %d, ", tmp_call_data->member_count);
113 dbg("is_ecc : %d, ", tmp_call_data->is_ecc);
114 dbg("is_voicemail_number : %d, ", tmp_call_data->is_voicemail_number);
115 dbg("person_id : %d", tmp_call_data->person_id);
116 dbg("start time : %ld", tmp_call_data->start_time);
117 dbg("name mode : %d", tmp_call_data->name_mode);
118 dbg("\n\n <<<<<<<<< CallData Info in Library END >>>>>>>>>> \n");
120 *call_data = tmp_call_data;
125 static void __cm_on_signal_recv(GDBusConnection *conn, const gchar *name,
126 const gchar *path, const gchar *interface, const gchar *sig,
127 GVariant *param, gpointer user_data)
129 info("[%s] received", sig);
130 cm_client_h handle = user_data;
131 struct __cm_async_data *ad = NULL;
132 char *noti_id = NULL;
134 CM_RETURN_IF_FAIL(handle);
136 noti_id = g_strdup_printf("%s:%s:%s", path, interface, sig);
137 ad = g_hash_table_lookup(handle->evt_list, noti_id);
139 err("can't find noti_id(%s) callback info", noti_id);
144 if (!g_strcmp0(sig, DBUS_CALL_MANAGER_SIGNAL_CALL_STATUS)) {
145 cm_call_status_e call_status = CM_CALL_STATUS_IDLE;
146 cm_call_type_e call_type = CM_CALL_TYPE_INVALID;
147 char *call_number = NULL;
149 g_variant_get(param, "(iis)", &call_status, &call_type, &call_number);
150 dbg("call status: %d, call_type: %d", call_status, call_type);
152 dbg("call number: %s", call_number);
155 ((cm_call_status_cb)ad->cb_fn)(call_status, call_number, ad->user_data);
157 } else if (!g_strcmp0(sig, DBUS_CALL_MANAGER_SIGNAL_CALL_EVENT)) {
158 const gchar *param_type;
160 cm_call_event_data_t *evt_data = NULL;
161 cm_multi_sim_slot_type_e sim_slot = CM_SIM_SLOT_DEFAULT_E;
162 cm_call_end_cause_type_e end_cause = CM_CALL_ENDCAUSE_MAX;
163 unsigned int call_id = 0;
164 cm_call_data_t *callData = NULL;
165 GVariantIter *iter_incom = 0, *iter_active_dial = 0, *iter_held = 0;
167 param_type = g_variant_get_type_string(param);
168 dbg("param_type: '%s'", param_type);
169 g_variant_get(param, "(iuiia{sv}a{sv}a{sv})", &event, &call_id, &sim_slot, &end_cause, &iter_incom, &iter_active_dial, &iter_held);
170 dbg("received event: '%d'", event);
172 evt_data = calloc(1, sizeof(cm_call_event_data_t));
173 if (NULL == evt_data) {
174 err("memory allocation failed...");
175 g_variant_iter_free(iter_incom);
176 g_variant_iter_free(iter_active_dial);
177 g_variant_iter_free(iter_held);
181 evt_data->call_id = call_id;
182 evt_data->sim_slot = sim_slot;
183 evt_data->end_cause = end_cause;
185 dbg("call_event: %d, sim_slot: %d", event, sim_slot);
187 /*Fetch IncomingData*/
188 if (iter_incom && (g_variant_iter_n_children(iter_incom) > 0)) {
189 ret = __cm_fetch_call_data(iter_incom, &callData);
191 evt_data->incom = callData;
193 g_variant_iter_free(iter_incom);
197 if (iter_active_dial && (g_variant_iter_n_children(iter_active_dial) > 0)) {
198 ret = __cm_fetch_call_data(iter_active_dial, &callData);
200 evt_data->active_dial = callData;
202 g_variant_iter_free(iter_active_dial);
206 if (iter_held && (g_variant_iter_n_children(iter_held) > 0)) {
207 ret = __cm_fetch_call_data(iter_held, &callData);
209 evt_data->held = callData;
211 g_variant_iter_free(iter_held);
214 ((cm_call_event_cb)ad->cb_fn)(event, evt_data, ad->user_data);
215 if (evt_data->incom) {
216 cm_call_data_free(evt_data->incom);
218 if (evt_data->active_dial) {
219 cm_call_data_free(evt_data->active_dial);
221 if (evt_data->held) {
222 cm_call_data_free(evt_data->held);
225 } else if (!g_strcmp0(sig, DBUS_CALL_MANAGER_SIGNAL_AUDIO_STATE)) {
226 gint audio_status = -1;
228 g_variant_get(param, "(i)", &audio_status);
229 dbg("received audio_status: %d", audio_status);
231 ((cm_audio_state_changed_cb)ad->cb_fn)(audio_status, ad->user_data);
232 } else if (!g_strcmp0(sig, DBUS_CALL_MANAGER_SIGNAL_DTMF_INDI)) {
233 cm_dtmf_indi_type_e indi_type = CM_DTMF_INDI_IDLE_E;
234 char *dtmf_number = NULL;
236 g_variant_get(param, "(is)", &indi_type, &dtmf_number);
237 dbg("received indication: %d", indi_type);
239 dbg("received dtmf numbe: %s", dtmf_number);
242 ((cm_dtmf_indi_cb)ad->cb_fn)(indi_type, dtmf_number, ad->user_data);
244 } else if (!g_strcmp0(sig, DBUS_CALL_MANAGER_SIGNAL_GO_FOREGROUND)) {
245 ((cm_go_foreground_cb)ad->cb_fn)(ad->user_data);
246 } else if (!g_strcmp0(sig, DBUS_CALL_MANAGER_SIGNAL_DIAL_STATUS)) {
247 cm_dial_status_e dial_status = CM_DIAL_SUCCESS;
248 g_variant_get(param, "(i)", &dial_status);
249 dbg("received dial status: %d", dial_status);
251 ((cm_dial_status_cb)ad->cb_fn)(dial_status, ad->user_data);
252 } else if (!g_strcmp0(sig, DBUS_CALL_MANAGER_SIGNAL_VOICE_RECORD_STATUS)) {
253 cm_vr_status_e vr_status = -1;
254 cm_vr_status_extra_type_e extra_type;
256 g_variant_get (param, "(ii)", &vr_status, &extra_type);
257 dbg("received vr_status: '%d', extra_type: 0x%02x", vr_status, extra_type);
259 ((cm_voice_record_status_cb)ad->cb_fn)(vr_status, extra_type, ad->user_data);
260 } else if (!g_strcmp0(sig, DBUS_CALL_MANAGER_SIGNAL_MUTE_STATUS)) {
261 cm_mute_status_e mute_status = CM_MUTE_STATUS_MAX;
262 g_variant_get(param, "(i)", &mute_status);
263 dbg("received mute status: %d", mute_status);
265 ((cm_mute_status_cb)ad->cb_fn)(mute_status, ad->user_data);
270 static int __cm_set_cb(cm_client_h handle, char *signal, void *cb, void *user_data)
272 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
273 CM_RETURN_VAL_IF_FAIL(signal, CM_ERROR_INVALID_PARAMETER);
274 CM_RETURN_VAL_IF_FAIL(cb, CM_ERROR_INVALID_PARAMETER);
275 struct __cm_async_data *ad = NULL;
277 gchar *noti_id = NULL;
279 noti_id = g_strdup_printf("%s:%s:%s", DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, signal);
280 dbg("noti_id: '%s'", noti_id);
282 ad = g_hash_table_lookup(handle->evt_list, noti_id);
284 dbg("noti_id(%s) is already registered", noti_id);
286 return CM_ERROR_ALREADY_REGISTERED;
289 MAKE_CALL_STATE_ASYNC_DATA(ad, cb, user_data);
290 CM_RETURN_VAL_IF_FAIL(ad, CM_ERROR_OPERATION_FAILED);
292 id = g_dbus_connection_signal_subscribe(handle->dbus_conn,
293 DBUS_CALL_MANAGER, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, signal, DBUS_CALL_MANAGER_PATH, NULL,
294 G_DBUS_SIGNAL_FLAGS_NONE, __cm_on_signal_recv, handle, NULL);
299 g_hash_table_insert(handle->evt_list, noti_id, ad);
301 return CM_ERROR_NONE;
304 static int __cm_unset_cb(cm_client_h handle, char *signal)
306 struct __cm_async_data *ad = NULL;
307 gchar *noti_id = NULL;
309 CM_RETURN_VAL_IF_FAIL(signal, CM_ERROR_INVALID_PARAMETER);
310 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
312 noti_id = g_strdup_printf("%s:%s:%s", DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, signal);
313 dbg("noti_id: '%s'", noti_id);
315 ad = g_hash_table_lookup(handle->evt_list, noti_id);
317 warn("noti_id(%s) is not registered", noti_id);
319 return CM_ERROR_NOT_REGISTERED;
323 warn("id(%d) is wrong", ad->id);
325 return CM_ERROR_OPERATION_FAILED;
328 rv = g_hash_table_remove(handle->evt_list, noti_id);
330 warn("fail to deregister noti event(%s)", noti_id);
332 return CM_ERROR_OPERATION_FAILED;
336 return CM_ERROR_NONE;
339 static void __cm_evt_list_key_destroyed_cb(gpointer data)
341 dbg("__cm_evt_list_key_destroyed_cb()");
342 gchar *noti_id = (gchar *)data;
343 CM_RETURN_IF_FAIL(noti_id);
345 warn("Key[%s] is removed from hash table.", noti_id);
350 static void __cm_evt_list_value_destroyed_cb(gpointer data)
352 dbg("__cm_evt_list_value_destroyed_cb()");
353 struct __cm_async_data *ad = (struct __cm_async_data *)data;
354 CM_RETURN_IF_FAIL(ad);
355 cm_client_h handle = ad->handle;
356 CM_RETURN_IF_FAIL(handle);
358 g_dbus_connection_signal_unsubscribe(handle->dbus_conn, ad->id);
363 EXPORT_API int cm_init(cm_client_h *handle)
365 struct __cm_client *client_handle;
366 GError *error = NULL;
368 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
372 #if !GLIB_CHECK_VERSION(2, 35, 0)
376 client_handle = g_try_new0(struct __cm_client, 1);
378 return CM_ERROR_OPERATION_FAILED;
380 client_handle->dbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
381 if (!client_handle->dbus_conn) {
382 err("dbus connection get failed: %s", error->message);
384 g_free(client_handle);
385 return CM_ERROR_OPERATION_FAILED;
388 client_handle->ca = g_cancellable_new();
389 client_handle->evt_list = g_hash_table_new_full(g_str_hash, g_str_equal, __cm_evt_list_key_destroyed_cb,
390 __cm_evt_list_value_destroyed_cb);
392 *handle = client_handle;
394 return CM_ERROR_NONE;
397 EXPORT_API int cm_enable_recovery(cm_client_h handle, char* appid)
399 GError *error = NULL;
400 GVariant *dbus_result = NULL;
404 CM_RETURN_VAL_IF_FAIL(appid, CM_ERROR_INVALID_PARAMETER);
405 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
407 dbg(" appid [%s] cm_enable_recovery", appid);
409 own_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, appid,
410 G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, NULL,
413 err("g_bus_own_name failed");
414 return CM_ERROR_OPERATION_FAILED;
417 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
418 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_SET_WATCH_NAME,
419 g_variant_new("(s)", appid), NULL, G_DBUS_CALL_FLAGS_NONE,
420 CM_DEFAULT_TIMEOUT, handle->ca, &error);
423 err("Failed: %s", error->message);
425 return CM_ERROR_OPERATION_FAILED;
430 return CM_ERROR_OPERATION_FAILED;
433 g_variant_get(dbus_result, "(i)", &value);
434 g_variant_unref(dbus_result);
436 return CM_ERROR_NONE;
440 EXPORT_API int cm_deinit(cm_client_h handle)
442 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
446 g_hash_table_remove_all(handle->evt_list);
447 g_hash_table_unref(handle->evt_list);
449 g_cancellable_cancel(handle->ca);
451 g_object_unref(handle->ca);
453 g_object_unref(handle->dbus_conn);
455 memset(handle, 0, sizeof(struct __cm_client));
458 return CM_ERROR_NONE;
461 EXPORT_API int cm_dial_call(cm_client_h handle, char*number, cm_call_type_e call_type, cm_multi_sim_slot_type_e sim_slot)
463 GVariant *dbus_result;
464 GError *error = NULL;
465 gint value = CM_ERROR_NONE;
466 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
467 CM_RETURN_VAL_IF_FAIL(number, CM_ERROR_INVALID_PARAMETER);
469 dbg("cm_dial_call()");
471 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
472 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_DIAL_CALL,
473 g_variant_new("(siiib)", number, call_type, sim_slot, 0, FALSE/*is_emergency_contact*/), NULL, G_DBUS_CALL_FLAGS_NONE,
474 CM_DEFAULT_TIMEOUT, handle->ca, &error);
477 g_variant_get(dbus_result, "(i)", &value);
478 /* TODO: get proper error cause then return proper error */
480 value = CM_ERROR_OPERATION_FAILED;
483 err("g_dbus_conn failed. error (%s)", error->message);
484 if (strstr(error->message, "No access rights")) {
485 err("PERMISSION_DENIED");
486 value = CM_ERROR_PERMISSION_DENIED;
488 value = CM_ERROR_OPERATION_FAILED;
493 g_variant_unref(dbus_result);
498 EXPORT_API int cm_end_call(cm_client_h handle, unsigned int call_id, cm_call_release_type_e release_type)
500 GVariant *dbus_result;
501 GError *error = NULL;
503 dbg("cm_end_call()");
504 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
506 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
507 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_END_CALL,
508 g_variant_new("(ui)", call_id, release_type), NULL, G_DBUS_CALL_FLAGS_NONE,
509 CM_DEFAULT_TIMEOUT, handle->ca, &error);
512 err("Failed: %s", error->message);
514 return CM_ERROR_OPERATION_FAILED;
519 return CM_ERROR_OPERATION_FAILED;
522 g_variant_get(dbus_result, "(i)", &value);
523 g_variant_unref(dbus_result);
528 EXPORT_API int cm_reject_call(cm_client_h handle)
530 GVariant *dbus_result;
531 GError *error = NULL;
532 gint value = CM_ERROR_NONE;
534 dbg("cm_reject_call()");
536 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
538 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
539 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_REJECT_CALL,
540 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
541 CM_DEFAULT_TIMEOUT, handle->ca, &error);
544 g_variant_get(dbus_result, "(i)", &value);
546 value = CM_ERROR_OPERATION_FAILED;
549 err("g_dbus_conn failed. error (%s)", error->message);
550 if (strstr(error->message, "No access rights")) {
551 err("PERMISSION_DENIED");
552 value = CM_ERROR_PERMISSION_DENIED;
554 value = CM_ERROR_OPERATION_FAILED;
559 g_variant_unref(dbus_result);
565 EXPORT_API int cm_swap_call(cm_client_h handle)
567 GVariant *dbus_result;
568 GError *error = NULL;
570 dbg("cm_swap_call()");
571 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
573 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
574 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_SWAP_CALL,
575 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
576 CM_DEFAULT_TIMEOUT, handle->ca, &error);
579 err("Failed: %s", error->message);
581 return CM_ERROR_OPERATION_FAILED;
586 return CM_ERROR_OPERATION_FAILED;
589 g_variant_get(dbus_result, "(i)", &value);
590 g_variant_unref(dbus_result);
595 EXPORT_API int cm_hold_call(cm_client_h handle)
597 GVariant *dbus_result;
598 GError *error = NULL;
600 dbg("cm_hold_call()");
601 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
603 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
604 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_HOLD_CALL,
605 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
606 CM_DEFAULT_TIMEOUT, handle->ca, &error);
609 err("Failed: %s", error->message);
611 return CM_ERROR_OPERATION_FAILED;
616 return CM_ERROR_OPERATION_FAILED;
619 g_variant_get(dbus_result, "(i)", &value);
620 g_variant_unref(dbus_result);
625 EXPORT_API int cm_unhold_call(cm_client_h handle)
627 GVariant *dbus_result;
628 GError *error = NULL;
630 dbg("cm_unhold_call()");
631 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
633 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
634 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_UNHOLD_CALL,
635 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
636 CM_DEFAULT_TIMEOUT, handle->ca, &error);
639 err("Failed: %s", error->message);
641 return CM_ERROR_OPERATION_FAILED;
646 return CM_ERROR_OPERATION_FAILED;
649 g_variant_get(dbus_result, "(i)", &value);
650 g_variant_unref(dbus_result);
655 EXPORT_API int cm_join_call(cm_client_h handle)
657 GVariant *dbus_result;
658 GError *error = NULL;
660 dbg("cm_join_call()");
661 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
663 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
664 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_JOIN_CALL,
665 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
666 CM_DEFAULT_TIMEOUT, handle->ca, &error);
669 err("Failed: %s", error->message);
671 return CM_ERROR_OPERATION_FAILED;
676 return CM_ERROR_OPERATION_FAILED;
679 g_variant_get(dbus_result, "(i)", &value);
680 g_variant_unref(dbus_result);
685 EXPORT_API int cm_split_call(cm_client_h handle, unsigned int call_id)
687 GVariant *dbus_result;
688 GError *error = NULL;
690 dbg("cm_split_call()");
691 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
693 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
694 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_SPLIT_CALL,
695 g_variant_new("(u)", call_id), NULL, G_DBUS_CALL_FLAGS_NONE,
696 CM_DEFAULT_TIMEOUT, handle->ca, &error);
699 err("Failed: %s", error->message);
701 return CM_ERROR_OPERATION_FAILED;
706 return CM_ERROR_OPERATION_FAILED;
709 g_variant_get(dbus_result, "(i)", &value);
710 g_variant_unref(dbus_result);
715 EXPORT_API int cm_transfer_call(cm_client_h handle)
717 GVariant *dbus_result;
718 GError *error = NULL;
720 dbg("cm_transfer_call()");
721 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
723 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
724 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_TRANSFER_CALL,
725 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
726 CM_DEFAULT_TIMEOUT, handle->ca, &error);
729 err("Failed: %s", error->message);
731 return CM_ERROR_OPERATION_FAILED;
736 return CM_ERROR_OPERATION_FAILED;
739 g_variant_get(dbus_result, "(i)", &value);
740 g_variant_unref(dbus_result);
745 EXPORT_API int cm_answer_call(cm_client_h handle, cm_call_answer_type_e ans_type)
747 GVariant *dbus_result;
748 GError *error = NULL;
750 dbg("cm_answer_call()");
751 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
753 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
754 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_ANSWER_CALL,
755 g_variant_new("(i)", ans_type), NULL, G_DBUS_CALL_FLAGS_NONE,
756 CM_DEFAULT_TIMEOUT, handle->ca, &error);
759 err("Failed: %s", error->message);
761 return CM_ERROR_OPERATION_FAILED;
766 return CM_ERROR_OPERATION_FAILED;
769 g_variant_get(dbus_result, "(i)", &value);
770 g_variant_unref(dbus_result);
775 EXPORT_API int cm_speaker_on(cm_client_h handle)
777 GVariant *dbus_result;
778 GError *error = NULL;
781 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
783 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
784 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_SPK_ON,
785 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
786 CM_DEFAULT_TIMEOUT, handle->ca, &error);
789 err("Failed: %s", error->message);
791 return CM_ERROR_OPERATION_FAILED;
796 return CM_ERROR_OPERATION_FAILED;
799 g_variant_get(dbus_result, "(i)", &value);
800 g_variant_unref(dbus_result);
805 EXPORT_API int cm_speaker_off(cm_client_h handle)
807 GVariant *dbus_result;
808 GError *error = NULL;
811 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
813 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
814 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_SPK_OFF,
815 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
816 CM_DEFAULT_TIMEOUT, handle->ca, &error);
819 err("Failed: %s", error->message);
821 return CM_ERROR_OPERATION_FAILED;
826 return CM_ERROR_OPERATION_FAILED;
829 g_variant_get(dbus_result, "(i)", &value);
830 g_variant_unref(dbus_result);
835 EXPORT_API int cm_bluetooth_on(cm_client_h handle)
837 GVariant *dbus_result;
838 GError *error = NULL;
841 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
843 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
844 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_BLUETOOTH_ON,
845 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
846 CM_DEFAULT_TIMEOUT, handle->ca, &error);
849 err("Failed: %s", error->message);
851 return CM_ERROR_OPERATION_FAILED;
856 return CM_ERROR_OPERATION_FAILED;
859 g_variant_get(dbus_result, "(i)", &value);
860 g_variant_unref(dbus_result);
865 EXPORT_API int cm_bluetooth_off(cm_client_h handle)
867 GVariant *dbus_result;
868 GError *error = NULL;
871 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
873 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
874 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_BLUETOOTH_OFF,
875 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
876 CM_DEFAULT_TIMEOUT, handle->ca, &error);
879 err("Failed: %s", error->message);
881 return CM_ERROR_OPERATION_FAILED;
886 return CM_ERROR_OPERATION_FAILED;
889 g_variant_get(dbus_result, "(i)", &value);
890 g_variant_unref(dbus_result);
895 EXPORT_API int cm_set_extra_vol(cm_client_h handle, gboolean is_extra_vol)
897 GVariant *dbus_result;
898 GError *error = NULL;
901 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
903 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
904 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_SET_EXTRA_VOL,
905 g_variant_new("(b)", is_extra_vol), NULL, G_DBUS_CALL_FLAGS_NONE,
906 CM_DEFAULT_TIMEOUT, handle->ca, &error);
909 err("Failed: %s", error->message);
911 return CM_ERROR_OPERATION_FAILED;
916 return CM_ERROR_OPERATION_FAILED;
919 g_variant_get(dbus_result, "(i)", &value);
920 g_variant_unref(dbus_result);
925 EXPORT_API int cm_set_mute_state(cm_client_h handle, gboolean is_mute_state)
927 GVariant *dbus_result;
928 GError *error = NULL;
931 dbg("is_mute_state: %d", is_mute_state);
932 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
934 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
935 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_SET_MUTE_STATE,
936 g_variant_new("(b)", is_mute_state), NULL, G_DBUS_CALL_FLAGS_NONE,
937 CM_DEFAULT_TIMEOUT, handle->ca, &error);
940 err("Failed: %s", error->message);
942 return CM_ERROR_OPERATION_FAILED;
947 return CM_ERROR_OPERATION_FAILED;
950 g_variant_get(dbus_result, "(i)", &value);
951 g_variant_unref(dbus_result);
956 EXPORT_API int cm_start_dtmf(cm_client_h handle, unsigned char dtmf_digit)
958 GVariant *dbus_result;
959 GError *error = NULL;
961 dbg("cm_start_dtmf()");
962 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
963 CM_RETURN_VAL_IF_FAIL(dtmf_digit, CM_ERROR_INVALID_PARAMETER);
965 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
966 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_START_DTMF,
967 g_variant_new("(y)", dtmf_digit), NULL, G_DBUS_CALL_FLAGS_NONE,
968 CM_DEFAULT_TIMEOUT, handle->ca, &error);
971 err("Failed: %s", error->message);
973 return CM_ERROR_OPERATION_FAILED;
978 return CM_ERROR_OPERATION_FAILED;
981 g_variant_get(dbus_result, "(i)", &value);
982 g_variant_unref(dbus_result);
987 EXPORT_API int cm_stop_dtmf(cm_client_h handle)
989 GVariant *dbus_result;
990 GError *error = NULL;
992 dbg("cm_stop_dtmf()");
993 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
995 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
996 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_STOP_DTMF,
997 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
998 CM_DEFAULT_TIMEOUT, handle->ca, &error);
1001 err("Failed: %s", error->message);
1002 g_error_free(error);
1003 return CM_ERROR_OPERATION_FAILED;
1008 return CM_ERROR_OPERATION_FAILED;
1011 g_variant_get(dbus_result, "(i)", &value);
1012 g_variant_unref(dbus_result);
1017 EXPORT_API int cm_burst_dtmf(cm_client_h handle, char *dtmf_digits)
1019 GVariant *dbus_result;
1020 GError *error = NULL;
1022 dbg("cm_burst_dtmf()");
1023 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1024 CM_RETURN_VAL_IF_FAIL(dtmf_digits, CM_ERROR_INVALID_PARAMETER);
1026 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
1027 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_BURST_DTMF,
1028 g_variant_new("(s)", dtmf_digits), NULL, G_DBUS_CALL_FLAGS_NONE,
1029 CM_DEFAULT_TIMEOUT, handle->ca, &error);
1032 err("Failed: %s", error->message);
1033 g_error_free(error);
1034 return CM_ERROR_OPERATION_FAILED;
1039 return CM_ERROR_OPERATION_FAILED;
1042 g_variant_get(dbus_result, "(i)", &value);
1043 g_variant_unref(dbus_result);
1048 EXPORT_API int cm_send_dtmf_resp(cm_client_h handle, cm_dtmf_resp_type_e resp_type)
1050 GVariant *dbus_result;
1051 GError *error = NULL;
1054 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1056 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
1057 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_SEND_DTMF_RESP,
1058 g_variant_new("(i)", resp_type), NULL, G_DBUS_CALL_FLAGS_NONE,
1059 CM_DEFAULT_TIMEOUT, handle->ca, &error);
1062 err("Failed: %s", error->message);
1063 g_error_free(error);
1064 return CM_ERROR_OPERATION_FAILED;
1069 return CM_ERROR_OPERATION_FAILED;
1072 g_variant_get(dbus_result, "(i)", &value);
1073 g_variant_unref(dbus_result);
1078 EXPORT_API int cm_get_audio_state(cm_client_h handle, cm_audio_state_type_e *audio_state)
1080 GVariant *dbus_result;
1081 GError *error = NULL;
1083 dbg("cm_get_audio_state()");
1084 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1086 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
1087 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_GET_AUDIO_STATE,
1088 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
1089 CM_DEFAULT_TIMEOUT, handle->ca, &error);
1092 err("Failed: %s", error->message);
1093 g_error_free(error);
1094 return CM_ERROR_OPERATION_FAILED;
1099 return CM_ERROR_OPERATION_FAILED;
1102 g_variant_get(dbus_result, "(i)", &value);
1103 *audio_state = value;
1104 g_variant_unref(dbus_result);
1106 return CM_ERROR_NONE;
1109 EXPORT_API int cm_stop_alert(cm_client_h handle)
1112 GVariant *dbus_result;
1113 GError *error = NULL;
1115 dbg("cm_stop_alert()");
1117 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1119 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
1120 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_STOP_ALERT,
1121 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
1122 CM_DEFAULT_TIMEOUT, handle->ca, &error);
1125 g_variant_get(dbus_result, "(i)", &value);
1127 value = CM_ERROR_OPERATION_FAILED;
1130 err("g_dbus_conn failed. error (%s)", error->message);
1131 if (strstr(error->message, "No access rights")) {
1132 err("PERMISSION_DENIED");
1133 value = CM_ERROR_PERMISSION_DENIED;
1135 value = CM_ERROR_OPERATION_FAILED;
1137 g_error_free(error);
1140 g_variant_unref(dbus_result);
1145 EXPORT_API int cm_start_alert(cm_client_h handle)
1148 GVariant *dbus_result;
1149 GError *error = NULL;
1151 dbg("cm_start_alert()");
1153 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1155 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
1156 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_START_ALERT,
1157 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
1158 CM_DEFAULT_TIMEOUT, handle->ca, &error);
1161 g_variant_get(dbus_result, "(i)", &value);
1163 value = CM_ERROR_OPERATION_FAILED;
1166 err("g_dbus_conn failed. error (%s)", error->message);
1167 if (strstr(error->message, "No access rights")) {
1168 err("PERMISSION_DENIED");
1169 value = CM_ERROR_PERMISSION_DENIED;
1171 value = CM_ERROR_OPERATION_FAILED;
1173 g_error_free(error);
1176 g_variant_unref(dbus_result);
1181 EXPORT_API int cm_activate_ui(cm_client_h handle)
1183 dbg("cm_activate_ui()");
1184 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1185 GError *error = NULL;
1187 GVariant *dbus_result;
1189 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
1190 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_ACTIVATE_UI,
1191 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
1192 CM_DEFAULT_TIMEOUT, handle->ca, &error);
1195 err("Failed: %s", error->message);
1196 g_error_free(error);
1197 return CM_ERROR_OPERATION_FAILED;
1202 return CM_ERROR_OPERATION_FAILED;
1205 g_variant_get(dbus_result, "(i)", &value);
1206 g_variant_unref(dbus_result);
1210 EXPORT_API int cm_set_lcd_timeout(cm_client_h handle, cm_lcd_timeout_e timeout)
1212 dbg("cm_set_lcd_timeout()");
1213 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1215 int bPowerkeyMode = 0;
1220 int update_timer = 0;
1222 if (timeout == CM_LCD_TIMEOUT_LOCKSCREEN_SET) {
1228 ret = vconf_get_bool(VCONFKEY_CISSAPPL_POWER_KEY_ENDS_CALL_BOOL, &bPowerkeyMode);
1230 err("vconf_get_bool [VCONFKEY_CISSAPPL_POWER_KEY_ENDS_CALL_BOOL] failed.\n");
1233 dbg("set timeout : %d, powerkeymode : %d", timeout, bPowerkeyMode);
1234 if (timeout == CM_LCD_TIMEOUT_SET) {
1237 holdkey = bPowerkeyMode;
1238 } else if (timeout == CM_LCD_TIMEOUT_UNSET) {
1241 holdkey = bPowerkeyMode;
1242 } else if (timeout == CM_LCD_TIMEOUT_LOCKSCREEN_SET) { /*After lock-screen comes in Connected state LCD goes to OFF in 5 secs*/
1245 holdkey = bPowerkeyMode;
1246 } else if (timeout == CM_LCD_TIMEOUT_KEYPAD_SET) {
1249 holdkey = bPowerkeyMode;
1256 dbg("on(%d), dim(%d), hold(%d)", on, dim, holdkey);
1258 g_dbus_connection_call(handle->dbus_conn, DBUS_DEVICED,
1259 DBUS_DEVICED_PATH_DISPLAY, DBUS_DEVICED_INTERFACE_DISPLAY, DBUS_DEVICED_METHOD_SET_LCDTIMEOUT,
1260 g_variant_new("(iii)", on, dim, holdkey), NULL, G_DBUS_CALL_FLAGS_NONE,
1261 CM_DEFAULT_TIMEOUT, handle->ca, __cm_set_LCDtimeout_cb, NULL);
1263 g_dbus_connection_call(handle->dbus_conn, DBUS_DEVICED,
1264 DBUS_DEVICED_PATH_DISPLAY, DBUS_DEVICED_INTERFACE_DISPLAY, DBUS_DEVICED_METHOD_UPDATE_LCDTIMEOUT_BY_TOUCH,
1265 g_variant_new("(i)", update_timer), NULL, G_DBUS_CALL_FLAGS_NONE,
1266 CM_DEFAULT_TIMEOUT, handle->ca, __cm_set_LCDtimeout_cb, NULL);
1272 EXPORT_API int cm_get_all_call_list(cm_client_h handle, GSList **call_list)
1274 GVariant *dbus_result;
1275 GError *error = NULL;
1276 const gchar *param_type;
1277 cm_call_data_t *callData = NULL;
1278 GVariantIter *iter = 0, *iter_row = 0;
1280 dbg("cm_get_all_calllist()");
1281 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1283 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
1284 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_GET_CALL_LIST,
1285 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
1286 CM_DEFAULT_TIMEOUT, handle->ca, &error);
1289 err("Failed: %s", error->message);
1290 g_error_free(error);
1291 return CM_ERROR_OPERATION_FAILED;
1296 return CM_ERROR_OPERATION_FAILED;
1299 param_type = g_variant_get_type_string(dbus_result);
1300 dbg("param_type: '%s'", param_type);
1301 g_variant_get(dbus_result, "(aa{sv})", &iter);
1302 while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
1303 if (iter_row && (g_variant_iter_n_children(iter_row) > 0)) {
1304 ret = __cm_fetch_call_data(iter_row, &callData);
1306 *call_list = g_slist_append(*call_list, callData);
1308 g_variant_iter_free(iter_row);
1311 g_variant_iter_free(iter);
1312 g_variant_unref(dbus_result);
1314 return CM_ERROR_NONE;
1317 EXPORT_API int cm_get_conference_call_list(cm_client_h handle, GSList **call_list)
1319 GVariant *dbus_result;
1320 GError *error = NULL;
1321 const gchar *param_type;
1322 cm_conf_call_data_t *callData = NULL;
1323 GVariantIter *iter = 0, *iter_row = 0;
1324 dbg("cm_get_all_calllist()");
1325 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1327 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
1328 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_GET_CONF_CALL_LIST,
1329 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
1330 CM_DEFAULT_TIMEOUT, handle->ca, &error);
1333 err("Failed: %s", error->message);
1334 g_error_free(error);
1335 return CM_ERROR_OPERATION_FAILED;
1340 return CM_ERROR_OPERATION_FAILED;
1343 param_type = g_variant_get_type_string(dbus_result);
1344 dbg("param_type: '%s'", param_type);
1345 g_variant_get(dbus_result, "(aa{sv})", &iter);
1346 while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
1347 if (iter_row && (g_variant_iter_n_children(iter_row) > 0)) {
1349 GVariant *value = 0;
1351 callData = (cm_conf_call_data_t*)calloc(1, sizeof(cm_conf_call_data_t));
1352 CM_RETURN_VAL_IF_FAIL(callData, CM_ERROR_OPERATION_FAILED);
1354 while (g_variant_iter_loop(iter_row, "{sv}", &key, &value)) {
1355 if (!g_strcmp0(key, "call_id")) {
1356 callData->call_id = g_variant_get_uint32(value);
1357 } else if (!g_strcmp0(key, "call_number")) {
1358 callData->call_number = g_strdup(g_variant_get_string(value, 0));
1359 } else if (!g_strcmp0(key, "person_id")) {
1360 callData->person_id = g_variant_get_uint32(value);
1361 } else if (!g_strcmp0(key, "name_mode")) {
1362 callData->name_mode = g_variant_get_uint32(value);
1365 dbg("\n\n <<<<<<<<< CallData Info in Library START >>>>>>>>>> \n");
1366 dbg("call_id : %d, ", callData->call_id);
1367 if (callData->call_number) {
1368 dbg("call_number : %s, ", callData->call_number);
1370 dbg("person_id : %d", callData->person_id);
1371 dbg("name_mode : %d", callData->name_mode);
1372 dbg("\n\n <<<<<<<<< CallData Info in Library END >>>>>>>>>> \n");
1374 *call_list = g_slist_append(*call_list, callData);
1375 g_variant_iter_free(iter_row);
1378 g_variant_iter_free(iter);
1379 g_variant_unref(dbus_result);
1381 return CM_ERROR_NONE;
1384 EXPORT_API int cm_get_all_calldata(cm_client_h handle, cm_call_data_t **incom, cm_call_data_t **active, cm_call_data_t **held)
1386 GVariant *dbus_result;
1387 GError *error = NULL;
1388 const gchar *param_type;
1389 GVariantIter *iter_incom = 0, *iter_active_dial = 0, *iter_held = 0;
1390 dbg("cm_get_all_calldata()");
1391 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1393 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
1394 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_GET_ALL_CALL_DATA,
1395 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
1396 CM_DEFAULT_TIMEOUT, handle->ca, &error);
1399 err("Failed: %s", error->message);
1400 g_error_free(error);
1401 return CM_ERROR_OPERATION_FAILED;
1406 return CM_ERROR_OPERATION_FAILED;
1409 param_type = g_variant_get_type_string(dbus_result);
1410 dbg("param_type: '%s'", param_type);
1411 g_variant_get(dbus_result, "(a{sv}a{sv}a{sv})", &iter_incom, &iter_active_dial, &iter_held);
1413 /*Fetch IncomingData*/
1414 if (iter_incom && (g_variant_iter_n_children(iter_incom) > 0)) {
1415 __cm_fetch_call_data(iter_incom, incom);
1416 g_variant_iter_free(iter_incom);
1419 /*Fetch ActiveData*/
1420 if (iter_active_dial && (g_variant_iter_n_children(iter_active_dial) > 0)) {
1421 __cm_fetch_call_data(iter_active_dial, active);
1422 g_variant_iter_free(iter_active_dial);
1426 if (iter_held && (g_variant_iter_n_children(iter_held) > 0)) {
1427 __cm_fetch_call_data(iter_held, held);
1428 g_variant_iter_free(iter_held);
1431 return CM_ERROR_NONE;
1434 EXPORT_API int cm_get_call_status(cm_client_h handle, cm_call_status_e *call_status)
1436 GError *error = NULL;
1439 GVariant *dbus_result;
1440 int error_code = CM_ERROR_NONE;
1442 dbg("cm_get_call_status()");
1444 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1445 CM_RETURN_VAL_IF_FAIL(call_status, CM_ERROR_INVALID_PARAMETER);
1447 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
1448 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_GET_CALL_STATUS,
1449 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
1450 CM_DEFAULT_TIMEOUT, handle->ca, &error);
1453 g_variant_get(dbus_result, "(ii)", &status, &type);
1454 if (status < CM_CALL_STATUS_MAX) {
1455 *call_status = (cm_call_status_e)status;
1457 error_code = CM_ERROR_OPERATION_FAILED;
1460 err("g_dbus_conn failed. error (%s)", error->message);
1461 if (strstr(error->message, "No access rights")) {
1462 err("PERMISSION_DENIED");
1463 error_code = CM_ERROR_PERMISSION_DENIED;
1465 error_code = CM_ERROR_OPERATION_FAILED;
1467 g_error_free(error);
1470 g_variant_unref(dbus_result);
1475 EXPORT_API int cm_get_mute_status(cm_client_h handle, cm_mute_status_e *mute_status)
1477 GError *error = NULL;
1479 GVariant *dbus_result;
1480 int error_code = CM_ERROR_NONE;
1482 dbg("cm_get_mute_status()");
1484 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1485 CM_RETURN_VAL_IF_FAIL(mute_status, CM_ERROR_INVALID_PARAMETER);
1487 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
1488 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_GET_MUTE_STATUS,
1489 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
1490 CM_DEFAULT_TIMEOUT, handle->ca, &error);
1493 g_variant_get(dbus_result, "(i)", &status);
1494 if (status < CM_MUTE_STATUS_MAX && status >= CM_MUTE_STATUS_OFF) {
1495 *mute_status = (cm_mute_status_e)status;
1497 error_code = CM_ERROR_OPERATION_FAILED;
1500 err("g_dbus_conn failed. error (%s)", error->message);
1501 if (strstr(error->message, "No access rights")) {
1502 err("PERMISSION_DENIED");
1503 error_code = CM_ERROR_PERMISSION_DENIED;
1505 error_code = CM_ERROR_OPERATION_FAILED;
1507 g_error_free(error);
1510 g_variant_unref(dbus_result);
1516 EXPORT_API int cm_set_mute_status_cb(cm_client_h handle, cm_mute_status_cb cb, void *user_data)
1518 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1519 CM_RETURN_VAL_IF_FAIL(cb, CM_ERROR_INVALID_PARAMETER);
1520 return __cm_set_cb(handle, DBUS_CALL_MANAGER_SIGNAL_MUTE_STATUS, cb, user_data);
1523 EXPORT_API int cm_unset_mute_status_cb(cm_client_h handle)
1525 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1526 return __cm_unset_cb(handle, DBUS_CALL_MANAGER_SIGNAL_MUTE_STATUS);
1529 EXPORT_API int cm_set_call_status_cb(cm_client_h handle, cm_call_status_cb cb, void *user_data)
1531 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1532 CM_RETURN_VAL_IF_FAIL(cb, CM_ERROR_INVALID_PARAMETER);
1533 return __cm_set_cb(handle, DBUS_CALL_MANAGER_SIGNAL_CALL_STATUS, cb, user_data);
1536 EXPORT_API int cm_unset_call_status_cb(cm_client_h handle)
1538 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1539 return __cm_unset_cb(handle, DBUS_CALL_MANAGER_SIGNAL_CALL_STATUS);
1542 EXPORT_API int cm_set_call_event_cb(cm_client_h handle, cm_call_event_cb cb, void *user_data)
1544 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1545 CM_RETURN_VAL_IF_FAIL(cb, CM_ERROR_INVALID_PARAMETER);
1546 return __cm_set_cb(handle, DBUS_CALL_MANAGER_SIGNAL_CALL_EVENT, cb, user_data);
1549 EXPORT_API int cm_unset_call_event_cb(cm_client_h handle)
1551 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1552 return __cm_unset_cb(handle, DBUS_CALL_MANAGER_SIGNAL_CALL_EVENT);
1555 EXPORT_API int cm_set_dial_status_cb(cm_client_h handle, cm_dial_status_cb cb, void *user_data)
1557 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1558 CM_RETURN_VAL_IF_FAIL(cb, CM_ERROR_INVALID_PARAMETER);
1559 return __cm_set_cb(handle, DBUS_CALL_MANAGER_SIGNAL_DIAL_STATUS, cb, user_data);
1562 EXPORT_API int cm_unset_dial_status_cb(cm_client_h handle)
1564 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1565 return __cm_unset_cb(handle, DBUS_CALL_MANAGER_SIGNAL_DIAL_STATUS);
1568 EXPORT_API int cm_set_audio_state_changed_cb(cm_client_h handle, cm_audio_state_changed_cb cb, void *user_data)
1570 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1571 CM_RETURN_VAL_IF_FAIL(cb, CM_ERROR_INVALID_PARAMETER);
1572 return __cm_set_cb(handle, DBUS_CALL_MANAGER_SIGNAL_AUDIO_STATE, cb, user_data);
1575 EXPORT_API int cm_unset_audio_state_changed_cb(cm_client_h handle)
1577 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1578 return __cm_unset_cb(handle, DBUS_CALL_MANAGER_SIGNAL_AUDIO_STATE);
1581 EXPORT_API int cm_set_dtmf_indication_cb(cm_client_h handle, cm_dtmf_indi_cb cb, void *user_data)
1583 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1584 CM_RETURN_VAL_IF_FAIL(cb, CM_ERROR_INVALID_PARAMETER);
1585 return __cm_set_cb(handle, DBUS_CALL_MANAGER_SIGNAL_DTMF_INDI, cb, user_data);
1588 EXPORT_API int cm_unset_dtmf_indication_cb(cm_client_h handle)
1590 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1591 return __cm_unset_cb(handle, DBUS_CALL_MANAGER_SIGNAL_DTMF_INDI);
1594 EXPORT_API int cm_set_foreground_cb(cm_client_h handle, cm_go_foreground_cb cb, void *user_data)
1596 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1597 CM_RETURN_VAL_IF_FAIL(cb, CM_ERROR_INVALID_PARAMETER);
1598 return __cm_set_cb(handle, DBUS_CALL_MANAGER_SIGNAL_GO_FOREGROUND, cb, user_data);
1601 EXPORT_API int cm_unset_foreground_cb(cm_client_h handle)
1603 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1604 return __cm_unset_cb(handle, DBUS_CALL_MANAGER_SIGNAL_GO_FOREGROUND);
1607 EXPORT_API int cm_call_data_free(cm_call_data_t *call_data)
1609 CM_RETURN_VAL_IF_FAIL(call_data, CM_ERROR_INVALID_PARAMETER);
1610 g_free(call_data->call_number);
1611 g_free(call_data->calling_name);
1614 return CM_ERROR_NONE;
1617 EXPORT_API int cm_call_data_get_call_id(cm_call_data_t *call_data, unsigned int *call_id)
1619 CM_RETURN_VAL_IF_FAIL(call_data, CM_ERROR_INVALID_PARAMETER);
1620 CM_RETURN_VAL_IF_FAIL(call_id, CM_ERROR_INVALID_PARAMETER);
1622 *call_id = call_data->call_id;
1623 return CM_ERROR_NONE;
1626 EXPORT_API int cm_call_data_get_call_direction(cm_call_data_t *call_data, cm_call_direction_e *call_direction)
1628 CM_RETURN_VAL_IF_FAIL(call_data, CM_ERROR_INVALID_PARAMETER);
1629 CM_RETURN_VAL_IF_FAIL(call_direction, CM_ERROR_INVALID_PARAMETER);
1631 *call_direction = call_data->call_direction;
1632 return CM_ERROR_NONE;
1635 EXPORT_API int cm_call_data_get_call_number(cm_call_data_t *call_data, char **call_number)
1637 CM_RETURN_VAL_IF_FAIL(call_data, CM_ERROR_INVALID_PARAMETER);
1638 CM_RETURN_VAL_IF_FAIL(call_number, CM_ERROR_INVALID_PARAMETER);
1640 *call_number = call_data->call_number;
1641 return CM_ERROR_NONE;
1644 EXPORT_API int cm_call_data_get_calling_name(cm_call_data_t *call_data, char **calling_name)
1646 CM_RETURN_VAL_IF_FAIL(call_data, CM_ERROR_INVALID_PARAMETER);
1647 CM_RETURN_VAL_IF_FAIL(calling_name, CM_ERROR_INVALID_PARAMETER);
1649 *calling_name = call_data->calling_name;
1650 return CM_ERROR_NONE;
1653 EXPORT_API int cm_call_data_get_call_type(cm_call_data_t *call_data, cm_call_type_e *call_type)
1655 CM_RETURN_VAL_IF_FAIL(call_data, CM_ERROR_INVALID_PARAMETER);
1656 CM_RETURN_VAL_IF_FAIL(call_type, CM_ERROR_INVALID_PARAMETER);
1658 *call_type = call_data->call_type;
1659 return CM_ERROR_NONE;
1662 EXPORT_API int cm_call_data_get_call_state(cm_call_data_t *call_data, cm_call_state_e *call_state)
1664 CM_RETURN_VAL_IF_FAIL(call_data, CM_ERROR_INVALID_PARAMETER);
1665 CM_RETURN_VAL_IF_FAIL(call_state, CM_ERROR_INVALID_PARAMETER);
1667 *call_state = call_data->call_state;
1668 return CM_ERROR_NONE;
1671 EXPORT_API int cm_call_data_get_call_domain(cm_call_data_t *call_data, cm_call_domain_e *call_domain)
1673 CM_RETURN_VAL_IF_FAIL(call_data, CM_ERROR_INVALID_PARAMETER);
1674 CM_RETURN_VAL_IF_FAIL(call_domain, CM_ERROR_INVALID_PARAMETER);
1676 *call_domain = call_data->call_domain;
1677 return CM_ERROR_NONE;
1680 EXPORT_API int cm_call_data_get_person_id(cm_call_data_t *call_data, int *person_id)
1682 CM_RETURN_VAL_IF_FAIL(call_data, CM_ERROR_INVALID_PARAMETER);
1683 CM_RETURN_VAL_IF_FAIL(person_id, CM_ERROR_INVALID_PARAMETER);
1685 *person_id = call_data->person_id;
1686 return CM_ERROR_NONE;
1689 EXPORT_API int cm_call_data_get_call_member_count(cm_call_data_t *call_data, int *member_count)
1691 CM_RETURN_VAL_IF_FAIL(call_data, CM_ERROR_INVALID_PARAMETER);
1692 CM_RETURN_VAL_IF_FAIL(member_count, CM_ERROR_INVALID_PARAMETER);
1694 *member_count = call_data->member_count;
1695 return CM_ERROR_NONE;
1698 EXPORT_API int cm_call_data_is_emergency_call(cm_call_data_t *call_data, gboolean *is_emergency)
1700 CM_RETURN_VAL_IF_FAIL(call_data, CM_ERROR_INVALID_PARAMETER);
1701 CM_RETURN_VAL_IF_FAIL(is_emergency, CM_ERROR_INVALID_PARAMETER);
1703 *is_emergency = call_data->is_ecc;
1704 return CM_ERROR_NONE;
1707 EXPORT_API int cm_call_data_is_voicemail_number(cm_call_data_t *call_data, gboolean *is_voicemail_number)
1709 CM_RETURN_VAL_IF_FAIL(call_data, CM_ERROR_INVALID_PARAMETER);
1710 CM_RETURN_VAL_IF_FAIL(is_voicemail_number, CM_ERROR_INVALID_PARAMETER);
1712 *is_voicemail_number = call_data->is_voicemail_number;
1713 return CM_ERROR_NONE;
1716 EXPORT_API int cm_call_data_get_start_time(cm_call_data_t *call_data, long *start_time)
1718 CM_RETURN_VAL_IF_FAIL(call_data, CM_ERROR_INVALID_PARAMETER);
1719 CM_RETURN_VAL_IF_FAIL(start_time, CM_ERROR_INVALID_PARAMETER);
1721 *start_time = call_data->start_time;
1722 return CM_ERROR_NONE;
1725 EXPORT_API int cm_call_data_get_name_mode(cm_call_data_t *call_data, cm_name_mode_e *name_mode)
1727 CM_RETURN_VAL_IF_FAIL(call_data, CM_ERROR_INVALID_PARAMETER);
1728 CM_RETURN_VAL_IF_FAIL(name_mode, CM_ERROR_INVALID_PARAMETER);
1730 *name_mode = call_data->name_mode;
1731 return CM_ERROR_NONE;
1734 EXPORT_API int cm_call_event_data_get_call_id(cm_call_event_data_t *call_event_data, unsigned int *call_id)
1736 CM_RETURN_VAL_IF_FAIL(call_event_data, CM_ERROR_INVALID_PARAMETER);
1737 CM_RETURN_VAL_IF_FAIL(call_id, CM_ERROR_INVALID_PARAMETER);
1738 *call_id = call_event_data->call_id;
1739 return CM_ERROR_NONE;
1742 EXPORT_API int cm_call_event_data_get_sim_slot(cm_call_event_data_t *call_event_data, cm_multi_sim_slot_type_e *sim_slot)
1744 CM_RETURN_VAL_IF_FAIL(call_event_data, CM_ERROR_INVALID_PARAMETER);
1745 CM_RETURN_VAL_IF_FAIL(sim_slot, CM_ERROR_INVALID_PARAMETER);
1746 *sim_slot = call_event_data->sim_slot;
1747 return CM_ERROR_NONE;
1750 EXPORT_API int cm_call_event_data_get_end_cause(cm_call_event_data_t *call_event_data, cm_call_end_cause_type_e *end_cause)
1752 CM_RETURN_VAL_IF_FAIL(call_event_data, CM_ERROR_INVALID_PARAMETER);
1753 CM_RETURN_VAL_IF_FAIL(end_cause, CM_ERROR_INVALID_PARAMETER);
1754 *end_cause = call_event_data->end_cause;
1755 return CM_ERROR_NONE;
1758 EXPORT_API int cm_call_event_data_get_incom_call(cm_call_event_data_t *call_event_data, cm_call_data_t **incom_call)
1760 CM_RETURN_VAL_IF_FAIL(call_event_data, CM_ERROR_INVALID_PARAMETER);
1761 CM_RETURN_VAL_IF_FAIL(incom_call, CM_ERROR_INVALID_PARAMETER);
1762 *incom_call = call_event_data->incom;
1763 return CM_ERROR_NONE;
1766 EXPORT_API int cm_call_event_data_get_active_call(cm_call_event_data_t *call_event_data, cm_call_data_t **active_call)
1768 CM_RETURN_VAL_IF_FAIL(call_event_data, CM_ERROR_INVALID_PARAMETER);
1769 CM_RETURN_VAL_IF_FAIL(active_call, CM_ERROR_INVALID_PARAMETER);
1770 *active_call = call_event_data->active_dial;
1771 return CM_ERROR_NONE;
1774 EXPORT_API int cm_call_event_data_get_held_call(cm_call_event_data_t *call_event_data, cm_call_data_t **held_call)
1776 CM_RETURN_VAL_IF_FAIL(call_event_data, CM_ERROR_INVALID_PARAMETER);
1777 CM_RETURN_VAL_IF_FAIL(held_call, CM_ERROR_INVALID_PARAMETER);
1778 *held_call = call_event_data->held;
1779 return CM_ERROR_NONE;
1782 EXPORT_API int cm_conf_call_data_get_call_id(cm_conf_call_data_t *conf_call, unsigned int *call_id)
1784 CM_RETURN_VAL_IF_FAIL(conf_call, CM_ERROR_INVALID_PARAMETER);
1785 CM_RETURN_VAL_IF_FAIL(call_id, CM_ERROR_INVALID_PARAMETER);
1787 *call_id = conf_call->call_id;
1788 return CM_ERROR_NONE;
1791 EXPORT_API int cm_conf_call_data_get_call_number(cm_conf_call_data_t *conf_call, char **call_number)
1793 CM_RETURN_VAL_IF_FAIL(conf_call, CM_ERROR_INVALID_PARAMETER);
1794 CM_RETURN_VAL_IF_FAIL(call_number, CM_ERROR_INVALID_PARAMETER);
1796 *call_number = conf_call->call_number;
1797 return CM_ERROR_NONE;
1800 EXPORT_API int cm_conf_call_data_get_person_id(cm_conf_call_data_t *conf_call, int *person_id)
1802 CM_RETURN_VAL_IF_FAIL(conf_call, CM_ERROR_INVALID_PARAMETER);
1803 CM_RETURN_VAL_IF_FAIL(person_id, CM_ERROR_INVALID_PARAMETER);
1805 *person_id = conf_call->person_id;
1806 return CM_ERROR_NONE;
1809 EXPORT_API int cm_conf_call_data_get_name_mode(cm_conf_call_data_t *conf_call, cm_name_mode_e *name_mode)
1811 CM_RETURN_VAL_IF_FAIL(conf_call, CM_ERROR_INVALID_PARAMETER);
1812 CM_RETURN_VAL_IF_FAIL(name_mode, CM_ERROR_INVALID_PARAMETER);
1814 *name_mode = conf_call->name_mode;
1815 return CM_ERROR_NONE;
1818 EXPORT_API int cm_conf_call_data_free(cm_conf_call_data_t *conf_call)
1820 CM_RETURN_VAL_IF_FAIL(conf_call, CM_ERROR_INVALID_PARAMETER);
1821 g_free(conf_call->call_number);
1824 return CM_ERROR_NONE;
1827 EXPORT_API int cm_set_lcd_state(cm_lcd_control_state_e state)
1833 result = device_display_change_state(DISPLAY_STATE_SCREEN_OFF);
1837 result = device_display_change_state(DISPLAY_STATE_NORMAL);
1840 case CM_LCD_ON_LOCK:
1841 result = device_display_change_state(DISPLAY_STATE_NORMAL);
1842 result = device_power_request_lock(POWER_LOCK_DISPLAY, 0);
1845 case CM_LCD_ON_UNLOCK:
1846 result = device_display_change_state(DISPLAY_STATE_NORMAL);
1847 result = device_power_release_lock(POWER_LOCK_DISPLAY);
1848 result = device_power_release_lock(POWER_LOCK_CPU);
1851 case CM_LCD_OFF_SLEEP_LOCK:
1852 result = device_power_request_lock(POWER_LOCK_CPU, 0);
1855 case CM_LCD_OFF_SLEEP_UNLOCK:
1856 result = device_power_release_lock(POWER_LOCK_DISPLAY);
1857 result = device_power_release_lock(POWER_LOCK_CPU);
1863 if (result != DEVICE_ERROR_NONE) {
1864 warn("error during change lcd state");
1865 return CM_ERROR_OPERATION_FAILED;
1868 return CM_ERROR_NONE;
1871 EXPORT_API int cm_start_voice_record(cm_client_h handle, char *call_num)
1873 GVariant *dbus_result;
1874 GError *error = NULL;
1876 dbg("cm_start_voice_record()");
1877 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1878 CM_RETURN_VAL_IF_FAIL(call_num, CM_ERROR_INVALID_PARAMETER);
1880 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
1881 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_START_VOICE_RECORD,
1882 g_variant_new("(s)", call_num), NULL, G_DBUS_CALL_FLAGS_NONE,
1883 CM_DEFAULT_TIMEOUT, handle->ca, &error);
1886 err("Failed: %s", error->message);
1887 g_error_free(error);
1888 return CM_ERROR_OPERATION_FAILED;
1893 return CM_ERROR_OPERATION_FAILED;
1896 g_variant_get(dbus_result, "(i)", &value);
1897 g_variant_unref(dbus_result);
1902 EXPORT_API int cm_stop_voice_record(cm_client_h handle)
1904 GVariant *dbus_result;
1905 GError *error = NULL;
1907 dbg("cm_stop_voice_record()");
1908 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1910 dbus_result = g_dbus_connection_call_sync(handle->dbus_conn, DBUS_CALL_MANAGER,
1911 DBUS_CALL_MANAGER_PATH, DBUS_CALL_MANAGER_DEFAULT_INTERFACE, DBUS_CALL_MANAGER_METHOD_STOP_VOICE_RECORD,
1912 g_variant_new("()"), NULL, G_DBUS_CALL_FLAGS_NONE,
1913 CM_DEFAULT_TIMEOUT, handle->ca, &error);
1916 err("Failed: %s", error->message);
1917 g_error_free(error);
1918 return CM_ERROR_OPERATION_FAILED;
1923 return CM_ERROR_OPERATION_FAILED;
1926 g_variant_get(dbus_result, "(i)", &value);
1927 g_variant_unref(dbus_result);
1932 EXPORT_API int cm_set_voice_record_status_cb(cm_client_h handle, cm_voice_record_status_cb cb, void *user_data)
1934 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1935 CM_RETURN_VAL_IF_FAIL(cb, CM_ERROR_INVALID_PARAMETER);
1936 return __cm_set_cb(handle, DBUS_CALL_MANAGER_SIGNAL_VOICE_RECORD_STATUS, cb, user_data);
1939 EXPORT_API int cm_unset_voice_record_status_cb (cm_client_h handle)
1941 CM_RETURN_VAL_IF_FAIL(handle, CM_ERROR_INVALID_PARAMETER);
1942 return __cm_unset_cb(handle, DBUS_CALL_MANAGER_SIGNAL_VOICE_RECORD_STATUS);