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