|
1 /* |
|
2 * Copyright (c) 2005-2006 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: CContact implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "contact.h" |
|
21 #include "ldapcontact.h" |
|
22 #include "contactlink.h" |
|
23 #include "contactstore.h" |
|
24 #include "storebookmark.h" |
|
25 // Meaning full errors for ldap has not yet been defined, published |
|
26 // #include <vpbkerror.h> // Virtual phonebook errors |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // LDAP Store namespace |
|
30 // ----------------------------------------------------------------------------- |
|
31 namespace LDAPStore { |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CContact::CContact |
|
35 // C++ default constructor can NOT contain any code, that might leave. |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CContact::CContact(CContactStore& aStore,TBool aOwns) |
|
39 : iOwnsContact(aOwns), iStore(aStore) |
|
40 { |
|
41 // No implementation required |
|
42 } |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CContact::ConstructL |
|
45 // CContactStore constructor for performing 2nd stage construction |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 void CContact::ConstructL(CLDAPContact* aContact) |
|
49 { |
|
50 iFields.SetContact(*this,*aContact); |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CContact::NewLC |
|
55 // CContact two-phased constructor. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CContact* CContact::NewLC(CContactStore& aStore,CLDAPContact* aContact,TBool aOwns) |
|
59 { |
|
60 CContact* self = new (ELeave) CContact(aStore,aOwns); |
|
61 CleanupStack::PushL(self); |
|
62 self->ConstructL(aContact); |
|
63 self->iContact = aContact; |
|
64 return self; |
|
65 } |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CContact::NewL |
|
68 // CContact two-phased constructor. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CContact* CContact::NewL(CContactStore& aStore,CLDAPContact* aContact,TBool aOwns) |
|
72 { |
|
73 CContact* self = CContact::NewLC(aStore,aContact,aOwns); |
|
74 CleanupStack::Pop(self); |
|
75 return self; |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CContact::~CContact |
|
80 // CContact Destructor |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CContact::~CContact() |
|
84 { |
|
85 // LDAP Contact |
|
86 if (iContact && iOwnsContact) |
|
87 { |
|
88 delete iContact; |
|
89 iContact = NULL; |
|
90 } |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CContact public methods |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CContact::Index |
|
97 // Returns contact index. |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 TInt CContact::Index() const |
|
101 { |
|
102 return iIndex; |
|
103 } |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CContact::SetIndex |
|
106 // Sets contact index. |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 void CContact::SetIndex(TInt aIndex) |
|
110 { |
|
111 iIndex = aIndex; |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CContact::Store |
|
116 // Returns the store of this contact. |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 CContactStore& CContact::Store() const |
|
120 { |
|
121 return iStore; |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CContact::LDAPContact |
|
126 // Returns the contact inside this contact. |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 CLDAPContact& CContact::LDAPContact() const |
|
130 { |
|
131 return *iContact; |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CContact::Contact |
|
136 // Returns the contact inside this contact. |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 CLDAPContact* CContact::Contact() const |
|
140 { |
|
141 return iContact; |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // MVPbkObjectHierarchy implementation |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CContact::ParentObject |
|
148 // Returns parent of this contact - store |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 MVPbkObjectHierarchy& CContact::ParentObject() const |
|
152 { |
|
153 return iStore; |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // MVPbkBaseContact implementation |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CContact::Fields |
|
160 // Returns this contact's fields (read only). |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 const MVPbkStoreContactFieldCollection& CContact::Fields() const |
|
164 { |
|
165 return iFields; |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // CContact::IsSame |
|
170 // Returns true if this is same contact. |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 TBool CContact::IsSame(const MVPbkStoreContact& aOtherContact) const |
|
174 { |
|
175 // From same store |
|
176 if (&ParentStore() == &aOtherContact.ParentStore()) |
|
177 { |
|
178 // Cast to contact |
|
179 const CContact& other = static_cast<const CContact&>(aOtherContact); |
|
180 // Same index |
|
181 return (other.Index() == Index()); |
|
182 } |
|
183 return EFalse; |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CContact::CreateLinkLC |
|
188 // Creates link representing this contact. |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 MVPbkContactLink* CContact::CreateLinkLC() const |
|
192 { |
|
193 return CContactLink::NewLC(iStore,Index()); |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CContact::DeleteL |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 void CContact::DeleteL(MVPbkContactObserver& /* aObserver */) const |
|
201 { |
|
202 // Cannot delete, contact is from read only store |
|
203 User::Leave(KErrAccessDenied); |
|
204 } |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // CContact::MatchContactStore |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 TBool CContact::MatchContactStore(const TDesC& aContactStoreUri) const |
|
211 { |
|
212 return iStore.MatchContactStore(aContactStoreUri); |
|
213 } |
|
214 |
|
215 // ----------------------------------------------------------------------------- |
|
216 // CContact::MatchContactStoreDomain |
|
217 // ----------------------------------------------------------------------------- |
|
218 // |
|
219 TBool CContact::MatchContactStoreDomain(const TDesC& aContactStoreDomain) const |
|
220 { |
|
221 return iStore.MatchContactStoreDomain(aContactStoreDomain); |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CContact::CreateBookmarkLC |
|
226 // Bookmark this contact. |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 MVPbkContactBookmark* CContact::CreateBookmarkLC() const |
|
230 { |
|
231 return CStoreBookmark::NewLC(iStore,Index()); |
|
232 } |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // MVPbkStoreContact implementation |
|
236 // ----------------------------------------------------------------------------- |
|
237 // CContact::ParentStore |
|
238 // Returns this contact's parent store. |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 MVPbkContactStore& CContact::ParentStore() const |
|
242 { |
|
243 return iStore; |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // CContact::Fields |
|
248 // Returns this contact's fields. |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 MVPbkStoreContactFieldCollection& CContact::Fields() |
|
252 { |
|
253 return iFields; |
|
254 } |
|
255 |
|
256 // ----------------------------------------------------------------------------- |
|
257 // CContact::CreateFieldLC |
|
258 // Create field |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 MVPbkStoreContactField* CContact::CreateFieldLC( |
|
262 const MVPbkFieldType& /* aFieldType */) const |
|
263 { |
|
264 // Cannot create ldap fields like this |
|
265 User::Leave(KErrAccessDenied); |
|
266 return NULL; |
|
267 } |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // CContact::AddFieldL |
|
271 // Add field |
|
272 // ----------------------------------------------------------------------------- |
|
273 // |
|
274 TInt CContact::AddFieldL(MVPbkStoreContactField* /* aField */) |
|
275 { |
|
276 // Cannot add fields |
|
277 User::Leave(KErrAccessDenied); |
|
278 return KErrAccessDenied; |
|
279 } |
|
280 |
|
281 // ----------------------------------------------------------------------------- |
|
282 // CContact::RemoveField |
|
283 // Remove field |
|
284 // ----------------------------------------------------------------------------- |
|
285 // |
|
286 void CContact::RemoveField(TInt /* aIndex */) |
|
287 { |
|
288 // Cannot remove - this is not yet defined, should be coming |
|
289 // VPbkError::Panic(VPbkError::EInvalidAccessToReadOnlyContact); |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // CContact::RemoveAllFields |
|
294 // Remove all field |
|
295 // ----------------------------------------------------------------------------- |
|
296 // |
|
297 void CContact::RemoveAllFields() |
|
298 { |
|
299 // Cannot remove - this is not yet defined, should be coming |
|
300 // VPbkError::Panic(VPbkError::EInvalidAccessToReadOnlyContact); |
|
301 } |
|
302 |
|
303 // ----------------------------------------------------------------------------- |
|
304 // CContact::LockL |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 void CContact::LockL(MVPbkContactObserver& /* aObserver */) const |
|
308 { |
|
309 // Read only |
|
310 User::Leave(KErrAccessDenied); |
|
311 } |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // CContact::CommitL |
|
315 // ----------------------------------------------------------------------------- |
|
316 // |
|
317 void CContact::CommitL(MVPbkContactObserver& /* aObserver */) const |
|
318 { |
|
319 // Read only |
|
320 User::Leave(KErrAccessDenied); |
|
321 } |
|
322 |
|
323 // ----------------------------------------------------------------------------- |
|
324 // CContact::GroupsJoinedLC |
|
325 // ----------------------------------------------------------------------------- |
|
326 // |
|
327 MVPbkContactLinkArray* CContact::GroupsJoinedLC() const |
|
328 { |
|
329 // No groups |
|
330 return NULL; |
|
331 } |
|
332 |
|
333 // ----------------------------------------------------------------------------- |
|
334 // CContact::Group |
|
335 // ----------------------------------------------------------------------------- |
|
336 // |
|
337 MVPbkContactGroup* CContact::Group() |
|
338 { |
|
339 // No groups |
|
340 return NULL; |
|
341 } |
|
342 |
|
343 // ----------------------------------------------------------------------------- |
|
344 // CContact::MaxNumberOfFieldL |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 TInt CContact::MaxNumberOfFieldL(const MVPbkFieldType& /* aType */) const |
|
348 { |
|
349 return KVPbkStoreContactUnlimitedNumber; |
|
350 } |
|
351 |
|
352 } // End of namespace LDAPStore |
|
353 // ----------------------------------------------------------------------------- |
|
354 // End of File |
|
355 // ----------------------------------------------------------------------------- |