|
1 /* |
|
2 * Copyright (c) 2007 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: Async-Sync utility class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <eikenv.h> |
|
21 #include <eikappui.h> |
|
22 #include "lockappwait.h" |
|
23 |
|
24 // ---------------------------------------------------------- |
|
25 // Standard Symbian OS construction sequence |
|
26 // ---------------------------------------------------------- |
|
27 // |
|
28 CWait* CWait::NewL( ) |
|
29 { |
|
30 CWait* self = new (ELeave) CWait( ); |
|
31 CleanupStack::PushL( self ); |
|
32 self->ConstructL( ); |
|
33 CleanupStack::Pop( self ); |
|
34 return self; |
|
35 } |
|
36 |
|
37 // ---------------------------------------------------------- |
|
38 // 2nd phase constructor. |
|
39 // ---------------------------------------------------------- |
|
40 // |
|
41 void CWait::ConstructL( ) |
|
42 { |
|
43 CActiveScheduler::Add( this ); |
|
44 } |
|
45 |
|
46 // ---------------------------------------------------------- |
|
47 // Constructor |
|
48 // ---------------------------------------------------------- |
|
49 // |
|
50 CWait::CWait( ) : |
|
51 CActive(0) |
|
52 { |
|
53 // no implementation required |
|
54 } |
|
55 |
|
56 // ---------------------------------------------------------- |
|
57 // Destructor. |
|
58 // ---------------------------------------------------------- |
|
59 // |
|
60 CWait::~CWait( ) |
|
61 { |
|
62 Cancel( ); |
|
63 } |
|
64 |
|
65 // ---------------------------------------------------------- |
|
66 // |
|
67 // ---------------------------------------------------------- |
|
68 // |
|
69 TInt CWait::WaitForRequestL( ) |
|
70 { |
|
71 CWaitAbsorbingControl* absorbing = CWaitAbsorbingControl::NewLC( ); |
|
72 SetActive( ); |
|
73 iWait.Start( ); |
|
74 CleanupStack::PopAndDestroy( absorbing ); |
|
75 return iStatus.Int( ); |
|
76 } |
|
77 |
|
78 // ---------------------------------------------------------- |
|
79 // |
|
80 // ---------------------------------------------------------- |
|
81 // |
|
82 void CWait::RunL( ) |
|
83 { |
|
84 if ( iWait.IsStarted( ) ) |
|
85 { |
|
86 iWait.AsyncStop( ); |
|
87 } |
|
88 } |
|
89 |
|
90 // ---------------------------------------------------------- |
|
91 // Cancels code request |
|
92 // ---------------------------------------------------------- |
|
93 // |
|
94 void CWait::DoCancel( ) |
|
95 { |
|
96 if ( iWait.IsStarted( ) ) |
|
97 { |
|
98 iWait.AsyncStop( ); |
|
99 } |
|
100 } |
|
101 |
|
102 // ---------------------------------------------------------- |
|
103 // Sets active request type |
|
104 // ---------------------------------------------------------- |
|
105 // |
|
106 void CWait::SetRequestType(TInt aRequestType ) |
|
107 { |
|
108 iRequestType = aRequestType; |
|
109 } |
|
110 |
|
111 // ---------------------------------------------------------- |
|
112 // Gets active request type |
|
113 // ---------------------------------------------------------- |
|
114 // |
|
115 TInt CWait::GetRequestType( ) |
|
116 { |
|
117 return iRequestType; |
|
118 } |
|
119 |
|
120 // ---------------------------------------------------------- |
|
121 // Standard Symbian OS construction sequence |
|
122 // ---------------------------------------------------------- |
|
123 // |
|
124 CWaitAbsorbingControl* CWaitAbsorbingControl::NewLC( ) |
|
125 { |
|
126 CWaitAbsorbingControl* self= new (ELeave) CWaitAbsorbingControl(); |
|
127 CleanupStack::PushL( self ); |
|
128 self->ConstructL( ); |
|
129 return self; |
|
130 } |
|
131 |
|
132 // ---------------------------------------------------------- |
|
133 // |
|
134 // ---------------------------------------------------------- |
|
135 // |
|
136 CWaitAbsorbingControl::CWaitAbsorbingControl( ) |
|
137 { |
|
138 // no implementation required |
|
139 } |
|
140 |
|
141 // ---------------------------------------------------------- |
|
142 // Destructor. |
|
143 // ---------------------------------------------------------- |
|
144 // |
|
145 CWaitAbsorbingControl::~CWaitAbsorbingControl( ) |
|
146 { |
|
147 if ( iCoeEnv && iAppUi ) |
|
148 iAppUi->RemoveFromStack( this ); |
|
149 } |
|
150 |
|
151 // ---------------------------------------------------------- |
|
152 // |
|
153 // ---------------------------------------------------------- |
|
154 // |
|
155 void CWaitAbsorbingControl::ConstructL( ) |
|
156 { |
|
157 CreateWindowL( ); |
|
158 SetExtent( TPoint( 0, 0 ), TSize( 0, 0 ) ); |
|
159 ActivateL( ); |
|
160 SetPointerCapture( ETrue ); |
|
161 ClaimPointerGrab( ETrue ); |
|
162 iAppUi = iEikonEnv->EikAppUi(); |
|
163 iAppUi->AddToStackL( this, ECoeStackPriorityEnvironmentFilter ); |
|
164 } |
|
165 |
|
166 // ---------------------------------------------------------- |
|
167 // |
|
168 // ---------------------------------------------------------- |
|
169 // |
|
170 TKeyResponse CWaitAbsorbingControl::OfferKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) |
|
171 { |
|
172 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 ); |
|
173 return EKeyWasConsumed; |
|
174 } |
|
175 |
|
176 // End of file |