2 * Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved
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.
17 #include "vc_command.h"
22 static int g_waiting_time = 3000;
24 static Ecore_Fd_Handler* g_fd_handler = NULL;
26 static DBusConnection* g_conn_sender = NULL;
27 static DBusConnection* g_conn_listener = NULL;
29 extern int __vc_cb_error(int reason, int daemon_pid, char* msg);
31 extern void __vc_cb_result();
33 extern int __vc_cb_service_state(int state);
35 extern int __vc_cb_manager_pid(int manager_pid);
38 static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
40 if (NULL == g_conn_listener) return ECORE_CALLBACK_RENEW;
42 dbus_connection_read_write_dispatch(g_conn_listener, 50);
45 DBusMessage* msg = NULL;
46 msg = dbus_connection_pop_message(g_conn_listener);
48 /* loop again if we haven't read a message */
54 dbus_error_init(&err);
56 char if_name[64] = {0, };
57 snprintf(if_name, 64, "%s", VC_CLIENT_SERVICE_INTERFACE);
59 if (dbus_message_is_method_call(msg, if_name, VCD_METHOD_HELLO)) {
60 SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get Hello");
64 dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
66 if (dbus_error_is_set(&err)) {
67 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
68 dbus_error_free(&err);
72 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc get hello : pid(%d) ", pid);
75 SLOG(LOG_ERROR, TAG_VCC, "@@ vc get hello : invalid pid ");
78 DBusMessage* reply = NULL;
79 reply = dbus_message_new_method_return(msg);
82 dbus_message_append_args(reply, DBUS_TYPE_INT32, &response, DBUS_TYPE_INVALID);
84 if (!dbus_connection_send(g_conn_listener, reply, NULL))
85 SLOG(LOG_ERROR, TAG_VCC, "@@ vc get hello : fail to send reply");
87 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc get hello : result(%d)", response);
89 dbus_connection_flush(g_conn_listener);
90 dbus_message_unref(reply);
92 SLOG(LOG_ERROR, TAG_VCC, "@@ vc get hello : fail to create reply message");
95 SLOG(LOG_DEBUG, TAG_VCC, "@@@");
96 } /* VCD_METHOD_HELLO */
98 else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_SET_SERVICE_STATE)) {
101 dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID);
102 if (dbus_error_is_set(&err)) {
103 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Get arguments error (%s)", err.message);
104 dbus_error_free(&err);
107 SLOG(LOG_DEBUG, TAG_VCC, "@@ state changed : %d", state);
109 __vc_cb_service_state(state);
111 } /* VCD_METHOD_SET_SERVICE_STATE */
113 else if (dbus_message_is_method_call(msg, if_name, VCD_METHOD_RESULT)) {
114 SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get Client Result");
118 SLOG(LOG_DEBUG, TAG_VCC, "@@@");
120 } /* VCD_METHOD_RESULT */
121 else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_SEND_MANAGER_PID)) {
124 dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &manager_pid, DBUS_TYPE_INVALID);
125 if (dbus_error_is_set(&err)) {
126 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Get arguments error (%s)", err.message);
127 dbus_error_free(&err);
130 SLOG(LOG_DEBUG, TAG_VCC, "@@ manager pid is changed : %d", manager_pid);
132 __vc_cb_manager_pid(manager_pid);
134 } /* VCD_METHOD_SEND_MANAGER_PID */
136 else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_ERROR)) {
137 SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get Error");
142 dbus_message_get_args(msg, &err,
143 DBUS_TYPE_INT32, &reason,
144 DBUS_TYPE_INT32, &daemon_pid,
145 DBUS_TYPE_STRING, &err_msg,
148 if (dbus_error_is_set(&err)) {
149 SLOG(LOG_ERROR, TAG_VCC, "@@ vc Get Error message : Get arguments error (%s)", err.message);
150 dbus_error_free(&err);
152 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get Error message : reason(%d), daemon_pid(%d), msg(%s)", reason, daemon_pid, err_msg);
153 __vc_cb_error(reason, daemon_pid, err_msg);
156 SLOG(LOG_DEBUG, TAG_VCC, "@@@");
157 } /* VCD_METHOD_ERROR */
159 else if (dbus_message_is_signal(msg, "org.freedesktop.DBus", "NameOwnerChanged")) {
160 SLOG(LOG_DEBUG, TAG_VCC, "@@@ Owner Changed");
162 dbus_error_init(&err);
163 /* remove a rule for daemon error */
164 char rule_err[256] = {0, };
165 snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE);
166 dbus_bus_remove_match(g_conn_listener, rule_err, &err);
167 dbus_connection_flush(g_conn_listener);
169 if (dbus_error_is_set(&err)) {
170 SLOG(LOG_ERROR, TAG_VCC, "Match Error (%s)", err.message);
171 dbus_error_free(&err);
173 __vc_cb_error(VC_ERROR_SERVICE_RESET, -1, "Daemon Reset");
174 SLOG(LOG_DEBUG, TAG_VCC, "@@@");
175 } /* NameOwnerChanged */
178 SLOG(LOG_DEBUG, TAG_VCC, "Message is NOT valid");
179 dbus_message_unref(msg);
183 /* free the message */
184 dbus_message_unref(msg);
187 return ECORE_CALLBACK_PASS_ON;
190 static void __vc_dbus_connection_free()
192 if (NULL != g_conn_listener) {
193 dbus_connection_close(g_conn_listener);
194 dbus_connection_unref(g_conn_listener);
195 g_conn_listener = NULL;
197 if (NULL != g_conn_sender) {
198 dbus_connection_close(g_conn_sender);
199 dbus_connection_unref(g_conn_sender);
200 g_conn_sender = NULL;
204 int vc_dbus_open_connection()
206 if (NULL != g_conn_sender && NULL != g_conn_listener) {
207 SLOG(LOG_WARN, TAG_VCC, "already existed connection ");
214 /* initialise the error value */
215 dbus_error_init(&err);
217 /* connect to the DBUS system bus, and check for errors */
218 g_conn_sender = dbus_bus_get_private(DBUS_BUS_SESSION, &err);
220 if (dbus_error_is_set(&err)) {
221 SLOG(LOG_ERROR, TAG_VCC, "Dbus Connection Error (%s)", err.message);
222 dbus_error_free(&err);
225 if (NULL == g_conn_sender) {
226 SLOG(LOG_ERROR, TAG_VCC, "Fail to get dbus connection ");
227 return VC_ERROR_OPERATION_FAILED;
230 dbus_connection_set_exit_on_disconnect(g_conn_sender, false);
232 g_conn_listener = dbus_bus_get_private(DBUS_BUS_SESSION, &err);
234 if (dbus_error_is_set(&err)) {
235 SLOG(LOG_ERROR, TAG_VCC, "Dbus Connection Error (%s)", err.message);
236 dbus_error_free(&err);
239 if (NULL == g_conn_listener) {
240 SLOG(LOG_ERROR, TAG_VCC, "Fail to get dbus connection ");
241 __vc_dbus_connection_free();
242 return VC_ERROR_OPERATION_FAILED;
245 dbus_connection_set_exit_on_disconnect(g_conn_listener, false);
249 char service_name[64];
250 memset(service_name, '\0', 64);
251 snprintf(service_name, 64, "%s%d", VC_CLIENT_SERVICE_NAME, pid);
253 SLOG(LOG_DEBUG, TAG_VCC, "service name is %s", service_name);
255 /* register our name on the bus, and check for errors */
256 ret = dbus_bus_request_name(g_conn_listener, service_name, DBUS_NAME_FLAG_REPLACE_EXISTING, &err);
258 if (dbus_error_is_set(&err)) {
259 SLOG(LOG_ERROR, TAG_VCC, "Name Error (%s)", err.message);
260 dbus_error_free(&err);
263 if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) {
264 SLOG(LOG_ERROR, TAG_VCC, "fail dbus_bus_request_name()");
265 __vc_dbus_connection_free();
269 if (NULL != g_fd_handler) {
270 SLOG(LOG_WARN, TAG_VCC, "The handler already exists.");
271 __vc_dbus_connection_free();
275 char rule[256] = {0, };
276 snprintf(rule, 256, "type='signal',interface='%s'", VC_CLIENT_SERVICE_INTERFACE);
278 /* add a rule for which messages we want to see */
279 dbus_bus_add_match(g_conn_listener, rule, &err);
280 dbus_connection_flush(g_conn_listener);
282 if (dbus_error_is_set(&err)) {
283 SLOG(LOG_ERROR, TAG_VCC, "Match Error (%s)", err.message);
284 dbus_error_free(&err);
285 __vc_dbus_connection_free();
286 return VC_ERROR_OPERATION_FAILED;
289 /* add a rule for daemon error */
290 snprintf(rule, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE);
291 dbus_bus_add_match(g_conn_listener, rule, &err);
292 dbus_connection_flush(g_conn_listener);
294 if (dbus_error_is_set(&err)) {
295 SLOG(LOG_ERROR, TAG_VCC, "Match Error (%s)", err.message);
296 dbus_error_free(&err);
297 __vc_dbus_connection_free();
298 return VC_ERROR_OPERATION_FAILED;
302 if (1 != dbus_connection_get_unix_fd(g_conn_listener, &fd)) {
303 SLOG(LOG_ERROR, TAG_VCC, "fail to get fd from dbus ");
304 __vc_dbus_connection_free();
305 return VC_ERROR_OPERATION_FAILED;
307 SLOG(LOG_DEBUG, TAG_VCC, "Get fd from dbus : %d", fd);
310 g_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_event_callback, g_conn_listener, NULL, NULL);
311 if (NULL == g_fd_handler) {
312 SLOG(LOG_ERROR, TAG_VCC, "fail to get fd handler from ecore ");
313 __vc_dbus_connection_free();
314 return VC_ERROR_OPERATION_FAILED;
320 int vc_dbus_close_connection()
323 dbus_error_init(&err);
325 if (NULL != g_fd_handler) {
326 ecore_main_fd_handler_del(g_fd_handler);
330 if (NULL != g_conn_listener) {
333 char service_name[64];
334 memset(service_name, '\0', 64);
335 snprintf(service_name, 64, "%s%d", VC_CLIENT_SERVICE_NAME, pid);
337 dbus_bus_release_name(g_conn_listener, service_name, &err);
339 if (dbus_error_is_set(&err)) {
340 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
341 dbus_error_free(&err);
345 __vc_dbus_connection_free();
350 int vc_dbus_reconnect()
352 if (!g_conn_sender || !g_conn_listener) {
353 vc_dbus_close_connection();
355 if (0 != vc_dbus_open_connection()) {
356 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect");
360 SLOG(LOG_DEBUG, TAG_VCC, "[DBUS] Reconnect");
364 bool sender_connected = dbus_connection_get_is_connected(g_conn_sender);
365 bool listener_connected = dbus_connection_get_is_connected(g_conn_listener);
366 SLOG(LOG_WARN, TAG_VCC, "[DBUS] Sender(%s) Listener(%s)",
367 sender_connected ? "Connected" : "Not connected", listener_connected ? "Connected" : "Not connected");
369 if (false == sender_connected || false == listener_connected) {
370 vc_dbus_close_connection();
372 if (0 != vc_dbus_open_connection()) {
373 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect");
377 SLOG(LOG_DEBUG, TAG_VCC, "[DBUS] Reconnect");
383 static int __dbus_check()
385 if (NULL == g_conn_sender) {
386 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection");
387 return vc_dbus_reconnect();
392 int vc_dbus_request_hello()
394 if (0 != __dbus_check()) {
395 return VC_ERROR_OPERATION_FAILED;
400 msg = dbus_message_new_method_call(
401 VC_SERVER_SERVICE_NAME,
402 VC_SERVER_SERVICE_OBJECT_PATH,
403 VC_SERVER_SERVICE_INTERFACE,
407 SLOG(LOG_ERROR, TAG_VCC, "@@ Request vc hello : Fail to make message");
408 return VC_ERROR_OPERATION_FAILED;
412 dbus_error_init(&err);
414 DBusMessage* result_msg = NULL;
417 result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, 500, &err);
419 if (dbus_error_is_set(&err)) {
420 SLOG(LOG_DEBUG, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
421 dbus_error_free(&err);
424 dbus_message_unref(msg);
426 if (NULL != result_msg) {
427 dbus_message_unref(result_msg);
430 result = VC_ERROR_TIMED_OUT;
437 int vc_dbus_request_initialize(int pid, int* mgr_pid, int* service_state, int* daemon_pid)
439 if (0 != __dbus_check()) {
440 return VC_ERROR_OPERATION_FAILED;
445 msg = dbus_message_new_method_call(
446 VC_SERVER_SERVICE_NAME,
447 VC_SERVER_SERVICE_OBJECT_PATH,
448 VC_SERVER_SERVICE_INTERFACE,
449 VC_METHOD_INITIALIZE);
452 SLOG(LOG_ERROR, TAG_VCC, "@@ vc initialize : Fail to make message ");
453 return VC_ERROR_OPERATION_FAILED;
455 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc initialize : pid(%d)", pid);
458 dbus_message_append_args(msg,
459 DBUS_TYPE_INT32, &pid,
463 dbus_error_init(&err);
465 DBusMessage* result_msg;
466 int result = VC_ERROR_OPERATION_FAILED;
468 result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
469 dbus_message_unref(msg);
471 if (dbus_error_is_set(&err)) {
472 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
473 dbus_error_free(&err);
476 if (NULL != result_msg) {
478 int tmp_service_state = 0;
479 int tmp_daemon_pid = 0;
480 dbus_message_get_args(result_msg, &err,
481 DBUS_TYPE_INT32, &result,
482 DBUS_TYPE_INT32, &tmp,
483 DBUS_TYPE_INT32, &tmp_service_state,
484 DBUS_TYPE_INT32, &tmp_daemon_pid,
487 if (dbus_error_is_set(&err)) {
488 SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message);
489 dbus_error_free(&err);
490 result = VC_ERROR_OPERATION_FAILED;
493 dbus_message_unref(result_msg);
497 *service_state = tmp_service_state;
498 *daemon_pid = tmp_daemon_pid;
500 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc initialize : result = %d mgr = %d service = %d daemon_pid = %d", result, *mgr_pid, *service_state, *daemon_pid);
502 SLOG(LOG_ERROR, TAG_VCC, "@@ vc initialize : result = %d", result);
505 SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL ");
507 result = VC_ERROR_TIMED_OUT;
513 int vc_dbus_request_finalize(int pid)
516 dbus_error_init(&err);
518 if (0 != __dbus_check()) {
519 return VC_ERROR_OPERATION_FAILED;
522 /* remove a rule for daemon error */
523 char rule_err[256] = {0, };
524 snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE);
525 dbus_bus_remove_match(g_conn_listener, rule_err, &err);
526 dbus_connection_flush(g_conn_listener);
528 if (dbus_error_is_set(&err)) {
529 SLOG(LOG_ERROR, TAG_VCC, "Match Error (%s)", err.message);
530 dbus_error_free(&err);
535 msg = dbus_message_new_method_call(
536 VC_SERVER_SERVICE_NAME,
537 VC_SERVER_SERVICE_OBJECT_PATH,
538 VC_SERVER_SERVICE_INTERFACE,
542 SLOG(LOG_ERROR, TAG_VCC, "@@ vc finalize : Fail to make message ");
543 return VC_ERROR_OPERATION_FAILED;
545 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc finalize : pid(%d)", pid);
548 dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
550 DBusMessage* result_msg;
551 int result = VC_ERROR_OPERATION_FAILED;
553 result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
554 dbus_message_unref(msg);
556 if (dbus_error_is_set(&err)) {
557 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
558 dbus_error_free(&err);
561 if (NULL != result_msg) {
562 dbus_message_get_args(result_msg, &err,
563 DBUS_TYPE_INT32, &result,
566 if (dbus_error_is_set(&err)) {
567 SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message);
568 dbus_error_free(&err);
569 result = VC_ERROR_OPERATION_FAILED;
572 dbus_message_unref(result_msg);
575 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc finalize : result = %d", result);
577 SLOG(LOG_ERROR, TAG_VCC, "@@ vc finalize : result = %d", result);
580 SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL ");
582 result = VC_ERROR_TIMED_OUT;
588 int vc_dbus_request_set_exclusive_command(int pid, bool value)
590 if (0 != __dbus_check()) {
591 return VC_ERROR_OPERATION_FAILED;
596 msg = dbus_message_new_method_call(
597 VC_SERVER_SERVICE_NAME,
598 VC_SERVER_SERVICE_OBJECT_PATH,
599 VC_SERVER_SERVICE_INTERFACE,
600 VC_METHOD_SET_EXCLUSIVE_CMD);
603 SLOG(LOG_ERROR, TAG_VCC, "@@ vc set exclusive command : Fail to make message");
604 return VC_ERROR_OPERATION_FAILED;
606 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set exclusive command : pid(%d)", pid);
611 dbus_message_append_args(msg,
612 DBUS_TYPE_INT32, &pid,
613 DBUS_TYPE_INT32, &temp,
617 dbus_error_init(&err);
619 DBusMessage* result_msg;
620 int result = VC_ERROR_OPERATION_FAILED;
622 result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
623 dbus_message_unref(msg);
625 if (dbus_error_is_set(&err)) {
626 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
627 dbus_error_free(&err);
630 if (NULL != result_msg) {
631 dbus_message_get_args(result_msg, &err,
632 DBUS_TYPE_INT32, &result,
635 if (dbus_error_is_set(&err)) {
636 SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message);
637 dbus_error_free(&err);
638 result = VC_ERROR_OPERATION_FAILED;
640 dbus_message_unref(result_msg);
643 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set exclusive command : result = %d", result);
645 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set exclusive command : result = %d", result);
648 SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL");
650 result = VC_ERROR_TIMED_OUT;
656 int vc_dbus_request_set_command(int pid, vc_cmd_type_e cmd_type)
658 if (0 != __dbus_check()) {
659 return VC_ERROR_OPERATION_FAILED;
664 msg = dbus_message_new_method_call(
665 VC_SERVER_SERVICE_NAME,
666 VC_SERVER_SERVICE_OBJECT_PATH,
667 VC_SERVER_SERVICE_INTERFACE,
668 VC_METHOD_SET_COMMAND);
671 SLOG(LOG_ERROR, TAG_VCC, "@@ vc set command : Fail to make message");
672 return VC_ERROR_OPERATION_FAILED;
674 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set command : pid(%d)", pid);
677 dbus_message_append_args(msg,
678 DBUS_TYPE_INT32, &pid,
679 DBUS_TYPE_INT32, &cmd_type,
683 dbus_error_init(&err);
685 DBusMessage* result_msg;
686 int result = VC_ERROR_OPERATION_FAILED;
688 result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
689 dbus_message_unref(msg);
691 if (dbus_error_is_set(&err)) {
692 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
693 dbus_error_free(&err);
696 if (NULL != result_msg) {
697 dbus_message_get_args(result_msg, &err,
698 DBUS_TYPE_INT32, &result,
701 if (dbus_error_is_set(&err)) {
702 SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message);
703 dbus_error_free(&err);
704 result = VC_ERROR_OPERATION_FAILED;
706 dbus_message_unref(result_msg);
709 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set command : result = %d", result);
711 SLOG(LOG_ERROR, TAG_VCC, "@@ vc set command : result = %d", result);
714 SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL");
716 result = VC_ERROR_TIMED_OUT;
722 int vc_dbus_request_unset_command(int pid, vc_cmd_type_e cmd_type)
724 if (0 != __dbus_check()) {
725 return VC_ERROR_OPERATION_FAILED;
730 msg = dbus_message_new_method_call(
731 VC_SERVER_SERVICE_NAME,
732 VC_SERVER_SERVICE_OBJECT_PATH,
733 VC_SERVER_SERVICE_INTERFACE,
734 VC_METHOD_UNSET_COMMAND);
737 SLOG(LOG_ERROR, TAG_VCC, "@@ vc unset command : Fail to make message");
738 return VC_ERROR_OPERATION_FAILED;
740 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc unset command : pid(%d), type(%d)", pid, cmd_type);
743 dbus_message_append_args(msg,
744 DBUS_TYPE_INT32, &pid,
745 DBUS_TYPE_INT32, &cmd_type,
749 dbus_error_init(&err);
751 DBusMessage* result_msg;
752 int result = VC_ERROR_OPERATION_FAILED;
754 result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
755 dbus_message_unref(msg);
757 if (dbus_error_is_set(&err)) {
758 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
759 dbus_error_free(&err);
762 if (NULL != result_msg) {
763 dbus_message_get_args(result_msg, &err,
764 DBUS_TYPE_INT32, &result,
767 if (dbus_error_is_set(&err)) {
768 SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message);
769 dbus_error_free(&err);
770 result = VC_ERROR_OPERATION_FAILED;
772 dbus_message_unref(result_msg);
775 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc unset command : result = %d", result);
777 SLOG(LOG_ERROR, TAG_VCC, "@@ vc unset command : result = %d", result);
780 SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL");
782 result = VC_ERROR_TIMED_OUT;
788 int vc_dbus_set_foreground(int pid, bool value)
790 if (0 != __dbus_check()) {
791 return VC_ERROR_OPERATION_FAILED;
794 DBusMessage* msg = NULL;
797 tmp_value = (int)value;
799 msg = dbus_message_new_signal(
800 VC_MANAGER_SERVICE_OBJECT_PATH,
801 VC_MANAGER_SERVICE_INTERFACE,
802 VCC_MANAGER_METHOD_SET_FOREGROUND);
805 SLOG(LOG_ERROR, TAG_VCC, "@@ vc set foreground to manager : Fail to make message");
806 return VC_ERROR_OPERATION_FAILED;
808 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set foreground to manager : client pid(%d), value(%s)", pid, tmp_value ? "true" : "false");
811 dbus_message_append_args(msg,
812 DBUS_TYPE_INT32, &pid,
813 DBUS_TYPE_INT32, &tmp_value,
816 if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) {
817 SLOG(LOG_ERROR, TAG_VCC, "[Dbus ERROR] Fail to Send");
818 return VC_ERROR_OPERATION_FAILED;
821 dbus_message_unref(msg);
824 msg = dbus_message_new_method_call(
825 VC_SERVER_SERVICE_NAME,
826 VC_SERVER_SERVICE_OBJECT_PATH,
827 VC_SERVER_SERVICE_INTERFACE,
828 VC_METHOD_SET_FOREGROUND);
831 SLOG(LOG_ERROR, TAG_VCC, "@@ vc set foreground to daemon : Fail to make message");
832 return VC_ERROR_OPERATION_FAILED;
834 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set foreground to daemon : client pid(%d), value(%s)", pid, tmp_value ? "true" : "false");
837 dbus_message_append_args(msg,
838 DBUS_TYPE_INT32, &pid,
839 DBUS_TYPE_INT32, &tmp_value,
842 dbus_message_set_no_reply(msg, TRUE);
844 if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) {
845 SLOG(LOG_ERROR, TAG_VCC, "[Dbus ERROR] Fail to Send");
846 return VC_ERROR_OPERATION_FAILED;
849 dbus_connection_flush(g_conn_sender);
851 dbus_message_unref(msg);
856 int vc_dbus_request_dialog(int pid, const char* disp_text, const char* utt_text, bool continuous)
858 if (NULL == g_conn_sender) {
859 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection");
860 if (0 != vc_dbus_reconnect()) {
861 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect");
866 int tmp_continue = 0;
868 tmp_continue = (int)continuous;
870 msg = dbus_message_new_method_call(
871 VC_SERVER_SERVICE_NAME,
872 VC_SERVER_SERVICE_OBJECT_PATH,
873 VC_SERVER_SERVICE_INTERFACE,
877 SLOG(LOG_ERROR, TAG_VCC, "@@ vc request dialog to manager : Fail to make message");
878 return VC_ERROR_OPERATION_FAILED;
880 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc request dialog to manager : client pid(%d), disp_text(%s), utt_text(%s), continuous(%d)", getpid(), disp_text, utt_text, continuous);
883 dbus_message_append_args(msg,
884 DBUS_TYPE_INT32, &pid,
885 DBUS_TYPE_STRING, &disp_text,
886 DBUS_TYPE_STRING, &utt_text,
887 DBUS_TYPE_INT32, &tmp_continue,
890 dbus_message_set_no_reply(msg, TRUE);
892 if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) {
893 SLOG(LOG_ERROR, TAG_VCC, "[Dbus ERROR] Fail to Send");
894 return VC_ERROR_OPERATION_FAILED;
896 SLOG(LOG_DEBUG, TAG_VCC, "[Dbus DEBUG] Success to Send");
897 dbus_connection_flush(g_conn_sender);
900 dbus_message_unref(msg);
906 dbus_error_init(&err);
908 DBusMessage* result_msg;
909 int result = VC_ERROR_OPERATION_FAILED;
911 result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
912 dbus_message_unref(msg);
914 if (dbus_error_is_set(&err)) {
915 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
916 dbus_error_free(&err);
919 if (NULL != result_msg) {
920 dbus_message_get_args(result_msg, &err,
921 DBUS_TYPE_INT32, &result,
924 if (dbus_error_is_set(&err)) {
925 SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message);
926 dbus_error_free(&err);
927 result = VC_ERROR_OPERATION_FAILED;
929 dbus_message_unref(result_msg);
932 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set command : result = %d", result);
934 SLOG(LOG_ERROR, TAG_VCC, "@@ vc set command : result = %d", result);
937 SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL");
939 result = VC_ERROR_TIMED_OUT;
946 int vc_dbus_request_is_system_command_valid(int pid, bool* is_sys_cmd_valid)
948 if (NULL == g_conn_sender) {
949 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection");
950 if (0 != vc_dbus_reconnect()) {
951 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect");
957 msg = dbus_message_new_method_call(
958 VC_SERVER_SERVICE_NAME,
959 VC_SERVER_SERVICE_OBJECT_PATH,
960 VC_SERVER_SERVICE_INTERFACE,
961 VC_METHOD_IS_SYS_COMMAND_VALID);
964 SLOG(LOG_ERROR, TAG_VCC, "@@ vc is system command valid : Fail to make message");
965 return VC_ERROR_OPERATION_FAILED;
967 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc is system command valid : pid(%d)", pid);
970 dbus_message_append_args(msg,
971 DBUS_TYPE_INT32, &pid,
975 dbus_error_init(&err);
978 DBusMessage* result_msg;
979 int result = VC_ERROR_OPERATION_FAILED;
981 result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
982 dbus_message_unref(msg);
984 if (dbus_error_is_set(&err)) {
985 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
986 dbus_error_free(&err);
989 if (NULL != result_msg) {
990 dbus_message_get_args(result_msg, &err,
991 DBUS_TYPE_INT32, &result,
992 DBUS_TYPE_INT32, &tmp_sys_cmd,
995 if (dbus_error_is_set(&err)) {
996 SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message);
997 dbus_error_free(&err);
998 result = VC_ERROR_OPERATION_FAILED;
1000 dbus_message_unref(result_msg);
1003 *is_sys_cmd_valid = (bool)tmp_sys_cmd;
1004 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc is system command valid : result = %d, is_sys_cmd_valid = %d", result, *is_sys_cmd_valid);
1006 SLOG(LOG_ERROR, TAG_VCC, "@@ vc is system command valid : result = %d", result);
1009 SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL");
1010 vc_dbus_reconnect();
1011 result = VC_ERROR_TIMED_OUT;
1019 int vc_dbus_request_start(int pid, int silence)
1023 /* create a signal & check for errors */
1024 msg = dbus_message_new_method_call(
1025 VC_SERVER_SERVICE_NAME,
1026 VC_SERVER_SERVICE_OBJECT_PATH,
1027 VC_SERVER_SERVICE_INTERFACE,
1028 VC_METHOD_REQUEST_START);
1031 SLOG(LOG_ERROR, TAG_VCC, "@@ vc start : Fail to make message ");
1032 return VC_ERROR_OPERATION_FAILED;
1034 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc start : pid(%d), silence(%d)", pid, silence);
1037 DBusMessageIter args;
1038 dbus_message_iter_init_append(msg, &args);
1041 dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(pid));
1042 dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(silence));
1045 dbus_error_init(&err);
1047 DBusMessage* result_msg;
1048 int result = VC_ERROR_OPERATION_FAILED;
1050 result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
1051 dbus_message_unref(msg);
1053 if (dbus_error_is_set(&err)) {
1054 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
1055 dbus_error_free(&err);
1058 if (NULL != result_msg) {
1059 dbus_message_get_args(result_msg, &err,
1060 DBUS_TYPE_INT32, &result,
1063 if (dbus_error_is_set(&err)) {
1064 SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message);
1065 dbus_error_free(&err);
1066 result = VC_ERROR_OPERATION_FAILED;
1068 dbus_message_unref(result_msg);
1071 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc start : result = %d", result);
1073 SLOG(LOG_ERROR, TAG_VCC, "@@ vc start : result = %d", result);
1076 SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL");
1077 vc_dbus_reconnect();
1078 result = VC_ERROR_TIMED_OUT;
1084 int vc_dbus_request_stop(int pid)
1088 /* create a signal & check for errors */
1089 msg = dbus_message_new_method_call(
1090 VC_SERVER_SERVICE_NAME,
1091 VC_SERVER_SERVICE_OBJECT_PATH,
1092 VC_SERVER_SERVICE_INTERFACE,
1093 VC_METHOD_REQUEST_STOP);
1096 SLOG(LOG_ERROR, TAG_VCC, "@@ vc stop : Fail to make message ");
1097 return VC_ERROR_OPERATION_FAILED;
1099 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc stop : pid(%d)", pid);
1102 dbus_message_append_args(msg,
1103 DBUS_TYPE_INT32, &pid,
1107 dbus_error_init(&err);
1109 DBusMessage* result_msg;
1110 int result = VC_ERROR_OPERATION_FAILED;
1112 result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
1113 dbus_message_unref(msg);
1115 if (dbus_error_is_set(&err)) {
1116 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
1117 dbus_error_free(&err);
1120 if (NULL != result_msg) {
1121 dbus_message_get_args(result_msg, &err,
1122 DBUS_TYPE_INT32, &result,
1125 if (dbus_error_is_set(&err)) {
1126 SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message);
1127 dbus_error_free(&err);
1128 result = VC_ERROR_OPERATION_FAILED;
1130 dbus_message_unref(result_msg);
1133 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc stop : result = %d", result);
1135 SLOG(LOG_ERROR, TAG_VCC, "@@ vc stop : result = %d", result);
1138 SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL");
1139 vc_dbus_reconnect();
1140 result = VC_ERROR_TIMED_OUT;
1146 int vc_dbus_request_cancel(int pid)
1150 /* create a signal & check for errors */
1151 msg = dbus_message_new_method_call(
1152 VC_SERVER_SERVICE_NAME,
1153 VC_SERVER_SERVICE_OBJECT_PATH, /* object name of the signal */
1154 VC_SERVER_SERVICE_INTERFACE, /* interface name of the signal */
1155 VC_METHOD_REQUEST_CANCEL); /* name of the signal */
1158 SLOG(LOG_ERROR, TAG_VCC, "@@ vc cancel : Fail to make message ");
1159 return VC_ERROR_OPERATION_FAILED;
1161 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc cancel : pid(%d)", pid);
1164 dbus_message_append_args(msg,
1165 DBUS_TYPE_INT32, &pid,
1169 dbus_error_init(&err);
1171 DBusMessage* result_msg;
1172 int result = VC_ERROR_OPERATION_FAILED;
1174 result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
1175 dbus_message_unref(msg);
1177 if (dbus_error_is_set(&err)) {
1178 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
1179 dbus_error_free(&err);
1182 if (NULL != result_msg) {
1183 dbus_message_get_args(result_msg, &err,
1184 DBUS_TYPE_INT32, &result,
1187 if (dbus_error_is_set(&err)) {
1188 SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message);
1189 dbus_error_free(&err);
1190 result = VC_ERROR_OPERATION_FAILED;
1192 dbus_message_unref(result_msg);
1195 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc cancel : result = %d", result);
1197 SLOG(LOG_ERROR, TAG_VCC, "@@ vc cancel : result = %d", result);
1200 SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL");
1201 vc_dbus_reconnect();
1202 result = VC_ERROR_TIMED_OUT;
1210 int vc_dbus_request_auth_enable(int pid, int mgr_pid)
1212 if (0 != __dbus_check()) {
1213 return VC_ERROR_OPERATION_FAILED;
1218 char service_name[64] = {0,};
1219 char object_path[64] = {0,};
1220 char target_if_name[128] = {0,};
1222 snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, mgr_pid);
1223 snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH);
1224 snprintf(target_if_name, 128, "%s%d", VC_MANAGER_SERVICE_INTERFACE, mgr_pid);
1226 /* create a signal & check for errors */
1227 msg = dbus_message_new_method_call(
1229 object_path, /* object name of the signal */
1230 target_if_name, /* interface name of the signal */
1231 VC_METHOD_AUTH_ENABLE); /* name of the signal */
1234 SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth enable : Fail to make message ");
1235 return VC_ERROR_OPERATION_FAILED;
1237 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth enable : pid(%d)", pid);
1240 dbus_message_append_args(msg,
1241 DBUS_TYPE_INT32, &pid,
1245 dbus_error_init(&err);
1247 DBusMessage* result_msg;
1248 int result = VC_ERROR_OPERATION_FAILED;
1250 result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
1251 dbus_message_unref(msg);
1253 if (dbus_error_is_set(&err)) {
1254 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
1255 dbus_error_free(&err);
1258 if (NULL != result_msg) {
1259 dbus_message_get_args(result_msg, &err,
1260 DBUS_TYPE_INT32, &result,
1263 if (dbus_error_is_set(&err)) {
1264 SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message);
1265 dbus_error_free(&err);
1266 result = VC_ERROR_OPERATION_FAILED;
1268 dbus_message_unref(result_msg);
1271 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth enable : result = %d", result);
1273 SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth enable : result = %d", result);
1276 SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL");
1277 vc_dbus_reconnect();
1278 result = VC_ERROR_TIMED_OUT;
1284 int vc_dbus_request_auth_disable(int pid, int mgr_pid)
1286 if (0 != __dbus_check()) {
1287 return VC_ERROR_OPERATION_FAILED;
1292 char service_name[64] = {0,};
1293 char object_path[64] = {0,};
1294 char target_if_name[128] = {0,};
1296 snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, mgr_pid);
1297 snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH);
1298 snprintf(target_if_name, 128, "%s%d", VC_MANAGER_SERVICE_INTERFACE, mgr_pid);
1300 /* create a signal & check for errors */
1301 msg = dbus_message_new_method_call(
1303 object_path, /* object name of the signal */
1304 target_if_name, /* interface name of the signal */
1305 VC_METHOD_AUTH_DISABLE); /* name of the signal */
1308 SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth disable : Fail to make message ");
1309 return VC_ERROR_OPERATION_FAILED;
1311 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth disable : pid(%d)", pid);
1314 dbus_message_append_args(msg,
1315 DBUS_TYPE_INT32, &pid,
1319 dbus_error_init(&err);
1321 DBusMessage* result_msg;
1322 int result = VC_ERROR_OPERATION_FAILED;
1324 result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
1325 dbus_message_unref(msg);
1327 if (dbus_error_is_set(&err)) {
1328 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
1329 dbus_error_free(&err);
1332 if (NULL != result_msg) {
1333 dbus_message_get_args(result_msg, &err,
1334 DBUS_TYPE_INT32, &result,
1337 if (dbus_error_is_set(&err)) {
1338 SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message);
1339 dbus_error_free(&err);
1340 result = VC_ERROR_OPERATION_FAILED;
1342 dbus_message_unref(result_msg);
1345 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth disable : result = %d", result);
1347 SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth disable : result = %d", result);
1350 SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL");
1351 vc_dbus_reconnect();
1352 result = VC_ERROR_TIMED_OUT;
1358 int vc_dbus_request_auth_start(int pid, int mgr_pid)
1360 if (0 != __dbus_check()) {
1361 return VC_ERROR_OPERATION_FAILED;
1366 char service_name[64] = {0,};
1367 char object_path[64] = {0,};
1368 char target_if_name[128] = {0,};
1370 snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, mgr_pid);
1371 snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH);
1372 snprintf(target_if_name, 128, "%s%d", VC_MANAGER_SERVICE_INTERFACE, mgr_pid);
1374 /* create a signal & check for errors */
1375 msg = dbus_message_new_method_call(
1379 VC_METHOD_AUTH_START);
1382 SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth start : Fail to make message ");
1383 return VC_ERROR_OPERATION_FAILED;
1385 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth start : pid(%d)", pid);
1388 DBusMessageIter args;
1389 dbus_message_iter_init_append(msg, &args);
1392 dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(pid));
1395 dbus_error_init(&err);
1397 DBusMessage* result_msg;
1398 int result = VC_ERROR_OPERATION_FAILED;
1400 result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
1401 dbus_message_unref(msg);
1403 if (dbus_error_is_set(&err)) {
1404 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
1405 dbus_error_free(&err);
1408 if (NULL != result_msg) {
1409 dbus_message_get_args(result_msg, &err,
1410 DBUS_TYPE_INT32, &result,
1413 if (dbus_error_is_set(&err)) {
1414 SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message);
1415 dbus_error_free(&err);
1416 result = VC_ERROR_OPERATION_FAILED;
1418 dbus_message_unref(result_msg);
1421 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth start : result = %d", result);
1423 SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth start : result = %d", result);
1426 SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL");
1427 vc_dbus_reconnect();
1428 result = VC_ERROR_TIMED_OUT;
1434 int vc_dbus_request_auth_stop(int pid, int mgr_pid)
1436 if (0 != __dbus_check()) {
1437 return VC_ERROR_OPERATION_FAILED;
1442 char service_name[64] = {0,};
1443 char object_path[64] = {0,};
1444 char target_if_name[128] = {0,};
1446 snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, mgr_pid);
1447 snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH);
1448 snprintf(target_if_name, 128, "%s%d", VC_MANAGER_SERVICE_INTERFACE, mgr_pid);
1450 /* create a signal & check for errors */
1451 msg = dbus_message_new_method_call(
1455 VC_METHOD_AUTH_STOP);
1458 SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth stop : Fail to make message ");
1459 return VC_ERROR_OPERATION_FAILED;
1461 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth stop : pid(%d)", pid);
1464 dbus_message_append_args(msg,
1465 DBUS_TYPE_INT32, &pid,
1469 dbus_error_init(&err);
1471 DBusMessage* result_msg;
1472 int result = VC_ERROR_OPERATION_FAILED;
1474 result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
1475 dbus_message_unref(msg);
1477 if (dbus_error_is_set(&err)) {
1478 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
1479 dbus_error_free(&err);
1482 if (NULL != result_msg) {
1483 dbus_message_get_args(result_msg, &err,
1484 DBUS_TYPE_INT32, &result,
1487 if (dbus_error_is_set(&err)) {
1488 SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message);
1489 dbus_error_free(&err);
1490 result = VC_ERROR_OPERATION_FAILED;
1492 dbus_message_unref(result_msg);
1495 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth stop : result = %d", result);
1497 SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth stop : result = %d", result);
1500 SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL");
1501 vc_dbus_reconnect();
1502 result = VC_ERROR_TIMED_OUT;
1508 int vc_dbus_request_auth_cancel(int pid, int mgr_pid)
1510 if (0 != __dbus_check()) {
1511 return VC_ERROR_OPERATION_FAILED;
1516 char service_name[64] = {0,};
1517 char object_path[64] = {0,};
1518 char target_if_name[128] = {0,};
1520 snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, mgr_pid);
1521 snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH);
1522 snprintf(target_if_name, 128, "%s%d", VC_MANAGER_SERVICE_INTERFACE, mgr_pid);
1524 /* create a signal & check for errors */
1525 msg = dbus_message_new_method_call(
1527 object_path, /* object name of the signal */
1528 target_if_name, /* interface name of the signal */
1529 VC_METHOD_AUTH_CANCEL); /* name of the signal */
1532 SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth cancel : Fail to make message ");
1533 return VC_ERROR_OPERATION_FAILED;
1535 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth cancel : pid(%d)", pid);
1538 dbus_message_append_args(msg,
1539 DBUS_TYPE_INT32, &pid,
1543 dbus_error_init(&err);
1545 DBusMessage* result_msg;
1546 int result = VC_ERROR_OPERATION_FAILED;
1548 result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
1549 dbus_message_unref(msg);
1551 if (dbus_error_is_set(&err)) {
1552 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
1553 dbus_error_free(&err);
1556 if (NULL != result_msg) {
1557 dbus_message_get_args(result_msg, &err,
1558 DBUS_TYPE_INT32, &result,
1561 if (dbus_error_is_set(&err)) {
1562 SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message);
1563 dbus_error_free(&err);
1564 result = VC_ERROR_OPERATION_FAILED;
1566 dbus_message_unref(result_msg);
1569 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth cancel : result = %d", result);
1571 SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth cancel : result = %d", result);
1574 SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL");
1575 vc_dbus_reconnect();
1576 result = VC_ERROR_TIMED_OUT;