telephonyserverplugins/multimodetsy/hayes/TSYCONFG.CPP
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 1997-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 // TSY Configuation Class
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "ATSTD.H"
       
    19 #include "TSYCONFG.H"
       
    20 #include "mSLOGGER.H"
       
    21 #include <commsdattypesv1_1.h>
       
    22 #include <commsdat_partner.h>
       
    23 using namespace CommsDat;
       
    24 
       
    25 // 
       
    26 // Macros
       
    27 //
       
    28 
       
    29 #ifdef __LOGDEB__
       
    30 _LIT8(KLogEntry,"CTsyConfig::%S\t%S");
       
    31 #define LOCAL_LOGTEXT(function,text) {_LIT8(F,function);_LIT8(T,text);LOGTEXT3(KLogEntry,&F,&T);}
       
    32 #else
       
    33 #define LOCAL_LOGTEXT(function,text)
       
    34 #endif
       
    35 
       
    36 //
       
    37 // Define some defaults if the modem settings can't be found
       
    38 //
       
    39 const TInt KDefaultLocationInternalPref=0;
       
    40 const RCall::TMonitorSpeakerControl KDefaultModemSpeakerSetting=RCall::EMonitorSpeakerControlOnUntilCarrier;
       
    41 const RCall::TMonitorSpeakerVolume KDefaultMonitorSpeakerVolume=RCall::EMonitorSpeakerVolumeOff;
       
    42 const RCall::TWaitForDialTone KDefaultWaitForDialTone=RCall::EDialToneNoWait;
       
    43  
       
    44 CTsyConfig* CTsyConfig::NewL(TBool aExplicit) 
       
    45 /**
       
    46  * Passed a reference to the phone mode so that the default settings will not be altered whilst
       
    47  * a call is in progress
       
    48  */
       
    49 	{
       
    50 	CTsyConfig* tsyConfig=new(ELeave) CTsyConfig();
       
    51 	CleanupStack::PushL(tsyConfig);
       
    52 	tsyConfig->ConstructL(aExplicit); 
       
    53 	CleanupStack::Pop();
       
    54 	return (tsyConfig);
       
    55 	}
       
    56 	
       
    57 CTsyConfig::CTsyConfig()
       
    58 	{}
       
    59 
       
    60 void CTsyConfig::ConstructL(TBool aExplicit)
       
    61 	{
       
    62 	iLocationId = 0;
       
    63 	TInt r=KErrNone;
       
    64 	iManualConfigMode=aExplicit;
       
    65 	
       
    66 	if(!aExplicit)
       
    67 		{
       
    68 		for (TInt i=0;i<10;i++)
       
    69 			{
       
    70 			TRAP(r, GetCurrentTableViewsL()); // Place a cursor on the default modem record in comms database server
       
    71 			if (r==KErrAccessDenied) // if we get access denied from DBMS, which is a timing thing, just re-post
       
    72 				{
       
    73 				User::After(1000000);
       
    74 				continue;
       
    75 				}
       
    76 			else
       
    77 				break;
       
    78 			}
       
    79 		if (r)
       
    80 			{
       
    81 			LOGTEXT(_L8("CommDB values seem to be corrupt"));
       
    82 			ResetCurrentTableViews(); // clean up everything
       
    83 			User::Leave(KErrEtelModemSettingsCorrupt);
       
    84 			}
       
    85 
       
    86 		GetLocationModemSettingsL(); // Get other location and modem settings 
       
    87 		ResetCurrentTableViews(); // Clear location and modem table views and close handle to CCommsDatabase
       
    88 		}
       
    89 	}
       
    90 
       
    91 void CTsyConfig::GetLocationModemSettingsL()
       
    92 /**
       
    93  * Gets some commonly used settings from the Location and Modem Table Views and stores them
       
    94  * internally as these are not likely to change. 
       
    95  * If some of these settings are not found in the table view then a predefined default values are
       
    96  * used.
       
    97  */
       
    98 	{
       
    99 	if(iLocationId == 0)
       
   100 		{
       
   101 		iInterval=KDefaultLocationInternalPref;
       
   102 		iWaitForDialTonePref=KDefaultWaitForDialTone;
       
   103 		}
       
   104 	else
       
   105 		{
       
   106 		TBool value(EFalse);
       
   107 		CMDBField<TUint32>* intervalField = new(ELeave) CMDBField<TUint32>(KCDTIdPauseAfterDialOut);
       
   108 		CleanupStack::PushL(intervalField);
       
   109 		intervalField->SetRecordId(iLocationId);
       
   110 		intervalField->LoadL(*iDbSession);
       
   111 		iInterval = *intervalField;
       
   112 		CleanupStack::PopAndDestroy(intervalField);
       
   113 		
       
   114 		CMDBField<TUint32>* valueField = new(ELeave) CMDBField<TUint32>(KCDTIdWaitForDialTone);		
       
   115 		CleanupStack::PushL(valueField);
       
   116 		valueField->SetRecordId(iLocationId);
       
   117 		valueField->LoadL(*iDbSession);
       
   118 		value = *valueField;
       
   119 		CleanupStack::PopAndDestroy(valueField);
       
   120 		
       
   121 		if (value)
       
   122 			iWaitForDialTonePref = RCall::EDialToneWait;
       
   123 		else
       
   124 			iWaitForDialTonePref = RCall::EDialToneNoWait;
       
   125 		}
       
   126 
       
   127 	if (iModemBearer != 0)
       
   128 		{
       
   129 		CMDBField<TUint32>* speakerPrefField = new(ELeave) CMDBField<TUint32>(KCDTIdSpeakerPref);
       
   130 		CleanupStack::PushL(speakerPrefField);
       
   131 		speakerPrefField->SetRecordId(iModemBearer);
       
   132 		speakerPrefField->LoadL(*iDbSession);
       
   133 		iSpeakerSetting = static_cast<RCall::TMonitorSpeakerControl>(static_cast<TUint32>(*speakerPrefField));
       
   134 		CleanupStack::PopAndDestroy(speakerPrefField);
       
   135 		
       
   136 		CMDBField<TUint32>* speakerVolPrefField = new(ELeave) CMDBField<TUint32>(KCDTIdSpeakerVolPref);
       
   137 		CleanupStack::PushL(speakerVolPrefField);
       
   138 		speakerVolPrefField->SetRecordId(iModemBearer);
       
   139 		speakerVolPrefField->LoadL(*iDbSession);
       
   140 		iSpeakerVolume = static_cast<RCall::TMonitorSpeakerVolume>(static_cast<TUint32>(*speakerVolPrefField));			
       
   141 		CleanupStack::PopAndDestroy(speakerVolPrefField);
       
   142 		}
       
   143 
       
   144 	TUint32 rate;
       
   145 	TUint32 dataBits;
       
   146 	TUint32 stopBits;
       
   147 	TUint32 parity;
       
   148 	TUint32 handshake;
       
   149 	
       
   150 	if (iModemBearer == 0)
       
   151 		{
       
   152 		iSpeakerSetting = KDefaultModemSpeakerSetting;
       
   153 		iSpeakerVolume = KDefaultMonitorSpeakerVolume;
       
   154 		User::Leave(KErrNotFound);
       
   155 		}
       
   156 
       
   157 	CMDBField<TUint32>* rateField = new(ELeave) CMDBField<TUint32>(KCDTIdRate);
       
   158 	CleanupStack::PushL(rateField);
       
   159 	rateField->SetRecordId(iModemBearer);
       
   160 	rateField->LoadL(*iDbSession);
       
   161 	rate = *rateField;
       
   162 	CleanupStack::PopAndDestroy(rateField);
       
   163 	
       
   164 	CMDBField<TUint32>* dataBitsField = new(ELeave) CMDBField<TUint32>(KCDTIdDataBits);
       
   165 	CleanupStack::PushL(dataBitsField);
       
   166 	dataBitsField->SetRecordId(iModemBearer);
       
   167 	dataBitsField->LoadL(*iDbSession);
       
   168 	dataBits = *dataBitsField;
       
   169 	CleanupStack::PopAndDestroy(dataBitsField);
       
   170 
       
   171 	CMDBField<TUint32>* stopBitsField = new(ELeave) CMDBField<TUint32>(KCDTIdStopBits);
       
   172 	CleanupStack::PushL(stopBitsField);
       
   173 	stopBitsField->SetRecordId(iModemBearer);
       
   174 	stopBitsField->LoadL(*iDbSession);
       
   175 	stopBits = *stopBitsField;
       
   176 	CleanupStack::PopAndDestroy(stopBitsField);
       
   177 	
       
   178 	CMDBField<TUint32>* parityField = new(ELeave) CMDBField<TUint32>(KCDTIdParity);
       
   179 	CleanupStack::PushL(parityField);
       
   180 	parityField->SetRecordId(iModemBearer);
       
   181 	parityField->LoadL(*iDbSession);
       
   182 	parity = *parityField;
       
   183 	CleanupStack::PopAndDestroy(parityField);
       
   184 	
       
   185 	CMDBField<TUint32>* handshakeField = new(ELeave) CMDBField<TUint32>(KCDTIdHandshaking);
       
   186 	CleanupStack::PushL(handshakeField);
       
   187 	handshakeField->SetRecordId(iModemBearer);
       
   188 	handshakeField->LoadL(*iDbSession);
       
   189 	handshake = *handshakeField;
       
   190 	CleanupStack::PopAndDestroy(handshakeField);
       
   191 
       
   192 	iConfig.iRate = (TBps)rate;
       
   193 	iConfig.iDataBits = (TDataBits)dataBits;
       
   194 	iConfig.iStopBits = (TStopBits)stopBits;
       
   195 	iConfig.iParity = (TParity)parity;
       
   196 	iConfig.iHandshake = (TUint)handshake;
       
   197 	}
       
   198 
       
   199 CTsyConfig::~CTsyConfig()
       
   200 	{
       
   201 	// Just in case these have not been cleared
       
   202 	delete iDbSession;
       
   203 	}
       
   204 
       
   205 void CTsyConfig::CommConfigL(TCommConfigV01& aConfig)
       
   206 	{
       
   207 	aConfig = iConfig;
       
   208 	}
       
   209 
       
   210 TInt CTsyConfig::ConfigModemStringL(const TDesC& aStringTag, TDes8& aString)
       
   211 	{
       
   212 	TInt r=KErrNone;
       
   213 	for (TInt i=0;i<10;i++)
       
   214 		{
       
   215 		TRAP(r, GetCurrentTableViewsL()); // Place a cursor on the default modem record in comms database server
       
   216 		if (r==KErrAccessDenied) // if we get access denied from DBMS, which is a timing thing, just re-post
       
   217 			{
       
   218 			User::After(1000000);
       
   219 			continue;
       
   220 			}
       
   221 		else
       
   222 			break;
       
   223 		}
       
   224 	if (r)
       
   225 		{
       
   226 		LOGTEXT(_L8("CommDB values seem to be corrupt"));
       
   227 		ResetCurrentTableViews(); // clean up everything
       
   228 		return (KErrEtelModemSettingsCorrupt);
       
   229 		}
       
   230 
       
   231 	CCDModemBearerRecord* modemRecord = static_cast<CCDModemBearerRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdModemBearerRecord));
       
   232 	CleanupStack::PushL(modemRecord);
       
   233 	modemRecord->SetRecordId(iModemBearer);
       
   234 	modemRecord->LoadL(*iDbSession);
       
   235 	
       
   236 	TInt ret;
       
   237 	TInt type(0);
       
   238 	CMDBElement* baseField = NULL;
       
   239 	TRAP(ret, baseField = modemRecord->GetFieldByNameL(aStringTag, type));
       
   240 	if (ret == KErrNone)
       
   241 		{
       
   242 		// check for type
       
   243 		switch(type)
       
   244 			{
       
   245 			case EMedText:
       
   246 			case EText:
       
   247 				{
       
   248 				CMDBField<TDesC>* field16 = static_cast<CMDBField<TDesC>*>(baseField);
       
   249 				const TDesC& refField = *field16;
       
   250 				aString.Copy(refField);
       
   251 				ret = KErrNone;
       
   252 				}
       
   253 				break;
       
   254 			case EDesC8:
       
   255 				{
       
   256 				CMDBField<TDesC8>* field = static_cast<CMDBField<TDesC8>*>(baseField);
       
   257 				aString = *field;
       
   258 				ret = KErrNone;
       
   259 				}
       
   260 				break;
       
   261 			default:
       
   262 				ret = KErrNotFound;
       
   263 			}
       
   264     	}
       
   265 	CleanupStack::PopAndDestroy(modemRecord);
       
   266 
       
   267 	ResetCurrentTableViews(); // Clear location and modem table views and close handle to CCommsDatabase
       
   268 	return ret;
       
   269 	}
       
   270 
       
   271 TInt CTsyConfig::ConfigModemStringL(const TDesC& aStringTag, TDes16& aString)
       
   272 	{
       
   273 	TInt r=KErrNone;
       
   274 	for (TInt i=0;i<10;i++)
       
   275 		{
       
   276 		TRAP(r, GetCurrentTableViewsL()); // Place a cursor on the default modem record in comms database server
       
   277 		if (r==KErrAccessDenied) // if we get access denied from DBMS, which is a timing thing, just re-post
       
   278 			{
       
   279 			User::After(1000000);
       
   280 			continue;
       
   281 			}
       
   282 		else
       
   283 			break;
       
   284 		}
       
   285 	if (r)
       
   286 		{
       
   287 		LOGTEXT(_L8("CommDB values seem to be corrupt"));
       
   288 		ResetCurrentTableViews(); // clean up everything
       
   289 		return (KErrEtelModemSettingsCorrupt);
       
   290 		}
       
   291 
       
   292 	CCDModemBearerRecord* modemRecord = static_cast<CCDModemBearerRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdModemBearerRecord));
       
   293 	CleanupStack::PushL(modemRecord);
       
   294 	modemRecord->SetRecordId(iModemBearer);
       
   295 	modemRecord->LoadL(*iDbSession);
       
   296 
       
   297 	
       
   298 	TInt ret;
       
   299 	TInt type(0);
       
   300 	CMDBElement* baseField = NULL;
       
   301 	TRAP(ret, baseField = modemRecord->GetFieldByNameL(aStringTag, type));
       
   302 	if (ret == KErrNone)
       
   303 		{
       
   304 		// check for type
       
   305 		switch(type)
       
   306 			{
       
   307 			case EMedText:
       
   308 			case EText:
       
   309 		
       
   310 				{
       
   311 				CMDBField<TDesC>* field = static_cast<CMDBField<TDesC>*>(baseField);
       
   312 				aString = *field;
       
   313 				ret = KErrNone;
       
   314 				}
       
   315 				break;
       
   316 			case EDesC8:
       
   317 				{
       
   318 				// des16 needs to be cast to des8
       
   319 				CMDBField<TDesC8>* field8 = static_cast<CMDBField<TDesC8>*>(baseField);
       
   320 				const TDesC8& refField = *field8;
       
   321 				aString.Copy(refField);
       
   322 				ret = KErrNone;
       
   323 				}
       
   324 				break;
       
   325 			default:
       
   326 				ret = KErrNotFound;
       
   327 			}
       
   328 		}
       
   329 	
       
   330 	CleanupStack::PopAndDestroy(modemRecord);
       
   331 
       
   332 	ResetCurrentTableViews(); // Clear location and modem table views and close handle to CCommsDatabase
       
   333 	return ret;
       
   334 	}
       
   335 
       
   336 TInt CTsyConfig::ConfigModemString(const TDesC& aStringTag, TDes8& aString)
       
   337 	{
       
   338 	TInt ret = KErrNone;
       
   339 	TRAPD(error, ret = ConfigModemStringL(aStringTag, aString));
       
   340 	if(error != KErrNone)
       
   341 		{
       
   342 		ret = error;
       
   343 		}
       
   344 	return ret;
       
   345 	}
       
   346 
       
   347 TInt CTsyConfig::ConfigModemString(const TDesC& aStringTag, TDes16& aString)
       
   348 	{
       
   349 	TInt ret = KErrNone;
       
   350 	TRAPD(error, ret = ConfigModemStringL(aStringTag, aString));
       
   351 	if(error != KErrNone)
       
   352 		{
       
   353 		ret = error;
       
   354 		}
       
   355 	return ret;
       
   356 	}
       
   357 
       
   358 void CTsyConfig::GetIntervalPref(TInt& aInterval)
       
   359 /**
       
   360  * Stores the Interval Preferences settings internally. These settings are stored on construction
       
   361  * of the CTsyConfig object.
       
   362  * @param aInterval Interval Preference setting
       
   363  */
       
   364 	{
       
   365 	aInterval = iInterval;
       
   366 	}
       
   367 
       
   368 void CTsyConfig::GetSpeakerSettingPref(RCall::TMonitorSpeakerControl& aSpeakerSetting)
       
   369 /**
       
   370  * Stores the Speaker Preferences settings internally. These settings are stored on construction
       
   371  * of the CTsyConfig object.
       
   372  * @param aSpeakerSetting Speaker Preference setting
       
   373  */
       
   374 	{
       
   375 	aSpeakerSetting = iSpeakerSetting;
       
   376 	}
       
   377 
       
   378 void CTsyConfig::GetSpeakerVolumePref(RCall::TMonitorSpeakerVolume& aSpeakerVolume)
       
   379 /**
       
   380  * Stores the Speaker Volume Preferences settings internally. These settings are stored on construction
       
   381  * of the CTsyConfig object.
       
   382  * @param aSpeakerVolume Speaker Volume setting
       
   383  */
       
   384 	{
       
   385 	aSpeakerVolume = iSpeakerVolume;
       
   386 	}
       
   387 
       
   388 void CTsyConfig::GetWaitForDialTonePref(RCall::TWaitForDialTone& aWaitForDialTonePref)
       
   389 /**
       
   390  * Stores the Dial Tone Preferences settings internally. These settings are stored on construction
       
   391  * of the CTsyConfig object.
       
   392  * @param aWaitForDialTonePref Wait for Dial Tone Preference setting
       
   393  */
       
   394 	{
       
   395 	aWaitForDialTonePref = iWaitForDialTonePref;
       
   396 	}
       
   397 
       
   398 TInt CTsyConfig::PortConfig(TCommConfig& aConfigPckg, TConfigType aConfigType)
       
   399 /**
       
   400  * Gets the port config settings and masks out appropriate handshaking settings
       
   401  * according to whether state is about to initialise, just connected or about to hang up
       
   402  */ 
       
   403 	{
       
   404 	TInt r=KErrNone;
       
   405 	for (TInt i=0;i<10;i++)
       
   406 		{
       
   407 		TRAP(r, GetCurrentTableViewsL()); // Place a cursor on the default modem record in comms database server
       
   408 		if (r==KErrAccessDenied) // if we get access denied from DBMS, which is a timing thing, just re-post
       
   409 			{
       
   410 			User::After(1000000);
       
   411 			continue;
       
   412 			}
       
   413 		else
       
   414 			break;
       
   415 		}
       
   416 	if (r)
       
   417 		{
       
   418 		LOGTEXT(_L8("CommDB values seem to be corrupt"));
       
   419 		ResetCurrentTableViews(); // clean up everything
       
   420 		return (KErrEtelModemSettingsCorrupt);
       
   421 		}
       
   422 
       
   423 	TCommConfig configDummyPckg;
       
   424 	TCommConfigV01& config=configDummyPckg();
       
   425 	if (aConfigType==EConfigTypeHangUp ||
       
   426 		aConfigType==EConfigTypeQuickInit)
       
   427 		{
       
   428 		config = iConfig;
       
   429 		config.iHandshake = 0;//&= (~(KConfigFailDCD | KConfigObeyDCD | KConfigFailDSR));
       
   430 		}
       
   431 	else
       
   432 		{
       
   433 		TRAPD(ret,CommConfigL(config));
       
   434 		if (ret)
       
   435 			return ret;
       
   436 		switch (aConfigType)
       
   437 			{
       
   438 		case EConfigTypePreInit:
       
   439 			config.iHandshake &= (~(KConfigObeyCTS | KConfigFailCTS | KConfigObeyDCD | KConfigFailDCD | KConfigFailDSR));
       
   440 			break;
       
   441 		case EConfigTypeInit:
       
   442 			config.iHandshake &= (~(KConfigObeyCTS | KConfigFailCTS | KConfigObeyDCD | KConfigFailDCD));
       
   443 			break;
       
   444 		case EConfigTypeConnect:
       
   445 			config.iHandshake &= (~(KConfigFailCTS | KConfigFailDCD));	// fail DCD masked out, as should get NO CARRIER anyway
       
   446 			break;
       
   447 		case EConfigTypeFull:
       
   448 			break;
       
   449 		case EConfigTypeDDBugWorkAroundStart:
       
   450 			if (config.iRate!=EBps300)	// ensure that something other than handshaking has changed
       
   451 				config.iRate=EBps300;	// to work around the bug in the ARM device driver
       
   452 			else
       
   453 				config.iRate=EBps2400;
       
   454 			config.iHandshake=0;
       
   455 			break;
       
   456 		case EConfigTypeDDBugWorkAroundEnd:
       
   457 			config.iHandshake=0;
       
   458 			break;
       
   459 		default:
       
   460 			break;
       
   461 			}
       
   462 		}
       
   463 	aConfigPckg=configDummyPckg;
       
   464 	ResetCurrentTableViews(); // Clear location and modem table views and close handle to CCommsDatabase
       
   465 	return KErrNone;
       
   466 	}
       
   467 
       
   468 void CTsyConfig::GetCurrentTableViewsL() 
       
   469 /**
       
   470  * Opens a handle to CCommsDatabase	and positions the view on the default modem specified 
       
   471  * in the current Connected Modem record.
       
   472  * Note that the TSY does not keep the handle to the CCommsDatabase opened all the time, 
       
   473  * therefore this method is used to open the handle only when needed. The methods using 
       
   474  * this method are also responsible for calling ResetCurrentTableViews() to close the
       
   475  * handle to the CCommsDatabase and to clean up the table views.
       
   476  */
       
   477 	{
       
   478 	if(iManualConfigMode)
       
   479 		{	
       
   480 		GetRequestedTableViewsL();
       
   481 		}
       
   482 	else
       
   483 		{
       
   484 		ResetCurrentTableViews();
       
   485 		
       
   486 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   487 		iDbSession = CMDBSession::NewL(KCDVersion1_2);
       
   488 #else
       
   489 		iDbSession = CMDBSession::NewL(KCDVersion1_1);
       
   490 #endif
       
   491 		__ASSERT_DEBUG(iDbSession,Panic(ETsyConfigNullDBPointer));
       
   492 
       
   493 		TUint32 modemId(0), locationId(0);
       
   494 
       
   495 		// 
       
   496 		// Search the bearer tables for records using the MM.TSY
       
   497 		GetModemBearerIdL(modemId);
       
   498 	
       
   499 		//
       
   500 		// Get the associated locationId
       
   501 		
       
   502 		GetLocationIdL(modemId,locationId);
       
   503 		
       
   504 		//Check if the selected bearer is an MMTSY bearer with a valid location
       
   505 		if(!modemId || !locationId) 
       
   506 			{
       
   507 			//
       
   508 			// Selected bearer does not mention the MMTSY
       
   509 			LOCAL_LOGTEXT("GetCurrentSettingsL","MMTSY not mentioned in the selected bearer");
       
   510 			__ASSERT_DEBUG(EFalse,Panic(ETsyConfigMMTSYNotInModemTables));
       
   511 			User::Leave(KErrNotFound);
       
   512 			}
       
   513 		else
       
   514 			{
       
   515 						
       
   516 			iModemBearer = modemId;			
       
   517 			iLocationId = locationId;
       
   518 				
       
   519 			}
       
   520 		}
       
   521 	}
       
   522 void CTsyConfig::SetTableViewsL(RMobilePhone::TMMTableSettings& aMMTableSettings)
       
   523 	{
       
   524 	if(iManualConfigMode)
       
   525 		{
       
   526 		iMMTableSettings=aMMTableSettings;
       
   527 
       
   528 		ResetCurrentTableViews(ETrue); // Clear location and modem table views and close handle to CCommsDatabase
       
   529 		GetRequestedTableViewsL();
       
   530 		GetLocationModemSettingsL(); // Get other location and modem settings 
       
   531 		}
       
   532 	}	
       
   533 
       
   534 
       
   535 void CTsyConfig::GetRequestedTableViewsL()
       
   536 	{
       
   537 	
       
   538 	if (iDbSession == NULL)
       
   539 		{
       
   540 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   541 		iDbSession = CMDBSession::NewL(KCDVersion1_2);
       
   542 #else
       
   543 		iDbSession = CMDBSession::NewL(KCDVersion1_1);
       
   544 #endif
       
   545 		__ASSERT_DEBUG(iDbSession,Panic(ETsyConfigNullDBPointer));
       
   546 				
       
   547 		iModemBearer = 0;
       
   548 
       
   549 		CMDBField<TUint32>* bearerField = new(ELeave) CMDBField<TUint32>(KCDTIdIAPBearer);
       
   550 		CleanupStack::PushL(bearerField);
       
   551 		bearerField->SetRecordId(iMMTableSettings.iLocId);
       
   552 		bearerField->LoadL(*iDbSession);
       
   553 		iModemBearer = *bearerField;
       
   554 		CleanupStack::PopAndDestroy(bearerField);
       
   555 		}
       
   556 		
       
   557 		TName modem;
       
   558 		CMDBField<TDesC>* tsyField = new(ELeave) CMDBField<TDesC>(KCDTIdTsyName);
       
   559 		CleanupStack::PushL(tsyField);
       
   560 		tsyField->SetRecordId(iModemBearer);
       
   561 		tsyField->SetMaxLengthL(KMaxTextLength);
       
   562 		tsyField->LoadL(*iDbSession);
       
   563 		modem = *tsyField;
       
   564 		CleanupStack::PopAndDestroy(tsyField);
       
   565 		
       
   566 
       
   567 		if(modem.Compare(_L("MM"))!=KErrNone)
       
   568 			{
       
   569 			// Selected bearer does not mention the MMTSY
       
   570 			LOCAL_LOGTEXT("GetCurrentSettingsL","Bearer for selected IAP does not use MMTSY");
       
   571 			__ASSERT_DEBUG(EFalse,Panic(ETsyConfigMMTSYNotInModemTables));
       
   572 			User::Leave(KErrNotFound);
       
   573 			}
       
   574 
       
   575 
       
   576 
       
   577 	}
       
   578 	
       
   579 void CTsyConfig::ResetCurrentTableViews(TBool aForceErase)
       
   580 /**
       
   581  * Closes the handle to CCommsDatabase and clears the view on the default modem specified 
       
   582  * in the current Connected Modem record. This method needs to be called after 
       
   583  * GetCurrentTableViewsL().
       
   584  */
       
   585 	{
       
   586 	if( !iManualConfigMode || aForceErase )
       
   587 		{
       
   588 		delete iDbSession;
       
   589 		iDbSession = NULL;		
       
   590 
       
   591 		}
       
   592 	}
       
   593 
       
   594 void CTsyConfig::GetLocationIdL(const TUint32& aBearerId,TUint32& aLocationId) 
       
   595 /*
       
   596  *  Scan through the table for records containing MM.TSY
       
   597  *  Stop at the first instance of such a record and return the id
       
   598  *
       
   599  */
       
   600  	{
       
   601     CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord));
       
   602   	CleanupStack::PushL(iapRecord);
       
   603   	
       
   604   	iapRecord->iBearer = aBearerId;
       
   605   	TBool err = iapRecord->FindL(*iDbSession);
       
   606   	if (err)
       
   607   		{
       
   608   		aLocationId = iapRecord->iLocation;
       
   609   		}
       
   610   	else
       
   611   		{
       
   612   		aLocationId = static_cast<TUint32>(KErrNotFound);
       
   613   		}
       
   614   	
       
   615     CleanupStack::PopAndDestroy(iapRecord);
       
   616     
       
   617 	}
       
   618 
       
   619 void CTsyConfig::GetModemBearerIdL(TUint32& aBearerId) 
       
   620 /*
       
   621  *  Scan through the table for records containing MM.TSY
       
   622  *  Stop at the first instance of such a record and return the id
       
   623  *
       
   624  */
       
   625 	{
       
   626     CCDModemBearerRecord *modemRecord = static_cast<CCDModemBearerRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdModemBearerRecord));
       
   627     CleanupStack::PushL(modemRecord);
       
   628     
       
   629     _LIT(KTsyName,"MM");
       
   630     modemRecord->iTsyName.SetMaxLengthL(KMaxTextLength);
       
   631     modemRecord->iTsyName = KTsyName;
       
   632     
       
   633     TBool searchResult = modemRecord->FindL(*iDbSession);
       
   634     
       
   635     if (searchResult)
       
   636 	    {
       
   637 		aBearerId = modemRecord->RecordId();	
       
   638 	    }
       
   639 	else
       
   640 		{
       
   641 		aBearerId = static_cast<TUint32>(KErrNotFound);
       
   642 		}
       
   643     
       
   644     CleanupStack::PopAndDestroy(modemRecord);
       
   645 	}