lafagnosticuifoundation/uigraphicsutils/tulinc/tulphonenumberutils.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __TULPHONENUMBERUTILS_H__
       
    21 #define __TULPHONENUMBERUTILS_H__
       
    22 
       
    23 #include    <coemain.h>
       
    24 
       
    25 
       
    26 /**
       
    27 Class offers static methods for parsing and validating phone numbers. 
       
    28 Phone Parser API provides methods which are used to parse and validate
       
    29 phone numbers. The API consists of the TulPhoneNumberUtils class.
       
    30 
       
    31 Examples of valid phone numbers:
       
    32 1.	+358501234567
       
    33 2.	+358 (50) 123 4567
       
    34 
       
    35 Even though both of the above examples are valid phone numbers, only 1) is 
       
    36 accepted as a phone number by many systems. To convert 2) to 1), use the 
       
    37 parsing method of the API.
       
    38 
       
    39 Usage:
       
    40   
       
    41 @code
       
    42  #include <tulphonenumberutils.h> 
       
    43 
       
    44  // Example shows how to use the parsing method of the API.
       
    45 
       
    46  // A number to be parsed. 
       
    47  TBuf<50> number1 = _L("+358 (40) 123 132");
       
    48 
       
    49  // Type of the phone number to be parsed is a regular phone number.
       
    50  TBool validNumber1 = 
       
    51  TulPhoneNumberUtils::NormalizePhoneNumber( number1,
       
    52                                       TulPhoneNumberUtils::EPlainPhoneNumber );
       
    53 
       
    54  // The phone number number1 is a valid regular phone number.
       
    55  // After parsing validNumber1 is ETrue and 
       
    56  // number1 is "+35840123132".
       
    57  // Do something like SendSMS( number1 ) etc.
       
    58 
       
    59  // A number to be parsed. 
       
    60  TBuf<50> number2 = _L("+358 (40) 123p132"); // note 'p'
       
    61 
       
    62  // Type of the phone number to be parsed is a regular phone number.
       
    63  TBool validNumber2 = 
       
    64  TulPhoneNumberUtils::NormalizePhoneNumber( number2,
       
    65                                       TulPhoneNumberUtils::EPlainPhoneNumber );
       
    66 
       
    67  // The phone number number2 is not a valid regular phone number.
       
    68  // After parsing validNumber2 is EFalse and 
       
    69  // number2 is "+358 (40) 123p132" (unchanged).
       
    70 @endcode
       
    71 
       
    72 @publishedAll
       
    73 @released
       
    74 */
       
    75 NONSHARABLE_CLASS(TulPhoneNumberUtils)
       
    76     {
       
    77 public:
       
    78     /** 
       
    79     * Enumeration for phone number types. 
       
    80     * Used to specify the type of phone numbers in methods of 
       
    81     * TulPhoneNumberUtils class.
       
    82     */
       
    83     enum TPhoneNumberType
       
    84         {
       
    85         /** The supplied phone number is a regular phone number. */
       
    86         EPlainPhoneNumber,
       
    87         /** The supplied phone number is a contact card number. */
       
    88         EContactCardNumber,
       
    89         /** The supplied phone number is is a phone client number. */
       
    90         EPhoneClientNumber,
       
    91         /** The supplied phone number is an SMS number. */
       
    92         ESMSNumber
       
    93         };
       
    94 
       
    95     IMPORT_C static TBool Normalize( TDes& aNumber, TPhoneNumberType aType = EPlainPhoneNumber);
       
    96     IMPORT_C static TBool IsValid( const TDesC& aNumber, TPhoneNumberType aType = EPlainPhoneNumber );
       
    97 public: // deprecated
       
    98     inline static TBool ParsePhoneNumber( TDes& aNumber, TInt aType );
       
    99     inline static TBool IsValidPhoneNumber( const TDesC& aNumber, TInt aType );
       
   100 private:    
       
   101     static TBool IsValidPhoneNumber( const TDesC& aNumber, const TDesC& aValidChars);
       
   102     static void ParseInvalidChars( TDes& aNumber, const TDesC& aInvalidChars);
       
   103     };
       
   104 
       
   105 // For source compatibility with S60
       
   106 
       
   107 /** @deprecated */
       
   108 inline TBool TulPhoneNumberUtils::ParsePhoneNumber( TDes& aNumber, TInt aType )
       
   109 	{ return TulPhoneNumberUtils::Normalize(aNumber, static_cast<TPhoneNumberType>(aType)); }
       
   110 /** @deprecated */
       
   111 inline TBool TulPhoneNumberUtils::IsValidPhoneNumber( const TDesC& aNumber, TInt aType )
       
   112 	{ return TulPhoneNumberUtils::IsValid(aNumber, static_cast<TPhoneNumberType>(aType)); }
       
   113 	
       
   114 #endif      // __TULPHONENUMBERUTILS_H__
       
   115