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