/src/resiprocate/resip/stack/MessageWaitingContents.hxx
Line | Count | Source |
1 | | #if !defined(RESIP_MESSAGEWAITINGCONTENTS_HXX) |
2 | | #define RESIP_MESSAGEWAITINGCONTENTS_HXX |
3 | | |
4 | | #include <map> |
5 | | |
6 | | #include "resip/stack/Contents.hxx" |
7 | | #include "rutil/Data.hxx" |
8 | | |
9 | | namespace resip |
10 | | { |
11 | | |
12 | | const char* skipSipLWS(ParseBuffer& pb); |
13 | | |
14 | | /** @brief An enumeration of MessageWaiting header types for use with resip::MessageWaitingContents. |
15 | | |
16 | | Also see resip::mw_account to access the special Message-Account header for MessageWaiting. |
17 | | **/ |
18 | | typedef enum {mw_voice=0, mw_fax, mw_pager, mw_multimedia, mw_text, mw_none, MW_MAX} HeaderType; |
19 | | |
20 | | /** |
21 | | @ingroup sip_payload |
22 | | @brief SIP body type for holding MWI contents (MIME content-type application/simple-message-summary). |
23 | | |
24 | | See resip/stack/test/testMessageWaiting.cxx for usage examples. |
25 | | */ |
26 | | class MessageWaitingContents : public Contents |
27 | | { |
28 | | public: |
29 | | MessageWaitingContents(); |
30 | | MessageWaitingContents(const HeaderFieldValue& hfv, const Mime& contentType); |
31 | | MessageWaitingContents(const Data& data, const Mime& contentType); |
32 | | MessageWaitingContents(const MessageWaitingContents& rhs); |
33 | | virtual ~MessageWaitingContents(); |
34 | | MessageWaitingContents& operator=(const MessageWaitingContents& rhs); |
35 | | |
36 | | /** @brief duplicate an MessageWaitingContents object |
37 | | @return pointer to a new MessageWaitingContents object |
38 | | **/ |
39 | | virtual Contents* clone() const; |
40 | | |
41 | | static const Mime& getStaticType() ; |
42 | | |
43 | | virtual EncodeStream& encodeParsed(EncodeStream& str) const; |
44 | | virtual void parse(ParseBuffer& pb); |
45 | | |
46 | | class Header; |
47 | | |
48 | | /** @brief Get the header correspoding to ht |
49 | | @param ht HeaderType used to lookup MessageWaiting header |
50 | | @return Header corresponding to ht |
51 | | **/ |
52 | | Header& header(HeaderType ht); |
53 | | const Header& header(HeaderType ht) const; |
54 | | |
55 | | /** @brief Check if HeaderType is present |
56 | | @param ht HeaderType used to lookup MessageWaiting header |
57 | | @return bool true if HeaderType exists |
58 | | **/ |
59 | | bool exists(HeaderType ht) const; |
60 | | |
61 | | /** @brief Remove the header correspoding to ht |
62 | | @param ht HeaderType used to remove from MessageWaiting header |
63 | | **/ |
64 | | void remove(HeaderType ht); |
65 | | |
66 | | /** @brief makes accessing the MessageAccount Uri |
67 | | operate like accessing the other MessageWaiting headers. |
68 | | |
69 | | However, the user of these calls has to treat them differently |
70 | | since the two header calls return different classes. |
71 | | |
72 | | @todo This is an awkward attempt to make accessing the MessageAccount Uri |
73 | | operate like accessing the other MessageWaiting headers even though |
74 | | the user of these calls has to treat them differently to being with |
75 | | since the two header calls return different classes. ugh. .mjf. |
76 | | **/ |
77 | | class AccountHeader {}; |
78 | | |
79 | | /** @brief Get the Uri for Message-Account line |
80 | | @param ht AccountHeader used to lookup MessageWaiting header - not really used computationally |
81 | | @return Uri for Message-Account line |
82 | | **/ |
83 | | const Uri& header(const AccountHeader& ht) const; |
84 | | Uri& header(const AccountHeader& ht); |
85 | | |
86 | | /** @brief Check if Message-Account line is present |
87 | | @note This call only indicates the actual existence of the Message-Account |
88 | | line in the MessageWaiting doc if header(mw_account) hasn't been called. |
89 | | After that call the exists(mw_account) call will return true (since a |
90 | | Uri now exists) whether or not the Uri was built based on the |
91 | | MessageWaiting doc. |
92 | | @param ht AccountHeader used to lookup MessageWaiting header - not really used computationally |
93 | | @return bool true if HeaderType exists |
94 | | **/ |
95 | | bool exists(const AccountHeader& ht) const; |
96 | | |
97 | | /** @brief Remove the Uri for Message-Account line |
98 | | @param ht AccountHeader used to lookup MessageWaiting header - not really used computationally |
99 | | **/ |
100 | | void remove(const AccountHeader& ht); |
101 | | |
102 | | /** @brief Get the value correspoding to optional message header hn in the MessageWaiting doc. |
103 | | |
104 | | Used to access optional message headers in the MessageWaiting doc |
105 | | |
106 | | @param hn HeaderType used to lookup the optional MessageWaiting header |
107 | | @return Data corresponding to hn |
108 | | **/ |
109 | | const Data& header(const Data& hn) const; |
110 | | Data& header(const Data& hn); |
111 | | |
112 | | /** @brief Check if optional message header hn is present |
113 | | @param hn HeaderType used to lookup the optional MessageWaiting header |
114 | | @return bool true if optional message header exists |
115 | | **/ |
116 | | bool exists(const Data& hn) const; |
117 | | |
118 | | /** @brief Remove the optional message header corresponding to hn |
119 | | @param hn HeaderType used to lookup the optional MessageWaiting header |
120 | | **/ |
121 | | void remove(const Data& hn); |
122 | | |
123 | | /** @brief Check to see if there are messages |
124 | | @return bool true if there are messages |
125 | | **/ |
126 | 0 | bool& hasMessages() { checkParsed(); return mHasMessages; } |
127 | | |
128 | | /** @brief Provides an interface for reading and modifying MessageWaiting bodies. |
129 | | **/ |
130 | | class Header |
131 | | { |
132 | | public: |
133 | | /** @brief Header constructor. |
134 | | Create a Header using new count and old message counts. |
135 | | @param numNew new message count |
136 | | @param numOld old message count |
137 | | **/ |
138 | | Header(unsigned int numNew, |
139 | | unsigned int numOld); |
140 | | |
141 | | /** @brief Header constructor with urgent counts. |
142 | | Create a Header using new/old/urgent new/urgent old message counts. |
143 | | @param numNew new message count |
144 | | @param numOld old message count |
145 | | @param numUrgentNew new urgent message count |
146 | | @param numUrgentOld old urgent message count |
147 | | **/ |
148 | | Header(unsigned int numNew, |
149 | | unsigned int numOld, |
150 | | unsigned int numUrgentNew, |
151 | | unsigned int numUrgentOld); |
152 | | |
153 | | /** @brief Return new message count |
154 | | @return int new message count |
155 | | **/ |
156 | 0 | const unsigned int& newCount() const {return mNew;} |
157 | | |
158 | | /** @brief Return new message count |
159 | | @return int new message count |
160 | | **/ |
161 | 0 | unsigned int& newCount() {return mNew;} |
162 | | |
163 | | /** @brief Return old message count |
164 | | @return int new message count |
165 | | **/ |
166 | 0 | const unsigned int& oldCount() const {return mOld;} |
167 | | |
168 | | /** @brief Return old message count |
169 | | @return int new message count |
170 | | **/ |
171 | 0 | unsigned int& oldCount() {return mOld;} |
172 | | |
173 | | /** @brief Return bool indicating that there are urgent messages |
174 | | @note Currently this is only set during construction. Modification of the new and old urgent counts does not update this field. |
175 | | @return bool true if there are urgent messages |
176 | | **/ |
177 | 0 | const bool& urgent() const {return mHasUrgent;} |
178 | | |
179 | | /** @brief Return bool indicating that there are urgent messages |
180 | | @note Currently this is only set during construction. Modification of the new and old urgent counts does not update this field. |
181 | | @return bool true if there are urgent messages |
182 | | **/ |
183 | 0 | bool& urgent() {return mHasUrgent;} |
184 | | |
185 | | /** @brief Return new urgent message count |
186 | | @return int new message count |
187 | | **/ |
188 | 0 | const unsigned int& urgentNewCount() const {return mUrgentNew;} |
189 | | |
190 | | /** @brief Return new urgent message count |
191 | | @return int new message count |
192 | | **/ |
193 | 0 | unsigned int& urgentNewCount() {return mUrgentNew;} |
194 | | |
195 | | /** @brief Return new message count |
196 | | @return int new message count |
197 | | **/ |
198 | 0 | const unsigned int& urgentOldCount() const {return mUrgentOld;} |
199 | | |
200 | | /** @brief Return new message count |
201 | | @return int new message count |
202 | | **/ |
203 | 0 | unsigned int& urgentOldCount() {return mUrgentOld;} |
204 | | |
205 | | private: |
206 | | unsigned int mNew; |
207 | | unsigned int mOld; |
208 | | bool mHasUrgent; |
209 | | unsigned int mUrgentNew; |
210 | | unsigned int mUrgentOld; |
211 | | |
212 | | friend class MessageWaitingContents; |
213 | | }; |
214 | | |
215 | | static bool init(); |
216 | | private: |
217 | | void clear(); |
218 | | |
219 | | bool mHasMessages; |
220 | | Uri* mAccountUri; |
221 | | Header* mHeaders[MW_MAX]; |
222 | | std::map<Data, Data> mExtensions; |
223 | | }; |
224 | | |
225 | | /** @brief Used to access the Message-Account header in MessageWaiting docs. |
226 | | **/ |
227 | | extern MessageWaitingContents::AccountHeader mw_account; |
228 | | static bool invokeMessageWaitingContentsInit = MessageWaitingContents::init(); |
229 | | |
230 | | } |
231 | | |
232 | | #endif |
233 | | |
234 | | /* ==================================================================== |
235 | | * The Vovida Software License, Version 1.0 |
236 | | * |
237 | | * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. |
238 | | * |
239 | | * Redistribution and use in source and binary forms, with or without |
240 | | * modification, are permitted provided that the following conditions |
241 | | * are met: |
242 | | * |
243 | | * 1. Redistributions of source code must retain the above copyright |
244 | | * notice, this list of conditions and the following disclaimer. |
245 | | * |
246 | | * 2. Redistributions in binary form must reproduce the above copyright |
247 | | * notice, this list of conditions and the following disclaimer in |
248 | | * the documentation and/or other materials provided with the |
249 | | * distribution. |
250 | | * |
251 | | * 3. The names "VOCAL", "Vovida Open Communication Application Library", |
252 | | * and "Vovida Open Communication Application Library (VOCAL)" must |
253 | | * not be used to endorse or promote products derived from this |
254 | | * software without prior written permission. For written |
255 | | * permission, please contact vocal@vovida.org. |
256 | | * |
257 | | * 4. Products derived from this software may not be called "VOCAL", nor |
258 | | * may "VOCAL" appear in their name, without prior written |
259 | | * permission of Vovida Networks, Inc. |
260 | | * |
261 | | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED |
262 | | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
263 | | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND |
264 | | * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA |
265 | | * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES |
266 | | * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, |
267 | | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
268 | | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
269 | | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
270 | | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
271 | | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
272 | | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
273 | | * DAMAGE. |
274 | | * |
275 | | * ==================================================================== |
276 | | * |
277 | | * This software consists of voluntary contributions made by Vovida |
278 | | * Networks, Inc. and many individuals on behalf of Vovida Networks, |
279 | | * Inc. For more information on Vovida Networks, Inc., please see |
280 | | * <http://www.vovida.org/>. |
281 | | * |
282 | | */ |