void CExPolicy_Server::ReadDbItemsL(TBool aImsi) { TFileName QueryBuffer; QueryBuffer.Copy(_L("SELECT * FROM "));// just get all columns & rows if(aImsi) QueryBuffer.Append(KtxtImsilist); else QueryBuffer.Append(KtxtNumberlist); RDbView Myview; Myview.Prepare(iItemsDatabase,TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.EvaluateAll(); Myview.FirstL(); while(Myview.AtRow()) // Just delete one instance of the message { Myview.GetL(); TExampleItem NewItem; NewItem.iIndex = Myview.ColInt(1); NewItem.iName.Copy(Myview.ColDes(2)); NewItem.iValue.Copy(Myview.ColDes(3)); if(aImsi) iImsiArray.Append(NewItem); else iNumberArray.Append(NewItem); Myview.NextL(); } CleanupStack::PopAndDestroy(1); // Myview }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ TBool CExPolicy_Server::OkToAddToValDb(RDbDatabase& aDatabase,const TDesC& aCode,const TDesC8& aString) { TBool Ret(ETrue); TFileName QueryBuffer; QueryBuffer.Copy(_L("SELECT * FROM ")); QueryBuffer.Append(KtxtVallist); RDbView Myview; Myview.Prepare(aDatabase,TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.EvaluateAll(); Myview.FirstL(); QueryBuffer.Copy(aString); while(Myview.AtRow()) // Just delete one instance of the message { Myview.GetL(); if(QueryBuffer == Myview.ColDes(3) && aCode == Myview.ColDes(2)) { Ret = EFalse; break; } Myview.NextL(); } CleanupStack::PopAndDestroy(1); // Myview return Ret; }
TInt CSCPParamDB :: GetValuesForParameterL(TInt aParamID, RPointerArray <HBufC>& aParamValues, const TInt32 aApp) { _SCPDB_LOG(_L("[CSCPParamDB]-> GetValueForParameterL >>>")); RDbView lDBView; CleanupClosePushL(lDBView); HBufC* lSelectQry = HBufC :: NewLC(KSelectWhereParamIdAppID().Length() + 40); lSelectQry->Des().Format (KSelectWhereParamIdAppID, aParamID, aApp); __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry))); __LEAVE_IF_ERROR(lDBView.EvaluateAll()); if (lDBView.FirstL()) { TInt size(0); TInt lRowCount = lDBView.CountL(); if(lRowCount == 0) { _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter")); CleanupStack :: PopAndDestroy(2); return KErrNotFound; } TInt lErr(KErrNone); do { lDBView.GetL(); size = lDBView.ColDes(iColSet->ColNo(KColValueDes)).Size(); if(size) { HBufC* lBuff = HBufC :: NewL(size); TPtr lPtr(lBuff->Des()); lPtr.Copy(lDBView.ColDes(iColSet->ColNo(KColValueDes))); TRAP(lErr, aParamValues.AppendL(lBuff)); if(lErr != KErrNone) { aParamValues.ResetAndDestroy(); User :: Leave(lErr); } } } while(lDBView.NextL()); } CleanupStack :: PopAndDestroy(2); _SCPDB_LOG(_L("[CSCPParamDB]-> GetValuesForParameterL <<<")); return KErrNone; }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CScheduleDB::ReadDbItemsL(RPointerArray<CMsgSched>& aItemArray) { aItemArray.ResetAndDestroy();// first reset the array TFileName QueryBuffer; QueryBuffer.Copy(_L("SELECT * FROM "));// just get all columns & rows QueryBuffer.Append(KtxtItemlist); RDbView Myview; Myview.Prepare(iItemsDatabase,TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.EvaluateAll(); Myview.FirstL(); while(Myview.AtRow()) // Just delete one instance of the message { Myview.GetL(); CMsgSched* NewItem = new(ELeave)CMsgSched(); aItemArray.Append(NewItem); NewItem->iIndex = Myview.ColInt32(1); NewItem->iTime = Myview.ColTime(5); NewItem->iRepeat = Myview.ColInt32(6); if(Myview.ColInt32(2) > 50) NewItem->iUnicode = ETrue; else NewItem->iUnicode = EFalse; NewItem->iNunmber = Myview.ColDes(3).AllocL(); NewItem->iMessage = Myview.ColDes(4).AllocL(); if(Myview.ColInt32(7) > 50) NewItem->iEnabled = ETrue; else NewItem->iEnabled = EFalse; if(Myview.ColInt32(8) > 50) NewItem->iFlashSMS = ETrue; else NewItem->iFlashSMS = EFalse; Myview.NextL(); } CleanupStack::PopAndDestroy(1); // Myview }
// ----------------------------------------------------------------------------- // CWPInternetAPDB::ReadItemsL // ----------------------------------------------------------------------------- // void CWPInternetAPDB::ReadItemsL(RArray<TAccessPointItem>& aItemArray, TFileName QueryBuffer) { FLOG( _L( "[Provisioning] CWPInternetAPDB::ReadItemsL" ) ); RDbView Myview; Myview.Prepare(iItemsDatabase, TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.EvaluateAll(); if ( Myview.FirstL()) { while (Myview.AtRow()) { Myview.GetL(); TAccessPointItem AccessPointItem; AccessPointItem.iIndex = Myview.ColInt(1); AccessPointItem.iAPID = Myview.ColInt(2); AccessPointItem.iBearerType = Myview.ColInt(3); AccessPointItem.iOriginator.Copy(Myview.ColDes(4)); aItemArray.Append(AccessPointItem); Myview.NextL(); } } CleanupStack::PopAndDestroy(); // Myview FLOG( _L( "[Provisioning] CWPInternetAPDB::ReadItemsL: done" ) ); }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CScheduleDB::ReadDbItemsL(RPointerArray<CMsgStored>& aItemArray) { aItemArray.ResetAndDestroy();// first reset the array TFileName QueryBuffer; QueryBuffer.Copy(_L("SELECT * FROM "));// just get all columns & rows QueryBuffer.Append(KtxtItemlist2); RDbView Myview; Myview.Prepare(iItemsDatabase,TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.EvaluateAll(); Myview.FirstL(); while(Myview.AtRow()) // Just delete one instance of the message { Myview.GetL(); CMsgStored* NewItem = new(ELeave)CMsgStored(); aItemArray.Append(NewItem); NewItem->iIndex = Myview.ColInt32(1); NewItem->iMessage = Myview.ColDes(2).AllocL(); Myview.NextL(); } CleanupStack::PopAndDestroy(1); // Myview }
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); }
// --------------------------------------------------------------------------- // CFotaDB::RowToStateL // Extracts db row contents to package state object and aPkgUrl // Returns url in aPkgURL parameter // --------------------------------------------------------------------------- TPackageState CFotaDB::RowToStateL(HBufC8*& aPkgUrl, const RDbView& aView) { TPackageState s; TInt pkgid = aView.ColInt(iColSet->ColNo(KColPkgId)); TInt state = aView.ColInt(iColSet->ColNo(KColState)); TInt result = aView.ColInt(iColSet->ColNo(KColResult)); TSmlProfileId profileid(aView.ColInt(iColSet->ColNo(KColProfileId))); TPtrC pkgname = aView.ColDes(iColSet->ColNo(KColPkgName)); TPtrC version = aView.ColDes(iColSet->ColNo(KColVersion)); TInt smltrycount = aView.ColInt(iColSet->ColNo(KColSmlTryCount)); TInt sessiontype = aView.ColInt(iColSet->ColNo(KColSessionType)); TInt iapid = aView.ColInt(iColSet->ColNo(KColIapId)); TUint pkgsize = aView.ColUint(iColSet->ColNo(KColPkgSize)); TBool updateltr = aView.ColUint8(iColSet->ColNo(KColUpdateLtr)); s.iPkgId = pkgid; s.iPkgName.Copy(pkgname); s.iPkgVersion.Copy(version); s.iProfileId = profileid; s.iResult = result; s.iState = RFotaEngineSession::TState(state); s.iSmlTryCount = smltrycount; s.iSessionType = sessiontype; s.iIapId = iapid; s.iPkgSize = pkgsize; s.iUpdateLtr = updateltr; RDbColReadStream rstream; TInt len = aView.ColLength(iColSet->ColNo(KColPkgUrl)); rstream.OpenLC(aView, iColSet->ColNo(KColPkgUrl)); HBufC* pkgurl = HBufC::NewLC(len); TPtr ptr = pkgurl->Des(); rstream.ReadL(ptr, len); HBufC8* tmp = HBufC8::NewL(pkgurl->Des().Length()); tmp->Des().Copy(pkgurl->Des()); aPkgUrl = tmp; CleanupStack::PopAndDestroy(pkgurl); CleanupStack::PopAndDestroy(&rstream); return s; }
/** @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 eapol_am_wlan_authentication_symbian_c::read_configureL( const TDesC& aDbName, const TDesC& aTableName, eap_config_string field, const u32_t /*field_length*/, eap_variable_data_c * const data) { EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eapol_am_wlan_authentication_symbian_c::read_configureL(): %s, this = 0x%08x => 0x%08x\n"), (m_is_client == true) ? "client": "server", this, dynamic_cast<abs_eap_base_timer_c *>(this))); EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, TRACE_FLAGS_DEFAULT, "returns: eapol_am_wlan_authentication_symbian_c::read_configureL()"); // Open database RDbNamedDatabase db; TInt error = db.Open(m_session, aDbName); EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eapol_am_wlan_authentication_symbian_c::read_configureL(): db.Open(), error = %d\n"), error)); User::LeaveIfError(error); CleanupClosePushL(db); // Create a buffer for the ascii strings - initialised with the argument HBufC8* asciibuf = HBufC8::NewLC(128); TPtr8 asciiString = asciibuf->Des(); asciiString.Copy(reinterpret_cast<const unsigned char *>(field)); // Buffer for unicode parameter HBufC* unicodebuf = HBufC::NewLC(128); TPtr unicodeString = unicodebuf->Des(); // Convert to unicode unicodeString.Copy(asciiString); // Now do the database query HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); TPtr sqlStatement = buf->Des(); _LIT(KSQLQueryRow, "SELECT %S FROM %S"); sqlStatement.Format( KSQLQueryRow, &unicodeString, &aTableName ); RDbView view; User::LeaveIfError(view.Prepare(db, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); CleanupClosePushL(view); User::LeaveIfError(view.EvaluateAll()); if (view.FirstL()) { eap_status_e status(eap_status_process_general_error); view.GetL(); switch (view.ColType(1)) { case EDbColText: { unicodeString = view.ColDes(1); // Convert to 8-bit asciiString.Copy(unicodeString); if (asciiString.Size() > 0) { status = data->set_copy_of_buffer(asciiString.Ptr(), asciiString.Size()); if (status != eap_status_ok) { User::Leave(m_am_tools->convert_eapol_error_to_am_error( EAP_STATUS_RETURN(m_am_tools, status))); } } else { // Empty field. Do nothing...data remains invalid and the stack knows what to do hopefully. break; } } break; case EDbColUint32: { TUint value; value = view.ColUint32(1); status = data->set_copy_of_buffer((const unsigned char *) &value, sizeof(value)); if (status != eap_status_ok) { User::Leave(m_am_tools->convert_eapol_error_to_am_error( EAP_STATUS_RETURN(m_am_tools, status))); } } break; default: EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: read_configureL: Unexpected column type.\n"))); User::Panic(_L("EAPOL"), 1); } } else { // Could not find parameter EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: read_configureL: Could not find configuration parameter.\n"))); User::Leave(m_am_tools->convert_eapol_error_to_am_error( EAP_STATUS_RETURN(m_am_tools, eap_status_not_found))); } // Close database CleanupStack::PopAndDestroy(&view); CleanupStack::PopAndDestroy(buf); CleanupStack::PopAndDestroy(unicodebuf); CleanupStack::PopAndDestroy(asciibuf); CleanupStack::PopAndDestroy(&db); EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); }
TInt eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL() { EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): m_index_type=%d, m_index=%d, m_tunneling_type=0xfe%06x%08x\n"), m_index_type, m_index, m_tunneling_type.get_vendor_id(), m_tunneling_type.get_vendor_type())); TInt status = KErrNone; HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); TPtr sqlStatement = buf->Des(); // Query all the relevant parameters _LIT(KSQLQuery, "SELECT %S, %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); sqlStatement.Format( KSQLQuery, &cf_str_EAP_GTC_passcode_prompt_literal, &cf_str_EAP_GTC_identity_literal, &cf_str_EAP_GTC_passcode_literal, &KGtcTableName, &KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingTypeVendorId, m_tunneling_type.get_vendor_id(), &KTunnelingType, m_tunneling_type.get_vendor_type()); EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): Reads database\n"))); 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 view.FirstL(); view.GetL(); // Get column set so we get the correct column numbers CDbColSet* colSet = view.ColSetL(); CleanupStack::PushL(colSet); EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): Reads database\n"))); TPtrC username = view.ColDes(colSet->ColNo( cf_str_EAP_GTC_identity_literal ) ); EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): username"), username.Ptr(), username.Size())); TPtrC password = view.ColDes(colSet->ColNo( cf_str_EAP_GTC_passcode_literal ) ); EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): password"), password.Ptr(), password.Size())); TUint prompt = view.ColUint(colSet->ColNo(cf_str_EAP_GTC_passcode_prompt_literal)); EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): prompt=%d\n"), prompt)); if ((EEapDbFalse != prompt) || (username.Size() == 0) || (password.Size() == 0)) { if (username.Size() == 0) { m_dialog_data_ptr->iUsername.Zero(); } else { m_dialog_data_ptr->iUsername.Copy(username); } status = KErrCancel; } else { status = KErrNone; m_dialog_data_ptr->iUsername.Copy(username); m_dialog_data_ptr->iPassword.Copy(password); } CleanupStack::PopAndDestroy(colSet); // Delete colSet. CleanupStack::PopAndDestroy(&view); // Close view. CleanupStack::PopAndDestroy(buf); // Delete buf. EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): status=%d\n"), status)); return status; }