Fix TC fail bugs 47/111547/5 accepted/tizen/common/20170124.181820 accepted/tizen/ivi/20170124.120616 accepted/tizen/mobile/20170124.120540 accepted/tizen/tv/20170124.120557 submit/tizen/20170124.033450
authorJiwon Park <jiwony.park@samsung.com>
Sat, 21 Jan 2017 13:07:50 +0000 (22:07 +0900)
committerJiwon Park <jiwony.park@samsung.com>
Tue, 24 Jan 2017 01:54:52 +0000 (10:54 +0900)
Change-Id: I39ab6f53136ae419dd25187bf0d6289979eadf18
Signed-off-by: Jiwon Park <jiwony.park@samsung.com>
Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Client.cs
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Attributes.cs
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityClientManager.cs
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityServerManager.cs
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/RemoteResource.cs
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Resource.cs

index 842779b..2063716 100755 (executable)
@@ -85,7 +85,9 @@ internal static partial class Interop
 
                 internal enum ConnectivityType
                 {
-                    None = 0,
+                    None = -1,
+                    All,
+                    Ip,
                     Ipv4,
                     Ipv6
                 }
index 3d2bb9b..dc3cae3 100755 (executable)
@@ -796,7 +796,8 @@ namespace Tizen.Network.IoTConnectivity
                         Interop.IoTConnectivity.Common.List.ListCallback cb = (int pos, IntPtr value, IntPtr userData) =>
                         {
                             object childList = GetList(value);
-                            list.Add(childList);
+                            if (childList != null)
+                                list.Add(childList);
                             return true;
                         };
                         ret = Interop.IoTConnectivity.Common.List.ForeachList(listHandle, cb, IntPtr.Zero);
index 859f248..1cf67f2 100755 (executable)
@@ -196,6 +196,21 @@ namespace Tizen.Network.IoTConnectivity
         /// </code>
         public static void Deinitialize()
         {
+            s_presenceListenerId = 1;
+            s_presenceCallbacksMap.Clear();
+            s_presenceHandlesMap.Clear();
+
+            s_requestId = 1;
+            s_resourceFoundCallbacksMap.Clear();
+            s_deviceInformationCallbacksMap.Clear();
+            s_platformInformationCallbacksMap.Clear();
+
+            PresenceReceived = delegate{};
+            ResourceFound = delegate{};
+            PlatformInformationFound = delegate{};
+            DeviceInformationFound = delegate{};
+            FindingErrorOccurred = delegate{};
+
             Interop.IoTConnectivity.Client.IoTCon.Deinitialize();
         }
 
@@ -262,12 +277,7 @@ namespace Tizen.Network.IoTConnectivity
         /// </code>
         public static int StartReceivingPresence(string hostAddress, string resourceType)
         {
-            Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType connectivityType = RemoteResource.GetConnectivityType(hostAddress);
-            if (connectivityType == Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.None)
-            {
-                Log.Error(IoTConnectivityErrorFactory.LogTag, "Unable to parse host address");
-                throw new ArgumentException("Unable to parse host address");
-            }
+            Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType connectivityType = Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.Ip;
 
             if (resourceType != null && !ResourceTypes.IsValid(resourceType))
             {
@@ -426,12 +436,7 @@ namespace Tizen.Network.IoTConnectivity
         /// </code>
         public static int StartFindingResource(string hostAddress, ResourceQuery query = null)
         {
-            Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType connectivityType = RemoteResource.GetConnectivityType(hostAddress);
-            if (connectivityType == Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.None)
-            {
-                Log.Error(IoTConnectivityErrorFactory.LogTag, "Unable to parse host address");
-                throw new ArgumentException("Unable to parse host address");
-            }
+            Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType connectivityType = Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.Ip;
 
             IntPtr id = IntPtr.Zero;
             lock (s_resourceFoundCallbacksMap)
@@ -532,12 +537,7 @@ namespace Tizen.Network.IoTConnectivity
         /// </code>
         public static int StartFindingDeviceInformation(string hostAddress, ResourceQuery query = null)
         {
-            Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType connectivityType = RemoteResource.GetConnectivityType(hostAddress);
-            if (connectivityType == Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.None)
-            {
-                Log.Error(IoTConnectivityErrorFactory.LogTag, "Unable to parse host address");
-                throw new ArgumentException("Unable to parse host address");
-            }
+            Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType connectivityType = Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.Ip;
 
             IntPtr id = IntPtr.Zero;
             lock (s_deviceInformationCallbacksMap)
@@ -630,12 +630,7 @@ namespace Tizen.Network.IoTConnectivity
         /// </code>
         public static int StartFindingPlatformInformation(string hostAddress, ResourceQuery query = null)
         {
-            Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType connectivityType = RemoteResource.GetConnectivityType(hostAddress);
-            if (connectivityType == Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.None)
-            {
-                Log.Error(IoTConnectivityErrorFactory.LogTag, "Unable to parse host address");
-                throw new ArgumentException("Unable to parse host address");
-            }
+            Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType connectivityType = Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.Ip;
 
             IntPtr id = IntPtr.Zero;
             lock (s_platformInformationCallbacksMap)
index 2dbb05b..8af3813 100755 (executable)
@@ -15,6 +15,7 @@
  */
 
 using System;
+using System.Collections.Generic;
 
 namespace Tizen.Network.IoTConnectivity
 {
@@ -69,6 +70,7 @@ namespace Tizen.Network.IoTConnectivity
         /// </code>
         public static void Deinitialize()
         {
+            _resources.Clear();
             Interop.IoTConnectivity.Client.IoTCon.Deinitialize();
         }
 
@@ -107,6 +109,7 @@ namespace Tizen.Network.IoTConnectivity
             {
                 resource.ResourceHandle = handle;
             }
+            _resources.Add(resource);
         }
 
         /// <summary>
@@ -201,5 +204,6 @@ namespace Tizen.Network.IoTConnectivity
                 throw IoTConnectivityErrorFactory.GetException(ret);
             }
         }
+        private static List<Resource> _resources = new List<Resource>();
     }
 }
index 834ce37..30439e9 100755 (executable)
@@ -576,6 +576,8 @@ namespace Tizen.Network.IoTConnectivity
         {
             Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType type = Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.None;
 
+            Log.Info(IoTConnectivityErrorFactory.LogTag, hostAddress);
+
             if (hostAddress == IoTConnectivityClientManager.MulticastAddress)
             {
                 type = Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.Ipv4;
@@ -592,6 +594,23 @@ namespace Tizen.Network.IoTConnectivity
                         hostName = hostParts[0];
                     }
                 }
+                if (hostAddress.Contains("%"))
+                {
+                    string[] hostParts = hostAddress.Split('%');
+                    if (hostParts.Length == 2)
+                    {
+                        hostName = hostParts[0];
+                    }
+                }
+                if (hostName.Contains("["))
+                {
+                    string[] hostParts = hostName.Split('[');
+                    if (hostParts.Length == 2)
+                    {
+                        hostName = hostParts[1];
+                    }
+                }
+                Log.Info(IoTConnectivityErrorFactory.LogTag, hostName);
                 if (IPAddress.TryParse(hostName, out address))
                 {
                     switch (address.AddressFamily)
@@ -607,6 +626,10 @@ namespace Tizen.Network.IoTConnectivity
                             break;
                     }
                 }
+                else
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to parse hostname " + hostName);
+                }
             }
             return type;
         }
index 527c9e0..022c7aa 100755 (executable)
@@ -348,7 +348,7 @@ namespace Tizen.Network.IoTConnectivity
                         break;
                     }
                     default:
-                    break;
+                       break;
                 }
                 if (response == null)
                 {