|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __CSICONTENTHANDLER_H__ |
|
17 #define __CSICONTENTHANDLER_H__ |
|
18 |
|
19 // System includes |
|
20 // |
|
21 #include <e32base.h> |
|
22 |
|
23 // Local includes |
|
24 // |
|
25 #include <push/ccontenthandlerbase.h> |
|
26 #include "CMsgParser.h" |
|
27 |
|
28 // Constants |
|
29 // |
|
30 const TUid KUidPushSIContentHandler = { 0x101F3E61 }; |
|
31 _LIT(KSIContentHandlerData,"text/vnd.wap.si||application/vnd.wap.sic"); |
|
32 |
|
33 // Forward class declarations |
|
34 // |
|
35 class CSIPushMsgEntry; |
|
36 class CSISLPushMsgUtils; |
|
37 |
|
38 /** |
|
39 * CSIContentHandler handles Service Indication content |
|
40 * |
|
41 * This handler takes ownership of the SI message and processes it |
|
42 * according to the Reception rules |
|
43 * [WAP Service Indication version 08-Nov-1999 section 7.2] |
|
44 * and either stores the message or deletes it. |
|
45 * |
|
46 * OVERVIEW: |
|
47 * The main body of this class and its functionality lies within |
|
48 * HandleMessage (asynchonous). This : |
|
49 * 1. takes ownership of the push message |
|
50 * 2. validates the message and generates a parsed document tree |
|
51 * 3. extracts the message attribute values from document tree |
|
52 * 4. processes the received message |
|
53 * 5. finishes |
|
54 * |
|
55 * Step 4: is an algorithmic implementation of 7.2 Reception rules |
|
56 * from WAP Service Indication 08-Nov-1999 with the exception |
|
57 * that the final step (step 5: handling of information specified |
|
58 * in the info element) has not been implemented as this is a UI |
|
59 * feature. |
|
60 * |
|
61 * NB: a received message with no creation date will be stored (unless |
|
62 * its action is set to delete or the expiry condition is met). This |
|
63 * means that the si-id in the message store will not be unique. |
|
64 */ |
|
65 //##ModelId=3B659DB10116 |
|
66 class CSIContentHandler : public CContentHandlerBase, public MWAPElementHandler |
|
67 /** |
|
68 @internalComponent |
|
69 @released |
|
70 */ |
|
71 { |
|
72 public: // Methods |
|
73 |
|
74 static CSIContentHandler* NewL(); |
|
75 |
|
76 virtual ~CSIContentHandler(); |
|
77 |
|
78 private: // Methods from CPushHandlerBase |
|
79 |
|
80 virtual void HandleMessageL(CPushMessage* aPushMsg, TRequestStatus& aStatus); |
|
81 |
|
82 virtual void HandleMessageL(CPushMessage* aPushMsg); |
|
83 |
|
84 virtual void CancelHandleMessage(); |
|
85 |
|
86 virtual void CPushHandlerBase_Reserved1(); |
|
87 |
|
88 virtual void CPushHandlerBase_Reserved2(); |
|
89 |
|
90 private: |
|
91 // From MWAPElementHandler |
|
92 void HandleElementL ( const RString& aTag, const RString& aAttributeName, const RString& aAttributeValue ); |
|
93 void HandleContentL ( const TDesC8& aBytes ); |
|
94 |
|
95 private: // Methods from CActive |
|
96 |
|
97 virtual void DoCancel(); |
|
98 |
|
99 virtual void RunL(); |
|
100 |
|
101 virtual TInt RunError(TInt aError); |
|
102 |
|
103 private: // Methods |
|
104 |
|
105 CSIContentHandler(); |
|
106 |
|
107 void ConstructL(); |
|
108 |
|
109 void ParsePushMsgL(); |
|
110 |
|
111 void SetSIPushMsgEntryFieldsL(CSIPushMsgEntry& aSIPushMsgEntry); |
|
112 |
|
113 void ProcessingPushMsgEntryL(); |
|
114 |
|
115 void StoreSIMessageL(); |
|
116 |
|
117 TBool HandleMsgOrderReceptionL(); |
|
118 |
|
119 // conversion utilities |
|
120 |
|
121 TBool ConvertDateTimeL(const TDesC& aDateTime, TTime &aConvertedDate); |
|
122 |
|
123 TBool IsValidUTCTime(TDes& aDateTime); |
|
124 |
|
125 HBufC16* FormatDateStringL(const TDesC& aData); |
|
126 |
|
127 TUint ConvertActionString(const RString& aActionString); |
|
128 |
|
129 CSIPushMsgEntry* GetSiEntryL(); |
|
130 |
|
131 TBool ValidateDateTime(TDes& aDateTime); |
|
132 |
|
133 // Attribute flags |
|
134 inline void SetActionFlag(TBool aAction); |
|
135 |
|
136 inline void SetCreatedFlag(TBool aCreated); |
|
137 |
|
138 inline void SetHrefFlag(TBool aHref); |
|
139 |
|
140 inline void SetExpiresFlag(TBool aExpires); |
|
141 |
|
142 inline void SetSiIdFlag(TBool aSiId); |
|
143 |
|
144 inline void SetDataFlag(TBool aData); |
|
145 |
|
146 inline TBool ActionFlag() const; |
|
147 |
|
148 inline TBool CreatedFlag() const; |
|
149 |
|
150 inline TBool HrefFlag() const; |
|
151 |
|
152 inline TBool ExpiresFlag() const; |
|
153 |
|
154 inline TBool SiIdFlag() const; |
|
155 |
|
156 inline TBool DataFlag() const; |
|
157 |
|
158 private: // Attributes |
|
159 |
|
160 CSISLPushMsgUtils* iWapPushUtils; |
|
161 |
|
162 TUint32 iAttributes; |
|
163 |
|
164 enum { EAction=0x01, ECreated=0x02, EHref=0x04, EExpires=0x08, ESiId=0x10, EData=0x20 }; |
|
165 |
|
166 enum TState { EParsing, EProcessing, EDone }; |
|
167 |
|
168 TInt iPushMsgAction; |
|
169 |
|
170 HBufC* iHrefBuf; |
|
171 |
|
172 HBufC* iSiIdBuf; |
|
173 |
|
174 TTime iExpiresTime; |
|
175 |
|
176 TTime iCreatedTime; |
|
177 |
|
178 HBufC* iData; |
|
179 |
|
180 TBool iIndicationTagFound; |
|
181 |
|
182 TBool iValidDate; |
|
183 }; |
|
184 |
|
185 #include "CSIContentHandler.inl" |
|
186 |
|
187 #endif // __CSICONTENTHANDLER_H__ |