mobilemessaging/unieditor/utils/inc/UniAddressHandler.h
branchRCL_3
changeset 60 7fdbb852d323
parent 0 72b543305e3a
equal deleted inserted replaced
57:ebe688cedc25 60:7fdbb852d323
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:   Unified Message Editor Address Handler.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_UNIADDRESSHANDLER_H
       
    21 #define C_UNIADDRESSHANDLER_H
       
    22 
       
    23 // ========== INCLUDE FILES ================================
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <MsgCheckNames.h>
       
    27 #include <cmsvrecipientlist.h>
       
    28 #include <ConeResLoader.h>
       
    29 
       
    30 // ========== CONSTANTS ====================================
       
    31 
       
    32 // ========== MACROS =======================================
       
    33 
       
    34 // ========== FUNCTION PROTOTYPES ==========================
       
    35 
       
    36 // ========== FORWARD DECLARATIONS =========================
       
    37 
       
    38 class CCoeEnv;
       
    39 class CBaseMtm;
       
    40 class CMsgAddressControl;
       
    41 class CMsgEditorAppUi;
       
    42 class MObjectProvider;
       
    43 
       
    44 // ========== DATA TYPES ===================================
       
    45 
       
    46 // ========== CLASS DECLARATION ============================
       
    47 
       
    48 /**
       
    49 *  Unified Editor Address Handler class declaration.
       
    50 *  Class provides services for address handling. 
       
    51 *
       
    52 *  @lib UniUtils.lib
       
    53 *
       
    54 *  @since S60 3.2
       
    55 */
       
    56 NONSHARABLE_CLASS( CUniAddressHandler ) : public CBase
       
    57     {
       
    58     public:
       
    59 
       
    60         /**
       
    61         * Allocates and constructs a CUniAddressHandler object.
       
    62         *
       
    63         * @param aMtm       Client MTM
       
    64         * @param aControl   Address control to which this handler is connected
       
    65         * @param aCoeEnv    Handle to control environment
       
    66         *
       
    67         * @return Pointer to the new CUniAddressHandler object
       
    68         */
       
    69         IMPORT_C static CUniAddressHandler* NewL( CBaseMtm& aMtm,
       
    70                                                   CMsgAddressControl& aControl,
       
    71                                                   CCoeEnv& aCoeEnv );
       
    72         /**
       
    73         * Destructor
       
    74         */
       
    75         virtual ~CUniAddressHandler();
       
    76 
       
    77         /**
       
    78         * Clears given type addresses from MTM.
       
    79         *
       
    80         * @since S60 3.2
       
    81         *
       
    82         * @param aRecipientType Determines the address type to be cleared
       
    83         */        
       
    84         IMPORT_C void RemoveAddressesFromMtmL( TMsvRecipientTypeValues aRecipientType );
       
    85 
       
    86         /**
       
    87         * Clears given type old addresses from MTM and copies new from address control to MTM.
       
    88         *
       
    89         * @since S60 3.2
       
    90         *
       
    91         * @param aRecipientType Determines the address type to be copied
       
    92         */        
       
    93         IMPORT_C void CopyAddressesToMtmL( TMsvRecipientTypeValues aRecipientType );
       
    94 
       
    95         /**
       
    96         * Appends given type addresses from address control to MTM.
       
    97         * Note! Old addresses are not cleared from MTM
       
    98         *
       
    99         * @since S60 3.2
       
   100         *
       
   101         * @param aRecipientType Determines the address type to be appended
       
   102         */        
       
   103         IMPORT_C void AppendAddressesToMtmL( TMsvRecipientTypeValues aRecipientType );
       
   104 
       
   105         /**
       
   106         * Copies addresses from MTM to address control.
       
   107         *
       
   108         * @since S60 3.2
       
   109         *
       
   110         * @param aRecipientType Determines the address type to be appended
       
   111         * @param aAddInvalid    Specifies whether invalid contacts are added to address control
       
   112         *                       or stored for later use when client calls ShowInvalidRecipientInfoNotesL
       
   113         * 
       
   114         */        
       
   115         IMPORT_C void CopyAddressesFromMtmL( TMsvRecipientTypeValues aRecipientType,
       
   116                                              TBool aAddInvalid );
       
   117 
       
   118         /**
       
   119         * Verifies addresses in address control.
       
   120         *
       
   121         * @since S60 3.2
       
   122         *
       
   123         * @param aModified 
       
   124         *
       
   125         * @return ETrue, if verify successful,
       
   126         *         EFalse otherwise
       
   127         */        
       
   128         IMPORT_C TBool VerifyAddressesL( TBool& aModified );
       
   129 
       
   130         /**
       
   131         * Removes duplicate addresses from recipients at send time.
       
   132         * Removes duplicates from every address control at a time.
       
   133         *
       
   134         * @since S60 3.2
       
   135         *
       
   136         * @param aAppUi Pointer to editor appui
       
   137         * @param aAddressControls Array of address controls
       
   138         *
       
   139         * @return ETrue if something was removed,
       
   140         *         EFalse otherwise
       
   141         */        
       
   142         IMPORT_C static TBool RemoveDuplicateAddressesL( 
       
   143                 CArrayPtrFlat<CMsgAddressControl>& aAddressControls );
       
   144 
       
   145         /**
       
   146         * Add recipient.
       
   147         *
       
   148         * @since S60 3.2
       
   149         *
       
   150         * @param aInvalid               OUT ETrue if invalid addresses found
       
   151         *                                   EFalse otherwise
       
   152         * @return ETrue if something was added,
       
   153         *         EFalse otherwise
       
   154         */
       
   155         IMPORT_C TBool AddRecipientL( TBool& aInvalid );
       
   156 
       
   157         /** 
       
   158         * Checks address.
       
   159         *
       
   160         * @since S60 3.2
       
   161         *
       
   162         * @param aAddress, phonenumber or email
       
   163         * @return ETrue if address is valid, EFalse otherwise
       
   164         */        
       
   165         IMPORT_C TBool CheckSingleAddressL( const TDesC& aAddress );
       
   166 
       
   167         /**
       
   168         * Creates a string to be set as entry iDetails.
       
   169         * Places addresses one after other separated by ";".
       
   170         *
       
   171         * @since S60 3.2
       
   172         *
       
   173         * @param IN/OUT aDetails
       
   174         */
       
   175         IMPORT_C void MakeDetailsL( TDes& aDetails );
       
   176          
       
   177         /**
       
   178         * Shows address information notes for invalid contacts detected when
       
   179         * copying addresses from MTM.Allows UI to
       
   180         * determine correct timing for showing this information to user.
       
   181         *
       
   182         * @since S60 3.2
       
   183         *
       
   184         */
       
   185         IMPORT_C void ShowInvalidRecipientInfoNotesL();
       
   186         
       
   187         /**
       
   188         * Sets valid address type for the address handler.
       
   189         *
       
   190         * @since S60 3.2
       
   191         */
       
   192         inline void SetValidAddressType( CMsgCheckNames::TMsgAddressSelectType aValidAddressType );
       
   193         
       
   194         /**
       
   195         * Returns currently valid address type.
       
   196         *
       
   197         * @since S60 3.2
       
   198         */ 
       
   199         inline CMsgCheckNames::TMsgAddressSelectType ValidAddressType() const;
       
   200         
       
   201    private:
       
   202 
       
   203         /**
       
   204         * Default C++ constructor.
       
   205         */
       
   206         CUniAddressHandler();
       
   207         
       
   208         /**
       
   209         * Constructor.
       
   210         */
       
   211         CUniAddressHandler( CBaseMtm& aMtm,
       
   212                             CMsgAddressControl& aControl,
       
   213                             CCoeEnv& aCoeEnv );
       
   214 
       
   215         /**
       
   216         * By default Symbian OS constructor is private.
       
   217         */
       
   218         void ConstructL();
       
   219 
       
   220         /**
       
   221         * Shows address info (error) note
       
   222         *
       
   223         * @param aAddress
       
   224         * @param aAlias
       
   225         */
       
   226         void ShowAddressInfoNoteL( const TDesC& aAddress, const TDesC& aAlias );
       
   227 
       
   228         /**
       
   229         * Removes characters from string that confuses address 
       
   230         * control or clientMtm. Note that function does not make diffrence 
       
   231         * whether string is phone number or email address.
       
   232         *
       
   233         * @param aString
       
   234         * @return ETrue, chars were removed, EFalse otherwise 
       
   235         */
       
   236         static TBool RemoveIllegalChars( TDes& aString );
       
   237 
       
   238         /**
       
   239         * Check that character is not something that confuses address
       
   240         * control or clientMtm.
       
   241         *
       
   242         * @param aChar
       
   243         * @return ETrue, char is legal, EFalse otherwise 
       
   244         */
       
   245         static TBool IsValidChar( const TChar& aChar ); 
       
   246 
       
   247         /**
       
   248         * Converts number-strings to/from arabic-indic <-> western 
       
   249         * NOTE : Leaves string to CleanupStack
       
   250         * @param aOrigNumber contains the number to be converted
       
   251         * @param aDirection EFalse -> western, ETrue -> arabic-indic if needed
       
   252         * @return HBufC* buffer contains converted string
       
   253         */
       
   254         static HBufC* NumberConversionLC( const TDesC& aOrigNumber, TBool aDirection );
       
   255 
       
   256         /**
       
   257         * Performs proper recipient array cleanup.
       
   258         *
       
   259         * @param aArray CMsgRecipientArray pointer.
       
   260         */
       
   261         static void CleanupRecipientArray( TAny* aArray );
       
   262         
       
   263     private:
       
   264         
       
   265         struct TRecipientsInfo
       
   266             {
       
   267             CMsgRecipientArray*  iRecipients;
       
   268             TInt                 iOriginalCount;
       
   269             TBool                iModified;
       
   270             };
       
   271         
       
   272         //
       
   273         CBaseMtm&               iMtm;
       
   274         
       
   275         //
       
   276         CMsgAddressControl&     iControl;
       
   277         
       
   278         //
       
   279         CCoeEnv&                iCoeEnv;
       
   280 
       
   281         CMsgCheckNames*         iCheckNames;
       
   282         
       
   283         // List for invalid recipients.
       
   284         CMsgRecipientList*      iInvalidRecipients;
       
   285         
       
   286         // Valid address type.
       
   287         CMsgCheckNames::TMsgAddressSelectType iValidAddressType;
       
   288         
       
   289         RConeResourceLoader iResourceLoader;
       
   290     };
       
   291 
       
   292 #include <uniaddresshandler.inl>
       
   293 
       
   294 #endif // C_UNIADDRESSHANDLER_H
       
   295 
       
   296 // End of File