Version up : 1.0.2 to 1.0.3
authorJihoon Jung <jh8801.jung@samsung.com>
Mon, 9 Jan 2017 08:35:55 +0000 (17:35 +0900)
committerJihoon Jung <jh8801.jung@samsung.com>
Mon, 9 Jan 2017 08:39:15 +0000 (17:39 +0900)
Change-Id: I0400831aaa992de1c3b52b701b5422d13716cdee

packaging/csapi-network-nfc.spec
src/Tizen.Network.Nfc/Tizen.Network.Nfc.project.json [changed mode: 0644->0755]
src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManager.cs [changed mode: 0644->0755]
src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefMessage.cs [changed mode: 0644->0755]
src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefRecord.cs
src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcP2p.cs [changed mode: 0644->0755]
src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcP2pAdapter.cs [changed mode: 0644->0755]
src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcTagAdapter.cs [changed mode: 0644->0755]

index 1a00bc7..3c27369 100644 (file)
@@ -8,7 +8,7 @@
 
 Name:       csapi-network-nfc
 Summary:    Tizen Nfc API for C#
-Version:    1.0.2
+Version:    1.0.3
 Release:    1
 Group:      Development/Libraries
 License:    Apache-2.0
old mode 100644 (file)
new mode 100755 (executable)
index a4c6be0..303764a
@@ -1,7 +1,8 @@
-{
+{
   "dependencies": {
     "NETStandard.Library": "1.6.0",
-    "Tizen": "1.0.2"
+    "Tizen": "1.0.2",
+    "Tizen.System": "1.0.5"
   },
   "frameworks": {
     "netstandard1.3": {}
old mode 100644 (file)
new mode 100755 (executable)
index b743fb5..e0a82a2
@@ -17,6 +17,7 @@
 using System;
 using System.Collections.Generic;
 using System.Threading.Tasks;
+using Tizen.System;
 
 namespace Tizen.Network.Nfc
 {
@@ -33,6 +34,13 @@ namespace Tizen.Network.Nfc
         {
             get
             {
+                bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+                if (!isNfcSupported)
+                {
+                    return false;
+                }
+
                 try
                 {
                     return NfcManagerImpl.Instance.IsSupported;
@@ -51,6 +59,13 @@ namespace Tizen.Network.Nfc
         {
             get
             {
+                bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+                if (!isNfcSupported)
+                {
+                    return false;
+                }
+
                 try
                 {
                     return NfcManagerImpl.Instance.IsActivated;
@@ -69,6 +84,14 @@ namespace Tizen.Network.Nfc
         {
             get
             {
+                bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+                bool isTagSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc.tag", out isTagSupported);
+
+                if (!isNfcSupported || !isTagSupported)
+                {
+                    return NfcTagFilterType.AllDisable;
+                }
+
                 try
                 {
                     return NfcManagerImpl.Instance.TagFilterType;
@@ -80,12 +103,21 @@ namespace Tizen.Network.Nfc
             }
             set
             {
+                bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+                bool isTagSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc.tag", out isTagSupported);
+
+                if (!isNfcSupported || !isTagSupported)
+                {
+                    return;
+                }
+
                 try
                 {
                     NfcManagerImpl.Instance.TagFilterType = value;
                 }
                 catch (TypeInitializationException)
                 {
+                    return;
                 }
             }
         }
@@ -97,6 +129,14 @@ namespace Tizen.Network.Nfc
         {
             get
             {
+                bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+                bool isCeSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc.cardemulation", out isCeSupported);
+
+                if (!isNfcSupported || !isCeSupported)
+                {
+                    return NfcSecureElementType.Disable;
+                }
+
                 try
                 {
                     return NfcManagerImpl.Instance.SecureElementType;
@@ -125,6 +165,13 @@ namespace Tizen.Network.Nfc
         {
             get
             {
+                bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+                if (!isNfcSupported)
+                {
+                    return false;
+                }
+
                 try
                 {
                     return NfcManagerImpl.Instance.SystemHandlerEnabled;
@@ -136,12 +183,20 @@ namespace Tizen.Network.Nfc
             }
             set
             {
+                bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+                if (!isNfcSupported)
+                {
+                    return;
+                }
+
                 try
                 {
                     NfcManagerImpl.Instance.SystemHandlerEnabled = value;
                 }
                 catch (TypeInitializationException)
                 {
+                    return;
                 }
             }
         }
@@ -153,6 +208,13 @@ namespace Tizen.Network.Nfc
         {
             get
             {
+                bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+                if (!isNfcSupported)
+                {
+                    return null;
+                }
+
                 try
                 {
                     return NfcManagerImpl.Instance.CachedNdefMessage;
@@ -169,6 +231,14 @@ namespace Tizen.Network.Nfc
         /// </summary>
         static public NfcTagAdapter GetTagAdapter()
         {
+            bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+            bool isTagSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc.tag", out isTagSupported);
+
+            if (!isNfcSupported || !isTagSupported)
+            {
+                throw new NotSupportedException();
+            }
+
             try
             {
                 return NfcManagerImpl.Instance.TagAdapter;
@@ -184,6 +254,14 @@ namespace Tizen.Network.Nfc
         /// </summary>
         static public NfcP2pAdapter GetP2pAdapter()
         {
+            bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+            bool isP2pSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc.p2p", out isP2pSupported);
+
+            if (!isNfcSupported || !isP2pSupported)
+            {
+                throw new NotSupportedException();
+            }
+
             try
             {
                 return NfcManagerImpl.Instance.P2pAdapter;
@@ -199,6 +277,14 @@ namespace Tizen.Network.Nfc
         /// </summary>
         static public NfcCardEmulationAdapter GetCardEmulationAdapter()
         {
+            bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+            bool isCeSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc.cardemulation", out isCeSupported);
+
+            if (!isNfcSupported || !isCeSupported)
+            {
+                throw new NotSupportedException();
+            }
+
             try
             {
                 return NfcManagerImpl.Instance.CardEmulationAdapter;
@@ -215,6 +301,13 @@ namespace Tizen.Network.Nfc
         /// <returns>A task indicates whether the Activate method is done or not.</returns>
         static public Task SetActivateAsync(bool activation)
         {
+            bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+            if (!isNfcSupported)
+            {
+                throw new NotSupportedException();
+            }
+
             try
             {
                 return NfcManagerImpl.Instance.SetActivateAsync(activation);
@@ -232,6 +325,13 @@ namespace Tizen.Network.Nfc
         {
             add
             {
+                bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+                if (!isNfcSupported)
+                {
+                    throw new NotSupportedException();
+                }
+
                 try
                 {
                     NfcManagerImpl.Instance.ActivationChanged += value;
@@ -243,6 +343,13 @@ namespace Tizen.Network.Nfc
             }
             remove
             {
+                bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+                if (!isNfcSupported)
+                {
+                    throw new NotSupportedException();
+                }
+
                 try
                 {
                     NfcManagerImpl.Instance.ActivationChanged -= value;
@@ -261,6 +368,13 @@ namespace Tizen.Network.Nfc
         {
             add
             {
+                bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+                if (!isNfcSupported)
+                {
+                    throw new NotSupportedException();
+                }
+
                 try
                 {
                     NfcManagerImpl.Instance.NdefMessageDiscovered += value;
@@ -272,6 +386,13 @@ namespace Tizen.Network.Nfc
             }
             remove
             {
+                bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+                if (!isNfcSupported)
+                {
+                    throw new NotSupportedException();
+                }
+
                 try
                 {
                     NfcManagerImpl.Instance.NdefMessageDiscovered -= value;
old mode 100644 (file)
new mode 100755 (executable)
index 727a097..0e22636
@@ -67,13 +67,6 @@ namespace Tizen.Network.Nfc
 
         ~NfcNdefMessage()
         {
-            int ret = Interop.Nfc.NdefMessage.Destroy(_messageHandle);
-
-            if (ret != (int)NfcError.None)
-            {
-                Log.Error(Globals.LogTag, "Failed to destroy ndef message, Error - " + (NfcError)ret);
-            }
-
             Dispose(false);
         }
 
@@ -91,6 +84,12 @@ namespace Tizen.Network.Nfc
             if (disposing)
             {
                 // Free managed objects.
+                int ret = Interop.Nfc.NdefMessage.Destroy(_messageHandle);
+
+                if (ret != (int)NfcError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to destroy ndef message, Error - " + (NfcError)ret);
+                }
             }
             //Free unmanaged objects
             disposed = true;
index 33e822e..ca755f6 100755 (executable)
@@ -285,12 +285,12 @@ namespace Tizen.Network.Nfc
             if (disposing)
             {
                 // Free managed objects.
-                int ret = Interop.Nfc.NdefRecord.Destroy(_recordHandle);\r
-\r
-                if (ret != (int)NfcError.None)\r
-                {\r
-                    Log.Error(Globals.LogTag, "Failed to destroy ndef record, Error - " + (NfcError)ret);\r
-                }\r
+                int ret = Interop.Nfc.NdefRecord.Destroy(_recordHandle);
+
+                if (ret != (int)NfcError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to destroy ndef record, Error - " + (NfcError)ret);
+                }
             }
             //Free unmanaged objects
             disposed = true;
old mode 100644 (file)
new mode 100755 (executable)
index fd85440..1010d81
@@ -40,25 +40,18 @@ namespace Tizen.Network.Nfc
         {
             add
             {
-                if (_p2pDataReceived == null)
-                {
-                    RegisterP2pDataReceivedEvent();
-                }
                 _p2pDataReceived += value;
             }
             remove
             {
                 _p2pDataReceived -= value;
-                if (_p2pDataReceived == null)
-                {
-                    UnregisterP2pDataReceivedEvent();
-                }
             }
         }
 
         internal NfcP2p(IntPtr handle)
         {
             _p2pTargetHandle = handle;
+            RegisterP2pDataReceivedEvent();
         }
 
         ~NfcP2p()
@@ -80,6 +73,7 @@ namespace Tizen.Network.Nfc
             if (disposing)
             {
                 // Free managed objects.
+                UnregisterP2pDataReceivedEvent();
             }
             //Free unmanaged objects
             disposed = true;
old mode 100644 (file)
new mode 100755 (executable)
index 25af7d4..646f178
@@ -40,24 +40,17 @@ namespace Tizen.Network.Nfc
         {
             add
             {
-                if (_p2pTargetDiscovered == null)
-                {
-                    RegisterP2pTargetDiscoveredEvent();
-                }
                 _p2pTargetDiscovered += value;
             }
             remove
             {
                 _p2pTargetDiscovered -= value;
-                if (_p2pTargetDiscovered == null)
-                {
-                    UnregisterP2pTargetDiscoveredEvent();
-                }
             }
         }
 
         internal NfcP2pAdapter()
         {
+            RegisterP2pTargetDiscoveredEvent();
         }
 
         ~NfcP2pAdapter()
@@ -79,6 +72,7 @@ namespace Tizen.Network.Nfc
             if (disposing)
             {
                 // Free managed objects.
+                UnregisterP2pTargetDiscoveredEvent();
             }
             //Free unmanaged objects
             disposed = true;
old mode 100644 (file)
new mode 100755 (executable)
index 815b75f..97532b5
@@ -40,24 +40,17 @@ namespace Tizen.Network.Nfc
         {
             add
             {
-                if (_tagDiscovered == null)
-                {
-                    RegisterTagDiscoveredEvent();
-                }
                 _tagDiscovered += value;
             }
             remove
             {
                 _tagDiscovered -= value;
-                if (_tagDiscovered == null)
-                {
-                    UnregisterTagDiscoveredEvent();
-                }
             }
         }
 
         internal NfcTagAdapter()
         {
+            RegisterTagDiscoveredEvent();
         }
 
         ~NfcTagAdapter()
@@ -79,6 +72,7 @@ namespace Tizen.Network.Nfc
             if (disposing)
             {
                 // Free managed objects.
+                UnregisterTagDiscoveredEvent();
             }
             //Free unmanaged objects
             disposed = true;