utilityapps/loadgen/ui/hb/src/enginewrapper.cpp
changeset 55 2d9cac8919d3
equal deleted inserted replaced
53:819e59dfc032 55:2d9cac8919d3
       
     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 <hbmainwindow.h>
       
    20 //#include <hbcommonnote.h>
       
    21 #include <hbpopup.h>
       
    22 #include <hbaction.h>
       
    23 
       
    24 #include <QString>
       
    25  #include <QStringList>
       
    26  
       
    27 #include <e32std.h>
       
    28 #include <e32base.h>
       
    29 
       
    30 #include "notifications.h"
       
    31 #include "enginewrapper.h"
       
    32 #include "settingsview.h"
       
    33 #include "engine.h"
       
    34 #include "mainview.h"
       
    35 
       
    36 QStringList LOADTYPES = (QStringList() << "CPU load" << "Memory eat" << "Phone calls" << "Messages" 
       
    37 									   << "Network conn." << "Key presses" << "Applications" << "Photo captures" 
       
    38 									   << "Bluetooth actions" << "Pointer events");
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 
       
    42 EngineWrapper::EngineWrapper(HbMainWindow &mainWindow, MainView &mainView)
       
    43 : mEngine(0), 
       
    44   mMainView(mainView),
       
    45   mMainWindow(mainWindow),
       
    46   mEditExistingLoad(false)
       
    47 {
       
    48 }
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 
       
    52 EngineWrapper::~EngineWrapper()
       
    53 {
       
    54     if (mEngine != 0) {
       
    55 		TRAP_IGNORE(mEngine->DeActivateEngineL());
       
    56         delete mEngine;
       
    57     }
       
    58 }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 
       
    62 bool EngineWrapper::init()
       
    63 {
       
    64 	TInt err = KErrNone;
       
    65     TRAP(err, mEngine = CEngine::NewL(this));
       
    66     if(err != KErrNone) {
       
    67         return false;
       
    68     }
       
    69     else {
       
    70 		TRAP(err, mEngine->ActivateEngineL());
       
    71 		if (err != KErrNone) {
       
    72 			return false;
       
    73 		}
       
    74 		else {
       
    75 			return true;
       
    76 		}
       
    77     }
       
    78 }
       
    79 
       
    80 // ---------------------------------------------------------------------------	
       
    81 
       
    82 bool EngineWrapper::startNewLoad(int commandId)
       
    83 {
       
    84 	TRAPD(err, mEngine->StartNewLoadL(commandId));
       
    85 
       
    86 	// error handling
       
    87     if(err != KErrNone) {
       
    88         return false;
       
    89     }
       
    90     else {
       
    91         return true;
       
    92     }
       
    93 }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 
       
    97 void EngineWrapper::launchPerfMonApp()
       
    98 {
       
    99 	TRAPD(err, mEngine->LaunchPerfMonL());
       
   100 	// error handling
       
   101     if(err != KErrNone) {
       
   102         Notifications::error("Perf Mon launch failed.");
       
   103     }
       
   104 }
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 
       
   108 void EngineWrapper::loadAddedOrEdited(TLoadGenCommandIds cmdId)
       
   109 {
       
   110 	if (mEditExistingLoad == false) {
       
   111 		TRAP_IGNORE(mEngine->DoStartNewLoadL(cmdId));
       
   112 	}
       
   113 	else {
       
   114 		TRAP_IGNORE(mEngine->ExistingLoadEditedL());
       
   115 	}
       
   116 }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 
       
   120 void EngineWrapper::loadSettingsCanclled()
       
   121 {
       
   122 	if (mEditExistingLoad == true) {
       
   123 		TRAP_IGNORE(mEngine->ExistingLoadEditCancelled());
       
   124 	}
       
   125 }
       
   126 
       
   127 // ---------------------------------------------------------------------------
       
   128 
       
   129 void EngineWrapper::loadEdit(int rowIndex)
       
   130 {
       
   131 	TRAPD(err, mEngine->EditLoadL(rowIndex));
       
   132 	// error handling
       
   133     if(err != KErrNone) {
       
   134         Notifications::error("Load edit failed.");
       
   135     }
       
   136 }
       
   137 
       
   138 void EngineWrapper::StopAllLoadsYesNoDialogClosed(HbAction *action)
       
   139 {
       
   140 	TInt err = KErrNone;
       
   141     if( action && !action->text().compare("yes", Qt::CaseInsensitive) ){
       
   142         const CArrayFix<TInt>* selectionIndexes = NULL;
       
   143         try{
       
   144 			TRAP(err, mEngine->StopAllLoadItemsL());
       
   145         }
       
   146         catch(...){
       
   147             Notifications::error("Stop load failed.");
       
   148         }
       
   149     }
       
   150 }
       
   151 // ----------------------------------------------------------------------------
       
   152 void EngineWrapper::StopLoadYesNoDialogClosed(HbAction *action)
       
   153 {
       
   154     if( action && !action->text().compare("yes", Qt::CaseInsensitive) ){
       
   155         const CArrayFix<TInt>* selectionIndexes = NULL;
       
   156         try{
       
   157             QT_TRAP_THROWING( selectionIndexes = QueryListSelectedIndexesOrCurrentItemL() );
       
   158             if(selectionIndexes)
       
   159                 QT_TRAP_THROWING( mEngine->StopSelectedOrHighlightedItemsL(selectionIndexes) );
       
   160         }
       
   161         catch(...){
       
   162             Notifications::error("Stop load failed.");
       
   163         }
       
   164         if(selectionIndexes)
       
   165             delete selectionIndexes;
       
   166     }
       
   167 }
       
   168 
       
   169 // ---------------------------------------------------------------------------
       
   170 bool EngineWrapper::stopLoad(bool stopAll)
       
   171 {
       
   172 	
       
   173 	if (stopAll == true) {
       
   174 		QString message = QString("Stop all loads?");
       
   175         HbMessageBox::question(message, this, SLOT(StopAllLoadsYesNoDialogClosed(HbAction *)), HbMessageBox::Yes|HbMessageBox::No);
       
   176 		//TRAP(err, mEngine->StopAllLoadItemsL());
       
   177 		// error handling
       
   178         return true;
       
   179 	}
       
   180 	else {
       
   181         // by default use selected items
       
   182         QList<int> listIndices = mMainView.listSelectionIndexes();
       
   183         if (listIndices.count() > 0)
       
   184             {
       
   185             QString message = QString("Stop %1 selections?").arg( listIndices.count() );
       
   186             HbMessageBox::question(message, this, SLOT(StopLoadYesNoDialogClosed(HbAction *)), HbMessageBox::Yes|HbMessageBox::No);
       
   187             }
       
   188         else{
       
   189              TInt currentItemIndex = mMainView.currentItemIndex();
       
   190              if (mEngine->LoadItemCount() > currentItemIndex && currentItemIndex >= 0)
       
   191                  {
       
   192                  QString message("Stop highlighted selections?");
       
   193                  HbMessageBox::question(message, this, SLOT(StopLoadYesNoDialogClosed(HbAction *)), HbMessageBox::Yes|HbMessageBox::No);
       
   194                  }
       
   195             }
       
   196         return true;
       
   197 	}
       
   198 	
       
   199 }
       
   200 
       
   201 // ---------------------------------------------------------------------------
       
   202 
       
   203 void EngineWrapper::resumeAllLoadItems()
       
   204 {
       
   205 	TRAPD(err, mEngine->ResumeAllLoadItemsL());
       
   206 	// error handling
       
   207     if(err != KErrNone) {
       
   208         Notifications::error("Error in loads resume.");
       
   209     }
       
   210 }
       
   211 
       
   212 // ---------------------------------------------------------------------------
       
   213 
       
   214 void EngineWrapper::suspendAllLoadItems()
       
   215 {
       
   216 	TRAPD(err, mEngine->SuspendAllLoadItemsL());
       
   217 	// error handling
       
   218     if(err != KErrNone) {
       
   219         Notifications::error("Error in loads resume.");
       
   220     }
       
   221 }
       
   222 
       
   223 // ---------------------------------------------------------------------------
       
   224 void EngineWrapper::asyncSuspendOrResumeSelectedOrHighlightedItems()
       
   225 	{
       
   226 	TRAPD(err, mEngine->AsyncSuspRes() );
       
   227 		// error handling
       
   228 	    if(err != KErrNone) {
       
   229 	        Notifications::error("Error to show item action menu.");
       
   230 	    }
       
   231 	}
       
   232 
       
   233 void EngineWrapper::asyncStopLoad()
       
   234 	{
       
   235 	const CArrayFix<TInt>* selectionIndexes = NULL;
       
   236 	selectionIndexes = QueryListSelectedIndexesOrCurrentItemL();
       
   237 	if(selectionIndexes){
       
   238 		TRAPD(err, mEngine->AsyncStopLoad( selectionIndexes ) );
       
   239 		// error handling
       
   240 	    if(err != KErrNone) {
       
   241 	        Notifications::error("Error to show item action menu.");
       
   242 	    }
       
   243 	}
       
   244 	}
       
   245 
       
   246 
       
   247 // ---------------------------------------------------------------------------
       
   248 
       
   249 void EngineWrapper::suspendOrResumeSelectedOrHighlightedItems()
       
   250 {
       
   251 	TRAPD(err, mEngine->SuspendOrResumeSelectedOrHighlightedItemsL());
       
   252 	// error handling
       
   253     if(err != KErrNone) {
       
   254         Notifications::error("Error to show item action menu.");
       
   255     }
       
   256 }
       
   257 
       
   258 // ---------------------------------------------------------------------------
       
   259 
       
   260 void EngineWrapper::ShowErrorMessage(const TDesC& aErrorMessage)
       
   261 {
       
   262     QString errorMessage((QChar*)aErrorMessage.Ptr(),aErrorMessage.Length());
       
   263     Notifications::error(errorMessage);
       
   264  
       
   265 }
       
   266 
       
   267 // ---------------------------------------------------------------------------
       
   268 
       
   269 void EngineWrapper::ShowNote(const TDesC& aNoteMessage)
       
   270 {
       
   271     QString note((QChar*)aNoteMessage.Ptr(),aNoteMessage.Length());
       
   272     Notifications::showGlobalNote(note, HbMessageBox::MessageTypeInformation, HbPopup::StandardTimeout);
       
   273 }
       
   274  
       
   275 // ---------------------------------------------------------------------------
       
   276 
       
   277 TInt EngineWrapper::QueryCurrentItemIndex()
       
   278 {
       
   279 	return mMainView.currentItemIndex();
       
   280 }
       
   281 
       
   282 // ---------------------------------------------------------------------------
       
   283 
       
   284 const CArrayFix<TInt>*  EngineWrapper::QueryListSelectedIndexesOrCurrentItemL()
       
   285 {
       
   286 	QList<int> listIndices = mMainView.listSelectionIndexes();
       
   287 	TInt cnt = listIndices.count();
       
   288     CArrayFix<TInt>* indices = new(ELeave)CArrayFixFlat<TInt>( cnt > 0 ? cnt : 1 );
       
   289     CleanupDeletePushL(indices);
       
   290     if(cnt > 0){
       
   291         for (TInt i = 0; i < cnt; i++) {
       
   292             indices->AppendL(listIndices.at(i));
       
   293         }
       
   294     }
       
   295     else{
       
   296         indices->AppendL(mMainView.currentItemIndex());
       
   297     }
       
   298     CleanupStack::Pop(indices);
       
   299     return static_cast<const CArrayFix<TInt>*>(indices);	
       
   300 }
       
   301 
       
   302 // ---------------------------------------------------------------------------
       
   303 
       
   304 void EngineWrapper::OpenLoadSettings(TInt loadType, bool editExistingLoad)
       
   305 {
       
   306 	SettingsView* settings = new SettingsView((HbView&)ViewReference(), 
       
   307 											  WindowReference(), 
       
   308 											  *this);
       
   309 	mEditExistingLoad = editExistingLoad;
       
   310 
       
   311 	switch (loadType) {
       
   312 		case ELoadGenCmdNewLoadCPULoad: {
       
   313 			settings->open(LOADTYPES.at(Cpu), 
       
   314 			               (TLoadGenCommandIds)loadType);
       
   315 			break;
       
   316 		}
       
   317 		case ELoadGenCmdNewLoadEatMemory: {
       
   318 			settings->open(LOADTYPES.at(EatMemory), 
       
   319 			               (TLoadGenCommandIds)loadType);
       
   320 			break;
       
   321 		}
       
   322 		case ELoadGenCmdNewLoadPhoneCall: {
       
   323 			settings->open(LOADTYPES.at(PhoneCalls), 
       
   324 			               (TLoadGenCommandIds)loadType);
       
   325 			break;
       
   326 		}
       
   327 		case ELoadGenCmdNewLoadNetConn: {
       
   328 			settings->open(LOADTYPES.at(NWConnections),
       
   329                            (TLoadGenCommandIds)loadType);
       
   330 			break;
       
   331 		}
       
   332 		case ELoadGenCmdNewLoadKeyPress: {
       
   333 			settings->open(LOADTYPES.at(KeyPresses), 
       
   334 			               (TLoadGenCommandIds)loadType);
       
   335 			break;
       
   336 		}
       
   337 		case ELoadGenCmdNewLoadMessages: {
       
   338 			settings->open(LOADTYPES.at(Messages), 
       
   339 			               (TLoadGenCommandIds)loadType);
       
   340 			break;
       
   341 		}
       
   342 		case ELoadGenCmdNewLoadApplications: {
       
   343 			settings->open(LOADTYPES.at(Apps), 
       
   344 			               (TLoadGenCommandIds)loadType);
       
   345 			break;
       
   346 		}
       
   347 		case ELoadGenCmdNewLoadPhotoCaptures: {
       
   348 			settings->open(LOADTYPES.at(Photos), 
       
   349 			               (TLoadGenCommandIds)loadType);
       
   350 			break;
       
   351 		}
       
   352 		case ELoadGenCmdNewLoadBluetooth: {
       
   353 			settings->open(LOADTYPES.at(BTAct), 
       
   354 						   (TLoadGenCommandIds)loadType);
       
   355 			break;
       
   356 		}
       
   357 		case ELoadGenCmdNewLoadPointerEvent: {
       
   358 			settings->open(LOADTYPES.at(PointerEvents),
       
   359 						   (TLoadGenCommandIds)loadType);
       
   360 			break;
       
   361 		}
       
   362 		default: {
       
   363 			User::Panic(_L("Wrong new load"), 111);
       
   364 			break;
       
   365 		}
       
   366 	}
       
   367 }
       
   368 
       
   369 // ---------------------------------------------------------------------------	
       
   370 
       
   371 CPULoadAttributes EngineWrapper::getCpuLoadAttributes()
       
   372 {
       
   373     TCPULoadAttributes tCpuLoadAttributes = mEngine->GetCPULoadAttributes();
       
   374     CPULoadAttributes attributes;
       
   375 	
       
   376 	attributes.mId = tCpuLoadAttributes.iId;
       
   377 	attributes.mPriority = tCpuLoadAttributes.iPriority;
       
   378 	attributes.mMode = tCpuLoadAttributes.iMode;
       
   379 	attributes.mType = tCpuLoadAttributes.iType;
       
   380 	attributes.mLength = tCpuLoadAttributes.iLength;
       
   381 	attributes.mIdle = tCpuLoadAttributes.iIdle;
       
   382 	attributes.mRandomVariance = tCpuLoadAttributes.iRandomVariance;
       
   383 	attributes.mCpu = tCpuLoadAttributes.iCpu;
       
   384 	attributes.mCpuCount = tCpuLoadAttributes.iCpuCount;
       
   385 	return attributes;
       
   386 }
       
   387 
       
   388 // ---------------------------------------------------------------------------	
       
   389 
       
   390 void EngineWrapper::setCpuLoadAttributes(const CPULoadAttributes& attributes)
       
   391 {
       
   392     TCPULoadAttributes tCpuLoadAttributes;
       
   393 
       
   394 	tCpuLoadAttributes.iId = attributes.mId;
       
   395 	tCpuLoadAttributes.iPriority = attributes.mPriority;
       
   396 	tCpuLoadAttributes.iMode = attributes.mMode;
       
   397 	tCpuLoadAttributes.iType = attributes.mType;
       
   398 	tCpuLoadAttributes.iLength = attributes.mLength;
       
   399 	tCpuLoadAttributes.iIdle = attributes.mIdle;
       
   400 	tCpuLoadAttributes.iRandomVariance = attributes.mRandomVariance;
       
   401 	tCpuLoadAttributes.iCpu = attributes.mCpu;
       
   402 	tCpuLoadAttributes.iCpuCount = attributes.mCpuCount;	
       
   403 	
       
   404 	mEngine->ChangeCPULoadAttributes(tCpuLoadAttributes);
       
   405 }
       
   406 
       
   407 // ---------------------------------------------------------------------------	
       
   408 
       
   409 MemoryEatAttributes EngineWrapper::getMemoryEatAttributes()
       
   410 {
       
   411 
       
   412     TMemoryEatAttributes tMemoryEatAttributes = mEngine->GetMemoryEatAttributes();
       
   413     MemoryEatAttributes attributes;
       
   414 
       
   415     // Convert TMemoryEatAttributes to MemoryEatAttributes 
       
   416     attributes.mId         = tMemoryEatAttributes.iId;
       
   417     attributes.mPriority   = tMemoryEatAttributes.iPriority; 
       
   418 	attributes.mSource     = tMemoryEatAttributes.iSource;
       
   419 	attributes.mType       = tMemoryEatAttributes.iType;
       
   420 	attributes.mBuffer     = tMemoryEatAttributes.iBuffer;
       
   421 	attributes.mIdle       = tMemoryEatAttributes.iIdle;
       
   422 	attributes.mAmount     = tMemoryEatAttributes.iAmount;
       
   423 	attributes.mRandomMin  = tMemoryEatAttributes.iRandomMin;
       
   424 	attributes.mRandomMax  = tMemoryEatAttributes.iRandomMax;
       
   425 
       
   426     TBuf<64> amount;
       
   427     amount.Copy(tMemoryEatAttributes.iAmountDes);
       
   428     attributes.mAmountDes = QString((QChar*)amount.Ptr(), amount.Length()); 
       
   429 
       
   430     TBuf<64> min;
       
   431     min.Copy(tMemoryEatAttributes.iRandomMinDes);
       
   432     attributes.mAmountDes = QString((QChar*)min.Ptr(), min.Length()); 
       
   433 
       
   434     TBuf<64> max;
       
   435     max.Copy(tMemoryEatAttributes.iRandomMaxDes);
       
   436     attributes.mAmountDes = QString((QChar*)max.Ptr(), max.Length());
       
   437 	
       
   438 	attributes.mRandomVariance  = tMemoryEatAttributes.iRandomVariance;
       
   439     return attributes;
       
   440 }	
       
   441 
       
   442 // ---------------------------------------------------------------------------	
       
   443 
       
   444 void EngineWrapper::setMemoryEatAttributes(const MemoryEatAttributes& attributes)
       
   445 {
       
   446 	TMemoryEatAttributes tMemoryEatAttributes = mEngine->GetMemoryEatAttributes();//TMemoryEatAttributes tMemoryEatAttributes;
       
   447 
       
   448 	tMemoryEatAttributes.iId = attributes.mId;
       
   449 	tMemoryEatAttributes.iPriority = attributes.mPriority;
       
   450 	tMemoryEatAttributes.iSource = attributes.mSource;
       
   451 	tMemoryEatAttributes.iType = attributes.mType;
       
   452 	tMemoryEatAttributes.iBuffer = attributes.mBuffer;
       
   453 	tMemoryEatAttributes.iIdle = attributes.mIdle;
       
   454 	tMemoryEatAttributes.iAmount = attributes.mAmount;
       
   455 	tMemoryEatAttributes.iRandomMin = attributes.mRandomMin;
       
   456 	tMemoryEatAttributes.iRandomMax = attributes.mRandomMax;
       
   457 
       
   458     TBuf<64> amount = attributes.mAmountDes.utf16();
       
   459     tMemoryEatAttributes.iAmountDes.Copy(amount);	
       
   460 	
       
   461     TBuf<64> min = attributes.mRandomMinDes.utf16();
       
   462     tMemoryEatAttributes.iRandomMinDes.Copy(min);
       
   463       
       
   464     TBuf<64> max = attributes.mRandomMaxDes.utf16();
       
   465     tMemoryEatAttributes.iRandomMaxDes.Copy(max);
       
   466 	
       
   467 	tMemoryEatAttributes.iRandomVariance = attributes.mRandomVariance;
       
   468 	
       
   469 	mEngine->ChangeMemoryEatAttributes(tMemoryEatAttributes);
       
   470 }
       
   471 
       
   472 // ---------------------------------------------------------------------------	
       
   473 
       
   474 PhoneCallAttributes EngineWrapper::getPhoneCallAttributes()
       
   475 {
       
   476     TPhoneCallAttributes tPhoneCallAttributes = mEngine->GetPhoneCallAttributes();
       
   477     PhoneCallAttributes attributes;
       
   478 	
       
   479 	attributes.mId = tPhoneCallAttributes.iId;
       
   480 	attributes.mPriority = tPhoneCallAttributes.iPriority;
       
   481 
       
   482     TBuf<128> dest;
       
   483     dest.Copy(tPhoneCallAttributes.iDestination);
       
   484     attributes.mDestination = QString((QChar*)dest.Ptr(), dest.Length()); 	
       
   485 	
       
   486 	attributes.mLength = tPhoneCallAttributes.iLength;
       
   487 	attributes.mIdle = tPhoneCallAttributes.iIdle;
       
   488 	attributes.mRandomVariance = tPhoneCallAttributes.iRandomVariance;
       
   489 	return attributes;
       
   490 }
       
   491 
       
   492 // ---------------------------------------------------------------------------	
       
   493 
       
   494 void EngineWrapper::setPhoneCallAttributes(const PhoneCallAttributes& attributes)
       
   495 {
       
   496 	TPhoneCallAttributes tPhoneCallAttributes = mEngine->GetPhoneCallAttributes(); //TPhoneCallAttributes tPhoneCallAttributes;
       
   497 
       
   498 	tPhoneCallAttributes.iId = attributes.mId;
       
   499 	tPhoneCallAttributes.iPriority = attributes.mPriority;
       
   500 
       
   501     TBuf<128> dest = attributes.mDestination.utf16();
       
   502     tPhoneCallAttributes.iDestination.Copy(dest);	
       
   503 
       
   504 	tPhoneCallAttributes.iLength = attributes.mLength;
       
   505 	tPhoneCallAttributes.iIdle = attributes.mIdle;
       
   506 	tPhoneCallAttributes.iRandomVariance = attributes.mRandomVariance;
       
   507 	
       
   508 	mEngine->ChangePhoneCallAttributes(tPhoneCallAttributes);
       
   509 }
       
   510 
       
   511 // ---------------------------------------------------------------------------	
       
   512 
       
   513 NetConnAttributes EngineWrapper::getNetConnAttributes()
       
   514 {
       
   515     TNetConnAttributes tNetConnAttributes = mEngine->GetNetConnAttributes();
       
   516     NetConnAttributes attributes;
       
   517 	
       
   518 	attributes.mId = tNetConnAttributes.iId;
       
   519 	attributes.mPriority = tNetConnAttributes.iPriority;
       
   520 
       
   521     attributes.mDestination = QString::fromUtf16(tNetConnAttributes.iDestination.Ptr(), tNetConnAttributes.iDestination.Length()); 	
       
   522 
       
   523 	attributes.mIdle = tNetConnAttributes.iIdle;
       
   524 	attributes.mRandomVariance = tNetConnAttributes.iRandomVariance;
       
   525 	return attributes;
       
   526 }
       
   527 
       
   528 // ---------------------------------------------------------------------------	
       
   529 
       
   530 void EngineWrapper::setNetConnAttributes(const NetConnAttributes& attributes)
       
   531 {
       
   532 	TNetConnAttributes tNetConnAttributes = mEngine->GetNetConnAttributes(); //TNetConnAttributes tNetConnAttributes;
       
   533 
       
   534 	tNetConnAttributes.iId = attributes.mId;
       
   535 	tNetConnAttributes.iPriority = attributes.mPriority;
       
   536 
       
   537     TBuf<128> dest = attributes.mDestination.utf16();
       
   538     tNetConnAttributes.iDestination.Copy(dest);	
       
   539 
       
   540 	tNetConnAttributes.iIdle = attributes.mIdle;
       
   541 	tNetConnAttributes.iRandomVariance = attributes.mRandomVariance;
       
   542 	
       
   543 	mEngine->ChangeNetConnAttributes(tNetConnAttributes);
       
   544 }
       
   545 
       
   546 // ---------------------------------------------------------------------------	
       
   547 
       
   548 KeyPressAttributes EngineWrapper::getKeyPressAttributes()
       
   549 {
       
   550     TKeyPressAttributes tKeyPressAttributes = mEngine->GetKeyPressAttributes();
       
   551     KeyPressAttributes attributes;
       
   552 	
       
   553 	attributes.mId = tKeyPressAttributes.iId;
       
   554 	attributes.mPriority = tKeyPressAttributes.iPriority;
       
   555 	attributes.mHeartBeat = tKeyPressAttributes.iHeartBeat;	
       
   556 	attributes.mRandomVariance = tKeyPressAttributes.iRandomVariance;
       
   557 	return attributes;
       
   558 }
       
   559 
       
   560 // ---------------------------------------------------------------------------	
       
   561 
       
   562 void EngineWrapper::setKeyPressAttributes(const KeyPressAttributes& attributes)
       
   563 {
       
   564 	TKeyPressAttributes tKeyPressAttributes = mEngine->GetKeyPressAttributes(); //TKeyPressAttributes tKeyPressAttributes;
       
   565 
       
   566 	tKeyPressAttributes.iId = attributes.mId;
       
   567 	tKeyPressAttributes.iPriority = attributes.mPriority;
       
   568 	tKeyPressAttributes.iHeartBeat = attributes.mHeartBeat;
       
   569 	tKeyPressAttributes.iRandomVariance = attributes.mRandomVariance;
       
   570 	
       
   571 	mEngine->ChangeKeyPressAttributes(tKeyPressAttributes);
       
   572 }
       
   573 
       
   574 // ---------------------------------------------------------------------------	
       
   575 
       
   576 PointerEventAttributes EngineWrapper::getPointerEventAttributes()
       
   577 {
       
   578     TPointerEventAttributes tPointerEventAttributes = mEngine->GetPointerEventAttributes();
       
   579     PointerEventAttributes attributes;
       
   580 	
       
   581 	attributes.mId = tPointerEventAttributes.iId;
       
   582 	attributes.mPriority = tPointerEventAttributes.iPriority;
       
   583 	attributes.mHeartBeat = tPointerEventAttributes.iHeartBeat;	
       
   584 	attributes.mRandomVariance = tPointerEventAttributes.iRandomVariance;
       
   585 	return attributes;
       
   586 }
       
   587 
       
   588 // ---------------------------------------------------------------------------	
       
   589 
       
   590 void EngineWrapper::setPointerEventAttributes(const PointerEventAttributes& attributes)
       
   591 {
       
   592 	TPointerEventAttributes tPointerEventAttributes = mEngine->GetPointerEventAttributes();//TPointerEventAttributes tPointerEventAttributes;
       
   593 
       
   594 	tPointerEventAttributes.iId = attributes.mId;
       
   595 	tPointerEventAttributes.iPriority = attributes.mPriority;
       
   596 	tPointerEventAttributes.iHeartBeat = attributes.mHeartBeat;
       
   597 	tPointerEventAttributes.iRandomVariance = attributes.mRandomVariance;
       
   598 	
       
   599 	mEngine->ChangePointerEventAttributes(tPointerEventAttributes);
       
   600 }
       
   601 
       
   602 // ---------------------------------------------------------------------------	
       
   603 
       
   604 MessageAttributes EngineWrapper::getMessageAttributes()
       
   605 {
       
   606     TMessageAttributes tMessageAttributes = mEngine->GetMessageAttributes();
       
   607     MessageAttributes attributes;
       
   608 	
       
   609 	attributes.mId = tMessageAttributes.iId;
       
   610 	attributes.mMessageType = tMessageAttributes.iMessageType;
       
   611 
       
   612     TBuf<128> dest;
       
   613     dest.Copy(tMessageAttributes.iDestination);
       
   614     attributes.mDestination = QString((QChar*)dest.Ptr(), dest.Length()); 	
       
   615 	
       
   616 	attributes.mPriority = tMessageAttributes.iPriority;
       
   617 	attributes.mAmount = tMessageAttributes.iAmount;
       
   618 	attributes.mLength = tMessageAttributes.iLength;
       
   619 	attributes.mIdle = tMessageAttributes.iIdle;
       
   620 	attributes.mRandomVariance = tMessageAttributes.iRandomVariance;
       
   621 	return attributes;
       
   622 }
       
   623 
       
   624 // ---------------------------------------------------------------------------	
       
   625 
       
   626 void EngineWrapper::setMessageAttributes(const MessageAttributes& attributes)
       
   627 {
       
   628 	TMessageAttributes tMessageAttributes = mEngine->GetMessageAttributes();//TMessageAttributes tMessageAttributes;
       
   629 
       
   630 	tMessageAttributes.iId = attributes.mId;
       
   631 	tMessageAttributes.iMessageType = attributes.mMessageType;
       
   632     
       
   633 	TBuf<128> dest = attributes.mDestination.utf16();
       
   634     tMessageAttributes.iDestination.Copy(dest);	
       
   635 	
       
   636 	tMessageAttributes.iPriority = attributes.mPriority;
       
   637 	tMessageAttributes.iAmount = attributes.mAmount;
       
   638 	tMessageAttributes.iLength = attributes.mLength;
       
   639 	tMessageAttributes.iIdle = attributes.mIdle;
       
   640 	tMessageAttributes.iRandomVariance = attributes.mRandomVariance;
       
   641 	
       
   642 	mEngine->ChangeMessageAttributes(tMessageAttributes);
       
   643 }
       
   644 
       
   645 // ---------------------------------------------------------------------------	
       
   646 
       
   647 ApplicationsAttributes EngineWrapper::getApplicationsAttributes()
       
   648 {
       
   649     TApplicationsAttributes tApplicationsAttributes = mEngine->GetApplicationsAttributes();
       
   650     ApplicationsAttributes attributes;
       
   651 	
       
   652 	attributes.mId = tApplicationsAttributes.iId;
       
   653 	attributes.mPriority = tApplicationsAttributes.iPriority;
       
   654 	attributes.mLaunchingInterval = tApplicationsAttributes.iLaunchingInterval;
       
   655 	attributes.mKeyPressType = tApplicationsAttributes.iKeyPressType;
       
   656 	attributes.mMaxOpen = tApplicationsAttributes.iMaxOpen;
       
   657 	attributes.mHeartBeat = tApplicationsAttributes.iHeartBeat;
       
   658 	attributes.mRandomVariance = tApplicationsAttributes.iRandomVariance;
       
   659 
       
   660 	return attributes;
       
   661 }
       
   662 
       
   663 // ---------------------------------------------------------------------------	
       
   664 
       
   665 void EngineWrapper::setApplicationsAttributes(const ApplicationsAttributes& attributes)
       
   666 {
       
   667 	TApplicationsAttributes tApplicationsAttributes = mEngine->GetApplicationsAttributes(); //TApplicationsAttributes tApplicationsAttributes;
       
   668 
       
   669 	tApplicationsAttributes.iId = attributes.mId;
       
   670 	tApplicationsAttributes.iPriority = attributes.mPriority;
       
   671 	tApplicationsAttributes.iLaunchingInterval = attributes.mLaunchingInterval;
       
   672 	tApplicationsAttributes.iKeyPressType = attributes.mKeyPressType;
       
   673 	tApplicationsAttributes.iMaxOpen = attributes.mMaxOpen;
       
   674 	tApplicationsAttributes.iHeartBeat = attributes.mHeartBeat;	
       
   675 	tApplicationsAttributes.iRandomVariance = attributes.mRandomVariance;
       
   676 	
       
   677 	mEngine->ChangeApplicationsAttributes(tApplicationsAttributes);
       
   678 }
       
   679 
       
   680     QStringList mAppsArray;
       
   681 
       
   682 // ---------------------------------------------------------------------------	
       
   683 
       
   684 PhotoCaptureAttributes EngineWrapper::getPhotoCaptureAttributes()
       
   685 {
       
   686     TPhotoCaptureAttributes tPhotoCaptureAttributes = mEngine->GetPhotoCaptureAttributes();
       
   687     PhotoCaptureAttributes attributes;
       
   688 	
       
   689 	attributes.mId = tPhotoCaptureAttributes.iId;
       
   690 	attributes.mPriority = tPhotoCaptureAttributes.iPriority;
       
   691 	attributes.mCameraCount = tPhotoCaptureAttributes.iCameraCount;	
       
   692 	attributes.mCamera = tPhotoCaptureAttributes.iCamera;
       
   693 	attributes.mIdle = tPhotoCaptureAttributes.iIdle;
       
   694 	attributes.mRandomVariance = tPhotoCaptureAttributes.iRandomVariance;
       
   695 	return attributes;
       
   696 }
       
   697 
       
   698 // ---------------------------------------------------------------------------	
       
   699 
       
   700 void EngineWrapper::setPhotoCaptureAttributes(const PhotoCaptureAttributes& attributes)
       
   701 {
       
   702 	TPhotoCaptureAttributes tPhotoCaptureAttributes;
       
   703 
       
   704 	tPhotoCaptureAttributes.iId = attributes.mId;
       
   705 	tPhotoCaptureAttributes.iPriority = attributes.mPriority;
       
   706 	tPhotoCaptureAttributes.iCameraCount = attributes.mCameraCount;	
       
   707 	tPhotoCaptureAttributes.iCamera = attributes.mCamera;
       
   708 	tPhotoCaptureAttributes.iIdle = attributes.mIdle;
       
   709 	tPhotoCaptureAttributes.iRandomVariance = attributes.mRandomVariance;
       
   710 	
       
   711 	mEngine->ChangePhotoCaptureAttributes(tPhotoCaptureAttributes);
       
   712 }
       
   713 
       
   714 // ---------------------------------------------------------------------------	
       
   715 
       
   716 BluetoothAttributes EngineWrapper::getBluetoothAttributes()
       
   717 {
       
   718     TBluetoothAttributes tBluetoothAttributes = mEngine->GetBluetoothAttributes();
       
   719     BluetoothAttributes attributes;
       
   720 	
       
   721 	attributes.mId = tBluetoothAttributes.iId;
       
   722 	attributes.mPriority = tBluetoothAttributes.iPriority;
       
   723 	attributes.mIdle = tBluetoothAttributes.iIdle;
       
   724 	attributes.mRandomVariance = tBluetoothAttributes.iRandomVariance;
       
   725 	attributes.mBluetoothSupported = tBluetoothAttributes.iBluetoothSupported ? true : false;
       
   726 	return attributes;
       
   727 }
       
   728 
       
   729 // ---------------------------------------------------------------------------	
       
   730 
       
   731 void EngineWrapper::setBluetoothAttributes(const BluetoothAttributes& attributes)
       
   732 {
       
   733     TBluetoothAttributes tBluetoothAttributes;
       
   734 
       
   735 	tBluetoothAttributes.iId = attributes.mId;
       
   736 	tBluetoothAttributes.iPriority = attributes.mPriority;
       
   737 	tBluetoothAttributes.iIdle = attributes.mIdle;
       
   738 	tBluetoothAttributes.iRandomVariance = attributes.mRandomVariance;
       
   739 	
       
   740 	mEngine->ChangeBluetoothAttributes(tBluetoothAttributes);
       
   741 }
       
   742 
       
   743 // ---------------------------------------------------------------------------
       
   744 
       
   745 void EngineWrapper::ReFreshView(CDesCArray* aTextArray) 
       
   746 {
       
   747 	QStringList itemList;
       
   748 	TInt arrayCnt = aTextArray->Count();
       
   749 	for (int i = 0; i < arrayCnt; i++) {
       
   750 		itemList.append(QString::fromUtf16(
       
   751 				  aTextArray->MdcaPoint(i).Ptr(),
       
   752 				  aTextArray->MdcaPoint(i).Length()));
       
   753 	}
       
   754 	mMainView.setLoadListData(itemList);
       
   755 }
       
   756 
       
   757 // ---------------------------------------------------------------------------	
       
   758 
       
   759 void EngineWrapper::ClearSelection()
       
   760 {
       
   761 	mMainView.clearListSelection();
       
   762 }
       
   763 
       
   764 // ---------------------------------------------------------------------------	
       
   765 
       
   766 void EngineWrapper::SetCurrentItemIndex(TInt aIndex) 
       
   767 {
       
   768 	mMainView.setCurrentItemIndex(aIndex); 
       
   769 }
       
   770 
       
   771 // ---------------------------------------------------------------------------