1)Moved cloud services in NS Wrapper code inside WITH_CLOUD option built in scons.
2)Refractered the code to move the includes into cpp files.
patch 1 : initial commit
patch 2 : updated with review comments
Change-Id: Icce8f9dbbbec17cea944a8db0aa3ec284b3bf5d4
Signed-off-by: abitha.s <abitha.s@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9981
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
SConscript('android/SConscript')
# Go to build c++ wrapper
-#SConscript('cpp-wrapper/SConscript')
\ No newline at end of file
+SConscript('cpp-wrapper/SConscript')
\ No newline at end of file
--- /dev/null
+//******************************************************************\r
+//\r
+// Copyright 2016 Samsung Electronics All Rights Reserved.\r
+//\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+\r
+/**\r
+ * @file\r
+ *\r
+ * This file contains Notification service Error Codes.\r
+ */\r
+\r
+#ifndef _NS_ERROR_CODE_H_\r
+#define _NS_ERROR_CODE_H_\r
+\r
+\r
+namespace OIC\r
+{\r
+ namespace Service\r
+ {\r
+ /** Result - enumeration for NS service Result*/\r
+ enum class Result\r
+ {\r
+ OK = 100,\r
+ ERROR = 200,\r
+ SUCCESS = 300,\r
+ FAIL = 400,\r
+ ALLOW = 500,\r
+ DENY = 600,\r
+ };\r
+ }\r
+}\r
+#endif /* _NS_ERROR_CODE_H_ */\r
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
\r
#include "NSMediaContents.h"\r
+#include "string.h"\r
\r
namespace OIC\r
{\r
\r
#include <string>\r
#include "NSCommon.h"\r
-#include "oic_string.h"\r
-#include "string.h"\r
\r
namespace OIC\r
{\r
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
\r
#include "NSMessage.h"\r
+#include "string.h"\r
+#include <cstdint>\r
\r
namespace OIC\r
{\r
return m_mediaContents;\r
}\r
\r
+ void NSMessage::setMessageId(const uint64_t &messageId)\r
+ {\r
+ m_messageId = messageId;\r
+ }\r
+\r
+ void NSMessage::setProviderId(const std::string &providerId)\r
+ {\r
+ m_providerId = providerId;\r
+ }\r
+\r
void NSMessage::setType(const NSMessageType &type)\r
{\r
m_type = type;\r
#ifndef _NS_MESSAGE_H_\r
#define _NS_MESSAGE_H_\r
\r
+#include <string>\r
#include "NSMediaContents.h"\r
-#include "oic_string.h"\r
-#include <cstdint>\r
-#include "string.h"\r
\r
namespace OIC\r
{\r
uint64_t getMessageId() const;\r
\r
/**\r
+ * This method is for setting Message Id from the Notification service Message.\r
+ *\r
+ * @param messageId as uint64_t.\r
+ */\r
+ void setMessageId(const uint64_t &messageId);\r
+\r
+ /**\r
* This method is for getting Provider Id from the Notification service Message.\r
*\r
* @return Id as string.\r
std::string getProviderId() const;\r
\r
/**\r
+ * This method is for setting Provider Id from the Notification service Message.\r
+ *\r
+ * @param providerId as string.\r
+ */\r
+ void setProviderId(const std::string &providerId);\r
+\r
+ /**\r
* This method is for getting type from the Notification service Message.\r
*\r
* @return type as NSMessageType.\r
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
\r
#include "NSSyncInfo.h"\r
+#include "string.h"\r
\r
namespace OIC\r
{\r
\r
#include <string>\r
#include "NSCommon.h"\r
-#include "oic_string.h"\r
-#include "string.h"\r
\r
namespace OIC\r
{\r
notification_env.PrependUnique(LIBS = [
'oc_logger',
- 'libnotification_consumer'
+ 'notification_consumer'
])
notification_env.AppendUnique(CXXFLAGS = ['-O2', '-Wall', '-fmessage-length=0', '-std=c++0x','-frtti'])
if target_os == 'android':
notification_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
notification_env.PrependUnique(LIBS = ['gnustl_shared', 'log'])
+if env.get('WITH_CLOUD') == True:
+ notification_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
+
######################################################################
# Source files and Targets
######################################################################
consumersdk = notification_env.SharedLibrary('notification_consumer_wrapper', notification_consumer_src)
notification_env.InstallTarget(consumersdk, 'libnotification_consumer_wrapper')
notification_env.UserInstallTargetLib(consumersdk, 'libnotification_consumer_wrapper')
+
+consumersdk = notification_env.StaticLibrary('notification_consumer_wrapper', notification_consumer_src)
+notification_env.InstallTarget(consumersdk, 'libnotification_consumer_wrapper')
+notification_env.UserInstallTargetLib(consumersdk, 'libnotification_consumer_wrapper')
#ifndef _NS_CONSUMER_SERVICE_H_\r
#define _NS_CONSUMER_SERVICE_H_\r
\r
-#include "NSCommon.h"\r
-#include "NSConsumerInterface.h"\r
#include <list>\r
#include <algorithm>\r
-#include "NSConstants.h"\r
+#include "NSProvider.h"\r
+#include "NSErrorCode.h"\r
\r
\r
namespace OIC\r
{\r
namespace Service\r
{\r
- class NSProvider;\r
/**\r
* @class NSConsumerService\r
* @brief This class provides a set of C++APIs for Notification Consumer.\r
/**\r
* Request to discover to remote address as parameter.\r
* @param[in] server address combined with IP address and port number using delimiter :\r
- * @return result code of NSResult\r
+ * @return result code of Consumer Service\r
*/\r
- NSResult EnableRemoteService(const std::string &serverAddress);\r
+ Result EnableRemoteService(const std::string &serverAddress);\r
\r
/**\r
* Request discovery manually\r
\r
\r
#include <string>\r
-#include <cstring>\r
-#include "oic_string.h"\r
#include "NSSyncInfo.h"\r
-#include "NSConstants.h"\r
+#include "NSMessage.h"\r
\r
namespace OIC\r
{\r
namespace Service\r
{\r
- class NSMessage;\r
- class NSSyncInfo;\r
/**\r
* @class NSProvider\r
* @brief This class provides a set of Notification service Provider representation APIs.\r
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
\r
#include "NSConsumerService.h"\r
-#include "NSProvider.h"\r
+#include <cstring>\r
+#include "NSConsumerInterface.h"\r
#include "NSMessage.h"\r
+#include "NSCommon.h"\r
+#include "NSConstants.h"\r
+#include "oic_string.h"\r
\r
namespace OIC\r
{\r
return;\r
}\r
\r
- NSResult NSConsumerService::EnableRemoteService(const std::string &serverAddress)\r
+ Result NSConsumerService::EnableRemoteService(const std::string &serverAddress)\r
{\r
NS_LOG(DEBUG, "EnableRemoteService - IN");\r
- NSResult result = NSConsumerEnableRemoteService(OICStrdup(serverAddress.c_str()));\r
+ Result result = Result::ERROR;\r
+#ifdef WITH_CLOUD\r
+ result = (Result) NSConsumerEnableRemoteService(OICStrdup(serverAddress.c_str()));\r
+#else\r
+ NS_LOG(ERROR, "Remote Services feature is not enabled in the Build");\r
+#endif\r
NS_LOG(DEBUG, "EnableRemoteService - OUT");\r
return result;\r
}\r
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
\r
#include "NSProvider.h"\r
+#include <cstring>\r
#include "NSConsumerInterface.h"\r
+#include "NSConstants.h"\r
+#include "NSCommon.h"\r
+#include "oic_string.h"\r
\r
namespace OIC\r
{\r
+#******************************************************************
+#
+# Copyright 2016 Samsung Electronics All Rights Reserved.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
##
# Notification build script
##
if not env.get('RELEASE'):
notification_sample_env.AppendUnique(LIBS = ['log'])
+
+if env.get('WITH_CLOUD') == True:
+ notification_sample_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
+
####################################################################
# Source files and Targets
######################################################################
\r
std::cout << "1. Start Consumer" << std::endl;\r
std::cout << "2. Stop Consumer" << std::endl;\r
+#ifdef WITH_CLOUD\r
std::cout << "3. Enable NS Consumer RemoteService" << std::endl;\r
+#endif\r
std::cout << "5. Exit" << std::endl;\r
\r
std::cout << "Input: " << std::endl;\r
std::cout << "2. Stop the Notification Consumer" << std::endl;\r
NSConsumerService::getInstance()->Stop();\r
break;\r
+#ifdef WITH_CLOUD\r
case 3:\r
{\r
std::cout << "3. Enable NS Consumer RemoteService" << std::endl;\r
NSConsumerService::getInstance()->EnableRemoteService(REMOTE_SERVER_ADDRESS);\r
break;\r
}\r
+#endif\r
case 5:\r
std::cout << "5. Exit" << std::endl;\r
isExit = true;\r
std::cout << "2. Start the Notification Provider(Accepter: Consumer)" << std::endl;\r
std::cout << "3. SendMessage " << std::endl;\r
std::cout << "4. SendSyncInfo" << std::endl;\r
+#ifdef WITH_CLOUD\r
std::cout << "5. Enable NS Provider RemoteService" << std::endl;\r
std::cout << "6. Disable NS Provider RemoteService" << std::endl;\r
+#endif\r
std::cout << "9. Stop the Notification Provider" << std::endl;\r
std::cout << "0. Exit()" << std::endl;\r
\r
OIC::Service::NSSyncInfo::NSSyncType::NS_SYNC_READ);\r
break;\r
}\r
+#ifdef WITH_CLOUD\r
case 5:\r
{\r
std::cout << "3. Enable NS Provider RemoteService" << std::endl;\r
NSProviderService::getInstance()->DisableRemoteService(REMOTE_SERVER_ADDRESS);\r
break;\r
}\r
+#endif\r
case 9:\r
NSProviderService::getInstance()->Stop();\r
break;\r
notification_env.PrependUnique(LIBS = [
'oc_logger',
- 'libnotification_provider'
+ 'notification_provider'
])
notification_env.AppendUnique(CXXFLAGS = ['-O2', '-Wall', '-fmessage-length=0', '-std=c++0x','-frtti'])
if target_os == 'android':
notification_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
notification_env.PrependUnique(LIBS = ['gnustl_shared', 'log'])
+if env.get('WITH_CLOUD') == True:
+ notification_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
+
######################################################################
# Source files and Targets
######################################################################
providersdk = notification_env.SharedLibrary('notification_provider_wrapper', notification_provider_src)
notification_env.InstallTarget(providersdk, 'libnotification_provider_wrapper')
notification_env.UserInstallTargetLib(providersdk, 'libnotification_provider_wrapper')
+
+providersdk = notification_env.StaticLibrary('notification_provider_wrapper', notification_provider_src)
+notification_env.InstallTarget(providersdk, 'libnotification_provider_wrapper')
+notification_env.UserInstallTargetLib(providersdk, 'libnotification_provider_wrapper')
\r
\r
#include <string>\r
-#include <cstring>\r
#include "NSCommon.h"\r
-#include "oic_string.h"\r
-#include "NSConstants.h"\r
\r
namespace OIC\r
{\r
#ifndef _NS_PROVIDER_SERVICE_H_\r
#define _NS_PROVIDER_SERVICE_H_\r
\r
-#include "NSCommon.h"\r
-#include "NSProviderInterface.h"\r
-#include "NSMessage.h"\r
-#include "oic_string.h"\r
+#include <string>\r
#include "NSConsumer.h"\r
#include "NSSyncInfo.h"\r
-#include "NSConstants.h"\r
-#include <cstring>\r
+#include "NSMessage.h"\r
+#include "NSErrorCode.h"\r
\r
namespace OIC\r
{\r
* @param[in] policy Accepter\r
* @param[in] config ProviderConfig Callback function pointers to onConsumerSubscribed,\r
* and onMessageSynchronized function listeners\r
- * @return :: result code of NSResult\r
+ * @return :: result code of Provider Service\r
*/\r
- NSResult Start(NSAccessPolicy policy, ProviderConfig config);\r
+ Result Start(NSAccessPolicy policy, ProviderConfig config);\r
\r
/**\r
* Terminate notification service for provider\r
- * @return :: result code of NSResult\r
+ * @return :: result code of Provider Service\r
*/\r
- NSResult Stop();\r
+ Result Stop();\r
\r
/**\r
* Request to publish resource to cloud server\r
* @param[in] server address combined with IP address and port number using delimiter :\r
- * @return result code of NSResult\r
+ * @return result code of Provider Service\r
*/\r
- NSResult EnableRemoteService(const std::string &serverAddress);\r
+ Result EnableRemoteService(const std::string &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 result code of NSResult\r
+ * @return result code of Provider Service\r
*/\r
- NSResult DisableRemoteService(const std::string &serverAddress);\r
+ Result DisableRemoteService(const std::string &serverAddress);\r
\r
/**\r
* Send notification message to all subscribers\r
* @param[in] msg Notification message including id, title, contentText\r
- * @return :: result code of NSResult\r
+ * @return :: result code of Provider Service\r
*/\r
- NSResult SendMessage(NSMessage *msg);\r
+ Result SendMessage(NSMessage *msg);\r
\r
\r
/**\r
* Send read-check to provider in order to synchronize notification status with other consumers\r
* @param[in] messageId Notification message to synchronize the status\r
* @param[in] type NotificationSyncType of the SyncInfo message\r
- * @return :: result code of NSResult\r
*/\r
void SendSyncInfo(uint64_t messageId, NSSyncInfo::NSSyncType type);\r
\r
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
\r
#include "NSConsumer.h"\r
+#include <cstring>\r
#include "NSProviderInterface.h"\r
+#include "NSConstants.h"\r
+#include "oic_string.h"\r
\r
namespace OIC\r
{\r
\r
\r
#include "NSProviderService.h"\r
+#include <cstring>\r
+#include "NSCommon.h"\r
+#include "NSProviderInterface.h"\r
+#include "oic_string.h"\r
+#include "NSConsumer.h"\r
+#include "NSSyncInfo.h"\r
+#include "NSConstants.h"\r
\r
namespace OIC\r
{\r
return &s_instance;\r
}\r
\r
- NSResult NSProviderService::Start(NSProviderService::NSAccessPolicy policy,\r
- NSProviderService::ProviderConfig config)\r
+ Result NSProviderService::Start(NSProviderService::NSAccessPolicy policy,\r
+ NSProviderService::ProviderConfig config)\r
{\r
NS_LOG(DEBUG, "Start - IN");\r
\r
m_config = config;\r
- NSResult result = NSStartProvider((::NSAccessPolicy)policy, onConsumerSubscribedCallback,\r
- onMessageSynchronizedCallback);\r
+ Result result = (Result) NSStartProvider((::NSAccessPolicy)policy,\r
+ onConsumerSubscribedCallback, onMessageSynchronizedCallback);\r
NS_LOG(DEBUG, "Start - OUT");\r
return result;\r
}\r
\r
- NSResult NSProviderService::Stop()\r
+ Result NSProviderService::Stop()\r
{\r
NS_LOG(DEBUG, "Stop - IN");\r
- NSResult result = NSStopProvider();\r
+ Result result = (Result) NSStopProvider();\r
NS_LOG(DEBUG, "Stop - OUT");\r
return result;\r
}\r
\r
- NSResult NSProviderService::EnableRemoteService(const std::string &serverAddress)\r
+ Result NSProviderService::EnableRemoteService(const std::string &serverAddress)\r
{\r
NS_LOG(DEBUG, "EnableRemoteService - IN");\r
- NSResult result = NSProviderEnableRemoteService(OICStrdup(serverAddress.c_str()));\r
+ Result result = Result::ERROR;\r
+#ifdef WITH_CLOUD\r
+ result = (Result) NSProviderEnableRemoteService(OICStrdup(serverAddress.c_str()));\r
+#else\r
+ NS_LOG(ERROR, "Remote Services feature is not enabled in the Build");\r
+#endif\r
NS_LOG(DEBUG, "EnableRemoteService - OUT");\r
return result;\r
}\r
\r
- NSResult NSProviderService::DisableRemoteService(const std::string &serverAddress)\r
+ Result NSProviderService::DisableRemoteService(const std::string &serverAddress)\r
{\r
NS_LOG(DEBUG, "DisableRemoteService - IN");\r
- NSResult result = NSProviderDisableRemoteService(OICStrdup(serverAddress.c_str()));\r
+ Result result = Result::ERROR;\r
+#ifdef WITH_CLOUD\r
+ result = (Result) NSProviderDisableRemoteService(OICStrdup(serverAddress.c_str()));\r
+#else\r
+ NS_LOG(ERROR, "Remote Services feature is not enabled in the Build");\r
+#endif\r
NS_LOG(DEBUG, "DisableRemoteService - OUT");\r
return result;\r
}\r
\r
- NSResult NSProviderService::SendMessage(NSMessage *msg)\r
+ Result NSProviderService::SendMessage(NSMessage *msg)\r
{\r
NS_LOG(DEBUG, "SendMessage - IN");\r
- NSResult result = NS_ERROR;\r
+ Result result = Result::ERROR;\r
if (msg != nullptr)\r
- result = NSSendMessage(getNSMessage(msg));\r
+ result = (Result) NSSendMessage(getNSMessage(msg));\r
else\r
NS_LOG(DEBUG, "Empty Message");\r
NS_LOG(DEBUG, "SendMessage - OUT");\r