From: Sakthivel Samidurai Date: Sat, 15 Nov 2014 02:04:54 +0000 (-0800) Subject: Make command line option for secure and observer X-Git-Tag: 1.2.0+RC1~2107 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d1cff610891e9a86810bac1b5e75742b68c1e03;p=platform%2Fupstream%2Fiotivity.git Make command line option for secure and observer Implement command line option for secure resource and observer Remove duplicate case to avoid confusion Update app usage description Change-Id: I2aa090a7a65448a7fbc54b41fef4b29d212f18f8 Signed-off-by: Sakthivel Samidurai --- diff --git a/resource/examples/simpleclientserver.cpp b/resource/examples/simpleclientserver.cpp index 659a2b7..444c4dc 100644 --- a/resource/examples/simpleclientserver.cpp +++ b/resource/examples/simpleclientserver.cpp @@ -183,7 +183,7 @@ struct FooResource std::string resourceTypeName = "core.foo"; std::string resourceInterface = DEFAULT_INTERFACE; - uint8_t resourceProperty = OC_DISCOVERABLE | OC_SECURE ; + uint8_t resourceProperty = OC_DISCOVERABLE; EntityHandler eh(std::bind(&FooResource::entityHandler, this, std::placeholders::_1, std::placeholders::_2)); diff --git a/resource/examples/simpleserver.cpp b/resource/examples/simpleserver.cpp index 492fc80..186ffd4 100644 --- a/resource/examples/simpleserver.cpp +++ b/resource/examples/simpleserver.cpp @@ -38,9 +38,14 @@ int gObservation = 0; void * ChangeLightRepresentation (void *param); // Specifies where to notify all observers or list of observers -// 0 - notifies all observers -// 1 - notifies list of observers -int isListOfObservers = 0; +// false: notifies all observers +// true: notifies list of observers +bool isListOfObservers = false; + +// Specifies secure or non-secure +// false: non-secure resource +// true: secure resource +bool isSecure = false; // Forward declaring the entityHandler @@ -83,8 +88,15 @@ public: std::string resourceInterface = DEFAULT_INTERFACE; // resource interface. // OCResourceProperty is defined ocstack.h - uint8_t resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE | OC_SECURE; - + uint8_t resourceProperty; + if(isSecure) + { + resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE | OC_SECURE; + } + else + { + resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE; + } EntityHandler cb = std::bind(&LightResource::entityHandler, this,PH::_1, PH::_2); // This will internally create and register the resource. @@ -105,8 +117,15 @@ public: std::string resourceInterface = DEFAULT_INTERFACE; // resource interface. // OCResourceProperty is defined ocstack.h - uint8_t resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE | OC_SECURE; - + uint8_t resourceProperty; + if(isSecure) + { + resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE | OC_SECURE; + } + else + { + resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE; + } EntityHandler cb = std::bind(&LightResource::entityHandler, this,PH::_1, PH::_2); OCResourceHandle resHandle; @@ -406,9 +425,11 @@ void * ChangeLightRepresentation (void *param) void PrintUsage() { std::cout << std::endl; - std::cout << "Usage : simplserver \n"; - std::cout << " ObserveType : 0 - Observe All\n"; - std::cout << " ObserveType : 1 - Observe List of observers\n\n"; + std::cout << "Usage : simpleserver < secure resource and observer >\n"; + std::cout << " Default - Non-secure resource and notify all observers\n"; + std::cout << " 1 - Non-secure resource and notify list of observers\n\n"; + std::cout << " 2 - Secure resource and notify all observers\n"; + std::cout << " 3 - Secure resource and notify list of observers\n\n"; } @@ -418,16 +439,30 @@ int main(int argc, char* argv[1]) if (argc == 1) { - isListOfObservers = 0; + isListOfObservers = false; + isSecure = false; } else if (argc == 2) { int value = atoi(argv[1]); - if (value == 1) - isListOfObservers = 1; - else - isListOfObservers = 0; - } + switch (value) + { + case 1: + isListOfObservers = true; + isSecure = false; + break; + case 2: + isListOfObservers = false; + isSecure = true; + break; + case 3: + isListOfObservers = true; + isSecure = true; + break; + default: + break; + } + } else { return -1;