uifw/AvKon/src/AknDlgShut.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 // AKNDLGSHUT.CPP
       
    19 //
       
    20 // Copyright (c) 1997-2001 Symbian Ltd.  All rights reserved.
       
    21 //
       
    22 
       
    23 //
       
    24 // AknDialogShutter
       
    25 //
       
    26 
       
    27 #include "AknDlgShut.h"
       
    28 #include <eikenv.h>
       
    29 #include <eikappui.h>
       
    30 
       
    31 class CKludgeScheduler : public CBaActiveScheduler
       
    32 	{
       
    33 public:
       
    34 	inline TInt PublicLevel() const { return Level(); }
       
    35 	};
       
    36 
       
    37 TInt AknDialogShutter::StartLevel()
       
    38 	{
       
    39 	return ((CKludgeScheduler*)CActiveScheduler::Current())->PublicLevel();
       
    40 	}
       
    41 
       
    42 EXPORT_C void AknDialogShutter::ShutDialogsL(CEikonEnv& aEikEnv)
       
    43 	{
       
    44 	CEikAppUi* appUi=aEikEnv.EikAppUi();
       
    45 
       
    46 	for (TInt attempt=0; attempt<50; attempt++)		// maximum of 50 attempts to close dialogs
       
    47 		{
       
    48 		TInt startLevel=StartLevel();
       
    49 
       
    50 		if (appUi->IsDisplayingMenuOrDialog())
       
    51 			{
       
    52 			TKeyEvent key;
       
    53 			key.iCode=EKeyEscape;
       
    54 			key.iModifiers=0;
       
    55             key.iRepeats = 0;
       
    56             key.iScanCode = EStdKeyNull;
       
    57 			aEikEnv.SimulateKeyEventL(key, EEventKey);
       
    58 			}
       
    59 		else
       
    60 			{
       
    61 			break;							// stop if there are no more dialogs
       
    62 			}
       
    63 
       
    64 		if (StartLevel() > startLevel)
       
    65 			break;							// stop if a confirmation dialog has popped up
       
    66 		}
       
    67 	}
       
    68