X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=resource%2Fsrc%2FOCResource.cpp;h=0728df0430cd25a537d82f3c64e28f47b1d7f23c;hb=c315c87e07c4080ecd0ef488e7a1047bc3c509b2;hp=60306d8900abac44362da5db9805234c73afcf7a;hpb=edcfc3d2329da7b914771c0dcff5f42c9b74fd93;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/src/OCResource.cpp b/resource/src/OCResource.cpp index 60306d8..0728df0 100644 --- a/resource/src/OCResource.cpp +++ b/resource/src/OCResource.cpp @@ -52,12 +52,13 @@ OCResource::OCResource(std::weak_ptr clientWrapper, const OCDevAddr& devAddr, const std::string& uri, const std::string& serverId, uint8_t property, const std::vector& resourceTypes, - const std::vector& interfaces) + const std::vector& interfaces, + const std::string& deviceName) : m_clientWrapper(clientWrapper), m_uri(uri), m_resourceId(serverId, m_uri), m_devAddr(devAddr), m_isCollection(false), m_property(property), m_resourceTypes(resourceTypes), m_interfaces(interfaces), - m_observeHandle(nullptr) + m_observeHandle(nullptr), m_deviceName(deviceName) { m_isCollection = std::find(m_interfaces.begin(), m_interfaces.end(), LINK_INTERFACE) != m_interfaces.end(); @@ -67,8 +68,8 @@ OCResource::OCResource(std::weak_ptr clientWrapper, interfaces.empty()|| m_clientWrapper.expired()) { - throw ResourceInitException(m_uri.empty(), resourceTypes.empty(), - interfaces.empty(), m_clientWrapper.expired(), false, false); + throw ResourceInitException(m_uri.empty(), false, resourceTypes.empty(), + interfaces.empty(), m_clientWrapper.expired(), false, false, false); } } @@ -77,18 +78,19 @@ OCResource::OCResource(std::weak_ptr clientWrapper, const std::string& serverId, OCConnectivityType connectivityType, uint8_t property, const std::vector& resourceTypes, - const std::vector& interfaces) + const std::vector& interfaces, + const std::string& deviceName) : m_clientWrapper(clientWrapper), m_uri(uri), m_resourceId(serverId, m_uri), m_isCollection(false), m_property(property), m_resourceTypes(resourceTypes), m_interfaces(interfaces), - m_observeHandle(nullptr) + m_observeHandle(nullptr), m_deviceName(deviceName) { m_devAddr = OCDevAddr{OC_DEFAULT_ADAPTER, OC_DEFAULT_FLAGS, 0, {0}, 0, #if defined (ROUTING_GATEWAY) || defined (ROUTING_EP) - {0} + {0}, #endif - }; + {0}}; m_isCollection = std::find(m_interfaces.begin(), m_interfaces.end(), LINK_INTERFACE) != m_interfaces.end(); @@ -97,20 +99,20 @@ OCResource::OCResource(std::weak_ptr clientWrapper, interfaces.empty()|| m_clientWrapper.expired()) { - throw ResourceInitException(m_uri.empty(), resourceTypes.empty(), - interfaces.empty(), m_clientWrapper.expired(), false, false); + throw ResourceInitException(m_uri.empty(), false, resourceTypes.empty(), + interfaces.empty(), m_clientWrapper.expired(), false, false, false); } if (uri.length() == 1 && uri[0] == '/') { - throw ResourceInitException(m_uri.empty(), resourceTypes.empty(), - interfaces.empty(), m_clientWrapper.expired(), false, false); + throw ResourceInitException(m_uri.empty(), true, resourceTypes.empty(), + interfaces.empty(), m_clientWrapper.expired(), false, false, false); } if (uri[0] != '/') { - throw ResourceInitException(m_uri.empty(), resourceTypes.empty(), - interfaces.empty(), m_clientWrapper.expired(), false, false); + throw ResourceInitException(m_uri.empty(), true, resourceTypes.empty(), + interfaces.empty(), m_clientWrapper.expired(), false, false, false); } // construct the devAddr from the pieces we have @@ -156,8 +158,8 @@ void OCResource::setHost(const std::string& host) } else { - throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(), - m_interfaces.empty(), m_clientWrapper.expired(), false, false); + throw ResourceInitException(m_uri.empty(), false, m_resourceTypes.empty(), + m_interfaces.empty(), m_clientWrapper.expired(), false, false, true); } // remove 'coap://' or 'coaps://' or 'coap+tcp://' or 'coap+gatt://' or 'coap+rfcomm://' @@ -169,8 +171,8 @@ void OCResource::setHost(const std::string& host) if (std::string::npos == bracket || 0 == bracket) { - throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(), - m_interfaces.empty(), m_clientWrapper.expired(), false, false); + throw ResourceInitException(m_uri.empty(), false, m_resourceTypes.empty(), + m_interfaces.empty(), m_clientWrapper.expired(), false, true, false); } // extract the ipv6 address std::string ip6Addr = host_token.substr(1, bracket - 1); @@ -186,8 +188,8 @@ void OCResource::setHost(const std::string& host) const char *cAddr = ip6AddrToValidityCheck.c_str(); if (0 == inet_pton(AF_INET6, cAddr, &buf)) { - throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(), - m_interfaces.empty(), m_clientWrapper.expired(), false, false); + throw ResourceInitException(m_uri.empty(), false, m_resourceTypes.empty(), + m_interfaces.empty(), m_clientWrapper.expired(), true, false, false); } //skip ']' and ':' characters in host string @@ -196,8 +198,8 @@ void OCResource::setHost(const std::string& host) if (0 > port || UINT16_MAX < port) { - throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(), - m_interfaces.empty(), m_clientWrapper.expired(), false, false); + throw ResourceInitException(m_uri.empty(), false, m_resourceTypes.empty(), + m_interfaces.empty(), m_clientWrapper.expired(), true, false, false); } OCStackResult result = OCDecodeAddressForRFC6874(m_devAddr.addr, @@ -205,8 +207,8 @@ void OCResource::setHost(const std::string& host) if (OC_STACK_OK != result) { - throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(), - m_interfaces.empty(), m_clientWrapper.expired(), false, false); + throw ResourceInitException(m_uri.empty(), false, m_resourceTypes.empty(), + m_interfaces.empty(), m_clientWrapper.expired(), false, true, false); } m_devAddr.port = static_cast(port); @@ -214,8 +216,8 @@ void OCResource::setHost(const std::string& host) } else if (host_token[0] == ':') { - throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(), - m_interfaces.empty(), m_clientWrapper.expired(), false, false); + throw ResourceInitException(m_uri.empty(), false, m_resourceTypes.empty(), + m_interfaces.empty(), m_clientWrapper.expired(), false, false, true); } else { @@ -227,8 +229,8 @@ void OCResource::setHost(const std::string& host) // address validity check if (MAC_ADDR_STR_SIZE != macAddr.length()) { - throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(), - m_interfaces.empty(), m_clientWrapper.expired(), false, false); + throw ResourceInitException(m_uri.empty(), false, m_resourceTypes.empty(), + m_interfaces.empty(), m_clientWrapper.expired(), false, true, false); } for (size_t blockCnt = 0; blockCnt < MAC_ADDR_BLOCKS; blockCnt++) @@ -237,8 +239,8 @@ void OCResource::setHost(const std::string& host) if (std::string::npos != block.find_first_not_of("0123456789ABCDEFabcdef")) { - throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(), - m_interfaces.empty(), m_clientWrapper.expired(), false, false); + throw ResourceInitException(m_uri.empty(), false, m_resourceTypes.empty(), + m_interfaces.empty(), m_clientWrapper.expired(), false, true, false); } if (MAC_ADDR_BLOCKS - 1 > blockCnt) @@ -247,8 +249,8 @@ void OCResource::setHost(const std::string& host) if (':' != delimiter) { - throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(), - m_interfaces.empty(), m_clientWrapper.expired(), false, false); + throw ResourceInitException(m_uri.empty(), false, m_resourceTypes.empty(), + m_interfaces.empty(), m_clientWrapper.expired(), false, true, false); } } } @@ -262,8 +264,8 @@ void OCResource::setHost(const std::string& host) if (colon == std::string::npos || colon == 0) { - throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(), - m_interfaces.empty(), m_clientWrapper.expired(), false, false); + throw ResourceInitException(m_uri.empty(), false, m_resourceTypes.empty(), + m_interfaces.empty(), m_clientWrapper.expired(), false, true, false); } // extract the ipv4 address @@ -274,8 +276,8 @@ void OCResource::setHost(const std::string& host) const char *cAddr = ip4Addr.c_str(); if (0 == inet_pton(AF_INET, cAddr, &buf)) { - throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(), - m_interfaces.empty(), m_clientWrapper.expired(), false, false); + throw ResourceInitException(m_uri.empty(), false, m_resourceTypes.empty(), + m_interfaces.empty(), m_clientWrapper.expired(), true, false, false); } //skip ':' characters in host string @@ -284,8 +286,8 @@ void OCResource::setHost(const std::string& host) if (0 > port || UINT16_MAX < port) { - throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(), - m_interfaces.empty(), m_clientWrapper.expired(), false, false); + throw ResourceInitException(m_uri.empty(), false, m_resourceTypes.empty(), + m_interfaces.empty(), m_clientWrapper.expired(), true, false, false); } ip4Addr.copy(m_devAddr.addr, sizeof(m_devAddr.addr)); @@ -554,8 +556,8 @@ std::string OCResource::host() const m_devAddr.addr); if (OC_STACK_OK != result) { - throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(), - m_interfaces.empty(), m_clientWrapper.expired(), false, false); + throw ResourceInitException(m_uri.empty(), false, m_resourceTypes.empty(), + m_interfaces.empty(), m_clientWrapper.expired(), false, true, false); } ss << '[' << addressEncoded << ']'; } @@ -613,6 +615,16 @@ std::string OCResource::sid() const return this->uniqueIdentifier().m_representation; } +std::string OCResource::deviceName() const +{ + return m_deviceName; +} + +OCDevAddr OCResource::getDevAddr() const +{ + return m_devAddr; +} + #ifdef WITH_MQ OCStackResult OCResource::discoveryMQTopics(const QueryParamsMap& queryParametersMap, MQTopicCallback attributeHandler,