Scanner-v2 cleanup 61/231261/2
authorMinje Ahn <minje.ahn@samsung.com>
Mon, 20 Apr 2020 22:56:09 +0000 (07:56 +0900)
committerMinje ahn <minje.ahn@samsung.com>
Tue, 21 Apr 2020 04:35:24 +0000 (04:35 +0000)
Change-Id: I48802cc60beb69bd1d8033e70905421857fa10a1
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/scanner-v2/media-scanner-v2.c

index 4a52187..db99364 100644 (file)
@@ -59,56 +59,29 @@ static guint scanner_source_id2;
 static void __msc_add_event_receiver(void *data);
 static void __msc_remove_event_receiver(void);
 
-static void _power_off_cb(void* data)
+static void __push_power_off(GAsyncQueue *queue)
 {
-       ms_comm_msg_s *scan_data = NULL;
-       ms_comm_msg_s *reg_data = NULL;
+       if (!queue)
+               return;
 
-       MS_DBG_ERR("POWER OFF CB Begin");
+       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");
        //display_lock_state(POWER_STATE_STANDBY, 0);
 
        power_off2 = true;
 
-       if (scan_queue2) {
-               /*notify to scannig thread*/
-               scan_data = g_new0(ms_comm_msg_s, 1);
-
-               scan_data->pid = POWEROFF;
-               g_async_queue_push(scan_queue2, scan_data);
-       }
-
-       if (reg_queue2) {
-               /*notify to register thread*/
-               reg_data = g_new0(ms_comm_msg_s, 1);
-
-               reg_data->pid = POWEROFF;
-               g_async_queue_push(reg_queue2, reg_data);
-       }
-
-       if (storage_queue2) {
-               /*notify to register thread*/
-               reg_data = g_new0(ms_comm_msg_s, 1);
-
-               reg_data->pid = POWEROFF;
-               g_async_queue_push(storage_queue2, reg_data);
-       }
-
-       if (storage_extract_queue) {
-               /*notify to storage extract thread*/
-               reg_data = g_new0(ms_comm_msg_s, 1);
-
-               reg_data->pid = POWEROFF;
-               g_async_queue_push(storage_extract_queue, reg_data);
-       }
-
-       if (folder_extract_queue) {
-               /*notify to folder extract thread*/
-               reg_data = g_new0(ms_comm_msg_s, 1);
-
-               reg_data->pid = POWEROFF;
-               g_async_queue_push(folder_extract_queue, reg_data);
-       }
+       __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);
 
        g_source_remove(scanner_source_id2);
 
@@ -300,7 +273,7 @@ EXIT:
 
 static int __msc_power_off_cb(int option, void *data)
 {
-       _power_off_cb(NULL);
+       __power_off_cb();
 
        return MS_MEDIA_ERR_NONE;
 }