X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=service%2Fnotification%2Fsrc%2Fconsumer%2FNSConsumerCommon.h;h=2100b225244301e394b030c9307e7176c46917cb;hb=3c093548382bb2542c87a67e6e5fa32552c29cb3;hp=06d9494f24146d3d748545d64161b93809f91b2e;hpb=2fe1c5ea6741015a119958911e34613f4852c175;p=platform%2Fupstream%2Fiotivity.git diff --git a/service/notification/src/consumer/NSConsumerCommon.h b/service/notification/src/consumer/NSConsumerCommon.h index 06d9494..2100b22 100644 --- a/service/notification/src/consumer/NSConsumerCommon.h +++ b/service/notification/src/consumer/NSConsumerCommon.h @@ -18,8 +18,8 @@ // //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -#ifndef _NS_CONSUMER_CONSTANTS_H_ -#define _NS_CONSUMER_CONSTANTS_H_ +#ifndef _NS_CONSUMER_COMMON_H_ +#define _NS_CONSUMER_COMMON_H_ #ifdef __cplusplus extern "C" { @@ -32,113 +32,124 @@ extern "C" { #include "NSStructs.h" #include "ocstack.h" -#define NS_QOS OC_LOW_QOS -#define NS_RESOURCE_TYPE "oic.r.notification" +#define NS_QOS OC_HIGH_QOS +#define NS_RESOURCE_TYPE "x.org.iotivity.notification" #define NS_RESOURCE_URI "/notification" #define NS_INTERFACE_BASELINE "oic.if.baseline" -#define NS_INTERFACE_NOTIFICATION "oic.if.notification" #define NS_RESOURCE_QUERY "/oic/res" -#define NS_DISCOVER_QUERY "/oic/res?rt=oic.r.notification" - -#define NS_VERTIFY_NOT_NULL_V(obj) { if ((obj) == NULL) \ - { \ - NS_LOG_V(ERROR, "%s : obj is null", __func__); \ - return; \ - }} - -#define NS_VERTIFY_NOT_NULL(obj, retVal) { if ((obj) == NULL) \ - { \ - NS_LOG_V(ERROR, "%s : obj is null", __func__); \ - return (retVal); \ - }} - -#define NS_VERTIFY_NOT_NULL_WITH_POST_CLEANING(obj, retVal, func) { \ - if ((obj) == NULL) \ - { \ - NS_LOG_V(ERROR, "%s : obj is null", __func__); \ - NS_LOG(ERROR, "execute deletion"); \ - (func); \ - return (retVal); \ - }} - -#define NS_VERTIFY_STACK_OK_V(obj) { OCStackResult _ret = (obj); \ - if ( _ret != OC_STACK_OK) \ - { \ - NS_LOG_V(ERROR, "%s : obj is not OC_STACK_OK : %d", __func__, _ret); \ - return; \ - }} - -#define NS_VERTIFY_STACK_OK(obj, retVal) { OCStackResult _ret = (obj); \ - if ( _ret != OC_STACK_OK) \ - { \ - NS_LOG_V(ERROR, "%s : obj is not OC_STACK_OK : %d", __func__, _ret); \ - return (retVal); \ - }} - -#define NS_VERTIFY_STACK_OK_WITH_POST_CLEANING(obj, retVal, func) { \ - OCStackResult _ret = (obj); \ - if ( _ret != OC_STACK_OK) \ - { \ - NS_LOG_V(ERROR, "%s : obj is not OC_STACK_OK : %d", __func__, _ret); \ - (func); \ - return (retVal); \ - }} +#define NS_DISCOVER_QUERY "/oic/res?rt=x.org.iotivity.notification" +#define NS_DEVICE_ID_LENGTH 37 typedef enum { - Read, - Dismiss, - Notification, -} NSConsumerMessageTypes; + NS_DISCOVER_DEFAULT, // will work for adapter_ip. + NS_DISCOVER_UDP, + NS_DISCOVER_TCP, + NS_DISCOVER_CLOUD +} NSConsumerDiscoverType; -typedef struct +typedef enum +{ + NS_SELECTION_CONSUMER = 0, + NS_SELECTION_PROVIDER = 1 +} NSSelector; + +typedef struct NSProviderConnectionInfo { - // Mandatory - uint64_t messageId; - char * providerId; - - //optional - NSMessageType type; - char * dateTime; - uint64_t ttl; - char * title; - char * contentText; - char * sourceName; - NSMediaContents mediaContents; - - //Optional OCDevAddr * addr; + + OCDoHandle messageHandle; + OCDoHandle syncHandle; + + bool isCloudConnection; + bool isSubscribing; + + struct NSProviderConnectionInfo * next; + +} NSProviderConnectionInfo; + +typedef struct +{ + char providerId[NS_DEVICE_ID_LENGTH]; + + NSTopicLL * topicLL; + + char * messageUri; char * syncUri; - NSConsumerMessageTypes messageTypes; -} NSMessage_consumer; + char * topicUri; + + NSSelector accessPolicy; + NSProviderState state; + + NSProviderConnectionInfo * connection; + +} NSProvider_internal; + +typedef struct +{ + uint64_t messageId; + char providerId[NS_DEVICE_ID_LENGTH]; + NSSyncType state; + + NSProviderConnectionInfo * connection; + +} NSSyncInfo_internal; bool NSIsStartedConsumer(); void NSSetIsStartedConsumer(bool setValue); -void NSSetDiscoverProviderCb(NSProviderDiscoveredCallback cb); -void NSDiscoveredProvider(NSProvider * handle); +void NSSetProviderChangedCb(NSProviderStateCallback cb); +void NSProviderChanged(NSProvider * provider, NSProviderState response); -void NSSetNotificationPostedCb(NSNotificationReceivedCallback cb); -void NSNotificationPost(NSProvider * provider, NSMessage * obj); +void NSSetMessagePostedCb(NSMessageReceivedCallback cb); +void NSMessagePost(NSMessage * obj); -void NSSetNotificationSyncCb(NSSyncCallback cb); -void NSNotificationSync(NSProvider * provider, NSSyncInfo * sync); +void NSSetNotificationSyncCb(NSSyncInfoReceivedCallback cb); +void NSNotificationSync(NSSyncInfo * sync); -NSTask * NSMakeTask(NSTaskType, void *); +char ** NSGetConsumerId(); +void NSSetConsumerId(char * cId); +char * NSMakeRequestUriWithConsumerId(const char * uri); + +NSTask * NSMakeTask(NSTaskType, void *); NSResult NSConsumerPushEvent(NSTask *); -NSMessage_consumer * NSCopyMessage(NSMessage_consumer *); -void NSRemoveMessage(NSMessage_consumer *); +NSMessage * NSGetMessage(OCRepPayload * payload); +NSMessage * NSCopyMessage(NSMessage *); +void NSRemoveMessage(NSMessage *); + +void NSGetProviderPostClean( + char * pId, char * mUri, char * sUri, char * tUri, NSProviderConnectionInfo * connection); + +NSProvider_internal * NSGetProvider(OCClientResponse * clientResponse); +NSProviderConnectionInfo * NSCreateProviderConnections(OCDevAddr *); +NSProviderConnectionInfo * NSCopyProviderConnections(NSProviderConnectionInfo *); +void NSRemoveConnections(NSProviderConnectionInfo *); + +NSProvider_internal * NSCopyProvider_internal(NSProvider_internal *); +NSProvider * NSCopyProvider(NSProvider_internal *); +void NSRemoveProvider_internal(void *); +void NSRemoveProvider(NSProvider *); + +NSTopicLL * NSCopyTopicNode(NSTopicLL *); +void NSRemoveTopicNode(NSTopicLL *); +NSResult NSInsertTopicNode(NSTopicLL *, NSTopicLL *); + +NSTopicLL * NSCopyTopicLL(NSTopicLL *); +void NSRemoveTopicLL(NSTopicLL *); OCStackResult NSInvokeRequest(OCDoHandle * handle, OCMethod method, const OCDevAddr * addr, const char * queryUrl, OCPayload * payload, - void * callbackFunc, void * callbackData); + void * callbackFunc, void * callbackData, + OCClientContextDeleter cd, OCConnectivityType type); + +bool NSOCResultToSuccess(OCStackResult ret); #ifdef __cplusplus } #endif // __cplusplus -#endif // _NS_CONSUMER_CONSTANTS_H_ +#endif // _NS_CONSUMER_COMMON_H_