コード例 #1
0
// ---------------------------------------------------------
// RFavouritesSrvTable::SetUrlL
// ---------------------------------------------------------
//
void RFavouritesSrvTable::SetUrlL( const TDesC& aUrl )
{
    RDbColWriteStream stream;
    stream.OpenLC( *this, iColNoUrl );
    stream.WriteL( aUrl, aUrl.Length() );
    stream.CommitL();
    CleanupStack::PopAndDestroy();  // stream;
}
コード例 #2
0
// ---------------------------------------------------------
// RFavouritesSrvTable::SetExtraDataL
// ---------------------------------------------------------
//
void RFavouritesSrvTable::SetExtraDataL( MStreamBuf& aSource )
{
    RDbColWriteStream ws;
    ws.OpenLC( *this, iColNoExtraData );
    RReadStream rs( &aSource );
    ws.WriteL( rs );
    ws.CommitL();
    CleanupStack::PopAndDestroy();  // Close ws
}
コード例 #3
0
ファイル: FotaDB.cpp プロジェクト: kuailexs/symbiandump-mw3
// ---------------------------------------------------------------------------
// 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);
    }
コード例 #4
0
// ---------------------------------------------------------------------------
//  CNSmlDmFotaAdapterDb::SetLongStrValueL()
//  Streams aValue and its length as the value of aColumn in FW object 
//  identified by aObject.
// ---------------------------------------------------------------------------
// 
TInt CNSmlDmFotaAdapterDb::SetLongStrValueL( const TDesC& aColumn, 
                                             const TDesC8& aValue, 
                                             const TNSmlDmFwObjectId aObject )
    {
    _DBG_FILE("CNSmlDmFotaAdapterDb::SetLongStrValueL(): begin");
    
    HBufC* value = ConvertTo16BitLC( aValue );
    
    DBG_ARGS( _S16("CNSmlDmFotaAdapterDb::SetStrValueL(): ('%S', '%S', %d)"),
              &aColumn, value, aObject );
    
    TInt ret = UpdateRowL( aObject );
    
    if ( ret == KErrNone )
        {
        // do update
        
        RDbColWriteStream wStream;
        wStream.OpenL( iView, iColSet->ColNo( aColumn ) );
        CleanupClosePushL( wStream );
        
        wStream.WriteInt32L( value->Length() );
        wStream.WriteL( *value, value->Length() );
        
        CleanupStack::PopAndDestroy( &wStream );
        
        iView.PutL();
        }
    
    CommitAndCompact();
    
    CleanupStack::PopAndDestroy( value );
    
    _DBG_FILE("CNSmlDmFotaAdapterDb::SetLongStrValueL(): end");
    
    return ret;
    }
コード例 #5
0
ファイル: t_sql.cpp プロジェクト: cdaffara/symbiandump-os2
// write rows equivalent to TypeText and use its tests
void TestPredicate2::RunL()
	{
	Create(TypeLongText::KType);
	TBuf<1022> fill=_S("abcdefghijklmnopqrstuvqxyz");
	fill.AppendFill('.',fill.MaxLength()-fill.Length());

	for (TInt row=0;row<=TInt(elementsof(TypeText::KValues));++row)
		{
		TheTable.InsertL();
		TheTable.SetColL(1,row);
		if (row>0)
			{
			RDbColWriteStream blob;
			blob.OpenLC(TheTable,2);
			switch (row)
				{
			case 0:
				break;
			case 1: case 2: case 3: case 4: case 5: case 10: case 11:
				blob.WriteL(TPtrC(TypeText::KValues[row-1]));
				break;
			case 6:
				blob.WriteL(fill);
				blob.WriteL(_L("like"));
				break;
			case 7:
				blob.WriteL(_L("like"));
				blob.WriteL(fill);
				break;
			case 8:
				blob.WriteL(fill);
				blob.WriteL(_L("like"));
				blob.WriteL(fill);
				break;
			case 9:
				blob.WriteL(fill);
				blob.WriteL(_L("live"));
				blob.WriteL(fill);
				break;
				}
			blob.CommitL();
			CleanupStack::PopAndDestroy();
			}
		TheTable.PutL();
		}
	TheTable.Close();
	TInt r=TheDatabase.Commit();
	TEST2(r, KErrNone);
	TestViewL(TypeText::KTests,elementsof(TypeText::KTests),elementsof(TypeText::KValues));
	CDbKey& key=*CDbKey::NewLC();
	key.AddL(TDbKeyCol(_L("Test"),120));
	r=TheDatabase.CreateIndex(_L("Key"),_L("Compare"),key);
	TEST2(r, KErrNone);
	CleanupStack::PopAndDestroy();
	TestViewL(TypeText::KTests,elementsof(TypeText::KTests),elementsof(TypeText::KValues));
	r=TheDatabase.Execute(_L("DROP TABLE Compare"));
	TEST2(r, KErrNone);
	}
コード例 #6
0
void InsertTrackTableL()
	{	
	HBufC* randomDataBuf = HBufC::NewLC(KTestBlobSize);
	TPtr randomData(randomDataBuf->Des());
	FillRandomData(randomData);
	
	RDbView view;
	TInt err = view.Prepare(TheDatabase, _L("select * from TRACKS"), view.EInsertOnly);
	TEST2(err, KErrNone);
	TheRowSet = view;	
	
	CDbColSet* colSet = TheRowSet.ColSetL();
	const TInt KIdIdx = colSet->ColNo(KId);
	const TInt KLastNameIdx = colSet->ColNo(KLastName);
	const TInt KFirstNameIdx = colSet->ColNo(KFirstName);
	const TInt KTitleIdx = colSet->ColNo(KTitle);
	const TInt KDownloadSiteIdx = colSet->ColNo(KDownloadSite);
	const TInt KBandNameIdx = colSet->ColNo(KBandName);
	const TInt KOriginIdx = colSet->ColNo(KOrigin);
	const TInt KAutoStartIdx = colSet->ColNo(KAutoStart);
	const TInt KInitVolumeIdx = colSet->ColNo(KInitVolume);
	const TInt KMarkedToPlayIdx = colSet->ColNo(KMarked2Play);
	const TInt KCategoryIdIdx = colSet->ColNo(KCategoryId);
	//const TInt KMusicFileIdx = colSet->ColNo(KMusicFile);
	delete colSet;
	colSet = NULL;

	err = TheDatabase.Begin();
	TEST2(err, KErrNone);
	
	for (TInt ii=1;ii<=KTrackRecordCount;++ii)
		{
		TheRowSet.InsertL();
		TheRowSet.SetColL(KIdIdx, ii);
		TheRowSet.SetColL(KLastNameIdx, _L("Dummy"));
		TheRowSet.SetColL(KFirstNameIdx,_L("Dummy"));
		TheRowSet.SetColL(KTitleIdx,_L("Dummy"));
		TheRowSet.SetColL(KDownloadSiteIdx,_L("Dummy"));
		TheRowSet.SetColL(KBandNameIdx,_L("Dummy"));
		TheRowSet.SetColL(KOriginIdx,_L("Dummy"));
		TheRowSet.SetColL(KAutoStartIdx,(ii%2));
		TheRowSet.SetColL(KInitVolumeIdx,(ii%2));
		TheRowSet.SetColL(KMarkedToPlayIdx,(ii%2));
		TheRowSet.SetColL(KCategoryIdIdx,(ii%KCategoryRecordCount));

		//RDbColWriteStream musicfile;
		//musicfile.OpenLC(TheRowSet, KMusicFileIdx);
		//musicfile.WriteL(randomData,KTestBlobSize);
		//musicfile.CommitL();
		//CleanupStack::PopAndDestroy(&musicfile);

		TheRowSet.PutL();
		}

	err = TheDatabase.Commit();
	TEST2(err, KErrNone);

	//err = TheDatabase.Compact();
	//TEST2(err, KErrNone);

	TheRowSet.Close();	

	////////////////////////////////////////////////////////////////////////////////////////////////

	err = view.Prepare(TheDatabase, _L("select * from TRACKS2"), view.EInsertOnly);
	TEST2(err, KErrNone);
	TheRowSet = view;	
	
	colSet = TheRowSet.ColSetL();
	const TInt KIdIdx2 = colSet->ColNo(KId);
	const TInt KMusicFileIdx2 = colSet->ColNo(KMusicFile);
	delete colSet;

	err = TheDatabase.Begin();
	TEST2(err, KErrNone);

	for (TInt ii=1;ii<=KTrackRecordCount;++ii)
		{
		TheRowSet.InsertL();
		TheRowSet.SetColL(KIdIdx2, ii);
		
		RDbColWriteStream musicfile;
		musicfile.OpenLC(TheRowSet, KMusicFileIdx2);
		musicfile.WriteL(randomData,KTestBlobSize);
		musicfile.CommitL();
		CleanupStack::PopAndDestroy(&musicfile);
		
		TheRowSet.PutL();
		}

	err = TheDatabase.Commit();
	TEST2(err, KErrNone);

	//err = TheDatabase.Compact();
	//TEST2(err, KErrNone);

	TheRowSet.Close();	

	CleanupStack::PopAndDestroy(randomDataBuf);
	}
コード例 #7
0
ファイル: CAppConfig.cpp プロジェクト: azaka/puzzless60
static void save_game(void *ctx, void *buf, int len) {
    RDbColWriteStream *s = (RDbColWriteStream*)ctx;
    TPtrC8 p((TUint8*)buf, len);
    TRAPD(error, s->WriteL(p));
}
コード例 #8
0
static void TblCallTestL()
	{
	TheTest.Next(_L("Open()"));	
	TInt err = TheTbl1.Open(TheDb1, KTableName1);
	TEST2(err, KErrNone);
	
	TheTest.Next(_L("ColSetL()"));	
	CDbColSet* colset = TheTbl1.ColSetL();
	TInt cnt = colset->Count();
	TInt i;
	for(i=0;i<cnt;++i)
		{
		const TDbCol& dbc = (*colset)[i + 1];
		TheTest.Printf(_L("%02d, %S\n"), i + 1, &dbc.iName);
		}
	delete colset;
	
	TheTest.Next(_L("ColDef()"));	
	TDbCol dbcol = TheTbl1.ColDef(1);
	TheTest.Printf(_L("%S\n"), &dbcol.iName);

	TheTest.Next(_L("InsertL()/SetColL()/PutL()"));	
	TheTbl1.InsertL();
	TheTbl1.SetColL(2, 1);
	TheTbl1.SetColL(3, 2);
	TheTbl1.PutL();
	TheTbl1.InsertL();
	TheTbl1.SetColL(2, 3);
	TheTbl1.SetColL(3, 4);
	TheTbl1.PutL();
	
	TheTest.Next(_L("AtRow()/AtBeginning()/AtEnd()"));	
	(void)TheTbl1.AtRow();
	(void)TheTbl1.AtBeginning();
	(void)TheTbl1.AtEnd();

	TheTest.Next(_L("BeginningL()/EndL()"));	
	TheTbl1.BeginningL();
	TheTbl1.EndL();

	TheTest.Next(_L("FirstL()/LastL()/PreviousL()/PreviousL()"));	
	TBool res = TheTbl1.FirstL();
	TEST(res);
	TheTbl1.GetL();
	TInt32 val1 = TheTbl1.ColInt32(1);
	TInt32 val2 = TheTbl1.ColInt32(2);
	TInt32 val3 = TheTbl1.ColInt32(3);
	TEST(val1 == 0);
	TEST(val2 == 1);
	TEST(val3 == 2);
	
	res = TheTbl1.LastL();
	TEST(res);
	TheTbl1.GetL();
	val1 = TheTbl1.ColInt32(1);
	val2 = TheTbl1.ColInt32(2);
	val3 = TheTbl1.ColInt32(3);
	TEST(val1 == 1);
	TEST(val2 == 3);
	TEST(val3 == 4);

	res = TheTbl1.PreviousL();
	TEST(res);
	TheTbl1.GetL();
	val1 = TheTbl1.ColInt32(1);
	val2 = TheTbl1.ColInt32(2);
	val3 = TheTbl1.ColInt32(3);
	TEST(val1 == 0);
	TEST(val2 == 1);
	TEST(val3 == 2);
	
	res = TheTbl1.NextL();
	TEST(res);
	TheTbl1.GetL();
	val1 = TheTbl1.ColInt32(1);
	val2 = TheTbl1.ColInt32(2);
	val3 = TheTbl1.ColInt32(3);
	TEST(val1 == 1);
	TEST(val2 == 3);
	TEST(val3 == 4);

	TheTest.Next(_L("UpdateL()"));	
	TheTbl1.UpdateL();
	TheTbl1.SetColL(2, 33);
	TheTbl1.SetColL(3, 44);
	TheTbl1.PutL();

	TheTest.Next(_L("Cancel()"));	
	TheTbl1.UpdateL();
	TheTbl1.SetColL(2, 36);
	TheTbl1.SetColL(3, 47);
	TheTbl1.Cancel();

	TheTest.Next(_L("DeleteL()"));	
	TheTbl1.DeleteL();

	TheTest.Next(_L("IsColNull()"));	
	CDbColSet* colset2 = TDBSCUtils::CreateColSetLC(KColumns2);
	_LIT(KTempTblName, "TempTbl");
	err = TheDb1.CreateTable(KTempTblName, *colset2);
	TEST2(err, KErrNone);
	CleanupStack::PopAndDestroy(colset2);

	err = TheTbl2.Open(TheDb1, KTempTblName);
	TEST2(err, KErrNone);

	TheTbl2.InsertL();
	_LIT8(KTestData, "");
	TheTbl2.SetColL(2, KTestData);
	TheTbl2.PutL();
	
	TheTbl2.Close();
	err = TheTbl2.Open(TheDb1, KTempTblName);
	TEST2(err, KErrNone);
	res = TheTbl2.FirstL();
	TEST(res);
	TheTbl2.GetL();
	res = TheTbl2.IsColNull(2);
	TEST(res);
	TheTbl2.Close();
	
	TheTest.Next(_L("ColSize()"));	
	res = TheTbl1.FirstL();
	TEST(res);
	TheTbl1.GetL();
	res = TheTbl1.ColSize(1);
	TEST(res);
		
	TheTest.Next(_L("ColLength()"));	
	TInt len = TheTbl1.ColLength(1);
	TEST(len > 0);

	TheTbl1.InsertL();
	TheTbl1.SetColL(2, 3);
	TheTbl1.SetColL(3, 4);
	TheTbl1.PutL();

	TheTest.Next(_L("GotoL(TPosition)"));	
	res = TheTbl1.GotoL(RDbRowSet::EFirst);
	TEST(res);
	
	TheTest.Next(_L("Bookmark()/GotoL(TDbBookmark)"));	
	TDbBookmark bkmk = TheTbl1.Bookmark();
	res = TheTbl1.NextL();
	TEST(res);
	TheTbl1.GotoL(bkmk);
	TheTbl1.GetL();
	val1 = TheTbl1.ColInt32(1);
	TEST(val1 == 0);
	
	TheTest.Next(_L("CountL()/IsEmptyL()"));	
	cnt = TheTbl1.CountL();
	TEST(cnt == 2);
	res = TheTbl1.IsEmptyL();
	TEST(!res);
	
	TheTest.Next(_L("MatchL()"));	
	RDbRowConstraint match;
	CleanupClosePushL(match);
	err = match.Open(TheTbl1, TDbQuery(_L("ID > 0")));
	TEST2(err, KErrNone);
	res = EFalse;
	TheTbl1.BeginningL();
	while(TheTbl1.NextL())
		{
		if(TheTbl1.MatchL(match))
			{
			res = ETrue;
			}
		}
	CleanupStack::PopAndDestroy(&match);
	TEST(res);

	TheTest.Next(_L("FindL()"));	
	res = TheTbl1.FirstL();
	TEST(res);
	err = TheTbl1.FindL(RDbRowSet::EForwards, TDbQuery(_L("ID <> 0")));
	TEST(err >= 0);
	TheTbl1.GetL();
	val1 = TheTbl1.ColInt32(1);
	TEST(val1 > 0);

	_LIT8(KTestData2, "0123456789");
	HBufC8* buf = HBufC8::NewLC(10000);
	TPtr8 ptr = buf->Des(); 
	for(i=0;i<1000;++i)
		{
		ptr += KTestData2();
		}
	
	TheTest.Next(_L("RDbColReadStream"));	
	err = TheTbl2.Open(TheDb1, KTempTblName);
	TEST2(err, KErrNone);

	TheTbl2.InsertL();
	TheTbl2.SetColL(2, *buf);
	TheTbl2.PutL();
	
	TheTbl2.InsertL();
	TheTbl2.SetColL(2, KTestData2);
	TheTbl2.PutL();
	
	res = TheTbl2.PreviousL();
	TEST(res);
	TheTbl2.GetL();
	RDbColReadStream rstream;
	rstream.OpenLC(TheTbl2, 2);
	ptr.Zero();
	rstream.ReadL(ptr, ptr.MaxLength());
	CleanupStack::PopAndDestroy(&rstream);
	TEST(ptr.Length() == ptr.MaxLength());

	TheTest.Next(_L("RDbColWriteStream"));	
	TheTbl2.InsertL();
	RDbColWriteStream wstream;
	wstream.OpenLC(TheTbl2, 2);
	wstream.WriteL(ptr, ptr.Length());
	wstream.CommitL();
	CleanupStack::PopAndDestroy(&wstream);
	TheTbl2.PutL();
	
	TheTbl2.Close();
	CleanupStack::PopAndDestroy(buf);
			
	TheTbl1.Close();
	}