[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate bool IPv6AddressCallback(IntPtr ipv6, IntPtr userData);
- [DllImport(Libraries.Connection, EntryPoint = "connection_create")]
- public static extern int Create(out IntPtr handle);
+ [DllImport(Libraries.Connection, EntryPoint = "connection_create_cs")]
+ public static extern int Create(int tid, out IntPtr handle);
- [DllImport(Libraries.Connection, EntryPoint = "connection_destroy")]
- public static extern int Destroy(IntPtr handle);
+ [DllImport(Libraries.Connection, EntryPoint = "connection_destroy_cs")]
+ public static extern int Destroy(int tid, IntPtr handle);
[DllImport(Libraries.Connection, EntryPoint = "connection_get_type")]
public static extern int GetType(IntPtr handle, out int type);
namespace Tizen.Network.Connection
{
- class HandleHolder : IDisposable
+ class HandleHolder
{
private IntPtr Handle;
- private bool disposed = false;
+ private int tid;
public HandleHolder()
{
- Log.Debug(Globals.LogTag, "Handle: " + Handle);
- int ret = Interop.Connection.Create(out Handle);
+ tid = Thread.CurrentThread.ManagedThreadId;
+ Log.Info(Globals.LogTag, "PInvoke connection_destroy for Thread " + tid);
+ int ret = Interop.Connection.Create(tid, out Handle);
+ Log.Info(Globals.LogTag, "Handle: " + 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");
~HandleHolder()
{
- Dispose(false);
+ Destroy();
}
internal IntPtr GetHandle()
Log.Debug(Globals.LogTag, "handleholder handle = " + Handle);
return Handle;
}
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
- Log.Debug(Globals.LogTag, ">>> HandleHolder Dispose with " + disposing);
- Log.Debug(Globals.LogTag, ">>> Handle: " + Handle);
- if (disposed)
- return;
-
- if (disposing)
- {
- // Free managed objects.
- Destroy();
- }
- disposed = true;
- }
private void Destroy()
{
- Interop.Connection.Destroy(Handle);
+ Log.Info(Globals.LogTag, "PInvoke connection_destroy for Thread " + tid);
+ Interop.Connection.Destroy(tid, Handle);
if (Handle != IntPtr.Zero)
{
Handle = IntPtr.Zero;
internal class ConnectionInternalManager
{
- private bool disposed = false;
private static readonly Lazy<ConnectionInternalManager> s_instance =
new Lazy<ConnectionInternalManager>(() => new ConnectionInternalManager());
~ConnectionInternalManager()
{
- Dispose(false);
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
- Log.Debug(Globals.LogTag, ">>> ConnectionInternalManager Dispose with disposing " + disposing + ", disposed " + disposed);
- Log.Debug(Globals.LogTag, ">>> Handle: " + GetHandle());
- if (disposed)
- return;
-
- if (disposing)
- {
- // Free managed objects.
- }
-
- UnregisterEvents();
- disposed = true;
}
internal IntPtr GetHandle()
internal System.Net.IPAddress GetIPAddress(AddressFamily family)
{
- Log.Debug(Globals.LogTag, "GetIPAddress " + family);
+ Log.Info(Globals.LogTag, "GetIPAddress " + family);
IntPtr ip;
int ret = Interop.Connection.GetIPAddress(GetHandle(), (int)family, out ip);
if ((ConnectionError)ret != ConnectionError.None)
string result = Marshal.PtrToStringAnsi(ip);
Interop.Libc.Free(ip);
- Log.Debug(Globals.LogTag, "IPAddress " + result + " (" + result.Length + ")");
+ Log.Info(Globals.LogTag, "IPAddress " + result + " (" + result.Length + ")");
if (result.Length == 0)
{
if (family == AddressFamily.IPv4)
internal string GetMacAddress(ConnectionType type)
{
- Log.Debug(Globals.LogTag, "GetMacAddress " + type);
+ Log.Info(Globals.LogTag, "GetMacAddress " + type);
IntPtr mac;
int ret = Interop.Connection.GetMacAddress(GetHandle(), (int)type, out mac);
if ((ConnectionError)ret != ConnectionError.None)
{
get
{
- Log.Debug(Globals.LogTag, "get ConnectionType");
+ Log.Info(Globals.LogTag, "get ConnectionType");
int type = 0;
int ret = Interop.Connection.GetType(GetHandle(), out type);
if ((ConnectionError)ret != ConnectionError.None)
{
get
{
- Log.Debug(Globals.LogTag, "get CellularState");
+ Log.Info(Globals.LogTag, "get CellularState");
int type = 0;
int ret = Interop.Connection.GetCellularState(GetHandle(), out type);
if ((ConnectionError)ret != ConnectionError.None)
{
get
{
- Log.Debug(Globals.LogTag, "get WiFiState");
+ Log.Info(Globals.LogTag, "get WiFiState");
int type = 0;
int ret = Interop.Connection.GetWiFiState(GetHandle(), out type);
if ((ConnectionError)ret != ConnectionError.None)
{
get
{
- Log.Debug(Globals.LogTag, "get BluetoothState");
+ Log.Info(Globals.LogTag, "get BluetoothState");
int type = 0;
int ret = Interop.Connection.GetBtState(GetHandle(), out type);
if ((ConnectionError)ret != ConnectionError.None)
{
get
{
- Log.Debug(Globals.LogTag, "get ConnectionType");
+ Log.Info(Globals.LogTag, "get ConnectionType");
int type = 0;
int ret = Interop.Connection.GetEthernetState(GetHandle(), out type);
if ((ConnectionError)ret != ConnectionError.None)
{
get
{
- Log.Debug(Globals.LogTag, "get EthernetCableState");
+ Log.Info(Globals.LogTag, "get EthernetCableState");
int type = 0;
int ret = Interop.Connection.GetEthernetCableState(GetHandle(), out type);
if ((ConnectionError)ret != ConnectionError.None)
internal void UpdateProfile(ConnectionProfile profile)
{
- Log.Debug(Globals.LogTag, "UpdateProfile");
+ Log.Info(Globals.LogTag, "UpdateProfile");
if (profile != null)
{
int ret = Interop.Connection.UpdateProfile(GetHandle(), profile.ProfileHandle);
internal ConnectionProfile GetCurrentProfile()
{
- Log.Debug(Globals.LogTag, "GetCurrentProfile");
+ Log.Info(Globals.LogTag, "GetCurrentProfile");
IntPtr ProfileHandle;
int ret = Interop.Connection.GetCurrentProfile(GetHandle(), out ProfileHandle);
if ((ConnectionError)ret != ConnectionError.None)
internal delegate void RssiLevelChangedCallback(int level, IntPtr userData);
//capi-network-wifi-1.0.65-19.23.armv7l
- [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_initialize")]
- internal static extern int Initialize(out SafeWiFiManagerHandle wifi);
- [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_deinitialize")]
- internal static extern int Deinitialize(IntPtr wifi);
+ [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_initialize_cs")]
+ internal static extern int Initialize(int tid, out SafeWiFiManagerHandle wifi);
+ [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_deinitialize_cs")]
+ internal static extern int Deinitialize(int tid, IntPtr wifi);
////Wi-Fi Manager
[DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_activate")]
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class SafeWiFiManagerHandle : SafeHandle
{
+ private int tid;
+
internal SafeWiFiManagerHandle() : base(IntPtr.Zero, true)
{
}
/// </summary>
protected override bool ReleaseHandle()
{
- Interop.WiFi.Deinitialize(this.handle);
+ Interop.WiFi.Deinitialize(tid, this.handle);
this.SetHandle(IntPtr.Zero);
return true;
}
+
+ internal int TID
+ {
+ set
+ {
+ tid = value;
+ Log.Info(Globals.LogTag, "New Handle for Thread " + tid);
+ }
+ }
}
/// <summary>
internal HandleHolder()
{
_handle = WiFiManagerImpl.Instance.Initialize();
- Log.Debug(Globals.LogTag, "Handle: " + _handle);
+ Log.Info(Globals.LogTag, "Handle: " + _handle);
}
internal SafeWiFiManagerHandle GetSafeHandle()
internal SafeWiFiManagerHandle Initialize()
{
SafeWiFiManagerHandle handle;
- int ret = Interop.WiFi.Initialize(out handle);
+ int tid = Thread.CurrentThread.ManagedThreadId;
+ Log.Info(Globals.LogTag, "PInvoke wifi_manager_initialize");
+ int ret = Interop.WiFi.Initialize(tid, out handle);
if (ret != (int)WiFiError.None)
{
Log.Error(Globals.LogTag, "Failed to initialize wifi, Error - " + (WiFiError)ret);
WiFiErrorFactory.ThrowWiFiException(ret, "http://tizen.org/privilege/network.get");
}
+ handle.TID = tid;
return handle;
}
internal IEnumerable<WiFiAP> GetFoundAPs()
{
- Log.Debug(Globals.LogTag, "GetFoundAPs");
+ Log.Info(Globals.LogTag, "GetFoundAPs");
List<WiFiAP> apList = new List<WiFiAP>();
Interop.WiFi.HandleCallback callback = (IntPtr apHandle, IntPtr userData) =>
{
internal IEnumerable<WiFiAP> GetFoundSpecificAPs()
{
- Log.Debug(Globals.LogTag, "GetFoundSpecificAPs");
+ Log.Info(Globals.LogTag, "GetFoundSpecificAPs");
List<WiFiAP> apList = new List<WiFiAP>();
Interop.WiFi.HandleCallback callback = (IntPtr apHandle, IntPtr userData) =>
{
internal WiFiAP GetConnectedAP()
{
- Log.Debug(Globals.LogTag, "GetConnectedAP");
+ Log.Info(Globals.LogTag, "GetConnectedAP");
IntPtr apHandle;
int ret = Interop.WiFi.GetConnectedAP(GetSafeHandle(), out apHandle);
if (ret != (int)WiFiError.None)
internal Task ActivateAsync()
{
- Log.Debug(Globals.LogTag, "ActivateAsync");
+ Log.Info(Globals.LogTag, "ActivateAsync");
TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
IntPtr id;
lock (_callback_map)
id = (IntPtr)_requestId++;
_callback_map[id] = (error, key) =>
{
- Log.Debug(Globals.LogTag, "wifi activated");
+ Log.Info(Globals.LogTag, "wifi activated");
if (error != (int)WiFiError.None)
{
Log.Error(Globals.LogTag, "Error occurs during WiFi activating, " + (WiFiError)error);
internal Task DeactivateAsync()
{
- Log.Debug(Globals.LogTag, "DeactivateAsync");
+ Log.Info(Globals.LogTag, "DeactivateAsync");
TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
IntPtr id;
lock (_callback_map)
id = (IntPtr)_requestId++;
_callback_map[id] = (error, key) =>
{
- Log.Debug(Globals.LogTag, "Deactivation finished");
+ Log.Info(Globals.LogTag, "Deactivation finished");
if (error != (int)WiFiError.None)
{
Log.Error(Globals.LogTag, "Error occurs during WiFi deactivating, " + (WiFiError)error);
internal Task ScanAsync()
{
- Log.Debug(Globals.LogTag, "ScanAsync");
+ Log.Info(Globals.LogTag, "ScanAsync");
TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
IntPtr id;
lock (_callback_map)
id = (IntPtr)_requestId++;
_callback_map[id] = (error, key) =>
{
- Log.Debug(Globals.LogTag, "Scanning finished");
+ Log.Info(Globals.LogTag, "Scanning finished");
if (error != (int)WiFiError.None)
{
Log.Error(Globals.LogTag, "Error occurs during WiFi scanning, " + (WiFiError)error);
internal Task ScanSpecificAPAsync(string essid)
{
- Log.Debug(Globals.LogTag, "ScanSpecificAPAsync " + essid);
+ Log.Info(Globals.LogTag, "ScanSpecificAPAsync " + essid);
TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
IntPtr id;
lock (_callback_map)
id = (IntPtr)_requestId++;
_callback_map[id] = (error, key) =>
{
- Log.Debug(Globals.LogTag, "Scanning with specific AP finished");
+ Log.Info(Globals.LogTag, "Scanning with specific AP finished");
if (error != (int)WiFiError.None)
{
Log.Error(Globals.LogTag, "Error occurs during WiFi scanning, " + (WiFiError)error);