4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
24 #include "media-util.h"
26 #include "media-common-utils.h"
27 #include "media-common-db-svc.h"
28 #include "media-common-external-storage.h"
30 #include "media-util-err.h"
31 #include "media-scanner-dbg-v2.h"
32 #include "media-scanner-scan-v2.h"
33 #include "media-scanner-extract-v2.h"
34 #include "media-scanner-device-block-v2.h"
36 static void __msc_usb_remove_event(const char *mount_path)
38 MS_DBG_ERR("===========================================================");
39 MS_DBG_ERR("USB REMOVED, mountpath : %s", mount_path);
40 MS_DBG_ERR("===========================================================");
41 int update_status = -1;
42 int remain_request = 0;
45 if(!ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &update_status)) {
46 MS_DBG_ERR("ms_config_get_int[VCONFKEY_FILEMANAGER_DB_STATUS]");
49 if (msc_get_remain_scan_request(MS_SCAN_STORAGE, &remain_request) == MS_MEDIA_ERR_NONE) {
50 if (!(remain_request == 0 && update_status == VCONFKEY_FILEMANAGER_DB_UPDATED)) {
51 msc_set_blocked_path(mount_path);
57 if (msc_get_dir_scan_status(&status) == MS_MEDIA_ERR_NONE) {
59 MS_DBG_ERR("Doing directory scanning. Set cancel path");
60 msc_set_cancel_path(mount_path);
65 if (msc_get_remain_extract_request(MS_EXTRACT_STORAGE, &remain_request) == MS_MEDIA_ERR_NONE) {
66 if (!(remain_request == 0 && update_status == VCONFKEY_FILEMANAGER_DB_UPDATED)) {
67 msc_set_extract_blocked_path(mount_path);
72 if (msc_get_dir_scan_status(&status) == MS_MEDIA_ERR_NONE) {
74 MS_DBG_ERR("Doing directory extracting. Set cancel path");
75 msc_set_extract_cancel_path(mount_path);
83 int msc_mmc_remove_handler(const char *mount_path)
85 return MS_MEDIA_ERR_NONE;
88 void _msc_mmc_changed_event(const char *mount_path, ms_stg_status_e mount_status)
90 /* If scanner is not working, media server executes media scanner and sends request. */
91 /* If scanner is working, it detects changing status of SD card. */
92 if (mount_status == MS_STG_INSERTED) {
94 } else if (mount_status == MS_STG_REMOVED) {
95 msc_set_mmc_status(MS_STG_REMOVED);
96 msc_mmc_remove_handler(mount_path);
103 void msc_device_block_changed_cb(ms_block_info_s *block_info, void *user_data)
105 if (block_info->block_type == 0) {
106 MS_DBG_ERR("GET THE USB EVENT");
107 if (block_info->state == MS_STG_INSERTED) {
110 __msc_usb_remove_event(block_info->mount_path);
113 MS_DBG_ERR("GET THE MMC EVENT");
114 _msc_mmc_changed_event(block_info->mount_path, block_info->state);