Apply tizen coding rule 18/149018/2
authorHaejeong Kim <backto.kim@samsung.com>
Mon, 11 Sep 2017 09:18:45 +0000 (18:18 +0900)
committerHaejeong Kim <backto.kim@samsung.com>
Tue, 12 Sep 2017 01:19:47 +0000 (10:19 +0900)
Change-Id: Iac827c62dbcb787a70c65c5bf2174bc8966a0af3

33 files changed:
lib/include/media-util-internal.h
lib/media-util-cynara.c
lib/media-util-db.c
lib/media-util-dcm.c
lib/media-util-noti-internal.c
lib/media-util-noti.c
src/common/include/media-common-types.h
src/common/media-common-db-svc.c
src/common/media-common-external-storage.c
src/common/media-common-system.c
src/common/media-common-utils.c
src/mediadb-update.c
src/scanner-v2/include/media-scanner-db-manage-v2.h
src/scanner-v2/include/media-scanner-device-block-v2.h
src/scanner-v2/include/media-scanner-scan-v2.h
src/scanner-v2/media-scanner-db-manage-v2.c
src/scanner-v2/media-scanner-device-block-v2.c
src/scanner-v2/media-scanner-extract-v2.c
src/scanner-v2/media-scanner-scan-v2.c
src/scanner-v2/media-scanner-socket-v2.c
src/scanner-v2/media-scanner-v2.c
src/scanner/include/media-scanner-scan.h
src/scanner/media-scanner-scan.c
src/scanner/media-scanner.c
src/server/include/media-server-db-manage.h
src/server/include/media-server-device-block.h
src/server/include/media-server-scanner.h
src/server/media-server-db-manage.c
src/server/media-server-device-block.c
src/server/media-server-main.c
src/server/media-server-scanner.c
src/server/media-server-socket.c
src/server/media-server-thumb.c

index 5006f76..076c368 100755 (executable)
@@ -32,7 +32,7 @@
 #endif
 
 #define MS_SAFE_FREE(src)              { if (src) {free(src); src = NULL; } }
-#define MS_MALLOC(src, size)   { if (size > SIZE_MAX || size <= 0) {src = NULL; } \
+#define MS_MALLOC(src, size)   { if (size > SIZE_MAX || size <= 0) src = NULL; \
                                                        else { src = malloc(size); if (src) memset(src, 0x0, size); } }
 #define MS_STRING_VALID(str)   \
        ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
index 7625eb0..c79dc86 100755 (executable)
@@ -63,11 +63,10 @@ static void ms_cynara_dbg_err(const char *prefix, int error_code)
        error_buffer[0] = '\0';
 
        err = cynara_strerror(error_code, error_buffer, sizeof(error_buffer));
-       if (err == CYNARA_API_SUCCESS) {
+       if (err == CYNARA_API_SUCCESS)
                MSAPI_DBG_ERR("%s: %s", prefix, error_buffer);
-       } else {
+       else
                MSAPI_DBG_ERR("%s: error code %i", prefix, error_code);
-       }
 }
 
 int ms_cynara_initialize(void)
index fd8fa33..cf66b88 100755 (executable)
@@ -73,11 +73,10 @@ static int __media_db_connect_db_with_handle(sqlite3 **db_handle, uid_t uid, boo
        MSAPI_RETVM_IF(ret != MS_MEDIA_ERR_NONE, MS_MEDIA_ERR_DB_CONNECT_FAIL, "ms_user_get_media_db_path failed");
 
        /*Connect DB*/
-       if (need_write) {
+       if (need_write)
                ret = db_util_open_with_options(db_path, db_handle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
-       } else {
+       else
                ret = db_util_open_with_options(db_path, db_handle, SQLITE_OPEN_READONLY, NULL);
-       }
 
        MS_SAFE_FREE(db_path);
 
@@ -97,9 +96,8 @@ static int __media_db_connect_db_with_handle(sqlite3 **db_handle, uid_t uid, boo
 
        if (SQLITE_OK != ret) {
 
-               if (*db_handle) {
+               if (*db_handle)
                        MSAPI_DBG_ERR("[error when register busy handler] %s", sqlite3_errmsg(*db_handle));
-               }
 
                db_util_close(*db_handle);
                *db_handle = NULL;
@@ -116,9 +114,8 @@ static int __media_db_connect_db_with_handle(sqlite3 **db_handle, uid_t uid, boo
        sqlite3_free(sql);
        if (SQLITE_OK != ret) {
 
-               if (*db_handle) {
+               if (*db_handle)
                        MSAPI_DBG_ERR("[error when change the journal mode] %s", sqlite3_errmsg(*db_handle));
-               }
 
                db_util_close(*db_handle);
                *db_handle = NULL;
@@ -350,9 +347,8 @@ static int __media_db_request_batch_update(ms_msg_type_e msg_type, const char *r
        MSAPI_DBG("RECEIVE OK [%d]", recv_msg);
        ret = recv_msg;
 
-       if (ret != MS_MEDIA_ERR_NONE) {
+       if (ret != MS_MEDIA_ERR_NONE)
                MSAPI_DBG_ERR("batch updated[%d] failed, error [%d]", msg_type, ret);
-       }
 
        return ret;
 }
@@ -444,9 +440,8 @@ int media_db_request_update_db(const char *query_str, uid_t uid)
        MSAPI_RETVM_IF(!MS_STRING_VALID(query_str), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid Query");
 
        ret = __media_db_request_update_tcp(MS_MSG_DB_UPDATE, query_str, uid);
-       if (ret != MS_MEDIA_ERR_NONE) {
+       if (ret != MS_MEDIA_ERR_NONE)
                MSAPI_DBG_ERR("__media_db_request_update_tcp failed : %d", ret);
-       }
 
        return ret;
 }
@@ -467,9 +462,8 @@ int media_db_request_update_db_batch_start(const char *query_str, uid_t uid)
        }
 
        ret = __media_db_request_batch_update(MS_MSG_DB_UPDATE_BATCH_START, query_str, uid);
-       if (ret != MS_MEDIA_ERR_NONE) {
+       if (ret != MS_MEDIA_ERR_NONE)
                __media_db_close_tcp_client_socket();
-       }
 
        return ret;
 }
@@ -483,9 +477,8 @@ int media_db_request_update_db_batch(const char *query_str, uid_t uid)
        MSAPI_RETVM_IF(!MS_STRING_VALID(query_str), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid Query");
 
        ret = __media_db_request_batch_update(MS_MSG_DB_UPDATE_BATCH, query_str, uid);
-       if (ret != MS_MEDIA_ERR_NONE) {
+       if (ret != MS_MEDIA_ERR_NONE)
                __media_db_close_tcp_client_socket();
-       }
 
        return ret;
 }
index 1ffaecf..b197b5a 100755 (executable)
@@ -148,11 +148,10 @@ gboolean __media_dcm_write_socket(GIOChannel *src, GIOCondition condition, gpoin
 
        if ((err = recv(sock, &recv_msg, sizeof(dcmMsg), 0)) < 0) {
                MSAPI_DBG_STRERROR("recv failed ");
-               if (recv_msg.msg_size > 0) {
+               if (recv_msg.msg_size > 0)
                        __media_dcm_pop_data();
-               } else {
+               else
                        MSAPI_DBG_ERR("origin path size is wrong.");
-               }
 
                return FALSE;
        }
@@ -163,9 +162,8 @@ gboolean __media_dcm_write_socket(GIOChannel *src, GIOCondition condition, gpoin
                MSAPI_DBG_ERR("__media_dcm_check_cancel is true");
                if (data) {
                        faceUserData* cb = (faceUserData*)data;
-                       if (cb->func != NULL) {
+                       if (cb->func != NULL)
                                cb->func(recv_msg.msg_type, (int)(recv_msg.result), cb->user_data);
-                       }
                }
        }
 
index 7fb3a21..550d174 100755 (executable)
@@ -108,11 +108,10 @@ int media_db_update_send_internal(int pid, /* mandatory */
        } else if (item == MS_MEDIA_ITEM_DIRECTORY) {
                MSAPI_DBG("DIRECTORY CHANGED");
                /* fill all datas */
-               if (uuid != NULL) {
+               if (uuid != NULL)
                        message = g_variant_new("(iiiss)", item, pid, update_type, repl_path, uuid);
-               } else {
+               else
                        message = g_variant_new("(iiis)", item, pid, update_type, repl_path);
-               }
        } else {
                MSAPI_DBG("this request is wrong");
        }
index a96f2fd..31d7413 100755 (executable)
@@ -170,9 +170,8 @@ ERROR:
 
 int media_db_update_unsubscribe(void)
 {
-       if (g_bus == NULL) {
+       if (g_bus == NULL)
                return MS_MEDIA_ERR_NONE;
-       }
 
        g_mutex_lock(&noti_mutex);
 
@@ -248,11 +247,10 @@ int media_db_update_send(int pid, /* mandatory */
        } else if (item == MS_MEDIA_ITEM_DIRECTORY) {
                MSAPI_DBG("DIRECTORY CHANGED");
                /* fill all datas */
-               if (uuid != NULL) {
+               if (uuid != NULL)
                        message = g_variant_new("(iiiss)", item, pid, update_type, repl_path, uuid);
-               } else {
+               else
                        message = g_variant_new("(iiis)", item, pid, update_type, repl_path);
-               }
        } else {
                MSAPI_DBG("this request is wrong");
        }
index 2850b52..dda3f8c 100755 (executable)
@@ -56,7 +56,7 @@ typedef enum {
 #define POWEROFF -1 /*This number uses for stopping Scannig thread*/
 
 #define MS_SAFE_FREE(src)              { if (src) {free(src); src = NULL; } }
-#define MS_MALLOC(src, size)   { if (size > SIZE_MAX || size <= 0) {src = NULL; } \
+#define MS_MALLOC(src, size)   { if (size > SIZE_MAX || size <= 0) src = NULL; \
                                                        else { src = malloc(size); if (src) memset(src, 0x0, size); } }
 #define MS_STRING_VALID(str)   \
                                                                ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
index 9a62846..903318f 100755 (executable)
@@ -254,9 +254,9 @@ int ms_load_functions(void)
                if (func_array[lib_index] == NULL) {
                        int index;
 
-                       for (index = 0; index < lib_index; index++) {
+                       for (index = 0; index < lib_index; index++)
                                MS_SAFE_FREE(func_array[index]);
-                       }
+
                        MS_SAFE_FREE(func_array);
                        MS_SAFE_FREE(func_handle);
 
@@ -272,9 +272,9 @@ int ms_load_functions(void)
                        if (func_array[lib_index][func_index] == NULL) {
                                int index;
 
-                               for (index = 0; index < lib_index; index++) {
+                               for (index = 0; index < lib_index; index++)
                                        MS_SAFE_FREE(func_array[index]);
-                               }
+
                                MS_SAFE_FREE(func_array);
                                MS_SAFE_FREE(func_handle);
 
@@ -295,9 +295,8 @@ void ms_unload_functions(void)
                dlclose(func_handle[lib_index]);
 
        for (lib_index = 0; lib_index < lib_num; lib_index++) {
-                       if (func_array[lib_index]) {
+                       if (func_array[lib_index])
                                MS_SAFE_FREE(func_array[lib_index]);
-                       }
        }
 
        MS_SAFE_FREE(func_array);
@@ -406,9 +405,8 @@ int ms_validate_item(void **handle, const char *storage_id, const char *path, ui
                if (ret != 0) {
                        MS_SAFE_FREE(err_msg);
                        ret = ms_insert_item_batch(handle, storage_id, path, uid);
-                       if (ret != 0) {
+                       if (ret != 0)
                                res = MS_MEDIA_ERR_DB_INSERT_FAIL;
-                       }
                } else {
                        if (modified == FALSE) {
                                /*if meta data of file exist, change valid field to "1" */
@@ -427,9 +425,8 @@ int ms_validate_item(void **handle, const char *storage_id, const char *path, ui
                                        res = MS_MEDIA_ERR_DB_DELETE_FAIL;
                                } else {
                                        ret = ms_insert_item_batch(handle, storage_id, path, uid);
-                                       if (ret != 0) {
+                                       if (ret != 0)
                                                res = MS_MEDIA_ERR_DB_INSERT_FAIL;
-                                       }
                                }
                        }
                }
@@ -452,11 +449,10 @@ int ms_scan_validate_item(void **handle, const char *storage_id, const char *pat
                if (ret != 0) {
                        MS_SAFE_FREE(err_msg);
                        ret = ms_scan_item_batch(handle, storage_id, path, uid);
-                       if (ret != 0) {
+                       if (ret != 0)
                                res = MS_MEDIA_ERR_DB_INSERT_FAIL;
-                       } else {
+                       else
                                insert_count_for_partial++;
-                       }
                } else {
                        if (modified == FALSE) {
                                /*if meta data of file exist, change valid field to "1" */
@@ -477,11 +473,10 @@ int ms_scan_validate_item(void **handle, const char *storage_id, const char *pat
                                        res = MS_MEDIA_ERR_DB_DELETE_FAIL;
                                } else {
                                        ret = ms_scan_item_batch(handle, storage_id, path, uid);
-                                       if (ret != 0) {
+                                       if (ret != 0)
                                                res = MS_MEDIA_ERR_DB_INSERT_FAIL;
-                                       } else {
+                                       else
                                                insert_count_for_partial++;
-                                       }
                                }
                        }
                }
@@ -590,11 +585,10 @@ int ms_update_one_extract_item(void** handle, const char* storage_id, int storag
                if (ret != 0) {
                        MS_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
                        MS_SAFE_FREE(err_msg);
-                       if (ret == -2) {
+                       if (ret == -2)
                                res = MS_MEDIA_ERR_FILE_IO;
-                       } else {
+                       else
                                res = MS_MEDIA_ERR_DB_INSERT_FAIL;
-                       }
                }
        }
 
@@ -1149,11 +1143,10 @@ int ms_get_folder_id(void **handle, const char *storage_id, const char *path, ch
                }
        }
 
-       if (strlen(folder_uuid) == (MS_UUID_SIZE-1)) {
+       if (strlen(folder_uuid) == (MS_UUID_SIZE-1))
                *folder_id = strdup(folder_uuid);
-       } else {
+       else
                *folder_id = NULL;
-       }
 
        MS_DBG("folder_id [%s]", *folder_id);
 
index 0489561..b638ab0 100755 (executable)
@@ -71,15 +71,14 @@ void ms_make_default_path_mmc(const char *mount_path)
                if (!g_file_test(mmc_path, G_FILE_TEST_IS_DIR)) {
                        MS_DBG("%s path did not exist", mmc_path);
                        ret = mkdir(mmc_path, 0770);
-                       if (ret < 0) {
+                       if (ret < 0)
                                MS_DBG_ERR("mkdir failed");
-                       }
+
                        /*this fuction for emulator*/
                        /*at the first time, the directroies are made permission 755*/
                        ret = chmod(mmc_path, 0770);
-                       if (ret != 0) {
+                       if (ret != 0)
                                MS_DBG_STRERROR("chmod failed");
-                       }
                }
        }
 }
@@ -215,9 +214,8 @@ int ms_write_device_info(const char *root_path, char *device_uuid)
        char path[MS_FILE_PATH_LEN_MAX] = {0,};
 
        len = snprintf(path, MS_FILE_PATH_LEN_MAX -1, "%s/%s%s", root_path, DEVICE_INFO_FILE, device_uuid);
-       if (len < 0) {
+       if (len < 0)
                return MS_MEDIA_ERR_INVALID_PARAMETER;
-       }
 
        path[len] = '\0';
 
@@ -250,9 +248,8 @@ int ms_get_added_storage_path(void **handle, const char *add_path, char **device
                if (ret == MS_MEDIA_ERR_FILE_NOT_EXIST) {
                        ret = ms_genarate_uuid(handle, &id);
                        ret = ms_write_device_info(add_path , id);
-                       if (ret == MS_MEDIA_ERR_NONE) {
+                       if (ret == MS_MEDIA_ERR_NONE)
                                *device_id = strdup(id);
-                       }
                }
        } else {
                *device_id = strdup(id);
index beb3fc5..3266a8c 100755 (executable)
@@ -225,9 +225,8 @@ int ms_sys_set_device_block_event_cb(usb_connected_cb usr_callback, void *usr_da
 #ifdef _USE_DEVICED_DBUS
 int ms_sys_unset_device_block_event_cb(void)
 {
-       if (g_usb_bus == NULL) {
+       if (g_usb_bus == NULL)
                return MS_MEDIA_ERR_NONE;
-       }
 
        g_dbus_connection_signal_unsubscribe(g_usb_bus, g_usb_handler);
        g_object_unref(g_usb_bus);
@@ -354,9 +353,8 @@ static int __ms_gdbus_method_sync(const char *dest, const char *path, const char
                        MS_DBG("\tstorage_id(%d)", val_int[4]);
                }
 
-               for (i = 0; i < 7; i++) {
+               for (i = 0; i < 7; i++)
                        MS_SAFE_FREE(val_str[i]);
-               }
        }
 
        g_variant_iter_free(iter);
@@ -386,11 +384,11 @@ int ms_sys_get_device_list(ms_stg_type_e stg_type, GArray **dev_list)
                DEVICED_INTERFACE_BLOCK_MANAGER,
                BLOCK_DEVICE_METHOD,
                dev_params[stg_type], dev_list);
-       if (ret < 0) {
+
+       if (ret < 0)
                MS_DBG("Failed to send dbus (%d)", ret);
-       } else {
+       else
                MS_DBG("%d block devices are founded", ret);
-       }
 
        return MS_MEDIA_ERR_NONE;
 }
@@ -426,17 +424,15 @@ int ms_sys_get_device_list(ms_stg_type_e stg_type, GArray **dev_list)
                                        err = usb_device_list_get_first(list, &device);
                                        if (err != USB_ERROR_LIST_FAILED_TO_GET && device != NULL) {
                                                mount_path = usb_device_get_mountpath(device);
-                                               if (mount_path != NULL) {
+                                               if (mount_path != NULL)
                                                        MS_DBG_WARN("mount_path [%s]", mount_path);
-                                               }
                                        }
                                } else {
                                        usb_device_list_get_next(list, &device);
                                        if (device != NULL) {
                                                mount_path = usb_device_get_mountpath(device);
-                                               if (mount_path != NULL) {
+                                               if (mount_path != NULL)
                                                        MS_DBG_WARN("mount_path [%s]", mount_path);
-                                               }
                                        }
                                }
 
@@ -572,9 +568,8 @@ static void __poweroff_signal_cb(GDBusConnection *connection,
                MS_DBG_ERR("current type : %s", type_str);
        }
 
-       if (val_int == 2 || val_int == 3) {
+       if (val_int == 2 || val_int == 3)
                MS_DBG_WARN("PREPARE POWER OFF");
-       }
 
        if (val_int == 2 || val_int == 3)
                cb_func(power_info, usr_data);
@@ -640,9 +635,8 @@ int ms_sys_set_poweroff_cb(device_changed_cb user_callback, void *user_data)
 #ifdef _USE_DEVICED_DBUS
 int ms_sys_unset_poweroff_cb(void)
 {
-       if (g_pwr_bus == NULL) {
+       if (g_pwr_bus == NULL)
                return MS_MEDIA_ERR_NONE;
-       }
 
        g_dbus_connection_signal_unsubscribe(g_pwr_bus, g_pwr_handler);
        g_object_unref(g_pwr_bus);
index b29db0a..8cbbbdc 100755 (executable)
@@ -58,9 +58,8 @@ int ms_strappend(char *res, const int size, const char *pattern, const char *str
                return MS_MEDIA_ERR_INVALID_PARAMETER;
 
        len = snprintf(res, real_size, pattern, str1, str2);
-       if (len < 0) {
+       if (len < 0)
                return MS_MEDIA_ERR_INVALID_PARAMETER;
-       }
 
        res[len] = '\0';
 
index 4163ea6..4ca3325 100755 (executable)
@@ -200,16 +200,14 @@ int __get_device_list(GArray **dev_list)
                                data->mount_uuid = strdup(val_str[5]);
                                data->flags = val_int[3];
 
-                               if (*dev_list == NULL) {
+                               if (*dev_list == NULL)
                                        *dev_list = g_array_new(FALSE, FALSE, sizeof(block_info_s*));
-                               }
                                g_array_append_val(*dev_list, data);
                        }
                }
 
-               for (i = 0; i < 7; i++) {
+               for (i = 0; i < 7; i++)
                        MU_SAFE_FREE(val_str[i]);
-               }
        }
 
        g_variant_iter_free(iter);
index 2ba0f69..da03764 100755 (executable)
@@ -1,31 +1,31 @@
-/*\r
- *  Media Server\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#ifndef _MEDIA_SCANNER_DB_MANAGER_V2_H_\r
-#define _MEDIA_SCANNER_DB_MANAGER_V2_H_\r
-\r
-#include "media-common-types.h"\r
-\r
-int msc_check_db_size(uid_t uid, int scan_type);\r
-int msc_cleanup_invalid_values(uid_t uid);\r
-\r
-#endif\r
-\r
+/*
+ *  Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _MEDIA_SCANNER_DB_MANAGER_V2_H_
+#define _MEDIA_SCANNER_DB_MANAGER_V2_H_
+
+#include "media-common-types.h"
+
+int msc_check_db_size(uid_t uid, int scan_type);
+int msc_cleanup_invalid_values(uid_t uid);
+
+#endif
+
index 64cad9d..814d1a4 100755 (executable)
@@ -30,4 +30,4 @@ void msc_device_block_changed_cb(ms_block_info_s *block_info, void *user_data);
 void msc_device_block_changed_cb(usb_device_h usb_device, char *action, void *user_data);
 #endif
 
-#endif
\ No newline at end of file
+#endif
index 91845aa..7b47f35 100755 (executable)
@@ -61,4 +61,4 @@ int msc_get_remain_scan_request(ms_scan_type_e scan_type, int *remain_request);
 int msc_get_dir_scan_status(bool *scan_status);
 int msc_set_cancel_path(const char *cancel_path);
 
-#endif /*_MEDIA_SCANNER_SCAN_V2_H_*/
\ No newline at end of file
+#endif /*_MEDIA_SCANNER_SCAN_V2_H_*/
index aa79252..7049205 100755 (executable)
-/*\r
- *  Media Server\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <errno.h>\r
-#include <sys/stat.h>\r
-#include <sqlite3.h>\r
-\r
-#include "media-util.h"\r
-#include "media-common-utils.h"\r
-#include "media-common-system.h"\r
-#include "media-common-db-svc.h"\r
-#include "media-scanner-dbg-v2.h"\r
-#include "media-scanner-db-manage-v2.h"\r
-\r
-int msc_check_db_size(uid_t uid, int scan_type)\r
-{\r
-       double db_size = 0.0;\r
-       double free_space = 0.0;\r
-       int err = MS_MEDIA_ERR_NONE;\r
-\r
-       ms_check_size_mediadb(uid, &db_size);\r
-\r
-       if (scan_type == MS_MSG_STORAGE_ALL\r
-               || scan_type == MS_MSG_STORAGE_PARTIAL) {\r
-               if (db_size >= MEDIA_DB_SIZE_LIMIT_1) {\r
-                       MS_DBG_ERR("DB SIZE [%lf] reach the MEDIA_DB_SIZE_LIMIT_1[%lf]", db_size, MEDIA_DB_SIZE_LIMIT_1);\r
-                       return MS_MEDIA_ERR_DB_LIMIT_1;\r
-               }\r
-       } else if (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE\r
-               || scan_type == MS_MSG_DIRECTORY_SCANNING) {\r
-               if (db_size >= MEDIA_DB_SIZE_LIMIT_2) {\r
-                       MS_DBG_ERR("DB SIZE [%lf] reach the MEDIA_DB_SIZE_LIMIT_2[%lf]", db_size, MEDIA_DB_SIZE_LIMIT_2);\r
-\r
-                       MS_DBG_WARN("START REMOVE INVALID DATA");\r
-                       msc_cleanup_invalid_values(uid);\r
-                       MS_DBG_WARN("END REMOVE INVALID DATA");\r
-\r
-                       ms_check_size_mediadb(uid, &db_size);\r
-                       if (db_size >= MEDIA_DB_SIZE_LIMIT_2) {\r
-#ifdef _USE_TVPD_MODE\r
-                               ms_config_set_int(MS_DB_LIMIT, 0);\r
-#endif\r
-                               MS_DBG_ERR("DB IS FULL. CANNOT UPDATE");\r
-                               return MS_MEDIA_ERR_DB_FULL_FAIL;\r
-                       }\r
-               }\r
-       }\r
-\r
-       /*check remain space*/\r
-       err = ms_get_remain_space(&free_space);\r
-       if (err != MS_MEDIA_ERR_NONE) {\r
-               MS_DBG_ERR("ms_get_remain_space failed");\r
-       } else {\r
-               if (free_space < MEDIA_DB_SPACE_LIMIT) {\r
-                       MS_DBG_ERR("FREE SPACE [%lf] DB SIZE [%lf]", free_space, db_size);\r
-                       return MS_MEDIA_ERR_NOT_ENOUGH_SPACE;\r
-               }\r
-       }\r
-\r
-       return MS_MEDIA_ERR_NONE;\r
-}\r
-\r
-int msc_cleanup_invalid_values(uid_t uid)\r
-{\r
-       int ret = MS_MEDIA_ERR_NONE;\r
-       void **handle = NULL;\r
-\r
-       MS_DBG_ERR("START CLEANUP MEDIA DB");\r
-\r
-       ms_connect_db(&handle, uid);\r
-       ret = ms_cleanup_db(handle, uid);\r
-       if (ret != MS_MEDIA_ERR_NONE) {\r
-               MS_DBG_ERR("'Cleanup failed [%d]", ret);\r
-               return ret;\r
-       }\r
-\r
-       if (handle)\r
-               ms_disconnect_db(&handle);\r
-\r
-       MS_DBG_ERR("END CLEANUP MEDIA DB");\r
-\r
-       return ret;\r
-}\r
-\r
+/*
+ *  Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <errno.h>
+#include <sys/stat.h>
+#include <sqlite3.h>
+
+#include "media-util.h"
+#include "media-common-utils.h"
+#include "media-common-system.h"
+#include "media-common-db-svc.h"
+#include "media-scanner-dbg-v2.h"
+#include "media-scanner-db-manage-v2.h"
+
+int msc_check_db_size(uid_t uid, int scan_type)
+{
+       double db_size = 0.0;
+       double free_space = 0.0;
+       int err = MS_MEDIA_ERR_NONE;
+
+       ms_check_size_mediadb(uid, &db_size);
+
+       if (scan_type == MS_MSG_STORAGE_ALL
+               || scan_type == MS_MSG_STORAGE_PARTIAL) {
+               if (db_size >= MEDIA_DB_SIZE_LIMIT_1) {
+                       MS_DBG_ERR("DB SIZE [%lf] reach the MEDIA_DB_SIZE_LIMIT_1[%lf]", db_size, MEDIA_DB_SIZE_LIMIT_1);
+                       return MS_MEDIA_ERR_DB_LIMIT_1;
+               }
+       } else if (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE
+               || scan_type == MS_MSG_DIRECTORY_SCANNING) {
+               if (db_size >= MEDIA_DB_SIZE_LIMIT_2) {
+                       MS_DBG_ERR("DB SIZE [%lf] reach the MEDIA_DB_SIZE_LIMIT_2[%lf]", db_size, MEDIA_DB_SIZE_LIMIT_2);
+
+                       MS_DBG_WARN("START REMOVE INVALID DATA");
+                       msc_cleanup_invalid_values(uid);
+                       MS_DBG_WARN("END REMOVE INVALID DATA");
+
+                       ms_check_size_mediadb(uid, &db_size);
+                       if (db_size >= MEDIA_DB_SIZE_LIMIT_2) {
+#ifdef _USE_TVPD_MODE
+                               ms_config_set_int(MS_DB_LIMIT, 0);
+#endif
+                               MS_DBG_ERR("DB IS FULL. CANNOT UPDATE");
+                               return MS_MEDIA_ERR_DB_FULL_FAIL;
+                       }
+               }
+       }
+
+       /*check remain space*/
+       err = ms_get_remain_space(&free_space);
+       if (err != MS_MEDIA_ERR_NONE) {
+               MS_DBG_ERR("ms_get_remain_space failed");
+       } else {
+               if (free_space < MEDIA_DB_SPACE_LIMIT) {
+                       MS_DBG_ERR("FREE SPACE [%lf] DB SIZE [%lf]", free_space, db_size);
+                       return MS_MEDIA_ERR_NOT_ENOUGH_SPACE;
+               }
+       }
+
+       return MS_MEDIA_ERR_NONE;
+}
+
+int msc_cleanup_invalid_values(uid_t uid)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+       void **handle = NULL;
+
+       MS_DBG_ERR("START CLEANUP MEDIA DB");
+
+       ms_connect_db(&handle, uid);
+       ret = ms_cleanup_db(handle, uid);
+       if (ret != MS_MEDIA_ERR_NONE) {
+               MS_DBG_ERR("'Cleanup failed [%d]", ret);
+               return ret;
+       }
+
+       if (handle)
+               ms_disconnect_db(&handle);
+
+       MS_DBG_ERR("END CLEANUP MEDIA DB");
+
+       return ret;
+}
+
index 81702e6..53f7f53 100755 (executable)
@@ -44,14 +44,13 @@ static void __msc_usb_remove_event(const char *mount_path)
        int remain_request = 0;
        bool status = FALSE;
 
-       if (!ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &update_status)) {
+       if (!ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &update_status))
                MS_DBG_ERR("ms_config_get_int[VCONFKEY_FILEMANAGER_DB_STATUS]");
-       }
 
        if (msc_get_remain_scan_request(MS_SCAN_STORAGE, &remain_request) == MS_MEDIA_ERR_NONE) {
-               if (!(remain_request == 0 && update_status == VCONFKEY_FILEMANAGER_DB_UPDATED)) {
+               if (!(remain_request == 0 && update_status == VCONFKEY_FILEMANAGER_DB_UPDATED))
                        msc_set_blocked_path(mount_path);
-               }
+
                remain_request = 0;
        }
 
@@ -65,9 +64,9 @@ static void __msc_usb_remove_event(const char *mount_path)
        }
 
        if (msc_get_remain_extract_request(MS_EXTRACT_STORAGE, &remain_request) == MS_MEDIA_ERR_NONE) {
-               if (!(remain_request == 0 && update_status == VCONFKEY_FILEMANAGER_DB_UPDATED)) {
+               if (!(remain_request == 0 && update_status == VCONFKEY_FILEMANAGER_DB_UPDATED))
                        msc_set_extract_blocked_path(mount_path);
-               }
+
                remain_request = 0;
        }
 
@@ -93,8 +92,10 @@ void _msc_mmc_changed_event(const char *mount_path, ms_stg_status_e mount_status
        /* If scanner is not working, media server executes media scanner and sends request. */
        /* If scanner is working, it detects changing status of SD card. */
        if (mount_status == MS_STG_INSERTED) {
+               MS_DBG_WARN("GET THE MMC INSERT EVENT");
                /*DO NOT THING*/
        } else if (mount_status == MS_STG_REMOVED) {
+               MS_DBG_WARN("GET THE MMC REMOVE EVENT");
                msc_mmc_remove_handler(mount_path);
        }
 
@@ -105,10 +106,10 @@ void _msc_mmc_changed_event(const char *mount_path, ms_stg_status_e mount_status
 void msc_device_block_changed_cb(ms_block_info_s *block_info, void *user_data)
 {
        if (block_info->block_type == 0) {
-               MS_DBG_WARN("GET THE USB EVENT");
                if (block_info->state == MS_STG_INSERTED) {
-                       /*DO NOT THING*/
+                       MS_DBG_WARN("GET THE USB INSERT EVENT");
                } else {
+                       MS_DBG_WARN("GET THE USB REMOVE EVENT");
                        __msc_usb_remove_event(block_info->mount_path);
                }
        } else {
@@ -144,25 +145,22 @@ void msc_device_block_changed_cb(usb_device_h usb_device, char *action, void *us
                MS_DBG_ERR("USB BLOCKED, mountpath : %s", mount_path);
                int status = -1;
 
-               if (!ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &status)) {
+               if (!ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &status))
                        MS_DBG_ERR("ms_config_get_int[VCONFKEY_FILEMANAGER_DB_STATUS]");
-               }
 
-               if (!(g_async_queue_length(storage_queue2) == 0 && status == VCONFKEY_FILEMANAGER_DB_UPDATED)) {
+               if (!(g_async_queue_length(storage_queue2) == 0 && status == VCONFKEY_FILEMANAGER_DB_UPDATED))
                        msc_set_blocked_path(mount_path);
-               }
 
                if (g_directory_scan_processing2 != 0) {
                        MS_DBG_WARN("Doing directory scanning. Set cancel path");
                        msc_set_cancel_scan_item(mount_path, -1);
                }
 
-               if (!ms_config_get_int(VCONFKEY_PRIVATE_EXTRACTSTATUS, &status)) {
+               if (!ms_config_get_int(VCONFKEY_PRIVATE_EXTRACTSTATUS, &status))
                        MS_DBG_ERR("ms_config_get_int[VCONFKEY_FILEMANAGER_DB_STATUS]");
-               }
-               if (!(g_async_queue_length(storage_extract_queue) == 0 && status == MS_DB_UPDATED)) {
+
+               if (!(g_async_queue_length(storage_extract_queue) == 0 && status == MS_DB_UPDATED))
                        msc_set_extract_blocked_path(mount_path);
-               }
 
                if (g_directory_extract_processing == true) {
                        MS_DBG_WARN("Doing directory extracting. Set cancel path");
index 95d1ecc..bda9a02 100755 (executable)
@@ -142,11 +142,10 @@ int __msc_folder_bulk_extract(void **handle, const char* storage_id, int storage
                g_array_remove_index(data_array, 0);
 
                tmp_ret = ms_update_one_extract_item(handle, storage_id, storage_type, db_data, burst);
-               if (tmp_ret == MS_MEDIA_ERR_NONE) {
+               if (tmp_ret == MS_MEDIA_ERR_NONE)
                        extract_count++;
-               } else if (tmp_ret == MS_MEDIA_ERR_FILE_IO) {
+               else if (tmp_ret == MS_MEDIA_ERR_FILE_IO)
                        (*io_err_count)++;
-               }
 
                if (db_data) {
                        MS_SAFE_FREE(db_data->path);
@@ -155,9 +154,8 @@ int __msc_folder_bulk_extract(void **handle, const char* storage_id, int storage
                }
        }
 
-       if (extract_count > 0) {
+       if (extract_count > 0)
                ret = ms_query_do_update_list(handle);
-       }
 
        while (data_array->len != 0) {
                db_data = NULL;
@@ -254,9 +252,9 @@ gboolean msc_folder_extract_thread(void *data)
                ret = msc_check_db_size(uid, extract_data->msg_type);
                if (ret != MS_MEDIA_ERR_NONE) {
                        MS_DBG_ERR("NOT ENOUGH MEMORY");
-                       if (ret == MS_MEDIA_ERR_DB_FULL_FAIL) {
+                       if (ret == MS_MEDIA_ERR_DB_FULL_FAIL)
                                ret = MS_MEDIA_ERR_NONE;
-                       }
+
                        goto NEXT;
                }
 
@@ -554,9 +552,8 @@ int msc_remove_extract_request(const ms_comm_msg_s *recv_msg)
        int j = 0;
        for (; j < len; j++) {
                msg = g_async_queue_pop(temp_queue);
-               if (msg) {
+               if (msg)
                        g_async_queue_push(storage_extract_queue, GINT_TO_POINTER(msg));
-               }
        }
        g_async_queue_unref(temp_queue);
 
@@ -611,11 +608,10 @@ int msc_set_cancel_extract_item(const char* cancel_path, int pid)
        }
 
        if (cur_extract_item && cur_extract_item->path) {
-               if ((strcmp(cur_extract_item->path, cancel_path) == 0) && (pid == cur_extract_item->pid)) {
+               if ((strcmp(cur_extract_item->path, cancel_path) == 0) && (pid == cur_extract_item->pid))
                        ret = _msc_set_extract_item(&cancel_extract_item, cancel_path, pid);
-               } else if ((pid == -1) && (strncmp(cur_extract_item->path, cancel_path, strlen(cancel_path)) == 0)) {
+               else if ((pid == -1) && (strncmp(cur_extract_item->path, cancel_path, strlen(cancel_path)) == 0))
                        ret = _msc_set_extract_item(&cancel_extract_item, cancel_path, pid);
-               }
        }
        g_mutex_unlock(&extract_item_mutex);
 
index 0e21740..43dfc95 100755 (executable)
@@ -301,14 +301,12 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
        is_recursive = (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) ? false : true;
 
        /* folder validity set 0 under the start_path in folder table*/
-       if (ms_set_folder_validity(handle, storage_id, new_start_path, MS_INVALID, is_recursive, uid) != MS_MEDIA_ERR_NONE) {
+       if (ms_set_folder_validity(handle, storage_id, new_start_path, MS_INVALID, is_recursive, uid) != MS_MEDIA_ERR_NONE)
                MS_DBG_ERR("set_folder_validity failed [%d] ", scan_type);
-       }
 
        if (g_file_test(new_start_path, G_FILE_TEST_IS_DIR)) {
-               if (ms_insert_folder(handle, storage_id, new_start_path, uid) != MS_MEDIA_ERR_NONE) {
+               if (ms_insert_folder(handle, storage_id, new_start_path, uid) != MS_MEDIA_ERR_NONE)
                        MS_DBG_ERR("insert folder failed");
-               }
 
                MS_DBG_WARN("ms_insert_folder insert path11112222[%s]", new_start_path);
        }
@@ -318,9 +316,9 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
                /*check poweroff status*/
                ret = __msc_check_stop_status(scan_type, storage_type, new_start_path, pid);
                if (ret != MS_MEDIA_ERR_NONE) {
-                       if (is_recursive == true) {
+                       if (is_recursive == true)
                                ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
-                       }
+
                        goto STOP_SCAN;
                }
 
@@ -333,17 +331,16 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
                __msc_set_dir_scan_cur_path(current_path);
 
                if (strncmp(current_path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) != 0) {
-               ret = ms_check_scan_ignore(current_path);
-               if (ret != MS_MEDIA_ERR_NONE) {
-                       MS_DBG_ERR("%s is ignore", current_path);
-                       MS_SAFE_FREE(current_path);
-                       if (ret == MS_MEDIA_ERR_USB_UNMOUNTED) {
-                               goto STOP_SCAN;
-                       } else {
-                               ret = MS_MEDIA_ERR_NONE;
-                       }
+                       ret = ms_check_scan_ignore(current_path);
+                       if (ret != MS_MEDIA_ERR_NONE) {
+                               MS_DBG_ERR("%s is ignore", current_path);
+                               MS_SAFE_FREE(current_path);
+                               if (ret == MS_MEDIA_ERR_USB_UNMOUNTED)
+                                       goto STOP_SCAN;
+                               else
+                                       ret = MS_MEDIA_ERR_NONE;
 
-                       continue;
+                               continue;
                        }
                } else {
                        MS_DBG_ERR("[DATA DISC] PASS IGNORE");
@@ -351,13 +348,12 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
 
                ret = msc_check_db_size(uid, scan_type);
                if (ret != MS_MEDIA_ERR_NONE) {
-                       if (ret == MS_MEDIA_ERR_DB_FULL_FAIL) {
+                       if (ret == MS_MEDIA_ERR_DB_FULL_FAIL)
                                ret = MS_MEDIA_ERR_NONE;
-                       }
 
-                       if (is_recursive == true) {
+                       if (is_recursive == true)
                                ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
-                       }
+
                        goto STOP_SCAN;
                }
 
@@ -390,26 +386,26 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
                        /*check poweroff status*/
                        ret = __msc_check_stop_status(scan_type, storage_type, new_start_path, pid);
                        if (ret != MS_MEDIA_ERR_NONE) {
-                               if (is_recursive == true) {
+                               if (is_recursive == true)
                                        ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
-                               }
+
                                goto STOP_SCAN;
                        }
 
                        ret = msc_check_db_size(uid, scan_type);
                        if (ret != MS_MEDIA_ERR_NONE) {
                                //ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_STOP, ui);
-                               if (ret == MS_MEDIA_ERR_DB_FULL_FAIL) {
+                               if (ret == MS_MEDIA_ERR_DB_FULL_FAIL)
                                        ret = MS_MEDIA_ERR_NONE;
-                               }
+
                                goto STOP_SCAN;
                        }
 #if 0
                        if (io_err_folder == MS_MAX_IO_ERR_COUNT) {
                                MS_DBG_ERR("REACH I/O MAX COUNT[%d]", io_err_folder);
-                               if (is_recursive == true) {
+                               if (is_recursive == true)
                                        ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
-                               }
+
                                goto STOP_SCAN;
                        }
 #endif
@@ -420,30 +416,29 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
                                /*check poweroff status*/
                                ret = __msc_check_stop_status(scan_type, storage_type, new_start_path, pid);
                                if (ret != MS_MEDIA_ERR_NONE) {
-                                       if (is_recursive == true) {
+                                       if (is_recursive == true)
                                                ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
-                                       }
+
                                        goto STOP_SCAN;
                                }
 
                                ret = msc_check_db_size(uid, scan_type);
                                if (ret != MS_MEDIA_ERR_NONE) {
-                                       if (ret == MS_MEDIA_ERR_DB_FULL_FAIL) {
+                                       if (ret == MS_MEDIA_ERR_DB_FULL_FAIL)
                                                ret = MS_MEDIA_ERR_NONE;
-                                       }
 
-                                       if (is_recursive == true) {
+                                       if (is_recursive == true)
                                                ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
-                                       }
+
                                        //ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_STOP, uid);
                                        goto STOP_SCAN;
                                }
 #if 0
                                if (io_err_folder == MS_MAX_IO_ERR_COUNT) {
                                        MS_DBG_ERR("REACH I/O MAX COUNT[%d]", io_err_folder);
-                                       if (is_recursive == true) {
+                                       if (is_recursive == true)
                                                ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
-                                       }
+
                                        goto STOP_SCAN;
                                }
 #endif
@@ -469,11 +464,10 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
                                if (d->d_type == DT_UNKNOWN) {
                                        struct stat st;
                                        if (stat(path, &st) == 0) {
-                                               if (S_ISREG(st.st_mode)) {
+                                               if (S_ISREG(st.st_mode))
                                                        d->d_type = DT_REG;
-                                               } else if (S_ISDIR(st.st_mode)) {
+                                               else if (S_ISDIR(st.st_mode))
                                                        d->d_type = DT_DIR;
-                                               }
                                        }
                                }
 
@@ -488,9 +482,9 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
                                        ret = ms_scan_validate_item(handle, storage_id, path, uid);
                                        if (ret != MS_MEDIA_ERR_NONE) {
                                                MS_DBG_ERR("failed to update db : %d", scan_type);
-                                               if (ret == MS_MEDIA_ERR_FILE_IO) {
+                                               if (ret == MS_MEDIA_ERR_FILE_IO)
                                                        MS_DBG_ERR("I/O ERROR COUNT[%d]", io_err_folder++);
-                                               }
+
                                                bpos += d->d_reclen;
                                                continue;
                                        } else {
@@ -503,16 +497,16 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
                                                }
 
                                                if (insert_count_for_partial >= MAX_SCAN_COUNT) {
-                                                       if (pid != 0) {
+                                                       if (pid != 0)
                                                                msc_send_result_partial(ret, MS_MSG_SCANNER_PARTIAL, pid, (char*)start_path);
-                                                       }
+
                                                        insert_count_for_partial = 0;
                                                }
 
                                                if (set_count_for_partial >= MAX_SCAN_COUNT) {
-                                                       if (pid != 0) {
+                                                       if (pid != 0)
                                                                msc_send_result_partial(ret, MS_MSG_SCANNER_PARTIAL, pid, (char*)start_path);
-                                                       }
+
                                                        set_count_for_partial = 0;
                                                }
                                        }
@@ -523,9 +517,9 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
                                                new_path = strdup(path);
                                                g_array_append_val(dir_array, new_path);
 
-                                               if (ms_insert_folder(handle, storage_id, new_path, uid) != MS_MEDIA_ERR_NONE) {
+                                               if (ms_insert_folder(handle, storage_id, new_path, uid) != MS_MEDIA_ERR_NONE)
                                                        MS_DBG_ERR("insert folder failed");
-                                               }
+
                                        } else {
                                                /* this request is non-recursive scanning */
                                                /* don't add new directory to dir_array */
@@ -626,9 +620,8 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
 
        g_array_append_val(dir_array, start_path);
        ms_insert_folder_end(handle, uid);
-       if (ms_insert_folder(handle, storage_id, new_start_path, uid) != MS_MEDIA_ERR_NONE) {
+       if (ms_insert_folder(handle, storage_id, new_start_path, uid) != MS_MEDIA_ERR_NONE)
                MS_DBG_ERR("insert folder failed");
-       }
 
        scan_function = (scan_type == MS_MSG_STORAGE_ALL) ? ms_scan_item_batch : ms_scan_validate_item;
 
@@ -636,9 +629,8 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
        while (dir_array->len != 0) {
                /*check poweroff status*/
                ret = __msc_check_stop_status(scan_type, storage_type, new_start_path, pid);
-               if (ret != MS_MEDIA_ERR_NONE) {
+               if (ret != MS_MEDIA_ERR_NONE)
                        goto STOP_SCAN;
-               }
 
                ms_bacth_commit_disable(handle, TRUE, TRUE, uid);
                ms_bacth_commit_enable(handle, TRUE, TRUE, MS_NOTI_SWITCH_OFF, pid);
@@ -653,19 +645,17 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
                if (ret != MS_MEDIA_ERR_NONE) {
                        MS_DBG_ERR("%s is ignore", current_path);
                        MS_SAFE_FREE(current_path);
-                       if (ret == MS_MEDIA_ERR_USB_UNMOUNTED) {
+                       if (ret == MS_MEDIA_ERR_USB_UNMOUNTED)
                                goto STOP_SCAN;
-                       } else {
+                       else
                                ret = MS_MEDIA_ERR_NONE;
-                       }
 
                        continue;
                }
 
                ret = msc_check_db_size(uid, scan_type);
-               if (ret != MS_MEDIA_ERR_NONE) {
+               if (ret != MS_MEDIA_ERR_NONE)
                        goto STOP_SCAN;
-               }
 
                ms_get_folder_scan_status(handle, storage_id, current_path, (int *)&scan_status);
 
@@ -711,9 +701,8 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
 
                        /*check poweroff status*/
                        ret = __msc_check_stop_status(scan_type, storage_type, new_start_path, pid);
-                       if (ret != MS_MEDIA_ERR_NONE) {
+                       if (ret != MS_MEDIA_ERR_NONE)
                                goto STOP_SCAN;
-                       }
 
                        ret = msc_check_db_size(uid, scan_type);
                        if (ret != MS_MEDIA_ERR_NONE) {
@@ -732,9 +721,8 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
                        for (bpos = 0; bpos < nread;) {
                                /*check poweroff status*/
                                ret = __msc_check_stop_status(scan_type, storage_type, new_start_path, pid);
-                               if (ret != MS_MEDIA_ERR_NONE) {
+                               if (ret != MS_MEDIA_ERR_NONE)
                                        goto STOP_SCAN;
-                               }
 
                                ret = msc_check_db_size(uid, scan_type);
                                if (ret != MS_MEDIA_ERR_NONE) {
@@ -769,11 +757,10 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
                                if (d->d_type == DT_UNKNOWN) {
                                        struct stat st;
                                        if (stat(path, &st) == 0) {
-                                               if (S_ISREG(st.st_mode)) {
+                                               if (S_ISREG(st.st_mode))
                                                        d->d_type = DT_REG;
-                                               } else if (S_ISDIR(st.st_mode)) {
+                                               else if (S_ISDIR(st.st_mode))
                                                        d->d_type = DT_DIR;
-                                               }
                                        }
                                }
 
@@ -788,9 +775,9 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
                                        ret = scan_function(handle, storage_id, path, uid);
                                        if (ret != MS_MEDIA_ERR_NONE) {
                                                MS_DBG_ERR("failed to update db : %d", scan_type);
-                                               if (ret == MS_MEDIA_ERR_FILE_IO) {
+                                               if (ret == MS_MEDIA_ERR_FILE_IO)
                                                        MS_DBG_ERR("I/O ERROR COUNT[%d]", io_err_storage++);
-                                               }
+
                                                bpos += d->d_reclen;
                                                continue;
                                        } else {
@@ -808,9 +795,8 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
                                        new_path = strdup(path);
                                        g_array_append_val(dir_array, new_path);
 
-                                       if (ms_insert_folder(handle, storage_id, new_path, uid) != MS_MEDIA_ERR_NONE) {
+                                       if (ms_insert_folder(handle, storage_id, new_path, uid) != MS_MEDIA_ERR_NONE)
                                                MS_DBG_ERR("insert folder failed");
-                                       }
                                }
 
                                bpos += d->d_reclen;
@@ -837,9 +823,8 @@ NEXT_SCAN:
 
                                MS_DBG_WARN("no wait folder scan callback");
 
-                               if (ret != MS_MEDIA_ERR_NONE) {
+                               if (ret != MS_MEDIA_ERR_NONE)
                                        break;
-                               }
                        } else {
                                __msc_set_dir_scan_cb(__msc_dir_scan_cb);
 
@@ -851,9 +836,8 @@ NEXT_SCAN:
 
                                ret = __msc_get_null_scan_folder_list(handle, storage_id, NULL, dir_array);
 
-                               if (ret != MS_MEDIA_ERR_NONE) {
+                               if (ret != MS_MEDIA_ERR_NONE)
                                        break;
-                               }
                        }
                }
        }
@@ -1003,11 +987,10 @@ int __msc_dir_and_storage_scan_same_path(char *start_path)
        storage_len = strlen(storage_path);
        folder_len = strlen(g_dir_scan_path);
 
-       if (folder_len < storage_len) {
+       if (folder_len < storage_len)
                ret = -1;
-       } else {
+       else
                ret = strncmp(storage_path, g_dir_scan_path, storage_len);
-       }
 
        MS_SAFE_FREE(storage_path);
        g_mutex_unlock(&dir_scan_mutex2);
@@ -1051,15 +1034,14 @@ static int __msc_db_update(void **handle, const char *storage_id, const ms_comm_
        if (scan_type != MS_MSG_STORAGE_INVALID) {
                MS_DBG_WARN("INSERT");
                start_path = strndup(scan_data->msg, scan_data->msg_size);
-               if (scan_type == MS_MSG_DIRECTORY_SCANNING || scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) {
+               if (scan_type == MS_MSG_DIRECTORY_SCANNING || scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE)
                        err = __msc_dir_scan_for_folder(handle, storage_id, start_path, storage_type, scan_type, scan_data->pid, scan_data->uid);
-               } else if (scan_type == MS_MSG_STORAGE_ALL || scan_type == MS_MSG_STORAGE_PARTIAL) {
+               else if (scan_type == MS_MSG_STORAGE_ALL || scan_type == MS_MSG_STORAGE_PARTIAL)
                        err = __msc_dir_scan_for_storage(handle, storage_id, start_path, storage_type, scan_type, scan_data->pid, scan_data->uid);
-               }
 
-               if (err != MS_MEDIA_ERR_NONE) {
+               if (err != MS_MEDIA_ERR_NONE)
                        MS_DBG_ERR("error : %d", err);
-               }
+
        } else if (scan_type == MS_MSG_STORAGE_INVALID) {
                MS_DBG_WARN("INVALID");
                msc_remove_extract_request(scan_data);
@@ -1184,18 +1166,15 @@ gboolean msc_directory_scan_thread(void *data)
                                        sleep(1);
 
                                        ret = __msc_check_stop_status(scan_type, storage_type, scan_data->msg, scan_data->pid);
-                                       if (ret != MS_MEDIA_ERR_NONE) {
+                                       if (ret != MS_MEDIA_ERR_NONE)
                                                goto NEXT;
-                                       }
 
-                                       if ((++index) % 3 == 0) {
+                                       if ((++index) % 3 == 0)
                                                msc_send_result_partial(ret, MS_MSG_SCANNER_PARTIAL, scan_data->pid, scan_data->msg);
-                                       }
 
                                        err = __msc_check_scan_same_path(scan_data->msg);
-                                       if (err != MS_MEDIA_ERR_NONE) {
+                                       if (err != MS_MEDIA_ERR_NONE)
                                                break;
-                                       }
                                }
 
                                index = 0;
@@ -1205,11 +1184,10 @@ gboolean msc_directory_scan_thread(void *data)
                        } else {
                                ms_get_folder_scan_status(handle, storage_id, scan_data->msg, (int*)&scan_status);
 
-                               if (scan_status == MS_DIR_SCAN_DONE) {
+                               if (scan_status == MS_DIR_SCAN_DONE)
                                        ms_set_folder_item_validity(handle, storage_id, scan_data->msg, MS_VALIND_V2, MS_RECURSIVE, uid);
-                               } else {
+                               else
                                        ms_set_folder_item_validity(handle, storage_id, scan_data->msg, MS_INVALID, MS_RECURSIVE, uid);
-                               }
                        }
                } else {
                        MS_DBG_WARN("start non recursive dir scan!!");
@@ -1234,13 +1212,11 @@ gboolean msc_directory_scan_thread(void *data)
                                                sleep(1);
 
                                                ret = __msc_check_stop_status(scan_type, storage_type, scan_data->msg, scan_data->pid);
-                                               if (ret != MS_MEDIA_ERR_NONE) {
+                                               if (ret != MS_MEDIA_ERR_NONE)
                                                        goto NEXT;
-                                               }
 
-                                               if ((++index) % 3 == 0) {
+                                               if ((++index) % 3 == 0)
                                                        msc_send_result_partial(ret, MS_MSG_SCANNER_PARTIAL, scan_data->pid, scan_data->msg);
-                                               }
 
                                                ms_get_folder_scan_status(handle, storage_id, scan_data->msg, (int*)&scan_status);
                                                if ((scan_status == MS_DIR_SCAN_DONE) || (scan_status == MS_DIR_SCAN_STOP)) {
@@ -1286,13 +1262,11 @@ gboolean msc_directory_scan_thread(void *data)
                MS_DBG_WARN("folder scan done, sent cb event path = [%s]", scan_data->msg);
                __msc_call_dir_scan_cb();
 
-               if (!ms_delete_invalid_items(handle, storage_id, storage_type, scan_data->uid)) {
+               if (!ms_delete_invalid_items(handle, storage_id, storage_type, scan_data->uid))
                        MS_DBG_ERR("deleting invalid items in storage failed");
-               }
 
-               if (ms_delete_invalid_folder(handle, storage_id, storage_type, scan_data->uid) != MS_MEDIA_ERR_NONE) {
+               if (ms_delete_invalid_folder(handle, storage_id, storage_type, scan_data->uid) != MS_MEDIA_ERR_NONE)
                        MS_DBG_ERR("deleting invalid folders in storage failed");
-               }
 
                if (ret != MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
                        MS_DBG_INFO("working normally");
@@ -1443,21 +1417,18 @@ gboolean msc_storage_scan_thread(void *data)
 
                if (scan_type == MS_MSG_STORAGE_ALL) {
                        /* Delete all data before full scanning */
-                       if (!ms_delete_invalid_items(handle, scan_data->storage_id, storage_type, uid)) {
+                       if (!ms_delete_invalid_items(handle, scan_data->storage_id, storage_type, uid))
                                MS_DBG_ERR("ms_delete_invalid_items fails");
-                       }
                }
 
                ret = __msc_db_update(handle, scan_data->storage_id, scan_data);
 
                /*call for bundle commit*/
-               if (scan_type != MS_MSG_STORAGE_INVALID) {
+               if (scan_type != MS_MSG_STORAGE_INVALID)
                        ms_bacth_commit_disable(handle, TRUE, valid_status, uid);
-               }
 
-               if (scan_type == MS_MSG_STORAGE_PARTIAL && ret == MS_MEDIA_ERR_NONE) {
+               if (scan_type == MS_MSG_STORAGE_PARTIAL && ret == MS_MEDIA_ERR_NONE)
                        ms_delete_invalid_items(handle, scan_data->storage_id, storage_type, uid);
-               }
 
                /* send notification */
                ms_send_dir_update_noti(handle, scan_data->storage_id, update_path, NULL, MS_ITEM_UPDATE, scan_data->pid);
@@ -1512,13 +1483,13 @@ static void __msc_insert_register_request(GArray *register_array, ms_comm_msg_s
 {
        MS_DBG_SLOG("path : %s", insert_data->msg);
 
-       if (insert_data->pid == POWEROFF) {
+       if (insert_data->pid == POWEROFF)
                g_array_prepend_val(register_array, insert_data);
-       } else if (insert_data->msg_type == MS_MSG_BURSTSHOT_INSERT) {
+       else if (insert_data->msg_type == MS_MSG_BURSTSHOT_INSERT)
                g_array_prepend_val(register_array, insert_data);
-       } else {
+       else
                g_array_append_val(register_array, insert_data);
-       }
+
 }
 
 static int __msc_clear_file_list(GArray *path_array)
@@ -1826,9 +1797,9 @@ int msc_set_cancel_scan_item(const char* cancel_path, int pid)
        if (cur_scan_item != NULL && cur_scan_item->path != NULL) {
                MS_DBG_WARN("cur_scan_item->path[%s], cur_scan_item->pid[%d]", cur_scan_item->path, cur_scan_item->pid);
                MS_DBG_WARN("cancel_path[%s], pid[%d]", cancel_path, pid);
-               if ((strcmp(cur_scan_item->path, cancel_path) == 0) && (pid == cur_scan_item->pid)) {
+               if ((strcmp(cur_scan_item->path, cancel_path) == 0) && (pid == cur_scan_item->pid))
                        ret = _msc_set_scan_item(&cancel_scan_item, cancel_path, pid);
-               }
+
        } else {
                MS_DBG_ERR("cur_scan_item == NULL || cur_scan_item->path == NULL");
        }
index 5721582..1d34a96 100755 (executable)
@@ -88,9 +88,8 @@ static int _msc_remove_request(GAsyncQueue *req_queue, ms_comm_msg_s *recv_msg)
                int j = 0;
                for (; j < len; j++) {
                        msg = g_async_queue_pop(temp_scan_queue);
-                       if (msg) {
+                       if (msg)
                                g_async_queue_push(scan_queue2, GINT_TO_POINTER(msg));
-                       }
                }
                g_async_queue_unref(temp_scan_queue);
                MS_DBG_WARN("end update scan_queue2");
@@ -124,9 +123,8 @@ END_REMOVE_REQUEST:
                        int j = 0;
                        for (; j < len; j++) {
                                msg = g_async_queue_pop(temp_extract_queue);
-                               if (msg) {
+                               if (msg)
                                        g_async_queue_push(folder_extract_queue, GINT_TO_POINTER(msg));
-                               }
                        }
                        g_async_queue_unref(temp_extract_queue);
                        MS_DBG_WARN("end update folder_extract_queue");
index 9a532a6..f0f9f6e 100755 (executable)
@@ -119,9 +119,8 @@ static void _power_off_cb(void* data)
 
        if (g_main_loop_is_running(scanner_mainloop2)) g_main_loop_quit(scanner_mainloop2);
 
-       if (!ms_config_set_int(MSC_VCONF_KEY_SCANNER_POWEROFF_STATUS, 1)) {
+       if (!ms_config_set_int(MSC_VCONF_KEY_SCANNER_POWEROFF_STATUS, 1))
                MS_DBG_ERR("set power off status to 1 failed");
-       }
 
        MS_DBG_ERR("POWER OFF END");
 }
@@ -174,22 +173,19 @@ void _msc_datadisc_vconf_cb(void *data)
                                ms_config_set_int(MS_DISC_ACCESS_STATE, MS_DISC_ACCESS);
                        }
 
-                       if (!ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &status)) {
+                       if (!ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &status))
                                MS_DBG_ERR("ms_config_get_int[VCONFKEY_FILEMANAGER_DB_STATUS]");
-                       }
 
-                       if (!(g_async_queue_length(storage_queue2) == 0 && status == VCONFKEY_FILEMANAGER_DB_UPDATED)) {
+                       if (!(g_async_queue_length(storage_queue2) == 0 && status == VCONFKEY_FILEMANAGER_DB_UPDATED))
                                msc_set_blocked_path(storage_path);
-                       }
 
                        if (g_directory_scan_processing2 != 0) {
                                MS_DBG_WARN("Doing directory scanning. Set cancel path");
                                msc_set_cancel_scan_item(storage_path, -1);
                        }
 
-                       if (!(g_async_queue_length(storage_extract_queue) == 0 && status == VCONFKEY_FILEMANAGER_DB_UPDATED)) {
+                       if (!(g_async_queue_length(storage_extract_queue) == 0 && status == VCONFKEY_FILEMANAGER_DB_UPDATED))
                                msc_set_extract_blocked_path(storage_path);
-                       }
 
                        if (g_directory_extract_processing == true) {
                                MS_DBG_WARN("Doing directory extracting. Set cancel path");
@@ -241,9 +237,8 @@ int main(int argc, char **argv)
 
        /* Create pipe */
        err = unlink(MS_SCANNER_FIFO_PATH_REQ);
-       if (err != 0) {
+       if (err != 0)
                MS_DBG_STRERROR("[No-Error] unlink failed");
-       }
 
        err = mkfifo(MS_SCANNER_FIFO_PATH_REQ, MS_SCANNER_FIFO_MODE);
        if (err != 0) {
@@ -257,9 +252,8 @@ int main(int argc, char **argv)
                return MS_MEDIA_ERR_FILE_OPEN_FAIL;
        }
 
-       if (!ms_config_set_int(MSC_VCONF_KEY_SCANNER_POWEROFF_STATUS, 0)) {
+       if (!ms_config_set_int(MSC_VCONF_KEY_SCANNER_POWEROFF_STATUS, 0))
                MS_DBG_ERR("set power off status to 0 failed");
-       }
 
        context = g_main_loop_get_context(scanner_mainloop2);
 
@@ -315,9 +309,8 @@ int main(int argc, char **argv)
        ms_unload_functions();
 
 EXIT:
-       if (!ms_config_set_int(MSC_VCONF_KEY_SCANNER_POWEROFF_STATUS, 0)) {
+       if (!ms_config_set_int(MSC_VCONF_KEY_SCANNER_POWEROFF_STATUS, 0))
                MS_DBG_ERR("set power off status to 0 failed");
-       }
 
        MS_DBG_INFO("Scanner-V2 is shutting down");
        return 0;
index c7dae47..fa874c4 100755 (executable)
@@ -45,4 +45,4 @@ int msc_push_scan_request(ms_scan_type_e scan_type, ms_comm_msg_s *recv_msg);
 int msc_send_power_off_request(void);
 int msc_remove_dir_scan_request(ms_comm_msg_s *recv_msg);
 
-#endif /*_MEDIA_SCANNER_SCAN_H_*/
\ No newline at end of file
+#endif /*_MEDIA_SCANNER_SCAN_H_*/
index e8234b8..63f2323 100755 (executable)
@@ -81,9 +81,8 @@ static int __msc_dir_scan(void **handle, const char *storage_id, const char*star
 
        while (dir_array->len != 0) {
                ret = __msc_check_stop_status(storage_type);
-               if (ret != MS_MEDIA_ERR_NONE) {
+               if (ret != MS_MEDIA_ERR_NONE)
                        goto STOP_SCAN;
-               }
 
                current_path = g_array_index(dir_array , char*, 0);
                g_array_remove_index(dir_array, 0);
@@ -98,9 +97,9 @@ static int __msc_dir_scan(void **handle, const char *storage_id, const char*star
 
                dir = g_dir_open(current_path, 0, &error);
                if (error == NULL && dir != NULL) {
-                       if (ms_insert_folder(handle, storage_id, current_path, uid) != MS_MEDIA_ERR_NONE) {
+                       if (ms_insert_folder(handle, storage_id, current_path, uid) != MS_MEDIA_ERR_NONE)
                                MS_DBG_ERR("insert folder failed");
-                       }
+
                        while ((name = g_dir_read_name(dir))) {
                                ret = __msc_check_stop_status(storage_type);
                                if (ret != MS_MEDIA_ERR_NONE) {
@@ -131,9 +130,8 @@ static int __msc_dir_scan(void **handle, const char *storage_id, const char*star
                                                        continue;
                                                }
                                        } else {
-                                               if (ms_insert_folder(handle, storage_id, path, uid) != MS_MEDIA_ERR_NONE) {
+                                               if (ms_insert_folder(handle, storage_id, path, uid) != MS_MEDIA_ERR_NONE)
                                                        MS_DBG_ERR("insert folder failed");
-                                               }
                                        }
                                }
                        }
@@ -182,15 +180,14 @@ static int __msc_db_update(void **handle, const char *storage_id, const ms_comm_
                else
                        err = __msc_dir_scan(handle, storage_id, start_path, storage_type, true, true, scan_data->uid);
 
-               if (err != MS_MEDIA_ERR_NONE) {
+               if (err != MS_MEDIA_ERR_NONE)
                        MS_DBG_ERR("error : %d", err);
-               }
+
        } else {
                MS_DBG_INFO("INVALID");
                err = ms_validaty_change_all_items(handle, storage_id, storage_type, false, scan_data->uid);
-               if (err != MS_MEDIA_ERR_NONE) {
+               if (err != MS_MEDIA_ERR_NONE)
                        MS_DBG_ERR("error : %d", err);
-               }
 
                ms_set_folder_validity(handle, storage_id, start_path, 0, TRUE, scan_data->uid);
 
@@ -310,13 +307,11 @@ gboolean msc_directory_scan_thread(void *data)
 
                ms_bacth_commit_disable(handle, TRUE, TRUE, scan_data->uid);
 
-               if (!ms_delete_invalid_items(handle, storage_id, storage_type, scan_data->uid)) {
+               if (!ms_delete_invalid_items(handle, storage_id, storage_type, scan_data->uid))
                        MS_DBG_ERR("deleting invalid items in storage failed");
-               }
 
-               if (ms_delete_invalid_folder(handle, storage_id, storage_type, scan_data->uid) != MS_MEDIA_ERR_NONE) {
+               if (ms_delete_invalid_folder(handle, storage_id, storage_type, scan_data->uid) != MS_MEDIA_ERR_NONE)
                        MS_DBG_ERR("deleting invalid folders in storage failed");
-               }
 
                if (ret != MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
                        MS_DBG_INFO("working normally");
@@ -417,9 +412,9 @@ gboolean msc_storage_scan_thread(void *data)
 
                if (scan_type == MS_MSG_STORAGE_ALL) {
                        /* Delete all data before full scanning */
-                       if (!ms_delete_all_items(handle, storage_id, storage_type, scan_data->uid)) {
+                       if (!ms_delete_all_items(handle, storage_id, storage_type, scan_data->uid))
                                MS_DBG_ERR("msc_delete_all_record fails");
-                       }
+
                } else if (scan_type == MS_MSG_STORAGE_PARTIAL) {
                        ms_validaty_change_all_items(handle, storage_id, storage_type, false, scan_data->uid);
                }
@@ -430,23 +425,20 @@ gboolean msc_storage_scan_thread(void *data)
                ms_bacth_commit_disable(handle, TRUE, valid_status, scan_data->uid);
 
                if (scan_type == MS_MSG_STORAGE_PARTIAL && ret == MS_MEDIA_ERR_NONE) {
-                       if (!ms_delete_invalid_items(handle, storage_id, storage_type, scan_data->uid)) {
+                       if (!ms_delete_invalid_items(handle, storage_id, storage_type, scan_data->uid))
                                MS_DBG_ERR("deleting invalid items in storage failed");
-                       }
 
-                       if (ms_delete_invalid_folder(handle, storage_id, storage_type, scan_data->uid) != MS_MEDIA_ERR_NONE) {
+                       if (ms_delete_invalid_folder(handle, storage_id, storage_type, scan_data->uid) != MS_MEDIA_ERR_NONE)
                                MS_DBG_ERR("deleting invalid folders in storage failed");
-                       }
                }
 
                /* send notification */
                ms_send_dir_update_noti(handle, storage_id, update_path, NULL, MS_ITEM_UPDATE, scan_data->pid);
 
-               if (ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
+               if (ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP)
                        ms_set_db_status(MS_DB_STOPPED, storage_type);
-               } else {
+               else
                        ms_set_db_status(MS_DB_UPDATED, storage_type);
-               }
 
 NEXT:
                MS_SAFE_FREE(update_path);
@@ -481,13 +473,12 @@ static void __msc_insert_register_request(GArray *register_array, ms_comm_msg_s
 {
        MS_DBG_SLOG("path : %s", insert_data->msg);
 
-       if (insert_data->pid == POWEROFF) {
+       if (insert_data->pid == POWEROFF)
                g_array_prepend_val(register_array, insert_data);
-       } else if (insert_data->msg_type == MS_MSG_BURSTSHOT_INSERT) {
+       else if (insert_data->msg_type == MS_MSG_BURSTSHOT_INSERT)
                g_array_prepend_val(register_array, insert_data);
-       } else {
+       else
                g_array_append_val(register_array, insert_data);
-       }
 }
 
 static int __msc_clear_file_list(GArray *path_array)
@@ -785,9 +776,8 @@ static int __msc_dir_scan_meta_update(void **handle, const char*start_path, cons
 
        while (dir_array->len != 0) {
                ret = __msc_check_stop_status(storage_type);
-               if (ret != MS_MEDIA_ERR_NONE) {
+               if (ret != MS_MEDIA_ERR_NONE)
                        goto STOP_SCAN;
-               }
 
                current_path = g_array_index(dir_array , char*, 0);
                g_array_remove_index(dir_array, 0);
@@ -802,9 +792,8 @@ static int __msc_dir_scan_meta_update(void **handle, const char*start_path, cons
                if (error == NULL && dir != NULL) {
                        while ((name = g_dir_read_name(dir))) {
                                ret = __msc_check_stop_status(storage_type);
-                               if (ret != MS_MEDIA_ERR_NONE) {
+                               if (ret != MS_MEDIA_ERR_NONE)
                                        goto STOP_SCAN;
-                               }
 
                                if (name[0] == '.')
                                        continue;
@@ -1058,6 +1047,7 @@ int msc_remove_dir_scan_request(ms_comm_msg_s *recv_msg)
                /*create new queue to compare request*/
                msg = g_async_queue_pop(scan_queue);
                if ((strcmp(msg->msg, cancel_path) == 0) && (pid == msg->pid)) {
+                       MS_DBG("Find request. Remove it");
                        MS_SAFE_FREE(msg);
                } else {
                        g_async_queue_push(temp_scan_queue, GINT_TO_POINTER(msg));
index 8200e18..bbce2df 100755 (executable)
@@ -78,9 +78,8 @@ int main(int argc, char **argv)
        /* Create pipe */
        if (g_file_test(MS_SCANNER_FIFO_PATH_REQ, G_FILE_TEST_EXISTS)) {
                err = unlink(MS_SCANNER_FIFO_PATH_REQ);
-               if (err != 0) {
+               if (err != 0)
                        MS_DBG_STRERROR("unlink failed");
-               }
        }
 
        err = mkfifo(MS_SCANNER_FIFO_PATH_REQ, MS_SCANNER_FIFO_MODE);
index 42568cc..a4c8165 100755 (executable)
@@ -1,31 +1,31 @@
-/*\r
- *  Media Server\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#ifndef _MEDIA_SERVER_DB_MANAGER_H__\r
-#define _MEDIA_SERVER_DB_MANAGER_H__\r
-\r
-#include "media-common-types.h"\r
-\r
-int ms_reset_mediadb(uid_t uid);\r
-int ms_check_mediadb(uid_t uid, bool *is_reset);\r
-int ms_check_corrupt_mediadb(void);\r
-\r
-#endif\r
+/*
+ *  Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _MEDIA_SERVER_DB_MANAGER_H__
+#define _MEDIA_SERVER_DB_MANAGER_H__
+
+#include "media-common-types.h"
+
+int ms_reset_mediadb(uid_t uid);
+int ms_check_mediadb(uid_t uid, bool *is_reset);
+int ms_check_corrupt_mediadb(void);
+
+#endif
index 8f01033..1f90fec 100755 (executable)
@@ -34,4 +34,4 @@ void ms_device_block_changed_cb(usb_device_h usb_device, char *action, void *use
 #endif
 int ms_check_mounted_storage(uid_t uid);
 
-#endif
\ No newline at end of file
+#endif
index b591fda..6967af9 100755 (executable)
@@ -28,4 +28,4 @@ void ms_reset_scanner_status(void);
 int ms_get_scanner_pid(void);
 void ms_cleanup_scanner(void);
 
-#endif /*_MEDIA_SERVER_SCANNER_H*/
\ No newline at end of file
+#endif /*_MEDIA_SERVER_SCANNER_H*/
index afe6ba8..322941b 100755 (executable)
-/*\r
- * Media Server\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <errno.h>\r
-#include <sys/stat.h>\r
-#include <sqlite3.h>\r
-\r
-#include "media-util.h"\r
-#include "media-common-db-svc.h"\r
-#include "media-common-system.h"\r
-#include "media-common-utils.h"\r
-#include "media-server-ipc.h"\r
-#include "media-server-dbg.h"\r
-#include "media-server-scanner.h"\r
-#include "media-server-thumb.h"\r
-#include "media-server-db-manage.h"\r
-\r
-int ms_reset_mediadb(uid_t uid)\r
-{\r
-       MS_DBG_ERR("[MEDIA DB RESET START]");\r
-       int ret = MS_MEDIA_ERR_NONE;\r
-       char *command = "/bin/cp";\r
-       char *dummy_path = MS_DUMMY_MEDIA_DB_PATH;\r
-       char *db_path = NULL;\r
-\r
-       ret = ms_user_get_media_db_path(uid, &db_path);\r
-       if ((ret == MS_MEDIA_ERR_NONE) && (db_path != NULL)) {\r
-               char command_line[MS_FILE_PATH_LEN_MAX] = {0,};\r
-               snprintf(command_line, sizeof(command_line), "%s %s %s", command, dummy_path, db_path);\r
-\r
-               MS_DBG_ERR("[RESET COMMAND %s]", command_line);\r
-               WEXITSTATUS(system(command_line));\r
-       }\r
-\r
-       MS_SAFE_FREE(db_path);\r
-\r
-       MS_DBG_ERR("[MEDIA DB RESET END]");\r
-\r
-       return MS_MEDIA_ERR_NONE;\r
-}\r
-\r
-static int __ms_remake_mediadb(uid_t uid)\r
-{\r
-       int err = MS_MEDIA_ERR_NONE;\r
-       void **handle = NULL;\r
-\r
-       MS_DBG_ERR("THE SIZE OF MEDIA DB REACH THE LIMIT. RESET MEDIA DB.");\r
-\r
-       /*write read schema*/\r
-       /*load functions from plusin(s)*/\r
-       err = ms_load_functions();\r
-       if (err != MS_MEDIA_ERR_NONE) {\r
-               MS_DBG_ERR("function load failed [%d]", err);\r
-               return err;\r
-       }\r
-#ifdef _USE_TVPD_MODE\r
-       ms_config_set_int(MS_DB_RESET, 1);\r
-#endif\r
-       ms_reset_mediadb(uid);\r
-\r
-       ms_connect_db(&handle, uid);\r
-\r
-       MS_DBG_WARN("START WRITE SCHEMA");\r
-       if (ms_check_db_upgrade(handle, uid) != MS_MEDIA_ERR_NONE) {\r
-               MS_DBG_ERR("ms_check_db_upgrade fail");\r
-       }\r
-       MS_DBG_WARN("END WRITE SCHEMA");\r
-\r
-       /*disconnect form media db*/\r
-       if (handle) ms_disconnect_db(&handle);\r
-\r
-       /*unload functions*/\r
-       ms_unload_functions();\r
-\r
-#ifdef _USE_TVPD_MODE\r
-       ms_config_set_int(MS_DB_RESET, 0);\r
-#endif\r
-       return MS_MEDIA_ERR_NONE;\r
-}\r
-\r
-int ms_check_mediadb(uid_t uid, bool *is_reset)\r
-{\r
-       double db_size = 0.0;\r
-\r
-       ms_check_size_mediadb(uid, &db_size);\r
-\r
-       MS_DBG_WARN("[DB SIZE : %lf] [LIMIT1 : %lf] [LIMIT2 : %lf]", db_size, MEDIA_DB_SIZE_LIMIT_1, MEDIA_DB_SIZE_LIMIT_2);\r
-       if (db_size > MEDIA_DB_SIZE_LIMIT_2) {\r
-               MS_DBG_ERR("THE SIZE OF MEDIA DB REACH THE LIMIT. RESET MEDIA DB.");\r
-               MS_DBG_ERR("[DB SIZE : %lf] [LIMIT1 : %lf] [LIMIT2 : %lf]", db_size, MEDIA_DB_SIZE_LIMIT_1, MEDIA_DB_SIZE_LIMIT_2);\r
-               __ms_remake_mediadb(uid);\r
-               *is_reset = TRUE;\r
-       }\r
-\r
-       return MS_MEDIA_ERR_NONE;\r
-}\r
-\r
-int ms_check_corrupt_mediadb(void)\r
-{\r
-       MediaDBHandle *db_handle = NULL;\r
-       uid_t uid = MEDIA_DEFAULT_UID;\r
-\r
-       ms_sys_get_uid(&uid);\r
-\r
-       if (media_db_connect(&db_handle, uid, TRUE) != MS_MEDIA_ERR_NONE) {\r
-               MS_DBG_ERR("Failed to connect DB");\r
-               return MS_MEDIA_ERR_DB_CONNECT_FAIL;\r
-       }\r
-\r
-       /* Disconnect DB*/\r
-       media_db_disconnect(db_handle);\r
-\r
-       return MS_MEDIA_ERR_NONE;\r
-}\r
-\r
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <errno.h>
+#include <sys/stat.h>
+#include <sqlite3.h>
+
+#include "media-util.h"
+#include "media-common-db-svc.h"
+#include "media-common-system.h"
+#include "media-common-utils.h"
+#include "media-server-ipc.h"
+#include "media-server-dbg.h"
+#include "media-server-scanner.h"
+#include "media-server-thumb.h"
+#include "media-server-db-manage.h"
+
+int ms_reset_mediadb(uid_t uid)
+{
+       MS_DBG_ERR("[MEDIA DB RESET START]");
+       int ret = MS_MEDIA_ERR_NONE;
+       char *command = "/bin/cp";
+       char *dummy_path = MS_DUMMY_MEDIA_DB_PATH;
+       char *db_path = NULL;
+
+       ret = ms_user_get_media_db_path(uid, &db_path);
+       if ((ret == MS_MEDIA_ERR_NONE) && (db_path != NULL)) {
+               char command_line[MS_FILE_PATH_LEN_MAX] = {0,};
+               snprintf(command_line, sizeof(command_line), "%s %s %s", command, dummy_path, db_path);
+
+               MS_DBG_ERR("[RESET COMMAND %s]", command_line);
+               WEXITSTATUS(system(command_line));
+       }
+
+       MS_SAFE_FREE(db_path);
+
+       MS_DBG_ERR("[MEDIA DB RESET END]");
+
+       return MS_MEDIA_ERR_NONE;
+}
+
+static int __ms_remake_mediadb(uid_t uid)
+{
+       int err = MS_MEDIA_ERR_NONE;
+       void **handle = NULL;
+
+       MS_DBG_ERR("THE SIZE OF MEDIA DB REACH THE LIMIT. RESET MEDIA DB.");
+
+       /*write read schema*/
+       /*load functions from plusin(s)*/
+       err = ms_load_functions();
+       if (err != MS_MEDIA_ERR_NONE) {
+               MS_DBG_ERR("function load failed [%d]", err);
+               return err;
+       }
+#ifdef _USE_TVPD_MODE
+       ms_config_set_int(MS_DB_RESET, 1);
+#endif
+       ms_reset_mediadb(uid);
+
+       ms_connect_db(&handle, uid);
+
+       MS_DBG_WARN("START WRITE SCHEMA");
+       if (ms_check_db_upgrade(handle, uid) != MS_MEDIA_ERR_NONE)
+               MS_DBG_ERR("ms_check_db_upgrade fail");
+
+       MS_DBG_WARN("END WRITE SCHEMA");
+
+       /*disconnect form media db*/
+       if (handle) ms_disconnect_db(&handle);
+
+       /*unload functions*/
+       ms_unload_functions();
+
+#ifdef _USE_TVPD_MODE
+       ms_config_set_int(MS_DB_RESET, 0);
+#endif
+       return MS_MEDIA_ERR_NONE;
+}
+
+int ms_check_mediadb(uid_t uid, bool *is_reset)
+{
+       double db_size = 0.0;
+
+       ms_check_size_mediadb(uid, &db_size);
+
+       MS_DBG_WARN("[DB SIZE : %lf] [LIMIT1 : %lf] [LIMIT2 : %lf]", db_size, MEDIA_DB_SIZE_LIMIT_1, MEDIA_DB_SIZE_LIMIT_2);
+       if (db_size > MEDIA_DB_SIZE_LIMIT_2) {
+               MS_DBG_ERR("THE SIZE OF MEDIA DB REACH THE LIMIT. RESET MEDIA DB.");
+               MS_DBG_ERR("[DB SIZE : %lf] [LIMIT1 : %lf] [LIMIT2 : %lf]", db_size, MEDIA_DB_SIZE_LIMIT_1, MEDIA_DB_SIZE_LIMIT_2);
+               __ms_remake_mediadb(uid);
+               *is_reset = TRUE;
+       }
+
+       return MS_MEDIA_ERR_NONE;
+}
+
+int ms_check_corrupt_mediadb(void)
+{
+       MediaDBHandle *db_handle = NULL;
+       uid_t uid = MEDIA_DEFAULT_UID;
+
+       ms_sys_get_uid(&uid);
+
+       if (media_db_connect(&db_handle, uid, TRUE) != MS_MEDIA_ERR_NONE) {
+               MS_DBG_ERR("Failed to connect DB");
+               return MS_MEDIA_ERR_DB_CONNECT_FAIL;
+       }
+
+       /* Disconnect DB*/
+       media_db_disconnect(db_handle);
+
+       return MS_MEDIA_ERR_NONE;
+}
+
index 2001bec..e59b7d1 100755 (executable)
@@ -101,9 +101,8 @@ int ms_usb_insert_handler(const char *mount_path, const char *mount_uuid)
 
                        scan_type = MS_SCAN_PART;
                        ms_set_storage_validity(handle, mount_uuid, 1, uid);
-                       if (ms_set_storage_scan_status(handle, uuid, MEDIA_SCAN_PREPARE, uid) != MS_MEDIA_ERR_NONE) {
+                       if (ms_set_storage_scan_status(handle, uuid, MEDIA_SCAN_PREPARE, uid) != MS_MEDIA_ERR_NONE)
                                MS_DBG_ERR("ms_set_storage_scan_status failed");
-                       }
 
                        MS_DBG_WARN("init storage data in DB");
                        /* update storage_id table set validity=0 first */
@@ -202,9 +201,8 @@ static int __ms_get_mmc_info(void **handle, char **storage_name, char **storage_
        int ret = MS_MEDIA_ERR_NONE;
 
        ret = ms_get_mmc_info(handle, storage_name, storage_path, validity, info_exist);
-       if (ret != MS_MEDIA_ERR_NONE) {
+       if (ret != MS_MEDIA_ERR_NONE)
                MS_DBG_ERR("[No-Error] ms_get_mmc_info failed. Maybe storage info not in media db [%d]", ret);
-       }
 
        return ret;
 }
@@ -233,9 +231,8 @@ static int __ms_update_mmc_info(void **handle, const char *new_storage_name, con
        ms_sys_get_uid(&uid);
 
        ret = ms_delete_storage(handle, MMC_STORAGE_ID, uid);
-       if (ret != MS_MEDIA_ERR_NONE) {
+       if (ret != MS_MEDIA_ERR_NONE)
                MS_DBG_ERR("ms_delete_storage failed [%d]", ret);
-       }
 
        ret = ms_insert_storage(handle, MMC_STORAGE_ID, new_storage_name, new_storage_path, uid);
        if (ret != MS_MEDIA_ERR_NONE) {
@@ -446,9 +443,8 @@ static void __ms_usb_add_event(const char *mount_path)
                                }
                                scan_type = MS_SCAN_PART;
                                ms_set_storage_validity(handle, storage_id, 1, uid);
-                               if (ms_set_storage_scan_status(handle, storage_id, MEDIA_SCAN_PREPARE, uid) != MS_MEDIA_ERR_NONE) {
+                               if (ms_set_storage_scan_status(handle, storage_id, MEDIA_SCAN_PREPARE, uid) != MS_MEDIA_ERR_NONE)
                                        MS_DBG_ERR("ms_set_storage_scan_status failed");
-                               }
                        } else {
                                /* there is no information of this storage in Media DB */
                                ret = ms_insert_storage(handle, storage_id, NULL, mount_path, uid);
@@ -505,9 +501,8 @@ static void __ms_usb_remove_event(const char *mount_path)
                                ms_set_storage_validity(handle, device_id, 0, uid);
 
                                /* folder validity set 0 under the start_path in folder table*/
-                               if (ms_set_folder_validity(handle, device_id, mount_path, MS_INVALID, TRUE, uid) != MS_MEDIA_ERR_NONE) {
+                               if (ms_set_folder_validity(handle, device_id, mount_path, MS_INVALID, TRUE, uid) != MS_MEDIA_ERR_NONE)
                                        MS_DBG_ERR("set_folder_validity failed");
-                               }
 
                                if (ms_get_scanner_status()) {
                                        /*If the media scanner is running, the removed USB can be queueing in the job list.*/
@@ -557,16 +552,15 @@ void ms_device_block_changed_cb(usb_device_h usb_device, char *action, void *use
        } else if (!strcmp(action, "blocked")) { /*unmount->blocked stop accessing usb in time*/
                MS_DBG_WARN("USB blocked, mountpath : %s", mount_path);
                ms_check_mediadb(uid, &is_reset);
-               if (!is_reset) {
+               if (!is_reset)
                        __ms_usb_remove_event(mount_path);
-               }
        }
 
        free_usb_device_h(usb_device);
 
-       if (is_reset) {
+       if (is_reset)
                ms_check_mounted_storage(uid);
-       }
+
        MS_DBG_WARN("usb_event_callback END[%s]", action);
 }
 
@@ -582,9 +576,8 @@ static int __ms_check_mounted_storage_list(GArray **added_list)
 
        err = usb_device_get_device_list(USB_MASS_STORAGE, &list);
        if (err == 0) {
-               if (*added_list == NULL) {
+               if (*added_list == NULL)
                        *added_list = g_array_new(FALSE, FALSE, sizeof(char*));
-               }
 
                count = usb_device_list_get_count(list);
                if (count > 0) {
@@ -652,9 +645,8 @@ int ms_check_mounted_storage(uid_t uid)
 #else
        ret = __ms_check_mounted_storage_list(&added_list);
 #endif
-       if (ret != MS_MEDIA_ERR_NONE) {
+       if (ret != MS_MEDIA_ERR_NONE)
                MS_DBG_ERR("__ms_check_mounted_storage_list failed");
-       }
 
        if (added_list != NULL) {
                count = added_list->len;
@@ -726,9 +718,8 @@ int ms_check_mounted_storage(uid_t uid)
 
                        /* request to update media db */
                        ret = ms_insert_folder(handle, storage_id, mounted_path, uid);
-                       if (ret != MS_MEDIA_ERR_NONE) {
+                       if (ret != MS_MEDIA_ERR_NONE)
                                MS_DBG_ERR("error : ms_insert_folder failed");
-                       }
 
                        ms_send_storage_otg_scan_request(mounted_path, storage_id, scan_type, uid);
                        MS_SAFE_FREE(storage_id);
index b46a38b..c5286fd 100755 (executable)
@@ -109,9 +109,8 @@ void _ms_smarthub_vconf_cb(void *data)
        uid_t uid = MEDIA_DEFAULT_UID;
 
        if (power_off == FALSE) {
-               if (!ms_config_get_int(SMARTHUB_RESET_VCONF, &status)) {
+               if (!ms_config_get_int(SMARTHUB_RESET_VCONF, &status))
                        MS_DBG_ERR("Get VCONFKEY_SYSMAN_MMC_STATUS failed.");
-               }
 
                MS_DBG_ERR("CURRENT STATUS OF SMARTHUB_RESET_VCONF[%d]", status);
 
@@ -286,15 +285,13 @@ void _power_off_cb(ms_power_info_s *power_info, void* data)
 
        /*Quit Thumbnail Thread*/
        GMainLoop *thumb_mainloop = ms_get_thumb_thread_mainloop();
-       if (thumb_mainloop && g_main_is_running(thumb_mainloop)) {
+       if (thumb_mainloop && g_main_is_running(thumb_mainloop))
                g_main_loop_quit(thumb_mainloop);
-       }
 
        /*Quit DB Thread*/
        GMainLoop *db_mainloop = ms_db_get_mainloop();
-       if (db_mainloop && g_main_loop_is_running(db_mainloop)) {
+       if (db_mainloop && g_main_loop_is_running(db_mainloop))
                g_main_loop_quit(db_mainloop);
-       }
 
        __ms_remove_request_receiver(channel);
 
@@ -590,9 +587,8 @@ static void __ms_remove_request_receiver(GIOChannel *channel)
        g_io_channel_unref(channel);
 
        if (fd > 0) {
-               if (close(fd) < 0) {
+               if (close(fd) < 0)
                        MS_DBG_STRERROR("CLOSE ERROR");
-               }
        }
 }
 #endif
@@ -607,9 +603,8 @@ static void __ms_add_signal_handler(void)
        sigset.sa_flags = SA_RESTART |SA_NODEFER;
        sigset.sa_handler = _ms_signal_handler;
 
-       if (sigaction(SIGCHLD, &sigset, NULL) < 0) {
+       if (sigaction(SIGCHLD, &sigset, NULL) < 0)
                MS_DBG_STRERROR("sigaction failed");
-       }
 
        signal(SIGPIPE, SIG_IGN);
 }
@@ -808,9 +803,8 @@ static void __ms_check_mediadb(void)
                MS_DBG_ERR("ms_set_all_storage_validity fail");
 
 #ifdef _USE_SENIOR_MODE
-       if (ms_is_support_senior_mode()) {
+       if (ms_is_support_senior_mode())
                ms_send_storage_scan_request_senior_mode(db_handle);
-       }
 #endif
 
        ms_disconnect_db(&db_handle);
index 56fa6e2..4f64a27 100755 (executable)
@@ -74,16 +74,14 @@ ms_db_status_type_t ms_check_scanning_status(void)
        int status;
 
        if (ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &status)) {
-               if (status == VCONFKEY_FILEMANAGER_DB_UPDATING) {
+               if (status == VCONFKEY_FILEMANAGER_DB_UPDATING)
                        return MS_DB_UPDATING;
-               }
        }
 #ifdef _USE_TVPD_MODE
        if (ms_config_get_int(VCONFKEY_PRIVATE_EXTRACTSTATUS, &status)) {
                MS_DBG("extract status %d", status);
-               if (status == MS_DB_UPDATING) {
+               if (status == MS_DB_UPDATING)
                        return MS_DB_UPDATING;
-               }
        }
 #endif
        return MS_DB_UPDATED;
@@ -138,9 +136,9 @@ static gboolean _ms_stop_scanner(gpointer user_data)
 
        /* stop media scanner */
        if (child_pid > 0) {
-               if (kill(child_pid, SIGKILL) < 0) {
+               if (kill(child_pid, SIGKILL) < 0)
                        MS_DBG_ERR("kill failed[%d]", child_pid);
-               }
+
                MS_DBG_INFO("KILL SCANNER");
        } else {
                MS_DBG_ERR("SCANNER IS ALREADY DEAD");
@@ -236,9 +234,8 @@ int ms_scanner_start(void)
 
                if (g_file_test(MS_SCANNER_FIFO_PATH_RES, G_FILE_TEST_EXISTS)) {
                        err = unlink(MS_SCANNER_FIFO_PATH_RES);
-                       if (err != 0) {
+                       if (err != 0)
                                MS_DBG_STRERROR("unlink failed");
-                       }
                }
 
                err = mkfifo(MS_SCANNER_FIFO_PATH_RES, MS_SCANNER_FIFO_MODE);
index c25ccb0..8b51857 100755 (executable)
@@ -257,9 +257,9 @@ static int __ms_recovery_media_db(uid_t uid)
        ms_connect_db(&handle, uid);
 
        MS_DBG_WARN("START WRITE SCHEMA");
-       if (ms_check_db_upgrade(handle, uid) != MS_MEDIA_ERR_NONE) {
+       if (ms_check_db_upgrade(handle, uid) != MS_MEDIA_ERR_NONE)
                MS_DBG_ERR("ms_check_db_upgrade fail");
-       }
+
        MS_DBG_WARN("END WRITE SCHEMA");
 
        /*disconnect form media db*/
@@ -295,9 +295,8 @@ gboolean ms_read_socket(gpointer user_data)
 
        /* get client socket fd */
        ret = ms_ipc_accept_client_tcp(sockfd, &client_sock);
-       if (ret != MS_MEDIA_ERR_NONE) {
+       if (ret != MS_MEDIA_ERR_NONE)
                return TRUE;
-       }
 
        memset(&creds, 0, sizeof(creds));
 
@@ -434,9 +433,8 @@ int ms_send_scan_request(ms_comm_msg_s *send_msg, int client_sock)
                err = ms_scanner_start();
                if (err == MS_MEDIA_ERR_NONE) {
                        err = __ms_send_request(send_msg);
-                       if (err != MS_MEDIA_ERR_NONE) {
+                       if (err != MS_MEDIA_ERR_NONE)
                                MS_DBG_ERR("__ms_send_request failed [%d]", err);
-                       }
                } else {
                        MS_DBG_ERR("Scanner starting failed [%d]", err);
                        res = err;
@@ -499,9 +497,8 @@ int ms_send_storage_scan_request(const char *root_path, const char *storage_id,
                SAFE_STRLCPY(scan_msg.msg, root_path, sizeof(scan_msg.msg));
        }
 
-       if (storage_id != NULL) {
+       if (storage_id != NULL)
                SAFE_STRLCPY(scan_msg.storage_id, storage_id, sizeof(scan_msg.storage_id));
-       }
 
        scan_msg.uid = uid;
 
@@ -565,9 +562,8 @@ int ms_send_storage_scan_request_senior_mode(void **handle)
 
        /* request to update media db */
        ret = ms_insert_folder(handle, storage_id, path, uid);
-       if (ret != MS_MEDIA_ERR_NONE) {
+       if (ret != MS_MEDIA_ERR_NONE)
                MS_DBG_ERR("##[senior mode]error : ms_insert_folder failed");
-       }
 
        ms_send_storage_otg_scan_request(path, storage_id, scan_type, uid);
        MS_SAFE_FREE(storage_id);
@@ -600,9 +596,8 @@ gboolean ms_read_db_tcp_socket(GIOChannel *src, GIOCondition condition, gpointer
 
        /* get client socket fd */
        ret = ms_ipc_accept_client_tcp(sock, &client_sock);
-       if (ret != MS_MEDIA_ERR_NONE) {
+       if (ret != MS_MEDIA_ERR_NONE)
                return TRUE;
-       }
 
        memset(&creds, 0, sizeof(creds));
 
@@ -646,15 +641,13 @@ gboolean ms_read_db_tcp_socket(GIOChannel *src, GIOCondition condition, gpointer
        media_db_disconnect(db_handle);
 
 ERROR:
-       if (write(client_sock, &send_msg, sizeof(send_msg)) != sizeof(send_msg)) {
+       if (write(client_sock, &send_msg, sizeof(send_msg)) != sizeof(send_msg))
                MS_DBG_STRERROR("send failed");
-       } else {
+       else
                MS_DBG("Sent successfully");
-       }
 
-       if (close(client_sock) < 0) {
+       if (close(client_sock) < 0)
                MS_DBG_STRERROR("close failed");
-       }
 
        return TRUE;
 }
@@ -701,22 +694,18 @@ void _ms_process_tcp_message(gpointer data, gpointer user_data)
 
                sql_query = strndup(recv_msg.msg, recv_msg.msg_size);
                if (sql_query != NULL) {
-                       if (recv_msg.msg_type == MS_MSG_DB_UPDATE_BATCH_START) {
+                       if (recv_msg.msg_type == MS_MSG_DB_UPDATE_BATCH_START)
                                ret = media_db_update_db_batch_start(sql_query);
-                       } else if (recv_msg.msg_type == MS_MSG_DB_UPDATE_BATCH_END) {
+                       else if (recv_msg.msg_type == MS_MSG_DB_UPDATE_BATCH_END)
                                ret = media_db_update_db_batch_end(db_handle, sql_query);
-                       } else if (recv_msg.msg_type == MS_MSG_DB_UPDATE_BATCH) {
+                       else if (recv_msg.msg_type == MS_MSG_DB_UPDATE_BATCH)
                                ret = media_db_update_db_batch(sql_query);
-                       } else {
-
-                       }
 
                        MS_SAFE_FREE(sql_query);
                        send_msg = ret;
 
-                       if (write(client_sock, &send_msg, sizeof(send_msg)) != sizeof(send_msg)) {
+                       if (write(client_sock, &send_msg, sizeof(send_msg)) != sizeof(send_msg))
                                MS_DBG_STRERROR("send failed");
-                       }
 
                        if (recv_msg.msg_type == MS_MSG_DB_UPDATE_BATCH_END) {
                                MS_DBG_WARN("Batch job is successfull!client sockfd [%d]", client_sock);
@@ -739,9 +728,8 @@ void _ms_process_tcp_message(gpointer data, gpointer user_data)
                }
        }
 
-       if (close(client_sock) < 0) {
+       if (close(client_sock) < 0)
                MS_DBG_STRERROR("close failed");
-       }
 
        /* Disconnect DB*/
        media_db_disconnect(db_handle);
@@ -754,15 +742,13 @@ void _ms_process_tcp_message(gpointer data, gpointer user_data)
 ERROR:
 
        /* send error to client */
-       if (write(client_sock, &send_msg, sizeof(send_msg)) != sizeof(send_msg)) {
+       if (write(client_sock, &send_msg, sizeof(send_msg)) != sizeof(send_msg))
                MS_DBG_STRERROR("send failed");
-       } else {
+       else
                MS_DBG("Sent successfully");
-       }
 
-       if (close(client_sock) < 0) {
+       if (close(client_sock) < 0)
                MS_DBG_STRERROR("close failed");
-       }
 
        /* Disconnect DB*/
        media_db_disconnect(db_handle);
@@ -838,15 +824,13 @@ ERROR:
 
                /* send error to clinet*/
                send_msg = res;
-               if (write(client_sock, &send_msg, sizeof(send_msg)) != sizeof(send_msg)) {
+               if (write(client_sock, &send_msg, sizeof(send_msg)) != sizeof(send_msg))
                        MS_DBG_STRERROR("send failed");
-               } else {
+               else
                        MS_DBG("Sent successfully");
-               }
 
-               if (close(client_sock) < 0) {
+               if (close(client_sock) < 0)
                        MS_DBG_STRERROR("close failed");
-               }
        }
 
        return TRUE;
@@ -894,11 +878,10 @@ gboolean ms_receive_message_from_scanner(GIOChannel *src, GIOCondition condition
                        MS_DBG_WARN("ms_req_num-- [%d]", ms_req_num);
                }
 
-               if (pid != 0) {
+               if (pid != 0)
                        __ms_send_result_to_client(pid, &recv_msg);
-               } else {
+               else
                        MS_DBG_SLOG("This request is from media-server");
-               }
        } else {
                MS_DBG_ERR("This result message is wrong : %d", recv_msg.msg_type);
        }
index 33eb141..b69ab90 100755 (executable)
@@ -213,9 +213,9 @@ int _ms_thumb_recv_msg(int sock, thumbMsg *msg)
        }
 
        while (remain_size > 0) {
-               if (remain_size < MS_SOCK_BLOCK_SIZE) {
+               if (remain_size < MS_SOCK_BLOCK_SIZE)
                        block_size = remain_size;
-               }
+
                if ((recv_msg_len = recv(sock, block_buf, block_size, 0)) < 0) {
                        MS_DBG_STRERROR("recv failed");
                        MS_SAFE_FREE(buf);
@@ -340,9 +340,8 @@ gboolean _ms_thumb_agent_recv_msg_from_server()
        }
 
        //MS_DBG("Receive : %d(%d)", recv_msg.msg_type, recv_msg_size);
-       if (recv_msg.msg_type == MS_MSG_THUMB_SERVER_READY) {
+       if (recv_msg.msg_type == MS_MSG_THUMB_SERVER_READY)
                MS_DBG("Thumbnail server is ready");
-       }
 
        close(sockfd);
        return TRUE;
@@ -548,11 +547,10 @@ gboolean _ms_thumb_request_to_server(gpointer data)
                        unsigned char *buf = NULL;
                        _ms_thumb_set_buffer(&res_msg, &buf, &buf_size);
 
-                       if (send(client_sock, buf, buf_size, 0) != buf_size) {
+                       if (send(client_sock, buf, buf_size, 0) != buf_size)
                                MS_DBG_STRERROR("sendto failed");
-                       } else {
+                       else
                                MS_DBG("Sent Refuse msg from %s", recv_msg->org_path);
-                       }
 
                        close(client_sock);
 
@@ -577,21 +575,20 @@ gboolean _ms_thumb_request_to_server(gpointer data)
        _ms_thumb_set_buffer(&res_msg, &buf, &buf_size);
 
        while (buf_size > 0) {
-               if (buf_size < MS_SOCK_BLOCK_SIZE) {
+               if (buf_size < MS_SOCK_BLOCK_SIZE)
                        block_size = buf_size;
-               }
-               if (send(client_sock, buf+sending_block, block_size, 0) != block_size) {
+
+               if (send(client_sock, buf+sending_block, block_size, 0) != block_size)
                        MS_DBG_STRERROR("sendto failed");
-               }
+
                sending_block += block_size;
                buf_size -= block_size;
-               if (block_size < MS_SOCK_BLOCK_SIZE) {
+               if (block_size < MS_SOCK_BLOCK_SIZE)
                        block_size = MS_SOCK_BLOCK_SIZE;
-               }
        }
-       if (buf_size == 0) {
+
+       if (buf_size == 0)
                MS_DBG_SLOG("Sent data(%d) from %s", res_msg.thumb_size, res_msg.org_path);
-       }
 
        close(client_sock);
        MS_SAFE_FREE(buf);
@@ -677,11 +674,10 @@ gboolean _ms_thumb_agent_read_socket(GIOChannel *src,
                int buf_size = 0;
                _ms_thumb_set_buffer(&res_msg, &buf, &buf_size);
 
-               if (send(client_sock, buf, buf_size, 0) != buf_size) {
+               if (send(client_sock, buf, buf_size, 0) != buf_size)
                        MS_DBG_STRERROR("sendto failed");
-               } else {
+               else
                        MS_DBG("Sent Refuse msg from %s", recv_msg->org_path);
-               }
 
                close(client_sock);
                MS_SAFE_FREE(buf);
@@ -736,11 +732,10 @@ gpointer ms_thumb_agent_start_thread(gpointer data)
 
        context = g_main_context_new();
 
-       if (context == NULL) {
+       if (context == NULL)
                MS_DBG_ERR("g_main_context_new failed");
-       } else {
+       else
                MS_DBG("g_main_context_new success");
-       }
 
        g_thumb_agent_loop = g_main_loop_new(context, FALSE);
        g_main_context_push_thread_default(context);