|
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: DRM related function definitions for hgmyvideos* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <StringLoader.h> |
|
22 #include <DRMCommon.h> |
|
23 #include <DRMHelper.h> |
|
24 |
|
25 #include "IptvDebug.h" |
|
26 #include <vcxhgmyvideos.rsg> |
|
27 #include "vcxhgmyvideosfulldrminfo.h" |
|
28 |
|
29 // CONSTANTS |
|
30 _LIT( KVcxHgExtensionWmWithDot,".wm" ); |
|
31 _LIT( KVcxHgExtensionWmvWithDot,".wmv" ); |
|
32 _LIT( KVcxHgExtensionAsfWithDot,".asf" ); |
|
33 _LIT( KVcxHgSeparator, ": " ); // IPTV: Changed from "\t" to ": " |
|
34 _LIT( KVcxHgDateFormat1, "%1" ); |
|
35 _LIT( KVcxHgDateFormat2, "%2" ); |
|
36 _LIT( KVcxHgDateFormat3, "%3" ); |
|
37 _LIT( KVcxHgTimeFormatBefore, " %-B %J:%T" ); |
|
38 _LIT( KVcxHgTimeFormatAfter, " %J:%T %+B" ); |
|
39 _LIT( KVcxHgEmptyChar, " " ); |
|
40 const TUint KVcxHgSecondSeparator = 1; |
|
41 const TUint KVcxHgThirdSeparator = 2; |
|
42 |
|
43 // ============================ LOCAL FUNCTIONS =============================== |
|
44 |
|
45 namespace // unnamed namespace for local definitions |
|
46 { |
|
47 // ------------------------------------------------------------------------ |
|
48 // AppendLabelAndDataToArrayL |
|
49 // ------------------------------------------------------------------------ |
|
50 // |
|
51 void AppendLabelAndDataToArrayL( CDesCArray& aArray, |
|
52 const TDesC& aLabel, |
|
53 const TDesC& aData ) |
|
54 { |
|
55 HBufC* dataStr = HBufC::NewLC( aLabel.Length() + |
|
56 KVcxHgSeparator().Length() + |
|
57 aData.Length() ); |
|
58 |
|
59 TPtr dataPtr( dataStr->Des() ); |
|
60 dataPtr.Append( aLabel ); |
|
61 dataPtr.Append( KVcxHgSeparator ); |
|
62 dataPtr.Append( aData ); |
|
63 aArray.AppendL( dataPtr ); |
|
64 |
|
65 IPTVLOGSTRING2_LOW_LEVEL("Video Storage UI ## CVcxHgMyVideosFullDrmInfo/AppendLabelAndDataToArrayL - %S", dataStr); |
|
66 |
|
67 CleanupStack::PopAndDestroy( dataStr ); |
|
68 } |
|
69 |
|
70 // ------------------------------------------------------------------------ |
|
71 // DateTimeStringLC |
|
72 // ------------------------------------------------------------------------ |
|
73 // |
|
74 HBufC* DateTimeStringLC( const TTime& aTime ) |
|
75 { |
|
76 TBuf<20> dateStr; |
|
77 TBuf<20> timeStr; |
|
78 TBuf<20> dateStrFormat; |
|
79 |
|
80 // Localized date separator form |
|
81 TLocale local; |
|
82 dateStrFormat.Append( KVcxHgDateFormat1 ); |
|
83 dateStrFormat.Append( local.DateSeparator( KVcxHgSecondSeparator ) ); |
|
84 dateStrFormat.Append( KVcxHgDateFormat2 ); |
|
85 dateStrFormat.Append( local.DateSeparator( KVcxHgThirdSeparator ) ); |
|
86 dateStrFormat.Append( KVcxHgDateFormat3 ); |
|
87 aTime.FormatL( dateStr, dateStrFormat ); |
|
88 |
|
89 if ( local.AmPmSymbolPosition() == ELocaleBefore ) |
|
90 { |
|
91 aTime.FormatL( timeStr, KVcxHgTimeFormatBefore ); |
|
92 } |
|
93 else |
|
94 { |
|
95 aTime.FormatL( timeStr, KVcxHgTimeFormatAfter ); |
|
96 } |
|
97 |
|
98 HBufC* buf = HBufC::NewLC( dateStr.Length() + |
|
99 KVcxHgEmptyChar().Length() + |
|
100 timeStr.Length() ); |
|
101 TPtr ptrBuffer( buf->Des() ); |
|
102 ptrBuffer.Append( dateStr ); |
|
103 ptrBuffer.Append( KVcxHgEmptyChar ); |
|
104 ptrBuffer.Append( timeStr ); |
|
105 |
|
106 return buf; |
|
107 } |
|
108 |
|
109 // ------------------------------------------------------------------------ |
|
110 // DateTimeL |
|
111 // ------------------------------------------------------------------------ |
|
112 // |
|
113 void DateTimeL( CDesCArray& aArray, |
|
114 const TTime& aTime, |
|
115 TInt aResourceId, |
|
116 const TDesC& aType ) |
|
117 { |
|
118 HBufC* label = StringLoader::LoadLC( aResourceId, aType ); |
|
119 HBufC* dateTime = DateTimeStringLC( aTime ); |
|
120 |
|
121 AppendLabelAndDataToArrayL( aArray, *label, *dateTime ); |
|
122 |
|
123 CleanupStack::PopAndDestroy( dateTime ); |
|
124 CleanupStack::PopAndDestroy( label ); |
|
125 } |
|
126 |
|
127 // ------------------------------------------------------------------------ |
|
128 // FillCounterInfoL |
|
129 // ------------------------------------------------------------------------ |
|
130 // |
|
131 void FillCounterInfoL( CDesCArray& aArray, |
|
132 CDRMHelperRightsConstraints& aRights, |
|
133 const TDesC& aType ) |
|
134 { |
|
135 TUint32 count( 0 ); |
|
136 TUint32 timedCount( 0 ); |
|
137 TUint32 ignore1( 0 ); |
|
138 TUint32 ignore2( 0 ); |
|
139 TTimeIntervalSeconds ignore3( 0 ); |
|
140 TInt err( KErrNone ); |
|
141 |
|
142 TRAPD( errCount, aRights.GetCountersL( count, ignore1 ) ); |
|
143 TRAPD( errTimedCount, aRights.GetTimedCountL( timedCount, ignore2, |
|
144 ignore3 ) ); |
|
145 |
|
146 if ( errCount == KErrNone && errTimedCount == KErrNone ) |
|
147 { |
|
148 // Both counts present, use minimum |
|
149 count = Min( count, timedCount ); |
|
150 err = KErrNone; |
|
151 } |
|
152 else if ( errCount == KErrNone ) |
|
153 { |
|
154 // Use count |
|
155 err = KErrNone; |
|
156 } |
|
157 else if ( errTimedCount == KErrNone ) |
|
158 { |
|
159 // Use timed count |
|
160 count = timedCount; |
|
161 err = KErrNone; |
|
162 } |
|
163 else |
|
164 { |
|
165 // Neither regular nor timed count constraint |
|
166 // present, return error |
|
167 err = KErrNotFound; |
|
168 } |
|
169 |
|
170 if ( err == KErrNone ) |
|
171 { |
|
172 // "Times left (%U)" |
|
173 HBufC* label = |
|
174 StringLoader::LoadLC( R_VCXHGMYVIDEOS_DRM_MGR_DET_UTL_X, aType ); |
|
175 |
|
176 HBufC* data = NULL; |
|
177 |
|
178 if ( count == 1 ) |
|
179 { |
|
180 // "1 count" |
|
181 data = StringLoader::LoadLC( R_VCXHGMYVIDEOS_DRM_MGR_DET_1_COUNT ); |
|
182 } |
|
183 else |
|
184 { |
|
185 // "%N counts" |
|
186 data = StringLoader::LoadLC( R_VCXHGMYVIDEOS_DRM_MGR_DET_N_COUNTS, count ); |
|
187 } |
|
188 |
|
189 AppendLabelAndDataToArrayL( aArray, *label, *data ); |
|
190 |
|
191 CleanupStack::PopAndDestroy( data ); |
|
192 CleanupStack::PopAndDestroy( label ); |
|
193 } |
|
194 } |
|
195 |
|
196 // --------------------------------------------------------- |
|
197 // SplitTime |
|
198 // --------------------------------------------------------- |
|
199 // |
|
200 void SplitTime( const TTimeIntervalSeconds& aInterval, |
|
201 TInt& aIntYrs, TInt& aIntMon, TInt& aIntDay, |
|
202 TInt& aIntHrs, TInt& aIntMin, TInt& aIntSec ) |
|
203 { |
|
204 TInt temp( 0 ); |
|
205 TInt i( 0 ); |
|
206 const TInt secsInMin( 60 ); |
|
207 const TInt secsInHour( secsInMin * 60 ); |
|
208 const TInt secsInDay( secsInHour * 24 ); |
|
209 |
|
210 // includes leap year day |
|
211 const TInt maxDaysInMonths[12] = { 31, 62, 92, 123, 153, 184, |
|
212 215, 245, 276, 306, 337, 366 }; |
|
213 |
|
214 // calculate full days |
|
215 temp = aInterval.Int() / secsInDay; |
|
216 |
|
217 // calculate full years, calculate without leap year for user to get the |
|
218 // longest time possible |
|
219 aIntYrs = temp / ( maxDaysInMonths[11] - 1 ); |
|
220 |
|
221 // calc remainder days |
|
222 temp = temp % ( maxDaysInMonths[11] - 1 ); |
|
223 |
|
224 aIntMon = 0; |
|
225 |
|
226 i = 0; |
|
227 if ( temp >= maxDaysInMonths[0] ) |
|
228 { |
|
229 for ( i = 0; i < 11; i++ ) |
|
230 { |
|
231 // found correct amount of months |
|
232 if ( temp >= maxDaysInMonths[i] && temp < maxDaysInMonths[i+1] ) |
|
233 { |
|
234 // i now contains amount of full months (+1 because of table index) |
|
235 aIntMon = i + 1; |
|
236 break; |
|
237 } |
|
238 } |
|
239 } |
|
240 |
|
241 // calc remainder days = allSecs - secsInFullYears - secsInFullMonts |
|
242 if( temp >= maxDaysInMonths[i] ) |
|
243 { |
|
244 aIntDay = temp - maxDaysInMonths[i]; |
|
245 } |
|
246 else |
|
247 { |
|
248 aIntDay = temp; |
|
249 } |
|
250 |
|
251 // calculate remainder secs |
|
252 temp = aInterval.Int() % secsInDay; |
|
253 |
|
254 aIntHrs = temp / secsInHour; |
|
255 |
|
256 // calculate remainder secs |
|
257 temp = temp % secsInHour; |
|
258 |
|
259 aIntMin = temp / secsInMin; |
|
260 |
|
261 // calculate remainder secs |
|
262 aIntSec = temp % secsInMin; |
|
263 } |
|
264 |
|
265 // --------------------------------------------------------- |
|
266 // AddSinglePartOfTimeL |
|
267 // --------------------------------------------------------- |
|
268 // |
|
269 void AddSinglePartOfTimeL( TInt aNumOfElements, |
|
270 TInt aResourceIdSingle, |
|
271 TInt aResourceIdOneFinal, |
|
272 TInt aResourceIdTwoFour, |
|
273 TInt aResourceIdFiveZero, |
|
274 CDesCArrayFlat* aStrings ) |
|
275 { |
|
276 HBufC* stringHolder = NULL; |
|
277 TInt finalOneDigit( aNumOfElements % 10 ); |
|
278 TInt finalTwoDigits( aNumOfElements % 100 ); |
|
279 |
|
280 if ( aNumOfElements == 1 ) |
|
281 { |
|
282 stringHolder = StringLoader::LoadLC( aResourceIdSingle ); |
|
283 } |
|
284 else if ( finalOneDigit == 1 && finalTwoDigits != 11 ) |
|
285 { |
|
286 stringHolder = StringLoader::LoadLC( aResourceIdOneFinal, |
|
287 aNumOfElements ); |
|
288 } |
|
289 else if ( finalOneDigit == 0 || |
|
290 ( finalOneDigit >= 5 && finalOneDigit <= 9 ) || |
|
291 ( finalTwoDigits >= 11 && finalTwoDigits <= 14 ) ) |
|
292 { |
|
293 stringHolder = StringLoader::LoadLC( aResourceIdFiveZero, |
|
294 aNumOfElements ); |
|
295 } |
|
296 else |
|
297 { |
|
298 stringHolder = StringLoader::LoadLC( aResourceIdTwoFour, |
|
299 aNumOfElements ); |
|
300 } |
|
301 |
|
302 if ( aStrings ) |
|
303 { |
|
304 aStrings->AppendL( *stringHolder ); |
|
305 } |
|
306 |
|
307 CleanupStack::PopAndDestroy ( stringHolder ); |
|
308 } |
|
309 |
|
310 // --------------------------------------------------------- |
|
311 // AddPartsOfTimeLC |
|
312 // --------------------------------------------------------- |
|
313 // |
|
314 HBufC* AddPartsOfTimeLC( TInt aIntYrs, TInt aIntMon, TInt aIntDay, |
|
315 TInt aIntHrs, TInt aIntMin, TInt aIntSec ) |
|
316 { |
|
317 // Only the two most meaningful data will be showed |
|
318 TInt numOfData( 0 ); |
|
319 |
|
320 CDesCArrayFlat* strings = new ( ELeave ) CDesCArrayFlat( 2 ); |
|
321 CleanupStack::PushL( strings ); |
|
322 |
|
323 if ( aIntYrs > 0 ) |
|
324 { |
|
325 AddSinglePartOfTimeL( aIntYrs, |
|
326 R_VCXHGMYVIDEOS_DRM_NBR_OF_YEARS_ONE, |
|
327 R_VCXHGMYVIDEOS_DRM_NBR_OF_YEARS_ONE_FINAL, |
|
328 R_VCXHGMYVIDEOS_DRM_NBR_OF_YEARS_TWO_FOUR, |
|
329 R_VCXHGMYVIDEOS_DRM_NBR_OF_YEARS_FIVE_ZERO, |
|
330 strings ); |
|
331 numOfData++; |
|
332 } |
|
333 |
|
334 if ( aIntMon > 0 ) |
|
335 { |
|
336 // Second type not provided because 11 is the maximum! |
|
337 AddSinglePartOfTimeL( aIntMon, |
|
338 R_VCXHGMYVIDEOS_DRM_NBR_OF_MONTHS_ONE, |
|
339 0, |
|
340 R_VCXHGMYVIDEOS_DRM_NBR_OF_MONTHS_TWO_FOUR, |
|
341 R_VCXHGMYVIDEOS_DRM_NBR_OF_MONTHS_FIVE_ZERO, |
|
342 strings ); |
|
343 numOfData++; |
|
344 } |
|
345 |
|
346 // Only if years or months were missing! |
|
347 if ( aIntDay > 0 && numOfData < 2 ) |
|
348 { |
|
349 AddSinglePartOfTimeL( aIntDay, |
|
350 R_VCXHGMYVIDEOS_DRM_NBR_OF_DAYS_ONE, |
|
351 R_VCXHGMYVIDEOS_DRM_NBR_OF_DAYS_ONE_FINAL, |
|
352 R_VCXHGMYVIDEOS_DRM_NBR_OF_DAYS_TWO_FOUR, |
|
353 R_VCXHGMYVIDEOS_DRM_NBR_OF_DAYS_FIVE_ZERO, |
|
354 strings ); |
|
355 numOfData++; |
|
356 } |
|
357 |
|
358 if ( aIntHrs > 0 && numOfData < 2 ) |
|
359 { |
|
360 AddSinglePartOfTimeL( aIntHrs, |
|
361 R_VCXHGMYVIDEOS_DRM_NBR_OF_HOURS_ONE, |
|
362 R_VCXHGMYVIDEOS_DRM_NBR_OF_HOURS_ONE_FINAL, |
|
363 R_VCXHGMYVIDEOS_DRM_NBR_OF_HOURS_TWO_FOUR, |
|
364 R_VCXHGMYVIDEOS_DRM_NBR_OF_HOURS_FIVE_ZERO, |
|
365 strings ); |
|
366 numOfData++; |
|
367 } |
|
368 |
|
369 if ( aIntMin > 0 && numOfData < 2 ) |
|
370 { |
|
371 AddSinglePartOfTimeL( aIntMin, |
|
372 R_VCXHGMYVIDEOS_DRM_NBR_OF_MINS_ONE, |
|
373 R_VCXHGMYVIDEOS_DRM_NBR_OF_MINS_ONE_FINAL, |
|
374 R_VCXHGMYVIDEOS_DRM_NBR_OF_MINS_TWO_FOUR, |
|
375 R_VCXHGMYVIDEOS_DRM_NBR_OF_MINS_FIVE_ZERO, |
|
376 strings ); |
|
377 numOfData++; |
|
378 } |
|
379 |
|
380 // If interval is 0, then it shows "0 seconds" anyway |
|
381 if ( ( aIntSec > 0 && numOfData < 2 ) || numOfData == 0 ) |
|
382 { |
|
383 AddSinglePartOfTimeL( aIntSec, |
|
384 R_VCXHGMYVIDEOS_DRM_NBR_OF_SECS_ONE, |
|
385 R_VCXHGMYVIDEOS_DRM_NBR_OF_SECS_ONE_FINAL, |
|
386 R_VCXHGMYVIDEOS_DRM_NBR_OF_SECS_TWO_FOUR, |
|
387 R_VCXHGMYVIDEOS_DRM_NBR_OF_SECS_FIVE_ZERO, |
|
388 strings ); |
|
389 numOfData++; |
|
390 } |
|
391 |
|
392 HBufC* stringHolder = NULL; |
|
393 if ( numOfData == 1 ) |
|
394 { |
|
395 stringHolder = StringLoader::LoadL( R_VCXHGMYVIDEOS_DRM_MGR_DET_INTER, |
|
396 strings->MdcaPoint(0) ); |
|
397 } |
|
398 else |
|
399 { |
|
400 stringHolder = StringLoader::LoadL( R_VCXHGMYVIDEOS_DRM_MGR_DET_INTER_TWO, |
|
401 *strings ); |
|
402 } |
|
403 |
|
404 CleanupStack::PopAndDestroy( strings ); |
|
405 |
|
406 CleanupStack::PushL( stringHolder ); |
|
407 |
|
408 return stringHolder; |
|
409 } |
|
410 |
|
411 // ------------------------------------------------------------------------ |
|
412 // FillUsageTimeLeftInfoL |
|
413 // ------------------------------------------------------------------------ |
|
414 // |
|
415 void FillUsageTimeLeftInfoL( CDesCArray& aArray, |
|
416 const TTimeIntervalSeconds& aInterval, |
|
417 const TDesC& aType, |
|
418 TBool aIsAccumulatedTime ) |
|
419 { |
|
420 TInt years( 0 ); |
|
421 TInt months( 0 ); |
|
422 TInt days( 0 ); |
|
423 TInt hours( 0 ); |
|
424 TInt minutes( 0 ); |
|
425 TInt seconds( 0 ); |
|
426 HBufC* label = NULL; |
|
427 HBufC* data = NULL; |
|
428 |
|
429 if ( aIsAccumulatedTime ) |
|
430 { |
|
431 // "Usage time left" |
|
432 label = StringLoader::LoadLC( R_VCXHGMYVIDEOS_DRM_MGR_DET_ACCUM_TIME_LEFT ); |
|
433 } |
|
434 else |
|
435 { |
|
436 // "Time left (%U)" |
|
437 label = StringLoader::LoadLC( R_VCXHGMYVIDEOS_DRM_MGR_DET_UDL_X, aType ); |
|
438 } |
|
439 |
|
440 SplitTime( aInterval, years, months, days, hours, minutes, seconds ); |
|
441 data = AddPartsOfTimeLC( years, months, days, hours, minutes, seconds ); |
|
442 |
|
443 AppendLabelAndDataToArrayL( aArray, *label, *data ); |
|
444 |
|
445 CleanupStack::PopAndDestroy( data ); |
|
446 CleanupStack::PopAndDestroy( label ); |
|
447 } |
|
448 |
|
449 // ------------------------------------------------------------------------ |
|
450 // FillIntervalInfoL |
|
451 // ------------------------------------------------------------------------ |
|
452 // |
|
453 void FillIntervalInfoL( CDesCArray& aArray, |
|
454 CDRMHelperRightsConstraints& aRights, |
|
455 const TDesC& aType, |
|
456 TTime& aStartTime, |
|
457 TTime& aEndTime ) |
|
458 { |
|
459 TTimeIntervalSeconds intervalSeconds( 0 ); |
|
460 |
|
461 TRAPD( err, aRights.GetIntervalL( intervalSeconds ) ); |
|
462 |
|
463 if ( err != KErrNotFound && err != KErrNone ) |
|
464 { |
|
465 User::Leave( err ); |
|
466 } |
|
467 |
|
468 if ( err == KErrNone ) |
|
469 { |
|
470 TTime intervalStartTime( 0 ); |
|
471 |
|
472 TRAP( err, aRights.GetIntervalStartL( intervalStartTime ) ); |
|
473 |
|
474 if ( ( err != KErrNotFound ) && ( err != KErrNone ) ) |
|
475 { |
|
476 User::Leave( err ); |
|
477 } |
|
478 |
|
479 if ( err == KErrNotFound ) |
|
480 { |
|
481 // "Times status (%U)" |
|
482 HBufC* label = |
|
483 StringLoader::LoadLC( R_VCXHGMYVIDEOS_DRM_MGR_DET_UTS_X, aType ); |
|
484 |
|
485 // "Not activated" |
|
486 HBufC* data = StringLoader::LoadLC( R_VCXHGMYVIDEOS_DRM_MGR_DET_NOT_ACT ); |
|
487 |
|
488 AppendLabelAndDataToArrayL( aArray, *label, *data ); |
|
489 |
|
490 CleanupStack::PopAndDestroy( data ); |
|
491 CleanupStack::PopAndDestroy( label ); |
|
492 |
|
493 // "Time left (%U)" |
|
494 FillUsageTimeLeftInfoL( aArray, intervalSeconds, aType, EFalse ); |
|
495 } |
|
496 else |
|
497 { |
|
498 TTime endTime( intervalStartTime ); |
|
499 endTime += intervalSeconds; |
|
500 |
|
501 // "Valid from (%U)" |
|
502 DateTimeL( aArray, intervalStartTime, |
|
503 R_VCXHGMYVIDEOS_DRM_MGR_DET_RVF_X, aType ); |
|
504 |
|
505 // "Valid until (%U)" |
|
506 DateTimeL( aArray, endTime, R_VCXHGMYVIDEOS_DRM_MGR_DET_RVT_X, aType ); |
|
507 |
|
508 // IPTV: Caller will need the start and end time for activated interval. |
|
509 aStartTime = intervalStartTime; |
|
510 aEndTime = endTime; |
|
511 } |
|
512 } |
|
513 } |
|
514 |
|
515 // ------------------------------------------------------------------------ |
|
516 // FillTimeInfoL |
|
517 // ------------------------------------------------------------------------ |
|
518 // |
|
519 void FillTimeInfoL( CDesCArray& aArray, |
|
520 CDRMHelperRightsConstraints& aRights, |
|
521 const TDesC& aType, |
|
522 TTime& aStartTime, |
|
523 TTime& aEndTime ) |
|
524 { |
|
525 TTime startTime; |
|
526 TTime endTime; |
|
527 |
|
528 TRAPD( startErr, aRights.GetStartTimeL( startTime ) ); |
|
529 if ( startErr != KErrNotFound && startErr != KErrNone ) |
|
530 { |
|
531 User::Leave( startErr ); |
|
532 } |
|
533 |
|
534 TRAPD( endErr, aRights.GetEndTimeL( endTime ) ); |
|
535 if ( endErr != KErrNotFound && endErr != KErrNone ) |
|
536 { |
|
537 User::Leave( endErr ); |
|
538 } |
|
539 |
|
540 // IPTV: In case we got start & end time, we need to check if they match |
|
541 // the start & end time of activated interval constraint (as parameter). |
|
542 // If they match, we should not display the same information twice. |
|
543 if ( startErr == KErrNone && endErr == KErrNone ) |
|
544 { |
|
545 if ( startTime == aStartTime && endTime == aEndTime ) |
|
546 { |
|
547 IPTVLOGSTRING_LOW_LEVEL("Video Storage UI ## CVcxHgMyVideosFullDrmInfo/FillTimeInfoL - DateTime matches Interval."); |
|
548 return; |
|
549 } |
|
550 } |
|
551 |
|
552 if ( startErr == KErrNone ) |
|
553 { |
|
554 // "Valid from (%U)" |
|
555 DateTimeL( aArray, startTime, R_VCXHGMYVIDEOS_DRM_MGR_DET_RVF_X, aType ); |
|
556 } |
|
557 |
|
558 if ( endErr == KErrNone ) |
|
559 { |
|
560 // "Valid until (%U)" |
|
561 DateTimeL( aArray, endTime, R_VCXHGMYVIDEOS_DRM_MGR_DET_RVT_X, aType ); |
|
562 } |
|
563 } |
|
564 |
|
565 // ------------------------------------------------------------------------ |
|
566 // FillAccumulatedTimeInfoL |
|
567 // ------------------------------------------------------------------------ |
|
568 // |
|
569 void FillAccumulatedTimeInfoL( CDesCArray& aArray, |
|
570 CDRMHelperRightsConstraints& aRights, |
|
571 const TDesC& aType ) |
|
572 { |
|
573 TTimeIntervalSeconds accumSeconds( 0 ); |
|
574 TRAPD( err, aRights.GetAccumulatedTimeL( accumSeconds )); |
|
575 if ( err != KErrNotFound && err != KErrNone ) |
|
576 { |
|
577 User::Leave( err ); |
|
578 } |
|
579 if ( err == KErrNone ) |
|
580 { |
|
581 // "Usage time left" |
|
582 FillUsageTimeLeftInfoL( aArray, accumSeconds, aType, ETrue ); |
|
583 } |
|
584 } |
|
585 |
|
586 // ------------------------------------------------------------------------ |
|
587 // FillDrmInfoL |
|
588 // ------------------------------------------------------------------------ |
|
589 // |
|
590 void FillDrmInfoL( CDesCArray& aArray, |
|
591 CDRMHelperRightsConstraints* aRights, |
|
592 TInt aResourceId ) |
|
593 { |
|
594 IPTVLOGSTRING_LOW_LEVEL("Video Storage UI ## CVcxHgMyVideosFullDrmInfo::FillDrmInfoL - Enter"); |
|
595 |
|
596 // Check if no rights at all |
|
597 if ( !aRights ) |
|
598 { |
|
599 IPTVLOGSTRING_LOW_LEVEL("Video Storage UI ## CVcxHgMyVideosFullDrmInfo::FillDrmInfoL - Exit1"); |
|
600 return; |
|
601 } |
|
602 |
|
603 // Rights type is either "Play", "Display", "Execute" or "Print" |
|
604 HBufC* type = StringLoader::LoadLC( aResourceId ); |
|
605 |
|
606 // Check if full rights |
|
607 if ( aRights->FullRights() ) |
|
608 { |
|
609 // "Rights (%U)" |
|
610 HBufC* label = |
|
611 StringLoader::LoadLC( R_VCXHGMYVIDEOS_DRM_MGR_DET_FULL_X, *type ); |
|
612 |
|
613 // "Unlimited" |
|
614 HBufC* data = StringLoader::LoadLC( R_VCXHGMYVIDEOS_DRM_MGR_DET_UNLIMITED ); |
|
615 |
|
616 AppendLabelAndDataToArrayL( aArray, *label, *data ); |
|
617 |
|
618 CleanupStack::PopAndDestroy( data ); |
|
619 CleanupStack::PopAndDestroy( label ); |
|
620 CleanupStack::PopAndDestroy( type ); |
|
621 IPTVLOGSTRING_LOW_LEVEL("Video Storage UI ## CVcxHgMyVideosFullDrmInfo::FillDrmInfoL - Exit2"); |
|
622 return; // full rights -> return |
|
623 } |
|
624 |
|
625 IPTVLOGSTRING_LOW_LEVEL("Video Storage UI ## CVcxHgMyVideosFullDrmInfo::FillDrmInfoL - Fill counter info."); |
|
626 |
|
627 // Get detailed counter constraint information |
|
628 FillCounterInfoL( aArray, *aRights, *type ); |
|
629 |
|
630 IPTVLOGSTRING_LOW_LEVEL("Video Storage UI ## CVcxHgMyVideosFullDrmInfo::FillDrmInfoL - Fill interval info."); |
|
631 |
|
632 // Get detailed interval constraint information (start time + duration) |
|
633 // IPTV: Get start and end time of activated interval. |
|
634 TTime startTime( (TInt64) 0 ); |
|
635 TTime endTime( (TInt64) 0 ); |
|
636 FillIntervalInfoL( aArray, *aRights, *type, startTime, endTime ); |
|
637 |
|
638 IPTVLOGSTRING_LOW_LEVEL("Video Storage UI ## CVcxHgMyVideosFullDrmInfo::FillDrmInfoL - Fill time info."); |
|
639 |
|
640 // Get detailed time constraint information (start time + end time) |
|
641 // IPTV: Pass the start and end time of activated interval to algorithm. |
|
642 FillTimeInfoL( aArray, *aRights, *type, startTime, endTime ); |
|
643 |
|
644 IPTVLOGSTRING_LOW_LEVEL("Video Storage UI ## CVcxHgMyVideosFullDrmInfo::FillDrmInfoL - Fill accumulated time info."); |
|
645 |
|
646 // Get detailed accumulated time constraint information (duration) |
|
647 FillAccumulatedTimeInfoL( aArray, *aRights, *type ); |
|
648 |
|
649 CleanupStack::PopAndDestroy( type ); |
|
650 |
|
651 IPTVLOGSTRING_LOW_LEVEL("Video Storage UI ## CVcxHgMyVideosFullDrmInfo::FillDrmInfoL - Exit3"); |
|
652 } |
|
653 |
|
654 // ----------------------------------------------------------------------------- |
|
655 // ResetAndDestroy |
|
656 // ----------------------------------------------------------------------------- |
|
657 // |
|
658 void ResetAndDestroy( TAny* aItem ) |
|
659 { |
|
660 static_cast< RPointerArray<CDRMHelperRightsConstraints>* >( aItem )->ResetAndDestroy(); |
|
661 } |
|
662 |
|
663 } // namespace |
|
664 |
|
665 // ============================ MEMBER FUNCTIONS =============================== |
|
666 |
|
667 // ----------------------------------------------------------------------------- |
|
668 // TVcxHgMyVideosFullDrmInfo::TVcxHgMyVideosFullDrmInfo() |
|
669 // ----------------------------------------------------------------------------- |
|
670 // |
|
671 TVcxHgMyVideosFullDrmInfo::TVcxHgMyVideosFullDrmInfo() |
|
672 { |
|
673 } |
|
674 |
|
675 // ----------------------------------------------------------------------------- |
|
676 // TVcxHgMyVideosFullDrmInfo::~TVcxHgMyVideosFullDrmInfo() |
|
677 // ----------------------------------------------------------------------------- |
|
678 // |
|
679 TVcxHgMyVideosFullDrmInfo::~TVcxHgMyVideosFullDrmInfo() |
|
680 { |
|
681 } |
|
682 |
|
683 // ----------------------------------------------------------------------------- |
|
684 // TVcxHgMyVideosFullDrmInfo::GetFullDrmInfoL() |
|
685 // ----------------------------------------------------------------------------- |
|
686 // |
|
687 void TVcxHgMyVideosFullDrmInfo::GetFullDrmInfoL( CDesCArray& aItemArray, |
|
688 const TDesC& aFileName ) |
|
689 { |
|
690 TParsePtrC parse( aFileName ); |
|
691 TPtrC ext = parse.Ext(); |
|
692 TBool useCaf( EFalse ); |
|
693 |
|
694 if ( ext.CompareF( KVcxHgExtensionWmWithDot) == 0 || |
|
695 ext.CompareF( KVcxHgExtensionWmvWithDot) == 0 || |
|
696 ext.CompareF( KVcxHgExtensionAsfWithDot) == 0 ) |
|
697 { |
|
698 useCaf = ETrue; |
|
699 } |
|
700 |
|
701 if ( useCaf ) |
|
702 { |
|
703 ContentAccess::CData* cdata = NULL; |
|
704 TInt cafError = KErrNone; |
|
705 TBool isProtected = EFalse; |
|
706 TBool isForwardable = EFalse; |
|
707 TBool canPlay = EFalse; |
|
708 |
|
709 cdata = CData::NewLC( (TVirtualPathPtr) aFileName, EPeek, EContentShareReadWrite ); |
|
710 |
|
711 cafError = cdata->GetAttribute( ContentAccess::EIsProtected, isProtected ); |
|
712 |
|
713 if ( cafError == KErrNone && isProtected ) |
|
714 { |
|
715 cafError = cdata->GetAttribute( ContentAccess::ECanPlay, canPlay ); |
|
716 |
|
717 HBufC* statusLabel = StringLoader::LoadLC( R_VCXHGMYVIDEOS_DRM_MGR_DET_STAT ); |
|
718 HBufC* statusData = NULL; |
|
719 if ( cafError == KErrNone && canPlay ) |
|
720 { |
|
721 statusData = StringLoader::LoadLC( R_VCXHGMYVIDEOS_WMDRM_VALID ); |
|
722 } |
|
723 else |
|
724 { |
|
725 statusData = StringLoader::LoadLC( R_VCXHGMYVIDEOS_WMDRM_INVALID ); |
|
726 } |
|
727 AppendLabelAndDataToArrayL( aItemArray, *statusLabel, *statusData ); |
|
728 CleanupStack::PopAndDestroy( statusData ); |
|
729 CleanupStack::PopAndDestroy( statusLabel ); |
|
730 |
|
731 cafError = cdata->GetAttribute( ContentAccess::EIsForwardable, isForwardable ); |
|
732 |
|
733 if ( cafError == KErrNone && isForwardable ) |
|
734 { |
|
735 HBufC* sendingLabel = StringLoader::LoadLC( R_VCXHGMYVIDEOS_DRM_MGR_DET_CS ); |
|
736 HBufC* sendingData = StringLoader::LoadLC( R_VCXHGMYVIDEOS_DRM_MGR_DET_ALLOWED ); |
|
737 AppendLabelAndDataToArrayL( aItemArray, *sendingLabel, *sendingData ); |
|
738 CleanupStack::PopAndDestroy( sendingData ); |
|
739 CleanupStack::PopAndDestroy( sendingLabel ); |
|
740 } |
|
741 } |
|
742 |
|
743 CleanupStack::PopAndDestroy( cdata ); |
|
744 } |
|
745 else |
|
746 { |
|
747 TBool expired ( EFalse ); |
|
748 TBool sendingAllowed( EFalse ); |
|
749 RPointerArray<CDRMHelperRightsConstraints> tempArr; |
|
750 TCleanupItem cleanupItem( ResetAndDestroy, &tempArr ); |
|
751 CleanupStack::PushL( cleanupItem ); |
|
752 tempArr.AppendL( NULL ); // Play |
|
753 tempArr.AppendL( NULL ); // Display |
|
754 tempArr.AppendL( NULL ); // Execute |
|
755 tempArr.AppendL( NULL ); // Print |
|
756 |
|
757 CDRMHelper* drmHelper = CDRMHelper::NewLC(); |
|
758 |
|
759 TRAPD( err, drmHelper->GetRightsDetailsL( |
|
760 aFileName, |
|
761 0, // Details for everything |
|
762 expired, |
|
763 sendingAllowed, |
|
764 tempArr[0], |
|
765 tempArr[1], |
|
766 tempArr[2], |
|
767 tempArr[3] ) ); |
|
768 CleanupStack::PopAndDestroy( drmHelper ); |
|
769 |
|
770 // Check if the rights are valid or expired |
|
771 // Should probably be able to append this information also when the |
|
772 // rights have expired. |
|
773 // "Status" |
|
774 HBufC* label = StringLoader::LoadLC( R_VCXHGMYVIDEOS_DRM_MGR_DET_STAT ); |
|
775 HBufC* data = NULL; |
|
776 // "Valid" or "Expired" |
|
777 TInt resId = ( expired || err == DRMCommon::ENoRights ? |
|
778 R_VCXHGMYVIDEOS_DRM_MGR_DET_EXP : R_VCXHGMYVIDEOS_DRM_MGR_DET_VALID ); |
|
779 data = StringLoader::LoadLC( resId ); |
|
780 AppendLabelAndDataToArrayL( aItemArray, *label, *data ); |
|
781 CleanupStack::PopAndDestroy( data ); |
|
782 CleanupStack::PopAndDestroy( label ); |
|
783 |
|
784 // "Play" |
|
785 FillDrmInfoL( aItemArray, tempArr[0], R_VCXHGMYVIDEOS_DRM_MGR_DET2_PLAY ); |
|
786 |
|
787 // "Display" |
|
788 FillDrmInfoL( aItemArray, tempArr[1], R_VCXHGMYVIDEOS_DRM_MGR_DET2_DISPLAY ); |
|
789 |
|
790 // "Execute" |
|
791 FillDrmInfoL( aItemArray, tempArr[2], R_VCXHGMYVIDEOS_DRM_MGR_DET2_EXECUTE ); |
|
792 |
|
793 // "Print" |
|
794 FillDrmInfoL( aItemArray, tempArr[3], R_VCXHGMYVIDEOS_DRM_MGR_DET2_PRINT ); |
|
795 |
|
796 CleanupStack::PopAndDestroy( &tempArr ); |
|
797 |
|
798 // Check whether sending is allowed or not |
|
799 |
|
800 // "Sending" |
|
801 label = StringLoader::LoadLC( R_VCXHGMYVIDEOS_DRM_MGR_DET_CS ); |
|
802 data = NULL; |
|
803 // "Allowed" or "Forbidden" |
|
804 resId = ( sendingAllowed ? R_VCXHGMYVIDEOS_DRM_MGR_DET_ALLOWED |
|
805 : R_VCXHGMYVIDEOS_DRM_MGR_DET_FORBID ); |
|
806 data = StringLoader::LoadLC( resId ); |
|
807 AppendLabelAndDataToArrayL( aItemArray, *label, *data ); |
|
808 CleanupStack::PopAndDestroy( data ); |
|
809 CleanupStack::PopAndDestroy( label ); |
|
810 } |
|
811 } |