1 /*
2  * Copyright (C) 2024 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_RINGTONE_ERRNO_H
17 #define OHOS_RINGTONE_ERRNO_H
18 
19 #include <stdint.h>
20 #include <errno.h>
21 
22 namespace OHOS {
23 namespace Media {
24 #define RINGTONE_ERR(offset, errCode) (-((offset) + (errCode)))
25 
26 // common error code
27 // linux standard ERROR { 0, 200 }
28 constexpr int32_t E_OK = 0;
29 constexpr int32_t E_SUCCESS = 0;
30 
31 constexpr int32_t E_ERR = -1;
32 constexpr int32_t E_PERMISSION_DENIED = -EACCES;
33 constexpr int32_t E_NO_SUCH_FILE      = -ENOENT;
34 constexpr int32_t E_FILE_EXIST        = -EEXIST;
35 constexpr int32_t E_NO_MEMORY         = -ENOMEM;
36 constexpr int32_t E_NO_SPACE          = -ENOSPC;
37 constexpr int32_t E_CHECK_SYSTEMAPP_FAIL = 202;
38 
39 // ringtone inner common err { 200, 1999 }
40 constexpr int32_t E_COMMON_OFFSET           = 200;
41 constexpr int32_t E_COMMON_START            = RINGTONE_ERR(E_COMMON_OFFSET, 0);
42 constexpr int32_t E_FAIL                    = RINGTONE_ERR(E_COMMON_OFFSET, 0);
43 constexpr int32_t E_FILE_OPER_FAIL          = RINGTONE_ERR(E_COMMON_OFFSET, 1);
44 constexpr int32_t E_HAS_FS_ERROR            = RINGTONE_ERR(E_COMMON_OFFSET, 3);
45 constexpr int32_t E_CHECK_DIR_FAIL          = RINGTONE_ERR(E_COMMON_OFFSET, 4);
46 constexpr int32_t E_MODIFY_DATA_FAIL        = RINGTONE_ERR(E_COMMON_OFFSET, 5);
47 constexpr int32_t E_INVALID_VALUES          = RINGTONE_ERR(E_COMMON_OFFSET, 6);
48 constexpr int32_t E_INVALID_URI             = RINGTONE_ERR(E_COMMON_OFFSET, 7);
49 constexpr int32_t E_INVALID_FILEID          = RINGTONE_ERR(E_COMMON_OFFSET, 8);
50 constexpr int32_t E_INVALID_PATH            = RINGTONE_ERR(E_COMMON_OFFSET, 9);
51 constexpr int32_t E_VIOLATION_PARAMETERS    = RINGTONE_ERR(E_COMMON_OFFSET, 10);
52 constexpr int32_t E_RENAME_DIR_FAIL         = RINGTONE_ERR(E_COMMON_OFFSET, 11);
53 constexpr int32_t E_GET_VALUEBUCKET_FAIL    = RINGTONE_ERR(E_COMMON_OFFSET, 12);
54 constexpr int32_t E_GET_ASSET_FAIL          = RINGTONE_ERR(E_COMMON_OFFSET, 13);
55 constexpr int32_t E_GET_HASH_FAIL           = RINGTONE_ERR(E_COMMON_OFFSET, 14);
56 constexpr int32_t E_GET_CLIENTBUNDLE_FAIL   = RINGTONE_ERR(E_COMMON_OFFSET, 15);
57 constexpr int32_t E_EXIST_IN_DB             = RINGTONE_ERR(E_COMMON_OFFSET, 16);
58 constexpr int32_t E_INVALID_MODE            = RINGTONE_ERR(E_COMMON_OFFSET, 17);
59 constexpr int32_t E_INVALID_BUNDLENAME      = RINGTONE_ERR(E_COMMON_OFFSET, 18);
60 constexpr int32_t E_RENAME_FILE_FAIL        = RINGTONE_ERR(E_COMMON_OFFSET, 19);
61 constexpr int32_t E_DB_FAIL                 = RINGTONE_ERR(E_COMMON_OFFSET, 20);
62 constexpr int32_t E_DELETE_DENIED           = RINGTONE_ERR(E_COMMON_OFFSET, 21);
63 constexpr int32_t E_HAS_DB_ERROR            = RINGTONE_ERR(E_COMMON_OFFSET, 22);
64 constexpr int32_t E_INVALID_ARGUMENTS       = RINGTONE_ERR(E_COMMON_OFFSET, 23);
65 constexpr int32_t E_SQL_CHECK_FAIL          = RINGTONE_ERR(E_COMMON_OFFSET, 24);
66 constexpr int32_t E_IS_PENDING_ERROR        = RINGTONE_ERR(E_COMMON_OFFSET, 25);
67 constexpr int32_t E_NEED_FURTHER_CHECK      = RINGTONE_ERR(E_COMMON_OFFSET, 26);
68 constexpr int32_t E_CHECK_NATIVE_SA_FAIL    = RINGTONE_ERR(E_COMMON_OFFSET, 27);
69 constexpr int32_t E_INVALID_TIMESTAMP       = RINGTONE_ERR(E_COMMON_OFFSET, 28);
70 constexpr int32_t E_GRANT_URI_PERM_FAIL     = RINGTONE_ERR(E_COMMON_OFFSET, 29);
71 constexpr int32_t E_IS_IN_COMMIT            = RINGTONE_ERR(E_COMMON_OFFSET, 30);
72 constexpr int32_t E_IS_IN_REVERT            = RINGTONE_ERR(E_COMMON_OFFSET, 31);
73 constexpr int32_t E_GET_PRAMS_FAIL          = RINGTONE_ERR(E_COMMON_OFFSET, 32);
74 constexpr int32_t E_COMMON_END              = RINGTONE_ERR(E_COMMON_OFFSET, 1799);
75 
76 // ringtone directory and file type control { 2000, 2099 }
77 constexpr int32_t E_DIR_CTRL_OFFSET                             = 2000;
78 constexpr int32_t E_CHECK_EXTENSION_FAIL                        = RINGTONE_ERR(E_DIR_CTRL_OFFSET, 0);
79 constexpr int32_t E_DELETE_DIR_FAIL                             = RINGTONE_ERR(E_DIR_CTRL_OFFSET, 1);
80 constexpr int32_t E_CHECK_RINGTONE_FAIL                         = RINGTONE_ERR(E_DIR_CTRL_OFFSET, 2);
81 constexpr int32_t E_CHECK_ROOT_DIR_FAIL                         = RINGTONE_ERR(E_DIR_CTRL_OFFSET, 3);
82 constexpr int32_t E_CHECK_RINGTONETYPE_MATCH_EXTENSION_FAIL     = RINGTONE_ERR(E_DIR_CTRL_OFFSET, 4);
83 constexpr int32_t E_FILE_NAME_INVALID                           = RINGTONE_ERR(E_DIR_CTRL_OFFSET, 5);
84 constexpr int32_t E_ALBUM_OPER_ERR                              = RINGTONE_ERR(E_DIR_CTRL_OFFSET, 6);
85 constexpr int32_t E_DIR_OPER_ERR                                = RINGTONE_ERR(E_DIR_CTRL_OFFSET, 7);
86 constexpr int32_t E_SAME_PATH                                   = RINGTONE_ERR(E_DIR_CTRL_OFFSET, 8);
87 constexpr int32_t E_DIR_CHECK_DIR_FAIL                          = RINGTONE_ERR(E_DIR_CTRL_OFFSET, 9);
88 
89 // ringtone recycle, trash { 2100, 2199 }
90 constexpr int32_t E_TRASH_OFFSET            = 2100;
91 constexpr int32_t E_RECYCLE_FILE_IS_NULL    = RINGTONE_ERR(E_TRASH_OFFSET, 0);
92 constexpr int32_t E_IS_RECYCLED             = RINGTONE_ERR(E_TRASH_OFFSET, 1);
93 constexpr int32_t E_RECYCLE_DIR_FAIL        = RINGTONE_ERR(E_TRASH_OFFSET, 2);
94 constexpr int32_t E_CREATE_TRASHDIR_FAIL    = RINGTONE_ERR(E_TRASH_OFFSET, 3);
95 constexpr int32_t E_MAKE_HASHNAME_FAIL      = RINGTONE_ERR(E_TRASH_OFFSET, 4);
96 constexpr int32_t E_GET_EXTENSION_FAIL      = RINGTONE_ERR(E_TRASH_OFFSET, 5);
97 
98 // ringtone distributed { 2200, 2299 }
99 constexpr int32_t E_DISTRIBUTED_OFFSET      = 2200;
100 constexpr int32_t E_DEVICE_OPER_ERR         = RINGTONE_ERR(E_DISTRIBUTED_OFFSET, 0);
101 
102 // ringtone scanner { 2400, 2499 }
103 constexpr int32_t E_SCANNER_OFFSET  = 2400;
104 constexpr int32_t E_FILE_HIDDEN     = RINGTONE_ERR(E_SCANNER_OFFSET, 0);
105 constexpr int32_t E_DIR_HIDDEN      = RINGTONE_ERR(E_SCANNER_OFFSET, 1);
106 constexpr int32_t E_RDB             = RINGTONE_ERR(E_SCANNER_OFFSET, 2);
107 constexpr int32_t E_DATA            = RINGTONE_ERR(E_SCANNER_OFFSET, 3);
108 constexpr int32_t E_SYSCALL         = RINGTONE_ERR(E_SCANNER_OFFSET, 4);
109 constexpr int32_t E_SCANNED         = RINGTONE_ERR(E_SCANNER_OFFSET, 5);
110 constexpr int32_t E_AVMETADATA      = RINGTONE_ERR(E_SCANNER_OFFSET, 6);
111 constexpr int32_t E_IMAGE           = RINGTONE_ERR(E_SCANNER_OFFSET, 7);
112 constexpr int32_t E_NO_RESULT       = RINGTONE_ERR(E_SCANNER_OFFSET, 8);
113 constexpr int32_t E_STOP            = RINGTONE_ERR(E_SCANNER_OFFSET, 9);
114 constexpr int32_t E_IS_PENDING      = RINGTONE_ERR(E_SCANNER_OFFSET, 10);
115 
116 // ringtone file extension module error code { 3000, 3099 }
117 constexpr int32_t E_RINGTONE_FILE_OFFSET        = 3000;
118 constexpr int32_t E_URI_INVALID                 = RINGTONE_ERR(E_RINGTONE_FILE_OFFSET, 0);
119 constexpr int32_t E_DISTIBUTED_URI_NO_SUPPORT   = RINGTONE_ERR(E_RINGTONE_FILE_OFFSET, 1);
120 constexpr int32_t E_URI_IS_NOT_ALBUM            = RINGTONE_ERR(E_RINGTONE_FILE_OFFSET, 2);
121 constexpr int32_t E_URI_IS_NOT_FILE             = RINGTONE_ERR(E_RINGTONE_FILE_OFFSET, 3);
122 constexpr int32_t E_TWO_URI_ARE_THE_SAME        = RINGTONE_ERR(E_RINGTONE_FILE_OFFSET, 4);
123 constexpr int32_t E_OPENFILE_INVALID_FLAG       = RINGTONE_ERR(E_RINGTONE_FILE_OFFSET, 5);
124 constexpr int32_t E_INVALID_DISPLAY_NAME        = RINGTONE_ERR(E_RINGTONE_FILE_OFFSET, 6);
125 constexpr int32_t E_DENIED_MOVE                 = RINGTONE_ERR(E_RINGTONE_FILE_OFFSET, 7);
126 constexpr int32_t E_UPDATE_DB_FAIL              = RINGTONE_ERR(E_RINGTONE_FILE_OFFSET, 8);
127 constexpr int32_t E_DENIED_RENAME               = RINGTONE_ERR(E_RINGTONE_FILE_OFFSET, 9);
128 
129 // ringtone on notify module error code { 16000, 16099 }
130 constexpr int32_t E_RINGTONE_NOTIFY_OFFSET      = 16000;
131 constexpr int32_t E_ASYNC_WORKER_IS_NULL        = RINGTONE_ERR(E_RINGTONE_NOTIFY_OFFSET, 0);
132 constexpr int32_t E_NOTIFY_TASK_DATA_IS_NULL    = RINGTONE_ERR(E_RINGTONE_NOTIFY_OFFSET, 1);
133 constexpr int32_t E_SOLVE_URIS_FAILED           = RINGTONE_ERR(E_RINGTONE_NOTIFY_OFFSET, 2);
134 constexpr int32_t E_NOTIFY_CHANGE_EXT_FAILED    = RINGTONE_ERR(E_RINGTONE_NOTIFY_OFFSET, 3);
135 constexpr int32_t E_PARCEL_GET_SIZE_FAILED      = RINGTONE_ERR(E_RINGTONE_NOTIFY_OFFSET, 4);
136 constexpr int32_t E_GET_ALBUM_ID_FAILED         = RINGTONE_ERR(E_RINGTONE_NOTIFY_OFFSET, 5);
137 constexpr int32_t E_DO_NOT_NEDD_SEND_NOTIFY     = RINGTONE_ERR(E_RINGTONE_NOTIFY_OFFSET, 6);
138 } // namespace Media
139 } // namespace OHOS
140 #endif // OHOS_RINGTONE_ERRNO_H
141