testexecfw/stf/stfext/testmodules/scriptermod/src/TestScripterUtils.cpp
changeset 2 8bb370ba6d1d
equal deleted inserted replaced
1:bbd31066657e 2:8bb370ba6d1d
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description: This file contains TestScripter implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "TestScripterUtils.h"
       
    20 #include <f32file.h>
       
    21 #include "TestScripter.h"
       
    22 #include "Logging.h"
       
    23 
       
    24 // EXTERNAL DATA STRUCTURES
       
    25 // None
       
    26 
       
    27 // EXTERNAL FUNCTION PROTOTYPES  
       
    28 // None
       
    29 
       
    30 // CONSTANTS
       
    31 // None
       
    32 
       
    33 // MACROS
       
    34 // None
       
    35 
       
    36 // LOCAL CONSTANTS AND MACROS
       
    37 // None
       
    38 
       
    39 // MODULE DATA STRUCTURES
       
    40 // None
       
    41 
       
    42 // LOCAL FUNCTION PROTOTYPES
       
    43 // None
       
    44 
       
    45 // FORWARD DECLARATIONS
       
    46 // None
       
    47 
       
    48 // ==================== LOCAL FUNCTIONS =======================================
       
    49 
       
    50 // ================= MEMBER FUNCTIONS =========================================
       
    51 
       
    52 /*
       
    53 -------------------------------------------------------------------------------
       
    54 
       
    55      Class: CStartInfo
       
    56 
       
    57      Method: CStartInfo
       
    58 
       
    59      Description: Default constructor
       
    60 
       
    61      C++ default constructor can NOT contain any code, that
       
    62      might leave.
       
    63      
       
    64      Parameters: None
       
    65 
       
    66      Return Values: None
       
    67 
       
    68      Errors/Exceptions: None
       
    69 
       
    70      Status: Draft
       
    71     
       
    72 -------------------------------------------------------------------------------
       
    73 */
       
    74 CStartInfo::CStartInfo():
       
    75 iCategory( TFullTestResult::ECaseExecuted ) 
       
    76     {
       
    77     }
       
    78      
       
    79 /*
       
    80 -------------------------------------------------------------------------------
       
    81 
       
    82      Class: CStartInfo
       
    83 
       
    84      Method: ConstructL
       
    85 
       
    86      Description: Symbian OS second phase constructor
       
    87 
       
    88      Symbian OS default constructor can leave.
       
    89 
       
    90      Parameters:    None
       
    91      
       
    92      Return Values: None
       
    93 
       
    94      Errors/Exceptions: None
       
    95 
       
    96      Status: Draft
       
    97     
       
    98 -------------------------------------------------------------------------------
       
    99 */
       
   100 void CStartInfo::ConstructL()
       
   101     {
       
   102     iModule = HBufC::NewL( 0 );
       
   103     iIniFile = HBufC::NewL( 0 );
       
   104     iConfig = HBufC::NewL( 0 );
       
   105     iTestId = HBufC::NewL( 0 );
       
   106     iTitle = HBufC::NewL( 0 );
       
   107     }
       
   108 
       
   109 /*
       
   110 -------------------------------------------------------------------------------
       
   111 
       
   112      Class: CStartInfo
       
   113 
       
   114      Method: NewL
       
   115 
       
   116      Description: Two-phased constructor.
       
   117           
       
   118      Parameters:    None
       
   119      
       
   120      Return Values: CStartInfo*: new object
       
   121 
       
   122      Errors/Exceptions: Leaves if new or ConstructL leaves.
       
   123 
       
   124      Status: Draft
       
   125     
       
   126 -------------------------------------------------------------------------------
       
   127 */
       
   128 CStartInfo* CStartInfo::NewL()
       
   129     {
       
   130     CStartInfo* self = new (ELeave) CStartInfo();
       
   131      
       
   132     CleanupStack::PushL( self );
       
   133     self->ConstructL();
       
   134     CleanupStack::Pop();
       
   135 
       
   136     return self;
       
   137 
       
   138     }    
       
   139     
       
   140 /*
       
   141 -------------------------------------------------------------------------------
       
   142 
       
   143      Class: CStartInfo
       
   144 
       
   145      Method: ~CStartInfo
       
   146 
       
   147      Description: Destructor
       
   148      
       
   149      Parameters:    None
       
   150 
       
   151      Return Values: None
       
   152 
       
   153      Errors/Exceptions: None
       
   154 
       
   155      Status: Draft
       
   156     
       
   157 -------------------------------------------------------------------------------
       
   158 */     
       
   159 CStartInfo::~CStartInfo()
       
   160     {
       
   161     delete iModule;
       
   162     delete iIniFile;
       
   163     delete iConfig;
       
   164     delete iTestId;
       
   165     delete iTitle;
       
   166     }
       
   167 
       
   168 /*
       
   169 -------------------------------------------------------------------------------
       
   170 
       
   171      Class: CStartInfo
       
   172 
       
   173      Method: SetModuleNameL
       
   174 
       
   175      Description: Set module name.
       
   176      
       
   177      Parameters: TDesC& aModule: in: Module name 
       
   178                  TInt aExtLength: in: Extra length reserved for buffer
       
   179      
       
   180      Return Values: None
       
   181 
       
   182      Errors/Exceptions: None
       
   183 
       
   184      Status: Proposal
       
   185     
       
   186 -------------------------------------------------------------------------------
       
   187 */
       
   188  void CStartInfo::SetModuleNameL( const TDesC& aModule, TInt aExtLength )
       
   189     {
       
   190     HBufC* module = HBufC::NewL( aModule.Length() + aExtLength );
       
   191     CleanupStack::PushL( module );
       
   192     TPtr modulePtr( module->Des() );
       
   193     modulePtr.Append( aModule );
       
   194     
       
   195     // Remove optional '.DLL' from file name
       
   196     modulePtr.LowerCase();
       
   197     TParse parse;
       
   198     parse.Set( *module, NULL, NULL );
       
   199     
       
   200     if ( parse.Ext() == _L(".dll") )
       
   201         {
       
   202         const TInt len = parse.Ext().Length();
       
   203         modulePtr.Delete ( modulePtr.Length() - len, len );
       
   204         }
       
   205     CleanupStack::Pop( module );
       
   206     delete iModule;
       
   207     iModule = module;
       
   208     };
       
   209             
       
   210 /*
       
   211 -------------------------------------------------------------------------------
       
   212 
       
   213      Class: CStartInfo
       
   214 
       
   215      Method: SetIniFileL
       
   216 
       
   217      Description: Set initialization file name name.
       
   218      
       
   219      Parameters: TDesC& aIni: in: Initialization file name
       
   220      
       
   221      Return Values: None
       
   222 
       
   223      Errors/Exceptions: None
       
   224 
       
   225      Status: Proposal
       
   226     
       
   227 -------------------------------------------------------------------------------
       
   228 */        
       
   229 void CStartInfo::SetIniFileL( const TDesC& aIni )
       
   230     {
       
   231     HBufC* inifile = aIni.AllocL();
       
   232     delete iIniFile;
       
   233     iIniFile = inifile;
       
   234     };
       
   235             
       
   236 /*
       
   237 -------------------------------------------------------------------------------
       
   238 
       
   239      Class: CStartInfo
       
   240 
       
   241      Method: SetConfigL
       
   242 
       
   243      Description: Set configuration file name name.
       
   244      
       
   245      Parameters: TDesC& aConfig: in: Configuration file name
       
   246      
       
   247      Return Values: None
       
   248 
       
   249      Errors/Exceptions: None
       
   250 
       
   251      Status: Proposal
       
   252     
       
   253 -------------------------------------------------------------------------------
       
   254 */        
       
   255 void CStartInfo::SetConfigL( const TDesC& aConfig )
       
   256     {
       
   257     HBufC* config = aConfig.AllocL();
       
   258     delete iConfig;
       
   259     iConfig = config;
       
   260     };
       
   261             
       
   262 /*
       
   263 -------------------------------------------------------------------------------
       
   264 
       
   265      Class: CStartInfo
       
   266 
       
   267      Method: SetTestIdL
       
   268 
       
   269      Description: Set test identifier.
       
   270      
       
   271      Parameters: TDesC& aTestId: in: test identifier
       
   272      
       
   273      Return Values: None
       
   274 
       
   275      Errors/Exceptions: None
       
   276 
       
   277      Status: Proposal
       
   278     
       
   279 -------------------------------------------------------------------------------
       
   280 */        
       
   281 void CStartInfo::SetTestIdL( const TDesC& aTestId )
       
   282     {
       
   283     HBufC* testId = aTestId.AllocL();
       
   284     delete iTestId;
       
   285     iTestId = testId;
       
   286     };
       
   287 
       
   288 /*
       
   289 -------------------------------------------------------------------------------
       
   290 
       
   291      Class: CStartInfo
       
   292 
       
   293      Method: SetTitleL
       
   294 
       
   295      Description: Set title.
       
   296      
       
   297      Parameters: TDesC& aTitle: in: Test case title
       
   298      
       
   299      Return Values: None
       
   300 
       
   301      Errors/Exceptions: None
       
   302 
       
   303      Status: Proposal
       
   304     
       
   305 -------------------------------------------------------------------------------
       
   306 */        
       
   307 void CStartInfo::SetTitleL( const TDesC& aTitle)
       
   308     {
       
   309     HBufC* title = aTitle.AllocL();
       
   310     delete iTitle;
       
   311     iTitle = title;
       
   312     }
       
   313 
       
   314 /*
       
   315 -------------------------------------------------------------------------------
       
   316 
       
   317      Class: CStartInfo
       
   318 
       
   319      Method: SetTestCaseNumber
       
   320 
       
   321      Description: Sets test case index.
       
   322      
       
   323      Parameters: TInt aTestCaseNumber: in: Test case index
       
   324      
       
   325      Return Values: None
       
   326 
       
   327      Errors/Exceptions: None
       
   328 
       
   329      Status: Proposal
       
   330     
       
   331 -------------------------------------------------------------------------------
       
   332 */        
       
   333 void CStartInfo::SetTestCaseNumber( TInt aTestCaseNumber )
       
   334     {
       
   335     iCaseNum = aTestCaseNumber;
       
   336     }
       
   337 
       
   338 /*
       
   339 -------------------------------------------------------------------------------
       
   340 
       
   341      Class: CStartInfo
       
   342 
       
   343      Method: SetExpectedResult
       
   344 
       
   345      Description: Sets test case expected result
       
   346      
       
   347      Parameters: TInt aExpectedResult: in: Test case expected result
       
   348      
       
   349      Return Values: None
       
   350 
       
   351      Errors/Exceptions: None
       
   352 
       
   353      Status: Proposal
       
   354     
       
   355 -------------------------------------------------------------------------------
       
   356 */        
       
   357 void CStartInfo::SetExpectedResult( TInt aExpectedResult )
       
   358     {    
       
   359     iExpectedResult = aExpectedResult;
       
   360     }
       
   361 
       
   362 /*
       
   363 -------------------------------------------------------------------------------
       
   364 
       
   365      Class: CStartInfo
       
   366 
       
   367      Method: SetExpectedResultCategory
       
   368 
       
   369      Description: Sets test case expected result category
       
   370      
       
   371      Parameters: TFullTestResult::TCaseExecutionResult aCategory: in: Test case expected result category
       
   372      
       
   373      Return Values: None
       
   374 
       
   375      Errors/Exceptions: None
       
   376 
       
   377      Status: Proposal
       
   378     
       
   379 -------------------------------------------------------------------------------
       
   380 */        
       
   381 void CStartInfo::SetExpectedResultCategory( TFullTestResult::TCaseExecutionResult aCategory )
       
   382     {
       
   383     iCategory = aCategory;
       
   384     }
       
   385 
       
   386 /*
       
   387 -------------------------------------------------------------------------------
       
   388 
       
   389      Class: CStartInfo
       
   390 
       
   391      Method: SetTimeout
       
   392 
       
   393      Description: Sets test case timeout value
       
   394      
       
   395      Parameters:  TInt aTimeout: in: Test case timeout value
       
   396      
       
   397      Return Values: None
       
   398 
       
   399      Errors/Exceptions: None
       
   400 
       
   401      Status: Proposal
       
   402     
       
   403 -------------------------------------------------------------------------------
       
   404 */        
       
   405 void CStartInfo::SetTimeout( TInt aTimeout )
       
   406     {    
       
   407     iTimeout = aTimeout;
       
   408     }
       
   409 
       
   410 /*
       
   411 -------------------------------------------------------------------------------
       
   412 
       
   413      Class: CStartInfo
       
   414 
       
   415      Method: GetModuleName
       
   416 
       
   417      Description: Gets test module name.
       
   418      
       
   419      Parameters:  None
       
   420      
       
   421      Return Values: Test module name
       
   422 
       
   423      Errors/Exceptions: None
       
   424 
       
   425      Status: Proposal
       
   426     
       
   427 -------------------------------------------------------------------------------
       
   428 */        
       
   429 const TDesC& CStartInfo::GetModuleName() const
       
   430     {
       
   431     return *iModule;
       
   432     }
       
   433     
       
   434 /*
       
   435 -------------------------------------------------------------------------------
       
   436 
       
   437      Class: CStartInfo
       
   438 
       
   439      Method: GetIniFile
       
   440 
       
   441      Description: Gets ini file path
       
   442      
       
   443      Parameters:  None
       
   444      
       
   445      Return Values: Ini file path
       
   446 
       
   447      Errors/Exceptions: None
       
   448 
       
   449      Status: Proposal
       
   450     
       
   451 -------------------------------------------------------------------------------
       
   452 */        
       
   453 const TDesC& CStartInfo::GetIniFile() const
       
   454     {
       
   455     return *iIniFile;
       
   456     }
       
   457     
       
   458 /*
       
   459 -------------------------------------------------------------------------------
       
   460 
       
   461      Class: CStartInfo
       
   462 
       
   463      Method: GetConfig
       
   464 
       
   465      Description: Gets config file path
       
   466      
       
   467      Parameters:  None
       
   468      
       
   469      Return Values: Config file path
       
   470 
       
   471      Errors/Exceptions: None
       
   472 
       
   473      Status: Proposal
       
   474     
       
   475 -------------------------------------------------------------------------------
       
   476 */        
       
   477 const TDesC& CStartInfo::GetConfig() const
       
   478     {
       
   479     return *iConfig;
       
   480     }
       
   481     
       
   482 /*
       
   483 -------------------------------------------------------------------------------
       
   484 
       
   485      Class: CStartInfo
       
   486 
       
   487      Method: GetTestId
       
   488 
       
   489      Description: Gets test case id
       
   490      
       
   491      Parameters:  None
       
   492      
       
   493      Return Values: Test case id
       
   494 
       
   495      Errors/Exceptions: None
       
   496 
       
   497      Status: Proposal
       
   498     
       
   499 -------------------------------------------------------------------------------
       
   500 */        
       
   501 const TDesC& CStartInfo::GetTestId() const
       
   502     {
       
   503     return *iTestId;
       
   504     }
       
   505 
       
   506 /*
       
   507 -------------------------------------------------------------------------------
       
   508 
       
   509      Class: CStartInfo
       
   510 
       
   511      Method: GetTitle
       
   512 
       
   513      Description: Gets test case title
       
   514      
       
   515      Parameters:  None
       
   516      
       
   517      Return Values: Test case title
       
   518 
       
   519      Errors/Exceptions: None
       
   520 
       
   521      Status: Proposal
       
   522     
       
   523 -------------------------------------------------------------------------------
       
   524 */        
       
   525 const TDesC& CStartInfo::GetTitle() const
       
   526     {
       
   527     return *iTitle;
       
   528     }
       
   529 
       
   530 /*
       
   531 -------------------------------------------------------------------------------
       
   532 
       
   533      Class: CStartInfo
       
   534 
       
   535      Method: GetTestCaseNumber
       
   536 
       
   537      Description: Gets test case index
       
   538      
       
   539      Parameters:  None
       
   540      
       
   541      Return Values: Test case index
       
   542 
       
   543      Errors/Exceptions: None
       
   544 
       
   545      Status: Proposal
       
   546     
       
   547 -------------------------------------------------------------------------------
       
   548 */        
       
   549 TInt CStartInfo::GetTestCaseNumber() const
       
   550     {
       
   551     return iCaseNum;
       
   552     }
       
   553 
       
   554 /*
       
   555 -------------------------------------------------------------------------------
       
   556 
       
   557      Class: CStartInfo
       
   558 
       
   559      Method: GetExpectedResult
       
   560 
       
   561      Description: Gets test case expected result
       
   562      
       
   563      Parameters:  None
       
   564      
       
   565      Return Values: Test case expected result
       
   566 
       
   567      Errors/Exceptions: None
       
   568 
       
   569      Status: Proposal
       
   570     
       
   571 -------------------------------------------------------------------------------
       
   572 */        
       
   573 TInt CStartInfo::GetExpectedResult() const
       
   574     {
       
   575     return iExpectedResult;
       
   576     }
       
   577 
       
   578 /*
       
   579 -------------------------------------------------------------------------------
       
   580 
       
   581      Class: CStartInfo
       
   582 
       
   583      Method: GetExpectedResultCategory
       
   584 
       
   585      Description: Gets test case expected result category
       
   586      
       
   587      Parameters:  None
       
   588      
       
   589      Return Values: Test case expected result category
       
   590 
       
   591      Errors/Exceptions: None
       
   592 
       
   593      Status: Proposal
       
   594     
       
   595 -------------------------------------------------------------------------------
       
   596 */        
       
   597 TFullTestResult::TCaseExecutionResult CStartInfo::GetExpectedResultCategory() const
       
   598     {    
       
   599     return iCategory;
       
   600     }
       
   601 
       
   602 /*
       
   603 -------------------------------------------------------------------------------
       
   604 
       
   605      Class: CStartInfo
       
   606 
       
   607      Method: GetTimeout
       
   608 
       
   609      Description: Gets test case timeout value
       
   610      
       
   611      Parameters:  None
       
   612      
       
   613      Return Values: Test case timeout value
       
   614 
       
   615      Errors/Exceptions: None
       
   616 
       
   617      Status: Proposal
       
   618     
       
   619 -------------------------------------------------------------------------------
       
   620 */        
       
   621 TInt CStartInfo::GetTimeout() const
       
   622     {
       
   623     return iTimeout;
       
   624     }
       
   625 
       
   626 /*
       
   627 -------------------------------------------------------------------------------
       
   628 
       
   629      Class: CStartInfo
       
   630 
       
   631      Method: CopyL
       
   632 
       
   633      Description: Copy values from other CStartInfo instance.
       
   634      
       
   635      Parameters:  const CStartInfo& aStartInfo: in: CStartInfo instance
       
   636      
       
   637      Return Values: None
       
   638 
       
   639      Errors/Exceptions: None
       
   640 
       
   641      Status: Proposal
       
   642     
       
   643 -------------------------------------------------------------------------------
       
   644 */        
       
   645 void CStartInfo::CopyL( const CStartInfo& aStartInfo )
       
   646     {
       
   647     SetConfigL( aStartInfo.GetConfig() );
       
   648     SetExpectedResult( aStartInfo.GetExpectedResult() );
       
   649     SetExpectedResultCategory( aStartInfo.GetExpectedResultCategory() );
       
   650     SetIniFileL( aStartInfo.GetIniFile() );
       
   651     SetModuleNameL( aStartInfo.GetModuleName() );
       
   652     SetTestCaseNumber( aStartInfo.GetTestCaseNumber() );
       
   653     SetTestIdL( aStartInfo.GetTestId() );
       
   654     SetTimeout( aStartInfo.GetTimeout() );
       
   655     SetTitleL( aStartInfo.GetTitle() );    
       
   656     }
       
   657 
       
   658 
       
   659 /*
       
   660 -------------------------------------------------------------------------------
       
   661 
       
   662      Class: CLoopHelper
       
   663 
       
   664      Method: NewL
       
   665 
       
   666      Description: Two-phased constructor.
       
   667           
       
   668      Parameters: CTestRunner* aTestRunner: in: Pointer to CTestRunner
       
   669      
       
   670      Return Values: CLoopHelper*: new object
       
   671 
       
   672      Errors/Exceptions: Leaves if new or ConstructL leaves.
       
   673 
       
   674      Status: Draft
       
   675     
       
   676 -------------------------------------------------------------------------------
       
   677 */
       
   678 CLoopHelper* CLoopHelper::NewL( CTestRunner* aTestRunner )
       
   679     {    
       
   680     CLoopHelper* self = new(ELeave)CLoopHelper( aTestRunner );
       
   681     CleanupStack::PushL( self );
       
   682     self->ConstructL();
       
   683     CleanupStack::Pop( self );
       
   684     return self;
       
   685     }
       
   686 
       
   687 /*
       
   688 -------------------------------------------------------------------------------
       
   689 
       
   690      Class: CLoopHelper
       
   691 
       
   692      Method: ~CLoopHelper
       
   693 
       
   694      Description: Destructor.
       
   695           
       
   696      Parameters: None
       
   697      
       
   698      Return Values: None
       
   699 
       
   700      Errors/Exceptions: None
       
   701 
       
   702      Status: Draft
       
   703     
       
   704 -------------------------------------------------------------------------------
       
   705 */
       
   706 CLoopHelper::~CLoopHelper()
       
   707     {
       
   708     Cancel();
       
   709     iInLoopSubTestCases.Reset();
       
   710     iInLoopSubTestCases.Close();    
       
   711     }
       
   712 
       
   713 /*
       
   714 -------------------------------------------------------------------------------
       
   715 
       
   716      Class: CLoopHelper
       
   717 
       
   718      Method: CLoopHelper
       
   719 
       
   720      Description: Constructor.
       
   721           
       
   722      Parameters: CTestRunner* aTestRunner: in: Pointer to CTestRunner
       
   723      
       
   724      Return Values: None
       
   725 
       
   726      Errors/Exceptions: None
       
   727 
       
   728      Status: Draft
       
   729     
       
   730 -------------------------------------------------------------------------------
       
   731 */
       
   732 CLoopHelper::CLoopHelper( CTestRunner* aTestRunner )
       
   733 :CActive( EPriorityStandard ), iTestRunner( aTestRunner )
       
   734     {    
       
   735     }
       
   736 
       
   737 /*
       
   738 -------------------------------------------------------------------------------
       
   739 
       
   740      Class: CLoopHelper
       
   741 
       
   742      Method: ConstructL
       
   743 
       
   744      Description: Two-phased constructor.
       
   745           
       
   746      Parameters: None
       
   747      
       
   748      Return Values: None
       
   749 
       
   750      Errors/Exceptions: Leaves if new or ConstructL leaves.
       
   751 
       
   752      Status: Draft
       
   753     
       
   754 -------------------------------------------------------------------------------
       
   755 */
       
   756 void CLoopHelper::ConstructL()
       
   757     {    
       
   758     CActiveScheduler::Add( this );
       
   759     }
       
   760 
       
   761 /*
       
   762 -------------------------------------------------------------------------------
       
   763 
       
   764      Class: CLoopHelper
       
   765 
       
   766      Method: LoopStartL
       
   767 
       
   768      Description: Should be to indicate loop start.
       
   769           
       
   770      Parameters: None
       
   771      
       
   772      Return Values: None
       
   773 
       
   774      Errors/Exceptions: Leaves if new or ConstructL leaves.
       
   775 
       
   776      Status: Draft
       
   777     
       
   778 -------------------------------------------------------------------------------
       
   779 */
       
   780 void CLoopHelper::LoopStartL()
       
   781     {
       
   782     IterationBeginL( ETrue );
       
   783     }
       
   784 
       
   785 /*
       
   786 -------------------------------------------------------------------------------
       
   787 
       
   788      Class: CLoopHelper
       
   789 
       
   790      Method: IterationEndStartNextIterationL
       
   791 
       
   792      Description: Should be called to indicate end of iteration and begining of next iteration
       
   793           
       
   794      Parameters: None
       
   795      
       
   796      Return Values: None
       
   797 
       
   798      Errors/Exceptions: Leaves if new or ConstructL leaves.
       
   799 
       
   800      Status: Draft
       
   801     
       
   802 -------------------------------------------------------------------------------
       
   803 */
       
   804 void CLoopHelper::IterationEndStartNextIterationL()
       
   805     {
       
   806     IterationEndL( EFalse );
       
   807     }
       
   808 
       
   809 /*
       
   810 -------------------------------------------------------------------------------
       
   811 
       
   812      Class: CLoopHelper
       
   813 
       
   814      Method: LoopEndL
       
   815 
       
   816      Description: Should be called to indicate loop end
       
   817           
       
   818      Parameters: None
       
   819      
       
   820      Return Values: None
       
   821 
       
   822      Errors/Exceptions: Leaves if new or ConstructL leaves.
       
   823 
       
   824      Status: Draft
       
   825     
       
   826 -------------------------------------------------------------------------------
       
   827 */
       
   828 void CLoopHelper::LoopEndL()
       
   829     {
       
   830     IterationEndL( ETrue );
       
   831     }
       
   832 
       
   833 /*
       
   834 -------------------------------------------------------------------------------
       
   835 
       
   836      Class: CLoopHelper
       
   837 
       
   838      Method: IterationBeginL
       
   839 
       
   840      Description: Indicate begining of the loop iteration
       
   841           
       
   842      Parameters: TBool aFirstIteration: in: Indicates if it is first iteration
       
   843      
       
   844      Return Values: None
       
   845 
       
   846      Errors/Exceptions: Leaves if new or ConstructL leaves.
       
   847 
       
   848      Status: Draft
       
   849     
       
   850 -------------------------------------------------------------------------------
       
   851 */
       
   852 void CLoopHelper::IterationBeginL( TBool aFirstIteration )
       
   853     {
       
   854     // Check if it is first iteration. If yes then reset CLoopHelper state
       
   855     if ( aFirstIteration )
       
   856         {
       
   857         if ( iInProgress )
       
   858             {
       
   859             User::Leave( KErrInUse );
       
   860             }
       
   861         iPassedIterationsCounter = 0;
       
   862         iInProgress = ETrue;
       
   863         iLoopEnd = EFalse;
       
   864         }
       
   865 
       
   866     // Check for invalid calls order
       
   867     if ( iIterationOngoing )
       
   868         {
       
   869         User::Leave( KErrInUse );
       
   870         }
       
   871     iIterationOngoing = ETrue;
       
   872     iPassCurrentIteration = ETrue;    
       
   873     }
       
   874 
       
   875 /*
       
   876 -------------------------------------------------------------------------------
       
   877 
       
   878      Class: CLoopHelper
       
   879 
       
   880      Method: IterationEndL
       
   881 
       
   882      Description: Indicate end of the loop iteration
       
   883           
       
   884      Parameters: TBool aLastIteration: in: Indicates if it is last iteration
       
   885      
       
   886      Return Values: None
       
   887 
       
   888      Errors/Exceptions: Leaves if new or ConstructL leaves.
       
   889 
       
   890      Status: Draft
       
   891     
       
   892 -------------------------------------------------------------------------------
       
   893 */
       
   894 void CLoopHelper::IterationEndL( TBool aLastIteration )
       
   895     {
       
   896     // Perform tests to check if methods were called in proper order
       
   897     if ( IsActive() )
       
   898         {
       
   899         User::Leave( KErrInUse );
       
   900         }
       
   901     
       
   902     if ( !( iInProgress && iIterationOngoing ) )
       
   903         {
       
   904         User::Leave( KErrNotReady );
       
   905         }
       
   906     
       
   907     if ( aLastIteration )
       
   908         {
       
   909         iLoopEnd = ETrue;
       
   910         }
       
   911 
       
   912     // It is end of loop iteration. Wait for all sub test cases executed inside loop
       
   913     // to finish its execution.
       
   914     iStatus = KRequestPending;
       
   915     SetActive();
       
   916     if ( iInLoopSubTestCases.Count() == 0 )
       
   917         {
       
   918         // All sub test cases executed inside loop are already finished.
       
   919         // Schedule activation of CTestRunner to continue script execution after endloop keyword
       
   920         // ( it is done in CLoopHelper::RunL )
       
   921         TRequestStatus* status = &iStatus;
       
   922         User::RequestComplete( status, KErrNone );
       
   923         }
       
   924     }
       
   925 
       
   926 /*
       
   927 -------------------------------------------------------------------------------
       
   928 
       
   929      Class: CLoopHelper
       
   930 
       
   931      Method: RegisterInLoopSubTestCaseL
       
   932 
       
   933      Description: Should be called to register sub test case executed inside loop
       
   934           
       
   935      Parameters: CSubTestCaseRunner* aSubTestCaseRunner: in: Sub test case runner 
       
   936                  to be registered
       
   937      
       
   938      Return Values: None
       
   939 
       
   940      Errors/Exceptions: Leaves if new or ConstructL leaves.
       
   941 
       
   942      Status: Draft
       
   943     
       
   944 -------------------------------------------------------------------------------
       
   945 */
       
   946 void CLoopHelper::RegisterInLoopSubTestCaseL( CSubTestCaseRunner* aSubTestCaseRunner )
       
   947     {
       
   948     // Check if loop iteration is ongoing
       
   949     if ( !( iInProgress && iIterationOngoing ) )
       
   950         {
       
   951         User::Leave( KErrNotReady );
       
   952         }
       
   953     
       
   954     iInLoopSubTestCases.AppendL( aSubTestCaseRunner );
       
   955     }
       
   956 
       
   957 void CLoopHelper::UnregisterInLoopSubTestCaseL( CSubTestCaseRunner* aSubTestCaseRunner )
       
   958     {
       
   959     // Check if loop iteration is ongoing
       
   960     if ( !( iInProgress && iIterationOngoing ) )
       
   961         {
       
   962         User::Leave( KErrNotReady );
       
   963         }
       
   964     
       
   965     TInt idx = iInLoopSubTestCases.Find( aSubTestCaseRunner );
       
   966     if ( idx >= 0 )
       
   967         {
       
   968         iInLoopSubTestCases.Remove( idx );
       
   969         }    
       
   970     }
       
   971 
       
   972 void CLoopHelper::RegisterInLoopSlaveL( CSlave* aSlave )
       
   973     {
       
   974     // Check if loop iteration is ongoing
       
   975     if ( !( iInProgress && iIterationOngoing ) )
       
   976         {
       
   977         User::Leave( KErrNotReady );
       
   978         }
       
   979     
       
   980     iInLoopSlaves.AppendL( aSlave );
       
   981     }
       
   982 
       
   983 void CLoopHelper::UnregisterInLoopSlaveL( CSlave* aSlave )
       
   984     {
       
   985     // Check if loop iteration is ongoing
       
   986     if ( !( iInProgress && iIterationOngoing ) )
       
   987         {
       
   988         User::Leave( KErrNotReady );
       
   989         }
       
   990     TInt idx = iInLoopSlaves.Find( aSlave );
       
   991     if ( idx >= 0 )
       
   992         {
       
   993         iInLoopSlaves.Remove( idx );
       
   994         }
       
   995     }
       
   996 
       
   997 RPointerArray<CSlave>& CLoopHelper::GetRegisteredInLoopSlaves()
       
   998     {
       
   999     return iInLoopSlaves;
       
  1000     }
       
  1001 
       
  1002 /*
       
  1003 -------------------------------------------------------------------------------
       
  1004 
       
  1005      Class: CLoopHelper
       
  1006 
       
  1007      Method: NotifySubTestCaseEndL
       
  1008 
       
  1009      Description: Should be called to indicate end of sub test case executed inside loop
       
  1010           
       
  1011      Parameters:  CSubTestCaseRunner* aSubTestCaseRunner: in: Sub test case which ended
       
  1012                   TBool aPassed: in: Indicates if test case passed or not
       
  1013      
       
  1014      Return Values: None
       
  1015 
       
  1016      Errors/Exceptions: Leaves if new or ConstructL leaves.
       
  1017 
       
  1018      Status: Draft
       
  1019     
       
  1020 -------------------------------------------------------------------------------
       
  1021 */
       
  1022 void CLoopHelper::NotifySubTestCaseEndL( CSubTestCaseRunner* aSubTestCaseRunner, TBool aPassed )
       
  1023     {
       
  1024     // Check if execution of the loop is ongoing
       
  1025     if ( !iInProgress )
       
  1026         {
       
  1027         User::Leave( KErrNotReady );
       
  1028         }
       
  1029     
       
  1030     // Check if selected sub test case was executed inside loop
       
  1031     TInt idx = iInLoopSubTestCases.Find( aSubTestCaseRunner );
       
  1032     if ( idx >= 0 )
       
  1033         {
       
  1034         iInLoopSubTestCases.Remove( idx );
       
  1035         if ( !aPassed )
       
  1036             {
       
  1037             iPassCurrentIteration = EFalse;
       
  1038             }
       
  1039         
       
  1040         // Check if there are other ont finished sub test cases executed inside loop
       
  1041         if ( iInLoopSubTestCases.Count() == 0 )
       
  1042             {
       
  1043             // Check if CLoopHelper is active.
       
  1044             if ( IsActive() )
       
  1045                 {
       
  1046                 // CLoopHelper is active. It means that IterationEndL method was called 
       
  1047                 // and CTestRunner currently waiting for sub test end before executing next
       
  1048                 // iteration of the loop. Since all sub test cases executed inside lopp are 
       
  1049                 // already finished we can activate CTestRunner ( it is done in CLoopHelper::RunL )
       
  1050                 TRequestStatus* status = &iStatus;
       
  1051                 User::RequestComplete( status, KErrNone );
       
  1052                 }
       
  1053             }
       
  1054         }
       
  1055     }
       
  1056 
       
  1057 /*
       
  1058 -------------------------------------------------------------------------------
       
  1059 
       
  1060      Class: CLoopHelper
       
  1061 
       
  1062      Method: LoopInProgress
       
  1063 
       
  1064      Description: Indicates if loop execution is in progress
       
  1065           
       
  1066      Parameters: None
       
  1067      
       
  1068      Return Values: True if loop is in progress.
       
  1069 
       
  1070      Errors/Exceptions: None
       
  1071 
       
  1072      Status: Draft
       
  1073     
       
  1074 -------------------------------------------------------------------------------
       
  1075 */
       
  1076 TBool CLoopHelper::LoopInProgress() const
       
  1077     {
       
  1078     return iInProgress;
       
  1079     }
       
  1080 
       
  1081 /*
       
  1082 -------------------------------------------------------------------------------
       
  1083 
       
  1084      Class: CLoopHelper
       
  1085 
       
  1086      Method: DoCancel
       
  1087 
       
  1088      Description: See CActive::DoCancel
       
  1089           
       
  1090      Parameters: None
       
  1091      
       
  1092      Return Values: None
       
  1093 
       
  1094      Errors/Exceptions: None
       
  1095 
       
  1096      Status: Draft
       
  1097     
       
  1098 -------------------------------------------------------------------------------
       
  1099 */
       
  1100 void CLoopHelper::DoCancel()
       
  1101     {
       
  1102     TRequestStatus* status = &iStatus;
       
  1103     User::RequestComplete( status, KErrCancel );
       
  1104     }
       
  1105 
       
  1106 /*
       
  1107 -------------------------------------------------------------------------------
       
  1108 
       
  1109      Class: CLoopHelper
       
  1110 
       
  1111      Method: RunL
       
  1112 
       
  1113      Description: See CActive::RunL
       
  1114           
       
  1115      Parameters: None
       
  1116      
       
  1117      Return Values: None
       
  1118 
       
  1119      Errors/Exceptions: None
       
  1120 
       
  1121      Status: Draft
       
  1122     
       
  1123 -------------------------------------------------------------------------------
       
  1124 */
       
  1125 void CLoopHelper::RunL()
       
  1126     {
       
  1127     // Iteration has ended and all sub test cases executed inside loop has ended.
       
  1128     User::LeaveIfError( iStatus.Int() );
       
  1129     iIterationOngoing = EFalse;
       
  1130 
       
  1131     if ( iPassCurrentIteration )
       
  1132         {
       
  1133         iPassedIterationsCounter++;
       
  1134         }
       
  1135 
       
  1136     // Activate CTestRunner to continue test case execution
       
  1137     iTestRunner->SetRunnerActive();
       
  1138     
       
  1139     if ( iLoopEnd )
       
  1140         {
       
  1141         iTestRunner->ReleaseRemoteResourcesAllocatedInLoopL();
       
  1142         // It was last iteration. Report loop result to CTestRunner
       
  1143         iTestRunner->ReportLoopEndResultL( iPassedIterationsCounter );
       
  1144         // Reset CLoopHelper state
       
  1145         iLoopEnd = EFalse;
       
  1146         iInProgress = EFalse;
       
  1147         }
       
  1148     else
       
  1149         {
       
  1150         // Begin next loop iteration
       
  1151         IterationBeginL( EFalse );    
       
  1152         }
       
  1153     }
       
  1154     
       
  1155 /*
       
  1156 -------------------------------------------------------------------------------
       
  1157 
       
  1158      Class: CSlaveInfo
       
  1159 
       
  1160      Method: GetEvent
       
  1161 
       
  1162      Description: Returns event with given name.
       
  1163 
       
  1164      Parameters:  TDesC& aEventName: in; Event name
       
  1165 
       
  1166      Return Values: TEventTc: Event structure
       
  1167 
       
  1168      Errors/Exceptions: None
       
  1169 
       
  1170      Status: Draft
       
  1171     
       
  1172 -------------------------------------------------------------------------------
       
  1173 */
       
  1174 //TEventTc* CSlaveInfo::GetEvent( TDesC& aEventName )
       
  1175 //    {
       
  1176 //    
       
  1177 //    TInt count = iEvents.Count();
       
  1178 //    for( TInt i = 0; i < count; i++ )
       
  1179 //        {
       
  1180 //        if( iEvents[i]->Name() == aEventName )
       
  1181 //            {
       
  1182 //            return iEvents[i];
       
  1183 //            }
       
  1184 //        }
       
  1185 //    return NULL;
       
  1186 //    
       
  1187 //    }
       
  1188 
       
  1189 #ifdef LOGGER
       
  1190 #undef LOGGER
       
  1191 #endif
       
  1192 
       
  1193 #define LOGGER iLogger
       
  1194 
       
  1195 /*
       
  1196 -------------------------------------------------------------------------------
       
  1197 
       
  1198      Class: TEventTS
       
  1199 
       
  1200      Method: TEventTS
       
  1201 
       
  1202      Description: Default constructor
       
  1203 
       
  1204      C++ default constructor can NOT contain any code, that
       
  1205      might leave.
       
  1206      
       
  1207      Parameters: None
       
  1208      
       
  1209      Return Values: None
       
  1210 
       
  1211      Errors/Exceptions: None
       
  1212 
       
  1213      Status: Proposal
       
  1214     
       
  1215 -------------------------------------------------------------------------------
       
  1216 */
       
  1217 TEventTS::TEventTS()
       
  1218 :iClientReqStatus( NULL )
       
  1219     {
       
  1220     }
       
  1221         
       
  1222 /*
       
  1223 -------------------------------------------------------------------------------
       
  1224 
       
  1225      Class: TEventTS
       
  1226 
       
  1227      Method: TEventTS
       
  1228 
       
  1229      Description: Parametric constructor
       
  1230 
       
  1231      Parameters: None
       
  1232      
       
  1233      Return Values: None
       
  1234 
       
  1235      Errors/Exceptions: None
       
  1236 
       
  1237      Status: Proposal
       
  1238     
       
  1239 -------------------------------------------------------------------------------
       
  1240 */ 
       
  1241 TEventTS::TEventTS( TName& aEventName )
       
  1242 :iClientReqStatus( NULL )
       
  1243     {
       
  1244     SetName( aEventName );
       
  1245     SetType( EReqEvent );
       
  1246     }
       
  1247 
       
  1248 /*
       
  1249 -------------------------------------------------------------------------------
       
  1250 
       
  1251      Class: TEventTS
       
  1252 
       
  1253      Method: ~TEventTS
       
  1254 
       
  1255      Description: Destructor
       
  1256 
       
  1257      Parameters: None
       
  1258      
       
  1259      Return Values: None
       
  1260 
       
  1261      Errors/Exceptions: None
       
  1262 
       
  1263      Status: Proposal
       
  1264     
       
  1265 -------------------------------------------------------------------------------
       
  1266 */ 
       
  1267 TEventTS::~TEventTS()
       
  1268     { 
       
  1269     Complete( KErrNone ); 
       
  1270     }
       
  1271 /*
       
  1272 -------------------------------------------------------------------------------
       
  1273 
       
  1274      Class: TEventTS
       
  1275 
       
  1276      Method: SetRequestStatus
       
  1277 
       
  1278      Description: Set request status member.
       
  1279 
       
  1280      Parameters: None
       
  1281      
       
  1282      Return Values: None
       
  1283 
       
  1284      Errors/Exceptions: None
       
  1285 
       
  1286      Status: Proposal
       
  1287     
       
  1288 -------------------------------------------------------------------------------
       
  1289 */ 
       
  1290 void TEventTS::SetRequestStatus( TRequestStatus* aStatus )
       
  1291     { 
       
  1292     iClientReqStatus = aStatus; 
       
  1293     *iClientReqStatus = KRequestPending;
       
  1294     }
       
  1295 
       
  1296 /*
       
  1297 -------------------------------------------------------------------------------
       
  1298 
       
  1299      Class: TEventTS
       
  1300 
       
  1301      Method: Complete
       
  1302 
       
  1303      Description: Complete request status member.
       
  1304      
       
  1305      Parameters: None
       
  1306      
       
  1307      Return Values: None
       
  1308 
       
  1309      Errors/Exceptions: None
       
  1310 
       
  1311      Status: Proposal
       
  1312     
       
  1313 -------------------------------------------------------------------------------
       
  1314 */ 
       
  1315 void TEventTS::Complete( TInt aError )
       
  1316     { 
       
  1317     if( iClientReqStatus )
       
  1318         { 
       
  1319         User::RequestComplete( iClientReqStatus, aError ); 
       
  1320         }
       
  1321     }
       
  1322 
       
  1323 /*
       
  1324 -------------------------------------------------------------------------------
       
  1325 
       
  1326      Class: TEventTS
       
  1327 
       
  1328      Method: SetEvent
       
  1329 
       
  1330      Description: Set event pending.
       
  1331      
       
  1332      Parameters: None
       
  1333      
       
  1334      Return Values: None
       
  1335 
       
  1336      Errors/Exceptions: None
       
  1337 
       
  1338      Status: Proposal
       
  1339     
       
  1340 -------------------------------------------------------------------------------
       
  1341 */ 
       
  1342 void TEventTS::SetEvent( TEventType aEventType )
       
  1343     {
       
  1344     SetEventType( aEventType );
       
  1345     if( iClientReqStatus )
       
  1346         {
       
  1347         Complete( KErrNone );
       
  1348         if( EventType() == EState )
       
  1349             {
       
  1350             SetType( ESetEvent ) ;
       
  1351             }
       
  1352         }
       
  1353     else 
       
  1354         {
       
  1355         SetType( ESetEvent ) ;
       
  1356         }
       
  1357     }
       
  1358    
       
  1359 /*
       
  1360 -------------------------------------------------------------------------------
       
  1361 
       
  1362      Class: TEventTS
       
  1363 
       
  1364      Method: WaitEvent
       
  1365 
       
  1366      Description: Wait event.
       
  1367      
       
  1368      Parameters: None
       
  1369      
       
  1370      Return Values: None
       
  1371 
       
  1372      Errors/Exceptions: None
       
  1373 
       
  1374      Status: Proposal
       
  1375     
       
  1376 -------------------------------------------------------------------------------
       
  1377 */
       
  1378 void TEventTS::WaitEvent( TRequestStatus& aStatus )
       
  1379     {
       
  1380     SetRequestStatus( &aStatus );
       
  1381     if( Type() == ESetEvent )
       
  1382         {
       
  1383         Complete( KErrNone );
       
  1384         if( EventType() == EIndication )
       
  1385             {
       
  1386             SetType( EReqEvent );
       
  1387             }
       
  1388         }
       
  1389     }
       
  1390 
       
  1391 CRemoteCallsProxy* CRemoteCallsProxy::NewL( CTestModuleIf& aTestModuleIf, CStifLogger* aLogger )
       
  1392     {
       
  1393     CRemoteCallsProxy* self = new(ELeave)CRemoteCallsProxy( aTestModuleIf, aLogger );
       
  1394     CleanupStack::PushL( self );
       
  1395     self->ConstructL(); 
       
  1396     CleanupStack::Pop( self );
       
  1397     return self;
       
  1398     }
       
  1399 
       
  1400 CRemoteCallsProxy::~CRemoteCallsProxy()
       
  1401     {
       
  1402     Cancel();
       
  1403     
       
  1404     iLogger = NULL;
       
  1405     iSlaveAllocateFreeMonitor = NULL;
       
  1406     iRemoteTestCasesMonitor = NULL;
       
  1407     iRemoteEventsMonitor = NULL;
       
  1408     iRemoteSendReceiveMonitor = NULL;
       
  1409     iReceiveErrorHandler = NULL;    
       
  1410     }
       
  1411 
       
  1412 CRemoteCallsProxy::CRemoteCallsProxy( CTestModuleIf& aTestModuleIf, CStifLogger* aLogger )
       
  1413 : CActive( EPriorityNormal ), iLogger( aLogger ), iTestModuleIf( aTestModuleIf )
       
  1414     {
       
  1415     CActiveScheduler::Add( this );
       
  1416     }
       
  1417 
       
  1418 void CRemoteCallsProxy::ConstructL()
       
  1419     {
       
  1420     StartReceivingL();
       
  1421     }
       
  1422 
       
  1423 void CRemoteCallsProxy::DoCancel()
       
  1424     {
       
  1425     iTestModuleIf.RemoteReceiveCancel();
       
  1426     }
       
  1427 
       
  1428 void CRemoteCallsProxy::RunL()
       
  1429     {
       
  1430     RDebug::Print( _L("[STIF Master received response] %S"), &iReceivedRemoteMsg );    
       
  1431     
       
  1432     DispatchReceivedRemoteMsgL();
       
  1433     StartReceivingL();
       
  1434     }
       
  1435 
       
  1436 TInt CRemoteCallsProxy::RunError( TInt aError )
       
  1437     {
       
  1438     if ( iReceiveErrorHandler != NULL )
       
  1439         {
       
  1440         iReceiveErrorHandler->HandleRemoteReceiveError( aError, iReceiveErrorDescription );
       
  1441         return KErrNone;
       
  1442         }
       
  1443     return aError;
       
  1444     }
       
  1445 
       
  1446 void CRemoteCallsProxy::AllocateL( TUint32 aMasterId, const TDesC& aType )
       
  1447     {
       
  1448     CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL();
       
  1449     CleanupStack::PushL( remoteRequest );
       
  1450     
       
  1451     remoteRequest->CreateL();    
       
  1452     // Reserve message
       
  1453     User::LeaveIfError(
       
  1454             remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgReserve ) );
       
  1455     // Srcid. i.e. master id
       
  1456     User::LeaveIfError(
       
  1457             remoteRequest->AppendId( aMasterId ) );
       
  1458     // DstId, broacast id
       
  1459     User::LeaveIfError(
       
  1460             remoteRequest->AppendId( 0 ) );
       
  1461     // Slave type
       
  1462     User::LeaveIfError( 
       
  1463             remoteRequest->Append( aType ) );
       
  1464 
       
  1465     RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() );
       
  1466     
       
  1467     User::LeaveIfError( 
       
  1468         iTestModuleIf.RemoteSend( remoteRequest->Message() ) );
       
  1469     
       
  1470     CleanupStack::PopAndDestroy( remoteRequest );
       
  1471     }
       
  1472 
       
  1473 void CRemoteCallsProxy::FreeL( TUint32 aMasterId, TUint16 aSlaveId )
       
  1474     {
       
  1475     CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL();
       
  1476     CleanupStack::PushL( remoteRequest );
       
  1477     
       
  1478     remoteRequest->CreateL();
       
  1479     
       
  1480     // Release message
       
  1481     User::LeaveIfError( 
       
  1482             remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRelease ) );
       
  1483     // Srcid. i.e. master id
       
  1484     User::LeaveIfError( 
       
  1485             remoteRequest->AppendId( aMasterId ) );
       
  1486     // DstId is device broadcast
       
  1487     User::LeaveIfError( 
       
  1488             remoteRequest->AppendId( SETID( aSlaveId, 0 ) ) );
       
  1489     
       
  1490     RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() );
       
  1491 
       
  1492     User::LeaveIfError( 
       
  1493         iTestModuleIf.RemoteSend( remoteRequest->Message() ) );
       
  1494         
       
  1495     CleanupStack::PopAndDestroy( remoteRequest );
       
  1496     }
       
  1497 
       
  1498 void CRemoteCallsProxy::SendReceiveL(  TUint32 aMasterId, TUint16 aSlaveId, const TDesC& aMessage )
       
  1499     {
       
  1500     CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL();
       
  1501     CleanupStack::PushL( remoteRequest );
       
  1502     
       
  1503     remoteRequest->CreateL();
       
  1504     // Remote message
       
  1505     User::LeaveIfError(
       
  1506         remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ) );
       
  1507     // Srcid. i.e. master id
       
  1508     User::LeaveIfError( remoteRequest->AppendId( aMasterId ) );
       
  1509     // DstId, i.e.slave device id
       
  1510     User::LeaveIfError( remoteRequest->AppendId( SETID( aSlaveId, 0 ) ) );
       
  1511     // Run command
       
  1512     User::LeaveIfError( remoteRequest->Append( 
       
  1513         CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdSendReceive ) );
       
  1514     // asynchronous sendreceive's parameters    
       
  1515     if ( aMessage != KNullDesC )
       
  1516         {        
       
  1517         // Append parameters
       
  1518         User::LeaveIfError( remoteRequest->Append( aMessage ) );  
       
  1519         }
       
  1520     
       
  1521     RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() );
       
  1522     User::LeaveIfError( 
       
  1523         iTestModuleIf.RemoteSend( remoteRequest->Message() ) );
       
  1524 
       
  1525     CleanupStack::PopAndDestroy( remoteRequest );
       
  1526     }
       
  1527 
       
  1528 void CRemoteCallsProxy::SendUnknownL(  TUint32 aMasterId, TUint16 aSlaveId, 
       
  1529         const TDesC& aCommand, const TDesC& aMessage )
       
  1530     {
       
  1531     CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL();
       
  1532     CleanupStack::PushL( remoteRequest );
       
  1533     
       
  1534     remoteRequest->CreateL();
       
  1535     // Remote message
       
  1536     User::LeaveIfError(
       
  1537             remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ) );
       
  1538     // Srcid. i.e. master id
       
  1539     User::LeaveIfError( remoteRequest->AppendId( aMasterId ) );
       
  1540     // DstId, i.e.slave device id
       
  1541     User::LeaveIfError( remoteRequest->AppendId( SETID( aSlaveId, 0 ) ) );
       
  1542     
       
  1543     // Append command name
       
  1544     User::LeaveIfError( remoteRequest->Append( aCommand ) );
       
  1545     
       
  1546     if ( aMessage != KNullDesC )
       
  1547         {        
       
  1548         // Append parameters
       
  1549         User::LeaveIfError( remoteRequest->Append( aMessage ) );  
       
  1550         }
       
  1551     
       
  1552     RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() );
       
  1553 
       
  1554     User::LeaveIfError( 
       
  1555         iTestModuleIf.RemoteSend( remoteRequest->Message() ) );
       
  1556                 
       
  1557     CleanupStack::PopAndDestroy( remoteRequest );
       
  1558     }
       
  1559 
       
  1560 
       
  1561 void CRemoteCallsProxy::RunTestCaseL( TUint32 aMasterId, TUint16 aSlaveId, CStartInfo* aStartInfo )
       
  1562     {
       
  1563     CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL();
       
  1564     CleanupStack::PushL( remoteRequest );
       
  1565     remoteRequest->CreateL();
       
  1566     
       
  1567     // Remote message
       
  1568     User::LeaveIfError( 
       
  1569         remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ) );
       
  1570     // Srcid. i.e. master id
       
  1571     User::LeaveIfError( remoteRequest->AppendId( aMasterId ) );
       
  1572     // DstId is device broadcast
       
  1573     User::LeaveIfError( 
       
  1574         remoteRequest->AppendId( SETID( aSlaveId, 0 ) ) );
       
  1575     // Run command
       
  1576     User::LeaveIfError( 
       
  1577         remoteRequest->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdRun ) );
       
  1578     // Run parameters
       
  1579     User::LeaveIfError(
       
  1580         remoteRequest->Append( CStifTFwIfProt::RunParams, 
       
  1581                 CStifTFwIfProt::ERunModule, 
       
  1582                 aStartInfo->GetModuleName() ) );
       
  1583     User::LeaveIfError(
       
  1584         remoteRequest->Append( CStifTFwIfProt::RunParams, 
       
  1585                 CStifTFwIfProt::ERunTestcasenum, 
       
  1586                 aStartInfo->GetTestCaseNumber() ));
       
  1587     if( aStartInfo->GetIniFile().Length() > 0 )
       
  1588         {
       
  1589         // Initialization file
       
  1590         __TRACE( KMessage, (_L("ini: %S"), &aStartInfo->GetIniFile() ));     
       
  1591         User::LeaveIfError(
       
  1592             remoteRequest->Append( CStifTFwIfProt::RunParams, 
       
  1593                     CStifTFwIfProt::ERunInifile, 
       
  1594                     aStartInfo->GetIniFile() ) );
       
  1595         }
       
  1596     if( aStartInfo->GetConfig().Length() > 0 )
       
  1597         {
       
  1598         // Initialization file
       
  1599         __TRACE( KMessage, (_L("config: %S"), &aStartInfo->GetConfig() ));     
       
  1600         User::LeaveIfError(
       
  1601             remoteRequest->Append( CStifTFwIfProt::RunParams, 
       
  1602                     CStifTFwIfProt::ERunTestcasefile, 
       
  1603                     aStartInfo->GetConfig() ));
       
  1604         } 
       
  1605     //Title (must be given between quotation marks in case of any spaces inside
       
  1606     if( aStartInfo->GetTitle().Length() > 0 )
       
  1607         {
       
  1608         __TRACE(KMessage, (_L("title: %S"), &aStartInfo->GetTitle() ) );
       
  1609         TName title;
       
  1610         title.Format(_L("\"title=%S\""), &aStartInfo->GetTitle() );
       
  1611         User::LeaveIfError( remoteRequest->Append( title ) );
       
  1612         }
       
  1613     
       
  1614     RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() );
       
  1615 
       
  1616     User::LeaveIfError(
       
  1617         iTestModuleIf.RemoteSend( remoteRequest->Message() ) );
       
  1618         
       
  1619     CleanupStack::PopAndDestroy( remoteRequest );    
       
  1620     }
       
  1621 
       
  1622 void CRemoteCallsProxy::PauseTestCaseL( TUint32 aMasterId, TUint16 aSlaveId, TUint16 aTestId )
       
  1623     {
       
  1624     CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL();
       
  1625     CleanupStack::PushL( remoteRequest );
       
  1626     remoteRequest->CreateL();
       
  1627     // Remote message
       
  1628     User::LeaveIfError( 
       
  1629         remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ) );
       
  1630     // Srcid. i.e. master id
       
  1631     User::LeaveIfError(
       
  1632         remoteRequest->AppendId( aMasterId ) );
       
  1633     // DstId, i.e.slave id
       
  1634     User::LeaveIfError(
       
  1635         remoteRequest->AppendId( SETID( aSlaveId, aTestId ) ) );
       
  1636     
       
  1637     // Pause command
       
  1638     User::LeaveIfError(
       
  1639         remoteRequest->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdPause ) );
       
  1640     
       
  1641     RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() );
       
  1642 
       
  1643     User::LeaveIfError( 
       
  1644             iTestModuleIf.RemoteSend( remoteRequest->Message() ) );
       
  1645     
       
  1646     CleanupStack::PopAndDestroy( remoteRequest );    
       
  1647     }
       
  1648 
       
  1649 void CRemoteCallsProxy::ResumeTestCaseL( TUint32 aMasterId, TUint16 aSlaveId, TUint16 aTestId )
       
  1650     {    
       
  1651     CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL();
       
  1652     CleanupStack::PushL( remoteRequest );
       
  1653     remoteRequest->CreateL();
       
  1654     // Remote message
       
  1655     User::LeaveIfError( 
       
  1656         remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ) );
       
  1657     // Srcid. i.e. master id
       
  1658     User::LeaveIfError(
       
  1659         remoteRequest->AppendId( aMasterId ));
       
  1660     // DstId, i.e.slave id
       
  1661     User::LeaveIfError(
       
  1662         remoteRequest->AppendId( SETID( aSlaveId, aTestId ) ) );
       
  1663     
       
  1664     // Resume command
       
  1665     User::LeaveIfError( 
       
  1666         remoteRequest->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdResume ));
       
  1667     
       
  1668     RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() );
       
  1669 
       
  1670     User::LeaveIfError( 
       
  1671             iTestModuleIf.RemoteSend( remoteRequest->Message() ) );
       
  1672     
       
  1673     CleanupStack::PopAndDestroy( remoteRequest );    
       
  1674     }
       
  1675 
       
  1676 void CRemoteCallsProxy::CancelTestCaseL( TUint32 aMasterId, TUint16 aSlaveId, TUint16 aTestId )
       
  1677     {    
       
  1678     CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL();
       
  1679     CleanupStack::PushL( remoteRequest );
       
  1680     remoteRequest->CreateL();
       
  1681     // Remote message
       
  1682     User::LeaveIfError( 
       
  1683         remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ) );
       
  1684     // Srcid. i.e. master id
       
  1685     User::LeaveIfError(
       
  1686         remoteRequest->AppendId( aMasterId ));
       
  1687     // DstId, i.e.slave id
       
  1688     User::LeaveIfError(
       
  1689         remoteRequest->AppendId( SETID( aSlaveId, aTestId ) ) );
       
  1690     
       
  1691     // Cancel command
       
  1692     User::LeaveIfError( 
       
  1693         remoteRequest->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdCancel ));
       
  1694     
       
  1695     RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() );
       
  1696 
       
  1697     User::LeaveIfError( 
       
  1698             iTestModuleIf.RemoteSend( remoteRequest->Message() ) );
       
  1699     
       
  1700     CleanupStack::PopAndDestroy( remoteRequest );    
       
  1701     }
       
  1702 
       
  1703 void CRemoteCallsProxy::RequestEventL( TUint32 aMasterId, TUint16 aSlaveId, const TDesC& aEventName )
       
  1704     {
       
  1705     CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL();
       
  1706     CleanupStack::PushL( remoteRequest );
       
  1707     
       
  1708     remoteRequest->CreateL();
       
  1709     // Remote message
       
  1710     User::LeaveIfError( 
       
  1711         remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ));
       
  1712     // Srcid. i.e. master id
       
  1713     User::LeaveIfError( remoteRequest->AppendId( aMasterId ) );
       
  1714     // DstId, i.e.slave device id
       
  1715     User::LeaveIfError( remoteRequest->AppendId( SETID( aSlaveId, 0 ) ) );
       
  1716     
       
  1717     // Request event
       
  1718     User::LeaveIfError( 
       
  1719         remoteRequest->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdRequest )); 
       
  1720         
       
  1721     // Event name
       
  1722     User::LeaveIfError( remoteRequest->Append( aEventName ) ); 
       
  1723     
       
  1724     RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() );
       
  1725 
       
  1726     User::LeaveIfError( 
       
  1727             iTestModuleIf.RemoteSend( remoteRequest->Message() ) );
       
  1728     
       
  1729     CleanupStack::PopAndDestroy( remoteRequest );    
       
  1730     }
       
  1731 
       
  1732 void CRemoteCallsProxy::SetEventL( TUint32 aMasterId, TUint16 aSlaveId, const TDesC& aEventName, 
       
  1733         TEventIf::TEventType aEventType )
       
  1734     {
       
  1735     CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL();
       
  1736     CleanupStack::PushL( remoteRequest );
       
  1737     
       
  1738     remoteRequest->CreateL();
       
  1739     // Remote message
       
  1740     User::LeaveIfError( 
       
  1741         remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ));
       
  1742     // Srcid. i.e. master id
       
  1743     User::LeaveIfError( remoteRequest->AppendId( aMasterId ) );
       
  1744     // DstId, i.e.slave device id
       
  1745     User::LeaveIfError( remoteRequest->AppendId( SETID( aSlaveId, 0 ) ) );
       
  1746         
       
  1747     // Set event
       
  1748     User::LeaveIfError( 
       
  1749         remoteRequest->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdSetEvent ) ); 
       
  1750         
       
  1751     // Event name
       
  1752     User::LeaveIfError( remoteRequest->Append( aEventName ) ); 
       
  1753     
       
  1754     if ( aEventType == TEventIf::EState )
       
  1755         {
       
  1756         // State event
       
  1757         User::LeaveIfError( remoteRequest->Append( remoteRequest->EventType( aEventType ) ) ); 
       
  1758         }
       
  1759         
       
  1760     RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() );
       
  1761 
       
  1762     User::LeaveIfError( 
       
  1763             iTestModuleIf.RemoteSend( remoteRequest->Message() ) );    
       
  1764     
       
  1765     CleanupStack::PopAndDestroy( remoteRequest );    
       
  1766     }
       
  1767 
       
  1768 void CRemoteCallsProxy::UnsetEventL( TUint32 aMasterId, TUint16 aSlaveId, const TDesC& aEventName )
       
  1769     {
       
  1770     CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL();
       
  1771     CleanupStack::PushL( remoteRequest );
       
  1772     
       
  1773     remoteRequest->CreateL();
       
  1774     // Remote message
       
  1775     User::LeaveIfError( 
       
  1776         remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ));
       
  1777     // Srcid. i.e. master id
       
  1778     User::LeaveIfError( remoteRequest->AppendId( aMasterId ) );
       
  1779     // DstId, i.e.slave device id
       
  1780     User::LeaveIfError( remoteRequest->AppendId( SETID( aSlaveId, 0 ) ) );
       
  1781     
       
  1782     // Set event
       
  1783     User::LeaveIfError( 
       
  1784         remoteRequest->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdUnsetEvent ) ); 
       
  1785         
       
  1786     // Event name
       
  1787     User::LeaveIfError( remoteRequest->Append( aEventName ) ); 
       
  1788     
       
  1789     RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() );
       
  1790 
       
  1791     User::LeaveIfError( 
       
  1792             iTestModuleIf.RemoteSend( remoteRequest->Message() ) );    
       
  1793     
       
  1794     CleanupStack::PopAndDestroy( remoteRequest );    
       
  1795     }
       
  1796 
       
  1797 void CRemoteCallsProxy::ReleaseEventL( TUint32 aMasterId, TUint16 aSlaveId, const TDesC& aEventName )
       
  1798     {
       
  1799     CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL();
       
  1800     CleanupStack::PushL( remoteRequest );
       
  1801     
       
  1802     remoteRequest->CreateL();
       
  1803     // Remote message
       
  1804     User::LeaveIfError( 
       
  1805         remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ));
       
  1806     // Srcid. i.e. master id
       
  1807     User::LeaveIfError( remoteRequest->AppendId( aMasterId ) );
       
  1808     // DstId, i.e.slave device id
       
  1809     User::LeaveIfError( remoteRequest->AppendId( SETID( aSlaveId, 0 ) ) );
       
  1810     
       
  1811     // Release event
       
  1812     User::LeaveIfError(
       
  1813         remoteRequest->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdRelease )); 
       
  1814 
       
  1815     // Event name
       
  1816     User::LeaveIfError( remoteRequest->Append( aEventName ) );
       
  1817     
       
  1818     RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() );
       
  1819 
       
  1820     User::LeaveIfError( 
       
  1821             iTestModuleIf.RemoteSend( remoteRequest->Message() ) );    
       
  1822     
       
  1823     CleanupStack::PopAndDestroy( remoteRequest );
       
  1824     }
       
  1825 
       
  1826 void CRemoteCallsProxy::SetSlaveAllocateFreeMonitor( MSlaveAllocateFreeMonitor* aSlaveAllocateFreeMonitor )
       
  1827     {
       
  1828     iSlaveAllocateFreeMonitor = aSlaveAllocateFreeMonitor;
       
  1829     }
       
  1830 
       
  1831 void CRemoteCallsProxy::SetRemoteTestCasesMonitor( MRemoteTestCasesMonitor* aRemoteTestCasesMonitor )
       
  1832     {
       
  1833     iRemoteTestCasesMonitor = aRemoteTestCasesMonitor;
       
  1834     }
       
  1835 
       
  1836 void CRemoteCallsProxy::SetRemoteEventsMonitor( MRemoteEventsMonitor* aRemoteEventsMonitor )
       
  1837     {
       
  1838     iRemoteEventsMonitor = aRemoteEventsMonitor;
       
  1839     }
       
  1840 
       
  1841 void CRemoteCallsProxy::SetRemoteSendReceiveMonitor( MRemoteSendReceiveMonitor* aRemoteSendReceiveMonitor )
       
  1842     {
       
  1843     iRemoteSendReceiveMonitor = aRemoteSendReceiveMonitor;
       
  1844     }
       
  1845 
       
  1846 void CRemoteCallsProxy::SetReceiveErrorHandler( MReceiveErrorHandler* aReceiveErrorHandler )
       
  1847     {
       
  1848     iReceiveErrorHandler = aReceiveErrorHandler;
       
  1849     }
       
  1850 
       
  1851 void CRemoteCallsProxy::StartReceivingL()
       
  1852     {
       
  1853     iTestModuleIf.RemoteReceive( iReceivedRemoteMsg, iStatus );        
       
  1854     SetActive();
       
  1855     }
       
  1856 
       
  1857 void CRemoteCallsProxy::DispatchReceivedRemoteMsgL()
       
  1858     {
       
  1859     _LIT( KErrMsg, "Error during slave respons handling");
       
  1860     
       
  1861     iReceiveErrorDescription = KErrMsg;
       
  1862     
       
  1863     CStifTFwIfProt* msg = CStifTFwIfProt::NewL();
       
  1864     CleanupStack::PushL( msg );
       
  1865     TRAPD( err, msg->SetL( iReceivedRemoteMsg ); );
       
  1866     if( err != KErrNone )
       
  1867         {
       
  1868         __TRACE( KError, (_L("Response parsing failed")));
       
  1869         User::Leave( err );
       
  1870         }
       
  1871     
       
  1872     // Check protocol identifiers
       
  1873     if( ( msg->SrcDevId() == 0 ) ||
       
  1874         ( msg->DstDevId() == 0 ) ||
       
  1875         ( msg->DstTestId() == 0 ) )
       
  1876         {
       
  1877         __TRACE( KError, (_L("Illegal deviceid received")));
       
  1878         User::Leave( KErrGeneral );
       
  1879         }
       
  1880     
       
  1881     // This is master, cannot receive anything else but responses
       
  1882     if( msg->iMsgType != CStifTFwIfProt::EMsgResponse )
       
  1883         {
       
  1884         __TRACE( KError, (_L("Illegal message received %d"), 
       
  1885             msg->iMsgType ));
       
  1886         User::Leave( KErrGeneral );        
       
  1887         }
       
  1888         
       
  1889     switch( msg->iRespType )
       
  1890         {
       
  1891         case CStifTFwIfProt::EMsgReserve:
       
  1892             {
       
  1893             ReceiveResponseReserveL( msg );
       
  1894             }
       
  1895             break;
       
  1896         case CStifTFwIfProt::EMsgRelease:
       
  1897             {
       
  1898             ReceiveResponseReleaseL( msg );
       
  1899             }            
       
  1900             break;
       
  1901         case CStifTFwIfProt::EMsgRemote:
       
  1902             {         
       
  1903             __TRACE( KMessage, (_L("ReceiveResponse Remote")));
       
  1904             switch( msg->iCmdType )
       
  1905                 {
       
  1906                 case CStifTFwIfProt::ECmdRun:
       
  1907                     ReceiveResponseRunL( msg );
       
  1908                     break;
       
  1909                 case CStifTFwIfProt::ECmdPause:
       
  1910                 case CStifTFwIfProt::ECmdResume:
       
  1911                 case CStifTFwIfProt::ECmdCancel:
       
  1912                     ReceiveResponseTestCtlL( msg );
       
  1913                     break;
       
  1914                 case CStifTFwIfProt::ECmdRequest:
       
  1915                 case CStifTFwIfProt::ECmdRelease:
       
  1916                 case CStifTFwIfProt::ECmdSetEvent:
       
  1917                 case CStifTFwIfProt::ECmdUnsetEvent:
       
  1918                     ReceiveResponseEventCtlL( msg );                    
       
  1919                     break;
       
  1920                 case CStifTFwIfProt::ECmdSendReceive:
       
  1921                     ReceiveResponseSendReceiveL( msg );                    
       
  1922                     break;
       
  1923                 default:
       
  1924                     ReceiveResponseSendUnknownL( msg );                    
       
  1925                     break;
       
  1926                 }
       
  1927             }            
       
  1928             break;
       
  1929         default:
       
  1930             User::Leave( KErrGeneral );
       
  1931         } 
       
  1932                
       
  1933     CleanupStack::PopAndDestroy( msg );    
       
  1934     iReceiveErrorDescription = KNullDesC;
       
  1935     }
       
  1936 
       
  1937 void CRemoteCallsProxy::ReceiveResponseReserveL( CStifTFwIfProt* aMsg )
       
  1938     {
       
  1939     _LIT( KErrMsg, "Error during slave allocate respons handling");
       
  1940     __TRACE( KMessage, (_L("ReceiveResponse Reserve")));
       
  1941     
       
  1942     // Check protocol Src test id
       
  1943     if( aMsg->SrcTestId() != 0 )
       
  1944         {
       
  1945         __TRACE( KError, (_L("Illegal deviceid received")));
       
  1946         User::Leave( KErrGeneral );
       
  1947         }
       
  1948     
       
  1949     if( aMsg->iResult != KErrNone )
       
  1950         {
       
  1951         __TRACE( KError, (_L("Response with error %d"), aMsg->iResult ));
       
  1952         User::Leave( aMsg->iResult );
       
  1953         }
       
  1954     
       
  1955     iReceiveErrorDescription = KErrMsg;
       
  1956     iSlaveAllocateFreeMonitor->NotifySlaveAllocatedL( aMsg->SrcDevId() );
       
  1957     iReceiveErrorDescription = KNullDesC;
       
  1958     __TRACE( KMessage, (_L("Slave allocated succesfully, continue execution")));
       
  1959     }
       
  1960 
       
  1961 void CRemoteCallsProxy::ReceiveResponseReleaseL( CStifTFwIfProt* aMsg )
       
  1962     {
       
  1963     _LIT( KErrMsg, "Error during slave release respons handling");
       
  1964     __TRACE( KMessage, (_L("ReceiveResponse Release")));
       
  1965     
       
  1966     // Check protocol Src test id
       
  1967     if( aMsg->SrcTestId() != 0 )
       
  1968         {
       
  1969         __TRACE( KError, (_L("Illegal deviceid received")));
       
  1970         User::Leave( KErrGeneral );
       
  1971         }
       
  1972     
       
  1973     if( aMsg->iResult != KErrNone )
       
  1974         {
       
  1975         __TRACE( KError, (_L("Response with error %d"), aMsg->iResult ));
       
  1976         User::Leave( aMsg->iResult );
       
  1977         }
       
  1978 
       
  1979     iReceiveErrorDescription = KErrMsg;
       
  1980     iSlaveAllocateFreeMonitor->NotifySlaveFreedL( aMsg->SrcDevId() );
       
  1981     iReceiveErrorDescription = KNullDesC;
       
  1982     __TRACE( KMessage, (_L("Slave freed succesfully, continue execution")));
       
  1983     }
       
  1984 
       
  1985 void CRemoteCallsProxy::ReceiveResponseRunL( CStifTFwIfProt* aMsg )
       
  1986     {
       
  1987     _LIT( KErrMsgRun, "Error during remote sub test casse run respons handling");
       
  1988 
       
  1989     
       
  1990     TPtrC tmp = CStifTFwIfProt::RunStatus( aMsg->iRunStatus ); 
       
  1991     __TRACE( KMessage, (_L("ReceiveResponse Remote Run %S"), &tmp ));
       
  1992 
       
  1993     
       
  1994     if ( iRemoteTestCasesMonitor == NULL )
       
  1995         {
       
  1996         return;
       
  1997         }
       
  1998     
       
  1999     switch( aMsg->iRunStatus )
       
  2000         {
       
  2001         case CStifTFwIfProt::ERunStarted:
       
  2002             {
       
  2003             iReceiveErrorDescription = KErrMsgRun;
       
  2004             iRemoteTestCasesMonitor->NotifyTestCaseStartedL( aMsg->SrcDevId(), aMsg->SrcTestId() );
       
  2005             iReceiveErrorDescription = KNullDesC;
       
  2006             }
       
  2007             break;
       
  2008         case CStifTFwIfProt::ERunError:
       
  2009         case CStifTFwIfProt::ERunReady:
       
  2010             {
       
  2011             TFullTestResult testCaseResult;
       
  2012             switch( aMsg->iResultCategory )
       
  2013                 {
       
  2014                 case CStifTFwIfProt::EResultNormal:
       
  2015                     testCaseResult.iCaseExecutionResultType = 
       
  2016                         TFullTestResult::ECaseExecuted;
       
  2017                     testCaseResult.iTestResult.iResult = aMsg->iResult;
       
  2018                     testCaseResult.iCaseExecutionResultCode = 0;
       
  2019                     break;
       
  2020                 case CStifTFwIfProt::EResultPanic:
       
  2021                     testCaseResult.iCaseExecutionResultType = 
       
  2022                         TFullTestResult::ECasePanic;
       
  2023                     testCaseResult.iTestResult.iResult = KErrGeneral;
       
  2024                     testCaseResult.iCaseExecutionResultCode = aMsg->iResult;
       
  2025                     break;
       
  2026                 case CStifTFwIfProt::EResultException:
       
  2027                     testCaseResult.iCaseExecutionResultType = 
       
  2028                         TFullTestResult::ECaseException;
       
  2029                     testCaseResult.iTestResult.iResult = KErrGeneral;
       
  2030                     testCaseResult.iCaseExecutionResultCode = aMsg->iResult;
       
  2031                     break;
       
  2032                 case CStifTFwIfProt::EResultTimeout:
       
  2033                     testCaseResult.iCaseExecutionResultType = 
       
  2034                         TFullTestResult::ECaseTimeout;                
       
  2035                     testCaseResult.iTestResult.iResult = KErrGeneral;
       
  2036                     testCaseResult.iCaseExecutionResultCode = aMsg->iResult;
       
  2037                     break;
       
  2038                 case CStifTFwIfProt::EResultLeave:
       
  2039                     testCaseResult.iCaseExecutionResultType = 
       
  2040                         TFullTestResult::ECaseLeave;                
       
  2041                     testCaseResult.iTestResult.iResult = KErrGeneral;
       
  2042                     testCaseResult.iCaseExecutionResultCode = aMsg->iResult;
       
  2043                     break;
       
  2044                 default:
       
  2045                     User::Leave( KErrGeneral );
       
  2046                 }
       
  2047             
       
  2048             iReceiveErrorDescription = KErrMsgRun;
       
  2049             if ( aMsg->iRunStatus == CStifTFwIfProt::ERunError )
       
  2050                 {
       
  2051                 iRemoteTestCasesMonitor->NotifyTestCaseRunErrorL( aMsg->SrcDevId(), testCaseResult );
       
  2052                 }
       
  2053             else
       
  2054                 {
       
  2055                 iRemoteTestCasesMonitor->NotifyTestCaseFinishedL( aMsg->SrcDevId(), aMsg->SrcTestId(), testCaseResult );
       
  2056                 }
       
  2057             iReceiveErrorDescription = KNullDesC;
       
  2058             }
       
  2059             break;
       
  2060         default:
       
  2061             // Should never come here
       
  2062             User::Leave( KErrGeneral );    
       
  2063         }        
       
  2064     }
       
  2065 
       
  2066 void CRemoteCallsProxy::ReceiveResponseTestCtlL( CStifTFwIfProt* aMsg )
       
  2067     {
       
  2068     _LIT( KErrMsgPause, "Error during remote sub test casse pause respons handling");
       
  2069     _LIT( KErrMsgResume, "Error during remote sub test casse resume respons handling");
       
  2070     _LIT( KErrMsgCancel, "Error during remote sub test casse cancel respons handling");
       
  2071 
       
  2072     if( aMsg->iResult != KErrNone )
       
  2073         {
       
  2074         __TRACE( KError, (_L("Response with error %d"), aMsg->iResult ));
       
  2075         User::Leave( aMsg->iResult );
       
  2076         }
       
  2077         
       
  2078     switch( aMsg->iCmdType )
       
  2079         {
       
  2080         case CStifTFwIfProt::ECmdPause:
       
  2081             {
       
  2082             __TRACE( KMessage, (_L("ReceiveResponse Remote Pause")));
       
  2083             iReceiveErrorDescription = KErrMsgPause;
       
  2084             iRemoteTestCasesMonitor->NotifyTestCasePausedL( aMsg->SrcDevId(), aMsg->SrcTestId() );
       
  2085             iReceiveErrorDescription = KNullDesC;
       
  2086             }
       
  2087             break;
       
  2088         case CStifTFwIfProt::ECmdResume:
       
  2089             {
       
  2090             __TRACE( KMessage, (_L("ReceiveResponse Remote Resume")));
       
  2091             iReceiveErrorDescription = KErrMsgResume;
       
  2092             iRemoteTestCasesMonitor->NotifyTestCaseResumedL( aMsg->SrcDevId(), aMsg->SrcTestId() );
       
  2093             iReceiveErrorDescription = KNullDesC;
       
  2094             }
       
  2095             break;
       
  2096         case CStifTFwIfProt::ECmdCancel:
       
  2097             __TRACE( KMessage, (_L("ReceiveResponse Remote Cancel")));
       
  2098             iReceiveErrorDescription = KErrMsgCancel;
       
  2099             iRemoteTestCasesMonitor->NotifyTestCaseCancelledL( aMsg->SrcDevId(), aMsg->SrcTestId() );
       
  2100             iReceiveErrorDescription = KNullDesC;
       
  2101             break;
       
  2102         default:
       
  2103             // Should never come here
       
  2104             User::Leave( KErrGeneral );
       
  2105         }    
       
  2106     }
       
  2107 
       
  2108 void CRemoteCallsProxy::ReceiveResponseEventCtlL( CStifTFwIfProt* aMsg )
       
  2109     {
       
  2110     _LIT( KErrMsgRequest, "Error during remote event request respons handling");
       
  2111     _LIT( KErrMsgStateChanged, "Error during remote event state change respons handling");
       
  2112     _LIT( KErrMsgSet, "Error during remote event set respons handling");
       
  2113     _LIT( KErrMsgUnset, "Error during remote event unset respons handling");
       
  2114     _LIT( KErrMsgRelease, "Error during remote event release respons handling");
       
  2115     
       
  2116     if ( iRemoteEventsMonitor == NULL )
       
  2117         {
       
  2118         return;
       
  2119         }
       
  2120     
       
  2121     switch( aMsg->iCmdType )
       
  2122         {
       
  2123         case CStifTFwIfProt::ECmdRequest:
       
  2124             {
       
  2125             if ( ( aMsg->iEventStatus == CStifTFwIfProt::EEventSet ) || 
       
  2126                     ( aMsg->iEventStatus == CStifTFwIfProt::EEventUnset ) )
       
  2127                 {
       
  2128                 iReceiveErrorDescription = KErrMsgStateChanged;
       
  2129                 iRemoteEventsMonitor->NotifyEventStateChangedL( 
       
  2130                         aMsg->SrcDevId(),
       
  2131                         aMsg->iEventName,
       
  2132                         aMsg->iEventStatus,
       
  2133                         aMsg->iEventType,
       
  2134                         aMsg->iResult
       
  2135                         );
       
  2136                 iReceiveErrorDescription = KNullDesC;
       
  2137                 }
       
  2138             else
       
  2139                 {
       
  2140                 iReceiveErrorDescription = KErrMsgRequest;
       
  2141                 iRemoteEventsMonitor->NotifyEventRequestedL( 
       
  2142                         aMsg->SrcDevId(),
       
  2143                         aMsg->iEventName,
       
  2144                         aMsg->iEventStatus,
       
  2145                         aMsg->iEventType,
       
  2146                         aMsg->iResult
       
  2147                         );
       
  2148                 iReceiveErrorDescription = KNullDesC;
       
  2149                 }
       
  2150             }
       
  2151             break;
       
  2152         case CStifTFwIfProt::ECmdRelease:
       
  2153             {
       
  2154             iReceiveErrorDescription = KErrMsgRelease;
       
  2155             iRemoteEventsMonitor->NotifyEventReleasedL( 
       
  2156                     aMsg->SrcDevId(),
       
  2157                     aMsg->iEventName,
       
  2158                     aMsg->iResult
       
  2159                     );
       
  2160             iReceiveErrorDescription = KNullDesC;
       
  2161             }
       
  2162             break;
       
  2163         case CStifTFwIfProt::ECmdSetEvent:
       
  2164             {
       
  2165             iReceiveErrorDescription = KErrMsgSet;
       
  2166             iRemoteEventsMonitor->NotifyEventSetCompletedL( 
       
  2167                     aMsg->SrcDevId(),
       
  2168                     aMsg->iEventName,
       
  2169                     aMsg->iResult
       
  2170                     );
       
  2171             iReceiveErrorDescription = KNullDesC;
       
  2172             }
       
  2173             break;
       
  2174         case CStifTFwIfProt::ECmdUnsetEvent:
       
  2175             {
       
  2176             iReceiveErrorDescription = KErrMsgUnset;
       
  2177             iRemoteEventsMonitor->NotifyEventUnsetCompletedL( 
       
  2178                     aMsg->SrcDevId(),
       
  2179                     aMsg->iEventName,
       
  2180                     aMsg->iResult
       
  2181                     );
       
  2182             iReceiveErrorDescription = KNullDesC;
       
  2183             }
       
  2184             break;
       
  2185         default:
       
  2186             // Should never come here
       
  2187             User::Leave( KErrGeneral );
       
  2188         }
       
  2189     
       
  2190     }
       
  2191 
       
  2192 void CRemoteCallsProxy::ReceiveResponseSendReceiveL( CStifTFwIfProt* aMsg )
       
  2193     {
       
  2194     _LIT( KErrMsgStarted, "Error during remote sendreceive started respons handling");
       
  2195     _LIT( KErrMsgResult, "Error during remote sendreceive result respons handling");
       
  2196 
       
  2197     if ( iRemoteSendReceiveMonitor == NULL )
       
  2198         {
       
  2199         return;
       
  2200         }
       
  2201     
       
  2202     switch( aMsg->iRunStatus )
       
  2203         {
       
  2204         case CStifTFwIfProt::ERunStarted:
       
  2205             {
       
  2206             iReceiveErrorDescription = KErrMsgStarted;
       
  2207             iRemoteSendReceiveMonitor->NotifySendReceiveStartedL( aMsg->SrcDevId() );
       
  2208             iReceiveErrorDescription = KNullDesC;
       
  2209             break;
       
  2210             }
       
  2211         case CStifTFwIfProt::ERunError:
       
  2212         case CStifTFwIfProt::ERunReady:
       
  2213             {
       
  2214             iReceiveErrorDescription = KErrMsgResult;
       
  2215             iRemoteSendReceiveMonitor->NotifySendReceiveResultL( 
       
  2216                     aMsg->SrcDevId(),
       
  2217                     aMsg->iRunStatus,
       
  2218                     aMsg->iResult );
       
  2219             iReceiveErrorDescription = KNullDesC;
       
  2220             break;
       
  2221             }
       
  2222         default:
       
  2223             {
       
  2224             // Should never come here
       
  2225             User::Leave( KErrGeneral );    
       
  2226             }
       
  2227         }
       
  2228     }
       
  2229 
       
  2230 void CRemoteCallsProxy::ReceiveResponseSendUnknownL( CStifTFwIfProt* aMsg )
       
  2231     {
       
  2232     _LIT( KErrMsg, "Error during remote send unknown respons handling");
       
  2233 
       
  2234     if ( iRemoteSendReceiveMonitor == NULL )
       
  2235         {
       
  2236         return;
       
  2237         }
       
  2238     
       
  2239     iReceiveErrorDescription = KErrMsg;
       
  2240     iRemoteSendReceiveMonitor->NotifySendUnknownL( aMsg->SrcDevId(), aMsg->iResult );
       
  2241     iReceiveErrorDescription = KNullDesC;
       
  2242     }
       
  2243 
       
  2244 CSlave* CSlave::NewL()
       
  2245     {
       
  2246     CSlave* self = new(ELeave)CSlave;
       
  2247     CleanupStack::PushL( self );
       
  2248     self->ConstructL();
       
  2249     CleanupStack::Pop( self );
       
  2250     return self;
       
  2251     }
       
  2252 
       
  2253 CSlave::~CSlave()
       
  2254     {
       
  2255     iSubTestCases.Reset(); // CSlave does not own sub test cases objects
       
  2256     iSubTestCases.Close();
       
  2257     
       
  2258     iEvents.ResetAndDestroy();
       
  2259     iEvents.Close();
       
  2260     
       
  2261     delete iNestedASLoop;
       
  2262     iNestedASLoop = NULL;
       
  2263     
       
  2264     delete iName;
       
  2265     iName = NULL;
       
  2266     }
       
  2267 
       
  2268 CSlave::CSlave()
       
  2269     {    
       
  2270     }
       
  2271 
       
  2272 void CSlave::ConstructL()
       
  2273     {
       
  2274     iName = HBufC::NewL( 0 );
       
  2275     iNestedASLoop = new(ELeave)CActiveSchedulerWait;
       
  2276     }
       
  2277 
       
  2278 const TDesC& CSlave::GetName() const
       
  2279     {
       
  2280     return *iName;
       
  2281     }
       
  2282 
       
  2283 void CSlave::SetNameL( const TDesC& aName )
       
  2284     {
       
  2285     HBufC* tmp = aName.AllocL();
       
  2286     delete iName;
       
  2287     iName = tmp;
       
  2288     }
       
  2289 
       
  2290 TUint32 CSlave::GetMasterId() const
       
  2291     {    
       
  2292     return iMasterId;
       
  2293     }
       
  2294 
       
  2295 void CSlave::SetMasterId( TUint32 aMasterId )
       
  2296     {
       
  2297     iMasterId = aMasterId;
       
  2298     }
       
  2299 
       
  2300 TUint16 CSlave::GetSlaveId() const
       
  2301     {
       
  2302     return iSlaveId;
       
  2303     }
       
  2304 
       
  2305 TBool CSlave::HasRunningTestCases() const
       
  2306     {
       
  2307     if ( iSubTestCases.Count() > 0 )
       
  2308         {
       
  2309         return ETrue;
       
  2310         }
       
  2311     return EFalse;
       
  2312     }
       
  2313 
       
  2314 void CSlave::RegisterSubTestCaseL( CRemoteSubTestCaseRunner* aSubTestCase )
       
  2315     {
       
  2316     iSubTestCases.AppendL( aSubTestCase );
       
  2317     }
       
  2318         
       
  2319 void CSlave::UnregisterSubTestCaseL( CRemoteSubTestCaseRunner* aSubTestCase )
       
  2320     {    
       
  2321     TInt idx = iSubTestCases.Find( aSubTestCase );
       
  2322     if ( idx >= 0 )
       
  2323         {
       
  2324         iSubTestCases.Remove( idx );
       
  2325         }
       
  2326     else
       
  2327         {
       
  2328         User::Leave( KErrNotFound );
       
  2329         }
       
  2330     if ( ( !HasRunningTestCases() ) && iNestedASLoop->IsStarted() )
       
  2331         {
       
  2332         iNestedASLoop->AsyncStop();
       
  2333         }
       
  2334     }
       
  2335         
       
  2336 RPointerArray<CRemoteSubTestCaseRunner>& CSlave::GetSubTestCases()
       
  2337     {
       
  2338     return iSubTestCases;
       
  2339     }
       
  2340 
       
  2341 void CSlave::WaitForSubTestCasesL()
       
  2342     {
       
  2343     if ( iNestedASLoop->IsStarted() )
       
  2344         {
       
  2345         User::Leave( KErrInUse );
       
  2346         }
       
  2347     
       
  2348     if ( !HasRunningTestCases() )
       
  2349         {
       
  2350         return;
       
  2351         }
       
  2352     
       
  2353     iNestedASLoop->Start();
       
  2354     }
       
  2355 
       
  2356 void CSlave::CancelWaitForSubTestCases()
       
  2357     {
       
  2358     iNestedASLoop->AsyncStop();
       
  2359     }
       
  2360 
       
  2361 void CSlave::AddEventL( TEventTS* aEvent )
       
  2362     {
       
  2363     iEvents.AppendL( aEvent );
       
  2364     }
       
  2365 
       
  2366 void CSlave::RemoveEventL( TEventTS* aEvent )
       
  2367     {
       
  2368     TInt idx = iEvents.Find( aEvent );
       
  2369     if ( idx >= 0 )
       
  2370         {
       
  2371         iEvents.Remove( idx );        
       
  2372         }
       
  2373     else
       
  2374         {
       
  2375         User::Leave( KErrNotFound );
       
  2376         }    
       
  2377     }
       
  2378 
       
  2379 TEventTS* CSlave::GetEvent( const TDesC& aName )
       
  2380     {
       
  2381     for ( TInt i = 0; i < iEvents.Count(); i++ )
       
  2382         {
       
  2383         if ( iEvents[ i ]->Name() == aName )
       
  2384             {
       
  2385             return iEvents[ i ];
       
  2386             }
       
  2387         }
       
  2388     
       
  2389     return NULL;
       
  2390     }
       
  2391 
       
  2392 RPointerArray<TEventTS>& CSlave::GetEvents()
       
  2393     {
       
  2394     return iEvents;
       
  2395     }
       
  2396 
       
  2397 #ifdef LOGGER
       
  2398 #undef LOGGER
       
  2399 #endif
       
  2400 
       
  2401 #define LOGGER iTestRunner->GetLogger()
       
  2402 
       
  2403 void CSlave::SetSlaveId( TUint16 aSlaveId )
       
  2404     {
       
  2405     iSlaveId = aSlaveId;
       
  2406     }
       
  2407 
       
  2408 CSlavesManager* CSlavesManager::NewL( CTestRunner* aTestRunner, CTestModuleIf& aTestModuleIf )
       
  2409     {
       
  2410     CSlavesManager* self = new(ELeave)CSlavesManager( aTestRunner, aTestModuleIf );
       
  2411     CleanupStack::PushL( self );
       
  2412     self->ConstructL();
       
  2413     CleanupStack::Pop( self );
       
  2414     return self;
       
  2415     }
       
  2416 
       
  2417 CSlavesManager::~CSlavesManager()
       
  2418     {
       
  2419     Cancel();
       
  2420     iOperationTimeoutTimer.Close();
       
  2421 
       
  2422     iRemoteCallsProxy->Cancel();
       
  2423     
       
  2424     delete iSlaveForAllocate;
       
  2425     iSlaveForAllocate = NULL;
       
  2426     
       
  2427     iSlaves.ResetAndDestroy();
       
  2428     iSlaves.Close();
       
  2429     
       
  2430     delete iNestedASLoop;
       
  2431     iNestedASLoop = NULL;
       
  2432     
       
  2433     delete iRemoteCallsProxy;
       
  2434     iRemoteCallsProxy = NULL;
       
  2435     }
       
  2436 
       
  2437 CSlavesManager::CSlavesManager( CTestRunner* aTestRunner, CTestModuleIf& aTestModuleIf )
       
  2438 :CActive( EPriorityNormal ), iTestRunner( aTestRunner ), 
       
  2439  iTestModuleIf( aTestModuleIf ), iOperationTimeout( 30000000 )
       
  2440     {
       
  2441     CActiveScheduler::Add( this );
       
  2442     }
       
  2443 
       
  2444 void CSlavesManager::ConstructL()
       
  2445     {
       
  2446     iOperationTimeoutTimer.CreateLocal();
       
  2447     iRemoteCallsProxy = CRemoteCallsProxy::NewL( iTestModuleIf, LOGGER );
       
  2448     iNestedASLoop = new(ELeave)CActiveSchedulerWait;
       
  2449     
       
  2450     iRemoteCallsProxy->SetReceiveErrorHandler( this );
       
  2451     iRemoteCallsProxy->SetSlaveAllocateFreeMonitor( this );
       
  2452     iRemoteCallsProxy->SetRemoteTestCasesMonitor( this );
       
  2453     iRemoteCallsProxy->SetRemoteEventsMonitor( this );
       
  2454     iRemoteCallsProxy->SetRemoteSendReceiveMonitor( this );
       
  2455     }
       
  2456 
       
  2457 void CSlavesManager::SlaveAllocateL( const TDesC& aName, const TDesC& aType )
       
  2458     {
       
  2459     if ( iOperation != ESMOIdle )
       
  2460         {
       
  2461         User::Leave( KErrInUse );
       
  2462         }
       
  2463     if ( GetSlave( aName ) != NULL )
       
  2464         {
       
  2465         User::Leave( KErrAlreadyExists );
       
  2466         }
       
  2467     
       
  2468     delete iSlaveForAllocate;
       
  2469     iSlaveForAllocate = NULL;
       
  2470     
       
  2471     CSlave* slaveForAllocate = CSlave::NewL();
       
  2472     CleanupStack::PushL( slaveForAllocate );
       
  2473     slaveForAllocate->SetNameL( aName );
       
  2474     slaveForAllocate->SetMasterId( KRemoteProtocolMasterId );
       
  2475 
       
  2476     iRemoteCallsProxy->AllocateL( KRemoteProtocolMasterId, aType );    
       
  2477     CleanupStack::Pop( slaveForAllocate );
       
  2478     iSlaveForAllocate = slaveForAllocate;    
       
  2479     iOperation = ESMOSlaveAllocate;
       
  2480     iLastOperationResult = KErrNone;
       
  2481     
       
  2482     iOperationTimeoutTimer.After( iStatus, iOperationTimeout );
       
  2483     SetActive();
       
  2484     iNestedASLoop->Start();
       
  2485     
       
  2486     User::LeaveIfError( iLastOperationResult );
       
  2487     }
       
  2488 
       
  2489 void CSlavesManager::SlaveFreeL( const TDesC& aName )
       
  2490     {
       
  2491     if ( iOperation != ESMOIdle )
       
  2492         {
       
  2493         User::Leave( KErrInUse );
       
  2494         }
       
  2495     CSlave* slave = GetSlave( aName );
       
  2496     
       
  2497     if ( slave == NULL )
       
  2498         {
       
  2499         User::Leave( KErrNotFound );
       
  2500         }
       
  2501 
       
  2502     if ( slave->HasRunningTestCases() )
       
  2503         {
       
  2504     
       
  2505         }
       
  2506     
       
  2507     iSlaves.Remove( iSlaves.Find( slave ) );
       
  2508     
       
  2509     TUint32 masterId = slave->GetMasterId();
       
  2510     TUint16 slaveId = slave->GetSlaveId();
       
  2511 
       
  2512     delete slave;
       
  2513 
       
  2514     iRemoteCallsProxy->FreeL( masterId, slaveId );        
       
  2515     iOperation = ESMOSlaveFree;
       
  2516     iLastOperationResult = KErrNone;
       
  2517     
       
  2518     iOperationTimeoutTimer.After( iStatus, iOperationTimeout );
       
  2519     SetActive();
       
  2520     iNestedASLoop->Start();
       
  2521     
       
  2522     User::LeaveIfError( iLastOperationResult );
       
  2523     }
       
  2524 
       
  2525 void CSlavesManager::SendReceiveL( CSlave* aSlave, const TDesC& aMessage )
       
  2526     {
       
  2527     if ( iOperation != ESMOIdle )
       
  2528         {
       
  2529         User::Leave( KErrInUse );
       
  2530         }
       
  2531     
       
  2532     iRemoteCallsProxy->SendReceiveL( aSlave->GetMasterId(), 
       
  2533             aSlave->GetSlaveId(), aMessage );    
       
  2534     iOperation = ESMOSendReceiveWaitForStarted;
       
  2535     
       
  2536     iOperationTimeoutTimer.After( iStatus, iOperationTimeout );
       
  2537     SetActive();
       
  2538     iNestedASLoop->Start();
       
  2539     
       
  2540     User::LeaveIfError( iLastOperationResult );    
       
  2541     }
       
  2542 
       
  2543 void CSlavesManager::SendUnknownL( CSlave* aSlave, const TDesC& aCommand, const TDesC& aMessage )
       
  2544     {
       
  2545     if ( iOperation != ESMOIdle )
       
  2546         {
       
  2547         User::Leave( KErrInUse );
       
  2548         }
       
  2549     
       
  2550     iRemoteCallsProxy->SendUnknownL( aSlave->GetMasterId(), 
       
  2551             aSlave->GetSlaveId(), aCommand, aMessage );    
       
  2552     iOperation = ESMOSendUnknown;
       
  2553     
       
  2554     iOperationTimeoutTimer.After( iStatus, iOperationTimeout );
       
  2555     SetActive();
       
  2556     iNestedASLoop->Start();
       
  2557     
       
  2558     User::LeaveIfError( iLastOperationResult );  
       
  2559     }
       
  2560 
       
  2561 CSlave* CSlavesManager::GetSlave( const TDesC& aName )
       
  2562     {
       
  2563     for ( TInt i = 0; i < iSlaves.Count(); i++ )
       
  2564         {
       
  2565         if ( iSlaves[ i ]->GetName() == aName )
       
  2566             {
       
  2567             return iSlaves[ i ];
       
  2568             }
       
  2569         }
       
  2570     return NULL;
       
  2571     }
       
  2572 
       
  2573 CSlave* CSlavesManager::GetSlave( TUint16 aSlaveId )
       
  2574     {
       
  2575     for ( TInt i = 0; i < iSlaves.Count(); i++ )
       
  2576         {
       
  2577         if ( iSlaves[ i ]->GetSlaveId() == aSlaveId )
       
  2578             {
       
  2579             return iSlaves[ i ];
       
  2580             }
       
  2581         }
       
  2582     return NULL;
       
  2583     }
       
  2584 
       
  2585 RPointerArray<CSlave>& CSlavesManager::GetSlaves()
       
  2586     {
       
  2587     return iSlaves;
       
  2588     }
       
  2589 
       
  2590 CRemoteCallsProxy* CSlavesManager::GetRemoteCallsProxy()
       
  2591     {
       
  2592     return iRemoteCallsProxy;
       
  2593     }
       
  2594 
       
  2595 void CSlavesManager::EventRequestL( CSlave* aSlave, TEventTS* aEvent )
       
  2596     {
       
  2597     if ( iOperation != ESMOIdle )
       
  2598         {
       
  2599         User::Leave( KErrInUse );
       
  2600         }
       
  2601     
       
  2602     iEventForRequest = aEvent;
       
  2603     
       
  2604     iRemoteCallsProxy->RequestEventL( aSlave->GetMasterId(),
       
  2605             aSlave->GetSlaveId(), iEventForRequest->Name() );    
       
  2606     iOperation = ESMOEventRequest;
       
  2607     iLastOperationResult = KErrNone;
       
  2608     
       
  2609     iOperationTimeoutTimer.After( iStatus, iOperationTimeout );
       
  2610     SetActive();
       
  2611     iNestedASLoop->Start();
       
  2612     
       
  2613     iEventForRequest = NULL;
       
  2614     
       
  2615     User::LeaveIfError( iLastOperationResult );
       
  2616     }
       
  2617 
       
  2618 void CSlavesManager::EventReleaseL( CSlave* aSlave, const TDesC& aEventName )
       
  2619     {
       
  2620     if ( iOperation != ESMOIdle )
       
  2621         {
       
  2622         User::Leave( KErrInUse );
       
  2623         }
       
  2624     
       
  2625     iRemoteCallsProxy->ReleaseEventL( aSlave->GetMasterId(),
       
  2626             aSlave->GetSlaveId(), aEventName );    
       
  2627     iOperation = ESMOEventRelease;
       
  2628     
       
  2629     iOperationTimeoutTimer.After( iStatus, iOperationTimeout );
       
  2630     SetActive();
       
  2631     iNestedASLoop->Start();
       
  2632     
       
  2633     User::LeaveIfError( iLastOperationResult );
       
  2634     }
       
  2635 
       
  2636 void CSlavesManager::EventSetL( CSlave* aSlave, const TDesC& aEventName, TEventIf::TEventType aEventType )
       
  2637     {
       
  2638     if ( iOperation != ESMOIdle )
       
  2639         {
       
  2640         User::Leave( KErrInUse );
       
  2641         }
       
  2642     
       
  2643     iRemoteCallsProxy->SetEventL( aSlave->GetMasterId(),
       
  2644             aSlave->GetSlaveId(), aEventName, aEventType );    
       
  2645     iOperation = ESMOEventSet;
       
  2646     
       
  2647     iOperationTimeoutTimer.After( iStatus, iOperationTimeout );
       
  2648     SetActive();
       
  2649     iNestedASLoop->Start();
       
  2650     
       
  2651     User::LeaveIfError( iLastOperationResult );
       
  2652     }
       
  2653 
       
  2654 void CSlavesManager::EventUnsetL( CSlave* aSlave, const TDesC& aEventName )
       
  2655     {
       
  2656     if ( iOperation != ESMOIdle )
       
  2657         {
       
  2658         User::Leave( KErrInUse );
       
  2659         }
       
  2660     
       
  2661     iRemoteCallsProxy->UnsetEventL( aSlave->GetMasterId(), 
       
  2662             aSlave->GetSlaveId(), aEventName );    
       
  2663     iOperation = ESMOEventUnset;
       
  2664     
       
  2665     iOperationTimeoutTimer.After( iStatus, iOperationTimeout );
       
  2666     SetActive();
       
  2667     iNestedASLoop->Start();
       
  2668     
       
  2669     User::LeaveIfError( iLastOperationResult );
       
  2670     }
       
  2671 
       
  2672 void CSlavesManager::NotifySlaveAllocatedL( TUint16 aSlaveId )
       
  2673     {
       
  2674     Cancel(); // Stop operation timeout monitor
       
  2675 
       
  2676     if( iOperation != ESMOSlaveAllocate )
       
  2677         {        
       
  2678         iLastOperationResult = KErrNotReady;
       
  2679         delete iSlaveForAllocate;
       
  2680         iSlaveForAllocate = NULL;
       
  2681         User::Leave( KErrNotReady );
       
  2682         }
       
  2683     else
       
  2684         {
       
  2685         iSlaveForAllocate->SetSlaveId( aSlaveId );
       
  2686         iSlaves.AppendL( iSlaveForAllocate );
       
  2687         iSlaveForAllocate = NULL;
       
  2688         iLastOperationResult = KErrNone;
       
  2689         }
       
  2690 
       
  2691     iOperation = ESMOIdle;
       
  2692     iNestedASLoop->AsyncStop();
       
  2693     }
       
  2694 
       
  2695 void CSlavesManager::NotifySlaveFreedL( TUint16 /*aSlaveId*/ )
       
  2696     {
       
  2697     Cancel(); // Stop operation timeout monitor
       
  2698 
       
  2699     if( iOperation != ESMOSlaveFree )
       
  2700         {
       
  2701         User::Leave( KErrNotReady );
       
  2702         }
       
  2703 
       
  2704     iLastOperationResult = KErrNone;
       
  2705     
       
  2706     iOperation = ESMOIdle;
       
  2707     iNestedASLoop->AsyncStop();
       
  2708     }
       
  2709 
       
  2710 void CSlavesManager::NotifyTestCaseStartedL( TUint16 aSlaveId, TUint16 aSlaveTestId )
       
  2711     {
       
  2712     for ( TInt i = 0; i < iSlaves.Count(); i++ )
       
  2713         {
       
  2714         if ( iSlaves[ i ]->GetSlaveId() == aSlaveId )
       
  2715             {
       
  2716             RPointerArray<CRemoteSubTestCaseRunner>& remoteTestCases = 
       
  2717                     iSlaves[ i ]->GetSubTestCases();
       
  2718             for ( TInt k = 0; k < remoteTestCases.Count(); k++ )
       
  2719                 {
       
  2720                 if ( remoteTestCases[ k ]->IsRunSubTestCaseRequestOngoing() )
       
  2721                     {
       
  2722                     remoteTestCases[ k ]->NotifyTestCaseStartedL( aSlaveTestId );
       
  2723                     // There should be only one test case which waits for 
       
  2724                     // run test case request response
       
  2725                     return;
       
  2726                     }
       
  2727                 }        
       
  2728             }
       
  2729         }
       
  2730     
       
  2731     // There is no test case which waits for run request response
       
  2732     User::Leave( KErrNotFound );
       
  2733     }
       
  2734 
       
  2735 void CSlavesManager::NotifyTestCaseRunErrorL( TUint16 aSlaveId, const TFullTestResult& aTestCaseResult )
       
  2736     {
       
  2737     for ( TInt i = 0; i < iSlaves.Count(); i++ )
       
  2738         {
       
  2739         if ( iSlaves[ i ]->GetSlaveId() == aSlaveId )
       
  2740             {
       
  2741             RPointerArray<CRemoteSubTestCaseRunner>& remoteTestCases = 
       
  2742                     iSlaves[ i ]->GetSubTestCases();
       
  2743             for ( TInt k = 0; k < remoteTestCases.Count(); k++ )
       
  2744                 {
       
  2745                 if ( remoteTestCases[ k ]->IsRunSubTestCaseRequestOngoing() )
       
  2746                     {
       
  2747                     remoteTestCases[ k ]->NotifyTestCaseRunError( aTestCaseResult );
       
  2748                     // There should be only one test case which waits for 
       
  2749                     // run test case request response
       
  2750                     return;
       
  2751                     }
       
  2752                 }        
       
  2753             }
       
  2754         }
       
  2755     
       
  2756     // There is no test case which waits for run request response
       
  2757     User::Leave( KErrNotFound );
       
  2758     }
       
  2759 
       
  2760 void CSlavesManager::NotifyTestCaseFinishedL( TUint16 aSlaveId, TUint16 aSlaveTestId, const TFullTestResult& aTestCaseResult )
       
  2761     {
       
  2762     for ( TInt i = 0; i < iSlaves.Count(); i++ )
       
  2763         {
       
  2764         if ( iSlaves[ i ]->GetSlaveId() == aSlaveId )
       
  2765             {
       
  2766             RPointerArray<CRemoteSubTestCaseRunner>& remoteTestCases = 
       
  2767                     iSlaves[ i ]->GetSubTestCases();
       
  2768             for ( TInt k = 0; k < remoteTestCases.Count(); k++ )
       
  2769                 {
       
  2770                 if ( remoteTestCases[ k ]->GetTestCaseId() == aSlaveTestId )
       
  2771                     {
       
  2772                     remoteTestCases[ k ]->NotifyTestCaseFinishedL( aTestCaseResult );
       
  2773                     // There should be only one test case which waits for 
       
  2774                     // run test case request response
       
  2775                     return;
       
  2776                     }
       
  2777                 }        
       
  2778             }
       
  2779         }
       
  2780     // There is no test case which waits for run request response
       
  2781     User::Leave( KErrNotFound );
       
  2782     }
       
  2783 
       
  2784 void CSlavesManager::NotifyTestCasePausedL( TUint16 aSlaveId, TUint16 aSlaveTestId )
       
  2785     {    
       
  2786     for ( TInt i = 0; i < iSlaves.Count(); i++ )
       
  2787         {
       
  2788         if ( iSlaves[ i ]->GetSlaveId() == aSlaveId )
       
  2789             {
       
  2790             RPointerArray<CRemoteSubTestCaseRunner>& remoteTestCases = 
       
  2791                     iSlaves[ i ]->GetSubTestCases();
       
  2792             for ( TInt k = 0; k < remoteTestCases.Count(); k++ )
       
  2793                 {
       
  2794                 if ( remoteTestCases[ k ]->GetTestCaseId() == aSlaveTestId )
       
  2795                     {
       
  2796                     remoteTestCases[ k ]->NotifyTestCasePausedL();
       
  2797                     // There should be only one test case which waits for 
       
  2798                     // run test case request response
       
  2799                     return;
       
  2800                     }
       
  2801                 }        
       
  2802             }
       
  2803         }
       
  2804     // There is no test case which waits for run request response
       
  2805     User::Leave( KErrNotFound );
       
  2806     }
       
  2807 
       
  2808 void CSlavesManager::NotifyTestCaseResumedL( TUint16 aSlaveId, TUint16 aSlaveTestId )
       
  2809     {    
       
  2810     for ( TInt i = 0; i < iSlaves.Count(); i++ )
       
  2811         {
       
  2812         if ( iSlaves[ i ]->GetSlaveId() == aSlaveId )
       
  2813             {
       
  2814             RPointerArray<CRemoteSubTestCaseRunner>& remoteTestCases = 
       
  2815                     iSlaves[ i ]->GetSubTestCases();
       
  2816             for ( TInt k = 0; k < remoteTestCases.Count(); k++ )
       
  2817                 {
       
  2818                 if ( remoteTestCases[ k ]->GetTestCaseId() == aSlaveTestId )
       
  2819                     {
       
  2820                     remoteTestCases[ k ]->NotifyTestCaseResumedL();
       
  2821                     // There should be only one test case which waits for 
       
  2822                     // run test case request response
       
  2823                     return;
       
  2824                     }
       
  2825                 }        
       
  2826             }
       
  2827         }
       
  2828     // There is no test case which waits for run request response
       
  2829     User::Leave( KErrNotFound );
       
  2830     }
       
  2831 
       
  2832 void CSlavesManager::NotifyTestCaseCancelledL( TUint16 aSlaveId, TUint16 aSlaveTestId )
       
  2833     {    
       
  2834     for ( TInt i = 0; i < iSlaves.Count(); i++ )
       
  2835         {
       
  2836         if ( iSlaves[ i ]->GetSlaveId() == aSlaveId )
       
  2837             {
       
  2838             RPointerArray<CRemoteSubTestCaseRunner>& remoteTestCases = 
       
  2839                     iSlaves[ i ]->GetSubTestCases();
       
  2840             for ( TInt k = 0; k < remoteTestCases.Count(); k++ )
       
  2841                 {
       
  2842                 if ( remoteTestCases[ k ]->GetTestCaseId() == aSlaveTestId )
       
  2843                     {
       
  2844                     remoteTestCases[ k ]->NotifyTestCaseCancelledL();
       
  2845                     // There should be only one test case which waits for 
       
  2846                     // run test case request response
       
  2847                     return;
       
  2848                     }
       
  2849                 }        
       
  2850             }
       
  2851         }
       
  2852     // There is no test case which waits for run request response
       
  2853     User::Leave( KErrNotFound );
       
  2854     }
       
  2855 
       
  2856 void CSlavesManager::NotifyEventRequestedL( TUint16 /*aSlaveId*/, 
       
  2857         const TDesC& aEventName, 
       
  2858         CStifTFwIfProt::TEventStatus aEventStatus,
       
  2859         TEventIf::TEventType /*aEventType*/,
       
  2860         TInt aResult )
       
  2861     {
       
  2862     if ( iOperation != ESMOEventRequest )
       
  2863         {
       
  2864         User::Leave( KErrNotReady );
       
  2865         }
       
  2866     
       
  2867     Cancel(); // Stop operation timeout monitor    
       
  2868     
       
  2869     iLastOperationResult = KErrNone;
       
  2870     switch( aEventStatus )
       
  2871         {
       
  2872         case CStifTFwIfProt::EEventActive:
       
  2873             __TRACE( KMessage, (_L("Event %S active"), &aEventName ));
       
  2874             break;
       
  2875         case CStifTFwIfProt::EEventError:
       
  2876             __TRACE( KMessage, (_L("Event %S error %d"), &aEventName, aResult ));
       
  2877             iLastOperationResult = aResult;
       
  2878             break;
       
  2879         default:
       
  2880             User::Leave( KErrGeneral );
       
  2881         }    
       
  2882     
       
  2883     iOperation = ESMOIdle;
       
  2884     iNestedASLoop->AsyncStop();
       
  2885     }
       
  2886 
       
  2887 void CSlavesManager::NotifyEventStateChangedL( TUint16 aSlaveId, 
       
  2888         const TDesC& aEventName, 
       
  2889         CStifTFwIfProt::TEventStatus aEventStatus,
       
  2890         TEventIf::TEventType aEventType,
       
  2891         TInt aResult )
       
  2892     {
       
  2893     switch( aEventStatus )
       
  2894         {
       
  2895         case CStifTFwIfProt::EEventSet:
       
  2896             {
       
  2897             __TRACE( KMessage, (_L("Event %S set"), &aEventName ));
       
  2898             // Set event            
       
  2899             CSlave* slave = GetSlave( aSlaveId );
       
  2900             if ( slave != NULL )
       
  2901                 {
       
  2902                 TEventTS* event = slave->GetEvent( aEventName );
       
  2903                 if ( event != NULL )
       
  2904                     {
       
  2905                     event->SetEvent( aEventType );
       
  2906                     }                
       
  2907                 else
       
  2908                     {
       
  2909                     User::Leave( KErrNotFound );
       
  2910                     }
       
  2911                 }
       
  2912             else
       
  2913                 {
       
  2914                 User::Leave( KErrNotFound );
       
  2915                 }
       
  2916             }
       
  2917             break;
       
  2918         case CStifTFwIfProt::EEventUnset:
       
  2919             {
       
  2920             __TRACE( KMessage, (_L("Event %S set"), &aEventName ));
       
  2921             // Set event            
       
  2922             CSlave* slave = GetSlave( aSlaveId );
       
  2923             if ( slave != NULL )
       
  2924                 {
       
  2925                 TEventTS* event = slave->GetEvent( aEventName );
       
  2926                 if ( event != NULL )
       
  2927                     {
       
  2928                     event->SetType( TEventIf::EUnsetEvent );
       
  2929                     }                
       
  2930                 else
       
  2931                     {
       
  2932                     User::Leave( KErrNotFound );
       
  2933                     }
       
  2934                 }
       
  2935             else
       
  2936                 {
       
  2937                 User::Leave( KErrNotFound );
       
  2938                 }
       
  2939             }
       
  2940             break;
       
  2941         case CStifTFwIfProt::EEventError:
       
  2942             {
       
  2943             __TRACE( KMessage, (_L("Event %S error %d"), &aEventName, aResult ));
       
  2944             User::Leave( aResult );
       
  2945             }
       
  2946             break;
       
  2947         default:
       
  2948             {
       
  2949             User::Leave( KErrGeneral );
       
  2950             }
       
  2951         }
       
  2952     }
       
  2953 
       
  2954 void CSlavesManager::NotifyEventReleasedL( TUint16 /*aSlaveId*/, 
       
  2955         const TDesC& /*aEventName*/, TInt aResult )
       
  2956     {
       
  2957     if ( iOperation != ESMOEventRelease )
       
  2958         {
       
  2959         User::Leave( KErrNotReady );
       
  2960         }
       
  2961     
       
  2962     Cancel(); // Stop operation timeout monitor
       
  2963     
       
  2964     iOperation = ESMOIdle;
       
  2965     iLastOperationResult = aResult;
       
  2966     iNestedASLoop->AsyncStop();
       
  2967     }
       
  2968 
       
  2969 void CSlavesManager::NotifyEventSetCompletedL( TUint16 /*aSlaveId*/, 
       
  2970         const TDesC& /*aEventName*/, TInt aResult )       
       
  2971     {
       
  2972     if ( iOperation != ESMOEventSet )
       
  2973         {
       
  2974         User::Leave( KErrNotReady );
       
  2975         }
       
  2976     
       
  2977     Cancel(); // Stop operation timeout monitor
       
  2978     
       
  2979     iOperation = ESMOIdle;
       
  2980     iLastOperationResult = aResult;
       
  2981     iNestedASLoop->AsyncStop();
       
  2982     }
       
  2983 
       
  2984 void CSlavesManager::NotifyEventUnsetCompletedL( TUint16 /*aSlaveId*/, 
       
  2985         const TDesC& /*aEventName*/, TInt aResult )        
       
  2986     {
       
  2987     if ( iOperation != ESMOEventUnset )
       
  2988         {
       
  2989         User::Leave( KErrNotReady );
       
  2990         }
       
  2991     
       
  2992     Cancel(); // Stop operation timeout monitor
       
  2993     
       
  2994     iOperation = ESMOIdle;
       
  2995     iLastOperationResult = aResult;
       
  2996     iNestedASLoop->AsyncStop();
       
  2997     }
       
  2998 
       
  2999 
       
  3000 void CSlavesManager::NotifySendReceiveStartedL( TUint16 /*aSlaveId*/ )
       
  3001     {
       
  3002     if ( iOperation != ESMOSendReceiveWaitForStarted )
       
  3003         {
       
  3004         User::Leave( KErrNotReady );
       
  3005         }
       
  3006     
       
  3007     Cancel(); // Stop operation timeout monitor
       
  3008     
       
  3009     iOperation = ESMOSendReceiveWaitForReady;
       
  3010     }
       
  3011 
       
  3012 void CSlavesManager::NotifySendReceiveResultL( 
       
  3013         TUint16 /*aSlaveId*/, 
       
  3014         CStifTFwIfProt::TRunStatus /*aRunStatus*/,
       
  3015         TInt aRunResult )
       
  3016     {
       
  3017     if ( ( iOperation != ESMOSendReceiveWaitForStarted ) &&
       
  3018             ( iOperation != ESMOSendReceiveWaitForReady ) )
       
  3019         {
       
  3020         User::Leave( KErrNotReady );
       
  3021         }
       
  3022     
       
  3023     iLastOperationResult = aRunResult;
       
  3024     
       
  3025     if ( iOperation == ESMOSendReceiveWaitForStarted )
       
  3026         {
       
  3027         Cancel(); // Stop operation timeout monitor
       
  3028         }
       
  3029     
       
  3030     iOperation = ESMOIdle;
       
  3031     iNestedASLoop->AsyncStop();
       
  3032     }
       
  3033 
       
  3034 void CSlavesManager::NotifySendUnknownL( TUint16 aSlaveId, TInt aResult )
       
  3035     {
       
  3036     if ( iOperation != ESMOSendUnknown )
       
  3037         {
       
  3038         User::Leave( KErrNotReady );
       
  3039         }
       
  3040     
       
  3041     Cancel(); // Stop operation timeout monitor
       
  3042     
       
  3043     CSlave* slave = GetSlave( aSlaveId );
       
  3044     if( slave == NULL )
       
  3045         {
       
  3046         User::Leave( KErrNotFound );
       
  3047         }
       
  3048     
       
  3049     iOperation = ESMOIdle;
       
  3050     iLastOperationResult = aResult; 
       
  3051     iNestedASLoop->AsyncStop();    
       
  3052     }
       
  3053 
       
  3054 void CSlavesManager::HandleRemoteReceiveError( TInt aError, const TDesC& aErrorDescription )
       
  3055     {
       
  3056     iTestRunner->HandleRemoteReceiveError( aError, aErrorDescription );
       
  3057     }
       
  3058 
       
  3059 void CSlavesManager::RunL()
       
  3060     {
       
  3061     // Last operation timeouted
       
  3062     if ( iOperation ==  ESMOSlaveAllocate )
       
  3063         {
       
  3064         delete iSlaveForAllocate;
       
  3065         iSlaveForAllocate = NULL;
       
  3066         }
       
  3067     
       
  3068     iLastOperationResult = KErrTimedOut;
       
  3069     iOperation = ESMOIdle;
       
  3070     iNestedASLoop->AsyncStop();
       
  3071     }
       
  3072 
       
  3073 void CSlavesManager::DoCancel()
       
  3074     {
       
  3075     iOperationTimeoutTimer.Cancel();
       
  3076     }
       
  3077 
       
  3078 // EOF