[C# Connection] Adding C# Connection code
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.Connection / Interop / Interop.Connection.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 using Tizen.Network.Connection;
20
21 internal static partial class Interop
22 {
23     internal static partial class Connection
24     {
25         public delegate void ConnectionTypeChangedCallback(ConnectionType type, IntPtr userData);
26         public delegate void EthernetCableStateChangedCallback(EthernetCableState state, IntPtr userData);
27         public delegate void ConnectionAddressChangedCallback(IntPtr ipv4, IntPtr ipv6, IntPtr userData);
28         public delegate void ConnectionCallback(ConnectionError result, IntPtr userData);
29
30         [DllImport(Libraries.Connection, EntryPoint = "connection_create")]
31         public static extern int Create(out IntPtr handle);
32
33         [DllImport(Libraries.Connection, EntryPoint = "connection_destroy")]
34         public static extern int Destroy(IntPtr handle);
35
36         [DllImport(Libraries.Connection, EntryPoint = "connection_get_type")]
37         public static extern int GetType(IntPtr handle, out int type);
38
39         [DllImport(Libraries.Connection, EntryPoint = "connection_get_ip_address")]
40         public static extern int GetIpAddress(IntPtr handle, int family, out IntPtr address);
41
42         [DllImport(Libraries.Connection, EntryPoint = "connection_get_proxy")]
43         public static extern int GetProxy(IntPtr handle, int family, out IntPtr address);
44
45         [DllImport(Libraries.Connection, EntryPoint = "connection_get_mac_address")]
46         public static extern int GetMacAddress(IntPtr handle, int family, out IntPtr address);
47
48         [DllImport(Libraries.Connection, EntryPoint = "connection_get_wifi_state")]
49         public static extern int GetWiFiState(IntPtr handle, out int state);
50
51         [DllImport(Libraries.Connection, EntryPoint = "connection_get_cellular_state")]
52         public static extern int GetCellularState(IntPtr handle, out int state);
53
54         [DllImport(Libraries.Connection, EntryPoint = "connection_get_ethernet_state")]
55         public static extern int GetEthernetState(IntPtr handle, out int state);
56
57         [DllImport(Libraries.Connection, EntryPoint = "connection_get_ethernet_cable_state")]
58         public static extern int GetEthernetCableState(IntPtr handle, out int state);
59
60         [DllImport(Libraries.Connection, EntryPoint = "connection_get_bt_state")]
61         public static extern int GetBtState(IntPtr handle, out int state);
62
63         [DllImport(Libraries.Connection, EntryPoint = "connection_set_type_changed_cb")]
64         public static extern int SetTypeChangedCallback(IntPtr handle, ConnectionTypeChangedCallback callback, IntPtr userData);
65
66         [DllImport(Libraries.Connection, EntryPoint = "connection_set_ip_address_changed_cb")]
67         public static extern int SetIpAddressChangedCallback(IntPtr handle, ConnectionAddressChangedCallback callback, IntPtr userData);
68
69         [DllImport(Libraries.Connection, EntryPoint = "connection_set_ethernet_cable_state_chaged_cb")]
70         public static extern int SetEthernetCableStateChagedCallback(IntPtr handle, EthernetCableStateChangedCallback callback, IntPtr userData);
71
72         [DllImport(Libraries.Connection, EntryPoint = "connection_set_proxy_address_changed_cb")]
73         public static extern int SetProxyAddressChangedCallback(IntPtr handle, ConnectionAddressChangedCallback callback, IntPtr userData);
74
75         [DllImport(Libraries.Connection, EntryPoint = "connection_unset_type_changed_cb")]
76         public static extern int UnsetTypeChangedCallback(IntPtr handle);
77
78         [DllImport(Libraries.Connection, EntryPoint = "connection_unset_ip_address_changed_cb")]
79         public static extern int UnsetIpAddressChangedCallback(IntPtr handle);
80
81         [DllImport(Libraries.Connection, EntryPoint = "connection_unset_ethernet_cable_state_chaged_cb")]
82         public static extern int UnsetEthernetCableStateChagedCallback(IntPtr handle);
83
84         [DllImport(Libraries.Connection, EntryPoint = "connection_unset_proxy_address_changed_cb")]
85         public static extern int UnsetProxyAddressChangedCallback(IntPtr handle);
86
87         [DllImport(Libraries.Connection, EntryPoint = "connection_add_profile")]
88         public static extern int AddProfile(IntPtr handle, IntPtr profileHandle);
89
90         [DllImport(Libraries.Connection, EntryPoint = "connection_remove_profile")]
91         public static extern int RemoveProfile(IntPtr handle, IntPtr profileHandle);
92
93         [DllImport(Libraries.Connection, EntryPoint = "connection_update_profile")]
94         public static extern int UpdateProfile(IntPtr handle, IntPtr profileHandle);
95
96         [DllImport(Libraries.Connection, EntryPoint = "connection_get_default_cellular_service_profile")]
97         public static extern int GetDefaultCellularServiceProfile(IntPtr handle, int type, out IntPtr profileHandle);
98
99         [DllImport(Libraries.Connection, EntryPoint = "connection_get_current_profile")]
100         public static extern int GetCurrentProfile(IntPtr handle, out IntPtr profileHandle);
101
102         [DllImport(Libraries.Connection, EntryPoint = "connection_open_profile")]
103         public static extern int OpenProfile(IntPtr handle, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
104
105         [DllImport(Libraries.Connection, EntryPoint = "connection_close_profile")]
106         public static extern int CloseProfile(IntPtr handle, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
107
108         [DllImport(Libraries.Connection, EntryPoint = "connection_reset_profile")]
109         public static extern int ResetProfile(IntPtr handle, int Option, int Id, ConnectionCallback callback, IntPtr userData);
110
111         [DllImport(Libraries.Connection, EntryPoint = "connection_set_default_cellular_service_profile_async")]
112         public static extern int SetDefaultCellularServiceProfileAsync(IntPtr handle, int Type, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
113
114         [DllImport(Libraries.Connection, EntryPoint = "connection_get_profile_iterator")]
115         public static extern int GetProfileIterator(IntPtr handle, int type, out IntPtr iterHandle);
116
117         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_iterator_next")]
118         public static extern int GetNextProfileIterator(IntPtr iterHandle, out IntPtr profileHandle);
119
120         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_iterator_has_next")]
121         public static extern bool HasNextProfileIterator(IntPtr iterHandle);
122
123         [DllImport(Libraries.Connection, EntryPoint = "connection_destroy_profile_iterator")]
124         public static extern int DestroyProfileIterator(IntPtr iterHandle);
125     }
126
127     internal static partial class ConnectionProfile
128     {
129         public delegate void profile_state_changed_cb(ProfileState type, IntPtr userData);
130
131         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_create")]
132         public static extern int Create(int ProfileType, string Keyword, out IntPtr profileHandle);
133
134         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_clone")]
135         public static extern int Clone(out IntPtr cloneHandle, IntPtr profileHandle);
136
137         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_destroy")]
138         public static extern int Destroy(IntPtr profileHandle);
139
140         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_id")]
141         public static extern int GetId(IntPtr profileHandle, out IntPtr profileId);
142
143         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_name")]
144         public static extern int GetName(IntPtr profileHandle, out IntPtr name);
145
146         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_type")]
147         public static extern int GetType(IntPtr profileHandle, out int type);
148
149         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_network_interface_name")]
150         public static extern int GetNetworkInterfaceName(IntPtr profileHandle, out IntPtr interfaceName);
151
152         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_state")]
153         public static extern int GetState(IntPtr profileHandle, out int type);
154
155         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ip_config_type")]
156         public static extern int GetIpConfigType(IntPtr profileHandle, int family, out int type);
157
158         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_proxy_type")]
159         public static extern int GetProxyType(IntPtr profileHandle, out int type);
160
161         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ip_address")]
162         public static extern int GetIpAddress(IntPtr profileHandle, int family, out IntPtr address);
163
164         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_subnet_mask")]
165         public static extern int GetSubnetMask(IntPtr profileHandle, int family, out IntPtr address);
166
167         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_gateway_address")]
168         public static extern int GetGatewayAddress(IntPtr profileHandle, int family, out IntPtr address);
169
170         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_dns_address")]
171         public static extern int GetDnsAddress(IntPtr profileHandle, int order, int Family, out IntPtr address);
172
173         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_proxy_address")]
174         public static extern int GetProxyAddress(IntPtr profileHandle, int family, out IntPtr address);
175
176         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_ip_config_type")]
177         public static extern int SetIpConfigType(IntPtr profileHandle, int family, int type);
178
179         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_proxy_type")]
180         public static extern int SetProxyType(IntPtr profileHandle, int type);
181
182         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_ip_address")]
183         public static extern int SetIpAddress(IntPtr profileHandle, int family, string address);
184
185         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_subnet_mask")]
186         public static extern int SetSubnetMask(IntPtr profileHandle, int family, string address);
187
188         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_gateway_address")]
189         public static extern int SetGatewayAddress(IntPtr profileHandle, int family, string address);
190
191         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_dns_address")]
192         public static extern int SetDnsAddress(IntPtr profileHandle, int family, string address);
193
194         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_proxy_address")]
195         public static extern int SetProxyAddress(IntPtr profileHandle, int family, string address);
196
197         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_state_changed_cb")]
198         public static extern int SetStateChangeCallback(IntPtr profileHandle, profile_state_changed_cb callback, IntPtr userData);
199
200         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_unset_state_changed_cb")]
201         public static extern int UnsetStateChangeCallback(IntPtr profileHandle);
202     }
203
204     internal static partial class ConnectionCellularProfile
205     {
206         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_service_type")]
207         public static extern int GetServiceType(IntPtr profileHandle, out int type);
208
209         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_apn")]
210         public static extern int GetApn(IntPtr profileHandle, out IntPtr apn);
211
212         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_auth_info")]
213         public static extern int GetAuthInfo(IntPtr profileHandle, out int authType, out IntPtr name, out IntPtr password);
214
215         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_home_url")]
216         public static extern int GetHomeUrl(IntPtr profileHandle, out IntPtr homeUrl);
217
218         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_roaming")]
219         public static extern int IsRoaming(IntPtr profileHandle, out bool roaming);
220
221         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_hidden")]
222         public static extern int IsHidden(IntPtr profileHandle, out bool hidden);
223
224         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_editable")]
225         public static extern int IsEditable(IntPtr profileHandle, out bool editable);
226
227         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_default")]
228         public static extern int IsDefault(IntPtr profileHandle, out bool isDefault);
229
230         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_service_type")]
231         public static extern int SetServiceType(IntPtr profileHandle, int type);
232
233         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_apn")]
234         public static extern int SetApn(IntPtr profileHandle, string apn);
235
236         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_auth_info")]
237         public static extern int SetAuthInfo(IntPtr profileHandle, int authType, string name, string password);
238
239         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_home_url")]
240         public static extern int SetHomeUrl(IntPtr profileHandle, string homeUrl);
241
242     }
243
244     internal static partial class ConnectionWiFiProfile
245     {
246         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_essid")]
247         public static extern int GetEssid(IntPtr profileHandle, out IntPtr essid);
248
249         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_bssid")]
250         public static extern int GetBssid(IntPtr profileHandle, out IntPtr bssid);
251
252         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_rssi")]
253         public static extern int GetRssi(IntPtr profileHandle, out int rssi);
254
255         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_frequency")]
256         public static extern int GetFrequency(IntPtr profileHandle, out int frequency);
257
258         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_max_speed")]
259         public static extern int GetMaxSpeed(IntPtr profileHandle, out int maxSpeed);
260
261         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_security_type")]
262         public static extern int GetSecurityType(IntPtr profileHandle, out int type);
263
264         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_encryption_type")]
265         public static extern int GetEncryptionType(IntPtr profileHandle, out int type);
266
267         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_wifi_passphrase_required")]
268         public static extern int IsRequiredPassphrase(IntPtr profileHandle, out bool required);
269
270         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_wifi_passphrase")]
271         public static extern int SetPassphrase(IntPtr profileHandle, string passphrase);
272
273         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_wifi_wps_supported")]
274         public static extern int IsSupportedWps(IntPtr profileHandle, out bool supported);
275     }
276         
277     internal static partial class Libc
278     {
279         [DllImport(Libraries.Libc, EntryPoint = "free")]
280         public static extern void Free(IntPtr userData);
281
282     }
283 }