|
1 /* |
|
2 * Copyright (c) 2006-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: ECom search interface definition |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef C_MESSAGESSEARCHER_H |
|
22 #define C_MESSAGESSEARCHER_H |
|
23 |
|
24 //SYSTEM INCLUDES |
|
25 #include <smtcmtm.h> |
|
26 #include <popcmtm.h> |
|
27 #include <impcmtm.h> |
|
28 |
|
29 #include <mmsclient.h> |
|
30 #include <sendas2.h> |
|
31 #include <msvreg.h> |
|
32 #include <searchcontentsearcher.h> |
|
33 |
|
34 |
|
35 #include <apgcli.h> |
|
36 #include <apacmdln.h> |
|
37 #include <barsread2.h> |
|
38 #include <MuiuMsgEditorLauncher.h> |
|
39 |
|
40 |
|
41 // FORWARD DECLARATIONS |
|
42 class CSmsClientMtm; |
|
43 class CClientMtmRegistry; |
|
44 class MSearchPluginObserver; |
|
45 class CSearchTextSearcher; |
|
46 class CSearchCriteriaArray; |
|
47 class CSearchResult; |
|
48 class CSearchResultArray; |
|
49 class CSearchDocumentId; |
|
50 class CSearchSnippet; |
|
51 class CSearchSnippetInfo; |
|
52 class MSearchFScanObserver; |
|
53 class CMsgDesC; |
|
54 class CSearchSnippetCreator; |
|
55 class MSearchContentSearcher; |
|
56 class CSearchCondition; |
|
57 class TMsvSessionEvent; |
|
58 |
|
59 class TEditorParameters; |
|
60 |
|
61 /** |
|
62 * This class is the searcher class for the messages |
|
63 * |
|
64 * This class searches the contacts using the message server apis |
|
65 * |
|
66 * @lib |
|
67 */ |
|
68 class CMessagesSearcher : public CActive, |
|
69 public MSearchContentSearcher, |
|
70 public MMsvSessionObserver |
|
71 { |
|
72 public: |
|
73 |
|
74 enum TSearchField // what fields to search |
|
75 { |
|
76 ESearchFieldAll = 0, // all |
|
77 ESearchFieldTitleOnly, // title only |
|
78 ESearchFieldBodyOnly // doby only |
|
79 }; |
|
80 |
|
81 enum TSearchType // what type of message to search |
|
82 { |
|
83 ESearchTypeSms = 0, // sms |
|
84 ESearchTypeEmail, // email |
|
85 ESearchTypeAll, // all |
|
86 ESearchTypeNone // none |
|
87 }; |
|
88 |
|
89 enum TSearching // what is currently under search |
|
90 { |
|
91 ESearchingBody = 0, // sms body |
|
92 ESearchingSender, // sms sender |
|
93 ESearchingSMTPSubject, // smtp subject |
|
94 ESearchingSMTPSender, // smtp sender |
|
95 ESearchingSMTPBody, // smtp body |
|
96 ESearchingPOP3Subject, // pop3 subject |
|
97 ESearchingPOP3Sender, // pop3 sender |
|
98 ESearchingPOP3Body, // pop3 body |
|
99 ESearchingIMAP4Subject, // imap4 subject |
|
100 ESearchingIMAP4Sender, // imap4 sender |
|
101 ESearchingIMAP4Body, // imap4 body |
|
102 ESearchingMMSBody, // mms body |
|
103 ESearchingMMSSender, // mms sender |
|
104 ESearchingGenericEmailSubject, // pop3 subject |
|
105 ESearchingGenericEmailSender, // pop3 sender |
|
106 ESearchingGenericEmailBody // pop3 body |
|
107 }; |
|
108 |
|
109 |
|
110 |
|
111 /** |
|
112 * 1st phase constructor |
|
113 * |
|
114 * @param aContentIdArray - content id |
|
115 * @param aCondition - condition |
|
116 * @param aPluginId - Implementation id |
|
117 * @return returns pointer to the constructed object of type CContactsSearcher |
|
118 */ |
|
119 static CMessagesSearcher* NewL( const RArray<TUid>& aContentIdArray, |
|
120 const CSearchCondition& aCondition, |
|
121 const TUid& aPluginId, |
|
122 MSearchPluginObserver& aObserver ); |
|
123 /** |
|
124 * Destructor |
|
125 */ |
|
126 ~CMessagesSearcher(); |
|
127 |
|
128 /** |
|
129 * Checks the deltion of the entry before launching. |
|
130 * |
|
131 * @param aDocumentId Id of the document. |
|
132 * @ return ETrue if entry is deleted. |
|
133 */ |
|
134 TBool IsEntryDeleted( TMsvId& aMsgEntryId ); |
|
135 |
|
136 public: //from base class MSearchContentSearcher |
|
137 /** |
|
138 * From MSearchContentSearcher |
|
139 * Releses the object. |
|
140 * |
|
141 */ |
|
142 void Destroy(); |
|
143 |
|
144 /** |
|
145 * From MSearchContentSearcher |
|
146 * Starts the search. Progress of the search is notified through aObserver. |
|
147 * Notice that this call must be asynchronous. |
|
148 * |
|
149 * @param aObserver Observer for search progress. |
|
150 */ |
|
151 void SearchL( ); |
|
152 |
|
153 |
|
154 /** |
|
155 * From MSearchContentSearcher |
|
156 * Cancels the ongoing search. This call must complete synchronously and no calls for |
|
157 * observers must be made after this call. |
|
158 * |
|
159 */ |
|
160 void CancelSearch(); |
|
161 |
|
162 /** |
|
163 * From MSearchContentSearcher |
|
164 * Gets the results indicated by the given document ids. Asynchronous. Results will be given |
|
165 * through callback in MSearchPlugInObserver given in Search request. |
|
166 * |
|
167 * @param aResults Results of the search process. Ownership transfers to caller. |
|
168 */ |
|
169 void GetResultsL( const RPointerArray<CSearchDocumentId>& aDocumentIdArray ); |
|
170 |
|
171 /** |
|
172 * From MSearchContentSearcher |
|
173 * Cancels the result retrieval process. |
|
174 * |
|
175 */ |
|
176 void CancelResultsRetrieve(); |
|
177 |
|
178 |
|
179 /** |
|
180 * From MSearchContentSearcher , through MSearchTextSearcherObserver |
|
181 * Called when all search criteria are met. |
|
182 * |
|
183 * @param aKeyWordPos The character position of the keyword match within the original text |
|
184 */ |
|
185 void HitL( TInt aKeyWordPos ); |
|
186 |
|
187 |
|
188 /** |
|
189 * This funcion returns the launch info corresponding to a particular document id. |
|
190 * |
|
191 * @param aDocumentID The document id for which launch info is required. |
|
192 */ |
|
193 HBufC8* LaunchInfoL( const CSearchDocumentId& aDocumentID ); |
|
194 |
|
195 |
|
196 /** |
|
197 * Is called when contentsearcher finishes it's operation or it is unable to |
|
198 * search further. |
|
199 * @param aTotalNumOfItems |
|
200 * @param aSearchResult |
|
201 */ |
|
202 void ReportFinishedL( TInt aTotalNumOfItems, TInt aSearchResult = 0 ); |
|
203 |
|
204 |
|
205 public: //from base class MMsvSessionObserver |
|
206 |
|
207 /** |
|
208 * From MMsvSessionObserver |
|
209 *Provides the interface for notification of events from a Message Server session. |
|
210 * The types of event are given in the enumeration TMsvSessionEvent. Clients must provide an object that implements |
|
211 * the interface, and set it to be notified through CMsvSession::OpenSyncL() or CMsvSession::OpenASyncL(). |
|
212 * Additional observers can also be added and removed through CMsvSession. |
|
213 * |
|
214 * @TMsvSessionEvent the session event |
|
215 * @param |
|
216 */ |
|
217 void HandleSessionEventL( TMsvSessionEvent, TAny*, TAny*, TAny* ); |
|
218 |
|
219 |
|
220 void LaunchApplicationL( const TDesC8& aLaunchInfo ); |
|
221 |
|
222 /** |
|
223 * Finds the right application id to be started and returns it. |
|
224 * |
|
225 * @param aParams Editor parameters |
|
226 * @param aMtmType Result's Mtm type |
|
227 * |
|
228 * @return Editor application's uid |
|
229 * |
|
230 */ |
|
231 TUid DiscoverL( const TEditorParameters aParams, TUid aMtmType ); |
|
232 |
|
233 |
|
234 /** |
|
235 * Reads the parameters ( service type (View/Edit), MtmType) from |
|
236 * the opaque data. If type and mtm match, sets aAppUi as |
|
237 * the application id and returns ETrue. If not found, returns EFalse. |
|
238 */ |
|
239 TBool TryMatchL( const TEditorParameters aParams, |
|
240 TUid aMtmType, |
|
241 const TApaAppServiceInfo aInfo, |
|
242 TUid& aAppUid ); |
|
243 |
|
244 |
|
245 protected: // From base class CActive |
|
246 |
|
247 /** |
|
248 * From CActive |
|
249 * Implements cancellation of an outstanding request. |
|
250 * |
|
251 * This function is called as part of the active object's Cancel(). |
|
252 */ |
|
253 void DoCancel() ; |
|
254 |
|
255 /** |
|
256 * From CActive |
|
257 * Handles an active object's request completion event. |
|
258 * |
|
259 * The function is called by the active scheduler when a request |
|
260 * completion event occurs, i.e. after the active scheduler's |
|
261 * WaitForAnyRequest() function completes. |
|
262 * |
|
263 * Before calling this active object's RunL() function, the active scheduler |
|
264 * has: |
|
265 * |
|
266 * 1. decided that this is the highest priority active object with |
|
267 * a completed request |
|
268 * |
|
269 * 2. marked this active object's request as complete (i.e. the request is no |
|
270 * longer outstanding) |
|
271 * |
|
272 * RunL() runs under a trap harness in the active scheduler. If it leaves, |
|
273 * then the active scheduler calls RunError() to handle the leave. |
|
274 * |
|
275 * Note that once the active scheduler's Start() function has been called, |
|
276 * all user code is run under one of the program's active object's RunL() or |
|
277 * RunError() functions. |
|
278 * |
|
279 */ |
|
280 void RunL(); |
|
281 |
|
282 |
|
283 /** |
|
284 * From CActive |
|
285 * If the RunL function leaves, |
|
286 * then the active scheduler calls RunError() to handle the leave. |
|
287 * |
|
288 */ |
|
289 TInt RunError( TInt aError ); |
|
290 |
|
291 |
|
292 private: |
|
293 /** |
|
294 * Constructor |
|
295 * |
|
296 * |
|
297 * @param aPluginId |
|
298 */ |
|
299 CMessagesSearcher( const TUid& aPluginId); |
|
300 |
|
301 /** |
|
302 * 2nd phase constructor |
|
303 * |
|
304 * @param aContentIdArray |
|
305 * @param aCondition |
|
306 */ |
|
307 void ConstructL( const RArray<TUid>& aContentIdArray, |
|
308 const CSearchCondition& aCondition, |
|
309 MSearchPluginObserver& aObserver ); |
|
310 |
|
311 /** |
|
312 * Cleans up the memory held |
|
313 * |
|
314 */ |
|
315 void CleanUp(); |
|
316 |
|
317 /** |
|
318 * Does actual search |
|
319 * |
|
320 * |
|
321 */ |
|
322 TBool DoActualSearchL(); |
|
323 |
|
324 |
|
325 |
|
326 /** |
|
327 * Sets the folder(s) to be searched by the plug-in. |
|
328 * |
|
329 */ |
|
330 void SetTargetFolderL( ); |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 /** |
|
336 * Checks all folders that need to be searched. Folders to be searched are |
|
337 * set via SetTargetFolderL. |
|
338 * Calls AddFolderWithSubFoldersL to add the folder to the array of folders to be |
|
339 * searched. |
|
340 * |
|
341 * @param |
|
342 */ |
|
343 void ListSubFoldersL( const CMsvEntry& aFolderEntry ); |
|
344 |
|
345 /** |
|
346 * Will add the specified folder to the folder array to be searched. |
|
347 * Subfolders of the specified folder are checked by calling ListSubFoldersL. |
|
348 * |
|
349 * @param |
|
350 */ |
|
351 void AddFolderWithSubFoldersL( const TMsvId& aFolderId ); |
|
352 |
|
353 /** |
|
354 * Prepares the object for the search. MoveOnToNextMessageL is called |
|
355 * to find the 1st message in the to be searched folders. |
|
356 * |
|
357 * @return ETrue When messages are available |
|
358 * EFalse When 0 messages are available |
|
359 */ |
|
360 TBool PrepareForSearchL(); |
|
361 |
|
362 /** |
|
363 * Moves through all messages under those folders to be searched and returns |
|
364 * with ETrue when a message is found. |
|
365 * |
|
366 * @return ETrue When a message is found. |
|
367 * EFalse When no more messages are available under the to be |
|
368 * searched folders. |
|
369 */ |
|
370 TBool MoveOnToNextMessageL(); |
|
371 |
|
372 /** |
|
373 * Searches SMS message. |
|
374 * |
|
375 * @param |
|
376 */ |
|
377 void SearchSmsL( TMsvId& aMessageId ); |
|
378 |
|
379 /** |
|
380 * Searches MMS message. |
|
381 * |
|
382 * @param |
|
383 */ |
|
384 void SearchInMmsMessageL(const TMsvId& aMessageId); |
|
385 |
|
386 /** |
|
387 * Searches Email message. |
|
388 * |
|
389 * @param |
|
390 */ |
|
391 void SearchGenericEmailL( TMsvId& aMessageId, TUid aMessageUid); |
|
392 |
|
393 /** |
|
394 * Generates results from a hit in sms message. |
|
395 * |
|
396 * @param |
|
397 */ |
|
398 void ReportHitInSmsL( TInt aKeyWordPos ); |
|
399 |
|
400 /** |
|
401 * Generates results from a hit in mms message. |
|
402 * |
|
403 * @param |
|
404 */ |
|
405 void ReportHitInMmsL( TInt aKeyWordPos ); |
|
406 |
|
407 /** |
|
408 * Generates results from a hit in email message. |
|
409 * |
|
410 * @param |
|
411 */ |
|
412 void ReportHitInEmailL( TInt aKeyWordPos ); |
|
413 |
|
414 /** |
|
415 * Searches for Mtm -class from the array that can be used to open the message specified by aUid |
|
416 * If proper class is not found, it's created by using method AddIntoMtmArrayL(). |
|
417 * |
|
418 * @param aUid |
|
419 */ |
|
420 CBaseMtm* SearchFromMtmArrayL( TUid aUid ); |
|
421 |
|
422 /** |
|
423 * Checks if there's any entry in at least one folder |
|
424 * |
|
425 * |
|
426 */ |
|
427 TBool AnyEntriesInAllFolders(); |
|
428 |
|
429 private: // Data |
|
430 |
|
431 /** |
|
432 *client for opening sms |
|
433 */ |
|
434 CSmsClientMtm* iSmsMtm; |
|
435 |
|
436 /** |
|
437 *client for opening mms |
|
438 */ |
|
439 CMmsClientMtm* iMmsMtm; |
|
440 |
|
441 /** |
|
442 *client for opening emails |
|
443 */ |
|
444 CBaseMtm* iGenericMtm; |
|
445 |
|
446 /** |
|
447 *pointer to ClientMtmRegistry |
|
448 */ |
|
449 CClientMtmRegistry* iMtmReg; |
|
450 |
|
451 /** |
|
452 *pointer to message session |
|
453 */ |
|
454 CMsvSession* iSession; |
|
455 |
|
456 /** |
|
457 *array containing Mtm -objects used for opening messages. |
|
458 */ |
|
459 RPointerArray<CBaseMtm> iMtmArray; |
|
460 |
|
461 /** |
|
462 *Array of folders to be searched. |
|
463 */ |
|
464 RArray<TMsvId> iToBeSearchedFolders; |
|
465 |
|
466 /** |
|
467 *index of folder currently being |
|
468 */ |
|
469 TInt iToBeSearchedFoldersIdx; |
|
470 |
|
471 /** |
|
472 *reference to the file system |
|
473 */ |
|
474 RFs iFs; |
|
475 |
|
476 /** |
|
477 *folder currently being searched |
|
478 */ |
|
479 CMsvEntry* iFolderEntry; |
|
480 |
|
481 /** |
|
482 * Message Entry |
|
483 */ |
|
484 CMsvEntrySelection* iEntryDeleted; |
|
485 /** |
|
486 *message currently being searched |
|
487 */ |
|
488 CMsvEntry* iMessageEntry; |
|
489 |
|
490 /** |
|
491 *message currently being searched |
|
492 */ |
|
493 CMsvEntrySelection* iMessageEntries; |
|
494 |
|
495 /** |
|
496 *Id of messageentry |
|
497 */ |
|
498 TInt iMessageEntriesIdx; |
|
499 |
|
500 |
|
501 /** |
|
502 *no of matches found |
|
503 */ |
|
504 TInt iStatusItemCounter; |
|
505 |
|
506 /** |
|
507 *no of max entires found |
|
508 */ |
|
509 TInt iTotalNumOfItems; |
|
510 |
|
511 /** |
|
512 *What field is under search. Affects snippet handling. |
|
513 */ |
|
514 TSearching iFieldCurrentlyUnderSearch; |
|
515 |
|
516 /** |
|
517 *arrray contains heavyResults |
|
518 */ |
|
519 RPointerArray<CSearchResult> iHeavyResultsArray; |
|
520 |
|
521 |
|
522 |
|
523 /** |
|
524 *pluginID |
|
525 */ |
|
526 const TUid iPluginId; |
|
527 |
|
528 /** |
|
529 *Is search cancelled |
|
530 */ |
|
531 TBool iSearchNotCancelled; //when cancelled search.. |
|
532 |
|
533 |
|
534 /** |
|
535 *Message Description array |
|
536 */ |
|
537 RPointerArray<CMsgDesC> iMsgDesCArray; |
|
538 |
|
539 /** |
|
540 *array informing num messge entries in a folder |
|
541 */ |
|
542 RArray<TInt> iMsgEntriesInFoldersArray; |
|
543 |
|
544 |
|
545 /** |
|
546 * Text searcher |
|
547 * Own. |
|
548 */ |
|
549 CSearchTextSearcher* iTextSearcher; // Text searcher |
|
550 |
|
551 /** |
|
552 * Search Plugin Observer |
|
553 * Own. |
|
554 */ |
|
555 MSearchPluginObserver* iObserver; |
|
556 |
|
557 /** |
|
558 * The current text being searched |
|
559 * Own. |
|
560 */ |
|
561 HBufC* iCurrentTextBeingSearched; |
|
562 HBufC* iSenderReciever; |
|
563 |
|
564 |
|
565 /** |
|
566 * Flags for checking searchcontent |
|
567 */ |
|
568 TBool iHitFound; |
|
569 |
|
570 CMsvStore* iMsvStore; |
|
571 |
|
572 |
|
573 }; |
|
574 |
|
575 |
|
576 |
|
577 |
|
578 |
|
579 #endif //C_MESSAGESSEARCHER_H |
|
580 |
|
581 |
|
582 |