commondrm/drmutility/src/drmutilityui.cpp
changeset 49 69d8e75812b7
parent 23 493788a4a8a4
child 84 b09186059647
equal deleted inserted replaced
48:c68061d56109 49:69d8e75812b7
    56 #include "drmutilityui.h"
    56 #include "drmutilityui.h"
    57 #include "drmutilitysecondarydisplay.h"
    57 #include "drmutilitysecondarydisplay.h"
    58 #include "DrmUtilityGlobalNoteWrapper.h"
    58 #include "DrmUtilityGlobalNoteWrapper.h"
    59 #include "DrmUtilityInfoNoteWrapper.h"
    59 #include "DrmUtilityInfoNoteWrapper.h"
    60 
    60 
       
    61 #include "drmuidialogids.h"
       
    62 #include "drmuidialogs.h"
       
    63 
    61 // CONSTANTS
    64 // CONSTANTS
    62 #ifndef RD_MULTIPLE_DRIVE
    65 #ifndef RD_MULTIPLE_DRIVE
    63 _LIT( KDriveZ, "z:" );
    66 _LIT( KDriveZ, "z:" );
    64 #else
    67 #else
    65 _LIT( KRomDriveFormatter, "%c:" );
    68 _LIT( KRomDriveFormatter, "%c:" );
    72 const TInt KDRMUtilityMaxDateFormatLen( 30 );
    75 const TInt KDRMUtilityMaxDateFormatLen( 30 );
    73 const TInt KDRMUtilityMaxDateLen( 30 );
    76 const TInt KDRMUtilityMaxDateLen( 30 );
    74 const TInt KDRMUtilityMaxTimeFormatLen( 30 );
    77 const TInt KDRMUtilityMaxTimeFormatLen( 30 );
    75 const TInt KDRMUtilityMaxTimeLen( 30 );
    78 const TInt KDRMUtilityMaxTimeLen( 30 );
    76 const TInt KDRMUtilityNoteMaxSize ( 256 );
    79 const TInt KDRMUtilityNoteMaxSize ( 256 );
       
    80 const TInt KNoValue = -1;
    77 
    81 
    78 #ifdef _DEBUG
    82 #ifdef _DEBUG
    79 // debug panic
    83 // debug panic
    80 _LIT( KDRMUtilityDebugPanicMessage, "DrmUtilityCommonDebugPanic" );
    84 _LIT( KDRMUtilityDebugPanicMessage, "DrmUtilityCommonDebugPanic" );
    81 const TInt KDRMUtilityDebugPanicCode( 1 );
    85 const TInt KDRMUtilityDebugPanicCode( 1 );
   311 //
   315 //
   312 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL(
   316 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL(
   313     TInt aTextResourceId,
   317     TInt aTextResourceId,
   314     TInt aValue )
   318     TInt aValue )
   315     {
   319     {
   316     TInt buttonCode( 0 );
   320     TInt resultCode( ECancelled );
   317 
   321 
   318     if ( iCoeEnv )
   322     CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() ); 
   319         {
   323     resultCode = drmUiDialog->ShowNoteL( aTextResourceId, KNullDesC, aValue );
   320         TPtr bufPtr( NULL, 0 );
   324     CleanupStack::PopAndDestroy( drmUiDialog );
   321 
   325     return resultCode;
   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     }
   326     }
   349 
   327 
   350 // -----------------------------------------------------------------------------
   328 // -----------------------------------------------------------------------------
   351 // CDrmUtilityUI::DisplayQueryL
   329 // CDrmUtilityUI::DisplayQueryL
   352 // -----------------------------------------------------------------------------
   330 // -----------------------------------------------------------------------------
   353 //
   331 //
   354 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL(
   332 EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL(
   355     TInt aTextResourceId,
   333     TInt aTextResourceId,
   356     const TDesC& aString )
   334     const TDesC& aString )
   357     {
   335     {
   358     TInt buttonCode( 0 );
   336     TInt resultCode( ECancelled );
   359 
   337 
   360     if ( iCoeEnv )
   338     CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
   361         {
   339     resultCode = drmUiDialog->ShowNoteL( aTextResourceId, aString, KNoValue );
   362         TPtr bufPtr( NULL, 0 );
   340     CleanupStack::PopAndDestroy( drmUiDialog );
   363 
   341     return resultCode;
   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     }
   342     }
   392 
   343 
   393 // -----------------------------------------------------------------------------
   344 // -----------------------------------------------------------------------------
   394 // CDrmUtilityUI::DisplayQueryL
   345 // CDrmUtilityUI::DisplayQueryL
   395 // -----------------------------------------------------------------------------
   346 // -----------------------------------------------------------------------------
   483     CDRMConstraint* aConstraint )
   434     CDRMConstraint* aConstraint )
   484     {
   435     {
   485     __ASSERT_DEBUG( aConstraint, User::Panic( KDRMUtilityDebugPanicMessage,
   436     __ASSERT_DEBUG( aConstraint, User::Panic( KDRMUtilityDebugPanicMessage,
   486                                               KDRMUtilityDebugPanicCode ) );
   437                                               KDRMUtilityDebugPanicCode ) );
   487 
   438 
   488     TInt buttonCode( 1 );
   439     TInt buttonCode( EOk );
   489 
   440 
   490     if ( aConstraint->iActiveConstraints & EConstraintEndTime )
   441     if ( aConstraint->iActiveConstraints & EConstraintEndTime )
   491         {
   442         {
   492         TBuf<KDRMUtilityMaxDateLen> dateFormat;
   443         TBuf<KDRMUtilityMaxDateLen> dateFormat;
   493         TBuf<KDRMUtilityMaxDateLen> endDate;
   444         TBuf<KDRMUtilityMaxDateLen> endDate;
   504             dateFormat = iAvkonStringResourceReader->ReadResourceString(
   455             dateFormat = iAvkonStringResourceReader->ReadResourceString(
   505                                                 R_QTN_DATE_USUAL_WITH_ZERO );
   456                                                 R_QTN_DATE_USUAL_WITH_ZERO );
   506             }
   457             }
   507 
   458 
   508         endTime.FormatL( endDate, dateFormat );
   459         endTime.FormatL( endDate, dateFormat );
   509         buttonCode = DisplayQueryL(R_DRM_QUERY_SET_AUTOMATED, endDate );
   460 
       
   461         // Qt dialog not implmented yet.
       
   462         buttonCode = DisplayQueryL( EQueryLicenceValidUntil, endDate );
   510         }
   463         }
   511     else if ( aConstraint->iActiveConstraints & EConstraintInterval )
   464     else if ( aConstraint->iActiveConstraints & EConstraintInterval )
   512         {
   465         {
   513         buttonCode = DisplayQueryWithIdL( R_DRM_QUERY_SET_AUTO_INTERVAL,
   466         // Qt dialog not implemented yet.
   514                                           R_DRMUTILITY_CONFIRMATION_QUERY );
   467         buttonCode = DisplayQueryL( EQueryValidForLimitedTime, KNoValue );
   515 
       
   516         }
   468         }
   517     return buttonCode;
   469     return buttonCode;
   518     }
   470     }
   519 
   471 
   520 // -----------------------------------------------------------------------------
   472 // -----------------------------------------------------------------------------
   554     startTime.FormatL( startTimeBuf, timeFormat );
   506     startTime.FormatL( startTimeBuf, timeFormat );
   555     startDateBuf.Append( KSpace );
   507     startDateBuf.Append( KSpace );
   556     startDateBuf.Append( startTimeBuf );
   508     startDateBuf.Append( startTimeBuf );
   557 
   509 
   558     // display note with start date
   510     // display note with start date
   559     DisplayNoteL( R_DRMUTILITY_USAGE_RIGHTS_IN_FUTURE, startDateBuf );
   511     // Qt dialog not implemented yet
       
   512     DisplayNoteL( EConfUnableToUse, startDateBuf );
   560     }
   513     }
   561 
   514 
   562 // -----------------------------------------------------------------------------
   515 // -----------------------------------------------------------------------------
   563 // CDrmUtilityUI::DisplayNoteL
   516 // CDrmUtilityUI::DisplayNoteL
   564 // -----------------------------------------------------------------------------
   517 // -----------------------------------------------------------------------------
   565 //
   518 //
   566 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL( TInt aTextResourceId )
   519 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL( TInt aTextResourceId )
   567     {
   520     {
   568     if ( iCoeEnv )
   521     CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
   569         {
   522     drmUiDialog->ShowNoteL( aTextResourceId, KNullDesC, KNoValue );
   570         HBufC* msgText( StringLoader::LoadLC( aTextResourceId, iCoeEnv ) );
   523     CleanupStack::PopAndDestroy( drmUiDialog );
   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     }
   524     }
   583 
   525 
   584 // -----------------------------------------------------------------------------
   526 // -----------------------------------------------------------------------------
   585 // CDrmUtilityUI::DisplayNoteL
   527 // CDrmUtilityUI::DisplayNoteL
   586 // -----------------------------------------------------------------------------
   528 // -----------------------------------------------------------------------------
   587 //
   529 //
   588 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL(
   530 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL(
   589     TInt aTextResourceId,
   531     TInt aTextResourceId,
   590     const TDesC& aString )
   532     const TDesC& aString )
   591     {
   533     {
   592     if ( iCoeEnv )
   534     CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
   593         {
   535     drmUiDialog->ShowNoteL( aTextResourceId, aString, KNoValue );
   594         HBufC* msgText( StringLoader::LoadLC( aTextResourceId,
   536     CleanupStack::PopAndDestroy( drmUiDialog );
   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     }
   537     }
   613 
   538 
   614 // -----------------------------------------------------------------------------
   539 // -----------------------------------------------------------------------------
   615 // CDrmUtilityUI::DisplayNoteL
   540 // CDrmUtilityUI::DisplayNoteL
   616 // -----------------------------------------------------------------------------
   541 // -----------------------------------------------------------------------------
   617 //
   542 //
   618 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL(
   543 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL(
   619     TInt aTextResourceId,
   544     TInt aTextResourceId,
   620     TInt aValue )
   545     TInt aValue )
   621     {
   546     {
   622     if ( iCoeEnv )
   547     CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
   623         {
   548     drmUiDialog->ShowNoteL( aTextResourceId, KNullDesC, aValue );
   624         HBufC* msgText( StringLoader::LoadLC( aTextResourceId,
   549     CleanupStack::PopAndDestroy( drmUiDialog );
   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     }
   550     }
   643 
   551 
   644 // -----------------------------------------------------------------------------
   552 // -----------------------------------------------------------------------------
   645 // CDrmUtilityUI::DisplayNoteL
   553 // CDrmUtilityUI::DisplayNoteL
   646 // -----------------------------------------------------------------------------
   554 // -----------------------------------------------------------------------------