TStreamId TIniData::StoreL(CStreamStore& aStore) const { RStoreWriteStream stream; TStreamId id2=stream.CreateLC(aStore); stream << *this; stream.CommitL(); CleanupStack::PopAndDestroy(); TStreamId id1=stream.CreateLC(aStore); stream << *this; stream.CommitL(); CleanupStack::PopAndDestroy(); TStreamId id3=stream.CreateLC(aStore); stream << id1 << id2; stream.CommitL(); CleanupStack::PopAndDestroy(); return id3; }
TStreamId THighscoreHolder::StoreL(CStreamStore& aStore) const { RStoreWriteStream stream; TStreamId id = stream.CreateLC(aStore); ExternalizeL(stream); stream.CommitL(); CleanupStack::PopAndDestroy(); return id; }
/** @SYMTestCaseID SYSLIB-STORE-CT-1147 @SYMTestCaseDesc Writing to a store test @SYMTestPriority High @SYMTestActions Tests for writing to a store @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ LOCAL_C void testWriteL(CPersistentStore& aStore) { test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1147 Writing... ")); RStoreWriteStream out; TStreamId id=out.CreateLC(aStore); for (TInt i=0;i<=KTestLength;++i) { out.WriteL(KTestDes,i); out.WriteL(&KTestData[i],KTestLength-i); } out.CommitL(); out.Close(); aStore.SetRootL(out.CreateL(aStore)); out<<KTestDes; out<<id; out.CommitL(); CleanupStack::PopAndDestroy(); }
TStreamId CSWICertStoreTool::WriteCertDataL(const TDesC8& aData) { RStoreWriteStream stream; TStreamId streamId = stream.CreateLC(*iStore); stream.WriteL(aData); stream.CommitL(); CleanupStack::PopAndDestroy(&stream); return streamId; }
/** @SYMTestCaseID SYSLIB-STORE-CT-1151 @SYMTestCaseDesc Copying to a single file store test. @SYMTestPriority High @SYMTestActions Test for copying using different buffer sizes @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ LOCAL_C void testCopyL() { test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1151 Copying using small transfers ")); TParsePtrC parse(KFileLocationSpec); CFileStore* store=CFileStore::OpenLC(TheFs,parse.NameAndExt(),EFileRead|EFileWrite); RStoreReadStream in; in.OpenLC(*store,store->Root()); in>>TheBuf; TStreamId copyId; in>>copyId; in.Close(); in.OpenL(*store,copyId); RStoreWriteStream out; TStreamId id=out.CreateLC(*store); testCopyL(out,in); out.CommitL(); out.Close(); in.Close(); in.OpenL(*store,id); testReadL(in); in.Close(); // test.Next(_L("Copying using a single big transfer")); in.OpenL(*store,copyId); id=out.CreateL(*store); in.ReadL(out,KTestTotal); out.CommitL(); out.Close(); in.Close(); in.OpenL(*store,id); testReadL(in); in.Close(); in.OpenL(*store,copyId); id=out.CreateL(*store); out.WriteL(in,KTestTotal); out.CommitL(); out.Close(); in.Close(); in.OpenL(*store,id); testReadL(in); // CleanupStack::PopAndDestroy(3); }
// // Test writing to a store // // Writes two streams in a store - the first containing sections of // the test data repeated, and the the second containing the test data // and the id of the first stream. Returns the id of the second // stream. // LOCAL_C TStreamId testWriteL(CStreamStore& aStore) { test.Next(_L("Writing...")); RStoreWriteStream out; TStreamId id=out.CreateLC(aStore); for (TInt i=0;i<=KTestLength;++i) { out.WriteL(KTestDes,i); out.WriteL(&KTestData[i],KTestLength-i); } out.CommitL(); out.Close(); TStreamId head=out.CreateL(aStore); out<<KTestDes; out<<id; out.CommitL(); CleanupStack::PopAndDestroy(); return head; }
EXPORT_C void CClipboard::CommitL() { RStoreWriteStream stream; TStreamId streamId=stream.CreateLC(*iStore); stream<< *iStreamDictionary; stream.CommitL(); CleanupStack::PopAndDestroy(); // dictionary stream iStore->SetRootL(streamId); iStore->CommitL(); }
/** @SYMTestCaseID SYSLIB-STORE-CT-1152 @SYMTestCaseDesc Tests empty streams @SYMTestPriority High @SYMTestActions Tests for empty stream buffers.Check for end of file error,overflow error flags @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ LOCAL_C void testEmptyL(CStreamStore& aStore) { test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1152 Stream created using 'extend' ")); TStreamId empty=aStore.ExtendL(); RStoreReadStream in; in.OpenL(aStore,empty); TUint8 b; test(in.Source()->ReadL(&b,1)==0); in.Source()->SeekL(0,KStreamBeginning); test(in.Source()->SeekL(MStreamBuf::ERead,EStreamMark)==KStreamBeginning); test(in.Source()->SizeL()==0); TRAPD(r,in.Source()->SeekL(MStreamBuf::ERead,EStreamBeginning,1)); test(r==KErrEof); TRAP(r,in.Source()->SeekL(MStreamBuf::ERead,EStreamEnd,-1)); test(r==KErrEof); in.Close(); RStoreWriteStream out; out.OpenL(aStore,empty); out.Sink()->SeekL(0,KStreamBeginning); test(out.Sink()->SeekL(MStreamBuf::EWrite,EStreamMark)==KStreamBeginning); test(out.Sink()->SizeL()==0); TRAP(r,out.Sink()->SeekL(MStreamBuf::EWrite,EStreamBeginning,1)); test(r==KErrEof); TRAP(r,out.Sink()->SeekL(MStreamBuf::EWrite,EStreamEnd,-1)); test(r==KErrEof); TRAP(r,out.WriteUint8L(0)); test(r==KErrOverflow); out.Close(); // test.Next(_L("Replacing empty with empty")); out.ReplaceL(aStore,empty); out.CommitL(); out.Release(); in.OpenL(aStore,empty); test(in.Source()->ReadL(&b,1)==0); in.Source()->SeekL(0,KStreamBeginning); test(in.Source()->SeekL(MStreamBuf::ERead,EStreamMark)==KStreamBeginning); test(in.Source()->SizeL()==0); TRAP(r,in.Source()->SeekL(MStreamBuf::ERead,EStreamBeginning,1)); test(r==KErrEof); TRAP(r,in.Source()->SeekL(MStreamBuf::ERead,EStreamEnd,-1)); test(r==KErrEof); in.Close(); out.OpenL(aStore,empty); out.Sink()->SeekL(0,KStreamBeginning); test(out.Sink()->SeekL(MStreamBuf::EWrite,EStreamMark)==KStreamBeginning); test(out.Sink()->SizeL()==0); TRAP(r,out.Sink()->SeekL(MStreamBuf::EWrite,EStreamBeginning,1)); test(r==KErrEof); TRAP(r,out.Sink()->SeekL(MStreamBuf::EWrite,EStreamEnd,-1)); test(r==KErrEof); TRAP(r,out.WriteUint8L(0)); test(r==KErrOverflow); out.Close(); }
EXPORT_C TStreamId CApaModelDoor::StoreL(CStreamStore& aTargetStore)const /** Stores the model data in the specified store as an embedded store. The function stores the model data, if the model exists in memory, otherwise, it simply copies the stream containing the embedded document into the specified store. @param aStore The store in which the model data is to be stored. @return The stream ID of the head stream for the embedded model data. This stream contains the stream dictionary through which the embedded data and its door can be restored. */ { // create stream dictionary CStreamDictionary* streamDic = CStreamDictionary::NewLC(); // // stream out door's state ExternalizeBaseStreamL(aTargetStore,*streamDic); // // store the model TStreamId id; RStoreWriteStream stream; if (iModelHeader) { // create an embedded store in a new write stream id = stream.CreateL(aTargetStore); CEmbeddedStore* target=CEmbeddedStore::NewLC(stream); // takes ownership of stream streamDic->AssignL(KUidApaDoorDocStream,id); // store the model CStreamDictionary* rootDict=CStreamDictionary::NewLC(); iModelHeader->StoreL(*target,*rootDict); CApaProcess::WriteRootStreamL(*target,*rootDict,iModelHeader->AppId()); CleanupStack::PopAndDestroy(); // rootDict // close the new embedded store target->CommitL(); CleanupStack::PopAndDestroy(); // target } else if (iStore) { RStoreWriteStream trg; id = trg.CreateLC(aTargetStore); CopyStoreL(*iStore,trg); CleanupStack::PopAndDestroy(); // trg streamDic->AssignL(KUidApaDoorDocStream,id); } else Panic(EPanicNoModelHeaderWhenStoring); // impossible situation // // store the stream dictionary and return its stream id id = stream.CreateLC(aTargetStore); stream<< *streamDic; stream.CommitL(); CleanupStack::PopAndDestroy(2); // stream,streamDic return id; }
void CSWICertStoreTool::WriteRootStreamL(TStreamId aInfoStreamId) { // Create root stream - just contains id of info stream ASSERT(aInfoStreamId != KNullStreamId); RStoreWriteStream rootStream; TStreamId rootStreamId = rootStream.CreateLC(*iStore); iStore->SetRootL(rootStreamId); rootStream << aInfoStreamId; rootStream.CommitL(); CleanupStack::PopAndDestroy(&rootStream); iStore->Commit(); }
LOCAL_C void doMakeAndStoreL(CStreamStore& aStore,TStreamId& anId) { // Construct an object of type CClassA and put some // data into it _LIT(KTxtForClassA,"Text for CClassA"); CClassA* theA = CClassA::NewLC(); theA->SetTextL(KTxtForClassA); theA->iIntValue = -1; theA->iUintValue = 2; // Construct an object of type CClassB and put some // data into it _LIT(KTxtForClassB,"Text for CClassB"); CClassB* theB = CClassB::NewLC(); theB->iFixBuffer = KTxtForClassB; theB->iIntValue = -3; theB->iUintValue = 4; theB->iRealValue = 5.6; // Show contents of the CClassA object _LIT(KTxtClassAContent,"CClassA content ..."); doShow(KTxtClassAContent,*theA); // Show contents of the CClassB object _LIT(KTxtClassBContent,"CClassB content ..."); doShow(KTxtClassBContent,*theB); // Construct the output stream. // The stream id (there is only one) is kept // in memory. RStoreWriteStream outstream; anId = outstream.CreateLC(aStore); // Stream out the CClassA object first outstream << *theA; // Stream out the CClassB object second outstream << *theB; // Equally we could have done: // outstream << *theA << *theB; // to the same effect // Commit changes to the stream outstream.CommitL(); // Cleanup the stream object. // Destroy the CClassB object, // Destroy the CClassA object, CleanupStack::PopAndDestroy(3); }
void CSecMgrStore::StorePolicyL(const CPolicy& aPolicy) { __UHEAP_MARK; HBufC *policyFile = HBufC::NewLC(KMaxName); TPtr ptr(policyFile->Des()); GetPolicyFile (ptr, aPolicy.PolicyID ()); CFileStore* store = CPermanentFileStore::ReplaceLC (iFsSession, ptr, EFileWrite); store->SetTypeL (KPermanentFileStoreLayoutUid); // Construct the output stream. RStoreWriteStream outstream; TStreamId id = outstream.CreateLC (*store); //Write version of the policy outstream.WriteReal32L (TReal(DEFAULT_VERSION)); TInt aliasCnt(aPolicy.AliasGroup().Count()); outstream.WriteInt32L (aliasCnt); RAliasGroup aliasGroups = aPolicy.AliasGroup(); for (TInt i(0); i!=aliasCnt;++i) { CPermission* alias = aliasGroups[i]; alias->ExternalizeL (outstream); } TInt domainCnt(aPolicy.ProtectionDomain().Count ()); outstream.WriteInt32L (domainCnt); RProtectionDomains domains = aPolicy.ProtectionDomain (); for (TInt i(0); i!=domainCnt;++i) { CProtectionDomain* domain = domains[i]; domain->ExternalizeL (outstream); } // Commit changes to the stream outstream.CommitL (); CleanupStack::PopAndDestroy (&outstream); // Set this stream id as the root store->SetRootL (id); // Commit changes to the store store->CommitL (); CleanupStack::PopAndDestroy (store); CleanupStack::PopAndDestroy (policyFile); __UHEAP_MARKEND; }
/** @SYMTestCaseID PDS-STORE-CT-4020 @SYMTestCaseDesc Tests writing and replacing a stream from securestore @SYMTestPriority High @SYMTestActions Create a new stream in the store and then open it for replacement @SYMTestExpectedResults stream is created and writtenn to successfully @SYMDEF DEF135804 */ LOCAL_C void testWriteReplaceL() { test.Next(_L("@SYMTestCaseID PDS-STORE-CT-4020")); TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive())); TParse parse; parse.Set(drive.Name(), &KFileLocationSpec, NULL); test.Next(_L("Testing Extend")); CFileStore* file=CPermanentFileStore::ReplaceLC(TheFs,parse.NameAndExt(),EFileRead|EFileWrite); file->SetTypeL(file->Layout()); CSecureStore* secure=NULL; secure=CSecureStore::NewLC(*file,*thePBEKey); RStoreWriteStream out; TStreamId id = out.CreateL(*secure); test(id != NULL); out.Close(); TRAPD(r, out.OpenL(*secure, id) ); test(r == KErrNone); out.WriteL(KTestDes,8); out.CommitL(); out.Close(); r = secure->Commit(); test(r == KErrNone); TRAP(r,out.ReplaceL(*secure, id)); test(r == KErrNone); out.WriteL(KTestDes,8); out.CommitL(); out.Close(); secure->Revert(); out.Close(); CleanupStack::PopAndDestroy(2); }
TStreamId CAgnCalendarConverter::WriteDescriptorToStreamL(const TDesC& aString) const /** @internalComponent */ { if (aString.Length() > 0) { RStoreWriteStream out; TStreamId id = out.CreateLC(*iOutputStreamStore); out.WriteUint32L(aString.Length()); out << aString; out.CommitL(); CleanupStack::PopAndDestroy(); //out return id; } return KNullStreamId; }
// ----------------------------------------------------------------------------- // CShapeListManager::StoreL() // Store the instance to the specified store // ----------------------------------------------------------------------------- // EXPORT_C TStreamId CShapeListManager::StoreL( CStreamStore& aStore ) const { RStoreWriteStream stream; // Create a stream within the store TStreamId id = stream.CreateLC( aStore ); // Write the data to the stream ExternalizeL( stream ); stream.CommitL(); CleanupStack::PopAndDestroy(); // the stream return id; // return the stream ID }
/** Writes the application identifier followed by the stream dictionary to the store and makes the stream dictionary the root stream of the store. Typically, the function is called by the application when it implements a file create or file save type operation. It is called after all model and UI data has been persisted. The IDs of the streams containing the model and UI data should have been lodged in the stream dictionary. In effect, the function finishes off the file save or file create type operation, leaving the file containing the store in a valid state with the standard interface. @param aStore The store to which the root stream is to be written. Before calling this function, a reference to the store must be saved by putting a pointer onto the cleanup stack or by making it member data of a class. This ensures that it is not orphaned in the event of this function leaving. @param aStreamDic The stream dictionary containing the locations and associated UIDs of other streams in the store. @param aAppId The application identifier to be written into the application identifier stream. */ EXPORT_C void CApaProcess::WriteRootStreamL(CPersistentStore& aStore,CStreamDictionary& aStreamDic,const TApaAppIdentifier& aAppId) { // this is a static method __SHOW_TRACE(_L("Starting CApaProcess::WriteRootStreamL(id)")); // create a stream WriteAppIdentifierL(aStore,aStreamDic,aAppId); // externalize the dictionary RStoreWriteStream stream; TStreamId streamId = stream.CreateLC(aStore); stream << aStreamDic; stream.CommitL(); CleanupStack::PopAndDestroy(); // dictionary stream // set the dictionary stream as the root stream aStore.SetRootL(streamId); }
/** Writes the application identifier to a new stream in the specified store and records the location of this stream in the specified stream dictionary. @param aStore The store to which the application identifier should be written. @param aStreamDic The stream dictionary. @param aAppId The application identifier to be externalised to a stream. */ EXPORT_C void CApaProcess::WriteAppIdentifierL(CStreamStore& aStore,CStreamDictionary& aStreamDic,const TApaAppIdentifier& aAppId) { // this is a static method __SHOW_TRACE(_L("Starting CApaProcess::WriteAppIdentifierL")); // create a stream RStoreWriteStream stream; TStreamId streamId = stream.CreateLC(aStore); // stream the header stream << aAppId; stream.CommitL(); CleanupStack::PopAndDestroy(); // id stream // enter the stream in the dictionary aStreamDic.AssignL(KUidAppIdentifierStream, streamId); }
TStreamId CSWICertStoreTool::WriteInfoStreamL() { // Create info stream RStoreWriteStream infoStream; TStreamId streamId = infoStream.CreateLC(*iStore); infoStream.WriteInt32L(iCerts.Count()); for (TInt i = 0 ; i < iCerts.Count() ; ++i) { iCerts[i]->ExternalizeL(infoStream); } // Commit info stream infoStream.CommitL(); CleanupStack::PopAndDestroy(&infoStream); return streamId; }
/* *This function assumes that the index doesn't exist */ void CSettingsManager::MakeSeedIndexL() { OpenStore2WriteLC(); RStoreWriteStream outstream; TStreamId invalidId(0); //caution: confirm the reliability of this value iRootId = outstream.CreateLC(*iStore); //write an invalid stream index for general settings i.e.iGenSettingsId outstream << invalidId; //write no. of controllers as 0 outstream.WriteInt8L(0); outstream.CommitL(); //commit stream changes CleanupStack::PopAndDestroy(); iStore->SetRootL(iRootId); iStore->CommitL(); //commit changes to store CleanupStack::PopAndDestroy(); //for iStore }
void CVersitTest::StreamLC(RReadStream& aStream) { GetSampleVersitL(); RFs fsSession; User::LeaveIfError(fsSession.Connect()); CFileStore* store = CDirectFileStore::ReplaceLC(fsSession,_L("c:\\TTVersitIn"),EFileWrite); store->SetTypeL(KDirectFileStoreLayoutUid); RStoreWriteStream outstream; TStreamId id = outstream.CreateLC(*store); TInt length=iVersit.Length(); for (TInt ii=0; ii<length; ii++) outstream.WriteInt8L(iVersit[ii]); outstream.CommitL(); CleanupStack::PopAndDestroy(); store->SetRootL(id); store->CommitL(); CleanupStack::PopAndDestroy(); // store store = CDirectFileStore::OpenLC(fsSession,_L("c:\\TTVersitIn"),EFileRead); //retrieve stream RStoreReadStream instream; instream.OpenLC(*store,store->Root()); CleanupStack::Pop(); // instream aStream=RReadStream(instream); }
TInt CSecMgrStore::WriteCounter(TExecutableID aExecID) { HBufC *configFile = HBufC::NewLC(KMaxName); TPtr ptr(configFile->Des()); TInt ret(GetConfigFile (ptr)); if ( KErrNone==ret) { CFileStore* store = CPermanentFileStore::ReplaceLC (iFsSession, *configFile, EFileWrite); // Must say what kind of file store. store->SetTypeL (KPermanentFileStoreLayoutUid); // Construct the output stream. RStoreWriteStream outstream; TStreamId id = outstream.CreateLC (*store); outstream.WriteInt32L (aExecID); // Commit changes to the stream outstream.CommitL (); // Cleanup the stream object CleanupStack::PopAndDestroy (&outstream); // Set this stream id as the root store->SetRootL (id); // Commit changes to the store store->CommitL (); CleanupStack::PopAndDestroy (store); } CleanupStack::PopAndDestroy (configFile); return ret; }
EXPORT_C void CMsvTestUtils::CreateServerMtmRegL(const TUid aMsgType, const TDesC& aHumanReadableName, const TMsvTestDllInfo& aServerMtm, const TMsvTestDllInfo& aClientMtm, const TMsvTestDllInfo& aUiMtm, const TMsvTestDllInfo& aUiDataMtm, const TUid aGroup, const TDesC& aDatFile) { CMtmDllInfoArray* mtmdllinfoarray=new(ELeave) CMtmDllInfoArray(); CleanupStack::PushL(mtmdllinfoarray); CMtmDllInfo* mtmdllinfo1=CMtmDllInfo::NewL(aHumanReadableName,TUidType(KDynamicLibraryUid,KUidMtmServerComponent,TUid::Uid(KUidMtmDefaultSpecificVal)),aServerMtm.iFileName,aServerMtm.iOrdinal,aServerMtm.iVersion); mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo1); CMtmDllInfo* mtmdllinfo2=CMtmDllInfo::NewL(aHumanReadableName,TUidType(KDynamicLibraryUid,KUidMtmClientComponent,TUid::Uid(KUidMtmDefaultSpecificVal)),aClientMtm.iFileName,aClientMtm.iOrdinal,aClientMtm.iVersion); mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo2); CMtmDllInfo* mtmdllinfo3=CMtmDllInfo::NewL(aHumanReadableName,TUidType(KDynamicLibraryUid,KUidMtmUiComponent,TUid::Uid(KUidMtmDefaultSpecificVal)),aUiMtm.iFileName,aUiMtm.iOrdinal,aUiMtm.iVersion); mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo3); CMtmDllInfo* mtmdllinfo4=CMtmDllInfo::NewL(aHumanReadableName,TUidType(KDynamicLibraryUid,KUidMtmUiDataComponent,TUid::Uid(KUidMtmDefaultSpecificVal)),aUiDataMtm.iFileName,aUiDataMtm.iOrdinal,aUiDataMtm.iVersion); mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo4); // Create an empty capability set for creating a new group data object TCapabilitySet capSet; capSet.SetEmpty(); CleanupStack::Pop(mtmdllinfoarray); // next line takes ownership CMtmGroupData* mtmgroupdata=CMtmGroupData::NewL(aMsgType, aGroup, mtmdllinfoarray, capSet); CleanupStack::PushL(mtmgroupdata); CFileStore* filestore = CPermanentFileStore::ReplaceLC(FileSession(), aDatFile, EFileShareExclusive|EFileStream|EFileWrite); TUidType uidtype(KPermanentFileStoreLayoutUid, KUidMsvDataComponent, aMsgType); filestore->SetTypeL(uidtype); RStoreWriteStream out; TStreamId streamid=out.CreateLC(*filestore); // Push to stack mtmgroupdata->ExternalizeL(out); out.CommitL(); CleanupStack::PopAndDestroy(); // out filestore->SetRootL(streamid); filestore->CommitL(); CleanupStack::PopAndDestroy(2, mtmgroupdata); // filestore, mtmgroupdata }
void CSettingsManager::WriteGeneralSettingsL(CMVSAppUi* aAppUI) { OpenStore2WriteLC(); RStoreWriteStream outstream; /* if already there is stream id for general settings open the existing stream; otherwise create new stream id */ TBool updation = iGenSettingsId.Value(); if(updation) { outstream.ReplaceLC(*iStore,iGenSettingsId); } else { iGenSettingsId = outstream.CreateLC(*iStore); } //write the general settings aAppUI->ExternalizeL(outstream); outstream.CommitL(); CleanupStack::PopAndDestroy(); if(!updation) { outstream.ReplaceLC(*iStore,iStore->Root()); TUid tempUid; TStreamId tempStreamId(0); WriteIndexL(outstream,tempUid,tempStreamId); CleanupStack::PopAndDestroy(); } iStore->CommitL();// commit the changes to the store CleanupStack::PopAndDestroy(); //for iStore iFsSession.Close(); //close the file session }
EXPORT_C void CApaDoorBase::ExternalizeBaseStreamL(CStreamStore& aStore,CStreamDictionary& aStreamDict)const /** Externalises the information contained in this base class to a stream in the specified store. The resulting stream ID is associated with an internal UID, and placed in the specified stream dictionary. @publishedAll @released @param aStore The store to contain the stream. @param aStreamDict The stream dictionary to contain the stream ID (and an associated internal UID). */ { RStoreWriteStream stream; TStreamId id=stream.CreateLC(aStore); // // write the format if (iFormat==ETemporarilyIconic) stream.WriteInt8L(EGlassDoor); else stream.WriteInt8L(iFormat); // // write the size TSize size; if (iFormat==ETemporarilyIconic) size = GlassDoorSize(); else GetSizeInTwips(size); stream<< size; // // write the source and close stream<< iSource; stream.CommitL(); CleanupStack::PopAndDestroy(); // stream aStreamDict.AssignL(KUidApaDoorBaseStream,id); }
void CSecMgrStore::WriteScriptInfoL(TExecutableID aExecID, CScript& aScriptInfo) { __UHEAP_MARK; HBufC *scriptFile = HBufC::NewLC(KMaxName); TPtr ptr(scriptFile->Des()); User::LeaveIfError (GetScriptFile (ptr,aExecID)); CFileStore* store = CPermanentFileStore::ReplaceLC (iFsSession, ptr, EFileWrite); // Must say what kind of file store. store->SetTypeL (KPermanentFileStoreLayoutUid); // Construct the output stream. RStoreWriteStream outstream; TStreamId id = outstream.CreateLC (*store); aScriptInfo.ExternalizeL (outstream); // Commit changes to the stream outstream.CommitL (); // Cleanup the stream object CleanupStack::PopAndDestroy (&outstream); // Set this stream id as the root store->SetRootL (id); // Commit changes to the store store->CommitL (); CleanupStack::PopAndDestroy (store); CleanupStack::PopAndDestroy (scriptFile); __UHEAP_MARKEND; }
void CVersitTest::StreamInL() //Convert the iVersit into stream format, save it as "TTVersitIn" //and internalize it as a CVersitParser { RFs fsSession; User::LeaveIfError(fsSession.Connect()); CFileStore* store = CDirectFileStore::ReplaceLC(fsSession,_L("c:\\TTVersit2"),EFileWrite); store->SetTypeL(KDirectFileStoreLayoutUid); RStoreWriteStream outstream; TStreamId id = outstream.CreateLC(*store); TInt length=iVersit.Length(); for (TInt ii=0; ii<length; ii++) outstream.WriteInt8L(iVersit[ii]); outstream.CommitL(); CleanupStack::PopAndDestroy(); store->SetRootL(id); store->CommitL(); CleanupStack::PopAndDestroy(); store = CDirectFileStore::OpenLC(fsSession,_L("c:\\TTVersit2"),EFileRead); //retrieve stream RStoreReadStream instream; instream.OpenLC(*store,store->Root()); iParser->InternalizeL(instream); CleanupStack::PopAndDestroy(2); //store + stream }
void CVersitTest::Stream2LC(RReadStream& aStream) { GetSampleVersit2L(); RFile file; FileRegister->CreateTempFileLC(file, _L("ExpDelVersitIn2")); CDirectFileStore* store = CDirectFileStore::NewLC(file); store->SetTypeL(KDirectFileStoreLayoutUid); RStoreWriteStream outstream; TStreamId id = outstream.CreateLC(*store); TInt length=iVersit.Length(); for (TInt ii=0; ii<length; ii++) outstream.WriteInt8L(iVersit[ii]); outstream.CommitL(); CleanupStack::PopAndDestroy(); store->SetRootL(id); store->CommitL(); CleanupStack::PopAndDestroy(); // store FileRegister->OpenTempFileLC(file, _L("ExpDelVersitIn2")); store = CDirectFileStore::NewLC(file); RStoreReadStream instream; instream.OpenLC(*store,store->Root()); CleanupStack::Pop(); // instream aStream=RReadStream(instream); }
LOCAL_C void DoTestsL() { // create test database test.Start(_L("@SYMTESTCaseID:PIM-T-TTVERS-0001 Preparing tests")); User::LeaveIfError(TheFs.Connect()); CleanupClosePushL(TheFs); CTestRegister * TempFiles = CTestRegister::NewLC(); TempFiles->RegisterL(KDatabaseFileName, EFileTypeCnt); TempFiles->RegisterL(_L("C:\\ttversitin")); TempFiles->RegisterL(_L("C:\\ttversitin2")); TempFiles->RegisterL(_L("C:\\ttversitin3")); TempFiles->RegisterL(_L("C:\\ttversitout")); TempFiles->RegisterL(_L("C:\\ttversitout.vcf")); TempFiles->RegisterL(_L("C:\\ttversitoutb.vcf")); TheIds=CContactIdArray::NewLC(); TRAPD(err, CContactDatabase::DeleteDatabaseL(KDatabaseFileName)); if ((err != KErrNone) && (err != KErrNotFound)) { User::Leave(err); } CVersitTest* vtest=NULL; if (vtest) CleanupStack::PopAndDestroy(); //vtest; vtest=new(ELeave)CVCardTest; CleanupStack::PushL(vtest); CVersitTest* vtest2=NULL; vtest2=new(ELeave)CVCardTest; CleanupStack::PushL(vtest2); CVersitTest* vtest3=NULL; vtest3=new(ELeave)CVCardTest; CleanupStack::PushL(vtest3); //Import test.Next(_L("Importing vcard")); CContactDatabase* db=CntTest->CreateDatabaseL(); CntTest->Db()->OverrideMachineUniqueId(0); //testcode assumes machineUID is 0 TBool success; TUid vcardmode; vcardmode.iUid=KUidVCardConvDefaultImpl; RReadStream stream; vtest->StreamLC(stream); stream.PushL(); TheItems=db->ImportContactsL(vcardmode,stream,success,CContactDatabase::EIncludeX); test(success); CleanupStack::PopAndDestroy(2); // stream,store test(db->CountL()==1); test(TheItems->Count()==1); test((*TheItems)[0]->UidStringL(0x0)==_L("AAA")); //Export test.Next(_L("Exporting vcard")); CFileStore* store = CDirectFileStore::ReplaceLC(TheFs,_L("c:\\ttVersitout.vcf"),EFileWrite); store->SetTypeL(KDirectFileStoreLayoutUid); RStoreWriteStream outstream; TStreamId id = outstream.CreateLC(*store); TUid uid; uid.iUid=KUidVCardConvDefaultImpl; TInt itemCount=TheItems->Count(); for (TInt ii=0;ii<itemCount;ii++) TheIds->AddL((*TheItems)[ii]->Id()); db->ExportSelectedContactsL(uid,*TheIds,outstream,CContactDatabase::ETTFormat); outstream.CommitL(); store->SetRootL(id); store->CommitL(); CleanupStack::PopAndDestroy(2); // store+ oustream // check there are no X-EPOC CFileStore* store2 = CDirectFileStore::OpenLC(TheFs,_L("c:\\ttVersitout.vcf"),EFileRead); //retrieve stream RStoreReadStream tinstream; tinstream.OpenLC(*store2,id); RReadStream xstream=RReadStream(tinstream); HBufC* xdes=HBufC::NewLC(99); TPtr ptr(xdes->Des()); xstream.ReadL(ptr); test(xdes->Des().Match(_L("*X-*"))==KErrNotFound); CleanupStack::PopAndDestroy(3); // store2+ instream //DisplayDatabase(db); test.Next(_L("Updating vcard 2")); RReadStream stream2; vtest2->Stream2LC(stream2); stream2.PushL(); TheItems2=db->ImportContactsL(vcardmode,stream2,success,CContactDatabase::ETTFormat); test(success); CleanupStack::PopAndDestroy(2); // stream,store test(db->CountL()==1); //Export again //DisplayDatabase(db); test.Next(_L("Exporting vcard")); TheIds->Reset(); TheIds->AddL(1); store = CDirectFileStore::ReplaceLC(TheFs,_L("c:\\ttVersitoutb.vcf"),EFileWrite); store->SetTypeL(KDirectFileStoreLayoutUid); id = outstream.CreateLC(*store); uid.iUid=KUidVCardConvDefaultImpl; itemCount=TheItems->Count(); db->ExportSelectedContactsL(uid,*TheIds,outstream,CContactDatabase::ETTFormat); outstream.CommitL(); store->SetRootL(id); store->CommitL(); CleanupStack::PopAndDestroy(2); // store+ oustream /** @SYMTestCaseID PIM-T-TTVERS-0002 @SYMTestType UT @SYMTestPriority High @SYMDEF INC056117 @SYMTestCaseDesc To verify that the incorrect behaviour described in INC056117 no longer exists. @SYMTestActions A vCard is imported where the N, ADR;WORK, EMAIL;INTERNET, TITLE, ORG, NOTE, URL, ROLE and FN property values all have > 255 characters. @SYMTestExpectedResults The vCard is correctly imported i.e. properties which map to text fields with maximum of 255 characters are truncated and no overflow occurs in the DBMS component (leading to a panic in the test case). Further sanity checks are made to ensure that the contacts database contains the expected number of contacts (2), that the number of CContactItem objects in TheItems3 is as expected (1) and that the UID string for the CContactItem object in TheItems3 is as expected ("BBB"). */ test.Next(_L("@SYMTESTCaseID:PIM-T-TTVERS-0002 Import vCard with property values > 255 characters")); RReadStream stream3; vtest3->Stream3LC(stream3); stream3.PushL(); TheItems3=db->ImportContactsL(vcardmode,stream3,success,CContactDatabase::EIncludeX); test(success); CleanupStack::PopAndDestroy(2); // stream3,store test(db->CountL()==2); test(TheItems3->Count()==1); test((*TheItems3)[0]->UidStringL(0x0)==_L("BBB")); if (TheItems) TheItems->ResetAndDestroy(); delete TheItems; if (TheItems2) TheItems2->ResetAndDestroy(); delete TheItems2; if (TheItems3) TheItems3->ResetAndDestroy(); delete TheItems3; CleanupStack::PopAndDestroy(4); // TheIds, vtest, vtest2, vtest3 // ExportImportTestL(); // CntTest->CloseDatabase(); User::After(1000000); CntTest->DeleteDatabaseL(); CleanupStack::PopAndDestroy(2); // FS, TempFiles }
/** @SYMTestCaseID SYSLIB-STORE-CT-1130 @SYMTestCaseDesc Tests copying from one stream to another stream @SYMTestPriority High @SYMTestActions Attempt for copying using different transfer sizes @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ LOCAL_C void testCopyL() { test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1130 Opening host file ")); TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive())); TParse parse; parse.Set(drive.Name(), &KFileLocationSpec, NULL); CFileStore* file=CFileStore::OpenLC(TheFs,parse.NameAndExt(),EFileRead|EFileWrite); // test.Next(_L("Opening source (root) store")); TStreamId root=file->Root(); RStoreReadStream src; src.OpenLC(*file,root); RDecryptStream decrypt; decrypt.OpenLC(src,*thePBEKey); TBuf8<5> b; TStreamId embed; decrypt>>b>>embed; test(b==_L8(" root")); CleanupStack::PopAndDestroy(2); // src, decrypt src.OpenL(*file,embed); CEmbeddedStore* source=CEmbeddedStore::FromLC(src); CSecureStore* ssource=NULL; ssource=CSecureStore::NewLC(*source,*thePBEKey); test.Next(_L("Creating target store")); RStoreWriteStream trg; trg.CreateL(*file); CEmbeddedStore* target=CEmbeddedStore::NewLC(trg); CSecureStore* starget=NULL; starget=CSecureStore::NewLC(*target,*thePBEKey); test.Next(_L("Copying using small transfers")); RStoreReadStream in; in.OpenL(*ssource,source->Root()); in>>TheBuf; TStreamId copyId; in>>copyId; in.Close(); in.OpenL(*ssource,copyId); RStoreWriteStream out; TStreamId id=out.CreateL(*starget); testCopyL(out,in); out.CommitL(); out.Close(); in.Close(); in.OpenL(*starget,id); testReadL(in); in.Close(); // test.Next(_L("Copying using a single big transfer")); in.OpenL(*ssource,copyId); id=out.CreateL(*starget); in.ReadL(out,KTestTotal); out.CommitL(); out.Close(); in.Close(); in.OpenL(*starget,id); testReadL(in); in.Close(); in.OpenL(*ssource,copyId); id=out.CreateL(*starget); out.WriteL(in,KTestTotal); out.CommitL(); out.Close(); in.Close(); in.OpenL(*starget,id); testReadL(in); in.Close(); // CleanupStack::PopAndDestroy(5); }
LOCAL_C void ExportImportTestL() { CDirectFileStore *store=CDirectFileStore::ReplaceLC(CntTest->Fs(),_L("c:\\ttVersitout"),EFileWrite); store->SetTypeL(KDirectFileStoreLayoutUid); RStoreWriteStream outStream; TStreamId streamId=outStream.CreateLC(*store); // CContactDatabase* db=CntTest->Db(); CContactIdArray *idList=CContactIdArray::NewLC(); CContactCard *card=CContactCard::NewLC(); SetNameL(*card,KUidContactFieldNote,KUidContactFieldVCardMapNOTE,_L("ABCDE"),EFalse); SetNameL(*card,KUidContactFieldEMail,KUidContactFieldVCardMapEMAILINTERNET,_L("One"),EFalse); idList->AddL(db->AddNewContactL(*card)); //zzz hits a Versit bug // SetNameL(*card,KUidContactFieldFax,KUidContactFieldVCardMapFAX,_L("ZYX"),EFalse); SetNameL(*card,KUidContactFieldFax,KUidContactFieldVCardMapTEL,_L("ZYX"),EFalse); SetNameL(*card,KUidContactFieldEMail,KUidContactFieldVCardMapEMAILINTERNET,_L("Two"),EFalse); idList->AddL(db->AddNewContactL(*card)); SetNameL(*card,KUidContactFieldSms,KUidContactFieldVCardMapTEL,_L("QQQQ"),EFalse); SetNameL(*card,KUidContactFieldEMail,KUidContactFieldVCardMapEMAILINTERNET,_L("Three"),EFalse); idList->AddL(db->AddNewContactL(*card)); CleanupStack::PopAndDestroy(); // card // db->ExportSelectedContactsL(TUid::Uid(KUidVCardConvDefaultImpl),*idList,outStream,CContactDatabase::ETTFormat); TInt targetCount=db->CountL(); for(TInt loop3=0;loop3<idList->Count();loop3++) { CContactItem *delFieldContact=db->OpenContactLX((*idList)[loop3]); CleanupStack::PushL(delFieldContact); delFieldContact->CardFields().Remove(0); db->CommitContactL(*delFieldContact); CleanupStack::PopAndDestroy(2); // OpenContact, delFieldContact } CleanupStack::PopAndDestroy(); // idList outStream.CommitL(); store->SetRootL(streamId); store->CommitL(); CleanupStack::PopAndDestroy(); // outStream // RStoreReadStream inStream; inStream.OpenLC(*store,streamId); TBool success=EFalse; CArrayPtr<CContactItem>* importedContacts=db->ImportContactsL(TUid::Uid(KUidVCardConvDefaultImpl),inStream,success,CContactDatabase::ETTFormat); CleanupStack::PushL(importedContacts); test(success); test(importedContacts->Count()==3); test(targetCount==db->CountL()); // const CContactIdArray *sortList=db->SortedItemsL(); for(TInt loop2=0;loop2<sortList->Count();loop2++) { CContactItem *contact=db->ReadContactLC((*sortList)[loop2]); TPtrC fieldTxt=FieldText(*contact,KUidContactFieldGivenName); if (fieldTxt==_L("One")) test(FieldText(*contact,KUidContactFieldNote)==_L("ABCDE")); else if (fieldTxt==_L("Two")) test(FieldText(*contact,KUidContactFieldFax)==_L("ZYX")); else if (fieldTxt==_L("Three")) test(FieldText(*contact,KUidContactFieldPhoneNumber)==_L("QQQQ")); CleanupStack::PopAndDestroy(); // contact } // for(TInt loop=0;loop<importedContacts->Count();loop++) db->DeleteContactL((*importedContacts)[loop]->Id()); importedContacts->ResetAndDestroy(); CleanupStack::PopAndDestroy(2); // importedContacts, inStream // CleanupStack::PopAndDestroy(); // store }