terminalsecurity/SCP/SCPDatabase/src/SCPParamDB.cpp
changeset 0 b497e44ab2fc
child 5 3f7d9dbe57c8
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 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 #include "SCPDBDebug.h"
       
    18 #include "SCPParamDB.h"
       
    19 #include "SCPDBCommon.h"
       
    20 #include "SCPConfiguration.h"
       
    21 
       
    22 #define __LEAVE_IF_ERROR(x) if(KErrNone!=x) {_SCPDB_LOG(_L("LEAVE (%d) at %s : %d"), x, __FILE__, __LINE__); User::Leave(x); }
       
    23 
       
    24 CSCPParamDB :: ~CSCPParamDB() {
       
    25     _SCPDB_LOG(_L("[CSCPParamDB]-> >>> ~CSCPDeviceLockdb"));
       
    26 
       
    27     if(iColSet) {
       
    28         delete iColSet;
       
    29         iColSet = NULL;
       
    30     }
       
    31 
       
    32     iTable.Close();
       
    33     iParameterDB.Close();
       
    34     iRdbSession.Close();
       
    35     _SCPDB_LOG(_L("[CSCPParamDB]-> <<< ~CSCPDeviceLockdb"));
       
    36 }
       
    37 
       
    38 CSCPParamDB* CSCPParamDB :: NewL() {
       
    39     _SCPDB_LOG(_L("[CSCPParamDB]-> >>> NewL()"));
       
    40     CSCPParamDB* self = new(ELeave) CSCPParamDB();
       
    41     CleanupStack :: PushL(self);
       
    42     self->ConstructL();
       
    43     CleanupStack :: Pop();
       
    44     _SCPDB_LOG(_L("[CSCPParamDB]-> <<< NewL()"));
       
    45     return self;
       
    46 }
       
    47 
       
    48 CSCPParamDB* CSCPParamDB :: NewLC() {
       
    49     _SCPDB_LOG(_L("[CSCPParamDB]-> >>> NewLC()"));
       
    50     CSCPParamDB* self = NewL();
       
    51     CleanupStack :: PushL(self);
       
    52     _SCPDB_LOG(_L("[CSCPParamDB]-> <<< NewLC()"));
       
    53     return self;
       
    54 }
       
    55 
       
    56 void CSCPParamDB :: ConstructL() {
       
    57     __LEAVE_IF_ERROR(iRdbSession.Connect());
       
    58 
       
    59     _SCPDB_LOG(_L("[CSCPParamDB]-> >>> ConstructL"));
       
    60 
       
    61     TParse lDBName;
       
    62     lDBName.Set(KDatabaseName(), NULL, NULL);
       
    63     
       
    64     _SCPDB_LOG(_L("[CSCPParamDB]-> Opening the database..."));
       
    65     TInt lErr = iParameterDB.Open ( iRdbSession, lDBName.FullName(), KDBMSOwnerProcess);
       
    66     _SCPDB_LOG(_L("[CSCPParamDB]-> lErr=%d"), lErr);
       
    67     
       
    68     switch(lErr) {
       
    69         case KErrNone:
       
    70             break;    
       
    71         default: {
       
    72             _SCPDB_LOG(_L("[CSCPParamDB]-> Deleting the database (if any)..."));
       
    73             TInt x = iRdbSession.DeleteDatabase(lDBName.FullName(), KOwnerProcess);
       
    74             
       
    75             _SCPDB_LOG(_L("[CSCPParamDB]-> Creating the database afresh..."));
       
    76             __LEAVE_IF_ERROR( iParameterDB.Create( iRdbSession, lDBName.FullName(), KDBMSOwnerProcess ) );
       
    77             __LEAVE_IF_ERROR( iParameterDB.Begin() );
       
    78             _SCPDB_LOG(_L("[CSCPParamDB]-> Creating the table PARAMETER..."));
       
    79             __LEAVE_IF_ERROR( iParameterDB.Execute(KCreateTable) );
       
    80             _SCPDB_LOG(_L("[CSCPParamDB]-> calling commit..."));
       
    81             __LEAVE_IF_ERROR( iParameterDB.Commit() );
       
    82             _SCPDB_LOG(_L("[CSCPParamDB]-> calling compact..."));
       
    83             __LEAVE_IF_ERROR( iParameterDB.Compact() );
       
    84         }
       
    85         break;
       
    86     }
       
    87 
       
    88     _SCPDB_LOG(_L("[CSCPParamDB]-> Opening the table PARAMETER..."));
       
    89     lErr = iTable.Open (iParameterDB, KTblParameter);
       
    90     _SCPDB_LOG(_L("[CSCPParamDB]-> lErr=%d"), lErr);
       
    91     
       
    92     if(lErr != KErrNone) {
       
    93         User :: Leave(lErr);
       
    94     }
       
    95     
       
    96     iColSet = iTable.ColSetL();
       
    97     _SCPDB_LOG(_L("[CSCPParamDB]-> ConstructL <<"));
       
    98 }
       
    99 
       
   100 TInt CSCPParamDB :: SetValueForParameterL(TInt aParamID, const TInt32 aValue, const TInt32 aApp) {
       
   101     _SCPDB_LOG(_L("[CSCPParamDB]-> SetValueForParameterL >>>"));
       
   102 
       
   103     HBufC* sql = HBufC :: NewLC(256);
       
   104     sql->Des().Format(KUpdateValIntWhereParamId, aApp, aValue, aParamID);
       
   105 
       
   106     _SCPDB_LOG(_L("[CSCPParamDB]-> SQL Query: %S"), &sql->Des());
       
   107 
       
   108     __LEAVE_IF_ERROR(iParameterDB.Begin());
       
   109 
       
   110     TInt rows = (iParameterDB.Execute(*sql));
       
   111 
       
   112     __LEAVE_IF_ERROR(iParameterDB.Commit());
       
   113     __LEAVE_IF_ERROR(iParameterDB.Compact());
       
   114 
       
   115     if(rows == 0) {
       
   116         sql->Des().Format(KInsertValInt, aParamID, aValue, aApp);
       
   117 
       
   118         __LEAVE_IF_ERROR(iParameterDB.Begin());
       
   119 
       
   120         TInt rows = (iParameterDB.Execute(*sql));
       
   121 
       
   122         __LEAVE_IF_ERROR(iParameterDB.Commit());
       
   123         __LEAVE_IF_ERROR(iParameterDB.Compact());
       
   124 
       
   125         if(rows == 0) {
       
   126             _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: Unable to insert value for the parameter '%d'..."), aParamID);
       
   127             User :: Leave(KErrCorrupt);
       
   128         }
       
   129     }
       
   130     else if(rows > 1) {
       
   131         _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: More than one record meets the criterion. Db is corrupt! Leaving..."));
       
   132         User :: Leave(KErrCorrupt);
       
   133     }
       
   134 
       
   135     CleanupStack :: PopAndDestroy();
       
   136     _SCPDB_LOG(_L("[CSCPParamDB]-> SetValueForParameterL <<<"));
       
   137     return KErrNone;
       
   138 }
       
   139 
       
   140 TInt CSCPParamDB :: SetValuesForParameterL(TInt aParamID, const RPointerArray <HBufC>& aParamValues, const TInt32 aApp) {
       
   141     _SCPDB_LOG(_L("[CSCPParamDB]-> SetValuesForParameterL >>>"));
       
   142     
       
   143     TInt lCount = aParamValues.Count();
       
   144     
       
   145     for(TInt i=0; i < lCount; i++) {
       
   146         HBufC * lDataPtr = aParamValues[i];
       
   147         HBufC* sql = HBufC :: NewLC(KInsertValDes().Length() + lDataPtr->Des().Length() + 40);        
       
   148         sql->Des().Format(KInsertValDes, aParamID, &lDataPtr->Des(), aApp);
       
   149 
       
   150         __LEAVE_IF_ERROR(iParameterDB.Begin());
       
   151 
       
   152         TInt rows = (iParameterDB.Execute(*sql));
       
   153 
       
   154         __LEAVE_IF_ERROR(iParameterDB.Commit());
       
   155         __LEAVE_IF_ERROR(iParameterDB.Compact());
       
   156 
       
   157         if(rows == 0) {
       
   158             _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: Unable to insert value for the parameter '%d'..."), aParamID);
       
   159             User :: Leave(KErrCorrupt);
       
   160         }
       
   161         
       
   162         CleanupStack :: PopAndDestroy();
       
   163     }
       
   164     
       
   165     _SCPDB_LOG(_L("[CSCPParamDB]-> SetValuesForParameterL <<<"));
       
   166     return KErrNone;
       
   167 }
       
   168 
       
   169 TInt CSCPParamDB :: GetValueForParameterL(TInt aParamID, TInt32& aValue, TInt32& aApp) {
       
   170     _SCPDB_LOG(_L("[CSCPParamDB]-> GetValueForParameterL >>>"));
       
   171 
       
   172     RDbView lDBView;
       
   173     CleanupClosePushL(lDBView);
       
   174 
       
   175     HBufC* lSelectQry  = HBufC :: NewLC(KSelectWhereParamId().Length() + 15);
       
   176     lSelectQry->Des().Format(KSelectWhereParamId, aParamID);
       
   177 
       
   178     __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
       
   179     __LEAVE_IF_ERROR(lDBView.EvaluateAll());
       
   180     lDBView.FirstL();
       
   181 
       
   182     TInt lRowCount = lDBView.CountL();
       
   183 
       
   184     if(lRowCount == 0) {
       
   185         _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter"));
       
   186         CleanupStack :: PopAndDestroy(2);
       
   187         return KErrNotFound;
       
   188     }
       
   189     else if(lRowCount > 1) {
       
   190         _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: More than one record matches the criterion. Db is corrupt! Leaving..."));
       
   191         User :: Leave(KErrCorrupt);
       
   192     }
       
   193 
       
   194     lDBView.GetL();
       
   195     aApp = lDBView.ColInt(iColSet->ColNo(KColAppId));
       
   196     aValue = lDBView.ColInt(iColSet->ColNo(KColValueInt));
       
   197     CleanupStack :: PopAndDestroy(2);
       
   198 
       
   199     _SCPDB_LOG(_L("[CSCPParamDB]-> GetValueForParameterL <<<"));
       
   200     return KErrNone;
       
   201 }
       
   202 
       
   203 TInt CSCPParamDB :: GetValuesForParameterL(TInt aParamID, RPointerArray <HBufC>& aParamValues, const TInt32 aApp) {
       
   204     _SCPDB_LOG(_L("[CSCPParamDB]-> GetValueForParameterL >>>"));
       
   205 
       
   206     RDbView lDBView;
       
   207     CleanupClosePushL(lDBView);
       
   208 
       
   209     HBufC* lSelectQry  = HBufC :: NewLC(KSelectWhereParamIdAppID().Length() + 40);
       
   210     lSelectQry->Des().Format (KSelectWhereParamIdAppID, aParamID, aApp);
       
   211 
       
   212     __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
       
   213     __LEAVE_IF_ERROR(lDBView.EvaluateAll());
       
   214     
       
   215     lDBView.FirstL();
       
   216 
       
   217     TInt size(0);
       
   218     TInt lRowCount = lDBView.CountL();
       
   219 
       
   220     if(lRowCount == 0) {
       
   221         _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter"));
       
   222         CleanupStack :: PopAndDestroy(2);
       
   223         return KErrNotFound;
       
   224     }
       
   225     
       
   226     TInt lErr(KErrNone);
       
   227     
       
   228     do {
       
   229         lDBView.GetL();
       
   230         size = lDBView.ColDes(iColSet->ColNo(KColValueDes)).Size();
       
   231 
       
   232         if(size) {
       
   233             HBufC* lBuff = HBufC :: NewL(size);
       
   234             TPtr lPtr(lBuff->Des());
       
   235             lPtr.Copy(lDBView.ColDes(iColSet->ColNo(KColValueDes)));
       
   236           
       
   237             TRAP(lErr, aParamValues.AppendL(lBuff));
       
   238             
       
   239             if(lErr != KErrNone) {
       
   240                 aParamValues.ResetAndDestroy();
       
   241                 User :: Leave(lErr);
       
   242             }
       
   243         }
       
   244     }
       
   245     while(lDBView.NextL());
       
   246 
       
   247     CleanupStack :: PopAndDestroy(2);
       
   248     _SCPDB_LOG(_L("[CSCPParamDB]-> GetValuesForParameterL <<<"));
       
   249     return KErrNone;   
       
   250 }
       
   251 
       
   252 TInt CSCPParamDB :: GetApplicationIDListL(RArray <TUid>& aIDArray) {
       
   253     _SCPDB_LOG(_L("[CSCPParamDB]-> GetApplicationIDList() >>>"));
       
   254     
       
   255     RDbView lDBView;
       
   256     CleanupClosePushL(lDBView);
       
   257     
       
   258     HBufC* lSelectQry  = HBufC :: NewLC(KSelectAll().Length());
       
   259     lSelectQry->Des().Append(KSelectAll);
       
   260     
       
   261     __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
       
   262     __LEAVE_IF_ERROR(lDBView.EvaluateAll());
       
   263     
       
   264     TBool lStatus(EFalse);
       
   265     TInt lRet(KErrNone);
       
   266     
       
   267     TRAP(lRet, lStatus = lDBView.FirstL());
       
   268     
       
   269     if(lRet == KErrNone && lStatus) {
       
   270         do {
       
   271             lDBView.GetL();
       
   272             TUid lAppUID = TUid :: Uid(lDBView.ColInt(iColSet->ColNo(KColAppId)));
       
   273             
       
   274             if(aIDArray.Find(lAppUID) == KErrNotFound) {
       
   275                 aIDArray.AppendL(lAppUID);
       
   276             }
       
   277         }
       
   278         while(lDBView.NextL());
       
   279     }
       
   280     
       
   281     _SCPDB_LOG(_L("[CSCPParamDB]-> GetApplicationIDList() >>>"));
       
   282     CleanupStack :: PopAndDestroy(2);
       
   283     return KErrNone;
       
   284 }
       
   285 
       
   286 TBool CSCPParamDB :: IsParamValueSharedL(HBufC* aParamValue, const TInt32 aApp) {
       
   287     _SCPDB_LOG(_L("[CSCPParamDB]-> IsParamValueShared >>>"));
       
   288     
       
   289     if(aParamValue == NULL) {
       
   290         return KErrArgument;
       
   291     }
       
   292     
       
   293     RDbView lDBView;
       
   294     CleanupClosePushL(lDBView);
       
   295     
       
   296     HBufC* lSelectQry  = HBufC :: NewLC(KSelectAppIDParamValNotIn().Length() + aParamValue->Des().Length() + 50);
       
   297     lSelectQry->Des().Format(KSelectAppIDParamValNotIn, aApp, &aParamValue->Des());
       
   298     
       
   299     __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
       
   300     __LEAVE_IF_ERROR(lDBView.EvaluateAll());
       
   301     
       
   302     TInt lRowCnt(0);
       
   303     TInt lStatus(KErrNone);
       
   304     
       
   305     TRAP(lStatus, lRowCnt = lDBView.CountL());
       
   306     
       
   307     if(lStatus != KErrNone) {
       
   308         _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: Unable to determine row count..."));    
       
   309     }
       
   310     else {
       
   311         if(lRowCnt > 0) {
       
   312             CleanupStack :: PopAndDestroy(2);
       
   313             return ETrue;
       
   314         }
       
   315     }
       
   316     
       
   317     _SCPDB_LOG(_L("[CSCPParamDB]-> IsParamValueShared <<<"));
       
   318     CleanupStack :: PopAndDestroy(2);
       
   319     return EFalse;
       
   320 }
       
   321 
       
   322 TInt CSCPParamDB :: DropValuesL(TInt aParamID, RPointerArray <HBufC>& aParamValues, const TInt32 aApp) {
       
   323     _SCPDB_LOG(_L("[CSCPParamDB]-> DropValuesL() >>>"));
       
   324     
       
   325     TInt lCount = aParamValues.Count();
       
   326     
       
   327     if(lCount < 1) {
       
   328         _SCPDB_LOG(_L("[CSCPParamDB]-> WARNING: Nothing to do!!"));
       
   329         return KErrNone;  
       
   330     }
       
   331     
       
   332     TInt lAffRows(0);
       
   333     HBufC* lDelQuery(NULL);
       
   334     
       
   335     if(iParameterDB.InTransaction()) {
       
   336         _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: The DB in use! leaving..."));
       
   337         User :: Leave(KErrInUse);
       
   338     }
       
   339         
       
   340     __LEAVE_IF_ERROR(iParameterDB.Begin());
       
   341     
       
   342     for(TInt i=0; i < lCount; i++) {
       
   343         if(aApp == -1) {
       
   344             lDelQuery = HBufC :: NewLC(KDeleteWhereParamIDValueDes().Length() + (aParamValues[i])->Length());
       
   345             lDelQuery->Des().Format(KDeleteWhereParamIDValueDes, aParamID, &(aParamValues[i])->Des());
       
   346         }
       
   347         else {
       
   348             lDelQuery = HBufC :: NewLC(KDeleteWhereParamIDValueDesAppID().Length() + (aParamValues[i])->Des().Length() + 100);
       
   349             lDelQuery->Des().Format(KDeleteWhereParamIDValueDesAppID, aParamID, &(aParamValues[i])->Des(), aApp);
       
   350         }
       
   351 
       
   352         lAffRows = iParameterDB.Execute(*lDelQuery);
       
   353         _SCPDB_LOG(_L("[CSCPParamDB]-> INFO: Total rows affected=%d"), lAffRows);
       
   354         CleanupStack :: PopAndDestroy();
       
   355     }
       
   356     
       
   357     TInt lErr = iParameterDB.Commit();
       
   358     
       
   359     if(lErr != KErrNone) {
       
   360         _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: Commit failed!!"));
       
   361         iParameterDB.Rollback();
       
   362         User :: Leave(lErr);
       
   363     }
       
   364     
       
   365     _SCPDB_LOG(_L("[CSCPParamDB]-> DropValuesL() <<<"));
       
   366     return KErrNone;
       
   367 }
       
   368 
       
   369 TInt CSCPParamDB :: ListParamsUsedByAppL(RArray <TInt>& aParamIds, const TInt32 aApp) {
       
   370     _SCPDB_LOG(_L("[CSCPParamDB]-> ListParamsUsedByApp() >>>"));
       
   371     
       
   372     RDbView lDBView;
       
   373     CleanupClosePushL(lDBView);
       
   374     
       
   375     HBufC* lSelectQry(NULL);
       
   376     
       
   377     if(aApp == -1) {
       
   378         lSelectQry = HBufC :: NewLC(KSelectAllAscParamID().Length());
       
   379         lSelectQry->Des().Append(KSelectAllAscParamID);
       
   380     }
       
   381     else {
       
   382         lSelectQry = HBufC :: NewLC(KSelectWhereAppIdByAscParamID().Length() + 15);
       
   383         lSelectQry->Des().Format(KSelectWhereAppIdByAscParamID, aApp);
       
   384     }
       
   385     
       
   386     _SCPDB_LOG(_L("[CSCPParamDB]-> SQL Query: %S"), &lSelectQry->Des());
       
   387     _SCPDB_LOG(_L("[CSCPParamDB]-> Executing the query..."));
       
   388     __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(lSelectQry->Des())));
       
   389     __LEAVE_IF_ERROR(lDBView.EvaluateAll());
       
   390     
       
   391     TInt lErr(KErrNone);
       
   392     TInt lStatus(KErrNone);    
       
   393     
       
   394     TRAP(lErr, lStatus = lDBView.FirstL());
       
   395     _SCPDB_LOG(_L("[CSCPParamDB]-> Fetching values for the column KColParamId"));
       
   396     
       
   397     if(lErr == KErrNone && lStatus) {
       
   398         do {
       
   399             lDBView.GetL();
       
   400             TInt lPID = lDBView.ColInt(iColSet->ColNo(KColParamId));
       
   401             
       
   402             if(aParamIds.Find(lPID) == KErrNotFound) {
       
   403                 aParamIds.AppendL(lPID);
       
   404             }
       
   405         }
       
   406         while(lDBView.NextL());
       
   407     }
       
   408     
       
   409     _SCPDB_LOG(_L("[CSCPParamDB]-> Query execution complete..."));
       
   410     CleanupStack :: PopAndDestroy(2);
       
   411     _SCPDB_LOG(_L("[CSCPParamDB]-> ListParamsUsedByApp() <<<"));
       
   412     return KErrNone;
       
   413 }
       
   414 
       
   415 TInt CSCPParamDB :: DropValuesL(TInt aParamID, const TInt32 aApp) {
       
   416     _SCPDB_LOG(_L("[CSCPParamDB]-> DropValuesL() >>>"));
       
   417     
       
   418     TInt lAffRows(0);
       
   419     HBufC* lDelQuery(NULL);
       
   420     
       
   421     if(iParameterDB.InTransaction()) {
       
   422         _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: The DB in use! leaving..."));
       
   423         User :: Leave(KErrInUse);
       
   424     }
       
   425         
       
   426     __LEAVE_IF_ERROR(iParameterDB.Begin());
       
   427     
       
   428     if(aApp == -1) {
       
   429         lDelQuery = HBufC :: NewLC(KDeleteWhereParamID().Length() + 50);
       
   430         lDelQuery->Des().Format(KDeleteWhereParamID, aParamID);
       
   431     }
       
   432     else {
       
   433         lDelQuery = HBufC :: NewLC(KDeleteWhereParamIDAppID().Length() + 100);
       
   434         lDelQuery->Des().Format(KDeleteWhereParamIDAppID, aParamID, aApp);
       
   435     }
       
   436     _SCPDB_LOG(_L("[CSCPParamDB]-> SQL Query: %S"), &lDelQuery->Des());
       
   437 
       
   438     lAffRows = iParameterDB.Execute(*lDelQuery);
       
   439     _SCPDB_LOG(_L("[CSCPParamDB]-> INFO: Total rows affected=%d"), lAffRows);
       
   440     CleanupStack :: PopAndDestroy();
       
   441     
       
   442     TInt lErr = iParameterDB.Commit();
       
   443     
       
   444     if(lErr != KErrNone) {
       
   445         _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: Commit failed!!"));
       
   446         iParameterDB.Rollback();
       
   447         User :: Leave(lErr);
       
   448     }
       
   449     
       
   450     _SCPDB_LOG(_L("[CSCPParamDB]-> DropValuesL() <<<"));
       
   451     return KErrNone;
       
   452 }
       
   453 
       
   454 TInt CSCPParamDB :: ListEntriesL(RArray <TInt32>& aNumCols, RPointerArray <HBufC>& aDesCols, const TInt32 aApp) {
       
   455     _SCPDB_LOG(_L("[CSCPParamDB]-> ListEntries() >>>"));
       
   456     
       
   457     RDbView lDBView;
       
   458     CleanupClosePushL(lDBView);
       
   459     
       
   460     HBufC* lSelectQry(NULL);
       
   461     
       
   462     if(aApp == -1) {
       
   463         lSelectQry = HBufC :: NewLC(KSelectAll().Length() + 50);
       
   464         lSelectQry->Des().Format(KSelectAll);
       
   465     }
       
   466     else {
       
   467         lSelectQry = HBufC :: NewLC(KSelectWhereAppId().Length() + 30);
       
   468         lSelectQry->Des().Format(KSelectWhereAppId, aApp);
       
   469     }
       
   470     
       
   471     __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
       
   472     __LEAVE_IF_ERROR(lDBView.EvaluateAll());
       
   473 
       
   474     TInt lRet(KErrNone);
       
   475     TBool lStatus(EFalse);
       
   476     
       
   477     TRAP(lRet, lStatus = lDBView.FirstL());
       
   478     
       
   479     if(lRet == KErrNone && lStatus) {
       
   480         do {
       
   481             lDBView.GetL();
       
   482 
       
   483             aNumCols.AppendL(lDBView.ColInt(iColSet->ColNo(KColParamId)));
       
   484             aNumCols.AppendL(lDBView.ColInt(iColSet->ColNo(KColAppId)));
       
   485             aNumCols.AppendL(lDBView.ColInt(iColSet->ColNo(KColValueInt)));           
       
   486 
       
   487             TPtrC lValueDes = lDBView.ColDes16(iColSet->ColNo(KColValueDes));
       
   488             HBufC* lBuff = HBufC :: NewL(lValueDes.Length());
       
   489             lBuff->Des().Append(lValueDes);
       
   490             aDesCols.AppendL(lBuff);
       
   491         }
       
   492         while(lDBView.NextL());
       
   493     }
       
   494     
       
   495     _SCPDB_LOG(_L("[CSCPParamDB]-> ListEntries() <<<"));
       
   496     CleanupStack :: PopAndDestroy(2);
       
   497     return KErrNone;
       
   498 }