Name: csapi-network-connection
Summary: Tizen Connection API for C#
-Version: 1.0.6
+Version: 1.0.7
Release: 1
Group: Development/Libraries
License: Apache-2.0
internal static partial class ConnectionProfile
{
- public delegate void profile_state_changed_cb(ProfileState type, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate void ProfileStateChangedCallback(ProfileState type, IntPtr userData);
[DllImport(Libraries.Connection, EntryPoint = "connection_profile_create")]
public static extern int Create(int ProfileType, string Keyword, out IntPtr profileHandle);
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);
+ public static extern int SetStateChangeCallback(IntPtr profileHandle, ProfileStateChangedCallback callback, IntPtr userData);
[DllImport(Libraries.Connection, EntryPoint = "connection_profile_unset_state_changed_cb")]
public static extern int UnsetStateChangeCallback(IntPtr profileHandle);
<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>
-<?xml version="1.0" encoding="utf-8"?>
+<?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>
<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>
namespace Tizen.Network.Connection
{
/// <summary>
- /// This Class is CellularProfile
+ /// This Class is CellularProfile. It provides functions to manage the cellular profile.
/// </summary>
public class CellularProfile : ConnectionProfile
{
}
/// <summary>
- /// Gets the APN (access point name).
+ /// The APN (access point name).
/// </summary>
public string Apn
{
}
/// <summary>
- /// Gets the home URL.
+ /// The home URL.
/// </summary>
public string HomeUri
{
}
/// <summary>
- /// Gets the service type.
+ /// The service type.
/// </summary>
public CellularServiceType ServiceType
{
}
/// <summary>
- /// The authentication information.
+ /// This Class is CellularAuthInformation. It provides the properties to get and set the cellular authentication information.
/// </summary>
public class CellularAuthInformation
{
}
}
- public event EventHandler ProxyAddressChanged
+ internal event EventHandler ProxyAddressChanged
{
add
{
return Interop.Connection.DestroyProfileIterator(iterator);
}
- public string GetIpAddress(AddressFamily family)
+ internal string GetIpAddress(AddressFamily family)
{
IntPtr ip;
int ret = Interop.Connection.GetIpAddress(GetHandle(), (int)family, out ip);
return result;
}
- public string GetProxy(AddressFamily family)
+ internal string GetProxy(AddressFamily family)
{
IntPtr ip;
int ret = Interop.Connection.GetProxy(GetHandle(), (int)family, out ip);
return result;
}
- public string GetMacAddress(ConnectionType type)
+ internal string GetMacAddress(ConnectionType type)
{
IntPtr ip;
int ret = Interop.Connection.GetMacAddress(GetHandle(), (int)type, out ip);
return result;
}
- public ConnectionType ConnectionType
+ internal ConnectionType ConnectionType
{
get
{
}
}
- public CellularState CellularState
+ internal CellularState CellularState
{
get
{
}
}
- public ConnectionState WiFiState
+ internal ConnectionState WiFiState
{
get
{
}
}
- public ConnectionState BluetoothState
+ internal ConnectionState BluetoothState
{
get
{
}
}
- public ConnectionState EthernetState
+ internal ConnectionState EthernetState
{
get
{
}
}
- public EthernetCableState EthernetCableState
+ internal EthernetCableState EthernetCableState
{
get
{
}
}
- static public IntPtr CreateRequestProfile(ConnectionProfileType type, string keyword)
+ internal IntPtr CreateCellularProfile(ConnectionProfileType type, string keyword)
{
- Log.Error(Globals.LogTag, "CreateRequestProfile, " + type + ", " + keyword);
+ Log.Error(Globals.LogTag, "CreateCellularProfile, " + type + ", " + keyword);
+ IntPtr connectionHandle = GetHandle();
+ if (connectionHandle == IntPtr.Zero)
+ {
+ Log.Error(Globals.LogTag, "It failed to create connection handle");
+ throw new InvalidOperationException("Invalid connection handle");
+ }
+
IntPtr handle = IntPtr.Zero;
int ret = Interop.ConnectionProfile.Create((int)type, keyword, out handle);
if ((ConnectionError)ret != ConnectionError.None)
return handle;
}
- public int AddProfile(RequestProfile profile)
+ internal int AddCellularProfile(CellularProfile profile)
{
- int ret = 0;
+ int ret = -1;
if (profile.Type == ConnectionProfileType.Cellular)
{
- ret = Interop.Connection.AddProfile(GetHandle(), ((RequestCellularProfile)profile).ProfileHandle);
+ ret = Interop.Connection.AddProfile(GetHandle(), profile.ProfileHandle);
if ((ConnectionError)ret != ConnectionError.None)
{
- Log.Error(Globals.LogTag, "It failed to add profile, " + (ConnectionError)ret);
+ Log.Error(Globals.LogTag, "Failed to add cellular profile, " + (ConnectionError)ret);
ConnectionErrorFactory.ThrowConnectionException(ret);
}
+ return ret;
}
- else if (profile.Type == ConnectionProfileType.WiFi)
+
+ else
{
- ret = Interop.Connection.AddProfile(GetHandle(), ((RequestWiFiProfile)profile).ProfileHandle);
- if ((ConnectionError)ret != ConnectionError.None)
- {
- Log.Error(Globals.LogTag, "It failed to add profile, " + (ConnectionError)ret);
- ConnectionErrorFactory.ThrowConnectionException(ret);
- }
+ throw new InvalidOperationException("Profile type is not cellular");
}
- return ret;
}
- public int RemoveProfile(ConnectionProfile profile)
+ internal int RemoveProfile(ConnectionProfile profile)
{
int ret = Interop.Connection.RemoveProfile(GetHandle(), profile.ProfileHandle);
if ((ConnectionError)ret != ConnectionError.None)
return ret;
}
- public int UpdateProfile(ConnectionProfile profile)
+ internal int UpdateProfile(ConnectionProfile profile)
{
int ret = Interop.Connection.UpdateProfile(GetHandle(), profile.ProfileHandle);
if ((ConnectionError)ret != ConnectionError.None)
return ret;
}
- public ConnectionProfile GetCurrentProfile()
+ internal ConnectionProfile GetCurrentProfile()
{
IntPtr ProfileHandle;
int ret = Interop.Connection.GetCurrentProfile(GetHandle(), out ProfileHandle);
return Profile;
}
- public ConnectionProfile GetDefaultCellularProfile(CellularServiceType type)
+ internal ConnectionProfile GetDefaultCellularProfile(CellularServiceType type)
{
IntPtr ProfileHandle;
int ret = Interop.Connection.GetDefaultCellularServiceProfile(GetHandle(), (int)type, out ProfileHandle);
return Profile;
}
- public Task<ConnectionError> SetDefaultCellularProfile(CellularServiceType type, ConnectionProfile profile)
+ internal Task<ConnectionError> SetDefaultCellularProfile(CellularServiceType type, ConnectionProfile profile)
{
var task = new TaskCompletionSource<ConnectionError>();
Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) =>
}
- public Task<IEnumerable<ConnectionProfile>> GetProfileListAsync(ProfileListType type)
+ internal Task<IEnumerable<ConnectionProfile>> GetProfileListAsync(ProfileListType type)
{
var task = new TaskCompletionSource<IEnumerable<ConnectionProfile>>();
return task.Task;
}
- public Task<ConnectionError> OpenProfileAsync(ConnectionProfile profile)
+ internal Task<ConnectionError> OpenProfileAsync(ConnectionProfile profile)
{
var task = new TaskCompletionSource<ConnectionError>();
Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) =>
return task.Task;
}
- public Task<ConnectionError> CloseProfileAsync(ConnectionProfile profile)
+ internal Task<ConnectionError> CloseProfileAsync(ConnectionProfile profile)
{
var task = new TaskCompletionSource<ConnectionError>();
Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) =>
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
namespace Tizen.Network.Connection
{
/// <summary>
- /// This class is ConnectionManager
+ /// This class is ConnectionManager. It provides functions to manage data connections.
/// </summary>
- public static partial class ConnectionManager
+ public static class ConnectionManager
{
private static ConnectionItem _currentConnection = null;
/// <summary>
/// Gets the IP address of the current connection.
/// </summary>
+ /// <param name="family">The address family</param>
+ /// <returns>IP address of the connection.</returns>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
public static string GetIpAddress(AddressFamily family)
{
/// <summary>
/// Gets the proxy address of the current connection.
/// </summary>
+ /// <param name="family">The address family</param>
+ /// <returns>Proxy address of the connection.</returns>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
public static string GetProxy(AddressFamily family)
{
/// <summary>
/// Gets the MAC address of the Wi-Fi or ethernet.
/// </summary>
+ /// <param name="type">The type of current network connection</param>
+ /// <returns>MAC address of the Wi-Fi or ethernet.</returns>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
public static string GetMacAddress(ConnectionType type)
{
}
/// <summary>
- /// Gets type and state of the current profile for data connection
+ /// Type and state of the current profile for data connection
/// </summary>
public static ConnectionItem CurrentConnection
{
}
}
- public static RequestProfile CreateRequestProfile(ConnectionProfileType type, string keyword)
+ /// <summary>
+ /// Creates a cellular profile handle.
+ /// </summary>
+ /// <param name="type">The type of profile. Cellular profile type is supported.</param>
+ /// <param name="keyword">The keyword included in profile name.</param>
+ /// <returns>CellularProfile object</returns>
+ public static CellularProfile CreateCellularProfile(ConnectionProfileType type, string keyword)
{
- IntPtr ProfileHandle = ConnectionInternalManager.CreateRequestProfile(type, keyword);
- if (type == ConnectionProfileType.WiFi)
- {
- return new RequestWiFiProfile(ProfileHandle);
- }
- else if (type == ConnectionProfileType.Cellular)
+ IntPtr profileHandle = IntPtr.Zero;
+ if (type == ConnectionProfileType.Cellular)
{
- return new RequestCellularProfile(ProfileHandle);
+ profileHandle = ConnectionInternalManager.Instance.CreateCellularProfile(type, keyword);
}
+
else
{
- Log.Error(Globals.LogTag, "Nut supported profile type");
+ Log.Error(Globals.LogTag, "ConnectionProfile Type is not supported");
ConnectionErrorFactory.ThrowConnectionException((int)ConnectionError.InvalidParameter);
}
- return null;
+
+ return new CellularProfile(profileHandle);
}
/// <summary>
- /// Gets the state of cellular connection.
+ /// The state of cellular connection.
/// </summary>
public static CellularState CellularState
{
}
/// <summary>
- /// Gets the state of the Wi-Fi.
+ /// The state of the Wi-Fi.
/// </summary>
/// <privilege>http://tizen.org/privilege/network.get</privilege>
public static ConnectionState WiFiState
} // class ConnectionManager
/// <summary>
- /// class which contains connection information such as connection type and state
+ /// This class contains connection information such as connection type and state.
/// </summary>
public class ConnectionItem
{
}
/// <summary>
- /// Gets the type of the current profile for data connection.
+ /// The type of the current profile for data connection.
/// </summary>
public ConnectionType Type
{
}
/// <summary>
- /// Gets the state of the current profile for data connection.
+ /// The state of the current profile for data connection.
/// </summary>
public ConnectionState State
{
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
namespace Tizen.Network.Connection
{
/// <summary>
- /// This Class is ConnectionProfile
+ /// This Class is ConnectionProfile. It provides event and propeties of the connection profile.
/// </summary>
public class ConnectionProfile : IDisposable
{
private IAddressInformation Ipv4;
private IAddressInformation Ipv6;
private bool disposed = false;
- private EventHandler _ProfileStateChanged;
+ private EventHandler _ProfileStateChanged = null;
+
+ private Interop.ConnectionProfile.ProfileStateChangedCallback _profileChangedCallback;
internal IntPtr GetHandle()
{
}
}
- private void TypeChangedCallback(ProfileState state, IntPtr userData)
+ private void ProfileStateChangedStart()
{
- if (_ProfileStateChanged != null)
+ _profileChangedCallback = (ProfileState state, IntPtr userData) =>
{
- _ProfileStateChanged(null, new ProfileStateEventArgs(state));
- }
- }
+ if (_ProfileStateChanged != null)
+ {
+ _ProfileStateChanged(null, new ProfileStateEventArgs(state));
+ }
+ };
- private void ProfileStateChangedStart()
- {
- int ret = Interop.ConnectionProfile.SetStateChangeCallback(ProfileHandle, TypeChangedCallback, IntPtr.Zero);
+ int ret = Interop.ConnectionProfile.SetStateChangeCallback(ProfileHandle, _profileChangedCallback, IntPtr.Zero);
if ((ConnectionError)ret != ConnectionError.None)
{
Log.Error(Globals.LogTag, "It failed to register callback for changing profile state, " + (ConnectionError)ret);
}
/// <summary>
- /// Gets the profile ID.
+ /// The profile ID.
/// </summary>
public string Id
{
}
/// <summary>
- /// Gets the profile name.
+ /// The profile name.
/// </summary>
/// <privilege>http://tizen.org/privilege/network.get</privilege>
public string Name
}
/// <summary>
- /// Gets the network type.
+ /// The network type.
/// </summary>
public ConnectionProfileType Type
{
}
/// <summary>
- /// Gets the name of the network interface, e.g. eth0 and pdp0.
+ /// The name of the network interface, e.g. eth0 and pdp0.
/// </summary>
public string InterfaceName
{
}
/// <summary>
- /// Gets the profile state.
+ /// The profile state.
/// </summary>
public ProfileState State
{
}
/// <summary>
- /// Gets the Proxy type.
+ /// The Proxy type.
/// </summary>
public ProxyType ProxyType
{
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
namespace Tizen.Network.Connection
{
/// <summary>
- /// This class is ConnectionManager
+ /// This class is ConnectionProfileManager. It provides functions to add, get, connect or modify the connection profile.
/// </summary>
- public static partial class ConnectionManager
+ public static class ConnectionProfileManager
{
/// <summary>
/// Adds a new profile
/// </summary>
/// <privilege>http://tizen.org/privilege/network.profile</privilege>
+ /// <param name="profile">The cellular profile object</param>
+ /// <returns>0 on success, else exception is thrown.</returns>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
- public static int AddProfile(RequestProfile profile)
+ public static int AddCellularProfile(CellularProfile profile)
{
- return ConnectionInternalManager.Instance.AddProfile(profile);
+ return ConnectionInternalManager.Instance.AddCellularProfile(profile);
}
/// <summary>
/// Gets the list of profile with profile list type
/// </summary>
/// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <param name="type">The type of profile</param>
+ /// <returns>List of connection profile objects.</returns>
public static Task<IEnumerable<ConnectionProfile>> GetProfileListAsync(ProfileListType type)
{
return ConnectionInternalManager.Instance.GetProfileListAsync(type);
/// </summary>
/// <privilege>http://tizen.org/privilege/network.get</privilege>
/// <privilege>http://tizen.org/privilege/network.set</privilege>
+ /// <param name="profile">The connection profile object</param>
+ /// <returns>A task indicates whether the ConnectProfileAsync method is done successfully or not.</returns>
public static Task<ConnectionError> ConnectProfileAsync(ConnectionProfile profile)
{
return ConnectionInternalManager.Instance.OpenProfileAsync(profile);
/// Closes a connection of profile.
/// </summary>
/// <privilege>http://tizen.org/privilege/network.set</privilege>
+ /// <param name="profile">The connection profile object</param>
+ /// <returns>A task indicates whether the DisconnectProfileAsync method is done successfully or not.</returns>
public static Task<ConnectionError> DisconnectProfileAsync(ConnectionProfile profile)
{
return ConnectionInternalManager.Instance.CloseProfileAsync(profile);
/// </summary>
/// <privilege>http://tizen.org/privilege/network.get</privilege>
/// <privilege>http://tizen.org/privilege/network.profile</privilege>
+ /// <param name="profile">The connection profile object</param>
+ /// <returns>0 on success, else exception is thrown.</returns>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
public static int RemoveProfile(ConnectionProfile profile)
{
/// </summary>
/// <privilege>http://tizen.org/privilege/network.get</privilege>
/// <privilege>http://tizen.org/privilege/network.profile</privilege>
+ /// <param name="profile">The connection profile object</param>
+ /// <returns>0 on success, else exception is thrown.</returns>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
public static int UpdateProfile(ConnectionProfile profile)
{
/// Gets the name of the default profile.
/// </summary>
/// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <returns>Connection profile object.</returns>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
public static ConnectionProfile GetCurrentProfile()
{
/// Gets the default profile which provides the given cellular service.
/// </summary>
/// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <param name="type">The cellular service type</param>
+ /// <returns>Connection profile object.</returns>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
public static ConnectionProfile GetDefaultCellularProfile(CellularServiceType type)
{
/// </summary>
/// <privilege>http://tizen.org/privilege/network.get</privilege>
/// <privilege>http://tizen.org/privilege/network.profile</privilege>
+ /// <param name="type">The cellular service type</param>
+ /// <param name="profile">The connection profile object</param>
+ /// <returns>A task indicates whether the SetDefaultCellularProfile method is done successfully or not.</returns>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
public static Task<ConnectionError> SetDefaultCellularProfile(CellularServiceType type, ConnectionProfile profile)
{
namespace Tizen.Network.Connection
{
/// <summary>
- /// This Class is ConnectionAddress
+ /// This interface provides properties to manage address information of the connection.
/// </summary>
public interface IAddressInformation : IDisposable
{
+++ /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>
- internal RequestCellularProfile(IntPtr handle)
- {
- Log.Debug(Globals.LogTag, "RequestCellularProfile is created : " + handle);
-
- ProfileHandle = handle;
- Ipv4 = new ConnectionAddressInformation(ProfileHandle, AddressFamily.Ipv4);
- Ipv6 = new ConnectionAddressInformation(ProfileHandle, AddressFamily.Ipv6);
- 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)
- {
- Log.Debug(Globals.LogTag, ">>> RequestCellularProfile Dispose with " + disposing);
- if (disposed)
- return;
-
- if (disposing)
- {
- // Free managed objects.
- Destroy();
- }
- disposed = true;
- }
-
- private void Destroy()
- {
- Interop.ConnectionProfile.Destroy(ProfileHandle);
- }
-
- /// <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>
- internal RequestWiFiProfile(IntPtr handle)
- {
- Log.Debug(Globals.LogTag, "RequestWiFiProfile is created : " + handle);
-
- ProfileHandle = handle;
- Ipv4 = new ConnectionAddressInformation(ProfileHandle, AddressFamily.Ipv4);
- Ipv6 = new ConnectionAddressInformation(ProfileHandle, AddressFamily.Ipv6);
- }
-
- /// <summary>
- /// The destructor of WiFiProfile class
- /// </summary>
- ~RequestWiFiProfile()
- {
- Dispose(false);
- }
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
- Log.Debug(Globals.LogTag, ">>> RequestWiFiProfile Dispose with " + disposing);
- if (disposed)
- return;
-
- if (disposing)
- {
- // Free managed objects.
- Destroy();
- }
- disposed = true;
- }
-
- private void Destroy()
- {
- Interop.ConnectionProfile.Destroy(ProfileHandle);
- }
-
- /// <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;
- }
- }
-}
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
namespace Tizen.Network.Connection
{
/// <summary>
- /// This Class is WiFiProfile
+ /// This Class is WiFiProfile. It provides functions to manage the WiFi profile.
/// </summary>
public class WiFiProfile : ConnectionProfile
{
}
/// <summary>
- /// Gets the ESSID (Extended Service Set Identifier).
+ /// The ESSID (Extended Service Set Identifier).
/// </summary>
public string Essid
{
}
/// <summary>
- /// Gets the BSSID (Basic Service Set Identifier).
+ /// The BSSID (Basic Service Set Identifier).
/// </summary>
public string Bssid
{
}
/// <summary>
- /// Gets the RSSI.
+ /// The RSSI.
/// </summary>
public int Rssi
{
}
/// <summary>
- /// Gets the frequency (MHz).
+ /// The frequency (MHz).
/// </summary>
public int Frequency
{
}
/// <summary>
- /// Gets the max speed (Mbps).
+ /// The max speed (Mbps).
/// </summary>
public int MaxSpeed
{
}
/// <summary>
- /// Gets the security type of Wi-Fi.
+ /// The security type of Wi-Fi.
/// </summary>
public WiFiSecureType SecureType
{
}
/// <summary>
- /// Gets the encryption type of Wi-Fi.
+ /// The encryption type of Wi-Fi.
/// </summary>
public WiFiEncryptionType EncryptionType
{
/// <summary>
/// Sets the passphrase of the Wi-Fi WPA.
/// </summary>
+ /// <param name="passphrase">The passphrase of Wi-Fi security</param>
+ /// <returns>0 on success, else exception is thrown.</returns>
+ /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
public int SetPassphrase(string passphrase)
{
int ret = Interop.ConnectionWiFiProfile.SetPassphrase(ProfileHandle, (string)passphrase);
- if ((ConnectionError)ret != ConnectionError.NoConnection)
+ if ((ConnectionError)ret != ConnectionError.None)
{
Log.Error(Globals.LogTag, "It failed to set passphrase, " + (ConnectionError)ret);
ConnectionErrorFactory.ThrowConnectionException(ret);