--- /dev/null
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+Name: csapi-network-connection
+Summary: Tizen Connection API for C#
+Version: 1.0.2
+Release: 1
+Group: Development/Libraries
+License: Apache-2.0
+URL: https://www.tizen.org
+Source0: %{name}-%{version}.tar.gz
+Source1: %{name}.manifest
+
+AutoReqProv: no
+ExcludeArch: aarch64 %ix86
+
+BuildRequires: dotnet-build-tools
+
+# C# API Requires
+BuildRequires: csapi-tizen-nuget
+
+%define Assemblies Tizen.Network.Connection
+
+%description
+%{summary}
+
+%dotnet_import_sub_packages
+
+%prep
+%setup -q
+cp %{SOURCE1} .
+
+%build
+for ASM in %{Assemblies}; do
+%dotnet_build $ASM
+%dotnet_pack $ASM/$ASM.nuspec %{version}
+done
+
+%install
+for ASM in %{Assemblies}; do
+%dotnet_install $ASM
+done
+
+%files
+%manifest %{name}.manifest
+%license LICENSE
+%attr(644,root,root) %{dotnet_assembly_files}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen.Network.Connection;
+
+internal static partial class Interop
+{
+ internal static partial class Connection
+ {
+ public delegate void ConnectionTypeChangedCallback(ConnectionType type, IntPtr userData);
+ public delegate void EthernetCableStateChangedCallback(EthernetCableState state, IntPtr userData);
+ public delegate void ConnectionAddressChangedCallback(IntPtr ipv4, IntPtr ipv6, IntPtr userData);
+ public delegate void ConnectionCallback(ConnectionError result, IntPtr userData);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_create")]
+ public static extern int Create(out IntPtr handle);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_destroy")]
+ public static extern int Destroy(IntPtr handle);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_get_type")]
+ public static extern int GetType(IntPtr handle, out int type);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_get_ip_address")]
+ public static extern int GetIpAddress(IntPtr handle, int family, out IntPtr address);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_get_proxy")]
+ public static extern int GetProxy(IntPtr handle, int family, out IntPtr address);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_get_mac_address")]
+ public static extern int GetMacAddress(IntPtr handle, int family, out IntPtr address);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_get_wifi_state")]
+ public static extern int GetWiFiState(IntPtr handle, out int state);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_get_cellular_state")]
+ public static extern int GetCellularState(IntPtr handle, out int state);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_get_ethernet_state")]
+ public static extern int GetEthernetState(IntPtr handle, out int state);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_get_ethernet_cable_state")]
+ public static extern int GetEthernetCableState(IntPtr handle, out int state);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_get_bt_state")]
+ public static extern int GetBtState(IntPtr handle, out int state);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_set_type_changed_cb")]
+ public static extern int SetTypeChangedCallback(IntPtr handle, ConnectionTypeChangedCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_set_ip_address_changed_cb")]
+ public static extern int SetIpAddressChangedCallback(IntPtr handle, ConnectionAddressChangedCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_set_ethernet_cable_state_chaged_cb")]
+ public static extern int SetEthernetCableStateChagedCallback(IntPtr handle, EthernetCableStateChangedCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_set_proxy_address_changed_cb")]
+ public static extern int SetProxyAddressChangedCallback(IntPtr handle, ConnectionAddressChangedCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_unset_type_changed_cb")]
+ public static extern int UnsetTypeChangedCallback(IntPtr handle);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_unset_ip_address_changed_cb")]
+ public static extern int UnsetIpAddressChangedCallback(IntPtr handle);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_unset_ethernet_cable_state_chaged_cb")]
+ public static extern int UnsetEthernetCableStateChagedCallback(IntPtr handle);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_unset_proxy_address_changed_cb")]
+ public static extern int UnsetProxyAddressChangedCallback(IntPtr handle);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_add_profile")]
+ public static extern int AddProfile(IntPtr handle, IntPtr profileHandle);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_remove_profile")]
+ public static extern int RemoveProfile(IntPtr handle, IntPtr profileHandle);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_update_profile")]
+ public static extern int UpdateProfile(IntPtr handle, IntPtr profileHandle);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_get_default_cellular_service_profile")]
+ public static extern int GetDefaultCellularServiceProfile(IntPtr handle, int type, out IntPtr profileHandle);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_get_current_profile")]
+ public static extern int GetCurrentProfile(IntPtr handle, out IntPtr profileHandle);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_open_profile")]
+ public static extern int OpenProfile(IntPtr handle, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_close_profile")]
+ public static extern int CloseProfile(IntPtr handle, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_reset_profile")]
+ public static extern int ResetProfile(IntPtr handle, int Option, int Id, ConnectionCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_set_default_cellular_service_profile_async")]
+ public static extern int SetDefaultCellularServiceProfileAsync(IntPtr handle, int Type, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_get_profile_iterator")]
+ public static extern int GetProfileIterator(IntPtr handle, int type, out IntPtr iterHandle);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_iterator_next")]
+ public static extern int GetNextProfileIterator(IntPtr iterHandle, out IntPtr profileHandle);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_iterator_has_next")]
+ public static extern bool HasNextProfileIterator(IntPtr iterHandle);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_destroy_profile_iterator")]
+ public static extern int DestroyProfileIterator(IntPtr iterHandle);
+ }
+
+ internal static partial class ConnectionProfile
+ {
+ public delegate void profile_state_changed_cb(ProfileState type, IntPtr userData);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_create")]
+ public static extern int Create(int ProfileType, string Keyword, out IntPtr profileHandle);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_clone")]
+ public static extern int Clone(out IntPtr cloneHandle, IntPtr profileHandle);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_destroy")]
+ public static extern int Destroy(IntPtr profileHandle);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_id")]
+ public static extern int GetId(IntPtr profileHandle, out IntPtr profileId);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_name")]
+ public static extern int GetName(IntPtr profileHandle, out IntPtr name);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_type")]
+ public static extern int GetType(IntPtr profileHandle, out int type);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_network_interface_name")]
+ public static extern int GetNetworkInterfaceName(IntPtr profileHandle, out IntPtr interfaceName);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_state")]
+ public static extern int GetState(IntPtr profileHandle, out int type);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ip_config_type")]
+ public static extern int GetIpConfigType(IntPtr profileHandle, int family, out int type);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_proxy_type")]
+ public static extern int GetProxyType(IntPtr profileHandle, out int type);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ip_address")]
+ public static extern int GetIpAddress(IntPtr profileHandle, int family, out IntPtr address);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_subnet_mask")]
+ public static extern int GetSubnetMask(IntPtr profileHandle, int family, out IntPtr address);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_gateway_address")]
+ public static extern int GetGatewayAddress(IntPtr profileHandle, int family, out IntPtr address);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_dns_address")]
+ public static extern int GetDnsAddress(IntPtr profileHandle, int order, int Family, out IntPtr address);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_proxy_address")]
+ public static extern int GetProxyAddress(IntPtr profileHandle, int family, out IntPtr address);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_ip_config_type")]
+ public static extern int SetIpConfigType(IntPtr profileHandle, int family, int type);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_proxy_type")]
+ public static extern int SetProxyType(IntPtr profileHandle, int type);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_ip_address")]
+ public static extern int SetIpAddress(IntPtr profileHandle, int family, string address);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_subnet_mask")]
+ public static extern int SetSubnetMask(IntPtr profileHandle, int family, string address);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_gateway_address")]
+ public static extern int SetGatewayAddress(IntPtr profileHandle, int family, string address);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_dns_address")]
+ public static extern int SetDnsAddress(IntPtr profileHandle, int family, string address);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_proxy_address")]
+ public static extern int SetProxyAddress(IntPtr profileHandle, int family, string address);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_state_changed_cb")]
+ public static extern int SetStateChangeCallback(IntPtr profileHandle, profile_state_changed_cb callback, IntPtr userData);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_unset_state_changed_cb")]
+ public static extern int UnsetStateChangeCallback(IntPtr profileHandle);
+ }
+
+ internal static partial class ConnectionCellularProfile
+ {
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_service_type")]
+ public static extern int GetServiceType(IntPtr profileHandle, out int type);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_apn")]
+ public static extern int GetApn(IntPtr profileHandle, out IntPtr apn);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_auth_info")]
+ public static extern int GetAuthInfo(IntPtr profileHandle, out int authType, out IntPtr name, out IntPtr password);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_home_url")]
+ public static extern int GetHomeUrl(IntPtr profileHandle, out IntPtr homeUrl);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_roaming")]
+ public static extern int IsRoaming(IntPtr profileHandle, out bool roaming);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_hidden")]
+ public static extern int IsHidden(IntPtr profileHandle, out bool hidden);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_editable")]
+ public static extern int IsEditable(IntPtr profileHandle, out bool editable);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_default")]
+ public static extern int IsDefault(IntPtr profileHandle, out bool isDefault);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_service_type")]
+ public static extern int SetServiceType(IntPtr profileHandle, int type);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_apn")]
+ public static extern int SetApn(IntPtr profileHandle, string apn);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_auth_info")]
+ public static extern int SetAuthInfo(IntPtr profileHandle, int authType, string name, string password);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_home_url")]
+ public static extern int SetHomeUrl(IntPtr profileHandle, string homeUrl);
+
+ }
+
+ internal static partial class ConnectionWiFiProfile
+ {
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_essid")]
+ public static extern int GetEssid(IntPtr profileHandle, out IntPtr essid);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_bssid")]
+ public static extern int GetBssid(IntPtr profileHandle, out IntPtr bssid);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_rssi")]
+ public static extern int GetRssi(IntPtr profileHandle, out int rssi);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_frequency")]
+ public static extern int GetFrequency(IntPtr profileHandle, out int frequency);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_max_speed")]
+ public static extern int GetMaxSpeed(IntPtr profileHandle, out int maxSpeed);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_security_type")]
+ public static extern int GetSecurityType(IntPtr profileHandle, out int type);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_encryption_type")]
+ public static extern int GetEncryptionType(IntPtr profileHandle, out int type);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_wifi_passphrase_required")]
+ public static extern int IsRequiredPassphrase(IntPtr profileHandle, out bool required);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_wifi_passphrase")]
+ public static extern int SetPassphrase(IntPtr profileHandle, string passphrase);
+
+ [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_wifi_wps_supported")]
+ public static extern int IsSupportedWps(IntPtr profileHandle, out bool supported);
+ }
+
+ internal static partial class Libc
+ {
+ [DllImport(Libraries.Libc, EntryPoint = "free")]
+ public static extern void Free(IntPtr userData);
+
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+ internal static partial class Libraries
+ {
+ public const string Connection = "libcapi-network-connection.so.1";
+ public const string WiFi = "libcapi-network-wifi.so.1";
+ public const string Bluetooth = "libcapi-network-bluetooth.so.0";
+ public const string Smartcard = "libcapi-network-smartcard.so.0";
+ public const string Nfc = "libcapi-network-nfc.so.0";
+ public const string WiFiDirect = "libwifi-direct.so.1";
+ public const string Glib = "libglib-2.0.so.0";
+ public const string Libc = "libc.so.6";
+ }
+}
--- /dev/null
+using System.Reflection;\r
+using System.Runtime.CompilerServices;\r
+using System.Runtime.InteropServices;\r
+\r
+// General Information about an assembly is controlled through the following\r
+// set of attributes. Change these attribute values to modify the information\r
+// associated with an assembly.\r
+[assembly: AssemblyTitle("Tizen.Network.Connection")]\r
+[assembly: AssemblyDescription("")]\r
+[assembly: AssemblyConfiguration("")]\r
+[assembly: AssemblyCompany("Samsung Electronics")]\r
+[assembly: AssemblyProduct("Tizen.Network.Connection")]\r
+[assembly: AssemblyCopyright("Copyright © Samsung Electronics 2016")]\r
+[assembly: AssemblyTrademark("")]\r
+[assembly: AssemblyCulture("")]\r
+\r
+// Setting ComVisible to false makes the types in this assembly not visible\r
+// to COM components. If you need to access a type in this assembly from\r
+// COM, set the ComVisible attribute to true on that type.\r
+[assembly: ComVisible(false)]\r
+\r
+// The following GUID is for the ID of the typelib if this project is exposed to COM\r
+[assembly: Guid("d9b186b9-bff3-4bd5-9dc0-3706390caaf9")]\r
+\r
+// Version information for an assembly consists of the following four values:\r
+//\r
+// Major Version\r
+// Minor Version\r
+// Build Number\r
+// Revision\r
+//\r
+// You can specify all the values or you can default the Build and Revision Numbers\r
+// by using the '*' as shown below:\r
+// [assembly: AssemblyVersion("1.0.*")]\r
+[assembly: AssemblyVersion("1.0.0.0")]\r
+[assembly: AssemblyFileVersion("1.0.0.0")]\r
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{3E8CB60C-B3E5-41B6-B58C-996515C6B4B2}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Tizen.Network.Connection</RootNamespace>
+ <AssemblyName>Tizen.Network.Connection</AssemblyName>
+ <FileAlignment>512</FileAlignment>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\Net45\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\Net45\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>Tizen.Network.Connection.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Interop\Interop.Libraries.cs" />
+ <Compile Include="Interop\Interop.Connection.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Tizen.Network.Connection\CellularProfile.cs" />
+ <Compile Include="Tizen.Network.Connection\ConnectionError.cs" />
+ <Compile Include="Tizen.Network.Connection\ConnectionInternalManager.cs" />
+ <Compile Include="Tizen.Network.Connection\ConnectionManager.cs" />
+ <Compile Include="Tizen.Network.Connection\ConnectionProfile.cs" />
+ <Compile Include="Tizen.Network.Connection\ConnectionProfileManager.cs" />
+ <Compile Include="Tizen.Network.Connection\ConnectionTypes.cs" />
+ <Compile Include="Tizen.Network.Connection\IAddressInformation.cs" />
+ <Compile Include="Tizen.Network.Connection\RequestCellularProfile.cs" />
+ <Compile Include="Tizen.Network.Connection\RequestProfile.cs" />
+ <Compile Include="Tizen.Network.Connection\RequestWiFiProfile.cs" />
+ <Compile Include="Tizen.Network.Connection\WiFiProfile.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Tizen.Network.Connection.nuspec" />
+ <None Include="Tizen.Network.Connection.Net45.project.json" />
+ <None Include="Tizen.Network.Connection.snk" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
--- /dev/null
+{
+ "dependencies": {
+ "Tizen": "1.0.2"
+ },
+ "frameworks": {
+ "net45": {}
+ },
+ "runtimes": {
+ "win": {}
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{D9B186B9-BFF3-4BD5-9DC0-3706390CAAF9}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Tizen.Network.Connection</RootNamespace>
+ <AssemblyName>Tizen.Network.Connection</AssemblyName>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup>
+ <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>
+ <TargetFrameworkVersion>v1.3</TargetFrameworkVersion>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker>
+ <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
+ <NoStdLib>true</NoStdLib>
+ <NoWarn>$(NoWarn);1701;1702</NoWarn>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>Tizen.Network.Connection.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="Interop\Interop.Libraries.cs" />
+ <Compile Include="Interop\Interop.Connection.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Tizen.Network.Connection\CellularProfile.cs" />
+ <Compile Include="Tizen.Network.Connection\ConnectionError.cs" />
+ <Compile Include="Tizen.Network.Connection\ConnectionInternalManager.cs" />
+ <Compile Include="Tizen.Network.Connection\ConnectionManager.cs" />
+ <Compile Include="Tizen.Network.Connection\ConnectionProfile.cs" />
+ <Compile Include="Tizen.Network.Connection\ConnectionProfileManager.cs" />
+ <Compile Include="Tizen.Network.Connection\ConnectionTypes.cs" />
+ <Compile Include="Tizen.Network.Connection\IAddressInformation.cs" />
+ <Compile Include="Tizen.Network.Connection\RequestCellularProfile.cs" />
+ <Compile Include="Tizen.Network.Connection\RequestProfile.cs" />
+ <Compile Include="Tizen.Network.Connection\RequestWiFiProfile.cs" />
+ <Compile Include="Tizen.Network.Connection\WiFiProfile.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Tizen.Network.Connection.nuspec" />
+ <None Include="Tizen.Network.Connection.project.json" />
+ <None Include="Tizen.Network.Connection.snk" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+ <PropertyGroup>
+ <!-- https://github.com/dotnet/corefxlab/tree/master/samples/NetCoreSample and
+ https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/target-dotnetcore-with-msbuild
+ -->
+ <!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two
+ properties to any folder that exists to skip the GetReferenceAssemblyPaths task (not target) and
+ to prevent it from outputting a warning (MSB3644).
+ -->
+ <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)</_TargetFrameworkDirectories>
+ <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>
+ <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>
+ </PropertyGroup>
+</Project>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<package>
+ <metadata>
+ <id>Tizen.Network.Connection</id>
+ <version>$version$</version>
+ <authors>Samsung Electronics</authors>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
+ <projectUrl>https://www.tizen.org/</projectUrl>
+ <iconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</iconUrl>
+ <copyright>© Samsung Electronics Co., Ltd All Rights Reserved</copyright>
+ <description>Provides the Connection APIs for Tizen.Network.Connection</description>
+ <dependencies>
+ <dependency id="Tizen" version="1.0.2" />
+ </dependencies>
+ </metadata>
+ <files>
+ <file src="bin/$Configuration$/Tizen.Network.Connection.dll" target="lib/netstandard1.3" />
+ <file src="bin/$Configuration$/Net45/Tizen.Network.Connection.dll" target="lib/net45" />
+ </files>
+</package>
--- /dev/null
+{\r
+ "dependencies": {\r
+ "NETStandard.Library": "1.6.0",\r
+ "Tizen": "1.0.2"\r
+ },\r
+ "frameworks": {\r
+ "netstandard1.3": {}\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Visual Studio 14\r
+VisualStudioVersion = 14.0.25420.1\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Network.Connection", "Tizen.Network.Connection.csproj", "{D9B186B9-BFF3-4BD5-9DC0-3706390CAAF9}"\r
+EndProject\r
+Global\r
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+ Debug|Any CPU = Debug|Any CPU\r
+ Release|Any CPU = Release|Any CPU\r
+ EndGlobalSection\r
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+ {D9B186B9-BFF3-4BD5-9DC0-3706390CAAF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+ {D9B186B9-BFF3-4BD5-9DC0-3706390CAAF9}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+ {D9B186B9-BFF3-4BD5-9DC0-3706390CAAF9}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+ {D9B186B9-BFF3-4BD5-9DC0-3706390CAAF9}.Release|Any CPU.Build.0 = Release|Any CPU\r
+ EndGlobalSection\r
+ GlobalSection(SolutionProperties) = preSolution\r
+ HideSolutionNode = FALSE\r
+ EndGlobalSection\r
+EndGlobal\r
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Network.Connection
+{
+ /// <summary>
+ /// This Class is CellularProfile
+ /// </summary>
+ public class CellularProfile : ConnectionProfile
+ {
+ private CellularAuthInformation AuthInfo;
+
+ internal CellularProfile(IntPtr handle): base(handle)
+ {
+ AuthInfo = new CellularAuthInformation(handle);
+ }
+
+ ~CellularProfile()
+ {
+ }
+
+ /// <summary>
+ /// Gets the APN (access point name).
+ /// </summary>
+ public string Apn
+ {
+ get
+ {
+ IntPtr Value;
+ int ret = Interop.ConnectionCellularProfile.GetApn(ProfileHandle, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get apn, " + (ConnectionError)ret);
+ }
+ string result = Marshal.PtrToStringAnsi(Value);
+ Interop.Libc.Free(Value);
+ return result;
+ }
+ set
+ {
+ int ret = Interop.ConnectionCellularProfile.SetApn(ProfileHandle, (string)value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set apn, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets the home URL.
+ /// </summary>
+ public string HomeUri
+ {
+ get
+ {
+ IntPtr Value;
+ int ret = Interop.ConnectionCellularProfile.GetHomeUrl(ProfileHandle, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get home url, " + (ConnectionError)ret);
+ }
+ string result = Marshal.PtrToStringAnsi(Value);
+ Interop.Libc.Free(Value);
+ return result;
+ }
+ set
+ {
+ int ret = Interop.ConnectionCellularProfile.SetHomeUrl(ProfileHandle, (string)value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set home url, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+
+ }
+ }
+
+ /// <summary>
+ /// Gets the service type.
+ /// </summary>
+ public CellularServiceType ServiceType
+ {
+ get
+ {
+ int value;
+ int ret = Interop.ConnectionCellularProfile.GetServiceType(ProfileHandle, out value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get service type, " + (ConnectionError)ret);
+ }
+ return (CellularServiceType)value;
+ }
+ set
+ {
+ int ret = Interop.ConnectionCellularProfile.SetServiceType(ProfileHandle, (int)value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set service type, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets cellular Authentification Information.
+ /// </summary>
+ public CellularAuthInformation CellularAuthInfo
+ {
+ get
+ {
+ return AuthInfo;
+ }
+ }
+
+ /// <summary>
+ /// Checks whether the profile is hidden.
+ /// </summary>
+ public bool Hidden
+ {
+ get
+ {
+ bool value;
+ int ret = Interop.ConnectionCellularProfile.IsHidden(ProfileHandle, out value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get hidden value, " + (ConnectionError)ret);
+ }
+ return value;
+ }
+ }
+
+ /// <summary>
+ /// Checks whether the profile is editable.
+ /// </summary>
+ public bool Editable
+ {
+ get
+ {
+ bool value;
+ int ret = Interop.ConnectionCellularProfile.IsEditable(ProfileHandle, out value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get editable value, " + (ConnectionError)ret);
+ }
+ return value;
+ }
+ }
+
+ /// <summary>
+ /// Checks whether the profile is default.
+ /// </summary>
+ public bool IsDefault
+ {
+ get
+ {
+ bool value;
+ int ret = Interop.ConnectionCellularProfile.IsDefault(ProfileHandle, out value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get IsDefault value, " + (ConnectionError)ret);
+ }
+ return value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// The authentication information.
+ /// </summary>
+ public class CellularAuthInformation
+ {
+ private IntPtr ProfileHandle;
+
+ private string Name = "";
+ private string Passwd = "";
+ private CellularAuthType AuthenType = CellularAuthType.None;
+
+ internal CellularAuthInformation(IntPtr handle)
+ {
+ ProfileHandle = handle;
+ }
+
+ /// <summary>
+ /// The user name.
+ /// </summary>
+ public string UserName
+ {
+ get
+ {
+ int type;
+ IntPtr name;
+ IntPtr password;
+
+ int ret = Interop.ConnectionCellularProfile.GetAuthInfo(ProfileHandle, out type, out name, out password);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get auth information, " + (ConnectionError)ret);
+ }
+
+ Name = Marshal.PtrToStringAnsi(name);
+ Passwd = Marshal.PtrToStringAnsi(name);
+ AuthenType = (CellularAuthType)type;
+
+ Interop.Libc.Free(name);
+ Interop.Libc.Free(password);
+
+ return Name;
+ }
+ set
+ {
+ Name = value;
+ int ret = Interop.ConnectionCellularProfile.SetAuthInfo(ProfileHandle, (int)AuthenType, (string)value, Passwd);
+ Log.Error(Globals.LogTag, "UserName : "+ value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set auth information, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+
+ /// <summary>
+ /// The password
+ /// </summary>
+ public string Password
+ {
+ get
+ {
+ int type;
+ IntPtr name;
+ IntPtr password;
+
+ int ret = Interop.ConnectionCellularProfile.GetAuthInfo(ProfileHandle, out type, out name, out password);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get auth information, " + (ConnectionError)ret);
+ }
+ Name = Marshal.PtrToStringAnsi(name);
+ Passwd = Marshal.PtrToStringAnsi(password);
+ AuthenType = (CellularAuthType)type;
+
+ Interop.Libc.Free(name);
+ Interop.Libc.Free(password);
+
+ return Passwd;
+ }
+ set
+ {
+ Passwd = value;
+ int ret = Interop.ConnectionCellularProfile.SetAuthInfo(ProfileHandle, (int)AuthenType, Name, (string)value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set auth information, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+
+ /// <summary>
+ /// The authentication type
+ /// </summary>
+ public CellularAuthType AuthType
+ {
+ get
+ {
+ int type;
+ IntPtr name;
+ IntPtr password;
+
+ int ret = Interop.ConnectionCellularProfile.GetAuthInfo(ProfileHandle, out type, out name, out password);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get auth information, " + (ConnectionError)ret);
+ }
+
+ Name = Marshal.PtrToStringAnsi(name);
+ Passwd = Marshal.PtrToStringAnsi(name);
+ AuthenType = (CellularAuthType)type;
+
+ Interop.Libc.Free(name);
+ Interop.Libc.Free(password);
+ return AuthenType;
+ }
+ set
+ {
+ AuthenType = value;
+ int ret = Interop.ConnectionCellularProfile.SetAuthInfo(ProfileHandle, (int)value, Name, Passwd);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set auth information, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tizen.Network.Connection
+{
+ internal class ConnectionErrorFactory
+ {
+ static public void ThrowConnectionException(int errno)
+ {
+ ConnectionError error = (ConnectionError)errno;
+ if (error == ConnectionError.AddressFamilyNotSupported)
+ {
+ throw new InvalidOperationException("Address Family Not Supported");
+ }
+ else if (error == ConnectionError.AlreadyExists)
+ {
+ throw new InvalidOperationException("Already Exists");
+ }
+ else if (error == ConnectionError.DhcpFailed)
+ {
+ throw new InvalidOperationException("DHCP Failed");
+ }
+ else if (error == ConnectionError.EndOfIteration)
+ {
+ throw new InvalidOperationException("End Of Iteration");
+ }
+ else if (error == ConnectionError.InvalidKey)
+ {
+ throw new InvalidOperationException("Invalid Key");
+ }
+ else if (error == ConnectionError.InvalidOperation)
+ {
+ throw new InvalidOperationException("Invalid Operation");
+ }
+ else if (error == ConnectionError.InvalidParameter)
+ {
+ throw new InvalidOperationException("Invalid Parameter");
+ }
+ else if (error == ConnectionError.NoConnection)
+ {
+ throw new InvalidOperationException("No Connection");
+ }
+ else if (error == ConnectionError.NoReply)
+ {
+ throw new InvalidOperationException("No Reply");
+ }
+ else if (error == ConnectionError.NotSupported)
+ {
+ throw new NotSupportedException("Not Supported");
+ }
+ else if (error == ConnectionError.NowInProgress)
+ {
+ throw new InvalidOperationException("Now In Progress");
+ }
+ else if (error == ConnectionError.OperationAborted)
+ {
+ throw new InvalidOperationException("Operation Aborted");
+ }
+ else if (error == ConnectionError.OperationFailed)
+ {
+ throw new InvalidOperationException("Operation Failed");
+ }
+ else if (error == ConnectionError.OutOfMemoryError)
+ {
+ throw new InvalidOperationException("Out Of Memory Error");
+ }
+ else if (error == ConnectionError.PermissionDenied)
+ {
+ throw new InvalidOperationException("Permission Denied");
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Runtime.InteropServices;
+using System.Collections;
+
+namespace Tizen.Network.Connection
+{
+ class HandleHolder : IDisposable
+ {
+ private IntPtr Handle;
+ private bool disposed = false;
+
+ public HandleHolder()
+ {
+ Log.Debug(Globals.LogTag, "HandleHolder() ^^");
+ Interop.Connection.Create(out Handle);
+ Log.Debug(Globals.LogTag, "Handle: " + Handle);
+ }
+
+ ~HandleHolder()
+ {
+ Dispose(false);
+ }
+
+ internal IntPtr GetHandle()
+ {
+ return Handle;
+ }
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (disposed)
+ return;
+
+ if (disposing)
+ {
+ // Free managed objects.
+ }
+ Interop.Connection.Destroy(Handle);
+ disposed = true;
+ }
+ }
+
+ static class ConnectionInternalManager
+ {
+ private static HandleHolder Holder = new HandleHolder();
+
+ static public IntPtr GetHandle()
+ {
+ return Holder.GetHandle();
+ }
+
+ static internal int GetProfileIterator(ProfileListType type, out IntPtr iterator)
+ {
+ return Interop.Connection.GetProfileIterator(Holder.GetHandle(), (int)type, out iterator);
+ }
+
+ static internal bool HasNext(IntPtr iterator)
+ {
+ return Interop.Connection.HasNextProfileIterator(iterator);
+ }
+
+ static internal int NextProfileIterator(IntPtr iterator, out IntPtr profileHandle)
+ {
+ return Interop.Connection.GetNextProfileIterator(iterator, out profileHandle);
+ }
+
+ static internal int DestoryProfileIterator(IntPtr iterator)
+ {
+ return Interop.Connection.DestroyProfileIterator(iterator);
+ }
+
+ static public string GetIpAddress(AddressFamily family)
+ {
+ IntPtr ip;
+ int ret = Interop.Connection.GetIpAddress(Holder.GetHandle(), (int)family, out ip);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get IP address, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ string result = Marshal.PtrToStringAnsi(ip);
+ Interop.Libc.Free(ip);
+ return result;
+ }
+
+ static public string GetProxy(AddressFamily family)
+ {
+ IntPtr ip;
+ int ret = Interop.Connection.GetProxy(Holder.GetHandle(), (int)family, out ip);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get proxy, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ string result = Marshal.PtrToStringAnsi(ip);
+ Interop.Libc.Free(ip);
+ return result;
+ }
+
+ static public string GetMacAddress(ConnectionType type)
+ {
+ IntPtr ip;
+ int ret = Interop.Connection.GetMacAddress(Holder.GetHandle(), (int)type, out ip);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get mac address, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ string result = Marshal.PtrToStringAnsi(ip);
+ Interop.Libc.Free(ip);
+ return result;
+ }
+
+ static public ConnectionType ConnectionType
+ {
+ get
+ {
+ int type = 0;
+ Log.Debug(Globals.LogTag, "Handle: " + Holder.GetHandle());
+ int ret = Interop.Connection.GetType(Holder.GetHandle(), out type);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get connection type, " + (ConnectionError)ret);
+ }
+ return (ConnectionType)type;
+ }
+ }
+
+ static public CellularState CellularState
+ {
+ get
+ {
+ int type = 0;
+ int ret = Interop.Connection.GetCellularState(Holder.GetHandle(), out type);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get cellular state, " + (ConnectionError)ret);
+ }
+ return (CellularState)type;
+ }
+ }
+
+ static public ConnectionState WiFiState
+ {
+ get
+ {
+ int type = 0;
+ int ret = Interop.Connection.GetWiFiState(Holder.GetHandle(), out type);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get wifi state, " + (ConnectionError)ret);
+ }
+ return (ConnectionState)type;
+ }
+ }
+
+ static public ConnectionState BluetoothState
+ {
+ get
+ {
+ int type = 0;
+ int ret = Interop.Connection.GetBtState(Holder.GetHandle(), out type);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get bluetooth state, " + (ConnectionError)ret);
+ }
+ return (ConnectionState)type;
+ }
+ }
+
+ static public ConnectionState EthernetState
+ {
+ get
+ {
+ int type = 0;
+ int ret = Interop.Connection.GetEthernetState(Holder.GetHandle(), out type);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get ethernet state, " + (ConnectionError)ret);
+ }
+ return (ConnectionState)type;
+ }
+ }
+
+ static public EthernetCableState EthernetCableState
+ {
+ get
+ {
+ int type = 0;
+ int ret = Interop.Connection.GetEthernetCableState(Holder.GetHandle(), out type);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get ethernet cable state, " + (ConnectionError)ret);
+ }
+ return (EthernetCableState)type;
+ }
+ }
+
+ static public IntPtr CreateRequestProfile(ConnectionProfileType type, string keyword)
+ {
+ Log.Error(Globals.LogTag, "CreateRequestProfile, " + type + ", " + keyword);
+ Log.Debug(Globals.LogTag, "Handle: " + GetHandle());
+ IntPtr handle = IntPtr.Zero;
+ int ret = Interop.ConnectionProfile.Create((int)type, keyword, out handle);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to Create profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+
+ return handle;
+ }
+
+ static public int AddProfile(RequestProfile profile)
+ {
+ int ret = 0;
+ if (profile.Type == ConnectionProfileType.Cellular)
+ {
+ ret = Interop.Connection.AddProfile(Holder.GetHandle(), ((RequestCellularProfile)profile).ProfileHandle);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to add profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ else if (profile.Type == ConnectionProfileType.WiFi)
+ {
+ ret = Interop.Connection.AddProfile(Holder.GetHandle(), ((RequestWiFiProfile)profile).ProfileHandle);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to add profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ return ret;
+ }
+
+ static public int RemoveProfile(ConnectionProfile profile)
+ {
+ int ret = Interop.Connection.RemoveProfile(Holder.GetHandle(), profile.ProfileHandle);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to remove profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ return ret;
+ }
+
+ static public int UpdateProfile(ConnectionProfile profile)
+ {
+ int ret = Interop.Connection.UpdateProfile(Holder.GetHandle(), profile.ProfileHandle);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to update profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ return ret;
+ }
+
+ static public ConnectionProfile GetCurrentProfile()
+ {
+ IntPtr ProfileHandle;
+ int ret = Interop.Connection.GetCurrentProfile(Holder.GetHandle(), out ProfileHandle);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get current profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ ConnectionProfile Profile = new ConnectionProfile(ProfileHandle);
+ return Profile;
+ }
+
+ static public ConnectionProfile GetDefaultCellularProfile(CellularServiceType type)
+ {
+ IntPtr ProfileHandle;
+ int ret = Interop.Connection.GetDefaultCellularServiceProfile(Holder.GetHandle(), (int)type, out ProfileHandle);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "Error: " + ret);
+ Log.Error(Globals.LogTag, "It failed to get default cellular profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ CellularProfile Profile = new CellularProfile(ProfileHandle);
+ return Profile;
+ }
+
+ static public Task<ConnectionError> SetDefaultCellularProfile(CellularServiceType type, ConnectionProfile profile)
+ {
+ var task = new TaskCompletionSource<ConnectionError>();
+ Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) =>
+ {
+ task.SetResult((ConnectionError)Result);
+ return;
+ };
+ int ret = Interop.Connection.SetDefaultCellularServiceProfileAsync(Holder.GetHandle(), (int)type, profile.ProfileHandle, Callback, (IntPtr)0);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set default cellular profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ return task.Task;
+ }
+
+
+ static public Task<IEnumerable<ConnectionProfile>> GetProfileListAsync(ProfileListType type)
+ {
+ var task = new TaskCompletionSource<IEnumerable<ConnectionProfile>>();
+
+ List<ConnectionProfile> Result = new List<ConnectionProfile>();
+ IntPtr iterator;
+ int ret = Interop.Connection.GetProfileIterator(Holder.GetHandle(), (int)type, out iterator);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get profile iterator, " + (ConnectionError)ret);
+ }
+
+ while (Interop.Connection.HasNextProfileIterator(iterator))
+ {
+ IntPtr nextH;
+ IntPtr profileH;
+ Interop.Connection.GetNextProfileIterator(iterator, out nextH);
+ Interop.ConnectionProfile.Clone(out profileH, nextH);
+
+ int profileType;
+ Interop.ConnectionProfile.GetType(profileH, out profileType);
+
+ if ((ConnectionProfileType)profileType == ConnectionProfileType.WiFi)
+ {
+ WiFiProfile cur = new WiFiProfile(profileH);
+ Result.Add(cur);
+ }
+ else if ((ConnectionProfileType)profileType == ConnectionProfileType.Cellular)
+ {
+ CellularProfile cur = new CellularProfile(profileH);
+ Result.Add(cur);
+ }
+ else {
+ ConnectionProfile cur = new ConnectionProfile(profileH);
+ Result.Add(cur);
+ }
+ }
+ Interop.Connection.DestroyProfileIterator(iterator);
+ task.SetResult(Result);
+ return task.Task;
+ }
+
+ static public Task<ConnectionError> OpenProfileAsync(ConnectionProfile profile)
+ {
+ var task = new TaskCompletionSource<ConnectionError>();
+ Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) =>
+ {
+ task.SetResult((ConnectionError)Result);
+ return;
+ };
+ int ret = Interop.Connection.OpenProfile(Holder.GetHandle(), profile.ProfileHandle, Callback, IntPtr.Zero);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to oepn profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ return task.Task;
+ }
+
+ static public Task<ConnectionError> CloseProfileAsync(ConnectionProfile profile)
+ {
+ var task = new TaskCompletionSource<ConnectionError>();
+ Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) =>
+ {
+ task.SetResult((ConnectionError)Result);
+ return;
+ };
+ int ret = Interop.Connection.CloseProfile(Holder.GetHandle(), profile.ProfileHandle, Callback, IntPtr.Zero);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to close profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ return task.Task;
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Runtime.InteropServices;
+
+/// <summary>
+/// The Connection API provides functions, enumerations to get the status of network and current profile and manage profiles.
+/// </summary>
+namespace Tizen.Network.Connection
+{
+ /// <summary>
+ /// This class is ConnectionManager
+ /// </summary>
+ public class ConnectionManager : IDisposable
+ {
+ static internal ConnectionItem CurConnction = new ConnectionItem();
+ private bool disposed = false;
+
+ static private EventHandler _ConnectionTypeChanged = null;
+ static private EventHandler _IPAddressChanged = null;
+ static private EventHandler _EthernetCableStateChanged = null;
+ static private EventHandler _ProxyAddressChanged = null;
+
+ /// <summary>
+ /// Event that is called when the type of the current connection is changed.
+ /// </summary>
+ static public event EventHandler ConnectionTypeChanged
+ {
+ add
+ {
+ if (_ConnectionTypeChanged == null)
+ {
+ ConnectionTypeChangedStart();
+ }
+ _ConnectionTypeChanged += value;
+ }
+ remove
+ {
+ _ConnectionTypeChanged -= value;
+ if (_ConnectionTypeChanged == null)
+ {
+ ConnectionTypeChangedStop();
+ }
+ }
+ }
+
+ static private void ConnectionTypeChangedStart()
+ {
+ int ret = Interop.Connection.SetTypeChangedCallback(ConnectionInternalManager.GetHandle(), TypeChangedCallback, IntPtr.Zero);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to register connection type changed callback, " + (ConnectionError)ret);
+ }
+ }
+
+ static private void ConnectionTypeChangedStop()
+ {
+ int ret = Interop.Connection.UnsetTypeChangedCallback(ConnectionInternalManager.GetHandle());
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to unregister connection type changed callback, " + (ConnectionError)ret);
+ }
+ }
+
+ static private void TypeChangedCallback(ConnectionType type, IntPtr user_data)
+ {
+ if (_ConnectionTypeChanged != null)
+ {
+ _ConnectionTypeChanged(null, new ConnectionTypeEventArgs(type));
+ }
+ }
+
+ /// <summary>
+ /// Event for ethernet cable is plugged [in/out] event.
+ /// </summary>
+ static public event EventHandler EthernetCableStateChanged
+ {
+ add
+ {
+ if (_EthernetCableStateChanged == null)
+ {
+ EthernetCableStateChangedStart();
+ }
+ _EthernetCableStateChanged += value;
+ }
+ remove
+ {
+ _EthernetCableStateChanged -= value;
+ if (_EthernetCableStateChanged == null)
+ {
+ EthernetCableStateChangedtop();
+ }
+ }
+ }
+
+ static private void EthernetCableStateChangedStart()
+ {
+ int ret = Interop.Connection.SetEthernetCableStateChagedCallback(ConnectionInternalManager.GetHandle(), EthernetCableStateChangedCallback, IntPtr.Zero);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to register ethernet cable state changed callback, " + (ConnectionError)ret);
+ }
+ }
+
+ static private void EthernetCableStateChangedtop()
+ {
+ int ret = Interop.Connection.UnsetEthernetCableStateChagedCallback(ConnectionInternalManager.GetHandle());
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to unregister ethernet cable state changed callback, " + (ConnectionError)ret);
+ }
+ }
+
+ static private void EthernetCableStateChangedCallback(EthernetCableState state, IntPtr user_data)
+ {
+ if (_EthernetCableStateChanged != null)
+ {
+ _EthernetCableStateChanged(null, new EthernetCableStateEventArgs(state));
+ }
+ }
+
+ /// <summary>
+ /// Event that is called when the IP address is changed.
+ /// </summary>
+ static public event EventHandler IpAddressChanged
+ {
+ add
+ {
+ if (_IPAddressChanged == null)
+ {
+ IpAddressChangedStart();
+ }
+ _IPAddressChanged += value;
+ }
+ remove
+ {
+ _IPAddressChanged -= value;
+ if (_IPAddressChanged == null)
+ {
+ IpAddressChangedStop();
+ }
+ }
+ }
+
+ static private void IpAddressChangedStart()
+ {
+ int ret = Interop.Connection.SetIpAddressChangedCallback(ConnectionInternalManager.GetHandle(), IPAddressChangedCallback, IntPtr.Zero);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to register callback for changing IP address, " + (ConnectionError)ret);
+ }
+ }
+
+ static private void IpAddressChangedStop()
+ {
+ int ret = Interop.Connection.UnsetIpAddressChangedCallback(ConnectionInternalManager.GetHandle());
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to unregister callback for changing IP address, " + (ConnectionError)ret);
+ }
+ }
+
+ static private void IPAddressChangedCallback(IntPtr Ipv4, IntPtr Ipv6, IntPtr UserData)
+ {
+ if (_IPAddressChanged != null)
+ {
+ string ipv4 = Marshal.PtrToStringAnsi(Ipv4);
+ string ipv6 = Marshal.PtrToStringAnsi(Ipv6);
+
+ if ((string.IsNullOrEmpty(ipv4) == false) || (string.IsNullOrEmpty(ipv6) == false))
+ {
+ _IPAddressChanged(null, new AddressEventArgs(ipv4, ipv6));
+ }
+ }
+ }
+
+ /// <summary>
+ /// Event that is called when the proxy address is changed.
+ /// </summary>
+ static public event EventHandler ProxyAddressChanged
+ {
+ add
+ {
+ //Console.WriteLine("ProxyAddressChanged Add **");
+ if (_ProxyAddressChanged == null)
+ {
+ ProxyAddressChangedStart();
+ }
+ _ProxyAddressChanged += value;
+ }
+ remove
+ {
+ //Console.WriteLine("ProxyAddressChanged Remove");
+ _ProxyAddressChanged -= value;
+ if (_ProxyAddressChanged == null)
+ {
+ ProxyAddressChangedStop();
+ }
+ }
+ }
+
+ static private void ProxyAddressChangedStart()
+ {
+ int ret = Interop.Connection.SetProxyAddressChangedCallback(ConnectionInternalManager.GetHandle(), IPAddressChangedCallback, IntPtr.Zero);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to register callback for changing proxy address, " + (ConnectionError)ret);
+ }
+ }
+
+ static private void ProxyAddressChangedStop()
+ {
+ int ret = Interop.Connection.UnsetProxyAddressChangedCallback(ConnectionInternalManager.GetHandle());
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to unregister callback for changing proxy address, " + (ConnectionError)ret);
+ }
+ }
+
+ static private void ProxyAddressChangedCallback(IntPtr Ipv4, IntPtr Ipv6, IntPtr UserData)
+ {
+ if (_ProxyAddressChanged != null)
+ {
+ string ipv4 = Marshal.PtrToStringAnsi(Ipv4);
+ string ipv6 = Marshal.PtrToStringAnsi(Ipv6);
+ Interop.Libc.Free(Ipv4);
+ Interop.Libc.Free(Ipv6);
+
+ _ProxyAddressChanged(null, new AddressEventArgs(ipv4, ipv6));
+ }
+ }
+
+ internal ConnectionManager()
+ {
+ }
+
+ ~ConnectionManager()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (disposed)
+ return;
+
+ if (disposing)
+ {
+ // Free managed objects.
+ }
+ ProxyAddressChangedStop();
+ ConnectionTypeChangedStop();
+ EthernetCableStateChangedtop();
+ IpAddressChangedStop();
+ disposed = true;
+ }
+
+
+ /// <summary>
+ /// Gets the IP address of the current connection.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+ static public string GetIpAddress(AddressFamily family)
+ {
+ return ConnectionInternalManager.GetIpAddress(family);
+ }
+
+ /// <summary>
+ /// Gets the proxy address of the current connection.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+ static public string GetProxy(AddressFamily family)
+ {
+ return ConnectionInternalManager.GetProxy(family);
+ }
+
+ /// <summary>
+ /// Gets the MAC address of the Wi-Fi or ethernet.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+ static public string GetMacAddress(ConnectionType type)
+ {
+ return ConnectionInternalManager.GetMacAddress(type);
+ }
+
+ /// <summary>
+ /// Gets the type of the current profile for data connection.
+ /// </summary>
+ static public ConnectionItem CurrentConnection
+ {
+ get
+ {
+ return CurConnction;
+ }
+ }
+
+ /// <summary>
+ /// Gets the state of cellular connection.
+ /// </summary>
+ static public CellularState CellularState
+ {
+ get
+ {
+ return ConnectionInternalManager.CellularState;
+ }
+ }
+
+ /// <summary>
+ /// Gets the state of the Wi-Fi.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ static public ConnectionState WiFiState
+ {
+ get
+ {
+ return ConnectionInternalManager.WiFiState;
+ }
+ }
+
+ /// <summary>
+ /// The state of the Bluetooth.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ static public ConnectionState BluetoothState
+ {
+ get
+ {
+ return ConnectionInternalManager.BluetoothState;
+ }
+ }
+
+ /// <summary>
+ /// The Ethernet connection state.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ static public ConnectionState EthernetState
+ {
+ get
+ {
+ return ConnectionInternalManager.EthernetState;
+ }
+ }
+
+ /// <summary>
+ /// Checks for ethernet cable is attached or not.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ static public EthernetCableState EthernetCableState
+ {
+ get
+ {
+ return ConnectionInternalManager.EthernetCableState;
+ }
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class ConnectionItem
+ {
+ internal ConnectionItem()
+ {
+ }
+
+ /// <summary>
+ /// Gets the type of the current profile for data connection.
+ /// </summary>
+ public ConnectionType Type
+ {
+ get
+ {
+ return ConnectionInternalManager.ConnectionType;
+ }
+ }
+
+ /// <summary>
+ /// Gets the type of the current profile for data connection.
+ /// </summary>
+ public ConnectionState State
+ {
+ get
+ {
+ if (ConnectionInternalManager.ConnectionType == ConnectionType.Cellular)
+ {
+ if (ConnectionInternalManager.CellularState == CellularState.Connected)
+ {
+ return ConnectionState.Connected;
+ }
+ else if (ConnectionInternalManager.CellularState == CellularState.Available)
+ {
+ return ConnectionState.Disconnected;
+ }
+ else {
+ return ConnectionState.Deactivated;
+ }
+ }
+ else if (ConnectionInternalManager.ConnectionType == ConnectionType.Bluetooth)
+ {
+ return ConnectionInternalManager.BluetoothState;
+ }
+ else if (ConnectionInternalManager.ConnectionType == ConnectionType.WiFi)
+ {
+ return ConnectionInternalManager.WiFiState;
+ }
+ else if (ConnectionInternalManager.ConnectionType == ConnectionType.Ethernet)
+ {
+ return ConnectionInternalManager.EthernetState;
+ }
+ else { // TO DO : Add Net Proxy
+ return ConnectionState.Disconnected;
+ }
+ }
+ }
+
+ }
+
+ /// <summary>
+ /// An extended EventArgs class which contains changed connection type.
+ /// </summary>
+ public class ConnectionTypeEventArgs : EventArgs
+ {
+ private ConnectionType Type = ConnectionType.Disconnected;
+
+ internal ConnectionTypeEventArgs(ConnectionType type)
+ {
+ Type = type;
+ }
+
+ /// <summary>
+ /// The connection type.
+ /// </summary>
+ public ConnectionType ConnectionType
+ {
+ get
+ {
+ return Type;
+ }
+ }
+ }
+
+ /// <summary>
+ /// An extended EventArgs class which contains changed ethernet cable state.
+ /// </summary>
+ public class EthernetCableStateEventArgs : EventArgs
+ {
+ private EthernetCableState State;
+
+ internal EthernetCableStateEventArgs(EthernetCableState state)
+ {
+ State = state;
+ }
+
+ /// <summary>
+ /// The ethernet cable state.
+ /// </summary>
+ public EthernetCableState EthernetCableState
+ {
+ get
+ {
+ return State;
+ }
+ }
+ }
+
+ /// <summary>
+ /// An extended EventArgs class which contains changed address.
+ /// </summary>
+ public class AddressEventArgs : EventArgs
+ {
+ private string Ipv4 = "";
+ private string Ipv6 = "";
+
+ internal AddressEventArgs(string ipv4, string ipv6)
+ {
+ Ipv4 = ipv4;
+ Ipv6 = ipv6;
+ }
+
+ /// <summary>
+ /// The IPV4 address.
+ /// </summary>
+ public string Ipv4Address
+ {
+ get
+ {
+ return Ipv4;
+ }
+ }
+
+ /// <summary>
+ /// The IPV6 address.
+ /// </summary>
+ public string Ipv6Address
+ {
+ get
+ {
+ return Ipv6;
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Network.Connection
+{
+ /// <summary>
+ /// This Class is ConnectionProfile
+ /// </summary>
+ public class ConnectionProfile : IDisposable
+ {
+ internal IntPtr ProfileHandle = IntPtr.Zero;
+ private IAddressInformation Ipv4;
+ private IAddressInformation Ipv6;
+ private bool disposed = false;
+ private EventHandler _ProfileStateChanged;
+
+ /// <summary>
+ /// The event that is called when the state of profile is changed.
+ /// </summary>
+ public event EventHandler ProfileStateChanged
+ {
+ add
+ {
+ if (_ProfileStateChanged == null)
+ {
+ ProfileStateChangedStart();
+ }
+ _ProfileStateChanged += value;
+ }
+ remove
+ {
+ _ProfileStateChanged -= value;
+ if (_ProfileStateChanged == null)
+ {
+ ProfileStateChangedStop();
+ }
+ }
+ }
+
+ private void TypeChangedCallback(ProfileState state, IntPtr userData)
+ {
+ if (_ProfileStateChanged != null)
+ {
+ _ProfileStateChanged(null, new ProfileStateEventArgs(state));
+ }
+ }
+
+ private void ProfileStateChangedStart()
+ {
+ int ret = Interop.ConnectionProfile.SetStateChangeCallback(ProfileHandle, TypeChangedCallback, IntPtr.Zero);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to register callback for changing profile state, " + (ConnectionError)ret);
+ }
+ }
+
+ private void ProfileStateChangedStop()
+ {
+ int ret = Interop.ConnectionProfile.UnsetStateChangeCallback(ProfileHandle);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to unregister callback for changing profile state, " + (ConnectionError)ret);
+ }
+ }
+
+ public ConnectionProfile(IntPtr handle)
+ {
+ ProfileHandle = handle;
+ Ipv4 = AddressFactory.CreateAddressInformation(handle, AddressFamily.Ipv4, AddressInformationType.Connection);
+ Ipv6 = AddressFactory.CreateAddressInformation(handle, AddressFamily.Ipv6, AddressInformationType.Connection);
+ }
+
+ ~ConnectionProfile()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (disposed)
+ return;
+
+ if (disposing)
+ {
+ // Free managed objects.
+ }
+ Interop.ConnectionProfile.Destroy(ProfileHandle);
+ ProfileStateChangedStop();
+ disposed = true;
+ }
+
+ /// <summary>
+ /// Gets the profile ID.
+ /// </summary>
+ public string Id
+ {
+ get
+ {
+ IntPtr Value;
+ int ret = Interop.ConnectionProfile.GetId(ProfileHandle, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get id of connection profile, " + (ConnectionError)ret);
+ }
+ string result = Marshal.PtrToStringAnsi(Value);
+ Interop.Libc.Free(Value);
+ return result;
+ }
+ }
+
+ /// <summary>
+ /// Gets the profile name.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ public string Name
+ {
+ get
+ {
+ IntPtr Value;
+ int ret = Interop.ConnectionProfile.GetName(ProfileHandle, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get name of connection profile, " + (ConnectionError)ret);
+ }
+ string result = Marshal.PtrToStringAnsi(Value);
+ Interop.Libc.Free(Value);
+ return result;
+ }
+ }
+
+ /// <summary>
+ /// Gets the network type.
+ /// </summary>
+ public ConnectionProfileType Type
+ {
+ get
+ {
+ int Value;
+ int ret = Interop.ConnectionProfile.GetType(ProfileHandle, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get type of connection profile, " + (ConnectionError)ret);
+ }
+ return (ConnectionProfileType)Value;
+ }
+ }
+
+ /// <summary>
+ /// Gets the name of the network interface, e.g. eth0 and pdp0.
+ /// </summary>
+ public string InterfaceName
+ {
+ get
+ {
+ IntPtr Value;
+ int ret = Interop.ConnectionProfile.GetNetworkInterfaceName(ProfileHandle, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get network interface name, " + (ConnectionError)ret);
+ }
+ string result = Marshal.PtrToStringAnsi(Value);
+ Interop.Libc.Free(Value);
+ return result;
+ }
+ }
+
+ /// <summary>
+ /// Gets the profile state.
+ /// </summary>
+ public ProfileState State
+ {
+ get
+ {
+ int Value;
+ int ret = Interop.ConnectionProfile.GetState(ProfileHandle, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get profile state, " + (ConnectionError)ret);
+ }
+ return (ProfileState)Value;
+ }
+ }
+
+ /// <summary>
+ /// Gets the Proxy type.
+ /// </summary>
+ public ProxyType ProxyType
+ {
+ get
+ {
+ int Value;
+ int ret = Interop.ConnectionProfile.GetProxyType(ProfileHandle, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get proxy type, " + (ConnectionError)ret);
+ }
+ return (ProxyType)Value;
+
+ }
+ set
+ {
+ int ret = Interop.ConnectionProfile.SetProxyType(ProfileHandle, (int)value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set proxy type, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+
+ /// <summary>
+ /// The proxy address.
+ /// </summary>
+ public String ProxyAddress
+ {
+ get
+ {
+ IntPtr Value;
+ int ret = Interop.ConnectionProfile.GetProxyAddress(ProfileHandle, (int)AddressFamily.Ipv4, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get proxy address, " + (ConnectionError)ret);
+ }
+ string result = Marshal.PtrToStringAnsi(Value);
+ Interop.Libc.Free(Value);
+ return result;
+
+ }
+ set
+ {
+ int ret = Interop.ConnectionProfile.SetProxyAddress(ProfileHandle, (int)AddressFamily.Ipv4, value.ToString());
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set proxy address, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+
+ /// <summary>
+ /// The subnet mask address(Ipv4).
+ /// </summary>
+ public IAddressInformation Ipv4Settings
+ {
+ get
+ {
+ return Ipv4;
+
+ }
+ }
+
+ /// <summary>
+ /// The subnet mask address(Ipv4).
+ /// </summary>
+ public IAddressInformation Ipv6Settings
+ {
+ get
+ {
+ return Ipv6;
+ }
+ }
+ }
+
+ /// <summary>
+ /// An extended EventArgs class which contains changed profile state.
+ /// </summary>
+ public class ProfileStateEventArgs : EventArgs
+ {
+ private ProfileState _State = ProfileState.Disconnected;
+
+ internal ProfileStateEventArgs(ProfileState state)
+ {
+ _State = state;
+ }
+
+ /// <summary>
+ /// The profile state.
+ /// </summary>
+ public ProfileState State
+ {
+ get
+ {
+ return _State;
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Collections;
+
+namespace Tizen.Network.Connection
+{
+ /// <summary>
+ /// This class is ConnectionProfileManager
+ /// </summary>
+ public class ConnectionProfileManager
+ {
+ /// <summary>
+ /// Adds a new profile
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/network.profile</privilege>
+ /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+ static public int AddProfile(RequestProfile profile)
+ {
+ return ConnectionInternalManager.AddProfile(profile);
+ }
+
+ /// <summary>
+ /// Gets the list of profile with profile list type
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ static public Task<IEnumerable<ConnectionProfile>> GetProfileListAsync(ProfileListType type)
+ {
+ return ConnectionInternalManager.GetProfileListAsync(type);
+ }
+
+ /// <summary>
+ /// Opens a connection of profile, asynchronously.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <privilege>http://tizen.org/privilege/network.set</privilege>
+ static public Task<ConnectionError> ConnectProfileAsync(ConnectionProfile profile)
+ {
+ return ConnectionInternalManager.OpenProfileAsync(profile);
+ }
+
+ /// <summary>
+ /// Closes a connection of profile.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/network.set</privilege>
+ static public Task<ConnectionError> DisconnectProfileAsync(ConnectionProfile profile)
+ {
+ return ConnectionInternalManager.CloseProfileAsync(profile);
+ }
+
+ /// <summary>
+ /// Removes an existing profile.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <privilege>http://tizen.org/privilege/network.profile</privilege>
+ /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+ static public int RemoveProfile(ConnectionProfile profile)
+ {
+ Log.Debug(Globals.LogTag, "RemoveProfile. Id: " + profile.Id + ", Name: " + profile.Name + ", Type: " + profile.Type);
+ return ConnectionInternalManager.RemoveProfile(profile);
+ }
+
+ /// <summary>
+ /// Updates an existing profile.
+ /// When a profile is changed, these changes will be not applied to the ConnectionProfileManager immediately.
+ /// When you call this function, your changes affect the ConnectionProfileManager and the existing profile is updated.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <privilege>http://tizen.org/privilege/network.profile</privilege>
+ /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+ static public int UpdateProfile(ConnectionProfile profile)
+ {
+ return ConnectionInternalManager.UpdateProfile(profile);
+ }
+
+ /// <summary>
+ /// Gets the name of the default profile.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+ static public ConnectionProfile GetCurrentProfile()
+ {
+ return ConnectionInternalManager.GetCurrentProfile();
+ }
+
+ /// <summary>
+ /// Gets the default profile which provides the given cellular service.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+ static public ConnectionProfile GetDefaultCellularProfile(CellularServiceType type)
+ {
+ return ConnectionInternalManager.GetDefaultCellularProfile(type);
+ }
+
+ /// <summary>
+ /// Sets the default profile which provides the given cellular service.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <privilege>http://tizen.org/privilege/network.profile</privilege>
+ /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+ static public Task<ConnectionError> SetDefaultCellularProfile(CellularServiceType type, ConnectionProfile profile)
+ {
+ return ConnectionInternalManager.SetDefaultCellularProfile(type, profile);
+ }
+ }
+
+ /// <summary>
+ /// An extended EventArgs class which contains the state of changed connection profile.
+ /// </summary>
+ public class ConnectionProfileStateEventArgs : EventArgs
+ {
+ private ConnectionProfileState State;
+
+ internal ConnectionProfileStateEventArgs(ConnectionProfileState state)
+ {
+ State = state;
+ }
+
+ /// <summary>
+ /// The connection profile state.
+ /// </summary>
+ public ConnectionProfileState ConnectionProfileState
+ {
+ get
+ {
+ return State;
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Tizen.Internals.Errors;
+
+
+namespace Tizen.Network.Connection
+{
+ /// <summary>
+ /// Enumeration for connection type.
+ /// </summary>
+ public enum ConnectionType
+ {
+ Disconnected = 0, /**< Disconnected */
+ WiFi = 1, /**< Wi-Fi type */
+ Cellular = 2, /**< Cellular type */
+ Ethernet = 3, /**< Ethernet type */
+ Bluetooth = 4, /**< Bluetooth type */
+ NetProxy = 5 /**< Proxy type for internet connection (Since 3.0) */
+ }
+
+ /// <summary>
+ /// Enumeration for address family.
+ /// </summary>
+ public enum AddressFamily
+ {
+ Ipv4 = 0,
+ Ipv6 = 1
+ }
+
+ /// <summary>
+ /// Enumeration for cellular network state.
+ /// </summary>
+ public enum CellularState
+ {
+ OutOfService = 0, /**< Out of service */
+ FlightMode = 1, /**< Flight mode */
+ RoamingOff = 2, /**< Roaming is turned off */
+ CallOnlyAvailable = 3, /**< Call is only available */
+ Available = 4, /**< Available but not connected yet */
+ Connected = 5, /**< Connected */
+ }
+
+ /// <summary>
+ /// Enumeration for connection state.
+ /// </summary>
+ public enum ConnectionState
+ {
+ Deactivated = 0, /**< Deactivated */
+ Disconnected = 1, /**< Disconnected */
+ Connected = 2, /**< Connected */
+ }
+
+ /// <summary>
+ /// This enumeration defines the attached or detached state of ethernet cable.
+ /// </summary>
+ public enum EthernetCableState
+ {
+ Detached = 0, /**< Ethernet cable is detached */
+ Attached = 1, /**< Ethernet cable is attached */
+ }
+
+ /// <summary>
+ /// Enumeration for network connection type.
+ /// </summary>
+ public enum ConnectionProfileType
+ {
+ Cellular = 0, /**< Cellular type */
+ WiFi = 1, /**< Wi-Fi type */
+ Ethernet = 2, /**< Ethernet type */
+ Bt = 3, /**< Bluetooth type */
+ }
+
+ /// <summary>
+ /// Enumeration for profile state type.
+ /// </summary>
+ public enum ProfileState
+ {
+ Disconnected = 0, /**< Disconnected state */
+ Association = 1, /**< Association state */
+ Configuration = 2, /**< Configuration state */
+ Connected = 3, /**< Connected state */
+ }
+
+ /// <summary>
+ /// Enumeration for proxy method type.
+ /// </summary>
+ public enum ProxyType
+ {
+ Direct = 0, /**< Direct connection */
+ Auto = 1, /**< Auto configuration(Use PAC file). If URL property is not set, DHCP/WPAD auto-discover will be tried */
+ Manual = 2, /**< Manual configuration */
+ }
+
+ /// <summary>
+ /// Enumeration for IP configuration type.
+ /// </summary>
+ public enum IpConfigType
+ {
+ None = 0, /**< Not defined */
+ Static = 1, /**< Manual IP configuration */
+ Dynamic = 2, /**< Config IP using DHCP client*/
+ Auto = 3, /**< Config IP from Auto IP pool (169.254/16). Later with DHCP client, if available */
+ Fixed = 4, /**< Indicates an IP address that can not be modified */
+ }
+
+ /// <summary>
+ /// Enumeration for cellular service type.
+ /// </summary>
+ public enum CellularServiceType
+ {
+ Unknown = 0, /**< Unknown */
+ Internet = 1, /**< Internet */
+ MMS = 2, /**< MMS */
+ PrepaidInternet = 3, /**< Prepaid internet */
+ PrepaidMMS = 4, /**< Prepaid MMS */
+ Tethering = 5, /**< Tethering */
+ Application = 6, /**< Specific application */
+ }
+
+ static internal class ConnectionErrorValue
+ {
+ internal const int Base = -0x01C10000;
+ }
+
+
+ /// <summary>
+ /// Enumeration for connection errors.
+ /// </summary>
+ // To do : have to assign valid error code
+ public enum ConnectionError
+ {
+ None = ErrorCode.None, /**< Successful */
+ InvalidParameter = ErrorCode.InvalidParameter, /**< Invalid parameter */
+ OutOfMemoryError = ErrorCode.OutOfMemory, /**< Out of memory error */
+ InvalidOperation = ErrorCode.InvalidOperation, /**< Invalid Operation */
+ AddressFamilyNotSupported = ErrorCode.AddressFamilyNotSupported, /**< Address family not supported */
+ OperationFailed = ConnectionErrorValue.Base | 0x0401, /**< Operation failed */
+ EndOfIteration = ConnectionErrorValue.Base | 0x0402, /**< End of iteration */
+ NoConnection = ConnectionErrorValue.Base | 0x0403, /**< There is no connection */
+ NowInProgress = ErrorCode.NowInProgress, /** Now in progress */
+ AlreadyExists = ConnectionErrorValue.Base | 0x0404, /**< Already exists */
+ OperationAborted = ConnectionErrorValue.Base | 0x0405, /**< Operation is aborted */
+ DhcpFailed = ConnectionErrorValue.Base | 0x0406, /**< DHCP failed */
+ InvalidKey = ConnectionErrorValue.Base | 0x0407, /**< Invalid key */
+ NoReply = ConnectionErrorValue.Base | 0x0408, /**< No reply */
+ PermissionDenied = ErrorCode.PermissionDenied, /**< Permission denied */
+ NotSupported = ErrorCode.NotSupported /**< Not Supported */
+ }
+
+ /// <summary>
+ /// Enumeration for profile list type.
+ /// </summary>
+ public enum ProfileListType
+ {
+ Registered = 0, /**< The iterator of the registered profile */
+ Connected = 1, /**< The iterator of the connected profile */
+ Default = 2, /**< The iterator of the default profile */
+ }
+
+ /// <summary>
+ /// Enumeration for security type of Wi-Fi.
+ /// </summary>
+ public enum WiFiSecureType
+ {
+ None = 0, /**< Security disabled */
+ Wep = 1, /**< WEP */
+ WpaPsk = 2, /**< WPA-PSK */
+ Wpa2Psk = 3, /**< WPA2-PSK */
+ Eap = 4, /**< EAP */
+ }
+
+ /// <summary>
+ /// Enumeration for encryption modes.
+ /// </summary>
+ public enum WiFiEncryptionType
+ {
+ None = 0, /**< Encryption disabled */
+ Wep = 1, /**< WEP */
+ Tkip = 2, /**< TKIP */
+ Aes = 3, /**< AES */
+ TkipAesMixed = 4, /**< TKIP and AES are both supported */
+ }
+
+ /// <summary>
+ /// Enumeration for connection profile state.
+ /// </summary>
+ public enum ConnectionProfileState
+ {
+ Disconnected = 0, /**< Disconnected state */
+ Association = 1, /**< Association state */
+ Configuration = 2, /**< Configuration state */
+ Connected = 3, /**< Connected state */
+ }
+
+ /// <summary>
+ /// Enumeration for cellular authentication type.
+ /// </summary>
+ public enum CellularAuthType
+ {
+ None = 0, /**< No authentication */
+ Pap = 1, /**< PAP authentication */
+ Chap = 2, /**< CHAP authentication */
+ }
+
+ public enum AddressInformationType
+ {
+ Connection = 0,
+ WiFi = 1
+ }
+
+ static internal class Globals
+ {
+ internal const string LogTag = "Tizen.Network.Connection";
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Collections;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Network.Connection
+{
+ /// <summary>
+ /// This Class is ConnectionAddress
+ /// </summary>
+ public interface IAddressInformation : IDisposable
+ {
+ /// <summary>
+ /// The DNS address.
+ /// </summary>
+ System.Net.IPAddress Dns1 { get; set; }
+
+ /// <summary>
+ /// The DNS address.
+ /// </summary>
+ System.Net.IPAddress Dns2 { get; set; }
+
+ /// <summary>
+ /// The gateway address.
+ /// </summary>
+ System.Net.IPAddress Gateway { get; set; }
+
+ /// <summary>
+ /// The subnet mask address.
+ /// </summary>
+ System.Net.IPAddress SubnetMask { get; set; }
+
+ /// <summary>
+ /// The IP address.
+ /// </summary>
+ System.Net.IPAddress Ip { get; set; }
+
+ /// <summary>
+ /// The type of IP config.
+ /// </summary>
+ IpConfigType IpConfigType { get; set; }
+ }
+
+ public static class AddressFactory
+ {
+ public static IAddressInformation CreateAddressInformation(IntPtr handle, AddressFamily family, AddressInformationType infoType)
+ {
+ return new ConnectionAddressInformation(handle, family);
+ }
+ }
+
+ internal class ConnectionAddressInformation : IAddressInformation
+ {
+ private IntPtr _profileHandle;
+ private AddressFamily _family;
+ private bool _disposed = false;
+
+ internal ConnectionAddressInformation(IntPtr handle, AddressFamily family)
+ {
+ _profileHandle = handle;
+ _family = family;
+ }
+
+ ~ConnectionAddressInformation()
+ {
+ Dispose(false);
+ }
+
+ protected void Dispose(bool disposing)
+ {
+ if (_disposed)
+ return;
+
+ if (disposing)
+ {
+ // Release managed resources.
+ }
+ // Release unmanaged resources.
+ _disposed = true;
+ }
+
+ public void Dispose()
+ {
+ throw new NotImplementedException();
+ }
+
+ public System.Net.IPAddress Dns1
+ {
+ get
+ {
+ IntPtr Value;
+ int ret = Interop.ConnectionProfile.GetDnsAddress(_profileHandle, 1, (int)_family, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get dns1 address, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ string result = Marshal.PtrToStringAnsi(Value);
+ Interop.Libc.Free(Value);
+ if (result == null)
+ return System.Net.IPAddress.Parse("0.0.0.0");
+ return System.Net.IPAddress.Parse(result);
+ }
+ set
+ {
+ int ret = Interop.ConnectionProfile.SetDnsAddress(_profileHandle, (int)_family, value.ToString());
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set dns1 address, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+ public System.Net.IPAddress Dns2
+ {
+ get
+ {
+ IntPtr Value;
+ int ret = Interop.ConnectionProfile.GetDnsAddress(_profileHandle, 2, (int)_family, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get dns2 address, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ string result = Marshal.PtrToStringAnsi(Value);
+ Interop.Libc.Free(Value);
+ if (result == null)
+ return System.Net.IPAddress.Parse("0.0.0.0");
+ return System.Net.IPAddress.Parse(result);
+ }
+ set
+ {
+ int ret = Interop.ConnectionProfile.SetDnsAddress(_profileHandle, (int)_family, value.ToString());
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set dns2 address, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+
+ public System.Net.IPAddress Gateway
+ {
+ get
+ {
+ IntPtr Value;
+ int ret = Interop.ConnectionProfile.GetGatewayAddress(_profileHandle, (int)_family, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get gateway, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ string result = Marshal.PtrToStringAnsi(Value);
+ Interop.Libc.Free(Value);
+ if (result == null)
+ return System.Net.IPAddress.Parse("0.0.0.0");
+ return System.Net.IPAddress.Parse(result);
+ }
+ set
+ {
+ int ret = Interop.ConnectionProfile.SetGatewayAddress(_profileHandle, (int)_family, value.ToString());
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set gateway, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+
+
+ public System.Net.IPAddress SubnetMask
+ {
+ get
+ {
+ IntPtr Value;
+ int ret = Interop.ConnectionProfile.GetSubnetMask(_profileHandle, (int)_family, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get subnet mask, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ string result = Marshal.PtrToStringAnsi(Value);
+ Interop.Libc.Free(Value);
+ if (result == null)
+ return System.Net.IPAddress.Parse("0.0.0.0");
+ return System.Net.IPAddress.Parse(result);
+ }
+ set
+ {
+ int ret = Interop.ConnectionProfile.SetSubnetMask(_profileHandle, (int)_family, value.ToString());
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set subnet mask, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+
+
+ public System.Net.IPAddress Ip
+ {
+ get
+ {
+ IntPtr Value;
+ int ret = Interop.ConnectionProfile.GetIpAddress(_profileHandle, (int)_family, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get ip, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ string result = Marshal.PtrToStringAnsi(Value);
+ Interop.Libc.Free(Value);
+ if (result == null)
+ return System.Net.IPAddress.Parse("0.0.0.0");
+ return System.Net.IPAddress.Parse(result);
+ }
+ set
+ {
+ int ret = Interop.ConnectionProfile.SetIpAddress(_profileHandle, (int)_family, value.ToString());
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set ip, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+
+ public IpConfigType IpConfigType
+ {
+ get
+ {
+ int Value;
+ int ret = Interop.ConnectionProfile.GetIpConfigType(_profileHandle, (int)_family, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get ip config type, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ return (IpConfigType)Value;
+ }
+ set
+ {
+ int ret = Interop.ConnectionProfile.SetIpConfigType(_profileHandle, (int)_family, (int)value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set ip config type, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Runtime.InteropServices;
+
+
+namespace Tizen.Network.Connection
+{
+ /// <summary>
+ /// This Class is RequestCellularProfile.
+ /// CellularServiceType should be set before AddProfile method of ConnectionProfileManager is called.
+ /// </summary>
+ public class RequestCellularProfile : RequestProfile
+ {
+ internal IntPtr ProfileHandle = IntPtr.Zero;
+ private IAddressInformation Ipv4;
+ private IAddressInformation Ipv6;
+ private bool disposed = false;
+
+ private CellularAuthInformation AuthInfo;
+ /// <summary>
+ /// The constructor of CellularProfile class with profile type and keyword.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ public RequestCellularProfile(string keyword)
+ {
+ Log.Debug(Globals.LogTag, "RequestCellularProfile : " + keyword);
+ ProfileHandle = ConnectionInternalManager.CreateRequestProfile(ConnectionProfileType.Cellular, keyword);
+ Log.Debug(Globals.LogTag, "RequestCellularProfile is created : " + ProfileHandle);
+
+ Ipv4 = AddressFactory.CreateAddressInformation(ProfileHandle, AddressFamily.Ipv4, AddressInformationType.Connection);
+ Ipv6 = AddressFactory.CreateAddressInformation(ProfileHandle, AddressFamily.Ipv6, AddressInformationType.Connection);
+
+ AuthInfo = new CellularAuthInformation(ProfileHandle);
+ }
+
+ /// <summary>
+ /// The destructor of CellularProfile class
+ /// </summary>
+ ~RequestCellularProfile()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (disposed)
+ return;
+
+ if (disposing)
+ {
+ // Free managed objects.
+ }
+ Interop.ConnectionProfile.Destroy(ProfileHandle);
+ disposed = true;
+ }
+
+ /// <summary>
+ /// Gets the network type.
+ /// </summary>
+ public ConnectionProfileType Type
+ {
+ get
+ {
+ int Value;
+ int ret = Interop.ConnectionProfile.GetType(ProfileHandle, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get profile type, " + (ConnectionError)ret);
+ }
+ return (ConnectionProfileType)Value;
+ }
+ }
+
+ /// <summary>
+ /// Gets the Proxy type.
+ /// </summary>
+ public ProxyType ProxyType
+ {
+ get
+ {
+ int Value;
+ int ret = Interop.ConnectionProfile.GetProxyType(ProfileHandle, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get proxy type, " + (ConnectionError)ret);
+ }
+ return (ProxyType)Value;
+
+ }
+ set
+ {
+ int ret = Interop.ConnectionProfile.SetProxyType(ProfileHandle, (int)value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set proxy type, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+
+ /// <summary>
+ /// The proxy address.
+ /// </summary>
+ public System.Net.IPAddress ProxyAddress
+ {
+ get
+ {
+ IntPtr Value;
+ int ret = Interop.ConnectionProfile.GetProxyAddress(ProfileHandle, (int)AddressFamily.Ipv4, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get proxy address, " + (ConnectionError)ret);
+ }
+ string result = Marshal.PtrToStringAnsi(Value);
+ Interop.Libc.Free(Value);
+ if (result == null)
+ return System.Net.IPAddress.Parse("0.0.0.0");
+ return System.Net.IPAddress.Parse(result);
+
+ }
+ set
+ {
+ int ret = Interop.ConnectionProfile.SetProxyAddress(ProfileHandle, (int)AddressFamily.Ipv4, value.ToString());
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set proxy address, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+
+ }
+
+ /// <summary>
+ /// The subnet mask address(Ipv4).
+ /// </summary>
+ public IAddressInformation Ipv4Settings
+ {
+ get
+ {
+ return Ipv4;
+ }
+ }
+
+
+ /// <summary>
+ /// The subnet mask address(Ipv4).
+ /// </summary>
+ public IAddressInformation Ipv6Settings
+ {
+ get
+ {
+ return Ipv6;
+ }
+ }
+
+ /// <summary>
+ /// Gets the APN (access point name).
+ /// </summary>
+ public string Apn
+ {
+ get
+ {
+ IntPtr Value;
+ int ret = Interop.ConnectionCellularProfile.GetApn(ProfileHandle, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get apn, " + (ConnectionError)ret);
+ }
+ string result = Marshal.PtrToStringAnsi(Value);
+ Interop.Libc.Free(Value);
+ return result;
+ }
+ set
+ {
+ int ret = Interop.ConnectionCellularProfile.SetApn(ProfileHandle, (string)value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set apn, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets the home URL.
+ /// </summary>
+ public string HomeUri
+ {
+ get
+ {
+ IntPtr Value;
+ int ret = Interop.ConnectionCellularProfile.GetHomeUrl(ProfileHandle, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get home uri, " + (ConnectionError)ret);
+ }
+ string result = Marshal.PtrToStringAnsi(Value);
+ Interop.Libc.Free(Value);
+ return result;
+ }
+ set
+ {
+ int ret = Interop.ConnectionCellularProfile.SetHomeUrl(ProfileHandle, value);
+ Log.Error(Globals.LogTag, "home uri " + value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set home uri, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets the service type.
+ /// </summary>
+ public CellularServiceType ServiceType
+ {
+ get
+ {
+ int value;
+ int ret = Interop.ConnectionCellularProfile.GetServiceType(ProfileHandle, out value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get service type, " + (ConnectionError)ret);
+ }
+ return (CellularServiceType)value;
+ }
+ set
+ {
+ int ret = Interop.ConnectionCellularProfile.SetServiceType(ProfileHandle, (int)value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set service type, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets cellular Authentification Information.
+ /// </summary>
+ public CellularAuthInformation CellularAuthInfo
+ {
+ get
+ {
+ return AuthInfo;
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Network.Connection
+{
+ /// <summary>
+ /// RequestProfile is interface for RequestCellularProfile and RequestWiFiProfile
+ /// </summary>
+ public interface RequestProfile : IDisposable
+ {
+ /// <summary>
+ /// Gets the network type.
+ /// </summary>
+ ConnectionProfileType Type{ get; }
+
+ /// <summary>
+ /// Gets the Proxy type.
+ /// </summary>
+ ProxyType ProxyType { get; set; }
+
+ /// <summary>
+ /// The proxy address.
+ /// </summary>
+ System.Net.IPAddress ProxyAddress { get; set; }
+
+ /// <summary>
+ /// The subnet mask address(Ipv4).
+ /// </summary>
+ IAddressInformation Ipv4Settings { get; }
+
+ /// <summary>
+ /// The subnet mask address(Ipv4).
+ /// </summary>
+ IAddressInformation Ipv6Settings { get; }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Network.Connection
+{
+ /// <summary>
+ /// This Class is RequestWiFiProfile
+ /// </summary>
+ public class RequestWiFiProfile : RequestProfile
+ {
+ internal IntPtr ProfileHandle = IntPtr.Zero;
+ private IAddressInformation Ipv4;
+ private IAddressInformation Ipv6;
+ private bool disposed = false;
+
+ /// <summary>
+ /// The constructor of WiFiProfile class with profile type and keyword.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ public RequestWiFiProfile(string keyword)
+ {
+ Log.Debug(Globals.LogTag, "RequestWiFiProfile : " + keyword);
+ ProfileHandle = ConnectionInternalManager.CreateRequestProfile(ConnectionProfileType.WiFi, keyword);
+
+ Ipv4 = AddressFactory.CreateAddressInformation(ProfileHandle, AddressFamily.Ipv4, AddressInformationType.Connection);
+ Ipv6 = AddressFactory.CreateAddressInformation(ProfileHandle, AddressFamily.Ipv6, AddressInformationType.Connection);
+ }
+
+ /// <summary>
+ /// The destructor of WiFiProfile class
+ /// </summary>
+ ~RequestWiFiProfile()
+ {
+ Dispose(false);
+ }
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (disposed)
+ return;
+
+ if (disposing)
+ {
+ // Free managed objects.
+ }
+ Interop.ConnectionProfile.Destroy(ProfileHandle);
+ disposed = true;
+ }
+
+ /// <summary>
+ /// Gets the network type.
+ /// </summary>
+ public ConnectionProfileType Type
+ {
+ get
+ {
+ int Value;
+ int ret = Interop.ConnectionProfile.GetType(ProfileHandle, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get profile type, " + (ConnectionError)ret);
+ }
+ return (ConnectionProfileType)Value;
+ }
+ }
+
+ /// <summary>
+ /// Gets the Proxy type.
+ /// </summary>
+ public ProxyType ProxyType
+ {
+ get
+ {
+ int Value;
+ int ret = Interop.ConnectionProfile.GetProxyType(ProfileHandle, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get proxy type, " + (ConnectionError)ret);
+ }
+ return (ProxyType)Value;
+
+ }
+ set
+ {
+ int ret = Interop.ConnectionProfile.SetProxyType(ProfileHandle, (int)value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set proxy type, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+
+ /// <summary>
+ /// The proxy address.
+ /// </summary>
+ public System.Net.IPAddress ProxyAddress
+ {
+ get
+ {
+ IntPtr Value;
+ int ret = Interop.ConnectionProfile.GetProxyAddress(ProfileHandle, (int)AddressFamily.Ipv4, out Value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get proxy address, " + (ConnectionError)ret);
+ }
+ string result = Marshal.PtrToStringAnsi(Value);
+ Interop.Libc.Free(Value);
+ if (result == null)
+ return System.Net.IPAddress.Parse("0.0.0.0");
+ return System.Net.IPAddress.Parse(result);
+
+ }
+ set
+ {
+ int ret = Interop.ConnectionProfile.SetProxyAddress(ProfileHandle, (int)AddressFamily.Ipv4, value.ToString());
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set proxy address, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+ }
+
+ /// <summary>
+ /// The subnet mask address(Ipv4).
+ /// </summary>
+ public IAddressInformation Ipv4Settings
+ {
+ get
+ {
+ return Ipv4;
+
+ }
+ }
+
+ /// <summary>
+ /// The subnet mask address(Ipv4).
+ /// </summary>
+ public IAddressInformation Ipv6Settings
+ {
+ get
+ {
+ return Ipv6;
+
+ }
+ }
+
+ /// <summary>
+ /// Sets the passphrase of the Wi-Fi WPA.
+ /// </summary>
+ public int SetPassphrase(string passphrase)
+ {
+ int ret = Interop.ConnectionWiFiProfile.SetPassphrase(ProfileHandle, (string)passphrase);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set passphrase, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ return ret;
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Network.Connection
+{
+ /// <summary>
+ /// This Class is WiFiProfile
+ /// </summary>
+ public class WiFiProfile : ConnectionProfile
+ {
+ internal WiFiProfile(IntPtr Handle) : base(Handle)
+ {
+ }
+
+ ~WiFiProfile()
+ {
+ }
+
+ /// <summary>
+ /// Gets the ESSID (Extended Service Set Identifier).
+ /// </summary>
+ public string Essid
+ {
+ get
+ {
+ IntPtr value;
+ int ret = Interop.ConnectionWiFiProfile.GetEssid(ProfileHandle, out value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to create profile handle, " + (ConnectionError)ret);
+ }
+ string result = Marshal.PtrToStringAnsi(value);
+ Interop.Libc.Free(value);
+ return result;
+ }
+ }
+
+ /// <summary>
+ /// Gets the BSSID (Basic Service Set Identifier).
+ /// </summary>
+ public string Bssid
+ {
+ get
+ {
+ IntPtr value;
+ int ret = Interop.ConnectionWiFiProfile.GetBssid(ProfileHandle, out value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get bssid, " + (ConnectionError)ret);
+ }
+ string result = Marshal.PtrToStringAnsi(value);
+ Interop.Libc.Free(value);
+ return result;
+ }
+ }
+
+ /// <summary>
+ /// Gets the RSSI.
+ /// </summary>
+ public int Rssi
+ {
+ get
+ {
+ int value;
+ int ret = Interop.ConnectionWiFiProfile.GetRssi(ProfileHandle, out value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get rssi, " + (ConnectionError)ret);
+ }
+ return value;
+ }
+ }
+
+ /// <summary>
+ /// Gets the frequency (MHz).
+ /// </summary>
+ public int Frequency
+ {
+ get
+ {
+ int value;
+ int ret = Interop.ConnectionWiFiProfile.GetFrequency(ProfileHandle, out value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get frequency, " + (ConnectionError)ret);
+ }
+ return value;
+ }
+ }
+
+ /// <summary>
+ /// Gets the max speed (Mbps).
+ /// </summary>
+ public int MaxSpeed
+ {
+ get
+ {
+ int value;
+ int ret = Interop.ConnectionWiFiProfile.GetMaxSpeed(ProfileHandle, out value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get max speed, " + (ConnectionError)ret);
+ }
+ return value;
+ }
+ }
+
+ /// <summary>
+ /// Gets the security type of Wi-Fi.
+ /// </summary>
+ public WiFiSecureType SecureType
+ {
+ get
+ {
+ int value;
+ int ret = Interop.ConnectionWiFiProfile.GetSecurityType(ProfileHandle, out value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get security type, " + (ConnectionError)ret);
+ }
+ return (WiFiSecureType)value;
+ }
+ }
+
+ /// <summary>
+ /// Gets the encryption type of Wi-Fi.
+ /// </summary>
+ public WiFiEncryptionType EncryptionType
+ {
+ get
+ {
+ int value;
+ int ret = Interop.ConnectionWiFiProfile.GetEncryptionType(ProfileHandle, out value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get encryption type, " + (ConnectionError)ret);
+ }
+ return (WiFiEncryptionType)value;
+ }
+ }
+
+ /// <summary>
+ /// Checks whether passphrase is required.
+ /// </summary>
+ public bool PassphraseRequired
+ {
+ get
+ {
+ bool value;
+ int ret = Interop.ConnectionWiFiProfile.IsRequiredPassphrase(ProfileHandle, out value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get PassphraseRequired, " + (ConnectionError)ret);
+ }
+ return value;
+ }
+ }
+
+ /// <summary>
+ /// Checks whether the WPS (Wi-Fi Protected Setup) is supported.
+ /// </summary>
+ public bool WpsSupported
+ {
+ get
+ {
+ bool value;
+ int ret = Interop.ConnectionWiFiProfile.IsSupportedWps(ProfileHandle, out value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to get IsSupportedWps, " + (ConnectionError)ret);
+ }
+ return value;
+ }
+ }
+
+ /// <summary>
+ /// Sets the passphrase of the Wi-Fi WPA.
+ /// </summary>
+ public int SetPassphrase(string passphrase)
+ {
+ int ret = Interop.ConnectionWiFiProfile.SetPassphrase(ProfileHandle, (string)passphrase);
+ if ((ConnectionError)ret != ConnectionError.NoConnection)
+ {
+ Log.Error(Globals.LogTag, "It failed to set passphrase, " + (ConnectionError)ret);
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ return ret;
+ }
+ }
+}