/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CExPolicy_Server::AddToValDatabase(RDbDatabase& aDatabase,const TDesC& aCode,const TDesC8& aString) { TFileName QueryBuffer; QueryBuffer.Copy(_L("SELECT * FROM ")); QueryBuffer.Append(KtxtVallist); aDatabase.Begin(); RDbView Myview; Myview.Prepare(aDatabase,TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.InsertL(); Myview.SetColL(2,aCode); QueryBuffer.Copy(aString); Myview.SetColL(3,QueryBuffer); Myview.PutL(); CleanupStack::PopAndDestroy(1); // Myview aDatabase.Commit(); }
// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // EXPORT_C void PosLmLandmarkHandler::AddCategoriesToLandmarkL( CPosLmLocalDbAccess& aDbAccess, const RArray<TPosLmItemId>& aCategories, const TPosLmItemId& aLandmarkId) { if (aCategories.Count() > 0) { HBufC* sql = HBufC::NewLC(KPosLmSqlStatementMaxLen); sql->Des().Format(KPosLmSqlSelect, &KPosLmSqlAll, &KPosLmLandmarkCategoryTable); RDbView view; aDbAccess.PrepareViewLC(CPosLmLocalDbAccess::EAddPreparation, view, *sql); for (TInt i = 0; i < aCategories.Count(); i++) { view.InsertL(); view.SetColL(EPosLmLccLandmarkIdCol, aLandmarkId); view.SetColL(EPosLmLccCategoryIdCol, aCategories[i]); view.PutL(); } CleanupStack::PopAndDestroy(2, sql); //&view } }
// ----------------------------------------------------------------------------- // CWPInternetAPDB::SaveToDatabaseL // ----------------------------------------------------------------------------- // void CWPInternetAPDB::SaveToDatabaseL(TInt& aIndex, TUint aAPId, TUint32 aBearerType, const TDesC& aOriginator) { FLOG( _L( "[Provisioning] CWPInternetAPDB::SaveToDatabaseL" ) ); //If there is any existing rows for the same APID, delete those if (DeleteFromDatabaseL(aAPId)) { iItemsDatabase.Begin(); } TFileName QueryBuffer; QueryBuffer.Copy(_L("SELECT * FROM ")); QueryBuffer.Append(KtxtItemlist); RDbView Myview; Myview.Prepare(iItemsDatabase, TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.InsertL(); Myview.SetColL(2, aAPId); Myview.SetColL(3, aBearerType); Myview.SetColL(4, aOriginator); Myview.PutL(); aIndex = Myview.ColInt(1);// autoincrement gives us unique index. CleanupStack::PopAndDestroy(1); // Myview iItemsDatabase.Commit(); FLOG( _L( "[Provisioning] CWPInternetAPDB::SaveToDatabaseL:done" ) ); }
// -------------------------------- // CNSmlRoamTable::AddItemL( CNSmlRoamItem& aItem ) // Adds item to IAP table // -------------------------------- // void CNSmlRoamTable::AddItemL( CNSmlRoamItem& aItem ) { RFs fs; User::LeaveIfError( fs.Connect() ); CleanupClosePushL(fs); if (SysUtil::FFSSpaceBelowCriticalLevelL(&fs, 12)) { User::Leave( KErrDiskFull ); } CleanupStack::PopAndDestroy(); //fs TBuf<KNSmlMaxSQLLength> sqlBuf; sqlBuf.Format( KSQLInsertQuery, aItem.iProfileId, aItem.iIAPId, aItem.iPriority ); RDbView view; CleanupClosePushL( view ); view.Prepare(iDatabase, TDbQuery(KSQLMatchQuery2), RDbView::EInsertOnly); view.InsertL(); view.SetColL( iColSet->ColNo( KColProfileId ), aItem.iProfileId ); view.SetColL( iColSet->ColNo( KColPriority ), aItem.iPriority ); view.SetColL( iColSet->ColNo( KColIapId ), aItem.iIAPId ); view.PutL(); CleanupStack::PopAndDestroy(); //view #ifdef __MODULETEST test.iAdded++; #endif }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CScheduleDB::UpdateDatabaseL(CMsgSched* aData) { if(aData) { TFileName QueryBuffer; QueryBuffer.Copy(_L("SELECT * FROM ")); QueryBuffer.Append(KtxtItemlist); QueryBuffer.Append(_L(" WHERE ")); QueryBuffer.Append(NCol0); QueryBuffer.Append(_L(" = ")); QueryBuffer.AppendNum(aData->iIndex); iItemsDatabase.Begin(); RDbView Myview; Myview.Prepare(iItemsDatabase,TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.EvaluateAll(); Myview.FirstL(); if(Myview.AtRow()) { Myview.UpdateL(); if(aData->iUnicode) Myview.SetColL(2,0x100); else Myview.SetColL(2,0x000); if(aData->iNunmber) Myview.SetColL(3,*aData->iNunmber); if(aData->iMessage) Myview.SetColL(4,*aData->iMessage); Myview.SetColL(5,aData->iTime); Myview.SetColL(6,aData->iRepeat); if(aData->iEnabled) Myview.SetColL(7,0x100); else Myview.SetColL(7,0x000); if(aData->iFlashSMS) Myview.SetColL(8,0x100); else Myview.SetColL(8,0x000); Myview.PutL(); } CleanupStack::PopAndDestroy(1); // Myview iItemsDatabase.Commit(); } }
void CAlmSettingsSession::ProcessDataL(void) { TInt func=Message().Function(); _LIT(KSQL,"select id,name,cid,value from settings where cid=%u and name='%S'"); RDbView view; TBuf<128> sql; TUint32 cid=CategoryL(Message().Ptr0()); HBufC8* param1=ValueLC(Message().Ptr1()); TPtrC name((const TUint16*)param1->Ptr(),param1->Length()/2); sql.Format(KSQL,cid,&name); User::LeaveIfError(view.Prepare(iServer.DbL(),TDbQuery(sql),(func==ESettingsServerRequestSet)?RDbView::EUpdatable:RDbView::EReadOnly)); CleanupClosePushL(view); User::LeaveIfError(view.EvaluateAll()); TBool first=view.FirstL(); if(func==ESettingsServerRequestSet) { if(first) view.UpdateL(); else view.InsertL(); CleanupCancelPushL(view); if(!first) { view.SetColL(2,name); view.SetColL(3,cid); } HBufC8* value=ValueLC(Message().Ptr2()); view.SetColL(4,*value); view.PutL(); CleanupStack::Pop(); //view cancel CleanupStack::PopAndDestroy(); //value iServer.Notify(); } else { if(!first) User::Leave(KErrNotFound); view.GetL(); TInt len=view.ColSize(4); if(func==ESettingsServerRequestGetData) { HBufC8* data=HBufC8::NewLC(len); TPtr8 ptr(data->Des()); RDbColReadStream stream; stream.OpenLC(view,4); stream.ReadL(ptr,len); Message().WriteL(Message().Ptr2(),ptr); CleanupStack::PopAndDestroy(2); //stream,data } else { TPckgC<TInt> size(len); Message().WriteL(Message().Ptr2(),size); } } CleanupStack::PopAndDestroy(2); //view,param1 }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CScheduleDB::SaveToDatabaseL(CMsgSched* aData) { if(aData) { TFileName QueryBuffer; QueryBuffer.Copy(_L("SELECT * FROM ")); QueryBuffer.Append(KtxtItemlist); iItemsDatabase.Begin(); RDbView Myview; Myview.Prepare(iItemsDatabase,TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.InsertL(); if(aData->iUnicode) Myview.SetColL(2,0x100); else Myview.SetColL(2,0x000); if(aData->iNunmber) Myview.SetColL(3,*aData->iNunmber); if(aData->iMessage) Myview.SetColL(4,*aData->iMessage); Myview.SetColL(5,aData->iTime); Myview.SetColL(6,aData->iRepeat); if(aData->iEnabled) Myview.SetColL(7,0x100); else Myview.SetColL(7,0x000); if(aData->iFlashSMS) Myview.SetColL(8,0x100); else Myview.SetColL(8,0x000); Myview.PutL(); aData->iIndex = Myview.ColInt(1);// autoincrement gives us unique index. CleanupStack::PopAndDestroy(1); // Myview iItemsDatabase.Commit(); } }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CScheduleDB::UpdateDatabaseL(CMsgStored* aData) { if(aData) { TFileName QueryBuffer; QueryBuffer.Copy(_L("SELECT * FROM ")); QueryBuffer.Append(KtxtItemlist2); QueryBuffer.Append(_L(" WHERE ")); QueryBuffer.Append(NCol0); QueryBuffer.Append(_L(" = ")); QueryBuffer.AppendNum(aData->iIndex); iItemsDatabase.Begin(); RDbView Myview; Myview.Prepare(iItemsDatabase,TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.EvaluateAll(); Myview.FirstL(); if(Myview.AtRow()) { Myview.UpdateL(); if(aData->iMessage) Myview.SetColL(2,*aData->iMessage); Myview.PutL(); } CleanupStack::PopAndDestroy(1); // Myview iItemsDatabase.Commit(); } }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CScheduleDB::SaveToDatabaseL(CMsgStored* aData) { if(aData) { TFileName QueryBuffer; QueryBuffer.Copy(_L("SELECT * FROM ")); QueryBuffer.Append(KtxtItemlist2); iItemsDatabase.Begin(); RDbView Myview; Myview.Prepare(iItemsDatabase,TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.InsertL(); if(aData->iMessage) Myview.SetColL(2,*aData->iMessage); Myview.PutL(); aData->iIndex = Myview.ColInt(1);// autoincrement gives us unique index. CleanupStack::PopAndDestroy(1); // Myview iItemsDatabase.Commit(); } }
// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // void PosLmLandmarkHandler::InsertFieldL( RDbView& view, const TPositionFieldId& aFieldId, const CPosLandmark& aLandmark) { TPtrC fieldValue; User::LeaveIfError(aLandmark.GetPositionField(aFieldId, fieldValue)); view.InsertL(); view.SetColL(EPosLmLfcLandmarkIdCol, aLandmark.LandmarkId()); view.SetColL(EPosLmLfcFieldTypeCol, (TUint)aFieldId); PosLmLongTextColHandler::WriteToLongTextColumnL(fieldValue, view, EPosLmLfcFieldStringCol); view.PutL(); }
// -------------------------------- // CNSmlRoamTable::UpdateItemL(RDbView& aView, CNSmlRoamItem& aItem ) // Updates item in the IAP table // -------------------------------- // void CNSmlRoamTable::UpdateItemL(RDbView& aView, CNSmlRoamItem& aItem ) { aView.FirstL(); aView.UpdateL(); aView.SetColL( iColSet->ColNo( KColProfileId ), aItem.iProfileId ); aView.SetColL( iColSet->ColNo( KColPriority ), aItem.iPriority ); aView.SetColL( iColSet->ColNo( KColIapId ), aItem.iIAPId ); aView.PutL(); #ifdef __MODULETEST test.iUpdated++; #endif }
static void ViewTestL() { RDbView view; CleanupClosePushL(view); TheTest.Next(_L("Prepare()")); TInt err = view.Prepare(TheDb1, TDbQuery(_L("SELECT * FROM ATbl"))); TEST2(err, KErrNone); TheTest.Next(_L("Update()")); TBool res = view.FirstL(); TEST(res); view.GetL(); view.UpdateL(); view.SetColL(2, 100); view.SetColL(3, 200); view.PutL(); CleanupStack::PopAndDestroy(&view); TheTest.Next(_L("Prepare() with an update sql")); CleanupClosePushL(view); err = view.Prepare(TheDb1, TDbQuery(_L("UPDATE ATbl SET DATA1 = 400 WHERE ID = 0"))); TEST2(err, KErrArgument); CleanupStack::PopAndDestroy(&view); }
void CSCOMOAdapterDb::UpdateRetryCountForLuidL(TInt aLuid, TInt aRetryCount) { TFileName sqlQuery; PrepareLuidQuery(aLuid, sqlQuery); BeginDatabaseTransaction(); RDbView view; view.Prepare(iDatabase, TDbQuery(sqlQuery)); CleanupClosePushL(view); view.EvaluateAll(); view.FirstL(); if(view.AtRow()) { view.UpdateL(); view.SetColL(7, aRetryCount); view.PutL(); } CleanupStack::PopAndDestroy(1); // view CommitDatabaseTransaction(); }
// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // void PosLmLandmarkHandler::SetPositionL( RDbView& aView, const CPosLandmark& aLandmark) { TLocality position; if (aLandmark.GetPosition(position) == KErrNone) { aView.SetColL(EPosLmLcLatitudeCol, position.Latitude()); aView.SetColL(EPosLmLcLongitudeCol, position.Longitude()); if (!Math::IsNaN(position.Altitude())) { aView.SetColL(EPosLmLcAltitudeCol, position.Altitude()); } else { aView.SetColNullL(EPosLmLcAltitudeCol); } if (!Math::IsNaN(position.HorizontalAccuracy())) { aView.SetColL(EPosLmLcHorizAccCol, position.HorizontalAccuracy()); } else { aView.SetColNullL(EPosLmLcHorizAccCol); } if (!Math::IsNaN(position.VerticalAccuracy())) { aView.SetColL(EPosLmLcVertAccCol, position.VerticalAccuracy()); } else { aView.SetColNullL(EPosLmLcVertAccCol); } } else { aView.SetColNullL(EPosLmLcLatitudeCol); aView.SetColNullL(EPosLmLcLongitudeCol); aView.SetColNullL(EPosLmLcAltitudeCol); aView.SetColNullL(EPosLmLcHorizAccCol); aView.SetColNullL(EPosLmLcVertAccCol); } }
/* ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- */ TInt CExPolicy_Server::UpdateStatusL(TBool& aValue, TBool aProtect) { TInt ErrRet(KErrNone); TRAP(ErrRet, DeleteStatusInfoL(); if(aProtect) { iProtectStatus = aValue; } else { iScreenStatus = aValue; } TFileName QueryBuffer; QueryBuffer.Copy(_L("SELECT * FROM ")); QueryBuffer.Append(KtxtStatuslist); iItemsDatabase.Begin(); RDbView Myview; Myview.Prepare(iItemsDatabase,TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.EvaluateAll(); Myview.FirstL(); Myview.InsertL(); if(iProtectStatus) Myview.SetColL(2,0x100); else Myview.SetColL(2,0x000); if(iScreenStatus) Myview.SetColL(3,0x100); else Myview.SetColL(3,0x000); Myview.PutL(); CleanupStack::PopAndDestroy(1); // Myview iItemsDatabase.Commit(); );
// ----------------------------------------------------------------------------- // CWPInternetAPDB::SaveToDatabaseL // ----------------------------------------------------------------------------- // void CSCOMOAdapterDb::SaveToDatabaseL(TInt& aIndex, TUint32 aLuid, TInt aProfileid, TInt aRetryCount, const TDesC8& aSourceURI, const TDesC8& aServerid, const TDesC8& aCorrelator) { BeginDatabaseTransaction(); TFileName sqlQuery; sqlQuery.Copy(_L("SELECT * FROM ")); sqlQuery.Append(KTableAMMgmtObject); RDbView view; view.Prepare(iDatabase, TDbQuery(sqlQuery)); CleanupClosePushL(view); view.InsertL(); view.SetColL(2, aLuid); view.SetColL(3, aProfileid); view.SetColL(4, aServerid); view.SetColL(5, aCorrelator); view.SetColL(6, aSourceURI); view.SetColL(7, aRetryCount); view.PutL(); aIndex = view.ColInt(1);// autoincrement gives us unique index. CleanupStack::PopAndDestroy(1); // view CommitDatabaseTransaction(); }
// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // void PosLmLandmarkHandler::SetIconL( RDbView& aView, const CPosLandmark& aLandmark, const TUint32 aIconPathId) { TPtrC path; TInt iconIndex; TInt maskIndex; if (aLandmark.GetIcon(path, iconIndex, maskIndex) == KErrNone) { aView.SetColL(EPosLmLcIconIdCol, aIconPathId); aView.SetColL(EPosLmLcIconPicNrCol, iconIndex); aView.SetColL(EPosLmLcMaskPicNrCol, maskIndex); } else { aView.SetColNullL(EPosLmLcIconIdCol); aView.SetColNullL(EPosLmLcIconPicNrCol); aView.SetColNullL(EPosLmLcMaskPicNrCol); } }
// --------------------------------------------------------------------------- // CFotaDB::StateToRowL // Converts state object to database row (into view object) // --------------------------------------------------------------------------- void CFotaDB::StateToRowL(const TPackageState& aPkg, const TDesC8& aPkgURL, RDbView& aView) { HBufC* pkgname = HBufC::NewLC(aPkg.iPkgName.Length()); HBufC* version = HBufC::NewLC(aPkg.iPkgVersion.Length()); pkgname->Des().Copy(aPkg.iPkgName); version->Des().Copy(aPkg.iPkgVersion); aView.SetColL(iColSet->ColNo(KColPkgId), aPkg.iPkgId); aView.SetColL(iColSet->ColNo(KColResult), aPkg.iResult); aView.SetColL(iColSet->ColNo(KColState), aPkg.iState); aView.SetColL(iColSet->ColNo(KColProfileId), aPkg.iProfileId); aView.SetColL(iColSet->ColNo(KColPkgName), *pkgname); aView.SetColL(iColSet->ColNo(KColVersion), *version); aView.SetColL(iColSet->ColNo(KColSmlTryCount), aPkg.iSmlTryCount); aView.SetColL(iColSet->ColNo(KColSessionType), aPkg.iSessionType); aView.SetColL(iColSet->ColNo(KColIapId), aPkg.iIapId); aView.SetColL(iColSet->ColNo(KColPkgSize), aPkg.iPkgSize); aView.SetColL(iColSet->ColNo(KColUpdateLtr), aPkg.iUpdateLtr); RDbColWriteStream wstream; CleanupClosePushL(wstream); wstream.OpenL(aView, iColSet->ColNo(KColPkgUrl)); // Cannot write 8 bit descriptors to databae HBufC* buf = HBufC::NewLC(aPkgURL.Length()); buf->Des().Copy(aPkgURL); wstream.WriteL(buf->Des()); FLOG(_L("CFotaDB::StateToRowL id:%d result:%d state:%d profileid:%d \ name:%d chars version: %d chars url: %d chars sessiontype:%d iapid:%d pkgsize:%d updateltr = %d"), aPkg.iPkgId, aPkg.iResult, aPkg.iState, aPkg.iProfileId, pkgname->Des().Length(), version->Des().Length(), buf->Des().Length(), aPkg.iSessionType, aPkg.iIapId, aPkg.iPkgSize, aPkg.iUpdateLtr); CleanupStack::PopAndDestroy(buf); CleanupStack::PopAndDestroy(&wstream); CleanupStack::PopAndDestroy(version); CleanupStack::PopAndDestroy(pkgname); }
// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // void PosLmLandmarkHandler::SetCoverageRadiusL( RDbView& aView, const CPosLandmark& aLandmark) { TReal32 covRadius; if (aLandmark.GetCoverageRadius(covRadius) == KErrNone) { aView.SetColL(EPosLmLcCoverageRadiusCol, covRadius); } else { aView.SetColNullL(EPosLmLcCoverageRadiusCol); } }
void eapol_am_wlan_authentication_symbian_c::SavePSKL(TPSKEntry& entry) { EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eapol_am_wlan_authentication_symbian_c::SavePSKL(): this = 0x%08x\n"), this)); EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::SavePSKL()"); // Connect to CommDBif so that we can delete PSK entries that have no IAP associated anymore. CWLanSettings* wlan_settings = new(ELeave) CWLanSettings; CleanupStack::PushL(wlan_settings); SWLANSettings wlanSettings; if (wlan_settings->Connect() != KErrNone) { // Could not connect to CommDB User::Leave(KErrCouldNotConnect); } // Open database RDbNamedDatabase db; TFileName aPrivateDatabasePathName; EapPluginTools::GetPrivatePathL( m_session, aPrivateDatabasePathName); aPrivateDatabasePathName.Append(KEapolDatabaseName); EAP_TRACE_DATA_DEBUG_SYMBIAN(("aPrivateDatabasePathName", aPrivateDatabasePathName.Ptr(), aPrivateDatabasePathName.Size())); User::LeaveIfError(db.Open(m_session, aPrivateDatabasePathName)); CleanupClosePushL(db); HBufC* sqlbuf = HBufC::NewLC(KMaxSqlQueryLength); TPtr sqlStatement = sqlbuf->Des(); RDbView view; _LIT(KSQL, "SELECT %S, %S, %S, %S, %S FROM %S"); sqlStatement.Format(KSQL, &KServiceType, &KServiceIndex, &KSSID, &KPassword, &KPSK, &KEapolPSKTableName); User::LeaveIfError(view.Prepare(db, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); CleanupClosePushL(view); User::LeaveIfError(view.EvaluateAll()); // Get column set so we get the correct column numbers CDbColSet* colSet = view.ColSetL(); CleanupStack::PushL(colSet); // Delete old row and also rows that have no associated IAP settings. if (view.FirstL()) { do { view.GetL(); if ((wlan_settings->GetWlanSettingsForService(view.ColUint32(colSet->ColNo(KServiceIndex)), wlanSettings) != KErrNone) || (view.ColUint32(colSet->ColNo(KServiceType)) == static_cast<TUint>(entry.indexType) && view.ColUint32(colSet->ColNo(KServiceIndex)) == static_cast<TUint>(entry.index))) { // Not found or current IAP view.DeleteL(); } } while (view.NextL() != EFalse); } wlan_settings->Disconnect(); view.InsertL(); view.SetColL(colSet->ColNo(KServiceType), (TUint)entry.indexType); view.SetColL(colSet->ColNo(KServiceIndex), (TUint)entry.index); view.SetColL(colSet->ColNo(KSSID), entry.ssid); view.SetColL(colSet->ColNo(KPassword), entry.password); view.SetColL(colSet->ColNo(KPSK), entry.psk); view.PutL(); CleanupStack::PopAndDestroy( colSet ); // Delete colSet. CleanupStack::PopAndDestroy(&view); CleanupStack::PopAndDestroy(sqlbuf); CleanupStack::PopAndDestroy(&db); CleanupStack::PopAndDestroy(wlan_settings); }
// --------------------------------------------------------------------------- // CIRNmsLogDb:AddNmsLogStartL() // adds the NmsLog log entry into data base // --------------------------------------------------------------------------- // void CIRNmsLogDb::AddNmsLogStartL( CIRNmsLogger& aNmsLog ) { IRLOG_DEBUG( "CIRNmsLogDb::AddNmsLogStartL" ); OpenDbL(); RDbTable nmsLogtable; TInt error=nmsLogtable.Open( iNmsLogDb, KNmsLogTable, nmsLogtable. EUpdatable ); CleanupClosePushL( nmsLogtable ); if ( error ) { CloseDb(); User::LeaveIfError( error ); } //! arrange the presets in incresing order of index nmsLogtable.SetIndex( KNmsLogIndex ); nmsLogtable.Reset(); //if NmsLog log is greater or equal to than 5 if ( nmsLogtable.CountL() >= KMaxNoNmsLog ) { //first row is selected nmsLogtable.FirstL(); //the current row is selected nmsLogtable.GetL(); //delete that entry nmsLogtable.DeleteL(); } CleanupStack::PopAndDestroy( &nmsLogtable ); //Algorithm : else condition need not handle seperatly //Algorithm : add NmsLogid and informations like //starttime,connectedfrom,NmsLogid,connectiontype,channelid //currentnetwork,homenetwork,NmsLogtable //Algorithm: if no. of NmsLog is greater than 5 _LIT( query, "SELECT * FROM %S" ); HBufC* sqlStr=HBufC::NewLC( query().Length() + KNmsLogTable().Length() ); sqlStr->Des().Format( query, &KNmsLogTable ); // Create a view on the database RDbView view; error = view.Prepare( iNmsLogDb, *sqlStr ); if ( error ) { CloseDb(); User::LeaveIfError( error ); } CleanupStack::PopAndDestroy( sqlStr ); CleanupClosePushL( view ); error = view.EvaluateAll(); if ( error ) { CloseDb(); User::LeaveIfError( error ); } CDbColSet* columns = view.ColSetL(); CleanupStack::PushL( columns ); RDbColWriteStream writeStream; TRAP( error, //trap start // Insert a row. Column order matches sql select statement view.InsertL(); //get index view.SetColL( columns->ColNo( KID ), aNmsLog.NmsLogId() ); //!open stream writeStream.OpenLC( view, columns->ColNo( KNmsLogCol ) ); aNmsLog.ExternalizeL( writeStream ); writeStream.CommitL(); CleanupStack::PopAndDestroy( &writeStream ); );
/** @SYMTestCaseID SYSLIB-DBMS-CT-0645 @SYMTestCaseDesc Searching for data from a database @SYMTestPriority Medium @SYMTestActions Tests for EDbColText,EDbColLongText column type @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ static void TestSearchL( TInt aIndex ) { // Default database _LIT( KComposer1, "Elgar" ); _LIT( KCol1, "Artist" ); _LIT( KCol2, "Notes" ); _LIT( KTable, "CDs" ); TInt err = TheFsSession.Delete( KSearchTestDbPath ); if ( ( err != KErrNone ) && ( err != KErrNotFound ) && ( err != KErrPathNotFound ) ) { __LEAVE( err ); } RDbNamedDatabase db; CleanupClosePushL( db ); __LEAVE_IF_ERROR( db.Create( TheFsSession, KSearchTestDbPath ) ); // // Create the database table // // Create a table definition CDbColSet* columns = CDbColSet::NewLC(); // add the columns columns->AddL( TDbCol( KCol1, EDbColText ) ); if ( aIndex == 0 ) columns->AddL( TDbCol( KCol2, EDbColText ) ); else columns->AddL( TDbCol( KCol2, EDbColLongText ) ); // if the column is of type "EDbColText" instead, // all searching is working properly // Create a table __LEAVE_IF_ERROR( db.CreateTable( KTable, *columns ) ); // cleanup the column set CleanupStack::PopAndDestroy( columns ); // // Add data // // create a view on the database _LIT( KSQLStatement, "select Artist,Notes from CDs order by Artist" ); RDbView view; __LEAVE_IF_ERROR( view.Prepare( db, TDbQuery( KSQLStatement, EDbCompareNormal ) ) ); __LEAVE_IF_ERROR( view.EvaluateAll() ); // Get the structure of rowset CDbColSet* colSet = view.ColSetL(); // insert a row view.InsertL(); view.SetColL( colSet->ColNo( KCol1 ), KComposer1 ); // Artist // Use the stream // RDbColWriteStream out; // TDbColNo col = colSet->ColNo( KCol2 ); // Ordinal position of long column // // out.OpenLC( view, col ); // out.WriteL( _L( "Some additional comment here." ) ); // out.Close(); // // CleanupStack::PopAndDestroy(); // out view.SetColL( colSet->ColNo( KCol2 ), _L( "Some additional comment here." ) ); view.PutL(); // close the view view.Close(); delete colSet; // // Display the data // _LIT( KRowFormatter, "\r\n Artist: %S \r\n Notes: %S \r\n" ); __LEAVE_IF_ERROR( view.Prepare( db, TDbQuery( KSQLStatement, EDbCompareNormal ) ) ); __LEAVE_IF_ERROR( view.EvaluateAll() ); // Get the structure of the rowset colSet = view.ColSetL(); // iterate across the row set for ( view.FirstL(); view.AtRow(); view.NextL() ) { // retrieve the row view.GetL(); // while the rowset is on this row, can use a TPtrC to // refer to any text columns TPtrC artist = view.ColDes( colSet->ColNo( KCol1 ) ); // and a stream for long columns RDbColReadStream in; TDbColNo col = colSet->ColNo( KCol2 ); // Ordinal position of long column TBuf<256> notes; // Buffer for out notes in.OpenLC( view, col ); in.ReadL( notes, view.ColLength( col ) ); in.Close(); CleanupStack::PopAndDestroy(); // in // Display the artist and notes TBuf<512> msg; msg.Format( KRowFormatter, &artist, ¬es ); TheTest.Printf( msg ); } // close the view view.Close(); delete colSet; // // Search for the data // TInt result; result = SearchForL( _L( "Some*" ), db ); // matches TEST(result == 1); result = SearchForL( _L( "some*" ), db ); // defect causes no match, should match TEST(result == 1); result = SearchForL( _L( "*some*" ), db ); // matches TEST(result == 1); result = SearchForL( _L( "s?me*" ), db ); // matches TEST(result == 1); result = SearchForL( _L( "Some additional comment here." ), db ); // matches TEST(result == 1); result = SearchForL( _L( "some additional comment here." ), db ); // defect causes no match, should match TEST(result == 1); CleanupStack::PopAndDestroy( &db ); }
void eap_am_type_securid_symbian_c::store_authentication_timeL() { EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL("eap_am_type_securid_symbian_c::store_authentication_timeL: EAP-tunneling type=0xfe%06x%08x\n"), m_tunneling_type.get_vendor_id(), m_tunneling_type.get_vendor_type())); HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); TPtr sqlStatement = buf->Des(); // Query all the relevant parameters _LIT(KSQLQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); if (m_eap_type == eap_type_generic_token_card) { sqlStatement.Format( KSQLQuery, &KGTCLastFullAuthTime, &KGtcTableName, &KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingTypeVendorId, m_tunneling_type.get_vendor_id(), &KTunnelingType, m_tunneling_type.get_vendor_type()); } else { // Secure ID is not supported at the moment. // Leave with error. CleanupStack::PopAndDestroy(buf); // Delete buf. User::Leave(KErrNotSupported); } RDbView view; // Evaluate view User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); CleanupClosePushL(view); User::LeaveIfError(view.EvaluateAll()); // Get the first (and only) row for updation. view.FirstL(); view.UpdateL(); // Get column set so we get the correct column numbers CDbColSet* colSet = view.ColSetL(); CleanupStack::PushL(colSet); // Get the current universal time. TTime currentTime; currentTime.UniversalTime(); #if defined(_DEBUG) || defined(DEBUG) TDateTime currentDateTime = currentTime.DateTime(); EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::store_authentication_time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), currentDateTime.Day()+1, currentDateTime.Month()+1,currentDateTime.Year(), currentDateTime.Hour(), currentDateTime.Minute(), currentDateTime.Second(), currentDateTime.MicroSecond())); #endif TInt64 fullAuthTime = currentTime.Int64(); view.SetColL(colSet->ColNo(KGTCLastFullAuthTime), fullAuthTime); view.PutL(); CleanupStack::PopAndDestroy(colSet); // Delete colSet. CleanupStack::PopAndDestroy(&view); // Close view. CleanupStack::PopAndDestroy(buf); // Delete buf. EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); }