commondrm/drmutility/src/drmutilityui.cpp
branchRCL_3
changeset 71 1221b68b8a5f
parent 32 457cd4423b8c
child 72 1481bf457703
equal deleted inserted replaced
67:50c53e893c3f 71:1221b68b8a5f
    30 #include <stringresourcereader.h>
    30 #include <stringresourcereader.h>
    31 #include <aknnotewrappers.h>
    31 #include <aknnotewrappers.h>
    32 #include <AknGlobalNote.h>
    32 #include <AknGlobalNote.h>
    33 #include <AknQueryDialog.h>
    33 #include <AknQueryDialog.h>
    34 #include <aknlistquerydialog.h>
    34 #include <aknlistquerydialog.h>
    35 #include <aknmessagequerydialog.h> 
       
    36 
    35 
    37 // secondary display support
    36 // secondary display support
    38 #include <AknMediatorFacade.h>
    37 #include <AknMediatorFacade.h>
    39 #include <featmgr.h>
    38 #include <featmgr.h>
    40 #include <aknSDData.h>
    39 #include <aknSDData.h>
    57 #include "drmutilityui.h"
    56 #include "drmutilityui.h"
    58 #include "drmutilitysecondarydisplay.h"
    57 #include "drmutilitysecondarydisplay.h"
    59 #include "DrmUtilityGlobalNoteWrapper.h"
    58 #include "DrmUtilityGlobalNoteWrapper.h"
    60 #include "DrmUtilityInfoNoteWrapper.h"
    59 #include "DrmUtilityInfoNoteWrapper.h"
    61 
    60 
       
    61 #include "drmuidialogids.h"
       
    62 #include "drmuidialogs.h"
       
    63 
    62 // CONSTANTS
    64 // CONSTANTS
    63 #ifndef RD_MULTIPLE_DRIVE
    65 #ifndef RD_MULTIPLE_DRIVE
    64 _LIT( KDriveZ, "z:" );
    66 _LIT( KDriveZ, "z:" );
    65 #else
    67 #else
    66 _LIT( KRomDriveFormatter, "%c:" );
    68 _LIT( KRomDriveFormatter, "%c:" );
    73 const TInt KDRMUtilityMaxDateFormatLen( 30 );
    75 const TInt KDRMUtilityMaxDateFormatLen( 30 );
    74 const TInt KDRMUtilityMaxDateLen( 30 );
    76 const TInt KDRMUtilityMaxDateLen( 30 );
    75 const TInt KDRMUtilityMaxTimeFormatLen( 30 );
    77 const TInt KDRMUtilityMaxTimeFormatLen( 30 );
    76 const TInt KDRMUtilityMaxTimeLen( 30 );
    78 const TInt KDRMUtilityMaxTimeLen( 30 );
    77 const TInt KDRMUtilityNoteMaxSize ( 256 );
    79 const TInt KDRMUtilityNoteMaxSize ( 256 );
       
    80 const TInt KNoValue = -1;
    78 
    81 
    79 #ifdef _DEBUG
    82 #ifdef _DEBUG
    80 // debug panic
    83 // debug panic
    81 _LIT( KDRMUtilityDebugPanicMessage, "DrmUtilityCommonDebugPanic" );
    84 _LIT( KDRMUtilityDebugPanicMessage, "DrmUtilityCommonDebugPanic" );
    82 const TInt KDRMUtilityDebugPanicCode( 1 );
    85 const TInt KDRMUtilityDebugPanicCode( 1 );
   230 
   233 
   231     iNoteList.ResetAndDestroy();
   234     iNoteList.ResetAndDestroy();
   232     iNoteList.Close();
   235     iNoteList.Close();
   233 
   236 
   234     FeatureManager::UnInitializeLib();
   237     FeatureManager::UnInitializeLib();
   235     delete iNoteWrapper;	
       
   236     	
       
   237     }
   238     }
   238 
   239 
   239 // -----------------------------------------------------------------------------
   240 // -----------------------------------------------------------------------------
   240 // CDrmUtilityUI::DisplayQueryWithIdL
   241 // CDrmUtilityUI::DisplayQueryWithIdL
   241 // -----------------------------------------------------------------------------
   242 // -----------------------------------------------------------------------------
   314 //
   315 //
   315 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL(
   316 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL(
   316     TInt aTextResourceId,
   317     TInt aTextResourceId,
   317     TInt aValue )
   318     TInt aValue )
   318     {
   319     {
   319     TInt buttonCode( 0 );
   320     TInt resultCode( ECancelled );
   320 
   321 
   321     if ( iCoeEnv )
   322     CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() ); 
   322         {
   323     resultCode = drmUiDialog->ShowNoteL( aTextResourceId, KNullDesC, aValue );
   323         TPtr bufPtr( NULL, 0 );
   324     CleanupStack::PopAndDestroy( drmUiDialog );
   324 
   325     return resultCode;
   325         HBufC* stringholder( StringLoader::LoadLC( aTextResourceId,
       
   326                                                    aValue,
       
   327                                                    iCoeEnv ) );
       
   328         CAknQueryDialog* dlg(
       
   329                         CAknQueryDialog::NewL( CAknQueryDialog::ENoTone ) );
       
   330 
       
   331         bufPtr.Set( stringholder->Des() );
       
   332         AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
       
   333         PrepareSecondaryDisplayL( *dlg, aTextResourceId, KNullDesC, aValue );
       
   334 
       
   335         buttonCode = dlg->ExecuteLD( R_DRMUTILITY_CONFIRMATION_QUERY,
       
   336                                      *stringholder );
       
   337 
       
   338         CancelSecondaryDisplayL( aTextResourceId );
       
   339         CleanupStack::PopAndDestroy( stringholder );
       
   340         }
       
   341     else
       
   342         {
       
   343         DRM::CDrmUtilityGlobalNoteWrapper* noteWrapper(
       
   344             DRM::CDrmUtilityGlobalNoteWrapper::NewLC( iUtilityStringResourceReader ) );
       
   345 
       
   346         buttonCode = noteWrapper->ShowNoteL( aTextResourceId, aValue );
       
   347 
       
   348         CleanupStack::PopAndDestroy( noteWrapper );
       
   349         }
       
   350     return buttonCode;
       
   351     }
   326     }
   352 
   327 
   353 // -----------------------------------------------------------------------------
   328 // -----------------------------------------------------------------------------
   354 // CDrmUtilityUI::DisplayQueryL
   329 // CDrmUtilityUI::DisplayQueryL
   355 // -----------------------------------------------------------------------------
   330 // -----------------------------------------------------------------------------
   356 //
   331 //
   357 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL(
   332 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL(
   358     TInt aTextResourceId,
   333     TInt aTextResourceId,
   359     const TDesC& aString )
   334     const TDesC& aString )
   360     {
   335     {
   361     TInt buttonCode( 0 );
   336     TInt resultCode( ECancelled );
   362 
   337 
   363     if ( iCoeEnv )
   338     CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
   364         {
   339     resultCode = drmUiDialog->ShowNoteL( aTextResourceId, aString, KNoValue );
   365         TPtr bufPtr( NULL, 0 );
   340     CleanupStack::PopAndDestroy( drmUiDialog );
   366 
   341     return resultCode;
   367         HBufC* stringholder( StringLoader::LoadLC( aTextResourceId,
       
   368                                                    aString,
       
   369                                                    iCoeEnv ) );
       
   370         CAknQueryDialog* dlg(
       
   371             CAknQueryDialog::NewL( CAknQueryDialog::ENoTone ) );
       
   372 
       
   373         bufPtr.Set( stringholder->Des() );
       
   374         AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
       
   375         PrepareSecondaryDisplayL( *dlg, aTextResourceId, aString, -1 );
       
   376 
       
   377         buttonCode = dlg->ExecuteLD( R_DRMUTILITY_CONFIRMATION_QUERY,
       
   378                                      *stringholder );
       
   379 
       
   380         CancelSecondaryDisplayL( aTextResourceId );
       
   381         CleanupStack::PopAndDestroy( stringholder );
       
   382         }
       
   383     else
       
   384         {
       
   385         DRM::CDrmUtilityGlobalNoteWrapper* noteWrapper(
       
   386             DRM::CDrmUtilityGlobalNoteWrapper::NewLC( iUtilityStringResourceReader ) );
       
   387 
       
   388         buttonCode = noteWrapper->ShowNoteL( aTextResourceId, aString );
       
   389 
       
   390         CleanupStack::PopAndDestroy( noteWrapper );
       
   391         }
       
   392 
       
   393     return buttonCode;
       
   394     }
   342     }
   395 
   343 
   396 // -----------------------------------------------------------------------------
   344 // -----------------------------------------------------------------------------
   397 // CDrmUtilityUI::DisplayQueryL
   345 // CDrmUtilityUI::DisplayQueryL
   398 // -----------------------------------------------------------------------------
   346 // -----------------------------------------------------------------------------
   486     CDRMConstraint* aConstraint )
   434     CDRMConstraint* aConstraint )
   487     {
   435     {
   488     __ASSERT_DEBUG( aConstraint, User::Panic( KDRMUtilityDebugPanicMessage,
   436     __ASSERT_DEBUG( aConstraint, User::Panic( KDRMUtilityDebugPanicMessage,
   489                                               KDRMUtilityDebugPanicCode ) );
   437                                               KDRMUtilityDebugPanicCode ) );
   490 
   438 
   491     TInt buttonCode( 1 );
   439     TInt buttonCode( EOk );
   492 
   440 
   493     if ( aConstraint->iActiveConstraints & EConstraintEndTime )
   441     if ( aConstraint->iActiveConstraints & EConstraintEndTime )
   494         {
   442         {
   495         TBuf<KDRMUtilityMaxDateLen> dateFormat;
   443         TBuf<KDRMUtilityMaxDateLen> dateFormat;
   496         TBuf<KDRMUtilityMaxDateLen> endDate;
   444         TBuf<KDRMUtilityMaxDateLen> endDate;
   507             dateFormat = iAvkonStringResourceReader->ReadResourceString(
   455             dateFormat = iAvkonStringResourceReader->ReadResourceString(
   508                                                 R_QTN_DATE_USUAL_WITH_ZERO );
   456                                                 R_QTN_DATE_USUAL_WITH_ZERO );
   509             }
   457             }
   510 
   458 
   511         endTime.FormatL( endDate, dateFormat );
   459         endTime.FormatL( endDate, dateFormat );
   512         buttonCode = DisplayQueryL(R_DRM_QUERY_SET_AUTOMATED, endDate );
   460 
       
   461         // Qt dialog not implmented yet.
       
   462         buttonCode = DisplayQueryL( EQueryLicenceValidUntil, endDate );
   513         }
   463         }
   514     else if ( aConstraint->iActiveConstraints & EConstraintInterval )
   464     else if ( aConstraint->iActiveConstraints & EConstraintInterval )
   515         {
   465         {
   516         buttonCode = DisplayQueryWithIdL( R_DRM_QUERY_SET_AUTO_INTERVAL,
   466         // Qt dialog not implemented yet.
   517                                           R_DRMUTILITY_CONFIRMATION_QUERY );
   467         buttonCode = DisplayQueryL( EQueryValidForLimitedTime, KNoValue );
   518 
       
   519         }
   468         }
   520     return buttonCode;
   469     return buttonCode;
   521     }
   470     }
   522 
   471 
   523 // -----------------------------------------------------------------------------
   472 // -----------------------------------------------------------------------------
   557     startTime.FormatL( startTimeBuf, timeFormat );
   506     startTime.FormatL( startTimeBuf, timeFormat );
   558     startDateBuf.Append( KSpace );
   507     startDateBuf.Append( KSpace );
   559     startDateBuf.Append( startTimeBuf );
   508     startDateBuf.Append( startTimeBuf );
   560 
   509 
   561     // display note with start date
   510     // display note with start date
   562     DisplayNoteL( R_DRMUTILITY_USAGE_RIGHTS_IN_FUTURE, startDateBuf );
   511     // Qt dialog not implemented yet
       
   512     DisplayNoteL( EConfUnableToUse, startDateBuf );
   563     }
   513     }
   564 
   514 
   565 // -----------------------------------------------------------------------------
   515 // -----------------------------------------------------------------------------
   566 // CDrmUtilityUI::DisplayNoteL
   516 // CDrmUtilityUI::DisplayNoteL
   567 // -----------------------------------------------------------------------------
   517 // -----------------------------------------------------------------------------
   568 //
   518 //
   569 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL( TInt aTextResourceId )
   519 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL( TInt aTextResourceId )
   570     {
   520     {
   571     if ( iCoeEnv )
   521     CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
   572         {
   522     drmUiDialog->ShowNoteL( aTextResourceId, KNullDesC, KNoValue );
   573         HBufC* msgText( StringLoader::LoadLC( aTextResourceId, iCoeEnv ) );
   523     CleanupStack::PopAndDestroy( drmUiDialog );
   574         DisplayNoteL( *msgText, aTextResourceId );
       
   575         CleanupStack::PopAndDestroy( msgText );
       
   576         }
       
   577 
       
   578     else
       
   579         {
       
   580         TBuf<KDRMUtilityNoteMaxSize> buffer(
       
   581             iUtilityStringResourceReader->ReadResourceString( aTextResourceId ) );
       
   582 
       
   583         DisplayNoteL( buffer, aTextResourceId );
       
   584         }
       
   585     }
   524     }
   586 
   525 
   587 // -----------------------------------------------------------------------------
   526 // -----------------------------------------------------------------------------
   588 // CDrmUtilityUI::DisplayNoteL
   527 // CDrmUtilityUI::DisplayNoteL
   589 // -----------------------------------------------------------------------------
   528 // -----------------------------------------------------------------------------
   590 //
   529 //
   591 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL(
   530 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL(
   592     TInt aTextResourceId,
   531     TInt aTextResourceId,
   593     const TDesC& aString )
   532     const TDesC& aString )
   594     {
   533     {
   595     if ( iCoeEnv )
   534     CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
   596         {
   535     drmUiDialog->ShowNoteL( aTextResourceId, aString, KNoValue );
   597         HBufC* msgText( StringLoader::LoadLC( aTextResourceId,
   536     CleanupStack::PopAndDestroy( drmUiDialog );
   598                                               aString,
       
   599                                               iCoeEnv ) );
       
   600         DisplayNoteL( *msgText, aTextResourceId );
       
   601         CleanupStack::PopAndDestroy( msgText );
       
   602         }
       
   603     else
       
   604         {
       
   605         TBuf<KDRMUtilityNoteMaxSize + KMaxFileName> destBuffer;
       
   606 
       
   607 
       
   608         TBuf<KDRMUtilityNoteMaxSize> buffer(
       
   609             iUtilityStringResourceReader->ReadResourceString( aTextResourceId ) );
       
   610 
       
   611 
       
   612         StringLoader::Format( destBuffer, buffer, -1, aString );
       
   613         DisplayNoteL( destBuffer, aTextResourceId, aString, -1 );
       
   614         }
       
   615     }
   537     }
   616 
   538 
   617 // -----------------------------------------------------------------------------
   539 // -----------------------------------------------------------------------------
   618 // CDrmUtilityUI::DisplayNoteL
   540 // CDrmUtilityUI::DisplayNoteL
   619 // -----------------------------------------------------------------------------
   541 // -----------------------------------------------------------------------------
   620 //
   542 //
   621 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL(
   543 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL(
   622     TInt aTextResourceId,
   544     TInt aTextResourceId,
   623     TInt aValue )
   545     TInt aValue )
   624     {
   546     {
   625     if ( iCoeEnv )
   547     CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
   626         {
   548     drmUiDialog->ShowNoteL( aTextResourceId, KNullDesC, aValue );
   627         HBufC* msgText( StringLoader::LoadLC( aTextResourceId,
   549     CleanupStack::PopAndDestroy( drmUiDialog );
   628                                               aValue,
       
   629                                               iCoeEnv ) );
       
   630 
       
   631         DisplayNoteL( *msgText, aTextResourceId, KNullDesC, aValue );
       
   632         CleanupStack::PopAndDestroy( msgText );
       
   633         }
       
   634     else
       
   635         {
       
   636         TBuf<KDRMUtilityNoteMaxSize + KMaxFileName> destBuffer;
       
   637 
       
   638         TBuf<KDRMUtilityNoteMaxSize> buffer(
       
   639             iUtilityStringResourceReader->ReadResourceString( aTextResourceId ) );
       
   640 
       
   641 
       
   642         StringLoader::Format( destBuffer, buffer, -1, aValue );
       
   643         DisplayNoteL( destBuffer, aTextResourceId, KNullDesC, aValue );
       
   644         }
       
   645     }
   550     }
   646 
   551 
   647 // -----------------------------------------------------------------------------
   552 // -----------------------------------------------------------------------------
   648 // CDrmUtilityUI::DisplayNoteL
   553 // CDrmUtilityUI::DisplayNoteL
   649 // -----------------------------------------------------------------------------
   554 // -----------------------------------------------------------------------------
   769     {
   674     {
   770     return 0;
   675     return 0;
   771     }
   676     }
   772 
   677 
   773 #endif  // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
   678 #endif  // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
   774 
       
   775 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayMessageQueryL( TInt aMessage, TInt aHeader, const TDesC& aString)
       
   776     {
       
   777     TInt buttonCode = 0;
       
   778 		if ( iCoeEnv )
       
   779 	    	{
       
   780 		    CAknMessageQueryDialog* messageQuery = new (ELeave) CAknMessageQueryDialog();
       
   781 		    messageQuery->PrepareLC(R_DRMUTILITY_SYNC_DIALOG);
       
   782 		    		    
       
   783 		    HBufC* headerStringholder ( StringLoader::LoadLC( aHeader, iCoeEnv ) );
       
   784         
       
   785 		    messageQuery->QueryHeading()->SetTextL(*headerStringholder);
       
   786  				CleanupStack::PopAndDestroy(); // headerStringholder
       
   787  				 				
       
   788  				HBufC* messageStringholder ( StringLoader::LoadLC( aMessage, aString, iCoeEnv ) );
       
   789  				
       
   790  				messageQuery->SetMessageTextL(*messageStringholder);
       
   791  				CleanupStack::PopAndDestroy(); // messageStringholder
       
   792 		    
       
   793 		    buttonCode =  messageQuery->RunLD();
       
   794 		    }
       
   795 		else
       
   796 		  	{
       
   797 		  	if(!iNoteWrapper)
       
   798 		  			{
       
   799 		    		iNoteWrapper = DRM::CDrmUtilityGlobalNoteWrapper::NewL( iUtilityStringResourceReader );
       
   800         		}
       
   801         		
       
   802         iNoteWrapper->ShowMessageQueryL(aMessage, aHeader, aString);
       
   803 				}
       
   804 		return buttonCode;
       
   805     }
       
   806 
       
   807 
   679 
   808 // -----------------------------------------------------------------------------
   680 // -----------------------------------------------------------------------------
   809 // CDrmUtilityUI::CreateNoteForResourceL
   681 // CDrmUtilityUI::CreateNoteForResourceL
   810 // -----------------------------------------------------------------------------
   682 // -----------------------------------------------------------------------------
   811 //
   683 //