Add new functions to handle power off event 15/239615/7
authorhj kim <backto.kim@samsung.com>
Tue, 28 Jul 2020 07:29:59 +0000 (16:29 +0900)
committerhj kim <backto.kim@samsung.com>
Wed, 29 Jul 2020 01:52:37 +0000 (10:52 +0900)
And remove unnecessary "extern" and add static keyoword

Change-Id: I987810a424365bbc7d238610e123e929c658787b

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

index d1a6b1a..19f1382 100755 (executable)
@@ -41,6 +41,7 @@ void msc_insert_exactor_request(int message_type, bool ins_status, const char *s
 int msc_remove_extract_request(const ms_comm_msg_s *recv_msg);
 int msc_set_cancel_extract_item(const char* path, int pid);
 void msc_set_extract_blocked_path(const char *blocked_path);
+void msc_send_power_off_request_to_extractor(void);
 void msc_remove_folder_extract_request(ms_comm_msg_s *recv_msg);
 
 #endif /*_MEDIA_SCANNER_EXTRACT_V2_H_*/
index c1efe85..00586cc 100755 (executable)
@@ -46,6 +46,7 @@ void msc_set_blocked_path(const char *blocked_path);
 void msc_init_scanner(void);
 void msc_deinit_scanner(void);
 int msc_push_scan_request(ms_scan_type_e scan_type, ms_comm_msg_s *recv_msg);
+void msc_send_power_off_request(void);
 void msc_remove_dir_scan_request(ms_comm_msg_s *recv_msg);
 
 #endif /*_MEDIA_SCANNER_SCAN_V2_H_*/
index 2ed63f2..7aefbd4 100644 (file)
@@ -42,7 +42,7 @@
 #include "media-scanner-extract-v2.h"
 
 GAsyncQueue *storage_extract_queue;
-GAsyncQueue *folder_extract_queue;
+static GAsyncQueue *folder_extract_queue;
 static GMutex extract_req_mutex;
 static GMutex extract_blocked_mutex;
 static char *g_extract_blocked_path;
@@ -746,6 +746,25 @@ static int __msc_extract_set_db_status(ms_db_status_type_t status)
        return res;
 }
 
+void msc_send_power_off_request_to_extractor(void)
+{
+       ms_comm_msg_s *data = NULL;
+
+       if (storage_extract_queue) {
+               data = g_new0(ms_comm_msg_s, 1);
+
+               data->pid = POWEROFF;
+               g_async_queue_push(storage_extract_queue, data);
+       }
+
+       if (folder_extract_queue) {
+               data = g_new0(ms_comm_msg_s, 1);
+
+               data->pid = POWEROFF;
+               g_async_queue_push(folder_extract_queue, data);
+       }
+}
+
 void msc_remove_folder_extract_request(ms_comm_msg_s *recv_msg)
 {
        int i = 0;
index 1b2d758..287b37d 100644 (file)
@@ -51,8 +51,8 @@
 #define DIR_SCAN_NON_RECURSIVE 2
 
 GAsyncQueue *storage_queue2;
-GAsyncQueue *scan_queue2;
-GAsyncQueue *reg_queue2;
+static GAsyncQueue *scan_queue2;
+static GAsyncQueue *reg_queue2;
 static GMutex scan_req_mutex2;
 static GMutex blocked_mutex2;
 static GMutex storage_scan_mutex2;
@@ -1708,6 +1708,32 @@ int msc_push_scan_request(ms_scan_type_e scan_type, ms_comm_msg_s *recv_msg)
        return ret;
 }
 
+void msc_send_power_off_request(void)
+{
+       ms_comm_msg_s *data = NULL;
+
+       if (scan_queue2) {
+               data = g_new0(ms_comm_msg_s, 1);
+
+               data->pid = POWEROFF;
+               msc_push_scan_request(MS_SCAN_DIRECTORY, data);
+       }
+
+       if (reg_queue2) {
+               data = g_new0(ms_comm_msg_s, 1);
+
+               data->pid = POWEROFF;
+               msc_push_scan_request(MS_SCAN_REGISTER, data);
+       }
+
+       if (storage_queue2) {
+               data = g_new0(ms_comm_msg_s, 1);
+
+               data->pid = POWEROFF;
+               msc_push_scan_request(MS_SCAN_STORAGE, data);
+       }
+}
+
 void msc_remove_dir_scan_request(ms_comm_msg_s *recv_msg)
 {
        char *cancel_path = recv_msg->msg;
index 9323cc6..b025655 100644 (file)
 
 #define MSC_VCONF_KEY_SCANNER_POWEROFF_STATUS "db/mediascanner/poweroff_status"
 
-extern GAsyncQueue *storage_queue2;
-extern GAsyncQueue *scan_queue2;
-extern GAsyncQueue *reg_queue2;
-extern GAsyncQueue *storage_extract_queue;
-extern GAsyncQueue *folder_extract_queue;
-
 static GMainLoop *scanner_mainloop2 = NULL;
 static guint scanner_source_id2;
 
 static void __msc_add_event_receiver(void *data);
 static void __msc_remove_event_receiver(void);
 
-static void __push_power_off(GAsyncQueue *queue)
-{
-       if (!queue)
-               return;
-
-       ms_comm_msg_s *_data = g_new0(ms_comm_msg_s, 1);
-       _data->pid = POWEROFF;
-
-       g_async_queue_push(queue, _data);
-}
-
 static void __power_off_cb(void)
 {
        MS_DBG_ERR("POWER OFF CB Begin");
@@ -73,11 +56,8 @@ static void __power_off_cb(void)
 
        _msc_set_power_status(true);
 
-       __push_power_off(scan_queue2);
-       __push_power_off(reg_queue2);
-       __push_power_off(storage_queue2);
-       __push_power_off(storage_extract_queue);
-       __push_power_off(folder_extract_queue);
+       msc_send_power_off_request();
+       msc_send_power_off_request_to_extractor();
 
        g_source_remove(scanner_source_id2);