[IoTConnectivity] Added Base implementation
[platform/core/csapi/iotcon.git] / Tizen.Network.IoTConnectivity / Interop / Interop.IoTConnectivity.Common.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 Common
17         {
18             internal enum DataType
19             {
20                 None = 0,
21                 Int,
22                 Bool,
23                 Double,
24                 String,
25                 ByteStr,
26                 Null,
27                 List,
28                 State
29             }
30
31             internal static partial class ResourceTypes
32             {
33                 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
34                 internal delegate bool ForeachCallback(string type, IntPtr userData);
35
36                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_create")]
37                 internal static extern int Create(out IntPtr types);
38
39                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_destroy")]
40                 internal static extern void Destroy(IntPtr types);
41
42                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_add")]
43                 internal static extern int Add(IntPtr types, string type);
44
45                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_remove")]
46                 internal static extern int Remove(IntPtr types, string type);
47
48                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_foreach")]
49                 internal static extern int Foreach(IntPtr types, ForeachCallback cb, IntPtr userData);
50
51                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_clone")]
52                 internal static extern int Clone(IntPtr src, out IntPtr dest);
53             }
54
55             internal static partial class ResourceInterfaces
56             {
57                 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
58                 internal delegate bool ForeachCallback(string iface, IntPtr userData);
59
60                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_create")]
61                 internal static extern int Create(out IntPtr ifaces);
62
63                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_destroy")]
64                 internal static extern void Destroy(IntPtr ifaces);
65
66                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_add")]
67                 internal static extern int Add(IntPtr ifaces, string iface);
68
69                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_remove")]
70                 internal static extern int Remove(IntPtr ifaces, string iface);
71
72                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_foreach")]
73                 internal static extern int Foreach(IntPtr ifaces, ForeachCallback cb, IntPtr userData);
74
75                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_clone")]
76                 internal static extern int Clone(IntPtr src, out IntPtr dest);
77             }
78
79             internal static partial class State
80             {
81                 internal delegate bool StateCallback(IntPtr state, string key, IntPtr userData);
82
83                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_create")]
84                 internal static extern int Create(out IntPtr state);
85
86                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_destroy")]
87                 internal static extern void Destroy(IntPtr state);
88
89                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_clone")]
90                 internal static extern int Clone(IntPtr state, out IntPtr dest);
91
92                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_int")]
93                 internal static extern int AddInt(IntPtr state, string key, int val);
94
95                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_bool")]
96                 internal static extern int AddBool(IntPtr state, string key, bool val);
97
98                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_double")]
99                 internal static extern int AddDouble(IntPtr state, string key, double val);
100
101                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_str")]
102                 internal static extern int AddStr(IntPtr state, string key, string val);
103
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);
106
107                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_list")]
108                 internal static extern int AddList(IntPtr state, string key, IntPtr list);
109
110                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_state")]
111                 internal static extern int AddState(IntPtr dest, string key, IntPtr src);
112
113                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_null")]
114                 internal static extern int AddNull(IntPtr state, string key);
115
116                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_int")]
117                 internal static extern int GetInt(IntPtr state, string key, out int val);
118
119                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_bool")]
120                 internal static extern int GetBool(IntPtr state, string key, out bool val);
121
122                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_double")]
123                 internal static extern int GetDouble(IntPtr state, string key, out double val);
124
125                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_str")]
126                 internal static extern int GetStr(IntPtr state, string key, out string val);
127
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);
130
131                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_list")]
132                 internal static extern int GetList(IntPtr state, string key, out IntPtr list);
133
134                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_state")]
135                 internal static extern int GetState(IntPtr src, string key, out IntPtr dest);
136
137                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_is_null")]
138                 internal static extern int IsNull(IntPtr state, string key, out bool isNull);
139
140                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_remove")]
141                 internal static extern int Remove(IntPtr state, string key);
142
143                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_type")]
144                 internal static extern int GetType(IntPtr state, string key, out DataType type);
145
146                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_foreach")]
147                 internal static extern int Foreach(IntPtr state, StateCallback cb, IntPtr userData);
148
149                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_keys_count")]
150                 internal static extern int GetKeysCount(IntPtr state, out int count);
151             }
152
153             internal static partial class Query
154             {
155                 internal delegate bool QueryCallback(string key, string value, IntPtr userData);
156
157                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_create")]
158                 internal static extern int Create(out IntPtr query);
159
160                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_destroy")]
161                 internal static extern void Destroy(IntPtr query);
162
163                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_get_resource_type")]
164                 internal static extern int GetResourceType(IntPtr query, out string resourceType);
165
166                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_get_interface")]
167                 internal static extern int GetInterface(IntPtr query, out string resourceInterface);
168
169                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_set_resource_type")]
170                 internal static extern int SetResourceType(IntPtr query, string resourceType);
171
172                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_set_interface")]
173                 internal static extern int SetInterface(IntPtr query, string resourceInterface);
174
175                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_add")]
176                 internal static extern int Add(IntPtr query, string key, string value);
177
178                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_remove")]
179                 internal static extern int Remove(IntPtr query, string key);
180
181                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_lookup")]
182                 internal static extern int Lookup(IntPtr query, string key, out string data);
183
184                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_foreach")]
185                 internal static extern int Foreach(IntPtr query, QueryCallback cb, IntPtr userData);
186             }
187
188             internal static partial class Representation
189             {
190                 internal delegate bool RepresentationChildrenCallback(IntPtr child, IntPtr userData);
191
192                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_create")]
193                 internal static extern int Create(out IntPtr repr);
194
195                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_destroy")]
196                 internal static extern void Destroy(IntPtr repr);
197
198                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_clone")]
199                 internal static extern int Clone(IntPtr src, out IntPtr dest);
200
201                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_uri_path")]
202                 internal static extern int SetUriPath(IntPtr repr, string uriPath);
203
204                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_uri_path")]
205                 internal static extern int GetUriPath(IntPtr repr, out string uriPath);
206
207                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_resource_types")]
208                 internal static extern int SetResourceTypes(IntPtr repr, IntPtr types);
209
210                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_resource_types")]
211                 internal static extern int GetResourceTypes(IntPtr repr, out IntPtr types);
212
213                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_resource_interfaces")]
214                 internal static extern int SetResourceInterfaces(IntPtr repr, IntPtr ifaces);
215
216                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_resource_interfaces")]
217                 internal static extern int GetResourceInterfaces(IntPtr repr, out IntPtr ifaces);
218
219                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_state")]
220                 internal static extern int SetState(IntPtr repr, IntPtr state);
221
222                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_state")]
223                 internal static extern int GetState(IntPtr repr, out IntPtr state);
224
225                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_add_child")]
226                 internal static extern int AddChild(IntPtr parent, IntPtr child);
227
228                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_remove_child")]
229                 internal static extern int RemoveChild(IntPtr parent, IntPtr child);
230
231                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_foreach_children")]
232                 internal static extern int ForeachChildren(IntPtr parent, RepresentationChildrenCallback cb, IntPtr userData);
233
234                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_children_count")]
235                 internal static extern int GetChildrenCount(IntPtr parent, out int count);
236
237                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_nth_child")]
238                 internal static extern int GetNthChild(IntPtr parent, int pos, out IntPtr child);
239             }
240
241             internal static partial class Options
242             {
243                 internal delegate bool OptionsCallback(ushort id, string data, IntPtr userData);
244
245                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_create")]
246                 internal static extern int Create(out IntPtr options);
247
248                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_destroy")]
249                 internal static extern void Destroy(IntPtr options);
250
251                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_add")]
252                 internal static extern int Add(IntPtr options, ushort id, string data);
253
254                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_remove")]
255                 internal static extern int Remove(IntPtr options, ushort id);
256
257                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_lookup")]
258                 internal static extern int Lookup(IntPtr options, ushort id, out string data);
259
260                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_foreach")]
261                 internal static extern int ForEach(IntPtr options, OptionsCallback cb, IntPtr userData);
262             }
263
264             internal static partial class List
265             {
266                 internal delegate bool IntCallback(int pos, int value, IntPtr userData);
267
268                 internal delegate bool BoolCallback(int pos, bool value, IntPtr userData);
269
270                 internal delegate bool DoubleCallback(int pos, double value, IntPtr userData);
271
272                 internal delegate bool ByteStrCallback(int pos, byte[] value, int len, IntPtr userData);
273
274                 internal delegate bool StrCallback(int pos, string value, IntPtr userData);
275
276                 internal delegate bool ListCallback(int pos, IntPtr value, IntPtr userData);
277
278                 internal delegate bool StateCallback(int pos, IntPtr value, IntPtr userData);
279
280                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_create")]
281                 internal static extern int Create(DataType type, out IntPtr list);
282
283                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_destroy")]
284                 internal static extern void Destroy(IntPtr list);
285
286                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_int")]
287                 internal static extern int AddInt(IntPtr list, int val, int pos);
288
289                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_bool")]
290                 internal static extern int AddBool(IntPtr list, bool val, int pos);
291
292                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_double")]
293                 internal static extern int AddDouble(IntPtr list, double val, int pos);
294
295                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_str")]
296                 internal static extern int AddStr(IntPtr list, string val, int pos);
297
298                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_byte_str")]
299                 internal static extern int AddByteStr(IntPtr list, byte[] val, int len, int pos);
300
301                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_list")]
302                 internal static extern int AddList(IntPtr list, IntPtr val, int pos);
303
304                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_state")]
305                 internal static extern int AddState(IntPtr list, IntPtr val, int pos);
306
307                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_int")]
308                 internal static extern int GetNthInt(IntPtr list, int pos, out int val);
309
310                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_bool")]
311                 internal static extern int GetNthBool(IntPtr list, int pos, out bool val);
312
313                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_double")]
314                 internal static extern int GetNthDouble(IntPtr list, int pos, out double val);
315
316                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_str")]
317                 internal static extern int GetNthStr(IntPtr list, int pos, out string val);
318
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);
321
322                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_list")]
323                 internal static extern int GetNthList(IntPtr src, int pos, out IntPtr dest);
324
325                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_state")]
326                 internal static extern int GetNthState(IntPtr list, int pos, out IntPtr state);
327
328                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_remove_nth")]
329                 internal static extern int RemoveNth(IntPtr list, int pos);
330
331                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_type")]
332                 internal static extern int GetType(IntPtr list, out int type);
333
334                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_length")]
335                 internal static extern int GetLength(IntPtr list, out int length);
336
337                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_int")]
338                 internal static extern int ForeachInt(IntPtr list, IntCallback cb, IntPtr userData);
339
340                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_bool")]
341                 internal static extern int ForeachBool(IntPtr list, BoolCallback cb, IntPtr userData);
342
343                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_double")]
344                 internal static extern int ForeachDouble(IntPtr list, DoubleCallback cb, IntPtr userData);
345
346                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_byte_str")]
347                 internal static extern int ForeachByteStr(IntPtr list, ByteStrCallback cb, IntPtr userData);
348
349                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_str")]
350                 internal static extern int ForeachStr(IntPtr list, StrCallback cb, IntPtr userData);
351
352                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_list")]
353                 internal static extern int ForeachList(IntPtr list, ListCallback cb, IntPtr userData);
354
355                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_state")]
356                 internal static extern int ForeachState(IntPtr list, StateCallback cb, IntPtr userData);
357             }
358         }
359     }
360 }