terminalsecurity/SCP/SCPDatabase/src/SCPParamDB.cpp
changeset 22 19fb38abab1d
parent 5 3f7d9dbe57c8
child 60 eb6690d0d439
equal deleted inserted replaced
5:3f7d9dbe57c8 22:19fb38abab1d
   175     HBufC* lSelectQry  = HBufC :: NewLC(KSelectWhereParamId().Length() + 15);
   175     HBufC* lSelectQry  = HBufC :: NewLC(KSelectWhereParamId().Length() + 15);
   176     lSelectQry->Des().Format(KSelectWhereParamId, aParamID);
   176     lSelectQry->Des().Format(KSelectWhereParamId, aParamID);
   177 
   177 
   178     __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
   178     __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
   179     __LEAVE_IF_ERROR(lDBView.EvaluateAll());
   179     __LEAVE_IF_ERROR(lDBView.EvaluateAll());
   180     if(EFalse == lDBView.FirstL()) {
   180     lDBView.FirstL();
   181         return KErrNotFound;
       
   182     }
       
   183 
   181 
   184     TInt lRowCount = lDBView.CountL();
   182     TInt lRowCount = lDBView.CountL();
   185 
   183 
   186     if(lRowCount == 0) {
   184     if(lRowCount == 0) {
   187         _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter"));
   185         _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter"));
   212     lSelectQry->Des().Format (KSelectWhereParamIdAppID, aParamID, aApp);
   210     lSelectQry->Des().Format (KSelectWhereParamIdAppID, aParamID, aApp);
   213 
   211 
   214     __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
   212     __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
   215     __LEAVE_IF_ERROR(lDBView.EvaluateAll());
   213     __LEAVE_IF_ERROR(lDBView.EvaluateAll());
   216     
   214     
   217     if(EFalse == lDBView.FirstL()) {
   215     lDBView.FirstL();
   218         return KErrNotFound;
   216 
   219     }
       
   220 
   217 
   221     TInt size(0);
   218     TInt size(0);
   222     TInt lRowCount = lDBView.CountL();
   219     TInt lRowCount = lDBView.CountL();
   223 
   220 
   224     if(lRowCount == 0) {
   221     if(lRowCount == 0) {
   331     if(lCount < 1) {
   328     if(lCount < 1) {
   332         _SCPDB_LOG(_L("[CSCPParamDB]-> WARNING: Nothing to do!!"));
   329         _SCPDB_LOG(_L("[CSCPParamDB]-> WARNING: Nothing to do!!"));
   333         return KErrNone;  
   330         return KErrNone;  
   334     }
   331     }
   335     
   332     
   336     TInt lAffRows(0);
       
   337     HBufC* lDelQuery(NULL);
   333     HBufC* lDelQuery(NULL);
   338     
   334     
   339     if(iParameterDB.InTransaction()) {
   335     if(iParameterDB.InTransaction()) {
   340         _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: The DB in use! leaving..."));
   336         _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: The DB in use! leaving..."));
   341         User :: Leave(KErrInUse);
   337         User :: Leave(KErrInUse);
   351         else {
   347         else {
   352             lDelQuery = HBufC :: NewLC(KDeleteWhereParamIDValueDesAppID().Length() + (aParamValues[i])->Des().Length() + 100);
   348             lDelQuery = HBufC :: NewLC(KDeleteWhereParamIDValueDesAppID().Length() + (aParamValues[i])->Des().Length() + 100);
   353             lDelQuery->Des().Format(KDeleteWhereParamIDValueDesAppID, aParamID, &(aParamValues[i])->Des(), aApp);
   349             lDelQuery->Des().Format(KDeleteWhereParamIDValueDesAppID, aParamID, &(aParamValues[i])->Des(), aApp);
   354         }
   350         }
   355 
   351 
   356         lAffRows = iParameterDB.Execute(*lDelQuery);
   352         TInt lAffRows = iParameterDB.Execute(*lDelQuery);
   357         _SCPDB_LOG(_L("[CSCPParamDB]-> INFO: Total rows affected=%d"), lAffRows);
   353         _SCPDB_LOG(_L("[CSCPParamDB]-> INFO: Total rows affected=%d"), lAffRows);
   358         CleanupStack :: PopAndDestroy();
   354         CleanupStack :: PopAndDestroy();
   359     }
   355     }
   360     
   356     
   361     TInt lErr = iParameterDB.Commit();
   357     TInt lErr = iParameterDB.Commit();
   417 }
   413 }
   418 
   414 
   419 TInt CSCPParamDB :: DropValuesL(TInt aParamID, const TInt32 aApp) {
   415 TInt CSCPParamDB :: DropValuesL(TInt aParamID, const TInt32 aApp) {
   420     _SCPDB_LOG(_L("[CSCPParamDB]-> DropValuesL() >>>"));
   416     _SCPDB_LOG(_L("[CSCPParamDB]-> DropValuesL() >>>"));
   421     
   417     
   422     TInt lAffRows(0);
       
   423     HBufC* lDelQuery(NULL);
   418     HBufC* lDelQuery(NULL);
   424     
   419     
   425     if(iParameterDB.InTransaction()) {
   420     if(iParameterDB.InTransaction()) {
   426         _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: The DB in use! leaving..."));
   421         _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: The DB in use! leaving..."));
   427         User :: Leave(KErrInUse);
   422         User :: Leave(KErrInUse);
   437         lDelQuery = HBufC :: NewLC(KDeleteWhereParamIDAppID().Length() + 100);
   432         lDelQuery = HBufC :: NewLC(KDeleteWhereParamIDAppID().Length() + 100);
   438         lDelQuery->Des().Format(KDeleteWhereParamIDAppID, aParamID, aApp);
   433         lDelQuery->Des().Format(KDeleteWhereParamIDAppID, aParamID, aApp);
   439     }
   434     }
   440     _SCPDB_LOG(_L("[CSCPParamDB]-> SQL Query: %S"), &lDelQuery->Des());
   435     _SCPDB_LOG(_L("[CSCPParamDB]-> SQL Query: %S"), &lDelQuery->Des());
   441 
   436 
   442     lAffRows = iParameterDB.Execute(*lDelQuery);
   437     TInt lAffRows = iParameterDB.Execute(*lDelQuery);
   443     _SCPDB_LOG(_L("[CSCPParamDB]-> INFO: Total rows affected=%d"), lAffRows);
   438     _SCPDB_LOG(_L("[CSCPParamDB]-> INFO: Total rows affected=%d"), lAffRows);
   444     CleanupStack :: PopAndDestroy();
   439     CleanupStack :: PopAndDestroy();
   445     
   440     
   446     TInt lErr = iParameterDB.Commit();
   441     TInt lErr = iParameterDB.Commit();
   447     
   442