telephonyserverplugins/simtsy/src/CSimTsyMode.cpp
changeset 0 3553901f7fa8
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2004-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 // Implements determining the TSY mode to run in (ie CDMA or GSM)
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20 */
       
    21 
       
    22 #include "CSimTsyMode.h"
       
    23 #include "e32err.h"
       
    24 
       
    25 // read in from config file
       
    26 TInt CSimTsyMode::InitL(CSimPhone *aPhone)
       
    27 {
       
    28 	__ASSERT_ALWAYS(Dll::Tls() == NULL, SimPanic(ETlsAlreadySet));
       
    29 
       
    30 	TTsyMode* tsyMode = new(ELeave) TTsyMode;
       
    31 	*tsyMode = ENoCdma;
       
    32 	Dll::SetTls(tsyMode);
       
    33 
       
    34 	TBool tsyModeFound = FALSE;
       
    35 	const CTestConfigItem* tsyModeItem = aPhone->CfgFile()->Item(KTsyMode); // CfgFile is guaranteed to exist in phone object
       
    36 	TInt tmp = 0;
       
    37 	TInt tsyModeElement = KErrNone;
       
    38 	if (tsyModeItem)
       
    39 		{
       
    40 		tsyModeElement = CTestConfig::GetElement(tsyModeItem->Value(),KStdDelimiter,0,tmp);
       
    41 		if (tsyModeElement == KErrNone)
       
    42 			{
       
    43 			*tsyMode = static_cast<CSimTsyMode::TTsyMode>(tmp);
       
    44 			tsyModeFound = TRUE;
       
    45 			}
       
    46 		}
       
    47 	if (!tsyModeFound)
       
    48 		{
       
    49 		const CTestConfigSection* defaultConfigSection = aPhone->DefaultCfgFile();
       
    50 		if (defaultConfigSection)
       
    51 			{
       
    52 			tsyModeItem = defaultConfigSection->Item(KTsyMode);
       
    53 			if (tsyModeItem)
       
    54 				{
       
    55 				tsyModeElement = CTestConfig::GetElement(tsyModeItem->Value(),KStdDelimiter,0,tmp);
       
    56 				if (tsyModeElement == KErrNone)
       
    57 					{
       
    58 					*tsyMode = static_cast<CSimTsyMode::TTsyMode>(tmp);
       
    59 					tsyModeFound = TRUE;
       
    60 					}
       
    61 				}
       
    62 			}
       
    63 		}
       
    64 	if (!tsyModeFound)
       
    65 		{
       
    66 		*tsyMode = CSimTsyMode::ENoCdma;
       
    67 		}
       
    68 	return KErrNone;
       
    69 }
       
    70 
       
    71 
       
    72 void CSimTsyMode::FreeMode()
       
    73 	{
       
    74 	TTsyMode* tsyMode = static_cast<TTsyMode*>(Dll::Tls());
       
    75 	Dll::FreeTls();
       
    76 	delete tsyMode;
       
    77 	tsyMode = NULL;
       
    78 	}
       
    79 
       
    80 CSimTsyMode::TTsyMode CSimTsyMode::GetMode()
       
    81 	{
       
    82 	TTsyMode* tsyMode = static_cast<TTsyMode*>(Dll::Tls());
       
    83 	__ASSERT_ALWAYS(tsyMode != NULL, SimPanic(ETlsNotSet));
       
    84 	return *tsyMode;
       
    85 	}