Update resource protocol specification
authorcc <ch79.cho@samsung.com>
Thu, 1 Sep 2016 13:53:53 +0000 (22:53 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 2 Sep 2016 12:56:02 +0000 (12:56 +0000)
Resource attributes are updated as the resource model
defined by spec document.

Change-Id: Ia20601345c4b327bf002c515696837bd84893fa5
Signed-off-by: cc <ch79.cho@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11293
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: Uze Choi <uzchoi@samsung.com>
service/notification/examples/linux/notificationprovider.c
service/notification/include/NSProviderInterface.h
service/notification/src/common/NSConstants.h
service/notification/src/common/NSStructs.h
service/notification/src/consumer/NSConsumerDiscovery.c
service/notification/src/provider/NSProviderInterface.c
service/notification/src/provider/NSProviderResource.c
service/notification/src/provider/NSProviderResource.h
service/notification/src/provider/NSProviderSubscription.c
service/notification/src/provider/NSProviderTopic.c
service/notification/unittest/NSProviderTest.cpp

index 7deb1d3..8076992 100644 (file)
@@ -193,7 +193,7 @@ int main()
             {
                 printf("NSStartProvider(Accepter: Provider)");
                 NSProviderConfig config;
-                config.policy = true;
+                config.subControllability = true;
                 config.subRequestCallback = subscribeRequestCallback;
                 config.syncInfoCallback = syncCallback;
                 config.userInfo = OICStrdup("OCF_NOTIFICATION");
@@ -205,7 +205,7 @@ int main()
             {
                 printf("NSStartProvider(Accepter: Consumer)");
                 NSProviderConfig config;
-                config.policy = false;
+                config.subControllability = false;
                 config.subRequestCallback = subscribeRequestCallback;
                 config.syncInfoCallback = syncCallback;
                 config.userInfo = OICStrdup("OCF_NOTIFICATION");
index 38af5a6..534d102 100644 (file)
@@ -62,7 +62,7 @@ typedef struct
      * if policy is true, provider decides to allow or deny for all the subscribing consumers.\r
      * Otherwise(policy is false) consumer decides to request subscription to discovered providers.\r
      */\r
-    bool policy;\r
+    bool subControllability;\r
     /* User Information */\r
     char * userInfo;\r
 \r
index 3f71dc6..a6cc2a3 100644 (file)
         } \
     }
 
+#define VERSION        "1.2.0"
+
+#define NS_ATTRIBUTE_VERSION "VERSION"
 #define NS_ATTRIBUTE_POLICY "ACCEPTER"
 #define NS_ATTRIBUTE_MESSAGE "MESSAGE_URI"
 #define NS_ATTRIBUTE_SYNC "SYNC_URI"
index d38be95..bb9a15f 100644 (file)
@@ -95,7 +95,9 @@ typedef struct
 typedef struct\r
 {\r
     OCResourceHandle handle;\r
-    int accepter;\r
+    char providerId[NS_UUID_STRING_SIZE];\r
+    char * version;\r
+    bool policy;\r
     char * message_uri;\r
     char * sync_uri;\r
 \r
@@ -117,6 +119,7 @@ typedef struct
     char * title;\r
     char * contentText;\r
     char * sourceName;\r
+    char * topicName;\r
     NSMediaContents * mediaContents;\r
 } NSMessageResource;\r
 \r
@@ -124,12 +127,14 @@ typedef struct
 {\r
     OCResourceHandle handle;\r
     char * id;\r
+    char providerId[NS_UUID_STRING_SIZE];\r
     char * state;\r
 } NSSyncResource;\r
 \r
 typedef struct\r
 {\r
     OCResourceHandle handle;\r
+    char providerId[NS_UUID_STRING_SIZE];\r
     char consumerId[NS_UUID_STRING_SIZE];\r
     NSTopicList ** TopicList;\r
 } NSTopicResource;\r
index 0509ac5..1b21230 100644 (file)
@@ -207,7 +207,7 @@ NSProvider_internal * NSGetProvider(OCClientResponse * clientResponse)
     NSProviderConnectionInfo * connection = NULL;
 
     NS_LOG(DEBUG, "get information of accepter");
-    bool getResult = OCRepPayloadGetPropInt(payload, NS_ATTRIBUTE_POLICY, & accepter);
+    bool getResult = OCRepPayloadGetPropBool(payload, NS_ATTRIBUTE_POLICY, & accepter);
     NS_VERIFY_NOT_NULL(getResult == true ? (void *) 1 : NULL, NULL);
 
     NS_LOG(DEBUG, "get provider ID");
index f16335c..51d3785 100644 (file)
@@ -56,7 +56,7 @@ NSResult NSStartProvider(NSProviderConfig config)
         NS_LOG(DEBUG, "Init Provider");
         initProvider = true;
         NSInitProviderInfo(config.userInfo);
-        NSSetSubscriptionAccessPolicy(config.policy);
+        NSSetSubscriptionAccessPolicy(config.subControllability);
         NSRegisterSubscribeRequestCb(config.subRequestCallback);
         NSRegisterSyncCb(config.syncInfoCallback);
         CARegisterNetworkMonitorHandler((CAAdapterStateChangedCB)NSProviderAdapterStateListener,
@@ -375,4 +375,3 @@ NSResult NSProviderUnsetConsumerTopic(const char * consumerId, const char * topi
     NS_LOG(DEBUG, "NSProviderUnselectTopics - OUT");
     return NS_OK;
 }
-
index a3fa316..900d83f 100644 (file)
@@ -80,10 +80,12 @@ NSResult NSCreateResource(char *uri)
 
     if (strcmp(uri, NS_ROOT_URI) == 0)
     {
-        NotificationResource.accepter = 0;
+        NotificationResource.policy = true;
+        (NotificationResource.providerId)[0] = '\0';
         NotificationResource.message_uri = NS_COLLECTION_MESSAGE_URI;
         NotificationResource.sync_uri = NS_COLLECTION_SYNC_URI;
         NotificationResource.topic_uri = NS_COLLECTION_TOPIC_URI;
+        NotificationResource.version = VERSION;
         NotificationResource.handle = NULL;
 
         if (OCCreateResource(&NotificationResource.handle, NS_ROOT_TYPE, NS_DEFAULT_INTERFACE,
@@ -105,6 +107,7 @@ NSResult NSCreateResource(char *uri)
         NotificationMessageResource.title = NULL;
         NotificationMessageResource.contentText = NULL;
         NotificationMessageResource.sourceName = NULL;
+        NotificationMessageResource.topicName = NULL;
         NotificationMessageResource.mediaContents = NULL;
 
         if (OCCreateResource(&NotificationMessageResource.handle, NS_COLLECTION_MESSAGE_TYPE,
@@ -118,6 +121,7 @@ NSResult NSCreateResource(char *uri)
     else if (strcmp(uri, NS_COLLECTION_SYNC_URI) == 0)
     {
         NotificationSyncResource.id = NULL;
+        (NotificationSyncResource.providerId)[0] = '\0';
         NotificationSyncResource.state = NULL;
         NotificationSyncResource.handle = NULL;
 
@@ -131,6 +135,7 @@ NSResult NSCreateResource(char *uri)
     }
     else if (strcmp(uri, NS_COLLECTION_TOPIC_URI) == 0)
     {
+        (NotificationTopicResource.providerId)[0] = '\0';
         (NotificationTopicResource.consumerId)[0] = '\0';
         NotificationTopicResource.TopicList = NULL;
         NotificationTopicResource.handle = NULL;
@@ -222,14 +227,17 @@ NSResult NSUnRegisterResource()
     return NS_OK;
 }
 
-NSResult NSPutNotificationResource(int accepter, OCResourceHandle * handle)
+NSResult NSPutNotificationResource(bool policy, OCResourceHandle * handle)
 {
     NS_LOG(DEBUG, "NSPutNotificationResource - IN");
 
-    NotificationResource.accepter = accepter;
+    NotificationResource.policy = policy;
+    OICStrcpy(NotificationResource.providerId, UUID_STRING_SIZE,
+        NSGetProviderInfo()->providerId);
     NotificationResource.message_uri = NS_COLLECTION_MESSAGE_URI;
     NotificationResource.sync_uri = NS_COLLECTION_SYNC_URI;
     NotificationResource.topic_uri = NS_COLLECTION_TOPIC_URI;
+    NotificationResource.version = VERSION;
 
     *handle = NotificationResource.handle;
 
@@ -253,6 +261,7 @@ NSResult NSPutMessageResource(NSMessage *msg, OCResourceHandle * handle)
         NotificationMessageResource.title = msg->title;
         NotificationMessageResource.contentText = msg->contentText;
         NotificationMessageResource.sourceName = msg->sourceName;
+        NotificationMessageResource.topicName = msg->topic;
         NotificationMessageResource.mediaContents = msg->mediaContents;
     }
     else
@@ -261,8 +270,8 @@ NSResult NSPutMessageResource(NSMessage *msg, OCResourceHandle * handle)
     }
 
     *handle = NotificationMessageResource.handle;
-    NS_LOG(DEBUG, "NSPutMessageResource - OUT");
 
+    NS_LOG(DEBUG, "NSPutMessageResource - OUT");
     return NS_OK;
 }
 
index 3e273b9..7d38eea 100644 (file)
@@ -36,7 +36,7 @@ NSResult NSRegisterResource();
 
 NSResult NSUnRegisterResource();
 
-NSResult NSPutNotificationResource(int accepter, OCResourceHandle * handle);
+NSResult NSPutNotificationResource(bool policy, OCResourceHandle * handle);
 
 NSResult NSPutMessageResource(NSMessage *msg, OCResourceHandle * handle);
 
index 090e78d..375a05e 100644 (file)
@@ -81,7 +81,8 @@ NSResult NSSendAccessPolicyResponse(OCEntityHandlerRequest *entityHandlerRequest
 \r
     OCRepPayloadSetUri(payload, NS_ROOT_URI);\r
     OCRepPayloadSetPropString(payload, NS_ATTRIBUTE_PROVIDER_ID, NSGetProviderInfo()->providerId);\r
-    OCRepPayloadSetPropInt(payload, NS_ATTRIBUTE_POLICY, NSGetPolicy());\r
+    OCRepPayloadSetPropString(payload, NS_ATTRIBUTE_VERSION, VERSION);\r
+    OCRepPayloadSetPropBool(payload, NS_ATTRIBUTE_POLICY, NSGetPolicy());\r
     OCRepPayloadSetPropString(payload, NS_ATTRIBUTE_MESSAGE, NS_COLLECTION_MESSAGE_URI);\r
     OCRepPayloadSetPropString(payload, NS_ATTRIBUTE_SYNC, NS_COLLECTION_SYNC_URI);\r
     OCRepPayloadSetPropString(payload, NS_ATTRIBUTE_TOPIC, NS_COLLECTION_TOPIC_URI);\r
index 112c2ef..12688ce 100644 (file)
@@ -285,6 +285,8 @@ NSResult NSSendTopicList(OCEntityHandlerRequest * entityHandlerRequest)
     {\r
         OCRepPayloadSetPropString(payload, NS_ATTRIBUTE_CONSUMER_ID, id);\r
     }\r
+    OCRepPayloadSetPropString(payload, NS_ATTRIBUTE_PROVIDER_ID,\r
+        NSGetProviderInfo()->providerId);\r
     OCRepPayloadSetPropObjectArray(payload, NS_ATTRIBUTE_TOPIC_LIST,\r
             (const OCRepPayload**)(payloadTopicArray), dimensions);\r
 \r
index 4c832ba..ba46cc7 100755 (executable)
@@ -142,7 +142,7 @@ TEST_F(NotificationProviderTest, StartProviderPositiveWithNSPolicyTrue)
     NSProviderConfig config;
     config.subRequestCallback = NSRequestedSubscribeCallbackEmpty;
     config.syncInfoCallback = NSSyncCallbackEmpty;
-    config.policy = true;
+    config.subControllability = true;
     config.userInfo = NULL;
 
     NSResult ret = NSStartProvider(config);
@@ -168,7 +168,7 @@ TEST_F(NotificationProviderTest, StartProviderPositiveWithNSPolicyFalse)
     NSProviderConfig config;
     config.subRequestCallback = NSRequestedSubscribeCallbackEmpty;
     config.syncInfoCallback = NSSyncCallbackEmpty;
-    config.policy = false;
+    config.subControllability = false;
     config.userInfo = NULL;
 
     NSResult ret = NSStartProvider(config);
@@ -196,7 +196,7 @@ TEST_F(NotificationProviderTest, ExpectCallbackWhenReceiveSubscribeRequestWithAc
     NSProviderConfig config;
     config.subRequestCallback = NSRequestedSubscribeCallbackEmpty;
     config.syncInfoCallback = NSSyncCallbackEmpty;
-    config.policy = true;
+    config.subControllability = true;
     config.userInfo = NULL;
 
     NSStartProvider(config);