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