datacommsserver/networkcontroller/ts_common/Etel.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "etel.h"
       
    17 #include "etelmm.h"
       
    18 #include "etelpckt.h"
       
    19 #include "EtelBehaviour.h"
       
    20 
       
    21 //
       
    22 //  Implementation of RTelServer
       
    23 //
       
    24 
       
    25 TInt RTelServer::Connect()
       
    26 	{
       
    27 	
       
    28 	ASSERT(!iTestBehaviour);
       
    29 
       
    30 	return KErrNone;
       
    31 	}
       
    32 
       
    33 void RTelServer::Close()
       
    34 	{
       
    35 
       
    36 	if(iTestBehaviour)
       
    37 		{
       
    38 		delete iTestBehaviour;
       
    39 		iTestBehaviour = NULL;
       
    40 		}
       
    41 	}
       
    42 
       
    43 TInt RTelServer::EnumeratePhones(TInt& aNoOfPhones) const
       
    44 	{
       
    45 
       
    46 	ASSERT(iTestBehaviour);
       
    47 
       
    48 	return iTestBehaviour->RTelServerEnumeratePhones(aNoOfPhones);
       
    49 	}
       
    50 
       
    51 TInt RTelServer::GetPhoneInfo(const TInt aIndex,TPhoneInfo& aInfo) const
       
    52 	{
       
    53 
       
    54 	ASSERT(iTestBehaviour);
       
    55 
       
    56 	return iTestBehaviour->RTelServerGetPhoneInfo(aIndex, aInfo);
       
    57 	}
       
    58 
       
    59 TInt RTelServer::GetTsyName(const TInt aIndexOfPhone, TDes& aTsyName) const
       
    60 	{
       
    61 
       
    62 	ASSERT(iTestBehaviour);
       
    63 
       
    64 	return iTestBehaviour->RTelServerGetTsyName(aIndexOfPhone, aTsyName);
       
    65 	}
       
    66 
       
    67 CEtelBehaviourBase* RTelServer::CreateTestBehaviourL(const TDesC& aFileName)
       
    68 	{
       
    69 
       
    70 	CEtelBehaviourBase* behaviour = NULL;
       
    71 
       
    72 	if(aFileName == _L("Test Case NC-4-9"))
       
    73 		{
       
    74 		behaviour = CTest0409Behaviour::NewL();
       
    75 		}
       
    76 	else if(aFileName == _L("Test Case NC-4-11"))
       
    77 		{
       
    78 		behaviour = CTest0411Behaviour::NewL();
       
    79 		}
       
    80 	else if(aFileName == _L("Test Case NC-4-13"))
       
    81 		{
       
    82 		behaviour = CTest0413Behaviour::NewL();
       
    83 		}
       
    84 	else if(aFileName == _L("Test Case NC-4-15"))
       
    85 		{
       
    86 		behaviour = CTest0415Behaviour::NewL();
       
    87 		}
       
    88 	else if(aFileName == _L("Test Case NC-4-17"))
       
    89 		{
       
    90 		behaviour = CTest0417Behaviour::NewL();
       
    91 		}
       
    92 	else if(aFileName == _L("Test Case NC-4-20"))
       
    93 		{
       
    94 		behaviour = CTest0420Behaviour::NewL();
       
    95 		}
       
    96 	else
       
    97 		{
       
    98 		behaviour = CEtelBehaviour::NewL();
       
    99 		}
       
   100 
       
   101 	return behaviour;
       
   102 	}
       
   103 
       
   104 TInt RTelServer::LoadPhoneModule(const TDesC& aFileName)
       
   105 	{
       
   106 	
       
   107 	ASSERT(!iTestBehaviour);
       
   108 
       
   109 	TRAPD(err, iTestBehaviour = CreateTestBehaviourL(aFileName));
       
   110 	if(err == KErrNoMemory)
       
   111 		return err;
       
   112 
       
   113 	ASSERT(iTestBehaviour);
       
   114 
       
   115 	return iTestBehaviour->RTelServerLoadPhoneModule(aFileName);
       
   116 	}
       
   117 
       
   118 TInt RTelServer::UnloadPhoneModule(const TDesC& aFileName) const
       
   119 	{
       
   120 
       
   121 	ASSERT(iTestBehaviour);
       
   122 
       
   123 	return iTestBehaviour->RTelServerUnloadPhoneModule(aFileName);
       
   124 	}
       
   125 
       
   126 CEtelBehaviourBase* RTelServer::TestBehaviour() const
       
   127 	{
       
   128 
       
   129 	ASSERT(iTestBehaviour);
       
   130 
       
   131 	return iTestBehaviour;
       
   132 	}
       
   133 
       
   134 //
       
   135 //  Implementation of RPhone
       
   136 //
       
   137 
       
   138 TInt RPhone::Open(RTelServer& aSession,const TDesC& aName)
       
   139 	{
       
   140 
       
   141 	iTestBehaviour = aSession.TestBehaviour();
       
   142 
       
   143 	ASSERT(iTestBehaviour);
       
   144 
       
   145 	return iTestBehaviour->RPhoneOpen(aSession, aName);
       
   146 	}
       
   147 
       
   148 void RPhone::Close()
       
   149 	{
       
   150 	
       
   151 	ASSERT(iTestBehaviour);
       
   152 
       
   153 	iTestBehaviour = NULL;
       
   154 	}
       
   155 
       
   156 void RPhone::CancelAsyncRequest(TInt aReqToCancel) const
       
   157 	{
       
   158 
       
   159 	ASSERT(iTestBehaviour);
       
   160 
       
   161 	iTestBehaviour->RPhoneCancelAsyncRequest(aReqToCancel);
       
   162 	}
       
   163 
       
   164 TInt RPhone::GetCaps(TCaps& aCaps) const
       
   165 	{
       
   166 
       
   167 	ASSERT(iTestBehaviour);
       
   168 
       
   169 	return iTestBehaviour->RPhoneGetCaps(aCaps);
       
   170 	}
       
   171 
       
   172 CEtelBehaviourBase* RPhone::TestBehaviour() const
       
   173 	{
       
   174 
       
   175 	ASSERT(iTestBehaviour);
       
   176 
       
   177 	return iTestBehaviour;
       
   178 	}
       
   179 
       
   180 //
       
   181 //  Implementation of RMobilePhone
       
   182 //
       
   183 
       
   184 TInt RMobilePhone::GetMultimodeCaps(TUint32& aCaps) const
       
   185 	{
       
   186 
       
   187 	ASSERT(iTestBehaviour);
       
   188 
       
   189 	return iTestBehaviour->RMobilePhoneGetMultimodeCaps(aCaps);
       
   190 	}
       
   191 
       
   192 TInt RMobilePhone::GetCurrentMode(TMobilePhoneNetworkMode& aNetworkMode) const
       
   193 	{
       
   194 
       
   195 	ASSERT(iTestBehaviour);
       
   196 	
       
   197 	return iTestBehaviour->RMobilePhoneGetCurrentMode(aNetworkMode);
       
   198 	}
       
   199 
       
   200 void RMobilePhone::GetSignalStrength(TRequestStatus& aReqStatus, TInt32& aSignalStrength, TInt8& aBar) const
       
   201 	{
       
   202 
       
   203 	ASSERT(iTestBehaviour);
       
   204 
       
   205 	iTestBehaviour->RMobilePhoneGetSignalStrength(aReqStatus, aSignalStrength, aBar);
       
   206 	}
       
   207 
       
   208 void RMobilePhone::NotifySignalStrengthChange(TRequestStatus& aReqStatus, TInt32& aSignalStrength, TInt8& aBar) const
       
   209 	{
       
   210 	ASSERT(iTestBehaviour);
       
   211 
       
   212 	iTestBehaviour->RMobilePhoneNotifySignalStrengthChange(aReqStatus, aSignalStrength, aBar);
       
   213 	}
       
   214 
       
   215 //
       
   216 //  Implementation of RPacketService
       
   217 //
       
   218 
       
   219 TInt RPacketService::Open(RPhone& aPhone)
       
   220 	{
       
   221 
       
   222 	iTestBehaviour = aPhone.TestBehaviour();
       
   223 
       
   224 	ASSERT(iTestBehaviour);
       
   225 
       
   226 	return iTestBehaviour->RPacketServiceOpen(aPhone);
       
   227 	}
       
   228 
       
   229 void RPacketService::Close()
       
   230 	{
       
   231 
       
   232 	iTestBehaviour = NULL;
       
   233 	}
       
   234 
       
   235 void RPacketService::CancelAsyncRequest(TInt aReqToCancel) const
       
   236 	{
       
   237 
       
   238 	ASSERT(iTestBehaviour);
       
   239 
       
   240 	iTestBehaviour->RPacketServiceCancelAsyncRequest(aReqToCancel);
       
   241 	}
       
   242 
       
   243 TInt RPacketService::GetStatus(TStatus& aPacketStatus) const
       
   244 	{
       
   245 
       
   246 	ASSERT(iTestBehaviour);
       
   247 
       
   248 	return iTestBehaviour->RPacketServiceGetStatus(aPacketStatus);
       
   249 	}
       
   250 
       
   251 void RPacketService::GetMSClass(TRequestStatus& aStatus, TMSClass& aCurrentClass, TMSClass& aMaxClass) const
       
   252 	{
       
   253 
       
   254 	ASSERT(iTestBehaviour);
       
   255 
       
   256 	iTestBehaviour->RPacketServiceGetMSClass(aStatus, aCurrentClass, aMaxClass);
       
   257 	}
       
   258 
       
   259 void RPacketService::GetNtwkRegStatus(TRequestStatus& aStatus, TRegistrationStatus& aRegistrationStatus) const
       
   260 	{
       
   261 	
       
   262 	ASSERT(iTestBehaviour);
       
   263 
       
   264 	iTestBehaviour->RPacketServiceGetNtwkRegStatus(aStatus, aRegistrationStatus);
       
   265 	}
       
   266 
       
   267 TInt RPacketService::GetAttachMode(TAttachMode& aMode) const
       
   268 	{
       
   269 
       
   270 	ASSERT(iTestBehaviour);
       
   271 
       
   272 	return iTestBehaviour->RPacketServiceGetAttachMode(aMode);
       
   273 	}
       
   274