storage: Remove profile version from header files
[platform/core/system/libstorage.git] / include / storage-expand.h
1 /*
2  * storage
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
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
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17
18
19 #ifndef __STORAGE_EXPAND_H__
20 #define __STORAGE_EXPAND_H__
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26
27  /**
28  * @addtogroup CAPI_SYSTEM_STORAGE_MODULE
29  * @{
30  */
31
32 #include <tizen.h>
33
34
35 /**
36  * @brief Enumeration for Storage of error codes.
37  * @since_tizen 2.3
38  */
39 typedef enum {
40         STORAGE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
41         STORAGE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
42         STORAGE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
43         STORAGE_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NO_SUCH_DEVICE, /**< Storage not supported */
44         STORAGE_ERROR_OPERATION_FAILED  = TIZEN_ERROR_SYSTEM_CLASS | 0x12, /**< Operation failed */
45 } storage_error_e;
46
47
48 /**
49  * @brief Enumeration for the storage types.
50  * @since_tizen 2.3
51  */
52 typedef enum {
53         STORAGE_TYPE_INTERNAL,          /**< Internal device storage (built-in storage in a device, non-removable) */
54         STORAGE_TYPE_EXTERNAL,          /**< External storage */
55         STORAGE_TYPE_EXTENDED_INTERNAL, /**< Extended internal storage (External storage used as internal storage) (Since 4.0) */
56 } storage_type_e;
57
58
59 /**
60  * @brief Enumeration for storage devices state.
61  * @since_tizen 2.3
62  */
63 typedef enum {
64         STORAGE_STATE_UNMOUNTABLE = -2, /**< Storage is present but cannot be mounted. Typically it happens if the file system of the storage is corrupted */
65         STORAGE_STATE_REMOVED = -1, /**< Storage is not present */
66         STORAGE_STATE_MOUNTED = 0, /**< Storage is present and mounted with read/write access */
67         STORAGE_STATE_MOUNTED_READ_ONLY = 1, /**< Storage is present and mounted with read only access */
68 } storage_state_e;
69
70
71 /**
72  * @brief Called to get information once for each supported storage.
73  * @since_tizen 2.3
74  * @param[in] storage_id The unique storage ID
75  * @param[in] type The type of the storage
76  * @param[in] state The current state of the storage
77  * @param[in] path The absolute path to the root directory of the storage
78  * @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
81  * @pre storage_foreach_device_supported() will invoke this callback function.
82  * @see storage_foreach_device_supported()
83  */
84 typedef bool (*storage_device_supported_cb)(int storage_id, storage_type_e type,
85                 storage_state_e state, const char *path, void *user_data);
86
87
88 /**
89  * @brief Retrieves all the 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.
92  * @since_tizen 2.3
93  * @param[in] callback The iteration callback function
94  * @param[in] user_data The user data to be passed to the callback function
95  * @return @c 0 on success,
96  *         otherwise a negative error value
97  * @retval #STORAGE_ERROR_NONE Successful
98  * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
99  * @post This function invokes storage_device_supported_cb() repeatedly for each supported device.
100  * @see storage_device_supported_cb()
101  */
102 int storage_foreach_device_supported(storage_device_supported_cb callback, void *user_data);
103
104
105 /**
106  * @brief Gets the absolute path to the root directory of the given storage.
107  * @since_tizen 2.3
108  * @remarks Files saved on the internal/external storage are readable or writable by all applications.\n
109  *          When an application is uninstalled, the files written by that application are not removed from the internal/external storage.\n
110  *          If you want to access files or directories in internal storage, you must declare %http://tizen.org/privilege/mediastorage.\n
111  *          If you want to access files or directories in external storage, you must declare %http://tizen.org/privilege/externalstorage.\n
112  *          Refer to <a href="https://docs.tizen.org/application/native/guides/security/privacy-related-permissions"><b>Privacy-related Permissions</b></a>.\n
113  *          You must release @a path using free().
114  * @param[in] storage_id The storage device
115  * @param[out] path The absolute path to the storage directory
116  * @return @c 0 on success,
117  *         otherwise a negative error value
118  * @retval #STORAGE_ERROR_NONE Successful
119  * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
120  * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory
121  * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
122  * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
123  * @see storage_get_state()
124  */
125 int storage_get_root_directory(int storage_id, char **path);
126
127
128 /**
129  * @brief Enumeration for the storage directory types.
130  * @since_tizen 2.3
131  */
132 typedef enum {
133         STORAGE_DIRECTORY_IMAGES, /**< Image directory */
134         STORAGE_DIRECTORY_SOUNDS, /**< Sounds directory */
135         STORAGE_DIRECTORY_VIDEOS, /**< Videos directory */
136         STORAGE_DIRECTORY_CAMERA, /**< Camera directory */
137         STORAGE_DIRECTORY_DOWNLOADS, /**< Downloads directory */
138         STORAGE_DIRECTORY_MUSIC, /**< Music directory */
139         STORAGE_DIRECTORY_DOCUMENTS, /**< Documents directory */
140         STORAGE_DIRECTORY_OTHERS, /**< Others directory */
141         STORAGE_DIRECTORY_SYSTEM_RINGTONES, /**< System ringtones directory. Only available for internal storage. */
142         STORAGE_DIRECTORY_MAX
143 } storage_directory_e;
144
145
146 /**
147  * @brief Gets the absolute path to the each directory of the given storage.
148  * @since_tizen 2.3
149  * @remarks Files saved on the internal/external storage are readable or writable by all applications.\n
150  *          When an application is uninstalled, the files written by that application are not removed from the internal/external storage.\n
151  *          The directory path may not exist, so you must make sure that it exists before using it.\n
152  *          If you want to access files or directories in internal storage, you must declare %http://tizen.org/privilege/mediastorage.\n
153  *          If you want to access files or directories in external storage, you must declare %http://tizen.org/privilege/externalstorage.\n
154  *          Refer to <a href="https://docs.tizen.org/application/native/guides/security/privacy-related-permissions"><b>Privacy-related Permissions</b></a>.\n
155  *          You must release @a path using free().
156  * @param[in] storage_id The storage device
157  * @param[in] type The directory type
158  * @param[out] path The absolute path to the directory type
159  * @return @c 0 on success,
160  *         otherwise a negative error value
161  * @retval #STORAGE_ERROR_NONE Successful
162  * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
163  * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory
164  * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
165  * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
166  * @see storage_get_state()
167  */
168 int storage_get_directory(int storage_id, storage_directory_e type, char **path);
169
170
171 /**
172  * @brief Gets the type of the given storage.
173  * @since_tizen 2.3
174  * @param[in] storage_id The storage device
175  * @param[out] type The type of the storage
176  * @return @c 0 on success,
177  *         otherwise a negative error value
178  * @retval #STORAGE_ERROR_NONE Successful
179  * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
180  * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory
181  * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
182  * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
183  */
184 int storage_get_type(int storage_id, storage_type_e *type);
185
186
187 /**
188  * @brief Gets the current state of the given storage.
189  * @since_tizen 2.3
190  * @param[in] storage_id The storage device
191  * @param[out] state The current state of the storage
192  * @return @c 0 on success,
193  *         otherwise a negative error value
194  * @retval #STORAGE_ERROR_NONE Successful
195  * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
196  * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory
197  * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
198  * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
199  * @see storage_get_root_directory()
200  * @see storage_get_total_space()
201  * @see storage_get_available_space()
202  */
203 int storage_get_state(int storage_id, storage_state_e *state);
204
205
206 /**
207  * @brief Called when the state of storage changes.
208  * @since_tizen 2.3
209  * @param[in] storage_id The unique storage ID
210  * @param[in] state The current state of the storage
211  * @param[in] user_data The user data passed from the foreach function
212  * @pre storage_set_state_changed_cb() will invoke this callback function.
213  * @see storage_set_state_changed_cb()
214  * @see storage_unset_state_changed_cb()
215  */
216 typedef void (*storage_state_changed_cb)(int storage_id, storage_state_e state, void *user_data);
217
218
219 /**
220  * @brief Registers a callback function to be invoked when the state of the storage changes.
221  * @since_tizen 2.3
222  * @param[in] storage_id The storage device
223  * @param[in] callback The callback function to register
224  * @param[in] user_data The user data to be passed to the callback function
225  * @return @c 0 on success,
226  *         otherwise a negative error value
227  * @retval #STORAGE_ERROR_NONE Successful
228  * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
229  * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
230  * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
231  * @post storage_state_changed_cb() will be invoked if the state of the registered storage changes.
232  * @see storage_state_changed_cb()
233  * @see storage_unset_state_changed_cb()
234  */
235 int storage_set_state_changed_cb(int storage_id, storage_state_changed_cb callback, void *user_data);
236
237
238 /**
239  * @brief Unregisters the callback function.
240  * @since_tizen 2.3
241  * @param[in] storage_id The storage device to monitor
242  * @param[in] callback The callback function to register
243  * @return @c 0 on success,
244  *         otherwise a negative error value
245  * @retval #STORAGE_ERROR_NONE Successful
246  * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
247  * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
248  * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
249  * @see storage_state_changed_cb()
250  * @see storage_set_state_changed_cb()
251  */
252 int storage_unset_state_changed_cb(int storage_id, storage_state_changed_cb callback);
253
254
255 /**
256  * @brief Enumeration for storage device types.
257  * @since_tizen 3.0
258  */
259 typedef enum {
260         STORAGE_DEV_EXT_SDCARD = 1001,     /**< SD card device (external storage) */
261         STORAGE_DEV_EXT_USB_MASS_STORAGE,  /**< USB storage device (external storage) */
262         STORAGE_DEV_EXTENDED_INTERNAL,     /**< Extended internal storage device (External storage used as internal storage) (Since 4.0) */
263 } storage_dev_e;
264
265
266 /**
267  * @brief Called when the state of a storage type changes.
268  * @since_tizen 3.0
269  * @param[in] storage_id The unique storage ID
270  * @param[in] dev The type of the external storage device
271  * @param[in] state The state of the storage
272  * @param[in] fstype The type of the file system
273  * @param[in] fsuuid The uuid of the file system
274  * @param[in] mountpath The mount path of the file system
275  * @param[in] primary The primary partition
276  * @param[in] flags The flags for the storage status
277  * @param[in] user_data The user data
278  * @pre storage_set_changed_cb() will invoke this callback function.
279  * @see storage_set_changed_cb()
280  * @see storage_unset_changed_cb()
281  */
282 typedef void (*storage_changed_cb)(int storage_id,
283                 storage_dev_e dev, storage_state_e state,
284                 const char *fstype, const char *fsuuid, const char *mountpath,
285                 bool primary, int flags, void *user_data);
286
287
288 /**
289  * @brief Registers a callback function to be invoked when the state of the specified storage device type changes.
290  * @since_tizen 3.0
291  * @param[in] type The type of the storage device
292  * @param[in] callback The callback function to register
293  * @param[in] user_data The user data to be passed to the callback function
294  * @return @c 0 on success,
295  *         otherwise a negative error value
296  * @retval #STORAGE_ERROR_NONE Successful
297  * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
298  * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
299  * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
300  * @post storage_changed_cb() will be invoked if the state of the registered storage type changes.
301  * @see storage_changed_cb()
302  * @see storage_unset_changed_cb()
303  */
304 int storage_set_changed_cb(storage_type_e type, storage_changed_cb callback, void *user_data);
305
306
307 /**
308  * @brief Unregisters the callback function for storage type state changes.
309  * @since_tizen 3.0
310  * @param[in] type The type of the the storage device
311  * @param[in] callback The callback function to unregister
312  * @return @c 0 on success,
313  *         otherwise a negative error value
314  * @retval #STORAGE_ERROR_NONE Successful
315  * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
316  * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
317  * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
318  * @see storage_changed_cb()
319  * @see storage_set_changed_cb()
320  */
321 int storage_unset_changed_cb(storage_type_e type, storage_changed_cb callback);
322
323
324 /**
325  * @brief Gets the total space of the given storage in bytes.
326  * @since_tizen 2.3
327  * @param[in] storage_id The storage device
328  * @param[out] bytes The total space size of the storage (bytes)
329  * @return @c 0 on success,
330  *         otherwise a negative error value
331  * @retval #STORAGE_ERROR_NONE Successful
332  * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
333  * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory
334  * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
335  * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
336  * @see storage_get_state()
337  * @see storage_get_available_space()
338  */
339 int storage_get_total_space(int storage_id, unsigned long long *bytes);
340
341
342 /**
343  * @brief Gets the available space size of the given storage in bytes.
344  * @since_tizen 2.3
345  * @param[in] storage_id The storage device
346  * @param[out] bytes The available space size of the storage (bytes)
347  * @return @c 0 on success,
348  *         otherwise a negative error value
349  * @retval #STORAGE_ERROR_NONE Successful
350  * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter
351  * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory
352  * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported
353  * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed
354  * @see storage_get_state()
355  * @see storage_get_total_space()
356  */
357 int storage_get_available_space(int storage_id, unsigned long long *bytes);
358
359
360 /**
361  * @brief Gets the type and the kind of external device for the given storage id.
362  *
363  * @since_tizen 5.0
364  *
365  * @remarks This function works only for external storages.
366  * If @a type is #STORAGE_TYPE_INTERNAL, this function returns #STORAGE_ERROR_INVALID_PARAMETER and @a dev is unchanged.
367  *
368  * @param[in] storage_id The storage id
369  * @param[out] type The storage @a type (internal or external). If @a type is #STORAGE_TYPE_INTERNAL, this function returns #STORAGE_ERROR_INVALID_PARAMETER and @a dev is unchanged.
370  * @param[out] dev The storage device for external storage.
371  *
372  * @return @c 0 on success,
373  *         otherwise a negative error value
374  *
375  * @retval #STORAGE_ERROR_NONE               Successful
376  * @retval #STORAGE_ERROR_INVALID_PARAMETER  Invalid parameter
377  * @retval #STORAGE_ERROR_OUT_OF_MEMORY      Out of memory
378  * @retval #STORAGE_ERROR_NOT_SUPPORTED      Storage not supported
379  * @retval #STORAGE_ERROR_OPERATION_FAILED   Operation failed
380  */
381 int storage_get_type_dev(int storage_id, storage_type_e *type, storage_dev_e *dev);
382
383
384 /**
385  * @}
386  */
387
388 #ifdef __cplusplus
389 }
390 #endif
391 #endif