securitydialogs/Autolock/src/AutolockWait.cpp
branchRCL_3
changeset 21 09b1ac925e3f
parent 20 63339781d179
child 22 03674e5abf46
equal deleted inserted replaced
20:63339781d179 21:09b1ac925e3f
     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 
       
    19 
       
    20 
       
    21 #include    <e32base.h>
       
    22 #include	<eikenv.h>
       
    23 #include	<eikappui.h>
       
    24 #include	"AutolockWait.h"
       
    25 
       
    26 
       
    27 
       
    28 // ================= MEMBER FUNCTIONS =======================
       
    29 //
       
    30 // ----------------------------------------------------------
       
    31 // CWait::NewL()	
       
    32 // 
       
    33 // ----------------------------------------------------------
       
    34 // 
       
    35 CWait* CWait::NewL()
       
    36     {
       
    37     CWait* self = new(ELeave) CWait();
       
    38     CleanupStack::PushL(self);
       
    39     self->ConstructL();
       
    40     CleanupStack::Pop();
       
    41     return self;
       
    42     }
       
    43 //
       
    44 // ----------------------------------------------------------
       
    45 // CSystemLock::ConstructL()	
       
    46 // 
       
    47 // ----------------------------------------------------------
       
    48 // 
       
    49 void CWait::ConstructL()	
       
    50 	{	
       
    51 	CActiveScheduler::Add(this);			
       
    52 	}	
       
    53 //
       
    54 // ----------------------------------------------------------
       
    55 // CWait::CWait()
       
    56 // 
       
    57 // ----------------------------------------------------------
       
    58 //
       
    59 CWait::CWait() : CActive(0)
       
    60 	{ 
       
    61 	}
       
    62 //
       
    63 // ----------------------------------------------------------
       
    64 // CWait::~CWait()
       
    65 // Destructor
       
    66 // ----------------------------------------------------------
       
    67 //
       
    68 CWait::~CWait()
       
    69     {
       
    70         Cancel();
       
    71 	}
       
    72 //
       
    73 // ----------------------------------------------------------
       
    74 // CWait::StartWaitForRequest
       
    75 // 
       
    76 // ----------------------------------------------------------
       
    77 //
       
    78 TInt CWait::WaitForRequestL()
       
    79     {	
       
    80 	CWaitAbsorbingControl* absorbing = CWaitAbsorbingControl::NewLC();
       
    81 	SetActive();
       
    82 	iWait.Start();
       
    83 	CleanupStack::PopAndDestroy(absorbing);
       
    84 	return iStatus.Int();
       
    85 	}
       
    86 //
       
    87 // ----------------------------------------------------------
       
    88 // CWait::RunL()
       
    89 // 
       
    90 // ----------------------------------------------------------
       
    91 // 
       
    92 void CWait::RunL()
       
    93 	{
       
    94 	if(iWait.IsStarted())		
       
    95 	    iWait.AsyncStop();
       
    96 	}
       
    97 //
       
    98 // ----------------------------------------------------------
       
    99 // CWait::DoCancel()
       
   100 // Cancels code request
       
   101 // ----------------------------------------------------------
       
   102 //
       
   103 void CWait::DoCancel()
       
   104     {
       
   105     if(iWait.IsStarted())
       
   106 	    iWait.AsyncStop();
       
   107     }
       
   108 
       
   109 //
       
   110 // ----------------------------------------------------------
       
   111 // CWait::SetRequestType
       
   112 // Sets active request type
       
   113 // ----------------------------------------------------------
       
   114 //
       
   115 void CWait::SetRequestType(TInt aRequestType)
       
   116 {
       
   117     iRequestType = aRequestType;
       
   118 }
       
   119 
       
   120 //
       
   121 // ----------------------------------------------------------
       
   122 // CWait::GetRequestType
       
   123 // Gets active request type
       
   124 // ----------------------------------------------------------
       
   125 //
       
   126 TInt CWait::GetRequestType()
       
   127 {
       
   128     return iRequestType;
       
   129 }
       
   130 
       
   131 //
       
   132 // class CWaitAbsorbingControl
       
   133 //
       
   134 CWaitAbsorbingControl::CWaitAbsorbingControl()
       
   135 	{
       
   136 	}
       
   137 
       
   138 CWaitAbsorbingControl::~CWaitAbsorbingControl()
       
   139 	{
       
   140 	if (iCoeEnv && iAppUi)
       
   141 		iAppUi->RemoveFromStack(this);
       
   142 	}
       
   143 
       
   144 CWaitAbsorbingControl* CWaitAbsorbingControl::NewLC()
       
   145 	{
       
   146 	CWaitAbsorbingControl* self= new(ELeave) CWaitAbsorbingControl();
       
   147 	CleanupStack::PushL(self);
       
   148 	self->ConstructL();
       
   149 	return self;
       
   150 	}
       
   151 
       
   152 void CWaitAbsorbingControl::ConstructL()
       
   153 	{
       
   154 	CreateWindowL();
       
   155 	SetExtent(TPoint(0,0), TSize(0,0));
       
   156 	ActivateL();
       
   157 	SetPointerCapture(ETrue);
       
   158 	ClaimPointerGrab(ETrue);
       
   159 	iAppUi=iEikonEnv->EikAppUi();
       
   160 	iAppUi->AddToStackL(this, ECoeStackPriorityEnvironmentFilter);
       
   161 	}
       
   162 
       
   163 TKeyResponse CWaitAbsorbingControl::OfferKeyEventL(const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
       
   164 	{
       
   165 	return EKeyWasConsumed;
       
   166 	}
       
   167 
       
   168 // End of file