1 /// Copyright 2016 by Samsung Electronics, Inc.,
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.
10 using System.Runtime.InteropServices;
12 internal static partial class Interop
14 internal static partial class IoTConnectivity
16 internal static partial class Common
18 internal enum DataType
31 internal static partial class ResourceTypes
33 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
34 internal delegate bool ForeachCallback(string type, IntPtr userData);
36 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_create")]
37 internal static extern int Create(out IntPtr types);
39 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_destroy")]
40 internal static extern void Destroy(IntPtr types);
42 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_add")]
43 internal static extern int Add(IntPtr types, string type);
45 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_remove")]
46 internal static extern int Remove(IntPtr types, string type);
48 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_foreach")]
49 internal static extern int Foreach(IntPtr types, ForeachCallback cb, IntPtr userData);
51 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_clone")]
52 internal static extern int Clone(IntPtr src, out IntPtr dest);
55 internal static partial class ResourceInterfaces
57 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
58 internal delegate bool ForeachCallback(string iface, IntPtr userData);
60 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_create")]
61 internal static extern int Create(out IntPtr ifaces);
63 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_destroy")]
64 internal static extern void Destroy(IntPtr ifaces);
66 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_add")]
67 internal static extern int Add(IntPtr ifaces, string iface);
69 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_remove")]
70 internal static extern int Remove(IntPtr ifaces, string iface);
72 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_foreach")]
73 internal static extern int Foreach(IntPtr ifaces, ForeachCallback cb, IntPtr userData);
75 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_clone")]
76 internal static extern int Clone(IntPtr src, out IntPtr dest);
79 internal static partial class State
81 internal delegate bool StateCallback(IntPtr state, string key, IntPtr userData);
83 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_create")]
84 internal static extern int Create(out IntPtr state);
86 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_destroy")]
87 internal static extern void Destroy(IntPtr state);
89 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_clone")]
90 internal static extern int Clone(IntPtr state, out IntPtr dest);
92 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_int")]
93 internal static extern int AddInt(IntPtr state, string key, int val);
95 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_bool")]
96 internal static extern int AddBool(IntPtr state, string key, bool val);
98 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_double")]
99 internal static extern int AddDouble(IntPtr state, string key, double val);
101 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_str")]
102 internal static extern int AddStr(IntPtr state, string key, string val);
104 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_byte_str")]
105 internal static extern unsafe int AddByteStr(IntPtr state, string key, byte[] val, int len);
107 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_list")]
108 internal static extern int AddList(IntPtr state, string key, IntPtr list);
110 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_state")]
111 internal static extern int AddState(IntPtr dest, string key, IntPtr src);
113 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_null")]
114 internal static extern int AddNull(IntPtr state, string key);
116 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_int")]
117 internal static extern int GetInt(IntPtr state, string key, out int val);
119 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_bool")]
120 internal static extern int GetBool(IntPtr state, string key, out bool val);
122 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_double")]
123 internal static extern int GetDouble(IntPtr state, string key, out double val);
125 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_str")]
126 internal static extern int GetStr(IntPtr state, string key, out string val);
128 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_byte_str")]
129 internal static extern int GetByteStr(IntPtr state, string key, out IntPtr value, out int size);
131 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_list")]
132 internal static extern int GetList(IntPtr state, string key, out IntPtr list);
134 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_state")]
135 internal static extern int GetState(IntPtr src, string key, out IntPtr dest);
137 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_is_null")]
138 internal static extern int IsNull(IntPtr state, string key, out bool isNull);
140 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_remove")]
141 internal static extern int Remove(IntPtr state, string key);
143 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_type")]
144 internal static extern int GetType(IntPtr state, string key, out DataType type);
146 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_foreach")]
147 internal static extern int Foreach(IntPtr state, StateCallback cb, IntPtr userData);
149 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_keys_count")]
150 internal static extern int GetKeysCount(IntPtr state, out int count);
153 internal static partial class Query
155 internal delegate bool QueryCallback(string key, string value, IntPtr userData);
157 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_create")]
158 internal static extern int Create(out IntPtr query);
160 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_destroy")]
161 internal static extern void Destroy(IntPtr query);
163 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_get_resource_type")]
164 internal static extern int GetResourceType(IntPtr query, out string resourceType);
166 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_get_interface")]
167 internal static extern int GetInterface(IntPtr query, out string resourceInterface);
169 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_set_resource_type")]
170 internal static extern int SetResourceType(IntPtr query, string resourceType);
172 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_set_interface")]
173 internal static extern int SetInterface(IntPtr query, string resourceInterface);
175 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_add")]
176 internal static extern int Add(IntPtr query, string key, string value);
178 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_remove")]
179 internal static extern int Remove(IntPtr query, string key);
181 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_lookup")]
182 internal static extern int Lookup(IntPtr query, string key, out string data);
184 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_foreach")]
185 internal static extern int Foreach(IntPtr query, QueryCallback cb, IntPtr userData);
188 internal static partial class Representation
190 internal delegate bool RepresentationChildrenCallback(IntPtr child, IntPtr userData);
192 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_create")]
193 internal static extern int Create(out IntPtr repr);
195 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_destroy")]
196 internal static extern void Destroy(IntPtr repr);
198 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_clone")]
199 internal static extern int Clone(IntPtr src, out IntPtr dest);
201 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_uri_path")]
202 internal static extern int SetUriPath(IntPtr repr, string uriPath);
204 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_uri_path")]
205 internal static extern int GetUriPath(IntPtr repr, out string uriPath);
207 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_resource_types")]
208 internal static extern int SetResourceTypes(IntPtr repr, IntPtr types);
210 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_resource_types")]
211 internal static extern int GetResourceTypes(IntPtr repr, out IntPtr types);
213 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_resource_interfaces")]
214 internal static extern int SetResourceInterfaces(IntPtr repr, IntPtr ifaces);
216 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_resource_interfaces")]
217 internal static extern int GetResourceInterfaces(IntPtr repr, out IntPtr ifaces);
219 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_state")]
220 internal static extern int SetState(IntPtr repr, IntPtr state);
222 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_state")]
223 internal static extern int GetState(IntPtr repr, out IntPtr state);
225 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_add_child")]
226 internal static extern int AddChild(IntPtr parent, IntPtr child);
228 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_remove_child")]
229 internal static extern int RemoveChild(IntPtr parent, IntPtr child);
231 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_foreach_children")]
232 internal static extern int ForeachChildren(IntPtr parent, RepresentationChildrenCallback cb, IntPtr userData);
234 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_children_count")]
235 internal static extern int GetChildrenCount(IntPtr parent, out int count);
237 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_nth_child")]
238 internal static extern int GetNthChild(IntPtr parent, int pos, out IntPtr child);
241 internal static partial class Options
243 internal delegate bool OptionsCallback(ushort id, string data, IntPtr userData);
245 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_create")]
246 internal static extern int Create(out IntPtr options);
248 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_destroy")]
249 internal static extern void Destroy(IntPtr options);
251 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_add")]
252 internal static extern int Add(IntPtr options, ushort id, string data);
254 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_remove")]
255 internal static extern int Remove(IntPtr options, ushort id);
257 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_lookup")]
258 internal static extern int Lookup(IntPtr options, ushort id, out string data);
260 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_foreach")]
261 internal static extern int ForEach(IntPtr options, OptionsCallback cb, IntPtr userData);
264 internal static partial class List
266 internal delegate bool IntCallback(int pos, int value, IntPtr userData);
268 internal delegate bool BoolCallback(int pos, bool value, IntPtr userData);
270 internal delegate bool DoubleCallback(int pos, double value, IntPtr userData);
272 internal delegate bool ByteStrCallback(int pos, byte[] value, int len, IntPtr userData);
274 internal delegate bool StrCallback(int pos, string value, IntPtr userData);
276 internal delegate bool ListCallback(int pos, IntPtr value, IntPtr userData);
278 internal delegate bool StateCallback(int pos, IntPtr value, IntPtr userData);
280 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_create")]
281 internal static extern int Create(DataType type, out IntPtr list);
283 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_destroy")]
284 internal static extern void Destroy(IntPtr list);
286 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_int")]
287 internal static extern int AddInt(IntPtr list, int val, int pos);
289 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_bool")]
290 internal static extern int AddBool(IntPtr list, bool val, int pos);
292 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_double")]
293 internal static extern int AddDouble(IntPtr list, double val, int pos);
295 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_str")]
296 internal static extern int AddStr(IntPtr list, string val, int pos);
298 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_byte_str")]
299 internal static extern int AddByteStr(IntPtr list, byte[] val, int len, int pos);
301 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_list")]
302 internal static extern int AddList(IntPtr list, IntPtr val, int pos);
304 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_state")]
305 internal static extern int AddState(IntPtr list, IntPtr val, int pos);
307 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_int")]
308 internal static extern int GetNthInt(IntPtr list, int pos, out int val);
310 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_bool")]
311 internal static extern int GetNthBool(IntPtr list, int pos, out bool val);
313 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_double")]
314 internal static extern int GetNthDouble(IntPtr list, int pos, out double val);
316 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_str")]
317 internal static extern int GetNthStr(IntPtr list, int pos, out string val);
319 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_byte_str")]
320 internal static extern int GetNthByteStr(IntPtr list, int pos, out string val, out int len);
322 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_list")]
323 internal static extern int GetNthList(IntPtr src, int pos, out IntPtr dest);
325 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_state")]
326 internal static extern int GetNthState(IntPtr list, int pos, out IntPtr state);
328 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_remove_nth")]
329 internal static extern int RemoveNth(IntPtr list, int pos);
331 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_type")]
332 internal static extern int GetType(IntPtr list, out int type);
334 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_length")]
335 internal static extern int GetLength(IntPtr list, out int length);
337 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_int")]
338 internal static extern int ForeachInt(IntPtr list, IntCallback cb, IntPtr userData);
340 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_bool")]
341 internal static extern int ForeachBool(IntPtr list, BoolCallback cb, IntPtr userData);
343 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_double")]
344 internal static extern int ForeachDouble(IntPtr list, DoubleCallback cb, IntPtr userData);
346 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_byte_str")]
347 internal static extern int ForeachByteStr(IntPtr list, ByteStrCallback cb, IntPtr userData);
349 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_str")]
350 internal static extern int ForeachStr(IntPtr list, StrCallback cb, IntPtr userData);
352 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_list")]
353 internal static extern int ForeachList(IntPtr list, ListCallback cb, IntPtr userData);
355 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_state")]
356 internal static extern int ForeachState(IntPtr list, StateCallback cb, IntPtr userData);