void CMsvIndexContext::DoStoreConfigL() { // we only want to store the config file if it has changed, // we also don't care about UniqueIDs for the internal drive if(iConfig.iDebug!=iConfig.iDebugAsLoaded || iConfig.iDrive!=iConfig.iDriveAsLoaded || (iConfig.iDrive!=iServer.FileSession().GetSystemDrive() && iConfig.iUniqueID!=iConfig.iUniqueIDAsLoaded)) { TChar driveChar= iServer.FileSession().GetSystemDriveChar(); TBuf<2> systemDrive; systemDrive.Append(driveChar); systemDrive.Append(KDriveDelimiter); TPath pathName(systemDrive); pathName.Append(KServerINIFile); CDictionaryFileStore *store=CDictionaryFileStore::OpenLC(iServer.FileSession(),pathName,KNullUid); RDictionaryWriteStream stream; stream.AssignLC(*store, KUidMsvMessageDriveStream); stream.WriteUint8L(KMsvMessageDriveStreamVersionNumber); // version number stream << iConfig.iDrive.Name(); stream.WriteUint32L(iConfig.iUniqueID); stream.WriteInt8L(iConfig.iDebug); stream.CommitL(); store->CommitL(); CleanupStack::PopAndDestroy(2,store); // stream, store } }
void CPingAppUi::StorePreferencesL(const TPreferences &aPreferences) { CDictionaryStore *iniFile = Application()->OpenIniFileLC(iCoeEnv->FsSession()); RDictionaryWriteStream writeStream; writeStream.AssignLC(*iniFile, KUidPingApp); writeStream.WriteUint8L (aPreferences.iFlags); writeStream.WriteUint16L (aPreferences.iLastSecWait); writeStream.WriteUint16L (aPreferences.iPacketDataSize); writeStream.WriteUint16L (aPreferences.iSecWait); writeStream.WriteUint16L (aPreferences.iTotalPackets); writeStream.WriteInt16L (aPreferences.iHostname.Length()); writeStream.WriteL (aPreferences.iHostname); writeStream.WriteInt16L (aPreferences.iPattern.Length()); writeStream.WriteL (aPreferences.iPattern); #ifdef IAPSETTING writeStream.WriteUint16L (aPreferences.iIAP); #endif //.... // and whatever writeStream.CommitL(); CleanupStack::PopAndDestroy(); // write stream // in this replace XXVersionUid with another unique UID - usually the next one up from XXUid writeStream.AssignLC(*iniFile, KUidPingVersionUid); // write version 1.0 (major.minor) writeStream.WriteInt8L(1); // major writeStream.WriteInt8L(0); // minor writeStream.CommitL(); // flush CleanupStack::PopAndDestroy(); // writeStream; // commit changes to the store if (iniFile->Commit()!=KErrNone) iniFile->RevertL(); CleanupStack::PopAndDestroy(); }
void CCntServerSpeedDialManager::StoreL(CDictionaryFileStore& aStore) const { const TInt count = iSpeedDials.Count(); if (count) { RDictionaryWriteStream stream; stream.AssignLC(aStore, KUidCntSpeedDialStream); stream.WriteInt32L(iSpeedDials.Count()); for(TInt i=0; i<count; i++) { stream << *iSpeedDials[i]; } stream.CommitL(); CleanupStack::PopAndDestroy(); // stream } }
void CCntServerCurrentItemMap::StoreL(CDictionaryFileStore& aStore) const { RDictionaryWriteStream stream; stream.AssignLC(aStore, KUidCntCurrentItemStream); const TInt count = iCurrentItemMap.Count(); stream.WriteInt32L(count); for(TInt i=0; i<count; i++) { const CCntCurrentItemMapEntry* entry = iCurrentItemMap[i]; stream << *entry; } stream.CommitL(); CleanupStack::PopAndDestroy(); // stream }
LOCAL_C void AddEntryL() { TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive())); TParse dicFilePath; dicFilePath.Set(drive.Name(), &KDicFilePath, NULL); CDictionaryStore* dictionary=CDictionaryFileStore::OpenLC(TheFs,dicFilePath.FullName(),dicFileUid); RDictionaryWriteStream s; s.AssignLC(*dictionary,testUid4); s.WriteInt32L(value1); s.CommitL(); CleanupStack::PopAndDestroy(); // s TInt err = dictionary->Commit(); // changed from CommitL to ensure api coverage User::LeaveIfError(err); CleanupStack::PopAndDestroy(); // dictionary }
/** @SYMTestCaseID SYSLIB-STORE-CT-1183 @SYMTestCaseDesc Tests for CDictionaryFileStore::IsPresentL(),CDictionaryFileStore::Remove() functions @SYMTestPriority High @SYMTestActions Tests for writing an entry and commit it. Tests for reading the entry back. Tests for rewriting and reading back using LC functions. Tests for adding one more entry and check for the content. @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ LOCAL_C void Test1L(CDictionaryFileStore* aDict) { // write an entry and commit it test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1183 ")); RDictionaryWriteStream writeStream; TRAPD(ret, writeStream.AssignL(*aDict,testUid1)); test(ret==KErrNone); TRAP(ret, writeStream.WriteInt32L(value1)); test(ret==KErrNone); TRAP(ret, writeStream.CommitL()); test(ret==KErrNone); writeStream.Close(); // read that entry back RDictionaryReadStream readStream; TRAP(ret, readStream.OpenL(*aDict,testUid1)); test(ret==KErrNone); TInt val=0; TRAP(ret, val = readStream.ReadInt32L()); test(ret==KErrNone); test(val==value1); readStream.Close(); // test.Next(_L("Test the stream LC methods")); // read that entry back using the LC method readStream.OpenLC(*aDict,testUid1); TRAP(ret, val = readStream.ReadInt32L()); test(ret==KErrNone); test(val==value1); //readStream.Close(); CleanupStack::PopAndDestroy(); // readStream // // rewrite that entry using the LC method writeStream.AssignLC(*aDict,testUid1); //do some rading MStreamBuf* sbuf = writeStream.Sink(); HBufC8* buffer = HBufC8::NewLC(400); TUint8* buffptr = const_cast<TUint8*>(buffer->Ptr()); sbuf->ReadL(buffptr, 100); TPtr8 buffDes(buffer->Des()); TRequestStatus rstatus; sbuf->ReadL(buffDes, 100, rstatus); User::WaitForRequest(rstatus); CleanupStack::PopAndDestroy(); //buffer TRAP(ret, writeStream.WriteInt32L(value1)); test(ret==KErrNone); TRAP(ret, writeStream.CommitL()); test(ret==KErrNone); //writeStream.Close(); CleanupStack::PopAndDestroy(); // writestream // test.Next(_L("Test reverting the store")); // commit the store TRAP(ret, aDict->CommitL()); test(ret==KErrNone); // replace the 1st entry, commit it, then revert the store TRAP(ret, writeStream.AssignL(*aDict,testUid1)); test(ret==KErrNone); TRAP(ret, writeStream.WriteInt32L(value2)); test(ret==KErrNone); TRAP(ret, writeStream.CommitL()); test(ret==KErrNone); writeStream.Close(); TRAP(ret, aDict->RevertL()); test(ret==KErrNone); // check the value of the entry TRAP(ret, readStream.OpenL(*aDict,testUid1)); test(ret==KErrNone); TRAP(ret, val = readStream.ReadInt32L()); test(ret==KErrNone); test(val==value1); readStream.Close(); test.Next(_L("Test reverting the store using alternative Revert method")); // replace the 1st entry, commit it, then revert the store TRAP(ret, writeStream.AssignL(*aDict,testUid1)); test(ret==KErrNone); TRAP(ret, writeStream.WriteInt32L(value2)); test(ret==KErrNone); TRAP(ret, writeStream.CommitL()); test(ret==KErrNone); writeStream.Close(); aDict->Revert(); // check the value of the entry TRAP(ret, readStream.OpenL(*aDict,testUid1)); test(ret==KErrNone); TRAP(ret, val = readStream.ReadInt32L()); test(ret==KErrNone); test(val==value1); readStream.Close(); // // test.Next(_L("Test IsPresentL() and Remove()")); // add another entry TRAP(ret, writeStream.AssignL(*aDict,testUid2)); test(ret==KErrNone); TRAP(ret, writeStream.WriteInt32L(value2)); test(ret==KErrNone); test(!aDict->IsPresentL(testUid2)); TRAP(ret, writeStream.CommitL()); test(ret==KErrNone); writeStream.Close(); // test IsPresentL() test(aDict->IsPresentL(testUid1)); test(aDict->IsPresentL(testUid2)); test(!aDict->IsPresentL(testUid3)); // test Remove() TRAP(ret, aDict->RemoveL(testUid1)); test(!aDict->IsPresentL(testUid1)); // // test.Next(_L("Close the store and re-open it")); // commit the store and close it TRAP(ret, aDict->CommitL()); test(ret==KErrNone); // delete aDict; }