NS_LOG_V(DEBUG, "provider Id : %s", provider->providerId);\r
NS_LOG_V(DEBUG, "state : %d", (int)state);\r
\r
- NSProvider *nsProvider = new NSProvider(provider);\r
- NSProvider *oldProvider = NSConsumerService::getInstance()->getProvider(\r
- nsProvider->getProviderId());\r
+ std::string provId;\r
+ provId.assign(provider->providerId, NS_UTILS_UUID_STRING_SIZE - 1);\r
+ NSProvider *oldProvider = NSConsumerService::getInstance()->getProvider(provId);\r
\r
if (oldProvider == nullptr)\r
{\r
+ NSProvider *nsProvider = new NSProvider(provider);\r
NS_LOG(DEBUG, "Provider with same Id do not exist. updating Data for New Provider");\r
auto discoveredCallback = NSConsumerService::getInstance()->getProviderDiscoveredCb();\r
nsProvider->setProviderState((NSProviderState)state);\r
NS_LOG(DEBUG, "Provider with same Id exists. updating the old Provider data");\r
auto changeCallback = oldProvider->getProviderStateReceivedCb();\r
oldProvider->setProviderState((NSProviderState)state);\r
- delete nsProvider;\r
if (state == NS_ALLOW)\r
{\r
oldProvider->setProviderSubscribedState(NSProviderSubscribedState::SUBSCRIBED);\r
NS_LOG_V(DEBUG, "calling Lower layer UpdateTopicList for Provider Id : %s",\r
getProviderId().c_str());\r
NSResult result = (NSResult) NSConsumerUpdateTopicList(getProviderId().c_str(), topicLL);\r
+\r
+ if(topicLL);\r
+ {\r
+ NSTopicLL * iter = topicLL;\r
+ NSTopicLL * following = NULL;\r
+\r
+ while (iter)\r
+ {\r
+ following = iter->next;\r
+ if(iter);\r
+ {\r
+ NSOICFree(iter->topicName);\r
+ iter->next = NULL;\r
+ NSOICFree(iter);\r
+ }\r
+ iter = following;\r
+ }\r
+ }\r
NS_LOG(DEBUG, "updateTopicList - OUT");\r
return result;\r
}\r
******************************************************************/\r
\r
#include <iostream>\r
+#include <limits>\r
\r
#include <unistd.h>\r
#include "NSConsumerService.h"\r
topicList->addTopic("OCF_TOPIC3", NSTopic::NSTopicState::UNSUBSCRIBED);\r
\r
provider->updateTopicList(topicList);\r
+ delete topicList;\r
+ delete provider;\r
}\r
}\r
break;\r
#endif\r
case 6:\r
std::cout << "6. Exit" << std::endl;\r
+ NSConsumerService::getInstance()->stop();\r
isExit = true;\r
break;\r
default:\r
+ std::cin.clear();\r
+ std::cin.ignore(numeric_limits<streamsize>::max(), '\n');\r
break;\r
}\r
}\r
std::cout << "12. Disable NS Provider RemoteService" << std::endl;\r
#endif\r
std::cout << "13. Stop the Notification Provider" << std::endl;\r
- std::cout << "0. Exit()" << std::endl;\r
+ std::cout << "14. Exit()" << std::endl;\r
\r
std::cout << "input : ";\r
\r
case 13:\r
NSProviderService::getInstance()->stop();\r
break;\r
- case 0:\r
+ case 14:\r
NSProviderService::getInstance()->stop();\r
isExit = true;\r
break;\r
default:\r
std::cout << "Under Construction" << std::endl;\r
+ std::cin.clear();\r
+ std::cin.ignore(numeric_limits<streamsize>::max(), '\n');\r
break;\r
}\r
\r
nsConfig.resourceSecurity = config.resourceSecurity;\r
\r
NSResult result = (NSResult) NSStartProvider(nsConfig);\r
+ OICFree(nsConfig.userInfo);\r
NS_LOG(DEBUG, "start - OUT");\r
return result;\r
}\r
\r
NS_LOG_V(DEBUG, "nsMsg->providerId : %s", nsMsg->providerId);\r
result = (NSResult) NSSendMessage(nsMsg);\r
+ OICFree(nsMsg->dateTime);\r
+ OICFree(nsMsg->title);\r
+ OICFree(nsMsg->contentText);\r
+ OICFree(nsMsg->sourceName);\r
+ OICFree(nsMsg->topic);\r
+ OICFree(nsMsg->extraInfo);\r
delete nsMsg->mediaContents;\r
delete nsMsg;\r
}\r
NS_LOG_V(DEBUG, "Provider ID : %s", nsMessage->getProviderId().c_str());\r
NS_LOG(DEBUG, "createMessage - OUT");\r
\r
+ OICFree(message);\r
return nsMessage;\r
}\r
\r