static int g_privilege_allowed = -1;
static cynara *p_cynara = NULL;
-#if 0
-static Ecore_Event_Handler* g_focus_in_hander = NULL;
-static Ecore_Event_Handler* g_focus_out_hander = NULL;
-#endif
-
Eina_Bool __vc_notify_state_changed(void *data);
Eina_Bool __vc_notify_error(void *data);
static int __check_privilege(const char* uid, const char * privilege)
{
FILE *fp = NULL;
- char smack_label[1024] = "/proc/self/attr/current";
+ char label_path[1024] = "/proc/self/attr/current";
+ char smack_label[1024] = {'\0',};
if (!p_cynara) {
return false;
}
- fp = fopen(smack_label, "r");
+ fp = fopen(label_path, "r");
if (fp != NULL) {
if (fread(smack_label, 1, sizeof(smack_label), fp) <= 0)
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] fail to fread");
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request finalize : %s", __vc_get_error_code(ret));
}
-
-#if 0
- ecore_event_handler_del(g_focus_in_hander);
- ecore_event_handler_del(g_focus_out_hander);
-#endif
-
vc_cmd_parser_delete_file(getpid(), VC_COMMAND_TYPE_FOREGROUND);
vc_cmd_parser_delete_file(getpid(), VC_COMMAND_TYPE_BACKGROUND);
return VC_ERROR_NONE;
}
-#if 0
-static Eina_Bool __vc_x_event_window_focus_in(void *data, int type, void *event)
-{
- Ecore_X_Event_Window_Focus_In *e;
-
- e = event;
-
- int xid = -1;
- if (0 != vc_client_get_xid(g_vc, &xid)) {
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get current xid");
- return ECORE_CALLBACK_PASS_ON;
- }
-
- if (e->win == (Ecore_X_Window)xid) {
- SLOG(LOG_DEBUG, TAG_VCC, "Focus in : pid(%d) xid(%d)", getpid(), xid);
- int ret = vc_config_mgr_set_foreground(getpid(), true);
- if (0 != ret) {
- ret = vc_config_convert_error_code((vc_config_error_e)ret);
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set focus in : %s", __vc_get_error_code(ret));
- }
- /* set authority valid */
- vc_auth_state_e state = VC_AUTH_STATE_NONE;
- if (0 != vc_client_get_auth_state(g_vc, &state)) {
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state");
- }
- if (VC_AUTH_STATE_INVALID == state) {
- vc_client_set_auth_state(g_vc, VC_AUTH_STATE_VALID);
-
- /* notify auth changed cb */
- ecore_timer_add(0, __notify_auth_changed_cb, NULL);
- }
- }
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool __vc_x_event_window_focus_out(void *data, int type, void *event)
-{
- Ecore_X_Event_Window_Focus_In *e;
-
- e = event;
-
- int xid = -1;
- if (0 != vc_client_get_xid(g_vc, &xid)) {
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get current xid");
- return ECORE_CALLBACK_PASS_ON;
- }
-
- if (e->win == (Ecore_X_Window)xid) {
- SLOG(LOG_DEBUG, TAG_VCC, "Focus out : pid(%d) xid(%d)", getpid(), xid);
- int ret = vc_config_mgr_set_foreground(getpid(), false);
- if (0 != ret) {
- ret = vc_config_convert_error_code((vc_config_error_e)ret);
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set focus out : %s", __vc_get_error_code(ret));
- }
- /* set authority valid */
- vc_auth_state_e state = VC_AUTH_STATE_NONE;
- if (0 != vc_client_get_auth_state(g_vc, &state)) {
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state");
- }
- if (VC_AUTH_STATE_VALID == state) {
- vc_client_set_auth_state(g_vc, VC_AUTH_STATE_INVALID);
-
- /* notify authority changed cb */
- ecore_timer_add(0, __notify_auth_changed_cb, NULL);
- }
- }
-
- return ECORE_CALLBACK_PASS_ON;
-}
-#endif
-
static Eina_Bool __vc_connect_daemon(void *data)
{
/* Send hello */
vc_client_set_service_state(g_vc, (vc_service_state_e)service_state);
g_connect_timer = NULL;
-#if 0
- g_focus_in_hander = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_IN, __vc_x_event_window_focus_in, NULL);
- g_focus_out_hander = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_OUT, __vc_x_event_window_focus_out, NULL);
-#else
+
ret = aul_add_status_local_cb(__vc_app_state_changed_cb, NULL);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set app stae changed callback");
}
-#endif
+
+ int status = aul_app_get_status_bypid(getpid());
+ if (STATUS_FOCUS == status || STATUS_VISIBLE == status) {
+ SLOG(LOG_DEBUG, TAG_VCC, "===== Set foreground");
+ ret = vc_dbus_set_foreground(getpid(), true);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (true) : %d", ret);
+ }
+
+ ret = vc_client_set_is_foreground(g_vc, true);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to save is_foreground (true) : %d", ret);
+ }
+
+ /* set authority valid */
+ vc_auth_state_e state = VC_AUTH_STATE_NONE;
+ if (0 != vc_client_get_auth_state(g_vc, &state)) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state");
+ }
+ if (VC_AUTH_STATE_INVALID == state) {
+ vc_client_set_auth_state(g_vc, VC_AUTH_STATE_VALID);
+
+ /* notify auth changed cb */
+ ecore_idler_add(__notify_auth_changed_cb, NULL);
+ }
+ }
+
vc_client_set_client_state(g_vc, VC_STATE_READY);
ecore_timer_add(0, __vc_notify_state_changed, g_vc);
return VC_ERROR_NONE;
}
-#if 0
-int vc_set_window_id(int wid)
-{
- SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Set Window id");
-
- if (0 >= wid) {
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Input parameter is invalid");
- SLOG(LOG_DEBUG, TAG_VCC, "=====");
- SLOG(LOG_DEBUG, TAG_VCC, " ");
- return VC_ERROR_INVALID_PARAMETER;
- }
-
- vc_state_e state;
- if (0 != vc_client_get_client_state(g_vc, &state)) {
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available");
- SLOG(LOG_DEBUG, TAG_VCC, "=====");
- SLOG(LOG_DEBUG, TAG_VCC, " ");
- return VC_ERROR_INVALID_STATE;
- }
-
- /* check state */
- if (state != VC_STATE_READY) {
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'");
- SLOG(LOG_DEBUG, TAG_VCC, "=====");
- SLOG(LOG_DEBUG, TAG_VCC, " ");
- return VC_ERROR_INVALID_STATE;
- }
-
- if (0 != vc_client_set_xid(g_vc, wid)) {
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid");
- SLOG(LOG_DEBUG, TAG_VCC, "=====");
- SLOG(LOG_DEBUG, TAG_VCC, " ");
- return VC_ERROR_INVALID_STATE;
- }
-
- /* Check if current xid is top window */
- int ret = -1;
- if ((Ecore_X_Window)wid == ecore_x_window_focus_get()) {
- /* Set current pid */
- ret = vc_config_mgr_set_foreground(getpid(), true);
- if (0 != ret) {
- ret = vc_config_convert_error_code((vc_config_error_e)ret);
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set focus in : %s", __vc_get_error_code(ret));
- }
- }
-
- SLOG(LOG_DEBUG, TAG_VCC, "=====");
- SLOG(LOG_DEBUG, TAG_VCC, " ");
-
- return ret;
-}
-
-int vc_get_window_id(int* wid)
-{
- SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Get Window id");
-
- if (NULL == wid) {
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Input parameter is NULL");
- SLOG(LOG_DEBUG, TAG_VCC, "=====");
- SLOG(LOG_DEBUG, TAG_VCC, " ");
- return VC_ERROR_INVALID_PARAMETER;
- }
-
- vc_state_e state;
- if (0 != vc_client_get_client_state(g_vc, &state)) {
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available");
- SLOG(LOG_DEBUG, TAG_VCC, "=====");
- SLOG(LOG_DEBUG, TAG_VCC, " ");
- return VC_ERROR_INVALID_STATE;
- }
-
- /* check state */
- if (state != VC_STATE_READY) {
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'");
- SLOG(LOG_DEBUG, TAG_VCC, "=====");
- SLOG(LOG_DEBUG, TAG_VCC, " ");
- return VC_ERROR_INVALID_STATE;
- }
-
- if (0 != vc_client_get_xid(g_vc, wid)) {
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid");
- SLOG(LOG_DEBUG, TAG_VCC, "=====");
- SLOG(LOG_DEBUG, TAG_VCC, " ");
- return VC_ERROR_INVALID_STATE;
- }
-
- SLOG(LOG_DEBUG, TAG_VCC, "=====");
- SLOG(LOG_DEBUG, TAG_VCC, " ");
-
- return VC_ERROR_NONE;
-}
-#endif
-
/**
* @brief Checks whether the command format is supported.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
return ret;
}
- /* Check if current xid is top window */
int count = 0;
do {
ret = vc_dbus_request_set_exclusive_command(g_vc->handle, value);
return 0;
}
+static int __dbus_check()
+{
+ if (NULL == g_conn_sender) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection");
+ return vc_dbus_reconnect();
+ }
+ return 0;
+}
+
int vc_dbus_request_hello()
{
+ if (0 != __dbus_check()) {
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
DBusMessage* msg;
msg = dbus_message_new_method_call(
int vc_dbus_request_initialize(int pid, int* mgr_pid, int* service_state)
{
+ if (0 != __dbus_check()) {
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
DBusMessage* msg;
msg = dbus_message_new_method_call(
int vc_dbus_request_finalize(int pid)
{
+ if (0 != __dbus_check()) {
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
DBusMessage* msg;
msg = dbus_message_new_method_call(
int vc_dbus_request_set_exclusive_command(int pid, bool value)
{
+ if (0 != __dbus_check()) {
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
DBusMessage* msg;
msg = dbus_message_new_method_call(
int vc_dbus_request_set_command(int pid, vc_cmd_type_e cmd_type)
{
+ if (0 != __dbus_check()) {
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
DBusMessage* msg;
msg = dbus_message_new_method_call(
int vc_dbus_request_unset_command(int pid, vc_cmd_type_e cmd_type)
{
+ if (0 != __dbus_check()) {
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
DBusMessage* msg;
msg = dbus_message_new_method_call(
int vc_dbus_set_foreground(int pid, bool value)
{
+ if (0 != __dbus_check()) {
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
DBusMessage* msg = NULL;
int tmp_value = 0;
/* Authority */
int vc_dbus_request_auth_enable(int pid, int mgr_pid)
{
+ if (0 != __dbus_check()) {
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
DBusMessage* msg;
char service_name[64] = {0,};
int vc_dbus_request_auth_disable(int pid, int mgr_pid)
{
+ if (0 != __dbus_check()) {
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
DBusMessage* msg;
char service_name[64] = {0,};
int vc_dbus_request_auth_start(int pid, int mgr_pid)
{
+ if (0 != __dbus_check()) {
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
DBusMessage* msg;
char service_name[64] = {0,};
int vc_dbus_request_auth_stop(int pid, int mgr_pid)
{
+ if (0 != __dbus_check()) {
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
DBusMessage* msg;
char service_name[64] = {0,};
int vc_dbus_request_auth_cancel(int pid, int mgr_pid)
{
+ if (0 != __dbus_check()) {
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
DBusMessage* msg;
char service_name[64] = {0,};