1 //******************************************************************
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef _NS_CONSUMER_CONSTANTS_H_
22 #define _NS_CONSUMER_CONSTANTS_H_
31 #include "NSConsumerInterface.h"
32 #include "NSStructs.h"
36 #define NS_QOS OC_LOW_QOS
37 #define NS_RESOURCE_TYPE "oic.r.notification"
38 #define NS_RESOURCE_URI "/notification"
39 #define NS_INTERFACE_BASELINE "oic.if.baseline"
40 #define NS_INTERFACE_NOTIFICATION "oic.if.notification"
41 #define NS_RESOURCE_QUERY "/oic/res"
43 #define NS_DISCOVER_QUERY "/oic/res?rt=oic.r.notification"
44 #define NS_DEVICE_ID_LENGTH 37
46 #define NS_VERTIFY_NOT_NULL_V(obj) \
50 NS_LOG_V(ERROR, "%s : obj is null", __func__); \
55 #define NS_VERTIFY_NOT_NULL(obj, retVal) \
59 NS_LOG_V(ERROR, "%s : obj is null", __func__); \
64 #define NS_VERTIFY_NOT_NULL_WITH_POST_CLEANING(obj, retVal, func) \
68 NS_LOG_V(ERROR, "%s : obj is null", __func__); \
69 NS_LOG(ERROR, "execute deletion"); \
75 #define NS_VERTIFY_STACK_OK_V(obj) \
77 OCStackResult _ret = (obj); \
78 if ( _ret != OC_STACK_OK) \
80 NS_LOG_V(ERROR, "%s : obj is not OC_STACK_OK : %d", __func__, _ret); \
85 #define NS_VERTIFY_STACK_OK(obj, retVal) \
87 OCStackResult _ret = (obj); \
88 if ( _ret != OC_STACK_OK) \
90 NS_LOG_V(ERROR, "%s : obj is not OC_STACK_OK : %d", __func__, _ret); \
95 #define NS_VERTIFY_STACK_OK_WITH_POST_CLEANING(obj, retVal, func) \
97 OCStackResult _ret = (obj); \
98 if ( _ret != OC_STACK_OK) \
100 NS_LOG_V(ERROR, "%s : obj is not OC_STACK_OK : %d", __func__, _ret); \
106 #define NSOICFree(obj) \
120 } NSConsumerMessageTypes;
129 OCDoHandle messageHandle;
130 OCDoHandle syncHandle;
132 NSAccessPolicy accessPolicy;
134 } NSProvider_internal;
149 NSMediaContents mediaContents;
152 NSConsumerMessageTypes messageTypes;
153 } NSMessage_consumer;
155 bool NSIsStartedConsumer();
156 void NSSetIsStartedConsumer(bool setValue);
158 void NSSetDiscoverProviderCb(NSProviderDiscoveredCallback cb);
159 void NSDiscoveredProvider(NSProvider * handle);
161 void NSSetMessagePostedCb(NSNotificationReceivedCallback cb);
162 void NSMessagePost(NSProvider * provider, NSMessage * obj);
164 void NSSetNotificationSyncCb(NSSyncCallback cb);
165 void NSNotificationSync(NSProvider * provider, NSSyncInfo * sync);
167 char ** NSGetConsumerId();
168 void NSSetConsumerId(char * cId);
170 char * NSGetQuery(const char * uri);
172 NSTask * NSMakeTask(NSTaskType, void *);
174 NSResult NSConsumerPushEvent(NSTask *);
176 NSMessage_consumer * NSCopyMessage(NSMessage_consumer *);
177 void NSRemoveMessage(NSMessage_consumer *);
179 OCStackResult NSInvokeRequest(OCDoHandle * handle,
180 OCMethod method, const OCDevAddr * addr,
181 const char * queryUrl, OCPayload * payload,
182 void * callbackFunc, void * callbackData);
186 #endif // __cplusplus
188 #endif // _NS_CONSUMER_CONSTANTS_H_