mpxplugins/viewplugins/views/waitnotedialog/src/mpxwaitnotedialog.cpp
branchRCL_3
changeset 26 3de6c4cf6b67
equal deleted inserted replaced
25:14979e23cb5e 26:3de6c4cf6b67
       
     1 /*
       
     2 * Copyright (c)  Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Wait note dialog 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <AknIconUtils.h>
       
    21 #include <eikimage.h>
       
    22 #include <eikenv.h>
       
    23 #include <bautils.h>
       
    24 #include <AknUtils.h>
       
    25 #include <AknsUtils.h>
       
    26 #include <aknnotewrappers.h>
       
    27 #include <data_caging_path_literals.hrh>
       
    28 #include <mpxlog.h>
       
    29 #include <mpxcollectionutility.h>
       
    30 #include <aknSDData.h>
       
    31 #include <AknMediatorFacade.h>
       
    32 //#include <S32STRM.H>
       
    33 #include <mplayersecondarydisplayapi.h>
       
    34 
       
    35 #include <mpxwaitnotedialog.rsg>
       
    36 #include <mpxuser.h>
       
    37 #include "mpxwaitnotedialog.h"
       
    38 #include <mpxlog.h>
       
    39 
       
    40 // CONSTANTS
       
    41 _LIT( KMPXWaitNoteRscPath, "mpxwaitnotedialog.rsc" );
       
    42 
       
    43 
       
    44 // ======== MEMBER FUNCTIONS ========
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // Default constructor
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CMPXWaitNoteDialog::CMPXWaitNoteDialog( MMPXWaitNoteObserver* aObs,
       
    51                                         TWaitNoteType aType,
       
    52                                         TBool aVisibilityDelayOff  )
       
    53                                         : iObserver( aObs ),
       
    54                                           iWaitNoteType( aType ),
       
    55                                           iVisDelayOff( aVisibilityDelayOff ),
       
    56                                           iResourceOffset(0)
       
    57     {
       
    58 
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // Base Second Phase Constructor
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 void CMPXWaitNoteDialog::BaseConstructL()
       
    66     {
       
    67     // Collection Utility
       
    68     iCollection = MMPXCollectionUtility::NewL( this );
       
    69 
       
    70     // Resource file
       
    71     CEikonEnv* eikEnv = CEikonEnv::Static();
       
    72     TParse parse;
       
    73     parse.Set( KMPXWaitNoteRscPath, &KDC_APP_RESOURCE_DIR, NULL );
       
    74     TFileName resourceFile( parse.FullName() );
       
    75     User::LeaveIfError( MPXUser::CompleteWithDllPath( resourceFile ) );
       
    76     BaflUtils::NearestLanguageFile( eikEnv->FsSession(), resourceFile );
       
    77     iResourceOffset = eikEnv->AddResourceFileL( resourceFile );
       
    78     }
       
    79 
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // Virtual destructor
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 CMPXWaitNoteDialog::~CMPXWaitNoteDialog()
       
    86     {
       
    87     MPX_DEBUG1("CMPXWaitNoteDialog::~CMPXWaitNoteDialog <---");
       
    88     if( iWaitDialog )
       
    89         {
       
    90         iWaitDialog->SetCallback( NULL );
       
    91         TRAP_IGNORE( iWaitDialog->ProcessFinishedL() );
       
    92         }
       
    93     if( iProcessWaitDialog )
       
    94         {
       
    95         TRAP_IGNORE( iProcessWaitDialog->ProcessFinishedL() );
       
    96         }
       
    97 
       
    98     if( iResourceOffset )
       
    99         {
       
   100         CEikonEnv::Static()->DeleteResourceFile( iResourceOffset );
       
   101         }
       
   102 
       
   103     // Close any queries, if any
       
   104     TRAP_IGNORE( DismissQueryNoteL() );
       
   105 
       
   106     if( iCollection )
       
   107         {
       
   108         iCollection->Close();
       
   109         }
       
   110     MPX_DEBUG1("CMPXWaitNoteDialog::~CMPXWaitNoteDialog --->");
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // Execute the wait note
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 void CMPXWaitNoteDialog::ExecuteLD()
       
   118     {
       
   119     MPX_DEBUG1("CMPXWaitNoteDialog::ExecuteLD <--");
       
   120     // Construct the wait note
       
   121     if(iWaitDialog )
       
   122         {
       
   123         MPX_DEBUG1("CMPXWaitNoteDialog::ExecuteLD -- deleting dlg");
       
   124         iWaitDialog->SetCallback( NULL );
       
   125         iWaitDialog->ProcessFinishedL();
       
   126         iWaitDialog = NULL;
       
   127         }
       
   128 
       
   129     MPX_DEBUG1("CMPXWaitNoteDialog::ExecuteLD -- new dlg");
       
   130     iWaitDialog = new ( ELeave ) CAknWaitDialog(
       
   131                                         ( CEikDialog** )&iWaitDialog,
       
   132                                         iVisDelayOff );
       
   133     TInt dialogIndex = KErrNotFound;
       
   134     switch ( iWaitNoteType )
       
   135         {
       
   136         case EMPXScanningNote:
       
   137             {
       
   138             dialogIndex = EMPlayerNoteCreatingDb;
       
   139             break;
       
   140             }
       
   141 
       
   142         case EMPXOpeningNote:
       
   143             {
       
   144             dialogIndex = EMPlayerNoteOpeningDb;
       
   145             break;
       
   146             }
       
   147 
       
   148         case EMPXRefreshingNote:
       
   149             {
       
   150             dialogIndex = EMPlayerNoteUpdatingDb;
       
   151             break;
       
   152             }
       
   153 
       
   154         case EMPXCorruptScanningNote:
       
   155             {
       
   156             dialogIndex = EMPlayerNoteRebuildingDb;
       
   157             break;
       
   158             }
       
   159 
       
   160         case EMPXUsbEventNote:
       
   161             {
       
   162             dialogIndex = EMPlayerUSBConnectionInProgress;
       
   163             break;
       
   164             }
       
   165 
       
   166         case EMPXMTPEventNote:
       
   167             {
       
   168             dialogIndex = EMPlayerMTPConnectionInProgress;
       
   169             break;
       
   170             }
       
   171 
       
   172         case EMPXFormatScanningNote:
       
   173             {
       
   174             dialogIndex = EMPlayerFormatting;
       
   175             break;
       
   176             }
       
   177 
       
   178         case EMPXMediaNotAvailableNote:
       
   179         case EMPXNoteNotDefined:
       
   180         default:
       
   181             break;
       
   182         };
       
   183 
       
   184     if ( dialogIndex != KErrNotFound )
       
   185         {
       
   186         iWaitDialog->PublishDialogL(
       
   187             dialogIndex,
       
   188             KMPlayerNoteCategory );
       
   189 
       
   190         CAknMediatorFacade* covercl = AknMediatorFacade( iWaitDialog );
       
   191         if ( covercl )
       
   192             {
       
   193             covercl->BufStream().WriteInt32L( 0 );
       
   194             covercl->BufStream().CommitL();
       
   195             }
       
   196         }
       
   197     iWaitDialog->SetCallback( this );
       
   198     iWaitDialog->PrepareLC( R_MPX_GENERIC_WAIT_NOTE );
       
   199 
       
   200     PreNoteDisplayHandleL();
       
   201 
       
   202     iWaitDialog->RunLD();
       
   203     MPX_DEBUG1("CMPXWaitNoteDialog::ExecuteLD -->");
       
   204     }
       
   205 
       
   206 // ---------------------------------------------------------------------------
       
   207 // Cancel the wait note
       
   208 // ---------------------------------------------------------------------------
       
   209 //
       
   210 void CMPXWaitNoteDialog::CancelNoteL()
       
   211     {
       
   212     MPX_DEBUG1("CMPXWaitNoteDialog::CancelNoteL <---");
       
   213     if( iWaitDialog )
       
   214         {
       
   215         iWaitDialog->ProcessFinishedL();
       
   216         }
       
   217     }
       
   218 
       
   219 // ---------------------------------------------------------------------------
       
   220 // Check the destruction status of wait dialog
       
   221 // ---------------------------------------------------------------------------
       
   222 //
       
   223 TBool CMPXWaitNoteDialog::ReadyToDestroy()
       
   224     {
       
   225     // iWaitDialog will be updated by CAknWaitDialog self-destruction mech
       
   226     return iWaitDialog == NULL;
       
   227     }
       
   228 
       
   229 // ---------------------------------------------------------------------------
       
   230 // Do anything after the wait note is dismissed
       
   231 // ---------------------------------------------------------------------------
       
   232 //
       
   233 void CMPXWaitNoteDialog::PostNoteHandleL( TInt /*aButtonId*/ )
       
   234     {
       
   235     // Not used
       
   236     }
       
   237 
       
   238 // ---------------------------------------------------------------------------
       
   239 // Set the wait note CBA buttons
       
   240 // ---------------------------------------------------------------------------
       
   241 //
       
   242 void CMPXWaitNoteDialog::SetCBAL( TInt aCBAId )
       
   243     {
       
   244     if( iWaitDialog )
       
   245         {
       
   246         MEikButtonGroup* buttonGroup =
       
   247         iWaitDialog->ButtonGroupContainer().ButtonGroup();
       
   248         buttonGroup->SetCommandSetL( aCBAId );
       
   249         buttonGroup->AsControl()->DrawDeferred();
       
   250         }
       
   251     else
       
   252         {
       
   253         User::Leave( KErrNotReady );
       
   254         }
       
   255     }
       
   256 
       
   257 // ---------------------------------------------------------------------------
       
   258 // Set the wait note CBA text
       
   259 // ---------------------------------------------------------------------------
       
   260 //
       
   261 void CMPXWaitNoteDialog::SetTextL( const TDesC& aText )
       
   262     {
       
   263     if( iWaitDialog )
       
   264         {
       
   265         iWaitDialog->SetTextL( aText );
       
   266         }
       
   267     else
       
   268         {
       
   269         User::Leave( KErrNotReady );
       
   270         }
       
   271     }
       
   272 
       
   273 // ---------------------------------------------------------------------------
       
   274 // Set the wait note Icon
       
   275 // ---------------------------------------------------------------------------
       
   276 //
       
   277 void CMPXWaitNoteDialog::SetIconL( TNoteIconInfo& aIconInfo )
       
   278     {
       
   279     if( iWaitDialog )
       
   280         {
       
   281         MAknsSkinInstance* skin( AknsUtils::SkinInstance() );
       
   282 
       
   283         CFbsBitmap* bitmap = NULL;
       
   284         CFbsBitmap* mask = NULL;
       
   285 
       
   286         AknsUtils::CreateIconLC(
       
   287             skin,
       
   288             KAknsIIDNone,
       
   289             bitmap,
       
   290             mask,
       
   291             aIconInfo.bmpfile,
       
   292             aIconInfo.bitmapId,
       
   293             aIconInfo.maskId );
       
   294 
       
   295         CEikImage* icon = new ( ELeave ) CEikImage();
       
   296         CleanupStack::PushL( icon );
       
   297         icon->SetPicture( bitmap, mask );
       
   298         icon->SetPictureOwnedExternally( EFalse );
       
   299         iWaitDialog->SetImageL( icon );
       
   300         CleanupStack::Pop( 3 ); // icon, bitmap, mask
       
   301         }
       
   302     else
       
   303         {
       
   304         User::Leave( KErrNotReady );
       
   305         }
       
   306     }
       
   307 
       
   308 // ---------------------------------------------------------------------------
       
   309 // MMPXCollectionObserver
       
   310 // ---------------------------------------------------------------------------
       
   311 //
       
   312 void CMPXWaitNoteDialog::HandleCollectionMediaL(const CMPXMedia& /*aMedia*/,
       
   313                                                 TInt /*aError*/)
       
   314     {
       
   315     // Not used
       
   316     }
       
   317 
       
   318 // ---------------------------------------------------------------------------
       
   319 // MMPXCollectionObserver
       
   320 // ---------------------------------------------------------------------------
       
   321 //
       
   322 void CMPXWaitNoteDialog::HandleCollectionMessage(
       
   323     CMPXMessage* /*aMessage*/, TInt /*aError*/ )
       
   324     {
       
   325     // Not used
       
   326     }
       
   327 
       
   328 // ---------------------------------------------------------------------------
       
   329 // MMPXCollectionObserver
       
   330 // ---------------------------------------------------------------------------
       
   331 //
       
   332 void CMPXWaitNoteDialog::HandleOpenL(const CMPXMedia& /*aEntries*/,
       
   333                                      TInt /*aIndex*/,TBool /*aComplete*/,TInt /*aError*/)
       
   334     {
       
   335     // Not used
       
   336     }
       
   337 
       
   338 // ---------------------------------------------------------------------------
       
   339 // MMPXCollectionObserver
       
   340 // ---------------------------------------------------------------------------
       
   341 //
       
   342 void CMPXWaitNoteDialog::HandleOpenL(const CMPXCollectionPlaylist& /*aPlaylist*/,
       
   343                                      TInt /*aError*/)
       
   344     {
       
   345     // Not used
       
   346     }
       
   347 
       
   348 // ---------------------------------------------------------------------------
       
   349 // MProgressDialogCallback
       
   350 // ---------------------------------------------------------------------------
       
   351 //
       
   352 void CMPXWaitNoteDialog::DialogDismissedL( TInt aButtonId )
       
   353     {
       
   354     // Tell inherited class abut the event
       
   355     PostNoteHandleL( aButtonId );
       
   356 
       
   357     // Tell view that wait dialog is finished
       
   358     iObserver->HandleWaitNoteDismissedL();
       
   359     }
       
   360 
       
   361 // ---------------------------------------------------------------------------
       
   362 // Display a confirmation note
       
   363 // ---------------------------------------------------------------------------
       
   364 //
       
   365 void CMPXWaitNoteDialog::DisplayConfirmationNoteL( const TDesC& aLabel )
       
   366     {
       
   367     CAknConfirmationNote* note = new ( ELeave ) CAknConfirmationNote();
       
   368     note->ExecuteLD( aLabel );
       
   369     }
       
   370 
       
   371 // ---------------------------------------------------------------------------
       
   372 // Display a information note
       
   373 // ---------------------------------------------------------------------------
       
   374 //
       
   375 void CMPXWaitNoteDialog::DisplayInformationNoteL( const TDesC& aLabel )
       
   376     {
       
   377     CAknInformationNote* note = new ( ELeave ) CAknInformationNote();
       
   378     note->ExecuteLD( aLabel );
       
   379     }
       
   380 
       
   381 // ---------------------------------------------------------------------------
       
   382 // Display a query note
       
   383 // ---------------------------------------------------------------------------
       
   384 //
       
   385 TInt CMPXWaitNoteDialog::DisplayQueryNoteL( const TDesC& aQuery )
       
   386     {
       
   387     CAknQueryDialog* query = new( ELeave ) CAknQueryDialog();
       
   388     iQueryDialog = query;
       
   389 
       
   390     TInt rtn = query->ExecuteLD( R_MPX_QUERY_YES_NO ,
       
   391                                  aQuery );
       
   392     iQueryDialog = NULL;  // Dialog destroyed
       
   393     return rtn;
       
   394     }
       
   395 
       
   396 // ---------------------------------------------------------------------------
       
   397 // Dismiss the current query note
       
   398 // ---------------------------------------------------------------------------
       
   399 //
       
   400 void CMPXWaitNoteDialog::DismissQueryNoteL()
       
   401     {
       
   402     if( iQueryDialog )
       
   403         {
       
   404         iQueryDialog->DismissQueryL();
       
   405         }
       
   406     }
       
   407 
       
   408 // ---------------------------------------------------------------------------
       
   409 // Display a generic note dialog
       
   410 // ---------------------------------------------------------------------------
       
   411 //
       
   412 void CMPXWaitNoteDialog::DisplayNoteDialogL( TInt aDlgRsc, const TDesC& aLabel,
       
   413                                              CAknNoteDialog::TTone aTone )
       
   414     {
       
   415     iObserver->NoteDialogL( iNoteDialog, aDlgRsc, aTone );
       
   416     if ( iNoteDialog )
       
   417         {
       
   418         iNoteDialog->SetTextL( aLabel );
       
   419         }
       
   420     }
       
   421 
       
   422 // ---------------------------------------------------------------------------
       
   423 // Display a generic note dialog
       
   424 // ---------------------------------------------------------------------------
       
   425 //
       
   426 void CMPXWaitNoteDialog::DisplayNoteDialogL( TInt aDlgRsc, TInt aTextRsc,
       
   427                                              TInt aItemsAdded, const TDesC& aLabel,
       
   428                                              CAknNoteDialog::TTone aTone )
       
   429     {
       
   430     MPX_DEBUG1("CMPXWaitNoteDialog::DisplayNoteDialogL for COVER DISPLAY--->");
       
   431 
       
   432     CAknNoteDialog* note = new ( ELeave ) CAknNoteDialog( aTone );
       
   433     note->PrepareLC( aDlgRsc );
       
   434     note->SetTextL( aLabel );
       
   435     if ( aTextRsc == R_MPX_REFRESHING_DB_STOPPED_TXT )
       
   436         {
       
   437         note->PublishDialogL(
       
   438             EMPlayerNoteDbUpdateStopped,
       
   439             KMPlayerNoteCategory);
       
   440         }
       
   441     else if ( aTextRsc == R_MPX_SCANNING_STOPPED_TXT )
       
   442         {
       
   443         note->PublishDialogL(
       
   444             EMPlayerNoteDbSearchStoppedItemFound,
       
   445             KMPlayerNoteCategory);
       
   446         }
       
   447     else if ( aTextRsc == R_MPX_SCANNING_COMPLETE_TXT )
       
   448         {
       
   449         TInt noteId( EMPlayerNoteDbCreationCompleteEmpty );
       
   450         if ( aItemsAdded > 0 )
       
   451             {
       
   452             noteId = EMPlayerNoteDbCreationComplete;
       
   453             };
       
   454 
       
   455         note->PublishDialogL(
       
   456             noteId,
       
   457             KMPlayerNoteCategory);
       
   458         }
       
   459     else if ( aTextRsc == R_MPX_REFRESHING_DB_COMPLETE_TXT )
       
   460         {
       
   461         note->PublishDialogL(
       
   462             EMPlayerNoteDbUpdateComplete,
       
   463             KMPlayerNoteCategory);
       
   464         }
       
   465 
       
   466     if ( aTextRsc != KErrNotFound )
       
   467         {
       
   468         CAknMediatorFacade* covercl = AknMediatorFacade( note );
       
   469         if ( covercl )
       
   470             {
       
   471             covercl->BufStream().WriteInt32L( aItemsAdded );
       
   472             covercl->BufStream().CommitL();
       
   473             }
       
   474         }
       
   475 
       
   476     note->RunLD();
       
   477     MPX_DEBUG1("<--CMPXWaitNoteDialog::DisplayNoteDialogL for COVER DISPLAY End");
       
   478     }
       
   479 
       
   480 // ---------------------------------------------------------------------------
       
   481 // Display a generic process wait dialog
       
   482 // ---------------------------------------------------------------------------
       
   483 //
       
   484 void CMPXWaitNoteDialog::DisplayProcessWaitDialogL( TInt aDlgRsc, 
       
   485                                              const TDesC& aLabel,
       
   486                                              CAknWaitDialog::TTone aTone )
       
   487     {
       
   488     if(iProcessWaitDialog )
       
   489         {        
       
   490         iProcessWaitDialog->ProcessFinishedL();
       
   491         iProcessWaitDialog = NULL;
       
   492         }
       
   493 
       
   494     iProcessWaitDialog = new ( ELeave ) CAknWaitDialog(
       
   495                                     ( CEikDialog** )&iProcessWaitDialog,
       
   496                                     EFalse );
       
   497     
       
   498     iProcessWaitDialog->PrepareLC( aDlgRsc );
       
   499     iProcessWaitDialog->SetTextL( aLabel );
       
   500     iProcessWaitDialog->RunLD();
       
   501     }
       
   502 
       
   503 // ---------------------------------------------------------------------------
       
   504 // Cancel the process wait dialog
       
   505 // ---------------------------------------------------------------------------
       
   506 //
       
   507 void CMPXWaitNoteDialog::CancelProcessWaitDialogL()
       
   508     {
       
   509     if( iProcessWaitDialog )
       
   510         {
       
   511         iProcessWaitDialog->ProcessFinishedL();
       
   512         }
       
   513     }
       
   514 // End of file
       
   515