author | William Roberts <williamr@symbian.org> |
Wed, 31 Mar 2010 12:33:34 +0100 | |
branch | Symbian3 |
changeset 4 | 837f303aceeb |
permissions | -rw-r--r-- |
williamr@4 | 1 |
/* |
williamr@4 | 2 |
* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). |
williamr@4 | 3 |
* All rights reserved. |
williamr@4 | 4 |
* This component and the accompanying materials are made available |
williamr@4 | 5 |
* under the terms of "Eclipse Public License v1.0" |
williamr@4 | 6 |
* which accompanies this distribution, and is available |
williamr@4 | 7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
williamr@4 | 8 |
* |
williamr@4 | 9 |
* Initial Contributors: |
williamr@4 | 10 |
* Nokia Corporation - initial contribution. |
williamr@4 | 11 |
* |
williamr@4 | 12 |
* Contributors: |
williamr@4 | 13 |
* |
williamr@4 | 14 |
* Description: An interface for store contacts. |
williamr@4 | 15 |
* |
williamr@4 | 16 |
*/ |
williamr@4 | 17 |
|
williamr@4 | 18 |
|
williamr@4 | 19 |
#ifndef MVPBKSTORECONTACT_H |
williamr@4 | 20 |
#define MVPBKSTORECONTACT_H |
williamr@4 | 21 |
|
williamr@4 | 22 |
|
williamr@4 | 23 |
// INCLUDES |
williamr@4 | 24 |
#include <e32base.h> |
williamr@4 | 25 |
#include <mvpbkbasecontact.h> |
williamr@4 | 26 |
#include <mvpbkviewcontact.h> |
williamr@4 | 27 |
|
williamr@4 | 28 |
// Includes needed for covariant return types |
williamr@4 | 29 |
#include <mvpbkstorecontactfieldcollection.h> |
williamr@4 | 30 |
|
williamr@4 | 31 |
// FORWARD DECLARATIONS |
williamr@4 | 32 |
class MVPbkContactStore; |
williamr@4 | 33 |
class MVPbkContactObserver; |
williamr@4 | 34 |
class MVPbkStoreContactField; |
williamr@4 | 35 |
class MVPbkFieldType; |
williamr@4 | 36 |
class MVPbkContactLinkArray; |
williamr@4 | 37 |
class MVPbkContactGroup; |
williamr@4 | 38 |
class MVPbkStoreContactProperties; |
williamr@4 | 39 |
|
williamr@4 | 40 |
// CONSTANTS |
williamr@4 | 41 |
const TInt KVPbkStoreContactUnlimitedNumber = -1; |
williamr@4 | 42 |
|
williamr@4 | 43 |
//Use this UID to access contact store extension 2. |
williamr@4 | 44 |
// Used as a parameter to ContactStoreExtension() method. |
williamr@4 | 45 |
const TUid KMVPbkStoreContactExtension2Uid = { 2 }; |
williamr@4 | 46 |
// CLASS DECLARATIONS |
williamr@4 | 47 |
|
williamr@4 | 48 |
/** |
williamr@4 | 49 |
* An interface for store contacts. |
williamr@4 | 50 |
* |
williamr@4 | 51 |
* A store contact is a contact that includes all the fields of |
williamr@4 | 52 |
* the contact. For this reason it usually contains more data compared |
williamr@4 | 53 |
* to the corresponding view contact. It can contain all types of fields that |
williamr@4 | 54 |
* are supported by the its parent store. |
williamr@4 | 55 |
* |
williamr@4 | 56 |
* The store contact can be edited if it's not read-only. The client must |
williamr@4 | 57 |
* first lock the existing contact then edit it and finally commit the changes. |
williamr@4 | 58 |
* |
williamr@4 | 59 |
* @see MVPbkContactStore |
williamr@4 | 60 |
* @see MVPbkViewContact |
williamr@4 | 61 |
*/ |
williamr@4 | 62 |
class MVPbkStoreContact : public MVPbkBaseContact, |
williamr@4 | 63 |
public MVPbkObjectHierarchy |
williamr@4 | 64 |
{ |
williamr@4 | 65 |
public: // Destructor |
williamr@4 | 66 |
virtual ~MVPbkStoreContact() { } |
williamr@4 | 67 |
|
williamr@4 | 68 |
public: // From MVPbkBaseContact (covariant return types) |
williamr@4 | 69 |
const MVPbkStoreContactFieldCollection& Fields() const =0; |
williamr@4 | 70 |
|
williamr@4 | 71 |
public: // New functions |
williamr@4 | 72 |
/** |
williamr@4 | 73 |
* Pushes an item on the cleanup stack. |
williamr@4 | 74 |
* |
williamr@4 | 75 |
* Clients must use either this function or CleanupDeletePushL |
williamr@4 | 76 |
* from e32base.h. |
williamr@4 | 77 |
* |
williamr@4 | 78 |
* CleanupStack::PushL(TAny*) must not be used because the virtual |
williamr@4 | 79 |
* destructor of M-class won't be called. |
williamr@4 | 80 |
* This function should be used to make sure that the virtual destructor |
williamr@4 | 81 |
* of this object is called when popped and destroyed from the cleanup |
williamr@4 | 82 |
* stack. |
williamr@4 | 83 |
*/ |
williamr@4 | 84 |
inline void PushL(); |
williamr@4 | 85 |
|
williamr@4 | 86 |
/** |
williamr@4 | 87 |
* Returns this contact's parent store. |
williamr@4 | 88 |
* |
williamr@4 | 89 |
* @return The parent store of the contact. |
williamr@4 | 90 |
*/ |
williamr@4 | 91 |
virtual MVPbkContactStore& ParentStore() const =0; |
williamr@4 | 92 |
|
williamr@4 | 93 |
/** |
williamr@4 | 94 |
* Returns this contact's fields (read-write). |
williamr@4 | 95 |
* |
williamr@4 | 96 |
* @return A collection of contact fields. |
williamr@4 | 97 |
*/ |
williamr@4 | 98 |
virtual MVPbkStoreContactFieldCollection& Fields() =0; |
williamr@4 | 99 |
|
williamr@4 | 100 |
/** |
williamr@4 | 101 |
* Creates a new field for this contact. |
williamr@4 | 102 |
* |
williamr@4 | 103 |
* The new field must be added to the contact using AddFieldL. |
williamr@4 | 104 |
* |
williamr@4 | 105 |
* @param aFieldType A type of the field to create. Must be found in |
williamr@4 | 106 |
* ParentStore().SupportedFieldTypes(). |
williamr@4 | 107 |
* @return A new field object. The returned object is left on the |
williamr@4 | 108 |
* cleanup stack. |
williamr@4 | 109 |
* @exception KErrNotSupported if the field type is not supported. |
williamr@4 | 110 |
* @exception KErrAccessDenied if the contact can not be modified. |
williamr@4 | 111 |
*/ |
williamr@4 | 112 |
virtual MVPbkStoreContactField* CreateFieldLC( |
williamr@4 | 113 |
const MVPbkFieldType& aFieldType) const =0; |
williamr@4 | 114 |
|
williamr@4 | 115 |
/** |
williamr@4 | 116 |
* Adds a new field to the contact. |
williamr@4 | 117 |
* |
williamr@4 | 118 |
* The field must be previously created with CreateFieldLC and |
williamr@4 | 119 |
* it must NOT be used after adding. |
williamr@4 | 120 |
* |
williamr@4 | 121 |
* If the client needs the field after adding it must be retrieved |
williamr@4 | 122 |
* using Fields(). |
williamr@4 | 123 |
* |
williamr@4 | 124 |
* @param aField A new field that was created using CreateFieldLC. |
williamr@4 | 125 |
* This object takes ownership of the field. |
williamr@4 | 126 |
* @precond aField must not be NULL or |
williamr@4 | 127 |
* VPbkError::Panic(VPbkError::ENullContactField) is raised. |
williamr@4 | 128 |
* @precond aField must be returned from this->CreateFieldLC or |
williamr@4 | 129 |
* VPbkError::Panic(VPbkError::EInvalidContactField) panic is raised. |
williamr@4 | 130 |
* @postcond this->Fields().FieldCount() == |
williamr@4 | 131 |
* old(this->Fields().FieldCount()) + 1 |
williamr@4 | 132 |
* @return The index of the new field in the field collection. |
williamr@4 | 133 |
* @exception KErrAccessDenied if the contact can not be modified. |
williamr@4 | 134 |
*/ |
williamr@4 | 135 |
virtual TInt AddFieldL(MVPbkStoreContactField* aField) =0; |
williamr@4 | 136 |
|
williamr@4 | 137 |
/** |
williamr@4 | 138 |
* Removes a field from the contact. |
williamr@4 | 139 |
* |
williamr@4 | 140 |
* @param aIndex A zero-based index of the field to remove. |
williamr@4 | 141 |
* @precond aIndex >= 0 && aIndex < FieldCount(). |
williamr@4 | 142 |
* Panics with VPbkError::EInvalidFieldIndex. |
williamr@4 | 143 |
* @precond The contact is not read-only otherwise panics with |
williamr@4 | 144 |
* VPbkError::EInvalidAccessToReadOnlyContact. |
williamr@4 | 145 |
* @postcond this->Fields().FieldCount() == |
williamr@4 | 146 |
* old(this->Fields().FieldCount()) - 1 |
williamr@4 | 147 |
*/ |
williamr@4 | 148 |
virtual void RemoveField(TInt aIndex) =0; |
williamr@4 | 149 |
|
williamr@4 | 150 |
/** |
williamr@4 | 151 |
* Removes all the fields from the contact. |
williamr@4 | 152 |
* |
williamr@4 | 153 |
* @precond The contact is not read-only otherwise panics with |
williamr@4 | 154 |
* VPbkError::EInvalidAccessToReadOnlyContact. |
williamr@4 | 155 |
* @postcond this->Fields().FieldCount() == 0 |
williamr@4 | 156 |
*/ |
williamr@4 | 157 |
virtual void RemoveAllFields() =0; |
williamr@4 | 158 |
|
williamr@4 | 159 |
/** |
williamr@4 | 160 |
* Locks this contact for modification asynchronously. |
williamr@4 | 161 |
* |
williamr@4 | 162 |
* Once the observer is notified this contact is locked and cab |
williamr@4 | 163 |
* be modified. |
williamr@4 | 164 |
* |
williamr@4 | 165 |
* @param aObserver The observer to call back when the operation |
williamr@4 | 166 |
* completes. The observer will not be called if this |
williamr@4 | 167 |
* function leaves. |
williamr@4 | 168 |
* @exception KErrInUse If another asynchronous operation is |
williamr@4 | 169 |
* already in progress. |
williamr@4 | 170 |
* @exception KErrAccessDenied if the contact can not be modified. |
williamr@4 | 171 |
*/ |
williamr@4 | 172 |
virtual void LockL(MVPbkContactObserver& aObserver) const =0; |
williamr@4 | 173 |
|
williamr@4 | 174 |
/** |
williamr@4 | 175 |
* Saves the contact to its associated store asynchronously. |
williamr@4 | 176 |
* |
williamr@4 | 177 |
* LockL must have been called before commit if this is |
williamr@4 | 178 |
* an existing contact. Otherwise ContactOperationFailed is called |
williamr@4 | 179 |
* with KErrAccessDenied. |
williamr@4 | 180 |
* |
williamr@4 | 181 |
* @param aObserver The observer to call back when this operation |
williamr@4 | 182 |
* completes. The observer will not be called if this |
williamr@4 | 183 |
* function leaves. |
williamr@4 | 184 |
* @exception KErrInUse If another asynchronous operation is already |
williamr@4 | 185 |
* in progress. |
williamr@4 | 186 |
* @exception KErrAccessDenied if the contact can not be modified. |
williamr@4 | 187 |
*/ |
williamr@4 | 188 |
virtual void CommitL(MVPbkContactObserver& aObserver) const =0; |
williamr@4 | 189 |
|
williamr@4 | 190 |
/** |
williamr@4 | 191 |
* Returns the identifiers of the groups that the contact |
williamr@4 | 192 |
* belongs to. |
williamr@4 | 193 |
* |
williamr@4 | 194 |
* @return The groups that this contact belongs to. |
williamr@4 | 195 |
*/ |
williamr@4 | 196 |
virtual MVPbkContactLinkArray* GroupsJoinedLC() const =0; |
williamr@4 | 197 |
|
williamr@4 | 198 |
/** |
williamr@4 | 199 |
* Returns the group interface of the store contact if this contact |
williamr@4 | 200 |
* is a group. |
williamr@4 | 201 |
* If this contact is not a group, NULL is returned. |
williamr@4 | 202 |
* |
williamr@4 | 203 |
* @return The group interface or NULL. |
williamr@4 | 204 |
*/ |
williamr@4 | 205 |
virtual MVPbkContactGroup* Group() =0; |
williamr@4 | 206 |
|
williamr@4 | 207 |
/** |
williamr@4 | 208 |
* Returns the maximum amount of fields of given type that can be |
williamr@4 | 209 |
* inserted to the contact. |
williamr@4 | 210 |
* |
williamr@4 | 211 |
* E.g. A USIM ADN contact can have 1 or more phone numbers but there |
williamr@4 | 212 |
* is a limit that the store in USIM defines. |
williamr@4 | 213 |
* On the other hand the contact in the Contacts Model data base |
williamr@4 | 214 |
* doesn't have limits. |
williamr@4 | 215 |
* |
williamr@4 | 216 |
* @param aType The field type of the field |
williamr@4 | 217 |
* @return The maximum amount fields of given type in the contact |
williamr@4 | 218 |
* or KVPbkStoreContactUnlimitedNumber it there is no limit |
williamr@4 | 219 |
* set by the store contact |
williamr@4 | 220 |
*/ |
williamr@4 | 221 |
virtual TInt MaxNumberOfFieldL(const MVPbkFieldType& aType) const =0; |
williamr@4 | 222 |
|
williamr@4 | 223 |
|
williamr@4 | 224 |
/** |
williamr@4 | 225 |
* Returns an extension point for this interface or NULL. |
williamr@4 | 226 |
* |
williamr@4 | 227 |
* @param aExtensionUid no extensions defined currently. |
williamr@4 | 228 |
* @return An extension point for this interface or NULL. |
williamr@4 | 229 |
*/ |
williamr@4 | 230 |
virtual TAny* StoreContactExtension(TUid /*aExtensionUid*/) |
williamr@4 | 231 |
{ return NULL; } |
williamr@4 | 232 |
|
williamr@4 | 233 |
public: // from MVPbkBaseContact |
williamr@4 | 234 |
/// Do not override |
williamr@4 | 235 |
virtual TBool IsSame(const MVPbkBaseContact& aOtherContact) const |
williamr@4 | 236 |
{ |
williamr@4 | 237 |
return aOtherContact.IsSame(*this); |
williamr@4 | 238 |
} |
williamr@4 | 239 |
|
williamr@4 | 240 |
// Do not override |
williamr@4 | 241 |
virtual TBool IsSame(const MVPbkViewContact& aOtherContact) const |
williamr@4 | 242 |
{ |
williamr@4 | 243 |
return aOtherContact.IsSame(*this, &ContactStore()); |
williamr@4 | 244 |
} |
williamr@4 | 245 |
}; |
williamr@4 | 246 |
|
williamr@4 | 247 |
|
williamr@4 | 248 |
// INLINE FUNCTIONS |
williamr@4 | 249 |
inline void MVPbkStoreContact::PushL() |
williamr@4 | 250 |
{ |
williamr@4 | 251 |
CleanupDeletePushL(this); |
williamr@4 | 252 |
} |
williamr@4 | 253 |
|
williamr@4 | 254 |
#endif // MVPBKSTORECONTACT_H |
williamr@4 | 255 |
|
williamr@4 | 256 |
//End of file |