phonebookengines/contactsmodel/inc/CNTITEM.H
changeset 0 e686773b3f54
child 24 0ba2181d7c28
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Persistence layer exports
       
    15 // 
       
    16 //
       
    17 
       
    18 #if !defined(__CNTITEM_H__)
       
    19 #define __CNTITEM_H__
       
    20 
       
    21 #if !defined(__E32BASE_H__)
       
    22 #include <e32base.h>
       
    23 #endif
       
    24 
       
    25 #if !defined(__CNTDEF_H__)
       
    26 #include <cntdef.h>
       
    27 #endif
       
    28 
       
    29 #if !defined(__CNTFIELD_H__)
       
    30 #include <cntfield.h>
       
    31 #endif
       
    32 
       
    33 #include <cntdb.h>
       
    34 
       
    35 /** Maximum length of UID string.
       
    36 @publishedAll
       
    37 @released
       
    38 */
       
    39 const TInt KUidStringLength =244;
       
    40 
       
    41 /** UID string separator character
       
    42 @publishedAll
       
    43 @released
       
    44 */
       
    45 #define KUidStringSeparator '-'
       
    46 
       
    47 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    48 /** Constant used by vCard import/export.
       
    49 @internalComponent
       
    50 */
       
    51 #define KContactMaxFieldNumber 32
       
    52 #endif
       
    53 
       
    54 class CContactItemField;
       
    55 class CContactItemViewDef;
       
    56 class CContactItem;
       
    57 
       
    58 /** Constant to indicate that all fields in the fieldset should be searched.
       
    59 @publishedAll
       
    60 @released
       
    61 */
       
    62 const TInt KContactFieldSetSearchAll=-1;
       
    63 
       
    64 class CContactItemFieldSet : public CBase
       
    65 /** A contact item's field set. The field set owns an array of contact item fields
       
    66 (CContactItemFields). The field set is owned by a contact item, and can be
       
    67 retrieved using CContactItem::CardFields(). Use functions in class
       
    68 CContactItem to add and remove fields to/from the field set.
       
    69 
       
    70 A field set can contain more than one field of the same type, but this is
       
    71 not advisable as it may cause problems when synchronising the contacts database.
       
    72 @publishedAll
       
    73 @released
       
    74 */
       
    75 	{
       
    76 	friend class CContactItemField;
       
    77 	friend class CContactDatabase;
       
    78 	friend class CContactTables;
       
    79 	friend class RPplContactTable;
       
    80     friend class TCntPersistenceUtility;
       
    81 
       
    82 public:
       
    83 	IMPORT_C static CContactItemFieldSet* NewL();
       
    84 	IMPORT_C static CContactItemFieldSet* NewLC();
       
    85 	IMPORT_C ~CContactItemFieldSet();
       
    86 	inline const CContactItemField& operator[](TInt aIndex) const;
       
    87 	inline CContactItemField& operator[](TInt aIndex);
       
    88 	inline TInt Find(TFieldType aFieldType) const; // will only find the first such occurence
       
    89 	inline TInt Find(TFieldType aFieldType,TUid aMapping) const;
       
    90 	IMPORT_C TInt FindNext(TFieldType aFieldType,TInt aStartPos=KContactFieldSetSearchAll) const;
       
    91 	IMPORT_C TInt FindNext(TFieldType aFieldType,TUid aMapping,TInt aStartPos=KContactFieldSetSearchAll) const;
       
    92 	inline TInt Count() const;
       
    93 	inline void Reset();
       
    94 	IMPORT_C void UpdateFieldL(const CContactItemField& aField, TInt aMatchCount);
       
    95 	IMPORT_C void UpdateFieldSyncL(const CContactItemField& aField, TInt aMatchCount);
       
    96 	IMPORT_C CContactItemFieldSet& AddL(CContactItemField& aField);
       
    97 	IMPORT_C void Remove(TInt aIndex);
       
    98 	IMPORT_C void InsertL(TInt aIndex,CContactItemField& aField);
       
    99 	IMPORT_C void Move(TInt aFrom, TInt aTo);
       
   100 	IMPORT_C TStreamId StoreL(CStreamStore& aStore,RWriteStream& aTextStream,CStreamStore& aBlobStore);
       
   101 	TStreamId StoreL(CStreamStore& aStore,RWriteStream& aTextStream,CStreamStore& aBlobStore,CContactTables* aTables);
       
   102 	IMPORT_C void RestoreL(CStreamStore& aStore, TStreamId anId,CStreamStore* aBlobStore,const CContactItemViewDef& aViewDef,RReadStream& aReadStream);
       
   103 	IMPORT_C void RestoreL(CStreamStore& aStore, TStreamId anId,CStreamStore* aBlobStore,const CContactItemViewDef& aViewDef,const CContactItem* aTemplate, HBufC* aTextBuf);
       
   104 	TInt FieldText(TFieldType aFieldType, TDes &aText, TInt aStartPosition) const;
       
   105 	CArrayFix<TFieldHeader>* ConstructFieldHeaderArrayLC(RWriteStream& aTextStream, CStreamStore& aBlobStore);
       
   106 	TInt FieldTypeCount(const CContactItemFieldSet& aSystemTemplateFields, TInt aStartIndex, const CContactItemField& aField) const;
       
   107 	TBool ContainsFieldTypeMapping(const CContentType& aBaseFieldContentType, const TFieldType& aContactFieldType) const;
       
   108 	void ExternalizeL(RWriteStream& aStream) const;
       
   109 	void InternalizeL(RReadStream& aStream);
       
   110 
       
   111 private:
       
   112 	CContactItemFieldSet();
       
   113 	void ConstructL();
       
   114 	void SetFieldId(CContactItemField& aField);
       
   115 	const CContactItemField* FindById(TInt aId) const;
       
   116 	IMPORT_C TStreamId StoreL(CStreamStore& aStore,const CContactItem* aTemplate,RWriteStream& aStream,CStreamStore& aBlobStore,CContactTables* aTables);
       
   117 	void RestoreL(CStreamStore& aStore, TStreamId anId, CStreamStore* aBlobStore,const CContactItemViewDef& aViewDef,const CContactItem* aTemplate,RReadStream& aReadStream,CContactTables* aContactsTable, RArray<TInt>* aEmailIdArray);
       
   118 	void RestoreAndAddTemplateL(CStreamStore& aStore, TStreamId aId,CStreamStore* aBlobStore,const CContactItemViewDef& aViewDef,const CContactItem* aTemplate, RReadStream& aReadStream,CContactTables* aContactsTable,RArray<TInt>* aEmailIdArray);
       
   119 	TInt MatchTemplateField(const CContentType& aContentType,TUint aUserFlags,TBool &aExactMatch) const;
       
   120 	static HBufC* LoadTextStreamLC(RReadStream& aStream);
       
   121 	void NonZeroFieldText(TFieldType aFieldType, TDes &aText) const;
       
   122 
       
   123 private:
       
   124 	CArrayPtr<CContactItemField>* iFields;
       
   125 	};
       
   126 
       
   127 class CContactDatabase;
       
   128 class RCntModel;
       
   129 class CContactItem : public CBase
       
   130 /** The abstract base class for contact cards, templates and groups. All contact
       
   131 items are identified by a contact ID, (TContactItemId), have a last modified
       
   132 date/time and own one or more fields (the field set). Contact items also
       
   133 have an access count and attributes (e.g. hidden). Note that fields in a contact
       
   134 item also have attributes. Attribute values specified in the contact item
       
   135 override those in the contained fields. The access count is a record of the
       
   136 number of objects referencing a contact item. A contact item cannot be fully
       
   137 deleted until its access count is zero.
       
   138 @publishedAll
       
   139 @released
       
   140 */
       
   141 	{
       
   142 	friend class CContactCardTemplate;
       
   143 	friend class CContactItemPlusGroup;
       
   144 	friend class CContactCard;
       
   145 	friend class CContactTemplate;
       
   146 	friend class CContactGroup;
       
   147 	friend class CContactOwnCard;
       
   148 	friend class CVCardToContactsAppConverter;
       
   149 	friend class CContactICCEntry;
       
   150 	friend class RPplContactTable;
       
   151 	friend class RPplIdentityTable;
       
   152 	friend class RPplPreferencesTable;
       
   153 	friend class CPackagerTests; //Comparison test
       
   154 	friend class CPackagerCntComparator;
       
   155 	friend class CContactDatabase;
       
   156 	friend class CPplContactItemManager;
       
   157 public:
       
   158 	IMPORT_C ~CContactItem();
       
   159 	/** Gets the contact item's type.
       
   160 
       
   161 	@return The contact item's type. */
       
   162 	virtual TUid Type() const=0;
       
   163 	static CContactItem* NewLC(RReadStream& aStream);
       
   164 	IMPORT_C static CContactItem* NewLC(TUid aType);
       
   165 	IMPORT_C TContactItemId Id() const;
       
   166 	IMPORT_C TContactItemId TemplateRefId() const;
       
   167 	IMPORT_C TTime LastModified() const;
       
   168 	IMPORT_C void SetLastModified(const TTime& aLastModified);
       
   169 	IMPORT_C void AddFieldL(CContactItemField& aField);
       
   170 	IMPORT_C void RemoveField(TInt aFieldPos);
       
   171 	IMPORT_C void InsertFieldL(CContactItemField& aField,TInt aFieldPos);
       
   172 	IMPORT_C CContactItemFieldSet& CardFields() const;
       
   173 	IMPORT_C void SetHidden(TBool aHidden);
       
   174 	IMPORT_C void SetSystem(TBool aSystem);
       
   175 	IMPORT_C TBool IsHidden();
       
   176 	IMPORT_C TBool IsSystem();
       
   177 	IMPORT_C void UpdateFieldSet(CContactItemFieldSet* aNewFieldSet);
       
   178 	IMPORT_C void SetDeleted(TBool aDeleted);
       
   179 	IMPORT_C TBool IsDeleted() const;
       
   180 	IMPORT_C void SetTemplateRefId(TContactItemId aUid);
       
   181 	TContactItemId Agent();
       
   182 	inline TBool IsDeletable();
       
   183 	inline void IncAccessCount();
       
   184 	inline void DecAccessCount();
       
   185 	inline TInt AccessCount() const;
       
   186 	IMPORT_C void SetUidStringL(TDesC& aString);
       
   187 	IMPORT_C TPtrC UidStringL(TInt64 aMachineUniqueId) const;
       
   188 	TStreamId PopulateStoreL(CStreamStore& aStore, CArrayFix<TFieldHeader>& aFieldHeaderArray) const;
       
   189 	void AddLabelFieldL();
       
   190 	IMPORT_C void RestoreTemplateFieldsL(const CContactItemFieldSet& aSystemTemplateFields, const CContactItemFieldSet& aTemplateFields, const CContactItemViewDef& aViewDef);
       
   191 	void ClearFieldContent();
       
   192 	inline TPtrC Guid();
       
   193 	virtual void ExternalizeL(RWriteStream& aStream) const;
       
   194 	virtual void InternalizeL(RReadStream& aStream);
       
   195 
       
   196 	IMPORT_C void SetId(TContactItemId aId);
       
   197 	IMPORT_C TUint32 Attributes() const;
       
   198 	IMPORT_C void SetAttributes(TUint32 aAttributes);
       
   199 	IMPORT_C void SetAccessCount(TUint32 aAccessCount);
       
   200 	IMPORT_C void SetCreationDate(const TTime& aTime);
       
   201 
       
   202 public:
       
   203 	/** Contact item's attribute flags
       
   204 
       
   205 	These flags can be used to set the various attributes of a contact item. */
       
   206 	enum
       
   207 	{
       
   208 	/** To set the contact item's system attribute. */
       
   209 	ESystem=0x01,
       
   210 	/** To set the contact item's hidden attribute. */
       
   211 	EHidden=0x02,
       
   212 	/** To set the contact item's hidden attribute. */
       
   213 	ECompressedGuid=0x04,
       
   214 	/** To set the contact item's Is deleted attribute. */
       
   215 	EDeleted=0x08
       
   216 	};
       
   217 
       
   218 private:
       
   219 	CContactItem();
       
   220 	void ConstructL();
       
   221 	void ConstructL(const CContactItem *aTemplate);
       
   222 	void MakeUidStringL(TInt64 aMachineUniqueId);
       
   223 	IMPORT_C void SetHasCompressedGuid(TBool aCompressed);
       
   224 	TBool GuidIsCompressed() const;
       
   225 	TInt NumberOfFieldsToStore() const;
       
   226 
       
   227 private:
       
   228 	CContactItemFieldSet* iFieldSet;
       
   229 	TUint32 iAttributes;
       
   230 	TContactItemId iId;
       
   231 	TContactItemId iTemplateRefId;
       
   232 	TTime iLastModified;
       
   233 	TTime iCreationDate;
       
   234 	TUint32 iAccessCount;
       
   235 	HBufC* iGuid;
       
   236 	};
       
   237 
       
   238 class CContactItemPlusGroup : public CContactItem
       
   239 /** Abstract base class for CContactGroup, CContactCard and CContactOwnCard.
       
   240 
       
   241 The purpose of this class is to avoid duplication of group functionality
       
   242 in its derived classes.
       
   243 @publishedAll
       
   244 @released
       
   245 */
       
   246 	{
       
   247 public:
       
   248 	IMPORT_C const CContactIdArray* GroupsJoined() const;
       
   249 	IMPORT_C CContactIdArray* GroupsJoinedLC() const;
       
   250 protected:
       
   251 	CContactItemPlusGroup();
       
   252 	IMPORT_C ~CContactItemPlusGroup();
       
   253 public:
       
   254 	virtual void ExternalizeL(RWriteStream& aStream) const;
       
   255 	virtual void InternalizeL(RReadStream& aStream);
       
   256 
       
   257 	IMPORT_C void ResetGroups();
       
   258 	IMPORT_C void SetGroups(CContactIdArray* aGroups);
       
   259 
       
   260 private:
       
   261 	CContactIdArray* iGroups;
       
   262 	friend class CContactDatabase;
       
   263 	friend class RPplLookupGroupsTable;
       
   264 	friend class RPplGroupMembershipTable;
       
   265 	};
       
   266 
       
   267 class CContactGroup : public CContactItemPlusGroup
       
   268 /** A contact group.
       
   269 
       
   270 A contact group is a contact item which holds a set of associated contact
       
   271 item IDs. The members of the group may be contact cards, own cards, or even
       
   272 other groups. The group has a label which identifies the group to users, e.g.
       
   273 "family", or "colleagues". The type of a contact group is KUidContactGroup,
       
   274 as returned by Type().
       
   275 
       
   276 Objects of this class are constructed using CContactDatabase::CreateContactGroupL()
       
   277 or CreateContactGroupLC(). These functions create the group, optionally with
       
   278 a label, add it to the database, and return a pointer to it.
       
   279 
       
   280 To create an association between a card and a group, use CContactDatabase::AddContactToGroupL()
       
   281 and to remove the association, use RemoveContactFromGroupL(). To find out
       
   282 which groups a card belongs to, use CContactCard::GroupsJoinedLC() or CContactOwnCard::GroupsJoinedLC().
       
   283 
       
   284 The function CContactDatabase::GetGroupIdListL() may be used to retrieve a
       
   285 list of IDs for all groups in the database.
       
   286 @publishedAll
       
   287 @released
       
   288 */
       
   289 	{
       
   290 public:
       
   291 	IMPORT_C static CContactGroup* NewL();
       
   292 	IMPORT_C static CContactGroup* NewLC();
       
   293 	IMPORT_C ~CContactGroup();
       
   294 public: // from CContactItem
       
   295 	IMPORT_C TUid Type() const;
       
   296 public:
       
   297 	// default sorted item array is ascending
       
   298 	IMPORT_C CContactIdArray* ItemsContainedLC() const;
       
   299 	IMPORT_C const CContactIdArray* ItemsContained() const;
       
   300 	IMPORT_C TBool IsSystem() const;
       
   301 	IMPORT_C void SetSystem(TBool aSystem);
       
   302 	IMPORT_C TBool ContainsItem(TContactItemId aContactId);
       
   303 	IMPORT_C void SetGroupLabelL(const TDesC& aLabel);
       
   304 	IMPORT_C TPtrC GetGroupLabelL();
       
   305 	IMPORT_C TBool HasItemLabelField();
       
   306 	IMPORT_C CContactIdArray* GroupsJoinedLC() const;
       
   307 
       
   308 	IMPORT_C void AddContactL(TContactItemId aContactId);
       
   309 	IMPORT_C void RemoveContactL(TContactItemId aContactId);
       
   310 	virtual void ExternalizeL(RWriteStream& aStream) const;
       
   311 	virtual void InternalizeL(RReadStream& aStream);
       
   312 
       
   313 	IMPORT_C void ResetItems();
       
   314 	IMPORT_C void SetItems(CContactIdArray* aItems);
       
   315 
       
   316 private:
       
   317 	CContactGroup();
       
   318 
       
   319 private:
       
   320 	CContactIdArray* iItems;
       
   321 	friend class CContactDatabase;
       
   322 	friend class RPplGroupMembershipTable;
       
   323 	};
       
   324 
       
   325 class CContactCardTemplate : public CContactItem
       
   326 /** A contact card template.
       
   327 
       
   328 This is a contact item containing a set of fields on which new contact items can
       
   329 be based. Templates have a label which is a string which identifies the template
       
   330 to a user. For instance, 'work template' could indicate a template used
       
   331 to create contact cards in the style of a work colleague. Contact card templates
       
   332 have a type of KUidContactCardTemplate, as returned by Type().
       
   333 
       
   334 Objects of this class cannot be constructed directly because its constructors
       
   335 are protected. Instead, use either CContactDatabase::CreateContactCardTemplateL()
       
   336 or CreateContactCardTemplateLC(). These functions create a contact card template,
       
   337 add it to the database, and return a pointer to it.
       
   338 
       
   339 The function CContactDatabase::GetCardTemplateIdListL() gets a list of the
       
   340 IDs of all contact card templates in the database.
       
   341 @publishedAll
       
   342 @released
       
   343 */
       
   344 	{
       
   345 	friend class CContactDatabase;
       
   346 	friend class CContactTables;
       
   347 	friend class RPplContactTable;
       
   348 	friend class CContactItem;
       
   349 public:
       
   350 	IMPORT_C void SetTemplateLabelL(const TDesC& aLabel);
       
   351 	IMPORT_C TPtrC GetTemplateLabelL();
       
   352 protected:
       
   353 	IMPORT_C static CContactCardTemplate* NewL();
       
   354 	IMPORT_C static CContactCardTemplate* NewLC();
       
   355 	IMPORT_C static CContactCardTemplate* NewL(const CContactItem *aTemplate);
       
   356 	IMPORT_C static CContactCardTemplate* NewLC(const CContactItem *aTemplate);
       
   357 	IMPORT_C TBool HasItemLabelField();
       
   358 
       
   359 /** Intended usage: Reserved to preserve future BC */
       
   360 	IMPORT_C void ReservedFunction1();
       
   361 /** Intended usage: Reserved to preserve future BC */
       
   362 	IMPORT_C void ReservedFunction2();
       
   363 
       
   364 protected: // from CContactItem
       
   365 	IMPORT_C TUid Type() const;
       
   366 
       
   367 private:
       
   368 	CContactCardTemplate();
       
   369 	};
       
   370 
       
   371 class CContactCard : public CContactItemPlusGroup
       
   372 /** A contact card.
       
   373 
       
   374 Implements the Type() function declared in class CContactItem.
       
   375 Contact cards may optionally be constructed from a template.
       
   376 @publishedAll
       
   377 @released
       
   378 */
       
   379 	{
       
   380 public:
       
   381 	IMPORT_C ~CContactCard();
       
   382 	IMPORT_C static CContactCard* NewL();
       
   383 	IMPORT_C static CContactCard* NewLC();
       
   384 	IMPORT_C static CContactCard* NewL(const CContactItem *aTemplate);
       
   385 	IMPORT_C static CContactCard* NewLC(const CContactItem *aTemplate);
       
   386 public: // from CContactItem
       
   387 	IMPORT_C TUid Type() const;
       
   388 public:
       
   389 	IMPORT_C CContactIdArray* GroupsJoinedLC() const;
       
   390 private:
       
   391 	CContactCard();
       
   392 private:
       
   393 	friend class CContactDatabase;
       
   394 	};
       
   395 
       
   396 class CContactOwnCard : public CContactItemPlusGroup
       
   397 /** Own card.
       
   398 
       
   399 An own card is a contact card which contains information about the device's
       
   400 owner. This can be sent to another compatible electronic device as a vCard.
       
   401 The contact database recognises a single own card, referred to as the
       
   402 current own card; its ID is returned by CContactDatabase::OwnCardId(). Like
       
   403 a contact card, an own card can be a member of one or more contact card groups.
       
   404 The own card type is identified by a UID of KUidContactOwnCard.
       
   405 
       
   406 Own cards can be constructed using either CContactDatabase::CreateOwnCardLC()
       
   407 or CreateOwnCardL(). These functions create an own card, based on the system
       
   408 template, add it to the database, set it as the database's current own card
       
   409 and return a pointer to it. To change the database's current own card, use
       
   410 CContactDatabase::SetOwnCardL().
       
   411 @publishedAll
       
   412 @released
       
   413 */
       
   414 	{
       
   415 public:
       
   416 	IMPORT_C ~CContactOwnCard();
       
   417 	IMPORT_C static CContactOwnCard* NewL();
       
   418 	IMPORT_C static CContactOwnCard* NewLC();
       
   419 	IMPORT_C static CContactOwnCard* NewL(const CContactItem *aTemplate);
       
   420 	IMPORT_C static CContactOwnCard* NewLC(const CContactItem *aTemplate);
       
   421 public: // from CContactItem
       
   422 	IMPORT_C TUid Type() const;
       
   423 public:
       
   424 	IMPORT_C CContactIdArray* GroupsJoinedLC() const;
       
   425 private:
       
   426 	CContactOwnCard();
       
   427 private:
       
   428 	friend class CContactDatabase;
       
   429 	};
       
   430 
       
   431 class CContactTemplate : public CContactItem
       
   432 /** A contact item template.
       
   433 
       
   434 This is a contact item which is used to seed the initial field set for
       
   435 other contact items.
       
   436 
       
   437 Non-system (i.e. user-defined) templates are implemented
       
   438 by the CContactCardTemplate class. CContactCardTemplate should be
       
   439 used in preference to CContactTemplate.
       
   440 @publishedAll
       
   441 @released
       
   442 */
       
   443 	{
       
   444 public:
       
   445 	IMPORT_C static CContactTemplate* NewL();
       
   446 	IMPORT_C static CContactTemplate* NewLC();
       
   447 	IMPORT_C static CContactTemplate* NewL(const CContactItem *aTemplate);
       
   448 	IMPORT_C static CContactTemplate* NewLC(const CContactItem *aTemplate);
       
   449 public: // from CContactItem
       
   450 	IMPORT_C TUid Type() const;
       
   451 private:
       
   452 	CContactTemplate();
       
   453 	};
       
   454 
       
   455 
       
   456 class CContactICCEntry : public CContactItemPlusGroup
       
   457 /** A contact ICC entry.
       
   458 @publishedAll
       
   459 @released
       
   460 */
       
   461 	{
       
   462 public:
       
   463 	IMPORT_C ~CContactICCEntry();
       
   464 	IMPORT_C static CContactICCEntry* NewL(const CContactItem& aTemplate);
       
   465 	static CContactICCEntry* NewL();
       
   466 public: //from CContactItem
       
   467 	TUid Type() const;
       
   468 private:
       
   469 	CContactICCEntry();
       
   470 	};
       
   471 
       
   472 
       
   473 class ContactGuid
       
   474 /** A globally unique identifier enquiry utility.
       
   475 
       
   476 Each contact item has a unique identifier, stored as a descriptor. It is
       
   477 referred to as the 'UID string'. This is a combination of the unique
       
   478 identifier of the database in which the contact item was created, the
       
   479 contact item ID and the date/time of the contact item's creation. ContactGuid
       
   480 provides a single static exported function to enquire whether an item was
       
   481 created in a specified database.
       
   482 @publishedAll
       
   483 @released
       
   484 */
       
   485 	{
       
   486 public:
       
   487 	IMPORT_C static TContactItemId IsLocalContactUidString(const TDesC& aString, TInt64 aMachineUniqueId);
       
   488 	IMPORT_C static TBool GetCreationDate(TDes& aString, TInt64 aMachineUniqueId);
       
   489 	static HBufC* CreateGuidLC(const TDesC& aCreationDate,TContactItemId aId, TInt64 aMachineUniqueId);
       
   490 	static HBufC* CreateGuidLC(const TTime& aCreationDate,TContactItemId aId, TInt64 aMachineUniqueId);
       
   491 	static HBufC* CreateGuidLC(TContactItemId aId, TInt64 aMachineUniqueId);
       
   492 	};
       
   493 
       
   494 inline const CContactItemField& CContactItemFieldSet::operator[](TInt aIndex) const
       
   495 /** Gets the field located at a specified position in the field set.
       
   496 
       
   497 @param aIndex The position of the field in the field set. This is relative to zero.
       
   498 It must be non-negative and less than the number of objects in the array, otherwise
       
   499 the operator raises a panic.
       
   500 
       
   501 @return A const reference to an element in the array. */
       
   502 	{ return *(*iFields)[aIndex]; }
       
   503 
       
   504 inline CContactItemField& CContactItemFieldSet::operator[](TInt aIndex)
       
   505 /** Gets the field located at a specified position in the field set.
       
   506 
       
   507 @param aIndex The position of the field in the field set. This is relative to zero.
       
   508 It must be non-negative and less than the number of objects in the array, otherwise
       
   509 the operator raises a panic.
       
   510 
       
   511 @return A non-const reference to an element in the array. */
       
   512 	{ return *(*iFields)[aIndex]; }
       
   513 
       
   514 inline TInt CContactItemFieldSet::Find(TFieldType aFieldType) const
       
   515 /** Finds the first field in the field set with the specified field type.
       
   516 
       
   517 @param aFieldType The field type of interest.
       
   518 @return If found, the index of the field within the field set, or KErrNotFound
       
   519 if not found. */
       
   520 	{ return FindNext(aFieldType,KContactFieldSetSearchAll); }
       
   521 
       
   522 inline TInt CContactItemFieldSet::Find(TFieldType aFieldType,TUid aMapping) const
       
   523 /** Finds the first field in the field set containing both the content type mapping
       
   524 and the field type specified.
       
   525 
       
   526 @param aFieldType The field type of interest.
       
   527 @param aMapping The content type mapping of interest.
       
   528 @return If found, the index of the field within the field set, or KErrNotFound
       
   529 if not found. */
       
   530 	{ return FindNext(aFieldType,aMapping,KContactFieldSetSearchAll); }
       
   531 
       
   532 inline TInt CContactItemFieldSet::Count() const
       
   533 /** Gets the number of fields in the field set.
       
   534 
       
   535 @return The number of fields in the field set. */
       
   536 	{ return iFields->Count(); }
       
   537 
       
   538 inline void CContactItemFieldSet::Reset()
       
   539 /** Deletes all fields in the field set. */
       
   540 	{ iFields->ResetAndDestroy(); }
       
   541 
       
   542 inline TBool CContactItem::IsDeletable()
       
   543 /** Tests whether the contact item is deletable.
       
   544 
       
   545 This is true if the item's access count is zero.
       
   546 
       
   547 @return ETrue if deletable, EFalse if not deletable. */
       
   548 	{return (iAccessCount == 0);}
       
   549 
       
   550 inline void CContactItem::IncAccessCount()
       
   551 /** Increments the contact item's access count. */
       
   552 	{iAccessCount++;}
       
   553 
       
   554 inline void CContactItem::DecAccessCount()
       
   555 /** Decrements the contact item's access count. */
       
   556 	{if(iAccessCount) iAccessCount--;}
       
   557 
       
   558 inline TInt CContactItem::AccessCount() const
       
   559 /** Gets the contact item's access count.
       
   560 
       
   561 @return The item's access count. */
       
   562 	{return(iAccessCount);}
       
   563 
       
   564 inline TPtrC CContactItem::Guid()
       
   565 /** Accessor function for Contact Guid.
       
   566  * This is used to cache contact items that are added during a sync.
       
   567  @return Guid    */
       
   568  { return iGuid ? *iGuid : TPtrC(KNullDesC); }
       
   569 
       
   570 #endif