fix send notifiacation noti type 56/166056/1 accepted/tizen/4.0/unified/20180111.051058 submit/tizen_4.0/20180108.083113
authorchen89.chen <chen89.chen@samsung.com>
Fri, 5 Jan 2018 08:43:55 +0000 (16:43 +0800)
committerJiyong Min <jiyong.min@samsung.com>
Fri, 5 Jan 2018 09:59:21 +0000 (09:59 +0000)
Change-Id: I6a11a1e69c88fd395c4dafc124d6030f17198a59

lib/include/media-server-ipc.h
src/scanner-v2/include/media-scanner-extract-v2.h
src/scanner-v2/media-scanner-extract-v2.c
src/scanner-v2/media-scanner-scan-v2.c

index 854dbc9..3990584 100755 (executable)
@@ -87,6 +87,7 @@ typedef struct {
        size_t msg_size; /*this is size of message below and this does not include the terminationg null byte ('\0'). */
        char storage_id[MS_UUID_SIZE];
        char msg[MAX_MSG_SIZE];
+       int noti_type;
 } ms_comm_msg_s;
 
 typedef struct {
index 0ec2a3d..b4e8f61 100755 (executable)
@@ -37,7 +37,7 @@ int msc_init_extract_thread();
 int msc_deinit_extract_thread();
 gboolean msc_folder_extract_thread(void *data);
 gboolean msc_storage_extract_thread(void *data);
-void msc_insert_exactor_request(int message_type, bool ins_status, const char *storage_id, const char *path, int pid, uid_t uid);
+void msc_insert_exactor_request(int message_type, bool ins_status, const char *storage_id, const char *path, int pid, uid_t uid, ms_noti_type_e noti_type);
 int msc_remove_extract_request(const ms_comm_msg_s *recv_msg);
 
 int _msc_set_extract_item(s_extract_item** item, const char* path, int pid);
index 0934f2e..c4704ac 100755 (executable)
@@ -187,6 +187,7 @@ gboolean msc_folder_extract_thread(void *data)
        uid_t uid = MEDIA_DEFAULT_UID;
        int disc_state = 0;
        int end_flag = NORMAL_EVENT;
+       ms_noti_type_e noti_type = MS_ITEM_INSERT;
 
        while (1) {
                extract_data = g_async_queue_pop(folder_extract_queue);
@@ -211,6 +212,7 @@ gboolean msc_folder_extract_thread(void *data)
                }
 
                scan_type = extract_data->msg_type;
+               noti_type = extract_data->noti_type;
 
                storage_id = strdup(extract_data->storage_id);
                if (storage_id == NULL) {
@@ -276,7 +278,7 @@ NEXT:
                        /*send notification*/
                        char *folder_uuid = NULL;
                        ms_get_folder_id(handle, storage_id, extract_data->msg, &folder_uuid);
-                       ms_send_dir_update_noti(handle, storage_id, update_path, folder_uuid, MS_ITEM_UPDATE, extract_data->pid);
+                       ms_send_dir_update_noti(handle, storage_id, update_path, folder_uuid, noti_type, extract_data->pid);
                        extract_data->msg_type = MS_MSG_EXTRACTOR_COMPLETE;
                        msc_send_result(ret, extract_data);
                }
@@ -493,7 +495,7 @@ _POWEROFF:
        return false;
 }
 
-void msc_insert_exactor_request(int message_type, bool ins_status, const char *storage_id, const char *path, int pid, uid_t uid)
+void msc_insert_exactor_request(int message_type, bool ins_status, const char *storage_id, const char *path, int pid, uid_t uid, ms_noti_type_e noti_type)
 {
        ms_comm_msg_s *extract_data = NULL;
        MS_MALLOC(extract_data, sizeof(ms_comm_msg_s));
@@ -507,6 +509,7 @@ void msc_insert_exactor_request(int message_type, bool ins_status, const char *s
        extract_data->uid = uid;
        extract_data->result = ins_status;
        extract_data->msg_size = strlen(path);
+       extract_data->noti_type = noti_type;
        SAFE_STRLCPY(extract_data->msg, path, sizeof(extract_data->msg));
        SAFE_STRLCPY(extract_data->storage_id, storage_id, sizeof(extract_data->storage_id));
 
index 7058645..75e3943 100755 (executable)
@@ -489,7 +489,7 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
                                                        //MS_DBG_ERR("storage_id = [%s]", storage_id);
                                                        ret = __msc_check_stop_status(scan_type, storage_type, new_start_path, pid);
                                                        if (ret == MS_MEDIA_ERR_NONE) {
-                                                               msc_insert_exactor_request(scan_type, FALSE, storage_id, current_path, pid, uid);
+                                                               msc_insert_exactor_request(scan_type, FALSE, storage_id, current_path, pid, uid, MS_ITEM_UPDATE);
                                                        } else {
                                                                if (is_recursive == true)
                                                                        ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
@@ -786,7 +786,7 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
                                                if (scan_count >= MAX_SCAN_COUNT) {
                                                        scan_count = 0;
                                                        //MS_DBG_ERR("storage_id = [%s]", storage_id);
-                                                       msc_insert_exactor_request(scan_type, FALSE, storage_id, current_path, 0, uid);
+                                                       msc_insert_exactor_request(scan_type, FALSE, storage_id, current_path, 0, uid, MS_ITEM_UPDATE);
                                                }
                                        }
                                } else if (d->d_type == DT_DIR) {
@@ -1070,6 +1070,7 @@ gboolean msc_directory_scan_thread(void *data)
        int index = 0;
        ms_user_storage_type_e storage_type = MS_STORAGE_INTERNAL;
        ms_dir_scan_status_e scan_status = MS_DIR_SCAN_NONE;
+       ms_noti_type_e noti_type = MS_ITEM_INSERT;
        char *folder_uuid = NULL;
        uid_t uid = MEDIA_DEFAULT_UID;
 
@@ -1137,12 +1138,15 @@ gboolean msc_directory_scan_thread(void *data)
                if (g_file_test(scan_data->msg, G_FILE_TEST_IS_DIR)) {
                        if (ms_check_folder_exist(handle, storage_id, scan_data->msg) == MS_MEDIA_ERR_NONE) {
                                /*already exist in media DB*/
+                               noti_type = MS_ITEM_UPDATE;
                                MS_DBG_WARN("[%s] already exist", scan_data->msg);
                        } else {
+                               noti_type = MS_ITEM_INSERT;
                                MS_DBG_WARN("[%s] new insert path", scan_data->msg);
                        }
                } else {
                        /*directory is deleted*/
+                       noti_type = MS_ITEM_DELETE;
                        scan_type = MS_MSG_DIRECTORY_SCANNING;
                        scan_data->msg_type = MS_MSG_DIRECTORY_SCANNING;
 
@@ -1269,14 +1273,13 @@ gboolean msc_directory_scan_thread(void *data)
                        MS_DBG_ERR("deleting invalid folders in storage failed");
 
                /*if (ret != MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
-                       MS_DBG_INFO("working normally");
                        ms_send_dir_update_noti(handle, storage_id, scan_data->msg, folder_uuid, noti_type, scan_data->pid);
                }*/
 
 SCAN_DONE:
                MS_DBG_WARN("storage_id = [%s], dir Path = [%s], pid = [%d]", storage_id, scan_data->msg, scan_data->pid);
                if (ret != MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
-                       msc_insert_exactor_request(scan_data->msg_type, TRUE, scan_data->storage_id, scan_data->msg, scan_data->pid, uid);
+                       msc_insert_exactor_request(scan_data->msg_type, TRUE, scan_data->storage_id, scan_data->msg, scan_data->pid, uid, noti_type);
                }
                if (power_off2) {
                        MS_DBG_ERR("power off");
@@ -1399,7 +1402,7 @@ gboolean msc_storage_scan_thread(void *data)
                if (ret != MS_MEDIA_ERR_NONE) {
                        ms_set_storage_scan_status(handle, scan_data->storage_id, MEDIA_SCAN_STOP, uid);
                        MS_DBG_ERR("storage_id = [%s]", scan_data->storage_id);
-                       msc_insert_exactor_request(scan_type, TRUE, scan_data->storage_id, scan_data->msg, scan_data->pid, uid);
+                       msc_insert_exactor_request(scan_type, TRUE, scan_data->storage_id, scan_data->msg, scan_data->pid, uid, MS_ITEM_UPDATE);
                        goto NEXT;
                }
 
@@ -1447,7 +1450,7 @@ gboolean msc_storage_scan_thread(void *data)
                }
 
                MS_DBG_WARN("storage_id = [%s]", scan_data->storage_id);
-               msc_insert_exactor_request(scan_type, TRUE, scan_data->storage_id, scan_data->msg, scan_data->pid, uid);
+               msc_insert_exactor_request(scan_type, TRUE, scan_data->storage_id, scan_data->msg, scan_data->pid, uid, MS_ITEM_UPDATE);
 
 NEXT:
                msc_del_blocked_path();