/** * Load the initial contents of the setting items. By default, * the setting items are populated with the default values from * the design. You can override those values here. * <p> * Note: this call alone does not update the UI. * LoadSettingsL() must be called afterwards. */ void CSymbian_ua_guiSettingItemList::LoadSettingValuesL() { // load values into iSettings TFileName path; TFileName pathWithoutDrive; CEikonEnv::Static()->FsSession().PrivatePath( pathWithoutDrive ); // Extract drive letter into appDrive: #ifdef __WINS__ path.Copy( _L("c:") ); #else RProcess process; path.Copy( process.FileName().Left(2) ); #endif path.Append( pathWithoutDrive ); path.Append( KtxDicFileName ); TFindFile AufFolder(CCoeEnv::Static()->FsSession()); if(KErrNone == AufFolder.FindByDir(path, KNullDesC)) { CDictionaryFileStore* MyDStore = CDictionaryFileStore::OpenLC(CCoeEnv::Static()->FsSession(),AufFolder.File(), TUid::Uid(1)); TUid FileUid; FileUid.iUid = KRegistrar; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); in >> iSettings.Ed_registrar(); CleanupStack::PopAndDestroy(1);// in }
void CPingAppUi::RestorePreferencesL(TPreferences &aPreferences) { CDictionaryStore *iniFile = Application()->OpenIniFileLC(iCoeEnv->FsSession()); TBool found = iniFile->IsPresentL(KUidPingApp); //replace XXUid with uid of prefs - usually the UID of the main app TInt error = KErrNone; if (found) { RDictionaryReadStream readStream; readStream.OpenLC (*iniFile, KUidPingApp); // ignore any reads off the end of the file etc - clear later on TRAP(error, aPreferences.iFlags = readStream.ReadUint8L()); //if (error!=KErrNone) // aPreferences.iFlags=0; TRAP(error, aPreferences.iLastSecWait = readStream.ReadUint16L()); //if (error!=KErrNone) TRAP(error, aPreferences.iPacketDataSize = readStream.ReadUint16L()); //if (error!=KErrNone) TRAP(error, aPreferences.iSecWait = readStream.ReadUint16L()); //if (error!=KErrNone) TRAP(error, aPreferences.iTotalPackets = readStream.ReadUint16L()); //if (error!=KErrNone) TInt length=0; TRAP(error, length = readStream.ReadInt16L()); TRAP(error, readStream.ReadL(aPreferences.iHostname,length)); length=0; TRAP(error, length = readStream.ReadInt16L()); TRAP(error, readStream.ReadL(aPreferences.iPattern,length)); #ifdef IAPSETTING TRAP(error, aPreferences.iIAP = readStream.ReadInt16L()); #endif //if (error!=KErrNone) //........ // read in all the fields as appropriate CleanupStack::PopAndDestroy(); // readStream } CleanupStack::PopAndDestroy(); // iniFile if (error!=KErrNone || !found) { // missing stream initialise CPing::DefaultPreferences(aPreferences); /* aPreferences.iFlags = 0; aPreferences.iLastSecWait=2; aPreferences.iPacketDataSize=56; aPreferences.iSecWait=1; aPreferences.iTotalPackets=10; aPreferences.iPattern=_L("FF"); */ //.... // and whatever is appropriate for all the other fields StorePreferencesL(aPreferences); // store the default ones - update inifile } }
/** Restore the current database filename from the ini file. */ void CIniFileManager::RestoreCurrentDatabaseL(CDictionaryFileStore& aStore) { if (aStore.IsPresentL(KContactsCurrentDatabaseUid)) { RDictionaryReadStream stream; stream.OpenLC(aStore, KContactsCurrentDatabaseUid); stream >> iCurrentDb; CleanupStack::PopAndDestroy(); // stream }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CMainContainer::GetValuesL(CDictionaryFileStore* aDStore,TInt aUID,TDes& aValue) { aValue.Zero(); if(aDStore == NULL) return; TUid FileUid = {0x10}; FileUid.iUid = aUID; if(aDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*aDStore,FileUid); in >> aValue; CleanupStack::PopAndDestroy(1);// in }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CCommandSCSettings::GetValuesL(CDictionaryFileStore* aDStore,TInt aUID,TInt& aValue) { if(aDStore == NULL) return; TUid FileUid = {0x10}; FileUid.iUid = aUID; if(aDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*aDStore,FileUid); aValue = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } else aValue = -1; }
LOCAL_C TBool CheckEntryL() { TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive())); TParse dicFilePath; dicFilePath.Set(drive.Name(), &KDicFilePath, NULL); CDictionaryStore* dictionary=CDictionaryFileStore::OpenLC(TheFs,dicFilePath.FullName(),dicFileUid); TBool isPresent=dictionary->IsPresentL(testUid4); if (isPresent) { RDictionaryReadStream s; s.OpenLC(*dictionary,testUid4); test (s.ReadInt32L()==value1); CleanupStack::PopAndDestroy(); // s } CleanupStack::PopAndDestroy(); // dictionary return isPresent; }
void CCntServerCurrentItemMap::RestoreL(CDictionaryFileStore& aStore) { if (aStore.IsPresentL(KUidCntCurrentItemStream)) { RDictionaryReadStream stream; stream.OpenLC(aStore, KUidCntCurrentItemStream); const TInt count = stream.ReadInt32L(); for(TInt i=0; i<count; i++) { CCntCurrentItemMapEntry* entry = new(ELeave) CCntCurrentItemMapEntry(); CleanupStack::PushL(entry); stream >> *entry; User::LeaveIfError(iCurrentItemMap.Append(entry)); CleanupStack::Pop(); // entry } CleanupStack::PopAndDestroy(); // stream }
TBool CFileExecuter::GetAssociatedApp( TFileName aFileExtension, TFileName& aAppPath ) { TBool aFoundType; CCoCoAppUi* nAppUi = (CCoCoAppUi*)(CEikonEnv::Static()->AppUi()); CDictionaryStore* nlinkStore = nAppUi->Application()->OpenIniFileLC( CEikonEnv::Static()->FsSession() ); aFileExtension.LowerCase(); const TUint16* aFileExtensionPtr = aFileExtension.Ptr(); TUint nDefaultUid = 0; TUint nMemberValue; for ( TInt i = 0; i < aFileExtension.Length(); i ++ ) { nMemberValue = aFileExtensionPtr[i]; if ( nMemberValue >= 97 && nMemberValue <= 122 ) { nMemberValue -= 97; } else if ( nMemberValue >= 48 && nMemberValue <= 57 ) { nMemberValue -= 48; } nDefaultUid = nDefaultUid* 10 + nMemberValue; } if ( nlinkStore->IsPresentL( TUid::Uid(nDefaultUid) ) ) { RDictionaryReadStream inLinkStoreStream; inLinkStoreStream.OpenLC( *nlinkStore, TUid::Uid(nDefaultUid) ); inLinkStoreStream >> aAppPath; CleanupStack::PopAndDestroy(); aFoundType = true; }
void CCntServerSpeedDialManager::RestoreL(CDictionaryFileStore& aStore) { if (aStore.IsPresentL(KUidCntSpeedDialStream)) { RDictionaryReadStream stream; stream.OpenLC(aStore, KUidCntSpeedDialStream); TInt count = stream.ReadInt32L(); if (count <0) { User::LeaveIfError(KErrCorrupt); } iSpeedDials.ResetAndDestroy(); TInt error(KErrNone) ; for(TInt i=0; i<count && (error == KErrNone); i++) { CCntServerSpeedDialTable* table = CCntServerSpeedDialTable::NewL(KNullDesC); CleanupStack::PushL(table); stream >> *table; error = iSpeedDials.Append(table); CleanupStack::Pop(table); } User::LeaveIfError(error); CleanupStack::PopAndDestroy(); // stream }
TBool CTrialHandler::IsNowOkL(TBool& aFirstTime,TInt& aDaysLeft) { TBool ret(EFalse); aFirstTime = EFalse; RFs fsSession; User::LeaveIfError(fsSession.Connect()); TFindFile AufFolder2(fsSession); if(KErrNone == AufFolder2.FindByDir(KtxTrialHandFileFileName, KNullDesC)){ TFindFile AufFolder3(fsSession); if(KErrNone == AufFolder3.FindByDir(KtxTrialHandFileFileName2, KNullDesC)) { BaflUtils::DeleteFile(fsSession,AufFolder3.File()); } }else{ TFindFile AufFolder4(fsSession); if(KErrNone == AufFolder4.FindByDir(KtxTrialHandFileFileName2, KNullDesC)) { aFirstTime = ETrue; TParsePtrC parsse(AufFolder4.File()); TFileName hjelpper; hjelpper.Copy(parsse.Drive()); hjelpper.Append(KtxTrialHandFileFileName); BaflUtils::RenameFile(fsSession,AufFolder4.File(),hjelpper); } } TFindFile AufFolder5(fsSession); if(KErrNone == AufFolder5.FindByDir(KtxTrialHandFileFileName, KNullDesC)){ TTime homme; homme.HomeTime(); CDictionaryFileStore* MyDStore = CDictionaryFileStore::OpenLC(fsSession,AufFolder5.File(), TUid::Uid(0x102013AD)); TInt sYear(-1),sMonth(-1),sDay(-1),sHour(-1),sMinute(-1); TInt mYear(-1),mMonth(-1),mDay(-1),mHour(-1),mMinute(-1); TInt eYear(-1),eMonth(-1),eDay(-1),eHour(-1),eMinute(-1); TUid FileUid = {0x8867675}; if(MyDStore->IsPresentL(FileUid)) { FileUid.iUid = 0x1299; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); sYear = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x1669; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); sMonth = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x4469; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); sDay = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x4421; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); sHour = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x4422; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); sMinute = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x9999; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); mYear = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x1688; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); mMonth = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x4889; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); mDay = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x4821; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); mHour = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x4822; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); mMinute = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x6789; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); eYear = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x1111; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); eMonth = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x9786; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); eDay = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x9721; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); eHour = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x9722; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); eMinute = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } if(sYear == -1 && sMonth == -1 && sDay == -1 && mYear == -1 && mMonth == -1 && mDay == -1 && eYear == -1 && eMonth == -1 && eDay == -1){ FileUid.iUid = 0x1299; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } RDictionaryWriteStream out1; out1.AssignLC(*MyDStore,FileUid); out1.WriteInt32L(homme.DateTime().Year()); out1.CommitL(); CleanupStack::PopAndDestroy(1);// out1 FileUid.iUid = 0x1669; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } RDictionaryWriteStream out2; out2.AssignLC(*MyDStore,FileUid); out2.WriteInt32L((TInt)homme.DateTime().Month()); out2.CommitL(); CleanupStack::PopAndDestroy(1);// out2 FileUid.iUid = 0x4469; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } RDictionaryWriteStream out3; out3.AssignLC(*MyDStore,FileUid); out3.WriteInt32L(homme.DateTime().Day()); out3.CommitL(); CleanupStack::PopAndDestroy(1);// out3 FileUid.iUid = 0x4421; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } RDictionaryWriteStream out31; out31.AssignLC(*MyDStore,FileUid); out31.WriteInt32L(homme.DateTime().Hour()); out31.CommitL(); CleanupStack::PopAndDestroy(1);// out31 FileUid.iUid = 0x4422; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } RDictionaryWriteStream out32; out32.AssignLC(*MyDStore,FileUid); out32.WriteInt32L(homme.DateTime().Minute()); out32.CommitL(); CleanupStack::PopAndDestroy(1);// out32 FileUid.iUid = 0x6789; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } homme = homme + TTimeIntervalDays(4); RDictionaryWriteStream out4; out4.AssignLC(*MyDStore,FileUid); out4.WriteInt32L(homme.DateTime().Year()); out4.CommitL(); CleanupStack::PopAndDestroy(1);// out4 FileUid.iUid = 0x1111; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } RDictionaryWriteStream out5; out5.AssignLC(*MyDStore,FileUid); out5.WriteInt32L((TInt)homme.DateTime().Month()); out5.CommitL(); CleanupStack::PopAndDestroy(1);// out5 FileUid.iUid = 0x9786; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } RDictionaryWriteStream out6; out6.AssignLC(*MyDStore,FileUid); out6.WriteInt32L(homme.DateTime().Day()); out6.CommitL(); CleanupStack::PopAndDestroy(1);// out6 FileUid.iUid = 0x9721; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } RDictionaryWriteStream out61; out61.AssignLC(*MyDStore,FileUid); out61.WriteInt32L(homme.DateTime().Hour()); out61.CommitL(); CleanupStack::PopAndDestroy(1);// out61 FileUid.iUid = 0x9722; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } RDictionaryWriteStream out62; out62.AssignLC(*MyDStore,FileUid); out62.WriteInt32L(homme.DateTime().Minute()); out62.CommitL(); CleanupStack::PopAndDestroy(1);// out62 MyDStore->CommitL(); TTime nowwTimm; nowwTimm.HomeTime(); TTimeIntervalHours leftTimm; homme.HoursFrom(nowwTimm,leftTimm); aDaysLeft = leftTimm.Int(); ret = ETrue; }else{ TTime startTime(TDateTime(sYear,(TMonth)sMonth,sDay,sHour,sMinute,0,0)); TTime middleTime(TDateTime(mYear,(TMonth)mMonth,mDay,mHour,mMinute,0,0)); TTime edningTime(TDateTime(eYear,(TMonth)eMonth,eDay,eHour,eMinute,0,0)); TTimeIntervalMinutes sInterval(0); TTimeIntervalMinutes mInterval(0); TTimeIntervalMinutes eInterval(0); homme.MinutesFrom(startTime,sInterval); homme.MinutesFrom(middleTime,mInterval); edningTime.MinutesFrom(homme,eInterval); if(sInterval.Int() >= 0 && mInterval.Int() >= 0 && eInterval.Int() >= 0){ TTimeIntervalHours leftTimm; edningTime.HoursFrom(homme,leftTimm); aDaysLeft = leftTimm.Int(); ret = ETrue; } } }else{ /* RDictionaryWriteStream out3; out3.AssignLC(*MyDStore,FileUid); out3.WriteInt32L(12985674); out3.CommitL(); CleanupStack::PopAndDestroy(1);// out3 MyDStore->CommitL();*/ } CleanupStack::PopAndDestroy(1);// Store } fsSession.Close(); return ret; }
/** @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; }