diff -r 000000000000 -r 3553901f7fa8 telephonyserverplugins/simtsy/test/Te_SimSms/Te_SimSmsUtil.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/telephonyserverplugins/simtsy/test/Te_SimSms/Te_SimSmsUtil.cpp Tue Feb 02 01:41:59 2010 +0200 @@ -0,0 +1,569 @@ +// Copyright (c) 1997-2009 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: +// + +#include // for RMobilePhone::TMobileAddress +#include "Te_SimSmsUtil.h" +#include "Te_SimSmsPanic.h" + +// +// Currently this file can not include the matstd file due to a dependency that +// the test code t_sms has on this. So the constants needed are duplicated below. +_LIT8(KMEStorage,"ME"); +_LIT8(KMTStorage,"MT"); +_LIT8(KSMStorage,"SM"); + +// +// Panic Function +// +GLDEF_C void Panic(TTSYPanic aPanicNumber) + { + _LIT(panicText,"MM TSY"); + User::Panic(panicText,aPanicNumber); + } + +RMobilePhone::TMobileTON CATSmsUtils::ConvertTypeOfNumber(TInt aValue) +/** + * @param aValue should be an ETSI Type-Of-Number field + * @return The equivalent RMobilePhone::TMobileTON value for aValue + */ + { + switch(aValue) + { + // The below 'magic numbers' come from the ETSI 03.40 + // specification for Address Fields (section 9.1.2.5) + case 0: + return RMobilePhone::EUnknownNumber; + case 1: + return RMobilePhone::EInternationalNumber; + case 2: + return RMobilePhone::ENationalNumber; + case 3: + return RMobilePhone::ENetworkSpecificNumber; + case 4: + return RMobilePhone::ESubscriberNumber; + default: + return RMobilePhone::EUnknownNumber; + } + + } + +TInt CATSmsUtils::ConvertTypeOfNumber(RMobilePhone::TMobileTON aEnum) +/** + * @param aEnum must be a n RMobile::TMobileTON value + * @return The equivalent ETSI Type-Of-Number value for aEnum + */ + { + switch(aEnum) + { + // The below 'magic numbers' come from the ETSI 03.40 + // specification for Address Fields (section 9.1.2.5) + case RMobilePhone::EInternationalNumber: + return 1; + case RMobilePhone::ENationalNumber: + return 2; + case RMobilePhone::ENetworkSpecificNumber: + return 3; + case RMobilePhone::ESubscriberNumber: + return 4; + case RMobilePhone::EUnknownNumber: + case RMobilePhone::EAbbreviatedNumber: + default: + return 0; + } + } + +RMobilePhone::TMobileNPI CATSmsUtils::ConvertNumberingPlan(TInt aValue) +/** + * @param aValue should be an ETSI Numbering-Plan-Identification field + * @return The equivalent RMobilePhone::TMobileNPI value for aValue + */ + { + switch(aValue) + { + // The below 'magic numbers' come from the ETSI 03.40 + // specification for Address Fields (section 9.1.2.5) + case 1: + return RMobilePhone::EIsdnNumberPlan; + case 3: + return RMobilePhone::EDataNumberPlan; + case 4: + return RMobilePhone::ETelexNumberPlan; + case 8: + return RMobilePhone::ENationalNumberPlan; + case 9: + return RMobilePhone::EPrivateNumberPlan; + default: + return RMobilePhone::EUnknownNumberingPlan; + } + } + + +TInt CATSmsUtils::ConvertNumberingPlan(RMobilePhone::TMobileNPI aEnum) +/** + * @param aEnum must be a n RMobile::TMobileNPI value + * @return The equivalent ETSI Numbering-Plan-Identification value for aEnum + */ + { + switch(aEnum) + { + // The below 'magic numbers' come from the ETSI 03.40 + // specification for Address Fields (section 9.1.2.5) + case RMobilePhone::EIsdnNumberPlan: + return 1; + case RMobilePhone::EDataNumberPlan: + return 3; + case RMobilePhone::ETelexNumberPlan: + return 4; + case RMobilePhone::ENationalNumberPlan: + return 8; + case RMobilePhone::EPrivateNumberPlan: + return 9; + case RMobilePhone::EUnknownNumberingPlan: + default: + return 0; + } + } + + + +TInt CATSmsUtils::AppendAddressToAscii(TDes8& aAscii,const RMobilePhone::TMobileAddress& aAddress,TBool aUse0340Format) +/** + * Default operation is to code Address-Length according to= + * 04.11 spec (ie. Address-Length=number of digits in Address-Value). + * + * If aUse0340Format argument is ETrue then Address Length will be coded using + * 03.40 format (ie. Address-Length=number of octets used for Address-Type + * and Address-Value). 03.40 is typically only used when prefixing an SCA to a PDU. + * + * @return Standard KErr... values + */ + { + // Duplicate tel number, removing all the weird chars + TBuf telNumber; + const TInt count(aAddress.iTelNumber.Length()); + TInt i; + for(i=0;i=0 && aBinary<=9) + return TChar(aBinary)+TChar('0'); // Assumes digit characters are one after each other + else if(aBinary==10) + return TChar('*'); + else if(aBinary==11) + return TChar('#'); + else if(aBinary==12) + return TChar('a'); + else if(aBinary==13) + return TChar('b'); + else if(aBinary==14) + return TChar('c'); + return TChar(0); // This is the cloest I can find to a NULL char + } + + + +TBool CATSmsUtils::IsAddressChar(TChar aChar) +/** + * Returns ETrue if, and only if, the given ASCII charcater is valid as an ASCII address character. + */ + { + if(aChar.IsDigit()) + return ETrue; + if(aChar==TChar('*') || + aChar==TChar('#') || + aChar==TChar('a') || + aChar==TChar('b') || + aChar==TChar('c')) + return ETrue; + return EFalse; + } + + +void CATSmsUtils::AppendDataToAscii(TDes8& aAscii,const TDesC8& aData) +/** + * Appends the binary data (aData) onto the end of an ASCII string (aAscii) in ASCII format. + */ + { + const TInt count(aData.Length()); + __ASSERT_DEBUG((aAscii.MaxLength()-aAscii.MaxLength())<=(count*2),Panic(EATSmsUtilsDescriptorOverflow)); + + for(TInt i=0;i=(aAscii.Length()/2),Panic(EATSmsUtilsDescriptorOverflow)); + + aData.Zero(); + TLex8 lex; + TUint8 val; + TInt ret; + const TInt count(aAscii.Length()); + for(TInt i=0;i>4)); + aAddress.iNumberPlan=ConvertNumberingPlan((TInt)(val&0x0f)); + + // Process Address-Value, filtering out non telephone chars + aAddress.iTelNumber.Zero(); + const TInt len=aAddressValueString.Length(); + TChar c; + for(TInt i=0;i>4); + aAddress.iNumberPlan=ConvertNumberingPlan(aVal&0x0f); + } + + + +void CATSmsUtils::ConvertStoreNameToPhoneVersion(const TDesC& aEtelMMVersion,TDes8& aPhoneVersion) +/** + * Convert from Etel MultiMode API SMS store names to ETSI GSM store names + */ + { + if(aEtelMMVersion.Compare(KETelMeSmsStore)==0) + { + aPhoneVersion.Copy(KMEStorage); + return; + } + if(aEtelMMVersion.Compare(KETelIccSmsStore)==0) + { + aPhoneVersion.Copy(KSMStorage); + return; + } + if(aEtelMMVersion.Compare(KETelCombinedSmsStore)==0) + { + aPhoneVersion.Copy(KMTStorage); + return; + } + + // Panic if we are in debug build + __ASSERT_DEBUG(EFalse,Panic(EATSmsUtilsUnknownStoreName)); + + // Return the combined store if we are in release build + aPhoneVersion.Copy(KMTStorage); + } + + +void CATSmsUtils::ConvertStoreNameToEtelMMVersion(TDes& aEtelMMVersion,const TDesC8& aPhoneVersion) +/** + * Convert from ETSI GSM store names to Etel MultiMode API SMS store names + */ + { + if(aPhoneVersion.Compare(KMEStorage)==0) + { + aEtelMMVersion.Copy(KETelMeSmsStore); + return; + } + if(aPhoneVersion.Compare(KSMStorage)==0) + { + aEtelMMVersion.Copy(KETelIccSmsStore); + return; + } + if(aPhoneVersion.Compare(KMTStorage)==0) + { + aEtelMMVersion.Copy(KETelCombinedSmsStore); + return; + } + + // Panic if we are in debug build + __ASSERT_DEBUG(EFalse,Panic(EATSmsUtilsUnknownStoreName)); + + // Return the combined store if we are in release build + aEtelMMVersion.Copy(KETelCombinedSmsStore); + } +