Add structs for topic cache.
[platform/upstream/iotivity.git] / service / notification / src / common / NSStructs.h
1 //******************************************************************\r
2 //\r
3 // Copyright 2016 Samsung Electronics All Rights Reserved.\r
4 //\r
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
6 //\r
7 // Licensed under the Apache License, Version 2.0 (the "License");\r
8 // you may not use this file except in compliance with the License.\r
9 // You may obtain a copy of the License at\r
10 //\r
11 //      http://www.apache.org/licenses/LICENSE-2.0\r
12 //\r
13 // Unless required by applicable law or agreed to in writing, software\r
14 // distributed under the License is distributed on an "AS IS" BASIS,\r
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16 // See the License for the specific language governing permissions and\r
17 // limitations under the License.\r
18 //\r
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
20 \r
21 #ifndef _NS_STRUCTS_H_\r
22 #define _NS_STRUCTS_H_\r
23 \r
24 #include <string.h>\r
25 #include <stdlib.h>\r
26 #include <stdio.h>\r
27 #include <stdbool.h>\r
28 #include <octypes.h>\r
29 #include "NSCommon.h"\r
30 #include "NSConstants.h"\r
31 #include "ocstack.h"\r
32 \r
33 typedef struct _nsTask\r
34 {\r
35     NSTaskType taskType;\r
36     void * taskData;\r
37     struct _nsTask * nextTask;\r
38 } NSTask;\r
39 \r
40 typedef void * NSCacheData;\r
41 \r
42 typedef struct _NSCacheElement\r
43 {\r
44     NSCacheData * data;\r
45     struct _NSCacheElement * next;\r
46 } NSCacheElement;\r
47 \r
48 typedef struct\r
49 {\r
50     NSCacheType cacheType;\r
51     NSCacheElement * head;\r
52     NSCacheElement * tail;\r
53 } NSCacheList;\r
54 \r
55 typedef struct\r
56 {\r
57     char id[37];\r
58     int syncObId; // sync resource observer ID for local consumer\r
59     int messageObId; // message resource observer ID for local consumer\r
60     int remote_syncObId; //sync observer ID subscribed through remote server\r
61     int remote_messageObId; //message observer ID subscribed through remote server\r
62     bool isWhite; // access state -> True: allowed / False: blocked\r
63 } NSCacheSubData;\r
64 \r
65 typedef struct\r
66 {\r
67     char * id;\r
68     int messageType; // noti = 1, read = 2, dismiss = 3\r
69     NSMessage * nsMessage;\r
70 } NSCacheMsgData;\r
71 \r
72 typedef struct\r
73 {\r
74     char * topicName;\r
75     NSTopicState state;\r
76 \r
77 } NSCacheTopicData;\r
78 \r
79 typedef struct\r
80 {\r
81     char id[37];\r
82     char * topicName;\r
83     NSTopicState state;\r
84 \r
85 } NSCacheTopicSubData;\r
86 \r
87 typedef struct\r
88 {\r
89     OCResourceHandle handle;\r
90     int accepter;\r
91     char * message_uri;\r
92     char * sync_uri;\r
93 \r
94     //optional\r
95     char * topic_uri;\r
96 } NSNotificationResource;\r
97 \r
98 typedef struct\r
99 {\r
100     OCResourceHandle handle;\r
101 \r
102     uint64_t messageId;\r
103     char providerId[37];\r
104 \r
105     //optional\r
106     NSMessageType type;\r
107     char * dateTime;\r
108     uint64_t ttl;\r
109     char * title;\r
110     char * contentText;\r
111     char * sourceName;\r
112     NSMediaContents * mediaContents;\r
113 } NSMessageResource;\r
114 \r
115 typedef struct\r
116 {\r
117     OCResourceHandle handle;\r
118     char * id;\r
119     char * state;\r
120 } NSSyncResource;\r
121 \r
122 typedef struct\r
123 {\r
124     OCResourceHandle handle;\r
125     char consumerId[37];\r
126     NSTopicList ** TopicList;\r
127 } NSTopicResource;\r
128 \r
129 typedef struct\r
130 {\r
131     char providerId[37];\r
132     char * providerName;\r
133     char * userInfo;\r
134 } NSProviderInfo;\r
135 \r
136 #endif /* _NS_STRUCTS_H_ */\r