datacommsserver/networkcontroller/ts_common/EtelBehaviour.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 "EtelBehaviour.h"
       
    17 #include "etelmm.h"
       
    18 #include "etelpckt.h"
       
    19 #include "pcktcs.h"
       
    20 
       
    21 CEtelBehaviourBase::~CEtelBehaviourBase()
       
    22 	{
       
    23 
       
    24 	if(iCurrentRPhoneRequestStatus)
       
    25 		CompleteCurrentRPhoneAsyncRequest(KErrCancel);
       
    26 	}
       
    27 
       
    28 CEtelBehaviourBase::CEtelBehaviourBase()
       
    29 	{
       
    30 	}
       
    31 
       
    32 void CEtelBehaviourBase::CompleteCurrentRPhoneAsyncRequest(TInt aError)
       
    33 	{
       
    34 
       
    35 	if(iCurrentRPhoneRequestStatus)
       
    36 		{
       
    37 		User::RequestComplete(iCurrentRPhoneRequestStatus, aError);
       
    38 		iCurrentRPhoneRequestStatus = NULL;
       
    39 		iCurrentRPhoneAsyncRequest = 0;
       
    40 		}
       
    41 	}
       
    42 
       
    43 void CEtelBehaviourBase::CompleteCurrentRPacketServiceAsyncRequest(TInt aError)
       
    44 	{
       
    45 
       
    46 	if(iCurrentRPacketServiceRequestStatus)
       
    47 		{
       
    48 		User::RequestComplete(iCurrentRPacketServiceRequestStatus, aError);
       
    49 		iCurrentRPacketServiceRequestStatus = NULL;
       
    50 		iCurrentRPacketServiceAsyncRequest = 0;
       
    51 		}
       
    52 	}
       
    53 
       
    54 COneShotTimer::COneShotTimer(MTimerObserver* aObserver)
       
    55 : CTimer(CActive::EPriorityStandard), iObserver(aObserver)
       
    56 	{
       
    57 
       
    58 	CActiveScheduler::Add(this);
       
    59 	}
       
    60 
       
    61 void COneShotTimer::RunL()
       
    62 	{
       
    63 
       
    64 	iObserver->TimerComplete(iStatus.Int());
       
    65 	}
       
    66 
       
    67 COneShotTimer* COneShotTimer::NewL(MTimerObserver* aObserver)
       
    68 	{
       
    69 
       
    70 	COneShotTimer* self = new(ELeave) COneShotTimer(aObserver);
       
    71 	CleanupStack::PushL(self);
       
    72 	self->ConstructL();
       
    73 	CleanupStack::Pop(); // self
       
    74 	return self;
       
    75 	}
       
    76 
       
    77 void COneShotTimer::ConstructL()
       
    78 	{
       
    79 
       
    80 	CTimer::ConstructL();
       
    81 	}
       
    82 
       
    83 CEtelBehaviour* CEtelBehaviour::NewL()
       
    84 	{
       
    85 	CEtelBehaviour* self = new(ELeave) CEtelBehaviour();
       
    86 	CleanupStack::PushL(self);
       
    87 	self->ConstructL();
       
    88 	CleanupStack::Pop(); // self
       
    89 	return self;
       
    90 	}
       
    91 
       
    92 CEtelBehaviour::CEtelBehaviour()
       
    93 	{ }
       
    94 
       
    95 void CEtelBehaviour::ConstructL()
       
    96 	{
       
    97 
       
    98 	iTimer = COneShotTimer::NewL(this);
       
    99 	}
       
   100 
       
   101 CEtelBehaviour::~CEtelBehaviour()
       
   102 	{
       
   103 
       
   104 	if(iTimer)
       
   105 		delete iTimer;
       
   106 	}
       
   107 
       
   108 TInt CEtelBehaviour::RTelServerLoadPhoneModule(const TDesC&)
       
   109 	{
       
   110 
       
   111 	return KErrNone;
       
   112 	}
       
   113 
       
   114 TInt CEtelBehaviour::RTelServerEnumeratePhones(TInt& aNoOfPhones)
       
   115 	{
       
   116 
       
   117 	aNoOfPhones = 5;
       
   118 	return KErrNone;
       
   119 	}
       
   120 
       
   121 TInt CEtelBehaviour::RTelServerGetTsyName(const TInt, TDes& aTsyName)
       
   122 	{
       
   123 
       
   124 	_LIT(KTsyName, "mm");
       
   125 	aTsyName = KTsyName();
       
   126 	return KErrNone;
       
   127 	}
       
   128 
       
   129 TInt CEtelBehaviour::RTelServerGetPhoneInfo(const TInt,RTelServer::TPhoneInfo& aInfo)
       
   130 	{
       
   131 
       
   132 	_LIT(KPhoneName, "mm");
       
   133 	aInfo.iNetworkType = RTelServer::ENetworkTypeMobileDigital;
       
   134 	aInfo.iName = KPhoneName();
       
   135 	aInfo.iNumberOfLines = 1;
       
   136 	aInfo.iExtensions = 1;
       
   137 	return KErrNone;
       
   138 	}
       
   139 
       
   140 TInt CEtelBehaviour::RTelServerUnloadPhoneModule(const TDesC&)
       
   141 	{
       
   142 
       
   143 	return KErrNone;
       
   144 	}
       
   145 
       
   146 TInt CEtelBehaviour::RPhoneOpen(RTelServer&,const TDesC&)
       
   147 	{
       
   148 
       
   149 	return KErrNone;
       
   150 	}
       
   151 
       
   152 void CEtelBehaviour::RPhoneCancelAsyncRequest(TInt aReqToCancel)
       
   153 	{
       
   154 	
       
   155 	ASSERT(iCurrentRPhoneAsyncRequest == aReqToCancel);
       
   156 	(void)aReqToCancel;
       
   157 
       
   158 	CompleteCurrentRPhoneAsyncRequest(KErrCancel);
       
   159 	}
       
   160 
       
   161 TInt CEtelBehaviour::RPhoneGetCaps(RPhone::TCaps& aCaps)
       
   162 	{
       
   163 
       
   164 	aCaps.iFlags = RPhone::KCapsData;
       
   165 	return KErrNone;
       
   166 	}
       
   167 
       
   168 TInt CEtelBehaviour::RMobilePhoneGetCurrentMode(RMobilePhone::TMobilePhoneNetworkMode& aNetworkMode)
       
   169 	{
       
   170 
       
   171 	aNetworkMode = RMobilePhone::ENetworkModeGsm;
       
   172 	return KErrNone;
       
   173 	}
       
   174 
       
   175 void CEtelBehaviour::RMobilePhoneGetSignalStrength(TRequestStatus& aReqStatus, TInt32& aSignalStrength, TInt8& aBar)
       
   176 	{
       
   177 
       
   178 	ASSERT(!iCurrentRPhoneRequestStatus);
       
   179 	
       
   180 	aReqStatus = KRequestPending;	
       
   181 	aSignalStrength = 1000;
       
   182 	aBar = 10;
       
   183 
       
   184 	iCurrentRPhoneAsyncRequest = EMobilePhoneGetSignalStrength;
       
   185 	iCurrentRPhoneRequestStatus = &aReqStatus;
       
   186 
       
   187 	CompleteCurrentRPhoneAsyncRequest(KErrNone);
       
   188 	}
       
   189 
       
   190 void CEtelBehaviour::RMobilePhoneNotifySignalStrengthChange(TRequestStatus& aReqStatus, TInt32& aSignalStrength, TInt8& aBar)
       
   191 	{
       
   192 
       
   193 	if(iCurrentRPhoneRequestStatus)
       
   194 		return;
       
   195 
       
   196 	ASSERT(!iCurrentRPhoneRequestStatus);
       
   197 
       
   198 	aReqStatus = KRequestPending;	
       
   199 	aSignalStrength = 1500;
       
   200 	aBar = 15;
       
   201 
       
   202 	iCurrentRPhoneAsyncRequest = EMobilePhoneNotifySignalStrengthChange;
       
   203 	iCurrentRPhoneRequestStatus = &aReqStatus;
       
   204 
       
   205 	// Complete request after 1 second
       
   206 	iTimer->After(1000000);
       
   207 	}
       
   208 
       
   209 void CEtelBehaviour::TimerComplete(TInt)
       
   210 	{
       
   211 
       
   212 	CompleteCurrentRPhoneAsyncRequest(KErrNone);
       
   213 	}
       
   214 
       
   215 TInt CEtelBehaviour::RMobilePhoneGetMultimodeCaps(TUint32& aCaps)
       
   216 	{
       
   217 
       
   218 	aCaps = RMobilePhone::KCapsGprsSupported;
       
   219 	return KErrNone;
       
   220 	}
       
   221 
       
   222 TInt CEtelBehaviour::RPacketServiceOpen(RPhone&)
       
   223 	{
       
   224 
       
   225 	return KErrNone;
       
   226 	}
       
   227 
       
   228 void CEtelBehaviour::RPacketServiceCancelAsyncRequest(TInt aReqToCancel)
       
   229 	{
       
   230 	
       
   231 	ASSERT(iCurrentRPacketServiceAsyncRequest == aReqToCancel);
       
   232 	(void)aReqToCancel;
       
   233 
       
   234 	CompleteCurrentRPacketServiceAsyncRequest(KErrCancel);
       
   235 	}
       
   236 
       
   237 TInt CEtelBehaviour::RPacketServiceGetStatus(RPacketService::TStatus& aPacketStatus)
       
   238 	{
       
   239 
       
   240 	aPacketStatus = RPacketService::EStatusAttached;
       
   241 	return KErrNone;
       
   242 	}
       
   243 
       
   244 void CEtelBehaviour::RPacketServiceGetMSClass(TRequestStatus& aStatus, RPacketService::TMSClass& aCurrentClass, RPacketService::TMSClass& aMaxClass)
       
   245 	{
       
   246 
       
   247 	ASSERT(!iCurrentRPacketServiceRequestStatus);
       
   248 
       
   249 	aStatus = KRequestPending;
       
   250 	aCurrentClass = RPacketService::EMSClassDualMode;
       
   251 	aMaxClass = RPacketService::EMSClassDualMode;
       
   252 
       
   253 	iCurrentRPacketServiceAsyncRequest = EPacketGetMSClass;
       
   254 	iCurrentRPacketServiceRequestStatus = &aStatus;
       
   255 
       
   256 	CompleteCurrentRPacketServiceAsyncRequest(KErrNone);
       
   257 	}
       
   258 
       
   259 void CEtelBehaviour::RPacketServiceGetNtwkRegStatus(TRequestStatus& aStatus, RPacketService::TRegistrationStatus& aRegistrationStatus)
       
   260 	{
       
   261 
       
   262 	ASSERT(!iCurrentRPacketServiceRequestStatus);
       
   263 
       
   264 	aStatus = KRequestPending;
       
   265 	aRegistrationStatus = RPacketService::ERegisteredOnHomeNetwork;
       
   266 
       
   267 	iCurrentRPacketServiceAsyncRequest = EPacketGetNtwkRegStatus;
       
   268 	iCurrentRPacketServiceRequestStatus = &aStatus;
       
   269 
       
   270 	CompleteCurrentRPacketServiceAsyncRequest(KErrNone);
       
   271 	}
       
   272 
       
   273 TInt CEtelBehaviour::RPacketServiceGetAttachMode(RPacketService::TAttachMode& aMode)
       
   274 	{
       
   275 
       
   276 	aMode = RPacketService::EAttachWhenPossible;
       
   277 	return KErrNone;
       
   278 	}
       
   279 
       
   280 
       
   281 //
       
   282 //  ETEL behaviour for test case NC-4-9
       
   283 //
       
   284 //  RTelServer LoadPhoneModule() will return KErrNotFound
       
   285 //
       
   286 
       
   287 CTest0409Behaviour* CTest0409Behaviour::NewL()
       
   288 	{
       
   289 
       
   290 	CTest0409Behaviour* self = new(ELeave) CTest0409Behaviour();
       
   291 	CleanupStack::PushL(self);
       
   292 	self->ConstructL();
       
   293 	CleanupStack::Pop(); // self
       
   294 	return self;
       
   295 	}
       
   296 
       
   297 CTest0409Behaviour::CTest0409Behaviour()
       
   298 	{ }
       
   299 
       
   300 void CTest0409Behaviour::ConstructL()
       
   301 	{
       
   302 
       
   303 	CEtelBehaviour::ConstructL();
       
   304 	}
       
   305 
       
   306 CTest0409Behaviour::~CTest0409Behaviour()
       
   307 	{ }
       
   308 
       
   309 TInt CTest0409Behaviour::RTelServerLoadPhoneModule(const TDesC&)
       
   310 	{
       
   311 
       
   312 	return KErrNotFound;
       
   313 	}
       
   314 
       
   315 
       
   316 //
       
   317 //  ETEL behaviour for test case NC-4-11
       
   318 //
       
   319 //  RPhone Open() will return KErrGeneral
       
   320 //
       
   321 
       
   322 CTest0411Behaviour* CTest0411Behaviour::NewL()
       
   323 	{
       
   324 
       
   325 	CTest0411Behaviour* self = new(ELeave) CTest0411Behaviour();
       
   326 	CleanupStack::PushL(self);
       
   327 	self->ConstructL();
       
   328 	CleanupStack::Pop(); // self
       
   329 	return self;
       
   330 	}
       
   331 
       
   332 CTest0411Behaviour::CTest0411Behaviour()
       
   333 	{ }
       
   334 
       
   335 void CTest0411Behaviour::ConstructL()
       
   336 	{
       
   337 
       
   338 	CEtelBehaviour::ConstructL();
       
   339 	}
       
   340 
       
   341 CTest0411Behaviour::~CTest0411Behaviour()
       
   342 	{ }
       
   343 
       
   344 TInt CTest0411Behaviour::RPhoneOpen(RTelServer&,const TDesC&)
       
   345 	{
       
   346 
       
   347 	return KErrGeneral;
       
   348 	}
       
   349 
       
   350 TInt CTest0411Behaviour::RTelServerGetTsyName(const TInt, TDes& aTsyName)
       
   351 	{
       
   352 
       
   353 	_LIT(KTsyName, "Test Case NC-4-11");
       
   354 	aTsyName = KTsyName();
       
   355 	return KErrNone;
       
   356 	}
       
   357 
       
   358 
       
   359 //
       
   360 //  ETEL behaviour for test case NC-4-13
       
   361 //
       
   362 //  RPhone GetCaps() will return KErrGeneral
       
   363 //
       
   364 
       
   365 CTest0413Behaviour* CTest0413Behaviour::NewL()
       
   366 	{
       
   367 
       
   368 	CTest0413Behaviour* self = new(ELeave) CTest0413Behaviour();
       
   369 	CleanupStack::PushL(self);
       
   370 	self->ConstructL();
       
   371 	CleanupStack::Pop(); // self
       
   372 	return self;
       
   373 	}
       
   374 
       
   375 CTest0413Behaviour::CTest0413Behaviour()
       
   376 	{ }
       
   377 
       
   378 void CTest0413Behaviour::ConstructL()
       
   379 	{
       
   380 
       
   381 	CEtelBehaviour::ConstructL();
       
   382 	}
       
   383 
       
   384 CTest0413Behaviour::~CTest0413Behaviour()
       
   385 	{ }
       
   386 
       
   387 TInt CTest0413Behaviour::RTelServerGetTsyName(const TInt, TDes& aTsyName)
       
   388 	{
       
   389 
       
   390 	_LIT(KTsyName, "Test Case NC-4-13");
       
   391 	aTsyName = KTsyName();
       
   392 	return KErrNone;
       
   393 	}
       
   394 
       
   395 TInt CTest0413Behaviour::RPhoneGetCaps(RPhone::TCaps&)
       
   396 	{
       
   397 
       
   398 	return KErrGeneral;
       
   399 	}
       
   400 
       
   401 
       
   402 //
       
   403 //  ETEL behaviour for test case NC-4-15
       
   404 //
       
   405 //  RPacketService Open() will return KErrNotFound
       
   406 //
       
   407 
       
   408 CTest0415Behaviour* CTest0415Behaviour::NewL()
       
   409 	{
       
   410 
       
   411 	CTest0415Behaviour* self = new(ELeave) CTest0415Behaviour();
       
   412 	CleanupStack::PushL(self);
       
   413 	self->ConstructL();
       
   414 	CleanupStack::Pop(); // self
       
   415 	return self;
       
   416 	}
       
   417 
       
   418 CTest0415Behaviour::CTest0415Behaviour()
       
   419 	{ }
       
   420 
       
   421 void CTest0415Behaviour::ConstructL()
       
   422 	{
       
   423 
       
   424 	CEtelBehaviour::ConstructL();
       
   425 	}
       
   426 
       
   427 CTest0415Behaviour::~CTest0415Behaviour()
       
   428 	{ }
       
   429 
       
   430 TInt CTest0415Behaviour::RTelServerGetTsyName(const TInt, TDes& aTsyName)
       
   431 	{
       
   432 
       
   433 	_LIT(KTsyName, "Test Case NC-4-15");
       
   434 	aTsyName = KTsyName();
       
   435 	return KErrNone;
       
   436 	}
       
   437 
       
   438 TInt CTest0415Behaviour::RPacketServiceOpen(RPhone&)
       
   439 	{
       
   440 
       
   441 	return KErrNotFound;
       
   442 	}
       
   443 
       
   444 
       
   445 //
       
   446 //  ETEL behaviour for test case NC-4-17
       
   447 //
       
   448 //  RPacketService GetStatus() will return KErrGeneral
       
   449 //
       
   450 
       
   451 CTest0417Behaviour* CTest0417Behaviour::NewL()
       
   452 	{
       
   453 
       
   454 	CTest0417Behaviour* self = new(ELeave) CTest0417Behaviour();
       
   455 	CleanupStack::PushL(self);
       
   456 	self->ConstructL();
       
   457 	CleanupStack::Pop(); // self
       
   458 	return self;
       
   459 	}
       
   460 
       
   461 CTest0417Behaviour::CTest0417Behaviour()
       
   462 	{ }
       
   463 
       
   464 void CTest0417Behaviour::ConstructL()
       
   465 	{
       
   466 
       
   467 	CEtelBehaviour::ConstructL();
       
   468 	}
       
   469 
       
   470 CTest0417Behaviour::~CTest0417Behaviour()
       
   471 	{ }
       
   472 
       
   473 TInt CTest0417Behaviour::RTelServerGetTsyName(const TInt, TDes& aTsyName)
       
   474 	{
       
   475 
       
   476 	_LIT(KTsyName, "Test Case NC-4-17");
       
   477 	aTsyName = KTsyName();
       
   478 	return KErrNone;
       
   479 	}
       
   480 
       
   481 TInt CTest0417Behaviour::RPacketServiceGetStatus(RPacketService::TStatus&)
       
   482 	{
       
   483 
       
   484 	return KErrGeneral;
       
   485 	}
       
   486 
       
   487 //
       
   488 //  ETEL behaviour for test case NC-4-20
       
   489 //
       
   490 //  RPacketService GetAttachMode() will RPacketService::EAttachWhenNeeded
       
   491 //
       
   492 
       
   493 CTest0420Behaviour* CTest0420Behaviour::NewL()
       
   494 	{
       
   495 
       
   496 	CTest0420Behaviour* self = new(ELeave) CTest0420Behaviour();
       
   497 	CleanupStack::PushL(self);
       
   498 	self->ConstructL();
       
   499 	CleanupStack::Pop(); // self
       
   500 	return self;
       
   501 	}
       
   502 
       
   503 CTest0420Behaviour::CTest0420Behaviour()
       
   504 	{ }
       
   505 
       
   506 void CTest0420Behaviour::ConstructL()
       
   507 	{
       
   508 
       
   509 	CEtelBehaviour::ConstructL();
       
   510 	}
       
   511 
       
   512 CTest0420Behaviour::~CTest0420Behaviour()
       
   513 	{ }
       
   514 
       
   515 TInt CTest0420Behaviour::RTelServerGetTsyName(const TInt, TDes& aTsyName)
       
   516 	{
       
   517 
       
   518 	_LIT(KTsyName, "Test Case NC-4-20");
       
   519 	aTsyName = KTsyName();
       
   520 	return KErrNone;
       
   521 	}
       
   522 
       
   523 TInt CTest0420Behaviour::RPacketServiceGetAttachMode(RPacketService::TAttachMode& aMode)
       
   524 	{
       
   525 
       
   526 	aMode = RPacketService::EAttachWhenNeeded;
       
   527 	return KErrNone;
       
   528 	}
       
   529