phonebookengines/VirtualPhonebook/VPbkSimStore/inc/CViewContact.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     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 virtual phonebook view contact implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef VPBKSIMSTORE_CVIEWCONTACT_H
       
    21 #define VPBKSIMSTORE_CVIEWCONTACT_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <MVPbkViewContact.h>
       
    26 #include <MVPbkViewContactFieldCollection.h>
       
    27 #include <MVPbkViewContactField.h>
       
    28 #include <MVPbkContactFieldTextData.h>
       
    29 #include <MVPbkContactObserver.h>
       
    30 #include <MVPbkSimContactObserver.h>
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class MVPbkSimContact;
       
    34 class MVPbkSimStoreOperation;
       
    35 
       
    36 namespace VPbkEngUtils {
       
    37 class CVPbkAsyncOperation;    
       
    38 }
       
    39 
       
    40 namespace VPbkSimStore {
       
    41 
       
    42 // FORWARD DECLARATIONS
       
    43 class CViewContact;
       
    44 class CContactView;
       
    45 
       
    46 // CLASS DECLARATION
       
    47 
       
    48 /**
       
    49 * A simple field data class for the view contact
       
    50 *
       
    51 */
       
    52 NONSHARABLE_CLASS( TViewContactFieldData ): 
       
    53         public MVPbkContactFieldTextData
       
    54     {
       
    55     public:  // Constructors and destructor
       
    56 
       
    57         /**
       
    58         * C++ constructor
       
    59         * @param aData the field data
       
    60         */
       
    61         TViewContactFieldData( const TDesC& aData );
       
    62 
       
    63     public: // Functions from base classes
       
    64 
       
    65         /**
       
    66         * From MVPbkContactFieldData
       
    67         */
       
    68         TBool IsEmpty() const;
       
    69 
       
    70         /**
       
    71         * From MVPbkContactFieldData
       
    72         */
       
    73         void CopyL( const MVPbkContactFieldData& aFieldData );
       
    74 
       
    75         /**
       
    76         * From MVPbkContactFieldTextData
       
    77         */
       
    78         TPtrC Text() const;
       
    79 
       
    80         /**
       
    81         * From MVPbkContactFieldTextData
       
    82         */
       
    83         void SetTextL( const TDesC& aText );
       
    84 
       
    85         /**
       
    86         * From MVPbkContactFieldTextData
       
    87         */
       
    88         TInt MaxLength() const;
       
    89 
       
    90     private:    // Data
       
    91         /// The field data
       
    92         TPtrC iData;
       
    93     };
       
    94 
       
    95 /**
       
    96 * A simple view contact field class for the view contact
       
    97 *
       
    98 */
       
    99 NONSHARABLE_CLASS( TViewContactField ): 
       
   100         public MVPbkViewContactField
       
   101     {
       
   102     public:  // Constructors and destructor
       
   103 
       
   104         /**
       
   105         * C++ constructor
       
   106         * @param aParentContact the parent view contact of this  field
       
   107         * @param aFieldType the field type of this field
       
   108         */
       
   109         TViewContactField( CViewContact& aParentContact,
       
   110             const MVPbkFieldType& aFieldType,
       
   111             const TDesC& aData );
       
   112 
       
   113     public: // New functions
       
   114 
       
   115         /**
       
   116         * Returns the field data
       
   117         */
       
   118         TViewContactFieldData& FieldData() { return iFieldData; }
       
   119 
       
   120     public: // Functions from base classes
       
   121 
       
   122         /**
       
   123         * From MVPbkObjectHierarchy
       
   124         */
       
   125         MVPbkObjectHierarchy& ParentObject() const;
       
   126 
       
   127         /**
       
   128         * From MVPbkBaseContactField
       
   129         */
       
   130         MVPbkBaseContact& ParentContact() const;
       
   131 
       
   132         /**
       
   133         * From MVPbkBaseContactField
       
   134         */
       
   135         const MVPbkFieldType* MatchFieldType( TInt aMatchPriority ) const;
       
   136         
       
   137         /**
       
   138         * From MVPbkBaseContactField
       
   139         */
       
   140         const MVPbkFieldType* BestMatchingFieldType() const;
       
   141 
       
   142         /**
       
   143         * From MVPbkBaseContactField
       
   144         */
       
   145         const MVPbkContactFieldData& FieldData() const;
       
   146 
       
   147         /**
       
   148         * From MVPbkBaseContactField
       
   149         */
       
   150         TBool IsSame(const MVPbkBaseContactField& aOther) const;
       
   151 
       
   152     private:    // Data
       
   153         /// The parent contact
       
   154         CViewContact& iParentContact;
       
   155         /// The field type of the field
       
   156         const MVPbkFieldType& iFieldType;
       
   157         /// The data of the field
       
   158         TViewContactFieldData iFieldData;
       
   159     };
       
   160 
       
   161 /**
       
   162 * A simple view contact field collection class for the view contact
       
   163 *
       
   164 */
       
   165 NONSHARABLE_CLASS( CViewContactFieldCollection ): 
       
   166         public CBase,
       
   167         public MVPbkViewContactFieldCollection
       
   168     {
       
   169     public:  // Constructors and destructor
       
   170 
       
   171         /**
       
   172         * Destructor.
       
   173         */
       
   174         virtual ~CViewContactFieldCollection();
       
   175         
       
   176     public: // New functions
       
   177 
       
   178         /**
       
   179         * Sets the parent contact
       
   180         * @param aParentContact the contact that owns field collection
       
   181         */
       
   182         void SetParentContact( CViewContact& aParentContact );
       
   183 
       
   184         /**
       
   185         * Resets field collection
       
   186         */
       
   187         void ResetFields();
       
   188 
       
   189         /**
       
   190         * Appends a new field to the field collection
       
   191         * @param aNewField the new view contact field
       
   192         */
       
   193         void AppendFieldL( TViewContactField& aNewField );
       
   194 
       
   195     public: // Functions from base classes
       
   196 
       
   197         /**
       
   198         * From MVPbkViewContactFieldCollection
       
   199         */
       
   200         MVPbkBaseContact& ParentContact() const;
       
   201 
       
   202         /**
       
   203         * From MVPbkViewContactFieldCollection
       
   204         */
       
   205         TInt FieldCount() const;
       
   206 
       
   207         /**
       
   208         * From MVPbkViewContactFieldCollection
       
   209         */
       
   210         const MVPbkBaseContactField& FieldAt( TInt aIndex ) const;
       
   211     private:    // Data
       
   212         /// Ref: the parent contact of the collection
       
   213         CViewContact* iParentContact;
       
   214         /// An array of fields
       
   215         RArray<TViewContactField> iFields;
       
   216     };
       
   217 
       
   218 /**
       
   219 *  A virtual phonebook view contact implementation
       
   220 *
       
   221 */
       
   222 NONSHARABLE_CLASS( CViewContact ): 
       
   223         public CBase,
       
   224         public MVPbkViewContact,
       
   225         private MVPbkSimContactObserver
       
   226     {
       
   227     public:  // Constructors and destructor
       
   228         
       
   229         /**
       
   230         * Two-phased constructor.
       
   231         * @param the parent view of the contact
       
   232         * @param aSortOrder the sort order of the view
       
   233         * @return a new instance of this class
       
   234         */
       
   235         static CViewContact* NewL( CContactView& aView,
       
   236             const MVPbkFieldTypeList& aSortOrder );
       
   237         
       
   238         /**
       
   239         * Destructor.
       
   240         */
       
   241         virtual ~CViewContact();
       
   242 
       
   243     public: // New functions
       
   244         
       
   245         /**
       
   246         * Sets the sim contact for this view contact
       
   247         * @param aSimContact the sim contact for the view contact
       
   248         */
       
   249         void SetSimContactL( MVPbkSimContact& aSimContact );
       
   250 
       
   251         /**
       
   252         * Returns the sim index of this contact
       
   253         * @return the sim index of this contact
       
   254         */
       
   255         TInt SimIndex() const;
       
   256 
       
   257         /**
       
   258         * Set field sort order for the view contact
       
   259         */
       
   260         void SetSortOrder( const MVPbkFieldTypeList& aSortOrder );
       
   261 
       
   262         /**
       
   263          * Returns a reference to the native contact if set by
       
   264          * SetSimContactL. Otherwise returns NULL
       
   265          */
       
   266         const MVPbkSimContact* NativeContact() const;
       
   267         
       
   268         /**
       
   269          * Returns the view that this contact belongs.
       
   270          */
       
   271         CContactView& View() const;
       
   272 
       
   273     public: // Functions from base classes
       
   274             
       
   275         /**
       
   276         * From MVPbkBaseContact
       
   277         */ 
       
   278         const MVPbkBaseContactFieldCollection& Fields() const;
       
   279 
       
   280         /**
       
   281         * From MVPbkBaseContact
       
   282         */ 
       
   283         TBool IsSame( const MVPbkStoreContact& aOtherContact ) const;
       
   284 
       
   285         /**
       
   286         * From MVPbkBaseContact
       
   287         */ 
       
   288         TBool IsSame( const MVPbkViewContact& aOtherContact ) const;
       
   289 
       
   290         /**
       
   291         * From MVPbkBaseContact
       
   292         */ 
       
   293         MVPbkContactLink* CreateLinkLC() const;
       
   294 
       
   295         /**
       
   296         * From MVPbkBaseContact
       
   297         */ 
       
   298         void DeleteL(MVPbkContactObserver& aObserver) const;
       
   299         
       
   300         /**
       
   301         * From MVPbkBaseContact
       
   302         */
       
   303         TBool MatchContactStore(const TDesC& aContactStoreUri) const;
       
   304         
       
   305         /**
       
   306         * From MVPbkBaseContact
       
   307         */
       
   308         TBool MatchContactStoreDomain(const TDesC& aContactStoreDomain) const;
       
   309         
       
   310         /**
       
   311         * From MVPbkBaseContact
       
   312         */
       
   313         MVPbkContactBookmark* CreateBookmarkLC() const;
       
   314         
       
   315         /**
       
   316         * From MVPbkViewContact
       
   317         */
       
   318         MVPbkContactViewBase& ParentView() const;
       
   319 
       
   320         /**
       
   321         * From MVPbkViewContact
       
   322         */
       
   323         void ReadL(MVPbkContactObserver& aObserver) const;
       
   324 
       
   325         /**
       
   326         * From MVPbkViewContact
       
   327         */
       
   328         void ReadAndLockL(MVPbkContactObserver& aObserver) const;
       
   329 
       
   330         /**
       
   331         * From MVPbkViewContact
       
   332         */
       
   333         MVPbkExpandable* Expandable() const;
       
   334 
       
   335         /**
       
   336         * From MVPbkViewContact
       
   337         */
       
   338         TBool IsSame(const MVPbkViewContact& aOtherContact, 
       
   339                      const MVPbkContactStore* aContactStore) const;
       
   340 
       
   341         /**
       
   342         * From MVPbkViewContact
       
   343         */
       
   344         TBool IsSame(const MVPbkStoreContact& aOtherContact, 
       
   345                      const MVPbkContactStore* aContactStore) const;
       
   346         
       
   347     private: // Construction
       
   348 
       
   349         /**
       
   350         * C++ constructor.
       
   351         */
       
   352         CViewContact( CContactView& aView, 
       
   353             const MVPbkFieldTypeList& aSortOrder );
       
   354         
       
   355         /**
       
   356         * By default Symbian 2nd phase constructor is private.
       
   357         */
       
   358         void ConstructL();
       
   359     
       
   360     private:    // Functions from base classes
       
   361         
       
   362         /**
       
   363         * From MVPbkViewContact
       
   364         */
       
   365         void ContactEventComplete( TEvent aEvent, 
       
   366             CVPbkSimContact* aContact );
       
   367 
       
   368         /**
       
   369         * From MVPbkViewContact
       
   370         */
       
   371         void ContactEventError( TEvent aEvent, 
       
   372             CVPbkSimContact* aContact, TInt aError );
       
   373             
       
   374     private:    // New functions
       
   375         void CreateReadCallbackL( MVPbkContactObserver& aObserver,
       
   376                 MVPbkContactObserver::TContactOpResult& aOpResult ) const;
       
   377     private:    // Data
       
   378         /// The parent view of the contact
       
   379         CContactView& iView;
       
   380         /// Field collection
       
   381         CViewContactFieldCollection iFieldCollection;
       
   382         /// The view sort order
       
   383         const MVPbkFieldTypeList* iSortOrder;
       
   384         /// Not Own: the native sim contact set by SetSimContactL
       
   385         MVPbkSimContact* iSimContact;
       
   386         /// Own: an asynchronous call back that is needed if observer
       
   387         /// must be notified e.g from ReadL
       
   388         VPbkEngUtils::CVPbkAsyncOperation* iAsyncOp;
       
   389         /// Ref: an observer of DeleteL
       
   390         mutable MVPbkContactObserver* iObserver;
       
   391         /// Own: an async operation handle.
       
   392         mutable MVPbkSimStoreOperation* iStoreOperation;
       
   393     };
       
   394 
       
   395 } // namespace VPbkSimStore
       
   396 #endif      // VPBKSIMSTORE_CVIEWCONTACT_H
       
   397             
       
   398 // End of File