X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=service%2Fnotification%2Fsrc%2Fconsumer%2FNSConsumerCommon.h;h=2100b225244301e394b030c9307e7176c46917cb;hb=refs%2Ftags%2Fsubmit%2Ftizen_4.0%2F20171010.021147;hp=4bd82e3ced0fa44a93be5cbf7ed6e8b38aefa3ed;hpb=d5243537633f13ee80c7088d0e748df76222273b;p=platform%2Fupstream%2Fiotivity.git diff --git a/service/notification/src/consumer/NSConsumerCommon.h b/service/notification/src/consumer/NSConsumerCommon.h index 4bd82e3..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,157 +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_DISCOVER_QUERY "/oic/res?rt=x.org.iotivity.notification" #define NS_DEVICE_ID_LENGTH 37 -#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 NSOICFree(obj) \ - { \ - if ((obj)) \ - { \ - OICFree((obj)); \ - (obj) = NULL; \ - } \ - } +typedef enum +{ + NS_DISCOVER_DEFAULT, // will work for adapter_ip. + NS_DISCOVER_UDP, + NS_DISCOVER_TCP, + NS_DISCOVER_CLOUD +} NSConsumerDiscoverType; typedef enum { - Read, - Dismiss, - Notification, -} NSConsumerMessageTypes; + NS_SELECTION_CONSUMER = 0, + NS_SELECTION_PROVIDER = 1 +} NSSelector; + +typedef struct NSProviderConnectionInfo +{ + OCDevAddr * addr; + + OCDoHandle messageHandle; + OCDoHandle syncHandle; + + bool isCloudConnection; + bool isSubscribing; + + struct NSProviderConnectionInfo * next; + +} NSProviderConnectionInfo; typedef struct { - char providerId[37]; + char providerId[NS_DEVICE_ID_LENGTH]; + + NSTopicLL * topicLL; char * messageUri; char * syncUri; + char * topicUri; - OCDoHandle messageHandle; - OCDoHandle syncHandle; - OCDevAddr * addr; - NSAccessPolicy accessPolicy; + NSSelector accessPolicy; + NSProviderState state; + + NSProviderConnectionInfo * connection; } NSProvider_internal; typedef struct { - // Mandatory uint64_t messageId; - char * providerId; + char providerId[NS_DEVICE_ID_LENGTH]; + NSSyncType state; - //optional - NSMessageType type; - char * dateTime; - uint64_t ttl; - char * title; - char * contentText; - char * sourceName; - NSMediaContents mediaContents; + NSProviderConnectionInfo * connection; - OCDevAddr * addr; - NSConsumerMessageTypes messageTypes; -} NSMessage_consumer; +} 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 NSSetMessagePostedCb(NSNotificationReceivedCallback cb); -void NSMessagePost(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); char ** NSGetConsumerId(); void NSSetConsumerId(char * cId); -char * NSGetQuery(const char * uri); +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_