65
|
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 |
|
|
92 |
/**
|
|
93 |
* Parse the Push SL message using XML parser.
|
|
94 |
* If Push Message is an SLC then convert it first to text using
|
|
95 |
* CWbxmlConverterUtil class.
|
|
96 |
* @return None.
|
|
97 |
*/
|
|
98 |
void ParsePushMsgL();
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Parse an attribute of the sl element.
|
|
102 |
* @param aAttrHandle The attribute to be parsed.
|
|
103 |
* @return None.
|
|
104 |
*/
|
|
105 |
void ParseSlAttributeL( NW_DOM_AttributeHandle_t& aAttrHandle );
|
|
106 |
|
|
107 |
/**
|
|
108 |
* Convert the action string to a representative numeric value to
|
|
109 |
* facilitate storing the message.
|
|
110 |
* @param aActionString The attribute value indicating the action level
|
|
111 |
* eg 'execute-high'
|
|
112 |
* @return TUint: a value representing the action type.
|
|
113 |
*/
|
|
114 |
TUint ConvertActionString( const TDesC8& aActionString ) const;
|
|
115 |
|
|
116 |
/**
|
|
117 |
* Set SL entry fields prior to storing message.
|
|
118 |
* @param aSlPushMsgEntry Entry represents message format to use when
|
|
119 |
* storing it.
|
|
120 |
* @return None.
|
|
121 |
*/
|
|
122 |
void SetSlPushMsgEntryFieldsL( CSLPushMsgEntry& aSlPushMsgEntry ) const;
|
|
123 |
|
|
124 |
/**
|
|
125 |
* Check if the message has to be discarded due to empty Href or
|
|
126 |
* there is a message with higher acton value.
|
|
127 |
* @return None.
|
|
128 |
*/
|
|
129 |
void ProcessingPushMsgEntryL();
|
|
130 |
|
|
131 |
/**
|
|
132 |
* Handle Service invocation: decide what to do next according to
|
|
133 |
* action value and push settings.
|
|
134 |
* @return Next state.
|
|
135 |
*/
|
|
136 |
TInt HandleServiceInvocationL() const;
|
|
137 |
|
|
138 |
/**
|
|
139 |
* Download the indicated content.
|
|
140 |
* In case of execute-high use the Browser to download the service.
|
|
141 |
* In case of cache use the fetch operation to download the service
|
|
142 |
* silently.
|
|
143 |
* @return None.
|
|
144 |
*/
|
|
145 |
void FetchPushMsgEntryL();
|
|
146 |
|
|
147 |
/**
|
|
148 |
* Start the Browser and instruct it to download the content
|
|
149 |
* indicated by the Sl's URI.
|
|
150 |
* @return None.
|
|
151 |
*/
|
|
152 |
void StartBrowserL();
|
|
153 |
|
|
154 |
/**
|
|
155 |
* Check the result of the SL-cache downloading. If it fails, save the
|
|
156 |
* message. If it succeeds, discard the message.
|
|
157 |
* @return None.
|
|
158 |
*/
|
|
159 |
void FetchCompletedL();
|
|
160 |
|
|
161 |
/**
|
|
162 |
* Apply reception rules and save the push message.
|
|
163 |
* If a message already exists with the same URL,
|
|
164 |
* it is saved only if it has a higher action value.
|
|
165 |
* @return None.
|
|
166 |
*/
|
|
167 |
void SavePushMsgEntryL();
|
|
168 |
|
|
169 |
/**
|
|
170 |
* Store the new message to Messaging.
|
|
171 |
* @param aMatchingEntryId ID of the matching SI entry.
|
|
172 |
* @return None.
|
|
173 |
*/
|
|
174 |
void StoreSLMessageL( TMsvId aMatchingEntryId );
|
|
175 |
|
|
176 |
// Attribute flags
|
|
177 |
|
|
178 |
/**
|
|
179 |
* Flag whether message has an action attribute
|
|
180 |
* @param aAction boolean to set flag to -
|
|
181 |
* ETrue for action attrib present
|
|
182 |
* EFalse for no action attrib.
|
|
183 |
*/
|
|
184 |
inline void SetActionFlag( TBool aAction );
|
|
185 |
|
|
186 |
/**
|
|
187 |
* Check status of action flag to see if message has an action
|
|
188 |
* attribute.
|
|
189 |
* @return TBool ETrue - action attribute present in message
|
|
190 |
* EFalse - no action attribute.
|
|
191 |
*/
|
|
192 |
inline TBool ActionFlag() const;
|
|
193 |
|
|
194 |
/**
|
|
195 |
* Flag whether message has a Href attribute
|
|
196 |
* @param aHref boolean to set flag to -
|
|
197 |
* ETrue for Href attrib present
|
|
198 |
* EFalse for no href attrib
|
|
199 |
*/
|
|
200 |
inline void SetHrefFlag( TBool aHref );
|
|
201 |
|
|
202 |
/**
|
|
203 |
* Check status of href flag to see if message has an href attribute.
|
|
204 |
* @return TBool
|
|
205 |
* ETrue - href attribute present in message
|
|
206 |
* EFalse - no href attribute
|
|
207 |
*/
|
|
208 |
inline TBool HrefFlag() const;
|
|
209 |
|
|
210 |
|
|
211 |
private: // Methods from CPushHandlerBase
|
|
212 |
|
|
213 |
/**
|
|
214 |
* HandleMessage Async. Version. Takes ownership of Push Message and
|
|
215 |
* sets self active to continue processing message.
|
|
216 |
* @param aPushMsg CPushMessage to process.
|
|
217 |
* @param aStatus Request status variable for use in asynchronous
|
|
218 |
* operations.
|
|
219 |
* @return None.
|
|
220 |
*/
|
|
221 |
void HandleMessageL(CPushMessage* aPushMsg, TRequestStatus& aStatus);
|
|
222 |
|
|
223 |
/**
|
|
224 |
* HandleMessage Sync. Version. Takes ownership of Push Message and
|
|
225 |
* sets self active to continue processing message.
|
|
226 |
* Initial State: Set data members then go to the next state
|
|
227 |
* @param aPushMsg CPushMessage to process.
|
|
228 |
*/
|
|
229 |
void HandleMessageL(CPushMessage* aPushMsg);
|
|
230 |
|
|
231 |
/**
|
|
232 |
* Same functionality as DoCancel()
|
|
233 |
*/
|
|
234 |
void CancelHandleMessage();
|
|
235 |
|
|
236 |
/**
|
|
237 |
* Reserved function.
|
|
238 |
*/
|
|
239 |
void CPushHandlerBase_Reserved1();
|
|
240 |
|
|
241 |
/**
|
|
242 |
* Reserved function.
|
|
243 |
*/
|
|
244 |
void CPushHandlerBase_Reserved2();
|
|
245 |
|
|
246 |
private: // Methods from CActive
|
|
247 |
|
|
248 |
/**
|
|
249 |
* Terminates any activity.
|
|
250 |
* @return None.
|
|
251 |
*/
|
|
252 |
void DoCancel();
|
|
253 |
|
|
254 |
/**
|
|
255 |
* Step through the various representative states for handling a
|
|
256 |
* message.
|
|
257 |
* @return None.
|
|
258 |
*/
|
|
259 |
void RunL();
|
|
260 |
|
|
261 |
/**
|
|
262 |
* This is invoked when RunL Leaves with an error so clean up and
|
|
263 |
* return.
|
|
264 |
* @return Error code to scheduler.
|
|
265 |
*/
|
|
266 |
TInt RunError( TInt aError );
|
|
267 |
|
|
268 |
private: // Data
|
|
269 |
|
|
270 |
enum
|
|
271 |
{
|
|
272 |
EAction = 0x01,
|
|
273 |
EHref = 0x02
|
|
274 |
};
|
|
275 |
|
|
276 |
enum TState ///< States of this state machine.
|
|
277 |
{
|
|
278 |
EGarbageCollecting,
|
|
279 |
EFilteringAndParsing,
|
|
280 |
EProcessing,
|
|
281 |
EFetching,
|
|
282 |
EFetchCompleted,
|
|
283 |
ESavePushMsgEntry,
|
|
284 |
EDone
|
|
285 |
};
|
|
286 |
|
|
287 |
TMsvId iSavedMsgId; ///< ID of the saved message.
|
|
288 |
TUint32 iAttributes; ///< Attribute indication (set or not).
|
|
289 |
TInt iPushMsgAction; ///< SL action.
|
|
290 |
HBufC* iHrefBuf; ///< Href attribute. Has.
|
|
291 |
|
|
292 |
/// Asynchronous fetch operation that downloads the SL-cache. Owned.
|
|
293 |
CPushMtmAutoFetchOperation* iFetchOp;
|
|
294 |
|
|
295 |
NW_Uint32 iCharEncoding; ///< Char encoding of the current msg.
|
|
296 |
TBool iSaveAsRead; ///< Mark the message 'read' after saving.
|
|
297 |
TInt iPushSLEnabled;
|
|
298 |
};
|
|
299 |
|
|
300 |
#include "CSLContentHandler.inl"
|
|
301 |
|
|
302 |
#endif // __CSLCONTENTHANDLER_H__
|
|
303 |
|