|
1 /* |
|
2 * Copyright (c) 2006 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: Implementation for PC Search Interface |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CCASEARCHINTERFACEPC_H |
|
20 #define CCASEARCHINTERFACEPC_H |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 #include "MCASearchInterfacePC.h" |
|
25 #include "MCABackgroundObserver.h" |
|
26 |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class MCASearchBackgroundObserverPC; |
|
30 class MCASearchInterface; |
|
31 class MCASearchObserverInterfacePC; |
|
32 class MCAGroupManagerInterface; |
|
33 class MCAStoredGroups; |
|
34 |
|
35 |
|
36 //class declaration |
|
37 /** |
|
38 * Implementation class for Search Interface for the UI. |
|
39 * |
|
40 * @lib wvuiprocessng.lib |
|
41 * @since 3.2 |
|
42 */ |
|
43 class CCASearchInterfacePC: public CBase, |
|
44 public MCASearchInterfacePC, |
|
45 public MCABackgroundObserver |
|
46 |
|
47 { |
|
48 |
|
49 public: |
|
50 |
|
51 /** |
|
52 * Symbian Two Phase Constructor |
|
53 * @param aSearchInterface : a reference to search interface in the chat engine |
|
54 * @param aBackgroundInterface : a ref. to background interface in the chat engine |
|
55 * @param groupMgrInterface : a ref. to group manager interface in the chat engine |
|
56 */ |
|
57 static CCASearchInterfacePC* NewL( MCASearchInterface* aSearchInterface , |
|
58 MCABackgroundInterface& aBackgroundInterface, |
|
59 MCAGroupManagerInterface& groupMgrInterface ); |
|
60 |
|
61 |
|
62 /** |
|
63 * virtual destructor |
|
64 */ |
|
65 virtual ~CCASearchInterfacePC(); |
|
66 |
|
67 private: |
|
68 /** |
|
69 * default constructor |
|
70 * @param aSearchInterface : a reference to search interface in the chat engine |
|
71 * @param aBackgroundInterface : a ref. to background interface in the chat engine |
|
72 */ |
|
73 |
|
74 |
|
75 CCASearchInterfacePC( MCASearchInterface* aSearchInterface, |
|
76 MCABackgroundInterface& aBackgroundInterface, |
|
77 MCAGroupManagerInterface& groupMgrInterface ); |
|
78 |
|
79 /** |
|
80 * constructor |
|
81 * @since 3.2 |
|
82 */ |
|
83 void ConstructL(); |
|
84 |
|
85 public: |
|
86 |
|
87 /** |
|
88 * Find any contact which id is aContactId |
|
89 * @param aContactId Contactid to recognize contact. |
|
90 * @return ETrue if contact found else EFalse |
|
91 */ |
|
92 TBool FindAnyContactL( const TDesC& aContactId ); |
|
93 |
|
94 /** |
|
95 * To convert the engine side TCABackgroundTasks enum to PC side TEnumsPC |
|
96 * @param aEventSource: enum type in engine MCABackgroundInterface::TCABackgroundTasks |
|
97 * @return TEnumsPC::TCABackgroundTasks |
|
98 */ |
|
99 TEnumsPC::TCABackgroundTasks ConvertTCABackgroundTasksToTEnumsPC |
|
100 ( MCABackgroundInterface::TCABackgroundTasks aEventSource ); |
|
101 |
|
102 /** |
|
103 * To convert the engine side TCABackgroundStatus enum to PC side TEnumsPC |
|
104 * @param aEventSource: enum type in engine MCABackgroundInterface::TCABackgroundStatus |
|
105 * @return TEnumsPC::TCABackgroundStatus |
|
106 */ |
|
107 TEnumsPC::TCABackgroundStatus ConvertTCABackgroundStatus |
|
108 ( MCABackgroundInterface::TCABackgroundStatus aStatus ); |
|
109 |
|
110 /** |
|
111 * To convert the PC Side TEnumsPC::TCABackgroundTasks enum to Engine side TCABackgroundStatus |
|
112 * @param aSource: enum type in process TEnumsPC::TCABackgroundStatus |
|
113 * @return enum type in engine MCABackgroundInterface::TCABackgroundStatus |
|
114 */ |
|
115 MCABackgroundInterface::TCABackgroundTasks ConvertToTCABackgroundTasks |
|
116 ( TEnumsPC::TCABackgroundTasks aSource ); |
|
117 |
|
118 /** |
|
119 * To convert the PC Side TSearchCriteria enum to IMEngine side TImpsSearchElement |
|
120 * @param aElement: enum type in process TEnumsPC::TSearchCriteria |
|
121 * @return enum type in IMEngine TImpsSearchElement |
|
122 */ |
|
123 TImpsSearchElement CCASearchInterfacePC:: |
|
124 ConvertToTImpsSearchElement( TEnumsPC::TSearchCriteria aElement ); |
|
125 |
|
126 /** |
|
127 * @return a CSearchPairs pointer |
|
128 */ |
|
129 CSearchPairs* SearchPairs(); |
|
130 |
|
131 /** |
|
132 * set search pairs |
|
133 * @param aCount: specifies the number of elements |
|
134 * in the array iSearchPairs that has to be constructed |
|
135 */ |
|
136 void SetSearchPairsL( TInt aCount ); |
|
137 |
|
138 /** |
|
139 * @return ETrue if iSearchPairs is not null |
|
140 */ |
|
141 TBool IsSearchPairsSet(); |
|
142 |
|
143 /** |
|
144 * @return SearchString -string to be searched |
|
145 */ |
|
146 HBufC* GetSearchStringLC(); |
|
147 |
|
148 /** |
|
149 * Builds the search pairs and sets the search requestSet values. |
|
150 * This allocates memory and copies aValue to its internal data storage. |
|
151 * @param aSearchCriteriaArray specifies list of search criterias (search keys) |
|
152 * @param aSearchStringArray specifies array of strings to be searched(search values) |
|
153 */ |
|
154 |
|
155 void SetRequestL( RArray<TEnumsPC::TSearchCriteria>& aSearchCriteriaArray, |
|
156 CDesCArray& aSearchStringArray ); |
|
157 public://From MCABackgroundObserver |
|
158 |
|
159 /** |
|
160 * Call if an event happend that match registered task and event mask. |
|
161 * @param aEventSource is the source of event |
|
162 * @param aStatus is the status of the background task |
|
163 * @param aSubTaskNumber is the number of subtask |
|
164 * @param aLeaveCode is the leave code of the task/subtask |
|
165 */ |
|
166 void HandleBackgroundEvent( |
|
167 MCABackgroundInterface::TCABackgroundTasks aEventSource, |
|
168 MCABackgroundInterface::TCABackgroundStatus aStatus, |
|
169 TInt aSubTaskNumber, |
|
170 TInt aLeaveCode |
|
171 ); |
|
172 |
|
173 public://From MCASearchInterfacePC |
|
174 |
|
175 /** |
|
176 * @see MCASearchInterfacePC |
|
177 * To add the UI side observer for MCASearchObserverInterfacePC |
|
178 * events from the engine. |
|
179 */ |
|
180 void AddObserver( MCASearchObserverInterfacePC* aObserver ); |
|
181 |
|
182 /** |
|
183 * @see MCASearchInterfacePC |
|
184 * To remove the UI side observer for MCASearchObserverInterfacePC |
|
185 * events from the engine. |
|
186 */ |
|
187 void RemoveObserver(); |
|
188 |
|
189 /** |
|
190 * Registers observer for background task |
|
191 * @param aBackgaBackgroundObserver pointer of instance of UI component |
|
192 * @param aTaskMask is an AND mask for task requested, |
|
193 * @param aEventMask is an AND mask for events requested, |
|
194 * @return KErrNone on success, system wide error code otherwise |
|
195 */ |
|
196 TInt RegisterBackgroundObserver( |
|
197 MCASearchBackgroundObserverPC* aBackgroundObserver, |
|
198 TInt aTaskMask, |
|
199 TInt aEventMask ); |
|
200 |
|
201 /** |
|
202 * Removes observer from the queue |
|
203 * @param aBackgroundObserver pointer of instance to remove |
|
204 */ |
|
205 void UnRegisterBackgroundObserver( |
|
206 MCASearchBackgroundObserverPC* aBackgroundObserver ); |
|
207 |
|
208 /** |
|
209 * @param aTaskID is an id of a background task |
|
210 * @retrun status of the background task or KErrNotFound |
|
211 */ |
|
212 TInt BackgroundTaskStatus( TEnumsPC::TCABackgroundTasks aTaskID ); |
|
213 |
|
214 public: |
|
215 |
|
216 /** |
|
217 * @see MCASearchObserverInterface::HandleSearchError |
|
218 */ |
|
219 void HandleSearchError( TInt aErrorCode ); |
|
220 /** |
|
221 * @see MCASearchObserverInterface::HandleSearchFinished |
|
222 */ |
|
223 void HandleSearchFinished( ); |
|
224 |
|
225 |
|
226 public: |
|
227 |
|
228 /** |
|
229 * @see MCASearchInterfacePC |
|
230 * Start the search. |
|
231 * @param aSearchLimit defines how many results you want. |
|
232 * @param aObserver The observer for this search operation |
|
233 * @param aSearchPairs Pairs to be searched |
|
234 * @return Error code. |
|
235 * Leaves |
|
236 * ESearchNotSupported |
|
237 */ |
|
238 TInt StartSearchL( TInt aSearchLimit, |
|
239 MCASearchObserverInterfacePC* aObserver, |
|
240 CSearchPairs* aSearchPairs = NULL ) ; |
|
241 |
|
242 /** |
|
243 * @see MCASearchInterfacePC |
|
244 * Stops the current search. Must be called before starting new search. |
|
245 * @return Error code. |
|
246 * Leaves |
|
247 * ESearchNotSupported |
|
248 */ |
|
249 TInt EndSearchL() ; |
|
250 |
|
251 /** |
|
252 * @see MCASearchInterfacePC |
|
253 * Continues search. This function must only be called when more results |
|
254 * are wanted. |
|
255 * @param aIndex specifies the next index where to start search. |
|
256 * @param aObserver The observer for this search operation |
|
257 * @return Error code. |
|
258 * Leaves |
|
259 * ERequestedResultsButNotAvailable |
|
260 * ESearchNotSupported |
|
261 */ |
|
262 TInt SearchNextL( TInt aIndex, MCASearchObserverInterfacePC* aObserver ) ; |
|
263 |
|
264 /** |
|
265 * Gets the properties of group |
|
266 * @param The group id |
|
267 * @param aCommonProps Common group properties |
|
268 * @param aPrivateProps Private group properties |
|
269 * @return CSP error code |
|
270 */ |
|
271 virtual TEnumsPC::TImpsCSPAllErrors GetPropertiesL( const TDesC& aGroupId, |
|
272 CImpsCommonGroupProps*& aCommonProps, |
|
273 CImpsPrivateGroupProps*& aPrivateProps |
|
274 ); |
|
275 |
|
276 /** |
|
277 * To set the groupname of the group whose id is aGroupId |
|
278 * @param aGroupId: id of the group whose name has to be set |
|
279 * @param aGroupName: name of the group to be set |
|
280 */ |
|
281 virtual void SetGroupNameL( const TDesC& aGroupId, const TDesC& aGroupName ); |
|
282 |
|
283 /** |
|
284 * To create a group with group id aGroupId |
|
285 * @param aGroupId: id of the group to be created |
|
286 */ |
|
287 virtual void CreateGroupL( const TDesC& aGroupId ); |
|
288 |
|
289 /** |
|
290 * To save the changes made to a groups properties and make it persistent. Once this is done |
|
291 * the isFavorite property of the group will always return true. |
|
292 * @param aGroupId: id of the group which has to be saved |
|
293 */ |
|
294 virtual void SaveChangesL( const TDesC& aGroupId ); |
|
295 |
|
296 /** |
|
297 * To populate the two arrays of group names and goup ids |
|
298 * @param aGroupNames: array of the current group names |
|
299 * @param aGroupIds: array of the current group IDs |
|
300 */ |
|
301 virtual MCAServerContactsArrayPC* GetPairArrayForServerContactsArrayLC() ; |
|
302 |
|
303 /** |
|
304 * To set the groupname of the group whose id is aGroupId |
|
305 * @param aGroupId: id of the group which has to be searched for |
|
306 * @param bool : returns true if the group with aGroupId is found else returns false |
|
307 */ |
|
308 virtual TBool FindGroup( const TDesC& aGroupId ); |
|
309 |
|
310 /** |
|
311 * Delete the given group |
|
312 * @param aGroupId The group id of the group to delete |
|
313 * @param aDeleteFromNetwork Defines whether the group should |
|
314 * be deleted also from network server or not |
|
315 * @return The errorcode |
|
316 */ |
|
317 virtual TInt DeleteGroupL( const TDesC& aGroupId, TBool aDeleteFromNetwork ); |
|
318 |
|
319 /** |
|
320 * To get the groupname of the group whose id is aGroupId |
|
321 * @param aGroupId: of the group whose name has to be set |
|
322 * @param aHasCommonProps: Returned by reference. True if the group has common group properties |
|
323 * else return false |
|
324 * @param aImpsError: return by reference. Return the error code if any. |
|
325 */ |
|
326 virtual TPtrC GetGroupNameL( const TDesC& aGroupId, TBool& aHasCommonProps, |
|
327 TEnumsPC::TImpsCSPAllErrors& aImpsError ); |
|
328 /* |
|
329 * Get the storage type of this group and check if it is a persistent grp. |
|
330 * If the group is marked as favourite, then it will be persistent |
|
331 * @return ETrue if favourite else EFalse |
|
332 */ |
|
333 virtual TBool IsFavouriteChatGroup( const TDesC& aGroupId ) const; |
|
334 |
|
335 |
|
336 /* |
|
337 * Get the total no. of groups the user has joined too'. |
|
338 */ |
|
339 virtual TInt JoinedGroups(); |
|
340 |
|
341 private: |
|
342 |
|
343 /* |
|
344 * To convert the imps error code to the TEnumsPC type to pass in to the UI. |
|
345 * @param integer imps error code |
|
346 * @return TImpsCSPAllErrors specified in TEnumsPC |
|
347 */ |
|
348 TEnumsPC::TImpsCSPAllErrors ConvertImpsErrorToUiEnums( TInt aImpsError ); |
|
349 |
|
350 private: |
|
351 |
|
352 /** |
|
353 * iDataInterface: a reference to searchdata interface in the chat engine |
|
354 */ |
|
355 MCASearchInterface* iSearchInterface; |
|
356 |
|
357 /** |
|
358 * Does not own, do not delete |
|
359 * iSearchObserverPC: a reference to the observer for events |
|
360 * from MCASearchInterfacePC. MCASearchInterfacePC inturn receives |
|
361 * the actual engine events from MCASearchObserverInterface. |
|
362 */ |
|
363 MCASearchObserverInterfacePC* iSearchObserverPC; |
|
364 |
|
365 /** |
|
366 * Pointer to BackgroundObserverPC that has to be given to UI |
|
367 */ |
|
368 MCASearchBackgroundObserverPC* iBackgroundObserver; |
|
369 |
|
370 /** |
|
371 * Reference to the engine's contactlist model |
|
372 */ |
|
373 MCABackgroundInterface& iBackgroundInterface; |
|
374 |
|
375 // SearchPairs, Owns. |
|
376 CSearchPairs* iSearchPairs; |
|
377 |
|
378 //Reference to the group manager interface in the engine component. Doesnt own |
|
379 MCAGroupManagerInterface& iGroupMgrInterface; |
|
380 |
|
381 //Pointer to stored groups interface in the storage component. Doesnt own |
|
382 MCAStoredGroups* iStoredGroupsInterface; |
|
383 }; |
|
384 |
|
385 #endif // CCASEARCHINTERFACEPC_H |
|
386 |
|
387 // End of File |