2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Runtime.InteropServices;
20 internal static partial class Interop
22 internal static partial class IoTConnectivity
24 internal static partial class Common
26 internal enum DataType
39 internal static partial class ResourceTypes
41 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
42 internal delegate bool ForeachCallback(string type, IntPtr userData);
44 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_create")]
45 internal static extern int Create(out IntPtr types);
47 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_destroy")]
48 internal static extern void Destroy(IntPtr types);
50 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_add")]
51 internal static extern int Add(IntPtr types, string type);
53 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_remove")]
54 internal static extern int Remove(IntPtr types, string type);
56 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_foreach")]
57 internal static extern int Foreach(IntPtr types, ForeachCallback cb, IntPtr userData);
59 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_clone")]
60 internal static extern int Clone(IntPtr src, out IntPtr dest);
63 internal static partial class ResourceInterfaces
65 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
66 internal delegate bool ForeachCallback(string iface, IntPtr userData);
68 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_create")]
69 internal static extern int Create(out IntPtr ifaces);
71 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_destroy")]
72 internal static extern void Destroy(IntPtr ifaces);
74 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_add")]
75 internal static extern int Add(IntPtr ifaces, string iface);
77 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_remove")]
78 internal static extern int Remove(IntPtr ifaces, string iface);
80 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_foreach")]
81 internal static extern int Foreach(IntPtr ifaces, ForeachCallback cb, IntPtr userData);
83 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_clone")]
84 internal static extern int Clone(IntPtr src, out IntPtr dest);
87 internal static partial class Attributes
89 internal delegate bool AttributesCallback(IntPtr attributes, string key, IntPtr userData);
91 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_create")]
92 internal static extern int Create(out IntPtr attributes);
94 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_destroy")]
95 internal static extern void Destroy(IntPtr attributes);
97 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_clone")]
98 internal static extern int Clone(IntPtr attributes, out IntPtr attributes_clone);
100 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_add_int")]
101 internal static extern int AddInt(IntPtr attributes, string key, int val);
103 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_add_bool")]
104 internal static extern int AddBool(IntPtr attributes, string key, bool val);
106 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_add_double")]
107 internal static extern int AddDouble(IntPtr attributes, string key, double val);
109 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_add_str")]
110 internal static extern int AddStr(IntPtr attributes, string key, string val);
112 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_add_byte_str")]
113 internal static extern int AddByteStr(IntPtr attributes, string key, byte[] val, int len);
115 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_add_list")]
116 internal static extern int AddList(IntPtr attributes, string key, IntPtr list);
118 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_add_attributes")]
119 internal static extern int AddAttributes(IntPtr dest, string key, IntPtr src);
121 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_add_null")]
122 internal static extern int AddNull(IntPtr attributes, string key);
124 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_int")]
125 internal static extern int GetInt(IntPtr attributes, string key, out int val);
127 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_bool")]
128 internal static extern int GetBool(IntPtr attributes, string key, out bool val);
130 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_double")]
131 internal static extern int GetDouble(IntPtr attributes, string key, out double val);
133 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_str")]
134 internal static extern int GetStr(IntPtr attributes, string key, out IntPtr val);
136 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_byte_str")]
137 internal static extern int GetByteStr(IntPtr attributes, string key, out IntPtr value, out int size);
139 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_list")]
140 internal static extern int GetList(IntPtr attributes, string key, out IntPtr list);
142 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_attributes")]
143 internal static extern int GetAttributes(IntPtr src, string key, out IntPtr dest);
145 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_is_null")]
146 internal static extern int IsNull(IntPtr attributes, string key, out bool isNull);
148 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_remove")]
149 internal static extern int Remove(IntPtr attributes, string key);
151 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_type")]
152 internal static extern int GetType(IntPtr attributes, string key, out DataType type);
154 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_foreach")]
155 internal static extern int Foreach(IntPtr attributes, AttributesCallback cb, IntPtr userData);
157 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_keys_count")]
158 internal static extern int GetKeysCount(IntPtr attributes, out int count);
161 internal static partial class Query
163 internal delegate bool QueryCallback(string key, string value, IntPtr userData);
165 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_create")]
166 internal static extern int Create(out IntPtr query);
168 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_destroy")]
169 internal static extern void Destroy(IntPtr query);
171 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_get_resource_type")]
172 internal static extern int GetResourceType(IntPtr query, out IntPtr resourceType);
174 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_get_interface")]
175 internal static extern int GetInterface(IntPtr query, out IntPtr resourceInterface);
177 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_set_resource_type")]
178 internal static extern int SetResourceType(IntPtr query, string resourceType);
180 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_set_interface")]
181 internal static extern int SetInterface(IntPtr query, string resourceInterface);
183 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_add")]
184 internal static extern int Add(IntPtr query, string key, string value);
186 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_remove")]
187 internal static extern int Remove(IntPtr query, string key);
189 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_lookup")]
190 internal static extern int Lookup(IntPtr query, string key, out IntPtr data);
192 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_foreach")]
193 internal static extern int Foreach(IntPtr query, QueryCallback cb, IntPtr userData);
196 internal static partial class Representation
198 internal delegate bool RepresentationChildrenCallback(IntPtr child, IntPtr userData);
200 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_create")]
201 internal static extern int Create(out IntPtr repr);
203 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_destroy")]
204 internal static extern void Destroy(IntPtr repr);
206 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_clone")]
207 internal static extern int Clone(IntPtr src, out IntPtr dest);
209 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_uri_path")]
210 internal static extern int SetUriPath(IntPtr repr, string uriPath);
212 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_uri_path")]
213 internal static extern int GetUriPath(IntPtr repr, out IntPtr uriPath);
215 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_resource_types")]
216 internal static extern int SetResourceTypes(IntPtr repr, IntPtr types);
218 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_resource_types")]
219 internal static extern int GetResourceTypes(IntPtr repr, out IntPtr types);
221 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_resource_interfaces")]
222 internal static extern int SetResourceInterfaces(IntPtr repr, IntPtr ifaces);
224 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_resource_interfaces")]
225 internal static extern int GetResourceInterfaces(IntPtr repr, out IntPtr ifaces);
227 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_attributes")]
228 internal static extern int SetAttributes(IntPtr repr, IntPtr attribs);
230 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_attributes")]
231 internal static extern int GetAttributes(IntPtr repr, out IntPtr attribs);
233 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_add_child")]
234 internal static extern int AddChild(IntPtr parent, IntPtr child);
236 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_remove_child")]
237 internal static extern int RemoveChild(IntPtr parent, IntPtr child);
239 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_foreach_children")]
240 internal static extern int ForeachChildren(IntPtr parent, RepresentationChildrenCallback cb, IntPtr userData);
242 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_children_count")]
243 internal static extern int GetChildrenCount(IntPtr parent, out int count);
245 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_nth_child")]
246 internal static extern int GetNthChild(IntPtr parent, int pos, out IntPtr child);
249 internal static partial class Options
251 internal delegate bool OptionsCallback(ushort id, string data, IntPtr userData);
253 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_create")]
254 internal static extern int Create(out IntPtr options);
256 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_destroy")]
257 internal static extern void Destroy(IntPtr options);
259 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_add")]
260 internal static extern int Add(IntPtr options, ushort id, string data);
262 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_remove")]
263 internal static extern int Remove(IntPtr options, ushort id);
265 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_lookup")]
266 internal static extern int Lookup(IntPtr options, ushort id, out IntPtr data);
268 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_foreach")]
269 internal static extern int ForEach(IntPtr options, OptionsCallback cb, IntPtr userData);
272 internal static partial class List
274 internal delegate bool IntCallback(int pos, int value, IntPtr userData);
276 internal delegate bool BoolCallback(int pos, bool value, IntPtr userData);
278 internal delegate bool DoubleCallback(int pos, double value, IntPtr userData);
280 internal delegate bool ByteStrCallback(int pos, byte[] value, int len, IntPtr userData);
282 internal delegate bool StrCallback(int pos, string value, IntPtr userData);
284 internal delegate bool ListCallback(int pos, IntPtr value, IntPtr userData);
286 internal delegate bool AttribsCallback(int pos, IntPtr value, IntPtr userData);
288 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_create")]
289 internal static extern int Create(DataType type, out IntPtr list);
291 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_destroy")]
292 internal static extern void Destroy(IntPtr list);
294 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_int")]
295 internal static extern int AddInt(IntPtr list, int val, int pos);
297 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_bool")]
298 internal static extern int AddBool(IntPtr list, bool val, int pos);
300 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_double")]
301 internal static extern int AddDouble(IntPtr list, double val, int pos);
303 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_str")]
304 internal static extern int AddStr(IntPtr list, string val, int pos);
306 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_byte_str")]
307 internal static extern int AddByteStr(IntPtr list, byte[] val, int len, int pos);
309 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_list")]
310 internal static extern int AddList(IntPtr list, IntPtr val, int pos);
312 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_attributes")]
313 internal static extern int AddAttributes(IntPtr list, IntPtr val, int pos);
315 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_int")]
316 internal static extern int GetNthInt(IntPtr list, int pos, out int val);
318 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_bool")]
319 internal static extern int GetNthBool(IntPtr list, int pos, out bool val);
321 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_double")]
322 internal static extern int GetNthDouble(IntPtr list, int pos, out double val);
324 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_str")]
325 internal static extern int GetNthStr(IntPtr list, int pos, out IntPtr val);
327 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_byte_str")]
328 internal static extern int GetNthByteStr(IntPtr list, int pos, out IntPtr val, out int len);
330 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_list")]
331 internal static extern int GetNthList(IntPtr src, int pos, out IntPtr dest);
333 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_attributes")]
334 internal static extern int GetNthAttributes(IntPtr list, int pos, out IntPtr attribs);
336 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_remove_nth")]
337 internal static extern int RemoveNth(IntPtr list, int pos);
339 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_type")]
340 internal static extern int GetType(IntPtr list, out int type);
342 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_length")]
343 internal static extern int GetLength(IntPtr list, out int length);
345 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_int")]
346 internal static extern int ForeachInt(IntPtr list, IntCallback cb, IntPtr userData);
348 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_bool")]
349 internal static extern int ForeachBool(IntPtr list, BoolCallback cb, IntPtr userData);
351 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_double")]
352 internal static extern int ForeachDouble(IntPtr list, DoubleCallback cb, IntPtr userData);
354 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_byte_str")]
355 internal static extern int ForeachByteStr(IntPtr list, ByteStrCallback cb, IntPtr userData);
357 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_str")]
358 internal static extern int ForeachStr(IntPtr list, StrCallback cb, IntPtr userData);
360 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_list")]
361 internal static extern int ForeachList(IntPtr list, ListCallback cb, IntPtr userData);
363 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_attributes")]
364 internal static extern int ForeachAttributes(IntPtr list, AttribsCallback cb, IntPtr userData);