예제 #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
    }
}
예제 #2
0
// -----------------------------------------------------------------------------
// CGbaServer::ReadOptionL()
// -----------------------------------------------------------------------------
//
TBool CGbaServer::ReadOptionL(const TUid& aOptionID, TDes8& aValue) const
{
    GBA_TRACE_DEBUG(("ReadOptionL"));
    TInt pushCount = 0;
    TInt result = EFalse;
    RFs fs;

    User::LeaveIfError( fs.Connect() );
    CleanupClosePushL( fs );
    pushCount++;
    TFindFile folder( fs );

    TFileName fullPath;
    MakePrivateFilenameL(fs, KGbaIniFileName, fullPath);

    TInt err = folder.FindByDir( fullPath, KNullDesC);

    if (  err != KErrNone )
    {
        CleanupStack::PopAndDestroy( pushCount );
        return result;
    }
    else
    {
        CDictionaryFileStore* pStore = CDictionaryFileStore::OpenLC( fs, fullPath , KGbaIniUid );
        pushCount++;

        if ( pStore->IsPresentL( aOptionID ) )
        {
            RDictionaryReadStream drs;
            CleanupClosePushL( drs );
            drs.OpenL(*pStore,aOptionID);

            TInt length = drs.ReadInt32L();
            drs.ReadL(aValue,length);
            CleanupStack::PopAndDestroy( &drs );
            result = ETrue;
        }
    }

    CleanupStack::PopAndDestroy( pushCount );
    return result;
}