{
printf("NSStartProvider(Accepter: Provider)");
NSProviderConfig config;
- config.policy = true;
+ config.subControllability = true;
config.subRequestCallback = subscribeRequestCallback;
config.syncInfoCallback = syncCallback;
config.userInfo = OICStrdup("OCF_NOTIFICATION");
{
printf("NSStartProvider(Accepter: Consumer)");
NSProviderConfig config;
- config.policy = false;
+ config.subControllability = false;
config.subRequestCallback = subscribeRequestCallback;
config.syncInfoCallback = syncCallback;
config.userInfo = OICStrdup("OCF_NOTIFICATION");
* 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
} \
}
+#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"
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
char * title;\r
char * contentText;\r
char * sourceName;\r
+ char * topicName;\r
NSMediaContents * mediaContents;\r
} NSMessageResource;\r
\r
{\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
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");
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,
NS_LOG(DEBUG, "NSProviderUnselectTopics - OUT");
return NS_OK;
}
-
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,
NotificationMessageResource.title = NULL;
NotificationMessageResource.contentText = NULL;
NotificationMessageResource.sourceName = NULL;
+ NotificationMessageResource.topicName = NULL;
NotificationMessageResource.mediaContents = NULL;
if (OCCreateResource(&NotificationMessageResource.handle, NS_COLLECTION_MESSAGE_TYPE,
else if (strcmp(uri, NS_COLLECTION_SYNC_URI) == 0)
{
NotificationSyncResource.id = NULL;
+ (NotificationSyncResource.providerId)[0] = '\0';
NotificationSyncResource.state = NULL;
NotificationSyncResource.handle = NULL;
}
else if (strcmp(uri, NS_COLLECTION_TOPIC_URI) == 0)
{
+ (NotificationTopicResource.providerId)[0] = '\0';
(NotificationTopicResource.consumerId)[0] = '\0';
NotificationTopicResource.TopicList = NULL;
NotificationTopicResource.handle = NULL;
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;
NotificationMessageResource.title = msg->title;
NotificationMessageResource.contentText = msg->contentText;
NotificationMessageResource.sourceName = msg->sourceName;
+ NotificationMessageResource.topicName = msg->topic;
NotificationMessageResource.mediaContents = msg->mediaContents;
}
else
}
*handle = NotificationMessageResource.handle;
- NS_LOG(DEBUG, "NSPutMessageResource - OUT");
+ NS_LOG(DEBUG, "NSPutMessageResource - OUT");
return NS_OK;
}
NSResult NSUnRegisterResource();
-NSResult NSPutNotificationResource(int accepter, OCResourceHandle * handle);
+NSResult NSPutNotificationResource(bool policy, OCResourceHandle * handle);
NSResult NSPutMessageResource(NSMessage *msg, OCResourceHandle * handle);
\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
{\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
NSProviderConfig config;
config.subRequestCallback = NSRequestedSubscribeCallbackEmpty;
config.syncInfoCallback = NSSyncCallbackEmpty;
- config.policy = true;
+ config.subControllability = true;
config.userInfo = NULL;
NSResult ret = NSStartProvider(config);
NSProviderConfig config;
config.subRequestCallback = NSRequestedSubscribeCallbackEmpty;
config.syncInfoCallback = NSSyncCallbackEmpty;
- config.policy = false;
+ config.subControllability = false;
config.userInfo = NULL;
NSResult ret = NSStartProvider(config);
NSProviderConfig config;
config.subRequestCallback = NSRequestedSubscribeCallbackEmpty;
config.syncInfoCallback = NSSyncCallbackEmpty;
- config.policy = true;
+ config.subControllability = true;
config.userInfo = NULL;
NSStartProvider(config);