context.Post((x) =>
{
Log.Info(Globals.LogTag, "Interop.Connection.SetDefaultCellularServiceProfileAsync " + profile.Name);
- int ret = Interop.Connection.SetDefaultCellularServiceProfileAsync(GetHandle(), (int)type, profile.ProfileHandle, Callback, (IntPtr)0);
- if ((ConnectionError)ret != ConnectionError.None)
+ try
{
- 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);
+ int ret = Interop.Connection.SetDefaultCellularServiceProfileAsync(GetHandle(), (int)type, profile.ProfileHandle, Callback, (IntPtr)0);
+
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "It failed to set default cellular profile, " + (ConnectionError)ret);
+ ConnectionErrorFactory.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);
+ }
+ } catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on SetDefaultCellularServiceProfileAsync\n" + e.ToString());
+ task.SetException(e);
}
}, null);
context.Post((x) =>
{
Log.Info(Globals.LogTag, "Interop.Connection.OpenProfile " + profile.Name);
- int ret = Interop.Connection.OpenProfile(GetHandle(), profile.ProfileHandle, Callback, IntPtr.Zero);
- if ((ConnectionError)ret != ConnectionError.None)
+ try
{
- 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);
+ int ret = Interop.Connection.OpenProfile(GetHandle(), profile.ProfileHandle, Callback, IntPtr.Zero);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ 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);
+ }
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on OpenProfile\n" + e.ToString());
+ task.SetException(e);
}
}, null);
context.Post((x) =>
{
Log.Info(Globals.LogTag, "Interop.Connection.CloseProfile " + profile.Name);
- int ret = Interop.Connection.CloseProfile(GetHandle(), profile.ProfileHandle, Callback, IntPtr.Zero);
- if ((ConnectionError)ret != ConnectionError.None)
+ try
{
- 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);
+ int ret = Interop.Connection.CloseProfile(GetHandle(), profile.ProfileHandle, Callback, IntPtr.Zero);
+ if ((ConnectionError)ret != ConnectionError.None)
+ {
+ 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);
+ }
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on CloseProfile\n" + e.ToString());
+ task.SetException(e);
}
}, null);
context.Post((x) =>
{
Log.Info(Globals.LogTag, "Interop.WiFi.Connect");
- int ret = Interop.WiFi.Connect(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id);
- if (ret != (int)WiFiError.None)
+ try
{
- Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret);
- WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
+ int ret = Interop.WiFi.Connect(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id);
+ if (ret != (int)WiFiError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret);
+ WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
+ }
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on ConnectAsync\n" + e.ToString());
+ task.SetException(e);
}
}, null);
context.Post((x) =>
{
- int ret = -1;
- if (info.GetType() == typeof(WpsPbcInfo))
- {
- Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPb");
- ret = Interop.WiFi.ConnectByWpsPbc(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id);
- }
- else if (info.GetType() == typeof(WpsPinInfo))
+ try
{
- WpsPinInfo pinInfo = (WpsPinInfo)info;
- if (pinInfo.GetWpsPin() == null)
+ int ret = -1;
+ if (info.GetType() == typeof(WpsPbcInfo))
{
- throw new ArgumentNullException("Wps pin should not be null");
+ Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPb");
+ ret = Interop.WiFi.ConnectByWpsPbc(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id);
}
-
- if (pinInfo.GetWpsPin().Length == 0 || pinInfo.GetWpsPin().Length > 8)
+ else if (info.GetType() == typeof(WpsPinInfo))
{
- throw new ArgumentOutOfRangeException("Wps pin should not be empty or more than 7 characters");
+ WpsPinInfo pinInfo = (WpsPinInfo)info;
+ if (pinInfo.GetWpsPin() == null)
+ {
+ throw new ArgumentNullException("Wps pin should not be null");
+ }
+
+ if (pinInfo.GetWpsPin().Length == 0 || pinInfo.GetWpsPin().Length > 8)
+ {
+ throw new ArgumentOutOfRangeException("Wps pin should not be empty or more than 7 characters");
+ }
+
+ Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPin");
+ ret = Interop.WiFi.ConnectByWpsPin(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, pinInfo.GetWpsPin(), _callback_map[id], id);
}
- Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPin");
- ret = Interop.WiFi.ConnectByWpsPin(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, pinInfo.GetWpsPin(), _callback_map[id], id);
+ if (ret != (int)WiFiError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret);
+ WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
+ }
}
-
- if (ret != (int)WiFiError.None)
+ catch (Exception e)
{
- Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret);
- WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
+ Log.Error(Globals.LogTag, "Exception on ConnectWpsAsync\n" + e.ToString());
+ task.SetException(e);
}
}, null);
s_context.Post((x) =>
{
- int ret = -1;
- if (info.GetType() == typeof(WpsPbcInfo))
+ try
{
- Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPbcWithoutSsid");
- ret = Interop.WiFi.ConnectByWpsPbcWithoutSsid(WiFiManagerImpl.Instance.GetSafeHandle(), s_callbackMap[id], id);
- }
- else if (info.GetType() == typeof(WpsPinInfo))
- {
- WpsPinInfo pinInfo = (WpsPinInfo)info;
- if (pinInfo.GetWpsPin() == null)
+ int ret = -1;
+ if (info.GetType() == typeof(WpsPbcInfo))
{
- throw new ArgumentNullException("Wps pin should not be null");
+ Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPbcWithoutSsid");
+ ret = Interop.WiFi.ConnectByWpsPbcWithoutSsid(WiFiManagerImpl.Instance.GetSafeHandle(), s_callbackMap[id], id);
}
-
- if (pinInfo.GetWpsPin().Length != 4 && pinInfo.GetWpsPin().Length != 8)
+ else if (info.GetType() == typeof(WpsPinInfo))
{
- throw new ArgumentOutOfRangeException("Wps pin should be of 4 or 8 characters long");
+ WpsPinInfo pinInfo = (WpsPinInfo)info;
+ if (pinInfo.GetWpsPin() == null)
+ {
+ throw new ArgumentNullException("Wps pin should not be null");
+ }
+
+ if (pinInfo.GetWpsPin().Length != 4 && pinInfo.GetWpsPin().Length != 8)
+ {
+ throw new ArgumentOutOfRangeException("Wps pin should be of 4 or 8 characters long");
+ }
+
+ Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPinWithoutSsid");
+ ret = Interop.WiFi.ConnectByWpsPinWithoutSsid(WiFiManagerImpl.Instance.GetSafeHandle(), pinInfo.GetWpsPin(), s_callbackMap[id], id);
}
- Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPinWithoutSsid");
- ret = Interop.WiFi.ConnectByWpsPinWithoutSsid(WiFiManagerImpl.Instance.GetSafeHandle(), pinInfo.GetWpsPin(), s_callbackMap[id], id);
+ if (ret != (int)WiFiError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret);
+ WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle());
+ }
}
-
- if (ret != (int)WiFiError.None)
+ catch (Exception e)
{
- Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret);
- WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle());
+ Log.Error(Globals.LogTag, "Exception on ConnectWpsWithoutSsidAsync\n" + e.ToString());
+ task.SetException(e);
}
}, null);
context.Post((x) =>
{
Log.Info(Globals.LogTag, "Interop.WiFi.Disconnect");
- int ret = Interop.WiFi.Disconnect(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id);
- if (ret != (int)WiFiError.None)
+ try
+ {
+ int ret = Interop.WiFi.Disconnect(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id);
+ if (ret != (int)WiFiError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to disconnect wifi, Error - " + (WiFiError)ret);
+ WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
+ }
+ }
+ catch (Exception e)
{
- Log.Error(Globals.LogTag, "Failed to disconnect wifi, Error - " + (WiFiError)ret);
- WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
+ Log.Error(Globals.LogTag, "Exception on Disconnect\n" + e.ToString());
+ task.SetException(e);
}
}, null);
context.Post((x) =>
{
Log.Info(Globals.LogTag, "Interop.WiFi.ActivateAsync");
- int ret = Interop.WiFi.Activate(GetSafeHandle(), _callback_map[id], id);
- if (ret != (int)WiFiError.None)
+ try
+ {
+ int ret = Interop.WiFi.Activate(GetSafeHandle(), _callback_map[id], id);
+ if (ret != (int)WiFiError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to activate wifi, Error - " + (WiFiError)ret);
+ WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle());
+ }
+ }
+ catch (Exception e)
{
- Log.Error(Globals.LogTag, "Failed to activate wifi, Error - " + (WiFiError)ret);
- WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle());
+ Log.Error(Globals.LogTag, "Exception on ActivateAsync\n" + e.ToString());
+ task.SetException(e);
}
}, null);
context.Post((x) =>
{
Log.Info(Globals.LogTag, "Interop.WiFi.ActivateWithWiFiPickerTestedAsync");
- int ret = Interop.WiFi.ActivateWithWiFiPickerTested(GetSafeHandle(), _callback_map[id], id);
- if (ret != (int)WiFiError.None)
+ try
{
- Log.Error(Globals.LogTag, "Failed to activate wifi, Error - " + (WiFiError)ret);
- WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle());
+ int ret = Interop.WiFi.ActivateWithWiFiPickerTested(GetSafeHandle(), _callback_map[id], id);
+ if (ret != (int)WiFiError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to activate wifi, Error - " + (WiFiError)ret);
+ WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle());
+ }
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on ActivateWithWiFiPickerTestedAsync\n" + e.ToString());
+ task.SetException(e);
}
}, null);
context.Post((x) =>
{
Log.Info(Globals.LogTag, "Interop.WiFi.Deactivate");
- int ret = Interop.WiFi.Deactivate(GetSafeHandle(), _callback_map[id], id);
- if (ret != (int)WiFiError.None)
+ try
+ {
+ int ret = Interop.WiFi.Deactivate(GetSafeHandle(), _callback_map[id], id);
+ if (ret != (int)WiFiError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to deactivate wifi, Error - " + (WiFiError)ret);
+ WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle());
+ }
+ }
+ catch (Exception e)
{
- Log.Error(Globals.LogTag, "Failed to deactivate wifi, Error - " + (WiFiError)ret);
- WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle());
+ Log.Error(Globals.LogTag, "Exception on Deactivate\n" + e.ToString());
+ task.SetException(e);
}
}, null);
context.Post((x) =>
{
Log.Info(Globals.LogTag, "Interop.WiFi.Scan");
- int ret = Interop.WiFi.Scan(GetSafeHandle(), _callback_map[id], id);
- if (ret != (int)WiFiError.None)
+ try
{
- Log.Error(Globals.LogTag, "Failed to scan all AP, Error - " + (WiFiError)ret);
- WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle());
+ int ret = Interop.WiFi.Scan(GetSafeHandle(), _callback_map[id], id);
+ if (ret != (int)WiFiError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to scan all AP, Error - " + (WiFiError)ret);
+ WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle());
+ }
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on Scan\n" + e.ToString());
+ task.SetException(e);
}
}, null);
context.Post((x) =>
{
Log.Info(Globals.LogTag, "Interop.WiFi.ScanSpecificAPAsync");
- int ret = Interop.WiFi.ScanSpecificAP(GetSafeHandle(), essid, _callback_map[id], id);
- if (ret != (int)WiFiError.None)
+ try
+ {
+ int ret = Interop.WiFi.ScanSpecificAP(GetSafeHandle(), essid, _callback_map[id], id);
+ if (ret != (int)WiFiError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to scan with specific AP, Error - " + (WiFiError)ret);
+ WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle());
+ }
+ }
+ catch (Exception e)
{
- Log.Error(Globals.LogTag, "Failed to scan with specific AP, Error - " + (WiFiError)ret);
- WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle());
+ Log.Error(Globals.LogTag, "Exception on ScanSpecificAPAsync\n" + e.ToString());
+ task.SetException(e);
}
}, null);