Change APIs for Subscribe device presence.
authorJaehong Jo <jaehong.jo@samsung.com>
Tue, 2 Aug 2016 02:44:53 +0000 (11:44 +0900)
committerJon A. Cruz <jon@joncruz.org>
Thu, 4 Aug 2016 20:50:26 +0000 (20:50 +0000)
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<std::string>& di

Change-Id: I2c8231a58425227333c2a9c672c086409e2e51be
Signed-off-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9917
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: jihwan seo <jihwan.seo@samsung.com>
Reviewed-by: Eunok Shin <eunok.shin@samsung.com>
Reviewed-by: Hyuna Jo <hyuna0213.jo@samsung.com>
Reviewed-by: Jon A. Cruz <jon@joncruz.org>
resource/include/IClientWrapper.h
resource/include/InProcClientWrapper.h
resource/include/OCPlatform.h
resource/include/OCPlatform_impl.h
resource/include/OutOfProcClientWrapper.h
resource/src/InProcClientWrapper.cpp
resource/src/OCPlatform.cpp
resource/src/OCPlatform_impl.cpp
resource/unittests/OCPlatformTest.cpp

index e560219..2a958f5 100644 (file)
@@ -112,7 +112,7 @@ namespace OC
 #ifdef WITH_CLOUD
         virtual OCStackResult SubscribeDevicePresence(OCDoHandle* handle,
                                                       const std::string& host,
-                                                      const QueryParamsList& queryParams,
+                                                      const std::vector<std::string>& di,
                                                       OCConnectivityType connectivityType,
                                                       ObserveCallback& callback) = 0;
 #endif
index 0cd2df4..2c90c90 100644 (file)
@@ -182,7 +182,7 @@ namespace OC
 #ifdef WITH_CLOUD
         virtual OCStackResult SubscribeDevicePresence(OCDoHandle* handle,
                                                       const std::string& host,
-                                                      const QueryParamsList& queryParams,
+                                                      const std::vector<std::string>& di,
                                                       OCConnectivityType connectivityType,
                                                       ObserveCallback& callback);
 #endif
index 768f5f1..c6062b2 100644 (file)
@@ -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<std::string>& di,
                                               OCConnectivityType connectivityType,
                                               ObserveCallback callback);
 #endif
index f1a84a3..90e3465 100644 (file)
@@ -232,7 +232,7 @@ namespace OC
 #ifdef WITH_CLOUD
         OCStackResult subscribeDevicePresence(OCPresenceHandle& presenceHandle,
                                               const std::string& host,
-                                              const QueryParamsList& queryParams,
+                                              const std::vector<std::string>& di,
                                               OCConnectivityType connectivityType,
                                               ObserveCallback callback);
 #endif
index 982fbb3..79c2d4e 100644 (file)
@@ -125,7 +125,7 @@ namespace OC
         virtual OCStackResult SubscribeDevicePresence(
             OCDoHandle* /*handle*/,
             const std::string& /*host*/,
-            const QueryParamsList& /*queryParams*/,
+            const std::vector<std::string>& /*di*/,
             OCConnectivityType /*connectivityType*/,
             ObserveCallback& /*callback*/)
             {return OC_STACK_NOTIMPL;}
index 196c822..b41b7ac 100644 (file)
@@ -1197,7 +1197,7 @@ namespace OC
 #ifdef WITH_CLOUD
     OCStackResult InProcClientWrapper::SubscribeDevicePresence(OCDoHandle* handle,
                                                                const std::string& host,
-                                                               const QueryParamsList& queryParams,
+                                                               const std::vector<std::string>& 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,
index 001133e..5369440 100644 (file)
@@ -269,13 +269,13 @@ namespace OC
 #ifdef WITH_CLOUD
         OCStackResult subscribeDevicePresence(OCPresenceHandle& presenceHandle,
                                               const std::string& host,
-                                              const QueryParamsList& queryParams,
+                                              const std::vector<std::string>& di,
                                               OCConnectivityType connectivityType,
                                               ObserveCallback callback)
         {
             return OCPlatform_impl::Instance().subscribeDevicePresence(presenceHandle,
                                                                        host,
-                                                                       queryParams,
+                                                                       di,
                                                                        connectivityType,
                                                                        callback);
         }
index 3525c33..d816e30 100644 (file)
@@ -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<std::string>& di,
                                                            OCConnectivityType connectivityType,
                                                            ObserveCallback callback)
     {
         return checked_guard(m_client, &IClientWrapper::SubscribeDevicePresence,
-                             &presenceHandle, host, queryParams, connectivityType, callback);
+                             &presenceHandle, host, di, connectivityType, callback);
     }
 #endif
 
index e5b16fa..0fea345 100644 (file)
@@ -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<std::string> 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<std::string> 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<std::string> 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<std::string> 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