3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #ifndef __STORAGE_EXPAND_H__
20 #define __STORAGE_EXPAND_H__
28 * @addtogroup CAPI_SYSTEM_STORAGE_MODULE
35 * @brief Enumeration of error codes for Storage.
36 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
39 STORAGE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
40 STORAGE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
41 STORAGE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
42 STORAGE_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NO_SUCH_DEVICE, /**< Storage not supported */
43 STORAGE_ERROR_OPERATION_FAILED = TIZEN_ERROR_SYSTEM_CLASS | 0x12, /**< Operation failed */
48 * @brief Enumeration of the storage types.
49 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
52 STORAGE_TYPE_INTERNAL, /**< Internal device storage (built-in storage in a device, non-removable) */
53 STORAGE_TYPE_EXTERNAL, /**< External storage */
58 * @brief Enumeration of the state of storage devices.
59 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
62 STORAGE_STATE_UNMOUNTABLE = -2, /**< Storage is present but cannot be mounted. Typically it happens if the file system of the storage is corrupted */
63 STORAGE_STATE_REMOVED = -1, /**< Storage is not present */
64 STORAGE_STATE_MOUNTED = 0, /**< Storage is present and mounted with read/write access */
65 STORAGE_STATE_MOUNTED_READ_ONLY = 1, /**< Storage is present and mounted with read only access */
69 * @brief Called to get information once for each supported storage.
71 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
73 * @param[in] storage_id The unique storage ID
74 * @param[in] type The type of the storage
75 * @param[in] state The current state of the storage
76 * @param[in] path The absolute path to the root directory of the storage
77 * @param[in] user_data The user data passed from the foreach function
79 * @return @c true to continue with the next iteration of the loop, \n
80 * otherwise @c false to break out of the loop
82 * @pre storage_foreach_device_supported() will invoke this callback function.
83 * @see storage_foreach_device_supported()
85 typedef bool (*storage_device_supported_cb)(int storage_id, storage_type_e type,
86 storage_state_e state, const char *path, void *user_data);
89 * @brief Retrieves all storage in a device.
90 * @details This function invokes the callback function once for each storage in a device. \n
91 * If storage_device_supported_cb() returns @c false, then the iteration will be finished.
93 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
95 * @param[in] callback The iteration callback function
96 * @param[in] user_data The user data to be passed to the callback function
98 * @return @c 0 on success,
99 * otherwise a negative error value
101 * @retval #STORAGE_ERROR_NONE Successful
102 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
104 * @post This function invokes storage_device_supported_cb() repeatedly for each supported device.
105 * @see storage_device_supported_cb()
107 int storage_foreach_device_supported(storage_device_supported_cb callback, void *user_data);
110 * @brief Gets the absolute path to the root directory of the given storage.
111 * @details Files saved on the internal/external storage are readable or writeable by all applications.
112 * When an application is uninstalled, the files written by that application are not removed from the internal/external storage.
114 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
116 * @remarks If you want to access files or directories in internal storage, you must declare http://tizen.org/privilege/mediastorage.\n
117 * If you want to access files or directories in external storage, you must declare http://tizen.org/privilege/externalstorage.\n
118 * You must release @a path using free().
120 * @param[in] storage_id The storage device
121 * @param[out] path The absolute path to the storage directory
123 * @return @c 0 on success,
124 * otherwise a negative error value
126 * @retval #STORAGE_ERROR_NONE Successful
127 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
128 * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory
129 * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
131 * @see storage_get_state()
133 int storage_get_root_directory(int storage_id, char **path);
136 * @brief Enumeration of the storage directory types
137 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
140 STORAGE_DIRECTORY_IMAGES, /**< Image directory */
141 STORAGE_DIRECTORY_SOUNDS, /**< Sounds directory */
142 STORAGE_DIRECTORY_VIDEOS, /**< Videos directory */
143 STORAGE_DIRECTORY_CAMERA, /**< Camera directory */
144 STORAGE_DIRECTORY_DOWNLOADS, /**< Downloads directory */
145 STORAGE_DIRECTORY_MUSIC, /**< Music directory */
146 STORAGE_DIRECTORY_DOCUMENTS, /**< Documents directory */
147 STORAGE_DIRECTORY_OTHERS, /**< Others directory */
148 STORAGE_DIRECTORY_SYSTEM_RINGTONES, /**< System ringtones directory. Only available for internal storage. */
149 STORAGE_DIRECTORY_MAX
150 } storage_directory_e;
153 * @brief Gets the absolute path to the each directory of the given storage.
154 * @details Files saved on the internal/external storage are readable or writeable by all applications.
155 * When an application is uninstalled, the files written by that application are not removed from the internal/external storage.
157 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
159 * @remarks The directory path may not exist, so you must make sure that it exists before using it.\n
160 * If you want to access files or directories in internal storage except #STORAGE_DIRECTORY_SYSTEM_RINGTONES, you must declare http://tizen.org/privilege/mediastorage.\n
161 * If you want to access files or directories in #STORAGE_DIRECTORY_SYSTEM_RINGTONES, you must declare %http://tizen.org/privilege/systemsettings.\n
162 * If you want to access files or directories in external storage, you must declare http://tizen.org/privilege/externalstorage.\n
163 * You must release @a path using free().
165 * @param[in] storage_id The storage device
166 * @param[in] type The directory type
167 * @param[out] path The absolute path to the directory type
169 * @return @c 0 on success,
170 * otherwise a negative error value
172 * @retval #STORAGE_ERROR_NONE Successful
173 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
174 * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory
175 * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
177 * @see storage_get_state()
179 int storage_get_directory(int storage_id, storage_directory_e type, char **path);
182 * @brief Gets the type of the given storage.
184 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
186 * @param[in] storage_id The storage device
187 * @param[out] type The type of the storage
189 * @return @c 0 on success,
190 * otherwise a negative error value
192 * @retval #STORAGE_ERROR_NONE Successful
193 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
194 * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
196 int storage_get_type(int storage_id, storage_type_e *type);
199 * @brief Gets the current state of the given storage.
201 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
203 * @param[in] storage_id The storage device
204 * @param[out] state The current state of the storage
206 * @return @c 0 on success,
207 * otherwise a negative error value
209 * @retval #STORAGE_ERROR_NONE Successful
210 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
211 * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
213 * @see storage_get_root_directory()
214 * @see storage_get_total_space()
215 * @see storage_get_available_space()
217 int storage_get_state(int storage_id, storage_state_e *state);
220 * @brief Called when the state of storage changes
222 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
224 * @param[in] storage_id The unique storage ID
225 * @param[in] state The current state of the storage
226 * @param[in] user_data The user data passed from the foreach function
228 * @pre storage_set_state_changed_cb() will invoke this callback function.
229 * @see storage_set_state_changed_cb()
230 * @see storage_unset_state_changed_cb()
232 typedef void (*storage_state_changed_cb)(int storage_id, storage_state_e state, void *user_data);
235 * @brief Registers a callback function to be invoked when the state of the storage changes.
237 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
239 * @param[in] storage_id The storage device
240 * @param[in] callback The callback function to register
241 * @param[in] user_data The user data to be passed to the callback function
243 * @return @c 0 on success,
244 * otherwise a negative error value
246 * @retval #STORAGE_ERROR_NONE Successful
247 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
248 * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
249 * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
251 * @post storage_state_changed_cb() will be invoked if the state of the registered storage changes.
252 * @see storage_state_changed_cb()
253 * @see storage_unset_state_changed_cb()
255 int storage_set_state_changed_cb(int storage_id, storage_state_changed_cb callback, void *user_data);
258 * @brief Unregisters the callback function.
260 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
262 * @param[in] storage_id The storage device to monitor
263 * @param[in] callback The callback function to register
265 * @return @c 0 on success,
266 * otherwise a negative error value
268 * @retval #STORAGE_ERROR_NONE Successful
269 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
270 * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
271 * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
273 * @see storage_state_changed_cb()
274 * @see storage_set_state_changed_cb()
276 int storage_unset_state_changed_cb(int storage_id, storage_state_changed_cb callback);
279 * @brief Gets the total space of the given storage in bytes.
281 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
283 * @param[in] storage_id The storage device
284 * @param[out] bytes The total space size of the storage (bytes)
286 * @return @c 0 on success,
287 * otherwise a negative error value
289 * @retval #STORAGE_ERROR_NONE Successful
290 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
291 * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
292 * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
294 * @see storage_get_state()
295 * @see storage_get_available_space()
297 int storage_get_total_space(int storage_id, unsigned long long *bytes);
300 * @brief Gets the available space size of the given storage in bytes.
302 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
304 * @param[in] storage_id The storage device
305 * @param[out] bytes The available space size of the storage (bytes)
307 * @return @c 0 on success,
308 * otherwise a negative error value
310 * @retval #STORAGE_ERROR_NONE Successful
311 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
312 * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
313 * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
315 * @see storage_get_state()
316 * @see storage_get_total_space()
318 int storage_get_available_space(int storage_id, unsigned long long *bytes);