From: Jiwon Park Date: Sat, 21 Jan 2017 13:07:50 +0000 (+0900) Subject: Fix TC fail bugs X-Git-Tag: submit/trunk/20170823.075128~105^2~29 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=97525f9f1c717e6d6295a813155a6145b9fef2d3;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git Fix TC fail bugs Change-Id: I39ab6f53136ae419dd25187bf0d6289979eadf18 Signed-off-by: Jiwon Park --- diff --git a/src/Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Client.cs b/src/Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Client.cs index 842779b..2063716 100755 --- a/src/Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Client.cs +++ b/src/Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Client.cs @@ -85,7 +85,9 @@ internal static partial class Interop internal enum ConnectivityType { - None = 0, + None = -1, + All, + Ip, Ipv4, Ipv6 } diff --git a/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Attributes.cs b/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Attributes.cs index 3d2bb9b..dc3cae3 100755 --- a/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Attributes.cs +++ b/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Attributes.cs @@ -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); diff --git a/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityClientManager.cs b/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityClientManager.cs index 859f248..1cf67f2 100755 --- a/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityClientManager.cs +++ b/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityClientManager.cs @@ -196,6 +196,21 @@ namespace Tizen.Network.IoTConnectivity /// 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 /// 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 /// 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 /// 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 /// 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) diff --git a/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityServerManager.cs b/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityServerManager.cs index 2dbb05b..8af3813 100755 --- a/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityServerManager.cs +++ b/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityServerManager.cs @@ -15,6 +15,7 @@ */ using System; +using System.Collections.Generic; namespace Tizen.Network.IoTConnectivity { @@ -69,6 +70,7 @@ namespace Tizen.Network.IoTConnectivity /// 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); } /// @@ -201,5 +204,6 @@ namespace Tizen.Network.IoTConnectivity throw IoTConnectivityErrorFactory.GetException(ret); } } + private static List _resources = new List(); } } diff --git a/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/RemoteResource.cs b/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/RemoteResource.cs index 834ce37..30439e9 100755 --- a/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/RemoteResource.cs +++ b/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/RemoteResource.cs @@ -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; } diff --git a/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Resource.cs b/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Resource.cs index 527c9e0..022c7aa 100755 --- a/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Resource.cs +++ b/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Resource.cs @@ -348,7 +348,7 @@ namespace Tizen.Network.IoTConnectivity break; } default: - break; + break; } if (response == null) {