|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Class for handling mpx collection interactions* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #include <bldvariant.hrh> |
|
21 #include "IptvDebug.h" |
|
22 #include "CIptvUtil.h" |
|
23 #include <mpxcollectionutility.h> |
|
24 #include <mpxmediacontainerdefs.h> |
|
25 #include <mpxmediageneraldefs.h> |
|
26 #include <mpxmessagegeneraldefs.h> |
|
27 #include <mpxcollectionmessagedefs.h> |
|
28 #include <mpxcollectionpath.h> |
|
29 #include <mpxmessage2.h> |
|
30 #include <mpxcollectionmessage.h> |
|
31 #include <mpxlog.h> |
|
32 #include <mpxitemid.h> |
|
33 #include <mpxmessagecontainerdefs.h> |
|
34 #include <vcxmyvideosdefs.h> |
|
35 #include <vcxmyvideosuids.h> |
|
36 #include <mpxcommandgeneraldefs.h> |
|
37 #include <mpxcollectioncommanddefs.h> |
|
38 #include <HttpDownloadMgrCommon.h> |
|
39 #include <mmf/common/mmfcontrollerpluginresolver.h> |
|
40 |
|
41 #include "vcnsscheduleddownloadmpxclient.h" |
|
42 #include "CIptvVodContentContentFullDetails.h" |
|
43 #include "CIptvMyVideosGlobalFileId.h" |
|
44 #include "CIptvVodDlDownloadEvent.h" |
|
45 #include "CIptvVodContentClient.h" |
|
46 #include "CIptvMediaContent.h" |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CVcxNsScheduledDownloadMpxClient::CVcxNsScheduledDownloadMpxClient( |
|
53 MVcxNsMpxClientObserver& aObserver, |
|
54 CIptvVodContentClient& aContentClient, |
|
55 TUint32 aServiceId ) : |
|
56 iObserver( aObserver ), |
|
57 iContentClient( aContentClient ), |
|
58 iServiceId( aServiceId ) |
|
59 { |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CVcxNsScheduledDownloadMpxClient* CVcxNsScheduledDownloadMpxClient::NewL( |
|
67 MVcxNsMpxClientObserver& aObserver, |
|
68 CIptvVodContentClient& aContentClient, |
|
69 TUint32 aServiceId ) |
|
70 { |
|
71 CVcxNsScheduledDownloadMpxClient* self = |
|
72 new (ELeave) CVcxNsScheduledDownloadMpxClient( aObserver, aContentClient, aServiceId ); |
|
73 |
|
74 CleanupStack::PushL( self ); |
|
75 self->ConstructL(); |
|
76 CleanupStack::Pop( self ); |
|
77 |
|
78 return self; |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CVcxNsScheduledDownloadMpxClient::ConstructL() |
|
86 { |
|
87 iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeDefault ); |
|
88 |
|
89 CMPXCollectionPath* path = CMPXCollectionPath::NewL(); |
|
90 CleanupStack::PushL( path ); |
|
91 path->AppendL( KVcxUidMyVideosMpxCollection ); |
|
92 iCollectionUtility->Collection().OpenL( *path ); |
|
93 CleanupStack::PopAndDestroy( path ); |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 CVcxNsScheduledDownloadMpxClient::~CVcxNsScheduledDownloadMpxClient() |
|
101 { |
|
102 if( iCollectionUtility ) |
|
103 { |
|
104 iCollectionUtility->Close(); |
|
105 } |
|
106 |
|
107 iDownloadedContents.ResetAndDestroy(); |
|
108 iDownloadedMedias.ResetAndDestroy(); |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 TIptvDlError CVcxNsScheduledDownloadMpxClient::DownloadL( TUint32 aIapId, |
|
116 CIptvService* aService, |
|
117 TIptvContentId aContentId, |
|
118 const TDesC& aName ) |
|
119 { |
|
120 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::DownloadL(s,c) IN"); |
|
121 |
|
122 CIptvMediaContent* content = NULL; |
|
123 RPointerArray<CIptvMediaContent> calist; |
|
124 CleanupResetAndDestroyPushL( calist ); |
|
125 |
|
126 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::DownloadL: get ca IN"); |
|
127 |
|
128 TInt ret = iContentClient.GetContentAccessListL( aContentId, calist ); |
|
129 |
|
130 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::DownloadL get ca OUT"); |
|
131 |
|
132 TInt i( 0 ); |
|
133 |
|
134 for( i = 0; i < calist.Count() && ret == KErrNone; i++ ) |
|
135 { |
|
136 TUint32 type = ( calist[i] )->iDownloadType; |
|
137 TUint32 expr = ( calist[i] )->iExpression; |
|
138 |
|
139 if( expr == CIptvMediaContent::EFull && type == EIptvDownloadTypeImmediate ) |
|
140 { |
|
141 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::DownloadL ca found"); |
|
142 content = calist[i]; |
|
143 break; |
|
144 } |
|
145 } |
|
146 |
|
147 if( ret == KErrNone && content && content->GetMediaContentUrl().Length() > 0 ) |
|
148 { |
|
149 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::DownloadL calling dl( ph.2 )"); |
|
150 |
|
151 TPtrC url ( content->GetMediaContentUrl() ); |
|
152 TPtrC name( aName ); |
|
153 TPtrC usr ( aService->GetUserName() ); |
|
154 TPtrC pwd ( aService->GetPassword() ); |
|
155 |
|
156 IPTVLOGSTRING2_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::DownloadL url = %S", &url ); |
|
157 IPTVLOGSTRING2_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::DownloadL name = %S", &name ); |
|
158 IPTVLOGSTRING2_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::DownloadL usr = %S", &usr ); |
|
159 IPTVLOGSTRING2_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::DownloadL psw = %S", &pwd ); |
|
160 |
|
161 ret = DoDownloadL( url, |
|
162 name, |
|
163 aIapId, |
|
164 ETrue, |
|
165 usr, |
|
166 pwd ); |
|
167 |
|
168 if ( ret == KErrNone ) |
|
169 { |
|
170 // To the download list. Content from Mpx events |
|
171 // is resolved from the list. |
|
172 AppendToDownloadList( content ); |
|
173 |
|
174 // Dl list takes ownership of content. |
|
175 calist.Remove( i ); |
|
176 } |
|
177 } |
|
178 |
|
179 CleanupStack::PopAndDestroy( &calist ); |
|
180 |
|
181 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::DownloadL(s,c) OUT"); |
|
182 |
|
183 return ret == KErrNone ? EIptvDlNoError : EIptvDlGeneral; |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 // ----------------------------------------------------------------------------- |
|
189 // |
|
190 TInt CVcxNsScheduledDownloadMpxClient::DoDownloadL( const TDesC& aAddress, |
|
191 const TDesC& aName, |
|
192 TUint32 aIapId, |
|
193 TBool aIsReadOnlyIap, |
|
194 const TDesC& aUserName, |
|
195 const TDesC& aPassword ) |
|
196 { |
|
197 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::DoDownloadL() start"); |
|
198 |
|
199 CMPXCommand* cmd = CMPXCommand::NewL(); |
|
200 CleanupStack::PushL( cmd ); // 1-> |
|
201 |
|
202 cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos ); |
|
203 cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosStartDownload ); |
|
204 cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, EFalse /* = async */ ); |
|
205 |
|
206 TUid colId = TUid::Uid( KVcxUidMyVideosMpxCollection ); |
|
207 cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, colId.iUid ); |
|
208 |
|
209 CMPXMedia* startDownloadReq = CMPXMedia::NewL(); |
|
210 CleanupStack::PushL( startDownloadReq ); // 2-> |
|
211 |
|
212 TUint flags = ( aIsReadOnlyIap ? EVcxMyVideosServiceHasReadOnlyIap : 0 ) | EVcxMyVideosSilent; |
|
213 |
|
214 startDownloadReq->SetTObjectValueL( KMPXMediaGeneralFlags, flags ); |
|
215 |
|
216 if( aIsReadOnlyIap ) |
|
217 { |
|
218 startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, aIapId ); |
|
219 } |
|
220 else |
|
221 { |
|
222 // not a read only iap, set iap 0 so download utility |
|
223 // can select iap via connectionutility |
|
224 startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, 0 ); |
|
225 } |
|
226 |
|
227 startDownloadReq->SetTextValueL( KVcxMediaMyVideosRemoteUrl, aAddress ); |
|
228 startDownloadReq->SetTextValueL( KVcxMediaMyVideosUsername, aUserName ); |
|
229 startDownloadReq->SetTextValueL( KVcxMediaMyVideosPassword, aPassword ); |
|
230 startDownloadReq->SetTextValueL( KMPXMediaGeneralTitle, aName ); |
|
231 |
|
232 cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, startDownloadReq ); |
|
233 |
|
234 iCollectionUtility->Collection().CommandL( *cmd ); |
|
235 |
|
236 CleanupStack::PopAndDestroy( startDownloadReq ); // <-2 |
|
237 CleanupStack::PopAndDestroy( cmd ); // <-1 |
|
238 |
|
239 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::DoDownloadL() exit"); |
|
240 |
|
241 return KErrNone; |
|
242 } |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // |
|
246 // ----------------------------------------------------------------------------- |
|
247 // |
|
248 TInt CVcxNsScheduledDownloadMpxClient::CancelDownloadL( TUint32 aServiceId, |
|
249 TUint32 aContentId ) |
|
250 { |
|
251 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::CancelDownloadL IN"); |
|
252 |
|
253 TInt ret( KErrNone ); |
|
254 |
|
255 CMPXCommand* cmd = CMPXCommand::NewL(); |
|
256 CleanupStack::PushL( cmd ); |
|
257 |
|
258 cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos ); |
|
259 cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosCancelDownload ); |
|
260 cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, EFalse /* = async */ ); |
|
261 TUid colId = TUid::Uid( KVcxUidMyVideosMpxCollection ); |
|
262 cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, colId.iUid ); |
|
263 |
|
264 CMPXMedia* cancelDownloadReq = CMPXMedia::NewL(); |
|
265 CleanupStack::PushL( cancelDownloadReq ); |
|
266 |
|
267 CIptvMediaContent* content = SearchFromDownloadList( aServiceId, aContentId ); |
|
268 |
|
269 if( content ) |
|
270 { |
|
271 CMPXMedia* media = GetMpxMediaFromList( content->iFileId ); |
|
272 |
|
273 if( media ) |
|
274 { |
|
275 TUint32 downloadId = media->ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId ); |
|
276 cancelDownloadReq->SetTObjectValueL( KVcxMediaMyVideosDownloadId, downloadId ); |
|
277 |
|
278 TUint32 mediaId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ).iId1; |
|
279 cancelDownloadReq->SetTObjectValueL( KMPXMediaGeneralId, mediaId ); |
|
280 |
|
281 cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, cancelDownloadReq ); |
|
282 |
|
283 iCollectionUtility->Collection().CommandL( *cmd ); |
|
284 } |
|
285 } |
|
286 |
|
287 CleanupStack::PopAndDestroy( cancelDownloadReq ); |
|
288 CleanupStack::PopAndDestroy( cmd ); |
|
289 |
|
290 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::CancelDownloadL OUT"); |
|
291 |
|
292 return ret; |
|
293 } |
|
294 |
|
295 // ----------------------------------------------------------------------------- |
|
296 // |
|
297 // ----------------------------------------------------------------------------- |
|
298 // |
|
299 void CVcxNsScheduledDownloadMpxClient::HandleCollectionMediaL( const CMPXMedia& /*aMedia*/, |
|
300 TInt /*aError*/ ) |
|
301 { |
|
302 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::HandleCollectionMediaL"); |
|
303 } |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // CVcxNsScheduledDownloadMpxClient::HandleCollectionMessage |
|
307 // ----------------------------------------------------------------------------- |
|
308 // |
|
309 void CVcxNsScheduledDownloadMpxClient::HandleCollectionMessage( CMPXMessage* aMessage, |
|
310 TInt aError ) |
|
311 { |
|
312 TRAPD( err, ExplodeCollectionMessagesL( aMessage, aError ) ); |
|
313 |
|
314 if ( err != KErrNone ) |
|
315 { |
|
316 IPTVLOGSTRING2_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::ExplodeCollectionMessagesL() leaved with error code %d", err); |
|
317 } |
|
318 } |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // CVcxNsScheduledDownloadMpxClient::ExplodeCollectionMessagesL |
|
322 // ----------------------------------------------------------------------------- |
|
323 // |
|
324 void CVcxNsScheduledDownloadMpxClient::ExplodeCollectionMessagesL( CMPXMessage* aMessage, |
|
325 TInt aError ) |
|
326 { |
|
327 if ( !aMessage ) |
|
328 { |
|
329 return; |
|
330 } |
|
331 |
|
332 TInt cmdId = aMessage->ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ); |
|
333 TInt myVideosCmd = -1; |
|
334 |
|
335 if ( cmdId == KVcxCommandIdMyVideos ) |
|
336 { |
|
337 myVideosCmd = aMessage->ValueTObjectL<TInt>( KVcxMediaMyVideosCommandId ); |
|
338 } |
|
339 |
|
340 if ( myVideosCmd != KVcxMessageMyVideosMessageArray ) |
|
341 { |
|
342 HandleSingleCollectionMessageL( aMessage, aError ); |
|
343 } |
|
344 else |
|
345 { |
|
346 if ( aMessage->IsSupported( KMPXMessageArrayContents ) ) |
|
347 { |
|
348 const CMPXMessageArray* messageArray = |
|
349 aMessage->Value<CMPXMessageArray>(KMPXMessageArrayContents); |
|
350 |
|
351 if ( messageArray->Count() > 0 ) |
|
352 { |
|
353 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient:: ----------------------."); |
|
354 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient:: MESSAGE ARRAY ARRIVED |"); |
|
355 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient:: ----------------------'"); |
|
356 } |
|
357 |
|
358 for( TInt i = 0; i < messageArray->Count(); i++ ) |
|
359 { |
|
360 HandleSingleCollectionMessageL( messageArray->AtL( i ), aError ); |
|
361 } |
|
362 } |
|
363 } |
|
364 } |
|
365 |
|
366 // ----------------------------------------------------------------------------- |
|
367 // |
|
368 // ----------------------------------------------------------------------------- |
|
369 // |
|
370 void CVcxNsScheduledDownloadMpxClient::HandleSingleCollectionMessageL( CMPXMessage* aMsg, |
|
371 TInt aErr ) |
|
372 { |
|
373 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::HandleSingleCollectionMessageL IN"); |
|
374 |
|
375 #ifdef _DEBUG |
|
376 |
|
377 TMPXMessageId msgId = aMsg->ValueTObjectL<TMPXMessageId>(KMPXMessageGeneralId); |
|
378 TUid colId = aMsg->ValueTObjectL<TUid>(KMPXMessageCollectionId); |
|
379 TMPXChangeEventType type = aMsg->ValueTObjectL<TMPXChangeEventType>(KMPXMessageChangeEventType); |
|
380 TMPXItemId itemId = aMsg->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
|
381 TInt cmdId = aMsg->ValueTObjectL<TInt>( KVcxMediaMyVideosCommandId ); |
|
382 |
|
383 IPTVLOGSTRING2_HIGH_LEVEL( "UI Engine ## HandleSingleCollectionMessageL() : msgId = %d", msgId ); |
|
384 IPTVLOGSTRING2_HIGH_LEVEL( "UI Engine ## HandleSingleCollectionMessageL() : colId = %d", colId ); |
|
385 IPTVLOGSTRING2_HIGH_LEVEL( "UI Engine ## HandleSingleCollectionMessageL() : type = %d", type ); |
|
386 IPTVLOGSTRING2_HIGH_LEVEL( "UI Engine ## HandleSingleCollectionMessageL() : item Id = %d", itemId.iId1 ); |
|
387 IPTVLOGSTRING2_HIGH_LEVEL( "UI Engine ## HandleSingleCollectionMessageL() : aErr = %d", aErr ); |
|
388 IPTVLOGSTRING2_HIGH_LEVEL( "UI Engine ## HandleSingleCollectionMessageL() : cmd Id = %d", cmdId ); |
|
389 |
|
390 #endif // _DEBUG |
|
391 |
|
392 DoHandleSingleCollectionMessageL( aMsg, aErr ); |
|
393 |
|
394 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::HandleSingleCollectionMessage OUT"); |
|
395 } |
|
396 |
|
397 // ----------------------------------------------------------------------------- |
|
398 // |
|
399 // ----------------------------------------------------------------------------- |
|
400 // |
|
401 void CVcxNsScheduledDownloadMpxClient::HandleOpenL( const CMPXCollectionPlaylist& |
|
402 /*aPlaylist*/, TInt /*aError*/ ) |
|
403 { |
|
404 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::HandleOpenL( playlist )"); |
|
405 } |
|
406 |
|
407 // ----------------------------------------------------------------------------- |
|
408 // |
|
409 // ----------------------------------------------------------------------------- |
|
410 // |
|
411 void CVcxNsScheduledDownloadMpxClient::HandleOpenL( const CMPXMedia& /*aEntries*/, |
|
412 TInt /*aIndex*/, TBool /*aComplete*/, TInt /*aError*/ ) |
|
413 { |
|
414 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::HandleOpenL( aEntries )"); |
|
415 } |
|
416 |
|
417 // ----------------------------------------------------------------------------- |
|
418 // |
|
419 // ----------------------------------------------------------------------------- |
|
420 // |
|
421 void CVcxNsScheduledDownloadMpxClient::HandleCommandComplete( CMPXCommand* aCommandResult, |
|
422 TInt aError ) |
|
423 { |
|
424 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::HandleCommandComplete IN"); |
|
425 |
|
426 if( aError ) |
|
427 { |
|
428 IPTVLOGSTRING2_HIGH_LEVEL( "UI Engine ## HandleCommandComplete() aError = %d ", aError); |
|
429 } |
|
430 |
|
431 if( !aCommandResult ) |
|
432 { |
|
433 IPTVLOGSTRING_LOW_LEVEL( |
|
434 "CVcxNsScheduledDownloadMpxClient::HandleCommandComplete OUT, aResult == NULL"); |
|
435 return; |
|
436 } |
|
437 |
|
438 if( aCommandResult->IsSupported( KVcxMediaMyVideosTransactionId ) ) |
|
439 { |
|
440 TInt tid = aCommandResult->ValueTObjectL<TInt>( KVcxMediaMyVideosTransactionId ); |
|
441 |
|
442 IPTVLOGSTRING2_LOW_LEVEL( |
|
443 "CVcxNsScheduledDownloadMpxClient::HandleCommandComplete , trid == %d", tid ); |
|
444 } |
|
445 |
|
446 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::HandleCommandComplete OUT"); |
|
447 } |
|
448 |
|
449 // ----------------------------------------------------------------------------- |
|
450 // CVcxNsScheduledDownloadMpxClient::GetMediaByMpxIdReqL |
|
451 // ----------------------------------------------------------------------------- |
|
452 // |
|
453 void CVcxNsScheduledDownloadMpxClient::GetMediaByMpxIdReqL( RArray<TUint32>& aMpxIds ) |
|
454 { |
|
455 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::GetMediaByMpxIdReqL IN"); |
|
456 |
|
457 CMPXCommand* cmd = CMPXCommand::NewL(); |
|
458 CleanupStack::PushL( cmd ); |
|
459 |
|
460 cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos ); |
|
461 cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosGetMediasByMpxId ); |
|
462 TUid colId = TUid::Uid( KVcxUidMyVideosMpxCollection ); |
|
463 cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, colId.iUid ); |
|
464 |
|
465 CMPXMediaArray* idMediaArray = CMPXMediaArray::NewL(); |
|
466 CleanupStack::PushL( idMediaArray ); |
|
467 |
|
468 CMPXMedia* media; |
|
469 TMPXItemId mpxId; |
|
470 |
|
471 for ( TInt i = 0; i < aMpxIds.Count(); i++ ) |
|
472 { |
|
473 media = CMPXMedia::NewL(); |
|
474 CleanupStack::PushL( media ); |
|
475 |
|
476 mpxId.iId1 = aMpxIds[i]; |
|
477 mpxId.iId2 = 0; // Id2: 0 is a media object, 1 is a category. |
|
478 |
|
479 media->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId ); |
|
480 idMediaArray->AppendL( *media ); |
|
481 CleanupStack::PopAndDestroy( media ); |
|
482 } |
|
483 |
|
484 cmd->SetCObjectValueL<CMPXMediaArray>( KMPXMediaArrayContents, idMediaArray ); |
|
485 |
|
486 cmd->SetTObjectValueL( KMPXMediaArrayCount, idMediaArray->Count() ); |
|
487 |
|
488 iCollectionUtility->Collection().CommandL( *cmd ); |
|
489 |
|
490 CleanupStack::PopAndDestroy( idMediaArray ); |
|
491 CleanupStack::PopAndDestroy( cmd ); |
|
492 |
|
493 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::GetMediaByMpxIdReqL OUT"); |
|
494 } |
|
495 |
|
496 // ----------------------------------------------------------------------------- |
|
497 // CVcxNsScheduledDownloadMpxClient::LinkMediaObjectsL |
|
498 // ----------------------------------------------------------------------------- |
|
499 // |
|
500 void CVcxNsScheduledDownloadMpxClient::LinkMediaObjectsL( CMPXMediaArray* aArray ) |
|
501 { |
|
502 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::LinkMediaObjectsL IN"); |
|
503 |
|
504 if ( aArray ) |
|
505 { |
|
506 for ( TInt i = aArray->Count()-1; i >= 0; i-- ) |
|
507 { |
|
508 SearchAndAddMpxMediaL( (*aArray)[i] ); |
|
509 } |
|
510 } |
|
511 |
|
512 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::LinkMediaObjectsL OUT"); |
|
513 } |
|
514 |
|
515 // ----------------------------------------------------------------------------- |
|
516 // CVcxNsScheduledDownloadMpxClient::SearchAndAddMpxMediaL |
|
517 // ----------------------------------------------------------------------------- |
|
518 // |
|
519 void CVcxNsScheduledDownloadMpxClient::SearchAndAddMpxMediaL( CMPXMedia* aMedia ) |
|
520 { |
|
521 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::SearchAndAddMpxMediaL IN"); |
|
522 CIptvMediaContent* content = NULL; |
|
523 TBool newMedia( EFalse ); |
|
524 TUint32 mpxId = aMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ).iId1; |
|
525 TPtrC uri = aMedia->ValueText( KVcxMediaMyVideosRemoteUrl ); |
|
526 |
|
527 // search from dl first by mpx id |
|
528 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::SearchAndAddMpxMediaL: SearchFromDownloadList( mpxId )"); |
|
529 |
|
530 content = SearchFromDownloadList( mpxId ); |
|
531 |
|
532 if( !content ) |
|
533 { |
|
534 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::SearchAndAddMpxMediaL: SearchFromDownloadList( uri ) "); |
|
535 // Not found from dl list, this |
|
536 // is new media. search by uri. |
|
537 content = SearchFromDownloadList( uri ); |
|
538 newMedia = ETrue; |
|
539 } |
|
540 |
|
541 if( !content ) |
|
542 { |
|
543 return; |
|
544 } |
|
545 |
|
546 if( newMedia ) |
|
547 { |
|
548 //implement better way to store this. |
|
549 content->iFileId = mpxId; |
|
550 |
|
551 iDownloadedMedias.Append( CMPXMedia::NewL( *aMedia ) ); |
|
552 |
|
553 iContentClient.SetMpxIdL( content->iContentKey, content->iIndex, mpxId ); |
|
554 |
|
555 CopyEcgDataToMpxColL( content, aMedia ); |
|
556 } |
|
557 |
|
558 CheckMediaStateL( mpxId ); |
|
559 |
|
560 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::SearchAndAddMpxMediaL OUT"); |
|
561 } |
|
562 |
|
563 // ----------------------------------------------------------------------------- |
|
564 // CVcxNsScheduledDownloadMpxClient::CheckMediaStateL |
|
565 // ----------------------------------------------------------------------------- |
|
566 // |
|
567 void CVcxNsScheduledDownloadMpxClient::CheckMediaStateL( TUint32 aMediaId ) |
|
568 { |
|
569 CMPXMedia* media = GetMpxMediaFromList( aMediaId ); |
|
570 |
|
571 if( !media || !media->IsSupported( KVcxMediaMyVideosDownloadState ) ) |
|
572 { |
|
573 return; |
|
574 } |
|
575 |
|
576 CIptvMediaContent* content = SearchFromDownloadList( aMediaId ); |
|
577 |
|
578 if( !content ) |
|
579 { |
|
580 return; |
|
581 } |
|
582 |
|
583 TUint8 state = media->ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState ); |
|
584 |
|
585 CIptvVodDlDownloadEvent* event = CIptvVodDlDownloadEvent::NewL(); |
|
586 CleanupStack::PushL( event ); |
|
587 |
|
588 event->iEvent = CIptvVodDlDownloadEvent::EDownloadState; |
|
589 event->iServiceId = iServiceId; |
|
590 event->iContentId = content->iContentKey; |
|
591 |
|
592 switch ( state ) |
|
593 { |
|
594 case EVcxMyVideosDlStateDownloading: |
|
595 { |
|
596 event->iState = KIptvVodDlDownloadRunning; |
|
597 iObserver.HandleVodDlDownloadEvent( *event ); |
|
598 break; |
|
599 } |
|
600 case EVcxMyVideosDlStateFailed: |
|
601 { |
|
602 event->iState = KIptvVodDlDownloadFailed; |
|
603 iObserver.HandleVodDlDownloadEvent( *event ); |
|
604 RemoveFromDownloadList( content ); |
|
605 break; |
|
606 } |
|
607 case EVcxMyVideosDlStatePaused: |
|
608 { |
|
609 event->iState = KIptvVodDlDownloadPaused; |
|
610 iObserver.HandleVodDlDownloadEvent( *event ); |
|
611 RemoveFromDownloadList( content ); |
|
612 break; |
|
613 } |
|
614 case EVcxMyVideosDlStateDownloaded: |
|
615 { |
|
616 event->iState = KIptvVodDlDownloadSucceeded; |
|
617 iObserver.HandleVodDlDownloadEvent( *event ); |
|
618 RemoveFromDownloadList( content ); |
|
619 break; |
|
620 } |
|
621 default: |
|
622 { |
|
623 break; |
|
624 } |
|
625 } |
|
626 |
|
627 CleanupStack::PopAndDestroy( event ); |
|
628 } |
|
629 |
|
630 // ----------------------------------------------------------------------------- |
|
631 // CVcxNsScheduledDownloadMpxClient::AppendToDownloadList |
|
632 // ----------------------------------------------------------------------------- |
|
633 // |
|
634 void CVcxNsScheduledDownloadMpxClient::AppendToDownloadList( CIptvMediaContent* aContent ) |
|
635 { |
|
636 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::AppendToDownloadList"); |
|
637 |
|
638 iDownloadedContents.Append( aContent ); |
|
639 } |
|
640 |
|
641 // ----------------------------------------------------------------------------- |
|
642 // CVcxNsScheduledDownloadMpxClient::RemoveFromDownloadList |
|
643 // ----------------------------------------------------------------------------- |
|
644 // |
|
645 void CVcxNsScheduledDownloadMpxClient::RemoveFromDownloadList( CIptvMediaContent* aContent ) |
|
646 { |
|
647 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::RemoveFromDownloadList"); |
|
648 |
|
649 TInt index = iDownloadedContents.Find( aContent ); |
|
650 |
|
651 if( index >= 0 ) |
|
652 { |
|
653 CIptvMediaContent* p = iDownloadedContents[ index ]; |
|
654 iDownloadedContents.Remove( index ); |
|
655 delete p; |
|
656 } |
|
657 } |
|
658 |
|
659 // ----------------------------------------------------------------------------- |
|
660 // CVcxNsScheduledDownloadMpxClient::SearchFromDownloadList |
|
661 // ----------------------------------------------------------------------------- |
|
662 // |
|
663 CIptvMediaContent* CVcxNsScheduledDownloadMpxClient::SearchFromDownloadList( const TDesC& aUri ) |
|
664 { |
|
665 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::SearchFromDownloadList (aUri) IN"); |
|
666 |
|
667 for( TInt i = iDownloadedContents.Count()-1; i >= 0 ; i-- ) |
|
668 { |
|
669 TPtrC contentUri = TPtrC( (iDownloadedContents[i])->GetMediaContentUrl() ); |
|
670 |
|
671 if ( contentUri.CompareF( aUri ) == 0 ) |
|
672 { |
|
673 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::SearchFromDownloadList (aUri) OUT, content found"); |
|
674 return iDownloadedContents[i]; |
|
675 } |
|
676 } |
|
677 |
|
678 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::SearchFromDownloadList (aUri) OUT, not found"); |
|
679 |
|
680 return NULL; |
|
681 } |
|
682 |
|
683 // ----------------------------------------------------------------------------- |
|
684 // CVcxNsScheduledDownloadMpxClient::SearchFromDownloadList |
|
685 // ----------------------------------------------------------------------------- |
|
686 // |
|
687 CIptvMediaContent* CVcxNsScheduledDownloadMpxClient::SearchFromDownloadList( const TUint32 aMpxId ) |
|
688 { |
|
689 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::SearchFromDownloadList (aId) IN"); |
|
690 |
|
691 for( TInt i = iDownloadedContents.Count()-1; i >= 0 ; i-- ) |
|
692 { |
|
693 //should we store mpx ids to own array? |
|
694 TUint32 mpxId = ( iDownloadedContents[i] )->iFileId; |
|
695 |
|
696 if ( mpxId == aMpxId ) |
|
697 { |
|
698 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::SearchFromDownloadList (aId) OUT, found"); |
|
699 return iDownloadedContents[i]; |
|
700 } |
|
701 } |
|
702 |
|
703 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::SearchFromDownloadList (aId) OUT, not found"); |
|
704 |
|
705 return NULL; |
|
706 } |
|
707 |
|
708 // ----------------------------------------------------------------------------- |
|
709 // CVcxNsScheduledDownloadMpxClient::SearchFromDownloadList |
|
710 // ----------------------------------------------------------------------------- |
|
711 // |
|
712 CIptvMediaContent* CVcxNsScheduledDownloadMpxClient::SearchFromDownloadList( const TUint32 aServiceId, |
|
713 const TUint32 aContentId ) |
|
714 { |
|
715 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::SearchFromDownloadList (aId) IN"); |
|
716 |
|
717 for( TInt i = iDownloadedContents.Count()-1; i >= 0 ; i-- ) |
|
718 { |
|
719 if ( aServiceId == iServiceId && |
|
720 aContentId == iDownloadedContents[i]->iContentKey ) |
|
721 { |
|
722 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::SearchFromDownloadList (aId) OUT, found"); |
|
723 return iDownloadedContents[i]; |
|
724 } |
|
725 } |
|
726 |
|
727 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::SearchFromDownloadList (aId) OUT, not found"); |
|
728 |
|
729 return NULL; |
|
730 } |
|
731 |
|
732 // ----------------------------------------------------------------------------- |
|
733 // CVcxNsScheduledDownloadMpxClient::DoHandleSingleCollectionMessageL |
|
734 // ----------------------------------------------------------------------------- |
|
735 // |
|
736 void CVcxNsScheduledDownloadMpxClient::DoHandleSingleCollectionMessageL( CMPXMessage* aMsg, TInt aErr ) |
|
737 { |
|
738 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::DoHandleSingleCollectionMessageL IN"); |
|
739 |
|
740 if ( aMsg && aErr == KErrNone ) |
|
741 { |
|
742 TMPXMessageId mpxMsgId = *( aMsg->Value<TMPXMessageId>( KMPXMessageGeneralId ) ); |
|
743 TInt mpxCmdId = aMsg->ValueTObjectL<TInt>( KVcxMediaMyVideosCommandId ); |
|
744 |
|
745 if ( mpxMsgId == KMPXMessageGeneral ) |
|
746 { |
|
747 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::DoHandleSingleCollectionMessageL KMPXMessageGeneral"); |
|
748 } |
|
749 else if ( mpxMsgId == KMPXMessageIdItemChanged ) |
|
750 { |
|
751 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::DoHandleSingleCollectionMessageL: KMPXMessageIdItemChanged"); |
|
752 |
|
753 HandleMpxItemChangedL( aMsg, aErr ); |
|
754 } |
|
755 |
|
756 else if ( mpxCmdId == KVcxMessageMyVideosGetMediasByMpxIdResp ) |
|
757 { |
|
758 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::DoHandleSingleCollectionMessageL KVcxMessageMyVideosGetMediasByMpxIdResp"); |
|
759 CMPXMedia* entries = CMPXMedia::NewL( *aMsg ); |
|
760 CleanupStack::PushL( entries ); |
|
761 |
|
762 CMPXMediaArray* array = entries->Value<CMPXMediaArray>( KMPXMediaArrayContents ); |
|
763 |
|
764 LinkMediaObjectsL( array ); |
|
765 |
|
766 CleanupStack::PopAndDestroy( entries ); |
|
767 } |
|
768 } |
|
769 |
|
770 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::DoHandleSingleCollectionMessageL OUT"); |
|
771 } |
|
772 |
|
773 // ----------------------------------------------------------------------------- |
|
774 // |
|
775 // ----------------------------------------------------------------------------- |
|
776 // |
|
777 void CVcxNsScheduledDownloadMpxClient::HandleMpxItemChangedL( CMPXMessage* aMsg, TInt /*aErr*/ ) |
|
778 { |
|
779 TUid colId = aMsg->ValueTObjectL<TUid>(KMPXMessageCollectionId); |
|
780 TMPXChangeEventType type = aMsg->ValueTObjectL<TMPXChangeEventType>(KMPXMessageChangeEventType); |
|
781 |
|
782 if( colId.iUid == KVcxUidMyVideosMpxCollection ) |
|
783 { |
|
784 TMPXItemId itemId = aMsg->ValueTObjectL<TMPXItemId>( KMPXMessageMediaGeneralId ); |
|
785 |
|
786 if ( type == EMPXItemModified ) |
|
787 { |
|
788 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::HandleCollectionMessageL EMPXItemModified"); |
|
789 |
|
790 CheckMediaStateL( itemId.iId1 ); |
|
791 } |
|
792 else if ( type == EMPXItemInserted ) |
|
793 { |
|
794 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::HandleCollectionMessageL EMPXItemInserted"); |
|
795 TMPXItemId mpxId(*( aMsg->Value<TMPXItemId>( KMPXMessageMediaGeneralId ))); |
|
796 RArray<TUint32> id; |
|
797 CleanupClosePushL( id ); |
|
798 id.Append( mpxId.iId1 ); |
|
799 GetMediaByMpxIdReqL( id ); |
|
800 CleanupStack::PopAndDestroy( &id ); |
|
801 } |
|
802 else if( type == EMPXItemDeleted ) |
|
803 { |
|
804 IPTVLOGSTRING_LOW_LEVEL("CVcxNsScheduledDownloadMpxClient::HandleCollectionMessageL EMPXItemDeleted"); |
|
805 |
|
806 CIptvMediaContent* content = SearchFromDownloadList( itemId.iId1 ); |
|
807 |
|
808 if ( content ) |
|
809 { |
|
810 RemoveFromDownloadList( content ); |
|
811 } |
|
812 } |
|
813 } |
|
814 } |
|
815 |
|
816 // ----------------------------------------------------------------------------- |
|
817 // |
|
818 // ----------------------------------------------------------------------------- |
|
819 // |
|
820 void CVcxNsScheduledDownloadMpxClient::CopyEcgDataToMpxColL( CIptvMediaContent *aContent, CMPXMedia *aMedia ) |
|
821 { |
|
822 if( !aMedia || !aContent ) |
|
823 { |
|
824 return; |
|
825 } |
|
826 |
|
827 CIptvVodContentContentFullDetails* details = CIptvVodContentContentFullDetails::NewL(); |
|
828 |
|
829 CleanupStack::PushL( details ); |
|
830 |
|
831 TInt ret = iContentClient.GetContentDetailsL( aContent->iContentKey, *details ); |
|
832 |
|
833 if( ret == KErrNone ) |
|
834 { |
|
835 // Language |
|
836 if ( aContent->iLanguage.Length() > 0 ) |
|
837 { |
|
838 aMedia->SetTextValueL( KVcxMediaMyVideosAudioLanguage, aContent->iLanguage ) ; |
|
839 } |
|
840 |
|
841 // Length |
|
842 if ( aContent->iDuration ) |
|
843 { |
|
844 aMedia->SetTObjectValueL<TReal32>( KVcxMediaMyVideosDuration, aContent->iDuration ); |
|
845 } |
|
846 |
|
847 // Description |
|
848 if ( details->iDescription.Length() > 0 ) |
|
849 { |
|
850 aMedia->SetTextValueL( KMPXMediaGeneralComment, details->iDescription ); |
|
851 } |
|
852 |
|
853 // Author |
|
854 if ( details->iAuthor.Length() > 0 ) |
|
855 { |
|
856 aMedia->SetTextValueL( KVcxMediaMyVideosAuthor, details->iAuthor ); |
|
857 } |
|
858 |
|
859 // Copyright |
|
860 if ( details->iCopyright.Length() > 0 ) |
|
861 { |
|
862 aMedia->SetTextValueL( KMPXMediaGeneralCopyright, details->iCopyright ); |
|
863 } |
|
864 |
|
865 // Age profile |
|
866 if ( details->iRatingAge > 0 ) |
|
867 { |
|
868 aMedia->SetTObjectValueL<TInt32>( KVcxMediaMyVideosAgeProfile, details->iRatingAge ); |
|
869 } |
|
870 } |
|
871 |
|
872 CleanupStack::PopAndDestroy( details ); |
|
873 } |
|
874 |
|
875 // ----------------------------------------------------------------------------- |
|
876 // |
|
877 // ----------------------------------------------------------------------------- |
|
878 // |
|
879 CMPXMedia* CVcxNsScheduledDownloadMpxClient::GetMpxMediaFromList( TUint32 aMediaId ) |
|
880 { |
|
881 for ( TInt i = iDownloadedMedias.Count()-1; i >= 0; i-- ) |
|
882 { |
|
883 TUint32 id = iDownloadedMedias[i]->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ).iId1; |
|
884 |
|
885 if( id == aMediaId ) |
|
886 { |
|
887 return iDownloadedMedias[i]; |
|
888 } |
|
889 } |
|
890 |
|
891 return NULL; |
|
892 } |