60
|
1 |
/*
|
|
2 |
* Copyright (c) 2008-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: Data source Task MDS Class
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
#ifndef _C_GLXDATASOURCETASKMDS_H_
|
|
22 |
#define _C_GLXDATASOURCETASKMDS_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,
|
|
72 |
public MMdEQueryObserver
|
|
73 |
{
|
|
74 |
public:
|
|
75 |
/**
|
|
76 |
* Constructor.
|
|
77 |
* @param aRequest request to be executed.
|
|
78 |
* @param aObserver observer to be informed when task has completed.
|
|
79 |
* @param aDataSource data source to be used by this object.
|
|
80 |
*/
|
|
81 |
CGlxDataSourceTaskMde(CGlxRequest* aRequest, MGlxDataSourceRequestObserver&
|
|
82 |
aObserver, CGlxDataSource* aDataSource);
|
|
83 |
|
|
84 |
/**
|
|
85 |
* Destructor.
|
|
86 |
*/
|
|
87 |
~CGlxDataSourceTaskMde();
|
|
88 |
|
|
89 |
/**
|
|
90 |
* Second stage constructor
|
|
91 |
*/
|
|
92 |
virtual void ConstructL();
|
|
93 |
|
|
94 |
protected: // to be implemented by deriving classes
|
|
95 |
/**
|
|
96 |
* See @ref CGlxDataSourceTask::ExecuteRequestL
|
|
97 |
*/
|
|
98 |
virtual void ExecuteRequestL() = 0;
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Must be implemented by deriving classes. To handle query completion
|
|
102 |
* @param aQuery Query that has been completed.
|
|
103 |
*/
|
|
104 |
virtual void DoHandleQueryCompletedL(CMdEQuery& aQuery) = 0;
|
|
105 |
|
|
106 |
/**
|
|
107 |
* Optionally implemented by deriving classes. Used if the deriving class has
|
|
108 |
* to run more than one query. Should start the next query or call HandleRequestComplete()
|
|
109 |
* if no futher queries are required to be run. If the deriving class only has a single query,
|
|
110 |
* HandleRequestComplete() can be called from DoHandleQueryCompletedL()
|
|
111 |
*/
|
|
112 |
virtual void DoNextQueryL() {}
|
|
113 |
|
|
114 |
public: // From CGlxDataSourceTask
|
|
115 |
/**
|
|
116 |
* See @ref CGlxDataSourceTask::CancelRequest
|
|
117 |
*/
|
|
118 |
void CancelRequest();
|
|
119 |
|
|
120 |
private: // from MMdEQueryObserver
|
|
121 |
/**
|
|
122 |
* See @ref MMdEQueryObserver::HandleQueryNewResults
|
|
123 |
*/
|
|
124 |
void HandleQueryNewResults( CMdEQuery& aQuery,
|
|
125 |
TInt aFirstNewItemIndex,
|
|
126 |
TInt aNewItemCount );
|
|
127 |
/**
|
|
128 |
* See @ref MMdEQueryObserver::HandleQueryNewResults
|
|
129 |
*/
|
|
130 |
void HandleQueryNewResults( CMdEQuery& aQuery,
|
|
131 |
TInt aNewObjectItemCount,
|
|
132 |
TInt aNewRelationItemCount,
|
|
133 |
TInt aNewEventItemCount);
|
|
134 |
/**
|
|
135 |
* See @ref MMdEQueryObserver::HandleQueryCompleted
|
|
136 |
*/
|
|
137 |
void HandleQueryCompleted( CMdEQuery& aQuery, TInt aError);
|
|
138 |
|
|
139 |
protected:
|
|
140 |
|
|
141 |
/**
|
|
142 |
* Returns a pointer to the CGlxDataSourceMde object passed in on instantiation.
|
|
143 |
* @return a pointer to the CGlxDataSourceMde object passed in on instantiation.
|
|
144 |
*/
|
|
145 |
CGlxDataSourceMde* DataSource();
|
|
146 |
|
|
147 |
/**
|
|
148 |
* Set query contditions by container id and filter properties.
|
|
149 |
* @param aLogicCondition logic condition to add conditions to
|
|
150 |
* @param aContainerId Id of the container
|
|
151 |
* @param aContainerIsLeft. This should be set to to ETrue if the container is on the left side of the releation, or
|
|
152 |
* EFalse if the container is on the right side of the relation
|
|
153 |
*
|
|
154 |
*/
|
|
155 |
void SetQueryConditionsL(CMdEQuery& aQuery, const TGlxFilterProperties& aFilterProperties,
|
|
156 |
const TGlxMediaId aContainerId, CMdEObjectDef& aObjectDef);
|
|
157 |
|
|
158 |
void SetQueryFilterConditionsL(CMdELogicCondition& aLogicCondition, CMdEObjectDef& aObjectDef,
|
|
159 |
const TGlxFilterProperties& aFilterProperties);
|
|
160 |
|
|
161 |
void SetSortOrderL(CMdEQuery& aQuery, CMdEObjectDef& aObjectDef,
|
|
162 |
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,
|
|
176 |
TQueryResultMode aResultMode, const TGlxMediaId& aContainerId);
|
|
177 |
|
|
178 |
/**
|
|
179 |
* Adds queries for images and or videos to the query queue. The queries will return objects
|
|
180 |
* of type image or video that have ids specified by aObjectIds.
|
|
181 |
* @param aObjectIds A list of the ids of the required objects.
|
|
182 |
* @param aFilterProperties TGlxFilterProperties.iItemType is used to determine if only
|
|
183 |
* image or video queries are required if iItemType is not set to EGlxFilterImage or
|
|
184 |
* EGlxFitlerVideo a query for images will be queued first followed by a query for videos.
|
|
185 |
*/
|
|
186 |
void QueueImageVideoObjectQueriesL(const RArray<TGlxMediaId>& aObjectIds,
|
|
187 |
const TGlxFilterProperties& aFilterProperties);
|
|
188 |
|
|
189 |
/**
|
|
190 |
* Adds a query for tag objects that have ids specified by aObjectIds
|
|
191 |
* to the query queue.
|
|
192 |
* @param aObjectIds A list of the ids of the required objects.
|
|
193 |
*/
|
|
194 |
void QueueTagObjectQueryL(const RArray<TGlxMediaId>& aObjectIds);
|
|
195 |
|
|
196 |
/**
|
|
197 |
* Adds a query for album objects that have ids specified by aObjectIds
|
|
198 |
* to the query queue.
|
|
199 |
* @param aObjectIds A list of the ids of the required objects.
|
|
200 |
*/
|
|
201 |
void QueueAlbumObjectQueryL(const RArray<TGlxMediaId>& aObjectIds);
|
|
202 |
|
|
203 |
/**
|
|
204 |
* Adds a query for objects of type specified by aObjectDef
|
|
205 |
* that have ids specified by aObjectIds to the query queue.
|
|
206 |
* @param aObjectDef type of objects required.
|
|
207 |
* @param aObjectIds A list of the ids of the required objects.
|
|
208 |
* @param aQueryType The query type.
|
|
209 |
*/
|
|
210 |
void QueueObjectQueryL(CMdEObjectDef& aObjectDef,
|
|
211 |
const RArray<TGlxMediaId>& aObjectIds, const TGlxQueryType& aQueryType);
|
|
212 |
|
|
213 |
/**
|
|
214 |
* Appends a query to the query queue. (the ownership of the query is transferred)
|
|
215 |
* @param aQuery query to append to the query queue ownership is transferred to
|
|
216 |
* the query queue. It is expected that aQuery is not on the cleanupstack before the
|
|
217 |
* call to AppendQueryL is made
|
|
218 |
* @param aQueryType the query type.
|
|
219 |
*/
|
|
220 |
void AppendQueryL(CMdEQuery* aQuery, const TGlxQueryType& aQueryType);
|
|
221 |
|
|
222 |
/**
|
|
223 |
* Executes the query at ordinal 0 in the
|
|
224 |
* query list implementation can be overidden by
|
|
225 |
* deriving classes.
|
|
226 |
*/
|
|
227 |
virtual void ExecuteQueryL();
|
|
228 |
|
|
229 |
private:
|
|
230 |
/*
|
|
231 |
* Helper function TRAPed and called by HandleQueryCompleted()
|
|
232 |
* @param aQuery the query that has been completed
|
|
233 |
*/
|
|
234 |
void HandleQueryCompletedL(CMdEQuery& aQuery);
|
|
235 |
|
|
236 |
/**
|
|
237 |
* Removes the observer from any existing queries, cancels and destroys them
|
|
238 |
*/
|
|
239 |
void DestroyQueries();
|
|
240 |
|
|
241 |
private:
|
|
242 |
/**
|
|
243 |
* Default namespace def (not owned)
|
|
244 |
*/
|
|
245 |
CMdENamespaceDef* iDefaultNameSpaceDef;
|
|
246 |
|
|
247 |
protected:
|
|
248 |
/**
|
|
249 |
* Outstanding queries array (owned)
|
|
250 |
*/
|
|
251 |
RPointerArray <CMdEQuery> iQueries;
|
|
252 |
|
|
253 |
/**
|
|
254 |
* Query types array (owned)
|
|
255 |
*/
|
|
256 |
RArray <TGlxQueryType> iQueryTypes;
|
|
257 |
|
|
258 |
/**
|
|
259 |
* Filter properties
|
|
260 |
*/
|
|
261 |
TGlxFilterProperties iFilterProperties;
|
|
262 |
};
|
|
263 |
|
|
264 |
#endif //_C_GLXDATASOURCETASKMDS_H_ |