Ejemplo n.º 1
0
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
    }
}
Ejemplo n.º 2
0
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();
		}
	}
Ejemplo n.º 3
0
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;
	}
Ejemplo n.º 4
0
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();
}