Commit 21256adb authored by Rafał Malinowski's avatar Rafał Malinowski

configuration: add new Configuration class

Signed-off-by: Rafał Malinowski's avatarRafał Malinowski <rafal.przemyslaw.malinowski@gmail.com>
parent fe354f8c
......@@ -25,8 +25,9 @@
#include "accounts/accounts-aware-object.h"
#include "buddies/buddy-manager.h"
#include "chat/chat-manager.h"
#include "configuration/deprecated-configuration-api.h"
#include "configuration/configuration.h"
#include "configuration/configuration-api.h"
#include "configuration/deprecated-configuration-api.h"
#include "contacts/contact-manager.h"
#include "core/core.h"
#include "gui/widgets/dialog/password-dialog-widget.h"
......
......@@ -24,6 +24,7 @@
#include "accounts/account-details.h"
#include "accounts/account-manager.h"
#include "accounts/account-status-container.h"
#include "configuration/configuration.h"
#include "configuration/deprecated-configuration-api.h"
#include "contacts/contact-manager.h"
#include "icons/kadu-icon.h"
......@@ -314,8 +315,8 @@ void AccountShared::setDisconnectStatus()
if (!ProtocolHandler->isConnected() && !ProtocolHandler->isDisconnecting())
return;
bool disconnectWithCurrentDescription = KaduApplication::instance()->deprecatedConfigurationApi()->readBoolEntry("General", "DisconnectWithCurrentDescription");
QString disconnectDescription = KaduApplication::instance()->deprecatedConfigurationApi()->readEntry("General", "DisconnectDescription");
bool disconnectWithCurrentDescription = KaduApplication::instance()->configuration()->deprecatedApi()->readBoolEntry("General", "DisconnectWithCurrentDescription");
QString disconnectDescription = KaduApplication::instance()->configuration()->deprecatedApi()->readEntry("General", "DisconnectDescription");
Status disconnectStatus;
disconnectStatus.setType(StatusTypeOffline);
......
......@@ -19,6 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "configuration/configuration.h"
#include "configuration/deprecated-configuration-api.h"
#include "icons/kadu-icon.h"
#include "protocols/protocol-factory.h"
......
......@@ -27,9 +27,10 @@
#include "accounts/account-details.h"
#include "accounts/account-manager.h"
#include "buddies/buddy-manager.h"
#include "configuration/configuration.h"
#include "configuration/configuration-api.h"
#include "configuration/deprecated-configuration-api.h"
#include "configuration/main-configuration-holder.h"
#include "configuration/configuration-api.h"
#include "contacts/contact-details.h"
#include "contacts/contact-manager.h"
#include "contacts/contact.h"
......
......@@ -8,6 +8,7 @@
#include <QtX11Extras/QX11Info>
#include "configuration/configuration.h"
#include "configuration/deprecated-configuration-api.h"
#include "os/x11/x11tools.h"
#undef KeyPress
......@@ -37,7 +38,7 @@
if( X11_isWindowShaded( QX11Info::display(), window->winId() ) )
X11_shadeWindow( QX11Info::display(), window->winId(), false );
// read user settings
int action = KaduApplication::instance()->deprecatedConfigurationApi()->readNumEntry( "General", "WindowActivationMethod" );
int action = KaduApplication::instance()->configuration()->deprecatedApi()->readNumEntry( "General", "WindowActivationMethod" );
// window & desktop
if( X11_getDesktopsCount( QX11Info::display() ) > 1 )
{
......
......@@ -24,8 +24,9 @@
#include "accounts/account.h"
#include "buddies/buddy-list.h"
#include "configuration/configuration-manager.h"
#include "configuration/configuration.h"
#include "configuration/configuration-api.h"
#include "configuration/configuration-manager.h"
#include "contacts/contact-manager.h"
#include "contacts/contact.h"
#include "core/core.h"
......@@ -62,11 +63,11 @@ void BuddyManager::init()
QMutexLocker locker(&mutex());
int itemsSize = items().size();
QDomElement buddiesNode = KaduApplication::instance()->configurationApi()->getNode("Buddies", ConfigurationApi::ModeFind);
QDomElement oldContactsNode = KaduApplication::instance()->configurationApi()->getNode("OldContacts", ConfigurationApi::ModeFind);
QDomElement buddiesNode = KaduApplication::instance()->configuration()->api()->getNode("Buddies", ConfigurationApi::ModeFind);
QDomElement oldContactsNode = KaduApplication::instance()->configuration()->api()->getNode("OldContacts", ConfigurationApi::ModeFind);
if (oldContactsNode.isNull() && (buddiesNode.isNull() || (itemsSize == 0 && !buddiesNode.hasAttribute("imported"))))
{
importConfiguration(KaduApplication::instance()->configurationApi());
importConfiguration(KaduApplication::instance()->configuration()->api());
buddiesNode.setAttribute("imported", "true");
}
}
......
......@@ -32,6 +32,7 @@
#include "buddies/buddy-manager.h"
#include "buddies/group-manager.h"
#include "buddies/group.h"
#include "configuration/configuration.h"
#include "configuration/configuration-api.h"
#include "contacts/contact-manager.h"
#include "contacts/contact.h"
......
......@@ -27,8 +27,9 @@
#include "avatars/avatar.h"
#include "buddies/buddy-manager.h"
#include "buddies/group.h"
#include "configuration/configuration-manager.h"
#include "configuration/configuration.h"
#include "configuration/configuration-api.h"
#include "configuration/configuration-manager.h"
#include "contacts/contact.h"
#include "core/core.h"
#include "icons/kadu-icon.h"
......
......@@ -26,6 +26,7 @@
#include <QtXml/QDomElement>
#include "buddies/buddy-manager.h"
#include "configuration/configuration.h"
#include "configuration/configuration-api.h"
#include "core/core.h"
#include "gui/windows/message-dialog.h"
......@@ -88,7 +89,7 @@ void GroupManager::load()
{
QMutexLocker locker(&mutex());
QDomElement groupsNode = KaduApplication::instance()->configurationApi()->getNode("Groups", ConfigurationApi::ModeFind);
QDomElement groupsNode = KaduApplication::instance()->configuration()->api()->getNode("Groups", ConfigurationApi::ModeFind);
if (groupsNode.isNull())
{
importConfiguration();
......
......@@ -20,6 +20,7 @@
*/
#include "buddies/group-manager.h"
#include "configuration/configuration.h"
#include "configuration/deprecated-configuration-api.h"
#include "misc/change-notifier.h"
#include "kadu-application.h"
......@@ -69,7 +70,7 @@ QString GroupShared::storageNodeName()
void GroupShared::importConfiguration(const QString &name)
{
Name = name;
Icon = KaduApplication::instance()->deprecatedConfigurationApi()->readEntry("GroupIcon", name);
Icon = KaduApplication::instance()->configuration()->deprecatedApi()->readEntry("GroupIcon", name);
NotifyAboutStatusChanges = true;
ShowInAllGroup= true;
OfflineToGroup= false;
......
......@@ -19,8 +19,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "configuration/deprecated-configuration-api.h"
#include "configuration/configuration.h"
#include "configuration/configuration-api.h"
#include "configuration/deprecated-configuration-api.h"
#include "storage/storage-point.h"
#include "group-manager.h"
......
......@@ -29,6 +29,7 @@
#include "chat-style/engine/configured-chat-style-renderer-factory-provider.h"
#include "chat-style/engine/kadu/kadu-style-engine.h"
#include "configuration/chat-configuration-holder.h"
#include "configuration/configuration.h"
#include "configuration/deprecated-configuration-api.h"
#include "core/core.h"
#include "formatted-string/formatted-string-factory.h"
......@@ -118,18 +119,18 @@ void ChatStyleManager::unregisterChatStyleEngine(const QString &name)
void ChatStyleManager::configurationUpdated()
{
if (KaduApplication::instance()->deprecatedConfigurationApi()->readBoolEntry("Chat", "ChatPrune", true))
Prune = KaduApplication::instance()->deprecatedConfigurationApi()->readNumEntry("Chat", "ChatPruneLen");
if (KaduApplication::instance()->configuration()->deprecatedApi()->readBoolEntry("Chat", "ChatPrune", true))
Prune = KaduApplication::instance()->configuration()->deprecatedApi()->readNumEntry("Chat", "ChatPruneLen");
else
{
KaduApplication::instance()->deprecatedConfigurationApi()->writeEntry("Chat", "ChatPrune", true);
KaduApplication::instance()->deprecatedConfigurationApi()->writeEntry("Chat", "ChatPruneLen", 0);
KaduApplication::instance()->configuration()->deprecatedApi()->writeEntry("Chat", "ChatPrune", true);
KaduApplication::instance()->configuration()->deprecatedApi()->writeEntry("Chat", "ChatPruneLen", 0);
Prune = 0;
}
ParagraphSeparator = KaduApplication::instance()->deprecatedConfigurationApi()->readNumEntry("Look", "ParagraphSeparator");
ParagraphSeparator = KaduApplication::instance()->configuration()->deprecatedApi()->readNumEntry("Look", "ParagraphSeparator");
QFont font = KaduApplication::instance()->deprecatedConfigurationApi()->readFontEntry("Look","ChatFont");
QFont font = KaduApplication::instance()->configuration()->deprecatedApi()->readFontEntry("Look","ChatFont");
QString fontFamily = font.family();
QString fontSize;
......@@ -171,13 +172,13 @@ void ChatStyleManager::configurationUpdated()
" padding: 3px;"
"}").arg(fontStyle, fontWeight, fontSize, fontFamily, textDecoration, QString::number(ParagraphSeparator), backgroundColor);
CfgNoHeaderRepeat = KaduApplication::instance()->deprecatedConfigurationApi()->readBoolEntry("Look", "NoHeaderRepeat", true);
CfgNoHeaderRepeat = KaduApplication::instance()->configuration()->deprecatedApi()->readBoolEntry("Look", "NoHeaderRepeat", true);
// headers removal stuff
if (CfgNoHeaderRepeat)
{
CfgHeaderSeparatorHeight = KaduApplication::instance()->deprecatedConfigurationApi()->readNumEntry("Look", "HeaderSeparatorHeight");
CfgNoHeaderInterval = KaduApplication::instance()->deprecatedConfigurationApi()->readNumEntry("Look", "NoHeaderInterval");
CfgHeaderSeparatorHeight = KaduApplication::instance()->configuration()->deprecatedApi()->readNumEntry("Look", "HeaderSeparatorHeight");
CfgNoHeaderInterval = KaduApplication::instance()->configuration()->deprecatedApi()->readNumEntry("Look", "NoHeaderInterval");
}
else
{
......@@ -185,10 +186,10 @@ void ChatStyleManager::configurationUpdated()
CfgNoHeaderInterval = 0;
}
NoServerTime = KaduApplication::instance()->deprecatedConfigurationApi()->readBoolEntry("Look", "NoServerTime");
NoServerTimeDiff = KaduApplication::instance()->deprecatedConfigurationApi()->readNumEntry("Look", "NoServerTimeDiff");
NoServerTime = KaduApplication::instance()->configuration()->deprecatedApi()->readBoolEntry("Look", "NoServerTime");
NoServerTimeDiff = KaduApplication::instance()->configuration()->deprecatedApi()->readNumEntry("Look", "NoServerTimeDiff");
auto newChatStyle = ChatStyle{KaduApplication::instance()->deprecatedConfigurationApi()->readEntry("Look", "Style"), KaduApplication::instance()->deprecatedConfigurationApi()->readEntry("Look", "ChatStyleVariant")};
auto newChatStyle = ChatStyle{KaduApplication::instance()->configuration()->deprecatedApi()->readEntry("Look", "Style"), KaduApplication::instance()->configuration()->deprecatedApi()->readEntry("Look", "ChatStyleVariant")};
// if Style was changed, load new Style
if (!CurrentEngine || newChatStyle != m_currentChatStyle)
......@@ -356,8 +357,8 @@ void ChatStyleManager::mainConfigurationWindowCreated(MainConfigurationWindow *w
void ChatStyleManager::configurationApplied()
{
KaduApplication::instance()->deprecatedConfigurationApi()->writeEntry("Look", "Style", SyntaxListCombo->currentText());
KaduApplication::instance()->deprecatedConfigurationApi()->writeEntry("Look", "ChatStyleVariant", VariantListCombo->currentText());
KaduApplication::instance()->configuration()->deprecatedApi()->writeEntry("Look", "Style", SyntaxListCombo->currentText());
KaduApplication::instance()->configuration()->deprecatedApi()->writeEntry("Look", "ChatStyleVariant", VariantListCombo->currentText());
}
void ChatStyleManager::styleChangedSlot(const QString &styleName)
......
......@@ -31,6 +31,7 @@
#include "chat/chat-manager.h"
#include "chat/type/chat-type-manager.h"
#include "chat/type/chat-type.h"
#include "configuration/configuration.h"
#include "configuration/deprecated-configuration-api.h"
#include "contacts/contact-set.h"
#include "misc/change-notifier.h"
......@@ -232,7 +233,7 @@ bool ChatShared::shouldStore()
return false;
// we dont need data for non-roster contacts only from 4 version of sql schema
if (KaduApplication::instance()->deprecatedConfigurationApi()->readNumEntry("History", "Schema", 0) < 4)
if (KaduApplication::instance()->configuration()->deprecatedApi()->readNumEntry("History", "Schema", 0) < 4)
return true;
if (customProperties()->shouldStore())
......
......@@ -23,6 +23,7 @@
#include <QtCore/QVector>
#include "chat/chat-manager.h"
#include "configuration/configuration.h"
#include "configuration/deprecated-configuration-api.h"
#include "message/message-manager.h"
#include "message/message.h"
......@@ -141,7 +142,7 @@ void RecentChatManager::store()
for (int i = 0; i < count; i++)
mainElement.removeChild(chatElements.at(i));
if (!KaduApplication::instance()->deprecatedConfigurationApi()->readBoolEntry("Chat", "RecentChatsClear", false))
if (!KaduApplication::instance()->configuration()->deprecatedApi()->readBoolEntry("Chat", "RecentChatsClear", false))
foreach (const Chat &chat, RecentChats)
if (chat && !chat.uuid().isNull())
{
......@@ -235,7 +236,7 @@ void RecentChatManager::removeRecentChat(Chat chat)
void RecentChatManager::configurationUpdated()
{
CleanUpTimer.stop();
RecentChatsTimeout = KaduApplication::instance()->deprecatedConfigurationApi()->readNumEntry("Chat", "RecentChatsTimeout") * 60;
RecentChatsTimeout = KaduApplication::instance()->configuration()->deprecatedApi()->readNumEntry("Chat", "RecentChatsTimeout") * 60;
if (RecentChatsTimeout > 0)
CleanUpTimer.start();
......
......@@ -2,6 +2,7 @@ set (configuration_SRCS
chat-configuration-holder.cpp
config-file-data-manager.cpp
config-file-variant-wrapper.cpp
configuration.cpp
configuration-api.cpp
configuration-aware-object.cpp
configuration-holder.cpp
......
......@@ -20,6 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "configuration/configuration.h"
#include "configuration/deprecated-configuration-api.h"
#include "kadu-application.h"
......@@ -58,35 +59,35 @@ void ChatConfigurationHolder::init()
void ChatConfigurationHolder::configurationUpdated()
{
AutoSend = KaduApplication::instance()->deprecatedConfigurationApi()->readBoolEntry("Chat", "AutoSend");
NiceDateFormat = KaduApplication::instance()->deprecatedConfigurationApi()->readBoolEntry("Look", "NiceDateFormat");
ChatTextCustomColors = KaduApplication::instance()->deprecatedConfigurationApi()->readBoolEntry("Look", "ChatTextCustomColors");
ChatTextBgColor = KaduApplication::instance()->deprecatedConfigurationApi()->readColorEntry("Look", "ChatTextBgColor");
ChatTextFontColor = KaduApplication::instance()->deprecatedConfigurationApi()->readColorEntry("Look", "ChatTextFontColor");
ForceCustomChatFont = KaduApplication::instance()->deprecatedConfigurationApi()->readBoolEntry("Look", "ForceCustomChatFont");
ChatFont = KaduApplication::instance()->deprecatedConfigurationApi()->readFontEntry("Look", "ChatFont");
ChatContents = KaduApplication::instance()->deprecatedConfigurationApi()->readEntry("Look", "ChatContents");
ConferenceContents = KaduApplication::instance()->deprecatedConfigurationApi()->readEntry("Look", "ConferenceContents");
ConferencePrefix = KaduApplication::instance()->deprecatedConfigurationApi()->readEntry("Look", "ConferencePrefix");
MyBackgroundColor = KaduApplication::instance()->deprecatedConfigurationApi()->readEntry("Look", "ChatMyBgColor");
MyFontColor = KaduApplication::instance()->deprecatedConfigurationApi()->readEntry("Look", "ChatMyFontColor");
MyNickColor = KaduApplication::instance()->deprecatedConfigurationApi()->readEntry("Look", "ChatMyNickColor");
UsrBackgroundColor = KaduApplication::instance()->deprecatedConfigurationApi()->readEntry("Look", "ChatUsrBgColor");
UsrFontColor = KaduApplication::instance()->deprecatedConfigurationApi()->readEntry("Look", "ChatUsrFontColor");
UsrNickColor = KaduApplication::instance()->deprecatedConfigurationApi()->readEntry("Look", "ChatUsrNickColor");
ContactStateChats = KaduApplication::instance()->deprecatedConfigurationApi()->readBoolEntry("Chat", "ContactStateChats");
ContactStateWindowTitle = KaduApplication::instance()->deprecatedConfigurationApi()->readBoolEntry("Chat", "ContactStateWindowTitle");
ContactStateWindowTitlePosition = KaduApplication::instance()->deprecatedConfigurationApi()->readNumEntry("Chat", "ContactStateWindowTitlePosition");
ContactStateWindowTitleComposingSyntax = KaduApplication::instance()->deprecatedConfigurationApi()->readEntry("Chat", "ContactStateWindowTitleComposingSyntax");
ChatBgFilled = KaduApplication::instance()->deprecatedConfigurationApi()->readBoolEntry("Look", "ChatBgFilled");
ChatBgColor = KaduApplication::instance()->deprecatedConfigurationApi()->readColorEntry("Look", "ChatBgColor");
UseTransparency = KaduApplication::instance()->deprecatedConfigurationApi()->readBoolEntry("Chat", "UseTransparency");
AutoSend = KaduApplication::instance()->configuration()->deprecatedApi()->readBoolEntry("Chat", "AutoSend");
NiceDateFormat = KaduApplication::instance()->configuration()->deprecatedApi()->readBoolEntry("Look", "NiceDateFormat");
ChatTextCustomColors = KaduApplication::instance()->configuration()->deprecatedApi()->readBoolEntry("Look", "ChatTextCustomColors");
ChatTextBgColor = KaduApplication::instance()->configuration()->deprecatedApi()->readColorEntry("Look", "ChatTextBgColor");
ChatTextFontColor = KaduApplication::instance()->configuration()->deprecatedApi()->readColorEntry("Look", "ChatTextFontColor");
ForceCustomChatFont = KaduApplication::instance()->configuration()->deprecatedApi()->readBoolEntry("Look", "ForceCustomChatFont");
ChatFont = KaduApplication::instance()->configuration()->deprecatedApi()->readFontEntry("Look", "ChatFont");
ChatContents = KaduApplication::instance()->configuration()->deprecatedApi()->readEntry("Look", "ChatContents");
ConferenceContents = KaduApplication::instance()->configuration()->deprecatedApi()->readEntry("Look", "ConferenceContents");
ConferencePrefix = KaduApplication::instance()->configuration()->deprecatedApi()->readEntry("Look", "ConferencePrefix");
MyBackgroundColor = KaduApplication::instance()->configuration()->deprecatedApi()->readEntry("Look", "ChatMyBgColor");
MyFontColor = KaduApplication::instance()->configuration()->deprecatedApi()->readEntry("Look", "ChatMyFontColor");
MyNickColor = KaduApplication::instance()->configuration()->deprecatedApi()->readEntry("Look", "ChatMyNickColor");
UsrBackgroundColor = KaduApplication::instance()->configuration()->deprecatedApi()->readEntry("Look", "ChatUsrBgColor");
UsrFontColor = KaduApplication::instance()->configuration()->deprecatedApi()->readEntry("Look", "ChatUsrFontColor");
UsrNickColor = KaduApplication::instance()->configuration()->deprecatedApi()->readEntry("Look", "ChatUsrNickColor");
ContactStateChats = KaduApplication::instance()->configuration()->deprecatedApi()->readBoolEntry("Chat", "ContactStateChats");
ContactStateWindowTitle = KaduApplication::instance()->configuration()->deprecatedApi()->readBoolEntry("Chat", "ContactStateWindowTitle");
ContactStateWindowTitlePosition = KaduApplication::instance()->configuration()->deprecatedApi()->readNumEntry("Chat", "ContactStateWindowTitlePosition");
ContactStateWindowTitleComposingSyntax = KaduApplication::instance()->configuration()->deprecatedApi()->readEntry("Chat", "ContactStateWindowTitleComposingSyntax");
ChatBgFilled = KaduApplication::instance()->configuration()->deprecatedApi()->readBoolEntry("Look", "ChatBgFilled");
ChatBgColor = KaduApplication::instance()->configuration()->deprecatedApi()->readColorEntry("Look", "ChatBgColor");
UseTransparency = KaduApplication::instance()->configuration()->deprecatedApi()->readBoolEntry("Chat", "UseTransparency");
emit chatConfigurationUpdated();
......
......@@ -21,6 +21,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "configuration/configuration.h"
#include "configuration/deprecated-configuration-api.h"
#include "kadu-application.h"
......@@ -31,7 +32,7 @@ void ConfigFileDataManager::writeEntry(const QString &section, const QString &na
if (section.isEmpty() || name.isEmpty())
return;
KaduApplication::instance()->deprecatedConfigurationApi()->writeEntry(section, name, value.toString());
KaduApplication::instance()->configuration()->deprecatedApi()->writeEntry(section, name, value.toString());
}
QVariant ConfigFileDataManager::readEntry(const QString &section, const QString &name)
......@@ -39,7 +40,7 @@ QVariant ConfigFileDataManager::readEntry(const QString &section, const QString
if (section.isEmpty() || name.isEmpty())
return QVariant(QString());
return QVariant(KaduApplication::instance()->deprecatedConfigurationApi()->readEntry(section, name));
return QVariant(KaduApplication::instance()->configuration()->deprecatedApi()->readEntry(section, name));
}
......
......@@ -21,6 +21,7 @@
#include <QtCore/QVariant>
#include "configuration/configuration.h"
#include "configuration/deprecated-configuration-api.h"
#include "kadu-application.h"
......@@ -37,10 +38,10 @@ ConfigFileVariantWrapper::~ConfigFileVariantWrapper()
QVariant ConfigFileVariantWrapper::get(const QVariant &defaultValue) const
{
return KaduApplication::instance()->deprecatedConfigurationApi()->readEntry(Group, Name, defaultValue.toString());
return KaduApplication::instance()->configuration()->deprecatedApi()->readEntry(Group, Name, defaultValue.toString());
}
void ConfigFileVariantWrapper::set(const QVariant &value)
{
KaduApplication::instance()->deprecatedConfigurationApi()->writeEntry(Group, Name, value.toString());
KaduApplication::instance()->configuration()->deprecatedApi()->writeEntry(Group, Name, value.toString());
}
......@@ -26,6 +26,7 @@
#include <QtWidgets/QApplication>
#include "configuration/toolbar-configuration-manager.h"
#include "configuration/configuration.h"
#include "configuration/configuration-api.h"
#include "storage/storable-object.h"
#include "kadu-application.h"
......@@ -62,11 +63,11 @@ ConfigurationManager::~ConfigurationManager()
void ConfigurationManager::load()
{
KaduApplication::instance()->configurationApi()->makeBackup();
KaduApplication::instance()->configuration()->api()->makeBackup();
importConfiguration();
Uuid = KaduApplication::instance()->configurationApi()->rootElement().attribute("uuid");
Uuid = KaduApplication::instance()->configuration()->api()->rootElement().attribute("uuid");
if (Uuid.isNull())
Uuid = QUuid::createUuid();
}
......@@ -76,8 +77,8 @@ void ConfigurationManager::flush()
foreach (StorableObject *object, RegisteredStorableObjects)
object->ensureStored();
KaduApplication::instance()->configurationApi()->rootElement().setAttribute("uuid", Uuid.toString());
KaduApplication::instance()->configurationApi()->sync();
KaduApplication::instance()->configuration()->api()->rootElement().setAttribute("uuid", Uuid.toString());
KaduApplication::instance()->configuration()->api()->sync();
}
void ConfigurationManager::registerStorableObject(StorableObject *object)
......@@ -105,9 +106,9 @@ void ConfigurationManager::unregisterStorableObject(StorableObject *object)
void ConfigurationManager::importConfiguration()
{
QDomElement root = KaduApplication::instance()->configurationApi()->rootElement();
QDomElement general = KaduApplication::instance()->configurationApi()->findElementByProperty(root.firstChild().firstChild().toElement(), "Group", "name", "General");
QDomElement mainConfiguration = KaduApplication::instance()->configurationApi()->findElementByProperty(general, "Entry", "name", "ConfigGeometry");
QDomElement root = KaduApplication::instance()->configuration()->api()->rootElement();
QDomElement general = KaduApplication::instance()->configuration()->api()->findElementByProperty(root.firstChild().firstChild().toElement(), "Group", "name", "General");
QDomElement mainConfiguration = KaduApplication::instance()->configuration()->api()->findElementByProperty(general, "Entry", "name", "ConfigGeometry");
if (!mainConfiguration.isNull())
mainConfiguration.setAttribute("name", "MainConfiguration_Geometry");
......
......@@ -35,6 +35,11 @@ ConfigurationStorage::~ConfigurationStorage()
{
}
QString ConfigurationStorage::profilePath() const
{
return m_profilePath;
}
QStringList ConfigurationStorage::possibleConfigurationFiles() const
{
auto backups_0_12 = QDir{m_profilePath, "kadu-0.12.conf.xml.backup.*", QDir::Name, QDir::Files};
......
......@@ -29,6 +29,8 @@ public:
explicit ConfigurationStorage(QString profilePath, QObject *parent = nullptr);
virtual ~ConfigurationStorage();
QString profilePath() const;
QStringList possibleConfigurationFiles() const;
/**
* @todo Hidden dependency is here. This functin can not be called before readConfiguration()
......
/*
* %kadu copyright begin%
* Copyright 2014 Rafał Malinowski (rafal.przemyslaw.malinowski@gmail.com)
* %kadu copyright end%
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "configuration.h"
#include "configuration/configuration-api.h"
#include "configuration/configuration-storage.h"
#include "configuration/deprecated-configuration-api.h"
#include "misc/memory.h"
#include <QtCore/QCoreApplication>
#include <QtWidgets/QMessageBox>
Configuration::Configuration(QObject *parent) :
QObject{parent},
m_configurationStorage{nullptr}
{
}
Configuration::~Configuration()
{
}
void Configuration::setConfigurationStorage(ConfigurationStorage *configurationStorage)
{
m_configurationStorage = configurationStorage;
}
ConfigurationApi * Configuration::api() const
{
return m_configurationApi.get();
}
DeprecatedConfigurationApi * Configuration::deprecatedApi() const
{
return m_deprecatedConfigurationApi.get();
}
void Configuration::read()
{
m_configurationApi = make_unique<ConfigurationApi>(m_configurationStorage->readConfiguration());
m_deprecatedConfigurationApi = make_unique<DeprecatedConfigurationApi>(m_configurationApi.get(), QLatin1String("kadu.conf"));
if (!m_configurationStorage->isUsable())
{
auto profilePath = m_configurationStorage->profilePath();
auto errorMessage = QCoreApplication::translate("@default", "We're sorry, but Kadu cannot be loaded. "
"Profile is inaccessible. Please check permissions in the '%1' directory.")
.arg(profilePath.left(profilePath.length() - 1));
QMessageBox::critical(0, QCoreApplication::translate("@default", "Profile Inaccessible"), errorMessage, QMessageBox::Abort);
qFatal("%s", qPrintable(errorMessage));
}
}
void Configuration::save()
{
}
#include "moc_configuration.cpp"
/*
* %kadu copyright begin%
* Copyright 2014 Rafał Malinowski (rafal.przemyslaw.malinowski@gmail.com)
* %kadu copyright end%
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "exports.h"
#include <QtCore/QObject>
#include <memory>
class ConfigurationApi;
class ConfigurationStorage;
class DeprecatedConfigurationApi;
class KADUAPI Configuration final : public QObject
{
Q_OBJECT
public:
explicit Configuration(QObject *parent = nullptr);
virtual ~Configuration();
void setConfigurationStorage(ConfigurationStorage *configurationStorage);
ConfigurationApi * api() const;
DeprecatedConfigurationApi * deprecatedApi() const;
void read();
void save();
private:
ConfigurationStorage *m_configurationStorage;
std::unique_ptr<ConfigurationApi> m_configurationApi;
std::unique_ptr<DeprecatedConfigurationApi> m_deprecatedConfigurationApi;
};
......@@ -24,6 +24,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/