17 |
17 |
18 |
18 |
19 #ifndef CMCSPLUGINENGINE_H |
19 #ifndef CMCSPLUGINENGINE_H |
20 #define CMCSPLUGINENGINE_H |
20 #define CMCSPLUGINENGINE_H |
21 |
21 |
22 // INCLUDE FILES |
22 // System includes |
23 #include <e32base.h> |
23 #include <e32base.h> |
24 #include <mcsmenu.h> |
24 #include <mcsmenu.h> |
25 #include <mcsmenunotifier.h> |
25 #include <mcsmenunotifier.h> |
26 #include <favouritesdbobserver.h> // For MFavouritesDbObserver |
26 #include <mcsmenuitem.h> |
27 #include <favouritesdb.h> // For RFavouritesDb |
27 #include <msvapi.h> |
28 #include <msvapi.h> // For MMsvSessionObserver |
28 |
29 |
29 // User includes |
30 #include "mcspluginwatcher.h" |
30 #include "mcspluginwatcher.h" |
31 |
31 |
|
32 // Forward declarations |
32 class CGulIcon; |
33 class CGulIcon; |
33 class CMCSPluginData; |
34 class CMCSPluginData; |
34 class TMCSData; |
35 class TMCSData; |
35 class CMCSPlugin; |
36 class CMCSPlugin; |
36 class CActiveFavouritesDbNotifier; |
|
37 |
37 |
38 /** |
38 /** |
39 * @ingroup group_mcsplugin |
39 * @ingroup group_mcsplugin |
40 * |
40 * |
41 * MCSPluginEngine class |
41 * MCSPluginEngine class |
42 * |
42 * |
43 * @since S60 9.1 |
43 * @since S60 5.2 |
44 */ |
44 */ |
45 class CMCSPluginEngine : public CBase, public MMCSPluginWatcherObserver, |
45 NONSHARABLE_CLASS( CMCSPluginEngine ) : public CBase, |
46 public MFavouritesDbObserver, public MMsvSessionObserver |
46 public MMCSPluginWatcherObserver, |
47 { |
47 public MMsvSessionObserver |
48 |
48 { |
49 public: // Constructors and destructor |
49 public: |
50 |
50 // constructor and destructor |
51 /** |
|
52 * Constructor to use in the object creation. Initializes the necessary |
|
53 * data. |
|
54 * |
|
55 * @param aPlugin |
|
56 * @param aInstanceUid |
|
57 */ |
|
58 CMCSPluginEngine( CMCSPlugin& aPlugin, const TDesC8& aInstanceUid ); |
|
59 |
51 |
60 /** |
52 /** |
61 * Part of the two phased constuction |
53 * Part of the two phased constuction |
62 * |
54 * |
63 * @param aPlugin |
55 * @param aPlugin |
73 * @param none |
65 * @param none |
74 * @return none |
66 * @return none |
75 */ |
67 */ |
76 ~CMCSPluginEngine(); |
68 ~CMCSPluginEngine(); |
77 |
69 |
78 /** |
70 private: |
79 * Gets the menu data. |
71 // constructors |
80 * |
72 |
81 * @param aIndex |
73 /** |
82 * @return TMCSData& |
74 * C++ default constructor |
83 */ |
75 */ |
84 TMCSData& MenuDataL( const TInt& aIndex ); |
76 CMCSPluginEngine( CMCSPlugin& aPlugin, const TDesC8& aInstanceUid ); |
85 |
77 |
86 /** Gets the menu item count |
78 /* |
87 * |
79 * 2nd phase constructor |
88 * @return TInt |
80 */ |
89 */ |
81 void ConstructL(); |
90 TInt MenuItemCount(); |
82 |
91 |
83 public: |
92 /** |
84 // new functions |
93 * Finds the menu item header for given filter. |
85 |
94 * |
|
95 * @param aFilter |
|
96 * @return TMenuItem |
|
97 */ |
|
98 TMenuItem FindMenuItemL( CMenuFilter& aFilter ); |
|
99 |
|
100 /** |
|
101 * Retrieves the menu item object from MCS. |
|
102 * |
|
103 * @param aMenuItem |
|
104 * @return CMenuItem* |
|
105 */ |
|
106 CMenuItem* FetchMenuItemL( const TMenuItem& aMenuItem ); |
|
107 |
|
108 /** |
|
109 * Returns icon for given menu item and given attribute |
|
110 * |
|
111 * @param aMenuItem |
|
112 * @param aAttr |
|
113 * @return CGulIcon* |
|
114 */ |
|
115 CGulIcon* ItemIconL( CMenuItem& aMenuItem, const TDesC& aAttr ); |
|
116 |
|
117 /** |
|
118 * Returns text for given menu item and given attribute |
|
119 * |
|
120 * @param aMenuItem |
|
121 * @param aAttr |
|
122 */ |
|
123 TPtrC ItemTextL( CMenuItem& aMenuItem, const TDesC& aAttr ); |
|
124 |
|
125 /** |
|
126 * Launches menu item |
|
127 * |
|
128 * @param aIndex |
|
129 */ |
|
130 void LaunchItemL( const TInt& aIndex ); |
|
131 |
|
132 /** |
|
133 * Resumes the engine |
|
134 * |
|
135 * @param void |
|
136 * @return void |
|
137 */ |
|
138 void ResumeL(); |
|
139 |
|
140 /** |
|
141 * Suspends the engine |
|
142 * |
|
143 * @param void |
|
144 * @return void |
|
145 */ |
|
146 void Suspend(); |
|
147 |
|
148 /** |
|
149 * ShowSettingsL |
|
150 */ |
|
151 void ShowSettingsL(); |
|
152 |
|
153 /** |
|
154 * From MMCSPluginWatcherObserver |
|
155 */ |
|
156 void HandleNotifyL(); |
|
157 |
|
158 // From MFavouritesDbObserver |
|
159 /** |
|
160 * Handles database event. |
|
161 * @param aEvent Database event. |
|
162 */ |
|
163 void HandleFavouritesDbEventL( RDbNotifier::TEvent aEvent ); |
|
164 |
|
165 // from base class MMsvSessionObserver |
|
166 /** |
|
167 * Handles an event from the message server. |
|
168 * Not used, but must be defined to be able to use the messaging server. |
|
169 * |
|
170 * @since S60 v3.2 |
|
171 * @param aEvent Indicates the event type. |
|
172 * @param aArg1 Event type-specific argument value |
|
173 * @param aArg2 Event type-specific argument value |
|
174 * @param aArg3 Event type-specific argument value |
|
175 */ |
|
176 void HandleSessionEventL( TMsvSessionEvent aEvent, TAny* aArg1, |
|
177 TAny* aArg2, TAny* aArg3 ); |
|
178 |
|
179 /** |
86 /** |
180 * Called during plugin desctruction |
87 * Called during plugin desctruction |
181 * Decrements reference counters of all run-time generated items |
88 * Decrements reference counters of all run-time generated items |
182 * and deletes those which have reference counter == 0 |
89 * and deletes those which have reference counter == 0 |
183 */ |
90 */ |
184 void CleanMCSItemsL(); |
91 void CleanMCSItemsL(); |
185 |
92 |
186 private: |
93 /** |
187 /* |
94 * Gets the menu data. |
188 * Part of the two phased construction |
95 * |
189 */ |
96 * @param aIndex |
190 void ConstructL(); |
97 * @return TMCSData& |
|
98 */ |
|
99 TMCSData& MenuDataL( const TInt& aIndex ); |
|
100 |
|
101 /** Gets the menu item count |
|
102 * |
|
103 * @return TInt |
|
104 */ |
|
105 TInt MenuItemCount(); |
|
106 |
|
107 /** |
|
108 * Finds the menu item header for given filter. |
|
109 * |
|
110 * @param aFilter |
|
111 * @return TMenuItem |
|
112 */ |
|
113 TMenuItem FindMenuItemL( CMenuFilter& aFilter ); |
|
114 |
|
115 /** |
|
116 * Retrieves the menu item object from MCS. |
|
117 * |
|
118 * @param aMenuItem |
|
119 * @return CMenuItem* |
|
120 */ |
|
121 CMenuItem* FetchMenuItemL( const TMenuItem& aMenuItem ); |
|
122 |
|
123 /** |
|
124 * Returns icon for given menu item and given attribute |
|
125 * |
|
126 * @param aMenuItem |
|
127 * @param aAttr |
|
128 * @return CGulIcon* |
|
129 */ |
|
130 CGulIcon* ItemIconL( CMenuItem& aMenuItem, const TDesC& aAttr ); |
|
131 |
|
132 /** |
|
133 * Returns text for given menu item and given attribute |
|
134 * |
|
135 * @param aMenuItem |
|
136 * @param aAttr |
|
137 */ |
|
138 TPtrC ItemTextL( CMenuItem& aMenuItem, const TDesC& aAttr ); |
|
139 |
|
140 /** |
|
141 * Launches menu item |
|
142 * |
|
143 * @param aIndex |
|
144 */ |
|
145 void LaunchItemL( const TInt& aIndex ); |
|
146 |
|
147 /** |
|
148 * Set backup/restore state |
|
149 * |
|
150 * @param aBackupRestore ETrue if backup/restore is ongoing |
|
151 * @return void |
|
152 */ |
|
153 void SetBackupRestore( TBool aBackupRestore ); |
|
154 |
|
155 /** |
|
156 * ShowSettingsL |
|
157 */ |
|
158 void ShowSettingsL(); |
|
159 |
|
160 private: |
|
161 // from MMCSPluginWatcherObserver |
|
162 |
|
163 /** |
|
164 * @see MMCSPluginWatcherObserver |
|
165 */ |
|
166 void HandleNotifyL(); |
|
167 |
|
168 private: |
|
169 // from MMsvSessionObserver |
|
170 |
|
171 /** |
|
172 * @see MMsvSessionObserver |
|
173 */ |
|
174 void HandleSessionEventL( TMsvSessionEvent aEvent, TAny* aArg1, |
|
175 TAny* aArg2, TAny* aArg3 ); |
|
176 |
|
177 private: |
|
178 // new functions |
191 |
179 |
192 /** |
180 /** |
193 * InitL |
181 * InitL |
194 */ |
182 */ |
195 void InitL(); |
183 void InitL(); |
196 |
184 |
197 /** |
185 /** |
198 * Tells the settings container to start observing for changes in favorites |
186 * Tells the settings container to start observing |
199 * database and mailbox db. |
187 * for changes in mailbox db. |
200 * |
|
201 */ |
188 */ |
202 void StartObservingL(); |
189 void StartObservingL(); |
203 |
190 |
204 /** |
191 /** |
205 * Tells the settings container to stop observing for changes in favorites |
192 * Tells the settings container to stop observing |
206 * database and mailbox db. |
193 * for changes in mailbox db. |
207 * |
|
208 */ |
194 */ |
209 void StopObserving(); |
195 void StopObserving(); |
210 |
196 |
211 /** |
197 /** |
212 * ConstructMenuItemForIconL |
198 * ConstructMenuItemForIconL |
213 * |
199 * |
214 * @param aPath |
200 * @param aPath |
215 * @param aMenuItem |
201 * @param aMenuItem |
216 * @return TBool |
202 * @return TBool |
217 */ |
203 */ |
218 TBool ConstructMenuItemForIconL( const TDesC& aPath, CMenuItem& aMenuItem ); |
204 TBool ConstructMenuItemForIconL( |
|
205 const TDesC& aPath, CMenuItem& aMenuItem ); |
219 |
206 |
220 /** |
207 /** |
221 * Helper method. Adds a given constant to a value of reference counter |
208 * Helper method. Adds a given constant to a value of reference counter |
222 * |
209 * |
223 * @param aItem A Menu Item to update |
210 * @param aItem A Menu Item to update |
224 * @param aValueToAdd A constant to add |
211 * @param aValueToAdd A constant to add |
225 * @return The actual value of updated reference count |
212 * @return The actual value of updated reference count |
226 */ |
213 */ |
227 TInt UpdateMenuItemsRefCountL( CMenuItem* aItem, const TInt aValueToAdd ); |
214 TInt UpdateMenuItemsRefCountL( |
228 |
215 CMenuItem* aItem, const TInt aValueToAdd ); |
229 protected: |
216 |
230 |
217 private: |
231 private: |
218 // data |
232 |
219 |
233 /* Plugin data |
220 /** Plugin data, owned */ |
234 * Own |
|
235 */ |
|
236 CMCSPluginData* iPluginData; |
221 CMCSPluginData* iPluginData; |
237 |
222 /** MCS resource handle, owned */ |
238 // MCS resource |
|
239 RMenu iMenu; |
223 RMenu iMenu; |
240 |
224 /** MCS change notifier handle, owned */ |
241 // MCS change notifier |
|
242 RMenuNotifier iNotifier; |
225 RMenuNotifier iNotifier; |
243 |
226 /** MCS asynchronous operation watcher, owned */ |
244 // MCS asynchronous operation watcher |
|
245 CMCSPluginWatcher* iWatcher; |
227 CMCSPluginWatcher* iWatcher; |
246 |
228 /** MCS change notifier watcher, owned */ |
247 // MCS change notifier watcher |
|
248 CMCSPluginWatcher* iNotifyWatcher; |
229 CMCSPluginWatcher* iNotifyWatcher; |
249 |
230 /** MCS plugin, not owned */ |
250 // |
|
251 CMCSPlugin& iPlugin; |
231 CMCSPlugin& iPlugin; |
252 |
232 /** Reference to plugin owned instanceUid */ |
253 // Reference to plugin owned instanceUid |
|
254 const TDesC8& iInstanceUid; |
233 const TDesC8& iInstanceUid; |
255 // Indicating that backup is in progress |
234 /** Flag Indicating that backup/restore is in progress */ |
256 TBool iSuspend; |
235 TBool iBackupRestore; |
257 //Offset of resource file. |
236 /** Offset of resource file */ |
258 TInt iResourceOffset; |
237 TInt iResourceOffset; |
259 |
238 /** Message server session, owned */ |
260 /** |
239 CMsvSession* iMsvSession; |
261 * Bookmark database change observer. |
240 /** "Undefined" menu item, owned */ |
262 * Own. |
241 CMenuItem* iUndefinedItem; |
263 */ |
242 /** "Undefined" menu item header */ |
264 CActiveFavouritesDbNotifier* iBookmarkDbObserver; |
243 TMenuItem iUndefinedItemHeader; |
265 |
244 }; |
266 /** |
|
267 * Bookmark database. |
|
268 */ |
|
269 RFavouritesDb iBookmarkDb; |
|
270 |
|
271 /** |
|
272 * Bookmark database session. |
|
273 */ |
|
274 RFavouritesSession iBookmarkSession; |
|
275 |
|
276 /** |
|
277 * Message server session |
|
278 * Own. |
|
279 */ |
|
280 CMsvSession* iMsvSession; |
|
281 }; |
|
282 |
245 |
283 #endif // CMCSPLUGINENGINE_H |
246 #endif // CMCSPLUGINENGINE_H |
284 |
247 |
285 |
248 // End of file |
|
249 |