|
1 /* |
|
2 * Copyright (c) 2009 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 // INCLUDE FILES |
|
21 #include "profiler_gui_appui.h" |
|
22 #include "profiler_gui_mainview.h" |
|
23 #include "profiler_gui.hrh" |
|
24 #include "profiler_gui_model.h" |
|
25 #include "profiler_gui_document.h" |
|
26 #include <piprofilerui.rsg> |
|
27 #include <piprofiler/ProfilerTraces.h> |
|
28 #include <piprofiler/ProfilerSession.h> |
|
29 #include <piprofiler/ProfilerConfig.h> |
|
30 |
|
31 #include <aknwaitdialog.h> |
|
32 #include <aknglobalnote.h> |
|
33 #include <avkon.hrh> |
|
34 #include <aknquerydialog.h> |
|
35 #include <aknmessagequerydialog.h> |
|
36 #include <PathInfo.h> |
|
37 |
|
38 |
|
39 // ================= MEMBER FUNCTIONS ======================= |
|
40 |
|
41 void CProfilerGuiAppUi::ConstructL() |
|
42 { |
|
43 // set as system application to prevent getting shut down events |
|
44 iEikonEnv->SetSystem(ETrue); |
|
45 |
|
46 BaseConstructL(EAknEnableSkin); |
|
47 |
|
48 // get model |
|
49 iModel = static_cast<CProfilerGuiDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model(); |
|
50 |
|
51 LOGTEXT(_L("ProfilerGuiAppUi::ConstructL - setting main view settings")); |
|
52 |
|
53 CProfilerGuiMainView* mainView = new(ELeave) CProfilerGuiMainView; |
|
54 CleanupStack::PushL(mainView); |
|
55 mainView->ConstructL(); |
|
56 AddViewL(mainView); // transfer ownership to CAknViewAppUi |
|
57 CleanupStack::Pop(); // mainView |
|
58 |
|
59 LOGTEXT(_L("ProfilerGuiAppUi::ConstructL - setting default view")); |
|
60 |
|
61 SetDefaultViewL(*mainView); |
|
62 |
|
63 LOGTEXT(_L("ProfilerGuiAppUi::ConstructL - activating model")); |
|
64 |
|
65 // notify the model that everything has been constructed |
|
66 iModel->ActivateModelL(); |
|
67 } |
|
68 |
|
69 // -------------------------------------------------------------------------------------------- |
|
70 |
|
71 CProfilerGuiAppUi::~CProfilerGuiAppUi() |
|
72 { |
|
73 // notify the model that the application is closing |
|
74 if (iModel) |
|
75 TRAP_IGNORE(iModel->DeActivateModelL()); |
|
76 |
|
77 } |
|
78 |
|
79 // -------------------------------------------------------------------------------------------- |
|
80 |
|
81 void CProfilerGuiAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) |
|
82 { |
|
83 if (aResourceId == R_PROFILER_GUI_APP_MENU) |
|
84 { |
|
85 if(iModel->iState == MProfilerStatusObserver::ERunning) |
|
86 { |
|
87 aMenuPane->SetItemDimmed(EProfilerGuiCmdStartAll, ETrue); |
|
88 aMenuPane->SetItemDimmed(EProfilerGuiCmdStopAll, EFalse); |
|
89 aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerControl, ETrue); |
|
90 aMenuPane->SetItemDimmed(EProfilerGuiCmdSettings, ETrue); |
|
91 } |
|
92 else if(iModel->iState == MProfilerStatusObserver::EIdle) |
|
93 { |
|
94 aMenuPane->SetItemDimmed(EProfilerGuiCmdStartAll, EFalse); |
|
95 aMenuPane->SetItemDimmed(EProfilerGuiCmdStopAll, ETrue); |
|
96 aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerControl, EFalse); |
|
97 aMenuPane->SetItemDimmed(EProfilerGuiCmdSettings, EFalse); |
|
98 } |
|
99 else |
|
100 { |
|
101 // if initializing or stopping no start/stop actions allowed |
|
102 aMenuPane->SetItemDimmed(EProfilerGuiCmdStartAll, ETrue); |
|
103 aMenuPane->SetItemDimmed(EProfilerGuiCmdStopAll, ETrue); |
|
104 aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerControl, ETrue); |
|
105 aMenuPane->SetItemDimmed(EProfilerGuiCmdSettings, ETrue); |
|
106 } |
|
107 } |
|
108 |
|
109 if(aResourceId == R_PROFILER_SAMPLER_CONTROL_MENU) |
|
110 { |
|
111 // check if item hidden, i.e. sampler cannot be started/stopped |
|
112 if(!iModel->GetSelectedItemHidden()) |
|
113 { |
|
114 // item enabled => dimm the "enable" item, and other way round |
|
115 if(iModel->GetSelectedItemEnabled()) |
|
116 { |
|
117 aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerEnable, ETrue); |
|
118 aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerDisable, EFalse); |
|
119 } |
|
120 // item enabled => dimm the "enable" item, and other way round |
|
121 else |
|
122 { |
|
123 aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerEnable, EFalse); |
|
124 aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerDisable, ETrue); |
|
125 } |
|
126 |
|
127 } |
|
128 // item hidden => dimm both enable and disable items |
|
129 else |
|
130 { |
|
131 aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerEnable, ETrue); |
|
132 aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerDisable, ETrue); |
|
133 } |
|
134 |
|
135 // if sampler item has specific settings to control |
|
136 if(iModel->GetSelectedItemHasSettings()) |
|
137 { |
|
138 aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerSettings, EFalse); |
|
139 } |
|
140 else |
|
141 { |
|
142 aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerSettings, ETrue); |
|
143 } |
|
144 } |
|
145 } |
|
146 |
|
147 // -------------------------------------------------------------------------------------------- |
|
148 |
|
149 TKeyResponse CProfilerGuiAppUi::HandleKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) |
|
150 { |
|
151 return EKeyWasNotConsumed; |
|
152 } |
|
153 |
|
154 void CProfilerGuiAppUi::HandleSystemEventL(const TWsEvent& aEvent) |
|
155 { |
|
156 switch (*(TApaSystemEvent*)(aEvent.EventData())) |
|
157 { |
|
158 case EApaSystemEventShutdown: |
|
159 // check if still profiling |
|
160 if( iModel->iState != MProfilerStatusObserver::EIdle ) |
|
161 { |
|
162 // stop profiling process |
|
163 iModel->StopAllSamplerItemsL(); |
|
164 } |
|
165 |
|
166 // terminate profiler engine |
|
167 iModel->TerminateProfilerL(); |
|
168 break; |
|
169 default: |
|
170 break; |
|
171 } |
|
172 // call base class implementation |
|
173 CAknAppUi::HandleSystemEventL(aEvent); |
|
174 } |
|
175 |
|
176 // -------------------------------------------------------------------------------------------- |
|
177 |
|
178 void CProfilerGuiAppUi::HandleCommandL(TInt aCommand) |
|
179 { |
|
180 switch ( aCommand ) |
|
181 { |
|
182 case EProfilerGuiCmdSettings: |
|
183 { |
|
184 // check if exit command received |
|
185 if (iModel->LaunchSettingsDialogL() == EAknCmdExit) |
|
186 { |
|
187 // terminate profiler engine... |
|
188 iModel->TerminateProfilerL(); |
|
189 |
|
190 // ... and exit |
|
191 Exit(); |
|
192 } |
|
193 break; |
|
194 } |
|
195 case EProfilerGuiCmdAbout: |
|
196 { |
|
197 CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog; |
|
198 dialog->ExecuteLD(R_PROFILER_GUI_ABOUT_DIALOG); |
|
199 } |
|
200 break; |
|
201 |
|
202 // a normal way to close an application |
|
203 case EAknCmdExit: |
|
204 case EEikCmdExit: |
|
205 case EAknSoftkeyExit: |
|
206 { |
|
207 // check if still profiling |
|
208 if( iModel->iState != MProfilerStatusObserver::EIdle && |
|
209 iModel->iState != MProfilerStatusObserver::EStopping ) |
|
210 { |
|
211 // ask user if he wants to leave profiling running in background process |
|
212 if( this->RunConfQueryL( NULL ) == 0 ) |
|
213 { |
|
214 // stop profiling process |
|
215 iModel->StopAllSamplerItemsL(); |
|
216 |
|
217 // terminate profiler engine |
|
218 iModel->TerminateProfilerL(); |
|
219 } |
|
220 } |
|
221 else |
|
222 { |
|
223 // terminate profiler engine |
|
224 iModel->TerminateProfilerL(); |
|
225 } |
|
226 |
|
227 Exit(); |
|
228 } |
|
229 break; |
|
230 |
|
231 default: |
|
232 break; |
|
233 } |
|
234 } |
|
235 |
|
236 TInt CProfilerGuiAppUi::RunConfQueryL( const TDesC* aOverrideText ) |
|
237 { |
|
238 CAknQueryDialog* queryDialog = CAknQueryDialog::NewL(); |
|
239 |
|
240 if(aOverrideText) |
|
241 { |
|
242 queryDialog->SetPromptL(*aOverrideText); |
|
243 } |
|
244 return queryDialog->ExecuteLD(R_PROFILER_GUI_CONF_QUERY); |
|
245 } |
|
246 |
|
247 |
|
248 // End of File |