48
|
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: Implementation of CPushLoadServiceOp.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
|
|
22 |
#include "PushLoadServiceOp.h"
|
|
23 |
#include "PushMtmUiDef.h"
|
|
24 |
#include "PushMtmUiPanic.h"
|
|
25 |
#include "PushMtmLog.h"
|
|
26 |
#include "PushMtmUtil.h"
|
|
27 |
#include "PushMtmSettings.h"
|
|
28 |
#include "PushAuthenticationUtilities.h"
|
|
29 |
#include <push/CSIPushMsgEntry.h>
|
|
30 |
#include <push/CSLPushMsgEntry.h>
|
|
31 |
#include <eikenv.h>
|
|
32 |
#include <apmstd.h>
|
|
33 |
#include <schemehandler.h>
|
|
34 |
#include <AknNoteWrappers.h>
|
|
35 |
#include <PushEntry.h>
|
|
36 |
#include <PushMtmUi.rsg>
|
|
37 |
#include <AknQueryDialog.h>
|
|
38 |
#include <bldvariant.hrh>
|
|
39 |
#include <FeatMgr.h>
|
|
40 |
#include <Uri16.h>
|
|
41 |
#include <data_caging_path_literals.hrh>
|
|
42 |
#include <f32file.h>
|
|
43 |
|
|
44 |
// CONSTANTS
|
|
45 |
|
|
46 |
_LIT( KDefaultScheme, "http://" );
|
|
47 |
|
|
48 |
// ================= MEMBER FUNCTIONS =======================
|
|
49 |
|
|
50 |
// ---------------------------------------------------------
|
|
51 |
// CPushLoadServiceOp::NewL
|
|
52 |
// ---------------------------------------------------------
|
|
53 |
//
|
|
54 |
CPushLoadServiceOp* CPushLoadServiceOp::NewL( CMsvSession& aSession,
|
|
55 |
TMsvId aEntryId,
|
|
56 |
TRequestStatus& aObserverStatus )
|
|
57 |
{
|
|
58 |
PUSHLOG_ENTERFN("CPushLoadServiceOp::NewL")
|
|
59 |
|
|
60 |
CPushLoadServiceOp* self =
|
|
61 |
new (ELeave) CPushLoadServiceOp( aSession, aEntryId, aObserverStatus );
|
|
62 |
CleanupStack::PushL( self );
|
|
63 |
self->ConstructL();
|
|
64 |
CleanupStack::Pop( self );
|
|
65 |
|
|
66 |
PUSHLOG_LEAVEFN("CPushLoadServiceOp::NewL")
|
|
67 |
return self;
|
|
68 |
}
|
|
69 |
|
|
70 |
// ---------------------------------------------------------
|
|
71 |
// CPushLoadServiceOp::~CPushLoadServiceOp
|
|
72 |
// ---------------------------------------------------------
|
|
73 |
//
|
|
74 |
CPushLoadServiceOp::~CPushLoadServiceOp()
|
|
75 |
{
|
|
76 |
PUSHLOG_ENTERFN("CPushLoadServiceOp::~CPushLoadServiceOp")
|
|
77 |
|
|
78 |
Cancel();
|
|
79 |
delete iSchemeHandler;
|
|
80 |
FeatureManager::UnInitializeLib();
|
|
81 |
|
|
82 |
PUSHLOG_LEAVEFN("CPushLoadServiceOp::~CPushLoadServiceOp")
|
|
83 |
}
|
|
84 |
|
|
85 |
// ---------------------------------------------------------
|
|
86 |
// CPushLoadServiceOp::StartL
|
|
87 |
// ---------------------------------------------------------
|
|
88 |
//
|
|
89 |
void CPushLoadServiceOp::StartL()
|
|
90 |
{
|
|
91 |
PUSHLOG_ENTERFN("CPushLoadServiceOp::StartL")
|
|
92 |
|
|
93 |
Cancel();
|
|
94 |
|
|
95 |
// Check expiration (SI specific).
|
|
96 |
if ( IsExpiredL( iTEntry ) )
|
|
97 |
{
|
|
98 |
PUSHLOG_WRITE(" Msg is expired.")
|
|
99 |
// The entry is expired.
|
|
100 |
|
|
101 |
// Display a confirmation dialog.
|
|
102 |
TParse* fileParser = new (ELeave) TParse;
|
|
103 |
CleanupStack::PushL( fileParser );
|
|
104 |
fileParser->Set( KPushMtmUiResourceFileAndDrive, &KDC_MTM_RESOURCE_DIR, NULL );
|
|
105 |
AssureResourceL( fileParser->FullName() );
|
|
106 |
CleanupStack::PopAndDestroy( fileParser ); // fileParser
|
|
107 |
fileParser = NULL;
|
|
108 |
|
|
109 |
HBufC* value = iCoeEnv.AllocReadResourceLC( R_PUSHLS_EXPIRED_NOTE );
|
|
110 |
CAknInformationNote* note = new (ELeave) CAknInformationNote( ETrue );
|
|
111 |
note->ExecuteLD( *value );
|
|
112 |
CleanupStack::PopAndDestroy( value ); // value
|
|
113 |
|
|
114 |
// Delete the expired message.
|
|
115 |
CMsvEntry* cParent = iMsvSession.GetEntryL( iTEntry.Parent() );
|
|
116 |
CleanupStack::PushL( cParent );
|
|
117 |
cParent->DeleteL( iEntryId );
|
|
118 |
CleanupStack::PopAndDestroy( cParent ); // cParent
|
|
119 |
|
|
120 |
// Nothing to do.
|
|
121 |
iDone = ETrue;
|
|
122 |
}
|
|
123 |
|
|
124 |
CPushMtmUiOperation::StartL();
|
|
125 |
|
|
126 |
PUSHLOG_LEAVEFN("CPushLoadServiceOp::StartL")
|
|
127 |
}
|
|
128 |
|
|
129 |
// ---------------------------------------------------------
|
|
130 |
// CPushLoadServiceOp::CPushLoadServiceOp
|
|
131 |
// ---------------------------------------------------------
|
|
132 |
//
|
|
133 |
CPushLoadServiceOp::CPushLoadServiceOp( CMsvSession& aSession,
|
|
134 |
TMsvId aEntryId,
|
|
135 |
TRequestStatus& aObserverStatus )
|
|
136 |
: CPushMtmUiOperation( aSession, aEntryId, aObserverStatus ),
|
|
137 |
iDone( EFalse )
|
|
138 |
{
|
|
139 |
PUSHLOG_WRITE("CPushLoadServiceOp constructing")
|
|
140 |
}
|
|
141 |
|
|
142 |
// ---------------------------------------------------------
|
|
143 |
// CPushLoadServiceOp::ConstructL
|
|
144 |
// ---------------------------------------------------------
|
|
145 |
//
|
|
146 |
void CPushLoadServiceOp::ConstructL()
|
|
147 |
{
|
|
148 |
PUSHLOG_ENTERFN("CPushLoadServiceOp::ConstructL")
|
|
149 |
|
|
150 |
FeatureManager::InitializeLibL();
|
|
151 |
|
|
152 |
CPushMtmUiOperation::ConstructL();
|
|
153 |
|
|
154 |
// Initialize iTEntry.
|
|
155 |
TMsvId service;
|
|
156 |
User::LeaveIfError( iMsvSession.GetEntry( iEntryId, service, iTEntry ) );
|
|
157 |
__ASSERT_ALWAYS( iTEntry.iMtm == KUidMtmWapPush,
|
|
158 |
UiPanic( EPushMtmUiPanBadMtm ) );
|
|
159 |
|
|
160 |
PUSHLOG_LEAVEFN("CPushLoadServiceOp::ConstructL")
|
|
161 |
}
|
|
162 |
|
|
163 |
// ---------------------------------------------------------
|
|
164 |
// CPushLoadServiceOp::IsExpiredL
|
|
165 |
// ---------------------------------------------------------
|
|
166 |
//
|
|
167 |
TBool CPushLoadServiceOp::IsExpiredL( const TMsvEntry& aTEntry ) const
|
|
168 |
{
|
|
169 |
TBool ret( EFalse );
|
|
170 |
|
|
171 |
if ( aTEntry.iBioType == KUidWapPushMsgSI.iUid )
|
|
172 |
{
|
|
173 |
CSIPushMsgEntry* si = CSIPushMsgEntry::NewL();
|
|
174 |
CleanupStack::PushL( si );
|
|
175 |
si->RetrieveL( iMsvSession, iEntryId );
|
|
176 |
// Check expiration if expiration time was set.
|
|
177 |
if ( si->Expires() != Time::NullTTime() )
|
|
178 |
{
|
|
179 |
TTime today;
|
|
180 |
today.UniversalTime();
|
|
181 |
if ( si->Expires() < today )
|
|
182 |
{
|
|
183 |
ret = ETrue;
|
|
184 |
}
|
|
185 |
}
|
|
186 |
CleanupStack::PopAndDestroy( si ); // si
|
|
187 |
}
|
|
188 |
|
|
189 |
return ret;
|
|
190 |
}
|
|
191 |
|
|
192 |
// ---------------------------------------------------------
|
|
193 |
// CPushLoadServiceOp::RetrieveContextAndGetUrlLC
|
|
194 |
// ---------------------------------------------------------
|
|
195 |
//
|
|
196 |
CPushMsgEntryBase* CPushLoadServiceOp::RetrieveContextAndGetUrlLC
|
|
197 |
( TPtrC& aUrl ) const
|
|
198 |
{
|
|
199 |
PUSHLOG_ENTERFN("CPushLoadServiceOp::RetrieveContextAndGetUrlLC");
|
|
200 |
|
|
201 |
CPushMsgEntryBase* context = NULL;
|
|
202 |
const TInt32 bioType( iTEntry.iBioType );
|
|
203 |
|
|
204 |
if ( bioType == KUidWapPushMsgSI.iUid )
|
|
205 |
{
|
|
206 |
context = CSIPushMsgEntry::NewL();
|
|
207 |
}
|
|
208 |
else if ( bioType == KUidWapPushMsgSL.iUid &&
|
|
209 |
FeatureManager::FeatureSupported( KFeatureIdPushSL ) )
|
|
210 |
{
|
|
211 |
context = CSLPushMsgEntry::NewL();
|
|
212 |
}
|
|
213 |
else
|
|
214 |
{
|
|
215 |
__ASSERT_DEBUG( EFalse, UiPanic( EPushMtmUiPanBadBioType ) );
|
|
216 |
User::Leave( KErrNotSupported );
|
|
217 |
}
|
|
218 |
|
|
219 |
CleanupStack::PushL( context );
|
|
220 |
context->RetrieveL( iMsvSession, iEntryId );
|
|
221 |
|
|
222 |
if ( bioType == KUidWapPushMsgSI.iUid )
|
|
223 |
{
|
|
224 |
CSIPushMsgEntry* si = STATIC_CAST( CSIPushMsgEntry*, context );
|
|
225 |
aUrl.Set( si->Url() );
|
|
226 |
}
|
|
227 |
else if ( bioType == KUidWapPushMsgSL.iUid )
|
|
228 |
{
|
|
229 |
CSLPushMsgEntry* sl = STATIC_CAST( CSLPushMsgEntry*, context );
|
|
230 |
aUrl.Set( sl->Url() );
|
|
231 |
}
|
|
232 |
else
|
|
233 |
{
|
|
234 |
__ASSERT_DEBUG( EFalse, UiPanic( EPushMtmUiPanBadBioType ) );
|
|
235 |
}
|
|
236 |
|
|
237 |
PUSHLOG_LEAVEFN("CPushLoadServiceOp::RetrieveContextAndGetUrlLC");
|
|
238 |
return context;
|
|
239 |
}
|
|
240 |
|
|
241 |
// ---------------------------------------------------------
|
|
242 |
// CPushLoadServiceOp::AuthenticateL
|
|
243 |
// ---------------------------------------------------------
|
|
244 |
//
|
|
245 |
TBool CPushLoadServiceOp::AuthenticateL( const CPushMsgEntryBase& aPushMsg,
|
|
246 |
const CPushMtmSettings& aMtmSettings ) const
|
|
247 |
{
|
|
248 |
PUSHLOG_ENTERFN("CPushLoadServiceOp::AuthenticateL");
|
|
249 |
|
|
250 |
TBool isAuthenticated = ETrue; // by default.
|
|
251 |
|
|
252 |
if ( iTEntry.iBioType != KUidWapPushMsgSL.iUid )
|
|
253 |
{
|
|
254 |
PUSHLOG_WRITE(" Not SL");
|
|
255 |
isAuthenticated = ETrue; // No authentication needed.
|
|
256 |
}
|
|
257 |
else
|
|
258 |
{
|
|
259 |
// SL cache & execute-high message requires additional authentication.
|
|
260 |
CSLPushMsgEntry& sl = (CSLPushMsgEntry&)aPushMsg;
|
|
261 |
|
|
262 |
if ( sl.Action() == CSLPushMsgEntry::ESLPushMsgExecuteCache )
|
|
263 |
{
|
|
264 |
PUSHLOG_WRITE(" SL cache");
|
|
265 |
isAuthenticated = TPushAuthenticationUtil::
|
|
266 |
AuthenticateMsgL( aMtmSettings, aPushMsg );
|
|
267 |
if ( !isAuthenticated )
|
|
268 |
{
|
|
269 |
// Ask the user...
|
|
270 |
isAuthenticated = ExecuteUserQueryL( R_PUSHLS_SL_CACHE_NOT_AUTH );
|
|
271 |
}
|
|
272 |
}
|
|
273 |
else if
|
|
274 |
(
|
|
275 |
sl.Action() == CSLPushMsgEntry::ESLPushMsgExecuteHigh &&
|
|
276 |
aMtmSettings.ServiceLoadingType() == CPushMtmSettings::EAutomatic
|
|
277 |
)
|
|
278 |
{
|
|
279 |
PUSHLOG_WRITE(" SL high + auto");
|
|
280 |
isAuthenticated = TPushAuthenticationUtil::
|
|
281 |
AuthenticateMsgL( aMtmSettings, aPushMsg );
|
|
282 |
if ( !isAuthenticated )
|
|
283 |
{
|
|
284 |
// Ask the user...
|
|
285 |
isAuthenticated = ExecuteUserQueryL( R_PUSHLS_SL_NOT_AUTH );
|
|
286 |
}
|
|
287 |
}
|
|
288 |
else
|
|
289 |
{
|
|
290 |
PUSHLOG_WRITE(" Other SL");
|
|
291 |
isAuthenticated = ETrue; // No authentication needed.
|
|
292 |
}
|
|
293 |
}
|
|
294 |
|
|
295 |
PUSHLOG_LEAVEFN("CPushLoadServiceOp::AuthenticateL");
|
|
296 |
return isAuthenticated;
|
|
297 |
}
|
|
298 |
|
|
299 |
// ---------------------------------------------------------
|
|
300 |
// CPushLoadServiceOp::ExecuteUserQueryL
|
|
301 |
// ---------------------------------------------------------
|
|
302 |
//
|
|
303 |
TBool CPushLoadServiceOp::ExecuteUserQueryL( TInt aResId ) const
|
|
304 |
{
|
|
305 |
CAknQueryDialog* queryDlg = CAknQueryDialog::NewL();
|
|
306 |
TInt userResponse = queryDlg->ExecuteLD( aResId );
|
|
307 |
TBool userWantsToDownload = ( userResponse == EAknSoftkeyYes );
|
|
308 |
|
|
309 |
return userWantsToDownload;
|
|
310 |
}
|
|
311 |
|
|
312 |
// ---------------------------------------------------------
|
|
313 |
// CPushLoadServiceOp::ValidateLC
|
|
314 |
// ---------------------------------------------------------
|
|
315 |
//
|
|
316 |
HBufC* CPushLoadServiceOp::ValidateLC( TDesC& aUrl ) const
|
|
317 |
{
|
|
318 |
TUriParser uriParser;
|
|
319 |
TInt err = uriParser.Parse( aUrl );
|
|
320 |
User::LeaveIfError( err );
|
|
321 |
HBufC* validated = NULL;
|
|
322 |
|
|
323 |
if ( uriParser.IsPresent( EUriScheme ) )
|
|
324 |
{
|
|
325 |
// Just copy the original URL.
|
|
326 |
validated = aUrl.AllocLC();
|
|
327 |
}
|
|
328 |
else
|
|
329 |
{
|
|
330 |
// Add default scheme.
|
|
331 |
validated = HBufC::NewLC( aUrl.Length() + KDefaultScheme().Length() );
|
|
332 |
validated->Des().Copy( KDefaultScheme );
|
|
333 |
validated->Des().Append( aUrl );
|
|
334 |
}
|
|
335 |
|
|
336 |
return validated;
|
|
337 |
}
|
|
338 |
|
|
339 |
// ---------------------------------------------------------
|
|
340 |
// CPushLoadServiceOp::RunL
|
|
341 |
// ---------------------------------------------------------
|
|
342 |
//
|
|
343 |
void CPushLoadServiceOp::RunL()
|
|
344 |
{
|
|
345 |
PUSHLOG_ENTERFN("CPushLoadServiceOp::RunL")
|
|
346 |
|
|
347 |
if ( iDone )
|
|
348 |
{
|
|
349 |
PUSHLOG_WRITE(" Done")
|
|
350 |
SignalObserver( KErrNone );
|
|
351 |
}
|
|
352 |
else
|
|
353 |
{
|
|
354 |
TPtrC url;
|
|
355 |
CPushMsgEntryBase* context = RetrieveContextAndGetUrlLC( url );
|
|
356 |
|
|
357 |
CPushMtmSettings* mtmSettings = CPushMtmSettings::NewLC();
|
|
358 |
TBool msgAuthenticated = AuthenticateL( *context, *mtmSettings );
|
|
359 |
CleanupStack::PopAndDestroy( mtmSettings ); // mtmSettings
|
|
360 |
|
|
361 |
if ( !msgAuthenticated )
|
|
362 |
{
|
|
363 |
// Ready.
|
|
364 |
SignalObserver( KErrNone );
|
|
365 |
}
|
|
366 |
else
|
|
367 |
{
|
|
368 |
// OK, authenticated. Can be downloaded.
|
|
369 |
|
|
370 |
// Mark service read.
|
|
371 |
iMtmUtil->MarkServiceUnreadL( iEntryId, EFalse );
|
|
372 |
|
|
373 |
// Download the URL.
|
|
374 |
delete iSchemeHandler;
|
|
375 |
iSchemeHandler = NULL;
|
|
376 |
HBufC* validatedUrl = ValidateLC( url );
|
|
377 |
iSchemeHandler = CSchemeHandler::NewL( *validatedUrl );
|
|
378 |
|
|
379 |
if( (url.Mid(0,7).Compare(_L("http://")) == 0) || (url.Mid(0,8).Compare(_L("https://")) == 0))
|
|
380 |
{
|
|
381 |
TRAPD( err, iSchemeHandler->HandleUrlStandaloneL());
|
|
382 |
CleanupStack::PopAndDestroy( validatedUrl ); // validatedUrl
|
|
383 |
SignalObserver( err );
|
|
384 |
}
|
|
385 |
else
|
|
386 |
{
|
|
387 |
iSchemeHandler->Observer( this );
|
|
388 |
TRAPD(err, iSchemeHandler->HandleUrlEmbeddedL());
|
|
389 |
CleanupStack::PopAndDestroy( validatedUrl ); // validatedUrl
|
|
390 |
if( err != KErrNone)
|
|
391 |
SignalObserver( err );
|
|
392 |
}
|
|
393 |
|
|
394 |
}
|
|
395 |
|
|
396 |
CleanupStack::PopAndDestroy( context ); // context, needed for 'url'
|
|
397 |
}
|
|
398 |
|
|
399 |
PUSHLOG_LEAVEFN("CPushLoadServiceOp::RunL")
|
|
400 |
}
|
|
401 |
|
|
402 |
// ---------------------------------------------------------
|
|
403 |
// CPushLoadServiceOp::DoCancel
|
|
404 |
// ---------------------------------------------------------
|
|
405 |
//
|
|
406 |
void CPushLoadServiceOp::DoCancel()
|
|
407 |
{
|
|
408 |
PUSHLOG_ENTERFN("CPushLoadServiceOp::DoCancel")
|
|
409 |
SignalObserver( KErrCancel );
|
|
410 |
PUSHLOG_LEAVEFN("CPushLoadServiceOp::DoCancel")
|
|
411 |
}
|
|
412 |
|
|
413 |
// ---------------------------------------------------------
|
|
414 |
// CPushLoadServiceOp::RunError
|
|
415 |
// ---------------------------------------------------------
|
|
416 |
//
|
|
417 |
TInt CPushLoadServiceOp::RunError( TInt aError )
|
|
418 |
{
|
|
419 |
PUSHLOG_ENTERFN("CPushLoadServiceOp::RunError")
|
|
420 |
PUSHLOG_WRITE_FORMAT(" CPushLoadServiceOp::RunError <%d>",aError)
|
|
421 |
|
|
422 |
TRAP_IGNORE( ShowGlobalErrorNoteL( aError ) );
|
|
423 |
return CPushMtmUiOperation::RunError( aError );
|
|
424 |
|
|
425 |
PUSHLOG_LEAVEFN("CPushLoadServiceOp::RunError")
|
|
426 |
}
|
|
427 |
|
|
428 |
// ---------------------------------------------------------
|
|
429 |
// CPushLoadServiceOp::HandleServerAppExit
|
|
430 |
// ---------------------------------------------------------
|
|
431 |
//
|
|
432 |
void CPushLoadServiceOp::HandleServerAppExit(TInt LOG_ONLY(aReason))
|
|
433 |
{
|
|
434 |
PUSHLOG_ENTERFN("CPushLoadServiceOp::HandleServerAppExit")
|
|
435 |
PUSHLOG_WRITE_FORMAT(" CPushLoadServiceOp::HandleServerAppExit <%d>",aReason)
|
|
436 |
|
|
437 |
// Ready.
|
|
438 |
SignalObserver( KErrNone );
|
|
439 |
|
|
440 |
PUSHLOG_LEAVEFN("CPushLoadServiceOp::HandleServerAppExit")
|
|
441 |
}
|
|
442 |
|
|
443 |
// End of file.
|