SConscript('android/SConscript')
# Go to build c++ wrapper
-SConscript('cpp-wrapper/SConscript')
+#SConscript('cpp-wrapper/SConscript')
OICStrcpy(mainConsumer, 37, consumer->consumerId);
}
- NSAcceptSubscription(consumer, true);
+ NSAcceptSubscription(consumer->consumerId, true);
}
void syncCallback(NSSyncInfo *sync)
case 5:
printf("NSProviderAddTopic\n");
- NSProviderAddTopic("OCF_TOPIC1");
- NSProviderAddTopic("OCF_TOPIC2");
- NSProviderAddTopic("OCF_TOPIC3");
- NSProviderAddTopic("OCF_TOPIC4");
+ NSProivderRegisterTopic("OCF_TOPIC1");
+ NSProivderRegisterTopic("OCF_TOPIC2");
+ NSProivderRegisterTopic("OCF_TOPIC3");
+ NSProivderRegisterTopic("OCF_TOPIC4");
break;
case 6:
printf("NSProviderDeleteTopic\n");
- NSProviderDeleteTopic("OCF_TOPIC2");
+ NSProviderUnregisterTopic("OCF_TOPIC2");
break;
case 7:
printf("NSProviderSelectTopic\n");
- NSProviderSelectTopic(mainConsumer, "OCF_TOPIC1");
- NSProviderSelectTopic(mainConsumer, "OCF_TOPIC2");
- NSProviderSelectTopic(mainConsumer, "OCF_TOPIC3");
- NSProviderSelectTopic(mainConsumer, "OCF_TOPIC4");
+ NSProviderSetConsumerTopic(mainConsumer, "OCF_TOPIC1");
+ NSProviderSetConsumerTopic(mainConsumer, "OCF_TOPIC2");
+ NSProviderSetConsumerTopic(mainConsumer, "OCF_TOPIC3");
+ NSProviderSetConsumerTopic(mainConsumer, "OCF_TOPIC4");
break;
case 8:
printf("NSProviderUnSelectTopic\n");
- NSProviderUnselectTopic(mainConsumer, "OCF_TOPIC1");
+ NSProviderUnsetConsumerTopic(mainConsumer, "OCF_TOPIC1");
break;
case 9:
* @param[in] server address combined with IP address and port number using delimiter :\r
* @return ::NS_OK or result code of NSResult\r
*/\r
-NSResult NSProviderEnableRemoteService(char *serverAddress);\r
+NSResult NSProviderEnableRemoteService(char * serverAddress);\r
\r
/**\r
* Request to cancel remote service using cloud server\r
* @param[in] server address combined with IP address and port number using delimiter :\r
* @return ::NS_OK or result code of NSResult\r
*/\r
-NSResult NSProviderDisableRemoteService(char *serverAddress);\r
+NSResult NSProviderDisableRemoteService(char * serverAddress);\r
\r
/**\r
* Send notification message to all subscribers\r
* @param[in] message Notification message including id, title, contentText\r
* @return ::NS_OK or result code of NSResult\r
*/\r
-NSResult NSSendMessage(NSMessage *msg);\r
+NSResult NSSendMessage(NSMessage * msg);\r
\r
/**\r
* Send acceptance to consumer who subscribes the resource of notification message\r
* @param[in] accepted the result of acceptance; Allow or Deny\r
* @return ::NS_OK or result code of NSResult\r
*/\r
-NSResult NSAcceptSubscription(NSConsumer *consumer, bool accepted);\r
+NSResult NSAcceptSubscription(const char * consumerId, bool accepted);\r
\r
/**\r
* Get consumer list that is stored in the cache of notification service\r
* @param[in] topicName Topic name to add\r
* @return ::NS_OK or result code of NSResult\r
*/\r
-NSResult NSProviderAddTopic(char* topicName);\r
+NSResult NSProivderRegisterTopic(const char * topicName);\r
\r
/**\r
* Delete topic from topic list\r
* @param[in] topicName Topic name to delete\r
* @return ::NS_OK or result code of NSResult\r
*/\r
-NSResult NSProviderDeleteTopic(char* topicName);\r
+NSResult NSProviderUnregisterTopic(const char * topicName);\r
\r
/**\r
* Select a topic name for a consumer\r
* @param[in] topicName Topic name to select\r
* @return ::NS_OK or result code of NSResult\r
*/\r
-NSResult NSProviderSelectTopic(char* consumerId, char* topicName);\r
+NSResult NSProviderSetConsumerTopic(const char * consumerId, const char * topicName);\r
\r
/**\r
* Unselect a topic from the topic list for consumer\r
* @param[in] topicName Topic name to unselect\r
* @return ::NS_OK or result code of NSResult\r
*/\r
-NSResult NSProviderUnselectTopic(char* consumerId, char* topicName);\r
+NSResult NSProviderUnsetConsumerTopic(const char * consumerId, const char * topicName);\r
\r
/**\r
* Request topic list with selection state for the consumer\r
* @param[in] consumerid the id of consumer which topic list is subscribed for\r
* @return :: Topic list\r
*/\r
-NSTopicLL * NSProviderGetConsumerTopics(char *consumerId);\r
+NSTopicLL * NSProviderGetConsumerTopics(const char * consumerId);\r
\r
/**\r
* Request topics list already registered by provider user\r
return NS_OK;\r
}\r
\r
-NSResult NSProviderEnableRemoteService(char *serverAddress)\r
+NSResult NSProviderEnableRemoteService(char * serverAddress)\r
{\r
NS_LOG(DEBUG, "NSProviderEnableRemoteService - IN");\r
pthread_mutex_lock(&nsInitMutex);\r
return NS_OK;\r
}\r
\r
-NSResult NSSendMessage(NSMessage *msg)\r
+NSResult NSSendMessage(NSMessage * msg)\r
{\r
NS_LOG(DEBUG, "NSSendNotification - IN");\r
\r
return NS_OK;\r
}\r
\r
-NSResult NSAcceptSubscription(NSConsumer *consumer, bool accepted)\r
+NSResult NSAcceptSubscription(const char * consumerId, bool accepted)\r
{\r
NS_LOG(DEBUG, "NSAccept - IN");\r
\r
pthread_mutex_lock(&nsInitMutex);\r
\r
- NSConsumer * newConsumer = NSDuplicateConsumer(consumer);\r
+ char * newConsumerId = OICStrdup(consumerId);\r
if(accepted)\r
{\r
NS_LOG(DEBUG, "accepted is true - ALLOW");\r
- NSPushQueue(SUBSCRIPTION_SCHEDULER, TASK_SEND_ALLOW, newConsumer);\r
+ NSPushQueue(SUBSCRIPTION_SCHEDULER, TASK_SEND_ALLOW, newConsumerId);\r
}\r
else\r
{\r
NS_LOG(DEBUG, "accepted is false - DENY");\r
- NSPushQueue(SUBSCRIPTION_SCHEDULER, TASK_SEND_DENY, newConsumer);\r
+ NSPushQueue(SUBSCRIPTION_SCHEDULER, TASK_SEND_DENY, newConsumerId);\r
}\r
\r
pthread_mutex_unlock(&nsInitMutex);\r
return msg;\r
}\r
\r
-NSTopicLL * NSProviderGetConsumerTopics(char *consumerId)\r
+NSTopicLL * NSProviderGetConsumerTopics(const char * consumerId)\r
{\r
NS_LOG(DEBUG, "NSProviderGetConsumerTopics - IN");\r
pthread_mutex_lock(&nsInitMutex);\r
return topics;\r
}\r
\r
-NSResult NSProviderAddTopic(char *topicName)\r
+NSResult NSProviderRegisterTopic(const char * topicName)\r
{\r
NS_LOG(DEBUG, "NSProviderAddTopics - IN");\r
pthread_mutex_lock(&nsInitMutex);\r
return NS_OK;\r
}\r
\r
-NSResult NSProviderDeleteTopic(char *topicName)\r
+NSResult NSProviderUnregisterTopic(const char * topicName)\r
{\r
NS_LOG(DEBUG, "NSProviderDeleteTopics - IN");\r
pthread_mutex_lock(&nsInitMutex);\r
return NS_OK;\r
}\r
\r
-NSResult NSProviderSelectTopic(char *consumerId, char *topicName)\r
+NSResult NSProviderSetConsumerTopic(const char * consumerId, const char * topicName)\r
{\r
NS_LOG(DEBUG, "NSProviderSelectTopics - IN");\r
pthread_mutex_lock(&nsInitMutex);\r
return NS_OK;\r
}\r
\r
-NSResult NSProviderUnselectTopic(char *consumerId, char *topicName)\r
+NSResult NSProviderUnsetConsumerTopic(const char * consumerId, const char * topicName)\r
{\r
NS_LOG(DEBUG, "NSProviderUnselectTopics - IN");\r
pthread_mutex_lock(&nsInitMutex);\r
case TASK_SEND_ALLOW:\r
{\r
NS_LOG(DEBUG, "CASE TASK_SEND_ALLOW : ");\r
- NSConsumer * consumer = (NSConsumer *) node->taskData;\r
+ char * consumerId = (char *) node->taskData;\r
\r
- NSCacheUpdateSubScriptionState(consumerSubList, consumer->consumerId, true);\r
- NSSendResponse(consumer->consumerId, true);\r
- NSFreeConsumer(consumer);\r
+ NSCacheUpdateSubScriptionState(consumerSubList, consumerId, true);\r
+ NSSendResponse(consumerId, true);\r
+ OICFree(consumerId);\r
break;\r
}\r
case TASK_SEND_DENY:\r
{\r
NS_LOG(DEBUG, "CASE TASK_SEND_DENY : ");\r
- NSConsumer * consumer = (NSConsumer *) node->taskData;\r
+ char * consumerId = (char *) node->taskData;\r
\r
- NSCacheUpdateSubScriptionState(consumerSubList, consumer->consumerId, false);\r
- NSSendResponse(consumer->consumerId, false);\r
- NSFreeConsumer(consumer);\r
+ NSCacheUpdateSubScriptionState(consumerSubList, consumerId, false);\r
+ NSSendResponse(consumerId, false);\r
+ NSFreeConsumer(consumerId);\r
\r
break;\r
}\r
std::mutex mutexForCondition;
NSConsumerSimulator g_consumerSimul;
- NSConsumer * g_consumer;
+ char * g_consumerID;
}
class TestWithMock: public testing::Test
TEST_F(NotificationProviderTest, ExpectCallbackWhenReceiveSubscribeRequestWithAccepterProvider)
{
- g_consumer = NULL;
+ g_consumerID = NULL;
mocks.OnCallFunc(NSRequestedSubscribeCallbackEmpty).Do(
[](NSConsumer * consumer)
{
std::cout << "NSRequestedSubscribeCallback" << std::endl;
- g_consumer = (NSConsumer *)malloc(sizeof(NSConsumer));
- strncpy(g_consumer->consumerId , consumer->consumerId, 37);
+ g_consumerID = strdup(consumer->consumerId);
responseCon.notify_all();
});
std::unique_lock< std::mutex > lock{ mutexForCondition };
responseCon.wait_for(lock, std::chrono::milliseconds(1000));
- EXPECT_NE((void*)g_consumer, (void*)NULL);
+ EXPECT_NE((void*)g_consumerID, (void*)NULL);
}
TEST_F(NotificationProviderTest, NeverCallNotifyOnConsumerByAcceptIsFalse)
}
});
- NSAcceptSubscription(g_consumer, false);
+ NSAcceptSubscription(g_consumerID, false);
NSMessage * msg = NSCreateMessage();
msgID = (int)msg->messageId;
EXPECT_EQ(expectTrue, true);
- NSAcceptSubscription(g_consumer, true);
+ NSAcceptSubscription(g_consumerID, true);
}
TEST_F(NotificationProviderTest, ExpectCallNotifyOnConsumerByAcceptIsTrue)
}
});
- NSAcceptSubscription(g_consumer, true);
+ NSAcceptSubscription(g_consumerID, true);
NSMessage * msg = NSCreateMessage();
msgID = (int)msg->messageId;