filemanager/View/src/CFileManagerGlobalDlgFull.cpp
branchRCL_3
changeset 20 491b3ed49290
parent 19 95243422089a
child 21 65326cf895ed
equal deleted inserted replaced
19:95243422089a 20:491b3ed49290
     1 /*
       
     2 * Copyright (c) 2006 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:  Global dialog handling
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <StringLoader.h>
       
    22 #include <AknGlobalNote.h>
       
    23 #include <AknGlobalConfirmationQuery.h>
       
    24 #include <AknGlobalProgressDialog.h>
       
    25 #include <avkon.rsg>
       
    26 #include <aknconsts.h>
       
    27 #include <avkon.mbg>
       
    28 #include "CFileManagerGlobalDlg.h"
       
    29 #include "CFileManagerGlobalQueryDlg.h"
       
    30 
       
    31 
       
    32 // CONSTANTS
       
    33 const TUint KCountdownTimeout = 1000000; // 1s
       
    34 const TInt KCountdownSteps = 30;
       
    35 const TInt KCountdownShowSKStep = 3;
       
    36 
       
    37 
       
    38 // ======== MEMBER FUNCTIONS ========
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // CFileManagerGlobalDlg::CFileManagerGlobalDlg
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 CFileManagerGlobalDlg::CFileManagerGlobalDlg() :
       
    45         CActive( EPriorityUserInput )
       
    46     {
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // CFileManagerGlobalDlg::NewL
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 EXPORT_C CFileManagerGlobalDlg* CFileManagerGlobalDlg::NewL()
       
    54     {
       
    55     CFileManagerGlobalDlg* self =
       
    56         new( ELeave ) CFileManagerGlobalDlg();
       
    57     CleanupStack::PushL( self );
       
    58     self->ConstructL();
       
    59     CleanupStack::Pop( self );
       
    60     return self;
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // CFileManagerGlobalDlg::ConstructL
       
    65 // ---------------------------------------------------------------------------
       
    66 // 
       
    67 void CFileManagerGlobalDlg::ConstructL()
       
    68     {
       
    69     CActiveScheduler::Add( this );
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CFileManagerGlobalDlg::~CFileManagerGlobalDlg
       
    74 // ---------------------------------------------------------------------------
       
    75 // 
       
    76 EXPORT_C CFileManagerGlobalDlg::~CFileManagerGlobalDlg()
       
    77     {
       
    78     Cancel();
       
    79     delete iQueryDialog;
       
    80     delete iProgressDialog;
       
    81     delete iCountdown;
       
    82     delete iCountdownText;
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // CFileManagerGlobalDlg::CancelDialog
       
    87 // ---------------------------------------------------------------------------
       
    88 // 
       
    89 EXPORT_C void CFileManagerGlobalDlg::CancelDialog()
       
    90     {
       
    91     delete iCountdown;
       
    92     iCountdown = NULL;
       
    93 
       
    94     if ( iQueryDialog )
       
    95         {
       
    96         iQueryDialog->CancelDialog();
       
    97         delete iQueryDialog;
       
    98         iQueryDialog = NULL;
       
    99         }
       
   100 
       
   101     if ( iProgressDialog )
       
   102         {
       
   103         iProgressDialog->CancelProgressDialog();
       
   104         delete iProgressDialog;
       
   105         iProgressDialog = NULL;
       
   106         }
       
   107 
       
   108     Cancel();
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------------------------
       
   112 // CFileManagerGlobalDlg::ShowDialogL
       
   113 // ---------------------------------------------------------------------------
       
   114 // 
       
   115 EXPORT_C void CFileManagerGlobalDlg::ShowDialogL(
       
   116         const CFileManagerGlobalDlg::TType aType,
       
   117         const TDesC& aText,
       
   118         const TInt aSkId )
       
   119     {
       
   120     CancelDialog();
       
   121 
       
   122     iType = aType;
       
   123 
       
   124     switch ( aType )
       
   125         {
       
   126         case ECountdownQuery:
       
   127             {
       
   128             iCountdownText = aText.AllocL();
       
   129             iQueryDialog = CFileManagerGlobalQueryDlg::NewL();
       
   130             iQueryDialog->ShowDialogL(
       
   131                 *iCountdownText,
       
   132                 R_AVKON_SOFTKEYS_EMPTY );
       
   133             iCountdownSteps = 0;
       
   134             StartCountdownL( KCountdownTimeout );
       
   135             break;
       
   136             }
       
   137         case EQuery:
       
   138             {
       
   139             iQueryDialog = CFileManagerGlobalQueryDlg::NewL();
       
   140             iQueryDialog->SetObserver( this );
       
   141             iQueryDialog->ShowDialogL(
       
   142                 aText,
       
   143                 aSkId );
       
   144             break;
       
   145             }
       
   146         case EQueryWithWarningIcon:
       
   147             {
       
   148             iQueryDialog = CFileManagerGlobalQueryDlg::NewL();
       
   149             iQueryDialog->SetObserver( this );
       
   150             iQueryDialog->ShowDialogL(
       
   151                 aText,
       
   152                 aSkId,
       
   153                 KAvkonBitmapFile,
       
   154                 EMbmAvkonQgn_note_warning,
       
   155                 EMbmAvkonQgn_note_warning_mask );
       
   156             break;
       
   157             }
       
   158         case EQueryWithInfoIcon:
       
   159             {
       
   160             iQueryDialog = CFileManagerGlobalQueryDlg::NewL();
       
   161             iQueryDialog->SetObserver( this );
       
   162             iQueryDialog->ShowDialogL(
       
   163                 aText,
       
   164                 aSkId,
       
   165                 KAvkonBitmapFile,
       
   166                 EMbmAvkonQgn_note_info,
       
   167                 EMbmAvkonQgn_note_info_mask );
       
   168             break;
       
   169             }
       
   170         case EProgressDialog:
       
   171             {
       
   172             iProgressDialog = CAknGlobalProgressDialog::NewL();
       
   173             if ( aSkId )
       
   174                 {
       
   175                 iProgressDialog->ShowProgressDialogL(
       
   176                     iStatus, aText, aSkId );
       
   177                 }
       
   178             else
       
   179                 {
       
   180                 iProgressDialog->ShowProgressDialogL(
       
   181                     iStatus, aText );
       
   182                 }
       
   183             SetActive();
       
   184             iFinalValue = 0;
       
   185             break;
       
   186             }
       
   187         case EErrorNote:
       
   188             {
       
   189             CAknGlobalNote* note = CAknGlobalNote::NewLC();
       
   190             note->SetTone( EAvkonSIDNoSound ); // no tone
       
   191             note->ShowNoteL( EAknGlobalErrorNote, aText );
       
   192             CleanupStack::PopAndDestroy( note );
       
   193             break;
       
   194             }
       
   195         case EInfoNote:
       
   196             {
       
   197             CAknGlobalNote* note = CAknGlobalNote::NewLC();
       
   198             note->SetTone( EAvkonSIDNoSound ); // no tone
       
   199             note->ShowNoteL( EAknGlobalInformationNote, aText );
       
   200             CleanupStack::PopAndDestroy( note );
       
   201             break;
       
   202             }
       
   203         default:
       
   204             {
       
   205             break;
       
   206             }
       
   207         }
       
   208     }
       
   209 
       
   210 // ---------------------------------------------------------------------------
       
   211 // CFileManagerGlobalDlg::ShowDialogL
       
   212 // ---------------------------------------------------------------------------
       
   213 // 
       
   214 EXPORT_C void CFileManagerGlobalDlg::ShowDialogL(
       
   215         const CFileManagerGlobalDlg::TType aType,
       
   216         const TInt aTextId,
       
   217         const TInt aSkId )
       
   218     {
       
   219     HBufC* text = StringLoader::LoadLC( aTextId );
       
   220     ShowDialogL( aType, *text, aSkId );
       
   221     CleanupStack::PopAndDestroy( text );
       
   222     }
       
   223 
       
   224 // ---------------------------------------------------------------------------
       
   225 // CFileManagerGlobalDlg::DoCancel
       
   226 // ---------------------------------------------------------------------------
       
   227 // 
       
   228 void CFileManagerGlobalDlg::DoCancel() 
       
   229 	{
       
   230     if ( iQueryDialog )
       
   231         {
       
   232         iQueryDialog->CancelDialog();
       
   233         }
       
   234     if ( iProgressDialog )
       
   235         {
       
   236         iProgressDialog->CancelProgressDialog();
       
   237         }
       
   238 	}
       
   239 
       
   240 // ---------------------------------------------------------------------------
       
   241 // CFileManagerGlobalDlg::RunL
       
   242 // ---------------------------------------------------------------------------
       
   243 // 
       
   244 void CFileManagerGlobalDlg::RunL()
       
   245     {
       
   246     CancelDialog();
       
   247     NotifyObserver( iStatus.Int() );
       
   248     }
       
   249 
       
   250 // ---------------------------------------------------------------------------
       
   251 // CFileManagerGlobalDlg::SetObserver
       
   252 // ---------------------------------------------------------------------------
       
   253 //
       
   254 EXPORT_C void CFileManagerGlobalDlg::SetObserver(
       
   255         MFileManagerGlobalDlgObserver* aObserver )
       
   256     {
       
   257     // This instance is not allowed to set by client
       
   258     if ( aObserver != this )
       
   259         {
       
   260         iObserver = aObserver;
       
   261         }
       
   262     }
       
   263 
       
   264 // ---------------------------------------------------------------------------
       
   265 // CFileManagerGlobalDlg::StartCountdownL
       
   266 // ---------------------------------------------------------------------------
       
   267 //
       
   268 void CFileManagerGlobalDlg::StartCountdownL( const TUint aTimeout )
       
   269     {
       
   270     delete iCountdown;
       
   271     iCountdown = NULL;
       
   272     iCountdown = CPeriodic::NewL( CActive::EPriorityStandard );
       
   273     iCountdown->Start( aTimeout, aTimeout, TCallBack( CountdownCB, this ) );
       
   274     }
       
   275 
       
   276 // ---------------------------------------------------------------------------
       
   277 // CFileManagerGlobalDlg::CountdownCB
       
   278 // ---------------------------------------------------------------------------
       
   279 // 
       
   280 TInt CFileManagerGlobalDlg::CountdownCB( TAny* aPtr )
       
   281     {
       
   282     CFileManagerGlobalDlg* self =
       
   283         static_cast< CFileManagerGlobalDlg* >( aPtr );
       
   284 
       
   285     TRAP_IGNORE( self->CountdownL() );
       
   286 
       
   287     return KErrNone;
       
   288     }
       
   289 
       
   290 // ---------------------------------------------------------------------------
       
   291 // CFileManagerGlobalDlg::CountdownL
       
   292 // ---------------------------------------------------------------------------
       
   293 // 
       
   294 void CFileManagerGlobalDlg::CountdownL()
       
   295     {
       
   296     if( iCountdownSteps < KCountdownSteps )
       
   297         {
       
   298         // Countdown in progress
       
   299         ++iCountdownSteps;
       
   300         if ( iCountdownSteps == KCountdownShowSKStep )
       
   301             {
       
   302             iProgressDialog = CAknGlobalProgressDialog::NewL();
       
   303             iProgressDialog->SetImageL(
       
   304                 KAvkonBitmapFile,
       
   305                 EMbmAvkonQgn_note_query,
       
   306                 EMbmAvkonQgn_note_query_mask );
       
   307             iProgressDialog->ShowProgressDialogL(
       
   308                 iStatus,
       
   309                 *iCountdownText,
       
   310                 R_AVKON_SOFTKEYS_YES_NO );
       
   311             SetActive();
       
   312 
       
   313             if ( iQueryDialog )
       
   314                 {
       
   315                 iQueryDialog->CancelDialog();
       
   316                 delete iQueryDialog;
       
   317                 iQueryDialog = NULL;
       
   318                 }
       
   319             }
       
   320 
       
   321         if ( iProgressDialog &&
       
   322             iCountdownSteps >= KCountdownShowSKStep )
       
   323             {
       
   324             iProgressDialog->UpdateProgressDialog(
       
   325                 iCountdownSteps, KCountdownSteps );
       
   326             }
       
   327         }
       
   328     else
       
   329         {
       
   330         // Countdown expired
       
   331         CancelDialog();
       
   332         NotifyObserver( EAknSoftkeyYes );
       
   333         }
       
   334     }
       
   335 
       
   336 // ---------------------------------------------------------------------------
       
   337 // CFileManagerGlobalDlg::UpdateProgressDialog
       
   338 // ---------------------------------------------------------------------------
       
   339 // 
       
   340 EXPORT_C void CFileManagerGlobalDlg::UpdateProgressDialog(
       
   341         const TInt aValue,
       
   342         const TInt aFinalValue )
       
   343     {
       
   344     if ( iProgressDialog )
       
   345         {
       
   346         if ( aFinalValue >= 0 )
       
   347             {
       
   348             iFinalValue = aFinalValue;
       
   349             }
       
   350         iProgressDialog->UpdateProgressDialog( aValue, iFinalValue );
       
   351         }
       
   352     }
       
   353 
       
   354 // ---------------------------------------------------------------------------
       
   355 // CFileManagerGlobalDlg::ProcessFinished
       
   356 // ---------------------------------------------------------------------------
       
   357 // 
       
   358 EXPORT_C void CFileManagerGlobalDlg::ProcessFinished()
       
   359     {
       
   360     if ( iProgressDialog )
       
   361         {
       
   362         iProgressDialog->ProcessFinished();
       
   363         delete iProgressDialog;
       
   364         iProgressDialog = NULL;
       
   365         }
       
   366     }
       
   367 
       
   368 // ---------------------------------------------------------------------------
       
   369 // CFileManagerGlobalDlg::NotifyObserver
       
   370 // ---------------------------------------------------------------------------
       
   371 // 
       
   372 void CFileManagerGlobalDlg::NotifyObserver( const TInt aValue )
       
   373     {
       
   374     if ( iObserver )
       
   375         {
       
   376         iObserver->HandleGlobalDlgResult( iType, aValue );
       
   377         }
       
   378     }
       
   379 
       
   380 // ---------------------------------------------------------------------------
       
   381 // CFileManagerGlobalDlg::HandleGlobalDlgResult
       
   382 // ---------------------------------------------------------------------------
       
   383 // 
       
   384 void CFileManagerGlobalDlg::HandleGlobalDlgResult(
       
   385         TInt /*aDlgType*/,
       
   386         TInt aDlgResult )
       
   387     {
       
   388     NotifyObserver( aDlgResult );
       
   389     }
       
   390 
       
   391 //  End of File