Properly defined URI & Resource Type values for Presence Advertisement.
[platform/upstream/iotivity.git] / resource / src / OCPlatform_impl.cpp
index 3039fe5..ccac71d 100644 (file)
@@ -30,6 +30,8 @@
 //
 //*********************************************************************
 
+#include "OCPlatform_impl.h"
+
 #include <random>
 #include <utility>
 #include <functional>
@@ -85,7 +87,7 @@ namespace OC
     OCPlatform_impl::OCPlatform_impl(const PlatformConfig& config)
      : m_cfg             { config },
        m_WrapperInstance { make_unique<WrapperFactory>() },
-       m_csdkLock        { make_shared<std::recursive_mutex>() }
+       m_csdkLock        { std::make_shared<std::recursive_mutex>() }
     {
         init(m_cfg);
     }
@@ -134,11 +136,10 @@ namespace OC
         return result_guard(
                    OCNotifyListOfObservers(resourceHandle,
                             &observationIds[0], observationIds.size(),
-                            reinterpret_cast<unsigned char *>(const_cast<char *>(payload.c_str())),
+                            payload.c_str(),
                             static_cast<OCQualityOfService>(QoS)));
     }
 
-#ifdef CA_INT
     OCResource::Ptr OCPlatform_impl::constructResourceObject(const std::string& host,
                                                 const std::string& uri,
                                                 OCConnectivityType connectivityType,
@@ -196,62 +197,6 @@ namespace OC
                              host, deviceURI, connectivityType, deviceInfoHandler, QoS);
     }
 
-#else
-    OCResource::Ptr OCPlatform_impl::constructResourceObject(const std::string& host,
-                                                const std::string& uri,
-                                                bool isObservable,
-                                                const std::vector<std::string>& resourceTypes,
-                                                const std::vector<std::string>& interfaces)
-    {
-        if(!m_client)
-        {
-            return std::shared_ptr<OCResource>();
-        }
-
-        return std::shared_ptr<OCResource>(new OCResource(m_client,
-                                            host,
-                                            uri,
-                                            "", // 'created' Resources have no way of knowing their
-                                                // server ID, so this has to be blank initially.
-                                            isObservable,
-                                            resourceTypes,
-                                            interfaces));
-    }
-
-    OCStackResult OCPlatform_impl::findResource(const std::string& host,
-                                            const std::string& resourceName,
-                                            FindCallback resourceHandler)
-    {
-        return findResource(host, resourceName, resourceHandler, m_cfg.QoS);
-    }
-
-    OCStackResult OCPlatform_impl::findResource(const std::string& host,
-                                            const std::string& resourceName,
-                                            FindCallback resourceHandler, QualityOfService QoS)
-    {
-
-        return checked_guard(m_client, &IClientWrapper::ListenForResource,
-                             host, resourceName, resourceHandler, QoS);
-    }
-
-    OCStackResult OCPlatform_impl::getDeviceInfo(const std::string& host,
-                                            const std::string& deviceURI,
-                                            FindDeviceCallback deviceInfoHandler)
-    {
-        return result_guard(getDeviceInfo(host, deviceURI, deviceInfoHandler, m_cfg.QoS));
-    }
-
-    OCStackResult OCPlatform_impl::getDeviceInfo(const std::string& host,
-                                            const std::string& deviceURI,
-                                            FindDeviceCallback deviceInfoHandler,
-                                            QualityOfService QoS)
-    {
-        return checked_guard(m_client, &IClientWrapper::ListenForDevice,
-                             host, deviceURI, deviceInfoHandler, QoS);
-    }
-
-#endif
-
     OCStackResult OCPlatform_impl::registerResource(OCResourceHandle& resourceHandle,
                                             std::string& resourceURI,
                                             const std::string& resourceTypeName,
@@ -260,7 +205,7 @@ namespace OC
                                             uint8_t resourceProperty)
     {
         return checked_guard(m_server, &IServerWrapper::registerResource,
-                             ref(resourceHandle), resourceURI, resourceTypeName,
+                             std::ref(resourceHandle), resourceURI, resourceTypeName,
                              resourceInterface, entityHandler, resourceProperty);
     }
 
@@ -276,7 +221,8 @@ namespace OC
         std::vector<std::string> resourceTypes = resource->getResourceTypes();
 
         return checked_guard(m_server, &IServerWrapper::registerResourceWithHost,
-                ref(resourceHandle), resource->host(), resource->uri(), resourceTypes[0]/*"core.remote"*/, "oc.mi.def",
+                std::ref(resourceHandle), resource->host(), resource->uri(),
+                resourceTypes[0]/*"core.remote"*/, DEFAULT_INTERFACE,
                 (EntityHandler) nullptr, resourceProperty);
     }
 
@@ -289,7 +235,7 @@ namespace OC
     OCStackResult OCPlatform_impl::unbindResource(OCResourceHandle collectionHandle,
                                             OCResourceHandle resourceHandle)
     {
-        return result_guard(OCUnBindResource(ref(collectionHandle), ref(resourceHandle)));
+        return result_guard(OCUnBindResource(std::ref(collectionHandle), std::ref(resourceHandle)));
     }
 
     OCStackResult OCPlatform_impl::unbindResources(const OCResourceHandle collectionHandle,
@@ -355,7 +301,6 @@ namespace OC
         return checked_guard(m_server, &IServerWrapper::stopPresence);
     }
 
-#ifdef CA_INT
     OCStackResult OCPlatform_impl::subscribePresence(OCPresenceHandle& presenceHandle,
                                             const std::string& host,
                                             OCConnectivityType connectivityType,
@@ -375,29 +320,11 @@ namespace OC
                              &presenceHandle, host, resourceType, connectivityType,
                              presenceHandler);
     }
-#else
-    OCStackResult OCPlatform_impl::subscribePresence(OCPresenceHandle& presenceHandle,
-                                            const std::string& host,
-                                            SubscribeCallback presenceHandler)
-    {
-        return subscribePresence(presenceHandle, host, "", presenceHandler);
-    }
-
-    OCStackResult OCPlatform_impl::subscribePresence(OCPresenceHandle& presenceHandle,
-                                            const std::string& host,
-                                            const std::string& resourceType,
-                                            SubscribeCallback presenceHandler)
-    {
-        return checked_guard(m_client, &IClientWrapper::SubscribePresence,
-                             &presenceHandle, host, resourceType,
-                             presenceHandler);
-    }
-#endif
 
     OCStackResult OCPlatform_impl::unsubscribePresence(OCPresenceHandle presenceHandle)
     {
         return checked_guard(m_client, &IClientWrapper::UnsubscribePresence,
-                             ref(presenceHandle));
+                             std::ref(presenceHandle));
     }
 
     OCStackResult OCPlatform_impl::sendResponse(const std::shared_ptr<OCResourceResponse> pResponse)
@@ -406,3 +333,4 @@ namespace OC
                              pResponse);
     }
 } //namespace OC
+