Just add some debug msg to check activated server/client list 21/197421/1
authorhj kim <backto.kim@samsung.com>
Fri, 11 Jan 2019 05:53:17 +0000 (14:53 +0900)
committerhj kim <backto.kim@samsung.com>
Fri, 11 Jan 2019 05:53:17 +0000 (14:53 +0900)
Change-Id: Id96b94abcfabcc0e8922ad730986a60881517b30

src/media_controller_client.c [changed mode: 0644->0755]
src/media_controller_db.c
src/media_controller_util.c

old mode 100644 (file)
new mode 100755 (executable)
index 4f70ab8..ad64225 100755 (executable)
@@ -978,6 +978,8 @@ int mc_db_check_server_table_exist(void *handle, const char *server_name, bool *
        mc_retvm_if(handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
        mc_retvm_if(server_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "server_name is NULL");
 
+       mc_debug("server name [%s]", server_name);
+
        sql_str = sqlite3_mprintf("SELECT COUNT(*) FROM SQLITE_MASTER WHERE type='table' and name='%q'", server_name);
        mc_retvm_if(!MC_STRING_VALID(sql_str), MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "SQL string is null");
 
@@ -1004,6 +1006,8 @@ int mc_db_check_server_table_exist(void *handle, const char *server_name, bool *
                *exist = TRUE;
        } else {
                mc_debug("No server info [%s]", server_name);
+               mc_db_foreach_server_list(handle, NULL, NULL);
+
                *exist = FALSE;
        }
 
@@ -1024,6 +1028,8 @@ int mc_db_check_client_table_exist(void *handle, const char *client_name, bool *
        mc_retvm_if(handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
        mc_retvm_if(client_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "server_name is NULL");
 
+       mc_debug("client name [%s]", client_name);
+
        sql_str = sqlite3_mprintf("SELECT COUNT(*) FROM '%q' WHERE client_name='%q'", MC_DB_TABLE_CLIENT_LIST, client_name);
        mc_retvm_if(!MC_STRING_VALID(sql_str), MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "SQL string is null");
 
@@ -1050,6 +1056,8 @@ int mc_db_check_client_table_exist(void *handle, const char *client_name, bool *
                *exist = TRUE;
        } else {
                mc_debug("No client info [%s]", client_name);
+               mc_db_foreach_client_list(handle, NULL, NULL);
+
                *exist = FALSE;
        }
 
@@ -1065,6 +1073,7 @@ int mc_db_foreach_server_list(void *handle, mc_activated_server_cb callback, voi
        sqlite3 *db_handle = (sqlite3 *)handle;
        char *sql_str = NULL;
        sqlite3_stmt *stmt = NULL;
+       int idx = 0;
 
        mc_retvm_if(db_handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
 
@@ -1085,18 +1094,29 @@ int mc_db_foreach_server_list(void *handle, mc_activated_server_cb callback, voi
                return MEDIA_CONTROLLER_ERROR_NONE;
        }
 
+       mc_info("[ * Activated Server List - Start * ]");
+
        while (SQLITE_ROW == ret) {
                char *server_name = NULL;
                server_name = strdup((char *)sqlite3_column_text(stmt, 0));
-               if (callback(server_name, user_data) == false) {
-                       MC_SAFE_FREE(server_name);
-                       break;
+
+               idx++;
+               mc_info("[%d] %s", idx, server_name);
+
+               if (callback != NULL) {
+                       if (callback(server_name, user_data) == false) {
+                               MC_SAFE_FREE(server_name);
+                               break;
+                       }
                }
+
                MC_SAFE_FREE(server_name);
 
                ret = sqlite3_step(stmt);
        }
 
+       mc_info("[ * Activated Server List - End * ]");
+
        SQLITE3_FINALIZE(stmt);
        SQLITE3_SAFE_FREE(sql_str);
 
@@ -1109,6 +1129,7 @@ int mc_db_foreach_client_list(void *handle, mc_activated_client_cb callback, voi
        sqlite3 *db_handle = (sqlite3 *)handle;
        char *sql_str = NULL;
        sqlite3_stmt *stmt = NULL;
+       int idx = 0;
 
        mc_retvm_if(db_handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
 
@@ -1129,18 +1150,28 @@ int mc_db_foreach_client_list(void *handle, mc_activated_client_cb callback, voi
                return MEDIA_CONTROLLER_ERROR_NONE;
        }
 
+       mc_info("[ * Activated Client List - Start * ]");
+
        while (SQLITE_ROW == ret) {
                char *client_name = NULL;
                client_name = strdup((char *)sqlite3_column_text(stmt, 0));
-               if (callback(client_name, user_data) == false) {
-                       MC_SAFE_FREE(client_name);
-                       break;
+
+               idx++;
+               mc_info("[%d] %s", idx, client_name);
+
+               if (callback != NULL) {
+                       if (callback(client_name, user_data) == false) {
+                               MC_SAFE_FREE(client_name);
+                               break;
+                       }
                }
                MC_SAFE_FREE(client_name);
 
                ret = sqlite3_step(stmt);
        }
 
+       mc_info("[ * Activated Client List - End * ]");
+
        SQLITE3_FINALIZE(stmt);
        SQLITE3_SAFE_FREE(sql_str);
 
index f3b82d7..0ba4519 100755 (executable)
@@ -92,6 +92,8 @@ int mc_util_get_own_name(char **name)
 
        *name = g_strdup(temp);
 
+       mc_info("app id : [%s]", *name);
+
        return MEDIA_CONTROLLER_ERROR_NONE;
 }