|
1 // Copyright (c) 2003-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 #include <push/cslpushmsgentry.h> |
|
17 |
|
18 |
|
19 GLREF_C TPtrC16 LimitStringSize(const TPtrC16& aString, TInt aMaxSize); |
|
20 |
|
21 |
|
22 /** |
|
23 Allocates and constructs a new Service Loading WAP Push message entry. |
|
24 |
|
25 @return |
|
26 New Service Loading WAP Push message entry. |
|
27 */ |
|
28 EXPORT_C CSLPushMsgEntry* CSLPushMsgEntry::NewL() |
|
29 { |
|
30 CSLPushMsgEntry* self = new (ELeave) CSLPushMsgEntry(); |
|
31 CleanupStack::PushL(self); |
|
32 self->ConstructL(); |
|
33 CleanupStack::Pop(); |
|
34 return self; |
|
35 } |
|
36 |
|
37 |
|
38 /** |
|
39 Allocates and constructs a new Service Loading WAP Push message entry, specifying |
|
40 the AppId as a string. |
|
41 |
|
42 @param aAppURI |
|
43 AppId in string form. |
|
44 |
|
45 @return |
|
46 New Service Loading WAP Push message entry. |
|
47 */ |
|
48 EXPORT_C CSLPushMsgEntry* CSLPushMsgEntry::NewL(const TPtrC8& aAppURI) |
|
49 { |
|
50 CSLPushMsgEntry* self = new (ELeave) CSLPushMsgEntry(); |
|
51 CleanupStack::PushL(self); |
|
52 self->ConstructL(aAppURI); |
|
53 CleanupStack::Pop(); |
|
54 return self; |
|
55 } |
|
56 |
|
57 |
|
58 /** |
|
59 Allocates and constructs a new Service Loading WAP Push message entry, specifying |
|
60 the AppId as a number. |
|
61 |
|
62 @param aAppID |
|
63 AppId in integer form. |
|
64 |
|
65 @return |
|
66 New Service Loading WAP Push message entry. |
|
67 */ |
|
68 EXPORT_C CSLPushMsgEntry* CSLPushMsgEntry::NewL(TInt& aAppID) |
|
69 { |
|
70 CSLPushMsgEntry* self = new (ELeave) CSLPushMsgEntry(); |
|
71 CleanupStack::PushL(self); |
|
72 self->ConstructL(aAppID); |
|
73 CleanupStack::Pop(); |
|
74 return self; |
|
75 } |
|
76 |
|
77 |
|
78 /** |
|
79 Destructor. |
|
80 */ |
|
81 EXPORT_C CSLPushMsgEntry::~CSLPushMsgEntry() |
|
82 { |
|
83 delete iUrl; |
|
84 delete iOriginUri; |
|
85 } |
|
86 |
|
87 |
|
88 /** |
|
89 Gets the Action level for the SL Push Message. |
|
90 |
|
91 The Action levels are defined by TSLPushMsgAction. |
|
92 |
|
93 @return |
|
94 Action level for the SL Push Message. |
|
95 |
|
96 @see CSLPushMsgEntry::TSLPushMsgAction |
|
97 */ |
|
98 EXPORT_C TInt CSLPushMsgEntry::Action() const |
|
99 { |
|
100 //Action is stored in Bits 4-7 of iMtmData1 of the TMsvEntry in the |
|
101 //Message Server Index. The function has to mask out all the other bits, |
|
102 //and then bitwise shift the values to get the Action level |
|
103 |
|
104 TInt action = iEntry.MtmData1() & KPushMaskOnlyAction; //Get the value of Bits 4-7 for action |
|
105 action = action >> 4; // bitshift 4 places right |
|
106 return action; |
|
107 } |
|
108 |
|
109 |
|
110 /** |
|
111 Sets the Action level for the SL Push Message. |
|
112 |
|
113 The Action levels are defined by TSLPushMsgAction. |
|
114 |
|
115 @param aActionFlags |
|
116 Action level for the SL Push Message. |
|
117 |
|
118 @see CSLPushMsgEntry::TSLPushMsgAction |
|
119 */ |
|
120 EXPORT_C void CSLPushMsgEntry::SetAction(TInt aActionFlags) |
|
121 { |
|
122 //Action value is stored in Bits 4-7 of iMtmData1 of the TMsvEntry in the |
|
123 //Message Server Index. The function clears the old action bits with a |
|
124 //bitwise AND, and then does a bitwise shifts on the action level to set |
|
125 //the iMtmData1 value. |
|
126 |
|
127 TInt everythingButAction = iEntry.MtmData1() & KPushMaskEverythingButAction; |
|
128 |
|
129 TInt action = aActionFlags << 4; // bitshift left 4 places, i.e to Bits 4-7 |
|
130 action = action & KPushMaskOnlyAction; //eliminate any non action bits |
|
131 iEntry.SetMtmData1(action + everythingButAction); |
|
132 } |
|
133 |
|
134 |
|
135 /** |
|
136 Sets the URL of the service to be loaded. |
|
137 |
|
138 @param aUrl |
|
139 URL of the service to be loaded. |
|
140 */ |
|
141 EXPORT_C void CSLPushMsgEntry::SetUrlL(const TDesC& aUrl) |
|
142 { |
|
143 HBufC* tempBuf = aUrl.AllocL(); |
|
144 |
|
145 delete iUrl; |
|
146 iUrl = tempBuf; |
|
147 } |
|
148 |
|
149 |
|
150 /** |
|
151 Constructor. |
|
152 */ |
|
153 CSLPushMsgEntry::CSLPushMsgEntry() |
|
154 { |
|
155 } |
|
156 |
|
157 |
|
158 /** |
|
159 Gets the push message type. |
|
160 |
|
161 For this class, this is KUidWapPushMsgSL. |
|
162 |
|
163 @return |
|
164 Push message type. This is a UID expressed as an integer. |
|
165 */ |
|
166 TInt32 CSLPushMsgEntry::PushMsgType() const |
|
167 { |
|
168 return KUidWapPushMsgSL.iUid; |
|
169 } |
|
170 |
|
171 |
|
172 /** |
|
173 Sets the push message type UID. |
|
174 |
|
175 For this class, this is KUidWapPushMsgSL. |
|
176 */ |
|
177 void CSLPushMsgEntry::SetPushMsgType() |
|
178 { |
|
179 iEntry.iBioType = KUidWapPushMsgSL.iUid; |
|
180 } |
|
181 |
|
182 |
|
183 /** |
|
184 Externalises the object to a message store stream. |
|
185 |
|
186 @param aStream |
|
187 The stream to which the data should be externalised. |
|
188 */ |
|
189 void CSLPushMsgEntry::ExternalizeL(RMsvWriteStream& aStream) |
|
190 { |
|
191 CPushMsgEntryBase::ExternalizeL(aStream); |
|
192 |
|
193 aStream<<LimitStringSize(Url(), KLongestStringAllowed);; |
|
194 aStream<< iTimeSent.Int64(); |
|
195 aStream<< MsgOriginUri(); |
|
196 } |
|
197 |
|
198 |
|
199 /** |
|
200 Internalises the object from a message store stream. |
|
201 |
|
202 @param aStream |
|
203 The stream from which the data should be internalised. |
|
204 */ |
|
205 void CSLPushMsgEntry::InternalizeL(RMsvReadStream& aStream) |
|
206 { |
|
207 CPushMsgEntryBase::InternalizeL(aStream); |
|
208 |
|
209 delete iUrl; |
|
210 iUrl = NULL; |
|
211 iUrl = HBufC::NewL(aStream, KLongestStringAllowed); |
|
212 |
|
213 TInt64 msgDateTime; |
|
214 aStream >> msgDateTime; |
|
215 iTimeSent = msgDateTime; |
|
216 |
|
217 delete iOriginUri; |
|
218 iOriginUri = NULL; |
|
219 iOriginUri = HBufC8::NewL(aStream, KLongestStringAllowed); |
|
220 } |
|
221 |
|
222 |
|
223 /** |
|
224 Sets the 8th bit of TMsvEntry::iMtmData1 to indicate whether the SL message is from a |
|
225 whitelisted source or from an unknown origin. |
|
226 |
|
227 @param aTrusted ETrue - push PDU source address is in whitelist. |
|
228 EFalse - push PDU is from unknown origin. |
|
229 |
|
230 @see TMsvEntry |
|
231 */ |
|
232 EXPORT_C void CSLPushMsgEntry::SetTrusted(TBool aTrusted) |
|
233 { |
|
234 (aTrusted == 1) ? (iEntry.SetMtmData1((iEntry.MtmData1()) | 0x00000100)) : (iEntry.SetMtmData1((iEntry.MtmData1()) & 0xFFFFFEFF)); |
|
235 } |
|
236 |
|
237 |
|
238 /** |
|
239 Reads the 8th bit of TMsvEntry::iMtmEntry1 and returns true if the SL message is from a |
|
240 whitelisted origin and false if the SL message is from an unknown origin. |
|
241 |
|
242 @return ETrue - push PDU source address is in whitelist. |
|
243 EFalse - push PDU is from unknown origin. |
|
244 */ |
|
245 EXPORT_C TBool CSLPushMsgEntry::Trusted() const |
|
246 { |
|
247 // Unmask and return the bit-8 |
|
248 return (((iEntry.MtmData1() & 0x00000100) == 0x00000100) ? ETrue : EFalse); |
|
249 } |
|
250 |
|
251 |
|
252 /** |
|
253 Sets the origin URI of the SL message. |
|
254 |
|
255 @param aOriginUri Origin URI of the SL message. |
|
256 */ |
|
257 EXPORT_C void CSLPushMsgEntry::SetMsgOriginUriL(const TDesC8& aOriginUri) |
|
258 { |
|
259 delete iOriginUri; |
|
260 iOriginUri = NULL; |
|
261 iOriginUri = aOriginUri.AllocL(); |
|
262 } |
|
263 |
|
264 |
|
265 /** |
|
266 Gets the origin URI of the SL message. |
|
267 |
|
268 @return Origin URI of the SL message. |
|
269 */ |
|
270 EXPORT_C const TDesC8& CSLPushMsgEntry::MsgOriginUri() const |
|
271 { |
|
272 if (iOriginUri) |
|
273 { |
|
274 return (*(iOriginUri)); |
|
275 } |
|
276 else |
|
277 { |
|
278 return KNullDesC8; |
|
279 } |
|
280 } |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |