mpxplugins/serviceplugins/collectionplugins/inc/mpxdbtable.h
changeset 0 ff3acec5bc43
child 9 13afc0e517bd
equal deleted inserted replaced
-1:000000000000 0:ff3acec5bc43
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Base class for all table classes.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef MPXDBTABLE_H
       
    20 #define MPXDBTABLE_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <mpxattribute.h>
       
    25 #include "mpxtable.h"
       
    26 
       
    27 // CLASS FORWARDS
       
    28 class CMPXDbManager;
       
    29 class RSqlStatement;
       
    30 class CMPXMedia;
       
    31 class CMPXMediaArray;
       
    32 
       
    33 // CONSTANTS
       
    34 const TInt KMPXTableDefaultIndex = 0;
       
    35 
       
    36 // CLASS DECLARATION
       
    37 
       
    38 /**
       
    39 * Base class for all table classes
       
    40 *
       
    41 * @lib MPXDbPlugin.lib
       
    42 */
       
    43 class CMPXDbTable :
       
    44     public CBase,
       
    45     public MMPXTable
       
    46     {
       
    47     protected:
       
    48 
       
    49         /**
       
    50         * C++ constructor
       
    51         * @param aDbManager database manager instance
       
    52         */
       
    53         IMPORT_C CMPXDbTable(CMPXDbManager& aDbManager);
       
    54 
       
    55         /**
       
    56         * Safely construct things that can leave
       
    57         */
       
    58         IMPORT_C void BaseConstructL();
       
    59 
       
    60         /**
       
    61         * Destructor
       
    62         */
       
    63         IMPORT_C virtual ~CMPXDbTable();
       
    64 
       
    65     protected:
       
    66 
       
    67         /**
       
    68         * Update the media from the table. To be implemeted by derived classes, the default
       
    69         * implemetation does nothing.
       
    70         * @param aRecord table view
       
    71         * @param aAttrs the attributes to return
       
    72         * @param aMedia updated with the table info
       
    73         */
       
    74         IMPORT_C virtual void UpdateMediaL(RSqlStatement& aRecord, const TArray<TMPXAttribute>& aAttrs,
       
    75             CMPXMedia& aMedia);
       
    76 
       
    77         /**
       
    78         * Executes a query that retrieves information in a media array.
       
    79         * @param aAttrs the attributes to return
       
    80         * @param aMediaArray on return contains the results
       
    81         * @param aQuery query to be executed
       
    82         */
       
    83         IMPORT_C void ExecuteMediaQueryL(const TArray<TMPXAttribute>& aAttrs,
       
    84             CMPXMediaArray& aMediaArray, const TDesC& aQuery);
       
    85 
       
    86         /**
       
    87         * Executes a query that retrieves information in a media array.
       
    88         * @param aAttrs the attributes to return
       
    89         * @param aMediaArray on return contains the results
       
    90         * @param aAsc if the block is in ascending order
       
    91         * @param aQuery query to be executed
       
    92         */
       
    93         IMPORT_C void ExecuteMediaQueryL(const TArray<TMPXAttribute>& aAttrs,
       
    94             CMPXMediaArray& aMediaArray, const TBool aAsc, const TDesC& aQuery);
       
    95 
       
    96         /**
       
    97         * Executes a query with an int parameter that retrieves information in a media array.
       
    98         * @param aAttrs the attributes to return
       
    99         * @param aMediaArray on return contains the results
       
   100         * @param aQuery query to be executed
       
   101         * @param aValue integer parameter
       
   102         */
       
   103         IMPORT_C void ExecuteMediaQueryL(const TArray<TMPXAttribute>& aAttrs,
       
   104             CMPXMediaArray& aMediaArray, const TDesC& aQuery, TInt aValue);
       
   105 
       
   106         /**
       
   107         * Executes a query with one parameter that retrieves information in a media array.
       
   108         * @param aAttrs the attributes to return
       
   109         * @param aMediaArray on return contains the results
       
   110         * @param aQuery query to be executed
       
   111         * @param aValue1 string parameter
       
   112         * @param aValue2 integer parameter
       
   113         */
       
   114         IMPORT_C void ExecuteMediaQueryL(const TArray<TMPXAttribute>& aAttrs,
       
   115             CMPXMediaArray& aMediaArray, const TDesC& aQuery, const TDesC& aValue);
       
   116 
       
   117         /**
       
   118         * Executes a query with two int parameters that retrieves information in a media array.
       
   119         * @param aAttrs the attributes to return
       
   120         * @param aMediaArray on return contains the results
       
   121         * @param aQuery query to be executed
       
   122         * @param aValue1 integer parameter
       
   123         * @param aValue2 integer parameter
       
   124         */
       
   125         IMPORT_C void ExecuteMediaQueryL(const TArray<TMPXAttribute>& aAttrs,
       
   126             CMPXMediaArray& aMediaArray, const TDesC& aQuery, TInt aValue1, TInt aValue2);
       
   127 
       
   128         /**
       
   129         * Executes a query with two parameters that retrieves information in a media array.
       
   130         * @param aAttrs the attributes to return
       
   131         * @param aMediaArray on return contains the results
       
   132         * @param aQuery query to be executed
       
   133         * @param aValue1 string parameter
       
   134         * @param aValue2 integer parameter
       
   135         */
       
   136         IMPORT_C void ExecuteMediaQueryL(const TArray<TMPXAttribute>& aAttrs,
       
   137             CMPXMediaArray& aMediaArray, const TDesC& aQuery, const TDesC& aValue1, TInt aValue2);
       
   138 
       
   139         /**
       
   140         * Executes a query with two parameters that retrieves information in a media array.
       
   141         * @param aAttrs the attributes to return
       
   142         * @param aMediaArray on return contains the results
       
   143         * @param aQuery query to be executed
       
   144         * @param aValue1 string parameter
       
   145         * @param aValue2 string parameter
       
   146         */
       
   147         IMPORT_C void ExecuteMediaQueryL(const TArray<TMPXAttribute>& aAttrs,
       
   148             CMPXMediaArray& aMediaArray, const TDesC& aQuery, const TDesC& aValue1, const TDesC& aValue2);
       
   149 
       
   150         /**
       
   151         * Executes a query with four parameters that retrieves information in a media array.
       
   152         * @param aAttrs the attributes to return
       
   153         * @param aMediaArray on return contains the results
       
   154         * @param aQuery query to be executed
       
   155         * @param aValue1 string parameter
       
   156         * @param aValue2 integer parameter
       
   157         * @param aValue3 string parameter
       
   158         * @param aValue4 integer parameter
       
   159         */
       
   160         IMPORT_C void ExecuteMediaQueryL(const TArray<TMPXAttribute>& aAttrs,
       
   161             CMPXMediaArray& aMediaArray, const TDesC& aQuery,
       
   162                 const TDesC& aValue1, TInt aValue2,
       
   163                 const TDesC& aValue3, TInt aValue4);
       
   164 
       
   165         /**
       
   166         * Executes a query that retrieves information in a media item.
       
   167         * @param aAttrs the attributes to return
       
   168         * @param aMedia on return contains the result
       
   169         * @param aQuery query to be executed
       
   170         */
       
   171         IMPORT_C void ExecuteMediaQueryL(const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aMedia,
       
   172             const TDesC& aQuery);
       
   173 
       
   174         /**
       
   175         * Executes a query with an int that retrieves information in a media item.
       
   176         * @param aAttrs the attributes to return
       
   177         * @param aMedia on return contains the result
       
   178         * @param aQuery query to be executed
       
   179         * @param aValue integer parameter
       
   180         */
       
   181         IMPORT_C void ExecuteMediaQueryL(const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aMedia,
       
   182             const TDesC& aQuery, TInt aValue);
       
   183 
       
   184         /**
       
   185         * Executes a query that returns an int field.
       
   186         * @param aQuery query to be executed
       
   187         * @return returned field value
       
   188         */
       
   189         IMPORT_C TUint32 ExecuteIntQueryL(const TDesC& aQuery);
       
   190 
       
   191         /**
       
   192         * Executes a query with an int parameter that returns an int field.
       
   193         * @param aQuery query to be executed
       
   194         * @param aValue integer parameter
       
   195         * @return returned field value
       
   196         */
       
   197         IMPORT_C TUint32 ExecuteIntQueryL(const TDesC& aQuery, TUint32 aValue);
       
   198 
       
   199         /**
       
   200         * Executes a query with a string parameter that returns an int field.
       
   201         * @param aQuery query to be executed
       
   202         * @param aValue string parameter
       
   203         * @return returned field value
       
   204         */
       
   205         IMPORT_C TUint32 ExecuteIntQueryL(const TDesC& aQuery, const TDesC& aValue);
       
   206 
       
   207         /**
       
   208         * Executes a query with a string and an int parameter that returns an int field.
       
   209         * @param aQuery query to be executed
       
   210         * @param aValue1 string parameter
       
   211         * @param aValue2 int parameter
       
   212         * @return returned field value
       
   213         */
       
   214         IMPORT_C TUint32 ExecuteIntQueryL(const TDesC& aQuery, const TDesC& aValue1, TUint32 aValue2);
       
   215 
       
   216         /**
       
   217         * Executes a query with two int parameters that returns an int field.
       
   218         * @param aQuery query to be executed
       
   219         * @param aValue1 int parameter
       
   220         * @param aValue2 int parameter
       
   221         * @return returned field value
       
   222         */
       
   223         IMPORT_C TUint32 ExecuteIntQueryL(const TDesC& aQuery, TUint32 aValue1, TUint32 aValue2);
       
   224 
       
   225         /**
       
   226          * Executes a query that returns an int field.
       
   227          * @param aDriveID drive identifier
       
   228          * @param aQuery query to be executed
       
   229          * @return returned field value
       
   230          */
       
   231          IMPORT_C TUint32 ExecuteIntQueryL(TInt aDriveID,const TDesC& aQuery);
       
   232 
       
   233         /**
       
   234         * Executes a query that returns one or multiple records with one int field each.
       
   235         * The int values are summed and the result returned.
       
   236         * @param aQuery query to be executed
       
   237         * @return sum of int values
       
   238         */
       
   239         IMPORT_C TInt ExecuteSumQueryL(const TDesC& aQuery);
       
   240 
       
   241         /**
       
   242         * Executes a sum query with an int parameter.
       
   243         * @param aQuery query to be executed
       
   244         * @param aValue int parameter
       
   245         * @return sum of int values
       
   246         */
       
   247         IMPORT_C TInt ExecuteSumQueryL(const TDesC& aQuery, TUint32 aValue);
       
   248 
       
   249         /**
       
   250         * Executes a sum query with two int parameters.
       
   251         * @param aQuery query to be executed
       
   252         * @param aValue1 int parameter
       
   253         * @param aValue2 int parameter
       
   254         * @return sum of int values
       
   255         */
       
   256         IMPORT_C TInt ExecuteSumQueryL(const TDesC& aQuery,
       
   257             TUint32 aValue1, TUint32 aValue2);
       
   258 
       
   259         /**
       
   260         * Executes a sum query with a string and an int parameter.
       
   261         * @param aQuery query to be executed
       
   262         * @param aValue1 string parameter
       
   263         * @param aValue2 int parameter
       
   264         * @return sum of int values
       
   265         */
       
   266         IMPORT_C TUint32 ExecuteSumQueryL(const TDesC& aQuery,
       
   267             const TDesC& aValue1, TUint32 aValue2);
       
   268 
       
   269         /**
       
   270         * Executes a sum query with three int parameters.
       
   271         * @param aQuery query to be executed
       
   272         * @param aValue1 int parameter
       
   273         * @param aValue2 int parameter
       
   274         * @param aValue3 int parameter
       
   275         * @return sum of int values
       
   276         */
       
   277         IMPORT_C TInt ExecuteSumQueryL(const TDesC& aQuery,
       
   278             TUint32 aValue1, TUint32 aValue2, TUint32 aValue3);
       
   279 
       
   280         /**
       
   281         * Executes a sum query with a string and an int parameter.
       
   282         * @param aQuery query to be executed
       
   283         * @param aValue1 string parameter
       
   284         * @param aValue2 string parameter
       
   285         * @return sum of int values
       
   286         */
       
   287         IMPORT_C TInt ExecuteSumQueryL(const TDesC& aQuery,
       
   288             const TDesC& aValue1, const TDesC& aValue2);
       
   289 
       
   290         /**
       
   291         * Executes a sum query with a string and an int parameter.
       
   292         * @param aQuery query to be executed
       
   293         * @param aValue string parameter
       
   294         * @return sum of int values
       
   295         */
       
   296         IMPORT_C TInt ExecuteSumQueryL(const TDesC& aQuery, const TDesC& aValue);
       
   297 
       
   298         /**
       
   299         * Executes a sum query with a string and an int parameter.
       
   300         * @param aQuery query to be executed
       
   301         * @param aValue1 string parameter
       
   302         * @param aValue2 int parameter
       
   303         * @param aValue3 string parameter
       
   304         * @param aValue4 int parameter
       
   305         * @return sum of int values
       
   306         */
       
   307         IMPORT_C TInt ExecuteSumQueryL(const TDesC& aQuery,
       
   308             const TDesC& aValue1, TUint32 aValue2, const TDesC& aValue3, TUint32 aValue4);
       
   309 
       
   310 
       
   311         /**
       
   312         * Executes a media query that is bound to a specific query id.
       
   313         * If the query has not been prepared it will be prepared
       
   314         * @param aAttrs the attributes to return
       
   315         * @param aMediaArray on return contains the results
       
   316         * @param aQuery query to be executed
       
   317         * @param aValue1 TInt value to be bound to the query
       
   318         * @param aValue2 TInt value to be bound to the query
       
   319         * @param aQueryId unique ID to identify the query
       
   320         */
       
   321         IMPORT_C void ExecuteMediaQueryL( const TArray<TMPXAttribute>& aAttrs,
       
   322                                           CMPXMediaArray& aMediaArray,
       
   323                                           const TDesC& aQuery,
       
   324                                           TInt aValue1,
       
   325                                           TInt aValue2,
       
   326                                           TUint aQueryId );
       
   327 
       
   328         /**
       
   329         * Executes a media query that is bound to a specific query id.
       
   330         * If the query has not been prepared it will be prepared
       
   331         * @param aAttrs the attributes to return
       
   332         * @param aMediaArray on return contains the results
       
   333         * @param aQuery query to be executed
       
   334         * @param aValue1 value to be bound to the query
       
   335         * @param aValue2 value to be bound to the query
       
   336         * @param aAsc ascending or descending data retrival
       
   337         * @param aQueryId unique ID to identify the query
       
   338         */
       
   339         IMPORT_C void ExecuteMediaQueryL( const TArray<TMPXAttribute>& aAttrs,
       
   340                                           CMPXMediaArray& aMediaArray,
       
   341                                           const TDesC& aQuery,
       
   342                                           const TDesC& aTitle,
       
   343                                           TInt aCount,
       
   344                                           TBool aAsc,
       
   345                                           TUint aQueryId );
       
   346 
       
   347         /**
       
   348         * Checks that the specified query can be executed.
       
   349         * @param aDatabase database to execute the query on
       
   350         * @param aQuery query to execute
       
   351         * @return ETrue if the query can be executed, EFalse otherwise
       
   352         */
       
   353         IMPORT_C TBool DoCheckTable(RSqlDatabase& aDatabase, const TDesC& aQuery);
       
   354 
       
   355         /**
       
   356         * Executes a query with four parameters that retrieves information in a media array.
       
   357         * @param aDrive integer parameter
       
   358         * @param aAttrs the attributes to return
       
   359         * @param aMediaArray on return contains the results
       
   360         * @param aQuery query to be executed
       
   361         * @param aPlaylistId string parameter
       
   362         */
       
   363         IMPORT_C void ExecuteMediaQueryL(TInt aDrive, const TArray<TMPXAttribute>& aAttrs,
       
   364         	CMPXMediaArray& aMediaArray,const TDesC& aQuery,TInt aPlaylistId);
       
   365        
       
   366         /**
       
   367         * Executes a query with an int parameter that retrieves information in a media array.
       
   368         * @param aDrive integer parameter
       
   369         * @param aAttrs the attributes to return
       
   370         * @param aMediaArray on return contains the results
       
   371         * @param aQuery query to be executed
       
   372         */
       
   373         IMPORT_C void ExecuteMediaQueryOnDriveL(TInt aDrive,const TArray<TMPXAttribute>& aAttrs,
       
   374         	    CMPXMediaArray& aMediaArray, const TDesC& aQuery);
       
   375             
       
   376     protected:    // Data
       
   377 
       
   378         CMPXDbManager& iDbManager;
       
   379     };
       
   380 
       
   381 #endif // MPXDBTABLE_H
       
   382 
       
   383 // End of File