mobilemessaging/unieditor/application/inc/UniEditorHeader.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2006,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:   UniEditor header.   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __UNIEDITORHEADER_H
       
    21 #define __UNIEDITORHEADER_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <MsgEditorView.h>
       
    25 #include <MsgEditor.hrh>    // TMsgControlId
       
    26 #include <MsgAddressControl.h>  
       
    27 
       
    28 #include "UniClientMtm.h"
       
    29 #include "uniaddresshandler.h"
       
    30 #include "unibaseheader.h"
       
    31 #include "uniobjectlist.h"
       
    32 
       
    33 // CONSTANTS
       
    34 
       
    35 // MACROS
       
    36 
       
    37 // DATA TYPES
       
    38 
       
    39 // FUNCTION PROTOTYPES
       
    40 
       
    41 // FORWARD DECLARATIONS
       
    42 
       
    43 class CMsgExpandableControl;
       
    44 class CMsgBaseControl;
       
    45 class CMsgEditorAppUi;
       
    46 class CUniEditorDocument;
       
    47 
       
    48 // CLASS DECLARATION
       
    49 
       
    50 // ==========================================================
       
    51 
       
    52 /**
       
    53 * Unified Message editor header class
       
    54 *
       
    55 * @since 3.2
       
    56 */
       
    57 class CUniEditorHeader : public CUniBaseHeader,
       
    58                          public MUniObjectListObserver
       
    59     {
       
    60     public:  // Constructor and destructor
       
    61 
       
    62         /**
       
    63         * Two-phased constructor.
       
    64         *
       
    65         * @return new object
       
    66         */
       
    67         static CUniEditorHeader* NewL( CUniClientMtm&      aMtm,
       
    68                                        CUniEditorDocument& aDoc,
       
    69                                        CMsgEditorView&     aView,
       
    70                                        RFs&                aFs);
       
    71 
       
    72         /**
       
    73         * Destructor.
       
    74         */
       
    75         virtual ~CUniEditorHeader();
       
    76                 
       
    77         /**
       
    78         * Delete controls from UI. Contents of data is lost
       
    79         *
       
    80         * @param aFlag Combination of EUniFeatureSubject, EUniFeatureCc
       
    81         *              and EUniFeatureBcc of enum TUniFeatures
       
    82         * @param aContentModified indicates whether removing causes data
       
    83         *        to be deleted
       
    84         */
       
    85         void AddHeadersDeleteL( TInt    aFlags,
       
    86                                 TBool   aContentModified);
       
    87 
       
    88         /**
       
    89         * Add controls to the UI. Adding maybe delayed, if header controls
       
    90         * are not visible. 
       
    91         *
       
    92         * @param aFlags Combination of EUniFeatureSubject, EUniFeatureCc
       
    93         *               and EUniFeatureBcc of enum TUniFeatures. Bits of existing fields
       
    94         *               are accepted and thus ignored.
       
    95         */
       
    96         void AddHeadersAddL(TInt aFlags);
       
    97 
       
    98         /**
       
    99         *  Clears old addresses from MTM and copies data from 
       
   100         *  address control to MTM, if any of the controls have changed.
       
   101         *  If changes have not taken place, returns immediately.
       
   102         *  MTM is not saved into messaging store
       
   103         *
       
   104         *  @param  aDocumentHeaderModified indicates whether document header is modified
       
   105         *
       
   106         *  @return ETrue, if addresses were really copied
       
   107         *          EFalse, no changes, addresses were not copied
       
   108         */        
       
   109         TBool CopyAddressesToMtmL(  TBool   aDocumentHeaderModified );
       
   110 
       
   111         /**
       
   112         *  Clears old addresses from MTM and copies data from 
       
   113         *  address control to MTM, if any of the controls have changed.
       
   114         *  Saves also subject, if it has changed.
       
   115         *  If changes have not taken place, returns immediately.
       
   116         *
       
   117         *  @param aDocumentHeaderModified indicates whether document header is modified
       
   118         *  @param aSaveToMtm whether changes are saved to store, if controls were
       
   119         *         modified
       
   120         *
       
   121         *  @return ETrue, if addresses were really copied
       
   122         *          EFalse, no changes, addresses were not copied
       
   123         */        
       
   124         TBool CopyHeadersToMtmL(    TBool aDocumentHeaderModified,
       
   125                                     TBool aSaveToMtm );
       
   126 
       
   127         /**
       
   128         * Verifies addresses in address control.
       
   129         *
       
   130         * @param aAcceptEmails tells if email addresses should be accepted
       
   131         *
       
   132         * @return ETrue, if verify successful,
       
   133         *         EFalse otherwise
       
   134         */        
       
   135         TBool VerifyAddressesL( TBool& aModified, TBool aAcceptEmails );
       
   136 
       
   137         /**
       
   138         * Removes duplicate addresses from recipients at send time.
       
   139         *
       
   140         * @param aAppUi Pointer to editor appui
       
   141         *
       
   142         * @return ETrue if something was removed,
       
   143         *         EFalse otherwise
       
   144         */        
       
   145         TBool RemoveDuplicateAddressesL();
       
   146 
       
   147         /**
       
   148         * Add recipient.
       
   149         *
       
   150         * @param aFocusedControl currently focused control
       
   151         * @param aParent    IN  Parent control (normally iView)
       
   152         * @param aIncludeEmailAddress IN Specifies whether recipients with email
       
   153         *                                address should be included.
       
   154         * @param aInvalid   OUT ETrue if invalid addresses found
       
   155         *                       EFalse otherwise
       
   156         *
       
   157         * @return ETrue if something was added,
       
   158         *         EFalse otherwise
       
   159         */
       
   160         TBool AddRecipientL( CMsgBaseControl* aFocusedControl,
       
   161                              MObjectProvider* aParent, 
       
   162                              TBool aIncludeEmailAddresses,
       
   163                              TBool& aInvalid );
       
   164 
       
   165         /**
       
   166         * Check if the header of the message is in the SMS scope
       
   167         *
       
   168         * @return ETrue, if header is SMS compatible
       
   169         *         EFalse otherwise
       
   170         */
       
   171         TBool IsHeaderSmsL();
       
   172         
       
   173         /**
       
   174         * Makes details. Operation not bound to any address type
       
   175         */
       
   176         inline void MakeDetailsL( TDes& aDetails );
       
   177 
       
   178         /**
       
   179         * Refreshes the length of the current longest email address (iLongestEmail variable)
       
   180         */
       
   181         void RefreshLongestEmailAddressL();
       
   182         
       
   183         /**
       
   184         * Returns the length of longest email address
       
   185         */
       
   186         inline TInt LongestEmailAddress();
       
   187         
       
   188         /**
       
   189         * Returns ETrue if there are unverified recipients
       
   190         */        
       
   191         TBool NeedsVerificationL();
       
   192 
       
   193         /**
       
   194         * Shows invalid recipient information notes for all invalid attachments
       
   195         * on every address field detected during editor application launching.
       
   196         */
       
   197         void ShowInvalidContactNotesL();
       
   198 
       
   199     public: // Functions from base classes
       
   200     
       
   201         /**
       
   202         * From MUniObjectListObserver
       
   203         * See UniObjectList.h
       
   204         */
       
   205         void ObjectAddedL( CUniObjectList* aList, 
       
   206                            CUniObject* aObject,
       
   207                            TInt aIndex );
       
   208         
       
   209         /**
       
   210         * From MUniObjectListObserver
       
   211         * See UniObjectList.h
       
   212         */
       
   213         void ObjectRemovedL( CUniObjectList* aList, 
       
   214                              CUniObject* aObject, 
       
   215                              TInt aIndex );
       
   216     
       
   217     private: // Constructors
       
   218 
       
   219         /**
       
   220         * C++ constructor.
       
   221         */
       
   222         CUniEditorHeader( CUniClientMtm& aMtm,
       
   223                           CUniEditorDocument& aDoc,
       
   224                           CMsgEditorView& aView,
       
   225                           RFs& aFs );
       
   226 
       
   227         /**
       
   228         * 2nd phase constructor.
       
   229         */
       
   230         void ConstructL();
       
   231 
       
   232         /**
       
   233         * Creates UI control for subject
       
   234         *
       
   235         * @param aReadContent determines whether content is read to the
       
   236         *        UI control from MTM.
       
   237         *        Reading is not needed, if control is added by user selection
       
   238         */
       
   239         void InsertSubjectL(TBool aReadContent );
       
   240         
       
   241         /**
       
   242         * From CUniBaseHeader
       
   243         * See UniBaseHeader.h
       
   244         */
       
   245         void InsertAttachmentL( TBool aReadContent );
       
   246         
       
   247         /**
       
   248         * Removes attachment control from header
       
   249         */
       
   250         void RemoveAttachmentL();
       
   251 
       
   252         /**
       
   253         * Adds additional headers onto the UI immediately
       
   254         *
       
   255         * @param aReadContent determines whether content is read to the
       
   256         *        UI control from MTM.
       
   257         *        Reading is not needed, if control is added by user selection
       
   258         */
       
   259         void DoAddHeadersAddL( TBool aReadContent );
       
   260 
       
   261         /**
       
   262         * Create UI control for recipient.
       
   263         *
       
   264         * @param aData data area for this recipient type
       
   265         * @param aResource resource to read basic recipient data from
       
   266         * @param aReadContent determines whether recipient data is read from
       
   267         *        MTM
       
   268         */
       
   269         void InsertRecipientL(  TAddressData&  aData,
       
   270                                 THeaderFields  aRecipientType,
       
   271                                 TBool          aReadContent);
       
   272 
       
   273         /**
       
   274         * Tells in which index the control aControlToAdd should be added
       
   275         */
       
   276         TInt ControlIndexForAdding( TInt aControlToAdd );
       
   277     
       
   278     	/**
       
   279         * Tells if the address is valid email address
       
   280         */
       
   281         TBool IsValidEmailAddress( const TDesC& aAddress );
       
   282         
       
   283     private: //Data
       
   284     
       
   285         CUniEditorDocument& iDoc;
       
   286         TInt                iLongestEmail;
       
   287     };
       
   288 
       
   289 // ---------------------------------------------------------
       
   290 // CUniEditorAppUi::MakeDetails
       
   291 // ---------------------------------------------------------
       
   292 //
       
   293 inline void CUniEditorHeader::MakeDetailsL( TDes& aDetails )    
       
   294     {
       
   295     return iHeaders[EHeaderAddressTo].iAddressHandler->MakeDetailsL( aDetails );
       
   296     }
       
   297 
       
   298 // ---------------------------------------------------------
       
   299 // CUniEditorAppUi::LongestEmailAddress
       
   300 // ---------------------------------------------------------
       
   301 //
       
   302 inline TInt CUniEditorHeader::LongestEmailAddress()
       
   303     {
       
   304     return iLongestEmail;
       
   305     }
       
   306 
       
   307 #endif // __UNIEDITORHEADER_H
       
   308 
       
   309 // End of File