email/pop3andsmtpmtm/servermtmutils/src/cimmobilitymanager.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 2006-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 "cimmobilitymanager.h"
       
    17 #include "cimmobilitypolicyprovider.h"
       
    18 #include "mobilitytestmtmapi.h"
       
    19 #include "cimmobilitylogger.h"
       
    20 #include <imutdll.h>
       
    21 
       
    22 /**
       
    23 The factory constructor. Part of two phased construction.
       
    24 @param aAccountId - the ID of the email account
       
    25 @param aMtm - Bearer Mobility API for the server MTM
       
    26 */
       
    27 EXPORT_C CImMobilityManager* CImMobilityManager::NewL(TUid aMtmUid, TMsvId aAccountId, MImMobileServer& aMtm)
       
    28 // static method
       
    29 	{
       
    30 	CImMobilityManager* self = new(ELeave) CImMobilityManager(aMtmUid, aAccountId, aMtm);
       
    31 	CleanupStack::PushL(self);
       
    32 	self->ConstructL();
       
    33 	CleanupStack::Pop(self);
       
    34 	return self;
       
    35 	}
       
    36 
       
    37 CImMobilityManager::CImMobilityManager(TUid aMtmUid, TMsvId aAccountId, MImMobileServer& aMtm)
       
    38 	: iMtmUid(aMtmUid), iAccountId(aAccountId), iMtm(aMtm), iIsCancelled(EFalse)
       
    39 	{
       
    40 	MOBILITY_TEST_CREATE(aAccountId, *this);
       
    41 	}
       
    42 
       
    43 void CImMobilityManager::ConstructL()
       
    44 	{
       
    45 	// Ensure an instance of the mobility Policy Provider exists.
       
    46 	CImMobilityPolicyProvider::CreateL();
       
    47 	}
       
    48 
       
    49 CImMobilityManager::~CImMobilityManager()
       
    50 	{
       
    51 	iIsCancelled = ETrue;
       
    52 	delete iCommsMobilityApi;
       
    53 	iCommsMobilityApi = NULL;
       
    54 	
       
    55 	if (iState == EMobilityWaitForUpgradePolicy   || 
       
    56 	    iState == EMobilityWaitForDowngradePolicy || 
       
    57 	    iState == EMobilityWaitForUpgradePolicyAndOldSocketClose)
       
    58 		{
       
    59 		CImMobilityPolicyProvider::GetRef().Cancel(iAccountId);
       
    60 		}
       
    61 	CImMobilityPolicyProvider::Delete();
       
    62 	MOBILITY_TEST_DELETE(*this);
       
    63 	}
       
    64 
       
    65 /**
       
    66 Registers with the Bearer Mobility Framework for preferred carrier notifications
       
    67 @param aConnection - the connected session.
       
    68 */
       
    69 EXPORT_C void CImMobilityManager::SetConnection(RCommsSubSession& aConnection)
       
    70 	{
       
    71 	if (iState == EMobilityUninitialised)
       
    72 		{
       
    73 		TRAPD(err, iCommsMobilityApi = CActiveCommsMobilityApiExt::NewL(aConnection, *this));
       
    74 
       
    75 		if (err == KErrNone)
       
    76 			{
       
    77 			iState = EMobilityIdle;
       
    78 			__LOG_FORMAT((KDefaultLog, "<%d> SetConnection() OK", iAccountId));
       
    79 			}
       
    80 		else
       
    81 			{
       
    82 			__LOG_FORMAT((KDefaultLog, "<%d> SetConnection() Error %d", iAccountId, err));
       
    83 			}
       
    84 		}
       
    85 	else
       
    86 		{
       
    87 		// unexpected in this state
       
    88 		__LOG_FORMAT((KDefaultLog, "<%d> SetConnection() unexpected state : %d", iAccountId, iState));
       
    89 		__ASSERT_DEBUG(EFalse, gPanic(EPanicInvalidMobilityState));
       
    90 		}
       
    91 	}
       
    92 	
       
    93 /**
       
    94 Notification of preferred carrier availability. 
       
    95 This is called as a result of a new, preferred carrier becoming available (upgrade)
       
    96 or the existing carrier being lost, with an alternative available (downgrade).
       
    97 
       
    98 The notification is handed up to the Mobility Policy Provider for decision.
       
    99 
       
   100 @param aOldAp		- info about the old carrier
       
   101 @param aNewAp		- info about the new carrier
       
   102 @param aIsUpgrade   - indicates if this is an upgrade
       
   103 @param aIsSeamless  - indicates if a migration will be seamless
       
   104 */
       
   105 void CImMobilityManager::PreferredCarrierAvailable(TAccessPointInfo aOldAp, TAccessPointInfo aNewAp, TBool aIsUpgrade, TBool aIsSeamless)
       
   106 	{
       
   107 	__LOG_FORMAT((KDefaultLog, "<%d> PreferredCarrierAvailable(state:%d old:%d new:%d isUp:%d isSless:%d)", iAccountId, iState, aOldAp.AccessPoint(), aNewAp.AccessPoint(), aIsUpgrade, aIsSeamless));
       
   108 	// Handle the upgrade notice
       
   109 	switch (iState)
       
   110 		{
       
   111 		case EMobilityIdle:
       
   112 		case EMobilityWaitForMigrate:
       
   113 		case EMobilityConnectingToNewCarrier:
       
   114 			{
       
   115 			// no special "extra" action to do in these states - just inform the
       
   116 			// MTM (in the case of a downgrade) and notify the policy provider.
       
   117 			// This is done below.
       
   118 			break;
       
   119 			}
       
   120 		case EMobilityWaitForUpgradePolicy:
       
   121 		case EMobilityWaitForDowngradePolicy:
       
   122 		case EMobilityWaitForUpgradePolicyAndOldSocketClose:
       
   123 			{
       
   124 			// If in these states, this function call indicates that the
       
   125 			// last received carrier availability notification is no longer
       
   126 			// applicable. This could happen for a number of reasons:
       
   127 			//   - the preferred carrier becomes unavailable
       
   128 			//   - the notice changes from an upgrade to a downgrade
       
   129 			//   - any others?
       
   130 			// Anyway, what needs to happen is for the policy provider to have
       
   131 			// its last notification cancelled, and the new one issued.
       
   132 			CImMobilityPolicyProvider::GetRef().Cancel(iAccountId);
       
   133 			break;
       
   134 			}
       
   135 		case EMobilityWaitForOldSocketClose:
       
   136 		case EMobilityWaitForOldSocketCloseCarrierRejected:
       
   137 			{
       
   138 			// If in this state, the previous notice was for an upgrade, and 
       
   139 			// the old connection is still being tidied up. If the new notice
       
   140 			// is for a downgrade, then the old connection must be torn down
       
   141 			// immediately. 
       
   142 			if (!aIsUpgrade)
       
   143 				{
       
   144 				iMtm.CarrierLost();
       
   145 				// If the new connection is the same as the new connection for
       
   146 				// the previous notice then the carrier change has already been
       
   147 				// accepted - otherwise fall through to re-notify the policy provider
       
   148 				if (aNewAp.AccessPoint()==iNewAp.AccessPoint())
       
   149 					{
       
   150 					iState = EMobilityWaitForMigrate;
       
   151 
       
   152 //#ifdef __MOBILITY_TEST_FRAMEWORK
       
   153 //					TBool handled = CImMobilityTestFramework::Response(*this, KMobilityTestResponseMigrateToPreferredCarrier);
       
   154 //					if (!handled)
       
   155 //#endif //__MOBILITY_TEST_FRAMEWORK
       
   156 					iCommsMobilityApi->MigrateToPreferredCarrier();
       
   157 					// job done, return
       
   158 					return;
       
   159 					}
       
   160 				// break;
       
   161 				}
       
   162 			else
       
   163 				{
       
   164 				// If the new notice is for an upgrade, it can only
       
   165 				// mean that an even better carrier has become available
       
   166 				// while waiting for the old old carrier to be tidied up!
       
   167 				iState = EMobilityWaitForUpgradePolicyAndOldSocketClose;
       
   168 				CImMobilityPolicyProvider::GetRef().PreferredCarrierAvailable(*this, iAccountId, iMtmUid, iMtm.MobilityProgress(), aOldAp, aNewAp, aIsUpgrade, aIsSeamless);
       
   169 				return;
       
   170 				}
       
   171 			break;
       
   172 			}
       
   173 		case EMobilityUninitialised:
       
   174 		default:
       
   175 			{
       
   176 			// unexpected in this state
       
   177 			__ASSERT_DEBUG(EFalse, gPanic(EPanicInvalidMobilityState));
       
   178 			}
       
   179 		}
       
   180 	
       
   181 	// pass the notification up to the policy provider.
       
   182 	if (aIsUpgrade)
       
   183 		{
       
   184 		if (iState != EMobilityWaitForUpgradePolicyAndOldSocketClose)
       
   185 			{
       
   186 			iState = EMobilityWaitForUpgradePolicy;
       
   187 			}
       
   188 		CImMobilityPolicyProvider::GetRef().PreferredCarrierAvailable(*this, iAccountId, iMtmUid, iMtm.MobilityProgress(), aOldAp, aNewAp, aIsUpgrade, aIsSeamless);
       
   189 		}
       
   190 	else
       
   191 		{
       
   192 		iMtm.CarrierLost();
       
   193 		iState = EMobilityWaitForDowngradePolicy;
       
   194 		CImMobilityPolicyProvider::GetRef().PreferredCarrierAvailable(*this, iAccountId, iMtmUid, iMtm.MobilityProgress(), aOldAp, aNewAp, aIsUpgrade, aIsSeamless);
       
   195 		}
       
   196 	}
       
   197 	
       
   198 /**
       
   199 Notification that the new carrier is active and available for connecting sockets.
       
   200 
       
   201 @param aNewAp		- info about the new carrier
       
   202 @param aIsSeamless  - indicates if a migration will be seamless
       
   203 */
       
   204 void CImMobilityManager::NewCarrierActive(TAccessPointInfo aNewAp, TBool aIsSeamless)
       
   205 	{
       
   206 	__LOG_FORMAT((KDefaultLog, "<%d> NewCarrierActive(state:%d new:%d isSless:%d)", iAccountId, iState, aNewAp.AccessPoint(), aIsSeamless));
       
   207 	switch (iState)
       
   208 		{
       
   209 		case EMobilityWaitForMigrate:
       
   210 			{
       
   211 			iState = EMobilityConnectingToNewCarrier;
       
   212 			iMtm.NewCarrierActive(aNewAp, aIsSeamless);
       
   213 			break;
       
   214 			}
       
   215 		case EMobilityUninitialised:
       
   216 		case EMobilityIdle:
       
   217 		case EMobilityWaitForUpgradePolicy:
       
   218 		case EMobilityWaitForDowngradePolicy:
       
   219 		case EMobilityWaitForOldSocketClose:
       
   220 		case EMobilityConnectingToNewCarrier:
       
   221 		case EMobilityWaitForUpgradePolicyAndOldSocketClose:
       
   222 		case EMobilityWaitForOldSocketCloseCarrierRejected:
       
   223 		default:
       
   224 			{
       
   225 			// unexpected in this state
       
   226 			__ASSERT_DEBUG(EFalse, gPanic(EPanicInvalidMobilityState));
       
   227 			}
       
   228 		}
       
   229 	}
       
   230 
       
   231 /**
       
   232 Notification that an error has occured.
       
   233 This indicates that the RConnection in use is no longer valid, therefore
       
   234 the Server MTM will be immediately notified. Once this is done, this function
       
   235 MUST NOT perform any actions that use class data, as the Server MTM may delete
       
   236 its instance of CImMobilityManager.
       
   237 
       
   238 @param aError - error code
       
   239 */
       
   240 void CImMobilityManager::Error(TInt aError)
       
   241 	{
       
   242 	// If we're closing down, we don't need to handle further notifications from Comms,
       
   243 	// and we can safely return from here.
       
   244 	if(iIsCancelled)
       
   245 		{
       
   246 		return;
       
   247 		}
       
   248 	
       
   249 	__LOG_FORMAT((KDefaultLog, "<%d> Error (state:%d error:%d)", iAccountId, iState, aError));
       
   250 	switch (iState)
       
   251 		{
       
   252 		case EMobilityWaitForUpgradePolicy:
       
   253 		case EMobilityWaitForDowngradePolicy:
       
   254 		case EMobilityWaitForUpgradePolicyAndOldSocketClose:
       
   255 			{
       
   256 			// cancel the policy request.
       
   257 			CImMobilityPolicyProvider::GetRef().Cancel(iAccountId);
       
   258 			// fall through
       
   259 			}
       
   260 		case EMobilityIdle:
       
   261 			{
       
   262 			iState = EMobilityUninitialised;
       
   263 			iMtm.MobilityError(aError);
       
   264 			break;
       
   265 			}
       
   266 		case EMobilityWaitForOldSocketClose:
       
   267 		case EMobilityWaitForMigrate:
       
   268 		case EMobilityConnectingToNewCarrier:
       
   269 		case EMobilityWaitForOldSocketCloseCarrierRejected:
       
   270 			{
       
   271 			iState = EMobilityUninitialised;
       
   272 			// Tell the policy provider about it. (must happen before informing MTM)
       
   273 			CImMobilityPolicyProvider::GetRef().MigrationComplete(iAccountId, KImMigrateMobilityError, iNewAp);
       
   274 			// Inform the MTM. Do this last - this may delete the mobility manager
       
   275 			iMtm.MobilityError(aError);
       
   276 			break;
       
   277 			}
       
   278 
       
   279 		case EMobilityUninitialised:
       
   280 		default:
       
   281 			{
       
   282 			// unexpected in this state
       
   283 			__ASSERT_DEBUG(EFalse, gPanic(EPanicInvalidMobilityState));
       
   284 			}
       
   285 		}
       
   286 	}
       
   287 	
       
   288 /**
       
   289 Instruction from the Messaging Plugin Provider that the new carrier is to be accepted.
       
   290 
       
   291 @param aAction - action that the server MTM should take when closing existing sockets.
       
   292 */
       
   293 EXPORT_C void CImMobilityManager::AcceptNewCarrier(TImMobilityAction aAction)
       
   294 	{
       
   295 	__LOG_FORMAT((KDefaultLog, "<%d> Accept New Carrier (state:%d action:%d)", iAccountId, iState, aAction));
       
   296 	switch (iState)
       
   297 		{
       
   298 		case EMobilityWaitForDowngradePolicy:
       
   299 			{
       
   300 			// old connections already closed - just inform the mobility framework
       
   301 			iState = EMobilityWaitForMigrate;
       
   302 //#ifdef __MOBILITY_TEST_FRAMEWORK
       
   303 //			TBool handled = CImMobilityTestFramework::Response(*this, KMobilityTestResponseMigrateToPreferredCarrier);
       
   304 //			if (!handled)
       
   305 //#endif //__MOBILITY_TEST_FRAMEWORK
       
   306 			iCommsMobilityApi->MigrateToPreferredCarrier();
       
   307 			break;
       
   308 			}
       
   309 		case EMobilityWaitForUpgradePolicy:
       
   310 			{
       
   311 			if (aAction == KAcceptImmediately)
       
   312 				{
       
   313 				iMtm.CarrierLost();
       
   314 				iState = EMobilityWaitForMigrate;
       
   315 //#ifdef __MOBILITY_TEST_FRAMEWORK
       
   316 //				TBool handled = CImMobilityTestFramework::Response(*this, KMobilityTestResponseMigrateToPreferredCarrier);
       
   317 //				if (!handled)
       
   318 //#endif //__MOBILITY_TEST_FRAMEWORK
       
   319 				iCommsMobilityApi->MigrateToPreferredCarrier();
       
   320 				}
       
   321 			else
       
   322 				{
       
   323 				iState = EMobilityWaitForOldSocketClose;
       
   324 				iMtm.PrepareForNewCarrier(aAction, iIsSeamless);
       
   325 				}
       
   326 			break;
       
   327 			}
       
   328 		case EMobilityWaitForUpgradePolicyAndOldSocketClose:
       
   329 			{
       
   330 			
       
   331 			if (aAction == KAcceptImmediately)
       
   332 				{
       
   333 				iMtm.CarrierLost();
       
   334 				iState = EMobilityWaitForMigrate;
       
   335 //#ifdef __MOBILITY_TEST_FRAMEWORK
       
   336 //				TBool handled = CImMobilityTestFramework::Response(*this, KMobilityTestResponseMigrateToPreferredCarrier);
       
   337 //				if (!handled)
       
   338 //#endif //__MOBILITY_TEST_FRAMEWORK
       
   339 				iCommsMobilityApi->MigrateToPreferredCarrier();
       
   340 				}
       
   341 			else
       
   342 				{
       
   343 				// already waiting to finish using old carrier
       
   344 				// do not update migration action, stick to first choice.
       
   345 				iState = EMobilityWaitForOldSocketClose;
       
   346 				}
       
   347 			break;
       
   348 			}
       
   349 
       
   350 		case EMobilityUninitialised:
       
   351 		case EMobilityIdle:
       
   352 		case EMobilityWaitForOldSocketClose:
       
   353 		case EMobilityWaitForOldSocketCloseCarrierRejected:
       
   354 		case EMobilityWaitForMigrate:
       
   355 		case EMobilityConnectingToNewCarrier:
       
   356 		default:
       
   357 			{
       
   358 			// unexpected in this state
       
   359 			__ASSERT_DEBUG(EFalse, gPanic(EPanicInvalidMobilityState));
       
   360 			}
       
   361 		}
       
   362 	}
       
   363 
       
   364 /**
       
   365 Instruction from the Messaging Plugin Provider that the new carrier is to be ignored.
       
   366 
       
   367 @param aAction - action that the server MTM should take when closing existing sockets.
       
   368 */
       
   369 EXPORT_C void CImMobilityManager::IgnoreNewCarrier()
       
   370 	{
       
   371 	__LOG_FORMAT((KDefaultLog, "<%d> Error (state:%d)", iAccountId, iState));
       
   372 	switch (iState)
       
   373 		{
       
   374 		case EMobilityWaitForUpgradePolicyAndOldSocketClose:
       
   375 			{
       
   376 			// defensive handling of "double upgrade" situation, in which an
       
   377 			// upgrade is accepted, then a second upgrade notification is
       
   378 			// received before the first handshake completes, and this second
       
   379 			// upgrage is rejected.
       
   380 			iState = EMobilityWaitForOldSocketCloseCarrierRejected;
       
   381 //#ifdef __MOBILITY_TEST_FRAMEWORK
       
   382 //			TBool handled = CImMobilityTestFramework::Response(*this, KMobilityTestResponseIgnorePreferredCarrier);
       
   383 //			if (!handled)
       
   384 //#endif //__MOBILITY_TEST_FRAMEWORK
       
   385 			iCommsMobilityApi->IgnorePreferredCarrier();
       
   386 			break;
       
   387 			}
       
   388 		case EMobilityWaitForUpgradePolicy:
       
   389 		case EMobilityWaitForDowngradePolicy:
       
   390 			{
       
   391 			iState = EMobilityIdle;
       
   392 //#ifdef __MOBILITY_TEST_FRAMEWORK
       
   393 //			TBool handled = CImMobilityTestFramework::Response(*this, KMobilityTestResponseIgnorePreferredCarrier);
       
   394 //			if (!handled)
       
   395 //#endif //__MOBILITY_TEST_FRAMEWORK
       
   396 			iCommsMobilityApi->IgnorePreferredCarrier();
       
   397 			break;
       
   398 			}
       
   399 		case EMobilityUninitialised:
       
   400 		case EMobilityIdle:
       
   401 		case EMobilityWaitForOldSocketClose:
       
   402 		case EMobilityWaitForOldSocketCloseCarrierRejected:
       
   403 		case EMobilityWaitForMigrate:
       
   404 		case EMobilityConnectingToNewCarrier:
       
   405 		default:
       
   406 			{
       
   407 			// unexpected in this state
       
   408 			__ASSERT_DEBUG(EFalse, gPanic(EPanicInvalidMobilityState));
       
   409 			}
       
   410 		}
       
   411 	}
       
   412 
       
   413 /**
       
   414 Notification from the server MTM that existing sockets have been closed and that
       
   415 it is ready for migration to the new carrier to occur.
       
   416 */
       
   417 EXPORT_C void CImMobilityManager::MigrateToNewCarrier()
       
   418 	{
       
   419 	__LOG_FORMAT((KDefaultLog, "<%d> MigrateToNewCarrier(state:%d)", iAccountId, iState));
       
   420 	// otherwise... switch on state.
       
   421 	switch (iState)
       
   422 		{
       
   423 		case EMobilityWaitForOldSocketClose:
       
   424 			{
       
   425 			iState = EMobilityWaitForMigrate;
       
   426 //#ifdef __MOBILITY_TEST_FRAMEWORK
       
   427 //			TBool handled = CImMobilityTestFramework::Response(*this, KMobilityTestResponseMigrateToPreferredCarrier);
       
   428 //			if (!handled)
       
   429 //endif //__MOBILITY_TEST_FRAMEWORK
       
   430 			iCommsMobilityApi->MigrateToPreferredCarrier();
       
   431 			break;
       
   432 			}
       
   433 		case EMobilityWaitForUpgradePolicyAndOldSocketClose:
       
   434 			{
       
   435 			// ahha! we have since received a notice that an even better
       
   436 			// carrier has come along. Wait for what we should do.
       
   437 			iState = EMobilityWaitForUpgradePolicy;
       
   438 			break;
       
   439 			}
       
   440 		case EMobilityWaitForOldSocketCloseCarrierRejected:
       
   441 			{
       
   442 			// instruct the MTM to reconnect - using the original AP
       
   443 			// This is effectively the same as making an initial connection
       
   444 			// so slip to default connected state.
       
   445 			iState = EMobilityIdle;
       
   446 			iMtm.NewCarrierActive(iOldAp, iIsSeamless);
       
   447 			break;
       
   448 			}
       
   449 		case EMobilityUninitialised:
       
   450 		case EMobilityIdle:
       
   451 		case EMobilityWaitForUpgradePolicy:
       
   452 		case EMobilityWaitForDowngradePolicy:
       
   453 		case EMobilityWaitForMigrate:
       
   454 		case EMobilityConnectingToNewCarrier:
       
   455 		default:
       
   456 			{
       
   457 			// unexpected in this state
       
   458 			__ASSERT_DEBUG(EFalse, gPanic(EPanicInvalidMobilityState));
       
   459 			}
       
   460 		}
       
   461 	}
       
   462 
       
   463 /**
       
   464 Notification from the server MTM that it has successfully re-established connection
       
   465 with the remote server using the new carrier.
       
   466 */
       
   467 EXPORT_C void CImMobilityManager::NewCarrierAccepted()
       
   468 	{
       
   469 	__LOG_FORMAT((KDefaultLog, "<%d> NewCarrierAccepted(state:%d)", iAccountId, iState));
       
   470 	switch (iState)
       
   471 		{
       
   472 		case EMobilityIdle:
       
   473 			{
       
   474 			// Do nothing. This might occur if previous state
       
   475 			// was EMobilityWaitForOldSocketCloseCarrierRejected
       
   476 			// the mobility framework is not expecting a response.
       
   477 			break;
       
   478 			}
       
   479 		case EMobilityConnectingToNewCarrier:
       
   480 			{
       
   481 			iState = EMobilityIdle;
       
   482 //#ifdef __MOBILITY_TEST_FRAMEWORK
       
   483 //			TBool handled = CImMobilityTestFramework::Response(*this, KMobilityTestResponseNewCarrierAccepted);
       
   484 //			if (!handled)
       
   485 //#endif //__MOBILITY_TEST_FRAMEWORK
       
   486 			iCommsMobilityApi->NewCarrierAccepted();
       
   487 			// Tell the policy provider about it.
       
   488 			CImMobilityPolicyProvider::GetRef().MigrationComplete(iAccountId, KImMigrateOK, iNewAp);
       
   489 			break;
       
   490 			}
       
   491 		case EMobilityUninitialised:
       
   492 		case EMobilityWaitForUpgradePolicy:
       
   493 		case EMobilityWaitForDowngradePolicy:
       
   494 		case EMobilityWaitForUpgradePolicyAndOldSocketClose:
       
   495 		case EMobilityWaitForOldSocketCloseCarrierRejected:
       
   496 		case EMobilityWaitForOldSocketClose:
       
   497 		case EMobilityWaitForMigrate:
       
   498 		default:
       
   499 			{
       
   500 			// unexpected in this state
       
   501 			__ASSERT_DEBUG(EFalse, gPanic(EPanicInvalidMobilityState));
       
   502 			}
       
   503 		}
       
   504 	}
       
   505 
       
   506 /**
       
   507 Notification from the server MTM that it has been unable to re-established connection
       
   508 with the remote server using the new carrier.
       
   509 */
       
   510 EXPORT_C void CImMobilityManager::NewCarrierRejected()
       
   511 	{
       
   512 	__LOG_FORMAT((KDefaultLog, "<%d> NewCarrierRejected(state:%d)", iAccountId, iState));
       
   513 	switch (iState)
       
   514 		{
       
   515 		case EMobilityIdle:   // this results from the initial carrier being rejected.
       
   516 		case EMobilityConnectingToNewCarrier:
       
   517 			{
       
   518 			iState = EMobilityIdle;
       
   519 //#ifdef __MOBILITY_TEST_FRAMEWORK
       
   520 //			TBool handled = CImMobilityTestFramework::Response(*this, KMobilityTestResponseNewCarrierRejected);
       
   521 //			if (!handled)
       
   522 //#endif //__MOBILITY_TEST_FRAMEWORK
       
   523 			iCommsMobilityApi->NewCarrierRejected();
       
   524 			// tell the policy provider about it.
       
   525 			CImMobilityPolicyProvider::GetRef().MigrationComplete(iAccountId, KImMigrateCouldNotReconnect, iNewAp);
       
   526 			break;
       
   527 			}
       
   528 		case EMobilityUninitialised:
       
   529 		case EMobilityWaitForUpgradePolicy:
       
   530 		case EMobilityWaitForDowngradePolicy:
       
   531 		case EMobilityWaitForUpgradePolicyAndOldSocketClose:
       
   532 		case EMobilityWaitForOldSocketCloseCarrierRejected:
       
   533 		case EMobilityWaitForOldSocketClose:
       
   534 		case EMobilityWaitForMigrate:
       
   535 		default:
       
   536 			{
       
   537 			// unexpected in this state
       
   538 			__ASSERT_DEBUG(EFalse, gPanic(EPanicInvalidMobilityState));
       
   539 			}
       
   540 		}
       
   541 	}