26
|
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.hrh"
|
|
22 |
#include "profiler_gui_mainview.h"
|
|
23 |
#include "profiler_gui_maincontainer.h"
|
|
24 |
#include "profiler_gui_document.h"
|
|
25 |
#include "profiler_gui_model.h"
|
|
26 |
#include <piprofilerui.rsg>
|
|
27 |
|
|
28 |
#include <AknWaitDialog.h>
|
|
29 |
#include <AknGlobalNote.h>
|
|
30 |
#include <eikenv.h>
|
|
31 |
#include <aknViewAppUi.h>
|
|
32 |
#include <akncontext.h>
|
|
33 |
#include <StringLoader.h>
|
|
34 |
#include <aknnavi.h>
|
|
35 |
#include <akntitle.h>
|
|
36 |
#include <barsread.h>
|
|
37 |
#include <aknnavide.h>
|
|
38 |
#include <aknmessagequerydialog.h>
|
|
39 |
|
|
40 |
// ================= MEMBER FUNCTIONS =======================
|
|
41 |
|
|
42 |
// ---------------------------------------------------------
|
|
43 |
// CProfilerGuiMainView::ConstructL(const TRect& aRect)
|
|
44 |
// EPOC two-phased constructor
|
|
45 |
// ---------------------------------------------------------
|
|
46 |
//
|
|
47 |
void CProfilerGuiMainView::ConstructL()
|
|
48 |
{
|
|
49 |
BaseConstructL( R_PROFILER_GUI_VIEW_MAIN );
|
|
50 |
|
|
51 |
iModel = static_cast<CProfilerGuiDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
|
|
52 |
iNaviDecorator = NULL;
|
|
53 |
iModel->SetMainView(this);
|
|
54 |
}
|
|
55 |
|
|
56 |
// ---------------------------------------------------------
|
|
57 |
// CProfilerGuiMainView::~CProfilerGuiMainView()
|
|
58 |
// ---------------------------------------------------------
|
|
59 |
//
|
|
60 |
CProfilerGuiMainView::~CProfilerGuiMainView()
|
|
61 |
{
|
|
62 |
|
|
63 |
if(iNaviDecorator)
|
|
64 |
{
|
|
65 |
delete iNaviDecorator;
|
|
66 |
iNaviDecorator = NULL;
|
|
67 |
}
|
|
68 |
|
|
69 |
if (iContainer)
|
|
70 |
{
|
|
71 |
AppUi()->RemoveFromViewStack( *this, iContainer );
|
|
72 |
delete iContainer;
|
|
73 |
iContainer = NULL;
|
|
74 |
}
|
|
75 |
|
|
76 |
}
|
|
77 |
|
|
78 |
// ---------------------------------------------------------
|
|
79 |
// TUid CProfilerGuiMainView::Id()
|
|
80 |
// ---------------------------------------------------------
|
|
81 |
//
|
|
82 |
TUid CProfilerGuiMainView::Id() const
|
|
83 |
{
|
|
84 |
return KMainViewUID;
|
|
85 |
}
|
|
86 |
|
|
87 |
// ---------------------------------------------------------
|
|
88 |
// TUid CProfilerGuiMainView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
|
|
89 |
// ---------------------------------------------------------
|
|
90 |
//
|
|
91 |
void CProfilerGuiMainView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
|
|
92 |
{
|
|
93 |
AppUi()->DynInitMenuPaneL(aResourceId, aMenuPane);
|
|
94 |
}
|
|
95 |
|
|
96 |
|
|
97 |
// ---------------------------------------------------------
|
|
98 |
// CProfilerGuiMainView::HandleCommandL(TInt aCommand)
|
|
99 |
// ---------------------------------------------------------
|
|
100 |
//
|
|
101 |
void CProfilerGuiMainView::HandleCommandL(TInt aCommand)
|
|
102 |
{
|
|
103 |
switch ( aCommand )
|
|
104 |
{
|
|
105 |
// commands from sampler control sub menu
|
|
106 |
case EProfilerGuiCmdSamplerEnable:
|
|
107 |
{
|
|
108 |
iModel->DisableOrEnableSelectedOrHighlightedItemsL();
|
|
109 |
break;
|
|
110 |
}
|
|
111 |
case EProfilerGuiCmdSamplerDisable:
|
|
112 |
{
|
|
113 |
iModel->DisableOrEnableSelectedOrHighlightedItemsL();
|
|
114 |
break;
|
|
115 |
}
|
|
116 |
case EProfilerGuiCmdSamplerSettings:
|
|
117 |
{
|
|
118 |
// check if sampler settings dialog returned exit command
|
|
119 |
iModel->EditSelectedSamplerL(iContainer->CurrentListBoxItemIndex());
|
|
120 |
break;
|
|
121 |
}
|
|
122 |
case EProfilerGuiCmdSamplerInfo:
|
|
123 |
{
|
|
124 |
iModel->SelectedSamplerInfoL(iContainer->CurrentListBoxItemIndex());
|
|
125 |
break;
|
|
126 |
}
|
|
127 |
|
|
128 |
case EProfilerGuiCmdStartAll:
|
|
129 |
case EProfilerGuiCmdStartTimed:
|
|
130 |
{
|
|
131 |
// still using the old way of starting all the samplers simultaneously
|
|
132 |
if( iModel->iState != MProfilerStatusObserver::ERunning )
|
|
133 |
{
|
|
134 |
// set state as "initializing" for a moment before profiling has started,
|
|
135 |
// NOTE: engine changes to "Running" state
|
|
136 |
iModel->iState = MProfilerStatusObserver::EInitializing;
|
|
137 |
// start the actual sampling process on Profiler Engine
|
|
138 |
if( aCommand == EProfilerGuiCmdStartTimed )
|
|
139 |
iModel->StartAllSamplerItemsL(CProfilerGuiModel::EProfilingModeTimed);
|
|
140 |
else
|
|
141 |
iModel->StartAllSamplerItemsL();
|
|
142 |
}
|
|
143 |
|
|
144 |
// prevent the control of sampler specific settings during the trace
|
|
145 |
iContainer->SetDimmed(ETrue);
|
|
146 |
break;
|
|
147 |
}
|
|
148 |
case EProfilerGuiCmdStopAll:
|
|
149 |
{
|
|
150 |
// check if still profiling
|
|
151 |
if( iModel->iState != MProfilerStatusObserver::EIdle )
|
|
152 |
{
|
|
153 |
// set to stopping mode
|
|
154 |
iModel->iState = MProfilerStatusObserver::EStopping;
|
|
155 |
// stop actual sampling process on Profiler Engine
|
|
156 |
iModel->StopAllSamplerItemsL();
|
|
157 |
}
|
|
158 |
|
|
159 |
// return the control to sampler specific settings when tracing stopped
|
|
160 |
iContainer->SetDimmed(EFalse);
|
|
161 |
|
|
162 |
break;
|
|
163 |
}
|
|
164 |
|
|
165 |
default:
|
|
166 |
{
|
|
167 |
AppUi()->HandleCommandL(aCommand);
|
|
168 |
break;
|
|
169 |
}
|
|
170 |
}
|
|
171 |
}
|
|
172 |
|
|
173 |
// ---------------------------------------------------------
|
|
174 |
// CProfilerGuiMainView::HandleClientRectChange()
|
|
175 |
// ---------------------------------------------------------
|
|
176 |
//
|
|
177 |
void CProfilerGuiMainView::HandleClientRectChange()
|
|
178 |
{
|
|
179 |
if ( iContainer )
|
|
180 |
{
|
|
181 |
iContainer->SetRect( ClientRect() );
|
|
182 |
}
|
|
183 |
}
|
|
184 |
|
|
185 |
// ---------------------------------------------------------
|
|
186 |
// CProfilerGuiMainView::DoActivateL(...)
|
|
187 |
// ---------------------------------------------------------
|
|
188 |
//
|
|
189 |
void CProfilerGuiMainView::DoActivateL(
|
|
190 |
const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
|
|
191 |
const TDesC8& /*aCustomMessage*/)
|
|
192 |
{
|
|
193 |
// show wait dialog
|
|
194 |
CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC();
|
|
195 |
waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_EMPTY);
|
|
196 |
TInt dialogId = waitDialog->ShowNoteL(EAknGlobalWaitNote, _L("Initializing samplers"));
|
|
197 |
|
|
198 |
// setup the profiler engine status pane
|
|
199 |
SetupStatusPaneL();
|
|
200 |
|
|
201 |
// check if container creation succesfull
|
|
202 |
if (!iContainer)
|
|
203 |
{
|
|
204 |
iContainer = new (ELeave) CProfilerGuiMainContainer;
|
|
205 |
iModel->SetMainContainer(iContainer);
|
|
206 |
iContainer->SetMopParent(this);
|
|
207 |
iContainer->ConstructL( ClientRect() );
|
|
208 |
iModel->NotifyContainerReadyL();
|
|
209 |
AppUi()->AddToStackL( *this, iContainer );
|
|
210 |
}
|
|
211 |
|
|
212 |
// remove the wait dialog
|
|
213 |
waitDialog->CancelNoteL(dialogId);
|
|
214 |
CleanupStack::PopAndDestroy(); //waitDialog;
|
|
215 |
}
|
|
216 |
|
|
217 |
// ---------------------------------------------------------
|
|
218 |
// CProfilerGuiMainView::DoDeactivate()
|
|
219 |
// ---------------------------------------------------------
|
|
220 |
//
|
|
221 |
void CProfilerGuiMainView::DoDeactivate()
|
|
222 |
{
|
|
223 |
TRAP_IGNORE(CleanupStatusPaneL());
|
|
224 |
|
|
225 |
if (iContainer)
|
|
226 |
{
|
|
227 |
AppUi()->RemoveFromViewStack( *this, iContainer );
|
|
228 |
delete iContainer;
|
|
229 |
iContainer = NULL;
|
|
230 |
}
|
|
231 |
}
|
|
232 |
|
|
233 |
void CProfilerGuiMainView::HandleStatusPaneSizeChange()
|
|
234 |
{
|
|
235 |
CAknView::HandleStatusPaneSizeChange();
|
|
236 |
|
|
237 |
TInt result;
|
|
238 |
TRAP(result, SetupStatusPaneL());
|
|
239 |
}
|
|
240 |
|
|
241 |
|
|
242 |
void CProfilerGuiMainView::SetupStatusPaneL()
|
|
243 |
{
|
|
244 |
TUid naviPaneUid = TUid::Uid(EEikStatusPaneUidNavi);
|
|
245 |
CEikStatusPaneBase::TPaneCapabilities subPaneNavi = StatusPane()->PaneCapabilities(naviPaneUid);
|
|
246 |
if(subPaneNavi.IsPresent() && subPaneNavi.IsAppOwned())
|
|
247 |
{
|
|
248 |
CAknNavigationControlContainer* naviPane = static_cast<CAknNavigationControlContainer*> (StatusPane()->ControlL(naviPaneUid));
|
|
249 |
if(iNaviDecorator)
|
|
250 |
{
|
|
251 |
delete iNaviDecorator;
|
|
252 |
iNaviDecorator = NULL;
|
|
253 |
}
|
|
254 |
|
|
255 |
// get the initial status label
|
|
256 |
HBufC* labelText = GetLabelTextLC(iModel->iState);
|
|
257 |
iNaviDecorator = naviPane->CreateNavigationLabelL(*labelText);
|
|
258 |
CleanupStack::PopAndDestroy(labelText);
|
|
259 |
|
|
260 |
naviPane->PushL(*iNaviDecorator);
|
|
261 |
}
|
|
262 |
}
|
|
263 |
|
|
264 |
void CProfilerGuiMainView::CleanupStatusPaneL()
|
|
265 |
{
|
|
266 |
// destructor for navi pane, called by destructor
|
|
267 |
TUid naviPaneUid = TUid::Uid(EEikStatusPaneUidNavi);
|
|
268 |
CEikStatusPaneBase::TPaneCapabilities subPaneNavi = StatusPane()->PaneCapabilities(naviPaneUid);
|
|
269 |
if(subPaneNavi.IsPresent() && subPaneNavi.IsAppOwned())
|
|
270 |
{
|
|
271 |
CAknNavigationControlContainer* naviPane = static_cast<CAknNavigationControlContainer*> (StatusPane()->ControlL(naviPaneUid));
|
|
272 |
if(iNaviDecorator)
|
|
273 |
{
|
|
274 |
naviPane->Pop(iNaviDecorator);
|
|
275 |
delete iNaviDecorator;
|
|
276 |
iNaviDecorator = NULL;
|
|
277 |
}
|
|
278 |
}
|
|
279 |
}
|
|
280 |
|
|
281 |
HBufC* CProfilerGuiMainView::GetLabelTextLC(TInt aStatus)
|
|
282 |
{
|
|
283 |
// get the predefined status text
|
|
284 |
HBufC* labelText = NULL;
|
|
285 |
switch(aStatus)
|
|
286 |
{
|
|
287 |
case MProfilerStatusObserver::EIdle:
|
|
288 |
labelText = StringLoader::LoadLC(R_PROFILER_GUI_NAVI_TEXT_IDLE);
|
|
289 |
break;
|
|
290 |
case MProfilerStatusObserver::EInitializing:
|
|
291 |
labelText = StringLoader::LoadLC(R_PROFILER_GUI_NAVI_TEXT_INITIALIZING);
|
|
292 |
break;
|
|
293 |
case MProfilerStatusObserver::ERunning:
|
|
294 |
labelText = StringLoader::LoadLC(R_PROFILER_GUI_NAVI_TEXT_RUNNING);
|
|
295 |
break;
|
|
296 |
case MProfilerStatusObserver::EStopping:
|
|
297 |
labelText = StringLoader::LoadLC(R_PROFILER_GUI_NAVI_TEXT_STOPPING);
|
|
298 |
break;
|
|
299 |
case MProfilerStatusObserver::ERestarting:
|
|
300 |
labelText = StringLoader::LoadLC(R_PROFILER_GUI_NAVI_TEXT_RUNNING);
|
|
301 |
break;
|
|
302 |
default:
|
|
303 |
labelText = StringLoader::LoadLC(R_PROFILER_GUI_NAVI_TEXT_IDLE);
|
|
304 |
break;
|
|
305 |
}
|
|
306 |
return labelText;
|
|
307 |
}
|
|
308 |
|
|
309 |
void CProfilerGuiMainView::UpdateStatusPaneL( TInt aStatus )
|
|
310 |
{
|
|
311 |
TUid naviPaneUid = TUid::Uid(EEikStatusPaneUidNavi);
|
|
312 |
CEikStatusPaneBase::TPaneCapabilities subPaneNavi = StatusPane()->PaneCapabilities(naviPaneUid);
|
|
313 |
// check if navi pane is correctly initialized
|
|
314 |
if(subPaneNavi.IsPresent() && subPaneNavi.IsAppOwned())
|
|
315 |
{
|
|
316 |
CAknNavigationControlContainer* naviPane = static_cast<CAknNavigationControlContainer*> (StatusPane()->ControlL(naviPaneUid));
|
|
317 |
if(iNaviDecorator)
|
|
318 |
{
|
|
319 |
delete iNaviDecorator;
|
|
320 |
iNaviDecorator = NULL;
|
|
321 |
}
|
|
322 |
HBufC* labelText;
|
|
323 |
|
|
324 |
// get the right status label text
|
|
325 |
labelText = GetLabelTextLC(aStatus);
|
|
326 |
iNaviDecorator = naviPane->CreateNavigationLabelL(*labelText);
|
|
327 |
CleanupStack::PopAndDestroy(labelText);
|
|
328 |
|
|
329 |
naviPane->PushL(*iNaviDecorator);
|
|
330 |
}
|
|
331 |
}
|
|
332 |
|
|
333 |
|
|
334 |
// End of File
|