|
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: For dialog shutter. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <eikenv.h> |
|
20 #include <eikappui.h> |
|
21 |
|
22 #include "calendialogshutter.h" |
|
23 |
|
24 const TInt KMaxNumEscKeysToSend = 50; |
|
25 |
|
26 // ================= MEMBER FUNCTIONS ======================= |
|
27 |
|
28 // --------------------------------------------------------- |
|
29 // CCalenDialogShutter::CCalenDialogShutter |
|
30 // C++ default constructor |
|
31 // (other items were commented in a header). |
|
32 // --------------------------------------------------------- |
|
33 // |
|
34 CCalenDialogShutter::CCalenDialogShutter( CEikonEnv* aEikEnv ) |
|
35 : CActive(EPriorityStandard) // Standard priority |
|
36 , iEikon( aEikEnv ) |
|
37 , iStartLevel( StartLevel() ) |
|
38 { |
|
39 } |
|
40 |
|
41 // ---------------------------------------------------------------------------- |
|
42 // CCalenDialogShutter::NewLC |
|
43 // (other items were commented in a header). |
|
44 // ---------------------------------------------------------------------------- |
|
45 // |
|
46 CCalenDialogShutter* CCalenDialogShutter::NewLC( CEikonEnv* aEikEnv ) |
|
47 { |
|
48 CCalenDialogShutter* self = new (ELeave) CCalenDialogShutter( aEikEnv ); |
|
49 CleanupStack::PushL(self); |
|
50 self->ConstructL(); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // ---------------------------------------------------------------------------- |
|
55 // CCalenDialogShutter::NewL |
|
56 // 1st phase of construction |
|
57 // (other items were commented in a header). |
|
58 // ---------------------------------------------------------------------------- |
|
59 // |
|
60 CCalenDialogShutter* CCalenDialogShutter::NewL( CEikonEnv* aEikEnv ) |
|
61 { |
|
62 CCalenDialogShutter* self = CCalenDialogShutter::NewLC( aEikEnv ); |
|
63 CleanupStack::Pop(); // self; |
|
64 return self; |
|
65 } |
|
66 |
|
67 // ---------------------------------------------------------------------------- |
|
68 // CCalenDialogShutter::ConstructL |
|
69 // Second phase of construction |
|
70 // (other items were commented in a header). |
|
71 // ---------------------------------------------------------------------------- |
|
72 // |
|
73 void CCalenDialogShutter::ConstructL() |
|
74 { |
|
75 CActiveScheduler::Add(this); // Add to scheduler |
|
76 } |
|
77 |
|
78 // ---------------------------------------------------------------------------- |
|
79 // CCalenDialogShutter::~CCalenDialogShutter |
|
80 // Destructor |
|
81 // (other items were commented in a header). |
|
82 // ---------------------------------------------------------------------------- |
|
83 // |
|
84 CCalenDialogShutter::~CCalenDialogShutter() |
|
85 { |
|
86 Cancel(); // Cancel any request, if outstanding |
|
87 } |
|
88 |
|
89 // ---------------------------------------------------------------------------- |
|
90 // CCalenDialogShutter::DoCancel |
|
91 // Cancel method to handle the user selection |
|
92 // (other items were commented in a header). |
|
93 // ---------------------------------------------------------------------------- |
|
94 // |
|
95 void CCalenDialogShutter::DoCancel() |
|
96 { |
|
97 iCount = 0; |
|
98 } |
|
99 |
|
100 // ---------------------------------------------------------------------------- |
|
101 // CCalenDialogShutter::Queue |
|
102 // (other items were commented in a header). |
|
103 // ---------------------------------------------------------------------------- |
|
104 // |
|
105 void CCalenDialogShutter::Queue() |
|
106 { |
|
107 if (!IsActive()) |
|
108 { |
|
109 SetActive(); |
|
110 TRequestStatus* status = &iStatus; |
|
111 User::RequestComplete( status, KErrNone ); |
|
112 } |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // CCalenDialogShutter::RunL |
|
117 // Handles the asyn requests completion |
|
118 // (other items were commented in a header). |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 void CCalenDialogShutter::RunL() |
|
122 { |
|
123 if ( iCount++ >= KMaxNumEscKeysToSend ) |
|
124 { |
|
125 return; |
|
126 } |
|
127 |
|
128 CEikAppUi* appUi=iEikon->EikAppUi(); |
|
129 TInt startLevel=StartLevel(); |
|
130 if ( startLevel > iStartLevel ) |
|
131 { |
|
132 return; |
|
133 } |
|
134 |
|
135 iStartLevel = startLevel; |
|
136 |
|
137 if (appUi->IsDisplayingMenuOrDialog()) |
|
138 { |
|
139 TKeyEvent key; |
|
140 key.iCode=EKeyEscape; |
|
141 key.iModifiers=0; |
|
142 key.iRepeats = 0; |
|
143 key.iScanCode = EStdKeyNull; |
|
144 iEikon->SimulateKeyEventL(key, EEventKey); |
|
145 } |
|
146 else |
|
147 { |
|
148 return; |
|
149 } |
|
150 Queue(); |
|
151 } |
|
152 |
|
153 // ---------------------------------------------------------------------------- |
|
154 // CCalenDialogShutter::RunError |
|
155 // Function to handle any errors in async request |
|
156 // (other items were commented in a header). |
|
157 // ---------------------------------------------------------------------------- |
|
158 // |
|
159 TInt CCalenDialogShutter::RunError(TInt aError) |
|
160 { |
|
161 return aError; |
|
162 } |
|
163 |
|
164 // ---------------------------------------------------------------------------- |
|
165 // CCalenDialogShutter::StartLevel |
|
166 // Function to get the startlevel of the opened dialogs |
|
167 // (other items were commented in a header). |
|
168 // ---------------------------------------------------------------------------- |
|
169 // |
|
170 TInt CCalenDialogShutter::StartLevel() |
|
171 { |
|
172 return ((CKludgeScheduler*)CActiveScheduler::Current())->PublicLevel(); |
|
173 } |
|
174 |
|
175 // ---------------------------------------------------------------------------- |
|
176 // CCalenDialogShutter::ShutDialogsL |
|
177 // Function for making the initial request |
|
178 // (other items were commented in a header). |
|
179 // ---------------------------------------------------------------------------- |
|
180 // |
|
181 void CCalenDialogShutter::ShutDialogsL( /*CActiveSchedulerWait* aWait*/ ) |
|
182 { |
|
183 Queue(); |
|
184 } |