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 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
113 * @remarks Files saved on the internal/external storage are readable or writable by all applications.\n
114 * When an application is uninstalled, the files written by that application are not removed from the internal/external storage.\n
115 * If you want to access files or directories in internal storage, you must declare http://tizen.org/privilege/mediastorage.\n
116 * If you want to access files or directories in external storage, you must declare http://tizen.org/privilege/externalstorage.\n
117 * You must release @a path using free().
119 * @param[in] storage_id The storage device
120 * @param[out] path The absolute path to the storage directory
122 * @return @c 0 on success,
123 * otherwise a negative error value
125 * @retval #STORAGE_ERROR_NONE Successful
126 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
127 * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory
128 * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
130 * @see storage_get_state()
132 int storage_get_root_directory(int storage_id, char **path);
135 * @brief Enumeration of the storage directory types
136 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
139 STORAGE_DIRECTORY_IMAGES, /**< Image directory */
140 STORAGE_DIRECTORY_SOUNDS, /**< Sounds directory */
141 STORAGE_DIRECTORY_VIDEOS, /**< Videos directory */
142 STORAGE_DIRECTORY_CAMERA, /**< Camera directory */
143 STORAGE_DIRECTORY_DOWNLOADS, /**< Downloads directory */
144 STORAGE_DIRECTORY_MUSIC, /**< Music directory */
145 STORAGE_DIRECTORY_DOCUMENTS, /**< Documents directory */
146 STORAGE_DIRECTORY_OTHERS, /**< Others directory */
147 STORAGE_DIRECTORY_SYSTEM_RINGTONES, /**< System ringtones directory. Only available for internal storage. */
148 STORAGE_DIRECTORY_MAX
149 } storage_directory_e;
152 * @brief Gets the absolute path to the each directory of the given storage.
153 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
155 * @remarks Files saved on the internal/external storage are readable or writable by all applications.\n
156 * When an application is uninstalled, the files written by that application are not removed from the internal/external storage.\n
157 * The directory path may not exist, so you must make sure that it exists before using it.\n
158 * 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
159 * If you want to access files or directories in #STORAGE_DIRECTORY_SYSTEM_RINGTONES, you must declare %http://tizen.org/privilege/systemsettings.\n
160 * If you want to access files or directories in external storage, you must declare http://tizen.org/privilege/externalstorage.\n
161 * You must release @a path using free().
163 * @param[in] storage_id The storage device
164 * @param[in] type The directory type
165 * @param[out] path The absolute path to the directory type
167 * @return @c 0 on success,
168 * otherwise a negative error value
170 * @retval #STORAGE_ERROR_NONE Successful
171 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
172 * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory
173 * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
175 * @see storage_get_state()
177 int storage_get_directory(int storage_id, storage_directory_e type, char **path);
180 * @brief Gets the type of the given storage.
182 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
184 * @param[in] storage_id The storage device
185 * @param[out] type The type of the storage
187 * @return @c 0 on success,
188 * otherwise a negative error value
190 * @retval #STORAGE_ERROR_NONE Successful
191 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
192 * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
194 int storage_get_type(int storage_id, storage_type_e *type);
197 * @brief Gets the current state of the given storage.
199 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
201 * @param[in] storage_id The storage device
202 * @param[out] state The current state of the storage
204 * @return @c 0 on success,
205 * otherwise a negative error value
207 * @retval #STORAGE_ERROR_NONE Successful
208 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
209 * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
211 * @see storage_get_root_directory()
212 * @see storage_get_total_space()
213 * @see storage_get_available_space()
215 int storage_get_state(int storage_id, storage_state_e *state);
218 * @brief Called when the state of storage changes
220 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
222 * @param[in] storage_id The unique storage ID
223 * @param[in] state The current state of the storage
224 * @param[in] user_data The user data passed from the foreach function
226 * @pre storage_set_state_changed_cb() will invoke this callback function.
227 * @see storage_set_state_changed_cb()
228 * @see storage_unset_state_changed_cb()
230 typedef void (*storage_state_changed_cb)(int storage_id, storage_state_e state, void *user_data);
233 * @brief Registers a callback function to be invoked when the state of the storage changes.
235 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
237 * @param[in] storage_id The storage device
238 * @param[in] callback The callback function to register
239 * @param[in] user_data The user data to be passed to the callback function
241 * @return @c 0 on success,
242 * otherwise a negative error value
244 * @retval #STORAGE_ERROR_NONE Successful
245 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
246 * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
247 * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
249 * @post storage_state_changed_cb() will be invoked if the state of the registered storage changes.
250 * @see storage_state_changed_cb()
251 * @see storage_unset_state_changed_cb()
253 int storage_set_state_changed_cb(int storage_id, storage_state_changed_cb callback, void *user_data);
256 * @brief Unregisters the callback function.
258 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
260 * @param[in] storage_id The storage device to monitor
261 * @param[in] callback The callback function to register
263 * @return @c 0 on success,
264 * otherwise a negative error value
266 * @retval #STORAGE_ERROR_NONE Successful
267 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
268 * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
269 * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
271 * @see storage_state_changed_cb()
272 * @see storage_set_state_changed_cb()
274 int storage_unset_state_changed_cb(int storage_id, storage_state_changed_cb callback);
277 * @brief Enumeration of storage device types
281 STORAGE_DEV_EXT_SDCARD = 1001, /**< sdcard device (external storage) */
282 STORAGE_DEV_EXT_USB_MASS_STORAGE, /**< USB storage device (external storage) */
286 * @brief Called when the state of a storage type changes.
290 * @param[in] storage_id The unique storage ID
291 * @param[in] type The type of the storage device
292 * @param[in] state The state of the storage
293 * @param[in] fstype The type of the file system
294 * @param[in] fsuuid The uuid of the file system
295 * @param[in] mountpath The mount path of the file system
296 * @param[in] primary The primary partition
297 * @param[in] flags The flags for the storage status
298 * @param[in] user_data The user data
300 * @pre storage_set_changed_cb() will invoke this callback function.
301 * @see storage_set_changed_cb()
302 * @see storage_unset_changed_cb()
304 typedef void (*storage_changed_cb)(int storage_id,
305 storage_dev_e dev, storage_state_e state,
306 const char *fstype, const char *fsuuid, const char *mountpath,
307 bool primary, int flags, void *user_data);
310 * @brief Registers a callback function to be invoked when the state of the specified storage device type changes.
314 * @param[in] type The type of the storage device
315 * @param[in] callback The callback function to register
316 * @param[in] user_data The user data to be passed to the callback function
318 * @return @c 0 on success,
319 * otherwise a negative error value
321 * @retval #STORAGE_ERROR_NONE Successful
322 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
323 * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
324 * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
326 * @post storage_changed_cb() will be invoked if the state of the registered storage type changes.
327 * @see storage_changed_cb()
328 * @see storage_unset_changed_cb()
330 int storage_set_changed_cb(storage_type_e type, storage_changed_cb callback, void *user_data);
333 * @brief Unregisters the callback function for storage type state changes.
337 * @param[in] type The type of the the storage device
338 * @param[in] callback The callback function to unregister
340 * @return @c 0 on success,
341 * otherwise a negative error value
343 * @retval #STORAGE_ERROR_NONE Successful
344 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
345 * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
346 * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
348 * @see storage_changed_cb()
349 * @see storage_set_changed_cb()
351 int storage_unset_changed_cb(storage_type_e type, storage_changed_cb callback);
354 * @brief Gets the total space of the given storage in bytes.
356 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
358 * @param[in] storage_id The storage device
359 * @param[out] bytes The total space size of the storage (bytes)
361 * @return @c 0 on success,
362 * otherwise a negative error value
364 * @retval #STORAGE_ERROR_NONE Successful
365 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
366 * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
367 * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
369 * @see storage_get_state()
370 * @see storage_get_available_space()
372 int storage_get_total_space(int storage_id, unsigned long long *bytes);
375 * @brief Gets the available space size of the given storage in bytes.
377 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
379 * @param[in] storage_id The storage device
380 * @param[out] bytes The available space size of the storage (bytes)
382 * @return @c 0 on success,
383 * otherwise a negative error value
385 * @retval #STORAGE_ERROR_NONE Successful
386 * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
387 * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
388 * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
390 * @see storage_get_state()
391 * @see storage_get_total_space()
393 int storage_get_available_space(int storage_id, unsigned long long *bytes);