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.wk.notification"
37 #define NS_RESOURCE_URI "/notification"
38 #define NS_INTERFACE_BASELINE "oic.if.baseline"
39 #define NS_RESOURCE_QUERY "/oic/res"
41 #define NS_DISCOVER_QUERY "/oic/res?rt=oic.wk.notification"
42 #define NS_DEVICE_ID_LENGTH 37
46 NS_DISCOVER_DEFAULT, // will work for adapter_ip.
50 } NSConsumerDiscoverType;
54 NS_SELECTION_CONSUMER = 0,
55 NS_SELECTION_PROVIDER = 1
58 typedef struct NSProviderConnectionInfo
62 OCDoHandle messageHandle;
63 OCDoHandle syncHandle;
65 bool isCloudConnection;
68 struct NSProviderConnectionInfo * next;
70 } NSProviderConnectionInfo;
74 char providerId[NS_DEVICE_ID_LENGTH];
82 NSSelector accessPolicy;
83 NSProviderState state;
85 NSProviderConnectionInfo * connection;
87 } NSProvider_internal;
92 char providerId[NS_DEVICE_ID_LENGTH];
95 NSProviderConnectionInfo * connection;
97 } NSSyncInfo_internal;
99 bool NSIsStartedConsumer();
100 void NSSetIsStartedConsumer(bool setValue);
102 void NSSetProviderChangedCb(NSProviderStateCallback cb);
103 void NSProviderChanged(NSProvider * provider, NSProviderState response);
105 void NSSetMessagePostedCb(NSMessageReceivedCallback cb);
106 void NSMessagePost(NSMessage * obj);
108 void NSSetNotificationSyncCb(NSSyncInfoReceivedCallback cb);
109 void NSNotificationSync(NSSyncInfo * sync);
111 char ** NSGetConsumerId();
112 void NSSetConsumerId(char * cId);
114 char * NSMakeRequestUriWithConsumerId(const char * uri);
116 NSTask * NSMakeTask(NSTaskType, void *);
118 NSResult NSConsumerPushEvent(NSTask *);
120 NSMessage * NSCopyMessage(NSMessage *);
121 void NSRemoveMessage(NSMessage *);
123 NSProviderConnectionInfo * NSCreateProviderConnections(OCDevAddr *);
124 NSProviderConnectionInfo * NSCopyProviderConnections(NSProviderConnectionInfo *);
125 void NSRemoveConnections(NSProviderConnectionInfo *);
127 NSProvider_internal * NSCopyProvider_internal(NSProvider_internal *);
128 NSProvider * NSCopyProvider(NSProvider_internal *);
129 void NSRemoveProvider_internal(void *);
130 void NSRemoveProvider(NSProvider *);
132 NSTopicLL * NSCopyTopicNode(NSTopicLL *);
133 void NSRemoveTopicNode(NSTopicLL *);
134 NSResult NSInsertTopicNode(NSTopicLL *, NSTopicLL *);
136 NSTopicLL * NSCopyTopicLL(NSTopicLL *);
137 void NSRemoveTopicLL(NSTopicLL *);
139 OCStackResult NSInvokeRequest(OCDoHandle * handle,
140 OCMethod method, const OCDevAddr * addr,
141 const char * queryUrl, OCPayload * payload,
142 void * callbackFunc, void * callbackData,
143 OCClientContextDeleter cd, OCConnectivityType type);
145 bool NSOCResultToSuccess(OCStackResult ret);
149 #endif // __cplusplus
151 #endif // _NS_CONSUMER_COMMON_H_