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