Add the detailed logs 62/88862/3
authorSungmin Kwak <sungmin.kwak@samsung.com>
Wed, 21 Sep 2016 03:55:56 +0000 (12:55 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 21 Sep 2016 06:36:42 +0000 (15:36 +0900)
Change-Id: Ib3764a2c986923e2a948e193a5ff0c844e1dccac

ism/src/isf_remote_control.cpp

index 11d5d07..e415ab4 100644 (file)
@@ -42,12 +42,14 @@ remote_handler(void *data, Ecore_Fd_Handler *fd_handler)
         switch (client->remote_client.recv_callback_message()) {
             case REMOTE_CONTROL_CALLBACK_FOCUS_IN:
             {
+                LOGD ("REMOTE_CONTROL_CALLBACK_FOCUS_IN");
                 focus_flag = true;
                 client->focus_in_cb (client->focus_in_cb_user_data);
                 break;
             }
             case REMOTE_CONTROL_CALLBACK_FOCUS_OUT:
             {
+                LOGD ("REMOTE_CONTROL_CALLBACK_FOCUS_OUT");
                 focus_flag = false;
                 client->focus_out_cb (client->focus_out_cb_user_data);
                 break;
@@ -56,7 +58,7 @@ remote_handler(void *data, Ecore_Fd_Handler *fd_handler)
             {
                 if (focus_flag) {
                     remote_control_entry_metadata_s *data = new remote_control_entry_metadata_s;
-                    int hint, layout, variation, autocapital_type;
+                    int hint = 0, layout = 0, variation = 0, autocapital_type = 0;
 
                     client->remote_client.get_entry_metadata (&hint, &layout, &variation, &autocapital_type);
                     data->hint = static_cast<Ecore_IMF_Input_Hints> (hint);
@@ -64,6 +66,8 @@ remote_handler(void *data, Ecore_Fd_Handler *fd_handler)
                     data->variation = variation;
                     data->autocapital_type = static_cast<Ecore_IMF_Autocapital_Type> (autocapital_type);
 
+                    LOGD ("REMOTE_CONTROL_CALLBACK_ENTRY_METADATA hint: 0x%04x, layout: %d, variation: %d, autocapital: %d",
+                        data->hint, data->layout, data->variation, data->autocapital_type);
                     client->metadata_cb (client->metadata_cb_user_data, data);
                     delete data;
                 }
@@ -73,19 +77,21 @@ remote_handler(void *data, Ecore_Fd_Handler *fd_handler)
             {
                 if (focus_flag) {
                     String surrounding_text;
-                    int cursor;
+                    int cursor = -1;
 
                     client->remote_client.get_surrounding_text (surrounding_text, &cursor);
-                    client->text_updated_cb (client->text_updated_cb_user_data, strdup (surrounding_text.c_str ()), cursor);
+                    SECURE_LOGD ("REMOTE_CONTROL_CALLBACK_TEXT_UPDATED \"%s\" %d", surrounding_text.c_str (), cursor);
+                    client->text_updated_cb (client->text_updated_cb_user_data, surrounding_text.c_str (), cursor);
                 }
                 break;
             }
             case REMOTE_CONTROL_CALLBACK_INPUT_RESOURCE:
             {
                 if (focus_flag) {
-                    int resource;
+                    int resource = 0;
 
                     client->remote_client.get_input_resource (&resource);
+                    LOGD ("REMOTE_CONTROL_CALLBACK_INPUT_RESOURCE: %s", (resource ? "REMOTE" : "LOCAL"));
                     client->input_resource_changed_cb (client->input_resource_changed_cb_user_data,
                         static_cast<remote_control_input_resource> (resource));
                 }
@@ -108,16 +114,18 @@ EXAPI remote_control_client * remote_control_connect(void)
     if (client) {
         RemoteInputClient *remote_client = new RemoteInputClient;
         client->remote_client = *remote_client;
-        if (!client->remote_client.open_connection())
+        if (!client->remote_client.open_connection()) {
+            LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT");
             goto cleanup;
+        }
 
         if (!client->remote_client.prepare()) {
-            LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT\n");
+            LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT");
             goto cleanup;
         }
 
         if (!client->remote_client.check_privilege()) {
-            LOGE ("REMOTE_CONTROL_PERMISSION_DENIED\n");
+            LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
             goto cleanup;
         }
 
@@ -126,14 +134,22 @@ EXAPI remote_control_client * remote_control_connect(void)
         if (client->remote_client_id >= 0) {
             client->remote_fd_handler = ecore_main_fd_handler_add(client->remote_client_id, ECORE_FD_READ, remote_handler, client, NULL, NULL);
 
-            if (client->remote_fd_handler == NULL)
+            if (client->remote_fd_handler == NULL) {
+                LOGE ("REMOTE_CONTROL_INVALID_OPERATION");
                 goto cleanup;
-        } else
+            }
+        }
+        else {
+            LOGE ("REMOTE_CONTROL_INVALID_OPERATION");
             goto cleanup;
-
-    } else
+        }
+    }
+    else {
+        LOGE ("REMOTE_CONTROL_INVALID_OPERATION");
         goto cleanup;
+    }
 
+    LOGD ("%p", client);
     return client;
 cleanup:
     if (client)
@@ -144,19 +160,27 @@ cleanup:
 
 EXAPI int remote_control_disconnect(remote_control_client *client)
 {
-    if (client == NULL)
+    if (client == NULL) {
+        LOGE ("REMOTE_CONTROL_INVALID_PARAMETER");
         return REMOTE_CONTROL_INVALID_PARAMETER;
+    }
 
-    if (!client->remote_client.prepare())
+    if (!client->remote_client.prepare()) {
+        LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT");
         return REMOTE_CONTROL_REPLY_TIMEOUT;
+    }
 
-    if (!client->remote_client.check_privilege())
+    if (!client->remote_client.check_privilege()) {
+        LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return REMOTE_CONTROL_PERMISSION_DENIED;
+    }
 
     if (client->remote_fd_handler)
         ecore_main_fd_handler_del(client->remote_fd_handler);
 
     client->remote_client.close_connection();
+
+    LOGD ("%p", client);
     delete client;
     client = NULL;
 
@@ -165,171 +189,241 @@ EXAPI int remote_control_disconnect(remote_control_client *client)
 
 EXAPI int remote_control_focus_in_callback_set(remote_control_client *client, remote_control_focus_in_cb func, void *user_data)
 {
-    if (client == NULL)
+    if (client == NULL || func == NULL) {
+        LOGE ("REMOTE_CONTROL_INVALID_PARAMETER");
         return REMOTE_CONTROL_INVALID_PARAMETER;
+    }
 
-    if (!client->remote_client.prepare())
+    if (!client->remote_client.prepare()) {
+        LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT");
         return REMOTE_CONTROL_REPLY_TIMEOUT;
+    }
 
-    if (!client->remote_client.check_privilege())
+    if (!client->remote_client.check_privilege()) {
+        LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return REMOTE_CONTROL_PERMISSION_DENIED;
+    }
 
     client->focus_in_cb = func;
     client->focus_in_cb_user_data = user_data;
 
+    LOGD ("%p", client);
     return REMOTE_CONTROL_ERROR_NONE;
 }
 
 EXAPI int remote_control_focus_in_callback_unset(remote_control_client *client)
 {
-    if (client == NULL)
+    if (client == NULL) {
+        LOGE ("REMOTE_CONTROL_INVALID_PARAMETER");
         return REMOTE_CONTROL_INVALID_PARAMETER;
+    }
 
-    if (!client->remote_client.prepare())
+    if (!client->remote_client.prepare()) {
+        LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT");
         return REMOTE_CONTROL_REPLY_TIMEOUT;
+    }
 
-    if (!client->remote_client.check_privilege())
+    if (!client->remote_client.check_privilege()) {
+        LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return REMOTE_CONTROL_PERMISSION_DENIED;
+    }
 
     client->focus_in_cb = NULL;
     client->focus_in_cb_user_data = NULL;
 
+    LOGD ("%p", client);
     return REMOTE_CONTROL_ERROR_NONE;
 }
 
 EXAPI int remote_control_focus_out_callback_set(remote_control_client *client, remote_control_focus_out_cb func , void *user_data)
 {
-    if (client == NULL)
+    if (client == NULL || func == NULL) {
+        LOGE ("REMOTE_CONTROL_INVALID_PARAMETER");
         return REMOTE_CONTROL_INVALID_PARAMETER;
+    }
 
-    if (!client->remote_client.prepare())
+    if (!client->remote_client.prepare()) {
+        LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT");
         return REMOTE_CONTROL_REPLY_TIMEOUT;
+    }
 
-    if (!client->remote_client.check_privilege())
+    if (!client->remote_client.check_privilege()) {
+        LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return REMOTE_CONTROL_PERMISSION_DENIED;
+    }
 
     client->focus_out_cb = func;
     client->focus_out_cb_user_data = user_data;
 
+    LOGD ("%p", client);
     return REMOTE_CONTROL_ERROR_NONE;
 }
 
 EXAPI int remote_control_focus_out_callback_unset(remote_control_client *client)
 {
-    if (client == NULL)
+    if (client == NULL) {
+        LOGE ("REMOTE_CONTROL_INVALID_PARAMETER");
         return REMOTE_CONTROL_INVALID_PARAMETER;
+    }
 
-    if (!client->remote_client.prepare())
+    if (!client->remote_client.prepare()) {
+        LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT");
         return REMOTE_CONTROL_REPLY_TIMEOUT;
+    }
 
-    if (!client->remote_client.check_privilege())
+    if (!client->remote_client.check_privilege()) {
+        LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return REMOTE_CONTROL_PERMISSION_DENIED;
+    }
 
     client->focus_out_cb = NULL;
     client->focus_out_cb_user_data = NULL;
 
+    LOGD ("%p", client);
     return REMOTE_CONTROL_ERROR_NONE;
 }
 
 EXAPI int remote_control_entry_metadata_callback_set(remote_control_client *client, remote_control_entry_metadata_cb func, void *user_data)
 {
-    if (client == NULL)
+    if (client == NULL || func == NULL) {
+        LOGE ("REMOTE_CONTROL_INVALID_PARAMETER");
         return REMOTE_CONTROL_INVALID_PARAMETER;
+    }
 
-    if (!client->remote_client.prepare())
+    if (!client->remote_client.prepare()) {
+        LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT");
         return REMOTE_CONTROL_REPLY_TIMEOUT;
+    }
 
-    if (!client->remote_client.check_privilege())
+    if (!client->remote_client.check_privilege()) {
+        LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return REMOTE_CONTROL_PERMISSION_DENIED;
+    }
 
     client->metadata_cb = func;
     client->metadata_cb_user_data = user_data;
 
+    LOGD ("%p", client);
     return REMOTE_CONTROL_ERROR_NONE;
 }
 
 EXAPI int remote_control_entry_metadata_callback_unset(remote_control_client *client)
 {
-    if (client == NULL)
+    if (client == NULL) {
+        LOGE ("REMOTE_CONTROL_INVALID_PARAMETER");
         return REMOTE_CONTROL_INVALID_PARAMETER;
+    }
 
-    if (!client->remote_client.prepare())
+    if (!client->remote_client.prepare()) {
+        LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT");
         return REMOTE_CONTROL_REPLY_TIMEOUT;
+    }
 
-    if (!client->remote_client.check_privilege())
+    if (!client->remote_client.check_privilege()) {
+        LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return REMOTE_CONTROL_PERMISSION_DENIED;
+    }
 
     client->metadata_cb = NULL;
     client->metadata_cb_user_data = NULL;
 
+    LOGD ("%p", client);
     return REMOTE_CONTROL_ERROR_NONE;
 }
 
 EXAPI int remote_control_text_updated_callback_set(remote_control_client *client, remote_control_text_updated_cb func, void *user_data)
 {
-    if (client == NULL)
+    if (client == NULL || func == NULL) {
+        LOGE ("REMOTE_CONTROL_INVALID_PARAMETER");
         return REMOTE_CONTROL_INVALID_PARAMETER;
+    }
 
-    if (!client->remote_client.prepare())
+    if (!client->remote_client.prepare()) {
+        LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT");
         return REMOTE_CONTROL_REPLY_TIMEOUT;
+    }
 
-    if (!client->remote_client.check_privilege())
+    if (!client->remote_client.check_privilege()) {
+        LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return REMOTE_CONTROL_PERMISSION_DENIED;
+    }
 
     client->text_updated_cb = func;
     client->text_updated_cb_user_data = user_data;
 
+    LOGD ("%p", client);
     return REMOTE_CONTROL_ERROR_NONE;
 }
 
 EXAPI int remote_control_text_updated_callback_unset(remote_control_client *client)
 {
-    if (client == NULL)
+    if (client == NULL) {
+        LOGE ("REMOTE_CONTROL_INVALID_PARAMETER");
         return REMOTE_CONTROL_INVALID_PARAMETER;
+    }
 
-    if (!client->remote_client.prepare())
+    if (!client->remote_client.prepare()) {
+        LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT");
         return REMOTE_CONTROL_REPLY_TIMEOUT;
+    }
 
-    if (!client->remote_client.check_privilege())
+    if (!client->remote_client.check_privilege()) {
+        LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return REMOTE_CONTROL_PERMISSION_DENIED;
+    }
 
     client->text_updated_cb = NULL;
     client->text_updated_cb_user_data = NULL;
 
+    LOGD ("%p", client);
     return REMOTE_CONTROL_ERROR_NONE;
 }
 
 EXAPI int remote_control_input_resource_changed_callback_set(remote_control_client *client, remote_control_input_resource_changed_cb func , void *user_data)
 {
-    if (client == NULL)
+    if (client == NULL || func == NULL) {
+        LOGE ("REMOTE_CONTROL_INVALID_PARAMETER");
         return REMOTE_CONTROL_INVALID_PARAMETER;
+    }
 
-    if (!client->remote_client.prepare())
+    if (!client->remote_client.prepare()) {
+        LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT");
         return REMOTE_CONTROL_REPLY_TIMEOUT;
+    }
 
-    if (!client->remote_client.check_privilege())
+    if (!client->remote_client.check_privilege()) {
+        LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return REMOTE_CONTROL_PERMISSION_DENIED;
+    }
 
     client->input_resource_changed_cb = func;
     client->input_resource_changed_cb_user_data = user_data;
 
+    LOGD ("%p", client);
     return REMOTE_CONTROL_ERROR_NONE;
 }
 
 EXAPI int remote_control_input_resource_changed_callback_unset(remote_control_client *client)
 {
-    if (client == NULL)
+    if (client == NULL) {
+        LOGE ("REMOTE_CONTROL_INVALID_PARAMETER");
         return REMOTE_CONTROL_INVALID_PARAMETER;
+    }
 
-    if (!client->remote_client.prepare())
+    if (!client->remote_client.prepare()) {
+        LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT");
         return REMOTE_CONTROL_REPLY_TIMEOUT;
+    }
 
-    if (!client->remote_client.check_privilege())
+    if (!client->remote_client.check_privilege()) {
+        LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return REMOTE_CONTROL_PERMISSION_DENIED;
+    }
 
     client->input_resource_changed_cb = NULL;
     client->input_resource_changed_cb_user_data = NULL;
 
+    LOGD ("%p", client);
     return REMOTE_CONTROL_ERROR_NONE;
 }
 
@@ -338,87 +432,105 @@ EXAPI int remote_control_send_key_event(remote_control_client *client, remote_co
     if (client == NULL || key < REMOTE_CONTROL_KEY_ENTER || key > REMOTE_CONTROL_KEY_PAGE_DOWN)
         return REMOTE_CONTROL_INVALID_PARAMETER;
 
-    if (!client->remote_client.prepare())
+    if (!client->remote_client.prepare()) {
+        LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT");
         return REMOTE_CONTROL_REPLY_TIMEOUT;
+    }
 
-    if (!client->remote_client.check_privilege())
+    if (!client->remote_client.check_privilege()) {
+        LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return REMOTE_CONTROL_PERMISSION_DENIED;
+    }
 
     char key_str[10] = {};
     snprintf(key_str, sizeof(key_str), "%d", key);
     String command = String ("|plain|send_key_event|") + String (key_str) + String ("|");
 
-    if (!client->remote_client.prepare())
-        return REMOTE_CONTROL_REPLY_TIMEOUT;
-
-    if (focus_flag && client->remote_client.send_remote_input_message(command.c_str ()))
+    if (focus_flag && client->remote_client.send_remote_input_message(command.c_str ())) {
+        SECURE_LOGD ("%p, key=%d", client, key);
         return REMOTE_CONTROL_ERROR_NONE;
+    }
 
+    LOGE ("REMOTE_CONTROL_INVALID_OPERATION");
     return REMOTE_CONTROL_INVALID_OPERATION;
 }
 
 EXAPI int remote_control_send_commit_string(remote_control_client *client, const char *text)
 {
-    if (client == NULL || !text || strlen(text) == 0)
+    if (client == NULL || !text)
         return REMOTE_CONTROL_INVALID_PARAMETER;
 
-    if (!client->remote_client.prepare())
+    if (!client->remote_client.prepare()) {
+        LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT");
         return REMOTE_CONTROL_REPLY_TIMEOUT;
+    }
 
-    if (!client->remote_client.check_privilege())
+    if (!client->remote_client.check_privilege()) {
+        LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return REMOTE_CONTROL_PERMISSION_DENIED;
+    }
 
     String command = String ("|plain|commit_string|") + String (text) + String ("|");
 
-    if (!client->remote_client.prepare())
-        return REMOTE_CONTROL_REPLY_TIMEOUT;
-
-    if (focus_flag && client->remote_client.send_remote_input_message(command.c_str ()))
+    if (focus_flag && client->remote_client.send_remote_input_message(command.c_str ())) {
+        SECURE_LOGD ("%p, \"%s\"", client, text);
         return REMOTE_CONTROL_ERROR_NONE;
+    }
 
+    LOGE ("REMOTE_CONTROL_INVALID_OPERATION");
     return REMOTE_CONTROL_INVALID_OPERATION;
 }
 
 EXAPI int remote_control_update_preedit_string(remote_control_client *client, const char *text, Eina_List *attrs, int cursor_pos)
 {
-    if (client == NULL || !text || strlen(text) == 0 || cursor_pos < 0)
+    if (client == NULL || !text || cursor_pos < 0)
         return REMOTE_CONTROL_INVALID_PARAMETER;
 
-    if (!client->remote_client.prepare())
+    if (!client->remote_client.prepare()) {
+        LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT");
         return REMOTE_CONTROL_REPLY_TIMEOUT;
+    }
 
-    if (!client->remote_client.check_privilege())
+    if (!client->remote_client.check_privilege()) {
+        LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return REMOTE_CONTROL_PERMISSION_DENIED;
-
+    }
     char cursor_position[10] = {};
     snprintf(cursor_position, sizeof(cursor_position), "%d", cursor_pos);
     String command = String ("|plain|update_preedit_string|") + String (text) + String ("|") + String (cursor_position) + String ("|");
 
-    if (!client->remote_client.prepare())
-        return REMOTE_CONTROL_REPLY_TIMEOUT;
-
-    if (focus_flag && client->remote_client.send_remote_input_message(command.c_str ()))
+    if (focus_flag && client->remote_client.send_remote_input_message(command.c_str ())) {
+        SECURE_LOGD ("%p, \"%s\", %d", client, text, cursor_pos);
         return REMOTE_CONTROL_ERROR_NONE;
+    }
 
+    LOGE ("REMOTE_CONTROL_INVALID_OPERATION");
     return REMOTE_CONTROL_INVALID_OPERATION;
 }
 
 EXAPI int remote_control_delete_surrounding_text(remote_control_client *client, int offset, int len)
 {
-    if (client == NULL || len < 0)
+    if (client == NULL || len < 0) {
+        LOGE ("REMOTE_CONTROL_INVALID_PARAMETER");
         return REMOTE_CONTROL_INVALID_PARAMETER;
+    }
 
-    if (!client->remote_client.prepare())
+    if (!client->remote_client.prepare()) {
+        LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT");
         return REMOTE_CONTROL_REPLY_TIMEOUT;
+    }
 
-    if (!client->remote_client.check_privilege())
+    if (!client->remote_client.check_privilege()) {
+        LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return REMOTE_CONTROL_PERMISSION_DENIED;
+    }
 
-    if (!client->remote_client.prepare())
-        return REMOTE_CONTROL_REPLY_TIMEOUT;
-
-    if (focus_flag && client->remote_client.delete_surrounding_text(offset, len))
+    if (focus_flag && client->remote_client.delete_surrounding_text(offset, len)) {
+        LOGD ("%p, (%d, %d)", client, offset, len);
         return REMOTE_CONTROL_ERROR_NONE;
+    }
 
+    LOGE ("REMOTE_CONTROL_INVALID_OPERATION");
     return REMOTE_CONTROL_INVALID_OPERATION;
-}
\ No newline at end of file
+}
+