• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 
16 #ifndef OHOS_MEDIALIBRARY_ERRNO_H
17 #define OHOS_MEDIALIBRARY_ERRNO_H
18 
19 #include <errno.h>
20 
21 namespace OHOS {
22 namespace Media {
23 #define MEDIA_LIBRARY_ERR(offset, errCode) (-((offset) + (errCode)))
24 
25 // common error code
26 // linux standard ERROR { 0, 200 }
27 constexpr int32_t E_OK = 0;
28 constexpr int32_t E_SUCCESS = 0;
29 constexpr int32_t MTP_SUCCESS = 0;
30 constexpr int32_t E_ERR = -1;
31 constexpr int32_t E_PERMISSION_DENIED = -EACCES;
32 constexpr int32_t E_NO_SUCH_FILE      = -ENOENT;
33 constexpr int32_t E_FILE_EXIST        = -EEXIST;
34 constexpr int32_t E_NO_MEMORY         = -ENOMEM;
35 constexpr int32_t E_NO_SPACE          = -ENOSPC;
36 constexpr int32_t E_CHECK_SYSTEMAPP_FAIL = 202;
37 
38 // medialibary inner common err { 200, 1999 }
39 constexpr int32_t E_COMMON_OFFSET = 200;
40 constexpr int32_t E_COMMON_START =          MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 0);
41 constexpr int32_t E_FAIL =                  MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 0);
42 constexpr int32_t E_FILE_OPER_FAIL =        MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 1);
43 constexpr int32_t E_HAS_FS_ERROR =          MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 3);
44 constexpr int32_t E_CHECK_DIR_FAIL =        MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 4);
45 constexpr int32_t E_MODIFY_DATA_FAIL =      MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 5);
46 constexpr int32_t E_INVALID_VALUES =        MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 6);
47 constexpr int32_t E_INVALID_URI =           MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 7);
48 constexpr int32_t E_INVALID_FILEID =        MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 8);
49 constexpr int32_t E_INVALID_PATH =          MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 9);
50 constexpr int32_t E_VIOLATION_PARAMETERS =  MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 10);
51 constexpr int32_t E_RENAME_DIR_FAIL  =      MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 11);
52 constexpr int32_t E_GET_VALUEBUCKET_FAIL =  MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 12);
53 constexpr int32_t E_GET_ASSET_FAIL =        MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 13);
54 constexpr int32_t E_GET_HASH_FAIL =         MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 14);
55 constexpr int32_t E_GET_CLIENTBUNDLE_FAIL = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 15);
56 constexpr int32_t E_EXIST_IN_DB =           MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 16);
57 constexpr int32_t E_INVALID_MODE =          MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 17);
58 constexpr int32_t E_INVALID_BUNDLENAME =    MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 18);
59 constexpr int32_t E_RENAME_FILE_FAIL =      MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 19);
60 constexpr int32_t E_DB_FAIL =               MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 20);
61 constexpr int32_t E_DELETE_DENIED =         MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 21);
62 constexpr int32_t E_HAS_DB_ERROR =          MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 22);
63 constexpr int32_t E_INVALID_ARGUMENTS =     MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 23);
64 constexpr int32_t E_SQL_CHECK_FAIL =        MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 24);
65 constexpr int32_t E_IS_PENDING_ERROR =      MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 25);
66 constexpr int32_t E_NEED_FURTHER_CHECK =    MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 26);
67 constexpr int32_t E_CHECK_NATIVE_SA_FAIL =  MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 27);
68 constexpr int32_t E_INVALID_TIMESTAMP =     MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 28);
69 constexpr int32_t E_GRANT_URI_PERM_FAIL =   MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 29);
70 constexpr int32_t E_COMMON_END =            MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 1799);
71 
72 // medialibary directory and file type control { 2000, 2099 }
73 constexpr int32_t E_DIR_CTRL_OFFSET = 2000;
74 constexpr int32_t E_CHECK_EXTENSION_FAIL =                  MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 0);
75 constexpr int32_t E_DELETE_DIR_FAIL =                       MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 1);
76 constexpr int32_t E_CHECK_MEDIATYPE_FAIL =                  MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 2);
77 constexpr int32_t E_CHECK_ROOT_DIR_FAIL =                   MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 3);
78 constexpr int32_t E_CHECK_MEDIATYPE_MATCH_EXTENSION_FAIL =  MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 4);
79 constexpr int32_t E_FILE_NAME_INVALID =                     MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 5);
80 constexpr int32_t E_ALBUM_OPER_ERR =                        MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 6);
81 constexpr int32_t E_DIR_OPER_ERR =                          MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 7);
82 constexpr int32_t E_SAME_PATH =                             MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 8);
83 constexpr int32_t E_DIR_CHECK_DIR_FAIL =                    MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 9);
84 
85 // medialibary recycle, trash { 2100, 2199 }
86 constexpr int32_t E_TRASH_OFFSET = 2100;
87 constexpr int32_t E_RECYCLE_FILE_IS_NULL = MEDIA_LIBRARY_ERR(E_TRASH_OFFSET, 0);
88 constexpr int32_t E_IS_RECYCLED =          MEDIA_LIBRARY_ERR(E_TRASH_OFFSET, 1);
89 constexpr int32_t E_RECYCLE_DIR_FAIL =     MEDIA_LIBRARY_ERR(E_TRASH_OFFSET, 2);
90 constexpr int32_t E_CREATE_TRASHDIR_FAIL = MEDIA_LIBRARY_ERR(E_TRASH_OFFSET, 3);
91 constexpr int32_t E_MAKE_HASHNAME_FAIL =   MEDIA_LIBRARY_ERR(E_TRASH_OFFSET, 4);
92 constexpr int32_t E_GET_EXTENSION_FAIL =   MEDIA_LIBRARY_ERR(E_TRASH_OFFSET, 5);
93 
94 
95 // medialibary distributed { 2200, 2299 }
96 constexpr int32_t E_DISTRIBUTED_OFFSET = 2200;
97 constexpr int32_t E_DEVICE_OPER_ERR = MEDIA_LIBRARY_ERR(E_DISTRIBUTED_OFFSET, 0);
98 
99 // medialibary thumbanail { 2300, 2399 }
100 constexpr int32_t E_THUMBNAIL_OFFSET = 2300;
101 constexpr int32_t E_THUMBNAIL_CONNECT_TIMEOUT = MEDIA_LIBRARY_ERR(E_THUMBNAIL_OFFSET, 0);
102 constexpr int32_t E_THUMBNAIL_HAS_OPENED_FAIL = MEDIA_LIBRARY_ERR(E_THUMBNAIL_OFFSET, 1);
103 constexpr int32_t E_THUMBNAIL_LOCAL_CREATE_FAIL = MEDIA_LIBRARY_ERR(E_THUMBNAIL_OFFSET, 2);
104 constexpr int32_t E_THUMBNAIL_REMOTE_CREATE_FAIL = MEDIA_LIBRARY_ERR(E_THUMBNAIL_OFFSET, 3);
105 constexpr int32_t E_THUMBNAIL_SERVICE_NULLPTR = MEDIA_LIBRARY_ERR(E_THUMBNAIL_OFFSET, 4);
106 
107 // medialibary scanner { 2400, 2499 }
108 constexpr int32_t E_SCANNER_OFFSET = 2400;
109 constexpr int32_t E_FILE_HIDDEN = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 0);
110 constexpr int32_t E_DIR_HIDDEN = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 1);
111 constexpr int32_t E_RDB = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 2);
112 constexpr int32_t E_DATA = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 3);
113 constexpr int32_t E_SYSCALL = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 4);
114 constexpr int32_t E_SCANNED = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 5);
115 constexpr int32_t E_AVMETADATA = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 6);
116 constexpr int32_t E_IMAGE = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 7);
117 constexpr int32_t E_NO_RESULT = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 8);
118 constexpr int32_t E_STOP = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 9);
119 constexpr int32_t E_IS_PENDING = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 10);
120 
121 // media file extension module error code { 3000, 3099 }
122 constexpr int32_t E_MEDIA_FILE_OFFSET = 3000;
123 constexpr int32_t E_URI_INVALID =               MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 0);
124 constexpr int32_t E_DISTIBUTED_URI_NO_SUPPORT = MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 1);
125 constexpr int32_t E_URI_IS_NOT_ALBUM =          MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 2);
126 constexpr int32_t E_URI_IS_NOT_FILE =           MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 3);
127 constexpr int32_t E_TWO_URI_ARE_THE_SAME =      MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 4);
128 constexpr int32_t E_OPENFILE_INVALID_FLAG =     MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 5);
129 constexpr int32_t E_INVALID_DISPLAY_NAME =      MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 6);
130 constexpr int32_t E_DENIED_MOVE =               MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 7);
131 constexpr int32_t E_UPDATE_DB_FAIL =            MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 8);
132 constexpr int32_t E_DENIED_RENAME =             MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 9);
133 
134 // common error {14000, 14099}
135 constexpr int32_t E_MTP_COMMON_OFFSET = 14000;
136 constexpr int32_t MTP_FAIL =                            MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 0);
137 constexpr int32_t MTP_ERROR_SESSION_ALREADY_OPEN =      MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 1);
138 constexpr int32_t MTP_ERROR_CONTEXT_IS_NULL =           MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 2);
139 constexpr int32_t MTP_ERROR_PACKET_INCORRECT =          MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 3);
140 constexpr int32_t MTP_ERROR_NO_THIS_FILE =              MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 4);
141 constexpr int32_t MTP_ERROR_INCOMPLETE_TRANSFER =       MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 5);
142 constexpr int32_t MTP_ERROR_SESSION_NOT_OPEN =          MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 6);
143 constexpr int32_t MTP_ERROR_INVALID_STORAGE_ID =        MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 7);
144 constexpr int32_t MTP_ERROR_INVALID_OBJECTHANDLE =      MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 8);
145 constexpr int32_t MTP_ERROR_DEVICEPROP_NOT_SUPPORTED =  MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 9);
146 constexpr int32_t MTP_ERROR_DRIVER_OPEN_FAILED =        MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 10);
147 
148 // medialibrary error { 15000, 15099 }
149 constexpr int32_t E_MTP_MEDIALIBRARY_OFFSET = 15000;
150 constexpr int32_t MTP_ERROR_STORE_NOT_AVAILABLE =       MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 0);
151 constexpr int32_t MTP_ERROR_NO_THUMBNAIL_PRESENT =      MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 1);
152 constexpr int32_t MTP_ERROR_INVALID_PARENTOBJECT =      MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 2);
153 constexpr int32_t MTP_ERROR_PARAMETER_NOT_SUPPORTED =   MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 3);
154 constexpr int32_t MTP_ERROR_INVALID_OBJECTPROP_VALUE =  MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 4);
155 constexpr int32_t MTP_ERROR_INVALID_OBJECTPROP_FORMAT = MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 5);
156 constexpr int32_t MTP_ERROR_INVALID_OBJECTPROPCODE =    MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 6);
157 constexpr int32_t MTP_ERROR_ACCESS_DENIED =             MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 7);
158 constexpr int32_t MTP_ERROR_SPECIFICATION_BY_GROUP_UNSUPPORTED = MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 8);
159 constexpr int32_t MTP_ERROR_SPECIFICATION_BY_DEPTH_UNSUPPORTED = MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 9);
160 
161 // media smart album module error code { 4000, 4099 }
162 constexpr int32_t E_MEDIA_SMART_OFFSET = 4000;
163 constexpr int32_t E_PARENT_SMARTALBUM_IS_NOT_EXISTED = MEDIA_LIBRARY_ERR(E_MEDIA_SMART_OFFSET, 0);
164 constexpr int32_t E_PARENT_SMARTALBUM_CAN_NOT_DELETE = MEDIA_LIBRARY_ERR(E_MEDIA_SMART_OFFSET, 1);
165 constexpr int32_t E_DELETE_SMARTALBUM_MAP_FAIL =       MEDIA_LIBRARY_ERR(E_MEDIA_SMART_OFFSET, 2);
166 constexpr int32_t E_SMARTALBUM_IS_NOT_EXISTED =        MEDIA_LIBRARY_ERR(E_MEDIA_SMART_OFFSET, 3);
167 constexpr int32_t E_CHILD_CAN_NOT_ADD_SMARTALBUM =     MEDIA_LIBRARY_ERR(E_MEDIA_SMART_OFFSET, 4);
168 constexpr int32_t E_TRASHALBUM_CAN_NOT_DELETE =        MEDIA_LIBRARY_ERR(E_MEDIA_SMART_OFFSET, 5);
169 constexpr int32_t E_FAVORITEALBUM_CAN_NOT_DELETE =     MEDIA_LIBRARY_ERR(E_MEDIA_SMART_OFFSET, 6);
170 constexpr int32_t E_PARENT_CAN_NOT_ADDASSETS =         MEDIA_LIBRARY_ERR(E_MEDIA_SMART_OFFSET, 7);
171 
172 
173 // media on notify module error code { 16000, 16099 }
174 constexpr int32_t E_MEDIA_NOTIFY_OFFSET = 16000;
175 constexpr int32_t E_ASYNC_WORKER_IS_NULL =             MEDIA_LIBRARY_ERR(E_MEDIA_NOTIFY_OFFSET, 0);
176 constexpr int32_t E_NOTIFY_TASK_DATA_IS_NULL =         MEDIA_LIBRARY_ERR(E_MEDIA_NOTIFY_OFFSET, 1);
177 constexpr int32_t E_SOLVE_URIS_FAILED =                MEDIA_LIBRARY_ERR(E_MEDIA_NOTIFY_OFFSET, 2);
178 constexpr int32_t E_NOTIFY_CHANGE_EXT_FAILED =         MEDIA_LIBRARY_ERR(E_MEDIA_NOTIFY_OFFSET, 3);
179 constexpr int32_t E_PARCEL_GET_SIZE_FAILED =           MEDIA_LIBRARY_ERR(E_MEDIA_NOTIFY_OFFSET, 4);
180 constexpr int32_t E_GET_ALBUM_ID_FAILED =              MEDIA_LIBRARY_ERR(E_MEDIA_NOTIFY_OFFSET, 5);
181 constexpr int32_t E_DO_NOT_NEDD_SEND_NOTIFY =          MEDIA_LIBRARY_ERR(E_MEDIA_NOTIFY_OFFSET, 6);
182 } // namespace Media
183 } // namespace OHOS
184 #endif // OHOS_MEDIALIBRARY_ERRNO_H
185