|
1 /* |
|
2 * Copyright (c) 2002 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 the License "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: Declaration of CSLContentHandler. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __CSLCONTENTHANDLER_H__ |
|
21 #define __CSLCONTENTHANDLER_H__ |
|
22 |
|
23 // INCLUDE FILES |
|
24 |
|
25 #include "CPushContentHandlerBase.h" |
|
26 #include "PushMtmDef.hrh" |
|
27 #include "PushContentHandlerDef.hrh" |
|
28 #include <E32Base.h> |
|
29 #include <bldvariant.hrh> |
|
30 #include <nw_dom_attribute.h> |
|
31 |
|
32 // CONSTANTS |
|
33 |
|
34 const TUid KUidPushSLContentHandler = { EUidPushSLContentHandler }; |
|
35 _LIT( KSLContentHandlerData, "text/vnd.wap.sl||application/vnd.wap.slc" ); |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 |
|
39 class CSLPushMsgEntry; |
|
40 class CPushMtmAutoFetchOperation; |
|
41 |
|
42 // CLASS DECLARATION |
|
43 |
|
44 /** |
|
45 * CSLContentHandler Handles Service Loading Content |
|
46 * |
|
47 * This handler takes ownership of the SL message and processes it |
|
48 * according to the Reception rules |
|
49 * [WAP Service Loading version 31-July-2001] |
|
50 * and either stores the message or deletes it. |
|
51 * Also S60 specific requirements are applied. |
|
52 * |
|
53 * NB. If __SERIES60_PUSH_SL is not defined, then all SL push messages are |
|
54 * discarded! |
|
55 */ |
|
56 class CSLContentHandler : public CPushContentHandlerBase |
|
57 { |
|
58 public: // Constructors and destructor |
|
59 |
|
60 /** |
|
61 * Two-phased constructor. Leaves on failure. |
|
62 * @return The constructed object. |
|
63 */ |
|
64 static CSLContentHandler* NewL(); |
|
65 |
|
66 /** |
|
67 * D'tor. |
|
68 */ |
|
69 virtual ~CSLContentHandler(); |
|
70 |
|
71 private: // Constructors |
|
72 |
|
73 /** |
|
74 * Constructor. |
|
75 */ |
|
76 CSLContentHandler(); |
|
77 |
|
78 /** |
|
79 * Symbian OS constructor. |
|
80 */ |
|
81 void ConstructL(); |
|
82 |
|
83 private: // New functions |
|
84 |
|
85 /** |
|
86 * Do Garbage Collection synchronously when a new message arrives. |
|
87 * @return None. |
|
88 */ |
|
89 void CollectGarbageL(); |
|
90 |
|
91 #ifdef __SERIES60_PUSH_SL |
|
92 |
|
93 /** |
|
94 * Parse the Push SL message using XML parser. |
|
95 * If Push Message is an SLC then convert it first to text using |
|
96 * CWbxmlConverterUtil class. |
|
97 * @return None. |
|
98 */ |
|
99 void ParsePushMsgL(); |
|
100 |
|
101 /** |
|
102 * Parse an attribute of the sl element. |
|
103 * @param aAttrHandle The attribute to be parsed. |
|
104 * @return None. |
|
105 */ |
|
106 void ParseSlAttributeL( NW_DOM_AttributeHandle_t& aAttrHandle ); |
|
107 |
|
108 /** |
|
109 * Convert the action string to a representative numeric value to |
|
110 * facilitate storing the message. |
|
111 * @param aActionString The attribute value indicating the action level |
|
112 * eg 'execute-high' |
|
113 * @return TUint: a value representing the action type. |
|
114 */ |
|
115 TUint ConvertActionString( const TDesC8& aActionString ) const; |
|
116 |
|
117 /** |
|
118 * Set SL entry fields prior to storing message. |
|
119 * @param aSlPushMsgEntry Entry represents message format to use when |
|
120 * storing it. |
|
121 * @return None. |
|
122 */ |
|
123 void SetSlPushMsgEntryFieldsL( CSLPushMsgEntry& aSlPushMsgEntry ) const; |
|
124 |
|
125 /** |
|
126 * Check if the message has to be discarded due to empty Href or |
|
127 * there is a message with higher acton value. |
|
128 * @return None. |
|
129 */ |
|
130 void ProcessingPushMsgEntryL(); |
|
131 |
|
132 /** |
|
133 * Handle Service invocation: decide what to do next according to |
|
134 * action value and push settings. |
|
135 * @return Next state. |
|
136 */ |
|
137 TInt HandleServiceInvocationL() const; |
|
138 |
|
139 /** |
|
140 * Download the indicated content. |
|
141 * In case of execute-high use the Browser to download the service. |
|
142 * In case of cache use the fetch operation to download the service |
|
143 * silently. |
|
144 * @return None. |
|
145 */ |
|
146 void FetchPushMsgEntryL(); |
|
147 |
|
148 /** |
|
149 * Start the Browser and instruct it to download the content |
|
150 * indicated by the Sl's URI. |
|
151 * @return None. |
|
152 */ |
|
153 void StartBrowserL(); |
|
154 |
|
155 /** |
|
156 * Check the result of the SL-cache downloading. If it fails, save the |
|
157 * message. If it succeeds, discard the message. |
|
158 * @return None. |
|
159 */ |
|
160 void FetchCompletedL(); |
|
161 |
|
162 /** |
|
163 * Apply reception rules and save the push message. |
|
164 * If a message already exists with the same URL, |
|
165 * it is saved only if it has a higher action value. |
|
166 * @return None. |
|
167 */ |
|
168 void SavePushMsgEntryL(); |
|
169 |
|
170 /** |
|
171 * Store the new message to Messaging. |
|
172 * @param aMatchingEntryId ID of the matching SI entry. |
|
173 * @return None. |
|
174 */ |
|
175 void StoreSLMessageL( TMsvId aMatchingEntryId ); |
|
176 |
|
177 // Attribute flags |
|
178 |
|
179 /** |
|
180 * Flag whether message has an action attribute |
|
181 * @param aAction boolean to set flag to - |
|
182 * ETrue for action attrib present |
|
183 * EFalse for no action attrib. |
|
184 */ |
|
185 inline void SetActionFlag( TBool aAction ); |
|
186 |
|
187 /** |
|
188 * Check status of action flag to see if message has an action |
|
189 * attribute. |
|
190 * @return TBool ETrue - action attribute present in message |
|
191 * EFalse - no action attribute. |
|
192 */ |
|
193 inline TBool ActionFlag() const; |
|
194 |
|
195 /** |
|
196 * Flag whether message has a Href attribute |
|
197 * @param aHref boolean to set flag to - |
|
198 * ETrue for Href attrib present |
|
199 * EFalse for no href attrib |
|
200 */ |
|
201 inline void SetHrefFlag( TBool aHref ); |
|
202 |
|
203 /** |
|
204 * Check status of href flag to see if message has an href attribute. |
|
205 * @return TBool |
|
206 * ETrue - href attribute present in message |
|
207 * EFalse - no href attribute |
|
208 */ |
|
209 inline TBool HrefFlag() const; |
|
210 |
|
211 #endif // __SERIES60_PUSH_SL |
|
212 |
|
213 private: // Methods from CPushHandlerBase |
|
214 |
|
215 /** |
|
216 * HandleMessage Async. Version. Takes ownership of Push Message and |
|
217 * sets self active to continue processing message. |
|
218 * @param aPushMsg CPushMessage to process. |
|
219 * @param aStatus Request status variable for use in asynchronous |
|
220 * operations. |
|
221 * @return None. |
|
222 */ |
|
223 void HandleMessageL(CPushMessage* aPushMsg, TRequestStatus& aStatus); |
|
224 |
|
225 /** |
|
226 * HandleMessage Sync. Version. Takes ownership of Push Message and |
|
227 * sets self active to continue processing message. |
|
228 * Initial State: Set data members then go to the next state |
|
229 * @param aPushMsg CPushMessage to process. |
|
230 */ |
|
231 void HandleMessageL(CPushMessage* aPushMsg); |
|
232 |
|
233 /** |
|
234 * Same functionality as DoCancel() |
|
235 */ |
|
236 void CancelHandleMessage(); |
|
237 |
|
238 /** |
|
239 * Reserved function. |
|
240 */ |
|
241 void CPushHandlerBase_Reserved1(); |
|
242 |
|
243 /** |
|
244 * Reserved function. |
|
245 */ |
|
246 void CPushHandlerBase_Reserved2(); |
|
247 |
|
248 private: // Methods from CActive |
|
249 |
|
250 /** |
|
251 * Terminates any activity. |
|
252 * @return None. |
|
253 */ |
|
254 void DoCancel(); |
|
255 |
|
256 /** |
|
257 * Step through the various representative states for handling a |
|
258 * message. |
|
259 * @return None. |
|
260 */ |
|
261 void RunL(); |
|
262 |
|
263 /** |
|
264 * This is invoked when RunL Leaves with an error so clean up and |
|
265 * return. |
|
266 * @return Error code to scheduler. |
|
267 */ |
|
268 TInt RunError( TInt aError ); |
|
269 |
|
270 private: // Data |
|
271 |
|
272 enum |
|
273 { |
|
274 EAction = 0x01, |
|
275 EHref = 0x02 |
|
276 }; |
|
277 |
|
278 enum TState ///< States of this state machine. |
|
279 { |
|
280 EGarbageCollecting, |
|
281 EFilteringAndParsing, |
|
282 EProcessing, |
|
283 EFetching, |
|
284 EFetchCompleted, |
|
285 ESavePushMsgEntry, |
|
286 EDone |
|
287 }; |
|
288 |
|
289 TMsvId iSavedMsgId; ///< ID of the saved message. |
|
290 TUint32 iAttributes; ///< Attribute indication (set or not). |
|
291 TInt iPushMsgAction; ///< SL action. |
|
292 HBufC* iHrefBuf; ///< Href attribute. Has. |
|
293 |
|
294 /// Asynchronous fetch operation that downloads the SL-cache. Owned. |
|
295 CPushMtmAutoFetchOperation* iFetchOp; |
|
296 |
|
297 NW_Uint32 iCharEncoding; ///< Char encoding of the current msg. |
|
298 TBool iSaveAsRead; ///< Mark the message 'read' after saving. |
|
299 }; |
|
300 |
|
301 #include "CSLContentHandler.inl" |
|
302 |
|
303 #endif // __CSLCONTENTHANDLER_H__ |
|
304 |