loadgen/ui/hb/src/engine.cpp
changeset 17 4f2773374eff
child 31 e7a04a6385be
equal deleted inserted replaced
15:e11368ed4880 17:4f2773374eff
       
     1 /*
       
     2 * Copyright (c) 2010 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 FILES
       
    20 #include "engine.h"
       
    21 #include "enginewrapper.h"
       
    22 #include "settingsview.h"
       
    23 #include "loadgen_utils.h"
       
    24 #include "loadgen_cpuload.h"
       
    25 #include "loadgen_memoryeat.h"
       
    26 #include "loadgen_phonecall.h"
       
    27 #include "loadgen_netconn.h"
       
    28 #include "loadgen_keypress.h"
       
    29 #include "loadgen_pointerevent.h"
       
    30 #include "loadgen_messages.h"
       
    31 #include "loadgen_applications.h"
       
    32 #include "loadgen_photocapture.h"
       
    33 #include "loadgen_bluetooth.h"
       
    34 #include "loadgen_traces.h"
       
    35 #include "loadgen_loadattributes.h"
       
    36 #include "loadgen.hrh"
       
    37 
       
    38 //#include "loadgen_editors.h"
       
    39 //#include "loadgen_app.h"
       
    40 //#include "loadgen_settingsviewdlg.h"
       
    41 //#include "loadgen_maincontainer.h"
       
    42 
       
    43 //#include <loadgen.rsg>
       
    44 
       
    45 #include <coeutils.h>
       
    46 #include <bautils.h>
       
    47 #include <eikenv.h>
       
    48 //#include <AknQueryDialog.h>
       
    49 #include <e32math.h> 
       
    50 #include <u32hal.h>
       
    51 #include <hal.h> 
       
    52 #include <hal_data.h>
       
    53 
       
    54 #include <ecam.h>
       
    55 //#include <aknnotewrappers.h>
       
    56 #include <featdiscovery.h>
       
    57 
       
    58 const TInt KZeroIndex = 0;
       
    59 
       
    60 // ===================================== MEMBER FUNCTIONS =====================================
       
    61 
       
    62 CEngine* CEngine::NewL(EngineWrapper *aEngineWrapper)
       
    63     {
       
    64     CEngine* self = new(ELeave) CEngine;
       
    65     CleanupStack::PushL(self);
       
    66     self->ConstructL(aEngineWrapper);
       
    67     CleanupStack::Pop();
       
    68     return self;
       
    69     }
       
    70 
       
    71 // --------------------------------------------------------------------------------------------
       
    72 
       
    73 CEngine::CEngine() : CActive(EPriorityStandard)
       
    74     {
       
    75     }
       
    76     
       
    77 // --------------------------------------------------------------------------------------------
       
    78 
       
    79 void CEngine::ConstructL(EngineWrapper *aEngineWrapper)
       
    80     {
       
    81 	iEngineWrapper = aEngineWrapper;
       
    82 
       
    83     iReferenceNumber = 0;
       
    84 	iCurrentItemIndex = 0;
       
    85 	iEditExistingLoad = EFalse;
       
    86     
       
    87     iEnv = CEikonEnv::Static();
       
    88     User::LeaveIfError(iLs.Connect());
       
    89     
       
    90     iLoadItemList = new(ELeave) CLoadItemList(64);
       
    91 
       
    92     User::LeaveIfError(iTimer.CreateLocal());
       
    93     CActiveScheduler::Add(this);
       
    94   
       
    95   }
       
    96 
       
    97 // --------------------------------------------------------------------------------------------
       
    98 
       
    99 void CEngine::ActivateEngineL()
       
   100     {
       
   101     // load settings
       
   102     //TRAP_IGNORE(LoadSettingsL());
       
   103 
       
   104 	// RAM
       
   105 	TMemoryInfoV1Buf ramMemory;
       
   106 	UserHal::MemoryInfo(ramMemory);
       
   107 	                
       
   108 	TInt freeRam = ramMemory().iFreeRamInBytes;
       
   109 
       
   110 	
       
   111     // set defaults to attributes
       
   112     iCpuLoadAttributes.iId = 0;
       
   113     iCpuLoadAttributes.iPriority = EThreadPriorityTypeNormal;
       
   114     iCpuLoadAttributes.iMode = ECpuLoadModeYielding;
       
   115     iCpuLoadAttributes.iType = ECpuLoadTypePeriodic;
       
   116     iCpuLoadAttributes.iLength = 4000;
       
   117     iCpuLoadAttributes.iIdle = 2000;
       
   118     iCpuLoadAttributes.iRandomVariance = 0;
       
   119     iCpuLoadAttributes.iCpu = KCPUSelection_FreeScheduling; // set CPU as "undefined" (can be >= 0 only in SMP environments)
       
   120     iCpuLoadAttributes.iCpuCount = UserSvr::HalFunction(EHalGroupKernel, KHalFunction_EKernelHalNumLogicalCpus, 0, 0);
       
   121     if( iCpuLoadAttributes.iCpuCount < 1 || iCpuLoadAttributes.iCpuCount > KMaxCPUs )
       
   122         {
       
   123         // HAL may not support this function, so let's use CPU count 1:
       
   124         iCpuLoadAttributes.iCpuCount = 1;
       
   125         }
       
   126     iMemoryEatAttributes.iId = 0;
       
   127     iMemoryEatAttributes.iPriority = EThreadPriorityTypeNormal;
       
   128     iMemoryEatAttributes.iSource = 0;
       
   129     iMemoryEatAttributes.iType = EMemoryEatTypeMemoryToBeLeft;
       
   130     iMemoryEatAttributes.iBuffer = 16*1024;
       
   131     iMemoryEatAttributes.iIdle = 0;
       
   132     iMemoryEatAttributes.iAmount = freeRam;//0;
       
   133     iMemoryEatAttributes.iRandomMin = 1000000;
       
   134     iMemoryEatAttributes.iRandomMax = 1500000;
       
   135     iMemoryEatAttributes.iAmountDes.Copy(KNullDesC);
       
   136     iMemoryEatAttributes.iRandomMinDes.Copy(KNullDesC);
       
   137     iMemoryEatAttributes.iRandomMaxDes.Copy(KNullDesC);
       
   138     iMemoryEatAttributes.iRandomVariance = 0;
       
   139 
       
   140     iPhoneCallAttributes.iId = 0;
       
   141     iPhoneCallAttributes.iPriority = EThreadPriorityTypeNormal;
       
   142     iPhoneCallAttributes.iDestination.Copy(_L("+358"));
       
   143     iPhoneCallAttributes.iLength = 60000;
       
   144     iPhoneCallAttributes.iIdle = 10000;
       
   145     iPhoneCallAttributes.iRandomVariance = 0;
       
   146 
       
   147     iNetConnAttributes.iId = 0;
       
   148     iNetConnAttributes.iPriority = EThreadPriorityTypeNormal;
       
   149     iNetConnAttributes.iDestination.Copy(_L("http://www.nokia.com"));
       
   150     iNetConnAttributes.iIdle = 10000;
       
   151     iNetConnAttributes.iRandomVariance = 0;
       
   152 
       
   153     iKeyPressAttributes.iId = 0;
       
   154     iKeyPressAttributes.iPriority = EThreadPriorityTypeNormal;
       
   155     iKeyPressAttributes.iHeartBeat = 100;
       
   156     iKeyPressAttributes.iRandomVariance = 0;
       
   157     
       
   158     iPointerEventAttributes.iId = 0;
       
   159     iPointerEventAttributes.iPriority = EThreadPriorityTypeNormal;
       
   160     iPointerEventAttributes.iHeartBeat = 1000;
       
   161     iPointerEventAttributes.iRandomVariance = 0;
       
   162 
       
   163     iMessageAttributes.iId = 0;
       
   164     iMessageAttributes.iPriority = EThreadPriorityTypeNormal;
       
   165     iMessageAttributes.iMessageType = EMessageTypeSMS;
       
   166     iMessageAttributes.iDestination.Copy(_L("+358"));
       
   167     iMessageAttributes.iAmount = 5;
       
   168     iMessageAttributes.iLength = 160;
       
   169     iMessageAttributes.iIdle = 15000;
       
   170     iMessageAttributes.iRandomVariance = 0;
       
   171     
       
   172     iApplicationsAttributes.iId = 0;
       
   173     iApplicationsAttributes.iLaunchingInterval = 2000;
       
   174     iApplicationsAttributes.iPriority = EThreadPriorityTypeNormal;
       
   175     iApplicationsAttributes.iKeyPressType = EApplicationsKeyPressTypeNone;
       
   176     iApplicationsAttributes.iMaxOpen = 20;
       
   177     iApplicationsAttributes.iHeartBeat = 50;
       
   178     iApplicationsAttributes.iRandomVariance = 0;
       
   179     
       
   180     iPhotoCaptureAttributes.iId = 0;
       
   181     iPhotoCaptureAttributes.iPriority = EThreadPriorityTypeNormal;
       
   182     iPhotoCaptureAttributes.iIdle = 10000;
       
   183     iPhotoCaptureAttributes.iRandomVariance = 0;        
       
   184     iPhotoCaptureAttributes.iCameraCount = CCamera::CamerasAvailable();
       
   185     if(iPhotoCaptureAttributes.iCameraCount > 0)
       
   186         {
       
   187         iPhotoCaptureAttributes.iCamera = 0; // Main camera
       
   188         }
       
   189     else
       
   190         {
       
   191         iPhotoCaptureAttributes.iCamera = -1;
       
   192         }
       
   193     
       
   194     iBluetoothAttributes.iId = 0;
       
   195     iBluetoothAttributes.iPriority = EThreadPriorityTypeNormal;
       
   196     iBluetoothAttributes.iIdle = 10000;
       
   197     iBluetoothAttributes.iRandomVariance = 0;
       
   198     iBluetoothAttributes.iBluetoothSupported = CFeatureDiscovery::IsFeatureSupportedL(KFeatureIdBt);
       
   199     }
       
   200 
       
   201 // --------------------------------------------------------------------------------------------
       
   202 
       
   203 void CEngine::DeActivateEngineL()
       
   204     {
       
   205     Cancel();
       
   206     
       
   207     // for a faster exit, send the application to background
       
   208     TApaTask selfTask(iEnv->WsSession());
       
   209     selfTask.SetWgId(iEnv->RootWin().Identifier());
       
   210     selfTask.SendToBackground();
       
   211     }
       
   212     
       
   213 // --------------------------------------------------------------------------------------------
       
   214 
       
   215 CEngine::~CEngine()
       
   216     {
       
   217     if (iLoadItemList)
       
   218         {
       
   219         DeleteAllLoadItems();
       
   220         delete iLoadItemList;
       
   221         }
       
   222     if ( iApplicationsAttributes.iAppsArray )
       
   223         {
       
   224         delete iApplicationsAttributes.iAppsArray;
       
   225         }
       
   226     iTimer.Close();
       
   227     iLs.Close();
       
   228     }
       
   229 
       
   230 // --------------------------------------------------------------------------------------------
       
   231 
       
   232 void CEngine::DoCancel()
       
   233     {
       
   234     iTimer.Cancel();
       
   235     }
       
   236 
       
   237 // --------------------------------------------------------------------------------------------
       
   238 
       
   239 void CEngine::RunL()
       
   240     {
       
   241     // continue    
       
   242     //iTimer.After(iStatus, 400000);
       
   243     //SetActive();
       
   244     }
       
   245     
       
   246 // --------------------------------------------------------------------------------------------
       
   247 
       
   248 void CEngine::StartNewLoadL(TInt aCommand)
       
   249     {
       
   250     // show new load query
       
   251 	//CLoadGenLoadTypeEditorBase* dlg = NULL;
       
   252 	
       
   253 	if(aCommand == ELoadGenCmdNewLoadPhotoCaptures && 
       
   254 	   iPhotoCaptureAttributes.iCameraCount == 0)
       
   255 		{
       
   256 		_LIT(message, "Cameras not available");
       
   257 		iEngineWrapper->ShowNote(message);
       
   258 		return;
       
   259 		}
       
   260 	if(aCommand == ELoadGenCmdNewLoadBluetooth &&
       
   261 	   iBluetoothAttributes.iBluetoothSupported == EFalse)
       
   262 		{
       
   263 		_LIT(message, "Bluetooth device not available");
       
   264 		iEngineWrapper->ShowNote(message); 
       
   265 		return;
       
   266 		}
       
   267 	/*
       
   268     switch ( aCommand )
       
   269         {
       
   270         case ELoadGenCmdNewLoadCPULoad:
       
   271             {
       
   272             //dlg = CLoadGenCPULoadEditor::NewL(iCpuLoadAttributes);
       
   273             break;
       
   274             }
       
   275         case ELoadGenCmdNewLoadEatMemory:
       
   276             {
       
   277             //dlg = CLoadGenMemoryEatEditor::NewL(iMemoryEatAttributes);
       
   278             break;
       
   279             }
       
   280         case ELoadGenCmdNewLoadPhoneCall:
       
   281             {
       
   282             //dlg = CLoadGenPhoneCallEditor::NewL(iPhoneCallAttributes);
       
   283             break;
       
   284             }
       
   285         case ELoadGenCmdNewLoadNetConn:
       
   286             {
       
   287             //dlg = CLoadGenNetConnEditor::NewL(iNetConnAttributes);
       
   288             break;
       
   289             }
       
   290         case ELoadGenCmdNewLoadKeyPress:
       
   291             {
       
   292             //dlg = CLoadGenKeyPressEditor::NewL(iKeyPressAttributes);
       
   293             break;
       
   294             }               
       
   295         case ELoadGenCmdNewLoadMessages:
       
   296             {
       
   297             //dlg = CLoadGenMessagesEditor::NewL( iMessageAttributes );
       
   298             break;
       
   299             }
       
   300         case ELoadGenCmdNewLoadApplications:
       
   301             {
       
   302             //dlg = CLoadGenApplicationsEditor::NewL( iApplicationsAttributes );
       
   303             break;
       
   304             }
       
   305         case ELoadGenCmdNewLoadPhotoCaptures:
       
   306             {
       
   307             if( iPhotoCaptureAttributes.iCameraCount > 0 )
       
   308                 {
       
   309                 //dlg = CLoadGenPhotoCaptureEditor::NewL( iPhotoCaptureAttributes );
       
   310                 }
       
   311             else
       
   312                 {
       
   313                 _LIT(message, "Cameras not available");
       
   314 				iEngineWrapper->ShowNote(message); 
       
   315                 //CAknErrorNote* errorNote = new(ELeave) CAknErrorNote;
       
   316                 //errorNote->ExecuteLD(message);
       
   317 				return;
       
   318                 }
       
   319             break;
       
   320             }
       
   321         case ELoadGenCmdNewLoadBluetooth:
       
   322             {
       
   323             if( iBluetoothAttributes.iBluetoothSupported )
       
   324                 {
       
   325                 //dlg = CLoadGenBluetoothEditor::NewL(iBluetoothAttributes);                
       
   326                 }
       
   327             else
       
   328                 {
       
   329                 _LIT(message, "Bluetooth device not available");
       
   330 				iEngineWrapper->ShowNote(message); 
       
   331                 //CAknErrorNote* errorNote = new(ELeave) CAknErrorNote;
       
   332                 //errorNote->ExecuteLD(message);
       
   333                 return;
       
   334                 }
       
   335             break;
       
   336             }
       
   337         case ELoadGenCmdNewLoadPointerEvent:
       
   338             {
       
   339             //dlg = CLoadGenPointerEventEditor::NewL(iPointerEventAttributes);
       
   340             break;
       
   341             } 
       
   342 
       
   343         default:
       
   344             {
       
   345             User::Panic(_L("Wrong new load"), 111);
       
   346             break;
       
   347             }
       
   348         }
       
   349 	*/
       
   350 	iEditExistingLoad = EFalse;
       
   351     iEngineWrapper->OpenLoadSettings(aCommand, EFalse); // = dlg->RunQueryLD();
       
   352 
       
   353     // set back title
       
   354     
       
   355 	//if (iMainContainer) 
       
   356     //    iMainContainer->SetDefaultTitlePaneTextL();
       
   357 
       
   358     // start creating new load if dialog accepted
       
   359     //if (dlgResult)
       
   360     //    {
       
   361     //    DoStartNewLoadL(aCommand);
       
   362     //    }
       
   363 	// DoStartNewLoadL() called from engine wrapper slot function newLoadAdded() after
       
   364 	// load settings closed by user select: ok.
       
   365     }
       
   366 
       
   367 // --------------------------------------------------------------------------------------------
       
   368 
       
   369 void CEngine::EditLoadL(TInt aIndex)
       
   370     {
       
   371 	CLoadBase* aItem = iLoadItemList->At(aIndex);
       
   372 	iCurrentItemIndex = aIndex;
       
   373 	iEditExistingLoad = ETrue;
       
   374     // suspend current
       
   375 	if (aItem->State() == CLoadBase::ELoadStateRunning)
       
   376 		{
       
   377 		iLoadStatusBeforeEdit = CLoadBase::ELoadStateRunning;
       
   378 		aItem->Suspend();
       
   379 		}
       
   380     
       
   381     // show new load query
       
   382 
       
   383 	/* CLoadGenLoadTypeEditorBase* dlg = NULL;
       
   384 	
       
   385 
       
   386     switch ( aItem->Type() )
       
   387         {
       
   388         case ELoadGenCmdNewLoadCPULoad:
       
   389             {
       
   390             //dlg = CLoadGenCPULoadEditor::NewL(static_cast<CCPULoad*>(aItem)->Attributes(), ETrue);
       
   391             break;
       
   392             }
       
   393         case ELoadGenCmdNewLoadEatMemory:
       
   394             {
       
   395             //dlg = CLoadGenMemoryEatEditor::NewL(static_cast<CMemoryEat*>(aItem)->Attributes(), ETrue);
       
   396             break;
       
   397             }
       
   398         case ELoadGenCmdNewLoadPhoneCall:
       
   399             {
       
   400             //dlg = CLoadGenPhoneCallEditor::NewL(static_cast<CPhoneCall*>(aItem)->Attributes(), ETrue);
       
   401             break;
       
   402             }
       
   403         case ELoadGenCmdNewLoadNetConn:
       
   404             {
       
   405             //dlg = CLoadGenNetConnEditor::NewL(static_cast<CNetConn*>(aItem)->Attributes(), ETrue);
       
   406             break;
       
   407             }
       
   408         case ELoadGenCmdNewLoadKeyPress:
       
   409             {
       
   410             //dlg = CLoadGenKeyPressEditor::NewL(static_cast<CKeyPress*>(aItem)->Attributes(), ETrue);
       
   411             break;
       
   412             }       
       
   413         case ELoadGenCmdNewLoadMessages:
       
   414             {
       
   415             //dlg = CLoadGenMessagesEditor::NewL(static_cast<CMessages*>(aItem)->Attributes(), ETrue);
       
   416             break;
       
   417             }
       
   418         case ELoadGenCmdNewLoadApplications:
       
   419             {
       
   420             //dlg = CLoadGenApplicationsEditor::NewL( static_cast<CAppLauncher*>(aItem)->Attributes(), ETrue );
       
   421             break;
       
   422             }
       
   423         case ELoadGenCmdNewLoadPhotoCaptures:
       
   424             {
       
   425             //dlg = CLoadGenPhotoCaptureEditor::NewL( static_cast<CPhotoCapture*>(aItem)->Attributes(), ETrue );
       
   426             break;
       
   427             }
       
   428         case ELoadGenCmdNewLoadBluetooth:
       
   429             {
       
   430             //dlg = CLoadGenBluetoothEditor::NewL( static_cast<CBluetooth*>(aItem)->Attributes(), ETrue );
       
   431             break;
       
   432             }
       
   433         case ELoadGenCmdNewLoadPointerEvent:
       
   434             {
       
   435             //dlg = CLoadGenPointerEventEditor::NewL(static_cast<CPointerEvent*>(aItem)->Attributes(), ETrue);
       
   436             break;
       
   437             }
       
   438         default:
       
   439             {
       
   440             User::Panic(_L("Wrong edit load"), 114);
       
   441             break;
       
   442             }
       
   443         }
       
   444 		*/
       
   445 	iEngineWrapper->OpenLoadSettings(aItem->Type(), iEditExistingLoad);
       
   446     // ExistingLoadEditedL method called from engine wrapper when load settings view close signal received.
       
   447     
       
   448 	//TBool dlgResult = ETrue; //dlg->RunQueryLD();
       
   449 
       
   450     // set back title
       
   451 	// TODO: check this.
       
   452     //if (iMainContainer)
       
   453     //    iMainContainer->SetDefaultTitlePaneTextL();
       
   454     
       
   455     // change priority of the load item
       
   456     //aItem->SetPriority();
       
   457 
       
   458     // resume execution the item
       
   459     //aItem->Resume();
       
   460     
       
   461     //if (dlgResult)
       
   462     //    RefreshViewL(EFalse);
       
   463     }
       
   464 
       
   465 // --------------------------------------------------------------------------------------------    
       
   466 	
       
   467 void CEngine::ExistingLoadEditedL()
       
   468 	{
       
   469 	CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
   470 	// change priority of the load item
       
   471     aItem->SetPriority();
       
   472 	if (iLoadStatusBeforeEdit == CLoadBase::ELoadStateRunning)
       
   473 		{
       
   474 		// resume execution the item
       
   475 		aItem->Resume();
       
   476 		RefreshViewL(EFalse);
       
   477 		}
       
   478 	// cancel:
       
   479 	
       
   480 	}
       
   481 	
       
   482 // --------------------------------------------------------------------------------------------    
       
   483 	
       
   484 void CEngine::ExistingLoadEditCancelled()
       
   485 	{
       
   486 	if (iLoadStatusBeforeEdit == CLoadBase::ELoadStateRunning)
       
   487 		{
       
   488 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
   489 		// resume execution due to suspend action before edit started:
       
   490 		aItem->Resume();
       
   491 		}	
       
   492 	RefreshViewL(EFalse);
       
   493 	}
       
   494 	
       
   495 // --------------------------------------------------------------------------------------------
       
   496 
       
   497 void CEngine::DoStartNewLoadL(TInt aCommand)
       
   498     {
       
   499     CLoadBase* item = NULL;
       
   500     
       
   501     switch ( aCommand )
       
   502         {
       
   503         case ELoadGenCmdNewLoadCPULoad:
       
   504             {
       
   505             if( iCpuLoadAttributes.iCpu == KCPUSelection_AllCPUs )
       
   506                 {
       
   507                 // Call this function recursively for all CPUs:
       
   508                 for( TUint i = 0; i < iCpuLoadAttributes.iCpuCount; ++i )
       
   509                     {                    
       
   510                     iCpuLoadAttributes.iCpu = i;
       
   511                     DoStartNewLoadL(aCommand);
       
   512                     }
       
   513                 // And finally set user selection back to "All CPUs"
       
   514                 iCpuLoadAttributes.iCpu = KCPUSelection_AllCPUs;
       
   515                 return;
       
   516                 }
       
   517             else
       
   518                 {
       
   519                 item = CCPULoad::NewL(iCpuLoadAttributes, iReferenceNumber);
       
   520                 }
       
   521             break;
       
   522             }
       
   523         case ELoadGenCmdNewLoadEatMemory:
       
   524             {
       
   525             item = CMemoryEat::NewL(iMemoryEatAttributes, iReferenceNumber);
       
   526             break;
       
   527             }
       
   528         case ELoadGenCmdNewLoadPhoneCall:
       
   529             {
       
   530             item = CPhoneCall::NewL(iPhoneCallAttributes, iReferenceNumber);
       
   531             break;
       
   532             }
       
   533         case ELoadGenCmdNewLoadNetConn:
       
   534             {
       
   535             item = CNetConn::NewL(iNetConnAttributes, iReferenceNumber);
       
   536             break;
       
   537             }
       
   538         case ELoadGenCmdNewLoadKeyPress:
       
   539             {
       
   540             item = CKeyPress::NewL(iKeyPressAttributes, iReferenceNumber);
       
   541             break;
       
   542             }        
       
   543         case ELoadGenCmdNewLoadMessages:
       
   544             {
       
   545             item = CMessages::NewL( iMessageAttributes, iReferenceNumber );
       
   546             break;
       
   547             }
       
   548         case ELoadGenCmdNewLoadApplications:
       
   549             {
       
   550             iApplicationsAttributes.iAppsArray = ListOfAllAppsL();
       
   551             item = CAppLauncher::NewL( iApplicationsAttributes, iReferenceNumber );            
       
   552             break;
       
   553             }
       
   554         case ELoadGenCmdNewLoadPhotoCaptures:
       
   555             {
       
   556             item = CPhotoCapture::NewL( iPhotoCaptureAttributes, iReferenceNumber);
       
   557             break;
       
   558             }
       
   559         case ELoadGenCmdNewLoadBluetooth:
       
   560             {
       
   561             item = CBluetooth::NewL( iBluetoothAttributes, iReferenceNumber);            
       
   562             break;
       
   563             }
       
   564         case ELoadGenCmdNewLoadPointerEvent:
       
   565             {
       
   566             item = CPointerEvent::NewL(iPointerEventAttributes, iReferenceNumber);
       
   567             break;
       
   568             }
       
   569             
       
   570         default:
       
   571             {
       
   572             User::Panic(_L("Wrong new load"), 112);
       
   573             break;
       
   574             }
       
   575         }
       
   576     
       
   577     iReferenceNumber++;
       
   578 
       
   579     // add item to the array
       
   580     AppendToLoadItemListL(item);
       
   581 
       
   582     // update the listbox
       
   583     RefreshViewL(EFalse);
       
   584 
       
   585     // set item index to the end
       
   586 	// Check this feature to be done in Orbit UI.
       
   587     // iMainContainer->ListBox()->SetCurrentItemIndexAndDraw( iMainContainer->ListBox()->Model()->NumberOfItems()-1 );
       
   588 
       
   589     // start the load
       
   590     item->Resume();
       
   591         
       
   592     // refresh again
       
   593     RefreshViewL(EFalse);    
       
   594     }
       
   595 
       
   596 // --------------------------------------------------------------------------------------------
       
   597 
       
   598 
       
   599 void CEngine::StopAllLoadItemsL()
       
   600     {
       
   601     DeleteAllLoadItems();
       
   602     
       
   603     RefreshViewL();
       
   604     }
       
   605     
       
   606 // --------------------------------------------------------------------------------------------
       
   607 
       
   608 void CEngine::SuspendAllLoadItemsL()
       
   609     {
       
   610     for (TInt i=0; i<LoadItemCount(); i++)
       
   611         {
       
   612         if ( iLoadItemList->At(i) )
       
   613             {
       
   614             iLoadItemList->At(i)->Suspend();
       
   615             }
       
   616         }
       
   617         
       
   618     RefreshViewL();    
       
   619     }
       
   620 // --------------------------------------------------------------------------------------------
       
   621 
       
   622 void CEngine::ResumeAllLoadItemsL()
       
   623     {
       
   624     for (TInt i=0; i<LoadItemCount(); i++)
       
   625         {
       
   626         if ( iLoadItemList->At(i) )
       
   627             {
       
   628             iLoadItemList->At(i)->Resume();
       
   629             }
       
   630         }
       
   631 
       
   632     RefreshViewL();    
       
   633     }    
       
   634     
       
   635 // --------------------------------------------------------------------------------------------
       
   636 
       
   637 void CEngine::RefreshViewL(TBool aClearSelection)
       
   638     {
       
   639 	// clear selections if any
       
   640 	iEngineWrapper->ClearSelection();
       
   641 	if (aClearSelection) 
       
   642 		{
       
   643 		iEngineWrapper->SetCurrentItemIndex(KZeroIndex);
       
   644 		}
       
   645 	iEngineWrapper->ReFreshView(GenerateListBoxItemTextArrayL());
       
   646     }
       
   647 
       
   648 // --------------------------------------------------------------------------------------------
       
   649 
       
   650 CDesCArray* CEngine::GenerateListBoxItemTextArrayL()
       
   651     {
       
   652     CDesCArray* textArray = new(ELeave) CDesCArrayFlat(64);
       
   653     CleanupStack::PushL(textArray);
       
   654 
       
   655     _LIT(KEntryTemplateRedIcon,   "1\t%S\t\t");
       
   656     _LIT(KEntryTemplateGreenIcon, "2\t%S\t\t");
       
   657     TInt cnt = LoadItemCount();
       
   658     for (TInt i=0; i< cnt; i++)
       
   659         {
       
   660         // add description from each entry
       
   661         TBuf<256> textEntry;
       
   662         TBuf<256> description = iLoadItemList->At(i)->Description();
       
   663         
       
   664         if (iLoadItemList->At(i)->State() == CLoadBase::ELoadStateRunning)
       
   665             textEntry.Format(KEntryTemplateGreenIcon, &description);
       
   666         else
       
   667             textEntry.Format(KEntryTemplateRedIcon, &description);
       
   668         
       
   669         textArray->AppendL(textEntry);
       
   670         }    
       
   671     
       
   672     CleanupStack::Pop(); //textArray
       
   673     return textArray;
       
   674     }
       
   675 	
       
   676 // --------------------------------------------------------------------------------------------
       
   677 
       
   678 void CEngine::AppendToLoadItemListL(CLoadBase* aItem)
       
   679     {
       
   680     if (iLoadItemList)
       
   681         iLoadItemList->AppendL( aItem );
       
   682     else
       
   683         User::Leave(KErrNotReady);
       
   684     }
       
   685 
       
   686 // --------------------------------------------------------------------------------------------
       
   687 
       
   688 void CEngine::DeleteFromLoadItemListL(TInt aIndex)
       
   689     {
       
   690     if (iLoadItemList)
       
   691         {
       
   692         if (iLoadItemList->Count() > aIndex && aIndex >= 0)
       
   693             {
       
   694             // first call delete on the item
       
   695             if (iLoadItemList->At(aIndex))
       
   696                 {                                
       
   697                 delete iLoadItemList->At(aIndex);
       
   698                 iLoadItemList->At(aIndex) = NULL;
       
   699                 }
       
   700             
       
   701             // and them remove the array entry
       
   702             iLoadItemList->Delete(aIndex);
       
   703             iLoadItemList->Compress();
       
   704             }
       
   705         else
       
   706             User::Leave(KErrNotFound);
       
   707         }
       
   708     else
       
   709         User::Leave(KErrNotReady);
       
   710     }
       
   711 
       
   712 // --------------------------------------------------------------------------------------------
       
   713 
       
   714 void CEngine::SuspendOrResumeFromLoadItemListL(TInt aIndex)
       
   715     {
       
   716     if (iLoadItemList)
       
   717         {
       
   718         if (iLoadItemList->Count() > aIndex && aIndex >= 0)
       
   719             {
       
   720             if (iLoadItemList->At(aIndex))
       
   721                 {
       
   722                 if (iLoadItemList->At(aIndex)->State() == CLoadBase::ELoadStateRunning)
       
   723                     {
       
   724                     iLoadItemList->At(aIndex)->Suspend();
       
   725                     }
       
   726                 else if (iLoadItemList->At(aIndex)->State() == CLoadBase::ELoadStateSuspended)
       
   727                     {
       
   728                     iLoadItemList->At(aIndex)->Resume();
       
   729                     }
       
   730                 }
       
   731             }
       
   732         else
       
   733             User::Leave(KErrNotFound);
       
   734         }
       
   735     else
       
   736         User::Leave(KErrNotReady);
       
   737     }
       
   738             
       
   739 // --------------------------------------------------------------------------------------------
       
   740 
       
   741 TInt CEngine::LoadItemCount() const
       
   742     {
       
   743     TInt count(0);
       
   744     
       
   745     if (iLoadItemList)
       
   746         count = iLoadItemList->Count();
       
   747     
       
   748     return count;
       
   749     }
       
   750     
       
   751 // --------------------------------------------------------------------------------------------
       
   752 
       
   753 void CEngine::DeleteAllLoadItems()
       
   754     {
       
   755     // call delete for each entry and free memory allocated for the array
       
   756     for (TInt i=0; i<LoadItemCount(); i++)
       
   757         {
       
   758         if ( iLoadItemList->At(i) )
       
   759             {            
       
   760             delete iLoadItemList->At(i);
       
   761             iLoadItemList->At(i) = NULL;
       
   762             }
       
   763         }
       
   764         
       
   765     iLoadItemList->Reset();    
       
   766     }  
       
   767           
       
   768 // --------------------------------------------------------------------------------------------
       
   769 
       
   770 void CEngine::StopSelectedOrHighlightedItemsL(const CArrayFix<TInt>* aSelectionIndexes)
       
   771     {
       
   772     TInt err(KErrNone);
       
   773 
       
   774     // by default use selected items
       
   775     if (aSelectionIndexes && aSelectionIndexes->Count() > 0)
       
   776         {
       
   777         TInt deleteIndexCounter(0);
       
   778         TInt ref(0);
       
   779         TKeyArrayFix key(0, ECmpTUint16);
       
   780         TInt index(0);
       
   781         
       
   782         TInt loadCount = LoadItemCount();
       
   783 
       
   784         for (TInt i=0; i<loadCount; i++)
       
   785             {
       
   786             ref = i;
       
   787 
       
   788             if (aSelectionIndexes->Find(ref, key, index) == 0)  
       
   789                 {
       
   790                 TRAP(err, DeleteFromLoadItemListL(i-deleteIndexCounter));
       
   791                 deleteIndexCounter++; // amount of indexes decreases after each delete
       
   792                 }
       
   793             }
       
   794             
       
   795             RefreshViewL();
       
   796             User::LeaveIfError(err);
       
   797         }
       
   798     }
       
   799 
       
   800 // --------------------------------------------------------------------------------------------
       
   801 
       
   802 void CEngine::SuspendOrResumeSelectedOrHighlightedItemsL()
       
   803     {
       
   804     const CArrayFix<TInt>* selectionIndexes = iEngineWrapper->QueryListSelectedIndexesOrCurrentItemL(); //iMainContainer->ListBoxSelectionIndexes();
       
   805 
       
   806     // by default use selected items
       
   807     if (selectionIndexes && selectionIndexes->Count() > 0)
       
   808         {
       
   809         TInt ref(0);
       
   810         TKeyArrayFix key(0, ECmpTUint16);
       
   811         TInt index(0);
       
   812 
       
   813         for (TInt i=0; i<LoadItemCount(); i++)
       
   814             {
       
   815             ref = i;
       
   816 
       
   817             if (selectionIndexes->Find(ref, key, index) == 0)  
       
   818                 {
       
   819                 SuspendOrResumeFromLoadItemListL(i);
       
   820                 }
       
   821             }
       
   822         
       
   823         RefreshViewL(EFalse);
       
   824         }  
       
   825     }                                
       
   826 // --------------------------------------------------------------------------------------------
       
   827 
       
   828 void CEngine::LoadSettingsL()
       
   829     {
       
   830     }
       
   831 
       
   832 // --------------------------------------------------------------------------------------------
       
   833 
       
   834 void CEngine::SaveSettingsL()
       
   835     {
       
   836     }
       
   837         
       
   838 // --------------------------------------------------------------------------------------------
       
   839 
       
   840 TInt CEngine::LaunchSettingsDialogL()
       
   841     {
       
   842     return 0;
       
   843     }
       
   844     
       
   845 // --------------------------------------------------------------------------------------------
       
   846 CDesCArray* CEngine::ListOfAllAppsL()
       
   847     {
       
   848     const TInt KMaxAppsArraySize=250;
       
   849     RApaLsSession ls;
       
   850     CleanupClosePushL(ls);
       
   851 
       
   852     User::LeaveIfError( ls.Connect() );
       
   853     CDesCArray* allAppsArray = new(ELeave) CDesCArrayFlat( KMaxAppsArraySize );
       
   854     CleanupStack::PushL( allAppsArray );
       
   855     // reset the apps list
       
   856     allAppsArray->Reset();
       
   857 
       
   858     // search all apps
       
   859     TApaAppInfo appInfo;
       
   860     User::LeaveIfError(ls.GetAllApps());
       
   861 
       
   862 
       
   863     while ( ls.GetNextApp( appInfo ) == KErrNone )
       
   864         {
       
   865         allAppsArray->AppendL( appInfo.iFullName );      
       
   866         }
       
   867     CleanupStack::Pop( allAppsArray );
       
   868     CleanupStack::PopAndDestroy( &ls );
       
   869    
       
   870 
       
   871     // remove loadgen.* from the list
       
   872     for ( TInt i = 0; i < allAppsArray->MdcaCount(); i++ )
       
   873         {
       
   874         if ( allAppsArray->MdcaPoint(i).FindF( _L("\\loadgen.") ) != KErrNotFound )
       
   875             {
       
   876             allAppsArray->Delete(i);
       
   877             allAppsArray->Compress();
       
   878             break;
       
   879             }
       
   880         }
       
   881 
       
   882     // sort the elements
       
   883     allAppsArray->Sort();
       
   884 
       
   885     return allAppsArray; // ownership transferred
       
   886     }
       
   887 
       
   888 // --------------------------------------------------------------------------------------------
       
   889 
       
   890 void CEngine::LaunchPerfMonL()
       
   891 	{
       
   892 	// launch Performance Monitor
       
   893 	const TUid KUidPerfMon = { 0x20011385 };
       
   894 	
       
   895 	RWsSession ws;
       
   896 	User::LeaveIfError( ws.Connect() );
       
   897 	CleanupClosePushL(ws);
       
   898 	
       
   899 	RApaLsSession ls;
       
   900 	User::LeaveIfError( ls.Connect() );
       
   901 	CleanupClosePushL(ls);
       
   902 	
       
   903 	
       
   904 	// try to find the task of PerfMon
       
   905 	TApaTaskList tasklist(ws);
       
   906 	TApaTask task = tasklist.FindApp(KUidPerfMon);
       
   907 
       
   908 	if (task.Exists())
       
   909 		{
       
   910 		// task exists, bring it to foreground
       
   911 		task.BringToForeground();
       
   912 		}
       
   913 	else
       
   914 		{
       
   915 		TApaAppInfo appInfo;
       
   916 		User::LeaveIfError(ls.GetAppInfo(appInfo, KUidPerfMon));
       
   917 		
       
   918 		CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
       
   919 		cmdLine->SetExecutableNameL(appInfo.iFullName);
       
   920 		cmdLine->SetCommandL(EApaCommandBackground);
       
   921 
       
   922 		// start the app
       
   923 		User::LeaveIfError(ls.StartApp(*cmdLine));
       
   924 		
       
   925 		CleanupStack::PopAndDestroy(); //cmdLine                
       
   926 		}
       
   927 	
       
   928 	CleanupStack::PopAndDestroy(2); //ws,ls
       
   929 	}
       
   930 
       
   931 // --------------------------------------------------------------------------------------------
       
   932 	
       
   933 TCPULoadAttributes CEngine::GetCPULoadAttributes()
       
   934 	{
       
   935 	if (iEditExistingLoad == EFalse) 
       
   936 		{
       
   937 		return iCpuLoadAttributes;
       
   938 		}
       
   939 	else 
       
   940 		{
       
   941 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
   942 		return (static_cast<CCPULoad*>(aItem)->Attributes());
       
   943 		}
       
   944 	}
       
   945 
       
   946 // --------------------------------------------------------------------------------------------
       
   947 
       
   948 void CEngine::ChangeCPULoadAttributes(TCPULoadAttributes aAttributes) 
       
   949 	{ 
       
   950 	if (iEditExistingLoad == EFalse) 
       
   951 		{
       
   952 		iCpuLoadAttributes = aAttributes; 
       
   953 		}
       
   954 	else 
       
   955 		{
       
   956 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
   957 		static_cast<CCPULoad*>(aItem)->SetAttributes(aAttributes);
       
   958 		}
       
   959 	}
       
   960 
       
   961 // --------------------------------------------------------------------------------------------
       
   962 
       
   963 TMemoryEatAttributes CEngine::GetMemoryEatAttributes()
       
   964 	{ 
       
   965 	if (iEditExistingLoad == EFalse)
       
   966 		{	
       
   967 		return iMemoryEatAttributes; 
       
   968 		}
       
   969 	else 
       
   970 		{
       
   971 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
   972 		return (static_cast<CMemoryEat*>(aItem)->Attributes());
       
   973 		}
       
   974 	}
       
   975 
       
   976 // --------------------------------------------------------------------------------------------
       
   977 
       
   978 void CEngine::ChangeMemoryEatAttributes(TMemoryEatAttributes aAttributes) 
       
   979 	{ 
       
   980 	if (iEditExistingLoad == EFalse) 
       
   981 		{
       
   982 		iMemoryEatAttributes = aAttributes; 
       
   983 		}
       
   984 	else 
       
   985 		{
       
   986 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
   987 		static_cast<CMemoryEat*>(aItem)->SetAttributes(aAttributes);
       
   988 		}
       
   989 	}	
       
   990 	
       
   991 // --------------------------------------------------------------------------------------------
       
   992 
       
   993 TPhoneCallAttributes CEngine::GetPhoneCallAttributes()
       
   994 	{ 
       
   995 	if (iEditExistingLoad == EFalse)
       
   996 		{	
       
   997 		return iPhoneCallAttributes; 
       
   998 		}
       
   999 	else 
       
  1000 		{
       
  1001 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1002 		return (static_cast<CPhoneCall*>(aItem)->Attributes());
       
  1003 		}
       
  1004 	}
       
  1005 
       
  1006 // --------------------------------------------------------------------------------------------	
       
  1007 
       
  1008 void CEngine::ChangePhoneCallAttributes(TPhoneCallAttributes aAttributes)
       
  1009 	{
       
  1010 	if (iEditExistingLoad == EFalse) 
       
  1011 		{
       
  1012 		iPhoneCallAttributes = aAttributes; 
       
  1013 		}
       
  1014 	else 
       
  1015 		{
       
  1016 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1017 		static_cast<CPhoneCall*>(aItem)->SetAttributes(aAttributes);
       
  1018 		}	
       
  1019 	}
       
  1020 	
       
  1021 // --------------------------------------------------------------------------------------------	
       
  1022 
       
  1023 TNetConnAttributes CEngine::GetNetConnAttributes()
       
  1024 	{ 
       
  1025 	if (iEditExistingLoad == EFalse)
       
  1026 		{	
       
  1027 		return iNetConnAttributes; 
       
  1028 		}
       
  1029 	else 
       
  1030 		{
       
  1031 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1032 		return (static_cast<CNetConn*>(aItem)->Attributes());
       
  1033 		}
       
  1034 	}
       
  1035 
       
  1036 // --------------------------------------------------------------------------------------------		
       
  1037 	
       
  1038 void CEngine::ChangeNetConnAttributes(TNetConnAttributes aAttributes)
       
  1039 	{
       
  1040 	if (iEditExistingLoad == EFalse) 
       
  1041 		{
       
  1042 		iNetConnAttributes = aAttributes; 
       
  1043 		}
       
  1044 	else 
       
  1045 		{
       
  1046 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1047 		static_cast<CNetConn*>(aItem)->SetAttributes(aAttributes);
       
  1048 		}	
       
  1049 	}
       
  1050 	
       
  1051 // --------------------------------------------------------------------------------------------	
       
  1052 
       
  1053 TKeyPressAttributes CEngine::GetKeyPressAttributes()
       
  1054 	{ 
       
  1055 	if (iEditExistingLoad == EFalse)
       
  1056 		{	
       
  1057 		return iKeyPressAttributes; 
       
  1058 		}
       
  1059 	else 
       
  1060 		{
       
  1061 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1062 		return (static_cast<CKeyPress*>(aItem)->Attributes());
       
  1063 		}
       
  1064 	}	
       
  1065 
       
  1066 	
       
  1067 // --------------------------------------------------------------------------------------------		
       
  1068 	
       
  1069 void CEngine::ChangeKeyPressAttributes(TKeyPressAttributes aAttributes)
       
  1070 	{
       
  1071 	if (iEditExistingLoad == EFalse) 
       
  1072 		{
       
  1073 		iKeyPressAttributes = aAttributes; 
       
  1074 		}
       
  1075 	else 
       
  1076 		{
       
  1077 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1078 		static_cast<CKeyPress*>(aItem)->SetAttributes(aAttributes);
       
  1079 		}	
       
  1080 	}	
       
  1081 	
       
  1082 // --------------------------------------------------------------------------------------------	
       
  1083 
       
  1084 TMessageAttributes CEngine::GetMessageAttributes()
       
  1085 	{ 
       
  1086 	if (iEditExistingLoad == EFalse)
       
  1087 		{	
       
  1088 		return iMessageAttributes; 
       
  1089 		}
       
  1090 	else 
       
  1091 		{
       
  1092 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1093 		return (static_cast<CMessages*>(aItem)->Attributes());
       
  1094 		}
       
  1095 	}	
       
  1096 	
       
  1097 // --------------------------------------------------------------------------------------------		
       
  1098 	
       
  1099 void CEngine::ChangeMessageAttributes(TMessageAttributes aAttributes)
       
  1100 	{
       
  1101 	if (iEditExistingLoad == EFalse) 
       
  1102 		{
       
  1103 		iMessageAttributes = aAttributes; 
       
  1104 		}
       
  1105 	else 
       
  1106 		{
       
  1107 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1108 		static_cast<CMessages*>(aItem)->SetAttributes(aAttributes);
       
  1109 		}	
       
  1110 	}
       
  1111 
       
  1112 // --------------------------------------------------------------------------------------------	
       
  1113 
       
  1114 TApplicationsAttributes CEngine::GetApplicationsAttributes()
       
  1115 	{ 
       
  1116 	if (iEditExistingLoad == EFalse)
       
  1117 		{	
       
  1118 		return iApplicationsAttributes; 
       
  1119 		}
       
  1120 	else 
       
  1121 		{
       
  1122 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1123 		return (static_cast<CAppLauncher*>(aItem)->Attributes());
       
  1124 		}
       
  1125 	}	
       
  1126 
       
  1127 // --------------------------------------------------------------------------------------------		
       
  1128 	
       
  1129 void CEngine::ChangeApplicationsAttributes(TApplicationsAttributes aAttributes)
       
  1130 	{
       
  1131 	if (iEditExistingLoad == EFalse) 
       
  1132 		{
       
  1133 		iApplicationsAttributes = aAttributes; 
       
  1134 		}
       
  1135 	else 
       
  1136 		{
       
  1137 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1138 		static_cast<CAppLauncher*>(aItem)->SetAttributes(aAttributes);
       
  1139 		}	
       
  1140 	}
       
  1141 	
       
  1142 // --------------------------------------------------------------------------------------------	
       
  1143 
       
  1144 TPhotoCaptureAttributes CEngine::GetPhotoCaptureAttributes()
       
  1145 	{ 
       
  1146 	if (iEditExistingLoad == EFalse)
       
  1147 		{	
       
  1148 		return iPhotoCaptureAttributes; 
       
  1149 		}
       
  1150 	else 
       
  1151 		{
       
  1152 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1153 		return (static_cast<CPhotoCapture*>(aItem)->Attributes());
       
  1154 		}
       
  1155 	}	
       
  1156 
       
  1157 // --------------------------------------------------------------------------------------------		
       
  1158 	
       
  1159 void CEngine::ChangePhotoCaptureAttributes(TPhotoCaptureAttributes aAttributes)
       
  1160 	{
       
  1161 	if (iEditExistingLoad == EFalse) 
       
  1162 		{
       
  1163 		iPhotoCaptureAttributes = aAttributes; 
       
  1164 		}
       
  1165 	else 
       
  1166 		{
       
  1167 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1168 		static_cast<CPhotoCapture*>(aItem)->SetAttributes(aAttributes);
       
  1169 		}	
       
  1170 	}	
       
  1171 	
       
  1172 // --------------------------------------------------------------------------------------------	
       
  1173 	
       
  1174 TBluetoothAttributes CEngine::GetBluetoothAttributes()
       
  1175 	{ 
       
  1176 	if (iEditExistingLoad == EFalse)
       
  1177 		{	
       
  1178 		return iBluetoothAttributes; 
       
  1179 		}
       
  1180 	else 
       
  1181 		{
       
  1182 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1183 		return (static_cast<CBluetooth*>(aItem)->Attributes());
       
  1184 		}
       
  1185 	}		
       
  1186 
       
  1187 	
       
  1188 // --------------------------------------------------------------------------------------------		
       
  1189 	
       
  1190 void CEngine::ChangeBluetoothAttributes(TBluetoothAttributes aAttributes)
       
  1191 	{
       
  1192 	if (iEditExistingLoad == EFalse) 
       
  1193 		{
       
  1194 		iBluetoothAttributes = aAttributes; 
       
  1195 		}
       
  1196 	else 
       
  1197 		{
       
  1198 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1199 		static_cast<CBluetooth*>(aItem)->SetAttributes(aAttributes);
       
  1200 		}	
       
  1201 	} 	
       
  1202 	
       
  1203 // --------------------------------------------------------------------------------------------	
       
  1204 	
       
  1205 TPointerEventAttributes CEngine::GetPointerEventAttributes()
       
  1206 	{
       
  1207 	if (iEditExistingLoad == EFalse)
       
  1208 		{	
       
  1209 		return iPointerEventAttributes; 
       
  1210 		}
       
  1211 	else 
       
  1212 		{
       
  1213 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1214 		return (static_cast<CPointerEvent*>(aItem)->Attributes());
       
  1215 		}
       
  1216 	}
       
  1217 
       
  1218 // --------------------------------------------------------------------------------------------		
       
  1219 	
       
  1220 void CEngine::ChangePointerEventAttributes(TPointerEventAttributes aAttributes)
       
  1221 	{
       
  1222 	if (iEditExistingLoad == EFalse) 
       
  1223 		{
       
  1224 		iPointerEventAttributes = aAttributes; 
       
  1225 		}
       
  1226 	else 
       
  1227 		{
       
  1228 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1229 		static_cast<CPointerEvent*>(aItem)->SetAttributes(aAttributes);
       
  1230 		}	
       
  1231 	} 
       
  1232 	
       
  1233 // --------------------------------------------------------------------------------------------
       
  1234 	
       
  1235 // End of File