perfsrv/piprofiler/plugins/BUPplugin/src/BupPlugin.cpp
changeset 62 1c2bb2fc7c87
parent 51 98307c651589
equal deleted inserted replaced
56:aa2539c91954 62:1c2bb2fc7c87
    73 	    {
    73 	    {
    74 	    // check if button listener still running
    74 	    // check if button listener still running
    75 	    if(Enabled())
    75 	    if(Enabled())
    76 	        {
    76 	        {
    77 	        // stop profiling
    77 	        // stop profiling
    78 	        iButtonListener->Stop();
    78 	        iButtonListener->Cancel();
    79 	        }
    79 	        }
    80         delete iButtonListener;
    80         delete iButtonListener;
    81 	    }
    81 	    }
    82 	
    82 	
    83 	if(iSamplerAttributes)
    83 	if(iSamplerAttributes)
   226 	TInt ret(KErrNone);
   226 	TInt ret(KErrNone);
   227 	
   227 	
   228 	// check if sampler enabled
   228 	// check if sampler enabled
   229 	if(iSamplerAttributes->At(0).iEnabled)
   229 	if(iSamplerAttributes->At(0).iEnabled)
   230 	    {
   230 	    {
   231         // create first the listener instance
       
   232         iButtonListener = CProfilerButtonListener::NewL(this);
       
   233         
       
   234         LOGTEXT(_L("CBupPlugin::ResetAndActivate() - listener created"));
       
   235         
       
   236         iStream = &aStream;
   231         iStream = &aStream;
   237         TInt length = this->CreateFirstSample();
   232         TInt length = this->CreateFirstSample();
   238         iVersion[0] = (TUint8)length;
   233         iVersion[0] = (TUint8)length;
   239         LOGSTRING2("CBupPlugin::ResetAndActivate() - AddSample, length %d",length);
   234         LOGSTRING2("CBupPlugin::ResetAndActivate() - AddSample, length %d",length);
   240         ret = AddSample(iVersion, length+1, 0);
   235         ret = AddSample(iVersion, length+1, 0);
   241         if(ret != KErrNone)
   236         if(ret != KErrNone)
   242             return ret;
   237             return ret;
   243         
   238 
   244         // activate button listener
   239         // create first the listener instance
   245         ret = iButtonListener->StartL();
   240         iButtonListener = new (ELeave)CProfilerButtonListener;
       
   241         iButtonListener->ConstructL(this);
       
   242         LOGTEXT(_L("CBupPlugin::ResetAndActivate() - listener created"));
   246 
   243 
   247         iEnabled = ETrue;
   244         iEnabled = ETrue;
   248         
   245         
   249         LOGTEXT(_L("CBupPlugin::ResetAndActivate() - exit"));
   246         LOGTEXT(_L("CBupPlugin::ResetAndActivate() - exit"));
   250 	    }
   247 	    }
   262 	return (TInt)(this->iVersionDescriptor.Length());
   259 	return (TInt)(this->iVersionDescriptor.Length());
   263 	}
   260 	}
   264 
   261 
   265 TInt CBupPlugin::StopSampling() 
   262 TInt CBupPlugin::StopSampling() 
   266 	{
   263 	{
       
   264     LOGTEXT(_L("CBupPlugin::StopSampling() - Start"));
       
   265 
   267 	if(iButtonListener)
   266 	if(iButtonListener)
   268 		{
   267 		{
   269 		iButtonListener->Stop();
   268 	    LOGTEXT(_L("CBupPlugin::StopSampling() - Cancelling listener..."));
       
   269 		iButtonListener->Cancel();
       
   270 	    LOGTEXT(_L("CBupPlugin::StopSampling() - deleting listener..."));
   270 		delete iButtonListener;	// delete listener after every trace
   271 		delete iButtonListener;	// delete listener after every trace
       
   272 	    LOGTEXT(_L("CBupPlugin::StopSampling() - finalizing listener..."));
   271 		iButtonListener = NULL;
   273 		iButtonListener = NULL;
   272 		}
   274 		}
   273 	
   275 	
   274     // set disabled
   276     // set disabled
   275     iEnabled = EFalse;
   277     iEnabled = EFalse;
   276 
   278 
       
   279     LOGTEXT(_L("CBupPlugin::StopSampling() - Exit"));
   277 	return KErrNone;
   280 	return KErrNone;
   278 	}
   281 	}
   279 
   282 
   280 void CBupPlugin::FillThisStreamBuffer(TBapBuf* /*aBapBuf*/, TRequestStatus& /*aStatus*/)
   283 void CBupPlugin::FillThisStreamBuffer(TBapBuf* /*aBapBuf*/, TRequestStatus& /*aStatus*/)
   281 	{
   284 	{
   282 	}
   285 	}
   283 
   286 
   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 
   287 
   446 
   288 
   447 ///////////////////////////////////////////////////////////////////////////////
   289 ///////////////////////////////////////////////////////////////////////////////
   448 ////////////////////////// CWindow implementation /////////////////////////////
   290 ////////////////////////// CWindow implementation /////////////////////////////
   449 ///////////////////////////////////////////////////////////////////////////////
   291 ///////////////////////////////////////////////////////////////////////////////
   497 : CActive(CActive::EPriorityStandard)
   339 : CActive(CActive::EPriorityStandard)
   498 	{
   340 	{
   499     LOGTEXT(_L("CWsClient::CWsClient()"));
   341     LOGTEXT(_L("CWsClient::CWsClient()"));
   500 	}
   342 	}
   501 
   343 
   502 void CWsClient::ConstructL()
   344 void CWsClient::ConstructL(CBupPlugin* aSampler)
   503 	{
   345 	{
   504     LOGTEXT(_L("CWsClient::ConstructL() - Start"));
   346     LOGTEXT(_L("CWsClient::ConstructL() - Start"));
       
   347     // pointer to parent, for collecting the trace data to the data stream
       
   348     iSampler = aSampler;
       
   349 
       
   350     // add to the active scheduler
       
   351     CActiveScheduler::Add(this);
       
   352     
   505     TInt r = RProperty::Define(EProfilerKeyEventPropertySample, RProperty::EInt, KAllowAllPolicy, KCapabilityNone);
   353     TInt r = RProperty::Define(EProfilerKeyEventPropertySample, RProperty::EInt, KAllowAllPolicy, KCapabilityNone);
   506     if (r!=KErrAlreadyExists)
   354     if (r!=KErrAlreadyExists)
   507         {
   355         {
   508         User::LeaveIfError(r);
   356         User::LeaveIfError(r);
   509         }
   357         }
   510     
   358     
   511 	CActiveScheduler::Add(this);
       
   512 
       
   513 	// attach to 
   359 	// attach to 
   514 	User::LeaveIfError(iProperty.Attach(KProfilerKeyEventPropertyCat,EProfilerKeyEventPropertySample));
   360 	User::LeaveIfError(iProperty.Attach(KProfilerKeyEventPropertyCat,EProfilerKeyEventPropertySample));
   515     
   361     
   516 	// get a session going
   362 	// get a session going
   517 	User::LeaveIfError(iWs.Connect());
   363 	User::LeaveIfError(iWs.Connect());
   526 	User::LeaveIfError(iGroup.Construct((TInt)this, EFalse)); // meaningless handle; enable focus
   372 	User::LeaveIfError(iGroup.Construct((TInt)this, EFalse)); // meaningless handle; enable focus
   527 	
   373 	
   528 	// construct main window
   374 	// construct main window
   529 	ConstructMainWindowL();
   375 	ConstructMainWindowL();
   530 
   376 
   531 	LOGTEXT(_L("CWsClient::CWsClient() - End"));
   377     // wait for a new sample
       
   378     IssueRequest();
       
   379 	
       
   380 	LOGTEXT(_L("CWsClient::ConstructL() - End"));
   532 	}
   381 	}
   533 
   382 
   534 CWsClient::~CWsClient()
   383 CWsClient::~CWsClient()
   535 	{
   384 	{
   536     LOGTEXT(_L("CWsClient::~CWsClient() - Start"));
   385     LOGTEXT(_L("CWsClient::~CWsClient() - Start"));
   537     
   386 
   538 	// get rid of everything we allocated
   387     // finish with window server
   539 	delete iGc;
   388     iWs.Close();
   540 	delete iScreen;
   389 
   541 	
   390     // neutralize us as an active object
   542 	iGroup.Close();
   391     Deque();
   543 	// finish with window server
       
   544 	iWs.Close();
       
   545 	
       
   546     LOGTEXT(_L("CWsClient::~CWsClient() - Exit"));
   392     LOGTEXT(_L("CWsClient::~CWsClient() - Exit"));
   547 	}
   393 	}
   548 
   394 
       
   395 CBupPlugin* CWsClient::GetSampler()
       
   396     {
       
   397     return iSampler;
       
   398     }
       
   399 
   549 void CWsClient::Exit()
   400 void CWsClient::Exit()
   550 	{
   401     {
   551     LOGTEXT(_L("CWsClient::Exit() - Start"));
   402     LOGTEXT(_L("CWsClient::Exit(): Start"));
   552 
   403     // get rid of everything we allocated
   553 	// destroy window group
   404     delete iGc;
   554 	iGroup.Close();
   405     delete iScreen;
   555 	// finish with window server
   406     // destroy the window group
       
   407     iGroup.Close();
       
   408     // close the key event P&S object
   556     iProperty.Close();
   409     iProperty.Close();
   557 	iWs.Close();
   410 
   558     LOGTEXT(_L("CWsClient::Exit() - Exit"));
   411     LOGTEXT(_L("CWsClient::Exit(): End"));
   559 	}
   412     }
   560 
   413 
   561 void CWsClient::IssueRequest()
   414 void CWsClient::IssueRequest()
   562 	{
   415 	{
   563     LOGTEXT(_L("CWsClient::IssueRequest() - Start"));
   416     LOGTEXT(_L("CWsClient::IssueRequest() - Start"));
   564     iProperty.Subscribe( iStatus );
   417     iProperty.Subscribe( iStatus );
   567 	}
   420 	}
   568 
   421 
   569 void CWsClient::DoCancel()
   422 void CWsClient::DoCancel()
   570 	{
   423 	{
   571     LOGTEXT(_L("CWsClient::DoCancel() - Start"));
   424     LOGTEXT(_L("CWsClient::DoCancel() - Start"));
   572 	// clean up the sample property
       
   573     iProperty.Cancel();
       
   574     iProperty.Close();
       
   575     LOGTEXT(_L("CWsClient::DoCancel() - Exit"));
   425     LOGTEXT(_L("CWsClient::DoCancel() - Exit"));
   576 	}
   426 	}
   577 
   427 
   578 void CWsClient::ConstructMainWindowL()
   428 void CWsClient::ConstructMainWindowL()
   579 	{
   429 	{
   580     LOGTEXT(_L("CWsClient::ConstructMainWindowL()"));
   430     LOGTEXT(_L("CWsClient::ConstructMainWindowL()"));
   581 	}
   431 	}
   582 
   432 
       
   433 
       
   434 /****************************************************************************\
       
   435 |   Function:   Constructor/Destructor for CMainWindow
       
   436 |               Doesn't do much, as most initialisation is done by the
       
   437 |               CWindow base class.
       
   438 |   Input:      aClient     Client application that owns the window
       
   439 \****************************************************************************/
       
   440 CMainWindow::CMainWindow (CWsClient* aClient)
       
   441 : CWindow (aClient)
       
   442     {
       
   443     LOGTEXT(_L("CMainWindow::CMainWindow()"));
       
   444     }
       
   445 
       
   446 CMainWindow::~CMainWindow ()
       
   447     {
       
   448     LOGTEXT(_L("CMainWindow::~CMainWindow(): Start"));
       
   449     LOGTEXT(_L("CMainWindow::~CMainWindow(): End"));
       
   450     }
       
   451 
       
   452 void CMainWindow::ConstructL (const TRect& aRect, CWindow* aParent)
       
   453     {
       
   454     LOGTEXT(_L("CMainWindow::ConstructL(): Start"));
       
   455     CWindow::ConstructL(aRect, aParent);
       
   456     LOGTEXT(_L("CMainWindow::ConstructL(): End"));
       
   457     }
       
   458 
       
   459 /****************************************************************************\
       
   460 |   Function:   CMainWindow::Draw
       
   461 |   Purpose:    Redraws the contents of CMainWindow within a given
       
   462 |               rectangle. As CMainWindow has no contents, it simply
       
   463 |               clears the redraw area. A blank window could be used here
       
   464 |               instead. The Clear() is needed because a redraw should
       
   465 |               always draw to every pixel in the redraw rectangle.
       
   466 |   Input:      aRect   Rectangle that needs redrawing
       
   467 |   Output:     None
       
   468 \****************************************************************************/
       
   469 void CMainWindow::Draw(const TRect& aRect)
       
   470     {
       
   471     LOGTEXT(_L("CMainWindow::Draw(): Start"));
       
   472     // empty
       
   473     LOGTEXT(_L("CMainWindow::Draw(): End"));
       
   474 }
       
   475 
       
   476 /****************************************************************************\
       
   477 |   Function:   CMainWindow::HandlePointerEvent
       
   478 |   Purpose:    Handles pointer events for CMainWindow.  Doesn't do
       
   479 |               anything except get the co-ordinates where the pointer
       
   480 |               event occurred.
       
   481 |   Input:      aPointerEvent   The pointer event
       
   482 |   Output:     None
       
   483 \****************************************************************************/
       
   484 void CMainWindow::HandlePointerEvent (TPointerEvent& /*aPointerEvent*/)
       
   485     {
       
   486     LOGTEXT(_L("CMainWindow::HandlePointerEvent(): Start"));
       
   487     //  TPoint point = aPointerEvent.iPosition;
       
   488     //  (void)point;
       
   489     LOGTEXT(_L("CMainWindow::HandlePointerEvent(): End"));
       
   490     }
       
   491 
       
   492 /*
       
   493  * 
       
   494  * Implementation of class CProfilerButtonListener
       
   495  * 
       
   496  */
       
   497 CProfilerButtonListener::CProfilerButtonListener() 
       
   498     {
       
   499     LOGTEXT(_L("CProfilerButtonListener::CProfilerButtonListener() - konstuktori"));
       
   500     iSampleStartTime = 0;
       
   501     LOGTEXT(_L("CProfilerButtonListener::CProfilerButtonListener() - konstuktori exit"));
       
   502     }
       
   503 
       
   504 CProfilerButtonListener::~CProfilerButtonListener() 
       
   505     {
       
   506     LOGTEXT(_L("CProfilerButtonListener::~CProfilerButtonListener() - entry"));
       
   507 
       
   508     // clean up the main window
       
   509     if(iMainWindow)
       
   510         {
       
   511         LOGTEXT(_L("CProfilerButtonListener::~CProfilerButtonListener(): flushing iWs"));
       
   512         iWs.Flush();
       
   513         LOGTEXT(_L("CProfilerButtonListener::~CProfilerButtonListener(): finishing"));
       
   514         }
       
   515     delete iMainWindow;
       
   516     LOGTEXT(_L("CProfilerButtonListener::~CProfilerButtonListener() - exit"));
       
   517     }
       
   518     
       
   519 void CProfilerButtonListener::ConstructMainWindowL()
       
   520     {
       
   521     LOGTEXT(_L("CProfilerButtonListener::ConstructMainWindowL() - Entry"));
       
   522 
       
   523     CMainWindow* window = new (ELeave) CMainWindow(this);
       
   524     CleanupStack::PushL( window );
       
   525     window->ConstructL(TRect(TPoint(0,0), TSize(0,0)));
       
   526     //window->Client()->Group().SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront + 1);   // in front of the Status Bar
       
   527     // hide this window group from the app switcher
       
   528     window->Client()->Group().SetOrdinalPosition(-1);
       
   529     window->Client()->Group().EnableReceiptOfFocus(EFalse);
       
   530     LOGTEXT(_L("CProfilerButtonListener::ConstructMainWindowL() - Activate touch server dll"));
       
   531 
       
   532     delete iMainWindow;
       
   533     iMainWindow = window;
       
   534     CleanupStack::Pop( window );
       
   535     
       
   536     // animation dll, the key event listener start
       
   537     TInt err(KErrNone);
       
   538     
       
   539     // get the property value
       
   540     TInt r = RProperty::Get(KGppPropertyCat, EGppPropertySyncSampleNumber, iSampleStartTime);
       
   541     if(r != KErrNone)
       
   542         {
       
   543         LOGSTRING2("CProfilerButtonListener::ConstructMainWindowL() - getting iSyncOffset failed, error %d", r);
       
   544         }
       
   545     
       
   546     iAnimDll = new (ELeave) RAnimDll(iWs);
       
   547     LOGTEXT(_L("CProfilerButtonListener::ConstructMainWindowL() - #1"));
       
   548     
       
   549     TParse* fp = new (ELeave) TParse();
       
   550     CleanupStack::PushL(fp);
       
   551     fp->Set( KDllName, &KDC_SHARED_LIB_DIR , NULL );    
       
   552     LOGSTRING2("CProfilerButtonListener::ConstructMainWindowL() - touch event server: %S" , &(fp->FullName()));
       
   553 
       
   554     err = iAnimDll->Load(fp->FullName());
       
   555     // check if anim dll load failed
       
   556     if(err != KErrNone)
       
   557         {
       
   558         CleanupStack::PopAndDestroy(fp);
       
   559         // stop plugin if failed
       
   560         iAnimDll->Close();
       
   561         User::Leave(err);
       
   562         }
       
   563     CleanupStack::PopAndDestroy(fp);
       
   564     LOGTEXT(_L("CProfilerButtonListener::ConstructMainWindowL() - #2"));
       
   565 
       
   566     iAnim = new (ELeave) RProfilerTouchEventAnim(*iAnimDll);
       
   567     LOGTEXT(_L("CProfilerButtonListener::ConstructMainWindowL() - #3"));
       
   568     iAnim->ConstructL(iMainWindow->Window());
       
   569     
       
   570     // activate the animation dll for collecting touch and key events
       
   571     iAnim->Activate();
       
   572     
       
   573     LOGTEXT(_L("CProfilerButtonListener::ConstructMainWindowL() - Exit"));
       
   574     }
       
   575 
       
   576 void CProfilerButtonListener::DoCancel()
       
   577     {
       
   578     LOGTEXT(_L("CProfilerButtonListener::DoCancel() - Start"));
       
   579     // animation dll deactivation, stopping key listener
       
   580     iAnim->Deactivate();
       
   581     iAnim->Close();
       
   582     iAnimDll->Close();
       
   583 
       
   584     // exiting the parent
       
   585     Exit();
       
   586     LOGTEXT(_L("CProfilerButtonListener::DoCancel() - Exit"));
       
   587     }
       
   588 
       
   589 void CProfilerButtonListener::RunL() 
       
   590     {   
       
   591     // resubscribe before processing new value to prevent missing updates
       
   592     IssueRequest();
       
   593     
       
   594     TInt c(0);
       
   595     if(RProperty::Get(KProfilerKeyEventPropertyCat, EProfilerKeyEventPropertySample, c) == KErrNone)
       
   596         {
       
   597         // do something with event
       
   598         LOGSTRING2("CProfilerButtonListener::RunL() - event [%d] received",c);
       
   599         HandleEvent(c);
       
   600         }
       
   601     }
       
   602 
       
   603 void CProfilerButtonListener::HandleKeyEventL (TKeyEvent& /*aKeyEvent*/)
       
   604     {
       
   605     LOGTEXT(_L("CProfilerButtonListener::HandleKeyEventL() - Start"));
       
   606     LOGTEXT(_L("CProfilerButtonListener::HandleKeyEventL() - End"));
       
   607     }
       
   608 
       
   609 void CProfilerButtonListener::HandleEvent(TInt c)
       
   610     {
       
   611     LOGTEXT(_L("CProfilerButtonListener::HandleEvent() - Start"));
       
   612     if(c >= 0)
       
   613         {
       
   614         // put the event to a sample and finally in to the data stream
       
   615         iSample[0] = c;
       
   616         iSample[1] = c >> 8;
       
   617         iSample[2] = c >> 16;
       
   618         iSample[3] = c >> 24;
       
   619         
       
   620         // Space for GPP sample time        
       
   621         TUint32 sampleTime(User::NTickCount() - iSampleStartTime); 
       
   622         LOGSTRING2("CProfilerButtonListener::RunL() - sample time is %d",sampleTime);
       
   623         
       
   624         iSample[4] = sampleTime;
       
   625         iSample[5] = sampleTime >> 8;
       
   626         iSample[6] = sampleTime >> 16;
       
   627         iSample[7] = sampleTime >> 24;
       
   628         
       
   629         GetSampler()->AddSample(iSample, 8, 0xb0);
       
   630         }
       
   631     LOGTEXT(_L("CProfilerButtonListener::HandleEvent() - End"));
       
   632     }