engine/collectionframework/datasource/plugins/glxdatasourcemde2.5/inc/glxdatasourcetaskmds.h
branchRCL_3
changeset 59 8e5f6eea9c9f
equal deleted inserted replaced
57:ea65f74e6de4 59:8e5f6eea9c9f
       
     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:   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef _C_GLXDATASOURCETASKMDS_H_
       
    21 #define _C_GLXDATASOURCETASKMDS_H_
       
    22 
       
    23 /**
       
    24  * @author Simon Brooks, Alex Birkett
       
    25  */
       
    26 
       
    27 // INCLUDES
       
    28 #include <e32cmn.h>
       
    29 #include <glxdatasource.h>
       
    30 #include <glxdatasourcetask.h>
       
    31 #include <glxfilterproperties.h>
       
    32 #include <mdccommon.h>
       
    33 #include <mdequery.h>
       
    34 #include <mglxtnthumbnailcreatorclient.h>
       
    35 #include <mpxfilter.h>
       
    36 
       
    37 // FORWARD DECLARATIONS
       
    38 class CGlxDataSourceMde;
       
    39 class CGlxRequest;
       
    40 class CGlxtnThumbnailCreator;
       
    41 class CMdEObjectDef;
       
    42 class CMdEObjectQuery;
       
    43 class CMdESession;
       
    44 
       
    45 
       
    46 /**
       
    47  * Query types supported by subclasses of CGlxDataSourceTaskMde
       
    48  */
       
    49 enum TGlxQueryType
       
    50     {
       
    51     EContainerFirstItemQuery,    // CGlxDataSourceTaskMdeThumbnail+
       
    52     EIdListQuery,                // GlxDataSourceTaskMdeIdList
       
    53     EAttributeQuery,             // CGlxDataSourceTaskMdeAttribute
       
    54     ELocationAttributeQuery,     // CGlxDataSourceTaskMdeAttribute
       
    55     EImageVideoQuery,            // CGlxDataSourceTaskMdeAttribute (but should be general)
       
    56     ECommandRemoveFromContainer, // CGlxDataSourceTaskMdeCommand
       
    57     ECommandAddToContainer,      // CGlxDataSourceTaskMdeCommand
       
    58     ECommandRemoveLocation,      // CGlxDataSourceTaskMdeCommand
       
    59     ECommandAddContainer,        // CGlxDataSourceTaskMdeCommand adds a container
       
    60     ECommandDeleteContainers,    // CGlxDataSourceTaskMdeCommand deletes containers objects
       
    61     ECommandDeleteItems,          // CGlxDataSourceTaskMdeCommand deletes containers objects
       
    62     ECommandRenameContainer,
       
    63     ECommandRename
       
    64     };
       
    65 
       
    66 /**
       
    67  *  CGlxDataSourceTaskMde class 
       
    68  *  Base class for mde tasks: provides task generic functionality.
       
    69  */
       
    70 NONSHARABLE_CLASS(CGlxDataSourceTaskMde) : 	public CGlxDataSourceTask, 
       
    71                                             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& 
       
    81             aObserver, 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, 
       
   147             TGlxFilterProperties& aFilterProperties);
       
   148     
       
   149     void AddMonthFilterL(CMdEObject* aMonth, TGlxFilterProperties& aFilterProperties);
       
   150         
       
   151 	/**
       
   152 	 * Set query contditions by container id and filter properties.
       
   153      * @param aLogicCondition logic condition to add conditions to
       
   154      * @param aContainerId Id of the container
       
   155      * @param aContainerIsLeft. This should be set to to ETrue if the container is on the left side of the releation, or
       
   156      * EFalse if the container is on the right side of the relation
       
   157      * 
       
   158      */	
       
   159     void SetQueryConditionsL(CMdEQuery& aQuery, const TGlxFilterProperties& aFilterProperties, 
       
   160             const TGlxMediaId aContainerId, CMdEObjectDef& aObjectDef);
       
   161 
       
   162     void SetQueryFilterConditionsL(CMdELogicCondition& aLogicCondition, CMdEObjectDef& aObjectDef,
       
   163             const TGlxFilterProperties& aFilterProperties);
       
   164 
       
   165     void SetSortOrderL(CMdEQuery& aQuery, CMdEObjectDef& aObjectDef, 
       
   166             const TGlxFilterProperties& aFilterProperties);
       
   167 
       
   168     /**
       
   169      * Returns the maximum number of items that a query should find.
       
   170      * @return Maximum number of results
       
   171      */
       
   172     TInt MaxQueryResultsCount(const TGlxFilterProperties& aFilterProperties) const;
       
   173     
       
   174     /**
       
   175      * Removes and destroys the oldest query in iQueries.
       
   176      */
       
   177     void RemoveQuery();
       
   178 
       
   179     void DoQueryL(CMdEObjectDef& aObjectDef, TBool aIsContent, TGlxQueryType aQueryType,
       
   180             TQueryResultMode aResultMode, const TGlxMediaId& aContainerId);
       
   181 
       
   182     /**
       
   183      * Adds queries for images and or videos to the query queue. The queries will return objects
       
   184      * of type image or video that have ids specified by aObjectIds. 
       
   185      * @param aObjectIds A list of the ids of the required objects.
       
   186      * @param aFilterProperties TGlxFilterProperties.iItemType is used to determine if only 
       
   187      * image or video queries are required if iItemType is not set to EGlxFilterImage or 
       
   188      * EGlxFitlerVideo a query for images will be queued first followed by a query for videos.
       
   189      */
       
   190     void QueueImageVideoObjectQueriesL(const RArray<TGlxMediaId>& aObjectIds, 
       
   191             const TGlxFilterProperties& aFilterProperties);
       
   192     
       
   193     /**
       
   194      * Adds a query for tag objects that have ids specified by aObjectIds
       
   195      * to the query queue.
       
   196      * @param aObjectIds A list of the ids of the required objects.
       
   197      */
       
   198     void QueueTagObjectQueryL(const RArray<TGlxMediaId>& aObjectIds);
       
   199 
       
   200     /**
       
   201      * Adds a query for album objects that have ids specified by aObjectIds
       
   202      * to the query queue.
       
   203      * @param aObjectIds A list of the ids of the required objects.
       
   204      */
       
   205     void QueueAlbumObjectQueryL(const RArray<TGlxMediaId>& aObjectIds);
       
   206     
       
   207     /**
       
   208      * Adds a query for "month" objects that have ids specified by aObjectIds
       
   209      * to the query queue.
       
   210      * @param aObjectIds A list of the ids of the required objects.
       
   211      */
       
   212     void QueueMonthObjectQueryL(const RArray<TGlxMediaId>& aObjectIds);
       
   213     
       
   214     /**
       
   215      * Adds a query for objects of type specified by aObjectDef
       
   216      * that have ids specified by aObjectIds to the query queue.
       
   217      * @param aObjectDef type of objects required.
       
   218      * @param aObjectIds A list of the ids of the required objects.
       
   219      * @param aQueryType The query type.
       
   220      */
       
   221     void QueueObjectQueryL(CMdEObjectDef& aObjectDef, 
       
   222             const RArray<TGlxMediaId>& aObjectIds, const TGlxQueryType& aQueryType);
       
   223 
       
   224     /**
       
   225      * Appends a query to the query queue. (the ownership of the query is transferred)
       
   226      * @param aQuery query to append to the query queue ownership is transferred to 
       
   227      * the query queue. It is expected that aQuery is not on the cleanupstack before the
       
   228      * call to AppendQueryL is made
       
   229      * @param aQueryType the query type.
       
   230      */
       
   231     void AppendQueryL(CMdEQuery* aQuery, const TGlxQueryType& aQueryType);
       
   232     
       
   233     /**
       
   234      * Executes the query at ordinal 0 in the
       
   235      * query list implementation can be overidden by
       
   236      * deriving classes.
       
   237      */
       
   238     virtual void ExecuteQueryL();
       
   239     
       
   240 private:
       
   241     /* 
       
   242     * Helper function TRAPed and called by HandleQueryCompleted()
       
   243     * @param aQuery the query that has been completed
       
   244     */
       
   245     void HandleQueryCompletedL(CMdEQuery& aQuery);
       
   246 
       
   247     /**
       
   248      * Removes the observer from any existing queries, cancels and destroys them
       
   249      */
       
   250     void DestroyQueries();
       
   251     
       
   252 private:
       
   253     /**
       
   254      * Default namespace def (not owned)
       
   255      */
       
   256     CMdENamespaceDef* iDefaultNameSpaceDef;
       
   257 
       
   258 protected:
       
   259     /**
       
   260      * Outstanding queries array (owned)
       
   261      */
       
   262     RPointerArray <CMdEQuery> iQueries;
       
   263     
       
   264     /**
       
   265      * Query types array (owned)
       
   266      */
       
   267     RArray <TGlxQueryType> iQueryTypes;
       
   268 
       
   269     /**
       
   270      * Filter properties
       
   271      */
       
   272     TGlxFilterProperties iFilterProperties;  
       
   273     };
       
   274 
       
   275 #endif //_C_GLXDATASOURCETASKMDS_H_