terminalsecurity/SCP/SCPDatabase/src/SCPParamDB.cpp
branchRCL_3
changeset 61 b183ec05bd8c
parent 9 57a65a3a658c
child 62 19bba8228ff0
equal deleted inserted replaced
59:13d7c31c74e0 61:b183ec05bd8c
   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 
   180     if( lDBView.FirstL())
   181     lDBView.FirstL();
   181     {
   182 
   182     	TInt lRowCount = lDBView.CountL();
   183     TInt lRowCount = lDBView.CountL();
   183 
   184 
   184     	if(lRowCount == 0) {
   185     if(lRowCount == 0) {
       
   186         _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter"));
   185         _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter"));
   187         CleanupStack :: PopAndDestroy(2);
   186         CleanupStack :: PopAndDestroy(2);
   188         return KErrNotFound;
   187         return KErrNotFound;
   189     }
   188     	}
   190     else if(lRowCount > 1) {
   189     	else if(lRowCount > 1) {
   191         _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: More than one record matches the criterion. Db is corrupt! Leaving..."));
   190         _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: More than one record matches the criterion. Db is corrupt! Leaving..."));
   192         User :: Leave(KErrCorrupt);
   191         User :: Leave(KErrCorrupt);
   193     }
   192     	}
   194 
   193 
   195     lDBView.GetL();
   194     	lDBView.GetL();
   196     aApp = lDBView.ColInt(iColSet->ColNo(KColAppId));
   195     	aApp = lDBView.ColInt(iColSet->ColNo(KColAppId));
   197     aValue = lDBView.ColInt(iColSet->ColNo(KColValueInt));
   196     	aValue = lDBView.ColInt(iColSet->ColNo(KColValueInt));
       
   197     }
   198     CleanupStack :: PopAndDestroy(2);
   198     CleanupStack :: PopAndDestroy(2);
   199 
   199 
   200     _SCPDB_LOG(_L("[CSCPParamDB]-> GetValueForParameterL <<<"));
   200     _SCPDB_LOG(_L("[CSCPParamDB]-> GetValueForParameterL <<<"));
   201     return KErrNone;
   201     return KErrNone;
   202 }
   202 }
   210     HBufC* lSelectQry  = HBufC :: NewLC(KSelectWhereParamIdAppID().Length() + 40);
   210     HBufC* lSelectQry  = HBufC :: NewLC(KSelectWhereParamIdAppID().Length() + 40);
   211     lSelectQry->Des().Format (KSelectWhereParamIdAppID, aParamID, aApp);
   211     lSelectQry->Des().Format (KSelectWhereParamIdAppID, aParamID, aApp);
   212 
   212 
   213     __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
   213     __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
   214     __LEAVE_IF_ERROR(lDBView.EvaluateAll());
   214     __LEAVE_IF_ERROR(lDBView.EvaluateAll());
   215 
   215     
   216     lDBView.FirstL();
   216     if (lDBView.FirstL())
   217 
   217     {
   218     TInt size(0);
   218     	TInt size(0);
   219     TInt lRowCount = lDBView.CountL();
   219     	TInt lRowCount = lDBView.CountL();
   220 
   220 
   221     if(lRowCount == 0) {
   221     	if(lRowCount == 0) {
   222         _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter"));
   222         _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter"));
   223         CleanupStack :: PopAndDestroy(2);
   223         CleanupStack :: PopAndDestroy(2);
   224         return KErrNotFound;
   224         return KErrNotFound;
   225     }
   225     	}
   226     
   226     
   227     TInt lErr(KErrNone);
   227     	TInt lErr(KErrNone);
   228     
   228     
   229     do {
   229     	do {
   230         lDBView.GetL();
   230         lDBView.GetL();
   231         size = lDBView.ColDes(iColSet->ColNo(KColValueDes)).Size();
   231         size = lDBView.ColDes(iColSet->ColNo(KColValueDes)).Size();
   232 
   232 
   233         if(size) {
   233         if(size) {
   234             HBufC* lBuff = HBufC :: NewL(size);
   234             HBufC* lBuff = HBufC :: NewL(size);
   240             if(lErr != KErrNone) {
   240             if(lErr != KErrNone) {
   241                 aParamValues.ResetAndDestroy();
   241                 aParamValues.ResetAndDestroy();
   242                 User :: Leave(lErr);
   242                 User :: Leave(lErr);
   243             }
   243             }
   244         }
   244         }
   245     }
   245     	}
   246     while(lDBView.NextL());
   246     	while(lDBView.NextL());
       
   247     }
   247 
   248 
   248     CleanupStack :: PopAndDestroy(2);
   249     CleanupStack :: PopAndDestroy(2);
   249     _SCPDB_LOG(_L("[CSCPParamDB]-> GetValuesForParameterL <<<"));
   250     _SCPDB_LOG(_L("[CSCPParamDB]-> GetValuesForParameterL <<<"));
   250     return KErrNone;   
   251     return KErrNone;   
   251 }
   252 }
   327     
   328     
   328     if(lCount < 1) {
   329     if(lCount < 1) {
   329         _SCPDB_LOG(_L("[CSCPParamDB]-> WARNING: Nothing to do!!"));
   330         _SCPDB_LOG(_L("[CSCPParamDB]-> WARNING: Nothing to do!!"));
   330         return KErrNone;  
   331         return KErrNone;  
   331     }
   332     }
   332 
   333     
   333     HBufC* lDelQuery(NULL);
   334     HBufC* lDelQuery(NULL);
   334     
   335     
   335     if(iParameterDB.InTransaction()) {
   336     if(iParameterDB.InTransaction()) {
   336         _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: The DB in use! leaving..."));
   337         _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: The DB in use! leaving..."));
   337         User :: Leave(KErrInUse);
   338         User :: Leave(KErrInUse);
   412     return KErrNone;
   413     return KErrNone;
   413 }
   414 }
   414 
   415 
   415 TInt CSCPParamDB :: DropValuesL(TInt aParamID, const TInt32 aApp) {
   416 TInt CSCPParamDB :: DropValuesL(TInt aParamID, const TInt32 aApp) {
   416     _SCPDB_LOG(_L("[CSCPParamDB]-> DropValuesL() >>>"));
   417     _SCPDB_LOG(_L("[CSCPParamDB]-> DropValuesL() >>>"));
   417 
   418     
   418     HBufC* lDelQuery(NULL);
   419     HBufC* lDelQuery(NULL);
   419     
   420     
   420     if(iParameterDB.InTransaction()) {
   421     if(iParameterDB.InTransaction()) {
   421         _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: The DB in use! leaving..."));
   422         _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: The DB in use! leaving..."));
   422         User :: Leave(KErrInUse);
   423         User :: Leave(KErrInUse);