Add Memory Cache module for Consumer on Linux.
[platform/upstream/iotivity.git] / service / notification / src / consumer / NSConsumerCommon.h
1 //******************************************************************
2 //
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #ifndef _NS_CONSUMER_CONSTANTS_H_
22 #define _NS_CONSUMER_CONSTANTS_H_
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif // __cplusplus
27
28 #include <stdio.h>
29 #include <stdbool.h>
30
31 #include "NSConsumerInterface.h"
32 #include "NSStructs.h"
33 #include "ocstack.h"
34
35 #define NS_QOS OC_LOW_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"
41
42 #define NS_DISCOVER_QUERY "/oic/res?rt=oic.r.notification"
43
44 typedef OCStackApplicationResult (*onRIResponseListener)(
45         void *, OCDoHandle, OCClientResponse *);
46
47 typedef enum
48 {
49     Read,
50     Dismiss,
51     Notification,
52 } NSConsumerMessageTypes;
53
54 typedef struct
55 {
56     // Mandatory
57     char * mId;
58     char * mTitle;
59
60     //Optional
61     char * mContentText;
62
63     OCDevAddr * addr;
64     char * syncUri;
65     NSConsumerMessageTypes type;
66 } NSMessage_consumer;
67
68 bool NSIsStartedConsumer();
69 void NSSetIsStartedConsumer(bool setValue);
70
71 void NSSetDiscoverProviderCb(NSProviderDiscoveredCallback cb);
72 void NSDiscoveredProvider(NSProvider * handle);
73
74 void NSSetNotificationPostedCb(NSNotificationReceivedCallback  cb);
75 void NSNotificationPost(NSProvider * provider, NSMessage * obj);
76
77 void NSSetNotificationSyncCb(NSSyncCallback cb);
78 void NSNotificationSync(NSProvider * provider, NSSync * sync);
79
80 onRIResponseListener NSGetResponseListener();
81 void NSSetResponseListener(onRIResponseListener cb);
82
83 NSTask * NSMakeTask(NSTaskType, void *);
84
85 NSResult NSConsumerPushEvent(NSTask *);
86
87 NSMessage_consumer * NSCopyMessage(NSMessage_consumer *);
88 void NSRemoveMessage(NSMessage_consumer *);
89
90 OCStackResult NSRequestToResourceIntrospection(OCDoHandle * handle,
91         OCMethod method, const OCDevAddr * addr,
92         const char * queryUrl, OCPayload * payload, void * callback);
93
94 #ifdef __cplusplus
95 }
96 #endif // __cplusplus
97
98 #endif // _NS_CONSUMER_CONSTANTS_H_