20
|
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 |
#include "BupPlugin.h"
|
|
20 |
//#include <piprofiler/EngineUIDs.h>
|
|
21 |
|
|
22 |
#include <w32std.h> // for listening key events
|
|
23 |
|
|
24 |
|
|
25 |
// LITERALS
|
|
26 |
// CONSTANTS
|
|
27 |
const TUid KSamplerBupPluginUid = { 0x2001E5B6 };
|
|
28 |
|
|
29 |
/*
|
|
30 |
*
|
|
31 |
* class CBupPlugin implementation
|
|
32 |
*
|
|
33 |
*/
|
|
34 |
|
|
35 |
CBupPlugin* CBupPlugin::NewL(const TUid /*aImplementationUid*/, TAny* /*aInitParams*/)
|
|
36 |
{
|
|
37 |
LOGTEXT(_L("CBupPlugin::NewL() - entry"));
|
|
38 |
CBupPlugin* self = new (ELeave) CBupPlugin();
|
|
39 |
CleanupStack::PushL( self );
|
|
40 |
self->ConstructL();
|
|
41 |
CleanupStack::Pop();
|
|
42 |
LOGTEXT(_L("CBupPlugin::NewL() - exit"));
|
|
43 |
return self;
|
|
44 |
}
|
|
45 |
|
|
46 |
CBupPlugin::CBupPlugin() :
|
|
47 |
iVersionDescriptor(&(this->iVersion[1]),0,19),
|
|
48 |
iSamplerType(PROFILER_USER_MODE_SAMPLER)
|
|
49 |
{
|
|
50 |
iSamplerId = PROFILER_BUP_SAMPLER_ID;
|
|
51 |
iEnabled = EFalse;
|
|
52 |
LOGTEXT(_L("CBupPlugin::CBupPlugin() - konstruktori"));
|
|
53 |
}
|
|
54 |
|
|
55 |
void CBupPlugin::ConstructL()
|
|
56 |
{
|
|
57 |
LOGTEXT(_L("CBupPlugin::ConstructL() - entry"));
|
|
58 |
|
|
59 |
// initiate sampler attributes array
|
|
60 |
iSamplerAttributes = new(ELeave) CArrayFixFlat<TSamplerAttributes>(1); // only one sampler
|
|
61 |
|
|
62 |
// insert default attributes to array
|
|
63 |
InitiateSamplerAttributesL();
|
|
64 |
|
|
65 |
LOGTEXT(_L("CBupPlugin::ConstructL() - exit"));
|
|
66 |
}
|
|
67 |
|
|
68 |
|
|
69 |
CBupPlugin::~CBupPlugin()
|
|
70 |
{
|
|
71 |
LOGTEXT(_L("CBupPlugin::~CBupPlugin() - entry"));
|
|
72 |
if(iButtonListener)
|
|
73 |
{
|
|
74 |
// check if button listener still running
|
|
75 |
if(Enabled())
|
|
76 |
{
|
|
77 |
// stop profiling
|
|
78 |
iButtonListener->Stop();
|
|
79 |
}
|
|
80 |
delete iButtonListener;
|
|
81 |
}
|
|
82 |
|
|
83 |
if(iSamplerAttributes)
|
|
84 |
{
|
|
85 |
iSamplerAttributes->Reset();
|
|
86 |
}
|
|
87 |
delete iSamplerAttributes;
|
|
88 |
|
|
89 |
LOGTEXT(_L("CBupPlugin::~CBupPlugin() - exit"));
|
|
90 |
}
|
|
91 |
|
|
92 |
TUid CBupPlugin::Id(TInt /*aUid*/) const
|
|
93 |
{
|
|
94 |
LOGSTRING2("CBupPlugin::Id():0x%X", KSamplerBupPluginUid.iUid );
|
|
95 |
return KSamplerBupPluginUid;
|
|
96 |
}
|
|
97 |
|
|
98 |
void CBupPlugin::InitiateSamplerAttributesL()
|
|
99 |
{
|
|
100 |
// create sampler attribute container
|
|
101 |
TSamplerAttributes attr(KSamplerBupPluginUid.iUid,
|
|
102 |
KBUPShortName(),
|
|
103 |
KBUPLongName(),
|
|
104 |
KBUPDescription(),
|
|
105 |
-1,
|
|
106 |
ETrue,
|
|
107 |
EFalse,
|
|
108 |
0); // default item count
|
|
109 |
this->iSamplerAttributes->AppendL(attr);
|
|
110 |
}
|
|
111 |
|
|
112 |
// returns setting array
|
|
113 |
void CBupPlugin::GetAttributesL(CArrayFixFlat<TSamplerAttributes>* aAttributes)
|
|
114 |
{
|
|
115 |
// append my own attributes to complete array, requested by profiler engine
|
|
116 |
aAttributes->AppendL(iSamplerAttributes->At(0));
|
|
117 |
}
|
|
118 |
|
|
119 |
TInt CBupPlugin::SetAttributesL(TSamplerAttributes aAttributes)
|
|
120 |
{
|
|
121 |
TSamplerAttributes attr;
|
|
122 |
|
|
123 |
attr = iSamplerAttributes->At(0);
|
|
124 |
// if UIDs match replace the old
|
|
125 |
if(attr.iUid == aAttributes.iUid)
|
|
126 |
{
|
|
127 |
// replace the old attribute container
|
|
128 |
iSamplerAttributes->Delete(0);
|
|
129 |
iSamplerAttributes->InsertL(0, aAttributes);
|
|
130 |
return KErrNone;
|
|
131 |
}
|
|
132 |
return KErrNotFound;
|
|
133 |
}
|
|
134 |
|
|
135 |
/*
|
|
136 |
* Method for parsing and transforming text array settings into TSamplerAttributes (per each sub sampler),
|
|
137 |
* called by CSamplerController class
|
|
138 |
*
|
|
139 |
* @param array of raw text setting lines, e.g. [gpp]\nenabled=true\nsampling_period_ms=1\n
|
|
140 |
*/
|
|
141 |
TInt CBupPlugin::ConvertRawSettingsToAttributes(CDesC8ArrayFlat* aAllSettingsArray)
|
|
142 |
{
|
|
143 |
// local literals
|
|
144 |
_LIT8(KBUPShort, "bup");
|
|
145 |
|
|
146 |
TInt err(KErrNone);
|
|
147 |
TBuf8<16> samplerSearchName;
|
|
148 |
samplerSearchName.Copy(KBUPShort);
|
|
149 |
|
|
150 |
// get sampler specific settings
|
|
151 |
err = DoSetSamplerSettings(aAllSettingsArray, samplerSearchName, 0);
|
|
152 |
|
|
153 |
// returns KErrNone if settings found, otherwise KErrNotFound
|
|
154 |
return err;
|
|
155 |
}
|
|
156 |
|
|
157 |
TInt CBupPlugin::DoSetSamplerSettings(CDesC8ArrayFlat* aAllSettings, TDesC8& aSamplerName, TInt aIndex)
|
|
158 |
{
|
|
159 |
//
|
|
160 |
TBuf8<16> samplerSearch;
|
|
161 |
samplerSearch.Copy(KBracketOpen);
|
|
162 |
samplerSearch.Append(aSamplerName);
|
|
163 |
samplerSearch.Append(KBracketClose);
|
|
164 |
|
|
165 |
// read a line
|
|
166 |
for (TInt i(0); i<aAllSettings->MdcaCount(); i++)
|
|
167 |
{
|
|
168 |
// check if this line has a setting block start, i.e. contains [xxx] in it
|
|
169 |
if (aAllSettings->MdcaPoint(i).CompareF(samplerSearch) == 0)
|
|
170 |
{
|
|
171 |
// right settings block found, now loop until the next block is found
|
|
172 |
for(TInt j(i+1);j<aAllSettings->MdcaCount();j++)
|
|
173 |
{
|
|
174 |
// check if the next settings block was found
|
|
175 |
if(aAllSettings->MdcaPoint(j).Left(1).CompareF(KBracketOpen) != 0)
|
|
176 |
{
|
|
177 |
// save found setting value directly to its owners attributes
|
|
178 |
SaveSettingToAttributes(aAllSettings->MdcaPoint(j), aIndex);
|
|
179 |
}
|
|
180 |
else
|
|
181 |
{
|
|
182 |
// next block found, return KErrNone
|
|
183 |
return KErrNone;
|
|
184 |
}
|
|
185 |
}
|
|
186 |
}
|
|
187 |
}
|
|
188 |
|
|
189 |
return KErrNotFound;
|
|
190 |
}
|
|
191 |
|
|
192 |
/**
|
|
193 |
* Method for setting a specific descriptor (from settings file) to attribute structure
|
|
194 |
*
|
|
195 |
* @param aSetting
|
|
196 |
* @param aName
|
|
197 |
*/
|
|
198 |
void CBupPlugin::SaveSettingToAttributes(const TDesC8& aSetting, TInt aIndex)
|
|
199 |
{
|
|
200 |
// find the equal mark from the setting line
|
|
201 |
TInt sepPos = aSetting.Find(KSettingItemSeparator);
|
|
202 |
// check that '=' is found
|
|
203 |
if (sepPos > 0)
|
|
204 |
{
|
|
205 |
// check that the element matches
|
|
206 |
if (aSetting.Left(sepPos).CompareF(KEnabled) == 0)
|
|
207 |
{
|
|
208 |
TBool en;
|
|
209 |
CSamplerPluginInterface::Str2Bool(aSetting.Right(aSetting.Length()-sepPos-1), en);
|
|
210 |
if(iSamplerAttributes->At(aIndex).iEnabled != en)
|
|
211 |
{
|
|
212 |
iSamplerAttributes->At(aIndex).iEnabled = en;
|
|
213 |
}
|
|
214 |
}
|
|
215 |
}
|
|
216 |
}
|
|
217 |
|
|
218 |
TInt CBupPlugin::GetSamplerType()
|
|
219 |
{
|
|
220 |
return iSamplerType;
|
|
221 |
}
|
|
222 |
|
|
223 |
TInt CBupPlugin::ResetAndActivateL(CProfilerSampleStream& aStream)
|
|
224 |
{
|
|
225 |
LOGTEXT(_L("CBupPlugin::ResetAndActivate() - entry"));
|
|
226 |
TInt ret(KErrNone);
|
|
227 |
|
|
228 |
// check if sampler enabled
|
|
229 |
if(iSamplerAttributes->At(0).iEnabled)
|
|
230 |
{
|
|
231 |
// create first the listener instance
|
|
232 |
iButtonListener = CProfilerButtonListener::NewL(this);
|
|
233 |
|
|
234 |
LOGTEXT(_L("CBupPlugin::ResetAndActivate() - listener created"));
|
|
235 |
|
|
236 |
iStream = &aStream;
|
|
237 |
TInt length = this->CreateFirstSample();
|
|
238 |
iVersion[0] = (TUint8)length;
|
|
239 |
LOGSTRING2("CBupPlugin::ResetAndActivate() - AddSample, length %d",length);
|
|
240 |
ret = AddSample(iVersion, length+1, 0);
|
|
241 |
if(ret != KErrNone)
|
|
242 |
return ret;
|
|
243 |
|
|
244 |
// activate button listener
|
|
245 |
ret = iButtonListener->StartL();
|
|
246 |
|
|
247 |
iEnabled = ETrue;
|
|
248 |
|
|
249 |
LOGTEXT(_L("CBupPlugin::ResetAndActivate() - exit"));
|
|
250 |
}
|
|
251 |
return ret;
|
|
252 |
|
|
253 |
}
|
|
254 |
|
|
255 |
TInt CBupPlugin::CreateFirstSample()
|
|
256 |
{
|
|
257 |
LOGTEXT(_L("CBupPlugin::CreateFirstSample - entry"));
|
|
258 |
this->iVersionDescriptor.Zero();
|
|
259 |
this->iVersionDescriptor.Append(_L8("Bappea_BUP_V"));
|
|
260 |
this->iVersionDescriptor.Append(PROFILER_BUP_SAMPLER_VERSION);
|
|
261 |
LOGTEXT(_L("CBupPlugin::CreateFirstSample - exit"));
|
|
262 |
return (TInt)(this->iVersionDescriptor.Length());
|
|
263 |
}
|
|
264 |
|
|
265 |
TInt CBupPlugin::StopSampling()
|
|
266 |
{
|
|
267 |
if(iButtonListener)
|
|
268 |
{
|
|
269 |
iButtonListener->Stop();
|
|
270 |
delete iButtonListener; // delete listener after every trace
|
|
271 |
iButtonListener = NULL;
|
|
272 |
}
|
|
273 |
|
|
274 |
// set disabled
|
|
275 |
iEnabled = EFalse;
|
|
276 |
|
|
277 |
return KErrNone;
|
|
278 |
}
|
|
279 |
|
|
280 |
void CBupPlugin::FillThisStreamBuffer(TBapBuf* /*aBapBuf*/, TRequestStatus& /*aStatus*/)
|
|
281 |
{
|
|
282 |
}
|
|
283 |
|
|
284 |
/*
|
|
285 |
*
|
|
286 |
* Implementation of class CProfilerButtonListener
|
|
287 |
*
|
|
288 |
*/
|
|
289 |
CProfilerButtonListener::CProfilerButtonListener(CBupPlugin* aSampler)
|
|
290 |
{
|
|
291 |
LOGTEXT(_L("CProfilerButtonListener::CProfilerButtonListener() - konstuktori"));
|
|
292 |
this->iSampler = aSampler;
|
|
293 |
iSampleStartTime = 0;
|
|
294 |
LOGTEXT(_L("CProfilerButtonListener::CProfilerButtonListener() - konstuktori exit"));
|
|
295 |
}
|
|
296 |
|
|
297 |
CProfilerButtonListener* CProfilerButtonListener::NewL(CBupPlugin* aSampler)
|
|
298 |
{
|
|
299 |
LOGTEXT(_L("CProfilerButtonListener::NewL() - entry"));
|
|
300 |
CProfilerButtonListener* self = new (ELeave) CProfilerButtonListener(aSampler);
|
|
301 |
CleanupStack::PushL( self );
|
|
302 |
self->ConstructL();
|
|
303 |
CleanupStack::Pop();
|
|
304 |
LOGTEXT(_L("CProfilerButtonListener::NewL() - exit"));
|
|
305 |
return self;
|
|
306 |
}
|
|
307 |
|
|
308 |
CProfilerButtonListener::~CProfilerButtonListener()
|
|
309 |
{
|
|
310 |
LOGTEXT(_L("CProfilerButtonListener::~CProfilerButtonListener() - entry af"));
|
|
311 |
|
|
312 |
if(iMainWindow)
|
|
313 |
{
|
|
314 |
LOGTEXT(_L("CProfilerButtonListener::~CProfilerButtonListener(): flushing iWs"));
|
|
315 |
iWs.Flush();
|
|
316 |
LOGTEXT(_L("CProfilerButtonListener::~CProfilerButtonListener(): finishing"));
|
|
317 |
}
|
|
318 |
delete iMainWindow;
|
|
319 |
LOGTEXT(_L("CProfilerButtonListener::~CProfilerButtonListener() - exit"));
|
|
320 |
}
|
|
321 |
|
|
322 |
void CProfilerButtonListener::ConstructMainWindowL()
|
|
323 |
{
|
|
324 |
LOGTEXT(_L("CProfilerButtonListener::ConstructMainWindowL() - Entry"));
|
|
325 |
|
|
326 |
CWindow* window = new (ELeave) CWindow(this);
|
|
327 |
CleanupStack::PushL( window );
|
|
328 |
window->ConstructL(TRect(TPoint(0,0), TSize(0,0)));
|
|
329 |
delete iMainWindow;
|
|
330 |
iMainWindow = window;
|
|
331 |
CleanupStack::Pop( window );
|
|
332 |
|
|
333 |
LOGTEXT(_L("CProfilerButtonListener::ConstructMainWindowL() - Exit"));
|
|
334 |
}
|
|
335 |
|
|
336 |
void CProfilerButtonListener::HandleKeyEventL (TKeyEvent& /*aKeyEvent*/)
|
|
337 |
{
|
|
338 |
LOGTEXT(_L("CProfilerButtonListener::HandleKeyEventL() - Start"));
|
|
339 |
LOGTEXT(_L("CProfilerButtonListener::HandleKeyEventL() - End"));
|
|
340 |
}
|
|
341 |
|
|
342 |
|
|
343 |
TInt CProfilerButtonListener::RunError(TInt aError)
|
|
344 |
{
|
|
345 |
// get rid of everything we allocated
|
|
346 |
// deactivate the anim dll before killing window, otherwise anim dll dies too early
|
|
347 |
iAnim->Deactivate();
|
|
348 |
iAnim->Close();
|
|
349 |
|
|
350 |
iAnimDll->Close();
|
|
351 |
|
|
352 |
return aError;
|
|
353 |
}
|
|
354 |
|
|
355 |
void CProfilerButtonListener::RunL()
|
|
356 |
{
|
|
357 |
// resubscribe before processing new value to prevent missing updates
|
|
358 |
IssueRequest();
|
|
359 |
|
|
360 |
TInt c = 0;
|
|
361 |
if(RProperty::Get(KProfilerKeyEventPropertyCat, EProfilerKeyEventPropertySample, c) == KErrNone)
|
|
362 |
{
|
|
363 |
// do something with event
|
|
364 |
LOGSTRING2("CProfilerButtonListener::RunL() - event [%d] received",c);
|
|
365 |
|
|
366 |
iSample[0] = c;
|
|
367 |
iSample[1] = c >> 8;
|
|
368 |
iSample[2] = c >> 16;
|
|
369 |
iSample[3] = c >> 24;
|
|
370 |
|
|
371 |
// Space for GPP sample time
|
|
372 |
TUint32 sampleTime = User::NTickCount() - iSampleStartTime;
|
|
373 |
LOGSTRING2("CProfilerButtonListener::RunL() - sample time is %d",sampleTime);
|
|
374 |
|
|
375 |
iSample[4] = sampleTime;
|
|
376 |
iSample[5] = sampleTime >> 8;
|
|
377 |
iSample[6] = sampleTime >> 16;
|
|
378 |
iSample[7] = sampleTime >> 24;
|
|
379 |
|
|
380 |
iSampler->AddSample(iSample, 8, 0xb0);
|
|
381 |
}
|
|
382 |
}
|
|
383 |
|
|
384 |
TInt CProfilerButtonListener::StartL()
|
|
385 |
{
|
|
386 |
LOGTEXT(_L("CProfilerButtonListener::StartL() - Activate touch server dll"));
|
|
387 |
TInt err(KErrNone);
|
|
388 |
|
|
389 |
// get the property value
|
|
390 |
TInt r = RProperty::Get(KGppPropertyCat, EGppPropertySyncSampleNumber, iSampleStartTime);
|
|
391 |
if(r != KErrNone)
|
|
392 |
{
|
|
393 |
LOGSTRING2("CProfilerButtonListener::StartL() - getting iSyncOffset failed, error %d", r);
|
|
394 |
}
|
|
395 |
|
|
396 |
iAnimDll = new (ELeave) RAnimDll(iWs);
|
|
397 |
LOGTEXT(_L("CProfilerButtonListener::StartL() - #1"));
|
|
398 |
|
|
399 |
TParse* fp = new (ELeave) TParse();
|
|
400 |
CleanupStack::PushL(fp);
|
|
401 |
fp->Set( KDllName, &KDC_SHARED_LIB_DIR , NULL );
|
|
402 |
LOGSTRING2("CProfilerButtonListener::StartL() - touch event server: %S" , &(fp->FullName()));
|
|
403 |
|
|
404 |
err = iAnimDll->Load(fp->FullName());
|
|
405 |
// check if anim dll load failed
|
|
406 |
if(err != KErrNone)
|
|
407 |
{
|
|
408 |
CleanupStack::PopAndDestroy(fp);
|
|
409 |
// stop plugin if failed
|
|
410 |
iAnimDll->Close();
|
|
411 |
return KErrGeneral;
|
|
412 |
}
|
|
413 |
CleanupStack::PopAndDestroy(fp);
|
|
414 |
LOGTEXT(_L("CProfilerButtonListener::StartL() - #2"));
|
|
415 |
|
|
416 |
iAnim = new (ELeave) RProfilerTouchEventAnim(*iAnimDll);
|
|
417 |
LOGTEXT(_L("CProfilerButtonListener::StartL() - #3"));
|
|
418 |
iAnim->ConstructL(iMainWindow->Window());
|
|
419 |
|
|
420 |
// activate the animation dll for collecting touch and key events
|
|
421 |
iAnim->Activate();
|
|
422 |
|
|
423 |
// wait for a new sample
|
|
424 |
IssueRequest();
|
|
425 |
|
|
426 |
// hide this window group from the app switcher
|
|
427 |
iMainWindow->Client()->Group().SetOrdinalPosition(-1);
|
|
428 |
iMainWindow->Client()->Group().EnableReceiptOfFocus(EFalse);
|
|
429 |
return KErrNone;
|
|
430 |
}
|
|
431 |
|
|
432 |
TInt CProfilerButtonListener::Stop()
|
|
433 |
{
|
|
434 |
LOGTEXT(_L("CProfilerButtonListener::Stop() - enter"));
|
|
435 |
// deactivate the anim dll before killing window, otherwise anim dll dies too early
|
|
436 |
iAnim->Deactivate();
|
|
437 |
iAnim->Close();
|
|
438 |
|
|
439 |
iAnimDll->Close();
|
|
440 |
|
|
441 |
Cancel();
|
|
442 |
LOGTEXT(_L("CProfilerButtonListener::Stop() - exit"));
|
|
443 |
return KErrNone;
|
|
444 |
}
|
|
445 |
|
|
446 |
|
|
447 |
///////////////////////////////////////////////////////////////////////////////
|
|
448 |
////////////////////////// CWindow implementation /////////////////////////////
|
|
449 |
///////////////////////////////////////////////////////////////////////////////
|
|
450 |
|
|
451 |
CWindow::CWindow(CWsClient* aClient)
|
|
452 |
: iClient(aClient)
|
|
453 |
{
|
|
454 |
LOGTEXT(_L("CWindow::CWindow()"));
|
|
455 |
}
|
|
456 |
|
|
457 |
void CWindow::ConstructL (const TRect& aRect, CWindow* aParent)
|
|
458 |
{
|
|
459 |
LOGTEXT(_L("CWindow::ConstructL(): Start"));
|
|
460 |
|
|
461 |
// If a parent window was specified, use it; if not, use the window group
|
|
462 |
// (aParent defaults to 0).
|
|
463 |
RWindowTreeNode* parent= aParent ? (RWindowTreeNode*) &(aParent->Window()) : &(iClient->iGroup);
|
|
464 |
iWindow=RWindow(iClient->iWs); // use app's session to window server
|
|
465 |
User::LeaveIfError(iWindow.Construct(*parent,(TUint32)this));
|
|
466 |
LOGSTRING2("CWindow::ConstructL(): Start - window handle is: 0x%08x", this);
|
|
467 |
iRect = aRect;
|
|
468 |
iWindow.SetExtent(iRect.iTl, iRect.Size()); // set extent relative to group coords
|
|
469 |
iWindow.Activate(); // window is now active
|
|
470 |
LOGTEXT(_L("CWindow::ConstructL(): End"));
|
|
471 |
}
|
|
472 |
|
|
473 |
|
|
474 |
CWindow::~CWindow()
|
|
475 |
{
|
|
476 |
LOGTEXT(_L("CWindow::~CWindow(): Start"));
|
|
477 |
iWindow.Close(); // close our window
|
|
478 |
LOGTEXT(_L("CWindow::~CWindow(): End"));
|
|
479 |
}
|
|
480 |
|
|
481 |
RWindow& CWindow::Window()
|
|
482 |
{
|
|
483 |
LOGTEXT(_L("CWindow::Window()"));
|
|
484 |
return iWindow;
|
|
485 |
}
|
|
486 |
|
|
487 |
CWindowGc* CWindow::SystemGc()
|
|
488 |
{
|
|
489 |
LOGTEXT(_L("CWindow::SystemGc()"));
|
|
490 |
return iClient->iGc;
|
|
491 |
}
|
|
492 |
|
|
493 |
/////////////////////////////////////////////////////////////////////////////////////
|
|
494 |
/////////////////////////// CWsClient implementation ////////////////////////////////
|
|
495 |
/////////////////////////////////////////////////////////////////////////////////////
|
|
496 |
CWsClient::CWsClient()
|
|
497 |
: CActive(CActive::EPriorityStandard)
|
|
498 |
{
|
|
499 |
LOGTEXT(_L("CWsClient::CWsClient()"));
|
|
500 |
}
|
|
501 |
|
|
502 |
void CWsClient::ConstructL()
|
|
503 |
{
|
|
504 |
LOGTEXT(_L("CWsClient::ConstructL() - Start"));
|
|
505 |
TInt r = RProperty::Define(EProfilerKeyEventPropertySample, RProperty::EInt, KAllowAllPolicy, KCapabilityNone);
|
|
506 |
if (r!=KErrAlreadyExists)
|
|
507 |
{
|
|
508 |
User::LeaveIfError(r);
|
|
509 |
}
|
|
510 |
|
|
511 |
CActiveScheduler::Add(this);
|
|
512 |
|
|
513 |
// attach to
|
|
514 |
User::LeaveIfError(iProperty.Attach(KProfilerKeyEventPropertyCat,EProfilerKeyEventPropertySample));
|
|
515 |
|
|
516 |
// get a session going
|
|
517 |
User::LeaveIfError(iWs.Connect());
|
|
518 |
|
|
519 |
// construct screen device and graphics context
|
|
520 |
iScreen=new (ELeave) CWsScreenDevice(iWs); // make device for this session
|
|
521 |
User::LeaveIfError(iScreen->Construct( 0 )); // and complete its construction
|
|
522 |
User::LeaveIfError(iScreen->CreateContext(iGc)); // create graphics context
|
|
523 |
|
|
524 |
// construct our one and only window group
|
|
525 |
iGroup=RWindowGroup(iWs);
|
|
526 |
User::LeaveIfError(iGroup.Construct((TInt)this, EFalse)); // meaningless handle; enable focus
|
|
527 |
|
|
528 |
// construct main window
|
|
529 |
ConstructMainWindowL();
|
|
530 |
|
|
531 |
LOGTEXT(_L("CWsClient::CWsClient() - End"));
|
|
532 |
}
|
|
533 |
|
|
534 |
CWsClient::~CWsClient()
|
|
535 |
{
|
|
536 |
LOGTEXT(_L("CWsClient::~CWsClient() - Start"));
|
|
537 |
|
|
538 |
// get rid of everything we allocated
|
|
539 |
delete iGc;
|
|
540 |
delete iScreen;
|
|
541 |
|
|
542 |
iGroup.Close();
|
|
543 |
// finish with window server
|
|
544 |
iWs.Close();
|
|
545 |
|
|
546 |
LOGTEXT(_L("CWsClient::~CWsClient() - Exit"));
|
|
547 |
}
|
|
548 |
|
|
549 |
void CWsClient::Exit()
|
|
550 |
{
|
|
551 |
LOGTEXT(_L("CWsClient::Exit() - Start"));
|
|
552 |
|
|
553 |
// destroy window group
|
|
554 |
iGroup.Close();
|
|
555 |
// finish with window server
|
|
556 |
iProperty.Close();
|
|
557 |
iWs.Close();
|
|
558 |
LOGTEXT(_L("CWsClient::Exit() - Exit"));
|
|
559 |
}
|
|
560 |
|
|
561 |
void CWsClient::IssueRequest()
|
|
562 |
{
|
|
563 |
LOGTEXT(_L("CWsClient::IssueRequest() - Start"));
|
|
564 |
iProperty.Subscribe( iStatus );
|
|
565 |
SetActive(); // so we're now active
|
|
566 |
LOGTEXT(_L("CWsClient::IssueRequest() - Exit"));
|
|
567 |
}
|
|
568 |
|
|
569 |
void CWsClient::DoCancel()
|
|
570 |
{
|
|
571 |
LOGTEXT(_L("CWsClient::DoCancel() - Start"));
|
|
572 |
// clean up the sample property
|
|
573 |
iProperty.Cancel();
|
|
574 |
iProperty.Close();
|
|
575 |
LOGTEXT(_L("CWsClient::DoCancel() - Exit"));
|
|
576 |
}
|
|
577 |
|
|
578 |
void CWsClient::ConstructMainWindowL()
|
|
579 |
{
|
|
580 |
LOGTEXT(_L("CWsClient::ConstructMainWindowL()"));
|
|
581 |
}
|
|
582 |
|