// --------------------------------------------------------------------------- // 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 eap_am_type_securid_symbian_c::type_configure_readL( 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("eap_am_type_securid_symbian_c::type_configure_readL(): 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())); EAP_UNREFERENCED_PARAMETER(field_length); // Create a buffer for the ascii strings - initialised with the argument HBufC16* unicodeBuf = HBufC16::NewLC(KMaxDBFieldNameLength); TPtr16 unicodeString = unicodeBuf->Des(); TPtrC8 fieldPtr(reinterpret_cast<const TUint8 *> (field), field_length); unicodeString.Copy(fieldPtr); // Now do the database query HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); TPtr sqlStatement = buf->Des(); _LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); if (m_eap_type == eap_type_securid) { sqlStatement.Format( KSQLQueryRow, &unicodeString, &KSecurIDTableName, &KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingTypeVendorId, m_tunneling_type.get_vendor_id(), &KTunnelingType, m_tunneling_type.get_vendor_type()); } else { sqlStatement.Format( KSQLQueryRow, &unicodeString, &KGtcTableName, &KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingTypeVendorId, m_tunneling_type.get_vendor_id(), &KTunnelingType, m_tunneling_type.get_vendor_type()); } RDbView view; User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); CleanupClosePushL(view); User::LeaveIfError(view.EvaluateAll()); if (view.FirstL()) { eap_status_e status = eap_status_ok; view.GetL(); switch (view.ColType(KDefaultColumnInView_One)) { case EDbColText: { if (view.ColLength(KDefaultColumnInView_One) > 0) { TPtrC16 value = view.ColDes16(KDefaultColumnInView_One); eap_variable_data_c string_unicode(m_am_tools); status = string_unicode.set_copy_of_buffer(value.Ptr(), value.Size()); if (status != eap_status_ok) { User::Leave( m_am_tools->convert_eapol_error_to_am_error( EAP_STATUS_RETURN(m_am_tools, status))); } status = m_am_tools->convert_unicode_to_utf8( *data, string_unicode); if (status != eap_status_ok) { User::Leave( m_am_tools->convert_eapol_error_to_am_error( EAP_STATUS_RETURN(m_am_tools, status))); } } else { data->reset(); status = data->set_copy_of_buffer("", 0); if (status != eap_status_ok) { User::Leave( m_am_tools->convert_eapol_error_to_am_error( EAP_STATUS_RETURN(m_am_tools, status))); } } } break; case EDbColUint32: { TUint value = view.ColUint32(KDefaultColumnInView_One); status = data->set_copy_of_buffer(reinterpret_cast<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("type_configure_readL: Unexpected column type.\n"))); User::Leave(KErrGeneral); break; } } else { // Could not find parameter EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("type_configure_readL: Could not find configuration parameter.\n"))); User::Leave(KErrArgument); } CleanupStack::PopAndDestroy(3); // Close view, 2 x buf EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); }