epoc32/include/tulphonenumberutils.h
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/tulphonenumberutils.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,115 @@
     1.4 +/*
     1.5 +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +#ifndef __TULPHONENUMBERUTILS_H__
    1.24 +#define __TULPHONENUMBERUTILS_H__
    1.25 +
    1.26 +#include    <coemain.h>
    1.27 +
    1.28 +
    1.29 +/**
    1.30 +Class offers static methods for parsing and validating phone numbers. 
    1.31 +Phone Parser API provides methods which are used to parse and validate
    1.32 +phone numbers. The API consists of the TulPhoneNumberUtils class.
    1.33 +
    1.34 +Examples of valid phone numbers:
    1.35 +1.	+358501234567
    1.36 +2.	+358 (50) 123 4567
    1.37 +
    1.38 +Even though both of the above examples are valid phone numbers, only 1) is 
    1.39 +accepted as a phone number by many systems. To convert 2) to 1), use the 
    1.40 +parsing method of the API.
    1.41 +
    1.42 +Usage:
    1.43 +  
    1.44 +@code
    1.45 + #include <tulphonenumberutils.h> 
    1.46 +
    1.47 + // Example shows how to use the parsing method of the API.
    1.48 +
    1.49 + // A number to be parsed. 
    1.50 + TBuf<50> number1 = _L("+358 (40) 123 132");
    1.51 +
    1.52 + // Type of the phone number to be parsed is a regular phone number.
    1.53 + TBool validNumber1 = 
    1.54 + TulPhoneNumberUtils::NormalizePhoneNumber( number1,
    1.55 +                                      TulPhoneNumberUtils::EPlainPhoneNumber );
    1.56 +
    1.57 + // The phone number number1 is a valid regular phone number.
    1.58 + // After parsing validNumber1 is ETrue and 
    1.59 + // number1 is "+35840123132".
    1.60 + // Do something like SendSMS( number1 ) etc.
    1.61 +
    1.62 + // A number to be parsed. 
    1.63 + TBuf<50> number2 = _L("+358 (40) 123p132"); // note 'p'
    1.64 +
    1.65 + // Type of the phone number to be parsed is a regular phone number.
    1.66 + TBool validNumber2 = 
    1.67 + TulPhoneNumberUtils::NormalizePhoneNumber( number2,
    1.68 +                                      TulPhoneNumberUtils::EPlainPhoneNumber );
    1.69 +
    1.70 + // The phone number number2 is not a valid regular phone number.
    1.71 + // After parsing validNumber2 is EFalse and 
    1.72 + // number2 is "+358 (40) 123p132" (unchanged).
    1.73 +@endcode
    1.74 +
    1.75 +@publishedAll
    1.76 +@released
    1.77 +*/
    1.78 +NONSHARABLE_CLASS(TulPhoneNumberUtils)
    1.79 +    {
    1.80 +public:
    1.81 +    /** 
    1.82 +    * Enumeration for phone number types. 
    1.83 +    * Used to specify the type of phone numbers in methods of 
    1.84 +    * TulPhoneNumberUtils class.
    1.85 +    */
    1.86 +    enum TPhoneNumberType
    1.87 +        {
    1.88 +        /** The supplied phone number is a regular phone number. */
    1.89 +        EPlainPhoneNumber,
    1.90 +        /** The supplied phone number is a contact card number. */
    1.91 +        EContactCardNumber,
    1.92 +        /** The supplied phone number is is a phone client number. */
    1.93 +        EPhoneClientNumber,
    1.94 +        /** The supplied phone number is an SMS number. */
    1.95 +        ESMSNumber
    1.96 +        };
    1.97 +
    1.98 +    IMPORT_C static TBool Normalize( TDes& aNumber, TPhoneNumberType aType = EPlainPhoneNumber);
    1.99 +    IMPORT_C static TBool IsValid( const TDesC& aNumber, TPhoneNumberType aType = EPlainPhoneNumber );
   1.100 +public: // deprecated
   1.101 +    inline static TBool ParsePhoneNumber( TDes& aNumber, TInt aType );
   1.102 +    inline static TBool IsValidPhoneNumber( const TDesC& aNumber, TInt aType );
   1.103 +private:    
   1.104 +    static TBool IsValidPhoneNumber( const TDesC& aNumber, const TDesC& aValidChars);
   1.105 +    static void ParseInvalidChars( TDes& aNumber, const TDesC& aInvalidChars);
   1.106 +    };
   1.107 +
   1.108 +// For source compatibility with S60
   1.109 +
   1.110 +/** @deprecated */
   1.111 +inline TBool TulPhoneNumberUtils::ParsePhoneNumber( TDes& aNumber, TInt aType )
   1.112 +	{ return TulPhoneNumberUtils::Normalize(aNumber, static_cast<TPhoneNumberType>(aType)); }
   1.113 +/** @deprecated */
   1.114 +inline TBool TulPhoneNumberUtils::IsValidPhoneNumber( const TDesC& aNumber, TInt aType )
   1.115 +	{ return TulPhoneNumberUtils::IsValid(aNumber, static_cast<TPhoneNumberType>(aType)); }
   1.116 +	
   1.117 +#endif      // __TULPHONENUMBERUTILS_H__
   1.118 +