2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Runtime.InteropServices;
19 using Tizen.Network.Connection;
21 internal static partial class Interop
23 internal static partial class Connection
25 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
26 public delegate void ConnectionTypeChangedCallback(ConnectionType type, IntPtr userData);
27 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
28 public delegate void EthernetCableStateChangedCallback(EthernetCableState state, IntPtr userData);
29 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
30 public delegate void ConnectionAddressChangedCallback(IntPtr ipv4, IntPtr ipv6, IntPtr userData);
31 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
32 public delegate void ConnectionCallback(ConnectionError result, IntPtr userData);
34 [DllImport(Libraries.Connection, EntryPoint = "connection_create")]
35 public static extern int Create(out IntPtr handle);
37 [DllImport(Libraries.Connection, EntryPoint = "connection_destroy")]
38 public static extern int Destroy(IntPtr handle);
40 [DllImport(Libraries.Connection, EntryPoint = "connection_get_type")]
41 public static extern int GetType(IntPtr handle, out int type);
43 [DllImport(Libraries.Connection, EntryPoint = "connection_get_ip_address")]
44 public static extern int GetIPAddress(IntPtr handle, int family, out IntPtr address);
46 [DllImport(Libraries.Connection, EntryPoint = "connection_get_proxy")]
47 public static extern int GetProxy(IntPtr handle, int family, out IntPtr address);
49 [DllImport(Libraries.Connection, EntryPoint = "connection_get_mac_address")]
50 public static extern int GetMacAddress(IntPtr handle, int family, out IntPtr address);
52 [DllImport(Libraries.Connection, EntryPoint = "connection_get_wifi_state")]
53 public static extern int GetWiFiState(IntPtr handle, out int state);
55 [DllImport(Libraries.Connection, EntryPoint = "connection_get_cellular_state")]
56 public static extern int GetCellularState(IntPtr handle, out int state);
58 [DllImport(Libraries.Connection, EntryPoint = "connection_get_ethernet_state")]
59 public static extern int GetEthernetState(IntPtr handle, out int state);
61 [DllImport(Libraries.Connection, EntryPoint = "connection_get_ethernet_cable_state")]
62 public static extern int GetEthernetCableState(IntPtr handle, out int state);
64 [DllImport(Libraries.Connection, EntryPoint = "connection_get_bt_state")]
65 public static extern int GetBtState(IntPtr handle, out int state);
67 [DllImport(Libraries.Connection, EntryPoint = "connection_set_type_changed_cb")]
68 public static extern int SetTypeChangedCallback(IntPtr handle, ConnectionTypeChangedCallback callback, IntPtr userData);
70 [DllImport(Libraries.Connection, EntryPoint = "connection_set_ip_address_changed_cb")]
71 public static extern int SetIPAddressChangedCallback(IntPtr handle, ConnectionAddressChangedCallback callback, IntPtr userData);
73 [DllImport(Libraries.Connection, EntryPoint = "connection_set_ethernet_cable_state_chaged_cb")]
74 public static extern int SetEthernetCableStateChagedCallback(IntPtr handle, EthernetCableStateChangedCallback callback, IntPtr userData);
76 [DllImport(Libraries.Connection, EntryPoint = "connection_set_proxy_address_changed_cb")]
77 public static extern int SetProxyAddressChangedCallback(IntPtr handle, ConnectionAddressChangedCallback callback, IntPtr userData);
79 [DllImport(Libraries.Connection, EntryPoint = "connection_unset_type_changed_cb")]
80 public static extern int UnsetTypeChangedCallback(IntPtr handle);
82 [DllImport(Libraries.Connection, EntryPoint = "connection_unset_ip_address_changed_cb")]
83 public static extern int UnsetIPAddressChangedCallback(IntPtr handle);
85 [DllImport(Libraries.Connection, EntryPoint = "connection_unset_ethernet_cable_state_chaged_cb")]
86 public static extern int UnsetEthernetCableStateChagedCallback(IntPtr handle);
88 [DllImport(Libraries.Connection, EntryPoint = "connection_unset_proxy_address_changed_cb")]
89 public static extern int UnsetProxyAddressChangedCallback(IntPtr handle);
91 [DllImport(Libraries.Connection, EntryPoint = "connection_add_profile")]
92 public static extern int AddProfile(IntPtr handle, IntPtr profileHandle);
94 [DllImport(Libraries.Connection, EntryPoint = "connection_remove_profile")]
95 public static extern int RemoveProfile(IntPtr handle, IntPtr profileHandle);
97 [DllImport(Libraries.Connection, EntryPoint = "connection_update_profile")]
98 public static extern int UpdateProfile(IntPtr handle, IntPtr profileHandle);
100 [DllImport(Libraries.Connection, EntryPoint = "connection_get_default_cellular_service_profile")]
101 public static extern int GetDefaultCellularServiceProfile(IntPtr handle, int type, out IntPtr profileHandle);
103 [DllImport(Libraries.Connection, EntryPoint = "connection_get_current_profile")]
104 public static extern int GetCurrentProfile(IntPtr handle, out IntPtr profileHandle);
106 [DllImport(Libraries.Connection, EntryPoint = "connection_open_profile")]
107 public static extern int OpenProfile(IntPtr handle, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
109 [DllImport(Libraries.Connection, EntryPoint = "connection_close_profile")]
110 public static extern int CloseProfile(IntPtr handle, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
112 [DllImport(Libraries.Connection, EntryPoint = "connection_reset_profile")]
113 public static extern int ResetProfile(IntPtr handle, int Option, int Id, ConnectionCallback callback, IntPtr userData);
115 [DllImport(Libraries.Connection, EntryPoint = "connection_set_default_cellular_service_profile_async")]
116 public static extern int SetDefaultCellularServiceProfileAsync(IntPtr handle, int Type, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
118 [DllImport(Libraries.Connection, EntryPoint = "connection_get_profile_iterator")]
119 public static extern int GetProfileIterator(IntPtr handle, int type, out IntPtr iterHandle);
121 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_iterator_next")]
122 public static extern int GetNextProfileIterator(IntPtr iterHandle, out IntPtr profileHandle);
124 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_iterator_has_next")]
125 public static extern bool HasNextProfileIterator(IntPtr iterHandle);
127 [DllImport(Libraries.Connection, EntryPoint = "connection_destroy_profile_iterator")]
128 public static extern int DestroyProfileIterator(IntPtr iterHandle);
131 internal static partial class ConnectionProfile
133 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
134 public delegate void ProfileStateChangedCallback(ProfileState type, IntPtr userData);
136 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_create")]
137 public static extern int Create(int ProfileType, string Keyword, out IntPtr profileHandle);
139 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_clone")]
140 public static extern int Clone(out IntPtr cloneHandle, IntPtr profileHandle);
142 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_destroy")]
143 public static extern int Destroy(IntPtr profileHandle);
145 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_id")]
146 public static extern int GetId(IntPtr profileHandle, out IntPtr profileId);
148 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_name")]
149 public static extern int GetName(IntPtr profileHandle, out IntPtr name);
151 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_type")]
152 public static extern int GetType(IntPtr profileHandle, out int type);
154 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_network_interface_name")]
155 public static extern int GetNetworkInterfaceName(IntPtr profileHandle, out IntPtr interfaceName);
157 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_state")]
158 public static extern int GetState(IntPtr profileHandle, out int type);
160 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ip_config_type")]
161 public static extern int GetIPConfigType(IntPtr profileHandle, int family, out int type);
163 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_proxy_type")]
164 public static extern int GetProxyType(IntPtr profileHandle, out int type);
166 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ip_address")]
167 public static extern int GetIPAddress(IntPtr profileHandle, int family, out IntPtr address);
169 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_subnet_mask")]
170 public static extern int GetSubnetMask(IntPtr profileHandle, int family, out IntPtr address);
172 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_gateway_address")]
173 public static extern int GetGatewayAddress(IntPtr profileHandle, int family, out IntPtr address);
175 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_dns_address")]
176 public static extern int GetDnsAddress(IntPtr profileHandle, int order, int Family, out IntPtr address);
178 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_proxy_address")]
179 public static extern int GetProxyAddress(IntPtr profileHandle, int family, out IntPtr address);
181 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_ip_config_type")]
182 public static extern int SetIPConfigType(IntPtr profileHandle, int family, int type);
184 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_proxy_type")]
185 public static extern int SetProxyType(IntPtr profileHandle, int type);
187 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_ip_address")]
188 public static extern int SetIPAddress(IntPtr profileHandle, int family, string address);
190 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_subnet_mask")]
191 public static extern int SetSubnetMask(IntPtr profileHandle, int family, string address);
193 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_gateway_address")]
194 public static extern int SetGatewayAddress(IntPtr profileHandle, int family, string address);
196 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_dns_address")]
197 public static extern int SetDnsAddress(IntPtr profileHandle, int family, string address);
199 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_proxy_address")]
200 public static extern int SetProxyAddress(IntPtr profileHandle, int family, string address);
202 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_state_changed_cb")]
203 public static extern int SetStateChangeCallback(IntPtr profileHandle, ProfileStateChangedCallback callback, IntPtr userData);
205 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_unset_state_changed_cb")]
206 public static extern int UnsetStateChangeCallback(IntPtr profileHandle);
209 internal static partial class ConnectionCellularProfile
211 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_service_type")]
212 public static extern int GetServiceType(IntPtr profileHandle, out int type);
214 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_apn")]
215 public static extern int GetApn(IntPtr profileHandle, out IntPtr apn);
217 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_auth_info")]
218 public static extern int GetAuthInfo(IntPtr profileHandle, out int authType, out IntPtr name, out IntPtr password);
220 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_home_url")]
221 public static extern int GetHomeUrl(IntPtr profileHandle, out IntPtr homeUrl);
223 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_roaming")]
224 public static extern int IsRoaming(IntPtr profileHandle, out bool roaming);
226 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_hidden")]
227 public static extern int IsHidden(IntPtr profileHandle, out bool hidden);
229 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_editable")]
230 public static extern int IsEditable(IntPtr profileHandle, out bool editable);
232 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_default")]
233 public static extern int IsDefault(IntPtr profileHandle, out bool isDefault);
235 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_service_type")]
236 public static extern int SetServiceType(IntPtr profileHandle, int type);
238 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_apn")]
239 public static extern int SetApn(IntPtr profileHandle, string apn);
241 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_auth_info")]
242 public static extern int SetAuthInfo(IntPtr profileHandle, int authType, string name, string password);
244 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_home_url")]
245 public static extern int SetHomeUrl(IntPtr profileHandle, string homeUrl);
249 internal static partial class ConnectionWiFiProfile
251 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_essid")]
252 public static extern int GetEssid(IntPtr profileHandle, out IntPtr essid);
254 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_bssid")]
255 public static extern int GetBssid(IntPtr profileHandle, out IntPtr bssid);
257 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_rssi")]
258 public static extern int GetRssi(IntPtr profileHandle, out int rssi);
260 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_frequency")]
261 public static extern int GetFrequency(IntPtr profileHandle, out int frequency);
263 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_max_speed")]
264 public static extern int GetMaxSpeed(IntPtr profileHandle, out int maxSpeed);
266 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_security_type")]
267 public static extern int GetSecurityType(IntPtr profileHandle, out int type);
269 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_encryption_type")]
270 public static extern int GetEncryptionType(IntPtr profileHandle, out int type);
272 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_wifi_passphrase_required")]
273 public static extern int IsRequiredPassphrase(IntPtr profileHandle, out bool required);
275 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_wifi_passphrase")]
276 public static extern int SetPassphrase(IntPtr profileHandle, string passphrase);
278 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_wifi_wps_supported")]
279 public static extern int IsSupportedWps(IntPtr profileHandle, out bool supported);
282 internal static partial class Libc
284 [DllImport(Libraries.Libc, EntryPoint = "free")]
285 public static extern void Free(IntPtr userData);