1 /* |
1 /* |
2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Dynamically loadable wrapper for Download manager |
14 * Description: Dynamically loadable wrapper for Download manager |
15 * |
15 * |
16 */ |
16 */ |
17 |
|
18 #include <centralrepository.h> |
17 #include <centralrepository.h> |
19 #include <cdblen.h> |
18 #include <cdblen.h> |
20 #include <cmconnectionmethod.h> |
19 #include <cmconnectionmethod.h> |
21 #include <cmdestination.h> |
20 #include <cmdestination.h> |
22 #include <cmconnectionmethoddef.h> |
21 #include <cmconnectionmethoddef.h> |
23 #include <cmmanager.h> |
22 #include <cmmanager.h> |
24 |
|
25 #ifdef __SERIES60_NATIVE_BROWSER |
|
26 #include <BrowserUiSDKCRKeys.h> |
|
27 #endif |
|
28 |
|
29 #ifdef RD_MULTIPLE_DRIVE |
23 #ifdef RD_MULTIPLE_DRIVE |
30 #include <driveinfo.h> |
24 #include <driveinfo.h> |
31 #endif |
25 #endif |
32 |
|
33 #include <StringLoader.h> |
26 #include <StringLoader.h> |
34 #include <data_caging_path_literals.hrh> |
27 #include <data_caging_path_literals.hrh> |
|
28 |
|
29 #include <downloadmgrclient.h> //download manager |
|
30 #include <es_enum.h> // tconnectioninfo |
|
31 #include <es_enum_partner.h> // TConnectionInfoV2 |
|
32 #include <es_sock.h> // rconnection rsocket |
|
33 #include <AknProgressDialog.h> // avkon classes |
|
34 #include <eikprogi.h> |
35 |
35 |
36 #include <ConeResLoader.h> |
36 #include <ConeResLoader.h> |
37 #include <apparc.h> |
37 #include <apparc.h> |
38 #include <DrmUtilityDmgrWrapper.rsg> |
38 #include <DrmUtilityDmgrWrapper.rsg> |
39 |
39 |
40 #include "RoapEng.h" |
40 #include <RoapEng.h> |
|
41 #include <RoapDef.h> |
|
42 #include <RoapObserver.h> |
|
43 |
41 #include "RoapSyncWrapper.h" |
44 #include "RoapSyncWrapper.h" |
42 #include "RoapDef.h" |
45 #include "RoapDef.h" |
43 |
|
44 #include "DrmUtilityDmgrWrapper.h" |
46 #include "DrmUtilityDmgrWrapper.h" |
45 #include "DrmUtilityDmgrWrapperLogger.h" |
47 #include "DrmUtilityDmgrWrapperLogger.h" |
46 |
48 #include "drmutilityconnection.h" |
47 // DEBUG macros |
49 #include "buffercontainers.h" //CnameContainer etc. |
48 #ifdef _DEBUG |
50 #include "cleanupresetanddestroy.h" |
49 #define DRMDEBUGLIT( a, b ) \ |
51 #include "buffercontainers.h" |
50 _LIT( a , b ) |
52 |
51 #define DRMDEBUG( a ) \ |
53 #include "OstTraceDefinitions.h" |
52 RDebug::Print( a ) |
54 #ifdef OST_TRACE_COMPILER_IN_USE |
53 #define DRMDEBUG2( a, b ) \ |
55 #include "DrmUtilityDmgrWrapperTraces.h" |
54 RDebug::Print( a, b ) |
|
55 #else |
|
56 #define DRMDEBUGLIT( a, b ) |
|
57 #define DRMDEBUG( a ) |
|
58 #define DRMDEBUG2( a, b ) |
|
59 #endif |
|
60 |
|
61 // CONSTANTS |
|
62 #ifndef __SERIES60_NATIVE_BROWSER |
|
63 const TUid KCRUidBrowser = {0x10008D39}; |
|
64 const TUint32 KBrowserDefaultAccessPoint = 0x0000000E; |
|
65 const TUint32 KBrowserAccessPointSelectionMode = 0x0000001E; |
|
66 #endif |
56 #endif |
67 |
57 |
68 #ifndef RD_MULTIPLE_DRIVE |
58 #ifndef RD_MULTIPLE_DRIVE |
69 _LIT( KDriveZ, "z:" ); |
59 _LIT( KDriveZ, "z:" ); |
70 _LIT( KDrmUtilityTriggerFilePath, "d:\\" ); |
60 _LIT( KDrmUtilityTriggerFilePath, "d:\\" ); |
71 #else |
61 #else |
72 _LIT( KRomDriveFormatter, "%c:" ); |
62 _LIT( KRomDriveFormatter, "%c:" ); |
73 _LIT( KKDrmUtilityTriggerFilePathFormatter, "%c:\\" ); |
63 _LIT( KKDrmUtilityTriggerFilePathFormatter, "%c:\\" ); |
74 #endif |
64 #endif |
75 |
|
76 _LIT( KCDrmUtilityDmgrWrapperResFileName,"DrmUtilityDmgrWrapper.rsc" ); |
65 _LIT( KCDrmUtilityDmgrWrapperResFileName,"DrmUtilityDmgrWrapper.rsc" ); |
77 const TInt KProgressInfoFinalValue( 200 ); |
66 const TInt KProgressInfoFinalValue(200); |
78 const TInt KProgressInfoIncrementSmall( 5 ); |
67 const TInt KProgressInfoIncrementSmall(5); |
79 const TInt KProgressInfoIncrementMedium( 10 ); |
68 const TInt KProgressInfoIncrementMedium(10); |
80 const TInt KProgressInfoIncrementLarge( 30 ); |
69 const TInt KProgressInfoIncrementLarge(30); |
81 |
70 |
82 // ======== LOCAL FUNCTIONS ======== |
71 // ======== LOCAL FUNCTIONS ======== |
83 |
72 |
84 // --------------------------------------------------------------------------- |
73 // --------------------------------------------------------------------------- |
|
74 // ClearIfNotRoapTemporaryError |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 void ClearIfNotRoapTemporaryError(TInt aError, HBufC8*& aBuffer) |
|
78 { |
|
79 // ROAP ERROR CODES |
|
80 switch (aError) |
|
81 { |
|
82 case KErrRoapGeneral: |
|
83 case KErrRoapServer: |
|
84 case KErrRoapDomainFull: |
|
85 case KErrRoapNotRegistered: |
|
86 break; |
|
87 default: |
|
88 delete aBuffer; |
|
89 aBuffer = NULL; |
|
90 break; |
|
91 } |
|
92 } |
|
93 |
|
94 |
|
95 // --------------------------------------------------------------------------- |
85 // DeleteHttpDowload |
96 // DeleteHttpDowload |
86 // --------------------------------------------------------------------------- |
97 // --------------------------------------------------------------------------- |
87 // |
98 // |
88 LOCAL_C void DeleteHttpDowload( TAny* aDownload ) |
99 LOCAL_C void DeleteHttpDowload(TAny* aDownload) |
89 { |
100 { |
90 reinterpret_cast< RHttpDownload* >( aDownload )->Delete(); |
101 reinterpret_cast<RHttpDownload*> (aDownload)->Delete(); |
91 } |
102 } |
92 |
103 |
93 // --------------------------------------------------------------------------- |
104 |
94 // IapIdOfDefaultSnapL |
105 // --------------------------------------------------------------------------- |
95 // for trapping purposes only |
106 // UpdateBufferL |
96 // --------------------------------------------------------------------------- |
107 // --------------------------------------------------------------------------- |
97 // |
108 // |
98 LOCAL_C TUint32 IapIdOfDefaultSnapL( |
109 template<typename bufType, typename descType> |
99 RCmManager& aCmManager, |
110 LOCAL_C void UpdateBufferL(bufType*& aTargetBuf, const descType& aSourceBuf) |
100 const TUint32 aDefaultSnap ) |
111 { |
101 { |
112 if (aTargetBuf) |
102 RCmDestination dest( aCmManager.DestinationL( aDefaultSnap ) ); |
113 { |
103 CleanupClosePushL( dest ); |
114 delete aTargetBuf; |
104 TUint32 iapIdOfDest( 0 ); |
115 aTargetBuf = NULL; |
105 |
116 } |
106 if ( dest.ConnectionMethodCount() <= 0 ) |
117 if (aSourceBuf.Length()) |
107 { |
118 { |
108 User::Leave( KErrNotFound ); |
119 aTargetBuf = aSourceBuf.AllocL(); |
109 } |
120 } |
110 |
121 } |
111 RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) ); |
|
112 CleanupClosePushL( cMeth ); |
|
113 |
|
114 iapIdOfDest = cMeth.GetIntAttributeL( CMManager::ECmIapId ); |
|
115 CleanupStack::PopAndDestroy( &cMeth ); |
|
116 CleanupStack::PopAndDestroy( &dest ); |
|
117 return iapIdOfDest; |
|
118 } |
|
119 |
|
120 |
122 |
121 // ======== MEMBER FUNCTIONS ======== |
123 // ======== MEMBER FUNCTIONS ======== |
122 |
124 |
123 // --------------------------------------------------------------------------- |
125 // --------------------------------------------------------------------------- |
124 // CDrmUtilityDmgrWrapper::CDrmUtilityDmgrWrapper |
126 // CDrmUtilityDmgrWrapper::CDrmUtilityDmgrWrapper |
125 // --------------------------------------------------------------------------- |
127 // --------------------------------------------------------------------------- |
126 // |
128 // |
127 CDrmUtilityDmgrWrapper::CDrmUtilityDmgrWrapper() : |
129 CDrmUtilityDmgrWrapper::CDrmUtilityDmgrWrapper() : |
128 iUseCoeEnv( EFalse ) |
130 CActive(CActive::EPriorityStandard), |
129 { |
131 iUseCoeEnv(EFalse), iIapId(0), iState(EInit) |
|
132 { |
|
133 CActiveScheduler::Add(this); |
130 } |
134 } |
131 |
135 |
132 // --------------------------------------------------------------------------- |
136 // --------------------------------------------------------------------------- |
133 // CDrmUtilityDmgrWrapper::ConstructL |
137 // CDrmUtilityDmgrWrapper::ConstructL |
134 // --------------------------------------------------------------------------- |
138 // --------------------------------------------------------------------------- |
135 // |
139 // |
136 void CDrmUtilityDmgrWrapper::ConstructL() |
140 void CDrmUtilityDmgrWrapper::ConstructL() |
137 { |
141 { |
138 CLOG_WRITE( "DMgrWrapper::ConstructL" ); |
142 CLOG_WRITE( "DMgrWrapper::ConstructL" ); |
139 const TInt KDrmUtilityDmgrWrapperUid = 0x102830FE; |
143 const TInt KDrmUtilityDmgrWrapperUid = 0x102830FE; |
140 iDlMgr.ConnectL( TUid::Uid(KDrmUtilityDmgrWrapperUid), *this, EFalse ); |
144 iConnection = DRM::CDrmUtilityConnection::NewL(ETrue); |
|
145 iDlMgr.ConnectL(TUid::Uid(KDrmUtilityDmgrWrapperUid), *this, EFalse); |
141 iProgressInfo = NULL; |
146 iProgressInfo = NULL; |
142 iProgressNoteDialog = NULL; |
147 iProgressNoteDialog = NULL; |
143 iDialogDismissed = ETrue; |
148 iDialogDismissed = ETrue; |
144 } |
149 User::LeaveIfError(iFs.Connect()); |
145 |
150 User::LeaveIfError(iFs.ShareProtected()); |
146 |
151 } |
147 |
152 |
148 // --------------------------------------------------------------------------- |
153 // --------------------------------------------------------------------------- |
149 // CDrmUtilityDmgrWrapper::NewL |
154 // CDrmUtilityDmgrWrapper::NewL |
150 // --------------------------------------------------------------------------- |
155 // --------------------------------------------------------------------------- |
151 // |
156 // |
152 CDrmUtilityDmgrWrapper* CDrmUtilityDmgrWrapper::NewL() |
157 CDrmUtilityDmgrWrapper* CDrmUtilityDmgrWrapper::NewL() |
153 { |
158 { |
154 CLOG_WRITE( "DMgrWrapper::NewL" ); |
159 CLOG_WRITE( "DMgrWrapper::NewL" ); |
155 CDrmUtilityDmgrWrapper* self( CDrmUtilityDmgrWrapper::NewLC() ); |
160 CDrmUtilityDmgrWrapper* self(CDrmUtilityDmgrWrapper::NewLC()); |
156 CleanupStack::Pop( self ); |
161 CleanupStack::Pop(self); |
157 return self; |
162 return self; |
158 } |
163 } |
159 |
164 |
160 |
|
161 // --------------------------------------------------------------------------- |
165 // --------------------------------------------------------------------------- |
162 // CDrmUtilityDmgrWrapper::NewLC |
166 // CDrmUtilityDmgrWrapper::NewLC |
163 // --------------------------------------------------------------------------- |
167 // --------------------------------------------------------------------------- |
164 // |
168 // |
165 CDrmUtilityDmgrWrapper* CDrmUtilityDmgrWrapper::NewLC() |
169 CDrmUtilityDmgrWrapper* CDrmUtilityDmgrWrapper::NewLC() |
166 { |
170 { |
167 CLOG_WRITE( "DMgrWrapper::NewLC" ); |
171 CLOG_WRITE( "DMgrWrapper::NewLC" ); |
168 CDrmUtilityDmgrWrapper* self( new( ELeave ) CDrmUtilityDmgrWrapper() ); |
172 CDrmUtilityDmgrWrapper* self(new (ELeave) CDrmUtilityDmgrWrapper()); |
169 CleanupStack::PushL( self ); |
173 CleanupStack::PushL(self); |
170 self->ConstructL(); |
174 self->ConstructL(); |
171 return self; |
175 return self; |
172 } |
176 } |
173 |
177 |
174 |
|
175 // --------------------------------------------------------------------------- |
178 // --------------------------------------------------------------------------- |
176 // CDrmUtilityDmgrWrapper::~CDrmUtilityDmgrWrapper |
179 // CDrmUtilityDmgrWrapper::~CDrmUtilityDmgrWrapper |
177 // --------------------------------------------------------------------------- |
180 // --------------------------------------------------------------------------- |
178 // |
181 // |
179 CDrmUtilityDmgrWrapper::~CDrmUtilityDmgrWrapper() |
182 CDrmUtilityDmgrWrapper::~CDrmUtilityDmgrWrapper() |
180 { |
183 { |
181 CLOG_WRITE( "DMgrWrapper destructor" ); |
184 CLOG_WRITE( "DMgrWrapper destructor" ); |
182 if ( iProgressNoteDialog ) |
185 Cancel(); |
183 { |
186 if (iProgressNoteDialog) |
184 // deletes the dialog |
187 { |
185 TRAPD( err, iProgressNoteDialog->ProcessFinishedL() ); |
188 // deletes the dialog |
186 if ( err ) |
189 TRAPD( err, iProgressNoteDialog->ProcessFinishedL() ); |
187 { |
190 if (err) |
188 delete iProgressNoteDialog; |
191 { |
189 } |
192 delete iProgressNoteDialog; |
190 iProgressNoteDialog = NULL; |
193 } |
191 } |
194 iProgressNoteDialog = NULL; |
|
195 } |
192 delete iErrorUrl; |
196 delete iErrorUrl; |
|
197 |
193 delete iPostResponseUrl; |
198 delete iPostResponseUrl; |
|
199 delete iConnection; |
|
200 |
|
201 delete iTriggerUrl; |
|
202 delete iTriggerBuf; |
|
203 delete iFileName; |
|
204 delete iRoapEng; |
194 |
205 |
195 #ifdef _DEBUG |
206 #ifdef _DEBUG |
196 |
207 |
197 if ( iDlMgr.Handle() ) |
208 if (iDlMgr.Handle()) |
198 { |
209 { |
199 iDlMgr.Close(); |
210 iDlMgr.Close(); |
200 } |
211 } |
201 |
212 |
202 #else |
213 #else |
203 |
214 |
204 iDlMgr.Close(); |
215 iDlMgr.Close(); |
205 |
216 |
206 #endif |
217 #endif |
|
218 |
|
219 iFs.Close(); |
|
220 |
207 } |
221 } |
208 |
222 |
209 |
223 |
210 // --------------------------------------------------------------------------- |
224 // --------------------------------------------------------------------------- |
211 // CDrmUtilityDmgrWrapper::DownloadAndHandleRoapTriggerL |
225 // CDrmUtilityDmgrWrapper::DownloadAndHandleRoapTriggerL |
212 // --------------------------------------------------------------------------- |
226 // --------------------------------------------------------------------------- |
213 // |
227 // |
214 void CDrmUtilityDmgrWrapper::DownloadAndHandleRoapTriggerL( const HBufC8* aUrl ) |
228 void CDrmUtilityDmgrWrapper::DownloadAndHandleRoapTriggerL(const HBufC8* aUrl) |
215 { |
229 { |
216 CLOG_WRITE( "DMgrWrapper::DownloadAndHandleRoapTriggerL" ); |
230 CLOG_WRITE( "DMgrWrapper::DownloadAndHandleRoapTriggerL" ); |
217 iUseCoeEnv = EFalse; |
231 iUseCoeEnv = EFalse; |
218 DoDownloadAndHandleRoapTriggerL( aUrl ); |
232 if (iState != EInit || iWait.IsStarted()) |
219 HandlePostResponseUrlL(); |
233 { |
220 } |
234 User::Leave(KErrNotReady); |
221 |
235 } |
|
236 |
|
237 UpdateBufferL<HBufC8, TDesC8> (iTriggerUrl, *aUrl); |
|
238 CompleteToState(EInit, KErrNone); |
|
239 iWait.Start(); |
|
240 } |
222 |
241 |
223 // --------------------------------------------------------------------------- |
242 // --------------------------------------------------------------------------- |
224 // CDrmUtilityDmgrWrapper::DownloadAndHandleRoapTriggerL |
243 // CDrmUtilityDmgrWrapper::DownloadAndHandleRoapTriggerL |
225 // --------------------------------------------------------------------------- |
244 // --------------------------------------------------------------------------- |
226 // |
245 // |
227 void CDrmUtilityDmgrWrapper::DownloadAndHandleRoapTriggerL( |
246 void CDrmUtilityDmgrWrapper::DownloadAndHandleRoapTriggerL( |
228 const HBufC8* aUrl, CCoeEnv& aCoeEnv ) |
247 const HBufC8* aUrl, CCoeEnv& aCoeEnv) |
229 { |
248 { |
230 CLOG_WRITE( "DMgrWrapper::DownloadAndHandleRoapTriggerL" ); |
249 CLOG_WRITE( "DMgrWrapper::DownloadAndHandleRoapTriggerL" ); |
231 iCoeEnv = &aCoeEnv; |
250 iCoeEnv = &aCoeEnv; |
232 iUseCoeEnv = ETrue; |
251 iUseCoeEnv = ETrue; |
233 DoDownloadAndHandleRoapTriggerL( aUrl ); |
252 if (iState != EInit || iWait.IsStarted()) |
234 HandlePostResponseUrlL(); |
253 { |
235 } |
254 User::Leave(KErrNotReady); |
236 |
255 } |
237 |
256 |
238 // --------------------------------------------------------------------------- |
257 UpdateBufferL<HBufC8, TDesC8> (iTriggerUrl, *aUrl); |
239 // CDrmUtilityDmgrWrapper::HandlePostResponseUrlL |
258 CompleteToState(EInit, KErrNone); |
240 // --------------------------------------------------------------------------- |
259 iWait.Start(); |
241 // |
260 } |
242 void CDrmUtilityDmgrWrapper::HandlePostResponseUrlL() |
261 |
243 { |
262 // --------------------------------------------------------------------------- |
244 if ( iPostResponseUrl ) |
263 // CDrmUtilityDmgrWrapper::GetErrorUrlL |
245 { |
264 // --------------------------------------------------------------------------- |
246 DoDownloadAndHandleRoapTriggerL( iPostResponseUrl ); |
265 // |
247 // prevent infinite post response fetches. |
266 HBufC8* CDrmUtilityDmgrWrapper::GetErrorUrlL() |
248 delete iPostResponseUrl; |
267 { |
249 iPostResponseUrl = NULL; |
268 if (iErrorUrl) |
250 |
269 { |
251 // Ensure progress note gets deleted. |
270 return iErrorUrl->AllocL(); |
252 // It remains open if prUrl initialted ROAP operation has PrUrl |
271 } |
253 // (unsupported chained metering report) |
272 return NULL; |
254 RemoveProgressNoteL(); |
273 } |
255 } |
274 |
256 } |
275 // --------------------------------------------------------------------------- |
257 |
276 // CDrmUtilityDmgrWrapper::DoConnectL |
258 |
277 // --------------------------------------------------------------------------- |
259 // --------------------------------------------------------------------------- |
278 // |
260 // CDrmUtilityDmgrWrapper::DoDownloadAndHandleRoapTriggerL |
279 void CDrmUtilityDmgrWrapper::DoConnectL(TDownloadState aNextState) |
261 // --------------------------------------------------------------------------- |
280 { |
262 // |
281 iConnection->ConnectL(&iStatus); |
263 void CDrmUtilityDmgrWrapper::DoDownloadAndHandleRoapTriggerL( |
282 if (iUseCoeEnv && iProgressInfo) |
264 const HBufC8* aUrl ) |
283 { |
265 { |
284 iProgressInfo->SetAndDraw(0); |
266 RFs fs; |
285 } |
|
286 iState = aNextState; |
|
287 SetActive(); |
|
288 } |
|
289 |
|
290 ///// |
|
291 // --------------------------------------------------------------------------- |
|
292 // CDrmUtilityDmgrWrapper::DoDownloadRoapTriggerL |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 void CDrmUtilityDmgrWrapper::DoDownloadRoapTriggerL(TDownloadState aNextState) |
|
296 { |
|
297 // Fetch name of opend connection to be used as part of DMGR |
|
298 // initialisation |
|
299 TUint32 iapId(0); |
|
300 if (iConnection->IsConnected(iapId)) |
|
301 { |
|
302 iDlMgr.SetIntAttribute( EDlMgrIap, iapId ); |
|
303 } |
267 RFile roapTrigger; |
304 RFile roapTrigger; |
268 HBufC8* triggerBuf( NULL ); |
305 TBool result(EFalse); |
269 TBool result( EFalse ); |
306 DRM::CFileNameContainer* triggerFileName(NULL); |
270 TFileName triggerFileName; |
307 |
271 |
308 // If no Trigger URL then nothing to download. So finish transaction |
272 CLOG_WRITE( "DMgrWrapper::DoDownloadAndHandleRoapTriggerL" ); |
309 if (!iTriggerUrl || iTriggerUrl->Length() <= 0) |
273 User::LeaveIfError( fs.Connect() ); |
310 { |
274 CleanupClosePushL( fs ); |
311 if (iUseCoeEnv && iProgressInfo) |
275 User::LeaveIfError( fs.ShareProtected() ); |
312 { |
276 |
313 // No PrUrl found. Progess is complete. |
277 #ifndef RD_MULTIPLE_DRIVE |
314 iProgressInfo->SetAndDraw(KProgressInfoFinalValue); |
278 |
315 } |
279 User::LeaveIfError( roapTrigger.Temp( |
316 CompleteToState(EComplete, KErrNone); |
280 fs, KDrmUtilityTriggerFilePath, triggerFileName, EFileWrite ) ); |
317 return; |
281 |
318 } |
282 #else //RD_MULTIPLE_DRIVE |
319 |
283 |
320 TPtrC8 KNullPtr8(NULL, 0); |
284 TInt driveNumber( -1 ); |
321 RHttpDownload* downloadPtr(iDlMgr.FindDownload(*iTriggerUrl, KNullPtr8)); |
285 TChar driveLetter; |
322 if (downloadPtr) |
286 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRam, driveNumber ); |
|
287 fs.DriveToChar( driveNumber, driveLetter ); |
|
288 |
|
289 TFileName utilityTriggerFilePath; |
|
290 |
|
291 utilityTriggerFilePath.Format( KKDrmUtilityTriggerFilePathFormatter, |
|
292 (TUint)driveLetter ); |
|
293 |
|
294 User::LeaveIfError( roapTrigger.Temp( |
|
295 fs, utilityTriggerFilePath, triggerFileName, EFileWrite ) ); |
|
296 |
|
297 #endif |
|
298 |
|
299 |
|
300 TPtrC8 KNullPtr8( NULL, 0 ); |
|
301 RHttpDownload* downloadPtr( iDlMgr.FindDownload( *aUrl, KNullPtr8 ) ); |
|
302 if ( downloadPtr ) |
|
303 { |
323 { |
304 // Stale download found. |
324 // Stale download found. |
305 // Remove it, and re-create a new download. |
325 // Remove it, and re-create a new download. |
306 downloadPtr->Delete(); |
326 downloadPtr->Delete(); |
307 downloadPtr = NULL; |
327 downloadPtr = NULL; |
308 } |
328 if (iFileName) |
|
329 { |
|
330 iFs.Delete(*iFileName); |
|
331 } |
|
332 } |
|
333 |
|
334 triggerFileName=DRM::CFileNameContainer::NewLC(); |
|
335 #ifndef RD_MULTIPLE_DRIVE |
|
336 |
|
337 User::LeaveIfError( roapTrigger.Temp( |
|
338 iFs, KDrmUtilityTriggerFilePath, triggerFileName->iBuffer, EFileWrite ) ); |
|
339 |
|
340 #else //RD_MULTIPLE_DRIVE |
|
341 TInt driveNumber(-1); |
|
342 TChar driveLetter; |
|
343 DriveInfo::GetDefaultDrive(DriveInfo::EDefaultRam, driveNumber); |
|
344 iFs.DriveToChar(driveNumber, driveLetter); |
|
345 |
|
346 DRM::CFileNameContainer* |
|
347 utilityTriggerFilePath(DRM::CFileNameContainer::NewLC()); |
|
348 |
|
349 utilityTriggerFilePath->iBuffer.Format( |
|
350 KKDrmUtilityTriggerFilePathFormatter, (TUint) driveLetter); |
|
351 |
|
352 User::LeaveIfError(roapTrigger.Temp(iFs, utilityTriggerFilePath->iBuffer, |
|
353 triggerFileName->iBuffer, EFileWrite)); |
|
354 CleanupStack::PopAndDestroy( utilityTriggerFilePath ); |
|
355 utilityTriggerFilePath=NULL; |
|
356 |
|
357 #endif |
|
358 UpdateBufferL<HBufC, TFileName> (iFileName, triggerFileName->iBuffer); |
|
359 CleanupStack::PopAndDestroy( triggerFileName ); |
|
360 triggerFileName=NULL; |
309 |
361 |
310 // create and start download |
362 // create and start download |
311 RHttpDownload& download = iDlMgr.CreateDownloadL( *aUrl, result ); |
363 RHttpDownload& download = iDlMgr.CreateDownloadL(*iTriggerUrl, result); |
312 // Put download for proper cleanup. |
364 // Put download for proper cleanup. |
313 TCleanupItem item( DeleteHttpDowload, &download ); |
365 TCleanupItem item(DeleteHttpDowload, &download); |
314 CleanupStack::PushL( item ); |
366 CleanupStack::PushL(item); |
315 |
367 |
316 CleanupClosePushL( roapTrigger ); |
368 CleanupClosePushL(roapTrigger); |
317 |
369 |
318 if ( !iPostResponseUrl ) |
370 if (result) |
319 { |
371 { |
320 // No post response retieval. Note must be created. |
|
321 ShowProgressNoteL(); |
|
322 } |
|
323 |
|
324 if ( result ) |
|
325 { |
|
326 const TInt KReadBufSize( 512 ); |
|
327 TInt triggerFileSize( 0 ); |
|
328 |
|
329 CLOG_WRITE( |
|
330 "DMgrWrapper::DoDownloadAndHandleRoapTriggerL: download created" ); |
|
331 iDownloadSuccess = EFalse; |
372 iDownloadSuccess = EFalse; |
332 iConnectionError = EFalse; |
373 iConnectionError = EFalse; |
333 |
374 |
334 SetDefaultAccessPointL(); |
375 User::LeaveIfError(download.SetFileHandleAttribute(roapTrigger)); |
335 |
376 User::LeaveIfError(download.SetBoolAttribute( |
336 User::LeaveIfError( download.SetFileHandleAttribute( roapTrigger ) ); |
377 EDlAttrNoContentTypeCheck, ETrue)); |
337 User::LeaveIfError( |
378 User::LeaveIfError(download.Start()); |
338 download.SetBoolAttribute( EDlAttrNoContentTypeCheck, ETrue ) ); |
|
339 User::LeaveIfError( download.Start() ); |
|
340 |
379 |
341 // wait until download is finished |
380 // wait until download is finished |
342 iWait.Start(); |
381 iState = aNextState; |
343 |
382 TRequestStatus* status(&iStatus); |
344 // Check success of download |
383 *status = KRequestPending; |
345 CLOG_WRITE( |
384 SetActive(); |
346 "DMgrWrapper::DoDownloadAndHandleRoapTriggerL: download finished" ); |
385 } |
347 |
386 CleanupStack::PopAndDestroy(&roapTrigger); |
348 CleanupStack::Pop( &roapTrigger ); |
387 CleanupStack::Pop(&download); // Left open for DoSaveRoapTrigger |
349 roapTrigger.Close(); |
388 } |
350 if ( !iDownloadSuccess ) |
389 // --------------------------------------------------------------------------- |
351 { |
390 // CDrmUtilityDmgrWrapper::DoSaveRoapTriggerL |
352 RemoveProgressNoteL(); |
391 // --------------------------------------------------------------------------- |
353 if ( iConnectionError ) |
392 // |
354 { |
393 void CDrmUtilityDmgrWrapper::DoSaveRoapTriggerL(TDownloadState aNextState) |
355 User::Leave( KErrCouldNotConnect ); |
394 { |
356 } |
395 // Check success of download |
357 else |
396 |
358 { |
397 // Fetch download created in DoDownloadRoapTriggerL |
359 User::Leave( KErrGeneral ); |
398 RHttpDownload* download = iDlMgr.FindDownload(*iTriggerUrl, KNullDesC8()); |
360 } |
399 // Delete trigger URL so that it is possible to check |
361 } |
400 // whether or not meteringResponse has PrUrl. |
362 User::LeaveIfError( roapTrigger.Open( fs, |
401 delete iTriggerUrl; |
363 triggerFileName, |
402 iTriggerUrl = NULL; |
364 EFileShareReadersOrWriters ) ); |
403 iStatus = KRequestPending; |
365 CleanupClosePushL( roapTrigger ); |
404 // Put download for proper cleanup. |
366 |
405 TCleanupItem item(DeleteHttpDowload, download); |
367 // Get filehandle of ROAP trigger |
406 CleanupStack::PushL(item); |
368 // Read file to buffer |
407 RFile roapTrigger; |
369 User::LeaveIfError( roapTrigger.Size( triggerFileSize ) ); |
408 |
370 triggerBuf = HBufC8::NewLC( triggerFileSize ); |
409 if (!iDownloadSuccess) |
371 |
|
372 RBuf8 readBuf; |
|
373 readBuf.CleanupClosePushL(); |
|
374 readBuf.CreateL( KReadBufSize ); |
|
375 |
|
376 User::LeaveIfError( roapTrigger.Read( readBuf, KReadBufSize ) ); |
|
377 triggerBuf->Des().Copy( readBuf ); |
|
378 while ( readBuf.Length() == KReadBufSize ) |
|
379 { |
|
380 User::LeaveIfError( roapTrigger.Read( readBuf, KReadBufSize ) ); |
|
381 triggerBuf->Des().Append( readBuf ); |
|
382 } |
|
383 |
|
384 CleanupStack::PopAndDestroy( &readBuf ); |
|
385 |
|
386 if ( iUseCoeEnv && iProgressInfo ) |
|
387 { |
|
388 iProgressInfo->IncrementAndDraw( KProgressInfoIncrementMedium ); |
|
389 } |
|
390 |
|
391 // And let ROAP handle it... |
|
392 CRoapSyncWrapper* roapWrapper( CRoapSyncWrapper::NewL() ); |
|
393 CleanupStack::PushL( roapWrapper ); |
|
394 TRAPD( err, roapWrapper->HandleTriggerL( *triggerBuf ) ); |
|
395 if ( err ) |
|
396 { |
|
397 TInt errorType( 0 ); |
|
398 TRAPD( err2, |
|
399 iErrorUrl = roapWrapper->GetErrorUrlL( err, errorType ) ); |
|
400 if ( err2 ) |
|
401 { |
|
402 RemoveProgressNoteL(); |
|
403 delete iErrorUrl; |
|
404 iErrorUrl = NULL; |
|
405 User::Leave( err2 ); |
|
406 } |
|
407 else if ( errorType != KErrRoapTemporary ) |
|
408 { |
|
409 RemoveProgressNoteL(); |
|
410 delete iErrorUrl; |
|
411 iErrorUrl = NULL; |
|
412 User::Leave( err ); |
|
413 } |
|
414 else |
|
415 { |
|
416 RemoveProgressNoteL(); |
|
417 User::Leave( err ); |
|
418 } |
|
419 } |
|
420 if ( iPostResponseUrl ) |
|
421 { |
|
422 delete iPostResponseUrl; |
|
423 iPostResponseUrl = NULL; |
|
424 } |
|
425 iPostResponseUrl = roapWrapper->GetPostResponseUrlL(); |
|
426 CleanupStack::PopAndDestroy( 2, triggerBuf ); |
|
427 |
|
428 if ( iUseCoeEnv && iProgressInfo && !iPostResponseUrl ) |
|
429 { |
|
430 // No PrUrl found. Progess is complete. |
|
431 iProgressInfo->SetAndDraw( KProgressInfoFinalValue ); |
|
432 } |
|
433 } |
|
434 |
|
435 // Trick to keep note open long enough during prUrl retrieval |
|
436 if ( !iPostResponseUrl ) |
|
437 { |
410 { |
438 RemoveProgressNoteL(); |
411 RemoveProgressNoteL(); |
439 } |
412 if (iConnectionError) |
440 else |
413 { |
441 { |
414 User::Leave(KErrCouldNotConnect); |
442 if ( iUseCoeEnv && iProgressInfo ) |
415 } |
443 { |
416 else |
444 iProgressInfo->IncrementAndDraw( KProgressInfoIncrementMedium ); |
417 { |
445 } |
418 User::Leave(KErrGeneral); |
446 } |
419 } |
447 |
420 } |
448 CleanupStack::PopAndDestroy( &roapTrigger ); |
421 User::LeaveIfError(roapTrigger.Open(iFs, *iFileName, |
449 CleanupStack::PopAndDestroy( &download ); |
422 EFileShareReadersOrWriters)); |
450 |
423 CleanupClosePushL(roapTrigger); |
451 fs.Delete( triggerFileName ); |
424 // Get filehandle of ROAP trigger |
452 CleanupStack::PopAndDestroy( &fs ); |
425 const TInt KReadBufSize = 512; |
453 } |
426 |
454 |
427 RBuf8 readBuf; |
455 |
428 readBuf.CleanupClosePushL(); |
456 // --------------------------------------------------------------------------- |
429 readBuf.CreateL(KReadBufSize); |
457 // CDrmUtilityDmgrWrapper::SetDefaultAccessPointL |
430 |
458 // --------------------------------------------------------------------------- |
431 // Read file to buffer |
459 // |
432 TInt triggerFileSize(0); |
460 void CDrmUtilityDmgrWrapper::SetDefaultAccessPointL() |
433 User::LeaveIfError(roapTrigger.Size(triggerFileSize)); |
461 { |
434 if (iTriggerBuf) |
462 const TInt KDestinationSelectionMode( 2 ); |
435 { |
463 CRepository* repository( NULL ); |
436 delete iTriggerBuf; |
464 TInt ap( 0 ); |
437 iTriggerBuf = NULL; |
465 TInt alwaysAsk( 0 ); |
438 } |
466 TUint32 iapd32( 0 ); |
439 iTriggerBuf = HBufC8::NewL(triggerFileSize); |
467 TInt defaultSnap( 0 ); |
440 User::LeaveIfError(roapTrigger.Read(readBuf, KReadBufSize)); |
468 TInt err( KErrNone ); |
441 iTriggerBuf->Des().Copy(readBuf); |
469 |
442 while (readBuf.Length() == KReadBufSize) |
470 CLOG_WRITE( "DMgrWrapper::SetDefaultAccessPointL" ); |
443 { |
471 DRMDEBUGLIT( KDuiBrApFormat, |
444 User::LeaveIfError(roapTrigger.Read(readBuf, KReadBufSize)); |
472 "CDrmUtilityDmgrWrapper::SetDefaultAccessPointL %d" ); |
445 iTriggerBuf->Des().Append(readBuf); |
473 DRMDEBUGLIT( KDuiBrApFormat2, " KBrowserDefaultAccessPoint = %d" ); |
446 } |
474 DRMDEBUGLIT( KDuiBrApFormat3, " KBrowserAccessPointSelectionMode = %d" ); |
447 |
475 DRMDEBUGLIT( KDuiBrApFormat4, " KBrowserNGDefaultSnapId = %d" ); |
448 // And let ROAP handle it... |
476 |
449 CleanupStack::PopAndDestroy(&readBuf); |
477 repository = CRepository::NewL( KCRUidBrowser ); |
450 CleanupStack::PopAndDestroy(&roapTrigger); |
478 CleanupStack::PushL( repository ); |
451 CleanupStack::PopAndDestroy(download); |
479 repository->Get( KBrowserDefaultAccessPoint, ap ); |
452 |
480 repository->Get( KBrowserAccessPointSelectionMode, alwaysAsk ); |
453 iFs.Delete(*iFileName); |
481 repository->Get( KBrowserNGDefaultSnapId, defaultSnap ); |
454 delete iFileName; |
482 DRMDEBUG2( KDuiBrApFormat(), __LINE__ ); |
455 iFileName = NULL; |
483 DRMDEBUG2( KDuiBrApFormat2(), ap ); |
456 if (iUseCoeEnv && iProgressInfo) |
484 DRMDEBUG2( KDuiBrApFormat3(), alwaysAsk ); |
457 { |
485 DRMDEBUG2( KDuiBrApFormat4(), defaultSnap ); |
458 iProgressInfo->IncrementAndDraw(KProgressInfoIncrementMedium); |
486 |
459 } |
487 if ( ap <= KErrNotFound && defaultSnap <= KErrNotFound ) |
460 |
488 { |
461 CompleteToState(aNextState, KErrNone); |
489 alwaysAsk = ETrue; |
462 } |
490 } |
463 |
491 else |
464 // --------------------------------------------------------------------------- |
492 { |
465 // CDrmUtilityDmgrWrapper::DoHandleRoapTriggerL |
493 RCmManager cmManager; |
466 // --------------------------------------------------------------------------- |
494 cmManager.OpenLC(); |
467 // |
495 if ( !alwaysAsk ) |
468 void CDrmUtilityDmgrWrapper::DoHandleRoapTriggerL(TDownloadState aNextState) |
496 { |
469 { |
497 TRAP( err, iapd32 = cmManager.GetConnectionMethodInfoIntL( |
470 Roap::TTriggerType triggerType; |
498 ap, CMManager::ECmIapId ) ); |
471 Roap::TRiContextStatus contextStatus; |
499 } |
472 Roap::TDomainOperation domainOperation; |
500 else if ( alwaysAsk == KDestinationSelectionMode ) |
473 |
501 { |
474 RPointerArray<HBufC8> contentIds; |
502 TRAP( err, iapd32 = |
475 CleanupResetAndDestroyPushL( contentIds ); |
503 IapIdOfDefaultSnapL( cmManager, defaultSnap ) ); |
476 |
504 } |
477 iRoapEng = Roap::CRoapEng::NewL(); |
505 CleanupStack::PopAndDestroy( &cmManager ); |
478 |
506 } |
479 iRoapEng->SetTriggerL(*iTriggerBuf, NULL, triggerType, contextStatus, |
507 if ( !err && ( !alwaysAsk || alwaysAsk == KDestinationSelectionMode ) ) |
480 domainOperation, contentIds); |
508 { |
481 |
509 err = iDlMgr.SetIntAttribute( EDlMgrIap, iapd32 ); |
482 CleanupStack::PopAndDestroy(&contentIds); |
510 } |
483 |
511 CleanupStack::PopAndDestroy( repository ); |
484 iRoapEng->AcceptL(this, &iStatus); |
512 } |
485 iState = aNextState; |
513 |
486 SetActive(); |
514 |
487 } |
515 // --------------------------------------------------------------------------- |
488 |
516 // CDrmUtilityDmgrWrapper::GetErrorUrlL |
489 // --------------------------------------------------------------------------- |
517 // --------------------------------------------------------------------------- |
490 // CDrmUtilityDmgrWrapper::CompleteToState |
518 // |
491 // --------------------------------------------------------------------------- |
519 HBufC8* CDrmUtilityDmgrWrapper::GetErrorUrlL() |
492 // |
520 { |
493 void CDrmUtilityDmgrWrapper::CompleteToState( |
521 if( iErrorUrl ) |
494 CDrmUtilityDmgrWrapper::TDownloadState aNextState, TInt aError) |
522 { |
495 { |
523 return iErrorUrl->AllocL(); |
496 iState = aNextState; |
524 } |
497 TRequestStatus* ownStatus(&iStatus); |
525 return NULL; |
498 User::RequestComplete(ownStatus, aError); |
526 } |
499 SetActive(); |
527 |
500 } |
528 |
501 |
|
502 // MHttpDownloadMgrObserver methods |
529 // --------------------------------------------------------------------------- |
503 // --------------------------------------------------------------------------- |
530 // From class MHttpDownloadMgrObserver |
504 // From class MHttpDownloadMgrObserver |
531 // |
505 // |
532 // CDrmUtilityDmgrWrapper::HandleDMgrEventL |
506 // CDrmUtilityDmgrWrapper::HandleDMgrEventL |
533 // --------------------------------------------------------------------------- |
507 // --------------------------------------------------------------------------- |
534 // |
508 // |
535 void CDrmUtilityDmgrWrapper::HandleDMgrEventL( |
509 void CDrmUtilityDmgrWrapper::HandleDMgrEventL(RHttpDownload& aDownload, |
536 RHttpDownload& aDownload, |
510 THttpDownloadEvent aEvent) |
537 THttpDownloadEvent aEvent ) |
|
538 { |
511 { |
539 _LIT8( KDrmUtilityMimeTypeROAPTrigger, |
512 _LIT8( KDrmUtilityMimeTypeROAPTrigger, |
540 "application/vnd.oma.drm.roap-trigger+xml" ); |
513 "application/vnd.oma.drm.roap-trigger+xml" ); |
541 |
514 |
542 CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL" ); |
515 |
543 CLOG_WRITE_FORMAT( "iDownLoadState = %d", aEvent.iDownloadState ); |
516 |
544 CLOG_WRITE_FORMAT( "iProgressState = %d", aEvent.iProgressState ); |
517 if (aEvent.iProgressState == EHttpContentTypeReceived) |
545 |
|
546 if ( aEvent.iProgressState == EHttpContentTypeReceived ) |
|
547 { |
518 { |
548 // check received mimetype |
519 // check received mimetype |
549 RBuf8 contentType; |
520 RBuf8 contentType; |
550 contentType.CleanupClosePushL(); |
521 contentType.CleanupClosePushL(); |
551 contentType.CreateL( KMaxContentTypeLength ); |
522 contentType.CreateL(KMaxContentTypeLength); |
552 User::LeaveIfError( |
523 User::LeaveIfError(aDownload.GetStringAttribute(EDlAttrContentType, |
553 aDownload.GetStringAttribute( EDlAttrContentType, contentType ) ); |
524 contentType)); |
554 if ( !contentType.FindF( KDrmUtilityMimeTypeROAPTrigger ) ) |
525 if (!contentType.FindF(KDrmUtilityMimeTypeROAPTrigger)) |
555 { |
526 { |
556 // ROAP trigger found, continue download |
527 // ROAP trigger found, continue download |
557 User::LeaveIfError( aDownload.Start() ); |
528 User::LeaveIfError(aDownload.Start()); |
558 } |
529 } |
559 else |
530 else |
560 { |
531 { |
561 // wrong MIME type, so stop download |
532 // wrong MIME type, so stop download |
562 iDownloadSuccess = EFalse; |
533 iDownloadSuccess = EFalse; |
563 User::LeaveIfError( aDownload.Delete() ); |
534 User::LeaveIfError(aDownload.Delete()); |
564 } |
535 } |
565 CleanupStack::PopAndDestroy( &contentType ); |
536 CleanupStack::PopAndDestroy(&contentType); |
566 } |
537 } |
567 |
538 |
568 if ( aEvent.iDownloadState == EHttpDlCreated ) |
539 if (aEvent.iDownloadState == EHttpDlCreated) |
569 { |
540 { |
570 CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpDlCreated" ); |
541 CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpDlCreated" ); |
571 if ( iUseCoeEnv ) |
542 if (iUseCoeEnv && iProgressInfo) |
572 { |
543 { |
573 iProgressInfo->IncrementAndDraw( KProgressInfoIncrementMedium ); |
544 iProgressInfo->IncrementAndDraw(KProgressInfoIncrementMedium); |
574 } |
545 } |
575 } |
546 } |
576 else if ( aEvent.iProgressState == EHttpProgDisconnected ) |
547 else if (aEvent.iProgressState == EHttpProgDisconnected) |
577 { |
548 { |
578 CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpProgDisconnected" ); |
549 CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpProgDisconnected" ); |
|
550 |
579 // store failure |
551 // store failure |
580 iDownloadSuccess = EFalse; |
552 iDownloadSuccess = EFalse; |
581 iConnectionError = ETrue; |
553 iConnectionError = ETrue; |
582 // finished |
554 // finished |
583 iWait.AsyncStop(); |
555 } |
584 } |
556 else if (aEvent.iDownloadState == EHttpDlInprogress) |
585 else if ( aEvent.iDownloadState == EHttpDlInprogress ) |
|
586 { |
557 { |
587 CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpDlInprogress" ); |
558 CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpDlInprogress" ); |
588 if ( iUseCoeEnv ) |
559 if (iUseCoeEnv) |
589 { |
560 { |
590 iProgressInfo->IncrementAndDraw( KProgressInfoIncrementSmall ); |
561 iProgressInfo->IncrementAndDraw(KProgressInfoIncrementSmall); |
591 } |
562 } |
592 } |
563 } |
593 else if ( aEvent.iDownloadState == EHttpDlCompleted ) |
564 else if (aEvent.iDownloadState == EHttpDlCompleted) |
594 { |
565 { |
595 // store success |
566 // store success |
596 CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpDlCompleted" ); |
567 CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpDlCompleted" ); |
597 iDownloadSuccess = ETrue; |
568 iDownloadSuccess = ETrue; |
598 if ( iUseCoeEnv ) |
569 iConnectionError = EFalse; |
599 { |
570 if (iUseCoeEnv) |
600 iProgressInfo->IncrementAndDraw( KProgressInfoIncrementLarge ); |
571 { |
|
572 iProgressInfo->IncrementAndDraw(KProgressInfoIncrementLarge); |
601 } |
573 } |
602 // finished |
574 // finished |
603 iWait.AsyncStop(); |
575 TRequestStatus* status(&iStatus); |
604 } |
576 User::RequestComplete(status, KErrNone); |
605 else if ( aEvent.iDownloadState == EHttpDlFailed ) |
577 } |
606 { |
578 else if (aEvent.iDownloadState == EHttpDlFailed) |
607 TInt32 err( KErrNone ); |
579 { |
|
580 TInt32 err(KErrNone); |
608 |
581 |
609 CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpDlFailed" ); |
582 CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpDlFailed" ); |
610 // store failure |
583 // store failure |
611 iDownloadSuccess = EFalse; |
584 iDownloadSuccess = EFalse; |
612 User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrErrorId, err ) ); |
585 User::LeaveIfError(aDownload.GetIntAttribute(EDlAttrErrorId, err)); |
613 CLOG_WRITE_FORMAT( "EDlAttrErrorId = %d", err ); |
586 CLOG_WRITE_FORMAT( "EDlAttrErrorId = %d", err ); |
614 |
587 |
615 if ( err == EConnectionFailed || |
588 if (err == EConnectionFailed || err == ETransactionFailed) |
616 err == ETransactionFailed) |
|
617 { |
589 { |
618 CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EConnectionFailed" ); |
590 CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EConnectionFailed" ); |
619 iConnectionError = ETrue; |
591 iConnectionError = ETrue; |
620 } |
592 } |
621 |
593 User::LeaveIfError(aDownload.Delete()); // remove useless download |
|
594 User::LeaveIfError(iDlMgr.Disconnect()); // disconnects Dmgr instantly. |
622 // finished |
595 // finished |
623 iWait.AsyncStop(); |
596 TRequestStatus* status(&iStatus); |
624 } |
597 if ( iConnection->HasMoreConnectionAttempts() ) |
625 } |
598 { |
626 |
599 iState = EInit; // re-try with another conection |
|
600 User::RequestComplete(status, KErrNone); |
|
601 } |
|
602 else |
|
603 { |
|
604 User::RequestComplete(status, KErrCancel); |
|
605 } |
|
606 } |
|
607 } |
627 |
608 |
628 // --------------------------------------------------------------------------- |
609 // --------------------------------------------------------------------------- |
629 // CDrmUtilityDmgrWrapper::ShowProgressNoteL |
610 // CDrmUtilityDmgrWrapper::ShowProgressNoteL |
630 // --------------------------------------------------------------------------- |
611 // --------------------------------------------------------------------------- |
631 // |
612 // |
632 void CDrmUtilityDmgrWrapper::ShowProgressNoteL() |
613 void CDrmUtilityDmgrWrapper::ShowProgressNoteL() |
633 { |
614 { |
634 TFileName resFileName; |
615 DRM::CFileNameContainer* resFileName(NULL); |
635 |
616 |
636 CLOG_WRITE( "DMgrWrapper::ShowProgressNoteL" ); |
617 CLOG_WRITE( "DMgrWrapper::ShowProgressNoteL" ); |
637 if ( iUseCoeEnv ) |
618 if (iUseCoeEnv) |
638 { |
619 { |
639 // Initialize the progress note dialog, it's values, |
620 // Initialize the progress note dialog, it's values, |
640 // and execute it |
621 // and execute it |
|
622 resFileName=DRM::CFileNameContainer::NewLC(); |
641 #ifndef RD_MULTIPLE_DRIVE |
623 #ifndef RD_MULTIPLE_DRIVE |
642 |
624 |
643 resFileName.Copy( KDriveZ ); |
625 resFileName->iBuffer.Copy( KDriveZ ); |
644 |
626 |
645 #else //RD_MULTIPLE_DRIVE |
627 #else //RD_MULTIPLE_DRIVE |
646 |
628 TInt driveNumber(-1); |
647 TInt driveNumber( -1 ); |
|
648 TChar driveLetter; |
629 TChar driveLetter; |
649 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber ); |
630 DriveInfo::GetDefaultDrive(DriveInfo::EDefaultRom, driveNumber); |
650 |
631 |
651 iCoeEnv->FsSession().DriveToChar( driveNumber, driveLetter ); |
632 iCoeEnv->FsSession().DriveToChar(driveNumber, driveLetter); |
652 |
633 |
653 resFileName.Format( KRomDriveFormatter, (TUint)driveLetter ); |
634 resFileName->iBuffer.Format(KRomDriveFormatter, (TUint) driveLetter); |
654 |
635 |
655 #endif |
636 #endif |
656 |
637 |
657 resFileName.Append( KDC_RESOURCE_FILES_DIR ); |
638 resFileName->iBuffer.Append(KDC_RESOURCE_FILES_DIR); |
658 resFileName.Append( KCDrmUtilityDmgrWrapperResFileName ); |
639 resFileName->iBuffer.Append(KCDrmUtilityDmgrWrapperResFileName); |
659 RConeResourceLoader loader( *iCoeEnv ); |
640 RConeResourceLoader loader(*iCoeEnv); |
660 loader.OpenL( resFileName ); |
641 loader.OpenL(resFileName->iBuffer); |
|
642 CleanupStack::PopAndDestroy( resFileName ); |
|
643 resFileName=NULL; |
661 |
644 |
662 iProgressNoteDialog = new (ELeave) CAknProgressDialog( |
645 iProgressNoteDialog = new (ELeave) CAknProgressDialog( |
663 reinterpret_cast< CEikDialog** >( &iProgressNoteDialog ) ); |
646 reinterpret_cast<CEikDialog**> (&iProgressNoteDialog)); |
664 iProgressNoteDialog->PrepareLC( R_SILENT_PROGRESS_NOTE ); |
647 iProgressNoteDialog->PrepareLC(R_SILENT_PROGRESS_NOTE); |
665 iProgressNoteDialog->SetCallback( this ); |
648 iProgressNoteDialog->SetCallback(this); |
666 iProgressInfo = iProgressNoteDialog->GetProgressInfoL(); |
649 iProgressInfo = iProgressNoteDialog->GetProgressInfoL(); |
667 iProgressInfo->SetFinalValue( KProgressInfoFinalValue ); |
650 iProgressInfo->SetFinalValue(KProgressInfoFinalValue); |
668 iDialogDismissed = EFalse; |
651 iDialogDismissed = EFalse; |
669 iProgressNoteDialog->RunLD(); |
652 iProgressNoteDialog->RunLD(); |
670 |
653 |
671 loader.Close(); |
654 loader.Close(); |
672 } |
655 } |
673 |
656 |
674 } |
657 } |
675 |
658 |
676 |
|
677 // --------------------------------------------------------------------------- |
659 // --------------------------------------------------------------------------- |
678 // CDrmUtilityDmgrWrapper::RemoveProgressNoteL |
660 // CDrmUtilityDmgrWrapper::RemoveProgressNoteL |
679 // --------------------------------------------------------------------------- |
661 // --------------------------------------------------------------------------- |
680 // |
662 // |
681 void CDrmUtilityDmgrWrapper::RemoveProgressNoteL() |
663 void CDrmUtilityDmgrWrapper::RemoveProgressNoteL() |
682 { |
664 { |
683 |
665 |
684 if ( iUseCoeEnv ) |
666 if (iUseCoeEnv) |
685 { |
667 { |
686 if (iProgressNoteDialog && !iDialogDismissed) |
668 if (iProgressNoteDialog && !iDialogDismissed) |
687 { |
669 { |
688 // deletes the dialog |
670 // deletes the dialog |
689 TRAPD(err, iProgressNoteDialog->ProcessFinishedL()); |
671 TRAPD(err, iProgressNoteDialog->ProcessFinishedL()); |
690 if (err != KErrNone) |
672 if (err != KErrNone) |
691 { |
673 { |
|
674 iProgressNoteDialog->SetCallback(NULL); |
692 delete iProgressNoteDialog; |
675 delete iProgressNoteDialog; |
|
676 iDialogDismissed = ETrue; |
693 } |
677 } |
694 iProgressNoteDialog = NULL; |
678 iProgressNoteDialog = NULL; |
695 } |
679 } |
696 } |
680 } |
697 |
681 } |
698 } |
|
699 |
|
700 |
682 |
701 // --------------------------------------------------------------------------- |
683 // --------------------------------------------------------------------------- |
702 // From class MAknProgressDialogCallback |
684 // From class MAknProgressDialogCallback |
703 // |
685 // |
704 // CDrmUtilityDmgrWrapper::DialogDismissedL |
686 // CDrmUtilityDmgrWrapper::DialogDismissedL |
705 // --------------------------------------------------------------------------- |
687 // --------------------------------------------------------------------------- |
706 // |
688 // |
707 void CDrmUtilityDmgrWrapper::DialogDismissedL( TInt /*aButtonId*/ ) |
689 void CDrmUtilityDmgrWrapper::DialogDismissedL(TInt aButtonId ) |
708 { |
690 { |
709 iDialogDismissed = ETrue; |
691 iDialogDismissed = ETrue; |
710 |
692 |
711 // Already freed, just set to NULL |
693 // Already freed, just set to NULL |
712 iProgressNoteDialog = NULL; |
694 iProgressNoteDialog = NULL; |
713 iProgressInfo = NULL; |
695 iProgressInfo = NULL; |
714 |
696 |
715 if( iWait.IsStarted() ) |
697 if (IsActive() && aButtonId == EAknSoftkeyCancel) |
|
698 { |
|
699 if ((iState == EGetMeteringTrigger || iState == EGetPrUrlTrigger)) |
|
700 { |
|
701 Cancel(); |
|
702 } |
|
703 else |
|
704 { |
|
705 TRequestStatus* status(&iStatus); |
|
706 User::RequestComplete(status, KErrCancel); |
|
707 } |
|
708 } |
|
709 //For avoiding active object deadlock |
|
710 iDlMgr.DeleteAll(); |
|
711 |
|
712 } |
|
713 |
|
714 // RoapObserver methods |
|
715 |
|
716 // --------------------------------------------------------------------------- |
|
717 // CDrmUtilityDmgrWrapper::PostResponseUrlL |
|
718 // --------------------------------------------------------------------------- |
|
719 // |
|
720 void CDrmUtilityDmgrWrapper::PostResponseUrlL(const TDesC8& aPostResponseUrl) |
|
721 { |
|
722 UpdateBufferL<HBufC8, TDesC8> (iTriggerUrl, aPostResponseUrl); |
|
723 |
|
724 if (iUseCoeEnv && iProgressInfo) |
|
725 { |
|
726 iProgressInfo->IncrementAndDraw(KProgressInfoIncrementMedium); |
|
727 } |
|
728 } |
|
729 |
|
730 // Trivial RoapObserver methods |
|
731 TBool CDrmUtilityDmgrWrapper::ConnectionConfL() |
|
732 { |
|
733 return ETrue; |
|
734 } |
|
735 |
|
736 TBool CDrmUtilityDmgrWrapper::ContactRiConfL() |
|
737 { |
|
738 return ETrue; |
|
739 } |
|
740 |
|
741 TBool CDrmUtilityDmgrWrapper::TransIdConfL() |
|
742 { |
|
743 return EFalse; |
|
744 } |
|
745 |
|
746 void CDrmUtilityDmgrWrapper::RightsObjectDetailsL(const RPointerArray< |
|
747 CDRMRights>& /*aRightsList*/) |
|
748 { |
|
749 // do nothing |
|
750 } |
|
751 |
|
752 void CDrmUtilityDmgrWrapper::ContentDownloadInfoL(TPath& /*aTempFolder*/, |
|
753 TFileName& /*aContentName*/, TInt& aMaxSize) |
|
754 { |
|
755 aMaxSize = -1; |
|
756 } |
|
757 |
|
758 void CDrmUtilityDmgrWrapper::ContentDetailsL(const TDesC& /*aPath*/, |
|
759 const TDesC8& /*aType*/, const TUid& /*aAppUid*/) |
|
760 { |
|
761 } |
|
762 |
|
763 void CDrmUtilityDmgrWrapper::RoapProgressInfoL(const TInt /*aProgressInfo*/) |
|
764 { |
|
765 // do nothing |
|
766 } |
|
767 |
|
768 void CDrmUtilityDmgrWrapper::ErrorUrlL(const TDesC8& aErrorUrl) |
|
769 { |
|
770 UpdateBufferL<HBufC8, TDesC8> (iErrorUrl, aErrorUrl); |
|
771 } |
|
772 |
|
773 // CActive methods |
|
774 |
|
775 // --------------------------------------------------------------------------- |
|
776 // CDrmUtilityDmgrWrapper::DoCancel |
|
777 // --------------------------------------------------------------------------- |
|
778 // |
|
779 void CDrmUtilityDmgrWrapper::DoCancel() |
|
780 { |
|
781 delete iRoapEng; |
|
782 iRoapEng = NULL; |
|
783 iConnection->Close(); |
|
784 if (iWait.IsStarted()) |
716 { |
785 { |
717 iWait.AsyncStop(); |
786 iWait.AsyncStop(); |
718 } |
787 } |
719 |
788 } |
720 } |
789 |
721 |
790 // --------------------------------------------------------------------------- |
722 |
791 // CDrmUtilityDmgrWrapper::RunL |
|
792 // --------------------------------------------------------------------------- |
|
793 // |
|
794 void CDrmUtilityDmgrWrapper::RunL() |
|
795 { |
|
796 TInt error(iStatus.Int()); |
|
797 |
|
798 ClearIfNotRoapTemporaryError(error, iErrorUrl); |
|
799 User::LeaveIfError(error); |
|
800 switch (iState) |
|
801 { |
|
802 case EInit: |
|
803 { |
|
804 if (!iProgressNoteDialog) |
|
805 { |
|
806 ShowProgressNoteL(); |
|
807 } |
|
808 DoConnectL(EGetMeteringTrigger); |
|
809 } |
|
810 break; |
|
811 case EGetMeteringTrigger: |
|
812 { |
|
813 DoDownloadRoapTriggerL(ESaveMeteringTrigger); |
|
814 } |
|
815 break; |
|
816 case ESaveMeteringTrigger: |
|
817 { |
|
818 DoSaveRoapTriggerL(EMeteringReportSubmit); |
|
819 } |
|
820 break; |
|
821 |
|
822 case EMeteringReportSubmit: |
|
823 { |
|
824 DoHandleRoapTriggerL(EGetPrUrlTrigger); |
|
825 } |
|
826 break; |
|
827 case EGetPrUrlTrigger: |
|
828 { |
|
829 delete iRoapEng; |
|
830 iRoapEng = NULL; |
|
831 DoDownloadRoapTriggerL(ESavePrUrlTrigger); |
|
832 } |
|
833 break; |
|
834 case ESavePrUrlTrigger: |
|
835 { |
|
836 DoSaveRoapTriggerL(EPrRoapRequest); |
|
837 } |
|
838 break; |
|
839 case EPrRoapRequest: |
|
840 { |
|
841 DoHandleRoapTriggerL(EComplete); |
|
842 } |
|
843 break; |
|
844 case EComplete: |
|
845 { |
|
846 RemoveProgressNoteL(); |
|
847 delete iRoapEng; |
|
848 iRoapEng = NULL; |
|
849 iWait.AsyncStop(); |
|
850 } |
|
851 break; |
|
852 |
|
853 default: |
|
854 User::Leave(KErrNotSupported); |
|
855 } |
|
856 } |
|
857 |
|
858 // --------------------------------------------------------------------------- |
|
859 // CDrmUtilityDmgrWrapper::RunError |
|
860 // --------------------------------------------------------------------------- |
|
861 // |
|
862 TInt CDrmUtilityDmgrWrapper::RunError(TInt /* aError */) |
|
863 { |
|
864 delete iRoapEng; |
|
865 iRoapEng = NULL; |
|
866 iConnection->Close(); |
|
867 if (iWait.IsStarted()) |
|
868 { |
|
869 iWait.AsyncStop(); |
|
870 } |
|
871 |
|
872 if (iUseCoeEnv) |
|
873 { |
|
874 if (iProgressNoteDialog && !iDialogDismissed) |
|
875 { |
|
876 iProgressNoteDialog->SetCallback(NULL); |
|
877 delete iProgressNoteDialog; |
|
878 iDialogDismissed = ETrue; |
|
879 } |
|
880 iProgressNoteDialog = NULL; |
|
881 } |
|
882 return KErrNone; |
|
883 } |
723 // ======== GLOBAL FUNCTIONS ======== |
884 // ======== GLOBAL FUNCTIONS ======== |
724 |
885 |
725 //------------------------------------------------------------------------------ |
886 //------------------------------------------------------------------------------ |
726 // GateFunctionDRM |
887 // GateFunctionDRM |
727 // DRM gate function |
888 // DRM gate function |
728 //------------------------------------------------------------------------------ |
889 //------------------------------------------------------------------------------ |
729 EXPORT_C TAny* GateFunctionDMgr() |
890 EXPORT_C TAny* GateFunctionDMgr() |
730 { |
891 { |
731 CDrmUtilityDmgrWrapper* launcher = NULL; |
892 CDrmUtilityDmgrWrapper* launcher = NULL; |
732 TRAPD( err, launcher = CDrmUtilityDmgrWrapper::NewL() ); |
893 TRAPD( err, launcher = CDrmUtilityDmgrWrapper::NewL() ); |
733 if( err != KErrNone ) |
894 if (err != KErrNone) |
734 { |
895 { |
735 return NULL; |
896 return NULL; |
736 } |
897 } |
737 |
898 |
738 return launcher; |
899 return launcher; |