|
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 start-up monitor. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPBK2STARTUPMONITOR_H |
|
20 #define CPBK2STARTUPMONITOR_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <badesca.h> |
|
25 #include <MPbk2StartupMonitor.h> |
|
26 #include <MVPbkContactStoreObserver.h> |
|
27 #include <MVPbkContactViewObserver.h> |
|
28 #include <MPbk2ProcessDecorator.h> |
|
29 #include <TVPbkContactStoreUriPtr.h> |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class MPbk2AppUiExtension; |
|
33 class CVPbkContactStoreUriArray; |
|
34 class CPbk2StorePropertyArray; |
|
35 class CPbk2StoreConfiguration; |
|
36 class CVPbkContactManager; |
|
37 |
|
38 // CLASS DECLARATION |
|
39 |
|
40 /** |
|
41 * Phonebook 2 start-up monitor. |
|
42 * Responsible for opening wanted stores and waiting that all stores |
|
43 * are open before continuing. |
|
44 */ |
|
45 class CPbk2StartupMonitor : public CBase, |
|
46 public MPbk2StartupMonitor, |
|
47 private MVPbkContactStoreObserver, |
|
48 private MVPbkContactViewObserver |
|
49 { |
|
50 public: // Constructors and destructor |
|
51 |
|
52 /** |
|
53 * Creates a new instance of this class. |
|
54 * |
|
55 * @param aAppUiExtension Application UI extension. |
|
56 * @param aStoreProperties Contact store properties. |
|
57 * @param aStoreConfiguration Contact store configuration. |
|
58 * @param aContactManager Virtual Phonebook contact manager. |
|
59 * @return A new instance of this class. |
|
60 */ |
|
61 static CPbk2StartupMonitor* NewL( |
|
62 MPbk2AppUiExtension& aAppUiExtension, |
|
63 CPbk2StorePropertyArray& aStoreProperties, |
|
64 CPbk2StoreConfiguration& aStoreConfiguration, |
|
65 CVPbkContactManager& aContactManager ); |
|
66 |
|
67 /** |
|
68 * Destructor. |
|
69 */ |
|
70 virtual ~CPbk2StartupMonitor(); |
|
71 |
|
72 public: // Interface |
|
73 |
|
74 /** |
|
75 * Calls start-up begins for extensions. |
|
76 */ |
|
77 void StartupBeginsL(); |
|
78 |
|
79 /** |
|
80 * Restart monitoring. |
|
81 */ |
|
82 void RestartStartupL(); |
|
83 |
|
84 public: // From MPbk2StartupMonitor |
|
85 void HandleStartupComplete(); |
|
86 void HandleStartupFailed( |
|
87 TInt aError ); |
|
88 void RegisterEventsL( |
|
89 MPbk2StartupObserver& aObserver ); |
|
90 void DeregisterEvents( |
|
91 MPbk2StartupObserver& aObserver ); |
|
92 void NotifyViewActivationL( |
|
93 TUid aViewId ); |
|
94 void NotifyViewActivationL( |
|
95 TUid aViewId, |
|
96 MVPbkContactViewBase& aContactView ); |
|
97 |
|
98 private: // From MVPbkContactStoreObserver |
|
99 void StoreReady( |
|
100 MVPbkContactStore& aContactStore ); |
|
101 void StoreUnavailable( |
|
102 MVPbkContactStore& aContactStore, |
|
103 TInt aReason ); |
|
104 void HandleStoreEventL( |
|
105 MVPbkContactStore& aContactStore, |
|
106 TVPbkContactStoreEvent aStoreEvent ); |
|
107 |
|
108 private: // From MVPbkContactViewObserver |
|
109 void ContactViewReady( |
|
110 MVPbkContactViewBase& aView ); |
|
111 void ContactViewUnavailable( |
|
112 MVPbkContactViewBase& aView ); |
|
113 void ContactAddedToView( |
|
114 MVPbkContactViewBase& aView, |
|
115 TInt aIndex, |
|
116 const MVPbkContactLink& aContactLink ); |
|
117 void ContactRemovedFromView( |
|
118 MVPbkContactViewBase& aView, |
|
119 TInt aIndex, |
|
120 const MVPbkContactLink& aContactLink ); |
|
121 void ContactViewError( |
|
122 MVPbkContactViewBase& aView, |
|
123 TInt aError, |
|
124 TBool aErrorNotified ); |
|
125 |
|
126 private: // Implementation |
|
127 CPbk2StartupMonitor( |
|
128 MPbk2AppUiExtension& aAppUiExtension, |
|
129 CPbk2StorePropertyArray& aStoreProperties, |
|
130 CPbk2StoreConfiguration& aStoreConfiguration, |
|
131 CVPbkContactManager& aContactManager ); |
|
132 void ConstructL(); |
|
133 void AddUnavailableStoreNameL( |
|
134 const TDesC& aName ); |
|
135 void ShowUnavailableStoresL(); |
|
136 void HandleStoreUnavailableL( |
|
137 MVPbkContactStore& aContactStore ); |
|
138 void HandleStoreNotificationL( |
|
139 MVPbkContactStore& aContactStore ); |
|
140 void HandleContactViewReadyEventL( |
|
141 MVPbkContactViewBase& aContactView ); |
|
142 static TInt SendMessageToObservers( |
|
143 TAny* aSelf ); |
|
144 void HandleError( |
|
145 TInt aResult ); |
|
146 void StopWaiter(); |
|
147 void RegisterStoreEventsForViewL( |
|
148 MVPbkContactViewBase& aContactView ); |
|
149 void DeregisterStoreEventsL( |
|
150 TVPbkContactStoreUriPtr aUri ); |
|
151 void StartAsyncCompletionNotification(); |
|
152 TBool IsNativePhoneBookView( TUid aActiveViewId ); |
|
153 |
|
154 private: // Data |
|
155 /// Ref: Application UI extension |
|
156 MPbk2AppUiExtension& iAppUiExtension; |
|
157 /// Ref: Contact store properties |
|
158 CPbk2StorePropertyArray& iStoreProperties; |
|
159 /// Ref: Contact store configuration |
|
160 CPbk2StoreConfiguration& iStoreConfiguration; |
|
161 /// Ref: Virtual Phonebook contact manager |
|
162 CVPbkContactManager& iContactManager; |
|
163 /// Own: The view id of the view that is activated first |
|
164 TUid iFirstViewId; |
|
165 /// Own: Stores that are listened by the monitor |
|
166 CVPbkContactStoreUriArray* iStoreUris; |
|
167 /// Ref: An array of observers |
|
168 RPointerArray<MPbk2StartupObserver> iObservers; |
|
169 /// Own: Start-up process waiter |
|
170 class CPbk2StartupWaiter; |
|
171 CPbk2StartupWaiter* iWaiter; |
|
172 /// Own: An array of unavailable store names |
|
173 CDesCArray* iUnavailableStoreNames; |
|
174 /// Own: For notifying observers when all contacts view is ready |
|
175 CIdle* iIdleNotifier; |
|
176 }; |
|
177 |
|
178 #endif // CPBK2STARTUPMONITOR_H |
|
179 |
|
180 // End of File |