|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Factory class's implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CPhoneCntFactoryImpl.h" |
|
22 #include "CPhCntThumbnailLoaderImpl.h" |
|
23 #include "CPhCntRfsHandlerImpl.h" |
|
24 #include "CPhCntMmiSecurityImpl.h" |
|
25 #include "CPhoneCntSaveAddToName.h" |
|
26 #include "CPhoneCntPbkOwner.h" |
|
27 #include "CPhCntMatcherImpl.h" |
|
28 #include "CPhCntProfileEngineImpl.h" |
|
29 |
|
30 #include <CProfileChangeNotifyHandler.h> |
|
31 #include <MProfileChangeObserver.h> |
|
32 |
|
33 #include "CPhCntSingleItemFetchService.h" |
|
34 #include "cphcntspeeddialimpl.h" |
|
35 #include "cphcntvpbkthumbnailloader.h" |
|
36 #include "CPhCntContactStores.h" |
|
37 #include "cphcntvpbkcontactid.h" |
|
38 #include "CPhCntContactManager.h" |
|
39 #include "cphcntphonebookservices.h" |
|
40 #include "cphcntmatchervoipimpl.h" |
|
41 #include "CPhCntMatcherImpl.h" |
|
42 #include "CPhCntAIWService.h" |
|
43 #include "tphcntservicerequestparamfactory.h" |
|
44 #include "cphcntcontactdataselectionimpl.h" |
|
45 #include "cphcntstoreloaderimpl.h" |
|
46 |
|
47 #include <coemain.h> // CONE |
|
48 #include <secui.h> // For TSecUi |
|
49 #include <featmgr.h> // Feature Manager |
|
50 #include <talogger.h> |
|
51 |
|
52 // ============================ MEMBER FUNCTIONS =============================== |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CPhCntFactoryImpl::NewL |
|
56 // Two-phased constructor. |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CPhCntFactoryImpl* CPhCntFactoryImpl::NewL() |
|
60 { |
|
61 CPhCntFactoryImpl* self = new (ELeave) CPhCntFactoryImpl; |
|
62 |
|
63 CleanupStack::PushL( self ); |
|
64 self->ConstructL(); |
|
65 CleanupStack::Pop(); |
|
66 |
|
67 return self; |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // CPhCntFactoryImpl::~CPhCntFactoryImpl |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 CPhCntFactoryImpl::~CPhCntFactoryImpl() |
|
75 { |
|
76 delete iPhonebookServices; |
|
77 delete iContactStores; |
|
78 |
|
79 if ( iSecUiInit ) |
|
80 { |
|
81 TSecUi::UnInitializeLib(); |
|
82 } |
|
83 |
|
84 iPbkResource.Close(); |
|
85 delete iPbkOwner; |
|
86 FeatureManager::UnInitializeLib(); |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CPhCntFactoryImpl::CreateSpeedDialMonitorL |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 CPhCntSpeedDialMonitor* CPhCntFactoryImpl::CreateSpeedDialMonitorL() |
|
94 { |
|
95 CreateContactStoreAndManagerL(); |
|
96 return CPhCntSpeedDialImpl::NewL( *iPbkOwner ); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CPhCntFactoryImpl::CreateThumbnailLoaderL |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 CPhCntThumbnailLoader* CPhCntFactoryImpl::CreateThumbnailLoaderL( |
|
104 MPhCntThumbnailLoaderObserver& aObserver ) |
|
105 { |
|
106 CreateContactStoreAndManagerL(); |
|
107 |
|
108 CPhCntContactStores* contactStores = |
|
109 CPhCntContactStores::NewL( *iPbkOwner->ContactManager() ); |
|
110 CleanupStack::PushL( contactStores ); |
|
111 |
|
112 CPhCntVPbkThumbnailLoader* loader = |
|
113 CPhCntVPbkThumbnailLoader::NewL( *contactStores ); |
|
114 CleanupStack::Pop( contactStores ); |
|
115 CleanupStack::PushL( loader ); |
|
116 |
|
117 CPhCntThumbnailLoaderImpl* impl = |
|
118 CPhCntThumbnailLoaderImpl::NewL( aObserver, *iPbkOwner, *loader ); |
|
119 CleanupStack::Pop( loader ); |
|
120 |
|
121 return impl; |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // CPhCntFactoryImpl::CreateSingleItemFetchL |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 CPhCntSingleItemFetch* CPhCntFactoryImpl::CreateSingleItemFetchL() |
|
129 { |
|
130 CreatePhonebookServicesL(); |
|
131 return CPhCntSingleItemFetchService::NewL( |
|
132 *iContactStores, *iPbkOwner->ContactManager() ); |
|
133 } |
|
134 // --------------------------------------------------------------------------- |
|
135 // CPhCntFactoryImpl::CreateContactDataSelectionL |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 CPhCntContactDataSelection* CPhCntFactoryImpl::CreateContactDataSelectionL() |
|
139 { |
|
140 CreatePhonebookServicesL(); |
|
141 CPhCntAiwService* service = CPhCntAiwService::NewL(); |
|
142 CleanupStack::PushL( service ); |
|
143 CPhCntServiceRequestParamFactory* factory = |
|
144 CPhCntServiceRequestParamFactory::NewLC( *iPbkOwner->ContactManager() ); |
|
145 CPhCntContactStores* contactStores = |
|
146 CPhCntContactStores::NewL( *iPbkOwner->ContactManager() ); |
|
147 CleanupStack::PushL( contactStores ); |
|
148 |
|
149 |
|
150 CPhCntContactDataSelectionImpl* impl = |
|
151 CPhCntContactDataSelectionImpl::NewL( |
|
152 service, |
|
153 factory, |
|
154 contactStores ); |
|
155 CleanupStack::Pop( 3, service ); |
|
156 return impl; |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // CPhCntFactoryImpl::CreateSaveAddToNameL |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 CPhoneCntSaveAddToName* CPhCntFactoryImpl::CreateSaveAddToNameL() |
|
164 { |
|
165 CreatePhonebookServicesL(); |
|
166 |
|
167 CPhoneCntSaveAddToName* phoneSaveAddToName = |
|
168 CPhoneCntSaveAddToName::NewL( *iPhonebookServices ); |
|
169 return phoneSaveAddToName; |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // CPhCntFactoryImpl::CreateRfsHandlerL |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 CPhCntRfsHandler* CPhCntFactoryImpl::CreateRfsHandlerL() |
|
177 { |
|
178 return CPhCntRfsHandlerImpl::NewL(); |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // CPhCntFactoryImpl::CreateMmiSecurityL |
|
183 // --------------------------------------------------------------------------- |
|
184 // |
|
185 CPhCntMmiSecurity* CPhCntFactoryImpl::CreateMmiSecurityL() |
|
186 { |
|
187 if ( !iSecUiInit ) |
|
188 { |
|
189 TSecUi::InitializeLibL(); |
|
190 iSecUiInit = ETrue; |
|
191 } |
|
192 |
|
193 return CPhCntMmiSecurityImpl::NewL(); |
|
194 } |
|
195 |
|
196 // --------------------------------------------------------------------------- |
|
197 // CPhCntFactoryImpl::CreateContactMatcherL |
|
198 // |
|
199 // Create contact matcher |
|
200 // --------------------------------------------------------------------------- |
|
201 // |
|
202 CPhCntMatcher* CPhCntFactoryImpl::CreateContactMatcherL() |
|
203 { |
|
204 CreateContactStoreAndManagerL(); |
|
205 CPhCntMatcherImpl* matcher = NULL; |
|
206 if( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) ) |
|
207 { |
|
208 matcher = CPhCntMatcherVoIPImpl::NewL( *iPbkOwner ); |
|
209 } |
|
210 else |
|
211 { |
|
212 matcher = CPhCntMatcherImpl::NewL( *iPbkOwner ); |
|
213 } |
|
214 |
|
215 return matcher; |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------------------------- |
|
219 // CPhCntFactoryImpl::CreateProfileEngineL |
|
220 // --------------------------------------------------------------------------- |
|
221 // |
|
222 CPhCntProfileEngine* CPhCntFactoryImpl::CreateProfileEngineL() |
|
223 { |
|
224 return CPhCntProfileEngineImpl::NewL(); |
|
225 } |
|
226 |
|
227 // --------------------------------------------------------------------------- |
|
228 // CPhCntFactoryImpl::CreateProfileEngineNotifyHandlerL |
|
229 // --------------------------------------------------------------------------- |
|
230 // |
|
231 CBase* CPhCntFactoryImpl::CreateProfileEngineNotifyHandlerL( |
|
232 MProfileChangeObserver* aObserver ) |
|
233 { |
|
234 return CProfileChangeNotifyHandler::NewL( aObserver ); |
|
235 } |
|
236 |
|
237 // --------------------------------------------------------------------------- |
|
238 // CPhCntFactoryImpl::CreateContactIdL |
|
239 // --------------------------------------------------------------------------- |
|
240 // |
|
241 CPhCntContactId* CPhCntFactoryImpl::CreateContactIdL() |
|
242 { |
|
243 CreateContactStoreAndManagerL(); |
|
244 MVPbkContactLink* nullLink = NULL; |
|
245 return CPhCntVPbkContactId::NewL( nullLink, *iPbkOwner->ContactManager() ); |
|
246 } |
|
247 |
|
248 // --------------------------------------------------------------------------- |
|
249 // CPhCntFactoryImpl::CreateContactIdL |
|
250 // --------------------------------------------------------------------------- |
|
251 // |
|
252 CPhCntContactId* CPhCntFactoryImpl::CreateContactIdL( |
|
253 TContactItemId aContactId ) |
|
254 { |
|
255 CreateContactStoreAndManagerL(); |
|
256 return CPhCntVPbkContactId::NewL( aContactId, *iPbkOwner->ContactManager() ); |
|
257 } |
|
258 |
|
259 // --------------------------------------------------------------------------- |
|
260 // CPhCntFactoryImpl::CreateContactIdL |
|
261 // --------------------------------------------------------------------------- |
|
262 // |
|
263 CPhCntContactId* CPhCntFactoryImpl::CreateContactIdL( |
|
264 const TDesC8& aContactId ) |
|
265 { |
|
266 CreateContactStoreAndManagerL(); |
|
267 return CPhCntVPbkContactId::NewL( aContactId, *iPbkOwner->ContactManager() ); |
|
268 } |
|
269 |
|
270 // --------------------------------------------------------------------------- |
|
271 // CPhCntFactoryImpl::CreateContactStoreLoaderL |
|
272 // --------------------------------------------------------------------------- |
|
273 // |
|
274 MPhCntStoreLoader* CPhCntFactoryImpl::CreateContactStoreLoaderL() |
|
275 { |
|
276 CreateContactStoreAndManagerL(); |
|
277 |
|
278 return CPhCntStoreLoaderImpl::NewL( *(iPbkOwner->ContactManager() ) ); |
|
279 } |
|
280 |
|
281 // ----------------------------------------------------------------------------- |
|
282 // CPhCntFactoryImpl::CPhCntFactoryImpl |
|
283 // C++ constructor can NOT contain any code, that |
|
284 // might leave. |
|
285 // ----------------------------------------------------------------------------- |
|
286 // |
|
287 CPhCntFactoryImpl::CPhCntFactoryImpl() |
|
288 : iPbkResource( *CCoeEnv::Static() ) |
|
289 { |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // CPhCntFactoryImpl::ConstructL |
|
294 // Symbian 2nd phase constructor can leave. |
|
295 // ----------------------------------------------------------------------------- |
|
296 // |
|
297 void CPhCntFactoryImpl::ConstructL() |
|
298 { |
|
299 TEFLOGSTRING( KTAOBJECT, "CNT CPhCntFactoryImpl::ConstructL" ); |
|
300 FeatureManager::InitializeLibL(); |
|
301 } |
|
302 |
|
303 // ----------------------------------------------------------------------------- |
|
304 // Creates phonebook services. |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 void CPhCntFactoryImpl::CreatePhonebookServicesL() |
|
308 { |
|
309 TEFLOGSTRING( KTAOBJECT, "CNT CPhCntFactoryImpl::CreatePhonebookServicesL" ); |
|
310 CreateContactStoreAndManagerL(); |
|
311 |
|
312 if( !iPbkResource.IsOpen() ) |
|
313 { |
|
314 iPbkResource.OpenL(); |
|
315 iPhonebookServices = |
|
316 CPhCntPhonebookServices::NewL( |
|
317 *iContactStores, |
|
318 *iPbkOwner->ContactManager() ); |
|
319 } |
|
320 } |
|
321 |
|
322 // ----------------------------------------------------------------------------- |
|
323 // Creates phonebook services. |
|
324 // ----------------------------------------------------------------------------- |
|
325 // |
|
326 void CPhCntFactoryImpl::CreateContactStoreAndManagerL() |
|
327 { |
|
328 if( !iPbkOwner ) |
|
329 { |
|
330 iPbkOwner = CPhoneCntPbkOwner::NewL( ); |
|
331 CPhCntContactManager* contactManager = iPbkOwner->ContactManager(); |
|
332 iContactStores = CPhCntContactStores::NewL( *contactManager ); |
|
333 } |
|
334 } |
|
335 |
|
336 // ================= OTHER EXPORTED FUNCTIONS ============== |
|
337 |
|
338 // --------------------------------------------------------------------------- |
|
339 // CreateCntFactoryL |
|
340 // |
|
341 // Creates instance of contact factory. |
|
342 // --------------------------------------------------------------------------- |
|
343 // |
|
344 EXPORT_C CPhCntFactory* CreateCntFactoryL() |
|
345 { |
|
346 TEFLOGSTRING( KTAOBJECT, "CNT CPhCntFactoryImpl::CreateCntFactoryL" ); |
|
347 return CPhCntFactoryImpl::NewL(); |
|
348 } |
|
349 |
|
350 // End of File |