Implement ServerID parsing and sample app
[platform/upstream/iotivity.git] / resource / src / InProcClientWrapper.cpp
index 83e4ef8..9fd3153 100644 (file)
@@ -163,7 +163,9 @@ namespace OC
         {
             oclog() << "listenCallback failed to parse a malformed message: "
                     << e.what()
-                    << std::endl <<std::endl
+                    << std::endl
+                    << clientResponse->resJSONPayload
+                    << std::endl
                     << clientResponse->result
                     << std::flush;
             return OC_STACK_KEEP_TRANSACTION;
@@ -172,8 +174,14 @@ namespace OC
         return OC_STACK_KEEP_TRANSACTION;
     }
 
+#ifdef CA_INT
+    OCStackResult InProcClientWrapper::ListenForResource(const std::string& serviceUrl,
+        const std::string& resourceType, uint8_t connectivityType,
+        FindCallback& callback, QualityOfService QoS)
+#else
     OCStackResult InProcClientWrapper::ListenForResource(const std::string& serviceUrl,
         const std::string& resourceType, FindCallback& callback, QualityOfService QoS)
+#endif
     {
         OCStackResult result;
 
@@ -192,12 +200,21 @@ namespace OC
         {
             std::lock_guard<std::recursive_mutex> lock(*cLock);
             OCDoHandle handle;
+#ifdef CA_INT
+            result = OCDoResource(&handle, OC_REST_GET,
+                                  resourceType.c_str(),
+                                  nullptr, nullptr, connectivityType,
+                                  static_cast<OCQualityOfService>(QoS),
+                                  &cbdata,
+                                  NULL, 0);
+#else
             result = OCDoResource(&handle, OC_REST_GET,
                                   resourceType.c_str(),
                                   nullptr, nullptr,
                                   static_cast<OCQualityOfService>(QoS),
                                   &cbdata,
                                   NULL, 0);
+#endif
         }
         else
         {
@@ -220,8 +237,14 @@ namespace OC
         return OC_STACK_KEEP_TRANSACTION;
     }
 
+#ifdef CA_INT
+    OCStackResult InProcClientWrapper::ListenForDevice(const std::string& serviceUrl,
+        const std::string& deviceURI, uint8_t connectivityType,
+        FindDeviceCallback& callback, QualityOfService QoS)
+#else
     OCStackResult InProcClientWrapper::ListenForDevice(const std::string& serviceUrl,
         const std::string& deviceURI, FindDeviceCallback& callback, QualityOfService QoS)
+#endif
     {
         OCStackResult result;
 
@@ -241,12 +264,21 @@ namespace OC
         {
             std::lock_guard<std::recursive_mutex> lock(*cLock);
             OCDoHandle handle;
+#ifdef CA_INT
+            result = OCDoResource(&handle, OC_REST_GET,
+                                  deviceURI.c_str(),
+                                  nullptr, nullptr, connectivityType,
+                                  static_cast<OCQualityOfService>(QoS),
+                                  &cbdata,
+                                  NULL, 0);
+#else
             result = OCDoResource(&handle, OC_REST_GET,
                                   deviceURI.c_str(),
                                   nullptr, nullptr,
                                   static_cast<OCQualityOfService>(QoS),
                                   &cbdata,
                                   NULL, 0);
+#endif
         }
         else
         {
@@ -300,10 +332,17 @@ namespace OC
         return OC_STACK_DELETE_TRANSACTION;
     }
 
+#ifdef CA_INT
+    OCStackResult InProcClientWrapper::GetResourceRepresentation(const std::string& host,
+        const std::string& uri, uint8_t connectivityType, const QueryParamsMap& queryParams,
+        const HeaderOptions& headerOptions, GetCallback& callback,
+        QualityOfService QoS)
+#else
     OCStackResult InProcClientWrapper::GetResourceRepresentation(const std::string& host,
         const std::string& uri, const QueryParamsMap& queryParams,
         const HeaderOptions& headerOptions, GetCallback& callback,
         QualityOfService QoS)
+#endif
     {
         OCStackResult result;
         OCCallbackData cbdata = {0};
@@ -326,11 +365,19 @@ namespace OC
             OCHeaderOption options[MAX_HEADER_OPTIONS];
 
             assembleHeaderOptions(options, headerOptions);
+#ifdef CA_INT
+            result = OCDoResource(&handle, OC_REST_GET, os.str().c_str(),
+                                  nullptr, nullptr, connectivityType,
+                                  static_cast<OCQualityOfService>(QoS),
+                                  &cbdata,
+                                  options, headerOptions.size());
+#else
             result = OCDoResource(&handle, OC_REST_GET, os.str().c_str(),
                                   nullptr, nullptr,
                                   static_cast<OCQualityOfService>(QoS),
                                   &cbdata,
                                   options, headerOptions.size());
+#endif
         }
         else
         {
@@ -398,10 +445,17 @@ namespace OC
         return ocInfo.getJSONRepresentation(OCInfoFormat::IncludeOC);
     }
 
+#ifdef CA_INT
+    OCStackResult InProcClientWrapper::PostResourceRepresentation(const std::string& host,
+        const std::string& uri, uint8_t connectivityType, const OCRepresentation& rep,
+        const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
+        PostCallback& callback, QualityOfService QoS)
+#else
     OCStackResult InProcClientWrapper::PostResourceRepresentation(const std::string& host,
         const std::string& uri, const OCRepresentation& rep,
         const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
         PostCallback& callback, QualityOfService QoS)
+#endif
     {
         OCStackResult result;
         OCCallbackData cbdata = {0};
@@ -426,11 +480,19 @@ namespace OC
             OCDoHandle handle;
 
             assembleHeaderOptions(options, headerOptions);
+#ifdef CA_INT
+            result = OCDoResource(&handle, OC_REST_POST,
+                                  os.str().c_str(), nullptr,
+                                  assembleSetResourcePayload(rep).c_str(), connectivityType,
+                                  static_cast<OCQualityOfService>(QoS),
+                                  &cbdata, options, headerOptions.size());
+#else
             result = OCDoResource(&handle, OC_REST_POST,
                                   os.str().c_str(), nullptr,
                                   assembleSetResourcePayload(rep).c_str(),
                                   static_cast<OCQualityOfService>(QoS),
                                   &cbdata, options, headerOptions.size());
+#endif
         }
         else
         {
@@ -441,11 +503,17 @@ namespace OC
         return result;
     }
 
-
+#ifdef CA_INT
+    OCStackResult InProcClientWrapper::PutResourceRepresentation(const std::string& host,
+        const std::string& uri, uint8_t connectivityType, const OCRepresentation& rep,
+        const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
+        PutCallback& callback, QualityOfService QoS)
+#else
     OCStackResult InProcClientWrapper::PutResourceRepresentation(const std::string& host,
         const std::string& uri, const OCRepresentation& rep,
         const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
         PutCallback& callback, QualityOfService QoS)
+#endif
     {
         OCStackResult result;
         OCCallbackData cbdata = {0};
@@ -470,12 +538,21 @@ namespace OC
             OCHeaderOption options[MAX_HEADER_OPTIONS];
 
             assembleHeaderOptions(options, headerOptions);
+#ifdef CA_INT
+            result = OCDoResource(&handle, OC_REST_PUT,
+                                  os.str().c_str(), nullptr,
+                                  assembleSetResourcePayload(rep).c_str(), connectivityType,
+                                  static_cast<OCQualityOfService>(QoS),
+                                  &cbdata,
+                                  options, headerOptions.size());
+#else
             result = OCDoResource(&handle, OC_REST_PUT,
                                   os.str().c_str(), nullptr,
                                   assembleSetResourcePayload(rep).c_str(),
                                   static_cast<OCQualityOfService>(QoS),
                                   &cbdata,
                                   options, headerOptions.size());
+#endif
         }
         else
         {
@@ -502,9 +579,15 @@ namespace OC
         return OC_STACK_DELETE_TRANSACTION;
     }
 
+#ifdef CA_INT
+    OCStackResult InProcClientWrapper::DeleteResource(const std::string& host,
+        const std::string& uri, uint8_t connectivityType, const HeaderOptions& headerOptions,
+         DeleteCallback& callback, QualityOfService QoS)
+#else
     OCStackResult InProcClientWrapper::DeleteResource(const std::string& host,
         const std::string& uri, const HeaderOptions& headerOptions,
          DeleteCallback& callback, QualityOfService QoS)
+#endif
     {
         OCStackResult result;
         OCCallbackData cbdata = {0};
@@ -528,11 +611,18 @@ namespace OC
             assembleHeaderOptions(options, headerOptions);
 
             std::lock_guard<std::recursive_mutex> lock(*cLock);
-
+#ifdef CA_INT
+            result = OCDoResource(&handle, OC_REST_DELETE,
+                                  os.str().c_str(), nullptr,
+                                  nullptr, connectivityType,
+                                  static_cast<OCQualityOfService>(m_cfg.QoS),
+                                  &cbdata, options, headerOptions.size());
+#else
             result = OCDoResource(&handle, OC_REST_DELETE,
                                   os.str().c_str(), nullptr,
                                   nullptr, static_cast<OCQualityOfService>(m_cfg.QoS),
                                   &cbdata, options, headerOptions.size());
+#endif
         }
         else
         {
@@ -563,9 +653,16 @@ namespace OC
         return OC_STACK_KEEP_TRANSACTION;
     }
 
+#ifdef CA_INT
+    OCStackResult InProcClientWrapper::ObserveResource(ObserveType observeType, OCDoHandle* handle,
+        const std::string& host, const std::string& uri, uint8_t connectivityType,
+        const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
+        ObserveCallback& callback, QualityOfService QoS)
+#else
     OCStackResult InProcClientWrapper::ObserveResource(ObserveType observeType, OCDoHandle* handle,
         const std::string& host, const std::string& uri, const QueryParamsMap& queryParams,
         const HeaderOptions& headerOptions, ObserveCallback& callback, QualityOfService QoS)
+#endif
     {
         OCStackResult result;
         OCCallbackData cbdata = {0};
@@ -601,12 +698,21 @@ namespace OC
             OCHeaderOption options[MAX_HEADER_OPTIONS];
 
             assembleHeaderOptions(options, headerOptions);
+#ifdef CA_INT
+            result = OCDoResource(handle, method,
+                                  os.str().c_str(), nullptr,
+                                  nullptr, connectivityType,
+                                  static_cast<OCQualityOfService>(QoS),
+                                  &cbdata,
+                                  options, headerOptions.size());
+#else
             result = OCDoResource(handle, method,
                                   os.str().c_str(), nullptr,
                                   nullptr,
                                   static_cast<OCQualityOfService>(QoS),
                                   &cbdata,
                                   options, headerOptions.size());
+#endif
         }
         else
         {
@@ -669,9 +775,15 @@ namespace OC
         return OC_STACK_KEEP_TRANSACTION;
     }
 
+#ifdef CA_INT
+    OCStackResult InProcClientWrapper::SubscribePresence(OCDoHandle* handle,
+        const std::string& host, const std::string& resourceType, uint8_t connectivityType,
+        SubscribeCallback& presenceHandler)
+#else
     OCStackResult InProcClientWrapper::SubscribePresence(OCDoHandle* handle,
         const std::string& host, const std::string& resourceType,
         SubscribeCallback& presenceHandler)
+#endif
     {
         OCCallbackData cbdata = {0};
 
@@ -698,8 +810,13 @@ namespace OC
             return OC_STACK_ERROR;
         }
 
+#ifdef CA_INT
+        return OCDoResource(handle, OC_REST_PRESENCE, os.str().c_str(), nullptr, nullptr,
+                            connectivityType, OC_LOW_QOS, &cbdata, NULL, 0);
+#else
         return OCDoResource(handle, OC_REST_PRESENCE, os.str().c_str(), nullptr, nullptr,
                             OC_LOW_QOS, &cbdata, NULL, 0);
+#endif
     }
 
     OCStackResult InProcClientWrapper::UnsubscribePresence(OCDoHandle handle)