1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef STORAGE_FILE_MANAGER_SERVICE_DEF_H 16 #define STORAGE_FILE_MANAGER_SERVICE_DEF_H 17 18 #include <vector> 19 #include <string> 20 #include <unordered_map> 21 #include "media_data_ability_const.h" 22 #include "media_lib_service_const.h" 23 24 namespace OHOS { 25 namespace FileManagerService { 26 enum Operation { 27 GET_ROOT, 28 MAKE_DIR, 29 LIST_FILE, 30 CREATE_FILE 31 }; 32 33 enum Equipment { 34 INTERNAL_STORAGE, 35 EXTERNAL_STORAGE 36 }; 37 38 enum VolumeState { 39 UNMOUNTED = 0, 40 CHECKING, 41 MOUNTED, 42 EJECTING 43 }; 44 constexpr int64_t MAX_NUM = 200; 45 constexpr int32_t CODE_MASK = 0xff; 46 constexpr int32_t EQUIPMENT_SHIFT = 16; 47 48 const std::string FISRT_LEVEL_ALBUM = "dataability:///album"; 49 // use to find out album in the root dir 50 const std::string RELATIVE_ROOT_PATH = ""; 51 52 const std::string MEDIA_ROOT_PATH = "/storage/media/local/files"; 53 const std::string IMAGE_ROOT_NAME = "image_album"; 54 const std::string VIDEO_ROOT_NAME = "video_album"; 55 const std::string AUDIO_ROOT_NAME = "audio_album"; 56 const std::string FILE_ROOT_NAME = "file_folder"; 57 58 const std::string ALBUM_TYPE = "album"; 59 const std::string FILE_MIME_TYPE = "file/*"; 60 61 const std::string EXTERNAL_STORAGE_URI = "dataability:///external_storage"; 62 const std::string MOUNT_POINT_ROOT = "/mnt/"; 63 64 constexpr int FILE_MEDIA_TYPE = Media::MediaType::MEDIA_TYPE_FILE; 65 constexpr int RESULTSET_EMPTY = 0; 66 constexpr int RESULTSET_ONE = 1; 67 68 const std::unordered_map<int, std::string> FILE_MIME_TYPE_MAPS = { 69 {Media::MediaType::MEDIA_TYPE_IMAGE, "image/*"}, 70 {Media::MediaType::MEDIA_TYPE_AUDIO, "audio/*"}, 71 {Media::MediaType::MEDIA_TYPE_VIDEO, "video/*"}, 72 {Media::MediaType::MEDIA_TYPE_FILE, "file/*"}, 73 {Media::MediaType::MEDIA_TYPE_ALBUM, "file/*"}, 74 }; 75 76 const std::unordered_map<int, std::string> MEDIA_TYPE_FOLDER_MAPS = { 77 {Media::MediaType::MEDIA_TYPE_IMAGE, "image/"}, 78 {Media::MediaType::MEDIA_TYPE_AUDIO, "audio/"}, 79 {Media::MediaType::MEDIA_TYPE_VIDEO, "video/"}, 80 {Media::MediaType::MEDIA_TYPE_FILE, "document/"}, 81 }; 82 83 const std::unordered_map<int, std::string> MEDIA_TYPE_URI_MAPS = { 84 {Media::MediaType::MEDIA_TYPE_IMAGE, Media::MEDIALIBRARY_IMAGE_URI}, 85 {Media::MediaType::MEDIA_TYPE_AUDIO, Media::MEDIALIBRARY_AUDIO_URI}, 86 {Media::MediaType::MEDIA_TYPE_VIDEO, Media::MEDIALIBRARY_VIDEO_URI}, 87 {Media::MediaType::MEDIA_TYPE_FILE, Media::MEDIALIBRARY_FILE_URI}, 88 }; 89 90 #define GET_COLUMN_INDEX_FROM_NAME(result, name, index) \ 91 do { \ 92 if (result->GetColumnIndex(name, index) != NativeRdb::E_OK) { \ 93 ERR_LOG("NativeRdb gets %{public}s index fail", name.c_str()); \ 94 return false; \ 95 } \ 96 } while (0) 97 } // namespace FileManagerService 98 } // namespace OHOS 99 #endif // STORAGE_FILE_MANAGER_SERVICE_DEF_H 100