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 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);
30 [DllImport(Libraries.Connection, EntryPoint = "connection_create")]
31 public static extern int Create(out IntPtr handle);
33 [DllImport(Libraries.Connection, EntryPoint = "connection_destroy")]
34 public static extern int Destroy(IntPtr handle);
36 [DllImport(Libraries.Connection, EntryPoint = "connection_get_type")]
37 public static extern int GetType(IntPtr handle, out int type);
39 [DllImport(Libraries.Connection, EntryPoint = "connection_get_ip_address")]
40 public static extern int GetIpAddress(IntPtr handle, int family, out IntPtr address);
42 [DllImport(Libraries.Connection, EntryPoint = "connection_get_proxy")]
43 public static extern int GetProxy(IntPtr handle, int family, out IntPtr address);
45 [DllImport(Libraries.Connection, EntryPoint = "connection_get_mac_address")]
46 public static extern int GetMacAddress(IntPtr handle, int family, out IntPtr address);
48 [DllImport(Libraries.Connection, EntryPoint = "connection_get_wifi_state")]
49 public static extern int GetWiFiState(IntPtr handle, out int state);
51 [DllImport(Libraries.Connection, EntryPoint = "connection_get_cellular_state")]
52 public static extern int GetCellularState(IntPtr handle, out int state);
54 [DllImport(Libraries.Connection, EntryPoint = "connection_get_ethernet_state")]
55 public static extern int GetEthernetState(IntPtr handle, out int state);
57 [DllImport(Libraries.Connection, EntryPoint = "connection_get_ethernet_cable_state")]
58 public static extern int GetEthernetCableState(IntPtr handle, out int state);
60 [DllImport(Libraries.Connection, EntryPoint = "connection_get_bt_state")]
61 public static extern int GetBtState(IntPtr handle, out int state);
63 [DllImport(Libraries.Connection, EntryPoint = "connection_set_type_changed_cb")]
64 public static extern int SetTypeChangedCallback(IntPtr handle, ConnectionTypeChangedCallback callback, IntPtr userData);
66 [DllImport(Libraries.Connection, EntryPoint = "connection_set_ip_address_changed_cb")]
67 public static extern int SetIpAddressChangedCallback(IntPtr handle, ConnectionAddressChangedCallback callback, IntPtr userData);
69 [DllImport(Libraries.Connection, EntryPoint = "connection_set_ethernet_cable_state_chaged_cb")]
70 public static extern int SetEthernetCableStateChagedCallback(IntPtr handle, EthernetCableStateChangedCallback callback, IntPtr userData);
72 [DllImport(Libraries.Connection, EntryPoint = "connection_set_proxy_address_changed_cb")]
73 public static extern int SetProxyAddressChangedCallback(IntPtr handle, ConnectionAddressChangedCallback callback, IntPtr userData);
75 [DllImport(Libraries.Connection, EntryPoint = "connection_unset_type_changed_cb")]
76 public static extern int UnsetTypeChangedCallback(IntPtr handle);
78 [DllImport(Libraries.Connection, EntryPoint = "connection_unset_ip_address_changed_cb")]
79 public static extern int UnsetIpAddressChangedCallback(IntPtr handle);
81 [DllImport(Libraries.Connection, EntryPoint = "connection_unset_ethernet_cable_state_chaged_cb")]
82 public static extern int UnsetEthernetCableStateChagedCallback(IntPtr handle);
84 [DllImport(Libraries.Connection, EntryPoint = "connection_unset_proxy_address_changed_cb")]
85 public static extern int UnsetProxyAddressChangedCallback(IntPtr handle);
87 [DllImport(Libraries.Connection, EntryPoint = "connection_add_profile")]
88 public static extern int AddProfile(IntPtr handle, IntPtr profileHandle);
90 [DllImport(Libraries.Connection, EntryPoint = "connection_remove_profile")]
91 public static extern int RemoveProfile(IntPtr handle, IntPtr profileHandle);
93 [DllImport(Libraries.Connection, EntryPoint = "connection_update_profile")]
94 public static extern int UpdateProfile(IntPtr handle, IntPtr profileHandle);
96 [DllImport(Libraries.Connection, EntryPoint = "connection_get_default_cellular_service_profile")]
97 public static extern int GetDefaultCellularServiceProfile(IntPtr handle, int type, out IntPtr profileHandle);
99 [DllImport(Libraries.Connection, EntryPoint = "connection_get_current_profile")]
100 public static extern int GetCurrentProfile(IntPtr handle, out IntPtr profileHandle);
102 [DllImport(Libraries.Connection, EntryPoint = "connection_open_profile")]
103 public static extern int OpenProfile(IntPtr handle, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
105 [DllImport(Libraries.Connection, EntryPoint = "connection_close_profile")]
106 public static extern int CloseProfile(IntPtr handle, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
108 [DllImport(Libraries.Connection, EntryPoint = "connection_reset_profile")]
109 public static extern int ResetProfile(IntPtr handle, int Option, int Id, ConnectionCallback callback, IntPtr userData);
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);
114 [DllImport(Libraries.Connection, EntryPoint = "connection_get_profile_iterator")]
115 public static extern int GetProfileIterator(IntPtr handle, int type, out IntPtr iterHandle);
117 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_iterator_next")]
118 public static extern int GetNextProfileIterator(IntPtr iterHandle, out IntPtr profileHandle);
120 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_iterator_has_next")]
121 public static extern bool HasNextProfileIterator(IntPtr iterHandle);
123 [DllImport(Libraries.Connection, EntryPoint = "connection_destroy_profile_iterator")]
124 public static extern int DestroyProfileIterator(IntPtr iterHandle);
127 internal static partial class ConnectionProfile
129 public delegate void profile_state_changed_cb(ProfileState type, IntPtr userData);
131 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_create")]
132 public static extern int Create(int ProfileType, string Keyword, out IntPtr profileHandle);
134 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_clone")]
135 public static extern int Clone(out IntPtr cloneHandle, IntPtr profileHandle);
137 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_destroy")]
138 public static extern int Destroy(IntPtr profileHandle);
140 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_id")]
141 public static extern int GetId(IntPtr profileHandle, out IntPtr profileId);
143 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_name")]
144 public static extern int GetName(IntPtr profileHandle, out IntPtr name);
146 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_type")]
147 public static extern int GetType(IntPtr profileHandle, out int type);
149 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_network_interface_name")]
150 public static extern int GetNetworkInterfaceName(IntPtr profileHandle, out IntPtr interfaceName);
152 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_state")]
153 public static extern int GetState(IntPtr profileHandle, out int type);
155 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ip_config_type")]
156 public static extern int GetIpConfigType(IntPtr profileHandle, int family, out int type);
158 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_proxy_type")]
159 public static extern int GetProxyType(IntPtr profileHandle, out int type);
161 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ip_address")]
162 public static extern int GetIpAddress(IntPtr profileHandle, int family, out IntPtr address);
164 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_subnet_mask")]
165 public static extern int GetSubnetMask(IntPtr profileHandle, int family, out IntPtr address);
167 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_gateway_address")]
168 public static extern int GetGatewayAddress(IntPtr profileHandle, int family, out IntPtr address);
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);
173 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_proxy_address")]
174 public static extern int GetProxyAddress(IntPtr profileHandle, int family, out IntPtr address);
176 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_ip_config_type")]
177 public static extern int SetIpConfigType(IntPtr profileHandle, int family, int type);
179 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_proxy_type")]
180 public static extern int SetProxyType(IntPtr profileHandle, int type);
182 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_ip_address")]
183 public static extern int SetIpAddress(IntPtr profileHandle, int family, string address);
185 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_subnet_mask")]
186 public static extern int SetSubnetMask(IntPtr profileHandle, int family, string address);
188 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_gateway_address")]
189 public static extern int SetGatewayAddress(IntPtr profileHandle, int family, string address);
191 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_dns_address")]
192 public static extern int SetDnsAddress(IntPtr profileHandle, int family, string address);
194 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_proxy_address")]
195 public static extern int SetProxyAddress(IntPtr profileHandle, int family, string address);
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);
200 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_unset_state_changed_cb")]
201 public static extern int UnsetStateChangeCallback(IntPtr profileHandle);
204 internal static partial class ConnectionCellularProfile
206 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_service_type")]
207 public static extern int GetServiceType(IntPtr profileHandle, out int type);
209 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_apn")]
210 public static extern int GetApn(IntPtr profileHandle, out IntPtr apn);
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);
215 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_home_url")]
216 public static extern int GetHomeUrl(IntPtr profileHandle, out IntPtr homeUrl);
218 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_roaming")]
219 public static extern int IsRoaming(IntPtr profileHandle, out bool roaming);
221 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_hidden")]
222 public static extern int IsHidden(IntPtr profileHandle, out bool hidden);
224 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_editable")]
225 public static extern int IsEditable(IntPtr profileHandle, out bool editable);
227 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_default")]
228 public static extern int IsDefault(IntPtr profileHandle, out bool isDefault);
230 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_service_type")]
231 public static extern int SetServiceType(IntPtr profileHandle, int type);
233 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_apn")]
234 public static extern int SetApn(IntPtr profileHandle, string apn);
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);
239 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_home_url")]
240 public static extern int SetHomeUrl(IntPtr profileHandle, string homeUrl);
244 internal static partial class ConnectionWiFiProfile
246 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_essid")]
247 public static extern int GetEssid(IntPtr profileHandle, out IntPtr essid);
249 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_bssid")]
250 public static extern int GetBssid(IntPtr profileHandle, out IntPtr bssid);
252 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_rssi")]
253 public static extern int GetRssi(IntPtr profileHandle, out int rssi);
255 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_frequency")]
256 public static extern int GetFrequency(IntPtr profileHandle, out int frequency);
258 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_max_speed")]
259 public static extern int GetMaxSpeed(IntPtr profileHandle, out int maxSpeed);
261 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_security_type")]
262 public static extern int GetSecurityType(IntPtr profileHandle, out int type);
264 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_encryption_type")]
265 public static extern int GetEncryptionType(IntPtr profileHandle, out int type);
267 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_wifi_passphrase_required")]
268 public static extern int IsRequiredPassphrase(IntPtr profileHandle, out bool required);
270 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_wifi_passphrase")]
271 public static extern int SetPassphrase(IntPtr profileHandle, string passphrase);
273 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_wifi_wps_supported")]
274 public static extern int IsSupportedWps(IntPtr profileHandle, out bool supported);
277 internal static partial class Libc
279 [DllImport(Libraries.Libc, EntryPoint = "free")]
280 public static extern void Free(IntPtr userData);