From b15643413083b95ed08c706a3fe1d8a83600ee83 Mon Sep 17 00:00:00 2001 From: Jaehong Jo Date: Tue, 2 Aug 2016 11:44:53 +0900 Subject: [PATCH] Change APIs for Subscribe device presence. Application developers have to pass devices id instead of the list of queries. It will make them more convenient. As-Is const QueryParamsList& queryParams To-Be const std::vector& di Change-Id: I2c8231a58425227333c2a9c672c086409e2e51be Signed-off-by: Jaehong Jo Reviewed-on: https://gerrit.iotivity.org/gerrit/9917 Tested-by: jenkins-iotivity Reviewed-by: jihwan seo Reviewed-by: Eunok Shin Reviewed-by: Hyuna Jo Reviewed-by: Jon A. Cruz --- resource/include/IClientWrapper.h | 2 +- resource/include/InProcClientWrapper.h | 2 +- resource/include/OCPlatform.h | 6 ++++-- resource/include/OCPlatform_impl.h | 2 +- resource/include/OutOfProcClientWrapper.h | 2 +- resource/src/InProcClientWrapper.cpp | 3 ++- resource/src/OCPlatform.cpp | 4 ++-- resource/src/OCPlatform_impl.cpp | 4 ++-- resource/unittests/OCPlatformTest.cpp | 18 +++++++++--------- 9 files changed, 23 insertions(+), 20 deletions(-) diff --git a/resource/include/IClientWrapper.h b/resource/include/IClientWrapper.h index e560219..2a958f5 100644 --- a/resource/include/IClientWrapper.h +++ b/resource/include/IClientWrapper.h @@ -112,7 +112,7 @@ namespace OC #ifdef WITH_CLOUD virtual OCStackResult SubscribeDevicePresence(OCDoHandle* handle, const std::string& host, - const QueryParamsList& queryParams, + const std::vector& di, OCConnectivityType connectivityType, ObserveCallback& callback) = 0; #endif diff --git a/resource/include/InProcClientWrapper.h b/resource/include/InProcClientWrapper.h index 0cd2df4..2c90c90 100644 --- a/resource/include/InProcClientWrapper.h +++ b/resource/include/InProcClientWrapper.h @@ -182,7 +182,7 @@ namespace OC #ifdef WITH_CLOUD virtual OCStackResult SubscribeDevicePresence(OCDoHandle* handle, const std::string& host, - const QueryParamsList& queryParams, + const std::vector& di, OCConnectivityType connectivityType, ObserveCallback& callback); #endif diff --git a/resource/include/OCPlatform.h b/resource/include/OCPlatform.h index 768f5f1..c6062b2 100644 --- a/resource/include/OCPlatform.h +++ b/resource/include/OCPlatform.h @@ -543,7 +543,9 @@ namespace OC * It will be set upon successful return of this method. * @param host The IP address/addressable name of the server to subscribe to. * This should be in the format coap://address:port - * @param queryParams map which can have the query parameter name and list of value. + * @param di Vector which can have the devices id. + * @param connectivityType ::OCConnectivityType type of connectivity indicating the + * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP. * @param observeHandler handles callback * The callback function will be invoked with a map of attribute name and values. * The callback function will also have the result from this observe operation @@ -553,7 +555,7 @@ namespace OC */ OCStackResult subscribeDevicePresence(OCPresenceHandle& presenceHandle, const std::string& host, - const QueryParamsList& queryParams, + const std::vector& di, OCConnectivityType connectivityType, ObserveCallback callback); #endif diff --git a/resource/include/OCPlatform_impl.h b/resource/include/OCPlatform_impl.h index f1a84a3..90e3465 100644 --- a/resource/include/OCPlatform_impl.h +++ b/resource/include/OCPlatform_impl.h @@ -232,7 +232,7 @@ namespace OC #ifdef WITH_CLOUD OCStackResult subscribeDevicePresence(OCPresenceHandle& presenceHandle, const std::string& host, - const QueryParamsList& queryParams, + const std::vector& di, OCConnectivityType connectivityType, ObserveCallback callback); #endif diff --git a/resource/include/OutOfProcClientWrapper.h b/resource/include/OutOfProcClientWrapper.h index 982fbb3..79c2d4e 100644 --- a/resource/include/OutOfProcClientWrapper.h +++ b/resource/include/OutOfProcClientWrapper.h @@ -125,7 +125,7 @@ namespace OC virtual OCStackResult SubscribeDevicePresence( OCDoHandle* /*handle*/, const std::string& /*host*/, - const QueryParamsList& /*queryParams*/, + const std::vector& /*di*/, OCConnectivityType /*connectivityType*/, ObserveCallback& /*callback*/) {return OC_STACK_NOTIMPL;} diff --git a/resource/src/InProcClientWrapper.cpp b/resource/src/InProcClientWrapper.cpp index 196c822..b41b7ac 100644 --- a/resource/src/InProcClientWrapper.cpp +++ b/resource/src/InProcClientWrapper.cpp @@ -1197,7 +1197,7 @@ namespace OC #ifdef WITH_CLOUD OCStackResult InProcClientWrapper::SubscribeDevicePresence(OCDoHandle* handle, const std::string& host, - const QueryParamsList& queryParams, + const std::vector& di, OCConnectivityType connectivityType, ObserveCallback& callback) { @@ -1222,6 +1222,7 @@ namespace OC std::ostringstream os; os << host << OCF_RSRVD_DEVICE_PRESENCE_URI; + QueryParamsList queryParams({{OC_RSRVD_DEVICE_ID, di}}); std::string url = assembleSetResourceUri(os.str(), queryParams); result = OCDoResource(handle, OC_REST_OBSERVE, diff --git a/resource/src/OCPlatform.cpp b/resource/src/OCPlatform.cpp index 001133e..5369440 100644 --- a/resource/src/OCPlatform.cpp +++ b/resource/src/OCPlatform.cpp @@ -269,13 +269,13 @@ namespace OC #ifdef WITH_CLOUD OCStackResult subscribeDevicePresence(OCPresenceHandle& presenceHandle, const std::string& host, - const QueryParamsList& queryParams, + const std::vector& di, OCConnectivityType connectivityType, ObserveCallback callback) { return OCPlatform_impl::Instance().subscribeDevicePresence(presenceHandle, host, - queryParams, + di, connectivityType, callback); } diff --git a/resource/src/OCPlatform_impl.cpp b/resource/src/OCPlatform_impl.cpp index 3525c33..d816e30 100644 --- a/resource/src/OCPlatform_impl.cpp +++ b/resource/src/OCPlatform_impl.cpp @@ -385,12 +385,12 @@ namespace OC #ifdef WITH_CLOUD OCStackResult OCPlatform_impl::subscribeDevicePresence(OCPresenceHandle& presenceHandle, const std::string& host, - const QueryParamsList& queryParams, + const std::vector& di, OCConnectivityType connectivityType, ObserveCallback callback) { return checked_guard(m_client, &IClientWrapper::SubscribeDevicePresence, - &presenceHandle, host, queryParams, connectivityType, callback); + &presenceHandle, host, di, connectivityType, callback); } #endif diff --git a/resource/unittests/OCPlatformTest.cpp b/resource/unittests/OCPlatformTest.cpp index e5b16fa..0fea345 100644 --- a/resource/unittests/OCPlatformTest.cpp +++ b/resource/unittests/OCPlatformTest.cpp @@ -835,44 +835,44 @@ namespace OCPlatformTest } #ifdef WITH_CLOUD - //SubscribeDevicePresence Test + // SubscribeDevicePresence Test TEST(SubscribeDevicePresenceTest, DISABLED_SubscribeDevicePresenceWithValidParameters) { std::string hostAddress = "192.168.1.2:5000"; OCPlatform::OCPresenceHandle presenceHandle = nullptr; - QueryParamsList queryParams = {}; + std::vector di; EXPECT_EQ(OC_STACK_OK, OCPlatform::subscribeDevicePresence(presenceHandle, - hostAddress, queryParams, CT_DEFAULT, &onObserve)); + hostAddress, di, CT_DEFAULT, &onObserve)); } TEST(SubscribeDevicePresenceTest, SubscribeDevicePresenceWithNullHost) { OCPlatform::OCPresenceHandle presenceHandle = nullptr; - QueryParamsList queryParams = {}; + std::vector di; EXPECT_ANY_THROW(OCPlatform::subscribeDevicePresence(presenceHandle, - nullptr, queryParams, CT_DEFAULT, &onObserve)); + nullptr, di, CT_DEFAULT, &onObserve)); } TEST(SubscribeDevicePresenceTest, SubscribeDevicePresenceWithNullOnObserve) { std::string hostAddress = "192.168.1.2:5000"; OCPlatform::OCPresenceHandle presenceHandle = nullptr; - QueryParamsList queryParams = {}; + std::vector di; EXPECT_ANY_THROW(OCPlatform::subscribeDevicePresence(presenceHandle, - hostAddress, queryParams, CT_DEFAULT, NULL)); + hostAddress, di, CT_DEFAULT, NULL)); } TEST(SubscribeDevicePresenceTest, DISABLED_UnsubscribePresenceWithValidHandle) { std::string hostAddress = "192.168.1.2:5000"; OCPlatform::OCPresenceHandle presenceHandle = nullptr; - QueryParamsList queryParams = {}; + std::vector di; EXPECT_EQ(OC_STACK_OK, OCPlatform::subscribeDevicePresence(presenceHandle, - hostAddress, queryParams, CT_DEFAULT, &onObserve)); + hostAddress, di, CT_DEFAULT, &onObserve)); EXPECT_EQ(OC_STACK_OK, OCPlatform::unsubscribePresence(presenceHandle)); } #endif -- 2.7.4