|
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: The virtual phonebook contact |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef VPBKCNTMODEL_CCONTACT_H |
|
21 #define VPBKCNTMODEL_CCONTACT_H |
|
22 |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include <MVPbkContactGroup.h> |
|
27 #include <cntdef.h> |
|
28 #include "TContactFieldCollection.h" |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CContactItem; |
|
32 class CContactIdArray; |
|
33 |
|
34 namespace VPbkCntModel { |
|
35 |
|
36 // FORWARD DECLARATIONS |
|
37 class CContactStore; |
|
38 class CFieldTypeMap; |
|
39 |
|
40 // CLASS DECLARATIONS |
|
41 |
|
42 /** |
|
43 * Maps a Contact Model CContactItem to a virtual Phonebook contact. |
|
44 */ |
|
45 NONSHARABLE_CLASS( CContact ): public CBase, |
|
46 public MVPbkContactGroup, |
|
47 public MVPbkBaseContact2 |
|
48 { |
|
49 public: // Constructor and destructor |
|
50 /** |
|
51 * Creates a new instance of this class. |
|
52 * |
|
53 * @param aParentStore the store where this contact is from. |
|
54 * @param aContactItem the Contact Model contact to map. This object |
|
55 * takes ownership of the passed object. Ownership |
|
56 * is not taken if this function leaves. |
|
57 * @param aIsNewContact is this a new contact |
|
58 * |
|
59 * @return a new instance of this class |
|
60 */ |
|
61 static CContact* NewL( |
|
62 CContactStore& aParentStore, |
|
63 CContactItem* aContactItem, |
|
64 TBool aIsNewContact = EFalse ); |
|
65 |
|
66 ~CContact(); |
|
67 |
|
68 public: // New functions |
|
69 /** |
|
70 * Returns the parent store of this contact. |
|
71 */ |
|
72 CContactStore& Store() const; |
|
73 |
|
74 /** |
|
75 * Returns the Contact Model contact. |
|
76 */ |
|
77 CContactItem* NativeContact() const; |
|
78 |
|
79 /** |
|
80 * Sets a new Contact Model contact. |
|
81 * |
|
82 * @param aContactItem the Contact Model contact to map. This object |
|
83 * takes ownership of the passed object. |
|
84 */ |
|
85 void SetContact( CContactItem* aContactItem ); |
|
86 |
|
87 /** |
|
88 * Returns the field type map to use for mapping Contact Model field |
|
89 * types to Virtual Phonebook field types. |
|
90 */ |
|
91 const CFieldTypeMap& FieldTypeMap() const; |
|
92 |
|
93 /** |
|
94 * Returns ETrue if this contact is a new contact. |
|
95 */ |
|
96 TBool IsNewContact() const; |
|
97 |
|
98 /** |
|
99 * Set modifed flag. |
|
100 */ |
|
101 void SetModified(); |
|
102 |
|
103 public: // from MVPbkObjectHierarchy |
|
104 MVPbkObjectHierarchy& ParentObject() const; |
|
105 |
|
106 public: // from MVPbkBaseContact |
|
107 TAny* BaseContactExtension( TUid aExtensionUid ); |
|
108 |
|
109 public: // from MVPbkBaseContact2 |
|
110 TBool IsOwnContact( TInt& aError ) const; |
|
111 |
|
112 public: // from MVPbkStoreContact |
|
113 const MVPbkStoreContactFieldCollection& Fields() const; |
|
114 TBool IsSame( const MVPbkStoreContact& aOtherContact ) const; |
|
115 TBool IsSame( const MVPbkViewContact& aOtherContact ) const; |
|
116 MVPbkContactLink* CreateLinkLC() const; |
|
117 void DeleteL( MVPbkContactObserver& aObserver ) const; |
|
118 TBool MatchContactStore( const TDesC& aContactStoreUri ) const; |
|
119 TBool MatchContactStoreDomain( const TDesC& aContactStoreDomain ) const; |
|
120 MVPbkContactBookmark* CreateBookmarkLC() const; |
|
121 |
|
122 MVPbkContactStore& ParentStore() const; |
|
123 MVPbkStoreContactFieldCollection& Fields(); |
|
124 MVPbkStoreContactField* CreateFieldLC( const MVPbkFieldType& aFieldType ) const; |
|
125 TInt AddFieldL( MVPbkStoreContactField* aField ); |
|
126 void RemoveField( TInt aIndex ); |
|
127 void RemoveAllFields(); |
|
128 void LockL( MVPbkContactObserver& aObserver ) const; |
|
129 void CommitL( MVPbkContactObserver& aObserver ) const; |
|
130 MVPbkContactLinkArray* GroupsJoinedLC() const; |
|
131 MVPbkContactGroup* Group(); |
|
132 TInt MaxNumberOfFieldL( const MVPbkFieldType& aType ) const; |
|
133 TAny* StoreContactExtension(TUid aExtensionUid) ; |
|
134 |
|
135 public: // from MVPbkStoreContact2 |
|
136 MVPbkStoreContactProperties* PropertiesL() const; |
|
137 void SetAsOwnL(MVPbkContactObserver& aObserver) const; |
|
138 |
|
139 public: // from MVPbkContactGroup |
|
140 void SetGroupLabelL( const TDesC& aLabel ); |
|
141 TPtrC GroupLabel() const; |
|
142 void AddContactL( const MVPbkContactLink& aContactLink ); |
|
143 void RemoveContactL( const MVPbkContactLink& aContactLink ); |
|
144 MVPbkContactLinkArray* ItemsContainedLC() const; |
|
145 |
|
146 private: // Implementation |
|
147 CContact( CContactStore& aParentStore, CContactItem& aContactItem, |
|
148 TBool aIsNewContact ); |
|
149 void ConstructL(); |
|
150 void UpdateTimeStampOfContactInGroupL( const MVPbkContactLink& aContactLink ); |
|
151 |
|
152 public: |
|
153 void UpdateTimeStampOfAllContactsInGroupL(); |
|
154 |
|
155 private: // Data |
|
156 /// Own: Is this new contact |
|
157 TBool iIsNewContact; |
|
158 /// Own:The Contact Model contact to map |
|
159 CContactItem* iContactItem; |
|
160 /// Own: Contact fields |
|
161 TContactFieldCollection iFields; |
|
162 /// Not Own: The store where this contact is from. |
|
163 CContactStore& iParentStore; |
|
164 /// Own: If this CContact is group, this contains all added contacts |
|
165 // to this group after this group is read from DB |
|
166 CContactIdArray* iAddedContacts; |
|
167 TBool iModified; |
|
168 |
|
169 TContactItemId iLastUpdatedGroupContactId; |
|
170 }; |
|
171 |
|
172 |
|
173 // INLINE FUNCTIONS |
|
174 |
|
175 inline CContactStore& CContact::Store() const |
|
176 { |
|
177 return iParentStore; |
|
178 } |
|
179 |
|
180 inline CContactItem* CContact::NativeContact() const |
|
181 { |
|
182 return iContactItem; |
|
183 } |
|
184 |
|
185 inline TBool CContact::IsNewContact() const |
|
186 { |
|
187 return iIsNewContact; |
|
188 } |
|
189 |
|
190 inline void CContact::SetModified() |
|
191 { |
|
192 iModified = ETrue; |
|
193 } |
|
194 |
|
195 } // namespace VPbkCntModel |
|
196 |
|
197 #endif // VPBKCNTMODEL_CCONTACT_H |
|
198 //End of file |
|
199 |
|
200 |