Remove CreateResourceWithHost calls.
authorCharlie Lenahan <charlie.lenahan@intel.com>
Fri, 29 May 2015 19:28:16 +0000 (15:28 -0400)
committerErich Keane <erich.keane@intel.com>
Mon, 1 Jun 2015 19:55:21 +0000 (19:55 +0000)
"host" member is never referenced anywhere or returned in
any callbacks,so it is just a blackhole.

Change-Id: I957e44361851191c2a834528e60a3007e58db026
Signed-off-by: Charlie Lenahan <charlie.lenahan@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1143
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Joseph Morrow <joseph.l.morrow@intel.com>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/stack/include/internal/ocresource.h
resource/csdk/stack/include/ocstack.h
resource/csdk/stack/src/ocstack.c
resource/include/IServerWrapper.h
resource/include/InProcServerWrapper.h
resource/src/InProcServerWrapper.cpp
resource/src/OCPlatform_impl.cpp

index acd6de4..58581ef 100644 (file)
@@ -129,7 +129,6 @@ typedef struct resourceinterface_t {
 typedef struct rsrc_t {
     struct rsrc_t *next; // Points to next resource in list
     // Relative path on the device; will be combined with base url to create fully qualified path
-    char *host;
     char *uri;
     OCResourceType *rsrcType; // Resource type(s); linked list
     OCResourceInterface *rsrcInterface; // Resource interface(s); linked list
index 49b0778..28ecba8 100644 (file)
@@ -213,29 +213,6 @@ OCStackResult OCCreateResource(OCResourceHandle *handle,
                                OCEntityHandler entityHandler,
                                uint8_t resourceProperties);
 
-/**
- * Create a resource. with host ip address for remote resource.
- *
- * @param handle Pointer to handle to newly created resource.  Set by ocstack.
- *               Used to refer to resource.
- * @param resourceTypeName Name of resource type.  Example: "core.led".
- * @param resourceInterfaceName Name of resource interface.  Example: "core.rw".
- * @param host HOST address of the remote resource.  Example:  "coap://xxx.xxx.xxx.xxx:xxxxx".
- * @param uri URI of the resource.  Example:  "/a/led".
- * @param entityHandler Entity handler function that is called by ocstack to handle requests, etc.
- *                      NULL for default entity handler.
- * @param resourceProperties Properties supported by resource.
- *                           Example: ::OC_DISCOVERABLE|::OC_OBSERVABLE
- *
- * @return ::OC_STACK_OK on success, some other value upon failure.
- */
-OCStackResult OCCreateResourceWithHost(OCResourceHandle *handle,
-                               const char *resourceTypeName,
-                               const char *resourceInterfaceName,
-                               const char *host,
-                               const char *uri,
-                               OCEntityHandler entityHandler,
-                               uint8_t resourceProperties);
 
 /**
  * Add a resource to a collection resource.
index aac4606..8bec995 100644 (file)
@@ -2725,46 +2725,6 @@ exit:
     return result;
 }
 
-OCStackResult OCCreateResourceWithHost(OCResourceHandle *handle,
-        const char *resourceTypeName,
-        const char *resourceInterfaceName,
-        const char *host,
-        const char *uri,
-        OCEntityHandler entityHandler,
-        uint8_t resourceProperties)
-{
-    OC_LOG(INFO, TAG, PCF("Entering OCCreateResourceWithHost"));
-    char *str = NULL;
-    size_t size = 0;
-
-    if(!host)
-    {
-        OC_LOG(ERROR, TAG, PCF("Added resource host is NULL."));
-        return OC_STACK_INVALID_PARAM;
-    }
-
-    OCStackResult result = OC_STACK_ERROR;
-
-    result = OCCreateResource(handle, resourceTypeName, resourceInterfaceName,
-                                uri, entityHandler, resourceProperties);
-
-    if (result == OC_STACK_OK)
-    {
-        // Set the uri
-        size = strlen(host) + 1;
-        str = (char *) OCMalloc(size);
-        if (!str)
-        {
-            OC_LOG(ERROR, TAG, PCF("Memory could not be allocated."));
-            return OC_STACK_NO_MEMORY;
-        }
-        strncpy(str, host, size);
-
-        ((OCResource *) *handle)->host = str;
-    }
-
-    return result;
-}
 
 OCStackResult OCBindResource(
         OCResourceHandle collectionHandle, OCResourceHandle resourceHandle)
index ef45485..66f2007 100644 (file)
@@ -57,15 +57,6 @@ namespace OC
         virtual OCStackResult registerPlatformInfo(
                     const OCPlatformInfo PlatformInfo) = 0;
 
-        virtual OCStackResult registerResourceWithHost(
-                    OCResourceHandle& resourceHandle,
-                    std::string& resourceHOST,
-                    std::string& resourceURI,
-                    const std::string& resourceTypeName,
-                    const std::string& resourceInterface,
-                    EntityHandler& entityHandler,
-                    uint8_t resourceProperty) = 0;
-
         virtual OCStackResult unregisterResource(
                     const OCResourceHandle& resourceHandle) = 0;
         virtual OCStackResult bindTypeToResource(
index 1a9192a..6ba6466 100644 (file)
@@ -51,15 +51,6 @@ namespace OC
         virtual OCStackResult registerPlatformInfo(
                     const OCPlatformInfo PlatformInfo);
 
-        virtual OCStackResult registerResourceWithHost(
-                    OCResourceHandle& resourceHandle,
-                    std::string& resourceHOST,
-                    std::string& resourceURI,
-                    const std::string& resourceTypeName,
-                    const std::string& resourceInterface,
-                    EntityHandler& entityHandler,
-                    uint8_t resourceProperty);
-
         virtual OCStackResult unregisterResource(
                     const OCResourceHandle& resourceHandle);
 
index f42a18c..0c31217 100644 (file)
@@ -377,65 +377,7 @@ namespace OC
         return result;
     }
 
-    OCStackResult InProcServerWrapper::registerResourceWithHost(
-                    OCResourceHandle& resourceHandle,
-                    std::string& resourceHOST,
-                    std::string& resourceURI,
-                    const std::string& resourceTypeName,
-                    const std::string& resourceInterface,
-                    EntityHandler& eHandler,
-                    uint8_t resourceProperties)
-
-    {
-        OCStackResult result = OC_STACK_ERROR;
 
-        auto cLock = m_csdkLock.lock();
-
-        if (cLock)
-        {
-            std::lock_guard < std::recursive_mutex > lock(*cLock);
-
-            if (NULL != eHandler)
-            {
-                result = OCCreateResourceWithHost(&resourceHandle, // OCResourceHandle *handle
-                        resourceTypeName.c_str(), // const char * resourceTypeName
-                        resourceInterface.c_str(), //const char * resourceInterfaceName //TODO fix
-                        resourceHOST.c_str(), // const char * host
-                        (resourceHOST + resourceURI).c_str(), // const char * uri
-                        EntityHandlerWrapper, // OCEntityHandler entityHandler
-                        resourceProperties // uint8_t resourceProperties
-                        );
-            }
-            else
-            {
-                result = OCCreateResourceWithHost(&resourceHandle, // OCResourceHandle *handle
-                        resourceTypeName.c_str(), // const char * resourceTypeName
-                        resourceInterface.c_str(), //const char * resourceInterfaceName //TODO fix
-                        resourceHOST.c_str(), // const char * host
-                        (resourceHOST + resourceURI).c_str(), // const char * uri
-                        nullptr, // OCEntityHandler entityHandler
-                        resourceProperties // uint8_t resourceProperties
-                        );
-            }
-
-            if (result != OC_STACK_OK)
-            {
-                resourceHandle = nullptr;
-            }
-            else
-            {
-                std::lock_guard<std::mutex> lock(OC::details::serverWrapperLock);
-                OC::details::entityHandlerMap[resourceHandle] = eHandler;
-                OC::details::resourceUriMap[resourceHandle] = resourceURI;
-            }
-        }
-        else
-        {
-            result = OC_STACK_ERROR;
-        }
-
-        return result;
-    }
 
     OCStackResult InProcServerWrapper::setDefaultDeviceEntityHandler
                                         (EntityHandler entityHandler)
index e694bab..230f924 100644 (file)
@@ -244,8 +244,8 @@ namespace OC
         uint8_t resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE;
         std::vector<std::string> resourceTypes = resource->getResourceTypes();
 
-        return checked_guard(m_server, &IServerWrapper::registerResourceWithHost,
-                std::ref(resourceHandle), resource->host(), resource->uri(),
+        return checked_guard(m_server, &IServerWrapper::registerResource,
+                std::ref(resourceHandle), resource->uri(),
                 resourceTypes[0]/*"core.remote"*/, DEFAULT_INTERFACE,
                 (EntityHandler) nullptr, resourceProperty);
     }