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_COMMON_H_
22 #define _NS_CONSUMER_COMMON_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
47 NS_DISCOVER_DEFAULT, // will work for adapter_ip.
51 } NSConsumerDiscoverType;
55 NS_SELECTION_CONSUMER = 0,
56 NS_SELECTION_PROVIDER = 1
59 typedef struct NSProviderConnectionInfo
63 OCDoHandle messageHandle;
64 OCDoHandle syncHandle;
66 bool isCloudConnection;
69 struct NSProviderConnectionInfo * next;
71 } NSProviderConnectionInfo;
75 char providerId[NS_DEVICE_ID_LENGTH];
83 NSSelector accessPolicy;
85 NSProviderConnectionInfo * connection;
87 } NSProvider_internal;
92 char providerId[NS_DEVICE_ID_LENGTH];
95 NSProviderConnectionInfo * connection;
97 } NSSyncInfo_internal;
106 bool NSIsStartedConsumer();
107 void NSSetIsStartedConsumer(bool setValue);
109 void NSSetDiscoverProviderCb(NSProviderDiscoveredCallback cb);
110 void NSDiscoveredProvider(NSProvider * provider);
112 void NSSetProviderChangedCb(NSProviderChangedCallback cb);
113 void NSProviderChanged(NSProvider * provider, NSResponse response);
115 void NSSetMessagePostedCb(NSMessageReceivedCallback cb);
116 void NSMessagePost(NSMessage * obj);
118 void NSSetNotificationSyncCb(NSSyncInfoReceivedCallback cb);
119 void NSNotificationSync(NSSyncInfo * sync);
121 char ** NSGetConsumerId();
122 void NSSetConsumerId(char * cId);
124 char * NSMakeRequestUriWithConsumerId(const char * uri);
126 NSTask * NSMakeTask(NSTaskType, void *);
128 NSResult NSConsumerPushEvent(NSTask *);
130 NSMessage * NSCopyMessage(NSMessage *);
131 void NSRemoveMessage(NSMessage *);
133 NSProviderConnectionInfo * NSCreateProviderConnections(OCDevAddr *);
134 NSProviderConnectionInfo * NSCopyProviderConnections(NSProviderConnectionInfo *);
135 void NSRemoveConnections(NSProviderConnectionInfo *);
137 NSProvider_internal * NSCopyProvider_internal(NSProvider_internal *);
138 NSProvider * NSCopyProvider(NSProvider_internal *);
139 void NSRemoveProvider_internal(NSProvider_internal *);
140 void NSRemoveProvider(NSProvider *);
142 NSSyncInfo_internal * NSCopySyncInfo(NSSyncInfo_internal *);
143 void NSRemoveSyncInfo(NSSyncInfo_internal *);
145 NSTopicLL * NSCopyTopicNode(NSTopicLL *);
146 void NSRemoveTopicNode(NSTopicLL *);
147 NSResult NSInsertTopicNode(NSTopicLL *, NSTopicLL *);
149 NSTopicLL * NSCopyTopicLL(NSTopicLL *);
150 void NSRemoveTopicLL(NSTopicLL *);
152 OCStackResult NSInvokeRequest(OCDoHandle * handle,
153 OCMethod method, const OCDevAddr * addr,
154 const char * queryUrl, OCPayload * payload,
155 void * callbackFunc, void * callbackData, OCConnectivityType type);
157 bool NSOCResultToSuccess(OCStackResult ret);
161 #endif // __cplusplus
163 #endif // _NS_CONSUMER_COMMON_H_