|
1 /* |
|
2 * Copyright (c) 2005 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: This interface is used by UI to access network services i.e. |
|
15 * sending messages and joining to groups e.g. This class is |
|
16 * also used to get different interfaces to the services |
|
17 * offered by the CCAEngine.dll. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 #ifndef CCAENGINE_H |
|
23 #define CCAENGINE_H |
|
24 |
|
25 // INCLUDES |
|
26 #include "PublicEngineDefinitions.h" |
|
27 #include "MCASettingsObserver.h" |
|
28 #include "MCASearchObserverInterface.h" |
|
29 #include "MCABackgroundTask.h" |
|
30 #include "MCABackgroundObserver.h" |
|
31 #include "MCAMessageUtils.h" |
|
32 #include "MCABackgroundTaskObserver.h" |
|
33 |
|
34 #include <e32base.h> |
|
35 #include <ImpsClient.h> |
|
36 #include <ImpsFundamental.h> |
|
37 #include <PEngWVServices2.h> |
|
38 |
|
39 // FORWARD DECLARATIONS |
|
40 class CCAGroupManager; |
|
41 class MCAPresence; |
|
42 class CCASearchManager; |
|
43 class CCABlockingManager; |
|
44 class CCASettingsManager; |
|
45 class CCAInviteManager; |
|
46 class CCAPartialSuccessData; |
|
47 class CCARequestMapper; |
|
48 class MCAError; |
|
49 class MCASearchInterface; |
|
50 class MCAPresence; |
|
51 class MCAInvite; |
|
52 class MCABlocking; |
|
53 class MCASettings; |
|
54 class MCAImpsImClient; |
|
55 class MCAImpsGroupClient; |
|
56 class MCAImpsFundClient; |
|
57 class MCAStoredGroups; |
|
58 class MCAGroupManagerInterface; |
|
59 class MCABackgroundInterface; |
|
60 class CCAStorageObserver; |
|
61 class TCALoggerMessageFactory; |
|
62 class MCALoggerHeadersInterface; |
|
63 class CCAImageLoader; |
|
64 class CCAContactListModel; |
|
65 |
|
66 class MCAChatInterface; |
|
67 class CCAChatContainer; |
|
68 class CCAMessageHandler; |
|
69 class CCAMessageCreator; |
|
70 |
|
71 class CPEngNWSessionSlotID2; |
|
72 class MCAAccessInterface; |
|
73 class CCAAccessManager; |
|
74 class MCAContactListModel; |
|
75 |
|
76 class MCABackgroundTaskObserver; |
|
77 struct SServerPrefers; |
|
78 |
|
79 /** |
|
80 * CCAEngine provides one of the interfaces to the engine. |
|
81 * This interface is used by UI to access network services i.e. |
|
82 * sending messages and joining to groups e.g. This class is |
|
83 * also used to get different interfaces to the services |
|
84 * offered by the CCAEngine.dll. |
|
85 * |
|
86 * @lib CAEngine.lib |
|
87 * @since 1.2 |
|
88 */ |
|
89 class CCAEngine : public CBase, |
|
90 public MCABackgroundTask, |
|
91 public MCABackgroundObserver, |
|
92 public MCAMessageUtils, |
|
93 private MImpsErrorHandler2, |
|
94 private MCASettingsObserver, |
|
95 private MCASearchObserverInterface |
|
96 { |
|
97 public: // Structures and enumerations |
|
98 |
|
99 public: // Constructors and destructor |
|
100 |
|
101 /** |
|
102 * Two-phased constructor. |
|
103 * @param aAppUid is the application's UID. |
|
104 */ |
|
105 IMPORT_C static CCAEngine* NewL( TUid aAppUid ); |
|
106 |
|
107 /** |
|
108 * Destructor. |
|
109 */ |
|
110 IMPORT_C virtual ~CCAEngine(); |
|
111 |
|
112 public: // Settings related functions |
|
113 |
|
114 /** |
|
115 * Gets internal settings handling interface. |
|
116 * @return Pointer to internal settings handler. |
|
117 */ |
|
118 IMPORT_C MCASettings* GetInternalSettingsInterface() const; |
|
119 |
|
120 public: // Search related functions |
|
121 |
|
122 /** |
|
123 * Gets search handling interface. |
|
124 * @return Pointer to the search handler. |
|
125 */ |
|
126 IMPORT_C MCASearchInterface* GetSearchInterface() const; |
|
127 |
|
128 public: // Invite related functions |
|
129 |
|
130 /** |
|
131 * Get invite related functions. |
|
132 * @return Pointer to the invite interface. |
|
133 */ |
|
134 IMPORT_C MCAInvite* GetInvitationInterface() const; |
|
135 |
|
136 public: // Blocking related functions |
|
137 |
|
138 /** |
|
139 * Get blocking handling interface. |
|
140 * @return Pointer to the blocking interface. |
|
141 */ |
|
142 IMPORT_C MCABlocking* GetBlockingInterface() const; |
|
143 |
|
144 public: // Imps fund client accessor |
|
145 |
|
146 /** |
|
147 * Get Imps fundamental client |
|
148 * @return Pointer to the Imps fundamental client |
|
149 */ |
|
150 IMPORT_C MCAImpsFundClient* GetFundClientInterface() const; |
|
151 |
|
152 public: // Access interface |
|
153 |
|
154 /** |
|
155 * Get Imps access interface |
|
156 */ |
|
157 IMPORT_C MCAAccessInterface* GetAccessInterface() const; |
|
158 |
|
159 public: |
|
160 |
|
161 /** |
|
162 * Get interface for contact list model |
|
163 */ |
|
164 IMPORT_C MCAContactListModel& ContactListModel() const; |
|
165 |
|
166 |
|
167 /** |
|
168 * Get interface for message handling. |
|
169 */ |
|
170 IMPORT_C MCAChatInterface& ChatInterface() const; |
|
171 |
|
172 /** |
|
173 * Get interface to message utils like messagecreator etc. |
|
174 */ |
|
175 IMPORT_C const MCAMessageUtils& MessageUtils() const; |
|
176 |
|
177 public: // Database interfaces |
|
178 |
|
179 /** |
|
180 * Get group interface. |
|
181 * @return Pointer to the group interface. |
|
182 */ |
|
183 IMPORT_C MCAGroupManagerInterface* GetGroupInterface() const; |
|
184 |
|
185 |
|
186 public: // Background specific functions |
|
187 |
|
188 /** |
|
189 * Get Background interface. |
|
190 * @return Pointer to the Background interface. |
|
191 */ |
|
192 IMPORT_C MCABackgroundInterface* BackgroundInterface() const; |
|
193 |
|
194 public: // From MCABackgroundTask |
|
195 |
|
196 /** |
|
197 * Handler for the background task event |
|
198 * @see MCABackgroundTask |
|
199 */ |
|
200 void HandleBackgroundTaskL( TInt aSubTask ); |
|
201 |
|
202 public: // From MCABackgroundObserver |
|
203 /** |
|
204 * Observers background task events |
|
205 * @see MCABackgroudObserver::HandleBackgroundEvent |
|
206 */ |
|
207 void HandleBackgroundEvent( |
|
208 MCABackgroundInterface::TCABackgroundTasks aEventSource, |
|
209 MCABackgroundInterface::TCABackgroundStatus aStatus, |
|
210 TInt aSubTaskNumber, |
|
211 TInt aLeaveCode |
|
212 ); |
|
213 |
|
214 private: // From MCAMessageUtils |
|
215 |
|
216 /** |
|
217 * @see MCAMessageUtils |
|
218 */ |
|
219 MCAMessageCreator& MessageCreator() const; |
|
220 |
|
221 /** |
|
222 * @see MCAMessageUtils |
|
223 */ |
|
224 MCAMessageErrorInformer& MessageErrorInformer() const; |
|
225 |
|
226 /** |
|
227 * @see MCAMessageUtils |
|
228 */ |
|
229 MCAContentProcessor& ImageScaler() const; |
|
230 |
|
231 /** |
|
232 * @see MCAMessageUtils |
|
233 */ |
|
234 MCABufferMemoryHandler& MemoryHandler() const; |
|
235 |
|
236 public: // New functions |
|
237 |
|
238 /** |
|
239 * Handles engine logic in login/logout events. |
|
240 * @param aLoggedIn If new state is online. |
|
241 * @param aNewUSerID specifies the new wv id. |
|
242 * @param aServerPrefers. Some preferred states like enable/disable |
|
243 * grantlist etc. |
|
244 */ |
|
245 IMPORT_C void HandleNetworkStateChangeL( |
|
246 TNetworkState aState, |
|
247 TPEngWVCspServicesTree2* aServicesSupported, |
|
248 const SServerPrefers& aServerPrefers, |
|
249 CPEngNWSessionSlotID2* aSessionSlotID = NULL ); |
|
250 |
|
251 /** |
|
252 * Returns the latest operations partially successful error codes. |
|
253 * @return Holds an array of error codes. |
|
254 */ |
|
255 IMPORT_C const RPointerArray<MCAError>* PartialSuccessData() const; |
|
256 |
|
257 /** |
|
258 * Checks CAEngine if its ready for shutdown. |
|
259 * @return ETrue if ready. |
|
260 */ |
|
261 IMPORT_C TBool ReadyForShutdown(); |
|
262 |
|
263 /** |
|
264 * Cancels pending requests in request mapper. |
|
265 */ |
|
266 IMPORT_C void CancelAllRequests(); |
|
267 |
|
268 /** |
|
269 * Get logger headers interface |
|
270 * @return pointer to logger header access. |
|
271 */ |
|
272 IMPORT_C MCALoggerHeadersInterface* GetLoggerHeadersInterface(); |
|
273 |
|
274 /** |
|
275 * Finalize the engine construction. It's done in two phases |
|
276 * for performance reasons. We need to delay the initialization |
|
277 * of IMPS Engine until after the login query, to appear fast. |
|
278 */ |
|
279 IMPORT_C void FinalizeEngineConstructionL(); |
|
280 |
|
281 /** |
|
282 * Check if engine is fully finalized |
|
283 * This should be checked before accessing the interfaces |
|
284 */ |
|
285 IMPORT_C TBool IsFinalized(); |
|
286 |
|
287 /** |
|
288 * Register to receive notifications related to |
|
289 * start and completetion of background task |
|
290 * @param MCABackGroundTaskObserver- object |
|
291 */ |
|
292 IMPORT_C void RegisterBackGroundTaskObserver( MCABackGroundTaskObserver* aObserver ); |
|
293 |
|
294 /** |
|
295 * UnRegister from receiving notifications related to |
|
296 * start and completetion of backgroundtask |
|
297 */ |
|
298 IMPORT_C void UnRegisterBackGroundTaskObserver( MCABackGroundTaskObserver* aObserver ); |
|
299 |
|
300 /** |
|
301 * To know whether Background task has started |
|
302 * @return TBool |
|
303 */ |
|
304 IMPORT_C TBool IsBackgroundTaskPending(); |
|
305 |
|
306 |
|
307 |
|
308 IMPORT_C void ResetLoggers(); |
|
309 |
|
310 |
|
311 private: // Functions from MImpsErrorHandler |
|
312 |
|
313 /** |
|
314 * From MImpsErrorHandler. |
|
315 * @see MImpsErrorHandler::HandleErrorL |
|
316 */ |
|
317 void HandleErrorL( TInt aStatus, |
|
318 TInt aOpId, |
|
319 const TDesC* aDescription, |
|
320 const CImpsDetailed* aDetailedRes, |
|
321 TImpsCspIdentifier& aCspId ); |
|
322 |
|
323 private: // From MCASettingsObserver |
|
324 |
|
325 /** |
|
326 * Handles setting changes. |
|
327 * @param aChangedSettingEnum specifies the changed setting. |
|
328 */ |
|
329 void HandleSettingsChangeL( TInt aChangedSettingEnum ); |
|
330 |
|
331 private: // from MCASearchObserverInterface |
|
332 |
|
333 /** |
|
334 * @see MCASearchObserverInterface::HandleSearchError |
|
335 */ |
|
336 void HandleSearchError( TInt aErrorCode ); |
|
337 |
|
338 /** |
|
339 * @see MCASearchObserverInterface::HandleSearchFinished |
|
340 */ |
|
341 void HandleSearchFinished(); |
|
342 |
|
343 private: // new methods |
|
344 |
|
345 |
|
346 /** |
|
347 * Notifies the observers of group synchronisation |
|
348 * @param aCompleted - ETrue if group synchro is complete else EFalse |
|
349 */ |
|
350 //void NotifyGroupSyncObservers(MCABackgroundTaskObserver::TCAGroupSyncEventType aCompleted) ; |
|
351 /** |
|
352 * Prepares and starts the synchronizing process if search |
|
353 * service available. |
|
354 * @param aServicesSupported The supported imps services |
|
355 */ |
|
356 void SynchronizeGroupsL( TPEngWVCspServicesTree2* aServicesSupported ); |
|
357 |
|
358 /** |
|
359 * Handler for finished searches |
|
360 */ |
|
361 void DoHandleSearchFinishedL(); |
|
362 |
|
363 /** |
|
364 * Synchronize the storage with the groups created by the user |
|
365 * (in this server). This method is asynchronous, although there |
|
366 * is a small delay when calling the initial search. |
|
367 */ |
|
368 void StartSynchronizeGroupsL(); |
|
369 |
|
370 /** |
|
371 * Stop the synchronization of groups created by the user |
|
372 * (in this server). Use this to force stop the StartSynchronizeGroupsL. |
|
373 */ |
|
374 void StopSynchronizeGroupsL(); |
|
375 |
|
376 private: |
|
377 |
|
378 /** |
|
379 * By default Symbian OS constructor is private. |
|
380 */ |
|
381 void ConstructL(); |
|
382 |
|
383 /** |
|
384 * C++ default constructor. |
|
385 * @see CCAEngine::NewL. |
|
386 */ |
|
387 CCAEngine( TUid aAppUid ); |
|
388 |
|
389 private: // Data |
|
390 |
|
391 // Owns (unless otherwise noted)/////////////////////////////////////// |
|
392 MCAPresence* iPresenceManager; |
|
393 CCASettingsManager* iSettingsManager; |
|
394 MCAImpsImClient* iImpsImServer; |
|
395 MCAImpsGroupClient* iImpsGroupServer; |
|
396 MCAImpsFundClient* iImpsFundAPI; |
|
397 CCASearchManager* iSearchManager; |
|
398 CCABlockingManager* iBlockingManager; |
|
399 CCAInviteManager* iInviteManager; |
|
400 CCARequestMapper* iRequestMapper; |
|
401 CCAStorageObserver* iStorageObserver; |
|
402 CCAGroupManager* iGroupManager; |
|
403 CCAAccessManager* iAccessManager; |
|
404 |
|
405 CCAChatContainer* iChatContainer; |
|
406 CCAMessageHandler* iMessageHandler; |
|
407 CCAMessageCreator* iMessageCreator; |
|
408 CCAImageLoader* iImageLoader; |
|
409 CCAContactListModel* iContactListModel; |
|
410 // //////////////////////////////////////////////////////////////////// |
|
411 |
|
412 // not owned (from Storage Manager) |
|
413 MCAStoredGroups* iStoredGroups; |
|
414 |
|
415 // Application UID received from the Application UI |
|
416 TUid iAppUid; |
|
417 |
|
418 // Owns |
|
419 CCAPartialSuccessData* iPartialSuccessData; |
|
420 |
|
421 // group synchronizing |
|
422 TInt iSearchResults; |
|
423 HBufC* iLoggedUserId; // owns |
|
424 CSearchPairs* iPairs; // owns |
|
425 CImpsSearchRequest* iRequest; // owns |
|
426 |
|
427 // protection from bogus network state changes, finite state machine |
|
428 // logic is inside HandleNetworkStateChangeL |
|
429 TNetworkState iState; |
|
430 |
|
431 // This is passed to MCALoggerReadInterface when instance called. |
|
432 // Pointer to T-class is used so that we do not have to include |
|
433 // header of TCALoggerMessageFactory in this header file. |
|
434 TCALoggerMessageFactory* iLoggerMessageFactory; |
|
435 |
|
436 //Interface to access logger headers. Owns |
|
437 MCALoggerHeadersInterface* iLoggerHeadersInterface; |
|
438 |
|
439 // ETrue when the engine has been fully constructed |
|
440 TBool iFullyConstructed; |
|
441 |
|
442 TBool iGroupSynchronizing; |
|
443 |
|
444 |
|
445 }; |
|
446 |
|
447 #endif // CCAEngine_H |
|
448 |
|
449 // End of File |