|
1 /* |
|
2 * Copyright (c) 2007 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 "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 Utility common UI |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 // multiple drive support |
|
22 #ifdef RD_MULTIPLE_DRIVE |
|
23 #include <DriveInfo.h> |
|
24 #endif |
|
25 |
|
26 // notes and queries |
|
27 #include <coemain.h> |
|
28 #include <bautils.h> |
|
29 #include <stringloader.h> |
|
30 #include <stringresourcereader.h> |
|
31 #include <aknnotewrappers.h> |
|
32 #include <aknglobalnote.h> |
|
33 #include <aknquerydialog.h> |
|
34 #include <aknlistquerydialog.h> |
|
35 |
|
36 // secondary display support |
|
37 #include <aknmediatorfacade.h> |
|
38 #include <featmgr.h> |
|
39 #include <aknsddata.h> |
|
40 #include <mediatoreventprovider.h> |
|
41 #include <mediatordomainuids.h> |
|
42 |
|
43 // caf |
|
44 #include <caf/caftypes.h> |
|
45 #include <caf/data.h> |
|
46 |
|
47 // resources |
|
48 #include <data_caging_path_literals.hrh> |
|
49 #include <drmutility.rsg> |
|
50 |
|
51 // drm |
|
52 #include <drmconstraint.h> |
|
53 #include <oma2agent.h> |
|
54 #include <drmutilitytypes.h> |
|
55 |
|
56 #include "drmutilityui.h" |
|
57 #include "drmutilitysecondarydisplay.h" |
|
58 #include "drmutilityglobalnotewrapper.h" |
|
59 #include "drmutilityinfonotewrapper.h" |
|
60 |
|
61 // CONSTANTS |
|
62 #ifndef RD_MULTIPLE_DRIVE |
|
63 _LIT( KDriveZ, "z:" ); |
|
64 #else |
|
65 _LIT( KRomDriveFormatter, "%c:" ); |
|
66 #endif |
|
67 |
|
68 _LIT( KCDrmUtilityResFileName,"drmutility.rsc" ); |
|
69 _LIT( KAvkonResFileName, "avkon.rsc" ); |
|
70 |
|
71 // buffer sizes |
|
72 const TInt KDRMUtilityMaxDateFormatLen( 30 ); |
|
73 const TInt KDRMUtilityMaxDateLen( 30 ); |
|
74 const TInt KDRMUtilityMaxTimeFormatLen( 30 ); |
|
75 const TInt KDRMUtilityMaxTimeLen( 30 ); |
|
76 const TInt KDRMUtilityNoteMaxSize ( 256 ); |
|
77 |
|
78 #ifdef _DEBUG |
|
79 // debug panic |
|
80 _LIT( KDRMUtilityDebugPanicMessage, "DrmUtilityCommonDebugPanic" ); |
|
81 const TInt KDRMUtilityDebugPanicCode( 1 ); |
|
82 #endif |
|
83 |
|
84 // ============================= LOCAL FUNCTIONS =============================== |
|
85 |
|
86 // ============================ MEMBER FUNCTIONS =============================== |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CDrmUtilityUI::CDrmUtilityUI |
|
90 // C++ default constructor can NOT contain any code, that |
|
91 // might leave. |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 DRM::CDrmUtilityUI::CDrmUtilityUI( |
|
95 CCoeEnv* aCoeEnv ) : iCoeEnv( aCoeEnv ) |
|
96 { |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CDrmUtilityUI::ConstructL |
|
101 // Symbian 2nd phase constructor can leave. |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void DRM::CDrmUtilityUI::ConstructL() |
|
105 { |
|
106 if ( !iCoeEnv ) |
|
107 { |
|
108 User::LeaveIfError( iFs.Connect() ); |
|
109 User::LeaveIfError( iFs.ShareAuto() ); |
|
110 } |
|
111 |
|
112 TPtr utilityResourcePtr( NULL, 0 ); |
|
113 iUtilityResourceFile = HBufC::NewL( KMaxFileName ); |
|
114 utilityResourcePtr.Set( iUtilityResourceFile->Des() ); |
|
115 |
|
116 TPtr avkonResourcePtr( NULL, 0 ); |
|
117 iAvkonResourceFile = HBufC::NewL( KMaxFileName ); |
|
118 avkonResourcePtr.Set( iAvkonResourceFile->Des() ); |
|
119 |
|
120 #ifndef RD_MULTIPLE_DRIVE |
|
121 |
|
122 utilityResourcePtr.Append( KDriveZ ); |
|
123 avkonResourcePtr.Append( KDriveZ ); |
|
124 |
|
125 #else //RD_MULTIPLE_DRIVE |
|
126 |
|
127 TInt driveNumber( -1 ); |
|
128 TChar driveLetter; |
|
129 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber ); |
|
130 |
|
131 if ( iCoeEnv ) |
|
132 { |
|
133 iCoeEnv->FsSession().DriveToChar( driveNumber, driveLetter ); |
|
134 } |
|
135 else |
|
136 { |
|
137 iFs.DriveToChar( driveNumber, driveLetter ); |
|
138 } |
|
139 |
|
140 utilityResourcePtr.AppendFormat( KRomDriveFormatter, (TUint)driveLetter ); |
|
141 avkonResourcePtr.AppendFormat( KRomDriveFormatter, (TUint)driveLetter ); |
|
142 |
|
143 #endif |
|
144 |
|
145 utilityResourcePtr.Append( KDC_RESOURCE_FILES_DIR ); |
|
146 utilityResourcePtr.Append( KCDrmUtilityResFileName ); |
|
147 |
|
148 avkonResourcePtr.Append( KDC_RESOURCE_FILES_DIR ); |
|
149 avkonResourcePtr.Append( KAvkonResFileName ); |
|
150 |
|
151 TFileName resourceFile; |
|
152 if ( iCoeEnv ) |
|
153 { |
|
154 resourceFile = *iUtilityResourceFile; |
|
155 BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), resourceFile ); |
|
156 iUtilityResourceFileOffset = iCoeEnv->AddResourceFileL( resourceFile ); |
|
157 |
|
158 resourceFile = *iAvkonResourceFile; |
|
159 BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), resourceFile ); |
|
160 iAvkonResourceFileOffset = iCoeEnv->AddResourceFileL( resourceFile ); |
|
161 } |
|
162 else |
|
163 { |
|
164 resourceFile = *iUtilityResourceFile; |
|
165 iUtilityStringResourceReader = CStringResourceReader::NewL( resourceFile, iFs ); |
|
166 |
|
167 resourceFile = *iAvkonResourceFile; |
|
168 iAvkonStringResourceReader = CStringResourceReader::NewL( resourceFile, iFs ); |
|
169 } |
|
170 |
|
171 FeatureManager::InitializeLibL(); |
|
172 |
|
173 if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ) |
|
174 { |
|
175 iEventProvider = CMediatorEventProvider::NewL(); |
|
176 } |
|
177 } |
|
178 |
|
179 |
|
180 // ----------------------------------------------------------------------------- |
|
181 // CDrmUtilityUI::NewLC |
|
182 // Two-phased constructor. |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 EXPORT_C DRM::CDrmUtilityUI* DRM::CDrmUtilityUI::NewLC( |
|
186 CCoeEnv* aCoeEnv ) |
|
187 { |
|
188 DRM::CDrmUtilityUI* self( new( ELeave ) CDrmUtilityUI( aCoeEnv ) ); |
|
189 |
|
190 CleanupStack::PushL( self ); |
|
191 self->ConstructL(); |
|
192 |
|
193 return self; |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CDrmUtilityUI::NewL |
|
198 // Two-phased constructor. |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 EXPORT_C DRM::CDrmUtilityUI* DRM::CDrmUtilityUI::NewL( |
|
202 CCoeEnv* aCoeEnv ) |
|
203 { |
|
204 DRM::CDrmUtilityUI* self( NewLC( aCoeEnv ) ); |
|
205 |
|
206 CleanupStack::Pop( self ); |
|
207 |
|
208 return self; |
|
209 } |
|
210 |
|
211 // Destructor |
|
212 DRM::CDrmUtilityUI::~CDrmUtilityUI() |
|
213 { |
|
214 if ( iCoeEnv ) |
|
215 { |
|
216 iCoeEnv->DeleteResourceFile( iUtilityResourceFileOffset ); |
|
217 iCoeEnv->DeleteResourceFile( iAvkonResourceFileOffset ); |
|
218 } |
|
219 else |
|
220 { |
|
221 delete iUtilityStringResourceReader; |
|
222 delete iAvkonStringResourceReader; |
|
223 iFs.Close(); |
|
224 } |
|
225 |
|
226 delete iUtilityResourceFile; |
|
227 delete iAvkonResourceFile; |
|
228 delete iEventProvider; |
|
229 |
|
230 iNoteList.ResetAndDestroy(); |
|
231 iNoteList.Close(); |
|
232 |
|
233 FeatureManager::UnInitializeLib(); |
|
234 } |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // CDrmUtilityUI::DisplayQueryWithIdL |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryWithIdL( |
|
241 TInt aTextResourceId, |
|
242 TInt aQueryResourceId ) |
|
243 { |
|
244 TInt button( 0 ); |
|
245 |
|
246 if ( iCoeEnv ) |
|
247 { |
|
248 HBufC* msgText( StringLoader::LoadLC( aTextResourceId, iCoeEnv ) ); |
|
249 button = DisplayQueryL( *msgText, aQueryResourceId ); |
|
250 CleanupStack::PopAndDestroy( msgText ); |
|
251 } |
|
252 else |
|
253 { |
|
254 TInt buttonsId( |
|
255 aQueryResourceId == R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY ? |
|
256 R_AVKON_SOFTKEYS_OK_EMPTY__OK : |
|
257 R_AVKON_SOFTKEYS_YES_NO__YES ); |
|
258 |
|
259 DRM::CDrmUtilityGlobalNoteWrapper* noteWrapper( |
|
260 DRM::CDrmUtilityGlobalNoteWrapper::NewLC( iUtilityStringResourceReader ) ); |
|
261 |
|
262 button = noteWrapper->ShowNoteWithButtonsL( aTextResourceId, buttonsId ); |
|
263 |
|
264 CleanupStack::PopAndDestroy( noteWrapper ); |
|
265 } |
|
266 |
|
267 return button; |
|
268 } |
|
269 |
|
270 // ----------------------------------------------------------------------------- |
|
271 // CDrmUtilityUI::DisplayQueryWithIdValueL |
|
272 // ----------------------------------------------------------------------------- |
|
273 // |
|
274 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryWithIdValueL( |
|
275 TInt aTextResourceId, |
|
276 TInt aQueryResourceId, |
|
277 const TDesC& aString ) |
|
278 { |
|
279 TInt button( 0 ); |
|
280 |
|
281 if ( iCoeEnv ) |
|
282 { |
|
283 HBufC* msgText( StringLoader::LoadLC( aTextResourceId, |
|
284 aString, |
|
285 iCoeEnv ) ); |
|
286 button = DisplayQueryL( *msgText, aQueryResourceId ); |
|
287 CleanupStack::PopAndDestroy( msgText ); |
|
288 } |
|
289 else |
|
290 { |
|
291 TInt buttonsId( |
|
292 aQueryResourceId == R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY ? |
|
293 R_AVKON_SOFTKEYS_OK_EMPTY__OK : |
|
294 R_AVKON_SOFTKEYS_YES_NO__YES ); |
|
295 |
|
296 DRM::CDrmUtilityGlobalNoteWrapper* noteWrapper( |
|
297 DRM::CDrmUtilityGlobalNoteWrapper::NewLC( iUtilityStringResourceReader ) ); |
|
298 |
|
299 button = noteWrapper->ShowNoteWithButtonsL( aTextResourceId, |
|
300 buttonsId, |
|
301 aString ); |
|
302 CleanupStack::PopAndDestroy( noteWrapper ); |
|
303 } |
|
304 |
|
305 return button; |
|
306 } |
|
307 |
|
308 // ----------------------------------------------------------------------------- |
|
309 // CDrmUtilityUI::DisplayQueryL |
|
310 // ----------------------------------------------------------------------------- |
|
311 // |
|
312 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL( |
|
313 TInt aTextResourceId, |
|
314 TInt aValue ) |
|
315 { |
|
316 TInt buttonCode( 0 ); |
|
317 |
|
318 if ( iCoeEnv ) |
|
319 { |
|
320 TPtr bufPtr( NULL, 0 ); |
|
321 |
|
322 HBufC* stringholder( StringLoader::LoadLC( aTextResourceId, |
|
323 aValue, |
|
324 iCoeEnv ) ); |
|
325 CAknQueryDialog* dlg( |
|
326 CAknQueryDialog::NewL( CAknQueryDialog::ENoTone ) ); |
|
327 |
|
328 bufPtr.Set( stringholder->Des() ); |
|
329 AknTextUtils::LanguageSpecificNumberConversion( bufPtr ); |
|
330 PrepareSecondaryDisplayL( *dlg, aTextResourceId, KNullDesC, aValue ); |
|
331 |
|
332 buttonCode = dlg->ExecuteLD( R_DRMUTILITY_CONFIRMATION_QUERY, |
|
333 *stringholder ); |
|
334 |
|
335 CancelSecondaryDisplayL( aTextResourceId ); |
|
336 CleanupStack::PopAndDestroy( stringholder ); |
|
337 } |
|
338 else |
|
339 { |
|
340 DRM::CDrmUtilityGlobalNoteWrapper* noteWrapper( |
|
341 DRM::CDrmUtilityGlobalNoteWrapper::NewLC( iUtilityStringResourceReader ) ); |
|
342 |
|
343 buttonCode = noteWrapper->ShowNoteL( aTextResourceId, aValue ); |
|
344 |
|
345 CleanupStack::PopAndDestroy( noteWrapper ); |
|
346 } |
|
347 return buttonCode; |
|
348 } |
|
349 |
|
350 // ----------------------------------------------------------------------------- |
|
351 // CDrmUtilityUI::DisplayQueryL |
|
352 // ----------------------------------------------------------------------------- |
|
353 // |
|
354 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL( |
|
355 TInt aTextResourceId, |
|
356 const TDesC& aString ) |
|
357 { |
|
358 TInt buttonCode( 0 ); |
|
359 |
|
360 if ( iCoeEnv ) |
|
361 { |
|
362 TPtr bufPtr( NULL, 0 ); |
|
363 |
|
364 HBufC* stringholder( StringLoader::LoadLC( aTextResourceId, |
|
365 aString, |
|
366 iCoeEnv ) ); |
|
367 CAknQueryDialog* dlg( |
|
368 CAknQueryDialog::NewL( CAknQueryDialog::ENoTone ) ); |
|
369 |
|
370 bufPtr.Set( stringholder->Des() ); |
|
371 AknTextUtils::LanguageSpecificNumberConversion( bufPtr ); |
|
372 PrepareSecondaryDisplayL( *dlg, aTextResourceId, aString, -1 ); |
|
373 |
|
374 buttonCode = dlg->ExecuteLD( R_DRMUTILITY_CONFIRMATION_QUERY, |
|
375 *stringholder ); |
|
376 |
|
377 CancelSecondaryDisplayL( aTextResourceId ); |
|
378 CleanupStack::PopAndDestroy( stringholder ); |
|
379 } |
|
380 else |
|
381 { |
|
382 DRM::CDrmUtilityGlobalNoteWrapper* noteWrapper( |
|
383 DRM::CDrmUtilityGlobalNoteWrapper::NewLC( iUtilityStringResourceReader ) ); |
|
384 |
|
385 buttonCode = noteWrapper->ShowNoteL( aTextResourceId, aString ); |
|
386 |
|
387 CleanupStack::PopAndDestroy( noteWrapper ); |
|
388 } |
|
389 |
|
390 return buttonCode; |
|
391 } |
|
392 |
|
393 // ----------------------------------------------------------------------------- |
|
394 // CDrmUtilityUI::DisplayQueryL |
|
395 // ----------------------------------------------------------------------------- |
|
396 // |
|
397 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL( |
|
398 TInt aTextResourceId, |
|
399 const TDesC& aString, |
|
400 TInt aValue, |
|
401 TInt aStringPos, |
|
402 TInt aValuePos ) |
|
403 { |
|
404 TInt buttonCode( 0 ); |
|
405 |
|
406 if ( iCoeEnv ) |
|
407 { |
|
408 TPtr bufPtr( NULL, 0 ); |
|
409 |
|
410 TBuf<KDRMUtilityNoteMaxSize> textBuffer; |
|
411 TBuf<KDRMUtilityNoteMaxSize> textBuffer2; |
|
412 StringLoader::Load( textBuffer, aTextResourceId, iCoeEnv ); |
|
413 StringLoader::Format( textBuffer2, textBuffer, aValuePos, aValue ); |
|
414 textBuffer = textBuffer2; |
|
415 StringLoader::Format( textBuffer2, textBuffer, aStringPos, aString ); |
|
416 |
|
417 bufPtr.Set( const_cast <TUint16*>( textBuffer2.Ptr() ), |
|
418 textBuffer2.Length(), |
|
419 textBuffer2.Length() ); |
|
420 |
|
421 AknTextUtils::LanguageSpecificNumberConversion( bufPtr ); |
|
422 |
|
423 CAknQueryDialog* dlg( |
|
424 CAknQueryDialog::NewL( CAknQueryDialog::ENoTone ) ); |
|
425 |
|
426 PrepareSecondaryDisplayL( *dlg, aTextResourceId, aString, aValue ); |
|
427 |
|
428 buttonCode = |
|
429 dlg->ExecuteLD( R_DRMUTILITY_CONFIRMATION_QUERY, textBuffer2 ); |
|
430 |
|
431 CancelSecondaryDisplayL( aTextResourceId ); |
|
432 } |
|
433 else |
|
434 { |
|
435 DRM::CDrmUtilityGlobalNoteWrapper* noteWrapper( |
|
436 DRM::CDrmUtilityGlobalNoteWrapper::NewLC( iUtilityStringResourceReader ) ); |
|
437 |
|
438 buttonCode = noteWrapper->ShowNoteL( aTextResourceId, |
|
439 aString, |
|
440 aValue, |
|
441 aStringPos, |
|
442 aValuePos ); |
|
443 |
|
444 CleanupStack::PopAndDestroy( noteWrapper ); |
|
445 } |
|
446 |
|
447 return buttonCode; |
|
448 } |
|
449 |
|
450 // ----------------------------------------------------------------------------- |
|
451 // CDrmUtilityUI::DisplayQueryL |
|
452 // ----------------------------------------------------------------------------- |
|
453 // |
|
454 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL( |
|
455 TDesC& aPromptText, |
|
456 TInt aQueryResourceId ) |
|
457 { |
|
458 CAknQueryDialog* dlg( new (ELeave) CAknQueryDialog( |
|
459 aPromptText, |
|
460 CAknQueryDialog::ENoTone ) ); |
|
461 |
|
462 TPtr bufPtr( NULL, 0 ); |
|
463 bufPtr.Set( const_cast <TUint16*>( aPromptText.Ptr() ), |
|
464 aPromptText.Length(), |
|
465 aPromptText.Length() ); |
|
466 |
|
467 AknTextUtils::LanguageSpecificNumberConversion( bufPtr ); |
|
468 |
|
469 PrepareSecondaryDisplayL( *dlg, aQueryResourceId, aPromptText, -1 ); |
|
470 |
|
471 TInt ret( dlg->ExecuteLD( aQueryResourceId ) ); |
|
472 |
|
473 CancelSecondaryDisplayL( aQueryResourceId ); |
|
474 |
|
475 return ret; |
|
476 } |
|
477 |
|
478 // ----------------------------------------------------------------------------- |
|
479 // CDrmUtilityUI::SetAutomatedQuery |
|
480 // ----------------------------------------------------------------------------- |
|
481 // |
|
482 EXPORT_C TInt DRM::CDrmUtilityUI::SetAutomatedQueryL( |
|
483 CDRMConstraint* aConstraint ) |
|
484 { |
|
485 __ASSERT_DEBUG( aConstraint, User::Panic( KDRMUtilityDebugPanicMessage, |
|
486 KDRMUtilityDebugPanicCode ) ); |
|
487 |
|
488 TInt buttonCode( 1 ); |
|
489 |
|
490 if ( aConstraint->iActiveConstraints & EConstraintEndTime ) |
|
491 { |
|
492 TBuf<KDRMUtilityMaxDateLen> dateFormat; |
|
493 TBuf<KDRMUtilityMaxDateLen> endDate; |
|
494 TTime endTime( aConstraint->iEndTime ); |
|
495 |
|
496 if ( iCoeEnv ) |
|
497 { |
|
498 StringLoader::Load( dateFormat, |
|
499 R_QTN_DATE_USUAL_WITH_ZERO, |
|
500 iCoeEnv ); |
|
501 } |
|
502 else |
|
503 { |
|
504 dateFormat = iAvkonStringResourceReader->ReadResourceString( |
|
505 R_QTN_DATE_USUAL_WITH_ZERO ); |
|
506 } |
|
507 |
|
508 endTime.FormatL( endDate, dateFormat ); |
|
509 buttonCode = DisplayQueryL(R_DRM_QUERY_SET_AUTOMATED, endDate ); |
|
510 } |
|
511 else if ( aConstraint->iActiveConstraints & EConstraintInterval ) |
|
512 { |
|
513 buttonCode = DisplayQueryWithIdL( R_DRM_QUERY_SET_AUTO_INTERVAL, |
|
514 R_DRMUTILITY_CONFIRMATION_QUERY ); |
|
515 |
|
516 } |
|
517 return buttonCode; |
|
518 } |
|
519 |
|
520 // ----------------------------------------------------------------------------- |
|
521 // CDrmUtilityUI::ShowFutureRightsNoteL |
|
522 // ----------------------------------------------------------------------------- |
|
523 // |
|
524 EXPORT_C void DRM::CDrmUtilityUI::ShowFutureRightsNoteL( |
|
525 CDRMConstraint* aConstraint) |
|
526 { |
|
527 __ASSERT_DEBUG( aConstraint, User::Panic( KDRMUtilityDebugPanicMessage, |
|
528 KDRMUtilityDebugPanicCode ) ); |
|
529 _LIT( KSpace, " " ); |
|
530 TTime startTime( Time::NullTTime() ); |
|
531 |
|
532 User::LeaveIfError( GetOmaStartTime( aConstraint, startTime ) ); |
|
533 |
|
534 TBuf<KDRMUtilityMaxDateFormatLen> dateFormat; |
|
535 TBuf<KDRMUtilityMaxTimeFormatLen> timeFormat; |
|
536 TBuf<KDRMUtilityMaxDateLen + KDRMUtilityMaxTimeLen + 1> startDateBuf; |
|
537 TBuf<KDRMUtilityMaxTimeLen> startTimeBuf; |
|
538 |
|
539 if ( iCoeEnv ) |
|
540 { |
|
541 StringLoader::Load( dateFormat, R_QTN_DATE_USUAL_WITH_ZERO, iCoeEnv ); |
|
542 StringLoader::Load( timeFormat, R_QTN_TIME_USUAL_WITH_ZERO, iCoeEnv ); |
|
543 } |
|
544 else |
|
545 { |
|
546 dateFormat = iAvkonStringResourceReader->ReadResourceString( |
|
547 R_QTN_DATE_USUAL_WITH_ZERO ); |
|
548 timeFormat = iAvkonStringResourceReader->ReadResourceString( |
|
549 R_QTN_TIME_USUAL_WITH_ZERO ); |
|
550 } |
|
551 |
|
552 // format date and time |
|
553 startTime.FormatL( startDateBuf, dateFormat ); |
|
554 startTime.FormatL( startTimeBuf, timeFormat ); |
|
555 startDateBuf.Append( KSpace ); |
|
556 startDateBuf.Append( startTimeBuf ); |
|
557 |
|
558 // display note with start date |
|
559 DisplayNoteL( R_DRMUTILITY_USAGE_RIGHTS_IN_FUTURE, startDateBuf ); |
|
560 } |
|
561 |
|
562 // ----------------------------------------------------------------------------- |
|
563 // CDrmUtilityUI::DisplayNoteL |
|
564 // ----------------------------------------------------------------------------- |
|
565 // |
|
566 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL( TInt aTextResourceId ) |
|
567 { |
|
568 if ( iCoeEnv ) |
|
569 { |
|
570 HBufC* msgText( StringLoader::LoadLC( aTextResourceId, iCoeEnv ) ); |
|
571 DisplayNoteL( *msgText, aTextResourceId ); |
|
572 CleanupStack::PopAndDestroy( msgText ); |
|
573 } |
|
574 |
|
575 else |
|
576 { |
|
577 TBuf<KDRMUtilityNoteMaxSize> buffer( |
|
578 iUtilityStringResourceReader->ReadResourceString( aTextResourceId ) ); |
|
579 |
|
580 DisplayNoteL( buffer, aTextResourceId ); |
|
581 } |
|
582 } |
|
583 |
|
584 // ----------------------------------------------------------------------------- |
|
585 // CDrmUtilityUI::DisplayNoteL |
|
586 // ----------------------------------------------------------------------------- |
|
587 // |
|
588 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL( |
|
589 TInt aTextResourceId, |
|
590 const TDesC& aString ) |
|
591 { |
|
592 if ( iCoeEnv ) |
|
593 { |
|
594 HBufC* msgText( StringLoader::LoadLC( aTextResourceId, |
|
595 aString, |
|
596 iCoeEnv ) ); |
|
597 DisplayNoteL( *msgText, aTextResourceId ); |
|
598 CleanupStack::PopAndDestroy( msgText ); |
|
599 } |
|
600 else |
|
601 { |
|
602 TBuf<KDRMUtilityNoteMaxSize + KMaxFileName> destBuffer; |
|
603 |
|
604 |
|
605 TBuf<KDRMUtilityNoteMaxSize> buffer( |
|
606 iUtilityStringResourceReader->ReadResourceString( aTextResourceId ) ); |
|
607 |
|
608 |
|
609 StringLoader::Format( destBuffer, buffer, -1, aString ); |
|
610 DisplayNoteL( destBuffer, aTextResourceId, aString, -1 ); |
|
611 } |
|
612 } |
|
613 |
|
614 // ----------------------------------------------------------------------------- |
|
615 // CDrmUtilityUI::DisplayNoteL |
|
616 // ----------------------------------------------------------------------------- |
|
617 // |
|
618 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL( |
|
619 TInt aTextResourceId, |
|
620 TInt aValue ) |
|
621 { |
|
622 if ( iCoeEnv ) |
|
623 { |
|
624 HBufC* msgText( StringLoader::LoadLC( aTextResourceId, |
|
625 aValue, |
|
626 iCoeEnv ) ); |
|
627 |
|
628 DisplayNoteL( *msgText, aTextResourceId, KNullDesC, aValue ); |
|
629 CleanupStack::PopAndDestroy( msgText ); |
|
630 } |
|
631 else |
|
632 { |
|
633 TBuf<KDRMUtilityNoteMaxSize + KMaxFileName> destBuffer; |
|
634 |
|
635 TBuf<KDRMUtilityNoteMaxSize> buffer( |
|
636 iUtilityStringResourceReader->ReadResourceString( aTextResourceId ) ); |
|
637 |
|
638 |
|
639 StringLoader::Format( destBuffer, buffer, -1, aValue ); |
|
640 DisplayNoteL( destBuffer, aTextResourceId, KNullDesC, aValue ); |
|
641 } |
|
642 } |
|
643 |
|
644 // ----------------------------------------------------------------------------- |
|
645 // CDrmUtilityUI::DisplayNoteL |
|
646 // ----------------------------------------------------------------------------- |
|
647 // |
|
648 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL( |
|
649 TDesC& aPromptText, |
|
650 TInt aResourceId, |
|
651 const TDesC& aString, |
|
652 TInt aValue ) |
|
653 { |
|
654 TPtr bufPtr( NULL, 0 ); |
|
655 bufPtr.Set( const_cast <TUint16*>( aPromptText.Ptr() ), |
|
656 aPromptText.Length(), |
|
657 aPromptText.Length() ); |
|
658 |
|
659 AknTextUtils::LanguageSpecificNumberConversion( bufPtr ); |
|
660 |
|
661 if ( iCoeEnv ) |
|
662 { |
|
663 CAknResourceNoteDialog* note( CreateNoteForResourceL( aResourceId ) ); |
|
664 PrepareSecondaryDisplayL( *note, aResourceId, aString, aValue ); |
|
665 note->ExecuteLD( aPromptText ); |
|
666 CancelSecondaryDisplayL( aResourceId ); |
|
667 } |
|
668 else |
|
669 { |
|
670 DRM::CDrmUtilityInfoNoteWrapper* note( |
|
671 DRM::CDrmUtilityInfoNoteWrapper::NewL() ); |
|
672 |
|
673 //a list for simultanous notes |
|
674 User::LeaveIfError( iNoteList.Append( note ) ); |
|
675 |
|
676 note->ShowNoteL( GlobalNoteTypeForResource( aResourceId ), |
|
677 aPromptText, |
|
678 aResourceId, |
|
679 aString, |
|
680 aValue ); |
|
681 } |
|
682 } |
|
683 |
|
684 // ----------------------------------------------------------------------------- |
|
685 // CDrmUtilityUI::DisplayPopupWindowsForPreviewL |
|
686 // ----------------------------------------------------------------------------- |
|
687 // |
|
688 #ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO |
|
689 |
|
690 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayPopupWindowsForPreviewL( |
|
691 ContentAccess::CData& aContent, |
|
692 TInt aPreviewType, |
|
693 TInt aMediaType ) |
|
694 { |
|
695 TInt buttonCode( 0 ); |
|
696 TInt resourceId( 0 ); |
|
697 TInt index( 0 ); |
|
698 TInt answer( 0 ); |
|
699 |
|
700 // if media type is not given, try to get if from MIME type |
|
701 if( aMediaType == DRM::EUPreviewRightsActionDefault || |
|
702 aMediaType == DRM::EUEmbeddedPreviewActionDefault ) |
|
703 { |
|
704 aMediaType = EvaluatePreviewMediaTypeL( aContent, aPreviewType ); |
|
705 } |
|
706 |
|
707 if ( aPreviewType == ContentAccess::EPreviewRights ) |
|
708 { |
|
709 // preview rights for audio |
|
710 if ( aMediaType == DRM::EUPreviewRightsActionDefaultAudio ) |
|
711 { |
|
712 resourceId = R_DRMUTILITY_PREV_AUDIO_GET_LIST_QUERY; |
|
713 } |
|
714 // preview rights for video |
|
715 else if ( aMediaType == DRM::EUPreviewRightsActionDefaultVideo ) |
|
716 { |
|
717 resourceId = R_DRMUTILITY_PREV_VIDEO_GET_LIST_QUERY; |
|
718 } |
|
719 } |
|
720 else if ( aPreviewType == ContentAccess::EInstantPreview ) |
|
721 { |
|
722 // embedded preview for audio |
|
723 if ( aMediaType == DRM::EUEmbeddedPreviewActionDefaultAudio ) |
|
724 { |
|
725 resourceId = R_DRMUTILITY_PREV_AUDIO_PLAY_LIST_QUERY; |
|
726 } |
|
727 // embedded preview for video |
|
728 else if ( aMediaType == DRM::EUEmbeddedPreviewActionDefaultVideo ) |
|
729 { |
|
730 resourceId = R_DRMUTILITY_PREV_VIDEO_PLAY_LIST_QUERY; |
|
731 } |
|
732 } |
|
733 |
|
734 if ( iCoeEnv && resourceId ) |
|
735 { |
|
736 CAknListQueryDialog* dlg = new( ELeave ) CAknListQueryDialog( &index ); |
|
737 |
|
738 PrepareSecondaryDisplayL( *dlg, resourceId ); |
|
739 answer = dlg->ExecuteLD( resourceId ); |
|
740 CancelSecondaryDisplayL( resourceId ); |
|
741 |
|
742 if ( answer ) |
|
743 { |
|
744 buttonCode = index + 1; |
|
745 } |
|
746 } |
|
747 else if( resourceId ) |
|
748 { |
|
749 DRM::CDrmUtilityGlobalNoteWrapper* noteWrapper( |
|
750 DRM::CDrmUtilityGlobalNoteWrapper::NewLC( iUtilityStringResourceReader ) ); |
|
751 |
|
752 buttonCode = noteWrapper->ShowPreviewListQueryL( resourceId ); |
|
753 |
|
754 CleanupStack::PopAndDestroy( noteWrapper ); |
|
755 } |
|
756 |
|
757 return buttonCode; |
|
758 } |
|
759 |
|
760 #else |
|
761 |
|
762 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayPopupWindowsForPreviewL( |
|
763 ContentAccess::CData& /*aContent*/, |
|
764 TInt /*aPreviewType*/, |
|
765 TInt /*aMediaType*/ ) |
|
766 { |
|
767 return 0; |
|
768 } |
|
769 |
|
770 #endif // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO |
|
771 |
|
772 // ----------------------------------------------------------------------------- |
|
773 // CDrmUtilityUI::CreateNoteForResourceL |
|
774 // ----------------------------------------------------------------------------- |
|
775 // |
|
776 CAknResourceNoteDialog* DRM::CDrmUtilityUI::CreateNoteForResourceL( |
|
777 TInt aResId ) |
|
778 { |
|
779 CAknResourceNoteDialog* resourceDialog( NULL ); |
|
780 |
|
781 switch ( aResId ) |
|
782 { |
|
783 case R_DRM_ERR_OPENING_FAIL_PERM: |
|
784 |
|
785 resourceDialog = new ( ELeave ) CAknErrorNote( ETrue ); |
|
786 |
|
787 break; |
|
788 |
|
789 case R_DRM_WARN_NO_CONN_DEFINED: |
|
790 case R_DRM_WARN_INVALID_OR_NO_AP: |
|
791 |
|
792 resourceDialog = new ( ELeave ) CAknWarningNote( ETrue ); |
|
793 |
|
794 break; |
|
795 |
|
796 default: |
|
797 |
|
798 resourceDialog = new ( ELeave ) CAknInformationNote( ETrue ); |
|
799 |
|
800 break; |
|
801 } |
|
802 |
|
803 return resourceDialog; |
|
804 } |
|
805 |
|
806 // ----------------------------------------------------------------------------- |
|
807 // CDrmUtilityUI::GlobalNoteTypeForResource |
|
808 // ----------------------------------------------------------------------------- |
|
809 /// |
|
810 TAknGlobalNoteType DRM::CDrmUtilityUI::GlobalNoteTypeForResource( |
|
811 TInt aResId ) |
|
812 { |
|
813 TAknGlobalNoteType noteType( EAknGlobalInformationNote ); |
|
814 |
|
815 switch ( aResId ) |
|
816 { |
|
817 case R_DRM_ERR_OPENING_FAIL_PERM: |
|
818 |
|
819 noteType = EAknGlobalErrorNote; |
|
820 |
|
821 break; |
|
822 |
|
823 case R_DRM_WARN_NO_CONN_DEFINED: |
|
824 case R_DRM_WARN_INVALID_OR_NO_AP: |
|
825 |
|
826 noteType = EAknGlobalWarningNote; |
|
827 |
|
828 break; |
|
829 |
|
830 default: |
|
831 |
|
832 break; |
|
833 } |
|
834 |
|
835 return noteType; |
|
836 } |
|
837 |
|
838 // ----------------------------------------------------------------------------- |
|
839 // CDrmUtilityUI::GetOmaStartTime |
|
840 // ----------------------------------------------------------------------------- |
|
841 // |
|
842 TInt DRM::CDrmUtilityUI::GetOmaStartTime( |
|
843 CDRMConstraint* aConstraint, |
|
844 TTime& aStartTime) |
|
845 { |
|
846 __ASSERT_DEBUG( aConstraint, User::Panic( KDRMUtilityDebugPanicMessage, |
|
847 KDRMUtilityDebugPanicCode ) ); |
|
848 TInt err( KErrNone ); |
|
849 |
|
850 // Activated interval is always the same or later than |
|
851 // the start time of the start-end |
|
852 if ( aConstraint->iActiveConstraints & EConstraintInterval && |
|
853 (aConstraint->iIntervalStart != Time::NullTTime() ) ) |
|
854 { |
|
855 aStartTime = aConstraint->iIntervalStart; |
|
856 } |
|
857 else if ( aConstraint->iActiveConstraints & EConstraintStartTime ) |
|
858 { |
|
859 aStartTime = aConstraint->iStartTime; |
|
860 } |
|
861 else |
|
862 { |
|
863 err = KErrCANoPermission; |
|
864 } |
|
865 |
|
866 return err; |
|
867 } |
|
868 |
|
869 // ----------------------------------------------------------------------------- |
|
870 // CDrmUtilityUI::EvaluatePreviewMediaType |
|
871 // ----------------------------------------------------------------------------- |
|
872 // |
|
873 #ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO |
|
874 |
|
875 TInt DRM::CDrmUtilityUI::EvaluatePreviewMediaTypeL( |
|
876 ContentAccess::CData& aContent, |
|
877 TInt aPreviewType ) |
|
878 { |
|
879 _LIT( KDRMUtilityMimeTypeVideo, "Video" ); |
|
880 _LIT( KDRMUtilityMimeTypeRealMedia, "Application/x-pn-realmedia" ); |
|
881 _LIT( KDRMUtilityMimeTypeVndRealMedia, "Application/vnd.rn-realmedia" ); |
|
882 TInt mediaType( 0 ); |
|
883 HBufC* mimeType( HBufC::NewLC( KMaxDataTypeLength ) ); |
|
884 TPtr mimePtr( mimeType->Des() ); |
|
885 |
|
886 User::LeaveIfError( aContent.GetStringAttribute( ContentAccess::EMimeType, mimePtr ) ); |
|
887 |
|
888 if( mimePtr.FindF( KDRMUtilityMimeTypeVideo ) == KErrNotFound && |
|
889 mimePtr.FindF( KDRMUtilityMimeTypeRealMedia ) == KErrNotFound && |
|
890 mimePtr.FindF( KDRMUtilityMimeTypeVndRealMedia ) == KErrNotFound ) |
|
891 { |
|
892 if ( aPreviewType == ContentAccess::EPreviewRights ) |
|
893 { |
|
894 mediaType = DRM::EUPreviewRightsActionDefaultAudio; |
|
895 } |
|
896 else if ( aPreviewType == ContentAccess::EInstantPreview ) |
|
897 { |
|
898 mediaType = DRM::EUEmbeddedPreviewActionDefaultAudio; |
|
899 } |
|
900 } |
|
901 else |
|
902 { |
|
903 if ( aPreviewType == ContentAccess::EPreviewRights ) |
|
904 { |
|
905 mediaType = DRM::EUPreviewRightsActionDefaultVideo; |
|
906 } |
|
907 else if ( aPreviewType == ContentAccess::EInstantPreview ) |
|
908 { |
|
909 mediaType = DRM::EUEmbeddedPreviewActionDefaultVideo; |
|
910 } |
|
911 } |
|
912 |
|
913 CleanupStack::PopAndDestroy( mimeType ); |
|
914 return mediaType; |
|
915 } |
|
916 |
|
917 #else |
|
918 |
|
919 TInt DRM::CDrmUtilityUI::EvaluatePreviewMediaTypeL( |
|
920 ContentAccess::CData& /*aContent*/, |
|
921 TInt /*aPreviewType*/ ) |
|
922 { |
|
923 return 0; |
|
924 } |
|
925 |
|
926 #endif // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO |
|
927 |
|
928 // ----------------------------------------------------------------------------- |
|
929 // CDrmUtilityUI::PrepareSecondaryDisplayL |
|
930 // ----------------------------------------------------------------------------- |
|
931 // |
|
932 void DRM::CDrmUtilityUI::PrepareSecondaryDisplayL( |
|
933 CEikDialog& aDialog, |
|
934 TInt aResourceId, |
|
935 const TDesC& aString, |
|
936 TInt aValue ) |
|
937 { |
|
938 // Check if we have cover display and shall we display something |
|
939 if ( !FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) || |
|
940 !DRM::CDrmUtilityInfoNoteWrapper::EvaluateCoverResourceId( |
|
941 aResourceId ) ) |
|
942 { |
|
943 return; |
|
944 } |
|
945 |
|
946 RProcess myProcess; |
|
947 TUid myProcessUid( KNullUid ); |
|
948 |
|
949 RThread().Process( myProcess ); |
|
950 myProcessUid = myProcess.Identity(); |
|
951 |
|
952 aDialog.PublishDialogL( aResourceId, KUidCoverUiCategoryDrmUtility ); |
|
953 |
|
954 // fetch akn utility for mediator support |
|
955 CAknMediatorFacade* covercl( AknMediatorFacade( &aDialog ) ); |
|
956 |
|
957 if ( covercl ) // returns null if cover display is not available |
|
958 { |
|
959 // Package dialog data |
|
960 // <oem/SecondaryDisplay/DrmUtilitySecondaryDisplay.h> |
|
961 TUtilitySDData utilityData; |
|
962 |
|
963 // First field is DrmUtility's Uid |
|
964 utilityData.iUtilityUid = KUidCoverUiCategoryDrmUtility; |
|
965 // ProcessId which uses DrmUtility |
|
966 utilityData.iHandlerProcessId = myProcessUid; |
|
967 if ( aString.Compare( KNullDesC ) ) |
|
968 { |
|
969 // If there is filename given, it's always in the PrimaryString |
|
970 utilityData.iStringParam.Append( aString ); |
|
971 } |
|
972 if ( aValue >= 0 ) |
|
973 { |
|
974 // If there is no other than numeric data, put it as NumericString |
|
975 utilityData.iNumParam.AppendNum( aValue ); |
|
976 } |
|
977 TUtilitySDDataPckg pckg( utilityData ); |
|
978 |
|
979 covercl->BufStream() << pckg; // Write the package data |
|
980 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
981 } |
|
982 } |
|
983 |
|
984 // ----------------------------------------------------------------------------- |
|
985 // CDrmUtilityUI::CancelSecondaryDisplayL |
|
986 // ----------------------------------------------------------------------------- |
|
987 // |
|
988 void DRM::CDrmUtilityUI::CancelSecondaryDisplayL( TInt aResourceId ) |
|
989 { |
|
990 |
|
991 // Check if we have cover display and shall we display something |
|
992 if( !FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) || |
|
993 !DRM::CDrmUtilityInfoNoteWrapper::EvaluateCoverResourceId( |
|
994 aResourceId ) ) |
|
995 { |
|
996 return; |
|
997 } |
|
998 |
|
999 RProcess myProcess; |
|
1000 TUid myProcessUid( KNullUid ); |
|
1001 |
|
1002 RThread().Process( myProcess ); |
|
1003 myProcessUid = myProcess.Identity(); |
|
1004 |
|
1005 TUtilitySDDataCancel cancelData; |
|
1006 cancelData.iHandlerProcessId = myProcessUid; |
|
1007 cancelData.iNoteId = aResourceId; |
|
1008 |
|
1009 TPckgBuf<TUtilitySDDataCancel> cancel( cancelData ); |
|
1010 |
|
1011 HBufC8* buf( |
|
1012 HBufC8::NewLC( sizeof( TUtilitySDDataCancel ) + sizeof( TInt ) ) ); |
|
1013 TPtr8 ptr( buf->Des() ); |
|
1014 |
|
1015 RDesWriteStream stream( ptr ); |
|
1016 stream << cancel; |
|
1017 stream.CommitL(); |
|
1018 |
|
1019 iEventProvider->RaiseEvent( KMediatorSecondaryDisplayDomain, |
|
1020 KUidCoverUiCategoryDrmUtility, |
|
1021 ECover_dialog_cancel, |
|
1022 TVersion( 0, 0, 0 ), |
|
1023 *buf ); |
|
1024 |
|
1025 stream.Close(); |
|
1026 CleanupStack::PopAndDestroy( buf ); |
|
1027 } |
|
1028 |
|
1029 // End of File |