uiservicetab/vimpststorage/tsrc/vimpststorage_ut/stubs/CVPbkStoreContactStub.h
branchRCL_3
changeset 28 3104fc151679
parent 27 2b7283837edb
child 29 9a48e301e94b
equal deleted inserted replaced
27:2b7283837edb 28:3104fc151679
     1 /*
       
     2 * Copyright (c) 2004-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:  
       
    15 :                
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef CVPbkStoreContactStub_H
       
    22 #define CVPbkStoreContactStub_H
       
    23 
       
    24 
       
    25 // INCLUDES
       
    26 #include <MVPbkStoreContact.h>
       
    27 #include <MVPbkViewContact.h>
       
    28 
       
    29 // CLASS DECLARATIONS
       
    30 
       
    31 /**
       
    32  * An interface for store contacts.
       
    33  *
       
    34  * A store contact is a contact that includes all the fields of
       
    35  * the contact. For this reason it usually contains more data compared
       
    36  * to the corresponding view contact. It can contain all types of fields that
       
    37  * are supported by the its parent store.
       
    38  *
       
    39  * The store contact can be edited if it's not read-only. The client must
       
    40  * first lock the existing contact then edit it and finally commit the changes.
       
    41  *
       
    42  * @see MVPbkContactStore
       
    43  * @see MVPbkViewContact
       
    44  */
       
    45 class CVPbkStoreContactStub : public CBase,
       
    46                           public MVPbkStoreContact,
       
    47                           public MVPbkViewContact
       
    48     {
       
    49     public:  // Destructor
       
    50     	CVPbkStoreContactStub() ;
       
    51     
       
    52         ~CVPbkStoreContactStub() { }
       
    53 
       
    54     public: // From MVPbkBaseContact (covariant return types)
       
    55         const MVPbkStoreContactFieldCollection& Fields() const ;
       
    56      
       
    57      
       
    58      
       
    59     	/**
       
    60          * Returns the parent view of the contact.
       
    61          *
       
    62          * @return The parent view of the contact.
       
    63          */
       
    64         MVPbkContactViewBase& ParentView() const ;
       
    65 
       
    66         /**
       
    67          * Reads the whole contact from the store asynchronously.
       
    68          *
       
    69          * A client can use this if it has a reference of the view contact but
       
    70          * it needs all the data fields instead of only those that are included
       
    71          * in the view contact.
       
    72          *
       
    73          * The contact is returned in a call back.
       
    74          *
       
    75          * @param aObserver An observer to call back when this operation 
       
    76          *                  completes. The observer will not be called if this
       
    77          *                  function leaves.
       
    78          * @exception KErrInUse If another asynchronous operation is already 
       
    79          *                      in progress.
       
    80          */
       
    81         void ReadL( MVPbkContactObserver& aObserver ) const ;
       
    82 
       
    83         /**
       
    84          * Reads the whole contact and locks it for modification 
       
    85          * asynchronously.
       
    86          *
       
    87          * A client can use this if it has a reference of the view contact and
       
    88          * it needs to modify the contact.
       
    89          *
       
    90          * The contact is returned in a call back.
       
    91          *
       
    92          * @param aObserver An observer to call back when this operation 
       
    93          *                  completes. The observer will not be called if this
       
    94          *                  function leaves.
       
    95          * @exception KErrInUse If another asynchronous operation is already 
       
    96          *                      in progress.
       
    97          * @exception KErrAccessDenied if contact is read-only
       
    98          */
       
    99         void ReadAndLockL( MVPbkContactObserver& aObserver ) const ;
       
   100 
       
   101         /**
       
   102          * Returns expandable interface for this object or NULL if expanding is 
       
   103          * not supported.
       
   104          *
       
   105          * Examples are a contact group that can be expanded to its members view
       
   106          * or a folding view that can be extended to its internals. Client can
       
   107          * get the type of the view from MVPbkContactViewBase::Type which is useful
       
   108          * for knowing the type of expansion.
       
   109          *
       
   110          * @return An expansion or NULL.
       
   111          */
       
   112         MVPbkExpandable* Expandable() const ;
       
   113 
       
   114         /**
       
   115          * Returns ETrue if two contacts are same.
       
   116          *
       
   117          * @param aOtherContact A contact to be compared.
       
   118          * @param aContactStore The store of the aOtherContact.
       
   119          * @return ETrue if two contacts are same.
       
   120          */
       
   121         TBool IsSame( const MVPbkViewContact& aOtherContact, 
       
   122                               const MVPbkContactStore* aContactStore ) const ;
       
   123         
       
   124         /**
       
   125          * Returns ETrue if two contacts are same.
       
   126          *
       
   127          * @param aOtherContact A contact to be compared.
       
   128          * @param aContactStore The store of the aOtherContact.
       
   129          * @return ETrue if two contacts are same.
       
   130          */                    
       
   131         TBool IsSame( const MVPbkStoreContact& aOtherContact, 
       
   132                               const MVPbkContactStore* aContactStore ) const ;    
       
   133 
       
   134     public:  // New functions
       
   135         
       
   136 
       
   137         /**
       
   138          * Returns this contact's parent store.
       
   139          *
       
   140          * @return The parent store of the contact.
       
   141          */
       
   142         MVPbkContactStore& ParentStore() const 
       
   143         { 
       
   144         MVPbkContactStore* ret=NULL;
       
   145         return *ret;
       
   146         };
       
   147 
       
   148         /**
       
   149          * Returns this contact's fields (read-write).
       
   150          *
       
   151          * @return A collection of contact fields.
       
   152          */
       
   153         MVPbkStoreContactFieldCollection& Fields();
       
   154 
       
   155         /**
       
   156          * Creates a new field for this contact.
       
   157          *
       
   158          * The new field must be added to the contact using AddFieldL.
       
   159          *
       
   160          * @param aFieldType  A type of the field to create. Must be found in
       
   161          *                    ParentStore().SupportedFieldTypes().
       
   162          * @return A new field object. The returned object is left on the
       
   163          *         cleanup stack.
       
   164          * @exception KErrNotSupported if the field type is not supported.
       
   165          * @exception KErrAccessDenied if the contact can not be modified.
       
   166          */
       
   167         MVPbkStoreContactField* CreateFieldLC(
       
   168                 const MVPbkFieldType& /*aFieldType*/) const { return NULL; };
       
   169 
       
   170         /**
       
   171          * Adds a new field to the contact.
       
   172          * 
       
   173          * The field must be previously created with CreateFieldLC and
       
   174          * it must NOT be used after adding.
       
   175          *
       
   176          * If the client needs the field after adding it must be retrieved
       
   177          * using Fields().
       
   178          *
       
   179          * @param aField A new field that was created using CreateFieldLC.
       
   180          *               This object takes ownership of the field.
       
   181          * @precond aField must not be NULL or 
       
   182          *          VPbkError::Panic(VPbkError::ENullContactField) is raised.
       
   183          * @precond aField must be returned from this->CreateFieldLC or
       
   184          *          VPbkError::Panic(VPbkError::EInvalidContactField) panic is raised.
       
   185          * @postcond this->Fields().FieldCount() == 
       
   186          *           old(this->Fields().FieldCount()) + 1
       
   187          * @return The index of the new field in the field collection.
       
   188          * @exception KErrAccessDenied if the contact can not be modified.
       
   189          */
       
   190         TInt AddFieldL(MVPbkStoreContactField* /*aField*/) { return 0; };
       
   191 
       
   192         /**
       
   193          * Removes a field from the contact.
       
   194          *
       
   195          * @param aIndex A zero-based index of the field to remove.
       
   196          * @precond aIndex >= 0 && aIndex < FieldCount().
       
   197          *          Panics with VPbkError::EInvalidFieldIndex.
       
   198          * @precond The contact is not read-only otherwise panics with 
       
   199          *          VPbkError::EInvalidAccessToReadOnlyContact.
       
   200          * @postcond this->Fields().FieldCount() == 
       
   201          *           old(this->Fields().FieldCount()) - 1
       
   202          */
       
   203         void RemoveField(TInt /*aIndex*/) {};
       
   204 
       
   205         /**
       
   206          * Removes all the fields from the contact.
       
   207          *
       
   208          * @precond The contact is not read-only otherwise panics with 
       
   209          *          VPbkError::EInvalidAccessToReadOnlyContact.
       
   210          * @postcond this->Fields().FieldCount() =
       
   211          */
       
   212         void RemoveAllFields() {};
       
   213 
       
   214         /**
       
   215          * Locks this contact for modification asynchronously.
       
   216          *
       
   217          * Once the observer is notified this contact is locked and cab
       
   218          * be modified.
       
   219          *
       
   220          * @param aObserver The observer to call back when the operation
       
   221          *                  completes. The observer will not be called if this
       
   222          *                  function leaves.
       
   223          * @exception KErrInUse If another asynchronous operation is 
       
   224          *            already in progress.
       
   225          * @exception KErrAccessDenied if the contact can not be modified.
       
   226          */
       
   227         void LockL(MVPbkContactObserver& /*aObserver*/) const {};
       
   228 
       
   229         /**
       
   230          * Saves the contact to its associated store asynchronously.
       
   231          *
       
   232          * LockL must have been called before commit if this is
       
   233          * an existing contact. Otherwise ContactOperationFailed is called
       
   234          * with KErrAccessDenied.
       
   235          *
       
   236          * @param aObserver The observer to call back when this operation
       
   237          *                  completes. The observer will not be called if this
       
   238          *                  function leaves.
       
   239          * @exception KErrInUse If another asynchronous operation is already
       
   240          *            in progress.
       
   241          * @exception KErrAccessDenied if the contact can not be modified.
       
   242          */
       
   243         void CommitL(MVPbkContactObserver& /*aObserver*/) const {};
       
   244 
       
   245         /**
       
   246          * Returns the identifiers of the groups that the contact 
       
   247          * belongs to.
       
   248          *
       
   249          * @return The groups that this contact belongs to.
       
   250          */
       
   251         MVPbkContactLinkArray* GroupsJoinedLC() const { return NULL; };
       
   252 
       
   253         /**
       
   254          * Returns the group interface of the store contact if this contact
       
   255          * is a group.
       
   256          * If this contact is not a group, NULL is returned.
       
   257          *
       
   258          * @return The group interface or NULL.
       
   259          */
       
   260         MVPbkContactGroup* Group() { return NULL; };
       
   261         
       
   262         /**
       
   263          * Returns the maximum amount of fields of given type that can be
       
   264          * inserted to the contact.
       
   265          *
       
   266          * E.g. A USIM ADN contact can have 1 or more phone numbers but there
       
   267          * is a limit that the store in USIM defines.
       
   268          * On the other hand the contact in the Contacts Model data base
       
   269          * doesn't have limits.
       
   270          *
       
   271          * @param aType The field type of the field
       
   272          * @return The maximum amount fields of given type in the contact
       
   273          *         or KVPbkStoreContactUnlimitedNumber it there is no limit
       
   274          *         set by the store contact
       
   275          */
       
   276         TInt MaxNumberOfFieldL(const MVPbkFieldType& /*aType*/) const { return 0; };
       
   277 
       
   278         /**
       
   279          * Returns auxiliary properties.
       
   280          * Can return NULL if underlying store doesn't support any 
       
   281          * of MVPbkStoreContactProperties functions.
       
   282          *
       
   283          * @return A properties object
       
   284          */
       
   285         MVPbkStoreContactProperties* PropertiesL() const { return NULL; };
       
   286         
       
   287         /**
       
   288          * Set the contact as the store's current own contact asynchronously. 
       
   289          *
       
   290          * @param aObserver The observer to call back when this operation
       
   291          *                  completes. The observer will not be called if this
       
   292          *                  function leaves.
       
   293          * @exception KErrInUse If another asynchronous operation is already
       
   294          *            in progress.
       
   295          * @exception KErrNotSupported If store does not support own contact
       
   296          */
       
   297         void SetAsOwnL(MVPbkContactObserver& /*aObserver*/) const {};
       
   298         
       
   299         
       
   300         
       
   301         /**
       
   302          * Returns this contact's fields (read only).
       
   303          * @return This contact's fields in read only mode.
       
   304          */
       
   305        // const MVPbkBaseContactFieldCollection& Fields() const ;
       
   306 
       
   307         /**
       
   308          * Returns true if this a representation of the same contact.
       
   309          *
       
   310          * @param aOtherContact a contact this contact is compared against.
       
   311          * @return ETrue if this and aOtherContact represent the same contact.
       
   312          */
       
   313         TBool IsSame(const MVPbkBaseContact& aOtherContact) const ;
       
   314 
       
   315         /**
       
   316          * Returns true if this a representation of the same contact.
       
   317          *
       
   318          * @param aOtherContact a contact this contact is compared against.
       
   319          * @return ETrue if this and aOtherContact represent the same contact.
       
   320          */
       
   321         TBool IsSame(const MVPbkStoreContact& aOtherContact) const ;
       
   322 
       
   323         /**
       
   324          * Returns true if this a representation of the same contact.
       
   325          *
       
   326          * @param aOtherContact a contact this contact is compared against.
       
   327          * @return ETrue if this and aOtherContact represent the same contact.
       
   328          */
       
   329         TBool IsSame(const MVPbkViewContact& aOtherContact) const ;
       
   330 
       
   331         /**
       
   332          * Creates link representing this contact.
       
   333          *
       
   334          * @return A link or NULL if the contact doesn't exist in the store, 
       
   335          *         e.g. a folding contact in the view could be that kind or
       
   336          *         a new contact that hasn't been committed to the store.
       
   337          *         NULL is not put into the CleanupStack.
       
   338          */
       
   339         MVPbkContactLink* CreateLinkLC() const ;
       
   340 
       
   341         /**
       
   342          * Deletes this contact from store asynchronously.
       
   343          *
       
   344          * @param aObserver The observer to call back when this operation 
       
   345          *                  completes. The observer will not be called 
       
   346          *                  if this function leaves.
       
   347          * @exception KErrInUse If another asynchronous operation is already 
       
   348          *                      in progress.
       
   349          * @exception KErrAccessDenied if the contact can not be modified.
       
   350          */
       
   351         void DeleteL(MVPbkContactObserver& aObserver) const ;
       
   352         
       
   353         /**
       
   354          * Returns ETrue if this view contact is from given store
       
   355          *
       
   356          * @param aContactStoreUri the URI of the store to compare
       
   357          * @return ETrue if the view contact was from the given store
       
   358          */
       
   359         TBool MatchContactStore(
       
   360                 const TDesC& aContactStoreUri) const ;
       
   361         
       
   362         /**
       
   363          * Returns ETrue if this contact is from the same store 
       
   364          * domain as the given one.
       
   365          *
       
   366          * @param aContactStoreDomain the the store domain
       
   367          * @return ETrue if the contact was from the same store domain.
       
   368          */
       
   369         TBool MatchContactStoreDomain(
       
   370                 const TDesC& aContactStoreDomain) const ;
       
   371         
       
   372         /**
       
   373          * Creates and returns a bookmark that points to the contact.
       
   374          * Bookmark can be used to retrieve an index of the contact in 
       
   375          * the view.
       
   376          *
       
   377          * @return A new bookmark to the contact
       
   378          */
       
   379         MVPbkContactBookmark* CreateBookmarkLC() const ;
       
   380         
       
   381         /**
       
   382          * Returns the parent object of this object. For the root of the 
       
   383          * hierarchy returns self.
       
   384          * @return The parent object.
       
   385          */
       
   386         MVPbkObjectHierarchy& ParentObject() const;
       
   387         
       
   388     };
       
   389 
       
   390 
       
   391 #endif  // CVPbkStoreContactStub
       
   392 
       
   393 //End of file