/*
* ApplicationPrefs.cpp
*
* Created on: Dec 31, 2009
* Author: TAMHAN
*/
#include "ApplicationPrefs.h"
#include <qDebug>
ApplicationPrefs::ApplicationPrefs()
{
// TODO Auto-generated constructor stub
myPasswordChangedFlag=false;
}
ApplicationPrefs::~ApplicationPrefs()
{
// TODO Auto-generated destructor stub
//CANNOT SAVE HERE, OR THE RED KEY WILL PREVENT DATA SAVAGE
}
void ApplicationPrefs::initPrefs()
{
QFile prefFile
(QDir::currentPath() + "/prefs.tmgn");
{
defaultPrefs();
return;
}
quint32 version;
in >> version; // not needed for this v
if(version==1)
{
in >> myLongIntCache;
int sampleVal;
in >> sampleVal;
myProtectionType=(QProtectionType)sampleVal;
//Init new values from V2
mySelfLockFlag=false;
mySelfLockTime=60;
myHideEmptyFieldsFlag=false;
mySelfDestructIsArmedFlag=false;
mySelfDestructPassword="";
myMustUpdateSchemesFlag=true;
myOldVersion=1;
goto terminateInit;
}
in >> myLongIntCache;
int sampleVal;
in >> sampleVal;
myProtectionType=(QProtectionType)sampleVal;
//all below is new for V2
in >> mySelfLockFlag;
in >> mySelfLockTime;
in >> myHideEmptyFieldsFlag;
in >> mySelfDestructIsArmedFlag;
in >> mySelfDestructPassword;
in >> myMustUpdateSchemesFlag;
myMustUpdateSchemesFlag=false;
if(version==2)
{//update for Nokia only
myMustUpdateSchemesFlag=true;
}
terminateInit:
prefFile.close();
}
void ApplicationPrefs::savePrefs()
{
QFile prefFile
(QDir::currentPath() +"/prefs.tmgn");
{
defaultPrefs();
return;
}
quint32 version=3;
out << version; // not needed for this v
out << myLongIntCache;
int sampleVal=myProtectionType;
out << sampleVal;
//all below is new for V2
out << mySelfLockFlag;
out << mySelfLockTime;
out << myHideEmptyFieldsFlag;
out << mySelfDestructIsArmedFlag;
out << mySelfDestructPassword;
out << myMustUpdateSchemesFlag;
prefFile.close();
}
void ApplicationPrefs::defaultPrefs()
{
myLongIntCache=1; //0 is reserved as magic number for XFER to other box
mySelfLockFlag=false;
mySelfLockTime=60;
myHideEmptyFieldsFlag=false;
mySelfDestructIsArmedFlag=false;
mySelfDestructPassword="";
myMustUpdateSchemesFlag=true;
myOldVersion=0;
}
bool ApplicationPrefs::prefsExist()
{
QFile prefFile
(QDir::currentPath() +"/prefs.tmgn");
if(prefFile.exists())
{
return true;
}
else
{
return false;
}
}
quint64 ApplicationPrefs::getUniqueID()
{
quint32 retval=myLongIntCache;
myLongIntCache++;
savePrefs();
return retval;
}
Bookmarks