change license
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.IoTConnectivity / Interop / Interop.IoTConnectivity.Server.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
18 using System;
19 using System.Runtime.InteropServices;
20
21 internal static partial class Interop
22 {
23     internal static partial class IoTConnectivity
24     {
25         internal static partial class Server
26         {
27             internal enum RequestType
28             {
29                 Unknown = 0,
30                 Get = 1,
31                 Put = 2,
32                 Post = 3,
33                 Delete = 4,
34             }
35
36             internal static partial class IoTCon
37             {
38                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_start_presence")]
39                 internal static extern int StartPresence(uint time);
40
41                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_stop_presence")]
42                 internal static extern int StopPresence();
43
44                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_set_device_name")]
45                 internal static extern int SetDeviceName(string deviceName);
46             }
47
48             internal static partial class Resource
49             {
50                 internal delegate void RequestHandlerCallback(IntPtr resource, IntPtr request, IntPtr userData);
51
52                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_create")]
53                 internal static extern int Create(string uriPath, IntPtr resTypes, IntPtr ifaces, int properties, RequestHandlerCallback cb, IntPtr userData, out IntPtr resourceHandle);
54
55                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_destroy")]
56                 internal static extern int Destroy(IntPtr resourceHandle);
57
58                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_bind_interface")]
59                 internal static extern int BindInterface(IntPtr resource, string iface);
60
61                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_bind_type")]
62                 internal static extern int BindType(IntPtr resourceHandle, string resourceType);
63
64                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_set_request_handler")]
65                 internal static extern int SetRequestHandler(IntPtr resource, RequestHandlerCallback cb, IntPtr userData);
66
67                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_bind_child_resource")]
68                 internal static extern int BindChildResource(IntPtr parent, IntPtr child);
69
70                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_unbind_child_resource")]
71                 internal static extern int UnbindChildResource(IntPtr parent, IntPtr child);
72
73                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_notify")]
74                 internal static extern int Notify(IntPtr resource, IntPtr repr, IntPtr observers, int qos);
75
76                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_number_of_children")]
77                 internal static extern int GetNumberOfChildren(IntPtr resource, out int number);
78
79                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_nth_child")]
80                 internal static extern int GetNthChild(IntPtr parent, int index, out IntPtr child);
81
82                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_uri_path")]
83                 internal static extern int GetUriPath(IntPtr resource, out IntPtr uriPath);
84
85                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_types")]
86                 internal static extern int GetTypes(IntPtr resource, out IntPtr types);
87
88                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_interfaces")]
89                 internal static extern int GetInterfaces(IntPtr resource, out IntPtr ifaces);
90
91                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_properties")]
92                 internal static extern int GetProperties(IntPtr resource, out int properties);
93             }
94
95             internal static partial class Request
96             {
97                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_host_address")]
98                 internal static extern int GetHostAddress(IntPtr request, out IntPtr hostAddress);
99
100                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_connectivity_type")]
101                 internal static extern int GetConnectivityType(IntPtr request, out int connectivityType);
102
103                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_representation")]
104                 internal static extern int GetRepresentation(IntPtr request, out IntPtr repr);
105
106                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_request_type")]
107                 internal static extern int GetRequestType(IntPtr request, out int type);
108
109                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_options")]
110                 internal static extern int GetOptions(IntPtr request, out IntPtr options);
111
112                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_query")]
113                 internal static extern int GetQuery(IntPtr request, out IntPtr query);
114
115                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_observe_type")]
116                 internal static extern int GetObserveType(IntPtr request, out int observeType);
117
118                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_observe_id")]
119                 internal static extern int GetObserveId(IntPtr request, out int observeId);
120             }
121
122             internal static partial class Response
123             {
124                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_create")]
125                 internal static extern int Create(IntPtr request, out IntPtr response);
126
127                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_destroy")]
128                 internal static extern void Destroy(IntPtr resp);
129
130                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_get_options")]
131                 internal static extern int GetOptions(IntPtr resp, out IntPtr options);
132
133                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_get_representation")]
134                 internal static extern int GetRepresentation(IntPtr resp, out IntPtr repr);
135
136                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_get_result")]
137                 internal static extern int GetResult(IntPtr resp, out int result);
138
139                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_set_result")]
140                 internal static extern int SetResult(IntPtr resp, int result);
141
142                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_set_representation")]
143                 internal static extern int SetRepresentation(IntPtr resp, IntPtr repr);
144
145                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_set_options")]
146                 internal static extern int SetOptions(IntPtr resp, IntPtr options);
147
148                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_send")]
149                 internal static extern int Send(IntPtr resp);
150             }
151
152             internal static partial class Observers
153             {
154                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_observers_create")]
155                 internal static extern int Create(out IntPtr observers);
156
157                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_observers_destroy")]
158                 internal static extern void Destroy(IntPtr observers);
159
160                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_observers_add")]
161                 internal static extern int Add(IntPtr observers, int observeId);
162
163                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_observers_remove")]
164                 internal static extern int Remove(IntPtr observers, int observeId);
165             }
166         }
167     }
168 }