phonebookengines/VirtualPhonebook/VPbkSimStore/inc/CContact.h
branchRCL_3
changeset 20 f4a778e096c2
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2002-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:  A contact adapter between VPbk framework and VPbkSimStoreImpl
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef VPBKSIMSTORE_CCONTACT_H
       
    20 #define VPBKSIMSTORE_CCONTACT_H
       
    21 
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <babitflags.h>
       
    26 #include "MVPbkStoreContact.h"
       
    27 #include <MVPbkStoreContact2.h>
       
    28 #include "TStoreContactFieldCollection.h"
       
    29 #include "MVPbkSimContactObserver.h"
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CVPbkSimContact;
       
    33 class MVPbkSimStoreOperation;
       
    34 class MVPbkStoreContactProperties;
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 namespace VPbkEngUtils { 
       
    38 class CVPbkAsyncOperation; 
       
    39 }
       
    40 
       
    41 namespace VPbkSimStore {
       
    42 
       
    43 // FORWARD DECLARATIONS
       
    44 class CContactStore;
       
    45 
       
    46 // CLASS DECLARATIONS
       
    47 
       
    48 /**
       
    49  * Maps a Sim entry to a virtual Phonebook contact.
       
    50  */
       
    51 NONSHARABLE_CLASS( CContact ): 
       
    52         public CBase, 
       
    53         public MVPbkStoreContact,
       
    54         public MVPbkStoreContact2,
       
    55         private MVPbkSimContactObserver
       
    56     {
       
    57     public:  // Constructor and destructor
       
    58         /**
       
    59         * Creates a new instance of this class.
       
    60         *
       
    61         * @param aParentStore the store in which this contact belongs
       
    62         * @param aSimContact a sim contact, ownership is taken 
       
    63         *        after construction.
       
    64         * @return a new instance of this class
       
    65         */
       
    66         static CContact* NewL( CContactStore& aParentStore,
       
    67             CVPbkSimContact* aSimContact, TBool aIsNewContact = EFalse );
       
    68 
       
    69         /**
       
    70         * Destructor.
       
    71         */
       
    72         ~CContact();
       
    73 
       
    74     public:  // New functions
       
    75 
       
    76         /**
       
    77         * Returns the parent store of this contact.
       
    78         * @return the parent store of this contact.
       
    79         */
       
    80         inline CContactStore& Store() const;
       
    81 
       
    82         /**
       
    83         * Returns the sim contact
       
    84         * @return the sim contact
       
    85         */
       
    86         inline CVPbkSimContact& SimContact() const;
       
    87 
       
    88         /**
       
    89         * Sets the lock status of the contact
       
    90         * @param aLocked if ETrue the contact is set to locked
       
    91         */
       
    92         inline void SetLock( TBool aLocked );
       
    93 
       
    94     public:  // From base classes
       
    95 
       
    96         /**
       
    97         * From MVPbkObjectHierarchy
       
    98         */
       
    99         MVPbkObjectHierarchy& ParentObject() const;
       
   100 
       
   101         /**
       
   102         * From MVPbkBaseContact
       
   103         */
       
   104         const MVPbkStoreContactFieldCollection& Fields() const;
       
   105         
       
   106         /**
       
   107         * From MVPbkBaseContact
       
   108         */
       
   109         TBool IsSame( const MVPbkStoreContact& aOtherContact ) const;
       
   110 
       
   111         /**
       
   112         * From MVPbkBaseContact
       
   113         */
       
   114         MVPbkContactLink* CreateLinkLC() const;
       
   115 
       
   116         /**
       
   117         * From MVPbkBaseContact
       
   118         */
       
   119         void DeleteL(MVPbkContactObserver& aObserver) const;
       
   120         
       
   121         /**
       
   122         * From MVPbkBaseContact
       
   123         */
       
   124         TBool MatchContactStore(const TDesC& aContactStoreUri) const;
       
   125         
       
   126         /**
       
   127         * From MVPbkBaseContact
       
   128         */
       
   129         TBool MatchContactStoreDomain(const TDesC& aContactStoreDomain) const;
       
   130         
       
   131         /**
       
   132         * From MVPbkBaseContact
       
   133         */
       
   134         MVPbkContactBookmark* CreateBookmarkLC() const;
       
   135         
       
   136         /**
       
   137         * From MVPbkStoreContact
       
   138         */
       
   139         MVPbkContactStore& ParentStore() const;
       
   140 
       
   141         /**
       
   142         * From MVPbkStoreContact
       
   143         */
       
   144         MVPbkStoreContactFieldCollection& Fields();
       
   145         
       
   146         /**
       
   147         * From MVPbkStoreContact
       
   148         */
       
   149         MVPbkStoreContactField* CreateFieldLC( 
       
   150             const MVPbkFieldType& aFieldType ) const;
       
   151         
       
   152         /**
       
   153         * From MVPbkStoreContact
       
   154         */
       
   155         TInt AddFieldL( MVPbkStoreContactField* aField );
       
   156 
       
   157         /**
       
   158         * From MVPbkStoreContact
       
   159         */
       
   160         void RemoveField( TInt aIndex );
       
   161 
       
   162         /**
       
   163         * From MVPbkStoreContact
       
   164         */
       
   165         void RemoveAllFields();
       
   166         
       
   167         /**
       
   168         * From MVPbkStoreContact
       
   169         */
       
   170         void LockL(MVPbkContactObserver& aObserver) const;
       
   171 
       
   172         /**
       
   173         * From MVPbkStoreContact
       
   174         */
       
   175         void CommitL( MVPbkContactObserver& aObserver ) const;
       
   176         
       
   177         /**
       
   178         * From MVPbkStoreContact
       
   179         */
       
   180         MVPbkContactLinkArray* GroupsJoinedLC() const;
       
   181         
       
   182         /**
       
   183         * From MVPbkStoreContact
       
   184         */
       
   185         MVPbkContactGroup* Group();
       
   186         
       
   187         /**
       
   188         * From MVPbkStoreContact
       
   189         */
       
   190         TInt MaxNumberOfFieldL(const MVPbkFieldType& aType) const;
       
   191 
       
   192         /**
       
   193         * From MVPbkStoreContact
       
   194         */
       
   195 		TAny* StoreContactExtension(TUid aExtensionUid) ;
       
   196         
       
   197         /**
       
   198         * From MVPbkStoreContact2
       
   199         */        
       
   200         MVPbkStoreContactProperties* PropertiesL() const;
       
   201         
       
   202         /**
       
   203         * From MVPbkStoreContact2
       
   204         */        
       
   205         void SetAsOwnL(MVPbkContactObserver& aObserver) const;
       
   206         
       
   207     private:  // Construction
       
   208 
       
   209         /**
       
   210         * C++ constructor.
       
   211         */
       
   212         CContact( CContactStore& aParentStore );
       
   213 
       
   214         /**
       
   215         * By default Symbian 2nd phase constructor is private.
       
   216         */
       
   217         void ConstructL( CVPbkSimContact& aSimContact, TBool aIsNewContact );
       
   218     
       
   219     private:    // Functions from base classes
       
   220         
       
   221         /**
       
   222         * From MVPbkSimContactObserver
       
   223         */
       
   224         void ContactEventComplete( TEvent aEvent, CVPbkSimContact* aContact );
       
   225 
       
   226         /**
       
   227         * From MVPbkSimContactObserver
       
   228         */
       
   229         void ContactEventError( TEvent aEvent, CVPbkSimContact* aContact, 
       
   230             TInt aError );
       
   231             
       
   232     private:    // New functions
       
   233         /// Resets the contact state after contact operation
       
   234         void ResetContactOperationState();
       
   235         
       
   236         /**
       
   237         * Remove empty field from aSimContact, these empty field was added 
       
   238         * in the sim contact before save it to keep the order of additional 
       
   239         * numbers in the USIM card. 
       
   240         */
       
   241         void RemoveAllEmptyFields( CVPbkSimContact& aSimContact );
       
   242         
       
   243         /**
       
   244         * Fill some empty field in the sim contact. hese empty field was added 
       
   245         * in the sim contact before save it to keep the order of additional 
       
   246         * numbers in the USIM card. 
       
   247         */
       
   248         void FillWithEmptyFieldsL() const;
       
   249                
       
   250     private:  // Data
       
   251 
       
   252         TStoreContactFieldCollection iFields;
       
   253         /// The parent store of the contact
       
   254         CContactStore& iParentStore;
       
   255         /// Own: the sim contact
       
   256         CVPbkSimContact* iSimContact;
       
   257         /// ETrue if this contact has been locked by the client.
       
   258         /// This is a requirement of vpbk framework -> sim contacts
       
   259         /// can't be actually locked
       
   260         mutable TBool iLocked;
       
   261         /// Flags for contact state
       
   262         mutable TBitFlagsT<TUint32> iFlags;
       
   263         /// Own: an asynchronous call back that is needed if observer
       
   264         /// must be notified e.g from ReadL
       
   265         VPbkEngUtils::CVPbkAsyncOperation* iAsyncOp;
       
   266         /// Ref: the observer for the CommitL/DeleteL
       
   267         mutable MVPbkContactObserver* iObserver;
       
   268         /// Own: an async operaton handle.
       
   269         mutable MVPbkSimStoreOperation* iStoreOperation;
       
   270     };
       
   271 
       
   272 
       
   273 // INLINE FUNCTIONS
       
   274 
       
   275 inline CContactStore& CContact::Store() const
       
   276     {
       
   277     return iParentStore;
       
   278     }
       
   279 
       
   280 inline CVPbkSimContact& CContact::SimContact() const
       
   281     {
       
   282     return *iSimContact;
       
   283     }
       
   284 
       
   285 inline void CContact::SetLock( TBool aLocked )
       
   286     {
       
   287     iLocked = aLocked;
       
   288     }
       
   289 } // namespace VPbkSimStore
       
   290 
       
   291 #endif  // VPBKSIMSTORE_CCONTACT_H
       
   292