|
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: Application class for Events Handler Application UI. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // SYSTEM FILES |
|
20 #include <avkon.hrh> |
|
21 #include <AknsConstants.h> |
|
22 #include <aknnotewrappers.h> |
|
23 #include <textresolver.h> |
|
24 |
|
25 // USER INCLUDES |
|
26 #include "evthandlerappui.h" |
|
27 #include "evtrequest.h" |
|
28 #include "evtmgmtuiengine.h" |
|
29 #include "evtdebug.h" |
|
30 |
|
31 // ----------------- Member funtions for CEvtHandlerAppUi -------------------- |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // void CEvtHandlerAppUi::ConstructL |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 void CEvtHandlerAppUi::ConstructL() |
|
38 { |
|
39 BaseConstructL( EAknEnableSkin | EAknEnableMSK ); |
|
40 iEngine = CEvtMgmtUiEngine::NewL(); |
|
41 iDlg = CEvtDlgLauncher::NewL( *iEngine, *this ); |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // CEvtHandlerAppUi::~CEvtHandlerAppUi |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 CEvtHandlerAppUi::~CEvtHandlerAppUi() |
|
49 { |
|
50 delete iDlg; |
|
51 iEventQue.ResetAndDestroy(); |
|
52 iEventQue.Close(); |
|
53 delete iEngine; |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // TKeyResponse CEvtHandlerAppUi::HandleKeyEventL |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 TKeyResponse CEvtHandlerAppUi::HandleKeyEventL( const TKeyEvent& /*aKeyEvent*/, |
|
61 TEventCode /*aType*/ ) |
|
62 { |
|
63 return EKeyWasNotConsumed; |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // void CEvtHandlerAppUi::HandleCommandL |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 void CEvtHandlerAppUi::HandleCommandL( TInt aCommand ) |
|
71 { |
|
72 switch ( aCommand ) |
|
73 { |
|
74 case EAknSoftkeyExit: |
|
75 case EEikCmdExit: |
|
76 { |
|
77 Exit(); |
|
78 break; |
|
79 } |
|
80 default: |
|
81 { |
|
82 break; |
|
83 } |
|
84 } |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // void CEvtHandlerAppUi::HandleWsEventL |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 void CEvtHandlerAppUi::HandleWsEventL(const TWsEvent &aEvent, CCoeControl* aDestination) |
|
92 { |
|
93 TInt eventType = aEvent.Type(); |
|
94 switch ( eventType ) |
|
95 { |
|
96 case EEventKey: |
|
97 { |
|
98 // Handle Key Escape key. |
|
99 if( aEvent.Key()->iCode == EKeyEscape ) |
|
100 { |
|
101 if( !iFlag ) |
|
102 iFlag = ETrue; |
|
103 else |
|
104 iFlag = EFalse; |
|
105 iDlg->CancelDlgL( EFalse ); |
|
106 } |
|
107 break; |
|
108 } |
|
109 case KAknUidValueEndKeyCloseEvent: |
|
110 { |
|
111 // Handle End key. |
|
112 if( iDlg ) |
|
113 { |
|
114 EVTUIDEBUG("= CEvtHandlerAppUi::HandleWsEventL() - End Key"); |
|
115 // Construct the TApaTask object. |
|
116 TApaTask task(iEikonEnv->WsSession( )); |
|
117 task.SetWgId(CEikonEnv::Static()->RootWin().Identifier()); |
|
118 task.BringToForeground(); |
|
119 |
|
120 // We Cancel any outstanding Dialog. |
|
121 iFlag = ETrue; |
|
122 iDlg->CancelDlgL( ETrue ); |
|
123 return; |
|
124 } |
|
125 break; |
|
126 } |
|
127 default: |
|
128 break; |
|
129 } |
|
130 |
|
131 return CEikAppUi::HandleWsEventL( aEvent, aDestination ); |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // void CEvtHandlerAppUi::NotifyDlgDismissedL |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 void CEvtHandlerAppUi::NotifyDlgDismissedL( ) |
|
139 { |
|
140 if( !iFlag ) |
|
141 { |
|
142 EVTUIDEBUG1("+ CEvtHandlerAppUi::NotifyDlgDismissedL() - %d", iEventQue[0]->Event().EventId()); |
|
143 CEvtRequest* evtReq = iEventQue[0]; |
|
144 iEventQue.Remove( 0 ); |
|
145 delete evtReq; |
|
146 if( iEventQue.Count() == 0 ) |
|
147 { |
|
148 Exit(); |
|
149 } |
|
150 |
|
151 HandleNextMessageL( ); |
|
152 EVTUIDEBUG("- CEvtHandlerAppUi::NotifyDlgDismissedL()"); |
|
153 } |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // void CEvtHandlerAppUi::ProcessCommandParametersL |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 TBool CEvtHandlerAppUi::ProcessCommandParametersL( CApaCommandLine &aCommandLine ) |
|
161 { |
|
162 EVTUIDEBUG("+ CEvtHandlerAppUi::ProcessCommandParametersL()"); |
|
163 // Process Command Parameters |
|
164 |
|
165 TBuf8<128> temp; |
|
166 temp.Copy(aCommandLine.TailEnd()); |
|
167 |
|
168 TLex8 input( temp ); |
|
169 |
|
170 TEvtEventId triggerId(0); |
|
171 TInt type(0); |
|
172 |
|
173 User::LeaveIfError( input.Val(triggerId, EDecimal) ); |
|
174 input.Inc(); |
|
175 User::LeaveIfError( input.Val(type) ); |
|
176 |
|
177 HandleRecievedMessageL(triggerId, static_cast<TEvtRequestType>(type)); |
|
178 |
|
179 EVTUIDEBUG("- CEvtHandlerAppUi::ProcessCommandParametersL()"); |
|
180 return CEikAppUi::ProcessCommandParametersL( aCommandLine ); |
|
181 } |
|
182 |
|
183 // --------------------------------------------------------------------------- |
|
184 // void CEvtHandlerAppUi::ProcessMessageL |
|
185 // --------------------------------------------------------------------------- |
|
186 // |
|
187 void CEvtHandlerAppUi::ProcessMessageL( TUid /*aUid*/, |
|
188 const TDesC8& aParams ) |
|
189 { |
|
190 EVTUIDEBUG("+ CEvtHandlerAppUi::ProcessMessageL()"); |
|
191 TBuf8<128> temp; |
|
192 temp.Copy( aParams ); |
|
193 |
|
194 TLex8 input( temp ); |
|
195 |
|
196 TEvtEventId triggerId(0); |
|
197 TInt type(0); |
|
198 |
|
199 User::LeaveIfError( input.Val(triggerId, EDecimal) ); |
|
200 input.Inc(); |
|
201 User::LeaveIfError( input.Val(type) ); |
|
202 |
|
203 HandleRecievedMessageL(triggerId, static_cast<TEvtRequestType>(type)); |
|
204 |
|
205 EVTUIDEBUG("- CEvtHandlerAppUi::ProcessMessageL()"); |
|
206 } |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // void CEvtHandlerAppUi::HandleRecievedMessageL |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 void CEvtHandlerAppUi::HandleRecievedMessageL( const TLbtTriggerId & aTriggerId, |
|
213 TEvtRequestType aReqestType ) |
|
214 { |
|
215 EVTUIDEBUG2("+ CEvtHandlerAppUi::HandleRecievedMessageL() - Id:%d, Type:%d", aTriggerId, aReqestType ); |
|
216 |
|
217 // We first update the Trigger state. |
|
218 iEngine->HandleFiredTriggerStateL( aTriggerId ); |
|
219 |
|
220 CEvtRequest* evtReq = CEvtRequest::NewL(); |
|
221 CEvtEvent* evt = iEngine->EventL( aTriggerId ); |
|
222 evtReq->SetEventL( evt ); |
|
223 evtReq->SetRequestType( aReqestType ); |
|
224 iEventQue.Insert(evtReq, 0); |
|
225 |
|
226 iFlag = ETrue; |
|
227 iDlg->CancelDlgL( ETrue ); |
|
228 HandleNextMessageL( ); |
|
229 |
|
230 EVTUIDEBUG("- CEvtHandlerAppUi::HandleRecievedMessageL()"); |
|
231 } |
|
232 |
|
233 // --------------------------------------------------------------------------- |
|
234 // void CEvtHandlerAppUi::HandleNextMessageL |
|
235 // --------------------------------------------------------------------------- |
|
236 // |
|
237 void CEvtHandlerAppUi::HandleNextMessageL( ) |
|
238 { |
|
239 EVTUIDEBUG("+ CEvtHandlerAppUi::HandleNextMessageL()"); |
|
240 if( iEventQue.Count() > 0 ) |
|
241 { |
|
242 EVTUIDEBUG1("= CEvtHandlerAppUi::HandleNextMessageL() - TriggerId:%d", iEventQue[0]->Event().EventId() ); |
|
243 CEvtRequest* evtReq = iEventQue[0]; |
|
244 iFlag = EFalse; |
|
245 iDlg->LaunchDlgL( *evtReq ); |
|
246 } |
|
247 EVTUIDEBUG("- CEvtHandlerAppUi::HandleNextMessageL()"); |
|
248 } |
|
249 |
|
250 // End of File |