Release 4.0.0-preview1-00051
[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                 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
51                 internal delegate void RequestHandlerCallback(IntPtr resource, IntPtr request, IntPtr userData);
52
53                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_create")]
54                 internal static extern int Create(string uriPath, IntPtr resTypes, IntPtr ifaces, int properties, RequestHandlerCallback cb, IntPtr userData, out IntPtr resourceHandle);
55
56                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_destroy")]
57                 internal static extern int Destroy(IntPtr resourceHandle);
58
59                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_bind_interface")]
60                 internal static extern int BindInterface(IntPtr resource, string iface);
61
62                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_bind_type")]
63                 internal static extern int BindType(IntPtr resourceHandle, string resourceType);
64
65                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_set_request_handler")]
66                 internal static extern int SetRequestHandler(IntPtr resource, RequestHandlerCallback cb, IntPtr userData);
67
68                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_bind_child_resource")]
69                 internal static extern int BindChildResource(IntPtr parent, IntPtr child);
70
71                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_unbind_child_resource")]
72                 internal static extern int UnbindChildResource(IntPtr parent, IntPtr child);
73
74                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_notify")]
75                 internal static extern int Notify(IntPtr resource, IntPtr repr, IntPtr observers, int qos);
76
77                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_number_of_children")]
78                 internal static extern int GetNumberOfChildren(IntPtr resource, out int number);
79
80                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_nth_child")]
81                 internal static extern int GetNthChild(IntPtr parent, int index, out IntPtr child);
82
83                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_uri_path")]
84                 internal static extern int GetUriPath(IntPtr resource, out IntPtr uriPath);
85
86                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_types")]
87                 internal static extern int GetTypes(IntPtr resource, out IntPtr types);
88
89                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_interfaces")]
90                 internal static extern int GetInterfaces(IntPtr resource, out IntPtr ifaces);
91
92                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_properties")]
93                 internal static extern int GetProperties(IntPtr resource, out int properties);
94             }
95
96             internal static partial class Request
97             {
98                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_host_address")]
99                 internal static extern int GetHostAddress(IntPtr request, out IntPtr hostAddress);
100
101                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_connectivity_type")]
102                 internal static extern int GetConnectivityType(IntPtr request, out int connectivityType);
103
104                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_representation")]
105                 internal static extern int GetRepresentation(IntPtr request, out IntPtr repr);
106
107                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_request_type")]
108                 internal static extern int GetRequestType(IntPtr request, out int type);
109
110                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_options")]
111                 internal static extern int GetOptions(IntPtr request, out IntPtr options);
112
113                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_query")]
114                 internal static extern int GetQuery(IntPtr request, out IntPtr query);
115
116                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_observe_type")]
117                 internal static extern int GetObserveType(IntPtr request, out int observeType);
118
119                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_observe_id")]
120                 internal static extern int GetObserveId(IntPtr request, out int observeId);
121             }
122
123             internal static partial class Response
124             {
125                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_create")]
126                 internal static extern int Create(IntPtr request, out IntPtr response);
127
128                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_destroy")]
129                 internal static extern void Destroy(IntPtr resp);
130
131                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_get_options")]
132                 internal static extern int GetOptions(IntPtr resp, out IntPtr options);
133
134                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_get_representation")]
135                 internal static extern int GetRepresentation(IntPtr resp, out IntPtr repr);
136
137                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_get_result")]
138                 internal static extern int GetResult(IntPtr resp, out int result);
139
140                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_set_result")]
141                 internal static extern int SetResult(IntPtr resp, int result);
142
143                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_set_representation")]
144                 internal static extern int SetRepresentation(IntPtr resp, IntPtr repr);
145
146                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_set_options")]
147                 internal static extern int SetOptions(IntPtr resp, IntPtr options);
148
149                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_send")]
150                 internal static extern int Send(IntPtr resp);
151             }
152
153             internal static partial class Observers
154             {
155                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_observers_create")]
156                 internal static extern int Create(out IntPtr observers);
157
158                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_observers_destroy")]
159                 internal static extern void Destroy(IntPtr observers);
160
161                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_observers_add")]
162                 internal static extern int Add(IntPtr observers, int observeId);
163
164                 [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_observers_remove")]
165                 internal static extern int Remove(IntPtr observers, int observeId);
166             }
167         }
168     }
169 }