|
1 /* |
|
2 * Copyright (c) 2005-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: Phonebook 2 application services. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cpbk2serverapplicationservices.h" |
|
21 |
|
22 // Phonebook 2 |
|
23 #include <cpbk2storemanager.h> |
|
24 #include <cpbk2sortordermanager.h> |
|
25 #include <mpbk2contactnameformatter.h> |
|
26 #include <mpbk2viewexplorer.h> |
|
27 #include <pbk2contactnameformatterfactory.h> |
|
28 #include <pbk2commonui.rsg> |
|
29 #include <cpbk2storepropertyarray.h> |
|
30 #include <cpbk2fieldpropertyarray.h> |
|
31 #include <pbk2menufilteringflags.hrh> |
|
32 #include <phonebook2privatecrkeys.h> |
|
33 #include <cpbk2contactviewsupplier.h> |
|
34 #include <cpbk2storeconfiguration.h> |
|
35 #include <cpbk2servicemanager.h> |
|
36 |
|
37 // Virtual Phonebook |
|
38 #include <cvpbkcontactmanager.h> |
|
39 #include <cvpbkcontactstoreuriarray.h> |
|
40 |
|
41 // System includes |
|
42 #include <stringloader.h> |
|
43 #include <centralrepository.h> |
|
44 |
|
45 // Debugging headers |
|
46 #include <pbk2debug.h> |
|
47 #include <pbk2profile.h> |
|
48 |
|
49 // -------------------------------------------------------------------------- |
|
50 // CPbk2ServerApplicationServices::CPbk2ServerApplicationServices |
|
51 // -------------------------------------------------------------------------- |
|
52 // |
|
53 CPbk2ServerApplicationServices::CPbk2ServerApplicationServices() |
|
54 { |
|
55 } |
|
56 |
|
57 // -------------------------------------------------------------------------- |
|
58 // CPbk2ServerApplicationServices::~CPbk2ServerApplicationServices |
|
59 // -------------------------------------------------------------------------- |
|
60 // |
|
61 CPbk2ServerApplicationServices::~CPbk2ServerApplicationServices() |
|
62 { |
|
63 delete iServiceManager; |
|
64 // sort order manager can use the views from iViewSupplier, |
|
65 // so delete iSortOrderManager before iViewSupplier |
|
66 delete iSortOrderManager; |
|
67 delete iViewSupplier; |
|
68 delete iNameFormatter; |
|
69 delete iFieldProperties; |
|
70 delete iStoreManager; |
|
71 delete iStoreProperties; |
|
72 delete iContactManager; |
|
73 delete iStoreConfiguration; |
|
74 } |
|
75 |
|
76 // -------------------------------------------------------------------------- |
|
77 // CPbk2ServerApplicationServices::ConstructL |
|
78 // -------------------------------------------------------------------------- |
|
79 // |
|
80 inline void CPbk2ServerApplicationServices::ConstructL() |
|
81 { |
|
82 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
83 ( "CPbk2ServerApplicationServices::ConstructL(0x%x)"), this ); |
|
84 |
|
85 // Create Virtual Phonebook contact manager for Phonebook 2 |
|
86 CreateManagerL(); |
|
87 |
|
88 CreateSortOrderManagerL(); |
|
89 CreateStorePropertyArrayL(); |
|
90 CreateStoreConfigurationL(); |
|
91 CreateViewSupplierL(); |
|
92 |
|
93 PBK2_PROFILE_START(Pbk2Profile::EAppServicesCreateStoreManager); |
|
94 iStoreManager = CPbk2StoreManager::NewL |
|
95 ( *iContactManager, *iStoreConfiguration, ETrue ); |
|
96 PBK2_PROFILE_END(Pbk2Profile::EAppServicesCreateStoreManager); |
|
97 |
|
98 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
99 ( "CPbk2ServerApplicationServices::ConstructL(0x%x) Store manager created"), |
|
100 this ); |
|
101 |
|
102 |
|
103 iServiceManager = CPbk2ServiceManager::NewL(iContactManager->FsSession()); |
|
104 CreateFieldPropertyArrayL(); |
|
105 CreateNameFormatterL(); |
|
106 |
|
107 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
108 ("CPbk2ServerApplicationServices::ConstructL(0x%x) end"), this); |
|
109 } |
|
110 |
|
111 // -------------------------------------------------------------------------- |
|
112 // CPbk2ServerApplicationServices::NewL |
|
113 // -------------------------------------------------------------------------- |
|
114 // |
|
115 CPbk2ServerApplicationServices* CPbk2ServerApplicationServices::NewL() |
|
116 { |
|
117 CPbk2ServerApplicationServices* self = |
|
118 new ( ELeave ) CPbk2ServerApplicationServices(); |
|
119 CleanupStack::PushL( self ); |
|
120 self->ConstructL(); |
|
121 CleanupStack::Pop( self ); |
|
122 return self; |
|
123 } |
|
124 |
|
125 // -------------------------------------------------------------------------- |
|
126 // CPbk2ServerApplicationServices::ContactManager |
|
127 // -------------------------------------------------------------------------- |
|
128 // |
|
129 CVPbkContactManager& CPbk2ServerApplicationServices::ContactManager() const |
|
130 { |
|
131 return *iContactManager; |
|
132 } |
|
133 |
|
134 // -------------------------------------------------------------------------- |
|
135 // CPbk2ServerApplicationServices::CommandHandlerL |
|
136 // -------------------------------------------------------------------------- |
|
137 // |
|
138 MPbk2CommandHandler* CPbk2ServerApplicationServices::CommandHandlerL() |
|
139 { |
|
140 // Not supported in Server App |
|
141 return NULL; |
|
142 } |
|
143 |
|
144 // -------------------------------------------------------------------------- |
|
145 // CPbk2ServerApplicationServices::NameFormatter |
|
146 // -------------------------------------------------------------------------- |
|
147 // |
|
148 MPbk2ContactNameFormatter& |
|
149 CPbk2ServerApplicationServices::NameFormatter() const |
|
150 { |
|
151 return *iNameFormatter; |
|
152 } |
|
153 |
|
154 // -------------------------------------------------------------------------- |
|
155 // CPbk2ServerApplicationServices::SortOrderManager |
|
156 // -------------------------------------------------------------------------- |
|
157 // |
|
158 CPbk2SortOrderManager& |
|
159 CPbk2ServerApplicationServices::SortOrderManager() const |
|
160 { |
|
161 return *iSortOrderManager; |
|
162 } |
|
163 |
|
164 // -------------------------------------------------------------------------- |
|
165 // CPbk2ServerApplicationServices::SendUiL |
|
166 // -------------------------------------------------------------------------- |
|
167 // |
|
168 CSendUi* CPbk2ServerApplicationServices::SendUiL() |
|
169 { |
|
170 // Not supported in Server App |
|
171 return NULL; |
|
172 } |
|
173 |
|
174 // -------------------------------------------------------------------------- |
|
175 // CPbk2ServerApplicationServices::StoreProperties |
|
176 // -------------------------------------------------------------------------- |
|
177 // |
|
178 CPbk2StorePropertyArray& |
|
179 CPbk2ServerApplicationServices::StoreProperties() const |
|
180 { |
|
181 return *iStoreProperties; |
|
182 } |
|
183 |
|
184 // -------------------------------------------------------------------------- |
|
185 // CPbk2ServerApplicationServices::FieldProperties |
|
186 // -------------------------------------------------------------------------- |
|
187 // |
|
188 CPbk2FieldPropertyArray& |
|
189 CPbk2ServerApplicationServices::FieldProperties() const |
|
190 { |
|
191 return *iFieldProperties; |
|
192 } |
|
193 |
|
194 // -------------------------------------------------------------------------- |
|
195 // CPbk2ServerApplicationServices::StoreConfiguration |
|
196 // -------------------------------------------------------------------------- |
|
197 // |
|
198 CPbk2StoreConfiguration& |
|
199 CPbk2ServerApplicationServices::StoreConfiguration() const |
|
200 { |
|
201 return *iStoreConfiguration; |
|
202 } |
|
203 |
|
204 // -------------------------------------------------------------------------- |
|
205 // CPbk2ServerApplicationServices::StoreObservationRegister |
|
206 // -------------------------------------------------------------------------- |
|
207 // |
|
208 MPbk2StoreObservationRegister& |
|
209 CPbk2ServerApplicationServices::StoreObservationRegister() const |
|
210 { |
|
211 return *iStoreManager; |
|
212 } |
|
213 |
|
214 // -------------------------------------------------------------------------- |
|
215 // CPbk2ServerApplicationServices::StoreValidityInformer |
|
216 // -------------------------------------------------------------------------- |
|
217 // |
|
218 MPbk2StoreValidityInformer& |
|
219 CPbk2ServerApplicationServices::StoreValidityInformer() const |
|
220 { |
|
221 return *iStoreManager; |
|
222 } |
|
223 |
|
224 // -------------------------------------------------------------------------- |
|
225 // CPbk2ServerApplicationServices::ViewSupplier |
|
226 // -------------------------------------------------------------------------- |
|
227 // |
|
228 MPbk2ContactViewSupplier& |
|
229 CPbk2ServerApplicationServices::ViewSupplier() const |
|
230 { |
|
231 return *iViewSupplier; |
|
232 } |
|
233 |
|
234 // -------------------------------------------------------------------------- |
|
235 // CPbk2ServerApplicationServices::GlobalMenuFilteringFlagsL |
|
236 // -------------------------------------------------------------------------- |
|
237 // |
|
238 TInt CPbk2ServerApplicationServices::GlobalMenuFilteringFlagsL() const |
|
239 { |
|
240 return KPbk2MenuFilteringFlagsNone; |
|
241 } |
|
242 |
|
243 // -------------------------------------------------------------------------- |
|
244 // CPbk2ServerApplicationServices::MPbk2ApplicationServicesExtension |
|
245 // -------------------------------------------------------------------------- |
|
246 // |
|
247 TAny* CPbk2ServerApplicationServices::MPbk2ApplicationServicesExtension( |
|
248 TUid aExtensionUid ) |
|
249 { |
|
250 if ( aExtensionUid == KMPbk2ApplicationServicesExtension2Uid ) |
|
251 { |
|
252 return static_cast<MPbk2ApplicationServices2*>( this ); |
|
253 } |
|
254 return NULL; |
|
255 } |
|
256 |
|
257 // -------------------------------------------------------------------------- |
|
258 // CPbk2ServerApplicationServices::StoreManager |
|
259 // -------------------------------------------------------------------------- |
|
260 // |
|
261 CPbk2StoreManager& CPbk2ServerApplicationServices::StoreManager() const |
|
262 { |
|
263 return *iStoreManager; |
|
264 } |
|
265 |
|
266 // -------------------------------------------------------------------------- |
|
267 // CPbk2ApplicationServices::ServicesManager |
|
268 // -------------------------------------------------------------------------- |
|
269 // |
|
270 CPbk2ServiceManager& CPbk2ServerApplicationServices::ServiceManager() const |
|
271 { |
|
272 return *iServiceManager; |
|
273 } |
|
274 |
|
275 // -------------------------------------------------------------------------- |
|
276 // CPbk2ServerApplicationServices::CreateManagerL |
|
277 // -------------------------------------------------------------------------- |
|
278 // |
|
279 inline void CPbk2ServerApplicationServices::CreateManagerL() |
|
280 { |
|
281 PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING |
|
282 ( "CPbk2ServerApplicationServices:CreateManagerL(0x%x)" ), this ); |
|
283 |
|
284 // Initialize contact manager with empty URI array |
|
285 CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewL(); |
|
286 CleanupStack::PushL( uriArray ); |
|
287 |
|
288 TSecurityInfo secInfo; |
|
289 secInfo.SetToCreatorInfo(); |
|
290 iContactManager = CVPbkContactManager::NewL( secInfo, *uriArray ); |
|
291 |
|
292 CleanupStack::PopAndDestroy(); // uriArray |
|
293 |
|
294 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
295 ("CPbk2ServerApplicationServices::CreateManagerL(0x%x) end"), this); |
|
296 } |
|
297 |
|
298 // -------------------------------------------------------------------------- |
|
299 // CPbk2ServerApplicationServices::CreateSortOrderManagerL |
|
300 // -------------------------------------------------------------------------- |
|
301 // |
|
302 inline void CPbk2ServerApplicationServices::CreateSortOrderManagerL() |
|
303 { |
|
304 PBK2_PROFILE_START( Pbk2Profile::EAppServicesCreateSortOrderManager ); |
|
305 |
|
306 iSortOrderManager = CPbk2SortOrderManager::NewL |
|
307 ( iContactManager->FieldTypes() ); |
|
308 |
|
309 PBK2_PROFILE_END( Pbk2Profile::EAppServicesCreateSortOrderManager ); |
|
310 } |
|
311 |
|
312 // -------------------------------------------------------------------------- |
|
313 // CPbk2ServerApplicationServices::CreateStorePropertyArrayL |
|
314 // -------------------------------------------------------------------------- |
|
315 // |
|
316 inline void CPbk2ServerApplicationServices::CreateStorePropertyArrayL() |
|
317 { |
|
318 PBK2_PROFILE_START( Pbk2Profile::EAppServicesCreateStorePropertyArray ); |
|
319 iStoreProperties = CPbk2StorePropertyArray::NewL(); |
|
320 PBK2_PROFILE_END( Pbk2Profile::EAppServicesCreateStorePropertyArray ); |
|
321 |
|
322 PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING |
|
323 ( "CPbk2ServerApplicationServices::CreateStorePropertyArrayL() done ") ); |
|
324 } |
|
325 |
|
326 // -------------------------------------------------------------------------- |
|
327 // CPbk2ServerApplicationServices::CreateFieldPropertyArrayL |
|
328 // -------------------------------------------------------------------------- |
|
329 // |
|
330 inline void CPbk2ServerApplicationServices::CreateFieldPropertyArrayL() |
|
331 { |
|
332 PBK2_PROFILE_START( Pbk2Profile::EAppServicesCreateFieldPropertyArray ); |
|
333 iFieldProperties = CPbk2FieldPropertyArray::NewL |
|
334 ( iContactManager->FieldTypes(), iContactManager->FsSession(), |
|
335 iServiceManager ); |
|
336 PBK2_PROFILE_END( Pbk2Profile::EAppServicesCreateFieldPropertyArray ); |
|
337 } |
|
338 |
|
339 // -------------------------------------------------------------------------- |
|
340 // CPbk2ServerApplicationServices::CreateNameFormatterL |
|
341 // -------------------------------------------------------------------------- |
|
342 // |
|
343 inline void CPbk2ServerApplicationServices::CreateNameFormatterL() |
|
344 { |
|
345 PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING |
|
346 ( "CPbk2ServerApplicationServices::CreateNameFormatterL(0x%x)" ), |
|
347 this ); |
|
348 |
|
349 HBufC* unnamedBuf = StringLoader::LoadLC( R_QTN_PHOB_UNNAMED ); |
|
350 TPtr unnamed = unnamedBuf->Des(); |
|
351 MPbk2ContactNameFormatter* nameFormatter = |
|
352 Pbk2ContactNameFormatterFactory::CreateL |
|
353 ( unnamed, iContactManager->FieldTypes(), *iSortOrderManager, |
|
354 &CCoeEnv::Static()->FsSession() ); |
|
355 CleanupStack::PopAndDestroy( unnamedBuf ); |
|
356 |
|
357 delete iNameFormatter; |
|
358 iNameFormatter = nameFormatter; |
|
359 |
|
360 PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING |
|
361 ( "CPbk2ServerApplicationServices::CreateNameFormatterL(0x%x) end" ), |
|
362 this ); |
|
363 } |
|
364 |
|
365 // -------------------------------------------------------------------------- |
|
366 // CPbk2ServerApplicationServices::CreateViewSupplierL |
|
367 // -------------------------------------------------------------------------- |
|
368 // |
|
369 inline void CPbk2ServerApplicationServices::CreateViewSupplierL() |
|
370 { |
|
371 iViewSupplier = CPbk2ContactViewSupplier::NewL |
|
372 ( *iContactManager, *iSortOrderManager, *iStoreConfiguration, |
|
373 *iStoreProperties, EFalse ); |
|
374 } |
|
375 |
|
376 // -------------------------------------------------------------------------- |
|
377 // CPbk2ServerApplicationServices::CreateStoreConfigurationL |
|
378 // -------------------------------------------------------------------------- |
|
379 // |
|
380 inline void CPbk2ServerApplicationServices::CreateStoreConfigurationL() |
|
381 { |
|
382 iStoreConfiguration = CPbk2StoreConfiguration::NewL(); |
|
383 } |
|
384 |
|
385 // End of File |