|
1 // Copyright (c) 2005-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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent |
|
19 @released |
|
20 */ |
|
21 |
|
22 |
|
23 #include "IteratorProxy.h" |
|
24 #include "rcntmodel.h" |
|
25 #include <ecom/ecom.h> |
|
26 #include <cntsync.h> |
|
27 #include "cntviewprivate.h" |
|
28 |
|
29 |
|
30 // The name of the test phone book sync plugin. This plugin will be used in the |
|
31 // first instance (i.e. if it exists then use it rather than any other plugin). |
|
32 _LIT(KTestPluginName,"Test phone book synchronizer Implementation"); |
|
33 |
|
34 |
|
35 /** |
|
36 CContactSynchroniser object factory method. |
|
37 |
|
38 This class is copied from the Persistence Layer. It should be refactored into |
|
39 a shared library if possible. |
|
40 |
|
41 @return CContactSynchroniser object. |
|
42 */ |
|
43 CContactSynchroniser* CContactSynchroniser::NewL() |
|
44 { |
|
45 RImplInfoPtrArray implInfoArray; |
|
46 CleanupResetAndDestroyPushL(implInfoArray); |
|
47 REComSession::ListImplementationsL(KUidEcomCntPhBkSyncInterface, implInfoArray); |
|
48 |
|
49 const TInt count = implInfoArray.Count(); |
|
50 __ASSERT_ALWAYS(count > 0, User::Leave(KErrNotSupported)); |
|
51 |
|
52 TInt pluginToBeUsed = 0; |
|
53 CImplementationInformation *info; |
|
54 |
|
55 // Scan the list of plugins for the test plugin. |
|
56 for (TInt plugIn = 0 ; plugIn < count ; ++plugIn) |
|
57 { |
|
58 info = implInfoArray[plugIn]; |
|
59 if(info->DisplayName() == KTestPluginName) |
|
60 { |
|
61 // We have found the test plugin so use it rather than any other |
|
62 // plugin. |
|
63 pluginToBeUsed = plugIn; |
|
64 break; |
|
65 } |
|
66 } |
|
67 |
|
68 // Create the implementation found for KUidEcomCntPhBkSyncInterface. |
|
69 const TUid theImplementationID = implInfoArray[pluginToBeUsed]->ImplementationUid(); |
|
70 TAny* ptr = REComSession::CreateImplementationL(theImplementationID, |
|
71 _FOFF(CContactSynchroniser,iDtor_ID_Key)); |
|
72 |
|
73 #ifdef __VERBOSE_DEBUG__ |
|
74 RDebug::Print(_L("[CNTMODEL] CContactSynchroniser::NewL(): Create sync plugin: %S\n"), &info->DisplayName()); |
|
75 #endif |
|
76 |
|
77 CleanupStack::PopAndDestroy(&implInfoArray); |
|
78 |
|
79 return reinterpret_cast<CContactSynchroniser*>(ptr); |
|
80 } |
|
81 |
|
82 |
|
83 /** |
|
84 CProxyFactory object factory method. |
|
85 |
|
86 @param aDb Contacts database used by the proxies this factory provides. |
|
87 |
|
88 @return CProxyFactory object. |
|
89 */ |
|
90 CProxyFactory* CProxyFactory::NewL(const CContactDatabase& aDb) |
|
91 { |
|
92 CProxyFactory* self = new (ELeave) CProxyFactory(aDb); |
|
93 CleanupStack::PushL(self); |
|
94 self->ConstructL(); |
|
95 CleanupStack::Pop(self); |
|
96 return self; |
|
97 } |
|
98 |
|
99 |
|
100 /** |
|
101 CProxyFactory second phase constructor. |
|
102 */ |
|
103 void CProxyFactory::ConstructL() |
|
104 { |
|
105 } |
|
106 |
|
107 |
|
108 /** |
|
109 CProxyFactory first phase constructor. |
|
110 |
|
111 @param aDb Contacts database used to access Contacts Model session handle. |
|
112 */ |
|
113 CProxyFactory::CProxyFactory(const CContactDatabase& aDb) |
|
114 : |
|
115 iDb(aDb) |
|
116 { |
|
117 } |
|
118 |
|
119 |
|
120 /** |
|
121 CProxyFactory destructor. |
|
122 */ |
|
123 CProxyFactory::~CProxyFactory() |
|
124 { |
|
125 if (iSynchroniser) |
|
126 { |
|
127 iSynchroniser->Release(); |
|
128 iSynchroniser = NULL; |
|
129 } |
|
130 delete iManager; |
|
131 delete iCollection; |
|
132 } |
|
133 |
|
134 |
|
135 /** |
|
136 Get the MLplViewIteratorManager proxy interface. If the |
|
137 CViewIteratorProxyManager proxy object does not yet exist then create it (lazy |
|
138 initialisation). |
|
139 |
|
140 @return MLplViewIteratorManager proxy interface instance. |
|
141 */ |
|
142 MLplViewIteratorManager& CProxyFactory::GetViewIteratorManagerL() |
|
143 { |
|
144 if(iManager == NULL) |
|
145 { |
|
146 iManager = CViewIteratorProxyManager::NewL(iDb); |
|
147 } |
|
148 return *iManager; |
|
149 } |
|
150 |
|
151 |
|
152 /** |
|
153 Get the MContactSynchroniser interface. If the CContactSynchroniser object does |
|
154 not yet exist then create it (lazy initialisation). |
|
155 |
|
156 @return MContactSynchroniser interface instance. |
|
157 */ |
|
158 MContactSynchroniser& CProxyFactory::GetContactSynchroniserL(TUint) |
|
159 { |
|
160 if(iSynchroniser == NULL) |
|
161 { |
|
162 iSynchroniser = CContactSynchroniser::NewL(); |
|
163 } |
|
164 return *iSynchroniser; |
|
165 } |
|
166 |
|
167 |
|
168 /** |
|
169 Get the MLplCollection proxy interface. If the CCollectionProxy proxy object |
|
170 does not yet exist then create it (lazy initialisation). |
|
171 |
|
172 @return MLplCollection proxy interface instance. |
|
173 */ |
|
174 MLplCollection& CProxyFactory::GetCollectorL() |
|
175 { |
|
176 if(iCollection == NULL) |
|
177 { |
|
178 iCollection = new (ELeave) CCollectionProxy(iDb); |
|
179 } |
|
180 return *iCollection; |
|
181 } |
|
182 |
|
183 |
|
184 /** |
|
185 CViewIteratorProxyManager object factory method. |
|
186 |
|
187 @param aDb Contacts database used to access Contacts Model session handle. |
|
188 |
|
189 @return CViewIteratorProxyManager object. |
|
190 */ |
|
191 CViewIteratorProxyManager* CViewIteratorProxyManager::NewL(const CContactDatabase& aDb) |
|
192 { |
|
193 CViewIteratorProxyManager* self = new (ELeave) CViewIteratorProxyManager(aDb); |
|
194 CleanupStack::PushL(self); |
|
195 self->ConstructL(); |
|
196 CleanupStack::Pop(self); |
|
197 return self; |
|
198 } |
|
199 |
|
200 |
|
201 /** |
|
202 CViewIteratorProxyManager second phase constructor. |
|
203 */ |
|
204 void CViewIteratorProxyManager::ConstructL() |
|
205 { |
|
206 } |
|
207 |
|
208 |
|
209 /** |
|
210 CViewIteratorProxyManager first phase constructor. |
|
211 |
|
212 @param aDb Contacts database used to access Contacts Model session handle. |
|
213 */ |
|
214 CViewIteratorProxyManager::CViewIteratorProxyManager(const CContactDatabase& aDb) |
|
215 : |
|
216 iDb(aDb) |
|
217 { |
|
218 } |
|
219 |
|
220 |
|
221 /** |
|
222 CViewIteratorProxyManager destructor. |
|
223 */ |
|
224 CViewIteratorProxyManager::~CViewIteratorProxyManager() |
|
225 { |
|
226 } |
|
227 |
|
228 |
|
229 /** |
|
230 Proxy implementation of pure virtual method in MLplViewIteratorManager. |
|
231 |
|
232 The proxy does not access the Persistence Layer directly. Instead it uses the |
|
233 Contacts Model session handle to access the Persistence Layer via the server. |
|
234 */ |
|
235 CViewContact* CViewIteratorProxyManager::ItemAtL(const TItemAtLParams& aParams, const CContactTextDef& aTextDef, TUint /*aSessionId*/) |
|
236 { |
|
237 return iDb.iCntSvr->ItemAtL(aParams,aTextDef); |
|
238 } |
|
239 |
|
240 |
|
241 /** |
|
242 Proxy implementation of pure virtual method in MLplViewIteratorManager. |
|
243 |
|
244 The proxy does not access the Persistence Layer directly. Instead it uses the |
|
245 Contacts Model session handle to access the Persistence Layer via the server. |
|
246 */ |
|
247 void CViewIteratorProxyManager::ReadContactTextDefL(TContactItemId aContactId, TDes &aResult,const CContactTextDef& aTextDef, TUint /*aSessionId*/) |
|
248 { |
|
249 iDb.iCntSvr->ReadContactTextDefL(aContactId,aResult,aTextDef); |
|
250 } |
|
251 |
|
252 |
|
253 /** |
|
254 Proxy implementation of pure virtual method in MLplViewIteratorManager. |
|
255 |
|
256 The proxy does not access the Persistence Layer directly. Instead it uses the |
|
257 Contacts Model session handle to access the Persistence Layer via the server. |
|
258 */ |
|
259 TBool CViewIteratorProxyManager::SeekContactL(TContactItemId aReqId,TContactItemId& aId,TUid& aContactType,TBool& aDeleted) |
|
260 { |
|
261 return iDb.iCntSvr->SeekContactL(aReqId,aId,aContactType,aDeleted); |
|
262 } |
|
263 |
|
264 |
|
265 /** |
|
266 Proxy implementation of pure virtual method in MLplViewIteratorManager. |
|
267 |
|
268 The proxy does not access the Persistence Layer directly. Instead it uses the |
|
269 Contacts Model session handle to access the Persistence Layer via the server. |
|
270 */ |
|
271 TBool CViewIteratorProxyManager::SeekIdentContactL(TContactItemId aId) |
|
272 { |
|
273 return iDb.iCntSvr->SeekIdentContactL(aId); |
|
274 } |
|
275 |
|
276 |
|
277 /** |
|
278 Proxy implementation of pure virtual method in MLplViewIteratorManager. |
|
279 |
|
280 The proxy does not access the Persistence Layer directly. Instead it uses the |
|
281 Contacts Model session handle to access the Persistence Layer via the server. |
|
282 */ |
|
283 void CViewIteratorProxyManager::TextFieldL(TInt aCntItemId,TFieldType aFieldType, TDes& aText) |
|
284 { |
|
285 iDb.iCntSvr->TextFieldL(aCntItemId,aFieldType,aText); |
|
286 } |
|
287 |
|
288 |
|
289 /** |
|
290 CCollectionProxy first phase constructor. |
|
291 |
|
292 @param aDb Contacts database used to access Contacts Model session handle. |
|
293 */ |
|
294 CCollectionProxy::CCollectionProxy(const CContactDatabase& aDb) |
|
295 : |
|
296 iDb(aDb) |
|
297 { |
|
298 } |
|
299 |
|
300 |
|
301 /** |
|
302 Proxy implementation of pure virtual method in MLplCollection. |
|
303 |
|
304 The proxy does not access the Persistence Layer directly. Instead it uses the |
|
305 Contacts Model session handle to access the Persistence Layer via the server. |
|
306 */ |
|
307 CContactIdArray* CCollectionProxy::CollectionL(TLplViewType aViewType,TTime aTime,const TDesC& aGuid) |
|
308 { |
|
309 return iDb.iCntSvr->CollectionL(aViewType,aTime,aGuid); |
|
310 } |
|
311 |
|
312 |
|
313 /** |
|
314 Proxy implementation of pure virtual method in MLplCollection. |
|
315 |
|
316 The proxy does not access the Persistence Layer directly. Instead it uses the |
|
317 Contacts Model session handle to access the Persistence Layer via the server. |
|
318 */ |
|
319 TInt CCollectionProxy::ContactCountL() |
|
320 { |
|
321 return iDb.iCntSvr->ContactCountL(); |
|
322 } |
|
323 |
|
324 |
|
325 /** |
|
326 Dummy method - implemented in the Persistence Layer. |
|
327 */ |
|
328 TBool CCollectionProxy::ContactMatchesHintFieldL (TInt /*aBitWiseFilter*/, TContactItemId /*aContactId*/) |
|
329 { |
|
330 return EFalse; |
|
331 } |
|
332 |
|
333 |
|
334 /** |
|
335 Dummy method - implemented in the Persistence Layer. |
|
336 */ |
|
337 CContactIdArray* CCollectionProxy::MatchPhoneNumberL(const TDesC& /*aNumber*/, const TInt /*aMatchLengthFromRight*/) |
|
338 { |
|
339 return NULL; |
|
340 } |
|
341 |
|
342 |
|
343 /** |
|
344 Proxy implementation of pure virtual method in MLplCollection. |
|
345 |
|
346 The proxy does not access the Persistence Layer directly. Instead it uses the |
|
347 Contacts Model session handle to access the Persistence Layer via the server. |
|
348 |
|
349 This method could be a dummy implementation since only CContactDatabase calls |
|
350 the client session FindL() method. |
|
351 */ |
|
352 CContactIdArray* CCollectionProxy::FindL(const TDesC& aText, const CContactItemFieldDef* aFieldDef, TUint /*aSessionId*/) |
|
353 { |
|
354 return iDb.iCntSvr->FindL(aText,aFieldDef); |
|
355 } |
|
356 |
|
357 |
|
358 /** |
|
359 Dummy method - implemented in the Persistence Layer. |
|
360 */ |
|
361 CContactIdArray* CCollectionProxy::FilterDatabaseL(CCntFilter& /*aFilter*/) |
|
362 { |
|
363 return NULL; |
|
364 } |
|
365 |
|
366 |
|
367 /** |
|
368 Dummy method - implemented in the Persistence Layer. |
|
369 */ |
|
370 void CCollectionProxy::Reset() |
|
371 { |
|
372 } |
|
373 |
|
374 |
|
375 /** |
|
376 Dummy method - implemented in the Persistence Layer. |
|
377 */ |
|
378 void CCollectionProxy::FindAsyncInitL(const TDesC& /*aText*/,CContactItemFieldDef* /*aFieldDef*/) |
|
379 { |
|
380 } |
|
381 |
|
382 |
|
383 /** |
|
384 Dummy method - implemented in the Persistence Layer. |
|
385 */ |
|
386 void CCollectionProxy::FindAsyncTextDefInitL(const CDesCArray& /*aWords*/,CContactTextDef* /*aTextDef*/) |
|
387 { |
|
388 } |
|
389 |
|
390 |
|
391 /** |
|
392 Dummy method - implemented in the Persistence Layer. |
|
393 */ |
|
394 CContactIdArray* CCollectionProxy::FindAsyncL(TBool& /*aMoreToGo*/, TUint /*aSessionId*/) |
|
395 { |
|
396 return NULL; |
|
397 } |
|
398 |
|
399 |
|
400 /** |
|
401 Dummy method - implemented in the Persistence Layer. |
|
402 */ |
|
403 TBool CCollectionProxy::UsesIdentityTableOnly(TInt /*aFindFlags*/) |
|
404 { |
|
405 return EFalse; |
|
406 } |
|
407 |
|
408 |
|
409 /** |
|
410 Dummy method - implemented in the Persistence Layer. |
|
411 */ |
|
412 void CCollectionProxy::ConstructBitwiseFlagsFromTextDef(TInt& /*aFindFlags*/, TInt& /*aIdentityColumnsCount*/, const CContactTextDef* /*aTextDef*/) |
|
413 { |
|
414 } |