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 } }
void TIniData::LoadL(CDictionaryStore& aStore) { if (aStore.IsPresentL(KTestUid)) { RDictionaryReadStream stream; stream.OpenL(aStore,KTestUid); CEmbeddedStore* store=CEmbeddedStore::FromLC(stream); RestoreL(*store,store->Root()); CleanupStack::PopAndDestroy(); } }
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; }