terminalsecurity/SCP/SCPDatabase/src/SCPParamDB.cpp
changeset 63 e0c1916b8ddc
parent 22 19fb38abab1d
equal deleted inserted replaced
57:f5b689a4f7a2 63:e0c1916b8ddc
   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     lDBView.FirstL();
   180     if( lDBView.FirstL())
   181 
   181     {
   182     TInt lRowCount = lDBView.CountL();
   182     	TInt lRowCount = lDBView.CountL();
   183 
   183 
   184     if(lRowCount == 0) {
   184     	if(lRowCount == 0) {
   185         _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter"));
   185         _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter"));
   186         CleanupStack :: PopAndDestroy(2);
   186         CleanupStack :: PopAndDestroy(2);
   187         return KErrNotFound;
   187         return KErrNotFound;
   188     }
   188     	}
   189     else if(lRowCount > 1) {
   189     	else if(lRowCount > 1) {
   190         _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..."));
   191         User :: Leave(KErrCorrupt);
   191         User :: Leave(KErrCorrupt);
   192     }
   192     	}
   193 
   193 
   194     lDBView.GetL();
   194     	lDBView.GetL();
   195     aApp = lDBView.ColInt(iColSet->ColNo(KColAppId));
   195     	aApp = lDBView.ColInt(iColSet->ColNo(KColAppId));
   196     aValue = lDBView.ColInt(iColSet->ColNo(KColValueInt));
   196     	aValue = lDBView.ColInt(iColSet->ColNo(KColValueInt));
       
   197     }
   197     CleanupStack :: PopAndDestroy(2);
   198     CleanupStack :: PopAndDestroy(2);
   198 
   199 
   199     _SCPDB_LOG(_L("[CSCPParamDB]-> GetValueForParameterL <<<"));
   200     _SCPDB_LOG(_L("[CSCPParamDB]-> GetValueForParameterL <<<"));
   200     return KErrNone;
   201     return KErrNone;
   201 }
   202 }
   210     lSelectQry->Des().Format (KSelectWhereParamIdAppID, aParamID, aApp);
   211     lSelectQry->Des().Format (KSelectWhereParamIdAppID, aParamID, aApp);
   211 
   212 
   212     __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
   213     __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
   213     __LEAVE_IF_ERROR(lDBView.EvaluateAll());
   214     __LEAVE_IF_ERROR(lDBView.EvaluateAll());
   214     
   215     
   215     lDBView.FirstL();
   216     if (lDBView.FirstL())
   216 
   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 }