2011-04-25 18:16:31 +02:00
|
|
|
/******************************************************************************\
|
2013-02-11 16:06:00 +01:00
|
|
|
* Copyright (c) 2004-2013
|
2011-04-25 18:16:31 +02:00
|
|
|
*
|
|
|
|
* Author(s):
|
|
|
|
* Volker Fischer
|
|
|
|
*
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License as published by the Free Software
|
|
|
|
* Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
* version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
|
|
|
#if !defined ( SETTINGS_H__3B0BA660_DGEG56G456G9876D31912__INCLUDED_ )
|
|
|
|
#define SETTINGS_H__3B0BA660_DGEG56G456G9876D31912__INCLUDED_
|
|
|
|
|
2013-01-02 21:41:04 +01:00
|
|
|
#include <QDomDocument>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QTextStream>
|
2011-04-25 18:16:31 +02:00
|
|
|
#include "global.h"
|
|
|
|
#include "client.h"
|
|
|
|
#include "server.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Classes ********************************************************************/
|
|
|
|
class CSettings
|
|
|
|
{
|
|
|
|
public:
|
2011-05-21 18:53:01 +02:00
|
|
|
CSettings ( CClient* pNCliP, const QString& sNFiName ) :
|
|
|
|
pClient ( pNCliP ), bIsClient ( true )
|
|
|
|
{ SetFileName ( sNFiName ); }
|
2011-04-25 18:16:31 +02:00
|
|
|
|
2011-05-21 18:53:01 +02:00
|
|
|
CSettings ( CServer* pNSerP, const QString& sNFiName ) :
|
|
|
|
pServer ( pNSerP ), bIsClient ( false )
|
|
|
|
{ SetFileName ( sNFiName ); }
|
2011-04-25 18:16:31 +02:00
|
|
|
|
2011-05-21 18:53:01 +02:00
|
|
|
void Load();
|
|
|
|
void Save();
|
2011-04-25 18:16:31 +02:00
|
|
|
|
2011-05-21 18:53:01 +02:00
|
|
|
protected:
|
|
|
|
void SetFileName ( const QString& sNFiName );
|
2011-04-25 18:16:31 +02:00
|
|
|
|
2013-12-14 23:09:59 +01:00
|
|
|
QString ToBase64 ( const QByteArray strIn ) const
|
|
|
|
{ return QString::fromLatin1 ( strIn.toBase64() ); }
|
|
|
|
QByteArray FromBase64 ( const QString strIn ) const
|
|
|
|
{ return QByteArray::fromBase64 ( strIn.toLatin1() ); }
|
|
|
|
|
2011-04-25 18:16:31 +02:00
|
|
|
// init file access function for read/write
|
2013-02-11 16:06:00 +01:00
|
|
|
void SetNumericIniSet ( QDomDocument& xmlFile,
|
|
|
|
const QString& strSection,
|
|
|
|
const QString& strKey,
|
|
|
|
const int iValue = 0 );
|
|
|
|
|
|
|
|
bool GetNumericIniSet ( const QDomDocument& xmlFile,
|
|
|
|
const QString& strSection,
|
|
|
|
const QString& strKey,
|
|
|
|
const int iRangeStart,
|
|
|
|
const int iRangeStop,
|
|
|
|
int& iValue );
|
|
|
|
|
|
|
|
void SetFlagIniSet ( QDomDocument& xmlFile,
|
|
|
|
const QString& strSection,
|
|
|
|
const QString& strKey,
|
|
|
|
const bool bValue = false );
|
|
|
|
|
|
|
|
bool GetFlagIniSet ( const QDomDocument& xmlFile,
|
|
|
|
const QString& strSection,
|
|
|
|
const QString& strKey,
|
|
|
|
bool& bValue );
|
2011-04-25 18:16:31 +02:00
|
|
|
|
|
|
|
// actual working function for init-file access
|
2013-02-11 16:06:00 +01:00
|
|
|
QString GetIniSetting( const QDomDocument& xmlFile,
|
|
|
|
const QString& sSection,
|
|
|
|
const QString& sKey,
|
|
|
|
const QString& sDefaultVal = "" );
|
|
|
|
|
|
|
|
void PutIniSetting ( QDomDocument& xmlFile,
|
|
|
|
const QString& sSection,
|
|
|
|
const QString& sKey,
|
|
|
|
const QString& sValue = "" );
|
2011-04-25 18:16:31 +02:00
|
|
|
|
|
|
|
// pointer to the client/server object which stores the various settings
|
|
|
|
CClient* pClient; // for client
|
|
|
|
CServer* pServer; // for server
|
|
|
|
|
|
|
|
bool bIsClient;
|
2011-05-21 18:53:01 +02:00
|
|
|
QString strFileName;
|
2011-04-25 18:16:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // !defined ( SETTINGS_H__3B0BA660_DGEG56G456G9876D31912__INCLUDED_ )
|