Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.System.Storage / Interop / Interop.Storage.cs
1 /*
2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 using System;
18 using System.Runtime.InteropServices;
19
20 internal static partial class Interop
21 {
22     internal static partial class Storage
23     {
24         internal enum ErrorCode
25         {
26             None = Tizen.Internals.Errors.ErrorCode.None,
27             InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
28             OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
29             NotSupported = Tizen.Internals.Errors.ErrorCode.NoSuchDevice,
30             OperationFailed = -0x00020000 | 0x12,
31         }
32
33         // Any change here might require changes in Tizen.System.StorageArea enum
34         internal enum StorageArea
35         {
36             Internal = 0,
37             External = 1,
38         }
39
40         // Any change here might require changes in Tizen.System.StorageState enum
41         internal enum StorageState
42         {
43             Unmountable = -2,
44             Removed = -1,
45             Mounted = 0,
46             MountedReadOnly = 1,
47         }
48
49         // Any change here might require changes in Tizen.System.directoryType enum
50         internal enum DirectoryType
51         {
52             Images = 0,
53             Sounds = 1,
54             Videos = 2,
55             Camera = 3,
56             Downloads = 4,
57             Music = 5,
58             Documents = 6,
59             Others = 7,
60             Ringtones = 8,
61         }
62
63         [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
64         internal delegate void StorageStateChangedCallback(int id, StorageState state, IntPtr userData);
65
66         [DllImport(Libraries.Storage, EntryPoint = "storage_get_root_directory")]
67         internal static extern ErrorCode StorageGetRootDirectory(int id, out string path);
68
69         [DllImport(Libraries.Storage, EntryPoint = "storage_get_directory")]
70         internal static extern ErrorCode StorageGetAbsoluteDirectory(int id, DirectoryType type, out string path);
71
72         [DllImport(Libraries.Storage, EntryPoint = "storage_get_state")]
73         internal static extern ErrorCode StorageGetState(int id, out StorageState state);
74
75         [DllImport(Libraries.Storage, EntryPoint = "storage_get_type")]
76         internal static extern ErrorCode StorageGetType(int id, out StorageArea type);
77
78         [DllImport(Libraries.Storage, EntryPoint = "storage_set_state_changed_cb")]
79         internal static extern ErrorCode StorageSetStateChanged(int id, StorageStateChangedCallback callback, IntPtr userData);
80
81         [DllImport(Libraries.Storage, EntryPoint = "storage_unset_state_changed_cb")]
82         internal static extern ErrorCode StorageUnsetStateChanged(int id, StorageStateChangedCallback callback);
83
84         [DllImport(Libraries.Storage, EntryPoint = "storage_get_total_space")]
85         internal static extern ErrorCode StorageGetTotalSpace(int id, out ulong bytes);
86
87         [DllImport(Libraries.Storage, EntryPoint = "storage_get_available_space")]
88         internal static extern ErrorCode StorageGetAvailableSpace(int id, out ulong bytes);
89
90         [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
91         internal delegate bool StorageDeviceSupportedCallback(int storageID, StorageArea type, StorageState state, string rootDirectory, IntPtr userData);
92
93         [DllImport(Libraries.Storage, EntryPoint = "storage_foreach_device_supported")]
94         public static extern ErrorCode StorageManagerGetForeachDeviceSupported(StorageDeviceSupportedCallback callback, IntPtr userData);
95     }
96 }