1 /* |
|
2 * Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Creates SMS message if Event in MailBox has occurred |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef IPVMBXENGINE_H |
|
21 #define IPVMBXENGINE_H |
|
22 |
|
23 #include <msvapi.h> |
|
24 #include <mcetransactiondatacontainer.h> |
|
25 #include <stringresourcereader.h> |
|
26 |
|
27 #include "ipvmbxinterface.h" |
|
28 #include "ipvmbxbase.h" |
|
29 #include "ipvmbxparsetype.h" |
|
30 |
|
31 |
|
32 class CSIPProfile; |
|
33 class CSPSettings; |
|
34 class CIpVmbxBase; |
|
35 class TIpVmbxEventMonitor; |
|
36 |
|
37 |
|
38 /** |
|
39 * Creates SMS message if Event in MailBox has occurred. |
|
40 * |
|
41 * @lib IpVmbxAppEngine.lib |
|
42 */ |
|
43 NONSHARABLE_CLASS( CIpVmbxEngine ) : |
|
44 public CBase, |
|
45 public MMsvSessionObserver |
|
46 { |
|
47 |
|
48 public: // Constructors and destructor |
|
49 |
|
50 /** Internal state messages */ |
|
51 enum TIpVmbxMessages |
|
52 { |
|
53 EEngineUndefined, |
|
54 EEngineSubscribed, |
|
55 EEngineTerminated, |
|
56 EEngineSubscribeRejected, |
|
57 EEngineIncorrectAccount, |
|
58 EEngineSmsError, |
|
59 EEngineSmsOom, |
|
60 EEngineNetworkLost, |
|
61 EEngineNetworkError, |
|
62 EEngineFatalNetworkError |
|
63 }; |
|
64 |
|
65 /** |
|
66 * Two-phased constructor. |
|
67 * |
|
68 * @param aInterface Instance to interface for status message sending |
|
69 */ |
|
70 IMPORT_C static CIpVmbxEngine* NewL( CIpVmbxInterface& aInterface ); |
|
71 |
|
72 /** |
|
73 * Destructor. |
|
74 */ |
|
75 virtual ~CIpVmbxEngine(); |
|
76 |
|
77 |
|
78 public: // New functions |
|
79 |
|
80 /** |
|
81 * Starts subscription to MailBox when SIP profile has registered. Only |
|
82 * one of these parameters can be used at same time. |
|
83 * |
|
84 * @param aServiceProviderId Service provider id of mail settings |
|
85 * @param aSipProfileId Connected SIP profile id |
|
86 */ |
|
87 void SubscribeProfileL( |
|
88 TUint32 aServiceProviderId, |
|
89 CSIPProfile& aSipProfile ); |
|
90 |
|
91 /** |
|
92 * Registration status of profile. |
|
93 * |
|
94 * @param aServiceProviderId Provider id which status is queried |
|
95 * @param aProfileSubscribe Status of subscription |
|
96 * @return KErrNotFound if profile does not exist |
|
97 */ |
|
98 TInt ProfileSubscribed( |
|
99 TUint32 aServiceProviderId, |
|
100 TBool& aProfileSubscribed ); |
|
101 |
|
102 /** |
|
103 * Resolve address of base class using recipient address |
|
104 * |
|
105 * @param aId Recipient |
|
106 * @return Address of base class |
|
107 */ |
|
108 CIpVmbxBase* SubscriptionByRecipient( const TDesC8& aRecipient8 ); |
|
109 |
|
110 /** |
|
111 * EventMonitor has received event and the event |
|
112 * will be gained and checked if it requires any action |
|
113 * |
|
114 * @param aRecipient Recipient of event |
|
115 */ |
|
116 #ifdef EUNIT_TEST_IMPLEMENTATION |
|
117 virtual void EventReceivedL( const TDesC8& aRecipient8 ); |
|
118 #else |
|
119 void EventReceivedL( const TDesC8& aRecipient8 ); |
|
120 #endif |
|
121 |
|
122 /** |
|
123 * Disconnects IPVME from voice mail -server |
|
124 * |
|
125 * @param aServiceProviderId Provider id to be unregistered |
|
126 */ |
|
127 void UnsubscribeProfileL( TUint32 aServiceProviderId ); |
|
128 |
|
129 /** |
|
130 * Cleanup base class and free resources |
|
131 * |
|
132 * @pre Unsubscribe has been sent to voice mail -server |
|
133 */ |
|
134 void CleanVmbxBase(); |
|
135 |
|
136 /** |
|
137 * Send status messages to observers |
|
138 * |
|
139 * @param aServiceProviderId Service provider id |
|
140 * @param aMessage MIpVmbxObserver status messages |
|
141 */ |
|
142 #ifdef EUNIT_TEST_IMPLEMENTATION |
|
143 |
|
144 virtual void HandleMessage( |
|
145 TUint32 aServiceProviderId, |
|
146 CIpVmbxEngine::TIpVmbxMessages aMessage ); |
|
147 |
|
148 #else |
|
149 |
|
150 void HandleMessage( |
|
151 TUint32 aServiceProviderId, |
|
152 CIpVmbxEngine::TIpVmbxMessages aMessage ); |
|
153 |
|
154 #endif |
|
155 |
|
156 /** |
|
157 * Fetch instance to base class using service id |
|
158 * |
|
159 * @param aServiceProviderId Service id to indentify base class |
|
160 * @return Instance to base |
|
161 */ |
|
162 CIpVmbxBase* SubscriptionByProvider( TUint32 aServiceProviderId ); |
|
163 |
|
164 |
|
165 protected: |
|
166 |
|
167 // from base class MMsvSessionObserver |
|
168 |
|
169 /** |
|
170 * From base class MMsvSessionObserver |
|
171 * For notification of events from a Message Server session |
|
172 * |
|
173 * @since Series 60 3.0 |
|
174 * @param aEvent Indicates the event type, |
|
175 * @param*aArg1 Event type-specific argument value |
|
176 * @param*aArg2 Event type-specific argument value |
|
177 * @param*aArg3 Event type-specific argument value |
|
178 */ |
|
179 virtual void HandleSessionEventL( TMsvSessionEvent aEvent, TAny *aArg1, |
|
180 TAny *aArg2, TAny *aArg3 ); |
|
181 |
|
182 |
|
183 private: |
|
184 |
|
185 void ConstructL(); |
|
186 |
|
187 /** |
|
188 * C++ default constructor. |
|
189 * |
|
190 * @param aInterface Instance to interface for status message sending |
|
191 */ |
|
192 CIpVmbxEngine( CIpVmbxInterface& aInterface ); |
|
193 |
|
194 /** |
|
195 * For parsing the content of NOTIFY and some optional messages. |
|
196 * If function completes without errors, supplied content is cut so that |
|
197 * only possible optional header data is left. |
|
198 * |
|
199 * @param aCreateSms ETrue if user has to be informed (SMS). |
|
200 * @param aContent Notify content to be parsed |
|
201 * @param aTotalMessages Total messages |
|
202 * @param aNewMessages New messages |
|
203 * @param aFrom Voice mail account |
|
204 */ |
|
205 void ParseNotifyContentL( |
|
206 TBool& aCreateSms, |
|
207 TDes8& aContent8, |
|
208 TDes8& aTotalMessages8, |
|
209 TDes8& aNewMessages8, |
|
210 TDes8& aFrom8 ) const; |
|
211 |
|
212 /** |
|
213 * Creates SMS message and sends it |
|
214 * |
|
215 * @param aFrom MBX uri |
|
216 * @param aMessageBody Generated message |
|
217 */ |
|
218 void CreateSMSMessageL( const TDesC8& aFrom8, const TDesC8& aMessageBody8 ); |
|
219 |
|
220 /** |
|
221 * For parsing optional headers from content of NOTIFY. |
|
222 * |
|
223 * @param aContent Notify content |
|
224 * @param aMessageBody Message body for optional parameters |
|
225 */ |
|
226 void ParseOptionalHeadersL( |
|
227 const TDesC8& aContent8, |
|
228 TDes8& aMessageBody8 ) const; |
|
229 |
|
230 /** |
|
231 * Read localized content to message body |
|
232 * |
|
233 * @param aTotalMessages Total messages |
|
234 * @param aNewMessages New messages |
|
235 * @param aMessagesBody Message body |
|
236 */ |
|
237 void ReadResourcesL( |
|
238 const TDesC8& aTotalMessages8, |
|
239 const TDesC8& aNewMessages8, |
|
240 TDes8& aMessagesBody8 ); |
|
241 |
|
242 /** |
|
243 * Creates and verifies message body |
|
244 * |
|
245 * @param aContent Notify content |
|
246 * @param aTotal Total messages |
|
247 * @param aNew New messages |
|
248 * @param aFrom MBX uri |
|
249 * @param aMessageBody Message body |
|
250 */ |
|
251 void CreateMessageBodyL( |
|
252 const TDesC8& aContent8, |
|
253 const TDesC8& aTotal8, |
|
254 const TDesC8& aNew8, |
|
255 TDes8& aFrom8, |
|
256 TDes8& aMessageBody8 ); |
|
257 |
|
258 /** |
|
259 * General optional parameter parser |
|
260 * |
|
261 * @param aTagPtr8 Source text |
|
262 * @param aResourceReader Instance to resource reader( to prevent |
|
263 * double instantiation ) |
|
264 * @return Translation, NULL if not found. |
|
265 */ |
|
266 HBufC* TranslateTagL( |
|
267 const TDesC8& aTagPtr8, |
|
268 CStringResourceReader& aResourceReader ) const; |
|
269 |
|
270 /** |
|
271 * Fetch message part from whole message. It gets first part from |
|
272 * provided string and checks validity of message part. |
|
273 * |
|
274 * @param aContent8 Source text |
|
275 * @return Message part, empty if content was not valid. |
|
276 */ |
|
277 TPtrC8 FetchMessagePartL( const TDesC8& aContent8 ) const; |
|
278 |
|
279 /** |
|
280 * Check name header from message part. |
|
281 * |
|
282 * @param aNameHeader8 Source text |
|
283 */ |
|
284 void TestNamePartL( const TDesC8& aNameHeader8 ) const; |
|
285 |
|
286 /** |
|
287 * Check value header from message part. |
|
288 * |
|
289 * @param aValueHeader8 Source text |
|
290 */ |
|
291 void TestValuePartL( const TDesC8& aValueHeader8 ) const; |
|
292 |
|
293 |
|
294 private: // data |
|
295 |
|
296 /** |
|
297 * MCE server connection |
|
298 * Own. |
|
299 */ |
|
300 CMceManager* iMceManager; |
|
301 |
|
302 /** |
|
303 * Event content |
|
304 */ |
|
305 TMceTransactionDataContainer iEventData; |
|
306 |
|
307 /** |
|
308 * MCE Event observer |
|
309 * Own. |
|
310 */ |
|
311 TIpVmbxEventMonitor* iIpVmbxEventMonitor; |
|
312 |
|
313 /** |
|
314 * Interface |
|
315 */ |
|
316 CIpVmbxInterface& iInterface; |
|
317 |
|
318 /** |
|
319 * Vmbx parameters |
|
320 * Own. |
|
321 */ |
|
322 CSPSettings* iServiceSettings; |
|
323 |
|
324 /** |
|
325 * Array of current Base classes |
|
326 */ |
|
327 RPointerArray< CIpVmbxBase > iVmbxBaseArray; |
|
328 |
|
329 /** |
|
330 * Indicates if VME is already running |
|
331 */ |
|
332 TBool iBasicServicesRunning; |
|
333 |
|
334 |
|
335 EUNIT_IMPLEMENTATION |
|
336 }; |
|
337 |
|
338 #endif // IPVMBXENGINE_H |
|