|
1 /* |
|
2 * Copyright (c) 2009 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: Container store search handler. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CONTAINER_STORE_SEARCH_HANDLER_H_ |
|
19 #define CONTAINER_STORE_SEARCH_HANDLER_H_ |
|
20 |
|
21 #include "ContainerStore.h" |
|
22 |
|
23 class CContainerStoreSearchResultTable; |
|
24 class CContainerStoreSortingTable; |
|
25 |
|
26 /** The interface to be implemented by asynchronous search clients. */ |
|
27 class MContainerStoreSearchClient |
|
28 { |
|
29 public: |
|
30 |
|
31 // ============== |
|
32 // PUBLIC METHODS |
|
33 // ============== |
|
34 |
|
35 virtual void MatchFound( TContainerId aMsgId, TContainerId aFolderId, const TDesC8& aPropertyBuf ) = 0; |
|
36 |
|
37 virtual void SearchComplete( TInt aStatus ) = 0; |
|
38 |
|
39 }; // end class MSearchClient |
|
40 |
|
41 /** The class represents an asynchronous search operation. */ |
|
42 class CContainerStoreSearchHandler : private CActive |
|
43 { |
|
44 public: |
|
45 |
|
46 // ============== |
|
47 // PUBLIC METHODS |
|
48 // ============== |
|
49 |
|
50 virtual ~CContainerStoreSearchHandler(); |
|
51 |
|
52 void StartL(); |
|
53 |
|
54 TBool IsSameSearchCriteriaL( RPointerArray<HBufC>& aSearchStrings ); |
|
55 |
|
56 void RestartL( TMsgStoreSearchCmdParams& aCmdParam, |
|
57 RArray<TContainerId>& aFolderIds, |
|
58 RPointerArray<HBufC8>& aPropertyNames ); |
|
59 |
|
60 void CancelSearch() { Cancel(); } |
|
61 |
|
62 TBool IsSearchInProgress() { return IsActive(); } |
|
63 |
|
64 private: |
|
65 |
|
66 // =============== |
|
67 // PRIVATE METHODS |
|
68 // =============== |
|
69 |
|
70 friend class CContainerStore; |
|
71 |
|
72 CContainerStoreSearchHandler( CContainerStore& aContainerStore, |
|
73 CContainerStoreContentManager& aContentManager, |
|
74 CContainerStoreSearchResultTable& aSearchResultTable, |
|
75 CContainerStoreSortingTable& aSortingTable, |
|
76 TContainerId aType, |
|
77 MContainerStoreSearchClient& aClient, |
|
78 TInt aPriority ); |
|
79 |
|
80 void ConstructL( RPointerArray<HBufC>& aSearchString, |
|
81 TMsgStoreSearchCmdParams& aCmdParam, |
|
82 RArray<TContainerId>& aFolderIds, |
|
83 RPointerArray<HBufC8>& aPropertyNames ); |
|
84 |
|
85 void InitializeL( TMsgStoreSearchCmdParams& aCmdParams, |
|
86 RArray<TContainerId>& aFolderIds, |
|
87 RPointerArray<HBufC8>& aPropertyNames ); |
|
88 |
|
89 void DoNextSearchL(); |
|
90 |
|
91 TBool SortNextFolderL(); |
|
92 |
|
93 TBool SearchL( TContainerId aMessageId ); |
|
94 |
|
95 void CreateSearchPatternL( RPointerArray<HBufC>& aOriginalSearchString, RPointerArray<HBufC>& aSearchPatterns ); |
|
96 |
|
97 void TPtrC8ToRBuf16L( const TPtrC8& aPtr8, RBuf& aBuf ) const; |
|
98 |
|
99 // inherited from CActive |
|
100 void RunL(); |
|
101 void DoCancel(); |
|
102 |
|
103 // ================== |
|
104 // PRIVATE ATTRIBUTES |
|
105 // ================== |
|
106 |
|
107 CContainerStore& iContainerStore; |
|
108 CContainerStoreContentManager& iContentManager; |
|
109 CContainerStoreSearchResultTable& iSearchResultTable; |
|
110 CContainerStoreSortingTable& iSortingTable; |
|
111 MContainerStoreSearchClient& iClient; |
|
112 TContainerId iParentId; |
|
113 TContainerId iType; |
|
114 TMsgStoreSearchCmdParams iSearchParams; |
|
115 RArray<TContainerId> iFolderIds; |
|
116 RPointerArray<HBufC8> iPropertyNames; |
|
117 RPointerArray<HBufC> iSearchStrings; |
|
118 //RArray<TContainerId> iSearchIds; |
|
119 |
|
120 // Keep the search buffer around for the duration of the search, to avoid a lot of |
|
121 // large allocates/deallocates. |
|
122 RBuf8 iSearchBuffer; |
|
123 |
|
124 TInt iCurFolderIdIndex; |
|
125 CMsgStoreSortResultRowSet* iSortResultSet; |
|
126 RBuf8 iPropertyBuf; |
|
127 TBool iIsNewSearch; |
|
128 |
|
129 __LOG_DECLARATION |
|
130 |
|
131 }; // end CContainerStoreSearchHandler |
|
132 |
|
133 |
|
134 |
|
135 #endif /*CONTAINER_STORE_SEARCH_HANDLER_H_*/ |