// -------------------------------- // CNSmlRoamTable::GetItemIAPL( TInt aProfileId, TInt aPriority ) // Return IAP for profile id and priority // -------------------------------- // EXPORT_C TUint32 CNSmlRoamTable::GetItemIAPL( TInt aProfileId, TInt aPriority ) { RDbView view; CleanupClosePushL(view); TUint32 uint(0); TBuf<KNSmlMaxSQLLength> sqlBuf; sqlBuf.Format( KSQLSelectUint, aProfileId, aPriority ); view.Prepare(iDatabase, TDbQuery( sqlBuf )); view.EvaluateAll(); if ( view.IsEmptyL() ) { User::Leave( KErrNotFound ); } view.FirstL(); view.GetL(); uint = view.ColUint( iColSet->ColNo( KColIapId )); CleanupStack::PopAndDestroy(); //view return uint; }
TInt CSCOMOAdapterDb::GetRetryCountForLuidL(TInt aLuid) { TInt retrycount = KErrNone; TFileName sqlQuery; PrepareLuidQuery(aLuid, sqlQuery); BeginDatabaseTransaction(); RDbView view; view.Prepare(iDatabase, TDbQuery(sqlQuery)); CleanupClosePushL(view); view.EvaluateAll(); view.FirstL(); if (!view.IsEmptyL()) { if(view.AtRow()) { view.GetL(); } retrycount = view.ColInt(7); } CleanupStack::PopAndDestroy(1); // view CommitDatabaseTransaction(); return retrycount; }
void CDscDatabase::GetDscDescriptionL(const TUid &aDscId, TDes& aDescription) const { RDbView view; CleanupClosePushL(view); RBuf sqlCmd; CleanupClosePushL(sqlCmd); sqlCmd.CreateL(KSqlSelectDscDescriptionLength); sqlCmd.Format(KSqlSelectDscDescription, &KDescriptionCol, &KDscTable, &KDscIdCol, aDscId); DebugPrint(sqlCmd); User::LeaveIfError(view.Prepare(iDatabase, sqlCmd)); User::LeaveIfError(view.EvaluateAll()); CleanupStack::PopAndDestroy(&sqlCmd); if(view.IsEmptyL()) { User::Leave(KErrNotFound); } view.FirstL(); view.GetL(); //Check the length of aDescription TPtrC description(view.ColDes(1)); if (description.Length() > aDescription.MaxLength()) { User::Leave(KErrOverflow); } aDescription.Zero(); aDescription=description; CleanupStack::PopAndDestroy(&view); }
// -------------------------------- // CNSmlRoamTable::IsNewItemL( RDbView& aView, CNSmlRoamItem& aItem) // Checks if whether IAP is new for profile id and priority // -------------------------------- // TBool CNSmlRoamTable::IsNewItemL( RDbView& aView, CNSmlRoamItem& aItem) { TBuf<KNSmlMaxSQLLength> sqlBuf; sqlBuf.Format( KSQLSelectUint, aItem.iProfileId, aItem.iPriority ); aView.Prepare(iDatabase, TDbQuery( sqlBuf )); aView.EvaluateAll(); return aView.IsEmptyL(); }
// -------------------------------- // CNSmlRoamTable::IsNewItemL( RDbView& aView, TInt aProfileId) // Checks if whether profile has IAPs // -------------------------------- // TBool CNSmlRoamTable::IsNewItemL( RDbView& aView, TInt aProfileId) { TBuf<KNSmlMaxSQLLength> sqlBuf; sqlBuf.Format(KSQLMultiQuery, aProfileId); aView.Prepare(iDatabase, TDbQuery( sqlBuf )); aView.EvaluateAll(); return aView.IsEmptyL(); }
//Check the existance of aItem TBool CDscDatabase::ItemExistsL( const CDscItem& aItem) const { RDbView view; CleanupClosePushL(view); QueryItemL(view, aItem); const TBool itemExists = !view.IsEmptyL(); CleanupStack::PopAndDestroy(&view); return (itemExists); }
// ----------------------------------------------------------------------------- // PosLmIconHandler::RemoveIconIfNotUsedL // // (other items were commented in a header). // ----------------------------------------------------------------------------- // void PosLmIconHandler::RemoveIconIfNotUsedL( CPosLmLocalDbAccess& aDbAccess, const TUint32& aIconPathId) { // First check landmark table HBufC* sql = HBufC::NewLC(KPosLmSqlStatementMaxLen); sql->Des().Format(KPosLmSqlFindUint, &KPosLmIconIdCol, &KPosLmLandmarkTable, &KPosLmIconIdCol, aIconPathId); RDbView view; aDbAccess.PrepareViewLC(CPosLmLocalDbAccess::EUpdatablePreparation, view, *sql); if (view.IsEmptyL()) { // Not found, check category table CleanupStack::PopAndDestroy(&view); // Delete old view sql->Des().Format(KPosLmSqlFindUint, &KPosLmIconIdCol, &KPosLmCategoryTable, &KPosLmIconIdCol, aIconPathId); aDbAccess.PrepareViewLC(CPosLmLocalDbAccess::EUpdatablePreparation, view, *sql); if (view.IsEmptyL()) { // Not found, remove icon path because it is not longer in use. sql->Des().Format(KPosLmSqlDeleteUint, &KPosLmIconTable, &KPosLmIconIdCol, aIconPathId); aDbAccess.ExecuteL(*sql); } } CleanupStack::PopAndDestroy(2, sql); //&view }
// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // EXPORT_C TBool PosLmLandmarkHandler::LandmarkExistsL( CPosLmLocalDbAccess& aDbAccess, TPosLmItemId aLandmarkId) { HBufC* sql = HBufC::NewLC(KPosLmSqlStatementMaxLen); sql->Des().Format(KPosLmSqlFindUint, &KPosLmLandmarkIdCol, &KPosLmLandmarkTable, &KPosLmLandmarkIdCol, aLandmarkId); RDbView view; aDbAccess.PrepareViewLC(CPosLmLocalDbAccess::EUpdatablePreparation, view, *sql); TBool exists = !view.IsEmptyL(); CleanupStack::PopAndDestroy(2, sql); //&view return exists; }
// ----------------------------------------------------------------------------- // CWPInternetAPDB::DeleteFromDatabaseL // ----------------------------------------------------------------------------- // TBool CWPInternetAPDB::DeleteFromDatabaseL(TUint aAPId) { FLOG( _L( "[Provisioning] CWPInternetAPDB::DeleteFromDatabaseL" ) ); TBool rowsdeleted = EFalse; TFileName QueryBuffer; QueryBuffer.Copy(_L("SELECT * FROM ")); QueryBuffer.Append(KtxtItemlist); QueryBuffer.Append(_L(" WHERE ")); QueryBuffer.Append(NCol2); QueryBuffer.Append(_L(" = ")); QueryBuffer.AppendNum(aAPId); iItemsDatabase.Begin(); RDbView Myview; // query buffer with index finds only the selected item row. Myview.Prepare(iItemsDatabase, TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.EvaluateAll(); if( Myview.FirstL()) { if (!Myview.IsEmptyL()) { // we have autoincrement in index so it should be unique // but just to make sure, we use 'while', instead of 'if' while (Myview.AtRow()) { Myview.GetL(); Myview.DeleteL(); Myview.NextL(); } iItemsDatabase.Commit(); // compacts the databse, by physically removig deleted data. iItemsDatabase.Compact(); rowsdeleted = ETrue; } } CleanupStack::PopAndDestroy(1); // Myview FLOG( _L( "[Provisioning] CWPInternetAPDB::DeleteFromDatabaseL: done" ) ); return rowsdeleted; }
// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // EXPORT_C TBool PosLmLandmarkHandler::HasLandmarkSpecifiedCategoryL( CPosLmLocalDbAccess& aDbAccess, TPosLmItemId aCategoryId, TPosLmItemId aLandmarkId) { HBufC* sql = HBufC::NewLC(KPosLmSqlStatementMaxLen); sql->Des().Format( KPosLmSqlFind2Uint, &KPosLmSqlAll, &KPosLmLandmarkCategoryTable, &KPosLmLandmarkIdCol, aLandmarkId, &KPosLmCategoryIdCol, aCategoryId); RDbView view; aDbAccess.PrepareViewLC(CPosLmLocalDbAccess::EUpdatablePreparation, view, *sql); TBool hasCategory = !view.IsEmptyL(); CleanupStack::PopAndDestroy(2, sql); //&view return hasCategory; }
//Check the existance of a DSC TBool CDscDatabase::DscExistsL(const TUid& aDscId) const { RDbView view; CleanupClosePushL(view); RBuf sqlCmd; CleanupClosePushL(sqlCmd); sqlCmd.CreateL(KSqlSelectDscLength); sqlCmd.Format(KSqlSelectDsc, &KDscIdCol, &KDscTable, &KDscIdCol, aDscId); DebugPrint(sqlCmd); User::LeaveIfError(view.Prepare(iDatabase, sqlCmd)); User::LeaveIfError(view.EvaluateAll()); const TBool dscExists = !view.IsEmptyL(); CleanupStack::PopAndDestroy(&sqlCmd); CleanupStack::PopAndDestroy(&view); return (dscExists); }
// ----------------------------------------------------------------------------- // CWPInternetAPDB::DeleteFromDatabaseL // ----------------------------------------------------------------------------- // TBool CSCOMOAdapterDb::DeleteFromDatabaseL(TUint32 aLuid) { TBool rowsdeleted = EFalse; TFileName sqlQuery; PrepareLuidQuery(aLuid, sqlQuery); BeginDatabaseTransaction(); RDbView view; // query buffer with index finds only the selected item row. view.Prepare(iDatabase, TDbQuery(sqlQuery)); CleanupClosePushL(view); view.EvaluateAll(); view.FirstL(); if (!view.IsEmptyL()) { // we have autoincrement in index so it should be unique // but just to make sure, we use 'while', instead of 'if' while (view.AtRow()) { view.GetL(); view.DeleteL(); view.NextL(); } CommitDatabaseTransaction(); // compacts the databse, by physically removig deleted data. iDatabase.Compact(); rowsdeleted = ETrue; } CleanupStack::PopAndDestroy(1); // view return rowsdeleted; }