change license
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.IoTConnectivity / Interop / Interop.IoTConnectivity.Client.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
18 using System;
19 using System.Runtime.InteropServices;
20
21 internal static partial class Interop
22 {
23     internal static partial class IoTConnectivity
24     {
25         internal static partial class Client
26         {
27             internal static partial class DeviceInformation
28             {
29                 internal delegate bool DeviceInformationCallback(IntPtr deviceInfoHandle, int result, IntPtr userData);
30
31                 internal enum Property
32                 {
33                     Name = 0,
34                     SpecVersion,
35                     Id,
36                     DataModelVersion,
37                 }
38
39                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_find_device_info")]
40                 internal static extern int Find(string hostAddress, int connectivityType, IntPtr query, DeviceInformationCallback cb, IntPtr userData);
41
42                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_device_info_get_property")]
43                 internal static extern int GetProperty(IntPtr deviceInfoHandle, int property, out IntPtr value);
44             }
45
46             internal static partial class PlatformInformation
47             {
48                 internal delegate bool PlatformInformationCallback(IntPtr platformInfoHandle, int result, IntPtr userData);
49
50                 internal enum Propery
51                 {
52                     Id = 0,
53                     MfgName,
54                     MfgUrl,
55                     ModelNumber,
56                     DateOfMfg,
57                     PlatformVer,
58                     OsVer,
59                     HardwareVer,
60                     FirmwareVer,
61                     SupportUrl,
62                     SystemTime
63                 }
64
65                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_find_platform_info")]
66                 internal static extern int Find(string hostAddress, int connectivityType, IntPtr query, PlatformInformationCallback cb, IntPtr userData);
67
68                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_platform_info_get_property")]
69                 internal static extern int GetProperty(IntPtr platformInfoHandle, int property, out IntPtr value);
70             }
71
72             internal static partial class RemoteResource
73             {
74                 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
75                 internal delegate void ResponseCallback(IntPtr resource, int err, int requestType, IntPtr response, IntPtr userData);
76
77                 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
78                 internal delegate void ObserveCallback(IntPtr resource, int err, int sequenceNumber, IntPtr response, IntPtr userData);
79
80                 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
81                 internal delegate void CachedRepresentationChangedCallback(IntPtr resource, IntPtr representation, IntPtr userData);
82
83                 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
84                 internal delegate void StateChangedCallback(IntPtr resource, int state, IntPtr userData);
85
86                 internal enum ConnectivityType
87                 {
88                     None = 0,
89                     Ipv4,
90                     Ipv6
91                 }
92
93                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_create")]
94                 internal static extern int Create(string hostAddress, int connectivityType, string uriPath, int properties, IntPtr resourceTypes, IntPtr resourceInterfaces, out IntPtr remoteResource);
95
96                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_destroy")]
97                 internal static extern void Destroy(IntPtr resource);
98
99                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_clone")]
100                 internal static extern int Clone(IntPtr src, out IntPtr dest);
101
102                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_observe_register")]
103                 internal static extern int RegisterObserve(IntPtr resource, int observePolicy, IntPtr query, ObserveCallback cb, IntPtr userData);
104
105                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_observe_deregister")]
106                 internal static extern int DeregisterObserve(IntPtr resource);
107
108                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get")]
109                 internal static extern int Get(IntPtr resource, IntPtr query, ResponseCallback cb, IntPtr userData);
110
111                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_put")]
112                 internal static extern int Put(IntPtr resource, IntPtr repr, IntPtr query, ResponseCallback cb, IntPtr userData);
113
114                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_post")]
115                 internal static extern int Post(IntPtr resource, IntPtr repr, IntPtr query, ResponseCallback cb, IntPtr userData);
116
117                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_delete")]
118                 internal static extern int Delete(IntPtr resource, ResponseCallback cb, IntPtr userData);
119
120                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_start_caching")]
121                 internal static extern int StartCaching(IntPtr resource, CachedRepresentationChangedCallback cb, IntPtr userData);
122
123                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_stop_caching")]
124                 internal static extern int StopCaching(IntPtr resource);
125
126                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_start_monitoring")]
127                 internal static extern int StartMonitoring(IntPtr resource, StateChangedCallback cb, IntPtr userData);
128
129                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_stop_monitoring")]
130                 internal static extern int StopMonitoring(IntPtr resource);
131
132                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_uri_path")]
133                 internal static extern int GetUriPath(IntPtr resource, out IntPtr uriPath);
134
135                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_connectivity_type")]
136                 internal static extern int GetConnectivityType(IntPtr resource, out int connectivityType);
137
138                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_host_address")]
139                 internal static extern int GetHostAddress(IntPtr resource, out IntPtr hostAddress);
140
141                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_device_id")]
142                 internal static extern int GetDeviceId(IntPtr resource, out IntPtr deviceId);
143
144                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_types")]
145                 internal static extern int GetTypes(IntPtr resource, out IntPtr types);
146
147                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_interfaces")]
148                 internal static extern int GetInterfaces(IntPtr resource, out IntPtr ifaces);
149
150                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_policies")]
151                 internal static extern int GetPolicies(IntPtr resource, out int properties);
152
153                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_options")]
154                 internal static extern int GetOptions(IntPtr resource, out IntPtr options);
155
156                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_set_options")]
157                 internal static extern int SetOptions(IntPtr resource, IntPtr options);
158
159                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_cached_representation")]
160                 internal static extern int GetCachedRepresentation(IntPtr resource, out IntPtr representation);
161
162                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_checking_interval")]
163                 internal static extern int GetTimeInterval(IntPtr resource, out int timeInterval);
164
165                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_set_checking_interval")]
166                 internal static extern int SetTimeInterval(IntPtr resource, int timeInterval);
167
168                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_device_name")]
169                 internal static extern int GetDeviceName(IntPtr resource, out IntPtr deviceName);
170             }
171
172             internal static partial class IoTCon
173             {
174                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_initialize")]
175                 internal static extern int Initialize(string filePath);
176
177                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_deinitialize")]
178                 internal static extern void Deinitialize();
179
180                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_get_timeout")]
181                 internal static extern int GetTimeout(out int timeoutSeconds);
182
183                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_set_timeout")]
184                 internal static extern int SetTimeout(int timeoutSeconds);
185
186                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_polling_get_interval")]
187                 internal static extern int GetPollingInterval(out int interval);
188
189                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_polling_set_interval")]
190                 internal static extern int SetPollingInterval(int interval);
191
192                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_polling_invoke")]
193                 internal static extern int InvokePolling();
194             }
195
196             internal static partial class ResourceFinder
197             {
198                 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
199                 internal delegate bool FoundResourceCallback(IntPtr remoteResourceHandle, int result, IntPtr userData);
200
201                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_find_resource")]
202                 internal static extern int AddResourceFoundCb(string hostAddress, int connectivityType, IntPtr query, FoundResourceCallback cb, IntPtr userData);
203             }
204
205             internal static partial class Presence
206             {
207                 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
208                 internal delegate void PresenceCallback(IntPtr presenceResponseHandle, int err, IntPtr response, IntPtr userData);
209
210                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_add_presence_cb")]
211                 internal static extern int AddPresenceCb(string hostAddress, int connectivityType, string resourceType, PresenceCallback cb, IntPtr userData, out IntPtr presenceHandle);
212
213                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remove_presence_cb")]
214                 internal static extern int RemovePresenceCb(IntPtr presenceHandle);
215
216                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_get_host_address")]
217                 internal static extern int GetHostAddress(IntPtr presence, out IntPtr hostAddress);
218
219                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_get_connectivity_type")]
220                 internal static extern int GetConnectivityType(IntPtr presence, out int connectivityType);
221
222                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_get_resource_type")]
223                 internal static extern int GetResourceType(IntPtr presence, out IntPtr resourceType);
224             }
225
226             internal static partial class PresenceResponse
227             {
228                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_result")]
229                 internal static extern int GetResult(IntPtr response, out int result);
230
231                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_trigger")]
232                 internal static extern int GetTrigger(IntPtr response, out int trigger);
233
234                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_host_address")]
235                 internal static extern int GetHostAddress(IntPtr response, out IntPtr hostAddress);
236
237                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_connectivity_type")]
238                 internal static extern int GetConnectivityType(IntPtr response, out int connectivityType);
239
240                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_resource_type")]
241                 internal static extern int GetResourceType(IntPtr response, out IntPtr resourceType);
242             }
243         }
244     }
245 }