- NS_LOG(DEBUG, "getting information of accepter");
- bool getResult = OCRepPayloadGetPropInt((OCRepPayload *)clientResponse->payload,
- NS_PAYLOAD_KEY_ACCEPTER, & accepter);
- NS_VERTIFY_NOT_NULL(getResult == true ? (void *) 1 : NULL, OC_STACK_KEEP_TRANSACTION);
-
- NS_LOG(DEBUG, "getting message URI");
- getResult = OCRepPayloadGetPropString(
- (OCRepPayload *)clientResponse->payload,
- "MESSAGE_URI", & messageUri);
- NS_VERTIFY_NOT_NULL(getResult == true ? (void *) 1 : NULL, OC_STACK_KEEP_TRANSACTION);
-
- NS_LOG(DEBUG, "getting sync URI");
- getResult = OCRepPayloadGetPropString((OCRepPayload *)clientResponse->payload,
- NS_ATTRIBUTE_SYNC, & syncUri);
- NS_VERTIFY_NOT_NULL_WITH_POST_CLEANING(getResult == true ? (void *) 1 : NULL,
- OC_STACK_KEEP_TRANSACTION, OICFree(messageUri));
-
- NSProvider * newProvider = (NSProvider *)OICMalloc(sizeof(NSProvider));
- NS_VERTIFY_NOT_NULL(newProvider, OC_STACK_KEEP_TRANSACTION);
-
- // TODO set id
- newProvider->mId = NULL;
- newProvider->messageUri = messageUri;
- newProvider->syncUri = syncUri;
-
- newProvider->mUserData = (void *)OICMalloc(sizeof(OCDevAddr));
- NS_VERTIFY_NOT_NULL_WITH_POST_CLEANING(newProvider->mUserData,
- OC_STACK_KEEP_TRANSACTION, OICFree(newProvider));
- memcpy(newProvider->mUserData, clientResponse->addr, sizeof(OCDevAddr));
-
- if (accepter == NS_ACCESS_DENY)
- {
- NS_LOG(DEBUG, "accepter is NS_ACCEPTER_CONSUMER, Callback to user");
+ NS_LOG(DEBUG, "build NSTask");
+ NSTask * task = NSMakeTask(TASK_CONSUMER_PROVIDER_DISCOVERED, (void *) newProvider);
+ NS_VERIFY_NOT_NULL_WITH_POST_CLEANING(task, NS_ERROR, NSRemoveProvider_internal(newProvider));
+
+ NSConsumerPushEvent(task);
+
+ return OC_STACK_KEEP_TRANSACTION;
+}