|
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: Phonebook 2 store manager. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <CPbk2StoreManager.h> |
|
21 |
|
22 // Phonebook 2 |
|
23 #include "CPbk2CompressPolicyManager.h" |
|
24 #include <CPbk2StoreConfiguration.h> |
|
25 #include <RPbk2LocalizedResourceFile.h> |
|
26 #include <Pbk2DataCaging.hrh> |
|
27 #include <Pbk2CommonUi.rsg> |
|
28 |
|
29 // Virtual Phonebook |
|
30 #include <CVPbkContactManager.h> |
|
31 #include <MVPbkContactStoreList.h> |
|
32 #include <MVPbkContactStore.h> |
|
33 #include <CVPbkContactStoreUriArray.h> |
|
34 #include <TVPbkContactStoreUriPtr.h> |
|
35 |
|
36 // System includes |
|
37 #include <barsread.h> |
|
38 #include <coemain.h> |
|
39 #include <aknnotewrappers.h> |
|
40 |
|
41 // Debugging headers |
|
42 #include <Pbk2Debug.h> |
|
43 |
|
44 /// Unnamed namespace for local definitions |
|
45 namespace { |
|
46 |
|
47 /** |
|
48 * Checks is the error received from the database at the open |
|
49 * fatal or not. |
|
50 * |
|
51 * @param aError Error code. |
|
52 * @return ETrue if the error is a fatal one. |
|
53 */ |
|
54 TBool IsFatalDbOpenError( TInt aError ) |
|
55 { |
|
56 TBool ret = ETrue; |
|
57 |
|
58 switch ( aError ) |
|
59 { |
|
60 case KErrNone: // FALLTHROUGH |
|
61 case KErrCancel: // FALLTHROUGH |
|
62 case KErrNoMemory: // FALLTHROUGH |
|
63 case KErrNotSupported: // FALLTHROUGH |
|
64 case KErrArgument: // FALLTHROUGH |
|
65 case KErrDied: // FALLTHROUGH |
|
66 case KErrInUse: // FALLTHROUGH |
|
67 case KErrServerTerminated: // FALLTHROUGH |
|
68 case KErrServerBusy: // FALLTHROUGH |
|
69 case KErrNotReady: // FALLTHROUGH |
|
70 case KErrAccessDenied: // FALLTHROUGH |
|
71 case KErrLocked: // FALLTHROUGH |
|
72 case KErrWrite: // FALLTHROUGH |
|
73 case KErrDisMounted: // FALLTHROUGH |
|
74 case KErrDiskFull: // FALLTHROUGH |
|
75 case KErrAbort: // FALLTHROUGH |
|
76 case KErrBadPower: // FALLTHROUGH |
|
77 case KErrDirFull: // FALLTHROUGH |
|
78 case KErrHardwareNotAvailable: |
|
79 { |
|
80 ret = EFalse; |
|
81 break; |
|
82 } |
|
83 |
|
84 default: |
|
85 { |
|
86 // All error codes not handled above end up here, |
|
87 // especially KErrCorrupt |
|
88 break; |
|
89 } |
|
90 } |
|
91 |
|
92 return ret; |
|
93 } |
|
94 |
|
95 } /// namespace |
|
96 |
|
97 // -------------------------------------------------------------------------- |
|
98 // CPbk2StoreManager::CPbk2StoreManager |
|
99 // -------------------------------------------------------------------------- |
|
100 // |
|
101 inline CPbk2StoreManager::CPbk2StoreManager |
|
102 ( CVPbkContactManager& aContactManager, |
|
103 CPbk2StoreConfiguration& aStoreConfiguration, |
|
104 TBool aActOnConfigurationEvents ) : |
|
105 iContactManager( aContactManager ), |
|
106 iStoreConfiguration( aStoreConfiguration ), |
|
107 iActOnConfigurationEvents( aActOnConfigurationEvents ) |
|
108 { |
|
109 } |
|
110 |
|
111 // -------------------------------------------------------------------------- |
|
112 // CPbk2StoreManager::~CPbk2StoreManager |
|
113 // -------------------------------------------------------------------------- |
|
114 // |
|
115 CPbk2StoreManager::~CPbk2StoreManager() |
|
116 { |
|
117 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
118 ("CPbk2StoreManager::~CPbk2StoreManager(0x%x)"), this); |
|
119 |
|
120 if ( iContactStores ) |
|
121 { |
|
122 iContactStores->CloseAll(*this); |
|
123 } |
|
124 |
|
125 iFailedStores.Reset(); |
|
126 iFailedStores.Close(); |
|
127 |
|
128 iOpenedStores.Reset(); |
|
129 iOpenedStores.Close(); |
|
130 |
|
131 iStoreObservers.Reset(); |
|
132 iStoreObservers.Close(); |
|
133 |
|
134 delete iCompressPolicy; |
|
135 } |
|
136 |
|
137 // -------------------------------------------------------------------------- |
|
138 // CPbk2StoreManager::ConstructL |
|
139 // -------------------------------------------------------------------------- |
|
140 // |
|
141 inline void CPbk2StoreManager::ConstructL() |
|
142 { |
|
143 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
144 ("CPbk2StoreManager::ConstructL(0x%x)"), this); |
|
145 |
|
146 iStoreConfiguration.AddObserverL( *this ); |
|
147 |
|
148 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
149 ("CPbk2StoreManager::ConstructL(0x%x) Store configuration created"), |
|
150 this); |
|
151 |
|
152 iCompressPolicy = |
|
153 CPbk2CompressPolicyManager::NewL( *this, iContactManager ); |
|
154 |
|
155 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
156 ("CPbk2StoreManager::ConstructL(0x%x) end"), this); |
|
157 } |
|
158 |
|
159 // -------------------------------------------------------------------------- |
|
160 // CPbk2StoreManager::NewL |
|
161 // -------------------------------------------------------------------------- |
|
162 // |
|
163 EXPORT_C CPbk2StoreManager* CPbk2StoreManager::NewL |
|
164 ( CVPbkContactManager& aContactManager, |
|
165 CPbk2StoreConfiguration& aStoreConfiguration, |
|
166 TBool aActOnConfigurationEvents ) |
|
167 { |
|
168 CPbk2StoreManager* self = new (ELeave) CPbk2StoreManager |
|
169 ( aContactManager, aStoreConfiguration, aActOnConfigurationEvents ); |
|
170 CleanupStack::PushL( self ); |
|
171 self->ConstructL(); |
|
172 CleanupStack::Pop( self ); |
|
173 return self; |
|
174 } |
|
175 |
|
176 // -------------------------------------------------------------------------- |
|
177 // CPbk2StoreManager::OpenStoresL |
|
178 // -------------------------------------------------------------------------- |
|
179 // |
|
180 EXPORT_C void CPbk2StoreManager::OpenStoresL() |
|
181 { |
|
182 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
183 ("CPbk2StoreManager::OpenStoresL")); |
|
184 |
|
185 if (iContactStores) |
|
186 { |
|
187 iContactStores->CloseAll(*this); |
|
188 } |
|
189 |
|
190 iContactStores = &iContactManager.ContactStoresL(); |
|
191 |
|
192 if (iContactStores) |
|
193 { |
|
194 iContactStores->OpenAllL(*this); |
|
195 } |
|
196 } |
|
197 |
|
198 // -------------------------------------------------------------------------- |
|
199 // CPbk2StoreManager::EnableCompression |
|
200 // -------------------------------------------------------------------------- |
|
201 // |
|
202 EXPORT_C void CPbk2StoreManager::EnableCompression(TBool aEnable) |
|
203 { |
|
204 if (aEnable) |
|
205 { |
|
206 iCompressPolicy->StartAllPolicies(); |
|
207 } |
|
208 else |
|
209 { |
|
210 iCompressPolicy->StopAllPolicies(); |
|
211 } |
|
212 } |
|
213 |
|
214 // -------------------------------------------------------------------------- |
|
215 // CPbk2StoreManager::EnsureDefaultSavingStoreIncludedL |
|
216 // -------------------------------------------------------------------------- |
|
217 // |
|
218 EXPORT_C void CPbk2StoreManager::EnsureDefaultSavingStoreIncludedL() |
|
219 { |
|
220 iStoreConfiguration.AddDefaultSavingStoreObserverL( *this ); |
|
221 iContactManager.LoadContactStoreL |
|
222 ( iStoreConfiguration.DefaultSavingStoreL() ); |
|
223 } |
|
224 |
|
225 // -------------------------------------------------------------------------- |
|
226 // CPbk2StoreManager::EnsureDefaultSavingStoreIncludedL |
|
227 // -------------------------------------------------------------------------- |
|
228 // |
|
229 EXPORT_C void CPbk2StoreManager::EnsureCurrentConfigurationStoresIncludedL() |
|
230 { |
|
231 CVPbkContactStoreUriArray* uriArray = |
|
232 iStoreConfiguration.CurrentConfigurationL(); |
|
233 CleanupStack::PushL( uriArray ); |
|
234 TInt count( uriArray->Count() ); |
|
235 for ( TInt i(0); i < count; ++i ) |
|
236 { |
|
237 iContactManager.LoadContactStoreL( (*uriArray)[i] ); |
|
238 } |
|
239 CleanupStack::PopAndDestroy( uriArray ); |
|
240 } |
|
241 |
|
242 // -------------------------------------------------------------------------- |
|
243 // CPbk2StoreManager::RegisterStoreEventsL |
|
244 // -------------------------------------------------------------------------- |
|
245 // |
|
246 void CPbk2StoreManager::RegisterStoreEventsL |
|
247 (const MVPbkContactStoreObserver& aObserver) |
|
248 { |
|
249 User::LeaveIfError( iStoreObservers.Append( &aObserver ) ); |
|
250 } |
|
251 |
|
252 // -------------------------------------------------------------------------- |
|
253 // CPbk2StoreManager::DeregisterStoreEvents |
|
254 // -------------------------------------------------------------------------- |
|
255 // |
|
256 void CPbk2StoreManager::DeregisterStoreEvents |
|
257 (const MVPbkContactStoreObserver& aObserver) |
|
258 { |
|
259 const TInt index = iStoreObservers.Find( &aObserver ); |
|
260 if ( index > KErrNotFound ) |
|
261 { |
|
262 iStoreObservers.Remove( index ); |
|
263 } |
|
264 } |
|
265 |
|
266 // -------------------------------------------------------------------------- |
|
267 // CPbk2StoreManager::CurrentlyValidStoresL |
|
268 // -------------------------------------------------------------------------- |
|
269 // |
|
270 CVPbkContactStoreUriArray* CPbk2StoreManager::CurrentlyValidStoresL() const |
|
271 { |
|
272 CVPbkContactStoreUriArray* uris = CurrentlyValidShownStoresL(); |
|
273 CleanupStack::PushL( uris ); |
|
274 |
|
275 // If default saving store is not part of current config, |
|
276 // check if it still valid store |
|
277 TVPbkContactStoreUriPtr defaultSavingStoreUri = |
|
278 iStoreConfiguration.DefaultSavingStoreL(); |
|
279 if ( !uris->IsIncluded( defaultSavingStoreUri )) |
|
280 { |
|
281 // Default store is not in the uris array |
|
282 MVPbkContactStore* defaultStore = |
|
283 iContactStores->Find( defaultSavingStoreUri ); |
|
284 // Add the default saving store to the list |
|
285 // if it is loaded, opened and not failed |
|
286 if ( defaultStore && IsStoreOpen(*defaultStore) |
|
287 && iFailedStores.Find( defaultStore ) == KErrNotFound ) |
|
288 { |
|
289 // Default saving store is valid store and successfully opened |
|
290 uris->AppendL( defaultSavingStoreUri ); |
|
291 } |
|
292 } |
|
293 CleanupStack::Pop( uris ); |
|
294 |
|
295 return uris; |
|
296 } |
|
297 |
|
298 // -------------------------------------------------------------------------- |
|
299 // CPbk2StoreManager::CurrentlyValidShownStoresL |
|
300 // -------------------------------------------------------------------------- |
|
301 // |
|
302 CVPbkContactStoreUriArray* |
|
303 CPbk2StoreManager::CurrentlyValidShownStoresL() const |
|
304 { |
|
305 // Gets the list of URI's that compose the current configuration |
|
306 CVPbkContactStoreUriArray* uris = |
|
307 iStoreConfiguration.CurrentConfigurationL(); |
|
308 |
|
309 // Remove stores that are not open or are unavailable from the list |
|
310 const TInt count = uris->Count(); |
|
311 for (TInt i = count - 1; i >= 0; --i) |
|
312 { |
|
313 TVPbkContactStoreUriPtr uri = (*uris)[i]; |
|
314 MVPbkContactStore* store = iContactStores->Find(uri); |
|
315 if ( !(store && IsStoreOpen( *store ) && |
|
316 ( iFailedStores.Find( store ) == KErrNotFound ) ) ) |
|
317 { |
|
318 // When the store is loaded, opened and not failed |
|
319 // it is not removed from the URI list |
|
320 uris->Remove(uri); |
|
321 } |
|
322 } |
|
323 |
|
324 return uris; |
|
325 } |
|
326 |
|
327 // -------------------------------------------------------------------------- |
|
328 // CPbk2StoreManager::OpenComplete |
|
329 // -------------------------------------------------------------------------- |
|
330 // |
|
331 void CPbk2StoreManager::OpenComplete() |
|
332 { |
|
333 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
334 ("CPbk2StoreManager::OpenComplete")); |
|
335 } |
|
336 |
|
337 // -------------------------------------------------------------------------- |
|
338 // CPbk2StoreManager::StoreReady |
|
339 // -------------------------------------------------------------------------- |
|
340 // |
|
341 void CPbk2StoreManager::StoreReady( |
|
342 MVPbkContactStore& aContactStore) |
|
343 { |
|
344 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
345 ("CPbk2StoreManager::StoreReady(0x%x)"), |
|
346 &aContactStore); |
|
347 |
|
348 // If the store was on the failed list, remove it |
|
349 // from there |
|
350 const TInt index = iFailedStores.Find(&aContactStore); |
|
351 if (index != KErrNotFound) |
|
352 { |
|
353 iFailedStores.Remove(index); |
|
354 } |
|
355 |
|
356 // Add it to the open stores list |
|
357 if (iOpenedStores.Find(&aContactStore) == KErrNotFound) |
|
358 { |
|
359 iOpenedStores.Append(&aContactStore); |
|
360 } |
|
361 |
|
362 // Notify observers |
|
363 for (TInt i=0; i < iStoreObservers.Count(); ++i) |
|
364 { |
|
365 iStoreObservers[i]->StoreReady(aContactStore); |
|
366 } |
|
367 } |
|
368 |
|
369 // -------------------------------------------------------------------------- |
|
370 // CPbk2StoreManager::StoreUnavailable |
|
371 // -------------------------------------------------------------------------- |
|
372 // |
|
373 void CPbk2StoreManager::StoreUnavailable |
|
374 ( MVPbkContactStore& aContactStore, TInt aReason ) |
|
375 { |
|
376 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
377 ("CPbk2StoreManager::StoreUnavailable(0x%x,%d)"), |
|
378 &aContactStore, aReason); |
|
379 |
|
380 // If the store is not found from the failed list, |
|
381 // add it there and try to replace it. |
|
382 // If the replace fails, the store will be found from the |
|
383 // failed list, and the replace is not called again. |
|
384 |
|
385 TBool informObservers = ETrue; |
|
386 if ( iFailedStores.Find( &aContactStore ) == KErrNotFound ) |
|
387 { |
|
388 iFailedStores.Append( &aContactStore ); |
|
389 if ( IsFatalDbOpenError( aReason ) ) |
|
390 { |
|
391 informObservers = EFalse; // inform only if the replace fails too |
|
392 TRAPD( err, ReplaceStoreL( aContactStore ) ); |
|
393 if ( err != KErrNone ) |
|
394 { |
|
395 informObservers = ETrue; |
|
396 CCoeEnv::Static()->HandleError( err ); |
|
397 } |
|
398 } |
|
399 } |
|
400 |
|
401 // Remove the store from the open store list if it is there |
|
402 const TInt index = iOpenedStores.Find( &aContactStore ); |
|
403 if ( index != KErrNotFound ) |
|
404 { |
|
405 iOpenedStores.Remove( index ); |
|
406 } |
|
407 |
|
408 // Notify observers |
|
409 if ( informObservers ) |
|
410 { |
|
411 for ( TInt i=0; i < iStoreObservers.Count(); ++i ) |
|
412 { |
|
413 iStoreObservers[i]->StoreUnavailable( aContactStore, aReason ); |
|
414 } |
|
415 } |
|
416 } |
|
417 |
|
418 // -------------------------------------------------------------------------- |
|
419 // CPbk2StoreManager::HandleStoreEventL |
|
420 // -------------------------------------------------------------------------- |
|
421 // |
|
422 void CPbk2StoreManager::HandleStoreEventL |
|
423 ( MVPbkContactStore& aContactStore, |
|
424 TVPbkContactStoreEvent aEvent ) |
|
425 { |
|
426 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
427 ("CPbk2StoreManager::HandleStoreEventL(0x%x,%d)"), |
|
428 &aContactStore, aEvent.iEventType); |
|
429 |
|
430 // Notify observers |
|
431 for (TInt i=0; i < iStoreObservers.Count(); ++i) |
|
432 { |
|
433 iStoreObservers[i]->HandleStoreEventL(aContactStore, aEvent); |
|
434 } |
|
435 } |
|
436 |
|
437 // -------------------------------------------------------------------------- |
|
438 // CPbk2StoreManager::ConfigurationChanged |
|
439 // -------------------------------------------------------------------------- |
|
440 // |
|
441 void CPbk2StoreManager::ConfigurationChanged() |
|
442 { |
|
443 if ( iActOnConfigurationEvents ) |
|
444 { |
|
445 TRAPD( err, HandleConfigurationChangedL() ); |
|
446 if ( err != KErrNone ) |
|
447 { |
|
448 CCoeEnv::Static()->HandleError( err ); |
|
449 } |
|
450 } |
|
451 } |
|
452 |
|
453 // -------------------------------------------------------------------------- |
|
454 // CPbk2StoreManager::ConfigurationChangedComplete |
|
455 // -------------------------------------------------------------------------- |
|
456 // |
|
457 void CPbk2StoreManager::ConfigurationChangedComplete() |
|
458 { |
|
459 if ( iActOnConfigurationEvents ) |
|
460 { |
|
461 TRAPD( err,CloseUnnecessaryStoresL() ); |
|
462 if ( err != KErrNone ) |
|
463 { |
|
464 CCoeEnv::Static()->HandleError( err ); |
|
465 } |
|
466 } |
|
467 } |
|
468 |
|
469 // -------------------------------------------------------------------------- |
|
470 // CPbk2StoreManager::SavingStoreChanged |
|
471 // -------------------------------------------------------------------------- |
|
472 // |
|
473 void CPbk2StoreManager::SavingStoreChanged() |
|
474 { |
|
475 TRAPD(err,HandleSavingStoreChangedL()); |
|
476 if (err != KErrNone) |
|
477 { |
|
478 CCoeEnv::Static()->HandleError(err); |
|
479 } |
|
480 } |
|
481 |
|
482 // -------------------------------------------------------------------------- |
|
483 // CPbk2StoreManager::HandleConfigurationChangedL |
|
484 // -------------------------------------------------------------------------- |
|
485 // |
|
486 void CPbk2StoreManager::HandleConfigurationChangedL() |
|
487 { |
|
488 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
489 ("CPbk2StoreManager::HandleConfigurationChangedL(0x%x)"), |
|
490 this); |
|
491 |
|
492 EnsureCurrentConfigurationLoadedAndOpenL(); |
|
493 |
|
494 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
495 ( "CPbk2StoreManager::HandleConfigurationChangedL(0x%x) end" ), |
|
496 this ); |
|
497 } |
|
498 |
|
499 // -------------------------------------------------------------------------- |
|
500 // CPbk2StoreManager::EnsureCurrentConfigurationLoadedAndOpenL |
|
501 // -------------------------------------------------------------------------- |
|
502 // |
|
503 void CPbk2StoreManager::EnsureCurrentConfigurationLoadedAndOpenL() |
|
504 { |
|
505 CVPbkContactStoreUriArray* supportedConfiguration = |
|
506 iStoreConfiguration.SupportedStoreConfigurationL(); |
|
507 CleanupStack::PushL(supportedConfiguration); |
|
508 |
|
509 CVPbkContactStoreUriArray* currentConfiguration = |
|
510 iStoreConfiguration.CurrentConfigurationL(); |
|
511 CleanupStack::PushL(currentConfiguration); |
|
512 |
|
513 MVPbkContactStoreList& storeList = iContactManager.ContactStoresL(); |
|
514 const TInt supportedCount = supportedConfiguration->Count(); |
|
515 for (TInt i = 0; i < supportedCount; ++i ) |
|
516 { |
|
517 // loop through the supported configurations and load and open |
|
518 // all stores that are not part of the current configuration |
|
519 TVPbkContactStoreUriPtr supportedStore = (*supportedConfiguration)[i]; |
|
520 if (currentConfiguration->IsIncluded(supportedStore)) |
|
521 { |
|
522 // if the supported store is not loaded, then load it |
|
523 if ( !storeList.Find(supportedStore) ) |
|
524 { |
|
525 iContactManager.LoadContactStoreL(supportedStore); |
|
526 } |
|
527 // if the supported store is not open, then open it |
|
528 MVPbkContactStore* store = storeList.Find(supportedStore); |
|
529 if (store && iOpenedStores.Find(store) == KErrNotFound) |
|
530 { |
|
531 store->OpenL(*this); |
|
532 } |
|
533 } |
|
534 } |
|
535 |
|
536 CleanupStack::PopAndDestroy( 2 ); // currentConfiguration, |
|
537 } // supportedConfiguration |
|
538 |
|
539 // -------------------------------------------------------------------------- |
|
540 // CPbk2StoreManager::CloseUnnecessaryStoresL |
|
541 // -------------------------------------------------------------------------- |
|
542 // |
|
543 void CPbk2StoreManager::CloseUnnecessaryStoresL() |
|
544 { |
|
545 CVPbkContactStoreUriArray* supportedConfiguration = |
|
546 iStoreConfiguration.SupportedStoreConfigurationL(); |
|
547 CleanupStack::PushL( supportedConfiguration ); |
|
548 |
|
549 CVPbkContactStoreUriArray* currentConfiguration = |
|
550 iStoreConfiguration.CurrentConfigurationL(); |
|
551 CleanupStack::PushL( currentConfiguration ); |
|
552 |
|
553 MVPbkContactStoreList& storeList = iContactManager.ContactStoresL(); |
|
554 TVPbkContactStoreUriPtr defaultStore = |
|
555 iStoreConfiguration.DefaultSavingStoreL(); |
|
556 const TInt supportedCount = supportedConfiguration->Count(); |
|
557 for (TInt i = 0; i < supportedCount; ++i ) |
|
558 { |
|
559 TVPbkContactStoreUriPtr supportedStore = (*supportedConfiguration)[i]; |
|
560 TBool isDefault( |
|
561 defaultStore.Compare( |
|
562 supportedStore, |
|
563 TVPbkContactStoreUriPtr::EContactStoreUriAllComponents) == 0 ); |
|
564 |
|
565 if ( !currentConfiguration->IsIncluded( supportedStore ) && !isDefault ) |
|
566 { |
|
567 // close stores that are not part of the current configuration |
|
568 // check whether the supported store is loaded |
|
569 MVPbkContactStore* store = storeList.Find(supportedStore); |
|
570 if (store) |
|
571 { |
|
572 // Close all which are not needed anymore |
|
573 store->Close( *this ); |
|
574 |
|
575 // remove the store from the open store list if it is there |
|
576 const TInt index = iOpenedStores.Find(store); |
|
577 if (index != KErrNotFound) |
|
578 { |
|
579 iOpenedStores.Remove(index); |
|
580 } |
|
581 } |
|
582 } |
|
583 } |
|
584 |
|
585 CleanupStack::PopAndDestroy( 2 ); // currentConfiguration, |
|
586 // supportedConfiguration |
|
587 } |
|
588 |
|
589 // -------------------------------------------------------------------------- |
|
590 // CPbk2StoreManager::HandleSavingStoreChangedL |
|
591 // -------------------------------------------------------------------------- |
|
592 // |
|
593 void CPbk2StoreManager::HandleSavingStoreChangedL() |
|
594 { |
|
595 CVPbkContactStoreUriArray* supportedConfiguration = |
|
596 iStoreConfiguration.SupportedStoreConfigurationL(); |
|
597 CleanupStack::PushL(supportedConfiguration); |
|
598 |
|
599 MVPbkContactStoreList& storeList = iContactManager.ContactStoresL(); |
|
600 const TInt supportedCount = supportedConfiguration->Count(); |
|
601 for ( TInt i = 0; i < supportedCount; ++i ) |
|
602 { |
|
603 TVPbkContactStoreUriPtr supportedStore = (*supportedConfiguration)[i]; |
|
604 if ( supportedStore.Compare( |
|
605 iStoreConfiguration.DefaultSavingStoreL(), |
|
606 TVPbkContactStoreUriPtr::EContactStoreUriAllComponents) == 0) |
|
607 { |
|
608 // load the plugin if it isnt loaded |
|
609 if ( !storeList.Find(supportedStore)) |
|
610 { |
|
611 iContactManager.LoadContactStoreL(supportedStore); |
|
612 } |
|
613 // if the saving store is not open, then open it |
|
614 MVPbkContactStore* store = storeList.Find(supportedStore); |
|
615 if (store && iOpenedStores.Find(store) == KErrNotFound) |
|
616 { |
|
617 store->OpenL(*this); |
|
618 break; // the default has been loaded so break the loop |
|
619 } |
|
620 } |
|
621 } |
|
622 |
|
623 CleanupStack::PopAndDestroy(); // supportedConfiguration |
|
624 } |
|
625 |
|
626 // -------------------------------------------------------------------------- |
|
627 // CPbk2StoreManager::IsStoreOpen |
|
628 // -------------------------------------------------------------------------- |
|
629 // |
|
630 TBool CPbk2StoreManager::IsStoreOpen |
|
631 ( MVPbkContactStore& aContactStore ) const |
|
632 { |
|
633 TBool ret = EFalse; |
|
634 if ( iOpenedStores.Find( &aContactStore ) >= 0 ) |
|
635 { |
|
636 ret = ETrue; |
|
637 } |
|
638 return ret; |
|
639 } |
|
640 |
|
641 // -------------------------------------------------------------------------- |
|
642 // CPbk2StoreManager::ReplaceStoreL |
|
643 // -------------------------------------------------------------------------- |
|
644 // |
|
645 void CPbk2StoreManager::ReplaceStoreL |
|
646 ( MVPbkContactStore& aContactStore ) |
|
647 { |
|
648 // Display corrupted note |
|
649 CAknNoteWrapper* note = new ( ELeave ) CAknNoteWrapper; |
|
650 note->ExecuteLD( R_PBK2_NOTE_DATABASE_CORRUPTED ); |
|
651 |
|
652 // Replace database |
|
653 aContactStore.ReplaceL( *this ); |
|
654 } |
|
655 |
|
656 // End of File |