[Tizen.Network.Connection] Init/deinit without ManagedThreadId (#1077)
authorchleun-moon <32117100+chleun-moon@users.noreply.github.com>
Tue, 15 Oct 2019 08:43:27 +0000 (17:43 +0900)
committerGitHub <noreply@github.com>
Tue, 15 Oct 2019 08:43:27 +0000 (17:43 +0900)
* Use connection_create/connection_destroy

* Fix parameter set

* Add log for event

src/Tizen.Network.Connection/Interop/Interop.Connection.cs
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs

index c0d4a8d..50480d3 100755 (executable)
@@ -33,11 +33,11 @@ internal static partial class Interop
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         public delegate bool IPv6AddressCallback(IntPtr ipv6, IntPtr userData);
 
-        [DllImport(Libraries.Connection, EntryPoint = "connection_create_cs")]
-        public static extern int Create(int tid, out IntPtr handle);
+        [DllImport(Libraries.Connection, EntryPoint = "connection_create")]
+        public static extern int Create(out IntPtr handle);
 
-        [DllImport(Libraries.Connection, EntryPoint = "connection_destroy_cs")]
-        public static extern int Destroy(int tid, IntPtr handle);
+        [DllImport(Libraries.Connection, EntryPoint = "connection_destroy")]
+        public static extern int Destroy(IntPtr handle);
 
         [DllImport(Libraries.Connection, EntryPoint = "connection_get_type")]
         public static extern int GetType(IntPtr handle, out int type);
index 42301a5..713d85d 100644 (file)
@@ -35,7 +35,7 @@ namespace Tizen.Network.Connection
         {
             _tid = Thread.CurrentThread.ManagedThreadId;
             Log.Info(Globals.LogTag, "PInvoke connection_create for Thread " + _tid);
-            int ret = Interop.Connection.Create(_tid, out Handle);
+            int ret = Interop.Connection.Create(out Handle);
             Log.Info(Globals.LogTag, "Handle: " + Handle);
             if(ret != (int)ConnectionError.None)
             {
@@ -60,7 +60,7 @@ namespace Tizen.Network.Connection
         {
 
             Log.Info(Globals.LogTag, "PInvoke connection_destroy for Thread " + _tid);
-            Interop.Connection.Destroy(_tid, Handle);
+            Interop.Connection.Destroy(Handle);
             if (Handle != IntPtr.Zero)
             {
                 Handle = IntPtr.Zero;
@@ -162,6 +162,7 @@ namespace Tizen.Network.Connection
             {
                 if (_ConnectionTypeChanged != null)
                 {
+                    Log.Debug(Globals.LogTag, "ConnectionTypeChanged event");
                     _ConnectionTypeChanged(null, new ConnectionTypeEventArgs(type));
                 }
             };
@@ -233,6 +234,7 @@ namespace Tizen.Network.Connection
             {
                 if (_EthernetCableStateChanged != null)
                 {
+                    Log.Debug(Globals.LogTag, "EthernetCableStateChanged event");
                     _EthernetCableStateChanged(null, new EthernetCableStateEventArgs(state));
                 }
             };
@@ -314,6 +316,7 @@ namespace Tizen.Network.Connection
 
                     if ((string.IsNullOrEmpty(ipv4) == false) || (string.IsNullOrEmpty(ipv6) == false))
                     {
+                        Log.Debug(Globals.LogTag, "IPAddressChanged event");
                         _IPAddressChanged(null, new AddressEventArgs(ipv4, ipv6));
                     }
                 }
@@ -389,6 +392,7 @@ namespace Tizen.Network.Connection
 
                     if ((string.IsNullOrEmpty(ipv4) == false) || (string.IsNullOrEmpty(ipv6) == false))
                     {
+                        Log.Debug(Globals.LogTag, "ProxyAddressChanged event");
                         _ProxyAddressChanged(null, new AddressEventArgs(ipv4, ipv6));
                     }
                 }
index a89919e..40604d2 100755 (executable)
@@ -101,6 +101,7 @@ namespace Tizen.Network.Connection
             {
                 if (_ProfileStateChanged != null)
                 {
+                    Log.Debug(Globals.LogTag, "ProfileStateChanged event");
                     _ProfileStateChanged(null, new ProfileStateEventArgs(state));
                 }
             };