|
1 /* |
|
2 * Copyright (c) 2005-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: This is find engine to manage object searching,* |
|
15 */ |
|
16 |
|
17 #ifndef __MDSFINDENGINE_H__ |
|
18 #define __MDSFINDENGINE_H__ |
|
19 |
|
20 #include <e32base.h> |
|
21 |
|
22 #include "mdscommoninternal.h" |
|
23 |
|
24 // FORWARD DECLARATIONS |
|
25 class CMdSFindSequence; |
|
26 class CMdSServerSession; |
|
27 class CMdSObjectLockList; |
|
28 class CMdCSerializationBuffer; |
|
29 class CMdsSchema; |
|
30 class CMdSServer; |
|
31 |
|
32 // CLASS DECLARATION |
|
33 /** |
|
34 * CMdSFindEngine. |
|
35 * Class for searching objects from metadata database. |
|
36 */ |
|
37 class CMdSFindEngine : public CBase |
|
38 { |
|
39 public: // Constructors and destructors |
|
40 |
|
41 /** |
|
42 * NewL. |
|
43 * Two-phased constructor. |
|
44 * @param aQueryId query id |
|
45 * @param aParent the session back reference |
|
46 * @param aLockList list of locked objects |
|
47 * @param aSchemaNew schema reference |
|
48 * |
|
49 * @return Pointer to created CMdSFindEngine object. |
|
50 */ |
|
51 static CMdSFindEngine* NewL( |
|
52 TUint32 aQueryId, |
|
53 CMdSServerSession& aParent, |
|
54 CMdSObjectLockList& aLockList, |
|
55 CMdsSchema& aSchemaNew); |
|
56 |
|
57 /** |
|
58 * NewLC. |
|
59 * Two-phased constructor. |
|
60 * @param aQueryId query id |
|
61 * @param aParent the session back reference |
|
62 * @param aLockList list of locked objects |
|
63 * @param aSchemaNew schema reference |
|
64 * @return Pointer to created CMdSFindEngine object. |
|
65 */ |
|
66 static CMdSFindEngine* NewLC( |
|
67 TUint32 aQueryId, |
|
68 CMdSServerSession& aParent, |
|
69 CMdSObjectLockList& aLockList, |
|
70 CMdsSchema& aSchemaNew); |
|
71 |
|
72 /** |
|
73 * 2nd phase constructor |
|
74 */ |
|
75 void ConstructL( CMdsSchema& aSchema ); |
|
76 |
|
77 /** |
|
78 * ~CMdSFindEngine. |
|
79 * Destructor. |
|
80 */ |
|
81 virtual ~CMdSFindEngine(); |
|
82 |
|
83 public: |
|
84 |
|
85 /** |
|
86 * Returns query's ID |
|
87 * @return query ID |
|
88 */ |
|
89 TUint32 QueryId(); |
|
90 |
|
91 /** |
|
92 * Creates the result set and sets message pointer |
|
93 * @param aMessage message for asynchronous client messaging |
|
94 */ |
|
95 void CreateResultSet(RMessage2 aMessage); |
|
96 |
|
97 /** |
|
98 * Sets parameters for the find. Ownership is transferred. |
|
99 */ |
|
100 void SetFindParams( TUint32 aNotifyCount ); |
|
101 |
|
102 /** |
|
103 * Sets serialized criteria buffer for the find. Ownership is transferred. |
|
104 */ |
|
105 void SetFindCriteria( CMdCSerializationBuffer* aSerializedCriteria ); |
|
106 |
|
107 /** |
|
108 * Initiates find |
|
109 * @param aUserLevel defines user's access rights |
|
110 * @return error code or KErrNone |
|
111 */ |
|
112 TInt FindL( TUserLevel aUserLevel ); |
|
113 |
|
114 /** |
|
115 * Continues ongoing sync find |
|
116 * @return error code or KErrNone |
|
117 */ |
|
118 TInt ContinueL(); |
|
119 |
|
120 /** |
|
121 * Initiates asynchronous find |
|
122 * @param aUserLevel defines user's access rights |
|
123 */ |
|
124 void FindAsyncL( TUserLevel aUserLevel ); |
|
125 |
|
126 /** |
|
127 * Continues ongoing find |
|
128 */ |
|
129 void ContinueAsync(); |
|
130 |
|
131 /** |
|
132 * Cancels find |
|
133 */ |
|
134 void Cancel( TInt aError ); |
|
135 |
|
136 /** |
|
137 * Transfer result set to client |
|
138 * @aError error code or KErrNone |
|
139 */ |
|
140 void SetComplete( TInt aError ); |
|
141 |
|
142 /** |
|
143 * Transfer results to client and completes find |
|
144 * @aError error code or KErrNone |
|
145 */ |
|
146 void FindComplete( TInt aError ); |
|
147 |
|
148 const CMdCSerializationBuffer& ResultsL() const; |
|
149 |
|
150 /** |
|
151 * Locks query result objects. |
|
152 * @param aLockList list of objects that must be locked |
|
153 */ |
|
154 void LockFindResultObjectsL( CMdSObjectLockList& aLockList ); |
|
155 |
|
156 /** |
|
157 * Sets result mode. |
|
158 * @param aResultModeItems ETrue if result mode is item mode |
|
159 */ |
|
160 void SetResultMode( TBool aResultModeItems ); |
|
161 |
|
162 /** |
|
163 * Returns whether find engine is complete or not. |
|
164 * Completed sequence can be safely delete. |
|
165 */ |
|
166 TBool IsComplete() const; |
|
167 |
|
168 /** |
|
169 * Returns whether find engine's query is complete or not. |
|
170 */ |
|
171 TBool IsQueryComplete(); |
|
172 |
|
173 CMdSServer& GetServer() const; |
|
174 |
|
175 private: // Constructors and destructors |
|
176 |
|
177 /** |
|
178 * CMdSManipulationEngine. |
|
179 * C++ default constructor. |
|
180 * @param . |
|
181 */ |
|
182 CMdSFindEngine( |
|
183 TUint32 aQueryId, |
|
184 CMdSServerSession& aParent, |
|
185 CMdSObjectLockList& aLockList); |
|
186 |
|
187 private: // Data |
|
188 |
|
189 TUint32 iQueryId; |
|
190 |
|
191 CMdSServerSession& iParent; |
|
192 |
|
193 CMdSObjectLockList& iLockList; |
|
194 |
|
195 CMdSFindSequence* iSequence; |
|
196 |
|
197 CMdCSerializationBuffer* iSerializedCriteria; |
|
198 |
|
199 RMessage2 iMessage; |
|
200 |
|
201 TBool iAsyncPending; |
|
202 |
|
203 // if last query result was Items result |
|
204 TBool iLastResultModeItems; |
|
205 |
|
206 }; |
|
207 |
|
208 #endif //__MDSFINDENGINE_H__ |