From ca7b728d3b6af54d7e6583b93f2312b4b4e0789b Mon Sep 17 00:00:00 2001 From: "hyuna0213.jo" Date: Tue, 2 Aug 2016 07:51:39 +0900 Subject: [PATCH] Add RD C++ API to supporting QoS in OCPlatform - add publishResourceToRD() overload function - add deleteResourceFromRD() overload function - remove unnecessary code - add null check logic for input parameter Change-Id: Ib3ad9d196af4a1b1662a4fca0dce40e963dc78f5 Signed-off-by: hyuna0213.jo Reviewed-on: https://gerrit.iotivity.org/gerrit/9907 Reviewed-by: Jaehong Jo Tested-by: jenkins-iotivity Reviewed-by: jihwan seo Reviewed-by: Jaewook Jung Reviewed-by: Ziran Sun --- resource/include/OCPlatform.h | 35 ++++++++++++++++++++++++++++++++--- resource/include/OCPlatform_impl.h | 4 ---- resource/src/InProcServerWrapper.cpp | 2 +- resource/src/OCPlatform.cpp | 21 +++++++++++++++++++++ 4 files changed, 54 insertions(+), 8 deletions(-) diff --git a/resource/include/OCPlatform.h b/resource/include/OCPlatform.h index c6062b2..74251a6 100644 --- a/resource/include/OCPlatform.h +++ b/resource/include/OCPlatform.h @@ -679,6 +679,21 @@ namespace OC PublishResourceCallback callback); /** + * @overload + * + * @param host Host IP Address of a service to direct resource publish query. + * @param connectivityType ::OCConnectivityType type of connectivity. + * @param callback Handles callbacks, success states and failure states. + * @param QoS the quality of communication. + * + * @return Returns ::OC_STACK_OK if success. + */ + OCStackResult publishResourceToRD(const std::string& host, + OCConnectivityType connectivityType, + PublishResourceCallback callback, + QualityOfService QoS); + + /** * API for Resource Publish to Resource Directory. * @note This API applies to resource server side only. * @@ -701,7 +716,7 @@ namespace OC * @param connectivityType ::OCConnectivityType type of connectivity. * @param resourceHandle resource handle of the resource. * @param callback function to callback with published resources. - * @param QoS the quality of communication + * @param QoS the quality of communication. * @see publishResourceToRD(const std::string&, OCConnectivityType, OCResourceHandle, * uint8_t, PublishResourceCallback) */ @@ -729,9 +744,23 @@ namespace OC * * @param host Host IP Address of a service to direct resource delete query. * @param connectivityType ::OCConnectivityType type of connectivity. + * @param callback Handles callbacks, success states and failure states. + * @param QoS the quality of communication. + * + * @return Returns ::OC_STACK_OK if success. + */ + OCStackResult deleteResourceFromRD(const std::string& host, + OCConnectivityType connectivityType, + DeleteResourceCallback callback, + QualityOfService QoS); + + /** + * @overload + * + * @param host Host IP Address of a service to direct resource delete query. + * @param connectivityType ::OCConnectivityType type of connectivity. * @param resourceHandle resource handle of the resource. * @param callback function to callback with published resources. - * @param QoS the quality of communication * @see publishResourceToRD(const std::string&, OCConnectivityType, OCResourceHandle, * uint8_t, PublishResourceCallback) */ @@ -747,7 +776,7 @@ namespace OC * @param connectivityType ::OCConnectivityType type of connectivity. * @param resourceHandle resource handle of the resource. * @param callback function to callback with published resources. - * @param QoS the quality of communication + * @param QoS the quality of communication. * @see publishResourceToRD(const std::string&, OCConnectivityType, OCResourceHandle, * uint8_t, PublishResourceCallback) */ diff --git a/resource/include/OCPlatform_impl.h b/resource/include/OCPlatform_impl.h index 90e3465..49d59d9 100644 --- a/resource/include/OCPlatform_impl.h +++ b/resource/include/OCPlatform_impl.h @@ -255,10 +255,6 @@ namespace OC OCStackResult deleteResourceFromRD(const std::string& host, OCConnectivityType connectivityType, - DeleteResourceCallback callback); - - OCStackResult deleteResourceFromRD(const std::string& host, - OCConnectivityType connectivityType, ResourceHandles& resourceHandles, DeleteResourceCallback callback); diff --git a/resource/src/InProcServerWrapper.cpp b/resource/src/InProcServerWrapper.cpp index bd7639d..3d0ad0a 100644 --- a/resource/src/InProcServerWrapper.cpp +++ b/resource/src/InProcServerWrapper.cpp @@ -602,7 +602,7 @@ namespace OC #ifdef RD_CLIENT OCRepresentation parseRDResponseCallback(OCClientResponse* clientResponse) { - if (nullptr == clientResponse->payload || + if (nullptr == clientResponse || nullptr == clientResponse->payload || PAYLOAD_TYPE_RD != clientResponse->payload->type) { return OCRepresentation(); diff --git a/resource/src/OCPlatform.cpp b/resource/src/OCPlatform.cpp index 5369440..4ab35a8 100644 --- a/resource/src/OCPlatform.cpp +++ b/resource/src/OCPlatform.cpp @@ -326,6 +326,17 @@ namespace OC OCStackResult publishResourceToRD(const std::string& host, OCConnectivityType connectivityType, + PublishResourceCallback callback, + QualityOfService QoS) + { + ResourceHandles resourceHandles; + return OCPlatform_impl::Instance().publishResourceToRD(host, connectivityType, + resourceHandles, + callback, QoS); + } + + OCStackResult publishResourceToRD(const std::string& host, + OCConnectivityType connectivityType, ResourceHandles& resourceHandles, PublishResourceCallback callback) { @@ -355,6 +366,16 @@ namespace OC OCStackResult deleteResourceFromRD(const std::string& host, OCConnectivityType connectivityType, + DeleteResourceCallback callback, + QualityOfService QoS) + { + ResourceHandles resourceHandles; + return OCPlatform_impl::Instance().deleteResourceFromRD(host, connectivityType, + resourceHandles, callback, QoS); + } + + OCStackResult deleteResourceFromRD(const std::string& host, + OCConnectivityType connectivityType, ResourceHandles& resourceHandles, DeleteResourceCallback callback) { -- 2.7.4