diff -r 000000000000 -r ff3b6d0fd310 telutils/phoneparser/src/CPhoneGsmOptionContainer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/telutils/phoneparser/src/CPhoneGsmOptionContainer.cpp Tue Feb 02 01:11:09 2010 +0200 @@ -0,0 +1,181 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of option container. +* +*/ + + +// INCLUDE FILES +#include "CPhoneGsmOptionContainer.h" +#include "PhoneGsmParser.h" +#include "CPhoneParserFeatures.h" + +// CONSTANTS +const TInt KPhoneGsmOptionGranularity = 5; + + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CPhoneGsmOptionContainer::CPhoneGsmOptionContainer +// ----------------------------------------------------------------------------- +// +CPhoneGsmOptionContainer::CPhoneGsmOptionContainer() + { + } + +// ----------------------------------------------------------------------------- +// CPhoneGsmOptionContainer::ConstructL +// ----------------------------------------------------------------------------- +// +void CPhoneGsmOptionContainer::ConstructL() + { + iOptions = + new ( ELeave ) COptionArray( KPhoneGsmOptionGranularity ); + } + +// ----------------------------------------------------------------------------- +// CPhoneGsmOptionContainer::NewL +// ----------------------------------------------------------------------------- +// +CPhoneGsmOptionContainer* CPhoneGsmOptionContainer::NewL() + { + CPhoneGsmOptionContainer* self = + new (ELeave) CPhoneGsmOptionContainer; + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + + return self; + } + +// ----------------------------------------------------------------------------- +// CPhoneGsmOptionContainer::~CPhoneGsmOptionContainer +// ----------------------------------------------------------------------------- +// +CPhoneGsmOptionContainer::~CPhoneGsmOptionContainer() + { + delete iOptions; + } + +// ----------------------------------------------------------------------------- +// CPhoneGsmOptionContainer::IsOptionDefined +// ----------------------------------------------------------------------------- +// +TBool CPhoneGsmOptionContainer::IsOptionDefined( + TInt aOptionUid ) const + { + // For two digit calling, we have one option defined + // in extension. + if ( aOptionUid == KPhoneOptionTwoDigitCalling ) + { + return ETrue; + } + + TKeyArrayFix key = MakeKey(); + TOptionItem option; + option.iUid = aOptionUid; + TInt index; + + return !iOptions->FindIsq( option, key, index ); + } + +// ----------------------------------------------------------------------------- +// CPhoneGsmOptionContainer::FindOptionStatus +// ----------------------------------------------------------------------------- +// +TBool CPhoneGsmOptionContainer::FindOptionStatus( + TInt aOptionUid ) const + { + // For two digit calling, we have one option defined + // in extension. + if ( aOptionUid == KPhoneOptionTwoDigitCalling ) + { + return CPhoneParserFeatures::TwoDigitCallingEnabled(); + } + + TKeyArrayFix key = MakeKey(); + TOptionItem option; + option.iUid = aOptionUid; + TInt index; + + if ( iOptions->FindIsq( option, key, index ) ) + { + PhoneGsmParser::Panic( PhoneGsmParser::EOptionNotDefined ); + } + + TBool result = iOptions->At( index ).iStatus; + return result; + } + +// ----------------------------------------------------------------------------- +// CPhoneGsmOptionContainer::SetOptionStatus +// ----------------------------------------------------------------------------- +// +void CPhoneGsmOptionContainer::SetOptionStatus( + TInt aOptionUid, + TBool aStatus ) + { + // For two digit calling, we have one option defined + // in extension - not allowed to be modified. + if ( aOptionUid == KPhoneOptionTwoDigitCalling ) + { + PhoneGsmParser::Panic( PhoneGsmParser::EIncorrectUse ); + } + + TKeyArrayFix key = MakeKey(); + TOptionItem option; + option.iUid = aOptionUid; + TInt index; + + if ( iOptions->FindIsq( option, key, index ) ) + { + PhoneGsmParser::Panic( PhoneGsmParser::EOptionNotDefined ); + } + + iOptions->At( index ).iStatus = aStatus; + } + +// ----------------------------------------------------------------------------- +// CPhoneGsmOptionContainer::DefineOptionL +// ----------------------------------------------------------------------------- +// +void CPhoneGsmOptionContainer::DefineOptionL( + TInt aOptionUid, + TBool aStatus ) + { + if ( IsOptionDefined( aOptionUid ) ) + { + PhoneGsmParser::Panic( PhoneGsmParser::EOptionAlreadyDefined ); + } + + TKeyArrayFix key = MakeKey(); + TOptionItem option; + option.iUid = aOptionUid; + option.iStatus = aStatus; + + iOptions->InsertIsqL( option, key ); + } + +// ----------------------------------------------------------------------------- +// CPhoneGsmOptionContainer::MakeKey +// ----------------------------------------------------------------------------- +// +TKeyArrayFix CPhoneGsmOptionContainer::MakeKey() + { + return TKeyArrayFix( _FOFF( TOptionItem, iUid ), ECmpTInt ); + } + +// End of File