Commit 469bcebd authored by Rafał Malinowski's avatar Rafał Malinowski

misc: rename KaduPaths to PathsProvider

Signed-off-by: Rafał Malinowski's avatarRafał Malinowski <rafal.przemyslaw.malinowski@gmail.com>
parent f1249a8c
......@@ -28,7 +28,7 @@
#include "buddies/buddy.h"
#include "contacts/contact.h"
#include "misc/change-notifier.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "avatar-shared.h"
......@@ -51,7 +51,7 @@ AvatarShared * AvatarShared::loadFromStorage(const std::shared_ptr<StoragePoint>
AvatarShared::AvatarShared(const QUuid &uuid) :
Shared(uuid)
{
AvatarsDir = KaduPaths::instance()->profilePath() + QLatin1String("avatars/");
AvatarsDir = PathsProvider::instance()->profilePath() + QLatin1String("avatars/");
connect(&changeNotifier(), SIGNAL(changed()), this, SIGNAL(updated()));
}
......@@ -142,7 +142,7 @@ void AvatarShared::storeAvatar()
storeValue("LastUpdated", LastUpdated);
storeValue("NextUpdate", NextUpdate);
QDir avatarsDir(KaduPaths::instance()->profilePath() + QLatin1String("avatars"));
QDir avatarsDir(PathsProvider::instance()->profilePath() + QLatin1String("avatars"));
if (!avatarsDir.exists())
avatarsDir.mkpath(QLatin1String("."));
......@@ -172,7 +172,7 @@ void AvatarShared::storeSmallPixmap()
if (!isValidStorage())
return;
QDir avatarsDir(KaduPaths::instance()->profilePath() + QLatin1String("avatars"));
QDir avatarsDir(PathsProvider::instance()->profilePath() + QLatin1String("avatars"));
if (!avatarsDir.exists())
avatarsDir.mkpath(QLatin1String("."));
......
......@@ -22,7 +22,7 @@
*/
#include "contacts/contact.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "avatar.h"
......
......@@ -38,7 +38,7 @@
#include "gui/widgets/configuration/configuration-widget.h"
#include "gui/windows/main-configuration-window.h"
#include "misc/algorithm.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "misc/memory.h"
#include "kadu-application.h"
......@@ -252,7 +252,7 @@ void ChatStyleManager::loadStyles()
QFileInfo fi;
QStringList files;
path = KaduPaths::instance()->profilePath() + QLatin1String("syntax/chat/");
path = PathsProvider::instance()->profilePath() + QLatin1String("syntax/chat/");
dir.setPath(path);
files = dir.entryList();
......@@ -277,7 +277,7 @@ void ChatStyleManager::loadStyles()
}
}
path = KaduPaths::instance()->dataPath() + QLatin1String("syntax/chat/");
path = PathsProvider::instance()->dataPath() + QLatin1String("syntax/chat/");
dir.setPath(path);
files = dir.entryList();
......
......@@ -28,7 +28,7 @@
#include "chat-style/engine/adium/adium-style.h"
#include "chat-style/engine/adium/adium-style-renderer-factory.h"
#include "message/message-html-renderer-service.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "misc/memory.h"
#include <QtCore/QDir>
......@@ -66,9 +66,9 @@ QString AdiumStyleEngine::defaultVariant(const QString &styleName)
QStringList AdiumStyleEngine::styleVariants(QString styleName)
{
QDir dir;
QString styleBaseHref = KaduPaths::instance()->profilePath() + QLatin1String("syntax/chat/") + styleName + QLatin1String("/Contents/Resources/Variants/");
QString styleBaseHref = PathsProvider::instance()->profilePath() + QLatin1String("syntax/chat/") + styleName + QLatin1String("/Contents/Resources/Variants/");
if (!dir.exists(styleBaseHref))
styleBaseHref = KaduPaths::instance()->dataPath() + QLatin1String("syntax/chat/") + styleName + QLatin1String("/Contents/Resources/Variants/");
styleBaseHref = PathsProvider::instance()->dataPath() + QLatin1String("syntax/chat/") + styleName + QLatin1String("/Contents/Resources/Variants/");
dir.setPath(styleBaseHref);
dir.setNameFilters(QStringList("*.css"));
return dir.entryList();
......
......@@ -33,7 +33,7 @@
#include "message/message-render-info.h"
#include "message/message-render-info-factory.h"
#include "misc/date-time.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "misc/misc.h"
#include "protocols/protocol.h"
#include "protocols/protocol-factory.h"
......@@ -130,7 +130,7 @@ void AdiumStyleRenderer::appendChatMessage(const Message &message, const Message
QString AdiumStyleRenderer::preprocessStyleBaseHtml(bool useTransparency)
{
QString styleBaseHtml = m_style->templateHtml();
styleBaseHtml.replace(styleBaseHtml.indexOf("%@"), 2, Qt::escape(KaduPaths::webKitPath(m_style->baseHref())));
styleBaseHtml.replace(styleBaseHtml.indexOf("%@"), 2, Qt::escape(PathsProvider::webKitPath(m_style->baseHref())));
styleBaseHtml.replace(styleBaseHtml.lastIndexOf("%@"), 2, replaceKeywords(m_style->baseHref(), m_style->footerHtml()));
styleBaseHtml.replace(styleBaseHtml.lastIndexOf("%@"), 2, replaceKeywords(m_style->baseHref(), m_style->headerHtml()));
......@@ -196,18 +196,18 @@ QString AdiumStyleRenderer::replaceKeywords(const QString &styleHref, const QStr
{
const Avatar &avatar = configuration().chat().contacts().toContact().avatar(true);
if (!avatar.isEmpty())
photoIncoming = KaduPaths::webKitPath(avatar.smallFilePath());
photoIncoming = PathsProvider::webKitPath(avatar.smallFilePath());
else
photoIncoming = KaduPaths::webKitPath(styleHref + QLatin1String("Incoming/buddy_icon.png"));
photoIncoming = PathsProvider::webKitPath(styleHref + QLatin1String("Incoming/buddy_icon.png"));
}
else
photoIncoming = KaduPaths::webKitPath(styleHref + QLatin1String("Incoming/buddy_icon.png"));
photoIncoming = PathsProvider::webKitPath(styleHref + QLatin1String("Incoming/buddy_icon.png"));
const Avatar &avatar = configuration().chat().chatAccount().accountContact().avatar(true);
if (!avatar.isEmpty())
photoOutgoing = KaduPaths::webKitPath(avatar.smallFilePath());
photoOutgoing = PathsProvider::webKitPath(avatar.smallFilePath());
else
photoOutgoing = KaduPaths::webKitPath(styleHref + QLatin1String("Outgoing/buddy_icon.png"));
photoOutgoing = PathsProvider::webKitPath(styleHref + QLatin1String("Outgoing/buddy_icon.png"));
result.replace(QString("%incomingIconPath%"), Qt::escape(photoIncoming));
result.replace(QString("%outgoingIconPath%"), Qt::escape(photoOutgoing));
......@@ -262,18 +262,18 @@ QString AdiumStyleRenderer::replaceKeywords(const QString &styleHref, const QStr
const Avatar &avatar = message.messageSender().avatar(true);
if (!avatar.isEmpty())
photoPath = Qt::escape(KaduPaths::webKitPath(avatar.smallFilePath()));
photoPath = Qt::escape(PathsProvider::webKitPath(avatar.smallFilePath()));
else
photoPath = Qt::escape(KaduPaths::webKitPath(styleHref + QLatin1String("Incoming/buddy_icon.png")));
photoPath = Qt::escape(PathsProvider::webKitPath(styleHref + QLatin1String("Incoming/buddy_icon.png")));
}
else if (message.type() == MessageTypeSent)
{
result.replace(QString("%messageClasses%"), "message outgoing");
const Avatar &avatar = message.messageChat().chatAccount().accountContact().avatar(true);
if (!avatar.isEmpty())
photoPath = Qt::escape(KaduPaths::webKitPath(avatar.smallFilePath()));
photoPath = Qt::escape(PathsProvider::webKitPath(avatar.smallFilePath()));
else
photoPath = Qt::escape(KaduPaths::webKitPath(styleHref + QLatin1String("Outgoing/buddy_icon.png")));
photoPath = Qt::escape(PathsProvider::webKitPath(styleHref + QLatin1String("Outgoing/buddy_icon.png")));
}
else
result.remove(QString("%messageClasses%"));
......
......@@ -21,7 +21,7 @@
#include "adium-style.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include <QtCore/QDir>
#include <QtCore/QTextCodec>
......@@ -100,9 +100,9 @@ AdiumStyle::AdiumStyle(const QString &styleName) :
Name{styleName}, StyleViewVersion{0}, DefaultBackgroundIsTransparent{false}, UsesCustomTemplateHtml{false}
{
QDir dir;
BaseHref = KaduPaths::instance()->profilePath() + QLatin1String("syntax/chat/") + styleName + QLatin1String("/Contents/Resources/");
BaseHref = PathsProvider::instance()->profilePath() + QLatin1String("syntax/chat/") + styleName + QLatin1String("/Contents/Resources/");
if (!dir.exists(BaseHref))
BaseHref = KaduPaths::instance()->dataPath() + QLatin1String("syntax/chat/") + styleName + QLatin1String("/Contents/Resources/");
BaseHref = PathsProvider::instance()->dataPath() + QLatin1String("syntax/chat/") + styleName + QLatin1String("/Contents/Resources/");
readConfiugrationFile();
loadHtmlFiles();
......@@ -138,7 +138,7 @@ void AdiumStyle::loadHtmlFiles()
TemplateHref = BaseHref + "template.html";
else
{
TemplateHref = KaduPaths::instance()->dataPath() + QLatin1String("syntax/chat/Default/Template.html");
TemplateHref = PathsProvider::instance()->dataPath() + QLatin1String("syntax/chat/Default/Template.html");
UsesCustomTemplateHtml = false;
}
......
......@@ -26,7 +26,7 @@
#include "configuration/configuration.h"
#include "configuration/deprecated-configuration-api.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "kadu-application.h"
#include "main-configuration-holder.h"
......
......@@ -23,7 +23,7 @@
#include "accounts/account.h"
#include "avatars/avatar.h"
#include "icons/kadu-icon.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "parser/parser.h"
#include "protocols/protocol.h"
#include "status/status-container-manager.h"
......@@ -37,7 +37,7 @@ static QString getAvatarPath(Talkable talkable)
if (talkable.avatar().pixmap().isNull())
return QString();
else
return KaduPaths::webKitPath(avatar.filePath());
return PathsProvider::webKitPath(avatar.filePath());
}
static QString getStatusIconPath(Talkable talkable)
......
......@@ -88,7 +88,7 @@
#include "message/unread-message-repository.h"
#include "misc/change-notifier-lock.h"
#include "misc/date-time-parser-tags.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "notify/notification-manager.h"
#include "parser/parser.h"
#include "plugin/dependency-graph/plugin-dependency-graph-builder.h"
......@@ -228,9 +228,9 @@ Core::Core() :
MainConfigurationHolder::createInstance();
Parser::GlobalVariables.insert(QLatin1String("DATA_PATH"), KaduPaths::instance()->dataPath());
Parser::GlobalVariables.insert(QLatin1String("HOME"), KaduPaths::homePath());
Parser::GlobalVariables.insert(QLatin1String("KADU_CONFIG"), KaduPaths::instance()->profilePath());
Parser::GlobalVariables.insert(QLatin1String("DATA_PATH"), PathsProvider::instance()->dataPath());
Parser::GlobalVariables.insert(QLatin1String("HOME"), PathsProvider::homePath());
Parser::GlobalVariables.insert(QLatin1String("KADU_CONFIG"), PathsProvider::instance()->profilePath());
DateTimeParserTags::registerParserTags();
importPre10Configuration();
......@@ -544,25 +544,25 @@ void Core::deleteOldConfigurationFiles()
{
kdebugf();
QDir oldConfigs(KaduPaths::instance()->profilePath(), "kadu-0.12.conf.xml.backup.*", QDir::Name, QDir::Files);
QDir oldConfigs(PathsProvider::instance()->profilePath(), "kadu-0.12.conf.xml.backup.*", QDir::Name, QDir::Files);
if (oldConfigs.count() > 20)
for (unsigned int i = 0, max = oldConfigs.count() - 20; i < max; ++i)
QFile::remove(KaduPaths::instance()->profilePath() + oldConfigs[static_cast<int>(i)]);
QFile::remove(PathsProvider::instance()->profilePath() + oldConfigs[static_cast<int>(i)]);
QDir oldConfigs2(KaduPaths::instance()->profilePath(), "kadu-0.6.6.conf.xml.backup.*", QDir::Name, QDir::Files);
QDir oldConfigs2(PathsProvider::instance()->profilePath(), "kadu-0.6.6.conf.xml.backup.*", QDir::Name, QDir::Files);
if (oldConfigs2.count() > 20)
for (unsigned int i = 0, max = oldConfigs2.count() - 20; i < max; ++i)
QFile::remove(KaduPaths::instance()->profilePath() + oldConfigs2[static_cast<int>(i)]);
QFile::remove(PathsProvider::instance()->profilePath() + oldConfigs2[static_cast<int>(i)]);
QDir oldBacktraces(KaduPaths::instance()->profilePath(), "kadu.backtrace.*", QDir::Name, QDir::Files);
QDir oldBacktraces(PathsProvider::instance()->profilePath(), "kadu.backtrace.*", QDir::Name, QDir::Files);
if (oldBacktraces.count() > 20)
for (unsigned int i = 0, max = oldBacktraces.count() - 20; i < max; ++i)
QFile::remove(KaduPaths::instance()->profilePath() + oldBacktraces[static_cast<int>(i)]);
QFile::remove(PathsProvider::instance()->profilePath() + oldBacktraces[static_cast<int>(i)]);
QDir oldDebugs(KaduPaths::instance()->profilePath(), "kadu.log.*", QDir::Name, QDir::Files);
QDir oldDebugs(PathsProvider::instance()->profilePath(), "kadu.log.*", QDir::Name, QDir::Files);
if (oldDebugs.count() > 20)
for (unsigned int i = 0, max = oldDebugs.count() - 20; i < max; ++i)
QFile::remove(KaduPaths::instance()->profilePath() + oldDebugs[static_cast<int>(i)]);
QFile::remove(PathsProvider::instance()->profilePath() + oldDebugs[static_cast<int>(i)]);
kdebugf2();
}
......@@ -733,7 +733,7 @@ void Core::runServices()
CurrentPluginDependencyGraphBuilder = new PluginDependencyGraphBuilder(this);
CurrentPluginMetadataFinder->setDirectory(KaduPaths::instance()->dataPath() + QLatin1String{"plugins"});
CurrentPluginMetadataFinder->setDirectory(PathsProvider::instance()->dataPath() + QLatin1String{"plugins"});
CurrentPluginMetadataFinder->setPluginMetadataReader(CurrentPluginMetadataReader);
CurrentPluginDependencyHandler = new PluginDependencyHandler(this);
......
......@@ -61,7 +61,7 @@
#include "gui/widgets/configuration/configuration-widget.h"
#include "gui/windows/configuration-window.h"
#include "icons/kadu-icon.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "kadu-application.h"
#include "debug.h"
......@@ -215,7 +215,7 @@ QList<ConfigWidget *> ConfigurationWidget::processUiSectionFromDom(QDomNode sect
QString iconPath = sectionElement.attribute("icon");
// Additional slash is needed so that QUrl would treat the rest as _path_, which is desired here.
if (iconPath.startsWith("datapath:///"))
iconPath = KaduPaths::instance()->dataPath() + iconPath.midRef(static_cast<int>(qstrlen("datapath:///")));
iconPath = PathsProvider::instance()->dataPath() + iconPath.midRef(static_cast<int>(qstrlen("datapath:///")));
configSection(KaduIcon(iconPath), QCoreApplication::translate("@default", sectionName.toUtf8().constData()), true);
const QDomNodeList children = sectionElement.childNodes();
......
......@@ -27,7 +27,7 @@
#include <QtWidgets/QPushButton>
#include "gui/windows/message-dialog.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "misc/syntax-list.h"
#include "syntax-editor.h"
......@@ -86,9 +86,9 @@ void SyntaxEditor::syntaxChangedSlot(const QString &newSyntax)
SyntaxInfo info = (*syntaxList)[newSyntax];
if (info.global)
fileName = KaduPaths::instance()->dataPath() + QLatin1String("syntax/") + category.toLower() + '/' + newSyntax + QLatin1String(".syntax");
fileName = PathsProvider::instance()->dataPath() + QLatin1String("syntax/") + category.toLower() + '/' + newSyntax + QLatin1String(".syntax");
else
fileName = KaduPaths::instance()->profilePath() + QLatin1String("syntax/") + category.toLower() + '/' + newSyntax + QLatin1String(".syntax");
fileName = PathsProvider::instance()->profilePath() + QLatin1String("syntax/") + category.toLower() + '/' + newSyntax + QLatin1String(".syntax");
file.setFileName(fileName);
if (!file.open(QIODevice::ReadOnly))
......
......@@ -25,7 +25,7 @@
#include "gui/widgets/webkit-messages-view/webkit-messages-view-display.h"
#include "gui/widgets/webkit-messages-view/webkit-messages-view-display-factory.h"
#include "gui/widgets/webkit-messages-view/webkit-messages-view-handler.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
WebkitMessagesViewHandlerFactory::WebkitMessagesViewHandlerFactory(QObject *parent) :
QObject{parent}
......
......@@ -38,7 +38,7 @@
#include "gui/widgets/webkit-messages-view/message-limit-policy.h"
#include "gui/widgets/webkit-messages-view/webkit-messages-view-handler.h"
#include "gui/widgets/webkit-messages-view/webkit-messages-view-handler-factory.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "protocols/protocol.h"
#include "protocols/services/chat-image-service.h"
#include "protocols/services/chat-service.h"
......@@ -210,7 +210,7 @@ void WebkitMessagesView::refreshView()
ChatStyleRendererConfiguration WebkitMessagesView::rendererConfiguration()
{
QFile file{KaduPaths::instance()->dataPath() + QLatin1String("scripts/chat-scripts.js")};
QFile file{PathsProvider::instance()->dataPath() + QLatin1String("scripts/chat-scripts.js")};
auto javaScript = file.open(QIODevice::ReadOnly | QIODevice::Text)
? file.readAll()
: QString{};
......
......@@ -51,7 +51,7 @@
#include "core/core.h"
#include "dom/dom-processor-service.h"
#include "icons/kadu-icon.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "os/generic/url-opener.h"
#include "os/generic/window-geometry-manager.h"
#include "url-handlers/url-handler-manager.h"
......@@ -232,7 +232,7 @@ QString About::loadFile(const QString &name)
{
kdebugf();
QFile file(KaduPaths::instance()->dataPath() + name);
QFile file(PathsProvider::instance()->dataPath() + name);
if (!file.open(QIODevice::ReadOnly))
{
kdebugm(KDEBUG_ERROR, "About::loadFile(%s) cannot open file\n", qPrintable(name));
......
......@@ -63,7 +63,7 @@
#include "gui/widgets/tool-tip-class-manager.h"
#include "gui/windows/kadu-window.h"
#include "gui/windows/message-dialog.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "network/proxy/network-proxy.h"
#include "plugin/gui/plugin-list/plugin-list-widget.h"
#include "status/status-container.h"
......@@ -174,7 +174,7 @@ MainConfigurationWindow::MainConfigurationWindow() :
{
setWindowRole("kadu-configuration");
widget()->appendUiFile(KaduPaths::instance()->dataPath() + QLatin1String("configuration/dialog.ui"));
widget()->appendUiFile(PathsProvider::instance()->dataPath() + QLatin1String("configuration/dialog.ui"));
#ifndef DEBUG_ENABLED
widget()->widgetById("debug")->hide();
......@@ -310,7 +310,7 @@ void MainConfigurationWindow::installIconTheme()
if (fileName.isEmpty())
return;
const QString &profilePath = KaduPaths::instance()->profilePath();
const QString &profilePath = PathsProvider::instance()->profilePath();
ArchiveExtractor extractor;
bool success = extractor.extract(fileName, profilePath + "icons");
if (success)
......@@ -395,7 +395,7 @@ void MainConfigurationWindow::showLookChatAdvanced()
if (!lookChatAdvanced)
{
lookChatAdvanced = new ConfigurationWindow("LookChatAdvanced", tr("Advanced chat's look configuration"), "General", instanceDataManager());
lookChatAdvanced.data()->widget()->appendUiFile(KaduPaths::instance()->dataPath() + QLatin1String("configuration/dialog-look-chat-advanced.ui"));
lookChatAdvanced.data()->widget()->appendUiFile(PathsProvider::instance()->dataPath() + QLatin1String("configuration/dialog-look-chat-advanced.ui"));
lookChatAdvanced.data()->widget()->widgetById("chatSyntax")->setToolTip(QCoreApplication::translate("@default", SyntaxText));
lookChatAdvanced.data()->widget()->widgetById("conferencePrefix")->setToolTip(QCoreApplication::translate("@default", SyntaxText));
......
......@@ -45,7 +45,7 @@
#include "gui/widgets/chat-widget/chat-widget-manager.h"
#include "gui/widgets/filtered-tree-view.h"
#include "gui/widgets/line-edit-with-clear-button.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "model/model-chain.h"
#include "model/roles.h"
#include "talkable/model/talkable-proxy-model.h"
......@@ -110,7 +110,7 @@ OpenChatWith::OpenChatWith() :
BuddiesView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
BuddiesView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
BuddiesView->setSource(QUrl(KaduPaths::instance()->dataPath() + "qml/openChatWith.qml"));
BuddiesView->setSource(QUrl(PathsProvider::instance()->dataPath() + "qml/openChatWith.qml"));
connect(BuddiesView->rootObject(), SIGNAL(itemActivated(int)), this, SLOT(itemActivated(int)));
......
......@@ -21,7 +21,7 @@
#include <QtGui/QIcon>
#include "icons/icons-manager.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "kadu-icon.h"
......@@ -32,7 +32,7 @@ QString KaduIcon::fullPath() const
QString KaduIcon::webKitPath() const
{
return KaduPaths::webKitPath(fullPath());
return PathsProvider::webKitPath(fullPath());
}
QIcon KaduIcon::icon() const
......
......@@ -153,7 +153,7 @@ public:
* @return WebKit-friendly representation of path
*
* Return WebKit-friendly representation of full path to the icon file. Makes use
* of KaduPaths::webKitPath() method.
* of PathsProvider::webKitPath() method.
*/
QString webKitPath() const;
......
......@@ -38,7 +38,7 @@
#include "configuration/configuration.h"
#include "configuration/configuration-storage.h"
#include "configuration/configuration-unusable-exception.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "misc/memory.h"
#include <QtWidgets/QMessageBox>
......@@ -71,7 +71,7 @@ KaduApplication::~KaduApplication()
void KaduApplication::readConfiguration() try
{
auto profilePath = KaduPaths::instance()->profilePath();
auto profilePath = PathsProvider::instance()->profilePath();
m_configurationStorage = make_qobject<ConfigurationStorage>(profilePath, this);
m_configuration = make_qobject<Configuration>(this);
......
......@@ -24,7 +24,7 @@
#include <QtCore/QDir>
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "languages-manager.h"
......@@ -32,7 +32,7 @@ QMap<QString, QString> LanguagesManager::Languages;
void LanguagesManager::loadLanguages()
{
QDir tranlationsDir(KaduPaths::instance()->dataPath() + QLatin1String("translations"));
QDir tranlationsDir(PathsProvider::instance()->dataPath() + QLatin1String("translations"));
QStringList languagesFilter;
languagesFilter << "*.language";
......
......@@ -62,7 +62,7 @@
#include "icons/icons-manager.h"
#include "misc/date-time.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "debug.h"
#include "kadu-application.h"
#include "kadu-config.h"
......@@ -197,7 +197,7 @@ int main(int argc, char *argv[]) try
auto profileDirectory = executionArguments.profileDirectory().isEmpty()
? QString::fromUtf8(qgetenv("CONFIG_DIR"))
: executionArguments.profileDirectory();
KaduPaths::createInstance(profileDirectory);
PathsProvider::createInstance(profileDirectory);
#ifndef Q_OS_WIN32
// Qt version is better on win32
......@@ -215,11 +215,11 @@ int main(int argc, char *argv[]) try
const QString lang = KaduApplication::instance()->configuration()->deprecatedApi()->readEntry("General", "Language", QLocale::system().name().left(2));
QTranslator qt_qm, kadu_qm;
qt_qm.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
kadu_qm.load("kadu_" + lang, KaduPaths::instance()->dataPath() + QLatin1String("translations"));
kadu_qm.load("kadu_" + lang, PathsProvider::instance()->dataPath() + QLatin1String("translations"));
QCoreApplication::installTranslator(&qt_qm);
QCoreApplication::installTranslator(&kadu_qm);
QtLocalPeer *peer = new QtLocalPeer(application.get(), KaduPaths::instance()->profilePath());
QtLocalPeer *peer = new QtLocalPeer(application.get(), PathsProvider::instance()->profilePath());
if (peer->isClient())
{
if (!executionArguments.openIds().isEmpty())
......@@ -252,7 +252,7 @@ int main(int argc, char *argv[]) try
kdebugm(KDEBUG_INFO, "exiting main\n");
KaduPaths::destroyInstance();
PathsProvider::destroyInstance();
return ret;
}
......
......@@ -33,7 +33,7 @@
#include "core/core.h"
#include "core/crash-aware-object.h"
#include "gui/windows/kadu-window.h"
#include "misc/kadu-paths.h"
#include "misc/paths-provider.h"
#include "plugin/activation/plugin-activation-service.h"
#include "activate.h"
#include "debug.h"
......@@ -90,7 +90,7 @@ static void kadu_signal_handler(int signal)
fprintf(stderr, "======= END OF BACKTRACE ======\n");
fflush(stderr);
FILE *backtraceFile = fopen(qPrintable(QString(KaduPaths::instance()->profilePath() + backtraceFileName)), "w");
FILE *backtraceFile = fopen(qPrintable(QString(PathsProvider::instance()->profilePath() + backtraceFileName)), "w");
if (backtraceFile)
{
fprintf(backtraceFile, "======= BEGIN OF BACKTRACE =====\n");
......
......@@ -5,7 +5,7 @@ set (misc_SRCS
date-time-parser-tags.cpp
error.cpp
misc.cpp
kadu-paths.cpp
paths-provider.cpp
string-utils.cpp
syntax-list.cpp
)
......
/*
* %kadu copyright begin%
* Copyright 2013 Rafał Malinowski (rafal.przemyslaw.malinowski@gmail.com)
* Copyright 2012 Bartosz Brachaczek (b.brachaczek@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 <QtCore/QCoreApplication>
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#ifdef Q_OS_WIN
#include <shlobj.h>
#include <windows.h>
#endif
#include "kadu-config.h"
#include "kadu-paths.h"
KaduPaths * KaduPaths::Instance;
void KaduPaths::createInstance(const QString &customProfileDir)
{
if (!Instance)
Instance = new KaduPaths(customProfileDir);
}
void KaduPaths::destroyInstance()
{
delete Instance;
Instance = 0;
}
QString KaduPaths::homePath()
{
#ifdef Q_OS_WIN
wchar_t homepath[MAX_PATH];
// There is unfortunately no way to get this path using Qt4 API.
if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, 0, homepath)))
return QDir(QString::fromWCharArray(homepath)).canonicalPath();
#endif
return QDir::homePath();
}
QString KaduPaths::webKitPath(const QString &path)
{
#ifdef Q_OS_WIN
QString winPath = path;
if (winPath.startsWith(QLatin1String("file:///")))
return winPath.remove(0, 8);
if (winPath.startsWith(QLatin1String("file://")))
return winPath.remove(0, 7);
return winPath;
#else
if (path.isEmpty())
return path;
if (path.startsWith(QLatin1String("file:///")))
return path;
if (path.startsWith('/'))
return "file://" + path;
return "file:///" + path;
#endif
}
KaduPaths::KaduPaths(const QString &customProfileDir)
{
initBasicPaths();
initProfilePath(customProfileDir);
}
void KaduPaths::initBasicPaths()
{
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
DesktopFilePath = QCoreApplication::applicationDirPath() + QLatin1String("/" KADU_DESKTOP_FILE_PATH_RELATIVE_TO_BIN);
DesktopFilePath = QFileInfo(DesktopFilePath).canonicalFilePath();
#endif
#ifdef Q_OS_MAC
// TODO: Remove this OS X-specific code. Needs small changes to CMake and create_macosx_bundle.sh scripts.
DataPath = QCoreApplication::applicationDirPath() + QLatin1String("/../../kadu");
#else
DataPath = QCoreApplication::applicationDirPath() + QLatin1String("/" KADU_DATADIR_RELATIVE_TO_BIN);
#endif
QString canonicalPath = QDir(DataPath).canonicalPath();
if (!canonicalPath.isEmpty())
DataPath = canonicalPath + '/';
#ifdef Q_OS_MAC
// TODO: Remove this OS X-specific code. Needs small changes to CMake and create_macosx_bundle.sh scripts.
PluginsLibPath = QCoreApplication::applicationDirPath() + QLatin1String("/../../kadu/plugins/");
#else
PluginsLibPath = QCoreApplication::applicationDirPath() + QLatin1String("/" KADU_PLUGINS_LIBDIR_RELATIVE_TO_BIN);
#endif
canonicalPath = QDir(PluginsLibPath).canonicalPath();
if (!canonicalPath.isEmpty())
PluginsLibPath = canonicalPath + '/';
}
void KaduPaths::initProfilePath(const QString &customProfileDir)