Commit 2d53cfe3 authored by Urs Fleisch's avatar Urs Fleisch
Browse files

moved common import from external server behavior to base class ImportSourceConfig

parent 75061fa3
/**
* \file freedbconfig.cpp
* General configuration.
* freedb.org import configuration.
*
* \b Project: Kid3
* \author Urs Fleisch
* \date 17 Sep 2003
*/
#include <qstring.h>
#include "freedbconfig.h"
#ifdef CONFIG_USE_KDE
#include <kconfig.h>
#endif
#include <qstring.h>
/**
* Constructor.
......@@ -20,89 +16,13 @@
*
* @param grp configuration group
*/
FreedbConfig::FreedbConfig(const QString &grp) : GeneralConfig(grp)
FreedbConfig::FreedbConfig(const QString &grp) : ImportSourceConfig(grp)
{
useProxy = false;
proxy = "";
server = "freedb.freedb.org:80";
cgiPath = "/~cddb/cddb.cgi";
m_windowWidth = -1;
m_windowHeight = -1;
m_server = "freedb.freedb.org:80";
m_cgiPath = "/~cddb/cddb.cgi";
}
/**
* Constructor.
* Use to create temporary configuration.
*/
FreedbConfig::FreedbConfig() : GeneralConfig("Temporary") {}
/**
* Destructor.
*/
FreedbConfig::~FreedbConfig() {}
/**
* Persist configuration.
*
* @param config KDE configuration
*/
void FreedbConfig::writeToConfig(
#ifdef CONFIG_USE_KDE
KConfig *config
#else
Kid3Settings *config
#endif
) const
{
#ifdef CONFIG_USE_KDE
config->setGroup(group);
config->writeEntry("UseProxy", useProxy);
config->writeEntry("Proxy", proxy);
config->writeEntry("Server", server);
config->writeEntry("CgiPath", cgiPath);
config->writeEntry("FreedbWindowWidth", m_windowWidth);
config->writeEntry("FreedbWindowHeight", m_windowHeight);
#else
config->beginGroup("/" + group);
config->writeEntry("/UseProxy", useProxy);
config->writeEntry("/Proxy", proxy);
config->writeEntry("/Server", server);
config->writeEntry("/CgiPath", cgiPath);
config->writeEntry("/FreedbWindowWidth", m_windowWidth);
config->writeEntry("/FreedbWindowHeight", m_windowHeight);
config->endGroup();
#endif
}
/**
* Read persisted configuration.
*
* @param config KDE configuration
*/
void FreedbConfig::readFromConfig(
#ifdef CONFIG_USE_KDE
KConfig *config
#else
Kid3Settings *config
#endif
)
{
#ifdef CONFIG_USE_KDE
config->setGroup(group);
useProxy = config->readBoolEntry("UseProxy", useProxy);
proxy = config->readEntry("Proxy", proxy);
server = config->readEntry("Server", server);
cgiPath = config->readEntry("CgiPath", cgiPath);
m_windowWidth = config->readNumEntry("FreedbWindowWidth", -1);
m_windowHeight = config->readNumEntry("FreedbWindowHeight", -1);
#else
config->beginGroup("/" + group);
useProxy = config->readBoolEntry("/UseProxy", useProxy);
proxy = config->readEntry("/Proxy", proxy);
server = config->readEntry("/Server", server);
cgiPath = config->readEntry("/CgiPath", cgiPath);
m_windowWidth = config->readNumEntry("/FreedbWindowWidth", -1);
m_windowHeight = config->readNumEntry("/FreedbWindowHeight", -1);
config->endGroup();
#endif
}
......@@ -10,14 +10,12 @@
#ifndef FREEDBCONFIG_H
#define FREEDBCONFIG_H
#include <qstringlist.h>
#include "config.h"
#include "generalconfig.h"
#include "importsourceconfig.h"
/**
* Freedb configuration.
*/
class FreedbConfig : public GeneralConfig {
class FreedbConfig : public ImportSourceConfig {
public:
/**
* Constructor.
......@@ -26,51 +24,11 @@ public:
* @param grp configuration group
*/
FreedbConfig(const QString &grp);
/**
* Constructor.
* Use to create temporary configuration.
*/
FreedbConfig();
/**
* Destructor.
*/
virtual ~FreedbConfig();
/**
* Persist configuration.
*
* @param config KDE configuration
*/
virtual void writeToConfig(
#ifdef CONFIG_USE_KDE
KConfig *config
#else
Kid3Settings *config
#endif
) const;
/**
* Read persisted configuration.
*
* @param config KDE configuration
*/
virtual void readFromConfig(
#ifdef CONFIG_USE_KDE
KConfig *config
#else
Kid3Settings *config
#endif
);
/** true if freedb proxy is used */
bool useProxy;
/** proxy used for freedb.org access */
QString proxy;
/** freedb.org server */
QString server;
/** CGI path used for freedb.org access */
QString cgiPath;
/** freedb.org window width */
int m_windowWidth;
/** freedb.org window height */
int m_windowHeight;
};
#endif
......@@ -8,90 +8,20 @@
*/
#include "musicbrainzconfig.h"
#ifdef HAVE_TUNEPIMP
#include <qstring.h>
#ifdef CONFIG_USE_KDE
#include <kconfig.h>
#endif
/**
* Constructor.
* Set default configuration.
*
* @param grp configuration group
*/
MusicBrainzConfig::MusicBrainzConfig(const QString &grp) : GeneralConfig(grp)
MusicBrainzConfig::MusicBrainzConfig(const QString &grp) : ImportSourceConfig(grp, false)
{
m_useProxy = false;
m_proxy = "";
m_server = "musicbrainz.org:80";
}
/**
* Constructor.
* Use to create temporary configuration.
*/
MusicBrainzConfig::MusicBrainzConfig() : GeneralConfig("Temporary") {}
/**
* Destructor.
*/
MusicBrainzConfig::~MusicBrainzConfig() {}
/**
* Persist configuration.
*
* @param config KDE configuration
*/
void MusicBrainzConfig::writeToConfig(
#ifdef CONFIG_USE_KDE
KConfig *config
#else
Kid3Settings *config
#endif
) const
{
#ifdef CONFIG_USE_KDE
config->setGroup(group);
config->writeEntry("UseProxy", m_useProxy);
config->writeEntry("Proxy", m_proxy);
config->writeEntry("Server", m_server);
#else
config->beginGroup("/" + group);
config->writeEntry("/UseProxy", m_useProxy);
config->writeEntry("/Proxy", m_proxy);
config->writeEntry("/Server", m_server);
config->endGroup();
#endif
}
/**
* Read persisted configuration.
*
* @param config KDE configuration
*/
void MusicBrainzConfig::readFromConfig(
#ifdef CONFIG_USE_KDE
KConfig *config
#else
Kid3Settings *config
#endif
)
{
#ifdef CONFIG_USE_KDE
config->setGroup(group);
m_useProxy = config->readBoolEntry("UseProxy", m_useProxy);
m_proxy = config->readEntry("Proxy", m_proxy);
m_server = config->readEntry("Server", m_server);
#else
config->beginGroup("/" + group);
m_useProxy = config->readBoolEntry("/UseProxy", m_useProxy);
m_proxy = config->readEntry("/Proxy", m_proxy);
m_server = config->readEntry("/Server", m_server);
config->endGroup();
#endif
}
#endif // HAVE_TUNEPIMP
......@@ -10,15 +10,12 @@
#ifndef MUSICBRAINZCONFIG_H
#define MUSICBRAINZCONFIG_H
#include "config.h"
#ifdef HAVE_TUNEPIMP
#include <qstringlist.h>
#include "generalconfig.h"
#include "importsourceconfig.h"
/**
* MusicBrainz configuration.
*/
class MusicBrainzConfig : public GeneralConfig {
class MusicBrainzConfig : public ImportSourceConfig {
public:
/**
* Constructor.
......@@ -28,53 +25,10 @@ public:
*/
MusicBrainzConfig(const QString &grp);
/**
* Constructor.
* Use to create temporary configuration.
*/
MusicBrainzConfig();
/**
* Destructor.
*/
virtual ~MusicBrainzConfig();
/**
* Persist configuration.
*
* @param config KDE configuration
*/
virtual void writeToConfig(
#ifdef CONFIG_USE_KDE
KConfig *config
#else
Kid3Settings *config
#endif
) const;
/**
* Read persisted configuration.
*
* @param config KDE configuration
*/
virtual void readFromConfig(
#ifdef CONFIG_USE_KDE
KConfig *config
#else
Kid3Settings *config
#endif
);
/** true if musicBrainz proxy is used */
bool m_useProxy;
/** proxy used for musicBrainz.org access */
QString m_proxy;
/** MusicBrainz server */
QString m_server;
};
#endif // HAVE_TUNEPIMP
#endif // MUSICBRAINZCONFIG_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment