terminalsecurity/SCP/SCPDatabase/src/SCPParamDB.cpp
branchRCL_3
changeset 9 57a65a3a658c
parent 5 3f7d9dbe57c8
child 25 b183ec05bd8c
equal deleted inserted replaced
5:3f7d9dbe57c8 9:57a65a3a658c
   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 
   181         return KErrNotFound;
   181     lDBView.FirstL();
   182     }
       
   183 
   182 
   184     TInt lRowCount = lDBView.CountL();
   183     TInt lRowCount = lDBView.CountL();
   185 
   184 
   186     if(lRowCount == 0) {
   185     if(lRowCount == 0) {
   187         _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter"));
   186         _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter"));
   211     HBufC* lSelectQry  = HBufC :: NewLC(KSelectWhereParamIdAppID().Length() + 40);
   210     HBufC* lSelectQry  = HBufC :: NewLC(KSelectWhereParamIdAppID().Length() + 40);
   212     lSelectQry->Des().Format (KSelectWhereParamIdAppID, aParamID, aApp);
   211     lSelectQry->Des().Format (KSelectWhereParamIdAppID, aParamID, aApp);
   213 
   212 
   214     __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
   213     __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
   215     __LEAVE_IF_ERROR(lDBView.EvaluateAll());
   214     __LEAVE_IF_ERROR(lDBView.EvaluateAll());
   216     
   215 
   217     if(EFalse == lDBView.FirstL()) {
   216     lDBView.FirstL();
   218         return KErrNotFound;
       
   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) {
   330     
   327     
   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();
   416     return KErrNone;
   412     return KErrNone;
   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