|
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: Data Source Task MDE |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef _C_GLXDATASOURCETASKMDE_H_ |
|
22 #define _C_GLXDATASOURCETASKMDE_H_ |
|
23 |
|
24 /** |
|
25 * @author Simon Brooks, Alex Birkett |
|
26 */ |
|
27 |
|
28 // INCLUDES |
|
29 #include <e32cmn.h> |
|
30 #include <glxdatasource.h> |
|
31 #include <glxdatasourcetask.h> |
|
32 #include <glxfilterproperties.h> |
|
33 #include <mdccommon.h> |
|
34 #include <mdequery.h> |
|
35 #include <mglxtnthumbnailcreatorclient.h> |
|
36 #include <mpxfilter.h> |
|
37 |
|
38 // FORWARD DECLARATIONS |
|
39 class CGlxDataSourceMde; |
|
40 class CGlxRequest; |
|
41 class CGlxtnThumbnailCreator; |
|
42 class CMdEObjectDef; |
|
43 class CMdEObjectQuery; |
|
44 class CMdESession; |
|
45 |
|
46 |
|
47 /** |
|
48 * Query types supported by subclasses of CGlxDataSourceTaskMde |
|
49 */ |
|
50 enum TGlxQueryType |
|
51 { |
|
52 EContainerFirstItemQuery, // CGlxDataSourceTaskMdeThumbnail+ |
|
53 EIdListQuery, // GlxDataSourceTaskMdeIdList |
|
54 EAttributeQuery, // CGlxDataSourceTaskMdeAttribute |
|
55 ELocationAttributeQuery, // CGlxDataSourceTaskMdeAttribute |
|
56 EImageVideoQuery, // CGlxDataSourceTaskMdeAttribute (but should be general) |
|
57 ECommandRemoveFromContainer, // CGlxDataSourceTaskMdeCommand |
|
58 ECommandAddToContainer, // CGlxDataSourceTaskMdeCommand |
|
59 ECommandRemoveLocation, // CGlxDataSourceTaskMdeCommand |
|
60 ECommandAddContainer, // CGlxDataSourceTaskMdeCommand adds a container |
|
61 ECommandDeleteContainers, // CGlxDataSourceTaskMdeCommand deletes containers objects |
|
62 ECommandDeleteItems, // CGlxDataSourceTaskMdeCommand deletes containers objects |
|
63 ECommandRenameContainer, |
|
64 ECommandRename |
|
65 }; |
|
66 |
|
67 /** |
|
68 * CGlxDataSourceTaskMde class |
|
69 * Base class for mde tasks: provides task generic functionality. |
|
70 */ |
|
71 NONSHARABLE_CLASS(CGlxDataSourceTaskMde) : public CGlxDataSourceTask, public MMdEQueryObserver |
|
72 { |
|
73 public: |
|
74 /** |
|
75 * Constructor. |
|
76 * @param aRequest request to be executed. |
|
77 * @param aObserver observer to be informed when task has completed. |
|
78 * @param aDataSource data source to be used by this object. |
|
79 */ |
|
80 CGlxDataSourceTaskMde(CGlxRequest* aRequest, MGlxDataSourceRequestObserver& aObserver, |
|
81 CGlxDataSource* aDataSource); |
|
82 |
|
83 /** |
|
84 * Destructor. |
|
85 */ |
|
86 ~CGlxDataSourceTaskMde(); |
|
87 |
|
88 /** |
|
89 * Second stage constructor |
|
90 */ |
|
91 virtual void ConstructL(); |
|
92 |
|
93 protected: // to be implemented by deriving classes |
|
94 /** |
|
95 * See @ref CGlxDataSourceTask::ExecuteRequestL |
|
96 */ |
|
97 virtual void ExecuteRequestL() = 0; |
|
98 |
|
99 /** |
|
100 * Must be implemented by deriving classes. To handle query completion |
|
101 * @param aQuery Query that has been completed. |
|
102 */ |
|
103 virtual void DoHandleQueryCompletedL(CMdEQuery& aQuery) = 0; |
|
104 |
|
105 /** |
|
106 * Optionally implemented by deriving classes. Used if the deriving class has |
|
107 * to run more than one query. Should start the next query or call HandleRequestComplete() |
|
108 * if no futher queries are required to be run. If the deriving class only has a single query, |
|
109 * HandleRequestComplete() can be called from DoHandleQueryCompletedL() |
|
110 */ |
|
111 virtual void DoNextQueryL() {} |
|
112 |
|
113 public: // From CGlxDataSourceTask |
|
114 /** |
|
115 * See @ref CGlxDataSourceTask::CancelRequest |
|
116 */ |
|
117 void CancelRequest(); |
|
118 |
|
119 private: // from MMdEQueryObserver |
|
120 /** |
|
121 * See @ref MMdEQueryObserver::HandleQueryNewResults |
|
122 */ |
|
123 void HandleQueryNewResults( CMdEQuery& aQuery, |
|
124 TInt aFirstNewItemIndex, |
|
125 TInt aNewItemCount ); |
|
126 /** |
|
127 * See @ref MMdEQueryObserver::HandleQueryNewResults |
|
128 */ |
|
129 void HandleQueryNewResults( CMdEQuery& aQuery, |
|
130 TInt aNewObjectItemCount, |
|
131 TInt aNewRelationItemCount, |
|
132 TInt aNewEventItemCount); |
|
133 /** |
|
134 * See @ref MMdEQueryObserver::HandleQueryCompleted |
|
135 */ |
|
136 void HandleQueryCompleted( CMdEQuery& aQuery, TInt aError); |
|
137 |
|
138 protected: |
|
139 |
|
140 /** |
|
141 * Returns a pointer to the CGlxDataSourceMde object passed in on instantiation. |
|
142 * @return a pointer to the CGlxDataSourceMde object passed in on instantiation. |
|
143 */ |
|
144 CGlxDataSourceMde* DataSource(); |
|
145 |
|
146 void AddMonthFilterL(const TGlxMediaId& aContainerId, TGlxFilterProperties& aFilterProperties); |
|
147 |
|
148 void AddMonthFilterL(CMdEObject* aMonth, TGlxFilterProperties& aFilterProperties); |
|
149 |
|
150 /** |
|
151 * Set query contditions by container id and filter properties. |
|
152 * @param aLogicCondition logic condition to add conditions to |
|
153 * @param aContainerId Id of the container |
|
154 * @param aContainerIsLeft. This should be set to to ETrue if the container is on the left side of the releation, or |
|
155 * EFalse if the container is on the right side of the relation |
|
156 * |
|
157 */ |
|
158 void SetQueryConditionsL(CMdEQuery& aQuery, const TGlxFilterProperties& aFilterProperties, const TGlxMediaId aContainerId, CMdEObjectDef& aObjectDef); |
|
159 |
|
160 void SetQueryFilterConditionsL(CMdELogicCondition& aLogicCondition, CMdEObjectDef& aObjectDef, const TGlxFilterProperties& aFilterProperties); |
|
161 |
|
162 void SetSortOrderL(CMdEQuery& aQuery, CMdEObjectDef& aObjectDef, const TGlxFilterProperties& aFilterProperties); |
|
163 |
|
164 /** |
|
165 * Returns the maximum number of items that a query should find. |
|
166 * @return Maximum number of results |
|
167 */ |
|
168 TInt MaxQueryResultsCount(const TGlxFilterProperties& aFilterProperties) const; |
|
169 |
|
170 /** |
|
171 * Removes and destroys the oldest query in iQueries. |
|
172 */ |
|
173 void RemoveQuery(); |
|
174 |
|
175 void DoQueryL(CMdEObjectDef& aObjectDef, TBool aIsContent, TGlxQueryType aQueryType, TQueryResultMode aResultMode, const TGlxMediaId& aContainerId); |
|
176 |
|
177 /** |
|
178 * Adds queries for images and or videos to the query queue. The queries will return objects |
|
179 * of type image or video that have ids specified by aObjectIds. |
|
180 * @param aObjectIds A list of the ids of the required objects. |
|
181 * @param aFilterProperties TGlxFilterProperties.iItemType is used to determine if only |
|
182 * image or video queries are required if iItemType is not set to EGlxFilterImage or |
|
183 * EGlxFitlerVideo a query for images will be queued first followed by a query for videos. |
|
184 */ |
|
185 void QueueImageVideoObjectQueriesL(const RArray<TItemId>& aObjectIds, const TGlxFilterProperties& aFilterProperties); |
|
186 |
|
187 /** |
|
188 * Adds a query for tag objects that have ids specified by aObjectIds |
|
189 * to the query queue. |
|
190 * @param aObjectIds A list of the ids of the required objects. |
|
191 */ |
|
192 void QueueTagObjectQueryL(const RArray<TItemId>& aObjectIds); |
|
193 |
|
194 /** |
|
195 * Adds a query for album objects that have ids specified by aObjectIds |
|
196 * to the query queue. |
|
197 * @param aObjectIds A list of the ids of the required objects. |
|
198 */ |
|
199 void QueueAlbumObjectQueryL(const RArray<TItemId>& aObjectIds); |
|
200 |
|
201 /** |
|
202 * Adds a query for "month" objects that have ids specified by aObjectIds |
|
203 * to the query queue. |
|
204 * @param aObjectIds A list of the ids of the required objects. |
|
205 */ |
|
206 void QueueMonthObjectQueryL(const RArray<TItemId>& aObjectIds); |
|
207 |
|
208 /** |
|
209 * Adds a query for objects of type specified by aObjectDef |
|
210 * that have ids specified by aObjectIds to the query queue. |
|
211 * @param aObjectDef type of objects required. |
|
212 * @param aObjectIds A list of the ids of the required objects. |
|
213 * @param aQueryType The query type. |
|
214 */ |
|
215 void QueueObjectQueryL(CMdEObjectDef& aObjectDef, |
|
216 const RArray<TItemId>& aObjectIds, const TGlxQueryType& aQueryType); |
|
217 |
|
218 /** |
|
219 * Appends a query to the query queue. (the ownership of the query is transferred) |
|
220 * @param aQuery query to append to the query queue ownership is transferred to |
|
221 * the query queue. It is expected that aQuery is not on the cleanupstack before the |
|
222 * call to AppendQueryL is made |
|
223 * @param aQueryType the query type. |
|
224 */ |
|
225 void AppendQueryL(CMdEQuery* aQuery, const TGlxQueryType& aQueryType); |
|
226 |
|
227 /** |
|
228 * Executes the query at ordinal 0 in the |
|
229 * query list implementation can be overidden by |
|
230 * deriving classes. |
|
231 */ |
|
232 virtual void ExecuteQueryL(); |
|
233 |
|
234 private: |
|
235 /* |
|
236 * Helper function TRAPed and called by HandleQueryCompleted() |
|
237 * @param aQuery the query that has been completed |
|
238 */ |
|
239 void HandleQueryCompletedL(CMdEQuery& aQuery); |
|
240 |
|
241 /** |
|
242 * Removes the observer from any existing queries, cancels and destroys them |
|
243 */ |
|
244 void DestroyQueries(); |
|
245 |
|
246 private: |
|
247 /** |
|
248 * Default namespace def (not owned) |
|
249 */ |
|
250 CMdENamespaceDef* iDefaultNameSpaceDef; |
|
251 |
|
252 protected: |
|
253 /** |
|
254 * Outstanding queries array (owned) |
|
255 */ |
|
256 RPointerArray <CMdEQuery> iQueries; |
|
257 |
|
258 /** |
|
259 * Query types array (owned) |
|
260 */ |
|
261 RArray <TGlxQueryType> iQueryTypes; |
|
262 |
|
263 /** |
|
264 * Filter properties |
|
265 */ |
|
266 TGlxFilterProperties iFilterProperties; |
|
267 }; |
|
268 |
|
269 #endif //_C_GLXDATASOURCETASKMDE_H_ |