Name: csapi-network-connection
Summary: Tizen Connection API for C#
-Version: 1.0.16
+Version: 1.0.17
Release: 1
Group: Development/Libraries
License: Apache-2.0
/// <summary>
/// The APN (access point name).
/// </summary>
+ /// <value>Cellular access point name.</value>
+ /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+ /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+ /// <exception cref="System.ArgumentNullException">Thrown during set when value is null.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+ /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
public string Apn
{
get
{
+ Log.Debug(Globals.LogTag, "Get Apn");
IntPtr Value;
int ret = Interop.ConnectionCellularProfile.GetApn(ProfileHandle, out Value);
if ((ConnectionError)ret != ConnectionError.None)
Interop.Libc.Free(Value);
return result;
}
+
set
{
- int ret = Interop.ConnectionCellularProfile.SetApn(ProfileHandle, (string)value);
- if ((ConnectionError)ret != ConnectionError.None)
+ Log.Debug(Globals.LogTag, "Set Apn");
+ CheckDisposed();
+ if (value != null)
{
- Log.Error(Globals.LogTag, "It failed to set apn, " + (ConnectionError)ret);
- ConnectionErrorFactory.ThrowConnectionException(ret);
+ int ret = Interop.ConnectionCellularProfile.SetApn(ProfileHandle, value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set apn, " + (ConnectionError)ret);
+ ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+
+ else
+ {
+ throw new ArgumentNullException("Value of Apn is null");
}
}
}
/// <summary>
/// The home URL.
/// </summary>
+ /// <value>Cellular home URL.</value>
+ /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+ /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+ /// <exception cref="System.ArgumentNullException">Thrown during set when value is null.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+ /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
public string HomeUri
{
get
{
+ Log.Debug(Globals.LogTag, "Get HomeUri");
IntPtr Value;
int ret = Interop.ConnectionCellularProfile.GetHomeUrl(ProfileHandle, out Value);
if ((ConnectionError)ret != ConnectionError.None)
Interop.Libc.Free(Value);
return result;
}
+
set
{
- int ret = Interop.ConnectionCellularProfile.SetHomeUrl(ProfileHandle, (string)value);
- if ((ConnectionError)ret != ConnectionError.None)
+ Log.Debug(Globals.LogTag, "Set HomeUri");
+ CheckDisposed();
+ if (value != null)
{
- Log.Error(Globals.LogTag, "It failed to set home url, " + (ConnectionError)ret);
- ConnectionErrorFactory.ThrowConnectionException(ret);
+ int ret = Interop.ConnectionCellularProfile.SetHomeUrl(ProfileHandle, value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set home url, " + (ConnectionError)ret);
+ ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
}
+ else
+ {
+ throw new ArgumentNullException("Value of HomeUri is null");
+ }
}
}
/// <summary>
/// The service type.
/// </summary>
+ /// <value>Cellular service type.</value>
+ /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+ /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+ /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
public CellularServiceType ServiceType
{
get
{
+ Log.Debug(Globals.LogTag, "Get ServiceType");
int value;
int ret = Interop.ConnectionCellularProfile.GetServiceType(ProfileHandle, out value);
if ((ConnectionError)ret != ConnectionError.None)
}
return (CellularServiceType)value;
}
+
set
{
+ Log.Debug(Globals.LogTag, "Set ServiceType");
+ CheckDisposed();
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.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
ConnectionErrorFactory.ThrowConnectionException(ret);
}
}
}
/// <summary>
- /// Gets cellular Authentification Information.
+ /// The cellular Authentication Information.
/// </summary>
+ /// <value>Cellular authentication information</value>
public CellularAuthInformation CellularAuthInfo
{
get
/// <summary>
/// Checks whether the profile is hidden.
/// </summary>
+ /// <value>True if the cellular profile is hidden, otherwise false.</value>
public bool Hidden
{
get
/// <summary>
/// Checks whether the profile is editable.
/// </summary>
+ /// <value>True if the cellular profile is editable, otherwise false.</value>
public bool Editable
{
get
/// <summary>
/// Checks whether the profile is default.
/// </summary>
+ /// <value>True if the cellular profile is default, otherwise false.</value>
public bool IsDefault
{
get
/// <summary>
/// The user name.
/// </summary>
+ /// <value>Cellular user name.</value>
public string UserName
{
get
/// <summary>
/// The password
/// </summary>
+ /// <value>Cellular password.</value>
public string Password
{
get
/// <summary>
/// The authentication type
/// </summary>
+ /// <value>Cellular authentication type.</value>
public CellularAuthType AuthType
{
get
{
internal static class ConnectionErrorFactory
{
- internal static void ThrowConnectionException(int errno)
+ internal static void CheckFeatureUnsupportedException(int err, string message)
+ {
+ if ((ConnectionError)err == ConnectionError.NotSupported)
+ {
+ ThrowConnectionException(err, message);
+ }
+ }
+
+ internal static void CheckPermissionDeniedException(int err, string message)
+ {
+ if ((ConnectionError)err == ConnectionError.PermissionDenied)
+ {
+ ThrowConnectionException(err, message);
+ }
+ }
+
+ internal static void CheckHandleNullException(int err, bool isHandleInvalid, string message)
+ {
+ if ((ConnectionError)err == ConnectionError.InvalidParameter)
+ {
+ if (isHandleInvalid)
+ {
+ ThrowConnectionException((int)ConnectionError.InvalidOperation, message);
+ }
+ }
+ }
+
+ internal static void ThrowConnectionException(int errno , string message = "")
{
ConnectionError _error = (ConnectionError)errno;
Log.Debug(Globals.LogTag, "ThrowConnectionException " + _error);
case ConnectionError.InvalidKey:
throw new InvalidOperationException("Invalid Key");
case ConnectionError.InvalidOperation:
- throw new InvalidOperationException("Invalid Operation");
+ throw new InvalidOperationException("Invalid Operation " + message);
case ConnectionError.InvalidParameter:
- throw new InvalidOperationException("Invalid Parameter");
+ throw new ArgumentException("Invalid Parameter");
case ConnectionError.NoConnection:
throw new InvalidOperationException("No Connection");
case ConnectionError.NoReply:
throw new InvalidOperationException("No Reply");
case ConnectionError.NotSupported:
- throw new NotSupportedException("Not Supported");
+ throw new NotSupportedException("Unsupported feature " + message);
case ConnectionError.NowInProgress:
throw new InvalidOperationException("Now In Progress");
case ConnectionError.OperationAborted:
case ConnectionError.OperationFailed:
throw new InvalidOperationException("Operation Failed");
case ConnectionError.OutOfMemoryError:
- throw new InvalidOperationException("Out Of Memory Error");
+ throw new OutOfMemoryException("Out Of Memory Error");
case ConnectionError.PermissionDenied:
- throw new InvalidOperationException("Permission Denied");
+ throw new UnauthorizedAccessException("Permission Denied " + message);
}
}
}
public HandleHolder()
{
- Log.Debug(Globals.LogTag, "HandleHolder() ^^");
- Interop.Connection.Create(out Handle);
Log.Debug(Globals.LogTag, "Handle: " + Handle);
+ int ret = Interop.Connection.Create(out Handle);
+ if(ret != (int)ConnectionError.None)
+ {
+ ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+ ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.get)");
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
}
~HandleHolder()
private void Destroy()
{
Interop.Connection.Destroy(Handle);
+ if (Handle != IntPtr.Zero)
+ {
+ Handle = IntPtr.Zero;
+ }
}
}
if ((ConnectionError)ret != ConnectionError.None)
{
Log.Error(Globals.LogTag, "It failed to get IP address, " + (ConnectionError)ret);
+ ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
ConnectionErrorFactory.ThrowConnectionException(ret);
}
+
string result = Marshal.PtrToStringAnsi(ip);
Interop.Libc.Free(ip);
return result;
if ((ConnectionError)ret != ConnectionError.None)
{
Log.Error(Globals.LogTag, "It failed to get proxy, " + (ConnectionError)ret);
+ ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
ConnectionErrorFactory.ThrowConnectionException(ret);
}
+
string result = Marshal.PtrToStringAnsi(ip);
Interop.Libc.Free(ip);
return result;
if ((ConnectionError)ret != ConnectionError.None)
{
Log.Error(Globals.LogTag, "It failed to get mac address, " + (ConnectionError)ret);
+ ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.ethernet");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
ConnectionErrorFactory.ThrowConnectionException(ret);
}
string result = Marshal.PtrToStringAnsi(ip);
internal IntPtr CreateCellularProfile(ConnectionProfileType type, string keyword)
{
- Log.Error(Globals.LogTag, "CreateCellularProfile, " + type + ", " + keyword);
- IntPtr connectionHandle = GetHandle();
- if (connectionHandle == IntPtr.Zero)
+
+ Log.Debug(Globals.LogTag, "CreateCellularProfile, " + type + ", " + keyword);
+ if (keyword != null)
{
- 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)
+ {
+ Log.Error(Globals.LogTag, "It failed to Create profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.telephony");
+ ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.get)");
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+
+ return handle;
}
- IntPtr handle = IntPtr.Zero;
- int ret = Interop.ConnectionProfile.Create((int)type, keyword, out handle);
- if ((ConnectionError)ret != ConnectionError.None)
+ else
{
- Log.Error(Globals.LogTag, "It failed to Create profile, " + (ConnectionError)ret);
- ConnectionErrorFactory.ThrowConnectionException(ret);
+ throw new ArgumentNullException("Keyword is null");
}
-
- return handle;
}
internal void AddCellularProfile(CellularProfile profile)
{
- if (profile.Type == ConnectionProfileType.Cellular)
+
+ Log.Debug(Globals.LogTag, "AddCellularProfile");
+ if (profile != null)
{
- int ret = Interop.Connection.AddProfile(GetHandle(), profile.ProfileHandle);
- if ((ConnectionError)ret != ConnectionError.None)
+ if (profile.Type == ConnectionProfileType.Cellular)
{
- Log.Error(Globals.LogTag, "Failed to add cellular profile, " + (ConnectionError)ret);
- ConnectionErrorFactory.ThrowConnectionException(ret);
+ int ret = Interop.Connection.AddProfile(GetHandle(), profile.ProfileHandle);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to add cellular profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony");
+ ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.profile)");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released");
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+
+ else
+ {
+ throw new ArgumentException("Profile type is not cellular");
}
}
else
{
- throw new InvalidOperationException("Profile type is not cellular");
+ throw new ArgumentNullException("Profile is null");
}
}
internal void RemoveProfile(ConnectionProfile profile)
{
- int ret = Interop.Connection.RemoveProfile(GetHandle(), profile.ProfileHandle);
- if ((ConnectionError)ret != ConnectionError.None)
+ Log.Debug(Globals.LogTag, "RemoveProfile");
+ if (profile != null)
{
- Log.Error(Globals.LogTag, "It failed to remove profile, " + (ConnectionError)ret);
- ConnectionErrorFactory.ThrowConnectionException(ret);
+ int ret = Interop.Connection.RemoveProfile(GetHandle(), profile.ProfileHandle);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to remove profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.telephony");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released");
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+
+ else
+ {
+ throw new ArgumentNullException("Profile is null");
}
}
internal void UpdateProfile(ConnectionProfile profile)
{
- int ret = Interop.Connection.UpdateProfile(GetHandle(), profile.ProfileHandle);
- if ((ConnectionError)ret != ConnectionError.None)
+ Log.Debug(Globals.LogTag, "UpdateProfile");
+ if (profile != null)
{
- Log.Error(Globals.LogTag, "It failed to update profile, " + (ConnectionError)ret);
- ConnectionErrorFactory.ThrowConnectionException(ret);
+ int ret = Interop.Connection.UpdateProfile(GetHandle(), profile.ProfileHandle);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to update profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.ethernet");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released");
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+
+ else
+ {
+ throw new ArgumentNullException("Profile is null");
}
}
if ((ConnectionError)ret != ConnectionError.None)
{
Log.Error(Globals.LogTag, "It failed to get current profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+ ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.get)");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
ConnectionErrorFactory.ThrowConnectionException(ret);
}
+
ConnectionProfile Profile = new ConnectionProfile(ProfileHandle);
return Profile;
}
{
Log.Error(Globals.LogTag, "Error: " + ret);
Log.Error(Globals.LogTag, "It failed to get default cellular profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony");
+ ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.get)");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
ConnectionErrorFactory.ThrowConnectionException(ret);
}
+
CellularProfile Profile = new CellularProfile(ProfileHandle);
return Profile;
}
internal Task SetDefaultCellularProfile(CellularServiceType type, ConnectionProfile profile)
{
- TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
- Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) =>
+ Log.Debug(Globals.LogTag, "SetDefaultCellularProfile");
+ if (profile != null)
{
- if (Result != ConnectionError.None)
+ TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
+ Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) =>
+ {
+ if (Result != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "Error occurs during set default cellular profile, " + Result);
+ task.SetException(new InvalidOperationException("Error occurs during set default cellular profile, " + Result));
+ }
+
+ task.SetResult(true);
+ };
+
+ int ret = Interop.Connection.SetDefaultCellularServiceProfileAsync(GetHandle(), (int)type, profile.ProfileHandle, Callback, (IntPtr)0);
+ if ((ConnectionError)ret != ConnectionError.None)
{
- Log.Error(Globals.LogTag, "Error occurs during set default cellular profile, " + Result);
- task.SetException(new InvalidOperationException("Error occurs during set default cellular profile, " + Result));
+ Log.Error(Globals.LogTag, "It failed to set default cellular profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released");
+ ConnectionErrorFactory.ThrowConnectionException(ret);
}
- task.SetResult(true);
- };
+ return task.Task;
+ }
- int ret = Interop.Connection.SetDefaultCellularServiceProfileAsync(GetHandle(), (int)type, profile.ProfileHandle, Callback, (IntPtr)0);
- if ((ConnectionError)ret != ConnectionError.None)
+ else
{
- Log.Error(Globals.LogTag, "It failed to set default cellular profile, " + (ConnectionError)ret);
- ConnectionErrorFactory.ThrowConnectionException(ret);
+ throw new ArgumentNullException("Profile is null");
}
-
- return task.Task;
}
if ((ConnectionError)ret != ConnectionError.None)
{
Log.Error(Globals.LogTag, "It failed to get profile iterator, " + (ConnectionError)ret);
+ ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+ ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.get)");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
+ ConnectionErrorFactory.ThrowConnectionException(ret);
}
while (Interop.Connection.HasNextProfileIterator(iterator))
internal Task OpenProfileAsync(ConnectionProfile profile)
{
- TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
- Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) =>
+ Log.Debug(Globals.LogTag, "OpenProfileAsync");
+ if (profile != null)
{
- if (Result != ConnectionError.None)
+ Log.Debug(Globals.LogTag, "OpenProfileAsync " + profile.Name);
+ TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
+ Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) =>
+ {
+ Log.Debug(Globals.LogTag, "Connected " + profile.Name);
+ if (Result != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "Error occurs during connecting profile, " + Result);
+ task.SetException(new InvalidOperationException("Error occurs during connecting profile, " + Result));
+ }
+
+ task.SetResult(true);
+ };
+
+ int ret = Interop.Connection.OpenProfile(GetHandle(), profile.ProfileHandle, Callback, IntPtr.Zero);
+ if ((ConnectionError)ret != ConnectionError.None)
{
- Log.Error(Globals.LogTag, "Error occurs during connecting profile, " + Result);
- task.SetException(new InvalidOperationException("Error occurs during connecting profile, " + Result));
+ Log.Error(Globals.LogTag, "It failed to connect profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released");
+ ConnectionErrorFactory.ThrowConnectionException(ret);
}
- task.SetResult(true);
- };
+ return task.Task;
+ }
- int ret = Interop.Connection.OpenProfile(GetHandle(), profile.ProfileHandle, Callback, IntPtr.Zero);
- if ((ConnectionError)ret != ConnectionError.None)
+ else
{
- Log.Error(Globals.LogTag, "It failed to connect profile, " + (ConnectionError)ret);
- ConnectionErrorFactory.ThrowConnectionException(ret);
+ throw new ArgumentNullException("Profile is null");
}
-
- return task.Task;
}
internal Task CloseProfileAsync(ConnectionProfile profile)
{
- TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
- Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) =>
+ Log.Debug(Globals.LogTag, "CloseProfileAsync");
+ if (profile != null)
{
- if (Result != ConnectionError.None)
+ Log.Debug(Globals.LogTag, "CloseProfileAsync " + profile.Name);
+ TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
+ Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) =>
+ {
+ if (Result != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "Error occurs during disconnecting profile, " + Result);
+ task.SetException(new InvalidOperationException("Error occurs during disconnecting profile, " + Result));
+ }
+
+ task.SetResult(true);
+ };
+
+ int ret = Interop.Connection.CloseProfile(GetHandle(), profile.ProfileHandle, Callback, IntPtr.Zero);
+ if ((ConnectionError)ret != ConnectionError.None)
{
- Log.Error(Globals.LogTag, "Error occurs during disconnecting profile, " + Result);
- task.SetException(new InvalidOperationException("Error occurs during disconnecting profile, " + Result));
+ Log.Error(Globals.LogTag, "It failed to disconnect profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth");
+ ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.set)");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released");
+ ConnectionErrorFactory.ThrowConnectionException(ret);
}
- task.SetResult(true);
- };
+ return task.Task;
+ }
- int ret = Interop.Connection.CloseProfile(GetHandle(), profile.ProfileHandle, Callback, IntPtr.Zero);
- if ((ConnectionError)ret != ConnectionError.None)
+ else
{
- Log.Error(Globals.LogTag, "It failed to disconnect profile, " + (ConnectionError)ret);
- ConnectionErrorFactory.ThrowConnectionException(ret);
+ throw new ArgumentNullException("Profile is null");
}
-
- return task.Task;
}
}
-}
\ No newline at end of file
+}
/// <summary>
/// Checks whether the handle value is valid or not.
/// </summary>
+ /// <value>True if the handle is invalid, otherwise false.</value>
public override bool IsInvalid
{
get
}
}
+ /// <summary>
+ /// Frees the handle.
+ /// </summary>
+ /// <returns>True if the handle is released successfully, otherwise false.</returns>
protected override bool ReleaseHandle()
{
this.SetHandle(IntPtr.Zero);
/// 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>
+ /// <returns>IP address of the connection (global address in case of IPv6).</returns>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <feature>http://tizen.org/feature/network.telephony</feature>
+ /// <feature>http://tizen.org/feature/network.wifi</feature>
+ /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+ /// <feature>http://tizen.org/feature/network.ethernet</feature>
+ /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+ /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+ /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+ /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation.</exception>
public static string GetIPAddress(AddressFamily family)
{
return ConnectionInternalManager.Instance.GetIPAddress(family);
/// </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>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <feature>http://tizen.org/feature/network.telephony</feature>
+ /// <feature>http://tizen.org/feature/network.wifi</feature>
+ /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+ /// <feature>http://tizen.org/feature/network.ethernet</feature>
+ /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+ /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+ /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+ /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation.</exception>
public static string GetProxy(AddressFamily family)
{
return ConnectionInternalManager.Instance.GetProxy(family);
/// </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>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <feature>http://tizen.org/feature/network.telephony</feature>
+ /// <feature>http://tizen.org/feature/network.wifi</feature>
+ /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+ /// <feature>http://tizen.org/feature/network.ethernet</feature>
+ /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+ /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+ /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+ /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation.</exception>
public static string GetMacAddress(ConnectionType type)
{
return ConnectionInternalManager.Instance.GetMacAddress(type);
/// <summary>
/// Type and state of the current profile for data connection
/// </summary>
+ /// <value>Instance of ConnectionItem</value>
public static ConnectionItem CurrentConnection
{
get
/// <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>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <feature>http://tizen.org/feature/network.telephony</feature>
+ /// <feature>http://tizen.org/feature/network.wifi</feature>
+ /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+ /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+ /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+ /// <exception cref="System.ArgumentNullException">Thrown when keyword value is null.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
public static CellularProfile CreateCellularProfile(ConnectionProfileType type, string keyword)
{
IntPtr profileHandle = IntPtr.Zero;
/// <summary>
/// The state of cellular connection.
/// </summary>
+ /// <value>Cellular network state.</value>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
public static CellularState CellularState
{
get
/// <summary>
/// The state of the Wi-Fi.
/// </summary>
+ /// <value>WiFi connection state.</value>
/// <privilege>http://tizen.org/privilege/network.get</privilege>
public static ConnectionState WiFiState
{
/// <summary>
/// The state of the Bluetooth.
/// </summary>
+ /// <value>Bluetooth connection state.</value>
/// <privilege>http://tizen.org/privilege/network.get</privilege>
public static ConnectionState BluetoothState
{
/// <summary>
/// The Ethernet connection state.
/// </summary>
+ /// <value>Ethernet connection state.</value>
/// <privilege>http://tizen.org/privilege/network.get</privilege>
public static ConnectionState EthernetState
{
/// <summary>
/// Checks for ethernet cable is attached or not.
/// </summary>
+ /// <value>Ethernet cable state.</value>
/// <privilege>http://tizen.org/privilege/network.get</privilege>
public static EthernetCableState EthernetCableState
{
/// <summary>
/// The type of the current profile for data connection.
/// </summary>
+ /// <value>Data connection current profile.</value>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
public ConnectionType Type
{
get
/// <summary>
/// The state of the current profile for data connection.
/// </summary>
+ /// <value>Connection state of the current connection type.</value>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
public ConnectionState State
{
get
/// <summary>
/// The connection type.
/// </summary>
+ /// <value>Type of the connection.</value>
public ConnectionType ConnectionType
{
get
/// <summary>
/// The ethernet cable state.
/// </summary>
+ /// <value>Attached or detached state of the ethernet cable.</value>
public EthernetCableState EthernetCableState
{
get
/// <summary>
/// The IPV4 address.
/// </summary>
+ /// <value>IP address in the format of IPV4 syntax.</value>
public string IPv4Address
{
get
/// <summary>
/// The IPV6 address.
/// </summary>
+ /// <value>IP address in the format of IPV6 syntax.</value>
public string IPv6Address
{
get
Dispose(false);
}
+ /// <summary>
+ /// Disposes the memory allocated to unmanaged resources.
+ /// </summary>
public void Dispose()
{
Dispose(true);
private void Destroy()
{
Interop.ConnectionProfile.Destroy(ProfileHandle);
+ ProfileHandle = IntPtr.Zero;
+ }
+
+ internal void CheckDisposed()
+ {
+ if (disposed)
+ {
+ throw new ObjectDisposedException(GetType().FullName);
+ }
}
/// <summary>
/// The profile ID.
/// </summary>
+ /// <value>Unique ID of the profile.</value>
public string Id
{
get
/// <summary>
/// The profile name.
/// </summary>
- /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <value>User friendly name of the profile.</value>
public string Name
{
get
/// <summary>
/// The network type.
/// </summary>
+ /// <value>Profile type of the network connection.</value>
public ConnectionProfileType Type
{
get
}
/// <summary>
- /// The name of the network interface, e.g. eth0 and pdp0.
+ /// The name of the network interface.
/// </summary>
+ /// <value>Network interface name, e.g. eth0 and pdp0.</value>
public string InterfaceName
{
get
/// <summary>
/// The Proxy type.
/// </summary>
+ /// <value>Proxy type of the connection.</value>
+ /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+ /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+ /// <exception cref="System.ObjectDisposedException">Thrown during set when operation is performed on a disposed object.</exception>
public ProxyType ProxyType
{
get
return (ProxyType)Value;
}
+
set
{
+ CheckDisposed();
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.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
ConnectionErrorFactory.ThrowConnectionException(ret);
}
}
/// <summary>
/// The proxy address.
/// </summary>
- public String ProxyAddress
+ /// <value>Proxy address of the connection.</value>
+ /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+ /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+ /// <exception cref="System.ArgumentNullException">Thrown during set when value is null.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+ /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
+ public string ProxyAddress
{
get
{
return result;
}
+
set
{
- int ret = Interop.ConnectionProfile.SetProxyAddress(ProfileHandle, (int)AddressFamily.IPv4, value.ToString());
- if ((ConnectionError)ret != ConnectionError.None)
+ CheckDisposed();
+ if (value != null)
{
- Log.Error(Globals.LogTag, "It failed to set proxy address, " + (ConnectionError)ret);
- ConnectionErrorFactory.ThrowConnectionException(ret);
+ int ret = Interop.ConnectionProfile.SetProxyAddress(ProfileHandle, (int)AddressFamily.IPv4, value);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set proxy address, " + (ConnectionError)ret);
+ ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+
+ else
+ {
+ throw new ArgumentNullException("ProxyAddress is null");
}
}
}
/// <summary>
/// The subnet mask address(IPv4).
/// </summary>
+ /// <value>Instance of IAddressInformation with IPV4 address.</value>
public IAddressInformation IPv4Settings
{
get
/// <summary>
/// The subnet mask address(IPv4).
/// </summary>
+ /// <value>Instance of IAddressInformation with IPV6 address.</value>
public IAddressInformation IPv6Settings
{
get
/// <summary>
/// The profile state.
/// </summary>
+ /// <value>State type of the connection profile.</value>
public ProfileState State
{
get
/// <summary>
/// Adds a new profile
/// </summary>
- /// <privilege>http://tizen.org/privilege/network.profile</privilege>
/// <param name="profile">The cellular profile object</param>
- /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+ /// <privilege>http://tizen.org/privilege/network.profile</privilege>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <feature>http://tizen.org/feature/network.telephony</feature>
+ /// <feature>http://tizen.org/feature/network.wifi</feature>
+ /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+ /// <feature>http://tizen.org/feature/network.ethernet</feature>
+ /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+ /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+ /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+ /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
+ /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
public static void AddCellularProfile(CellularProfile profile)
{
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>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <feature>http://tizen.org/feature/network.telephony</feature>
+ /// <feature>http://tizen.org/feature/network.wifi</feature>
+ /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+ /// <feature>http://tizen.org/feature/network.ethernet</feature>
+ /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+ /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+ /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+ /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown when connection instance has been disposed.</exception>
public static Task<IEnumerable<ConnectionProfile>> GetProfileListAsync(ProfileListType type)
{
return ConnectionInternalManager.Instance.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>
/// <param name="profile">The connection profile object</param>
/// <returns>A task indicates whether the ConnectProfileAsync method is done successfully or not.</returns>
- /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <privilege>http://tizen.org/privilege/network.set</privilege>
+ /// <feature>http://tizen.org/feature/network.telephony</feature>
+ /// <feature>http://tizen.org/feature/network.wifi</feature>
+ /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+ /// <feature>http://tizen.org/feature/network.ethernet</feature>
+ /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+ /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+ /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+ /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
+ /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
public static Task ConnectProfileAsync(ConnectionProfile profile)
{
return ConnectionInternalManager.Instance.OpenProfileAsync(profile);
/// <summary>
/// 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>
- /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <privilege>http://tizen.org/privilege/network.set</privilege>
+ /// <feature>http://tizen.org/feature/network.telephony</feature>
+ /// <feature>http://tizen.org/feature/network.wifi</feature>
+ /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+ /// <feature>http://tizen.org/feature/network.ethernet</feature>
+ /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+ /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+ /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+ /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
+ /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
public static Task DisconnectProfileAsync(ConnectionProfile profile)
{
return ConnectionInternalManager.Instance.CloseProfileAsync(profile);
/// <summary>
/// Removes an existing profile.
/// </summary>
+ /// <param name="profile">The connection profile object</param>
/// <privilege>http://tizen.org/privilege/network.get</privilege>
/// <privilege>http://tizen.org/privilege/network.profile</privilege>
- /// <param name="profile">The connection profile object</param>
- /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+ /// <feature>http://tizen.org/feature/network.telephony</feature>
+ /// <feature>http://tizen.org/feature/network.wifi</feature>
+ /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+ /// <feature>http://tizen.org/feature/network.ethernet</feature>
+ /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+ /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+ /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+ /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
+ /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
public static void RemoveProfile(ConnectionProfile profile)
{
Log.Debug(Globals.LogTag, "RemoveProfile. Id: " + profile.Id + ", Name: " + profile.Name + ", Type: " + profile.Type);
/// 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>
+ /// <param name="profile">The connection profile object</param>
/// <privilege>http://tizen.org/privilege/network.get</privilege>
/// <privilege>http://tizen.org/privilege/network.profile</privilege>
- /// <param name="profile">The connection profile object</param>
- /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+ /// <feature>http://tizen.org/feature/network.telephony</feature>
+ /// <feature>http://tizen.org/feature/network.wifi</feature>
+ /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+ /// <feature>http://tizen.org/feature/network.ethernet</feature>
+ /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+ /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+ /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+ /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
+ /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
public static void UpdateProfile(ConnectionProfile profile)
{
ConnectionInternalManager.Instance.UpdateProfile(profile);
/// <summary>
/// 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>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <feature>http://tizen.org/feature/network.telephony</feature>
+ /// <feature>http://tizen.org/feature/network.wifi</feature>
+ /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+ /// <feature>http://tizen.org/feature/network.ethernet</feature>
+ /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+ /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+ /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+ /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation</exception>
public static ConnectionProfile GetCurrentProfile()
{
return ConnectionInternalManager.Instance.GetCurrentProfile();
/// <summary>
/// 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>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <feature>http://tizen.org/feature/network.telephony</feature>
+ /// <feature>http://tizen.org/feature/network.wifi</feature>
+ /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+ /// <feature>http://tizen.org/feature/network.ethernet</feature>
+ /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+ /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+ /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+ /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation</exception>
public static ConnectionProfile GetDefaultCellularProfile(CellularServiceType type)
{
return ConnectionInternalManager.Instance.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>
/// <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>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <privilege>http://tizen.org/privilege/network.profile</privilege>
+ /// <feature>http://tizen.org/feature/network.telephony</feature>
+ /// <feature>http://tizen.org/feature/network.wifi</feature>
+ /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+ /// <feature>http://tizen.org/feature/network.ethernet</feature>
+ /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+ /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+ /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+ /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
+ /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
public static Task SetDefaultCellularProfile(CellularServiceType type, ConnectionProfile profile)
{
return ConnectionInternalManager.Instance.SetDefaultCellularProfile(type, profile);
/// <summary>
/// The connection profile state.
/// </summary>
+ /// <value>State of the connection profile.</value>
public ConnectionProfileState ConnectionProfileState
{
get
/// <summary>
/// The DNS address.
/// </summary>
+ /// <value>First DNS address of the connection.</value>
+ /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+ /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
System.Net.IPAddress Dns1 { get; set; }
/// <summary>
/// The DNS address.
/// </summary>
+ /// <value>Second DNS address of the connection.</value>
+ /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+ /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
System.Net.IPAddress Dns2 { get; set; }
/// <summary>
/// The gateway address.
/// </summary>
+ /// <value>Gateway address of the connection.</value>
+ /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+ /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
System.Net.IPAddress Gateway { get; set; }
/// <summary>
/// The subnet mask address.
/// </summary>
+ /// <value>Subnet mask of the connection.</value>
+ /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+ /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
System.Net.IPAddress SubnetMask { get; set; }
/// <summary>
/// The IP address.
/// </summary>
+ /// <value>IP address of the connection.</value>
+ /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+ /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
System.Net.IPAddress IP { get; set; }
/// <summary>
/// The type of IP config.
/// </summary>
+ /// <value>IP config type of the connection.</value>
+ /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+ /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
IPConfigType IPConfigType { get; set; }
}
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);
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.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (_profileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
ConnectionErrorFactory.ThrowConnectionException(ret);
}
}
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);
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.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (_profileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
ConnectionErrorFactory.ThrowConnectionException(ret);
}
}
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);
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.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (_profileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
ConnectionErrorFactory.ThrowConnectionException(ret);
}
}
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);
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.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (_profileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
ConnectionErrorFactory.ThrowConnectionException(ret);
}
}
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);
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.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (_profileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
ConnectionErrorFactory.ThrowConnectionException(ret);
}
}
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.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (_profileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
ConnectionErrorFactory.ThrowConnectionException(ret);
}
}
/// <summary>
/// The ESSID (Extended Service Set Identifier).
/// </summary>
+ /// <value>ESSID of the WiFi.</value>
public string Essid
{
get
/// <summary>
/// The BSSID (Basic Service Set Identifier).
/// </summary>
+ /// <value>BSSID of the WiFi.</value>
public string Bssid
{
get
/// <summary>
/// The RSSI.
/// </summary>
+ /// <value>RSSI of the WiFi.</value>
public int Rssi
{
get
/// <summary>
/// The frequency (MHz).
/// </summary>
+ /// <value>Frequency of the WiFi.</value>
public int Frequency
{
get
/// <summary>
/// The max speed (Mbps).
/// </summary>
+ /// <value>Maximum speed of the WiFi.</value>
public int MaxSpeed
{
get
}
/// <summary>
- /// The security type of Wi-Fi.
+ /// The security type of WiFi.
/// </summary>
+ /// <value>Security type of the WiFi.</value>
public WiFiSecurityType SecurityType
{
get
}
/// <summary>
- /// The encryption type of Wi-Fi.
+ /// The encryption type of WiFi.
/// </summary>
+ /// <value>Encryption mode of the WiFi.</value>
public WiFiEncryptionType EncryptionType
{
get
/// <summary>
/// Checks whether passphrase is required.
/// </summary>
+ /// <value>True if a passphrase is required, otherwise false.</value>
+ /// <remarks>This property is not valid if <c>WiFiSecurityType</c> is <c>Eap</c>.</remarks>
public bool PassphraseRequired
{
get
/// <summary>
/// Checks whether the WPS (Wi-Fi Protected Setup) is supported.
/// </summary>
+ /// <value>True if WPS is supported, otherwise false.</value>
public bool WpsSupported
{
get
/// Sets the passphrase of the Wi-Fi WPA.
/// </summary>
/// <param name="passphrase">The passphrase of Wi-Fi security</param>
- /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+ /// <feature>http://tizen.org/feature/network.wifi</feature>
+ /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+ /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+ /// <exception cref="System.ArgumentNullException">Thrown when passphrase is null.</exception>
+ /// <exception cref="System.InvalidOperationException">Thrown when profile instance is invalid or when method failed due to invalid operation.</exception>
+ /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
public void SetPassphrase(string passphrase)
{
- int ret = Interop.ConnectionWiFiProfile.SetPassphrase(ProfileHandle, (string)passphrase);
- if ((ConnectionError)ret != ConnectionError.None)
+ CheckDisposed();
+ if (passphrase != null)
{
- Log.Error(Globals.LogTag, "It failed to set passphrase, " + (ConnectionError)ret);
- ConnectionErrorFactory.ThrowConnectionException(ret);
+ int ret = Interop.ConnectionWiFiProfile.SetPassphrase(ProfileHandle, passphrase);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set passphrase, " + (ConnectionError)ret);
+ ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.wifi");
+ ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+ ConnectionErrorFactory.ThrowConnectionException(ret);
+ }
+ }
+
+ else
+ {
+ throw new ArgumentNullException("Value of passphrase is null");
}
}
}