From 5540efb645ae3e02d10444cc788c19268539bd2c Mon Sep 17 00:00:00 2001 From: Youngjae Shin Date: Fri, 26 Aug 2016 10:19:50 +0900 Subject: [PATCH] apply iotcon changes Change-Id: I6f340877151dfddd47a568f453eafd3a4b05e42f --- .../Interop/Interop.IoTConnectivity.Client.cs | 6 ++--- .../IoTConnectivityClientManager.cs | 31 +++++++++++----------- .../Tizen.Network.IoTConnectivity/ResponseCode.cs | 4 +++ 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Client.cs b/src/Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Client.cs index 92d095d..e31ea00 100644 --- a/src/Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Client.cs +++ b/src/Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Client.cs @@ -28,7 +28,7 @@ internal static partial class Interop } [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_find_device_info")] - internal static extern int Find(string hostAddress, int connectivityType, DeviceInformationCallback cb, IntPtr userData); + internal static extern int Find(string hostAddress, int connectivityType, IntPtr query, DeviceInformationCallback cb, IntPtr userData); [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_device_info_get_property")] internal static extern int GetProperty(IntPtr deviceInfoHandle, int property, out IntPtr value); @@ -54,7 +54,7 @@ internal static partial class Interop } [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_find_platform_info")] - internal static extern int Find(string hostAddress, int connectivityType, PlatformInformationCallback cb, IntPtr userData); + internal static extern int Find(string hostAddress, int connectivityType, IntPtr query, PlatformInformationCallback cb, IntPtr userData); [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_platform_info_get_property")] internal static extern int GetProperty(IntPtr platformInfoHandle, int property, out IntPtr value); @@ -190,7 +190,7 @@ internal static partial class Interop internal delegate bool FoundResourceCallback(IntPtr remoteResourceHandle, int result, IntPtr userData); [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_find_resource")] - internal static extern int AddResourceFoundCb(string hostAddress, int connectivityType, string resourceType, bool isSecure, FoundResourceCallback cb, IntPtr userData); + internal static extern int AddResourceFoundCb(string hostAddress, int connectivityType, IntPtr query, FoundResourceCallback cb, IntPtr userData); } internal static partial class Presence diff --git a/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityClientManager.cs b/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityClientManager.cs index dfe1079..f54742b 100644 --- a/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityClientManager.cs +++ b/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityClientManager.cs @@ -392,9 +392,8 @@ namespace Tizen.Network.IoTConnectivity /// /// http://tizen.org/privilege/internet /// - /// The address or addressable name of the server - /// A resource type specified as a filter for the resource - /// The flag for secure communication with the server + /// The address or addressable name of the server. The address includes a protocol like coaps:// + /// The query specified as a filter for founding resources /// RequestId - An identifier for this request ///
Initialize() should be called to initialize.
/// @@ -412,10 +411,12 @@ namespace Tizen.Network.IoTConnectivity /// } /// IoTConnectivityClientManager.ResourceFound += handler; /// IoTConnectivityClientManager.FindingErrorOccurred += errorHandler; + /// ResourceQuery query = new ResourceQuery(); + /// query.Type = "oic.iot.door"; /// // Do not forget to remove these event handlers when they are not required any more. - /// int id = IoTConnectivityClientManager.StartFindingResource(null, "oic.iot.door"); + /// int id = IoTConnectivityClientManager.StartFindingResource(null, query); /// - public static int StartFindingResource(string hostAddress, string resourceType, bool isSecure = false) + 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) @@ -424,11 +425,6 @@ namespace Tizen.Network.IoTConnectivity throw new ArgumentException("Unable to parse host address"); } - if (resourceType != null && !ResourceTypes.IsValid(resourceType)) - { - Log.Error(IoTConnectivityErrorFactory.LogTag, "Invalid type"); - throw new ArgumentException("Invalid type"); - } IntPtr id = IntPtr.Zero; lock (s_resourceFoundCallbacksMap) { @@ -478,7 +474,8 @@ namespace Tizen.Network.IoTConnectivity } return true; }; - int errorCode = Interop.IoTConnectivity.Client.ResourceFinder.AddResourceFoundCb(hostAddress, (int)connectivityType, resourceType, isSecure, s_resourceFoundCallbacksMap[id], id); + IntPtr queryHandle = (query == null) ? IntPtr.Zero : query._resourceQueryHandle; + int errorCode = Interop.IoTConnectivity.Client.ResourceFinder.AddResourceFoundCb(hostAddress, (int)connectivityType, queryHandle, s_resourceFoundCallbacksMap[id], id); if (errorCode != (int)IoTConnectivityError.None) { Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to register resource found event handler"); @@ -503,6 +500,7 @@ namespace Tizen.Network.IoTConnectivity /// http://tizen.org/privilege/internet /// /// The host address of remote server + /// The query specified as a filter for founding resources /// RequestId - An identifier for this request ///
Initialize() should be called to initialize.
/// @@ -524,7 +522,7 @@ namespace Tizen.Network.IoTConnectivity /// // Do not forget to remove these event handlers when they are not required any more. /// int id = IoTConnectivityClientManager.StartFindingDeviceInformation(IoTConnectivityClientManager.MulticastAddress); /// - public static int StartFindingDeviceInformation(string hostAddress) + 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) @@ -574,7 +572,8 @@ namespace Tizen.Network.IoTConnectivity return true; }; - int errorCode = Interop.IoTConnectivity.Client.DeviceInformation.Find(hostAddress, (int)connectivityType, s_deviceInformationCallbacksMap[id], id); + IntPtr queryHandle = (query == null) ? IntPtr.Zero : query._resourceQueryHandle; + int errorCode = Interop.IoTConnectivity.Client.DeviceInformation.Find(hostAddress, (int)connectivityType, queryHandle, s_deviceInformationCallbacksMap[id], id); if (errorCode != (int)IoTConnectivityError.None) { Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get device information"); @@ -600,6 +599,7 @@ namespace Tizen.Network.IoTConnectivity /// http://tizen.org/privilege/internet /// /// The host address of remote server + /// The query specified as a filter for founding resources /// RequestId - An identifier for this request ///
Initialize() should be called to initialize.
/// @@ -620,7 +620,7 @@ namespace Tizen.Network.IoTConnectivity /// // Do not forget to remove these event handlers when they are not required any more. /// int id = IoTConnectivityClientManager.StartFindingPlatformInformation(IoTConnectivityClientManager.MulticastAddress); /// - public static int StartFindingPlatformInformation(string hostAddress) + 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) @@ -670,7 +670,8 @@ namespace Tizen.Network.IoTConnectivity return true; }; - int errorCode = Interop.IoTConnectivity.Client.PlatformInformation.Find(hostAddress, (int)connectivityType, s_platformInformationCallbacksMap[id], id); + IntPtr queryHandle = (query == null) ? IntPtr.Zero : query._resourceQueryHandle; + int errorCode = Interop.IoTConnectivity.Client.PlatformInformation.Find(hostAddress, (int)connectivityType, queryHandle, s_platformInformationCallbacksMap[id], id); if (errorCode != (int)IoTConnectivityError.None) { Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get platform information"); diff --git a/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResponseCode.cs b/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResponseCode.cs index 02f21e2..eb2fbba 100644 --- a/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResponseCode.cs +++ b/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResponseCode.cs @@ -30,6 +30,10 @@ namespace Tizen.Network.IoTConnectivity /// Deleted, /// + /// Indicates result of response for changed resource + /// + Changed, + /// /// Indicates result of response for slow resource /// Slow, -- 2.7.4