videoutils_plat/videoconnutility_api/tsrc/VCXConnUtilTestExe/src/VCXConnUtilTester.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 <S32STRM.H>
       
    19 #include <S32MEM.H>
       
    20 
       
    21 #include "VCXTestLog.h"
       
    22 
       
    23 #include "VCXConnUtilTester.h"
       
    24 #include "vcxconnectionutility.h"
       
    25 #include "CIptvTestTimer.h"
       
    26 #include "CIptvTestActiveWait.h"
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CVCXConnUtilTester::NewL
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 CVCXConnUtilTester* CVCXConnUtilTester::NewL()
       
    33     {
       
    34     VCXLOGLO1(">>>CVCXConnUtilTester::NewL");
       
    35     CVCXConnUtilTester* self = new (ELeave) CVCXConnUtilTester();
       
    36     CleanupStack::PushL(self);
       
    37     self->ConstructL();
       
    38     CleanupStack::Pop(self);
       
    39     VCXLOGLO1("<<<CVCXConnUtilTester::NewL");
       
    40     return self;
       
    41     }
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CVCXConnUtilTester::CVCXConnUtilTester
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CVCXConnUtilTester::CVCXConnUtilTester()
       
    48     {
       
    49 
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CVCXConnUtilTester::ConstructL
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 void CVCXConnUtilTester::ConstructL()
       
    57     {
       
    58     VCXLOGLO1(">>>CVCXConnUtilTester::ConstructL");
       
    59 
       
    60     iIsRoamingAllowed = ETrue;
       
    61     iLeaveAtRoamingRequest = EFalse;
       
    62     iDelaySecondsAtRoamingRequest = 0;
       
    63 
       
    64     iConnUtil = CVcxConnectionUtility::InstanceL();
       
    65     iConnUtil->RegisterObserverL( this );
       
    66 
       
    67     iTimer = CIptvTestTimer::NewL( *this, 0 );
       
    68 
       
    69     iWait = CIptvTestActiveWait::NewL();
       
    70 
       
    71     VCXLOGLO1("<<<CVCXConnUtilTester::ConstructL");
       
    72     }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CVCXConnUtilTester::~CVCXConnUtilTester
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 CVCXConnUtilTester::~CVCXConnUtilTester()
       
    79     {
       
    80     VCXLOGLO2(">>>CVCXConnUtilTester::~CVCXConnUtilTester (%S)", &iName);
       
    81 
       
    82     if( iConnUtil )
       
    83         {
       
    84         iConnUtil->RemoveObserver( this );
       
    85         TRAP_IGNORE( iConnUtil->DisconnectL() );
       
    86         iConnUtil->DecreaseReferenceCount();
       
    87         }
       
    88     iConnUtil = NULL;
       
    89 
       
    90     if( iTimer )
       
    91         {
       
    92         iTimer->CancelTimer();
       
    93         delete iTimer;
       
    94         iTimer = NULL;
       
    95         }
       
    96 
       
    97     delete iWait;
       
    98     iWait = NULL;
       
    99 
       
   100     VCXLOGLO2("<<<CVCXConnUtilTester::~CVCXConnUtilTester (%S)", &iName);
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CVCXConnUtilTester::GetIap
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 TInt CVCXConnUtilTester::GetIap( TUint32& aIapId, TBool aSilent, TBool aIsTimed )
       
   108     {
       
   109     VCXLOGLO2(">>>CVCXConnUtilTester::GetIap (%S)", &iName);
       
   110     VCXLOGLO2("CVCXConnUtilTester:: isTimed: %d", aIsTimed);
       
   111 
       
   112     if( aIsTimed )
       
   113         {
       
   114         // Time GetIap request when next minute starts
       
   115         TInt seconds( 0 );
       
   116         TTime now;
       
   117         now.HomeTime();
       
   118 
       
   119         TDateTime time = now.DateTime();
       
   120 
       
   121         if( time.Second() >= 55 )
       
   122             {
       
   123             seconds += 10; // Wait extra 10 seconds to make sure any other test module is ready.
       
   124             }
       
   125 
       
   126         seconds += 60 - time.Second(); // Wait to end of minute
       
   127 
       
   128         VCXLOGLO3("CVCXConnUtilTester:: waiting %d seconds (%S)", seconds, &iName);
       
   129 
       
   130         TUint32 microSeconds( 0 );
       
   131         microSeconds = seconds * 1000000;
       
   132 
       
   133         microSeconds += 1 - time.MicroSecond(); // And any extra microseconds
       
   134 
       
   135         iTimer->After( microSeconds );
       
   136         iWait->Start();
       
   137         }
       
   138 
       
   139     VCXLOGLO2("CVCXConnUtilTester:: making GetIap call (%S) ----->", &iName);
       
   140     TInt err = iConnUtil->GetIap( aIapId, aSilent );
       
   141     VCXLOGLO2("CVCXConnUtilTester:: GetIap returns: %d", err);
       
   142     VCXLOGLO2("<<<CVCXConnUtilTester::GetIap (%S)", &iName);
       
   143     return err;
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CVCXConnUtilTester::WapIdFromIapIdL
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 TUint32 CVCXConnUtilTester::WapIdFromIapIdL( const TInt32& aIapId )
       
   151     {
       
   152     VCXLOGLO2(">>>CVCXConnUtilTester::WapIdFromIapIdL (%S) ----->", &iName);
       
   153     TUint32 aWapId = iConnUtil->WapIdFromIapIdL( aIapId );
       
   154     VCXLOGLO2("CVCXConnUtilTester:: WapIdFromIapIdL returns %d", aWapId);
       
   155     VCXLOGLO2("<<<CVCXConnUtilTester::WapIdFromIapIdL (%S)", &iName);
       
   156     return aWapId;
       
   157     }
       
   158 
       
   159 // -----------------------------------------------------------------------------
       
   160 // CVCXConnUtilTester::Disconnect
       
   161 // -----------------------------------------------------------------------------
       
   162 //
       
   163 TInt CVCXConnUtilTester::Disconnect()
       
   164     {
       
   165     VCXLOGLO2(">>>CVCXConnUtilTester::Disconnect (%S) ----->", &iName);
       
   166     TRAPD( err, iConnUtil->DisconnectL() );
       
   167     VCXLOGLO2("CVCXConnUtilTester:: Disconnect returns %d", err);
       
   168     VCXLOGLO2("<<<CVCXConnUtilTester::Disconnect (%S)", &iName);
       
   169     return err;
       
   170     }
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 // CVCXConnUtilTester::RequestIsRoamingAllowedL
       
   174 // -----------------------------------------------------------------------------
       
   175 //
       
   176 TBool CVCXConnUtilTester::RequestIsRoamingAllowedL()
       
   177     {
       
   178     VCXLOGLO2(">>>CVCXConnUtilTester::RequestIsRoamingAllowedL (%S) ----->", &iName);
       
   179 
       
   180     if( iLeaveAtRoamingRequest )
       
   181         {
       
   182         VCXLOGLO1("CVCXConnUtilTester:: iLeaveAtRoamingRequest set. LEAVING!");
       
   183         User::Leave( KErrTotalLossOfPrecision  );
       
   184         }
       
   185 
       
   186     if( iDelaySecondsAtRoamingRequest > 0 )
       
   187         {
       
   188         VCXLOGLO2("CVCXConnUtilTester:: delay: %d", iDelaySecondsAtRoamingRequest );
       
   189         iTimer->After( iDelaySecondsAtRoamingRequest * 1000000 );
       
   190         iWait->Start();
       
   191         }
       
   192 
       
   193     VCXLOGLO2("CVCXConnUtilTest:: iIsRoamingAllowed = %d", iIsRoamingAllowed);
       
   194 
       
   195     VCXLOGLO2("<<<CVCXConnUtilTester::RequestIsRoamingAllowedL (%S)", &iName);
       
   196     return iIsRoamingAllowed;
       
   197     }
       
   198 
       
   199 // -----------------------------------------------------------------------------
       
   200 // CVCXConnUtilTester::IapChangedL
       
   201 // -----------------------------------------------------------------------------
       
   202 //
       
   203 void CVCXConnUtilTester::IapChangedL()
       
   204     {
       
   205     VCXLOGLO2(">>>CVCXConnUtilTester::IapChangedL (%S)", &iName);
       
   206     VCXLOGLO2("<<<CVCXConnUtilTester::IapChangedL (%S)", &iName);
       
   207     }
       
   208 
       
   209 // -----------------------------------------------------------------------------
       
   210 // CVCXConnUtilTest::TimerComplete
       
   211 // -----------------------------------------------------------------------------
       
   212 //
       
   213 void CVCXConnUtilTester::TimerComplete( TInt /* aTimerId */, TInt aError )
       
   214     {
       
   215     VCXLOGLO3(">>>CVCXConnUtilTester::TimerComplete, err: %d (%S)", aError, &iName);
       
   216     iWait->Stop();
       
   217     VCXLOGLO2("<<<CVCXConnUtilTester::TimerComplete (%S)", &iName);
       
   218     }
       
   219 
       
   220 
       
   221 // EOF