landmarksui/uicontrols/src/lmkwaitdlglauncher.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     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:    LandmarksUi Content File -    Encapuslates the Wait dialog in an Active Object interface
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 // System Includes
       
    25 #include <lmkui.rsg>
       
    26 
       
    27 // User Includes
       
    28 #include "lmkwaitdlglauncher.h"
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CLmkWaitDialogLauncher::CLmkWaitDialogLauncher
       
    32 // C++ Overloaded constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CLmkWaitDialogLauncher::CLmkWaitDialogLauncher()
       
    37     :CActive( EPriorityStandard )
       
    38     {
       
    39     }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CLmkWaitDialogLauncher::~CLmkWaitDialogLauncher
       
    43 // C++ destructor
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 CLmkWaitDialogLauncher::~CLmkWaitDialogLauncher()
       
    47     {
       
    48     Cancel();
       
    49 
       
    50     if ( iSchedWait->IsStarted() )
       
    51         {
       
    52         iSchedWait->AsyncStop();
       
    53         }
       
    54 
       
    55     delete iSchedWait;
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CLmkWaitDialogLauncher* CLmkWaitDialogLauncher::NewL
       
    60 // Two phase constructor
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 CLmkWaitDialogLauncher* CLmkWaitDialogLauncher::NewL()
       
    64     {
       
    65     CLmkWaitDialogLauncher* self =
       
    66                 new ( ELeave ) CLmkWaitDialogLauncher();
       
    67     CleanupStack::PushL( self );
       
    68     self->ConstructL();
       
    69     CleanupStack::Pop( self );
       
    70     return self;
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // void CLmkWaitDialogLauncher::ConstructL
       
    75 // Second phase constructor
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 void CLmkWaitDialogLauncher::ConstructL()
       
    79     {
       
    80     iSchedWait = new ( ELeave )CActiveSchedulerWait;
       
    81     CActiveScheduler::Add( this);
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // void CLmkWaitDialogLauncher::StartWaitDialogL
       
    86 // Starts the wait dialog
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 void CLmkWaitDialogLauncher::StartWaitDialogL()
       
    90     {
       
    91     if( IsActive())
       
    92         {
       
    93         User::Leave( KErrInUse );
       
    94         }
       
    95 
       
    96     // Issue a request for Wait dialog launching
       
    97 
       
    98     TRequestStatus* status = &iStatus;
       
    99     User::RequestComplete( status, KErrNone );
       
   100     SetActive();
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // void CLmkWaitDialogLauncher::StartWaitDialogL
       
   105 // Stops the wait dialog
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 TInt CLmkWaitDialogLauncher::StopWaitDialogL()
       
   109     {
       
   110     if ( iWaitNote )
       
   111         {
       
   112         TRAPD( err, iWaitNote->ProcessFinishedL() );
       
   113         if (err != KErrNone)
       
   114     		{
       
   115 		    delete iWaitNote;
       
   116             iWaitNote = NULL;
       
   117             return KErrNone;
       
   118 	    	}
       
   119         }
       
   120 
       
   121     // Rechecking the Wait note is required since, the value might get modified
       
   122     // in DialogDismissedL call
       
   123 
       
   124     if( iWaitNote )
       
   125         {
       
   126         iSchedWait->Start();
       
   127         }
       
   128 
       
   129     // Return the Button ID with which the dialog was dismissed
       
   130     return iButtonId;
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // void CLmkWaitDialogLauncher::DialogDismissedL
       
   135 // Inherited from MProgressDialogCallback
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 void CLmkWaitDialogLauncher::DialogDismissedL( TInt aButtonId )
       
   139     {
       
   140     // Store the Button ID for later retrival
       
   141     iButtonId = aButtonId;
       
   142 
       
   143     if ( iSchedWait->IsStarted() )
       
   144         {
       
   145         iSchedWait->AsyncStop();
       
   146         }
       
   147     iWaitNote = NULL;
       
   148     if(iObserver)
       
   149     	{
       
   150     	iObserver->HandleDialogDismissed( iButtonId );
       
   151     	}
       
   152     }
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // void CLmkWaitDialogLauncher::RunL
       
   156 // Inherited from CActive
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 void CLmkWaitDialogLauncher::RunL()
       
   160     {
       
   161     if( iStatus.Int() == KErrNone )
       
   162         {
       
   163         // Launch the Wait dialog
       
   164         iWaitNote = new (ELeave) CAknWaitDialog
       
   165                       ((REINTERPRET_CAST(CEikDialog**,&iWaitNote)), ETrue );
       
   166         iWaitNote->SetCallback( this );
       
   167         if ( !iWaitNote->ExecuteLD( R_LMK_REQUEST_LOCATION ) )
       
   168             {
       
   169             //making iWaitNote null, since framework destroys waitnote
       
   170             //dialog on pressing cancel.
       
   171             iWaitNote = NULL;
       
   172             }
       
   173         }
       
   174     }
       
   175 
       
   176 // -----------------------------------------------------------------------------
       
   177 // void CLmkWaitDialogLauncher::DoCancel
       
   178 // Inherited from CActive
       
   179 // -----------------------------------------------------------------------------
       
   180 //
       
   181 void CLmkWaitDialogLauncher::DoCancel()
       
   182     {
       
   183     TRAP_IGNORE( iButtonId = StopWaitDialogL() );
       
   184     }
       
   185     
       
   186 // -----------------------------------------------------------------------------
       
   187 // void CLmkWaitDialogLauncher::SetObserver
       
   188 // -----------------------------------------------------------------------------
       
   189 void CLmkWaitDialogLauncher::SetObserver( MLmkWaitDialogLauncherObserver* aObserver)
       
   190 	{
       
   191 	iObserver = aObserver;
       
   192 	}
       
   193 
       
   194 // End of File