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"
35 #define NS_QOS OC_HIGH_QOS
36 #define NS_RESOURCE_TYPE "oic.r.notification"
37 #define NS_RESOURCE_URI "/notification"
38 #define NS_INTERFACE_BASELINE "oic.if.baseline"
39 #define NS_INTERFACE_NOTIFICATION "oic.if.notification"
40 #define NS_RESOURCE_QUERY "/oic/res"
42 #define NS_DISCOVER_QUERY "/oic/res?rt=oic.r.notification"
43 #define NS_DEVICE_ID_LENGTH 37
45 #define NS_VERIFY_NOT_NULL_V(obj) \
49 NS_LOG_V(ERROR, "%s : %s is null", __func__, #obj); \
54 #define NS_VERIFY_NOT_NULL(obj, retVal) \
58 NS_LOG_V(ERROR, "%s : %s is null", __func__, #obj); \
63 #define NS_VERIFY_NOT_NULL_WITH_POST_CLEANING_V(obj, func) \
67 NS_LOG_V(ERROR, "%s : %s is null", __func__, #obj); \
68 NS_LOG(ERROR, "execute deletion"); \
74 #define NS_VERIFY_NOT_NULL_WITH_POST_CLEANING(obj, retVal, func) \
78 NS_LOG_V(ERROR, "%s : %s is null", __func__, #obj); \
79 NS_LOG(ERROR, "execute deletion"); \
85 #define NS_VERIFY_STACK_SUCCESS_V(obj) \
90 NS_LOG_V(ERROR, "%s : %s is not OC_STACK_OK : %d", __func__, #obj, _ret); \
95 #define NS_VERIFY_STACK_SUCCESS(obj, retVal) \
100 NS_LOG_V(ERROR, "%s : %s is not OC_STACK_OK : %d", __func__, #obj, _ret); \
105 #define NS_VERIFY_STACK_SUCCESS_WITH_POST_CLEANING(obj, retVal, func) \
110 NS_LOG_V(ERROR, "%s : %s is not OC_STACK_OK : %d", __func__, #obj, _ret); \
116 #define NSOICFree(obj) \
122 NS_LOG_V(DEBUG, "%s : %s Removed", __func__, #obj); \
128 NS_DISCOVER_DEFAULT, // will work for adapter_ip.
132 } NSConsumerDiscoverType;
134 typedef struct NSProviderConnectionInfo
138 OCDoHandle messageHandle;
139 OCDoHandle syncHandle;
141 bool isCloudConnection;
144 struct NSProviderConnectionInfo * next;
146 } NSProviderConnectionInfo;
150 char providerId[NS_DEVICE_ID_LENGTH];
155 NSAccessPolicy accessPolicy;
157 NSProviderConnectionInfo * connection;
159 } NSProvider_internal;
164 char providerId[NS_DEVICE_ID_LENGTH];
167 NSProviderConnectionInfo * connection;
169 } NSSyncInfo_internal;
175 char providerId[NS_DEVICE_ID_LENGTH];
184 NSMediaContents * mediaContents;
186 } NSMessage_consumer;
188 bool NSIsStartedConsumer();
189 void NSSetIsStartedConsumer(bool setValue);
191 void NSSetDiscoverProviderCb(NSProviderDiscoveredCallback cb);
192 void NSDiscoveredProvider(NSProvider * provider);
194 void NSSetSubscriptionAcceptedCb(NSSubscriptionAcceptedCallback cb);
195 void NSSubscriptionAccepted(NSProvider * provider);
197 void NSSetMessagePostedCb(NSMessageReceivedCallback cb);
198 void NSMessagePost(NSMessage * obj);
200 void NSSetNotificationSyncCb(NSSyncInfoReceivedCallback cb);
201 void NSNotificationSync(NSSyncInfo * sync);
203 char ** NSGetConsumerId();
204 void NSSetConsumerId(char * cId);
206 char * NSMakeRequestUriWithConsumerId(const char * uri);
208 NSTask * NSMakeTask(NSTaskType, void *);
210 NSResult NSConsumerPushEvent(NSTask *);
212 NSMessage_consumer * NSCopyMessage(NSMessage_consumer *);
213 void NSRemoveMessage(NSMessage_consumer *);
215 NSProviderConnectionInfo * NSCreateProviderConnections(OCDevAddr * inAddr);
216 NSProviderConnectionInfo * NSCopyProviderConnections(NSProviderConnectionInfo * conn);
217 void NSRemoveConnections(NSProviderConnectionInfo * connections);
219 NSProvider_internal * NSCopyProvider(NSProvider_internal *);
220 void NSRemoveProvider(NSProvider_internal *);
222 OCStackResult NSInvokeRequest(OCDoHandle * handle,
223 OCMethod method, const OCDevAddr * addr,
224 const char * queryUrl, OCPayload * payload,
225 void * callbackFunc, void * callbackData, OCConnectivityType type);
227 bool NSOCResultToSuccess(OCStackResult ret);
231 #endif // __cplusplus
233 #endif // _NS_CONSUMER_CONSTANTS_H_