From 2d69fcd35da6717fd4d885af00b14ab87e582efd Mon Sep 17 00:00:00 2001 From: Akira Ohgaki <akiraohgaki@gmail.com> Date: Tue, 27 Feb 2018 00:03:57 +0900 Subject: [PATCH] Fix for Qtil --- app/src/handlers/confighandler.cpp | 12 ++++---- app/src/handlers/confighandler.h | 4 +-- app/src/handlers/itemhandler.cpp | 42 +++++++++++++------------- app/src/handlers/itemhandler.h | 8 ++--- app/src/handlers/ocsapihandler.cpp | 8 ++--- app/src/handlers/systemhandler.cpp | 2 +- app/src/handlers/updatehandler.cpp | 2 +- app/src/websockets/websocketserver.cpp | 6 ++-- 8 files changed, 42 insertions(+), 42 deletions(-) diff --git a/app/src/handlers/confighandler.cpp b/app/src/handlers/confighandler.cpp index 6807e93..d050787 100644 --- a/app/src/handlers/confighandler.cpp +++ b/app/src/handlers/confighandler.cpp @@ -8,10 +8,10 @@ ConfigHandler::ConfigHandler(QObject *parent) : QObject(parent) { - appConfig_ = qtil::Config(":/configs"); + appConfig_ = Qtil::Config(":/configs"); importAppConfigApplication(); importAppConfigInstallTypes(); - usrConfig_ = qtil::Config(qtil::Dir::genericConfigPath() + "/" + getAppConfigApplication()["id"].toString()); + usrConfig_ = Qtil::Config(Qtil::Dir::genericConfigPath() + "/" + getAppConfigApplication()["id"].toString()); } QJsonObject ConfigHandler::getAppConfigApplication() const @@ -229,7 +229,7 @@ QString ConfigHandler::convertPathString(const QString &path) const { auto newPath = path; if (newPath.contains("$HOME")) { - newPath.replace("$HOME", qtil::Dir::homePath()); + newPath.replace("$HOME", Qtil::Dir::homePath()); } else if (newPath.contains("$XDG_DOCUMENTS_DIR")) { newPath.replace("$XDG_DOCUMENTS_DIR", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); @@ -247,13 +247,13 @@ QString ConfigHandler::convertPathString(const QString &path) const newPath.replace("$XDG_VIDEOS_DIR", QStandardPaths::writableLocation(QStandardPaths::MoviesLocation)); } else if (newPath.contains("$XDG_DATA_HOME")) { - newPath.replace("$XDG_DATA_HOME", qtil::Dir::genericDataPath()); + newPath.replace("$XDG_DATA_HOME", Qtil::Dir::genericDataPath()); } else if (newPath.contains("$KDEHOME")) { - newPath.replace("$KDEHOME", qtil::Dir::kdehomePath()); + newPath.replace("$KDEHOME", Qtil::Dir::kdehomePath()); } else if (newPath.contains("$APP_DATA")) { - newPath.replace("$APP_DATA", qtil::Dir::genericDataPath() + "/" + getAppConfigApplication()["id"].toString()); + newPath.replace("$APP_DATA", Qtil::Dir::genericDataPath() + "/" + getAppConfigApplication()["id"].toString()); } return newPath; } diff --git a/app/src/handlers/confighandler.h b/app/src/handlers/confighandler.h index c7d3891..eb9d0b8 100644 --- a/app/src/handlers/confighandler.h +++ b/app/src/handlers/confighandler.h @@ -42,8 +42,8 @@ private: void importAppConfigInstallTypes(); QString convertPathString(const QString &path) const; - qtil::Config appConfig_; - qtil::Config usrConfig_; + Qtil::Config appConfig_; + Qtil::Config usrConfig_; QJsonObject appConfigApplication_; QJsonObject appConfigInstallTypes_; }; diff --git a/app/src/handlers/itemhandler.cpp b/app/src/handlers/itemhandler.cpp index 7d3d3f2..344973b 100644 --- a/app/src/handlers/itemhandler.cpp +++ b/app/src/handlers/itemhandler.cpp @@ -67,9 +67,9 @@ void ItemHandler::getItem(const QString &command, const QString &url, const QStr itemMetadataSet[itemKey] = metadata; setMetadataSet(itemMetadataSet); - auto *resource = new qtil::NetworkResource(itemKey, QUrl(url), true, this); - connect(resource, &qtil::NetworkResource::downloadProgress, this, &ItemHandler::downloadProgress); - connect(resource, &qtil::NetworkResource::finished, this, &ItemHandler::networkResourceFinished); + auto *resource = new Qtil::NetworkResource(itemKey, QUrl(url), true, this); + connect(resource, &Qtil::NetworkResource::downloadProgress, this, &ItemHandler::downloadProgress); + connect(resource, &Qtil::NetworkResource::finished, this, &ItemHandler::networkResourceFinished); resource->get(); result["status"] = QString("success_downloadstart"); @@ -145,7 +145,7 @@ void ItemHandler::uninstall(const QString &itemKey) auto installedItem = configHandler_->getUsrConfigInstalledItems()[itemKey].toObject(); auto installType = installedItem["install_type"].toString(); - qtil::Dir destDir; + Qtil::Dir destDir; #ifdef QTIL_OS_UNIX destDir.setPath(configHandler_->getAppConfigInstallTypes()[installType].toObject()["destination"].toString()); @@ -154,7 +154,7 @@ void ItemHandler::uninstall(const QString &itemKey) // plasmapkg: Installation process has should be saved plasmapkg into destination directory - qtil::Package package(fileInfo.filePath()); + Qtil::Package package(fileInfo.filePath()); // Uninstall if (installType == "bin") { @@ -185,10 +185,10 @@ void ItemHandler::uninstall(const QString &itemKey) // Remove file if (fileInfo.isDir()) { - qtil::Dir(fileInfo.filePath()).remove(); + Qtil::Dir(fileInfo.filePath()).remove(); } else { - qtil::File(fileInfo.filePath()).remove(); + Qtil::File(fileInfo.filePath()).remove(); } } #else @@ -197,10 +197,10 @@ void ItemHandler::uninstall(const QString &itemKey) for (const auto &filename : installedItem["files"].toArray()) { QFileInfo fileInfo(destDir.path() + "/" + filename.toString()); if (fileInfo.isDir()) { - qtil::Dir(fileInfo.filePath()).remove(); + Qtil::Dir(fileInfo.filePath()).remove(); } else { - qtil::File(fileInfo.filePath()).remove(); + Qtil::File(fileInfo.filePath()).remove(); } } #endif @@ -213,7 +213,7 @@ void ItemHandler::uninstall(const QString &itemKey) emit uninstallFinished(result); } -void ItemHandler::networkResourceFinished(qtil::NetworkResource *resource) +void ItemHandler::networkResourceFinished(Qtil::NetworkResource *resource) { auto itemKey = resource->id(); @@ -251,7 +251,7 @@ void ItemHandler::setMetadataSet(const QJsonObject &metadataSet) emit metadataSetChanged(); } -void ItemHandler::saveDownloadedFile(qtil::NetworkResource *resource) +void ItemHandler::saveDownloadedFile(Qtil::NetworkResource *resource) { auto itemKey = resource->id(); @@ -270,9 +270,9 @@ void ItemHandler::saveDownloadedFile(qtil::NetworkResource *resource) auto filename = metadata["filename"].toString(); auto installType = metadata["install_type"].toString(); - qtil::Dir destDir(configHandler_->getAppConfigInstallTypes()[installType].toObject()["destination"].toString()); + Qtil::Dir destDir(configHandler_->getAppConfigInstallTypes()[installType].toObject()["destination"].toString()); destDir.make(); - qtil::File destFile(destDir.path() + "/" + filename); + Qtil::File destFile(destDir.path() + "/" + filename); if (destFile.exists()) { auto filenamePrefix = QString::number(QDateTime::currentMSecsSinceEpoch()) + "_"; @@ -294,7 +294,7 @@ void ItemHandler::saveDownloadedFile(qtil::NetworkResource *resource) resource->deleteLater(); } -void ItemHandler::installDownloadedFile(qtil::NetworkResource *resource) +void ItemHandler::installDownloadedFile(Qtil::NetworkResource *resource) { // Installation pre-process auto itemKey = resource->id(); @@ -315,13 +315,13 @@ void ItemHandler::installDownloadedFile(qtil::NetworkResource *resource) auto installType = metadata["install_type"].toString(); QString tempDirPrefix = "temp_" + filename; - qtil::Dir tempDir(qtil::Dir::genericCachePath() + "/" + Qtil::Dir tempDir(Qtil::Dir::genericCachePath() + "/" + configHandler_->getAppConfigApplication()["id"].toString() + "/" + tempDirPrefix); tempDir.make(); - qtil::Dir tempDestDir(tempDir.path() + "/dest"); + Qtil::Dir tempDestDir(tempDir.path() + "/dest"); tempDestDir.make(); - qtil::Package package(tempDir.path() + "/" + filename); + Qtil::Package package(tempDir.path() + "/" + filename); if (!resource->saveData(package.path())) { result["status"] = QString("error_save"); @@ -341,7 +341,7 @@ void ItemHandler::installDownloadedFile(qtil::NetworkResource *resource) result["message"] = tr("Installing"); emit installStarted(result); - qtil::Dir destDir; + Qtil::Dir destDir; #ifdef QTIL_OS_UNIX destDir.setPath(configHandler_->getAppConfigInstallTypes()[installType].toObject()["destination"].toString()); @@ -398,7 +398,7 @@ void ItemHandler::installDownloadedFile(qtil::NetworkResource *resource) #else destDir.setPath(configHandler_->getAppConfigInstallTypes()[installType].toObject()["generic_destination"].toString()); - if (qtil::File(package.path()).copy(tempDestDir.path() + "/" + filename)) { + if (Qtil::File(package.path()).copy(tempDestDir.path() + "/" + filename)) { result["message"] = tr("The file has been installed"); } else { @@ -423,10 +423,10 @@ void ItemHandler::installDownloadedFile(qtil::NetworkResource *resource) } if (fileInfo.isDir()) { - qtil::Dir(fileInfo.filePath()).move(destDir.path() + "/" + destFilename); + Qtil::Dir(fileInfo.filePath()).move(destDir.path() + "/" + destFilename); } else { - qtil::File(fileInfo.filePath()).move(destDir.path() + "/" + destFilename); + Qtil::File(fileInfo.filePath()).move(destDir.path() + "/" + destFilename); } installedFiles.append(QJsonValue(destFilename)); diff --git a/app/src/handlers/itemhandler.h b/app/src/handlers/itemhandler.h index 79f5906..d461d4d 100644 --- a/app/src/handlers/itemhandler.h +++ b/app/src/handlers/itemhandler.h @@ -3,7 +3,7 @@ #include <QObject> #include <QJsonObject> -namespace qtil { +namespace Qtil { class NetworkResource; } @@ -37,13 +37,13 @@ public slots: void uninstall(const QString &itemKey); private slots: - void networkResourceFinished(qtil::NetworkResource *resource); + void networkResourceFinished(Qtil::NetworkResource *resource); private: void setMetadataSet(const QJsonObject &metadataSet); - void saveDownloadedFile(qtil::NetworkResource *resource); - void installDownloadedFile(qtil::NetworkResource *resource); + void saveDownloadedFile(Qtil::NetworkResource *resource); + void installDownloadedFile(Qtil::NetworkResource *resource); ConfigHandler *configHandler_; QJsonObject metadataSet_; diff --git a/app/src/handlers/ocsapihandler.cpp b/app/src/handlers/ocsapihandler.cpp index fcf7356..f177119 100644 --- a/app/src/handlers/ocsapihandler.cpp +++ b/app/src/handlers/ocsapihandler.cpp @@ -13,7 +13,7 @@ OcsApiHandler::OcsApiHandler(ConfigHandler *configHandler, QObject *parent) bool OcsApiHandler::addProviders(const QString &providerFileUrl) const { - auto providers = qtil::OcsApi::getProviderFile(QUrl(providerFileUrl)); + auto providers = Qtil::OcsApi::getProviderFile(QUrl(providerFileUrl)); if (!providers.isEmpty()) { for (const auto &providerValue : providers) { auto provider = providerValue.toObject(); @@ -60,7 +60,7 @@ bool OcsApiHandler::updateCategories(const QString &providerKey, bool force) con } auto baseUrl = providers[providerKey].toObject()["location"].toString(); - auto response = qtil::OcsApi(baseUrl, QUrl(baseUrl)).getContentCategories(); + auto response = Qtil::OcsApi(baseUrl, QUrl(baseUrl)).getContentCategories(); if (!response.contains("data")) { return false; @@ -185,7 +185,7 @@ QJsonObject OcsApiHandler::getContents(const QString &providerKeys, const QStrin query.addQueryItem("sortmode", sortmode); query.addQueryItem("pagesize", QString::number(pagesize)); query.addQueryItem("page", QString::number(page)); - responseSet[providerKey] = qtil::OcsApi(baseUrl, QUrl(baseUrl)).getContentDataSet(query); + responseSet[providerKey] = Qtil::OcsApi(baseUrl, QUrl(baseUrl)).getContentDataSet(query); } } @@ -198,7 +198,7 @@ QJsonObject OcsApiHandler::getContent(const QString &providerKey, const QString auto providers = configHandler_->getUsrConfigProviders(); if (providers.contains(providerKey)) { auto baseUrl = providers[providerKey].toObject()["location"].toString(); - response = qtil::OcsApi(baseUrl, QUrl(baseUrl)).getContentData(contentId); + response = Qtil::OcsApi(baseUrl, QUrl(baseUrl)).getContentData(contentId); } return response; } diff --git a/app/src/handlers/systemhandler.cpp b/app/src/handlers/systemhandler.cpp index e732fa3..4aa2b01 100644 --- a/app/src/handlers/systemhandler.cpp +++ b/app/src/handlers/systemhandler.cpp @@ -51,7 +51,7 @@ bool SystemHandler::openUrl(const QString &url) const #ifdef Q_OS_ANDROID if (path.endsWith(".apk", Qt::CaseInsensitive)) { - return qtil::Package(path).installAsApk(); + return Qtil::Package(path).installAsApk(); } #endif diff --git a/app/src/handlers/updatehandler.cpp b/app/src/handlers/updatehandler.cpp index 717495a..7de49c5 100644 --- a/app/src/handlers/updatehandler.cpp +++ b/app/src/handlers/updatehandler.cpp @@ -124,7 +124,7 @@ void UpdateHandler::appImageUpdaterFinished(AppImageUpdater *updater) configHandler_->setUsrConfigInstalledItemsItem(installedItemKey, installedItem); if (newFilename != filename) { - qtil::File(updater->path()).remove(); + Qtil::File(updater->path()).remove(); } configHandler_->removeUsrConfigUpdateAvailableItemsItem(itemKey); diff --git a/app/src/websockets/websocketserver.cpp b/app/src/websockets/websocketserver.cpp index bb9d639..877c784 100644 --- a/app/src/websockets/websocketserver.cpp +++ b/app/src/websockets/websocketserver.cpp @@ -116,7 +116,7 @@ void WebSocketServer::wsTextMessageReceived(const QString &message) { auto *wsClient = qobject_cast<QWebSocket *>(sender()); if (wsClient) { - qtil::Json json(message.toUtf8()); + Qtil::Json json(message.toUtf8()); if (json.isObject()) { auto object = json.toObject(); receiveMessage(object["id"].toString(), object["func"].toString(), object["data"].toArray()); @@ -128,7 +128,7 @@ void WebSocketServer::wsBinaryMessageReceived(const QByteArray &message) { auto *wsClient = qobject_cast<QWebSocket *>(sender()); if (wsClient) { - qtil::Json json(message); + Qtil::Json json(message); if (json.isObject()) { auto object = json.toObject(); receiveMessage(object["id"].toString(), object["func"].toString(), object["data"].toArray()); @@ -419,7 +419,7 @@ void WebSocketServer::sendMessage(const QString &id, const QString &func, const object["func"] = func; object["data"] = data; - auto binaryMessage = qtil::Json(object).toJson(); + auto binaryMessage = Qtil::Json(object).toJson(); auto textMessage = QString::fromUtf8(binaryMessage); for (auto *wsClient : wsClients_) { -- GitLab