loadgen/ui/hb/src/engine.cpp
branchRCL_3
changeset 21 b3cee849fa46
equal deleted inserted replaced
20:48060abbbeaf 21:b3cee849fa46
       
     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 */            
       
   539         case ELoadGenCmdNewLoadKeyPress:
       
   540             {
       
   541             item = CKeyPress::NewL(iKeyPressAttributes, iReferenceNumber);
       
   542             break;
       
   543             }        
       
   544         case ELoadGenCmdNewLoadMessages:
       
   545             {
       
   546             item = CMessages::NewL( iMessageAttributes, iReferenceNumber );
       
   547             break;
       
   548             }
       
   549         case ELoadGenCmdNewLoadApplications:
       
   550             {
       
   551             iApplicationsAttributes.iAppsArray = ListOfAllAppsL();
       
   552             item = CAppLauncher::NewL( iApplicationsAttributes, iReferenceNumber );            
       
   553             break;
       
   554             }
       
   555         case ELoadGenCmdNewLoadPhotoCaptures:
       
   556             {
       
   557             item = CPhotoCapture::NewL( iPhotoCaptureAttributes, iReferenceNumber);
       
   558             break;
       
   559             }
       
   560         case ELoadGenCmdNewLoadBluetooth:
       
   561             {
       
   562             item = CBluetooth::NewL( iBluetoothAttributes, iReferenceNumber);            
       
   563             break;
       
   564             }
       
   565         case ELoadGenCmdNewLoadPointerEvent:
       
   566             {
       
   567             item = CPointerEvent::NewL(iPointerEventAttributes, iReferenceNumber);
       
   568             break;
       
   569             }
       
   570             
       
   571         default:
       
   572             {
       
   573             User::Panic(_L("Wrong new load"), 112);
       
   574             break;
       
   575             }
       
   576         }
       
   577     
       
   578     iReferenceNumber++;
       
   579 
       
   580     // add item to the array
       
   581     AppendToLoadItemListL(item);
       
   582 
       
   583     // update the listbox
       
   584     RefreshViewL(EFalse);
       
   585 
       
   586     // set item index to the end
       
   587 	// Check this feature to be done in Orbit UI.
       
   588     // iMainContainer->ListBox()->SetCurrentItemIndexAndDraw( iMainContainer->ListBox()->Model()->NumberOfItems()-1 );
       
   589 
       
   590     // start the load
       
   591     item->Resume();
       
   592         
       
   593     // refresh again
       
   594     RefreshViewL(EFalse);    
       
   595     }
       
   596 
       
   597 // --------------------------------------------------------------------------------------------
       
   598 
       
   599 
       
   600 void CEngine::StopAllLoadItemsL()
       
   601     {
       
   602     DeleteAllLoadItems();
       
   603     
       
   604     RefreshViewL();
       
   605     }
       
   606     
       
   607 // --------------------------------------------------------------------------------------------
       
   608 
       
   609 void CEngine::SuspendAllLoadItemsL()
       
   610     {
       
   611     for (TInt i=0; i<LoadItemCount(); i++)
       
   612         {
       
   613         if ( iLoadItemList->At(i) )
       
   614             {
       
   615             iLoadItemList->At(i)->Suspend();
       
   616             }
       
   617         }
       
   618         
       
   619     RefreshViewL();    
       
   620     }
       
   621 // --------------------------------------------------------------------------------------------
       
   622 
       
   623 void CEngine::ResumeAllLoadItemsL()
       
   624     {
       
   625     for (TInt i=0; i<LoadItemCount(); i++)
       
   626         {
       
   627         if ( iLoadItemList->At(i) )
       
   628             {
       
   629             iLoadItemList->At(i)->Resume();
       
   630             }
       
   631         }
       
   632 
       
   633     RefreshViewL();    
       
   634     }    
       
   635     
       
   636 // --------------------------------------------------------------------------------------------
       
   637 
       
   638 void CEngine::RefreshViewL(TBool aClearSelection)
       
   639     {
       
   640 	// clear selections if any
       
   641 	iEngineWrapper->ClearSelection();
       
   642 	if (aClearSelection) 
       
   643 		{
       
   644 		iEngineWrapper->SetCurrentItemIndex(KZeroIndex);
       
   645 		}
       
   646 	iEngineWrapper->ReFreshView(GenerateListBoxItemTextArrayL());
       
   647     }
       
   648 
       
   649 // --------------------------------------------------------------------------------------------
       
   650 
       
   651 CDesCArray* CEngine::GenerateListBoxItemTextArrayL()
       
   652     {
       
   653     CDesCArray* textArray = new(ELeave) CDesCArrayFlat(64);
       
   654     CleanupStack::PushL(textArray);
       
   655 
       
   656     _LIT(KEntryTemplateRedIcon,   "1\t%S\t\t");
       
   657     _LIT(KEntryTemplateGreenIcon, "2\t%S\t\t");
       
   658     TInt cnt = LoadItemCount();
       
   659     for (TInt i=0; i< cnt; i++)
       
   660         {
       
   661         // add description from each entry
       
   662         TBuf<256> textEntry;
       
   663         TBuf<256> description = iLoadItemList->At(i)->Description();
       
   664         
       
   665         if (iLoadItemList->At(i)->State() == CLoadBase::ELoadStateRunning)
       
   666             textEntry.Format(KEntryTemplateGreenIcon, &description);
       
   667         else
       
   668             textEntry.Format(KEntryTemplateRedIcon, &description);
       
   669         
       
   670         textArray->AppendL(textEntry);
       
   671         }    
       
   672     
       
   673     CleanupStack::Pop(); //textArray
       
   674     return textArray;
       
   675     }
       
   676 	
       
   677 // --------------------------------------------------------------------------------------------
       
   678 
       
   679 void CEngine::AppendToLoadItemListL(CLoadBase* aItem)
       
   680     {
       
   681     if (iLoadItemList)
       
   682         iLoadItemList->AppendL( aItem );
       
   683     else
       
   684         User::Leave(KErrNotReady);
       
   685     }
       
   686 
       
   687 // --------------------------------------------------------------------------------------------
       
   688 
       
   689 void CEngine::DeleteFromLoadItemListL(TInt aIndex)
       
   690     {
       
   691     if (iLoadItemList)
       
   692         {
       
   693         if (iLoadItemList->Count() > aIndex && aIndex >= 0)
       
   694             {
       
   695             // first call delete on the item
       
   696             if (iLoadItemList->At(aIndex))
       
   697                 {                                
       
   698                 delete iLoadItemList->At(aIndex);
       
   699                 iLoadItemList->At(aIndex) = NULL;
       
   700                 }
       
   701             
       
   702             // and them remove the array entry
       
   703             iLoadItemList->Delete(aIndex);
       
   704             iLoadItemList->Compress();
       
   705             }
       
   706         else
       
   707             User::Leave(KErrNotFound);
       
   708         }
       
   709     else
       
   710         User::Leave(KErrNotReady);
       
   711     }
       
   712 
       
   713 // --------------------------------------------------------------------------------------------
       
   714 
       
   715 void CEngine::SuspendOrResumeFromLoadItemListL(TInt aIndex)
       
   716     {
       
   717     if (iLoadItemList)
       
   718         {
       
   719         if (iLoadItemList->Count() > aIndex && aIndex >= 0)
       
   720             {
       
   721             if (iLoadItemList->At(aIndex))
       
   722                 {
       
   723                 if (iLoadItemList->At(aIndex)->State() == CLoadBase::ELoadStateRunning)
       
   724                     {
       
   725                     iLoadItemList->At(aIndex)->Suspend();
       
   726                     }
       
   727                 else if (iLoadItemList->At(aIndex)->State() == CLoadBase::ELoadStateSuspended)
       
   728                     {
       
   729                     iLoadItemList->At(aIndex)->Resume();
       
   730                     }
       
   731                 }
       
   732             }
       
   733         else
       
   734             User::Leave(KErrNotFound);
       
   735         }
       
   736     else
       
   737         User::Leave(KErrNotReady);
       
   738     }
       
   739             
       
   740 // --------------------------------------------------------------------------------------------
       
   741 
       
   742 TInt CEngine::LoadItemCount() const
       
   743     {
       
   744     TInt count(0);
       
   745     
       
   746     if (iLoadItemList)
       
   747         count = iLoadItemList->Count();
       
   748     
       
   749     return count;
       
   750     }
       
   751     
       
   752 // --------------------------------------------------------------------------------------------
       
   753 
       
   754 void CEngine::DeleteAllLoadItems()
       
   755     {
       
   756     // call delete for each entry and free memory allocated for the array
       
   757     for (TInt i=0; i<LoadItemCount(); i++)
       
   758         {
       
   759         if ( iLoadItemList->At(i) )
       
   760             {            
       
   761             delete iLoadItemList->At(i);
       
   762             iLoadItemList->At(i) = NULL;
       
   763             }
       
   764         }
       
   765         
       
   766     iLoadItemList->Reset();    
       
   767     }  
       
   768           
       
   769 // --------------------------------------------------------------------------------------------
       
   770 
       
   771 void CEngine::StopSelectedOrHighlightedItemsL(const CArrayFix<TInt>* aSelectionIndexes)
       
   772     {
       
   773     TInt err(KErrNone);
       
   774 
       
   775     // by default use selected items
       
   776     if (aSelectionIndexes && aSelectionIndexes->Count() > 0)
       
   777         {
       
   778         TInt deleteIndexCounter(0);
       
   779         TInt ref(0);
       
   780         TKeyArrayFix key(0, ECmpTUint16);
       
   781         TInt index(0);
       
   782         
       
   783         TInt loadCount = LoadItemCount();
       
   784 
       
   785         for (TInt i=0; i<loadCount; i++)
       
   786             {
       
   787             ref = i;
       
   788 
       
   789             if (aSelectionIndexes->Find(ref, key, index) == 0)  
       
   790                 {
       
   791                 TRAP(err, DeleteFromLoadItemListL(i-deleteIndexCounter));
       
   792                 deleteIndexCounter++; // amount of indexes decreases after each delete
       
   793                 }
       
   794             }
       
   795             
       
   796             RefreshViewL();
       
   797             User::LeaveIfError(err);
       
   798         }
       
   799     }
       
   800 
       
   801 // --------------------------------------------------------------------------------------------
       
   802 
       
   803 void CEngine::SuspendOrResumeSelectedOrHighlightedItemsL()
       
   804     {
       
   805     const CArrayFix<TInt>* selectionIndexes = iEngineWrapper->QueryListSelectedIndexesOrCurrentItemL(); //iMainContainer->ListBoxSelectionIndexes();
       
   806 
       
   807     // by default use selected items
       
   808     if (selectionIndexes && selectionIndexes->Count() > 0)
       
   809         {
       
   810         TInt ref(0);
       
   811         TKeyArrayFix key(0, ECmpTUint16);
       
   812         TInt index(0);
       
   813 
       
   814         for (TInt i=0; i<LoadItemCount(); i++)
       
   815             {
       
   816             ref = i;
       
   817 
       
   818             if (selectionIndexes->Find(ref, key, index) == 0)  
       
   819                 {
       
   820                 SuspendOrResumeFromLoadItemListL(i);
       
   821                 }
       
   822             }
       
   823         
       
   824         RefreshViewL(EFalse);
       
   825         }  
       
   826     }                                
       
   827 // --------------------------------------------------------------------------------------------
       
   828 
       
   829 void CEngine::LoadSettingsL()
       
   830     {
       
   831     }
       
   832 
       
   833 // --------------------------------------------------------------------------------------------
       
   834 
       
   835 void CEngine::SaveSettingsL()
       
   836     {
       
   837     }
       
   838         
       
   839 // --------------------------------------------------------------------------------------------
       
   840 
       
   841 TInt CEngine::LaunchSettingsDialogL()
       
   842     {
       
   843     return 0;
       
   844     }
       
   845     
       
   846 // --------------------------------------------------------------------------------------------
       
   847 CDesCArray* CEngine::ListOfAllAppsL()
       
   848     {
       
   849     const TInt KMaxAppsArraySize=250;
       
   850     RApaLsSession ls;
       
   851     CleanupClosePushL(ls);
       
   852 
       
   853     User::LeaveIfError( ls.Connect() );
       
   854     CDesCArray* allAppsArray = new(ELeave) CDesCArrayFlat( KMaxAppsArraySize );
       
   855     CleanupStack::PushL( allAppsArray );
       
   856     // reset the apps list
       
   857     allAppsArray->Reset();
       
   858 
       
   859     // search all apps
       
   860     TApaAppInfo appInfo;
       
   861     User::LeaveIfError(ls.GetAllApps());
       
   862 
       
   863 
       
   864     while ( ls.GetNextApp( appInfo ) == KErrNone )
       
   865         {
       
   866         allAppsArray->AppendL( appInfo.iFullName );      
       
   867         }
       
   868     CleanupStack::Pop( allAppsArray );
       
   869     CleanupStack::PopAndDestroy( &ls );
       
   870    
       
   871 
       
   872     // remove loadgen.* from the list
       
   873     for ( TInt i = 0; i < allAppsArray->MdcaCount(); i++ )
       
   874         {
       
   875         if ( allAppsArray->MdcaPoint(i).FindF( _L("\\loadgen.") ) != KErrNotFound )
       
   876             {
       
   877             allAppsArray->Delete(i);
       
   878             allAppsArray->Compress();
       
   879             break;
       
   880             }
       
   881         }
       
   882 
       
   883     // sort the elements
       
   884     allAppsArray->Sort();
       
   885 
       
   886     return allAppsArray; // ownership transferred
       
   887     }
       
   888 
       
   889 // --------------------------------------------------------------------------------------------
       
   890 
       
   891 void CEngine::LaunchPerfMonL()
       
   892 	{
       
   893 	// launch Performance Monitor
       
   894 	const TUid KUidPerfMon = { 0x20011385 };
       
   895 	
       
   896 	RWsSession ws;
       
   897 	User::LeaveIfError( ws.Connect() );
       
   898 	CleanupClosePushL(ws);
       
   899 	
       
   900 	RApaLsSession ls;
       
   901 	User::LeaveIfError( ls.Connect() );
       
   902 	CleanupClosePushL(ls);
       
   903 	
       
   904 	
       
   905 	// try to find the task of PerfMon
       
   906 	TApaTaskList tasklist(ws);
       
   907 	TApaTask task = tasklist.FindApp(KUidPerfMon);
       
   908 
       
   909 	if (task.Exists())
       
   910 		{
       
   911 		// task exists, bring it to foreground
       
   912 		task.BringToForeground();
       
   913 		}
       
   914 	else
       
   915 		{
       
   916 		TApaAppInfo appInfo;
       
   917 		User::LeaveIfError(ls.GetAppInfo(appInfo, KUidPerfMon));
       
   918 		
       
   919 		CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
       
   920 		cmdLine->SetExecutableNameL(appInfo.iFullName);
       
   921 		cmdLine->SetCommandL(EApaCommandBackground);
       
   922 
       
   923 		// start the app
       
   924 		User::LeaveIfError(ls.StartApp(*cmdLine));
       
   925 		
       
   926 		CleanupStack::PopAndDestroy(); //cmdLine                
       
   927 		}
       
   928 	
       
   929 	CleanupStack::PopAndDestroy(2); //ws,ls
       
   930 	}
       
   931 
       
   932 // --------------------------------------------------------------------------------------------
       
   933 	
       
   934 TCPULoadAttributes CEngine::GetCPULoadAttributes()
       
   935 	{
       
   936 	if (iEditExistingLoad == EFalse) 
       
   937 		{
       
   938 		return iCpuLoadAttributes;
       
   939 		}
       
   940 	else 
       
   941 		{
       
   942 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
   943 		return (static_cast<CCPULoad*>(aItem)->Attributes());
       
   944 		}
       
   945 	}
       
   946 
       
   947 // --------------------------------------------------------------------------------------------
       
   948 
       
   949 void CEngine::ChangeCPULoadAttributes(TCPULoadAttributes aAttributes) 
       
   950 	{ 
       
   951 	if (iEditExistingLoad == EFalse) 
       
   952 		{
       
   953 		iCpuLoadAttributes = aAttributes; 
       
   954 		}
       
   955 	else 
       
   956 		{
       
   957 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
   958 		static_cast<CCPULoad*>(aItem)->SetAttributes(aAttributes);
       
   959 		}
       
   960 	}
       
   961 
       
   962 // --------------------------------------------------------------------------------------------
       
   963 
       
   964 TMemoryEatAttributes CEngine::GetMemoryEatAttributes()
       
   965 	{ 
       
   966 	if (iEditExistingLoad == EFalse)
       
   967 		{	
       
   968 		return iMemoryEatAttributes; 
       
   969 		}
       
   970 	else 
       
   971 		{
       
   972 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
   973 		return (static_cast<CMemoryEat*>(aItem)->Attributes());
       
   974 		}
       
   975 	}
       
   976 
       
   977 // --------------------------------------------------------------------------------------------
       
   978 
       
   979 void CEngine::ChangeMemoryEatAttributes(TMemoryEatAttributes aAttributes) 
       
   980 	{ 
       
   981 	if (iEditExistingLoad == EFalse) 
       
   982 		{
       
   983 		iMemoryEatAttributes = aAttributes; 
       
   984 		}
       
   985 	else 
       
   986 		{
       
   987 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
   988 		static_cast<CMemoryEat*>(aItem)->SetAttributes(aAttributes);
       
   989 		}
       
   990 	}	
       
   991 	
       
   992 // --------------------------------------------------------------------------------------------
       
   993 
       
   994 TPhoneCallAttributes CEngine::GetPhoneCallAttributes()
       
   995 	{ 
       
   996 	if (iEditExistingLoad == EFalse)
       
   997 		{	
       
   998 		return iPhoneCallAttributes; 
       
   999 		}
       
  1000 	else 
       
  1001 		{
       
  1002 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1003 		return (static_cast<CPhoneCall*>(aItem)->Attributes());
       
  1004 		}
       
  1005 	}
       
  1006 
       
  1007 // --------------------------------------------------------------------------------------------	
       
  1008 
       
  1009 void CEngine::ChangePhoneCallAttributes(TPhoneCallAttributes aAttributes)
       
  1010 	{
       
  1011 	if (iEditExistingLoad == EFalse) 
       
  1012 		{
       
  1013 		iPhoneCallAttributes = aAttributes; 
       
  1014 		}
       
  1015 	else 
       
  1016 		{
       
  1017 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1018 		static_cast<CPhoneCall*>(aItem)->SetAttributes(aAttributes);
       
  1019 		}	
       
  1020 	}
       
  1021 	
       
  1022 // --------------------------------------------------------------------------------------------	
       
  1023 
       
  1024 TNetConnAttributes CEngine::GetNetConnAttributes()
       
  1025 	{ 
       
  1026 /*  
       
  1027 	if (iEditExistingLoad == EFalse)
       
  1028 		{	
       
  1029 		return iNetConnAttributes; 
       
  1030 		}
       
  1031 	else 
       
  1032 		{
       
  1033 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1034 		return (static_cast<CNetConn*>(aItem)->Attributes());
       
  1035 		}
       
  1036 */		
       
  1037 	}
       
  1038 
       
  1039 // --------------------------------------------------------------------------------------------		
       
  1040 	
       
  1041 void CEngine::ChangeNetConnAttributes(TNetConnAttributes aAttributes)
       
  1042 	{
       
  1043 /*    
       
  1044 	if (iEditExistingLoad == EFalse) 
       
  1045 		{
       
  1046 		iNetConnAttributes = aAttributes; 
       
  1047 		}
       
  1048 	else 
       
  1049 		{
       
  1050 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1051 		static_cast<CNetConn*>(aItem)->SetAttributes(aAttributes);
       
  1052 		}
       
  1053 */			
       
  1054 	}
       
  1055 	
       
  1056 // --------------------------------------------------------------------------------------------	
       
  1057 
       
  1058 TKeyPressAttributes CEngine::GetKeyPressAttributes()
       
  1059 	{ 
       
  1060 	if (iEditExistingLoad == EFalse)
       
  1061 		{	
       
  1062 		return iKeyPressAttributes; 
       
  1063 		}
       
  1064 	else 
       
  1065 		{
       
  1066 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1067 		return (static_cast<CKeyPress*>(aItem)->Attributes());
       
  1068 		}
       
  1069 	}	
       
  1070 
       
  1071 	
       
  1072 // --------------------------------------------------------------------------------------------		
       
  1073 	
       
  1074 void CEngine::ChangeKeyPressAttributes(TKeyPressAttributes aAttributes)
       
  1075 	{
       
  1076 	if (iEditExistingLoad == EFalse) 
       
  1077 		{
       
  1078 		iKeyPressAttributes = aAttributes; 
       
  1079 		}
       
  1080 	else 
       
  1081 		{
       
  1082 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1083 		static_cast<CKeyPress*>(aItem)->SetAttributes(aAttributes);
       
  1084 		}	
       
  1085 	}	
       
  1086 	
       
  1087 // --------------------------------------------------------------------------------------------	
       
  1088 
       
  1089 TMessageAttributes CEngine::GetMessageAttributes()
       
  1090 	{ 
       
  1091 	if (iEditExistingLoad == EFalse)
       
  1092 		{	
       
  1093 		return iMessageAttributes; 
       
  1094 		}
       
  1095 	else 
       
  1096 		{
       
  1097 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1098 		return (static_cast<CMessages*>(aItem)->Attributes());
       
  1099 		}
       
  1100 	}	
       
  1101 	
       
  1102 // --------------------------------------------------------------------------------------------		
       
  1103 	
       
  1104 void CEngine::ChangeMessageAttributes(TMessageAttributes aAttributes)
       
  1105 	{
       
  1106 	if (iEditExistingLoad == EFalse) 
       
  1107 		{
       
  1108 		iMessageAttributes = aAttributes; 
       
  1109 		}
       
  1110 	else 
       
  1111 		{
       
  1112 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1113 		static_cast<CMessages*>(aItem)->SetAttributes(aAttributes);
       
  1114 		}	
       
  1115 	}
       
  1116 
       
  1117 // --------------------------------------------------------------------------------------------	
       
  1118 
       
  1119 TApplicationsAttributes CEngine::GetApplicationsAttributes()
       
  1120 	{ 
       
  1121 	if (iEditExistingLoad == EFalse)
       
  1122 		{	
       
  1123 		return iApplicationsAttributes; 
       
  1124 		}
       
  1125 	else 
       
  1126 		{
       
  1127 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1128 		return (static_cast<CAppLauncher*>(aItem)->Attributes());
       
  1129 		}
       
  1130 	}	
       
  1131 
       
  1132 // --------------------------------------------------------------------------------------------		
       
  1133 	
       
  1134 void CEngine::ChangeApplicationsAttributes(TApplicationsAttributes aAttributes)
       
  1135 	{
       
  1136 	if (iEditExistingLoad == EFalse) 
       
  1137 		{
       
  1138 		iApplicationsAttributes = aAttributes; 
       
  1139 		}
       
  1140 	else 
       
  1141 		{
       
  1142 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1143 		static_cast<CAppLauncher*>(aItem)->SetAttributes(aAttributes);
       
  1144 		}	
       
  1145 	}
       
  1146 	
       
  1147 // --------------------------------------------------------------------------------------------	
       
  1148 
       
  1149 TPhotoCaptureAttributes CEngine::GetPhotoCaptureAttributes()
       
  1150 	{ 
       
  1151 	if (iEditExistingLoad == EFalse)
       
  1152 		{	
       
  1153 		return iPhotoCaptureAttributes; 
       
  1154 		}
       
  1155 	else 
       
  1156 		{
       
  1157 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1158 		return (static_cast<CPhotoCapture*>(aItem)->Attributes());
       
  1159 		}
       
  1160 	}	
       
  1161 
       
  1162 // --------------------------------------------------------------------------------------------		
       
  1163 	
       
  1164 void CEngine::ChangePhotoCaptureAttributes(TPhotoCaptureAttributes aAttributes)
       
  1165 	{
       
  1166 	if (iEditExistingLoad == EFalse) 
       
  1167 		{
       
  1168 		iPhotoCaptureAttributes = aAttributes; 
       
  1169 		}
       
  1170 	else 
       
  1171 		{
       
  1172 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1173 		static_cast<CPhotoCapture*>(aItem)->SetAttributes(aAttributes);
       
  1174 		}	
       
  1175 	}	
       
  1176 	
       
  1177 // --------------------------------------------------------------------------------------------	
       
  1178 	
       
  1179 TBluetoothAttributes CEngine::GetBluetoothAttributes()
       
  1180 	{ 
       
  1181 	if (iEditExistingLoad == EFalse)
       
  1182 		{	
       
  1183 		return iBluetoothAttributes; 
       
  1184 		}
       
  1185 	else 
       
  1186 		{
       
  1187 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1188 		return (static_cast<CBluetooth*>(aItem)->Attributes());
       
  1189 		}
       
  1190 	}		
       
  1191 
       
  1192 	
       
  1193 // --------------------------------------------------------------------------------------------		
       
  1194 	
       
  1195 void CEngine::ChangeBluetoothAttributes(TBluetoothAttributes aAttributes)
       
  1196 	{
       
  1197 	if (iEditExistingLoad == EFalse) 
       
  1198 		{
       
  1199 		iBluetoothAttributes = aAttributes; 
       
  1200 		}
       
  1201 	else 
       
  1202 		{
       
  1203 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1204 		static_cast<CBluetooth*>(aItem)->SetAttributes(aAttributes);
       
  1205 		}	
       
  1206 	} 	
       
  1207 	
       
  1208 // --------------------------------------------------------------------------------------------	
       
  1209 	
       
  1210 TPointerEventAttributes CEngine::GetPointerEventAttributes()
       
  1211 	{
       
  1212 	if (iEditExistingLoad == EFalse)
       
  1213 		{	
       
  1214 		return iPointerEventAttributes; 
       
  1215 		}
       
  1216 	else 
       
  1217 		{
       
  1218 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1219 		return (static_cast<CPointerEvent*>(aItem)->Attributes());
       
  1220 		}
       
  1221 	}
       
  1222 
       
  1223 // --------------------------------------------------------------------------------------------		
       
  1224 	
       
  1225 void CEngine::ChangePointerEventAttributes(TPointerEventAttributes aAttributes)
       
  1226 	{
       
  1227 	if (iEditExistingLoad == EFalse) 
       
  1228 		{
       
  1229 		iPointerEventAttributes = aAttributes; 
       
  1230 		}
       
  1231 	else 
       
  1232 		{
       
  1233 		CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex);
       
  1234 		static_cast<CPointerEvent*>(aItem)->SetAttributes(aAttributes);
       
  1235 		}	
       
  1236 	} 
       
  1237 	
       
  1238 // --------------------------------------------------------------------------------------------
       
  1239 	
       
  1240 // End of File