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_VERIFY_NOT_NULL_V(obj) \
50 NS_LOG_V(ERROR, "%s : %s is null", __func__, #obj); \
55 #define NS_VERIFY_NOT_NULL(obj, retVal) \
59 NS_LOG_V(ERROR, "%s : %s is null", __func__, #obj); \
64 #define NS_VERIFY_NOT_NULL_WITH_POST_CLEANING(obj, retVal, func) \
68 NS_LOG_V(ERROR, "%s : %s is null", __func__, #obj); \
69 NS_LOG(ERROR, "execute deletion"); \
75 #define NS_VERIFY_STACK_OK_V(obj) \
77 OCStackResult _ret = (obj); \
78 if ( _ret != OC_STACK_OK) \
80 NS_LOG_V(ERROR, "%s : %s is not OC_STACK_OK : %d", __func__, #obj, _ret); \
85 #define NS_VERIFY_STACK_OK(obj, retVal) \
87 OCStackResult _ret = (obj); \
88 if ( _ret != OC_STACK_OK) \
90 NS_LOG_V(ERROR, "%s : %s is not OC_STACK_OK : %d", __func__, #obj, _ret); \
95 #define NS_VERIFY_STACK_OK_WITH_POST_CLEANING(obj, retVal, func) \
97 OCStackResult _ret = (obj); \
98 if ( _ret != OC_STACK_OK) \
100 NS_LOG_V(ERROR, "%s : %s is not OC_STACK_OK : %d", __func__, #obj, _ret); \
106 #define NSOICFree(obj) \
112 NS_LOG_V(DEBUG, "%s : %s Removed", __func__, #obj); \
121 } NSConsumerMessageTypes;
130 OCDoHandle messageHandle;
131 OCDoHandle syncHandle;
133 NSAccessPolicy accessPolicy;
135 } NSProvider_internal;
150 NSMediaContents mediaContents;
153 NSConsumerMessageTypes messageTypes;
154 } NSMessage_consumer;
156 bool NSIsStartedConsumer();
157 void NSSetIsStartedConsumer(bool setValue);
159 void NSSetDiscoverProviderCb(NSProviderDiscoveredCallback cb);
160 void NSDiscoveredProvider(NSProvider * provider);
162 void NSSetSubscriptionAcceptedCb(NSSubscriptionAcceptedCallback cb);
163 void NSSubscriptionAccepted(NSProvider * provider);
165 void NSSetMessagePostedCb(NSMessageReceivedCallback cb);
166 void NSMessagePost(NSMessage * obj);
168 void NSSetNotificationSyncCb(NSSyncInfoReceivedCallback cb);
169 void NSNotificationSync(NSSyncInfo * sync);
171 char ** NSGetConsumerId();
172 void NSSetConsumerId(char * cId);
174 char * NSMakeRequestUriWithConsumerId(const char * uri);
176 NSTask * NSMakeTask(NSTaskType, void *);
178 NSResult NSConsumerPushEvent(NSTask *);
180 NSMessage_consumer * NSCopyMessage(NSMessage_consumer *);
181 void NSRemoveMessage(NSMessage_consumer *);
183 OCStackResult NSInvokeRequest(OCDoHandle * handle,
184 OCMethod method, const OCDevAddr * addr,
185 const char * queryUrl, OCPayload * payload,
186 void * callbackFunc, void * callbackData);
190 #endif // __cplusplus
192 #endif // _NS_CONSUMER_CONSTANTS_H_