videoutils_plat/videoconnutility_api/tsrc/VCXConnUtilTestExe/src/VCXConnUtilTestExeTester.cpp
branchRCL_3
changeset 23 13a33d82ad98
parent 0 822a42b6c3f1
equal deleted inserted replaced
22:826cea16efd9 23:13a33d82ad98
       
     1 /*
       
     2 * Copyright (c) 2002 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 the License "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:   ?Description*
       
    15 */
       
    16 
       
    17 
       
    18 #include <mmf/common/mmfcontrollerpluginresolver.h> // CleanupResetAndDestroyPushL
       
    19 #include <e32property.h>
       
    20 
       
    21 #include "VCXTestCommon.h"
       
    22 #include "CIptvTestTimer.h"
       
    23 #include "VCXConnUtilTestCommon.h"
       
    24 #include "VCXConnUtilTestExeTester.h"
       
    25 #include "VCXConnUtilTestSubscriber.h"
       
    26 #include "VCXConnUtilTestPSObserver.h"
       
    27 #include "VCXConnUtilTester.h"
       
    28 
       
    29 #include "VCXTestLog.h"
       
    30 
       
    31 // EXTERNAL DATA STRUCTURES
       
    32 
       
    33 // EXTERNAL FUNCTION PROTOTYPES
       
    34 
       
    35 // CONSTANTS
       
    36 
       
    37 // MACROS
       
    38 
       
    39 // LOCAL CONSTANTS AND MACROS
       
    40 
       
    41 // MODULE DATA STRUCTURES
       
    42 
       
    43 // LOCAL FUNCTION PROTOTYPES
       
    44 
       
    45 // FORWARD DECLARATIONS
       
    46 
       
    47 // ============================= LOCAL FUNCTIONS ===============================
       
    48 
       
    49 // ============================ MEMBER FUNCTIONS ===============================
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CVCXConnUtilTestExeTester::
       
    53 // C++ default constructor can NOT contain any code, that
       
    54 // might leave.
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CVCXConnUtilTestExeTester* CVCXConnUtilTestExeTester::NewL( TUint aProcessId )
       
    58     {
       
    59     VCXLOGLO1(">>>CVCXConnUtilTestExeTester::NewL");
       
    60     CVCXConnUtilTestExeTester* self = new (ELeave) CVCXConnUtilTestExeTester();
       
    61     CleanupStack::PushL(self);
       
    62     self->ConstructL( aProcessId );
       
    63     CleanupStack::Pop( self );
       
    64     VCXLOGLO1("<<<CVCXConnUtilTestExeTester::NewL");
       
    65     return self;
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CVCXConnUtilTestExeTester::~CVCXConnUtilTestExeTester
       
    70 // destructor
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 CVCXConnUtilTestExeTester::~CVCXConnUtilTestExeTester()
       
    74     {
       
    75     VCXLOGLO1(">>>CVCXConnUtilTestExeTester::~CVCXConnUtilTestExeTester");
       
    76 
       
    77     delete iGlobalShutdownSubcriber;
       
    78     iGlobalShutdownSubcriber = NULL;
       
    79 
       
    80     delete iCmdSubcriber;
       
    81     iCmdSubcriber = NULL;
       
    82 
       
    83     delete iTester;
       
    84     iTester = NULL;
       
    85 
       
    86     // Remove the P&S keys for this process.
       
    87     RProperty::Delete( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyCmd + iPSKeyBase);
       
    88     RProperty::Delete( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyCmdIntParam1 + iPSKeyBase);
       
    89     RProperty::Delete( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyCmdIntParam2 + iPSKeyBase);
       
    90     RProperty::Delete( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyCmdDescParam1 + iPSKeyBase);
       
    91     RProperty::Delete( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyResponseAck + iPSKeyBase);
       
    92     RProperty::Delete( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyResponseCmd + iPSKeyBase);
       
    93     RProperty::Delete( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyResponseParam + iPSKeyBase);
       
    94     RProperty::Delete( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyResponseError + iPSKeyBase);
       
    95 
       
    96     VCXLOGLO1("<<<CVCXConnUtilTestExeTester::~CVCXConnUtilTestExeTester");
       
    97     }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CVCXConnUtilTestExeTester::~CVCXConnUtilTestExeTester
       
   101 // destructor
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 CVCXConnUtilTestExeTester::CVCXConnUtilTestExeTester()
       
   105     {
       
   106     VCXLOGLO1(">>>CVCXConnUtilTestExeTester::CVCXConnUtilTestExeTester");
       
   107 
       
   108     VCXLOGLO1("<<<CVCXConnUtilTestExeTester::CVCXConnUtilTestExeTester");
       
   109     }
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CVCXConnUtilTestExeTester::ConstructL
       
   113 //
       
   114 // -----------------------------------------------------------------------------
       
   115 //
       
   116 void CVCXConnUtilTestExeTester::ConstructL( TUint aProcessId )
       
   117     {
       
   118     VCXLOGLO1(">>>CVCXConnUtilTestExeTester::ConstructL");
       
   119 
       
   120     iTester = CVCXConnUtilTester::NewL();
       
   121 
       
   122     // Define and listen global shutdown key.
       
   123     
       
   124     TInt err( KErrNone );
       
   125     
       
   126     err = RProperty::Define( KVCXConnUtilTestPScategory, KVCXConnUtilTestExeGlobalShutdownKey, RProperty::EInt );
       
   127     VCXLOGLO3("CVCXConnUtilTestExeTester:: Define KVCXConnUtilTestExeGlobalShutdownKey: %d, err: %d", 
       
   128             KVCXConnUtilTestExeGlobalShutdownKey, err);
       
   129 
       
   130     iGlobalShutdownSubcriber = CVCXConnUtilTestSubscriber::NewL( KVCXConnUtilTestPScategory,
       
   131             KVCXConnUtilTestExeGlobalShutdownKey, RProperty::EInt, this );
       
   132     iGlobalShutdownSubcriber->Start();
       
   133     VCXLOGLO2("CVCXConnUtilTestExeTester:: Listening P&S key KVCXConnUtilTestExeGlobalShutdownKey: %d",
       
   134             KVCXConnUtilTestExeGlobalShutdownKey);
       
   135     
       
   136     // Get PS key base.
       
   137     
       
   138     TInt testerCount( 0 );
       
   139     
       
   140     User::LeaveIfError( CVCXTestCommon::GetPSProperty( 
       
   141             KVCXConnUtilTestPScategory, KVCXConnUtilTestExeGlobalTesterCount, testerCount ) );
       
   142 
       
   143     testerCount++;
       
   144     
       
   145     iPSKeyBase = testerCount * 1000 + aProcessId;
       
   146 
       
   147     VCXLOGLO2("CVCXConnUtilTestExeTester:: iPSKeyBase: %d", iPSKeyBase);
       
   148     
       
   149     // Define private P&S keys.
       
   150     
       
   151     err = RProperty::Define( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyCmd + iPSKeyBase,
       
   152             RProperty::EInt );
       
   153     VCXLOGLO3("CVCXConnUtilTestExeTester:: Define KVCXConnUtilTestExePsKeyCmd: %d, err: %d", 
       
   154             KVCXConnUtilTestExePsKeyCmd + iPSKeyBase, err);
       
   155     
       
   156     err = RProperty::Define( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyCmdIntParam1 + iPSKeyBase,
       
   157             RProperty::EInt );
       
   158     VCXLOGLO3("CVCXConnUtilTestExeTester:: Define KVCXConnUtilTestExePsKeyCmdIntParam1: %d, err: %d", 
       
   159             KVCXConnUtilTestExePsKeyCmdIntParam1 + iPSKeyBase, err);
       
   160     
       
   161     err = RProperty::Define( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyCmdIntParam2 + iPSKeyBase,
       
   162             RProperty::EInt );
       
   163     VCXLOGLO3("CVCXConnUtilTestExeTester:: Define KVCXConnUtilTestExePsKeyCmdIntParam2: %d, err: %d", 
       
   164             KVCXConnUtilTestExePsKeyCmdIntParam2 + iPSKeyBase, err);
       
   165     
       
   166     err = RProperty::Define( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyCmdDescParam1 + iPSKeyBase,
       
   167             RProperty::EText );
       
   168     VCXLOGLO3("CVCXConnUtilTestExeTester:: Define KVCXConnUtilTestExePsKeyCmdDescParam1: %d, err: %d", 
       
   169             KVCXConnUtilTestExePsKeyCmdDescParam1 + iPSKeyBase, err);
       
   170     
       
   171     err = RProperty::Define( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyResponseAck + iPSKeyBase,
       
   172             RProperty::EInt );
       
   173     VCXLOGLO3("CVCXConnUtilTestExeTester:: Define KVCXConnUtilTestExePsKeyResponseAck: %d, err: %d", 
       
   174             KVCXConnUtilTestExePsKeyResponseAck + iPSKeyBase, err);
       
   175     
       
   176     err = RProperty::Define( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyResponseCmd + iPSKeyBase,
       
   177             RProperty::EInt );
       
   178     VCXLOGLO3("CVCXConnUtilTestExeTester:: Define KVCXConnUtilTestExePsKeyResponseCmd: %d, err: %d", 
       
   179             KVCXConnUtilTestExePsKeyResponseCmd + iPSKeyBase, err);
       
   180     
       
   181     err = RProperty::Define( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyResponseParam + iPSKeyBase,
       
   182             RProperty::EInt );
       
   183     VCXLOGLO3("CVCXConnUtilTestExeTester:: Define KVCXConnUtilTestExePsKeyResponseParam: %d, err: %d", 
       
   184             KVCXConnUtilTestExePsKeyResponseParam + iPSKeyBase, err);
       
   185     
       
   186     err = RProperty::Define( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyResponseError + iPSKeyBase,
       
   187             RProperty::EInt );
       
   188     VCXLOGLO3("CVCXConnUtilTestExeTester:: Define KVCXConnUtilTestExePsKeyResponseError: %d, err: %d", 
       
   189             KVCXConnUtilTestExePsKeyResponseError + iPSKeyBase, err);
       
   190     
       
   191     // Subscribe P&S cmd key.
       
   192 
       
   193     iCmdSubcriber = CVCXConnUtilTestSubscriber::NewL( KVCXConnUtilTestPScategory,
       
   194             KVCXConnUtilTestExePsKeyCmd + iPSKeyBase, RProperty::EInt, this );
       
   195     iCmdSubcriber->Start();
       
   196     VCXLOGLO2("CVCXConnUtilTestExeTester:: Listening P&S key KVCXConnUtilTestExePsKeyCmd: %d", 
       
   197             KVCXConnUtilTestExePsKeyCmd + iPSKeyBase);
       
   198 
       
   199     iRunning = ETrue;
       
   200 
       
   201     // And update the tester count to P&S.
       
   202     User::LeaveIfError( CVCXTestCommon::SetPSProperty( 
       
   203             KVCXConnUtilTestPScategory, KVCXConnUtilTestExeGlobalTesterCount, testerCount ) );
       
   204     
       
   205     VCXLOGLO1("<<<CVCXConnUtilTestExeTester::ConstructL");
       
   206     }
       
   207 
       
   208 // -----------------------------------------------------------------------------
       
   209 // CVCXConnUtilTestExeTester::ValueChangedL
       
   210 //
       
   211 // -----------------------------------------------------------------------------
       
   212 //
       
   213 void CVCXConnUtilTestExeTester::ValueChangedL( const TUid& aUid, const TUint32& aKey, const TInt&  aValue )
       
   214     {
       
   215     // Right now this is only category we are subscribing for.
       
   216     if( aUid != KVCXConnUtilTestPScategory )
       
   217         {
       
   218         return;
       
   219         }
       
   220 
       
   221     if( aKey == KVCXConnUtilTestExeGlobalShutdownKey )
       
   222         {
       
   223         if( aValue == 1 )
       
   224             {
       
   225             iRunning = EFalse;
       
   226             VCXLOGLO2("CVCXConnUtilTestExeTester::ValueChangedL: cmd GLOBAL SHUTDOWN (%S) ----->", &iName);
       
   227             }
       
   228         return;
       
   229         }
       
   230 
       
   231     VCXLOGLO2(">>>CVCXConnUtilTestExeTester::ValueChangedL TInt (%S)", &iName);
       
   232 
       
   233     // Store possible parameters.
       
   234     TInt intParam1(0);
       
   235     TInt intParam2(0);
       
   236     TBuf<256> descParam1;
       
   237 
       
   238     CVCXTestCommon::GetPSProperty( KVCXConnUtilTestPScategory, 
       
   239             KVCXConnUtilTestExePsKeyCmdIntParam1 + iPSKeyBase, intParam1 );
       
   240     CVCXTestCommon::GetPSProperty( KVCXConnUtilTestPScategory, 
       
   241             KVCXConnUtilTestExePsKeyCmdIntParam2 + iPSKeyBase, intParam2 );
       
   242     CVCXTestCommon::GetPSProperty( KVCXConnUtilTestPScategory, 
       
   243             KVCXConnUtilTestExePsKeyCmdDescParam1 + iPSKeyBase, descParam1 );
       
   244 
       
   245     // Set response that cmd has been gotten.
       
   246 
       
   247     VCXLOGLO2("CVCXConnUtilTestExeTester:: Setting KVCXConnUtilTestExePsKeyResponseAck (%S) ----->", &iName);
       
   248     CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, 
       
   249             KVCXConnUtilTestExePsKeyResponseAck + iPSKeyBase, iAckCount++ );
       
   250 
       
   251     // Handle commands.
       
   252     if( aKey == KVCXConnUtilTestExePsKeyCmd + iPSKeyBase )
       
   253         {
       
   254         switch( aValue )
       
   255             {
       
   256             case EVcxConnUtilCommandShutdown:
       
   257                 {
       
   258                 VCXLOGLO2("CVCXConnUtilTestExeTester:: cmd EVcxConnUtilCommandShutdown (%S) ----->", &iName);
       
   259                 iRunning = EFalse;
       
   260                 }
       
   261                 break;
       
   262 
       
   263             case EVcxConnUtilCommandSetName:
       
   264                 {
       
   265                 iName.Copy( descParam1 );
       
   266                 iTester->iName.Copy( descParam1 );
       
   267                 VCXLOGLO2("CVCXConnUtilTestExeTester:: cmd EVcxConnUtilCommandSetName (%S) ----->", &iName);
       
   268                 }
       
   269                 break;
       
   270 
       
   271             case EVcxConnUtilCommandGetIap:
       
   272                 {
       
   273                 VCXLOGLO2("CVCXConnUtilTestExeTester:: cmd EVcxConnUtilCommandGetIap (%S) ----->", &iName);
       
   274 
       
   275                 TUint32 iapId(0);
       
   276                 TBool silent = static_cast<TBool>( intParam1);
       
   277                 TBool isTimed = static_cast<TBool>( intParam2 );
       
   278 
       
   279                 TInt err = iTester->GetIap( iapId, silent, isTimed );
       
   280 
       
   281                 if( err != KErrNone || iapId == 0 )
       
   282                     {
       
   283                     VCXLOGLO4("CVCXConnUtilTestExeTester:: GetIap error: %d, iap: %d (%S)", err, iapId, &iName);
       
   284                     }
       
   285 
       
   286                 VCXLOGLO2("CVCXConnUtilTestExeTester:: Setting response for EVcxConnUtilCommandGetIap (%S) ----->", 
       
   287                         &iName);
       
   288                 CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory,
       
   289                         KVCXConnUtilTestExePsKeyResponseParam + iPSKeyBase, iapId );
       
   290                 CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory,
       
   291                         KVCXConnUtilTestExePsKeyResponseError + iPSKeyBase, err );
       
   292                 CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory,
       
   293                         KVCXConnUtilTestExePsKeyResponseCmd + iPSKeyBase, EVcxConnUtilCommandGetIap );
       
   294 
       
   295                 }
       
   296                 break;
       
   297                 
       
   298                 
       
   299             case EVcxConnUtilCommandGetWapIdForIap:
       
   300                 {
       
   301                 VCXLOGLO2("CVCXConnUtilTestExeTester:: cmd EVcxConnUtilCommandGetWapIdForIap (%S) ----->", &iName);
       
   302 
       
   303                 TInt err( KErrNone );
       
   304                 
       
   305                 TUint32 wapId( 0 );
       
   306                 TRAP( err, iTester->WapIdFromIapIdL( intParam1 ) );
       
   307 
       
   308                 VCXLOGLO4("CVCXConnUtilTestExeTester:: GetWapIdFromIapIdL returned wapId: %d, err: %d (%S)", wapId, err, &iName);
       
   309 
       
   310                 VCXLOGLO2("CVCXConnUtilTestExeTester:: Setting response for EVcxConnUtilCommandGetWapIdForIap (%S) ----->", 
       
   311                         &iName);
       
   312                 CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory,
       
   313                         KVCXConnUtilTestExePsKeyResponseParam + iPSKeyBase, wapId );
       
   314                 CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory,
       
   315                         KVCXConnUtilTestExePsKeyResponseError + iPSKeyBase, err );
       
   316                 CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory,
       
   317                         KVCXConnUtilTestExePsKeyResponseCmd + iPSKeyBase, EVcxConnUtilCommandGetWapIdForIap );
       
   318 
       
   319                 }
       
   320                 break;
       
   321 
       
   322             case EVcxConnUtilCommandDisconnect:
       
   323                 {
       
   324                 VCXLOGLO2("CVCXConnUtilTestExeTester:: cmd EVcxConnUtilCommandDisconnect (%S) ----->", &iName);
       
   325 
       
   326                 TInt err = iTester->Disconnect();
       
   327 
       
   328                 if( err != KErrNone )
       
   329                     {
       
   330                     VCXLOGLO3("CVCXConnUtilTestExeTester:: disconnect error: %d (%S)", err, &iName);
       
   331                     }
       
   332 
       
   333                 VCXLOGLO2("CVCXConnUtilTestExeTester:: Setting response for EVcxConnUtilCommandDisconnect (%S) ----->", 
       
   334                         &iName);
       
   335                 CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory,
       
   336                         KVCXConnUtilTestExePsKeyResponseError + iPSKeyBase, err );
       
   337                 CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory,
       
   338                         KVCXConnUtilTestExePsKeyResponseCmd + iPSKeyBase, EVcxConnUtilCommandDisconnect );
       
   339                 }
       
   340                 break;
       
   341 
       
   342             case EVcxConnUtilCommandSetRoamingAllowed:
       
   343                 {
       
   344                 VCXLOGLO2("CVCXConnUtilTestExeTester:: cmd EVcxConnUtilCommandSetRoamingAllowed (%S) ----->", 
       
   345                         &iName);
       
   346                 iTester->iIsRoamingAllowed = intParam1;
       
   347                 }
       
   348                 break;
       
   349 
       
   350             case EVcxConnUtilCommandSetRoamingLeaveAtRoamingRequest:
       
   351                 {
       
   352                 VCXLOGLO2("CVCXConnUtilTestExeTester:: cmd EVcxConnUtilCommandSetRoamingLeaveAtRoamingRequest (%S) ----->", &iName);
       
   353                 iTester->iLeaveAtRoamingRequest = intParam1;
       
   354                 }
       
   355                 break;
       
   356 
       
   357             case EVcxConnUtilCommandSetDelayBeforeRoamingRequest:
       
   358                 {
       
   359                 VCXLOGLO2("CVCXConnUtilTestExeTester:: cmd EVcxConnUtilCommandSetDelayBeforeRoamingRequest (%S) ----->", &iName);
       
   360                 iTester->iDelaySecondsAtRoamingRequest = intParam1;
       
   361                 }
       
   362                 break;
       
   363 
       
   364             default:
       
   365                 {
       
   366                 VCXLOGLO3("CVCXConnUtilTestExeTester:: UNKNOWN cmd %d! (%S) ----->", aValue, &iName);
       
   367                 }
       
   368                 break;
       
   369             }
       
   370         }
       
   371 
       
   372     VCXLOGLO2("<<<CVCXConnUtilTestExeTester::ValueChangedL TInt (%S)", &iName);
       
   373     }
       
   374 
       
   375 // -----------------------------------------------------------------------------
       
   376 // CVCXConnUtilTestExeTester::ValueChangedL
       
   377 //
       
   378 // -----------------------------------------------------------------------------
       
   379 //
       
   380 void CVCXConnUtilTestExeTester::ValueChangedL( const TUid& aUid, const TUint32& /* aKey */, const TDesC& /* aValue */ )
       
   381     {
       
   382     VCXLOGLO1(">>>CVCXConnUtilTestExeTester::ValueChangedL TDesC");
       
   383 
       
   384     if( aUid == KVCXConnUtilTestPScategory )
       
   385         {
       
   386 
       
   387         }
       
   388 
       
   389     VCXLOGLO1("<<<CVCXConnUtilTestExeTester::ValueChangedL TDesC");
       
   390     }
       
   391 
       
   392 //  End of File