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