[IoTConnectivity] Added Base implementation
[platform/core/csapi/iotcon.git] / Tizen.Network.IoTConnectivity / Interop / Interop.IoTConnectivity.Client.cs
1 /// Copyright 2016 by Samsung Electronics, Inc.,
2 ///
3 /// This software is the confidential and proprietary information
4 /// of Samsung Electronics, Inc. ("Confidential Information"). You
5 /// shall not disclose such Confidential Information and shall use
6 /// it only in accordance with the terms of the license agreement
7 /// you entered into with Samsung.
8
9 using System;
10 using System.Runtime.InteropServices;
11
12 internal static partial class Interop
13 {
14     internal static partial class IoTConnectivity
15     {
16         internal static partial class Client
17         {
18             internal static partial class DeviceInformation
19             {
20                 internal delegate void DeviceInformationCallback(IntPtr deviceInfoHandle, int result, IntPtr userData);
21
22                 internal enum Property
23                 {
24                     Name = 0,
25                     SpecVersion,
26                     Id,
27                     DataModelVersion,
28                 }
29
30                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_get_device_info")]
31                 internal static extern int Get(string hostAddress, int connectivityType, DeviceInformationCallback cb, IntPtr userData);
32
33                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_device_info_get_property")]
34                 internal static extern int GetProperty(IntPtr deviceInfoHandle, int property, out string value);
35             }
36
37             internal static partial class PlatformInformation
38             {
39                 internal delegate void PlatformInformationCallback(IntPtr platformInfoHandle, int result, IntPtr userData);
40
41                 internal enum Propery
42                 {
43                     Id = 0,
44                     MfgName,
45                     MfgUrl,
46                     ModelNumber,
47                     DateOfMfg,
48                     PlatformVer,
49                     OsVer,
50                     HardwareVer,
51                     FirmwareVer,
52                     SupportUrl,
53                     SystemTime
54                 }
55
56                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_get_platform_info")]
57                 internal static extern int Get(string hostAddress, int connectivityType, PlatformInformationCallback cb, IntPtr userData);
58
59                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_platform_info_get_property")]
60                 internal static extern int GetProperty(IntPtr platformInfoHandle, int property, out string value);
61             }
62
63             internal static partial class RemoteResource
64             {
65                 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
66                 internal delegate void ResponseCallback(IntPtr resource, int err, int requestType, IntPtr response, IntPtr userData);
67
68                 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
69                 internal delegate void ObserveCallback(IntPtr resource, int err, int sequenceNumber, IntPtr response, IntPtr userData);
70
71                 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
72                 internal delegate void CachedRepresentationChangedCallback(IntPtr resource, IntPtr representation, IntPtr userData);
73
74                 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
75                 internal delegate void StateChangedCallback(IntPtr resource, int state, IntPtr userData);
76
77                 internal enum ConnectivityType
78                 {
79                     None = 0,
80                     Ipv4,
81                     Ipv6
82                 }
83
84                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_create")]
85                 internal static extern int Create(string hostAddress, int connectivityType, string uriPath, int properties, IntPtr resourceTypes, IntPtr resourceInterfaces, out IntPtr remoteResource);
86
87                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_destroy")]
88                 internal static extern void Destroy(IntPtr resource);
89
90                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_clone")]
91                 internal static extern int Clone(IntPtr src, out IntPtr dest);
92
93                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_observe_register")]
94                 internal static extern int RegisterObserve(IntPtr resource, int observePolicy, IntPtr query, ObserveCallback cb, IntPtr userData);
95
96                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_observe_deregister")]
97                 internal static extern int DeregisterObserve(IntPtr resource);
98
99                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get")]
100                 internal static extern int Get(IntPtr resource, IntPtr query, ResponseCallback cb, IntPtr userData);
101
102                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_put")]
103                 internal static extern int Put(IntPtr resource, IntPtr repr, IntPtr query, ResponseCallback cb, IntPtr userData);
104
105                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_post")]
106                 internal static extern int Post(IntPtr resource, IntPtr repr, IntPtr query, ResponseCallback cb, IntPtr userData);
107
108                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_delete")]
109                 internal static extern int Delete(IntPtr resource, ResponseCallback cb, IntPtr userData);
110
111                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_start_caching")]
112                 internal static extern int StartCaching(IntPtr resource, CachedRepresentationChangedCallback cb, IntPtr userData);
113
114                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_stop_caching")]
115                 internal static extern int StopCaching(IntPtr resource);
116
117                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_start_monitoring")]
118                 internal static extern int StartMonitoring(IntPtr resource, StateChangedCallback cb, IntPtr userData);
119
120                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_stop_monitoring")]
121                 internal static extern int StopMonitoring(IntPtr resource);
122
123                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_uriPath")]
124                 internal static extern int GetUriPath(IntPtr resource, out string uriPath);
125
126                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_connectivity_type")]
127                 internal static extern int GetConnectivityType(IntPtr resource, out int connectivityType);
128
129                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_host_address")]
130                 internal static extern int GetHostAddress(IntPtr resource, out string hostAddress);
131
132                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_device_id")]
133                 internal static extern int GetDeviceId(IntPtr resource, out string deviceId);
134
135                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_types")]
136                 internal static extern int GetTypes(IntPtr resource, out IntPtr types);
137
138                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_interfaces")]
139                 internal static extern int GetInterfaces(IntPtr resource, out IntPtr ifaces);
140
141                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_properties")]
142                 internal static extern int GetProperties(IntPtr resource, out int properties);
143
144                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_options")]
145                 internal static extern int GetOptions(IntPtr resource, out IntPtr options);
146
147                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_set_options")]
148                 internal static extern int SetOptions(IntPtr resource, IntPtr options);
149
150                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_cached_representation")]
151                 internal static extern int GetCachedRepresentation(IntPtr resource, out IntPtr representation);
152
153                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_time_interval")]
154                 internal static extern int GetTimeInterval(IntPtr resource, out int timeInterval);
155
156                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_set_time_interval")]
157                 internal static extern int SetTimeInterval(IntPtr resource, int timeInterval);
158             }
159
160             internal static partial class IoTCon
161             {
162                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_initialize")]
163                 internal static extern int Initialize();
164
165                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_deinitialize")]
166                 internal static extern void Deinitialize();
167
168                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_get_timeout")]
169                 internal static extern int GetTimeout(out int timeoutSeconds);
170
171                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_set_timeout")]
172                 internal static extern int SetTimeout(int timeoutSeconds);
173             }
174
175             internal static partial class ResourceFinder
176             {
177                 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
178                 internal delegate void FoundResourceCallback(IntPtr remoteResourceHandle, int result, IntPtr userData);
179
180                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_find_resource")]
181                 internal static extern int AddResourceFoundCb(string hostAddress, int connectivityType, string resourceType, bool isSecure, FoundResourceCallback cb, IntPtr userData);
182             }
183
184             internal static partial class Presence
185             {
186                 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
187                 internal delegate void PresenceCallback(IntPtr presenceResponseHandle, int err, IntPtr response, IntPtr userData);
188
189                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_add_presence_cb")]
190                 internal static extern int AddPresenceCb(string hostAddress, int connectivityType, string resourceType, PresenceCallback cb, IntPtr userData, out IntPtr presenceHandle);
191
192                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remove_presence_cb")]
193                 internal static extern int RemovePresenceCb(IntPtr presenceHandle);
194
195                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_get_host_address")]
196                 internal static extern int GetHostAddress(IntPtr presence, out string hostAddress);
197
198                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_get_connectivity_type")]
199                 internal static extern int GetConnectivityType(IntPtr presence, out int connectivityType);
200
201                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_get_resource_type")]
202                 internal static extern int GetResourceType(IntPtr presence, out string resourceType);
203             }
204
205             internal static partial class PresenceResponse
206             {
207                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_result")]
208                 internal static extern int GetResult(IntPtr response, out int result);
209
210                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_trigger")]
211                 internal static extern int GetTrigger(IntPtr response, out int trigger);
212
213                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_host_address")]
214                 internal static extern int GetHostAddress(IntPtr response, out string hostAddress);
215
216                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_connectivity_type")]
217                 internal static extern int GetConnectivityType(IntPtr response, out int connectivityType);
218
219                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_resource_type")]
220                 internal static extern int GetResourceType(IntPtr response, out string resourceType);
221             }
222         }
223     }
224 }