From 419a77de36d75ab0d947237e0f45a44405825792 Mon Sep 17 00:00:00 2001 From: DoHyun Pyun Date: Thu, 15 Nov 2018 17:14:53 +0900 Subject: [PATCH] Revert "[CONPRO-1337] Disabled Presence Feature" This reverts commit 127c4d9e2773e22cb3f4d6ffd8a568fa67312ec2. Change-Id: I2690b11b0fb187f6fbf8348c36beb218c449f307 Signed-off-by: DoHyun Pyun --- build_common/SConscript | 4 ---- plugins/samples/linux/IotivityandZigbeeServer.c | 3 +-- resource/csdk/stack/include/octypes.h | 6 +++++- resource/csdk/stack/src/ocserverrequest.c | 4 ++-- resource/examples/SConscript | 3 +-- resource/src/InProcClientWrapper.cpp | 10 ---------- resource/src/InProcServerWrapper.cpp | 8 -------- resource/unittests/OCExceptionTest.cpp | 2 -- resource/unittests/OCRepresentationEncodingTest.cpp | 2 -- service/notification/src/common/NSUtil.c | 2 -- service/notification/src/consumer/NSConsumerDiscovery.c | 7 ++----- service/notification/src/consumer/NSConsumerDiscovery.h | 3 +-- .../notification/src/consumer/NSConsumerNetworkEventListener.c | 7 +++---- service/notification/src/provider/NSProviderDiscovery.c | 4 ---- service/notification/src/provider/NSProviderDiscovery.h | 2 -- .../src/resourceBroker/src/DevicePresence.cpp | 2 -- .../src/resourceBroker/src/ResourcePresence.cpp | 2 -- .../src/resourceCache/src/ObserveCache.cpp | 2 -- 18 files changed, 15 insertions(+), 58 deletions(-) mode change 100644 => 100755 service/notification/src/common/NSUtil.c diff --git a/build_common/SConscript b/build_common/SConscript index 4a9a350..3d2404c 100644 --- a/build_common/SConscript +++ b/build_common/SConscript @@ -101,7 +101,6 @@ help_vars.Add(BoolVariable('WITH_PROXY', 'Build with CoAP-HTTP Proxy', False)) help_vars.Add(ListVariable('WITH_MQ', 'Build with MQ publisher/broker', 'OFF', ['OFF', 'SUB', 'PUB', 'BROKER'])) help_vars.Add(BoolVariable('WITH_CLOUD', 'Build including AccountManager class and Cloud Client sample', False)) help_vars.Add(ListVariable('RD_MODE', 'Resource Directory build mode', 'CLIENT', ['CLIENT', 'SERVER'])) -help_vars.Add(BoolVariable('DISABLE_PRESENCE', 'Disable Presence Feature', False)) help_vars.Add(BoolVariable('SIMULATOR', 'Build with simulator module', False)) @@ -359,9 +358,6 @@ if env.get('WITH_TCP'): if env.get('DISABLE_TCP_SERVER'): defines.append('-DDISABLE_TCP_SERVER=1') -if env.get('DISABLE_PRESENCE') == False: - env.AppendUnique(CPPDEFINES = ['WITH_PRESENCE']) - libs = [] if env.get('SECURED') == '1': defines.append('-D__WITH_DTLS__=1') diff --git a/plugins/samples/linux/IotivityandZigbeeServer.c b/plugins/samples/linux/IotivityandZigbeeServer.c index 74d987c..8caa729 100644 --- a/plugins/samples/linux/IotivityandZigbeeServer.c +++ b/plugins/samples/linux/IotivityandZigbeeServer.c @@ -51,14 +51,13 @@ int main() goto IotivityStop; } -#ifdef WITH_PRESENCE result = OCStartPresence(0); if (result != OC_STACK_OK) { OIC_LOG_V(ERROR, TAG, "OCStartPresence Failed: %d", result); goto IotivityStop; } -#endif + // PIStartPlugin PIPlugin* plugin = NULL; OIC_LOG(INFO, TAG, "IoTivity Initialized properly, Starting Zigbee Plugin..."); diff --git a/resource/csdk/stack/include/octypes.h b/resource/csdk/stack/include/octypes.h index df6df44..6afdb95 100644 --- a/resource/csdk/stack/include/octypes.h +++ b/resource/csdk/stack/include/octypes.h @@ -39,6 +39,9 @@ extern "C" { #endif // __cplusplus +/** For the feature presence.*/ +#define WITH_PRESENCE + #include "ocpresence.h" // TODO : need for secure psi @@ -84,11 +87,12 @@ extern "C" { /** Presence URI through which the OIC devices advertise their presence.*/ #define OC_RSRVD_PRESENCE_URI "/oic/ad" -#endif // WITH_PRESENCE /** Presence URI through which the OIC devices advertise their device presence.*/ #define OC_RSRVD_DEVICE_PRESENCE_URI "/oic/prs" +#endif // WITH_PRESENCE + /** For multicast Discovery mechanism.*/ #define OC_MULTICAST_DISCOVERY_URI "/oic/res" diff --git a/resource/csdk/stack/src/ocserverrequest.c b/resource/csdk/stack/src/ocserverrequest.c index 3dde884..325abb7 100644 --- a/resource/csdk/stack/src/ocserverrequest.c +++ b/resource/csdk/stack/src/ocserverrequest.c @@ -739,8 +739,8 @@ OCStackResult HandleSingleResponse(OCEntityHandlerResponse * ehResponse) OIC_LOG(INFO, TAG, "Calling OCSendResponse with:"); OIC_LOG_V(INFO, TAG, "\tEndpoint address: %s", responseEndpoint.addr); - OIC_LOG_V(INFO, TAG, "\tEndpoint adapter: %d", responseEndpoint.adapter); - OIC_LOG_V(INFO, TAG, "\tResponse result : %d", responseInfo.result); + OIC_LOG_V(INFO, TAG, "\tEndpoint adapter: %s", responseEndpoint.adapter); + OIC_LOG_V(INFO, TAG, "\tResponse result : %s", responseInfo.result); OIC_LOG_V(INFO, TAG, "\tResponse for uri: %s", responseInfo.info.resourceUri); result = OCSendResponse(&responseEndpoint, &responseInfo); diff --git a/resource/examples/SConscript b/resource/examples/SConscript index b2ce91f..4896179 100644 --- a/resource/examples/SConscript +++ b/resource/examples/SConscript @@ -102,6 +102,7 @@ example_names = [ if target_os not in ['windows', 'msys_nt']: example_names += [ 'fridgeserver', 'fridgeclient', + 'presenceserver', 'presenceclient', 'roomserver', 'roomclient', 'garageserver', 'garageclient', @@ -114,8 +115,6 @@ if target_os not in ['windows', 'msys_nt']: examples_env.AppendUnique(CPPPATH = ['../csdk/resource-directory/include']) example_names += ['rdclient'] examples_env.AppendUnique(LIBS = ['resource_directory']) - if examples_env.get('DISABLE_PRESENCE') == False: - example_names += ['presenceserver', 'presenceclient'] examples = map(make_single_file_cpp_program, example_names) diff --git a/resource/src/InProcClientWrapper.cpp b/resource/src/InProcClientWrapper.cpp index 41bb8fa..ee47425 100644 --- a/resource/src/InProcClientWrapper.cpp +++ b/resource/src/InProcClientWrapper.cpp @@ -1433,7 +1433,6 @@ namespace OC return result; } -#ifdef WITH_PRESENCE OCStackApplicationResult subscribePresenceCallback(void* ctx, OCDoHandle /*handle*/, OCClientResponse* clientResponse) @@ -1454,13 +1453,11 @@ namespace OC return OC_STACK_KEEP_TRANSACTION; } -#endif OCStackResult InProcClientWrapper::SubscribePresence(OCDoHandle* handle, const std::string& host, const std::string& resourceType, OCConnectivityType connectivityType, SubscribeCallback& presenceHandler) { -#ifdef WITH_PRESENCE if (!presenceHandler) { return OC_STACK_INVALID_PARAM; @@ -1494,14 +1491,10 @@ namespace OC os.str().c_str(), nullptr, nullptr, connectivityType, OC_LOW_QOS, &cbdata, NULL, 0); -#else - return OC_STACK_NOT_IMPLEMENTED; -#endif } OCStackResult InProcClientWrapper::UnsubscribePresence(OCDoHandle handle) { -#ifdef WITH_PRESENCE OCStackResult result; auto cLock = m_csdkLock.lock(); @@ -1516,9 +1509,6 @@ namespace OC } return result; -#else - return OC_STACK_NOT_IMPLEMENTED; -#endif } #ifdef WITH_CLOUD diff --git a/resource/src/InProcServerWrapper.cpp b/resource/src/InProcServerWrapper.cpp index 5989cf5..b4b799e 100644 --- a/resource/src/InProcServerWrapper.cpp +++ b/resource/src/InProcServerWrapper.cpp @@ -606,7 +606,6 @@ namespace OC OCStackResult InProcServerWrapper::startPresence(const unsigned int seconds) { -#ifdef WITH_PRESENCE auto cLock = m_csdkLock.lock(); OCStackResult result = OC_STACK_ERROR; if(cLock) @@ -620,14 +619,10 @@ namespace OC throw OCException(OC::Exception::START_PRESENCE_FAILED, result); } return result; -#else - return OC_STACK_NOT_IMPLEMENTED; -#endif } OCStackResult InProcServerWrapper::stopPresence() { -#ifdef WITH_PRESENCE auto cLock = m_csdkLock.lock(); OCStackResult result = OC_STACK_ERROR; if(cLock) @@ -641,9 +636,6 @@ namespace OC throw OCException(OC::Exception::END_PRESENCE_FAILED, result); } return result; -#else - return OC_STACK_NOT_IMPLEMENTED; -#endif } OCStackResult InProcServerWrapper::sendResponse( diff --git a/resource/unittests/OCExceptionTest.cpp b/resource/unittests/OCExceptionTest.cpp index d95d320..921b45f 100644 --- a/resource/unittests/OCExceptionTest.cpp +++ b/resource/unittests/OCExceptionTest.cpp @@ -72,11 +72,9 @@ namespace OC OC_STACK_SVR_DB_NOT_EXIST, OC_STACK_AUTHENTICATION_FAILURE, OC_STACK_NOT_ALLOWED_OXM, -#ifdef WITH_PRESENCE OC_STACK_PRESENCE_STOPPED, OC_STACK_PRESENCE_TIMEOUT, OC_STACK_PRESENCE_DO_NOT_HANDLE, -#endif OC_STACK_USER_DENIED_REQ, OC_STACK_NOT_ACCEPTABLE, OC_STACK_METHOD_NOT_ALLOWED, diff --git a/resource/unittests/OCRepresentationEncodingTest.cpp b/resource/unittests/OCRepresentationEncodingTest.cpp index 83e74df..ff0c657 100644 --- a/resource/unittests/OCRepresentationEncodingTest.cpp +++ b/resource/unittests/OCRepresentationEncodingTest.cpp @@ -283,7 +283,6 @@ namespace OCRepresentationEncodingTest OCPayloadDestroy((OCPayload *)platform1); } -#ifdef WITH_PRESENCE TEST(PresencePayload, Normal) { static const char uri1[] = "/testuri"; @@ -309,7 +308,6 @@ namespace OCRepresentationEncodingTest OCPayloadDestroy(cparsed); } -#endif // Representation Payloads TEST(RepresentationEncoding, BaseAttributeTypes) { diff --git a/service/notification/src/common/NSUtil.c b/service/notification/src/common/NSUtil.c old mode 100644 new mode 100755 index 35c1e25..8efb307 --- a/service/notification/src/common/NSUtil.c +++ b/service/notification/src/common/NSUtil.c @@ -609,9 +609,7 @@ bool NSOCResultToSuccess(OCStackResult ret) case OC_STACK_OK: case OC_STACK_RESOURCE_CREATED: case OC_STACK_RESOURCE_DELETED: -#ifdef WITH_PRESENCE case OC_STACK_PRESENCE_STOPPED: -#endif case OC_STACK_CONTINUE: case OC_STACK_RESOURCE_CHANGED: return true; diff --git a/service/notification/src/consumer/NSConsumerDiscovery.c b/service/notification/src/consumer/NSConsumerDiscovery.c index a408b6e..28c137e 100644 --- a/service/notification/src/consumer/NSConsumerDiscovery.c +++ b/service/notification/src/consumer/NSConsumerDiscovery.c @@ -32,7 +32,6 @@ #define NS_DISCOVER_QUERY "/oic/res?rt=x.org.iotivity.notification" #define NS_PRESENCE_SUBSCRIBE_QUERY_TCP "/oic/ad?rt=x.org.iotivity.notification" -#ifdef WITH_PRESENCE OCStackApplicationResult NSConsumerPresenceListener( void * ctx, OCDoHandle handle, OCClientResponse * clientResponse) { @@ -84,7 +83,6 @@ OCStackApplicationResult NSConsumerPresenceListener( return OC_STACK_KEEP_TRANSACTION; } -#endif OCStackApplicationResult NSProviderDiscoverListener( void * ctx, OCDoHandle handle, OCClientResponse * clientResponse) @@ -200,12 +198,11 @@ void NSConsumerHandleRequestDiscover(OCDevAddr * address, NSConsumerDiscoverType else if (address->adapter == OC_ADAPTER_TCP) { type = CT_ADAPTER_TCP; - NS_LOG(DEBUG, "Request discover [TCP]"); -#ifdef WITH_PRESENCE + NS_LOG(DEBUG, "Request discover and subscribe presence [TCP]"); NS_LOG(DEBUG, "Subscribe presence [TCP]"); NSInvokeRequest(NULL, OC_REST_PRESENCE, address, NS_PRESENCE_SUBSCRIBE_QUERY_TCP, NULL, NSConsumerPresenceListener, NULL, NULL, type); -#endif + if (rType == NS_DISCOVER_CLOUD) { callbackData = (void *) NS_DISCOVER_CLOUD; diff --git a/service/notification/src/consumer/NSConsumerDiscovery.h b/service/notification/src/consumer/NSConsumerDiscovery.h index 33803fd..01b3a25 100644 --- a/service/notification/src/consumer/NSConsumerDiscovery.h +++ b/service/notification/src/consumer/NSConsumerDiscovery.h @@ -32,9 +32,8 @@ extern "C" { void NSConsumerDiscoveryTaskProcessing(NSTask *); -#ifdef WITH_PRESENCE OCStackApplicationResult NSConsumerPresenceListener(void *, OCDoHandle, OCClientResponse *); -#endif + // for discover result OCStackApplicationResult NSProviderDiscoverListener(void *, OCDoHandle, OCClientResponse *); diff --git a/service/notification/src/consumer/NSConsumerNetworkEventListener.c b/service/notification/src/consumer/NSConsumerNetworkEventListener.c index 21881b1..d48d897 100644 --- a/service/notification/src/consumer/NSConsumerNetworkEventListener.c +++ b/service/notification/src/consumer/NSConsumerNetworkEventListener.c @@ -53,14 +53,13 @@ NSResult NSConsumerListenerInit() // { // return NS_ERROR; // } - OCStackResult stackResult; -#ifdef WITH_PRESENCE + NS_LOG(DEBUG, "Request to subscribe presence"); - stackResult = NSInvokeRequest(getPresenceHandle(), OC_REST_PRESENCE, NULL, + OCStackResult stackResult = NSInvokeRequest(getPresenceHandle(), OC_REST_PRESENCE, NULL, NS_PRESENCE_SUBSCRIBE_QUERY, NULL, NSConsumerPresenceListener, NULL, NULL, CT_DEFAULT); NS_VERIFY_STACK_SUCCESS(NSOCResultToSuccess(stackResult), NS_ERROR); -#endif + NS_LOG(DEBUG, "Request to discover provider"); stackResult = NSInvokeRequest(NULL, OC_REST_DISCOVER, NULL, NS_DISCOVER_QUERY, NULL, NSProviderDiscoverListener, diff --git a/service/notification/src/provider/NSProviderDiscovery.c b/service/notification/src/provider/NSProviderDiscovery.c index 7dac222..9452103 100644 --- a/service/notification/src/provider/NSProviderDiscovery.c +++ b/service/notification/src/provider/NSProviderDiscovery.c @@ -20,7 +20,6 @@ #include "NSProviderDiscovery.h" -#ifdef WITH_PRESENCE NSResult NSStartPresence() { NS_LOG(DEBUG, "NSStartPresence()"); @@ -48,7 +47,6 @@ NSResult NSStopPresence() NS_LOG(DEBUG, "NSStopPresence() NS_OK"); return NS_OK; } -#endif void * NSDiscoverySchedule(void * ptr) { @@ -69,7 +67,6 @@ void * NSDiscoverySchedule(void * ptr) switch (node->taskType) { -#ifdef WITH_PRESENCE case TASK_START_PRESENCE: NS_LOG(DEBUG, "CASE TASK_START_PRESENCE : "); NSStartPresence(); @@ -78,7 +75,6 @@ void * NSDiscoverySchedule(void * ptr) NS_LOG(DEBUG, "CASE TASK_STOP_PRESENCE : "); NSStopPresence(); break; -#endif case TASK_REGISTER_RESOURCE: NS_LOG(DEBUG, "CASE TASK_REGISTER_RESOURCE : "); NSRegisterResource(); diff --git a/service/notification/src/provider/NSProviderDiscovery.h b/service/notification/src/provider/NSProviderDiscovery.h index 1b1ffb0..c020ecb 100644 --- a/service/notification/src/provider/NSProviderDiscovery.h +++ b/service/notification/src/provider/NSProviderDiscovery.h @@ -26,9 +26,7 @@ #include "NSProviderScheduler.h" #include "NSProviderResource.h" -#ifdef WITH_PRESENCE NSResult NSStartPresence(); NSResult NSStopPresence(); -#endif #endif /* _NS_PROVIDER_DISCOVERY_H_ */ diff --git a/service/resource-encapsulation/src/resourceBroker/src/DevicePresence.cpp b/service/resource-encapsulation/src/resourceBroker/src/DevicePresence.cpp index 5c36b78..7ebdf3f 100644 --- a/service/resource-encapsulation/src/resourceBroker/src/DevicePresence.cpp +++ b/service/resource-encapsulation/src/resourceBroker/src/DevicePresence.cpp @@ -158,11 +158,9 @@ namespace OIC case OC_STACK_RESOURCE_DELETED: case OC_STACK_TIMEOUT: case OC_STACK_COMM_ERROR: -#ifdef WITH_PRESENCE case OC_STACK_PRESENCE_STOPPED: case OC_STACK_PRESENCE_TIMEOUT: case OC_STACK_PRESENCE_DO_NOT_HANDLE: -#endif { setDeviceState(DEVICE_STATE::LOST_SIGNAL); changeAllPresenceMode(BROKER_MODE::NON_PRESENCE_MODE); diff --git a/service/resource-encapsulation/src/resourceBroker/src/ResourcePresence.cpp b/service/resource-encapsulation/src/resourceBroker/src/ResourcePresence.cpp index a85e240..9836438 100644 --- a/service/resource-encapsulation/src/resourceBroker/src/ResourcePresence.cpp +++ b/service/resource-encapsulation/src/resourceBroker/src/ResourcePresence.cpp @@ -288,10 +288,8 @@ namespace OIC case OC_STACK_INVALID_REQUEST_HANDLE: case OC_STACK_TIMEOUT: case OC_STACK_COMM_ERROR: -#ifdef WITH_PRESENCE case OC_STACK_PRESENCE_STOPPED: case OC_STACK_PRESENCE_TIMEOUT: -#endif default: verifiedState = BROKER_STATE::LOST_SIGNAL; break; diff --git a/service/resource-encapsulation/src/resourceCache/src/ObserveCache.cpp b/service/resource-encapsulation/src/resourceCache/src/ObserveCache.cpp index c1b7a8f..2703af7 100644 --- a/service/resource-encapsulation/src/resourceCache/src/ObserveCache.cpp +++ b/service/resource-encapsulation/src/resourceCache/src/ObserveCache.cpp @@ -136,9 +136,7 @@ namespace OIC case OC_STACK_OK: case OC_STACK_RESOURCE_CREATED: case OC_STACK_RESOURCE_DELETED: -#ifdef WITH_PRESENCE case OC_STACK_PRESENCE_STOPPED: -#endif case OC_STACK_CONTINUE: case OC_STACK_RESOURCE_CHANGED: return true; -- 2.7.4