From: jake Date: Tue, 21 Feb 2017 05:01:19 +0000 (+0900) Subject: Update attributes name for notification. X-Git-Tag: 1.3.0~614 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8757e19bae9cc718452465178f681743a9d9d347;p=platform%2Fupstream%2Fiotivity.git Update attributes name for notification. - Add prefix "x.org.iotivity.ns." Change-Id: I245e9c78b90019699e49a129b2910045eb5602b5 Signed-off-by: jake Reviewed-on: https://gerrit.iotivity.org/gerrit/17393 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- diff --git a/service/notification/cpp-wrapper/unittest/NSConsumerServiceSimulator.h b/service/notification/cpp-wrapper/unittest/NSConsumerServiceSimulator.h index c34af54..f279d80 100755 --- a/service/notification/cpp-wrapper/unittest/NSConsumerServiceSimulator.h +++ b/service/notification/cpp-wrapper/unittest/NSConsumerServiceSimulator.h @@ -67,9 +67,9 @@ class NSConsumerSimulator } OC::OCRepresentation rep; - rep.setValue("providerid", providerID); - rep.setValue("messageid", id); - rep.setValue("state", type); + rep.setValue("x.org.iotivity.ns.providerid", providerID); + rep.setValue("x.org.iotivity.ns.messageid", id); + rep.setValue("x.org.iotivity.ns.state", type); m_syncResource->post(rep, OC::QueryParamsMap(), &onPost, OC::QualityOfService::LowQos); } @@ -115,7 +115,7 @@ class NSConsumerSimulator { OC::QueryParamsMap map; - map.insert(std::pair(std::string("consumerid"), + map.insert(std::pair(std::string("x.org.iotivity.ns.consumerid"), std::string("123456789012345678901234567890123456"))); try @@ -160,14 +160,14 @@ class NSConsumerSimulator std::shared_ptr ) { - if (rep.getUri() == "/notification/message" && rep.hasAttribute("messageid") - && rep.getValue("messageid") != 1) + if (rep.getUri() == "/notification/message" && rep.hasAttribute("x.org.iotivity.ns.messageid") + && rep.getValue("x.org.iotivity.ns.messageid") != 1) { - m_messageFunc(int(rep.getValue("messageid")), - std::string(rep.getValueToString("title")), - std::string(rep.getValueToString("contenttext")), - std::string(rep.getValueToString("source"))); - if (rep.getValue("messageid") == 3) + m_messageFunc(int(rep.getValue("x.org.iotivity.ns.messageid")), + std::string(rep.getValueToString("x.org.iotivity.ns.title")), + std::string(rep.getValueToString("x.org.iotivity.ns.contenttext")), + std::string(rep.getValueToString(".x.org.iotivity.ns.source"))); + if (rep.getValue("x.org.iotivity.ns.messageid") == 3) { m_topicResource->get(OC::QueryParamsMap(), std::bind(&NSConsumerSimulator::onTopicGet, this, std::placeholders::_1, @@ -177,7 +177,7 @@ class NSConsumerSimulator } else if (rep.getUri() == "/notification/sync") { - m_syncFunc(int(rep.getValue("state")), int(rep.getValue("messageid"))); + m_syncFunc(int(rep.getValue("x.org.iotivity.ns.state")), int(rep.getValue("x.org.iotivity.ns.messageid"))); } } void onTopicGet(const OC::HeaderOptions &/*headerOption*/, diff --git a/service/notification/cpp-wrapper/unittest/NSProviderServiceSimulator.h b/service/notification/cpp-wrapper/unittest/NSProviderServiceSimulator.h index 229e24b..01f9ff3 100755 --- a/service/notification/cpp-wrapper/unittest/NSProviderServiceSimulator.h +++ b/service/notification/cpp-wrapper/unittest/NSProviderServiceSimulator.h @@ -123,11 +123,11 @@ class NSProviderSimulator std::string syncUri = m_notificationUri + m_syncUri; std::string topicUri = m_notificationUri + m_topicUri; std::string providerId = "123456789012345678901234567890123456"; - rep.setValue("subcontrollability", m_accepter); - rep.setValue("messageuri", msgUri); - rep.setValue("syncuri", syncUri); - rep.setValue("topicuri", topicUri); - rep.setValue("providerid", providerId); + rep.setValue("x.org.iotivity.ns.subcontrollability", m_accepter); + rep.setValue("x.org.iotivity.ns.messageuri", msgUri); + rep.setValue("x.org.iotivity.ns.syncuri", syncUri); + rep.setValue("x.org.iotivity.ns.topicuri", topicUri); + rep.setValue("x.org.iotivity.ns.providerid", providerId); } else if (type == requestType::NS_SYNC) { @@ -157,14 +157,14 @@ class NSProviderSimulator [& topicArr](const NS_TopicState & topicState) { OC::OCRepresentation topic; - topic.setValue("topicname", topicState.first); - topic.setValue("topicstate", (int) topicState.second); + topic.setValue("x.org.iotivity.ns.topicname", topicState.first); + topic.setValue("x.org.iotivity.ns.topicstate", (int) topicState.second); topicArr.push_back(topic); } ); rep.setValue> - ("topiclist", topicArr); + ("x.org.iotivity.ns.topiclist", topicArr); } else { @@ -182,8 +182,8 @@ class NSProviderSimulator m_syncRep = requests->getResourceRepresentation(); std::cout << "Receive POST for Sync" << std::endl; - std::cout << "provider Id : " << m_syncRep.getValueToString("providerid") << std::endl; - std::cout << "Sync State : " << m_syncRep.getValueToString("state") << std::endl; + std::cout << "provider Id : " << m_syncRep.getValueToString("x.org.iotivity.ns.providerid") << std::endl; + std::cout << "Sync State : " << m_syncRep.getValueToString("x.org.iotivity.ns.state") << std::endl; response->setResourceRepresentation(m_syncRep); @@ -195,15 +195,15 @@ class NSProviderSimulator { auto receivePayload = requests->getResourceRepresentation() - .getValue>("topiclist"); + .getValue>("x.org.iotivity.ns.topiclist"); std::for_each (receivePayload.begin(), receivePayload.end(), [this](const OC::OCRepresentation & rep) { - auto tmp = m_allowedTopicList.find(rep.getValueToString("topicname")); + auto tmp = m_allowedTopicList.find(rep.getValueToString("x.org.iotivity.ns.topicname")); if (tmp != m_allowedTopicList.end()) { - tmp->second = (TopicAllowState) rep.getValue("topicstate"); + tmp->second = (TopicAllowState) rep.getValue("x.org.iotivity.ns.topicstate"); } } ); @@ -234,8 +234,8 @@ class NSProviderSimulator { OC::OCRepresentation rep; std::string providerId = "123456789012345678901234567890123456"; - rep.setValue("messageid", (int)messageType::NS_ALLOW); - rep.setValue("providerid", providerId); + rep.setValue("x.org.iotivity.ns.messageid", (int)messageType::NS_ALLOW); + rep.setValue("x.org.iotivity.ns.providerid", providerId); auto response = std::make_shared(); response->setRequestHandle(requests->getRequestHandle()); @@ -306,27 +306,27 @@ class NSProviderSimulator void sendRead(const uint64_t &id) { std::string providerId = "123456789012345678901234567890123456"; - m_syncRep.setValue("messageid", id); - m_syncRep.setValue("state", (int)1); - m_syncRep.setValue("providerid", providerId); + m_syncRep.setValue("x.org.iotivity.ns.messageid", id); + m_syncRep.setValue("x.org.iotivity.ns.state", (int)1); + m_syncRep.setValue("x.org.iotivity.ns.providerid", providerId); OC::OCPlatform::notifyAllObservers(m_syncHandle); } void sendDismiss(const uint64_t &id) { std::string providerId = "123456789012345678901234567890123456"; - m_syncRep.setValue("messageid", id); - m_syncRep.setValue("state", (int)2); - m_syncRep.setValue("providerid", providerId); + m_syncRep.setValue("x.org.iotivity.ns.messageid", id); + m_syncRep.setValue("x.org.iotivity.ns.state", (int)2); + m_syncRep.setValue("x.org.iotivity.ns.providerid", providerId); OC::OCPlatform::notifyAllObservers(m_syncHandle); } void setMessage(const uint64_t &id, const std::string &title, const std::string &content) { std::string providerId = "123456789012345678901234567890123456"; - m_messageRep.setValue("messageid", id); - m_messageRep.setValue("title", title); - m_messageRep.setValue("contenttext", content); - m_messageRep.setValue("providerid", providerId); + m_messageRep.setValue("x.org.iotivity.ns.messageid", id); + m_messageRep.setValue("x.org.iotivity.ns.title", title); + m_messageRep.setValue("x.org.iotivity.ns.contenttext", content); + m_messageRep.setValue("x.org.iotivity.ns.providerid", providerId); } void setTopics(const NS_TopicList &topics) diff --git a/service/notification/src/common/NSConstants.h b/service/notification/src/common/NSConstants.h index df3dde1..8393531 100644 --- a/service/notification/src/common/NSConstants.h +++ b/service/notification/src/common/NSConstants.h @@ -76,9 +76,9 @@ #define THREAD_COUNT 5 // NOTIOBJ // -#define NOTIOBJ_TITLE_KEY "title" -#define NOTIOBJ_ID_KEY "id" -#define NOTOOBJ_CONTENT_KEY "contenttext" +#define NOTIOBJ_TITLE_KEY "x.org.iotivity.ns.title" +#define NOTIOBJ_ID_KEY "x.org.iotivity.ns.id" +#define NOTOOBJ_CONTENT_KEY "x.org.iotivity.ns.contenttext" #define DISCOVERY_TAG "NS_PROVIDER_DISCOVERY" #define SUBSCRIPTION_TAG "NS_PROVIDER_SUBSCRIPTION" @@ -96,7 +96,7 @@ #define NS_INTERFACE_READ "oic.if.r" #define NS_INTERFACE_READWRITE "oic.if.rw" -#define NS_INTERFACE_BASELINE "oic.if.baseline" +#define NS_INTERFACE_BASELINE "oic.if.baseline" #define NS_ROOT_URI "/notification" #define NS_COLLECTION_MESSAGE_URI "/notification/message" @@ -106,8 +106,8 @@ #define NS_QUERY_SEPARATOR "&;" #define NS_KEY_VALUE_DELIMITER "=" -#define NS_QUERY_CONSUMER_ID "consumerid" -#define NS_QUERY_PROVIDER_ID "providerid" +#define NS_QUERY_CONSUMER_ID "x.org.iotivity.ns.consumerid" +#define NS_QUERY_PROVIDER_ID "x.org.iotivity.ns.providerid" #define NS_QUERY_INTERFACE "if" #define NS_QUERY_ID_SIZE 10 @@ -118,8 +118,8 @@ #define NS_RD_PUBLISH_QUERY "/oic/rd?rt=oic.wk.rdpub" #ifdef WITH_MQ -#define NS_ATTRIBUTE_MQ_MESSAGE "message" -#define NS_ATTIRBUTE_MQ_TOPICLIST "topiclist" +#define NS_ATTRIBUTE_MQ_MESSAGE "x.org.iotivity.ns.message" +#define NS_ATTIRBUTE_MQ_TOPICLIST "x.org.iotivity.ns.topiclist" #endif #define NS_VERIFY_NOT_NULL_V(obj) \ @@ -205,26 +205,26 @@ #define VERSION "1.2.0" -#define NS_ATTRIBUTE_VERSION "version" -#define NS_ATTRIBUTE_POLICY "subcontrollability" -#define NS_ATTRIBUTE_MESSAGE "messageuri" -#define NS_ATTRIBUTE_SYNC "syncuri" -#define NS_ATTRIBUTE_TOPIC "topicuri" -#define NS_ATTRIBUTE_MESSAGE_ID "messageid" -#define NS_ATTRIBUTE_PROVIDER_ID "providerid" -#define NS_ATTRIBUTE_CONSUMER_ID "consumerid" -#define NS_ATTRIBUTE_TOPIC_LIST "topiclist" -#define NS_ATTRIBUTE_TOPIC_NAME "topicname" -#define NS_ATTRIBUTE_TOPIC_SELECTION "topicstate" -#define NS_ATTRIBUTE_TITLE "title" -#define NS_ATTRIBUTE_TEXT "contenttext" -#define NS_ATTRIBUTE_SOURCE "source" -#define NS_ATTRIBUTE_STATE "state" -#define NS_ATTRIBUTE_DEVICE "device" -#define NS_ATTRIBUTE_TYPE "type" -#define NS_ATTRIBUTE_DATETIME "datetime" -#define NS_ATTRIBUTE_TTL "ttl" -#define NS_ATTRIBUTE_ICON_IMAGE "iconimage" +#define NS_ATTRIBUTE_VERSION "x.org.iotivity.ns.version" +#define NS_ATTRIBUTE_POLICY "x.org.iotivity.ns.subcontrollability" +#define NS_ATTRIBUTE_MESSAGE "x.org.iotivity.ns.messageuri" +#define NS_ATTRIBUTE_SYNC "x.org.iotivity.ns.syncuri" +#define NS_ATTRIBUTE_TOPIC "x.org.iotivity.ns.topicuri" +#define NS_ATTRIBUTE_MESSAGE_ID "x.org.iotivity.ns.messageid" +#define NS_ATTRIBUTE_PROVIDER_ID "x.org.iotivity.ns.providerid" +#define NS_ATTRIBUTE_CONSUMER_ID "x.org.iotivity.ns.consumerid" +#define NS_ATTRIBUTE_TOPIC_LIST "x.org.iotivity.ns.topiclist" +#define NS_ATTRIBUTE_TOPIC_NAME "x.org.iotivity.ns.topicname" +#define NS_ATTRIBUTE_TOPIC_SELECTION "x.org.iotivity.ns.topicstate" +#define NS_ATTRIBUTE_TITLE "x.org.iotivity.ns.title" +#define NS_ATTRIBUTE_TEXT "x.org.iotivity.ns.contenttext" +#define NS_ATTRIBUTE_SOURCE "x.org.iotivity.ns.source" +#define NS_ATTRIBUTE_STATE "x.org.iotivity.ns.state" +#define NS_ATTRIBUTE_DEVICE "x.org.iotivity.ns.device" +#define NS_ATTRIBUTE_TYPE "x.org.iotivity.ns.type" +#define NS_ATTRIBUTE_DATETIME "x.org.iotivity.ns.datetime" +#define NS_ATTRIBUTE_TTL "x.org.iotivity.ns.ttl" +#define NS_ATTRIBUTE_ICON_IMAGE "x.org.iotivity.ns.iconimage" typedef enum eConnectionState { diff --git a/service/notification/unittest/NSConsumerSimulator.h b/service/notification/unittest/NSConsumerSimulator.h index 328c6f6..359b831 100644 --- a/service/notification/unittest/NSConsumerSimulator.h +++ b/service/notification/unittest/NSConsumerSimulator.h @@ -69,9 +69,9 @@ public: } OC::OCRepresentation rep; - rep.setValue("providerid", providerID); - rep.setValue("messageid", id); - rep.setValue("state", type); + rep.setValue("x.org.iotivity.ns.providerid", providerID); + rep.setValue("x.org.iotivity.ns.messageid", id); + rep.setValue("x.org.iotivity.ns.state", type); m_syncResource->post(rep, OC::QueryParamsMap(), &onPost, OC::QualityOfService::LowQos); } @@ -113,7 +113,7 @@ private: std::shared_ptr resource) { OC::QueryParamsMap map; - map.insert(std::pair(std::string("consumerid"), + map.insert(std::pair(std::string("x.org.iotivity.ns.consumerid"), std::string("123456789012345678901234567890123456"))); try @@ -158,15 +158,15 @@ private: const OC::OCRepresentation &rep , const int & /*eCode*/, const int &, std::shared_ptr ) { - if (rep.getUri() == "/notification/message" && rep.hasAttribute("messageid") - && rep.getValue("messageid") != 1) + if (rep.getUri() == "/notification/message" && rep.hasAttribute("x.org.iotivity.ns.messageid") + && rep.getValue("x.org.iotivity.ns.messageid") != 1) { - m_messageFunc(int(rep.getValue("messageid")), - std::string(rep.getValueToString("title")), - std::string(rep.getValueToString("contenttext")), - std::string(rep.getValueToString("source"))); + m_messageFunc(int(rep.getValue("x.org.iotivity.ns.messageid")), + std::string(rep.getValueToString("x.org.iotivity.ns.title")), + std::string(rep.getValueToString("x.org.iotivity.ns.contenttext")), + std::string(rep.getValueToString("x.org.iotivity.ns.source"))); - if(rep.getValue("messageid") == 3) + if(rep.getValue("x.org.iotivity.ns.messageid") == 3) { m_topicResource->get(std::string("x.org.iotivity.notification"), std::string("oic.if.baseline"), OC::QueryParamsMap(), @@ -177,7 +177,7 @@ private: } else if (rep.getUri() == "/notification/sync") { - m_syncFunc(int(rep.getValue("state")), int(rep.getValue("messageid"))); + m_syncFunc(int(rep.getValue("x.org.iotivity.ns.state")), int(rep.getValue("x.org.iotivity.ns.messageid"))); } } @@ -192,7 +192,7 @@ private: OC::OCRepresentation postRep; std::vector topicArr = - rep.getValue>("topiclist"); + rep.getValue>("x.org.iotivity.ns.topiclist"); std::vector postTopicArr; @@ -203,8 +203,8 @@ private: OC::OCRepresentation topic = *it; OC::OCRepresentation postTopic; - postTopic.setValue("topicname", topic.getValueToString("topicname")); - postTopic.setValue("topicstate", (int) topic.getValue("topicstate")); + postTopic.setValue("x.org.iotivity.ns.topicname", topic.getValueToString("x.org.iotivity.ns.topicname")); + postTopic.setValue("x.org.iotivity.ns.topicstate", (int) topic.getValue("x.org.iotivity.ns.topicstate")); postTopicArr.push_back(topic); @@ -213,10 +213,10 @@ private: } postRep.setValue> - ("topiclist", postTopicArr); + ("x.org.iotivity.ns.topiclist", postTopicArr); OC::QueryParamsMap map; - map.insert(std::pair(std::string("consumerid"), + map.insert(std::pair(std::string("x.org.iotivity.ns.consumerid"), std::string("123456789012345678901234567890123456"))); m_topicResource->post(postRep, map, &onPost, OC::QualityOfService::LowQos); } diff --git a/service/notification/unittest/NSProviderSimulator.h b/service/notification/unittest/NSProviderSimulator.h index 31d4781..c66dc37 100644 --- a/service/notification/unittest/NSProviderSimulator.h +++ b/service/notification/unittest/NSProviderSimulator.h @@ -124,11 +124,11 @@ private: std::string syncUri = m_notificationUri + m_syncUri; std::string topicUri = m_notificationUri + m_topicUri; std::string providerId = "123456789012345678901234567890123456"; - rep.setValue("subcontrollability", m_accepter); - rep.setValue("messageuri", msgUri); - rep.setValue("syncuri", syncUri); - rep.setValue("topicuri", topicUri); - rep.setValue("providerid", providerId); + rep.setValue("x.org.iotivity.ns.subcontrollability", m_accepter); + rep.setValue("x.org.iotivity.ns.messageuri", msgUri); + rep.setValue("x.org.iotivity.ns.syncuri", syncUri); + rep.setValue("x.org.iotivity.ns.topicuri", topicUri); + rep.setValue("x.org.iotivity.ns.providerid", providerId); } else if (type == requestType::NS_SYNC) { @@ -158,14 +158,14 @@ private: [& topicArr](const NS_TopicState & topicState) { OC::OCRepresentation topic; - topic.setValue("topicname", topicState.first); - topic.setValue("topicstate", (int) topicState.second); + topic.setValue("x.org.iotivity.ns.topicname", topicState.first); + topic.setValue("x.org.iotivity.ns.topicstate", (int) topicState.second); topicArr.push_back(topic); } ); rep.setValue> - ("topiclist", topicArr); + ("x.org.iotivity.ns.topiclist", topicArr); } else { @@ -183,8 +183,8 @@ private: m_syncRep = requests->getResourceRepresentation(); std::cout << "Receive POST for Sync" << std::endl; - std::cout << "provider Id : " << m_syncRep.getValueToString("providerid") << std::endl; - std::cout << "Sync State : " << m_syncRep.getValueToString("state") << std::endl; + std::cout << "provider Id : " << m_syncRep.getValueToString("x.org.iotivity.ns.providerid") << std::endl; + std::cout << "Sync State : " << m_syncRep.getValueToString("x.org.iotivity.ns.state") << std::endl; response->setResourceRepresentation(m_syncRep); @@ -196,15 +196,15 @@ private: { auto receivePayload = requests->getResourceRepresentation() - .getValue>("topiclist"); + .getValue>("x.org.iotivity.ns.topiclist"); std::for_each (receivePayload.begin(), receivePayload.end(), [this](const OC::OCRepresentation & rep) { - auto tmp = m_allowedTopicList.find(rep.getValueToString("topicname")); + auto tmp = m_allowedTopicList.find(rep.getValueToString("x.org.iotivity.ns.topicname")); if (tmp != m_allowedTopicList.end()) { - tmp->second = (TopicAllowState) rep.getValue("topicstate"); + tmp->second = (TopicAllowState) rep.getValue("x.org.iotivity.ns.topicstate"); } } ); @@ -235,8 +235,8 @@ private: { OC::OCRepresentation rep; std::string providerId = "123456789012345678901234567890123456"; - rep.setValue("messageid", (int)messageType::NS_ALLOW); - rep.setValue("providerid", providerId); + rep.setValue("x.org.iotivity.ns.messageid", (int)messageType::NS_ALLOW); + rep.setValue("x.org.iotivity.ns.providerid", providerId); auto response = std::make_shared(); response->setRequestHandle(requests->getRequestHandle()); @@ -307,27 +307,27 @@ public: void sendRead(const uint64_t & id) { std::string providerId = "123456789012345678901234567890123456"; - m_syncRep.setValue("messageid", id); - m_syncRep.setValue("state", (int)1); - m_syncRep.setValue("providerid", providerId); + m_syncRep.setValue("x.org.iotivity.ns.messageid", id); + m_syncRep.setValue("x.org.iotivity.ns.state", (int)1); + m_syncRep.setValue("x.org.iotivity.ns.providerid", providerId); OC::OCPlatform::notifyAllObservers(m_syncHandle); } void sendDismiss(const uint64_t & id) { std::string providerId = "123456789012345678901234567890123456"; - m_syncRep.setValue("messageid", id); - m_syncRep.setValue("state", (int)2); - m_syncRep.setValue("providerid", providerId); + m_syncRep.setValue("x.org.iotivity.ns.messageid", id); + m_syncRep.setValue("x.org.iotivity.ns.state", (int)2); + m_syncRep.setValue("x.org.iotivity.ns.providerid", providerId); OC::OCPlatform::notifyAllObservers(m_syncHandle); } void setMessage(const uint64_t & id, const std::string & title, const std::string & content) { std::string providerId = "123456789012345678901234567890123456"; - m_messageRep.setValue("messageid", id); - m_messageRep.setValue("title", title); - m_messageRep.setValue("contenttext", content); - m_messageRep.setValue("providerid", providerId); + m_messageRep.setValue("x.org.iotivity.ns.messageid", id); + m_messageRep.setValue("x.org.iotivity.ns.title", title); + m_messageRep.setValue("x.org.iotivity.ns.contenttext", content); + m_messageRep.setValue("x.org.iotivity.ns.providerid", providerId); } void setTopics(const NS_TopicList & topics)