added cacheadapter interface and memorycache of notification.
[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 "NSCommon.h"
32 #include "NSStructs.h"
33 #include "ocstack.h"
34 #include "NSConsumerInterface.h"
35
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"
42
43 #define NS_DISCOVER_QUERY "/oic/res?rt=oic.r.notification"
44
45 typedef OCStackApplicationResult (*onRIResponseListener)(
46         void *, OCDoHandle, OCClientResponse *);
47
48 typedef enum
49 {
50     Read,
51     Dismiss,
52     Notification,
53 } NSConsumerMessageTypes;
54
55 typedef struct
56 {
57     // Mandatory
58     char * mId;
59     char * mTitle;
60
61     //Optional
62     char * mContentText;
63
64     OCDevAddr * addr;
65     char * syncUri;
66     NSConsumerMessageTypes type;
67 } NSMessage_consumer;
68
69 bool NSIsStartedConsumer();
70 void NSSetIsStartedConsumer(bool setValue);
71
72 void NSSetDiscoverProviderCb(NSProviderDiscoveredCallback cb);
73 void NSDiscoveredProvider(NSProvider * handle);
74
75 void NSSetNotificationPostedCb(NSNotificationReceivedCallback  cb);
76 void NSNotificationPost(NSProvider * provider, NSMessage * obj);
77
78 void NSSetNotificationSyncCb(NSSyncCallback cb);
79 void NSNotificationSync(NSProvider * provider, NSSync * sync);
80
81 onRIResponseListener NSGetResponseListener();
82 void NSSetResponseListener(onRIResponseListener cb);
83
84 NSTask * NSMakeTask(NSTaskType, void *);
85
86 NSResult NSConsumerPushEvent(NSTask *);
87
88 NSMessage_consumer * NSCopyMessage(NSMessage_consumer *);
89 void NSRemoveMessage(NSMessage_consumer *);
90
91 OCStackResult NSRequestToResourceIntrospection(OCDoHandle * handle,
92         OCMethod method, const OCDevAddr * addr,
93         const char * queryUrl, OCPayload * payload, void * callback);
94
95 #ifdef __cplusplus
96 }
97 #endif // __cplusplus
98
99 #endif // _NS_CONSUMER_CONSTANTS_H_