commondrm/drmutility/src/drmutilityui.cpp
branchRCL_3
changeset 27 1481bf457703
parent 26 1221b68b8a5f
equal deleted inserted replaced
26:1221b68b8a5f 27:1481bf457703
    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> 
    35 
    36 
    36 // secondary display support
    37 // secondary display support
    37 #include <AknMediatorFacade.h>
    38 #include <AknMediatorFacade.h>
    38 #include <featmgr.h>
    39 #include <featmgr.h>
    39 #include <aknSDData.h>
    40 #include <aknSDData.h>
    56 #include "drmutilityui.h"
    57 #include "drmutilityui.h"
    57 #include "drmutilitysecondarydisplay.h"
    58 #include "drmutilitysecondarydisplay.h"
    58 #include "DrmUtilityGlobalNoteWrapper.h"
    59 #include "DrmUtilityGlobalNoteWrapper.h"
    59 #include "DrmUtilityInfoNoteWrapper.h"
    60 #include "DrmUtilityInfoNoteWrapper.h"
    60 
    61 
    61 #include "drmuidialogids.h"
       
    62 #include "drmuidialogs.h"
       
    63 
       
    64 // CONSTANTS
    62 // CONSTANTS
    65 #ifndef RD_MULTIPLE_DRIVE
    63 #ifndef RD_MULTIPLE_DRIVE
    66 _LIT( KDriveZ, "z:" );
    64 _LIT( KDriveZ, "z:" );
    67 #else
    65 #else
    68 _LIT( KRomDriveFormatter, "%c:" );
    66 _LIT( KRomDriveFormatter, "%c:" );
    75 const TInt KDRMUtilityMaxDateFormatLen( 30 );
    73 const TInt KDRMUtilityMaxDateFormatLen( 30 );
    76 const TInt KDRMUtilityMaxDateLen( 30 );
    74 const TInt KDRMUtilityMaxDateLen( 30 );
    77 const TInt KDRMUtilityMaxTimeFormatLen( 30 );
    75 const TInt KDRMUtilityMaxTimeFormatLen( 30 );
    78 const TInt KDRMUtilityMaxTimeLen( 30 );
    76 const TInt KDRMUtilityMaxTimeLen( 30 );
    79 const TInt KDRMUtilityNoteMaxSize ( 256 );
    77 const TInt KDRMUtilityNoteMaxSize ( 256 );
    80 const TInt KNoValue = -1;
       
    81 
    78 
    82 #ifdef _DEBUG
    79 #ifdef _DEBUG
    83 // debug panic
    80 // debug panic
    84 _LIT( KDRMUtilityDebugPanicMessage, "DrmUtilityCommonDebugPanic" );
    81 _LIT( KDRMUtilityDebugPanicMessage, "DrmUtilityCommonDebugPanic" );
    85 const TInt KDRMUtilityDebugPanicCode( 1 );
    82 const TInt KDRMUtilityDebugPanicCode( 1 );
   233 
   230 
   234     iNoteList.ResetAndDestroy();
   231     iNoteList.ResetAndDestroy();
   235     iNoteList.Close();
   232     iNoteList.Close();
   236 
   233 
   237     FeatureManager::UnInitializeLib();
   234     FeatureManager::UnInitializeLib();
       
   235     delete iNoteWrapper;	
       
   236     	
   238     }
   237     }
   239 
   238 
   240 // -----------------------------------------------------------------------------
   239 // -----------------------------------------------------------------------------
   241 // CDrmUtilityUI::DisplayQueryWithIdL
   240 // CDrmUtilityUI::DisplayQueryWithIdL
   242 // -----------------------------------------------------------------------------
   241 // -----------------------------------------------------------------------------
   315 //
   314 //
   316 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL(
   315 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL(
   317     TInt aTextResourceId,
   316     TInt aTextResourceId,
   318     TInt aValue )
   317     TInt aValue )
   319     {
   318     {
   320     TInt resultCode( ECancelled );
   319     TInt buttonCode( 0 );
   321 
   320 
   322     CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() ); 
   321     if ( iCoeEnv )
   323     resultCode = drmUiDialog->ShowNoteL( aTextResourceId, KNullDesC, aValue );
   322         {
   324     CleanupStack::PopAndDestroy( drmUiDialog );
   323         TPtr bufPtr( NULL, 0 );
   325     return resultCode;
   324 
       
   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;
   326     }
   351     }
   327 
   352 
   328 // -----------------------------------------------------------------------------
   353 // -----------------------------------------------------------------------------
   329 // CDrmUtilityUI::DisplayQueryL
   354 // CDrmUtilityUI::DisplayQueryL
   330 // -----------------------------------------------------------------------------
   355 // -----------------------------------------------------------------------------
   331 //
   356 //
   332 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL(
   357 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL(
   333     TInt aTextResourceId,
   358     TInt aTextResourceId,
   334     const TDesC& aString )
   359     const TDesC& aString )
   335     {
   360     {
   336     TInt resultCode( ECancelled );
   361     TInt buttonCode( 0 );
   337 
   362 
   338     CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
   363     if ( iCoeEnv )
   339     resultCode = drmUiDialog->ShowNoteL( aTextResourceId, aString, KNoValue );
   364         {
   340     CleanupStack::PopAndDestroy( drmUiDialog );
   365         TPtr bufPtr( NULL, 0 );
   341     return resultCode;
   366 
       
   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;
   342     }
   394     }
   343 
   395 
   344 // -----------------------------------------------------------------------------
   396 // -----------------------------------------------------------------------------
   345 // CDrmUtilityUI::DisplayQueryL
   397 // CDrmUtilityUI::DisplayQueryL
   346 // -----------------------------------------------------------------------------
   398 // -----------------------------------------------------------------------------
   434     CDRMConstraint* aConstraint )
   486     CDRMConstraint* aConstraint )
   435     {
   487     {
   436     __ASSERT_DEBUG( aConstraint, User::Panic( KDRMUtilityDebugPanicMessage,
   488     __ASSERT_DEBUG( aConstraint, User::Panic( KDRMUtilityDebugPanicMessage,
   437                                               KDRMUtilityDebugPanicCode ) );
   489                                               KDRMUtilityDebugPanicCode ) );
   438 
   490 
   439     TInt buttonCode( EOk );
   491     TInt buttonCode( 1 );
   440 
   492 
   441     if ( aConstraint->iActiveConstraints & EConstraintEndTime )
   493     if ( aConstraint->iActiveConstraints & EConstraintEndTime )
   442         {
   494         {
   443         TBuf<KDRMUtilityMaxDateLen> dateFormat;
   495         TBuf<KDRMUtilityMaxDateLen> dateFormat;
   444         TBuf<KDRMUtilityMaxDateLen> endDate;
   496         TBuf<KDRMUtilityMaxDateLen> endDate;
   455             dateFormat = iAvkonStringResourceReader->ReadResourceString(
   507             dateFormat = iAvkonStringResourceReader->ReadResourceString(
   456                                                 R_QTN_DATE_USUAL_WITH_ZERO );
   508                                                 R_QTN_DATE_USUAL_WITH_ZERO );
   457             }
   509             }
   458 
   510 
   459         endTime.FormatL( endDate, dateFormat );
   511         endTime.FormatL( endDate, dateFormat );
   460 
   512         buttonCode = DisplayQueryL(R_DRM_QUERY_SET_AUTOMATED, endDate );
   461         // Qt dialog not implmented yet.
       
   462         buttonCode = DisplayQueryL( EQueryLicenceValidUntil, endDate );
       
   463         }
   513         }
   464     else if ( aConstraint->iActiveConstraints & EConstraintInterval )
   514     else if ( aConstraint->iActiveConstraints & EConstraintInterval )
   465         {
   515         {
   466         // Qt dialog not implemented yet.
   516         buttonCode = DisplayQueryWithIdL( R_DRM_QUERY_SET_AUTO_INTERVAL,
   467         buttonCode = DisplayQueryL( EQueryValidForLimitedTime, KNoValue );
   517                                           R_DRMUTILITY_CONFIRMATION_QUERY );
       
   518 
   468         }
   519         }
   469     return buttonCode;
   520     return buttonCode;
   470     }
   521     }
   471 
   522 
   472 // -----------------------------------------------------------------------------
   523 // -----------------------------------------------------------------------------
   506     startTime.FormatL( startTimeBuf, timeFormat );
   557     startTime.FormatL( startTimeBuf, timeFormat );
   507     startDateBuf.Append( KSpace );
   558     startDateBuf.Append( KSpace );
   508     startDateBuf.Append( startTimeBuf );
   559     startDateBuf.Append( startTimeBuf );
   509 
   560 
   510     // display note with start date
   561     // display note with start date
   511     // Qt dialog not implemented yet
   562     DisplayNoteL( R_DRMUTILITY_USAGE_RIGHTS_IN_FUTURE, startDateBuf );
   512     DisplayNoteL( EConfUnableToUse, startDateBuf );
       
   513     }
   563     }
   514 
   564 
   515 // -----------------------------------------------------------------------------
   565 // -----------------------------------------------------------------------------
   516 // CDrmUtilityUI::DisplayNoteL
   566 // CDrmUtilityUI::DisplayNoteL
   517 // -----------------------------------------------------------------------------
   567 // -----------------------------------------------------------------------------
   518 //
   568 //
   519 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL( TInt aTextResourceId )
   569 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL( TInt aTextResourceId )
   520     {
   570     {
   521     CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
   571     if ( iCoeEnv )
   522     drmUiDialog->ShowNoteL( aTextResourceId, KNullDesC, KNoValue );
   572         {
   523     CleanupStack::PopAndDestroy( drmUiDialog );
   573         HBufC* msgText( StringLoader::LoadLC( aTextResourceId, iCoeEnv ) );
       
   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         }
   524     }
   585     }
   525 
   586 
   526 // -----------------------------------------------------------------------------
   587 // -----------------------------------------------------------------------------
   527 // CDrmUtilityUI::DisplayNoteL
   588 // CDrmUtilityUI::DisplayNoteL
   528 // -----------------------------------------------------------------------------
   589 // -----------------------------------------------------------------------------
   529 //
   590 //
   530 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL(
   591 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL(
   531     TInt aTextResourceId,
   592     TInt aTextResourceId,
   532     const TDesC& aString )
   593     const TDesC& aString )
   533     {
   594     {
   534     CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
   595     if ( iCoeEnv )
   535     drmUiDialog->ShowNoteL( aTextResourceId, aString, KNoValue );
   596         {
   536     CleanupStack::PopAndDestroy( drmUiDialog );
   597         HBufC* msgText( StringLoader::LoadLC( aTextResourceId,
       
   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         }
   537     }
   615     }
   538 
   616 
   539 // -----------------------------------------------------------------------------
   617 // -----------------------------------------------------------------------------
   540 // CDrmUtilityUI::DisplayNoteL
   618 // CDrmUtilityUI::DisplayNoteL
   541 // -----------------------------------------------------------------------------
   619 // -----------------------------------------------------------------------------
   542 //
   620 //
   543 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL(
   621 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL(
   544     TInt aTextResourceId,
   622     TInt aTextResourceId,
   545     TInt aValue )
   623     TInt aValue )
   546     {
   624     {
   547     CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
   625     if ( iCoeEnv )
   548     drmUiDialog->ShowNoteL( aTextResourceId, KNullDesC, aValue );
   626         {
   549     CleanupStack::PopAndDestroy( drmUiDialog );
   627         HBufC* msgText( StringLoader::LoadLC( aTextResourceId,
       
   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         }
   550     }
   645     }
   551 
   646 
   552 // -----------------------------------------------------------------------------
   647 // -----------------------------------------------------------------------------
   553 // CDrmUtilityUI::DisplayNoteL
   648 // CDrmUtilityUI::DisplayNoteL
   554 // -----------------------------------------------------------------------------
   649 // -----------------------------------------------------------------------------
   674     {
   769     {
   675     return 0;
   770     return 0;
   676     }
   771     }
   677 
   772 
   678 #endif  // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
   773 #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 
   679 
   807 
   680 // -----------------------------------------------------------------------------
   808 // -----------------------------------------------------------------------------
   681 // CDrmUtilityUI::CreateNoteForResourceL
   809 // CDrmUtilityUI::CreateNoteForResourceL
   682 // -----------------------------------------------------------------------------
   810 // -----------------------------------------------------------------------------
   683 //
   811 //