wmdrm/camese/wmdrmdlautils/src/wmdrmdlaui.cpp
changeset 23 493788a4a8a4
parent 0 95b198f216e5
equal deleted inserted replaced
5:79d62d1d7957 23:493788a4a8a4
    25 
    25 
    26 #include <eikfrlb.h>
    26 #include <eikfrlb.h>
    27 #include <eikfrlbd.h>
    27 #include <eikfrlbd.h>
    28 #include <coemain.h>
    28 #include <coemain.h>
    29 #include <bautils.h>
    29 #include <bautils.h>
    30 #include <stringloader.h>
    30 #include <StringLoader.h>
    31 #include <aknnotewrappers.h>
    31 #include <aknnotewrappers.h>
    32 #include <aknglobalnote.h>
    32 #include <AknGlobalNote.h>
    33 #include <aknlistquerydialog.h>
    33 #include <aknlistquerydialog.h>
    34 #include <badesca.h>
    34 #include <badesca.h>
    35 #include <gulicon.h>
    35 #include <gulicon.h>
    36 
    36 
    37 #include <data_caging_path_literals.hrh>
    37 #include <data_caging_path_literals.hrh>
    44 
    44 
    45 // CONSTANTS
    45 // CONSTANTS
    46 #ifndef RD_MULTIPLE_DRIVE
    46 #ifndef RD_MULTIPLE_DRIVE
    47 _LIT( KDriveZ, "z:" );
    47 _LIT( KDriveZ, "z:" );
    48 #else
    48 #else
    49 _LIT( KRomDriveFormatter, "%c:" );                                      
    49 _LIT( KRomDriveFormatter, "%c:" );
    50 #endif
    50 #endif
    51 
    51 
    52 _LIT( KWmdrmDlaUtilsResFileName, "wmdrmdlautils.rsc" );
    52 _LIT( KWmdrmDlaUtilsResFileName, "wmdrmdlautils.rsc" );
    53 
    53 
    54 // ======== LOCAL FUNCTIONS ========
    54 // ======== LOCAL FUNCTIONS ========
    65     iCoeEnv = CCoeEnv::Static();
    65     iCoeEnv = CCoeEnv::Static();
    66     if ( !iCoeEnv )
    66     if ( !iCoeEnv )
    67         {
    67         {
    68         User::Leave( KErrNotSupported );
    68         User::Leave( KErrNotSupported );
    69         }
    69         }
    70     
    70 
    71     //Create resource file path
    71     //Create resource file path
    72     TPtr wmdrmDlaUtilsResourcePtr( NULL, 0 );
    72     TPtr wmdrmDlaUtilsResourcePtr( NULL, 0 );
    73     iWmdrmDlaUtilsResourceFile = HBufC::NewL( KMaxFileName );
    73     iWmdrmDlaUtilsResourceFile = HBufC::NewL( KMaxFileName );
    74     wmdrmDlaUtilsResourcePtr.Set( iWmdrmDlaUtilsResourceFile->Des() );
    74     wmdrmDlaUtilsResourcePtr.Set( iWmdrmDlaUtilsResourceFile->Des() );
    75 
    75 
    81 #else //RD_MULTIPLE_DRIVE
    81 #else //RD_MULTIPLE_DRIVE
    82 
    82 
    83     TInt driveNumber( -1 );
    83     TInt driveNumber( -1 );
    84     TChar driveLetter;
    84     TChar driveLetter;
    85     //Get rom drive number
    85     //Get rom drive number
    86     User::LeaveIfError( 
    86     User::LeaveIfError(
    87             DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, 
    87             DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom,
    88                                         driveNumber ) );
    88                                         driveNumber ) );
    89     //Get drive letter from the drive number
    89     //Get drive letter from the drive number
    90     User::LeaveIfError( 
    90     User::LeaveIfError(
    91             iCoeEnv->FsSession().DriveToChar( driveNumber, 
    91             iCoeEnv->FsSession().DriveToChar( driveNumber,
    92                                               driveLetter ) );
    92                                               driveLetter ) );
    93     wmdrmDlaUtilsResourcePtr.AppendFormat( KRomDriveFormatter, 
    93     wmdrmDlaUtilsResourcePtr.AppendFormat( KRomDriveFormatter,
    94                                            (TUint)driveLetter );
    94                                            (TUint)driveLetter );
    95 
    95 
    96 #endif
    96 #endif
    97 
    97 
    98     //Append directory to the path
    98     //Append directory to the path
   101     wmdrmDlaUtilsResourcePtr.Append( KWmdrmDlaUtilsResFileName );
   101     wmdrmDlaUtilsResourcePtr.Append( KWmdrmDlaUtilsResFileName );
   102 
   102 
   103     TFileName resourceFile;
   103     TFileName resourceFile;
   104     resourceFile = *iWmdrmDlaUtilsResourceFile;
   104     resourceFile = *iWmdrmDlaUtilsResourceFile;
   105     //Find the correct language file for the resource
   105     //Find the correct language file for the resource
   106     BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), 
   106     BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(),
   107                                     resourceFile );
   107                                     resourceFile );
   108     //Add resource file to the CCoeEnv. 
   108     //Add resource file to the CCoeEnv.
   109     //Resource file must be removed from the CCoeEnv when we are done
   109     //Resource file must be removed from the CCoeEnv when we are done
   110     iWmdrmDlaUtilsResourceFileOffset 
   110     iWmdrmDlaUtilsResourceFileOffset
   111         = iCoeEnv->AddResourceFileL( resourceFile );
   111         = iCoeEnv->AddResourceFileL( resourceFile );
   112     
   112 
   113     iGlobalNote = CAknGlobalNote::NewL();
   113     iGlobalNote = CAknGlobalNote::NewL();
   114     }
   114     }
   115 
   115 
   116 // ---------------------------------------------------------------------------
   116 // ---------------------------------------------------------------------------
   117 // CWmDrmDlaUi::CWmDrmDlaUi
   117 // CWmDrmDlaUi::CWmDrmDlaUi
   166 
   166 
   167 // ---------------------------------------------------------------------------
   167 // ---------------------------------------------------------------------------
   168 // CWmDrmDlaUi::ShowErrorNoteL
   168 // CWmDrmDlaUi::ShowErrorNoteL
   169 // ---------------------------------------------------------------------------
   169 // ---------------------------------------------------------------------------
   170 //
   170 //
   171 EXPORT_C void CWmDrmDlaUi::ShowErrorNoteL( 
   171 EXPORT_C void CWmDrmDlaUi::ShowErrorNoteL(
   172     TInt aTextResourceId )
   172     TInt aTextResourceId )
   173     {
   173     {
   174     LOGFN( "CWmDrmDlaUi::ShowErrorNoteL" );
   174     LOGFN( "CWmDrmDlaUi::ShowErrorNoteL" );
   175     HBufC* msgText( StringLoader::LoadLC( aTextResourceId, iCoeEnv ) );
   175     HBufC* msgText( StringLoader::LoadLC( aTextResourceId, iCoeEnv ) );
   176     CAknResourceNoteDialog* note = new ( ELeave ) CAknErrorNote( ETrue );
   176     CAknResourceNoteDialog* note = new ( ELeave ) CAknErrorNote( ETrue );
   180 
   180 
   181 // ---------------------------------------------------------------------------
   181 // ---------------------------------------------------------------------------
   182 // CWmDrmDlaUi::ShowWaitNoteL
   182 // CWmDrmDlaUi::ShowWaitNoteL
   183 // ---------------------------------------------------------------------------
   183 // ---------------------------------------------------------------------------
   184 //
   184 //
   185 EXPORT_C void CWmDrmDlaUi::ShowWaitNoteL( 
   185 EXPORT_C void CWmDrmDlaUi::ShowWaitNoteL(
   186     TInt aTextResourceId,
   186     TInt aTextResourceId,
   187     MWmDrmDlaWaitNoteCallback* aCallback )
   187     MWmDrmDlaWaitNoteCallback* aCallback )
   188     {
   188     {
   189     LOGFN( "CWmDrmDlaUi::ShowWaitNoteL" );
   189     LOGFN( "CWmDrmDlaUi::ShowWaitNoteL" );
   190     if ( IsActive() )
   190     if ( IsActive() )
   191         {
   191         {
   192         User::Leave( KErrInUse );
   192         User::Leave( KErrInUse );
   193         }
   193         }
   194     iGlobalNoteText = StringLoader::LoadL( aTextResourceId, iCoeEnv );
   194     iGlobalNoteText = StringLoader::LoadL( aTextResourceId, iCoeEnv );
   195     iGlobalNoteId = iGlobalNote->ShowNoteL( iStatus, 
   195     iGlobalNoteId = iGlobalNote->ShowNoteL( iStatus,
   196                                             EAknGlobalWaitNote, 
   196                                             EAknGlobalWaitNote,
   197                                             *iGlobalNoteText );
   197                                             *iGlobalNoteText );
   198     iCallback = aCallback;
   198     iCallback = aCallback;
   199     SetActive();
   199     SetActive();
   200     }
   200     }
   201 
   201 
   211 
   211 
   212 // ---------------------------------------------------------------------------
   212 // ---------------------------------------------------------------------------
   213 // CWmDrmDlaUi::ShowListQueryL
   213 // CWmDrmDlaUi::ShowListQueryL
   214 // ---------------------------------------------------------------------------
   214 // ---------------------------------------------------------------------------
   215 //
   215 //
   216 EXPORT_C TInt CWmDrmDlaUi::ShowListQueryL( 
   216 EXPORT_C TInt CWmDrmDlaUi::ShowListQueryL(
   217     MDesCArray* aItems,
   217     MDesCArray* aItems,
   218     CArrayPtr<CGulIcon>* aIcons )
   218     CArrayPtr<CGulIcon>* aIcons )
   219     {
   219     {
   220     LOGFN( "CWmDrmDlaUi::ShowListQueryL" );
   220     LOGFN( "CWmDrmDlaUi::ShowListQueryL" );
   221     
   221 
   222     //This method takes the ownership of the input parameters
   222     //This method takes the ownership of the input parameters
   223     //Push the input parameters to the cleanupstack to make sure we won't leak
   223     //Push the input parameters to the cleanupstack to make sure we won't leak
   224     //memory
   224     //memory
   225     CleanupStack::PushL( aIcons );
   225     CleanupStack::PushL( aIcons );
   226     CleanupStack::PushL( aItems );
   226     CleanupStack::PushL( aItems );
   227     
   227 
   228     //Check that both inputs really exist.
   228     //Check that both inputs really exist.
   229     if ( !aItems || !aIcons )
   229     if ( !aItems || !aIcons )
   230         {
   230         {
   231         User::Leave( KErrArgument );
   231         User::Leave( KErrArgument );
   232         }
   232         }
   233     
   233 
   234     //Create the query with index parameter
   234     //Create the query with index parameter
   235     //Query will take the ownership of the items and icons
   235     //Query will take the ownership of the items and icons
   236     TInt index( 0 );
   236     TInt index( 0 );
   237     CAknListQueryDialog* dlg = new (ELeave) CAknListQueryDialog( &index );
   237     CAknListQueryDialog* dlg = new (ELeave) CAknListQueryDialog( &index );
   238     dlg->PrepareLC( R_WMDRMDLA_LIST_QUERY );
   238     dlg->PrepareLC( R_WMDRMDLA_LIST_QUERY );
   239     
   239 
   240     //Arrange cleanupstack in a way that query can take the ownership of the
   240     //Arrange cleanupstack in a way that query can take the ownership of the
   241     //items and icons
   241     //items and icons
   242     CleanupStack::Pop( 2, aItems ); //dlg, aItems
   242     CleanupStack::Pop( 2, aItems ); //dlg, aItems
   243     //Ownership of the items is transferred to query
   243     //Ownership of the items is transferred to query
   244     dlg->SetItemTextArray( aItems );
   244     dlg->SetItemTextArray( aItems );
   246     CleanupStack::PushL( dlg );
   246     CleanupStack::PushL( dlg );
   247     //Ownership of the icons in transferred to query
   247     //Ownership of the icons in transferred to query
   248     dlg->SetIconArrayL( aIcons );
   248     dlg->SetIconArrayL( aIcons );
   249     CleanupStack::Pop( 2, aIcons ); //dlg, aIcons
   249     CleanupStack::Pop( 2, aIcons ); //dlg, aIcons
   250     CleanupStack::PushL( dlg );
   250     CleanupStack::PushL( dlg );
   251     
   251 
   252     //Enable marquee scrolling for the text items
   252     //Enable marquee scrolling for the text items
   253     CEikFormattedCellListBox* listbox( 
   253     CEikFormattedCellListBox* listbox(
   254             static_cast<CEikFormattedCellListBox*>( dlg->ListBox() ) /* ,
   254             static_cast<CEikFormattedCellListBox*>( dlg->ListBox() ) /* ,
   255             EAknListBoxItemSpecificMenuDisabled */ );
   255             EAknListBoxItemSpecificMenuDisabled */ );
   256     listbox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
   256     listbox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
   257     
   257 
   258     //Launch the query
   258     //Launch the query
   259     TInt key( dlg->RunLD() );
   259     TInt key( dlg->RunLD() );
   260     LOG2( "key: %d", key );
   260     LOG2( "key: %d", key );
   261     //If user cancelled query, then return -1
   261     //If user cancelled query, then return -1
   262     //Else return index of the selected service
   262     //Else return index of the selected service
   288     CancelWaitNote();
   288     CancelWaitNote();
   289     if ( iCallback )
   289     if ( iCallback )
   290         {
   290         {
   291         iCallback->UserWaitNoteCancellation();
   291         iCallback->UserWaitNoteCancellation();
   292         }
   292         }
   293     }    
   293     }
   294 
   294 
   295 // ---------------------------------------------------------------------------
   295 // ---------------------------------------------------------------------------
   296 // CWmDrmDlaUi::RunError
   296 // CWmDrmDlaUi::RunError
   297 // ---------------------------------------------------------------------------
   297 // ---------------------------------------------------------------------------
   298 //
   298 //
   299 TInt CWmDrmDlaUi::RunError( TInt /*aError*/ )
   299 TInt CWmDrmDlaUi::RunError( TInt /*aError*/ )
   300     {
   300     {
   301     return KErrNone;
   301     return KErrNone;
   302     }
   302     }
   303 
   303 
   304     
   304 
   305 // ---------------------------------------------------------------------------
   305 // ---------------------------------------------------------------------------
   306 // CWmDrmDlaUi::CancelWaitNote
   306 // CWmDrmDlaUi::CancelWaitNote
   307 // ---------------------------------------------------------------------------
   307 // ---------------------------------------------------------------------------
   308 //
   308 //
   309 void CWmDrmDlaUi::CancelWaitNote()
   309 void CWmDrmDlaUi::CancelWaitNote()