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

Merge pull request #24 from opendesktop/develop

Develop
parents e056cd69 b220c8fe
No related branches found
No related tags found
No related merge requests found
Showing with 76 additions and 76 deletions
*.pro.user
build_*/
lib/qtlib/
lib/qtil/
lib/AppImageUpdate/
lib/AppImageUpdate-prebuilt/
......@@ -3,15 +3,15 @@
#include <QStringList>
#include <QStandardPaths>
#include "qtlib_dir.h"
#include "qtil_dir.h"
ConfigHandler::ConfigHandler(QObject *parent)
: QObject(parent)
{
appConfig_ = qtlib::Config(":/configs");
appConfig_ = qtil::Config(":/configs");
importAppConfigApplication();
importAppConfigInstallTypes();
usrConfig_ = qtlib::Config(qtlib::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", qtlib::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", qtlib::Dir::genericDataPath());
newPath.replace("$XDG_DATA_HOME", qtil::Dir::genericDataPath());
}
else if (newPath.contains("$KDEHOME")) {
newPath.replace("$KDEHOME", qtlib::Dir::kdehomePath());
newPath.replace("$KDEHOME", qtil::Dir::kdehomePath());
}
else if (newPath.contains("$APP_DATA")) {
newPath.replace("$APP_DATA", qtlib::Dir::genericDataPath() + "/" + getAppConfigApplication()["id"].toString());
newPath.replace("$APP_DATA", qtil::Dir::genericDataPath() + "/" + getAppConfigApplication()["id"].toString());
}
return newPath;
}
......@@ -3,7 +3,7 @@
#include <QObject>
#include <QJsonObject>
#include "qtlib_config.h"
#include "qtil_config.h"
class ConfigHandler : public QObject
{
......@@ -42,8 +42,8 @@ private:
void importAppConfigInstallTypes();
QString convertPathString(const QString &path) const;
qtlib::Config appConfig_;
qtlib::Config usrConfig_;
qtil::Config appConfig_;
qtil::Config usrConfig_;
QJsonObject appConfigApplication_;
QJsonObject appConfigInstallTypes_;
};
......@@ -2,7 +2,7 @@
#include <QStringList>
#ifdef QTLIB_UNIX
#ifdef QTIL_OS_UNIX
#include <QFileInfo>
#include "desktopthemes/kdetheme.h"
......@@ -98,7 +98,7 @@ bool DesktopThemeHandler::isApplicableType(const QString &installType) const
bool DesktopThemeHandler::applyTheme(const QString &path, const QString &installType) const
{
#ifdef QTLIB_UNIX
#ifdef QTIL_OS_UNIX
if (QFileInfo::exists(path) && isApplicableType(installType)) {
auto desktop = desktopEnvironment();
......
......@@ -6,14 +6,14 @@
#include <QFileInfo>
#include <QDateTime>
#ifdef QTLIB_UNIX
#ifdef QTIL_OS_UNIX
#include <QProcess>
#endif
#include "qtlib_dir.h"
#include "qtlib_file.h"
#include "qtlib_networkresource.h"
#include "qtlib_package.h"
#include "qtil_dir.h"
#include "qtil_file.h"
#include "qtil_networkresource.h"
#include "qtil_package.h"
#include "handlers/confighandler.h"
......@@ -67,9 +67,9 @@ void ItemHandler::getItem(const QString &command, const QString &url, const QStr
itemMetadataSet[itemKey] = metadata;
setMetadataSet(itemMetadataSet);
auto *resource = new qtlib::NetworkResource(itemKey, QUrl(url), true, this);
connect(resource, &qtlib::NetworkResource::downloadProgress, this, &ItemHandler::downloadProgress);
connect(resource, &qtlib::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");
......@@ -146,8 +146,8 @@ void ItemHandler::uninstall(const QString &itemKey)
auto installedItem = configHandler_->getUsrConfigInstalledItems()[itemKey].toObject();
auto installType = installedItem["install_type"].toString();
qtlib::Dir destDir;
#ifdef QTLIB_UNIX
qtil::Dir destDir;
#ifdef QTIL_OS_UNIX
destDir.setPath(configHandler_->getAppConfigInstallTypes()[installType].toObject()["destination"].toString());
for (const auto &filename : installedItem["files"].toArray()) {
......@@ -155,7 +155,7 @@ void ItemHandler::uninstall(const QString &itemKey)
// plasmapkg: Installation process has should be saved plasmapkg into destination directory
qtlib::Package package(fileInfo.filePath());
qtil::Package package(fileInfo.filePath());
// Uninstall
if (installType == "bin") {
......@@ -186,10 +186,10 @@ void ItemHandler::uninstall(const QString &itemKey)
// Remove file
if (fileInfo.isDir()) {
qtlib::Dir(fileInfo.filePath()).remove();
qtil::Dir(fileInfo.filePath()).remove();
}
else {
qtlib::File(fileInfo.filePath()).remove();
qtil::File(fileInfo.filePath()).remove();
}
}
#else
......@@ -198,10 +198,10 @@ void ItemHandler::uninstall(const QString &itemKey)
for (const auto &filename : installedItem["files"].toArray()) {
QFileInfo fileInfo(destDir.path() + "/" + filename.toString());
if (fileInfo.isDir()) {
qtlib::Dir(fileInfo.filePath()).remove();
qtil::Dir(fileInfo.filePath()).remove();
}
else {
qtlib::File(fileInfo.filePath()).remove();
qtil::File(fileInfo.filePath()).remove();
}
}
#endif
......@@ -214,7 +214,7 @@ void ItemHandler::uninstall(const QString &itemKey)
emit uninstallFinished(result);
}
void ItemHandler::networkResourceFinished(qtlib::NetworkResource *resource)
void ItemHandler::networkResourceFinished(qtil::NetworkResource *resource)
{
auto itemKey = resource->id();
......@@ -252,7 +252,7 @@ void ItemHandler::setMetadataSet(const QJsonObject &metadataSet)
emit metadataSetChanged();
}
void ItemHandler::saveDownloadedFile(qtlib::NetworkResource *resource)
void ItemHandler::saveDownloadedFile(qtil::NetworkResource *resource)
{
auto itemKey = resource->id();
......@@ -271,9 +271,9 @@ void ItemHandler::saveDownloadedFile(qtlib::NetworkResource *resource)
auto filename = metadata["filename"].toString();
auto installType = metadata["install_type"].toString();
qtlib::Dir destDir(configHandler_->getAppConfigInstallTypes()[installType].toObject()["destination"].toString());
qtil::Dir destDir(configHandler_->getAppConfigInstallTypes()[installType].toObject()["destination"].toString());
destDir.make();
qtlib::File destFile(destDir.path() + "/" + filename);
qtil::File destFile(destDir.path() + "/" + filename);
if (destFile.exists()) {
auto filenamePrefix = QString::number(QDateTime::currentMSecsSinceEpoch()) + "_";
......@@ -295,7 +295,7 @@ void ItemHandler::saveDownloadedFile(qtlib::NetworkResource *resource)
resource->deleteLater();
}
void ItemHandler::installDownloadedFile(qtlib::NetworkResource *resource)
void ItemHandler::installDownloadedFile(qtil::NetworkResource *resource)
{
// Installation pre-process
auto itemKey = resource->id();
......@@ -316,13 +316,13 @@ void ItemHandler::installDownloadedFile(qtlib::NetworkResource *resource)
auto installType = metadata["install_type"].toString();
QString tempDirPrefix = "temp_" + filename;
qtlib::Dir tempDir(qtlib::Dir::genericCachePath() + "/"
qtil::Dir tempDir(qtil::Dir::genericCachePath() + "/"
+ configHandler_->getAppConfigApplication()["id"].toString() + "/"
+ tempDirPrefix);
tempDir.make();
qtlib::Dir tempDestDir(tempDir.path() + "/dest");
qtil::Dir tempDestDir(tempDir.path() + "/dest");
tempDestDir.make();
qtlib::Package package(tempDir.path() + "/" + filename);
qtil::Package package(tempDir.path() + "/" + filename);
if (!resource->saveData(package.path())) {
result["status"] = QString("error_save");
......@@ -342,8 +342,8 @@ void ItemHandler::installDownloadedFile(qtlib::NetworkResource *resource)
result["message"] = tr("Installing");
emit installStarted(result);
qtlib::Dir destDir;
#ifdef QTLIB_UNIX
qtil::Dir destDir;
#ifdef QTIL_OS_UNIX
destDir.setPath(configHandler_->getAppConfigInstallTypes()[installType].toObject()["destination"].toString());
// plasmapkg: Need to save package to remove installed files later
......@@ -399,7 +399,7 @@ void ItemHandler::installDownloadedFile(qtlib::NetworkResource *resource)
#else
destDir.setPath(configHandler_->getAppConfigInstallTypes()[installType].toObject()["generic_destination"].toString());
if (qtlib::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 {
......@@ -424,10 +424,10 @@ void ItemHandler::installDownloadedFile(qtlib::NetworkResource *resource)
}
if (fileInfo.isDir()) {
qtlib::Dir(fileInfo.filePath()).move(destDir.path() + "/" + destFilename);
qtil::Dir(fileInfo.filePath()).move(destDir.path() + "/" + destFilename);
}
else {
qtlib::File(fileInfo.filePath()).move(destDir.path() + "/" + destFilename);
qtil::File(fileInfo.filePath()).move(destDir.path() + "/" + destFilename);
}
installedFiles.append(QJsonValue(destFilename));
......
......@@ -3,7 +3,7 @@
#include <QObject>
#include <QJsonObject>
namespace qtlib {
namespace qtil {
class NetworkResource;
}
......@@ -37,13 +37,13 @@ public slots:
void uninstall(const QString &itemKey);
private slots:
void networkResourceFinished(qtlib::NetworkResource *resource);
void networkResourceFinished(qtil::NetworkResource *resource);
private:
void setMetadataSet(const QJsonObject &metadataSet);
void saveDownloadedFile(qtlib::NetworkResource *resource);
void installDownloadedFile(qtlib::NetworkResource *resource);
void saveDownloadedFile(qtil::NetworkResource *resource);
void installDownloadedFile(qtil::NetworkResource *resource);
ConfigHandler *configHandler_;
QJsonObject metadataSet_;
......
......@@ -3,7 +3,7 @@
#include <QStringList>
#include <QJsonValue>
#include "qtlib_ocsapi.h"
#include "qtil_ocsapi.h"
#include "handlers/confighandler.h"
......@@ -13,7 +13,7 @@ OcsApiHandler::OcsApiHandler(ConfigHandler *configHandler, QObject *parent)
bool OcsApiHandler::addProviders(const QString &providerFileUrl) const
{
auto providers = qtlib::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 = qtlib::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] = qtlib::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 = qtlib::OcsApi(baseUrl, QUrl(baseUrl)).getContentData(contentId);
response = qtil::OcsApi(baseUrl, QUrl(baseUrl)).getContentData(contentId);
}
return response;
}
......@@ -3,13 +3,13 @@
#include <QUrl>
#include <QDesktopServices>
#ifdef QTLIB_UNIX
#ifdef QTIL_OS_UNIX
#include <QFileInfo>
#include <QProcess>
#endif
#ifdef Q_OS_ANDROID
#include "qtlib_package.h"
#include "qtil_package.h"
#endif
SystemHandler::SystemHandler(QObject *parent)
......@@ -18,7 +18,7 @@ SystemHandler::SystemHandler(QObject *parent)
bool SystemHandler::isUnix() const
{
#ifdef QTLIB_UNIX
#ifdef QTIL_OS_UNIX
return true;
#endif
return false;
......@@ -42,7 +42,7 @@ bool SystemHandler::openUrl(const QString &url) const
path.replace("file://localhost", "", Qt::CaseInsensitive);
path.replace("file://", "", Qt::CaseInsensitive);
#ifdef QTLIB_UNIX
#ifdef QTIL_OS_UNIX
if ((path.endsWith(".appimage", Qt::CaseInsensitive) || path.endsWith(".exe", Qt::CaseInsensitive))
&& QFileInfo(path).isExecutable()) {
return QProcess::startDetached(path);
......@@ -51,7 +51,7 @@ bool SystemHandler::openUrl(const QString &url) const
#ifdef Q_OS_ANDROID
if (path.endsWith(".apk", Qt::CaseInsensitive)) {
return qtlib::Package(path).installAsApk();
return qtil::Package(path).installAsApk();
}
#endif
......
......@@ -5,11 +5,11 @@
#include <QJsonArray>
#include <QDateTime>
#include "qtlib_file.h"
#include "qtil_file.h"
#include "handlers/confighandler.h"
#ifdef QTLIB_UNIX
#ifdef QTIL_OS_UNIX
#include "updaters/appimageupdater.h"
#endif
......@@ -38,7 +38,7 @@ void UpdateHandler::checkAll()
auto installType = installedItem["install_type"].toString();
QString filePath = "";
#ifdef QTLIB_UNIX
#ifdef QTIL_OS_UNIX
filePath = configHandler_->getAppConfigInstallTypes()[installType].toObject()["destination"].toString() + "/" + filename;
#else
filePath = configHandler_->getAppConfigInstallTypes()[installType].toObject()["generic_destination"].toString() + "/" + filename;
......@@ -47,7 +47,7 @@ void UpdateHandler::checkAll()
QString updateMethod = "";
if (installType == "bin") {
#ifdef QTLIB_UNIX
#ifdef QTIL_OS_UNIX
if (filePath.endsWith(".appimage", Qt::CaseInsensitive)) {
if (AppImageUpdater(itemKey, filePath).checkForChanges()) {
updateMethod = "appimageupdate";
......@@ -86,7 +86,7 @@ void UpdateHandler::update(const QString &itemKey)
auto updateMethod = updateAvailableItems[itemKey].toObject()["update_method"].toString();
#ifdef QTLIB_UNIX
#ifdef QTIL_OS_UNIX
if (updateMethod == "appimageupdate") {
updateAppImage(itemKey);
}
......@@ -96,7 +96,7 @@ void UpdateHandler::update(const QString &itemKey)
#endif
}
#ifdef QTLIB_UNIX
#ifdef QTIL_OS_UNIX
void UpdateHandler::appImageUpdaterFinished(AppImageUpdater *updater)
{
auto itemKey = updater->id();
......@@ -124,7 +124,7 @@ void UpdateHandler::appImageUpdaterFinished(AppImageUpdater *updater)
configHandler_->setUsrConfigInstalledItemsItem(installedItemKey, installedItem);
if (newFilename != filename) {
qtlib::File(updater->path()).remove();
qtil::File(updater->path()).remove();
}
configHandler_->removeUsrConfigUpdateAvailableItemsItem(itemKey);
......@@ -134,7 +134,7 @@ void UpdateHandler::appImageUpdaterFinished(AppImageUpdater *updater)
}
#endif
#ifdef QTLIB_UNIX
#ifdef QTIL_OS_UNIX
void UpdateHandler::updateAppImage(const QString &itemKey)
{
auto updateAvailableItem = configHandler_->getUsrConfigUpdateAvailableItems()[itemKey].toObject();
......
......@@ -5,7 +5,7 @@
class ConfigHandler;
#ifdef QTLIB_UNIX
#ifdef QTIL_OS_UNIX
class AppImageUpdater;
#endif
......@@ -28,12 +28,12 @@ public slots:
void update(const QString &itemKey);
private slots:
#ifdef QTLIB_UNIX
#ifdef QTIL_OS_UNIX
void appImageUpdaterFinished(AppImageUpdater *updater);
#endif
private:
#ifdef QTLIB_UNIX
#ifdef QTIL_OS_UNIX
void updateAppImage(const QString &itemKey);
#endif
......
......@@ -16,7 +16,7 @@ int main(int argc, char *argv[])
// Init
QGuiApplication app(argc, argv); // This is backend program, but need GUI module
auto envPath = app.applicationDirPath() + ":" + QString::fromLocal8Bit(qgetenv("PATH").constData());
auto envPath = QString::fromLocal8Bit(qgetenv("PATH").constData()) + ":" + app.applicationDirPath();
qputenv("PATH", envPath.toUtf8().constData());
auto *configHandler = new ConfigHandler(&app);
......
......@@ -4,7 +4,7 @@
#include <QWebSocketServer>
#include <QWebSocket>
#include "qtlib_json.h"
#include "qtil_json.h"
#include "handlers/confighandler.h"
#include "handlers/systemhandler.h"
......@@ -108,7 +108,7 @@ void WebSocketServer::wsTextMessageReceived(const QString &message)
{
auto *wsClient = qobject_cast<QWebSocket *>(sender());
if (wsClient) {
qtlib::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());
......@@ -120,7 +120,7 @@ void WebSocketServer::wsBinaryMessageReceived(const QByteArray &message)
{
auto *wsClient = qobject_cast<QWebSocket *>(sender());
if (wsClient) {
qtlib::Json json(message);
qtil::Json json(message);
if (json.isObject()) {
auto object = json.toObject();
receiveMessage(object["id"].toString(), object["func"].toString(), object["data"].toArray());
......@@ -411,7 +411,7 @@ void WebSocketServer::sendMessage(const QString &id, const QString &func, const
object["func"] = func;
object["data"] = data;
auto binaryMessage = qtlib::Json(object).toJson();
auto binaryMessage = qtil::Json(object).toJson();
auto textMessage = QString::fromUtf8(binaryMessage);
for (auto *wsClient : wsClients_) {
......
include($${PWD}/qtlib/qtlib.pri)
include($${PWD}/qtil/qtil.pri)
unix:!ios:!android {
INCLUDEPATH += $${PWD}/AppImageUpdate/include
......
......@@ -8,7 +8,7 @@ curl -L -o linuxdeployqt "https://github.com/probonopd/linuxdeployqt/releases/do
chmod 755 linuxdeployqt
./linuxdeployqt --appimage-extract
sh scripts/import.sh
sh scripts/prepare.sh
qmake PREFIX="/usr"
make
make INSTALL_ROOT="${PKGNAME}.AppDir" install
......
......@@ -2,8 +2,8 @@
PROJDIR="$(cd "$(dirname "${0}")/../" && pwd)"
if [ ! -d "${PROJDIR}/lib/qtlib" ]; then
git clone https://github.com/akiraohgaki/qtlib.git -b release-0.2.1 --single-branch --depth=1 "${PROJDIR}/lib/qtlib"
if [ ! -d "${PROJDIR}/lib/qtil" ]; then
git clone https://github.com/akiraohgaki/qtil.git -b release-0.3.0 --single-branch --depth=1 "${PROJDIR}/lib/qtil"
fi
if [ ! -d "${PROJDIR}/lib/AppImageUpdate" ]; then
......
DISTFILES += \
$${PWD}/build-docker.sh \
$${PWD}/build.sh \
$${PWD}/import.sh
$${PWD}/prepare.sh
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