Skip to content
Snippets Groups Projects
Unverified Commit 57105a0e authored by akiraohgaki's avatar akiraohgaki Committed by GitHub
Browse files

Merge pull request #30 from opendesktop/develop

Develop
parents 6d7246a2 2d69fcd3
No related branches found
No related tags found
No related merge requests found
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
ConfigHandler::ConfigHandler(QObject *parent) ConfigHandler::ConfigHandler(QObject *parent)
: QObject(parent) : QObject(parent)
{ {
appConfig_ = qtil::Config(":/configs"); appConfig_ = Qtil::Config(":/configs");
importAppConfigApplication(); importAppConfigApplication();
importAppConfigInstallTypes(); importAppConfigInstallTypes();
usrConfig_ = qtil::Config(qtil::Dir::genericConfigPath() + "/" + getAppConfigApplication()["id"].toString()); usrConfig_ = Qtil::Config(Qtil::Dir::genericConfigPath() + "/" + getAppConfigApplication()["id"].toString());
} }
QJsonObject ConfigHandler::getAppConfigApplication() const QJsonObject ConfigHandler::getAppConfigApplication() const
...@@ -229,7 +229,7 @@ QString ConfigHandler::convertPathString(const QString &path) const ...@@ -229,7 +229,7 @@ QString ConfigHandler::convertPathString(const QString &path) const
{ {
auto newPath = path; auto newPath = path;
if (newPath.contains("$HOME")) { if (newPath.contains("$HOME")) {
newPath.replace("$HOME", qtil::Dir::homePath()); newPath.replace("$HOME", Qtil::Dir::homePath());
} }
else if (newPath.contains("$XDG_DOCUMENTS_DIR")) { else if (newPath.contains("$XDG_DOCUMENTS_DIR")) {
newPath.replace("$XDG_DOCUMENTS_DIR", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); newPath.replace("$XDG_DOCUMENTS_DIR", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));
...@@ -247,13 +247,13 @@ QString ConfigHandler::convertPathString(const QString &path) const ...@@ -247,13 +247,13 @@ QString ConfigHandler::convertPathString(const QString &path) const
newPath.replace("$XDG_VIDEOS_DIR", QStandardPaths::writableLocation(QStandardPaths::MoviesLocation)); newPath.replace("$XDG_VIDEOS_DIR", QStandardPaths::writableLocation(QStandardPaths::MoviesLocation));
} }
else if (newPath.contains("$XDG_DATA_HOME")) { 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")) { else if (newPath.contains("$KDEHOME")) {
newPath.replace("$KDEHOME", qtil::Dir::kdehomePath()); newPath.replace("$KDEHOME", Qtil::Dir::kdehomePath());
} }
else if (newPath.contains("$APP_DATA")) { 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; return newPath;
} }
...@@ -42,8 +42,8 @@ private: ...@@ -42,8 +42,8 @@ private:
void importAppConfigInstallTypes(); void importAppConfigInstallTypes();
QString convertPathString(const QString &path) const; QString convertPathString(const QString &path) const;
qtil::Config appConfig_; Qtil::Config appConfig_;
qtil::Config usrConfig_; Qtil::Config usrConfig_;
QJsonObject appConfigApplication_; QJsonObject appConfigApplication_;
QJsonObject appConfigInstallTypes_; QJsonObject appConfigInstallTypes_;
}; };
...@@ -67,9 +67,9 @@ void ItemHandler::getItem(const QString &command, const QString &url, const QStr ...@@ -67,9 +67,9 @@ void ItemHandler::getItem(const QString &command, const QString &url, const QStr
itemMetadataSet[itemKey] = metadata; itemMetadataSet[itemKey] = metadata;
setMetadataSet(itemMetadataSet); setMetadataSet(itemMetadataSet);
auto *resource = new qtil::NetworkResource(itemKey, QUrl(url), true, this); auto *resource = new Qtil::NetworkResource(itemKey, QUrl(url), true, this);
connect(resource, &qtil::NetworkResource::downloadProgress, this, &ItemHandler::downloadProgress); connect(resource, &Qtil::NetworkResource::downloadProgress, this, &ItemHandler::downloadProgress);
connect(resource, &qtil::NetworkResource::finished, this, &ItemHandler::networkResourceFinished); connect(resource, &Qtil::NetworkResource::finished, this, &ItemHandler::networkResourceFinished);
resource->get(); resource->get();
result["status"] = QString("success_downloadstart"); result["status"] = QString("success_downloadstart");
...@@ -145,7 +145,7 @@ void ItemHandler::uninstall(const QString &itemKey) ...@@ -145,7 +145,7 @@ void ItemHandler::uninstall(const QString &itemKey)
auto installedItem = configHandler_->getUsrConfigInstalledItems()[itemKey].toObject(); auto installedItem = configHandler_->getUsrConfigInstalledItems()[itemKey].toObject();
auto installType = installedItem["install_type"].toString(); auto installType = installedItem["install_type"].toString();
qtil::Dir destDir; Qtil::Dir destDir;
#ifdef QTIL_OS_UNIX #ifdef QTIL_OS_UNIX
destDir.setPath(configHandler_->getAppConfigInstallTypes()[installType].toObject()["destination"].toString()); destDir.setPath(configHandler_->getAppConfigInstallTypes()[installType].toObject()["destination"].toString());
...@@ -154,7 +154,7 @@ void ItemHandler::uninstall(const QString &itemKey) ...@@ -154,7 +154,7 @@ void ItemHandler::uninstall(const QString &itemKey)
// plasmapkg: Installation process has should be saved plasmapkg into destination directory // plasmapkg: Installation process has should be saved plasmapkg into destination directory
qtil::Package package(fileInfo.filePath()); Qtil::Package package(fileInfo.filePath());
// Uninstall // Uninstall
if (installType == "bin") { if (installType == "bin") {
...@@ -185,10 +185,10 @@ void ItemHandler::uninstall(const QString &itemKey) ...@@ -185,10 +185,10 @@ void ItemHandler::uninstall(const QString &itemKey)
// Remove file // Remove file
if (fileInfo.isDir()) { if (fileInfo.isDir()) {
qtil::Dir(fileInfo.filePath()).remove(); Qtil::Dir(fileInfo.filePath()).remove();
} }
else { else {
qtil::File(fileInfo.filePath()).remove(); Qtil::File(fileInfo.filePath()).remove();
} }
} }
#else #else
...@@ -197,10 +197,10 @@ void ItemHandler::uninstall(const QString &itemKey) ...@@ -197,10 +197,10 @@ void ItemHandler::uninstall(const QString &itemKey)
for (const auto &filename : installedItem["files"].toArray()) { for (const auto &filename : installedItem["files"].toArray()) {
QFileInfo fileInfo(destDir.path() + "/" + filename.toString()); QFileInfo fileInfo(destDir.path() + "/" + filename.toString());
if (fileInfo.isDir()) { if (fileInfo.isDir()) {
qtil::Dir(fileInfo.filePath()).remove(); Qtil::Dir(fileInfo.filePath()).remove();
} }
else { else {
qtil::File(fileInfo.filePath()).remove(); Qtil::File(fileInfo.filePath()).remove();
} }
} }
#endif #endif
...@@ -213,7 +213,7 @@ void ItemHandler::uninstall(const QString &itemKey) ...@@ -213,7 +213,7 @@ void ItemHandler::uninstall(const QString &itemKey)
emit uninstallFinished(result); emit uninstallFinished(result);
} }
void ItemHandler::networkResourceFinished(qtil::NetworkResource *resource) void ItemHandler::networkResourceFinished(Qtil::NetworkResource *resource)
{ {
auto itemKey = resource->id(); auto itemKey = resource->id();
...@@ -251,7 +251,7 @@ void ItemHandler::setMetadataSet(const QJsonObject &metadataSet) ...@@ -251,7 +251,7 @@ void ItemHandler::setMetadataSet(const QJsonObject &metadataSet)
emit metadataSetChanged(); emit metadataSetChanged();
} }
void ItemHandler::saveDownloadedFile(qtil::NetworkResource *resource) void ItemHandler::saveDownloadedFile(Qtil::NetworkResource *resource)
{ {
auto itemKey = resource->id(); auto itemKey = resource->id();
...@@ -270,9 +270,9 @@ void ItemHandler::saveDownloadedFile(qtil::NetworkResource *resource) ...@@ -270,9 +270,9 @@ void ItemHandler::saveDownloadedFile(qtil::NetworkResource *resource)
auto filename = metadata["filename"].toString(); auto filename = metadata["filename"].toString();
auto installType = metadata["install_type"].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(); destDir.make();
qtil::File destFile(destDir.path() + "/" + filename); Qtil::File destFile(destDir.path() + "/" + filename);
if (destFile.exists()) { if (destFile.exists()) {
auto filenamePrefix = QString::number(QDateTime::currentMSecsSinceEpoch()) + "_"; auto filenamePrefix = QString::number(QDateTime::currentMSecsSinceEpoch()) + "_";
...@@ -294,7 +294,7 @@ void ItemHandler::saveDownloadedFile(qtil::NetworkResource *resource) ...@@ -294,7 +294,7 @@ void ItemHandler::saveDownloadedFile(qtil::NetworkResource *resource)
resource->deleteLater(); resource->deleteLater();
} }
void ItemHandler::installDownloadedFile(qtil::NetworkResource *resource) void ItemHandler::installDownloadedFile(Qtil::NetworkResource *resource)
{ {
// Installation pre-process // Installation pre-process
auto itemKey = resource->id(); auto itemKey = resource->id();
...@@ -315,13 +315,13 @@ void ItemHandler::installDownloadedFile(qtil::NetworkResource *resource) ...@@ -315,13 +315,13 @@ void ItemHandler::installDownloadedFile(qtil::NetworkResource *resource)
auto installType = metadata["install_type"].toString(); auto installType = metadata["install_type"].toString();
QString tempDirPrefix = "temp_" + filename; QString tempDirPrefix = "temp_" + filename;
qtil::Dir tempDir(qtil::Dir::genericCachePath() + "/" Qtil::Dir tempDir(Qtil::Dir::genericCachePath() + "/"
+ configHandler_->getAppConfigApplication()["id"].toString() + "/" + configHandler_->getAppConfigApplication()["id"].toString() + "/"
+ tempDirPrefix); + tempDirPrefix);
tempDir.make(); tempDir.make();
qtil::Dir tempDestDir(tempDir.path() + "/dest"); Qtil::Dir tempDestDir(tempDir.path() + "/dest");
tempDestDir.make(); tempDestDir.make();
qtil::Package package(tempDir.path() + "/" + filename); Qtil::Package package(tempDir.path() + "/" + filename);
if (!resource->saveData(package.path())) { if (!resource->saveData(package.path())) {
result["status"] = QString("error_save"); result["status"] = QString("error_save");
...@@ -341,7 +341,7 @@ void ItemHandler::installDownloadedFile(qtil::NetworkResource *resource) ...@@ -341,7 +341,7 @@ void ItemHandler::installDownloadedFile(qtil::NetworkResource *resource)
result["message"] = tr("Installing"); result["message"] = tr("Installing");
emit installStarted(result); emit installStarted(result);
qtil::Dir destDir; Qtil::Dir destDir;
#ifdef QTIL_OS_UNIX #ifdef QTIL_OS_UNIX
destDir.setPath(configHandler_->getAppConfigInstallTypes()[installType].toObject()["destination"].toString()); destDir.setPath(configHandler_->getAppConfigInstallTypes()[installType].toObject()["destination"].toString());
...@@ -398,7 +398,7 @@ void ItemHandler::installDownloadedFile(qtil::NetworkResource *resource) ...@@ -398,7 +398,7 @@ void ItemHandler::installDownloadedFile(qtil::NetworkResource *resource)
#else #else
destDir.setPath(configHandler_->getAppConfigInstallTypes()[installType].toObject()["generic_destination"].toString()); 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"); result["message"] = tr("The file has been installed");
} }
else { else {
...@@ -423,10 +423,10 @@ void ItemHandler::installDownloadedFile(qtil::NetworkResource *resource) ...@@ -423,10 +423,10 @@ void ItemHandler::installDownloadedFile(qtil::NetworkResource *resource)
} }
if (fileInfo.isDir()) { if (fileInfo.isDir()) {
qtil::Dir(fileInfo.filePath()).move(destDir.path() + "/" + destFilename); Qtil::Dir(fileInfo.filePath()).move(destDir.path() + "/" + destFilename);
} }
else { else {
qtil::File(fileInfo.filePath()).move(destDir.path() + "/" + destFilename); Qtil::File(fileInfo.filePath()).move(destDir.path() + "/" + destFilename);
} }
installedFiles.append(QJsonValue(destFilename)); installedFiles.append(QJsonValue(destFilename));
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <QObject> #include <QObject>
#include <QJsonObject> #include <QJsonObject>
namespace qtil { namespace Qtil {
class NetworkResource; class NetworkResource;
} }
...@@ -37,13 +37,13 @@ public slots: ...@@ -37,13 +37,13 @@ public slots:
void uninstall(const QString &itemKey); void uninstall(const QString &itemKey);
private slots: private slots:
void networkResourceFinished(qtil::NetworkResource *resource); void networkResourceFinished(Qtil::NetworkResource *resource);
private: private:
void setMetadataSet(const QJsonObject &metadataSet); void setMetadataSet(const QJsonObject &metadataSet);
void saveDownloadedFile(qtil::NetworkResource *resource); void saveDownloadedFile(Qtil::NetworkResource *resource);
void installDownloadedFile(qtil::NetworkResource *resource); void installDownloadedFile(Qtil::NetworkResource *resource);
ConfigHandler *configHandler_; ConfigHandler *configHandler_;
QJsonObject metadataSet_; QJsonObject metadataSet_;
......
...@@ -13,7 +13,7 @@ OcsApiHandler::OcsApiHandler(ConfigHandler *configHandler, QObject *parent) ...@@ -13,7 +13,7 @@ OcsApiHandler::OcsApiHandler(ConfigHandler *configHandler, QObject *parent)
bool OcsApiHandler::addProviders(const QString &providerFileUrl) const bool OcsApiHandler::addProviders(const QString &providerFileUrl) const
{ {
auto providers = qtil::OcsApi::getProviderFile(QUrl(providerFileUrl)); auto providers = Qtil::OcsApi::getProviderFile(QUrl(providerFileUrl));
if (!providers.isEmpty()) { if (!providers.isEmpty()) {
for (const auto &providerValue : providers) { for (const auto &providerValue : providers) {
auto provider = providerValue.toObject(); auto provider = providerValue.toObject();
...@@ -60,7 +60,7 @@ bool OcsApiHandler::updateCategories(const QString &providerKey, bool force) con ...@@ -60,7 +60,7 @@ bool OcsApiHandler::updateCategories(const QString &providerKey, bool force) con
} }
auto baseUrl = providers[providerKey].toObject()["location"].toString(); 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")) { if (!response.contains("data")) {
return false; return false;
...@@ -185,7 +185,7 @@ QJsonObject OcsApiHandler::getContents(const QString &providerKeys, const QStrin ...@@ -185,7 +185,7 @@ QJsonObject OcsApiHandler::getContents(const QString &providerKeys, const QStrin
query.addQueryItem("sortmode", sortmode); query.addQueryItem("sortmode", sortmode);
query.addQueryItem("pagesize", QString::number(pagesize)); query.addQueryItem("pagesize", QString::number(pagesize));
query.addQueryItem("page", QString::number(page)); 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 ...@@ -198,7 +198,7 @@ QJsonObject OcsApiHandler::getContent(const QString &providerKey, const QString
auto providers = configHandler_->getUsrConfigProviders(); auto providers = configHandler_->getUsrConfigProviders();
if (providers.contains(providerKey)) { if (providers.contains(providerKey)) {
auto baseUrl = providers[providerKey].toObject()["location"].toString(); 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; return response;
} }
...@@ -51,7 +51,7 @@ bool SystemHandler::openUrl(const QString &url) const ...@@ -51,7 +51,7 @@ bool SystemHandler::openUrl(const QString &url) const
#ifdef Q_OS_ANDROID #ifdef Q_OS_ANDROID
if (path.endsWith(".apk", Qt::CaseInsensitive)) { if (path.endsWith(".apk", Qt::CaseInsensitive)) {
return qtil::Package(path).installAsApk(); return Qtil::Package(path).installAsApk();
} }
#endif #endif
......
...@@ -124,7 +124,7 @@ void UpdateHandler::appImageUpdaterFinished(AppImageUpdater *updater) ...@@ -124,7 +124,7 @@ void UpdateHandler::appImageUpdaterFinished(AppImageUpdater *updater)
configHandler_->setUsrConfigInstalledItemsItem(installedItemKey, installedItem); configHandler_->setUsrConfigInstalledItemsItem(installedItemKey, installedItem);
if (newFilename != filename) { if (newFilename != filename) {
qtil::File(updater->path()).remove(); Qtil::File(updater->path()).remove();
} }
configHandler_->removeUsrConfigUpdateAvailableItemsItem(itemKey); configHandler_->removeUsrConfigUpdateAvailableItemsItem(itemKey);
......
...@@ -116,7 +116,7 @@ void WebSocketServer::wsTextMessageReceived(const QString &message) ...@@ -116,7 +116,7 @@ void WebSocketServer::wsTextMessageReceived(const QString &message)
{ {
auto *wsClient = qobject_cast<QWebSocket *>(sender()); auto *wsClient = qobject_cast<QWebSocket *>(sender());
if (wsClient) { if (wsClient) {
qtil::Json json(message.toUtf8()); Qtil::Json json(message.toUtf8());
if (json.isObject()) { if (json.isObject()) {
auto object = json.toObject(); auto object = json.toObject();
receiveMessage(object["id"].toString(), object["func"].toString(), object["data"].toArray()); receiveMessage(object["id"].toString(), object["func"].toString(), object["data"].toArray());
...@@ -128,7 +128,7 @@ void WebSocketServer::wsBinaryMessageReceived(const QByteArray &message) ...@@ -128,7 +128,7 @@ void WebSocketServer::wsBinaryMessageReceived(const QByteArray &message)
{ {
auto *wsClient = qobject_cast<QWebSocket *>(sender()); auto *wsClient = qobject_cast<QWebSocket *>(sender());
if (wsClient) { if (wsClient) {
qtil::Json json(message); Qtil::Json json(message);
if (json.isObject()) { if (json.isObject()) {
auto object = json.toObject(); auto object = json.toObject();
receiveMessage(object["id"].toString(), object["func"].toString(), object["data"].toArray()); receiveMessage(object["id"].toString(), object["func"].toString(), object["data"].toArray());
...@@ -419,7 +419,7 @@ void WebSocketServer::sendMessage(const QString &id, const QString &func, const ...@@ -419,7 +419,7 @@ void WebSocketServer::sendMessage(const QString &id, const QString &func, const
object["func"] = func; object["func"] = func;
object["data"] = data; object["data"] = data;
auto binaryMessage = qtil::Json(object).toJson(); auto binaryMessage = Qtil::Json(object).toJson();
auto textMessage = QString::fromUtf8(binaryMessage); auto textMessage = QString::fromUtf8(binaryMessage);
for (auto *wsClient : wsClients_) { for (auto *wsClient : wsClients_) {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
PROJDIR="$(cd "$(dirname "${0}")/../" && pwd)" PROJDIR="$(cd "$(dirname "${0}")/../" && pwd)"
if [[ ! -d "${PROJDIR}/lib/qtil" ]]; then if [[ ! -d "${PROJDIR}/lib/qtil" ]]; then
git clone https://github.com/akiraohgaki/qtil.git -b release-0.3.1 --single-branch --depth=1 "${PROJDIR}/lib/qtil" git clone https://github.com/akiraohgaki/qtil.git -b release-0.4.0 --single-branch --depth=1 "${PROJDIR}/lib/qtil"
fi fi
if [[ ! -d "${PROJDIR}/lib/AppImageUpdate" ]]; then if [[ ! -d "${PROJDIR}/lib/AppImageUpdate" ]]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment