Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • akiraohgaki/ocs-url
  • ab3875o/ocs-url
  • dembego3/ocs-url
  • arakun/ocs-url
  • longviauroy/ocs-url
  • rolfen/ocs-url
  • hemm/ocs-url
  • simonsvw0000/ocs-url
  • dfn2/ocs-url
  • rws77/ocs-url
  • bitwalk/ocs-url
  • visdom/ocs-url
  • ricatfarker/ocs-url
  • mussah/ocs-url
  • tigefa/ocs-url
  • cobalt2727/ocs-url
  • ammark226/ocs-url
  • violethaze74/ocs-url
  • armedssault/ocs-url
  • billflick/ocs-url
  • kimblejeremy/ocs-url
  • yuvrajsm/ocs-url
  • wawmart/ocs-url
  • jhefry/ocs-url
  • robcdntruckin/ocs-url
  • bigmake2266/ocs-url
  • kamil-chbeir/ocs-url
  • jocker73/ocs-url
  • laboties/ocs-url
  • smekke61279-522014/ocs-url
  • coolduck/ocs-url
  • zulfikar-lahiya/ocs-url
  • faz-83/ocs-url
  • dado105/ocs-url
34 results
Show changes
Commits on Source (183)
Showing
with 445 additions and 270 deletions
*.pro.user
build_*/
lib/qtlib/
lib/qtil/
stages:
- build
ubuntu_deb:
stage: build
image: ubuntu:14.04
only:
- master
- /^release\-.+/
script:
- ./scripts/package ubuntu_deb
artifacts:
paths:
- build_*/ocs-url*.deb
expire_in: 2 days
fedora_rpm:
stage: build
image: fedora:20
only:
- master
- /^release\-.+/
script:
- ./scripts/package fedora_rpm
artifacts:
paths:
- build_*/RPMS/x86_64/ocs-url*.rpm
expire_in: 2 days
opensuse_rpm:
stage: build
image: opensuse:42.3
only:
- master
- /^release\-.+/
script:
- ./scripts/package opensuse_rpm
artifacts:
paths:
- build_*/RPMS/x86_64/ocs-url*.rpm
expire_in: 2 days
archlinux_pkg:
stage: build
image: archlinux/base:latest
only:
- master
- /^release\-.+/
script:
- ./scripts/package archlinux_pkg
artifacts:
paths:
- build_*/ocs-url*.pkg.tar.xz
expire_in: 2 days
# ocs-url
An install helper program for items served on OpenCollaborationServices (OCS).
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
Copyright: 2016-2017, Akira Ohgaki
An install helper program for items served via OpenCollaborationServices (ocs://).
Copyright: 2016-2019, Opendesktop.org
License: GPL-3+
Download Linux package from:
https://www.linux-apps.com/p/1136805/
And please check the ocs-url wiki for more information.
https://www.opendesktop.org/p/1136805/
https://github.com/ocs-url/ocs-url/wiki
And please see docs/* for more information.
CONFIG += c++11
QT += \
core \
gui \
widgets \
qml \
quick \
svg
......@@ -16,6 +19,7 @@ SOURCES += \
RESOURCES += \
$${PWD}/configs/configs.qrc \
$${PWD}/images/images.qrc \
$${PWD}/qml/qml.qrc
INCLUDEPATH += $${PWD}/src
{
"id": "ocs-url",
"name": "ocs-url",
"version": "2.0.3",
"organization": "ocs-url",
"domain": "com.ocs-url.ocs-url",
"version": "3.1.0",
"organization": "Opendesktop.org",
"domain": "org.opendesktop.ocs-url",
"icon": ":/desktop/ocs-url.svg",
"description": "An install helper program for items served on OpenCollaborationServices (OCS).",
"description": "An install helper program for items served via OpenCollaborationServices (ocs://).",
"license": "GPL-3+",
"author": "Akira Ohgaki",
"contact": "akiraohgaki@gmail.com",
"homepage": "https://github.com/ocs-url/ocs-url"
"author": "Opendesktop.org",
"contact": "contact@opendesktop.org",
"homepage": "https://git.opendesktop.org/akiraohgaki/ocs-url"
}
{
"bin": {
"name": "Softwares",
"name": "Software",
"destination": "$HOME/.local/bin",
"generic_destination": "$APP_DATA/bin"
},
"downloads": {
"name": "Downloads",
"destination": "$HOME/Downloads",
"destination": "$XDG_DOWNLOAD_DIR",
"generic_destination": "$APP_DATA/downloads"
},
"documents": {
"name": "Documents",
"destination": "$HOME/Documents",
"destination": "$XDG_DOCUMENTS_DIR",
"generic_destination": "$APP_DATA/documents"
},
"pictures": {
"name": "Pictures",
"destination": "$HOME/Pictures",
"destination": "$XDG_PICTURES_DIR",
"generic_destination": "$APP_DATA/pictures"
},
"music": {
"name": "Music",
"destination": "$HOME/Music",
"destination": "$XDG_MUSIC_DIR",
"generic_destination": "$APP_DATA/music"
},
"videos": {
"name": "Videos",
"destination": "$HOME/Videos",
"destination": "$XDG_VIDEOS_DIR",
"generic_destination": "$APP_DATA/videos"
},
"wallpapers": {
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="128" height="128" viewBox="0, 0, 128, 128">
<g id="icon">
<path d="M64,8 C33.072,8 8,33.072 8,64 C8,94.928 33.072,120 64,120 C94.928,120 120,94.928 120,64 C120,33.072 94.928,8 64,8 z M64,24 C68.418,24 72,27.582 72,32 C72,36.418 68.418,40 64,40 C59.582,40 56,36.418 56,32 C56,27.582 59.582,24 64,24 z M48,48 L72,48 L72,96 L80,96 L80,104 L48,104 L48,96 L56,96 L56,56 L48,56 L48,48 z" fill="#000000" id="dialog-information"/>
</g>
</svg>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="128" height="128" viewBox="0, 0, 128, 128">
<g id="icon">
<path d="M64,16 L8,112 L120,112 L64,16 z M56,48 L72,48 L72,80 L56,80 L56,48 z M64,88 C68.418,88 72,91.582 72,96 C72,100.418 68.418,104 64,104 C59.582,104 56,100.418 56,96 C56,91.582 59.582,88 64,88 z" fill="#000000" id="dialog-warning"/>
</g>
</svg>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="128" height="128" viewBox="0, 0, 128, 128">
<g id="icon">
<path d="M64,8 C33.072,8 8,33.072 8,64 C8,94.928 33.072,120 64,120 C94.928,120 120,94.928 120,64 C120,33.072 94.928,8 64,8 z M80,32 L104,32 L56,104 L32,80 L32,56 L56,80 L80,32 z" fill="#000000" id="emblem-default"/>
</g>
</svg>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="128" height="128" viewBox="0, 0, 128, 128">
<g id="icon">
<path d="M40,8 L40,48 L16,48 L64,96 L112,48 L88,48 L88,8 L40,8 z M8,72 L8,120 L120,120 L120,72 L104,72 L104,104 L24,104 L24,72 L8,72 z" fill="#000000" id="emblem-downloads"/>
</g>
</svg>
<RCC>
<qresource prefix="/images">
<file>icons/dialog-information.svg</file>
<file>icons/dialog-warning.svg</file>
<file>icons/emblem-default.svg</file>
<file>icons/emblem-downloads.svg</file>
</qresource>
</RCC>
import QtQuick 2.3
import QtQuick.Window 2.0
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import QtQuick 2.0
import QtQuick.Layouts 1.0
import QtQuick.Controls 1.0
import "ui" as Ui
import "scripts/Utility.js" as Utility
Window {
ApplicationWindow {
id: app
title: Qt.application.name
width: 400
height: 200
minimumWidth: 400
minimumHeight: 200
maximumWidth: 800
maximumHeight: 400
MessageDialog {
id: confirmDialog
title: app.title
icon: StandardIcon.Question
text: ""
informativeText: ""
detailedText: ""
standardButtons: StandardButton.Ok | StandardButton.Cancel
onAccepted: ocsUrlHandler.process()
onRejected: Qt.quit()
}
MessageDialog {
id: infoDialog
title: app.title
icon: StandardIcon.Information
text: ""
informativeText: ""
detailedText: ""
standardButtons: StandardButton.Open | StandardButton.Close
onAccepted: {
ocsUrlHandler.openDestination();
Qt.quit();
}
onRejected: Qt.quit()
}
MessageDialog {
id: errorDialog
title: app.title
icon: StandardIcon.Warning
text: ""
informativeText: ""
detailedText: ""
standardButtons: StandardButton.Close
onRejected: Qt.quit()
}
title: configHandler.getAppConfigApplication().name
Dialog {
id: progressDialog
title: app.title
property alias primaryLabel: primaryLabel
property alias informativeLabel: informativeLabel
property alias progressBar: progressBar
property alias progressLabel: progressLabel
contentItem: Item {
implicitWidth: 400
implicitHeight: 150
Column {
anchors.fill: parent
anchors.margins: 12
spacing: 8
Label {
id: primaryLabel
text: " "
font.bold: true
}
Label {
id: informativeLabel
text: " "
}
ProgressBar {
id: progressBar
maximumValue: 1
minimumValue: 0
value: 0
anchors.left: parent.left
anchors.right: parent.right
}
Label {
id: progressLabel
text: " "
anchors.right: parent.right
}
Button {
id: cancelButton
text: qsTr("Cancel")
anchors.right: parent.right
onClicked: Qt.quit()
}
}
}
}
visible: true
width: 400
minimumWidth: width
maximumWidth: width
height: 200
minimumHeight: height
maximumHeight: height
Component.onCompleted: {
function init() {
var metadata = ocsUrlHandler.metadata();
var primaryMessages = {
"success_download": qsTr("Download successfull"),
"success_install": qsTr("Installation successfull"),
"success_download": qsTr("Download successful"),
"success_install": qsTr("Installation successful"),
"error_validation": qsTr("Validation error"),
"error_network": qsTr("Network error"),
"error_save": qsTr("Saving file failed"),
......@@ -111,12 +32,13 @@ Window {
};
ocsUrlHandler.started.connect(function() {
confirmDialog.close();
progressDialog.open();
});
ocsUrlHandler.finishedWithSuccess.connect(function(result) {
progressDialog.close();
infoDialog.text = primaryMessages[result.status];
infoDialog.primaryText = primaryMessages[result.status];
infoDialog.informativeText = metadata.filename;
infoDialog.detailedText = result.message;
infoDialog.open();
......@@ -124,37 +46,124 @@ Window {
ocsUrlHandler.finishedWithError.connect(function(result) {
progressDialog.close();
errorDialog.text = primaryMessages[result.status];
errorDialog.primaryText = primaryMessages[result.status];
errorDialog.informativeText = metadata.filename;
errorDialog.detailedText = result.message;
errorDialog.open();
});
ocsUrlHandler.downloadProgress.connect(function(id, bytesReceived, bytesTotal) {
progressDialog.primaryLabel.text = qsTr("Downloading");
progressDialog.informativeLabel.text = metadata.filename;
progressDialog.progressBar.value = bytesReceived / bytesTotal;
progressDialog.progressLabel.text = Utility.convertByteToHumanReadable(bytesReceived)
+ " / " + Utility.convertByteToHumanReadable(bytesTotal)
progressDialog.primaryText = qsTr("Downloading");
progressDialog.informativeText = metadata.filename;
progressDialog.detailedContentLoader.item.progressBar = bytesReceived / bytesTotal;
progressDialog.detailedContentLoader.item.progressText
= Utility.convertByteToHumanReadable(bytesReceived)
+ " / " + Utility.convertByteToHumanReadable(bytesTotal);
});
if (ocsUrlHandler.isValid()) {
if (metadata.command === "download") {
confirmDialog.text = qsTr("Do you want to download?");
confirmDialog.primaryText = qsTr("Do you want to download?");
}
else if (metadata.command === "install") {
confirmDialog.text = qsTr("Do you want to install?");
confirmDialog.primaryText = qsTr("Do you want to install?");
}
confirmDialog.informativeText = metadata.filename;
confirmDialog.detailedText = qsTr("URL") + ": " + metadata.url + "\n\n"
+ qsTr("File") + ": " + metadata.filename + "\n\n"
+ qsTr("Type") + ": " + metadata.type;
confirmDialog.detailedText
= qsTr("URL") + ": " + metadata.url + "\n"
+ qsTr("File") + ": " + metadata.filename + "\n"
+ qsTr("Type") + ": " + configHandler.getAppConfigInstallTypes()[metadata.type].name;
confirmDialog.open();
}
else {
errorDialog.text = qsTr("Validation error");
errorDialog.primaryText = primaryMessages["error_validation"];
errorDialog.detailedText = qsTr("Invalid OCS-URL");
errorDialog.open();
}
}
function fixWindowSize(dialog) {
if (dialog.visible) {
app.height = dialog.implicitHeight + (dialog.anchors.margins * 2);
app.minimumHeight = app.height;
app.maximumHeight = app.height;
}
}
Ui.Dialog {
id: confirmDialog
icon: "qrc:/images/icons/dialog-information.svg"
actionButton.text: qsTr("Details")
actionButton.onClicked: toggleDetails()
acceptButton.text: qsTr("OK")
acceptButton.onClicked: ocsUrlHandler.process()
rejectButton.text: qsTr("Cancel")
rejectButton.onClicked: Qt.quit()
onVisibleChanged: app.fixWindowSize(confirmDialog)
onImplicitHeightChanged: app.fixWindowSize(confirmDialog)
}
Ui.Dialog {
id: infoDialog
icon: "qrc:/images/icons/emblem-default.svg"
actionButton.text: qsTr("Details")
actionButton.onClicked: toggleDetails()
acceptButton.text: qsTr("Open")
acceptButton.onClicked: {
ocsUrlHandler.openDestination();
Qt.quit();
}
rejectButton.text: qsTr("Close")
rejectButton.onClicked: Qt.quit()
onVisibleChanged: app.fixWindowSize(infoDialog)
onImplicitHeightChanged: app.fixWindowSize(infoDialog)
}
Ui.Dialog {
id: errorDialog
icon: "qrc:/images/icons/dialog-warning.svg"
actionButton.text: qsTr("Details")
actionButton.onClicked: toggleDetails()
rejectButton.text: qsTr("Close")
rejectButton.onClicked: Qt.quit()
onVisibleChanged: app.fixWindowSize(errorDialog)
onImplicitHeightChanged: app.fixWindowSize(errorDialog)
}
Component {
id: progressComponent
ColumnLayout {
property alias progressBar: progressBar.value
property alias progressText: progressText.text
anchors.fill: parent
spacing: 4
ProgressBar {
id: progressBar
minimumValue: 0
maximumValue: 1
value: 0
Layout.fillWidth: true
}
Label {
id: progressText
text: ""
Layout.alignment: Qt.AlignRight
}
}
}
Ui.Dialog {
id: progressDialog
icon: "qrc:/images/icons/emblem-downloads.svg"
detailsVisible: true
detailedContentLoader.sourceComponent: progressComponent
rejectButton.text: qsTr("Cancel")
rejectButton.onClicked: Qt.quit()
onVisibleChanged: app.fixWindowSize(progressDialog)
onImplicitHeightChanged: app.fixWindowSize(progressDialog)
}
Component.onCompleted: {
app.init();
}
}
<RCC>
<qresource prefix="/qml">
<file>main.qml</file>
<file>ui/Dialog.qml</file>
<file>scripts/Utility.js</file>
</qresource>
</RCC>
import QtQuick 2.0
import QtQuick.Layouts 1.0
import QtQuick.Controls 1.0
ColumnLayout {
id: dialog
visible: false
anchors.fill: parent
anchors.margins: 12
spacing: 12
property alias icon: icon.source
property alias primaryText: primaryText.text
property alias informativeText: informativeText.text
property alias detailsVisible: details.visible
property alias detailedText: detailedText.text
property alias detailedContentLoader: detailedContentLoader
property alias actionButton: actionButton
property alias acceptButton: acceptButton
property alias rejectButton: rejectButton
function open() {
dialog.visible = true;
}
function close() {
dialog.visible = false;
}
function toggleDetails() {
details.visible = details.visible ? false : true;
}
RowLayout {
Layout.fillWidth: true
spacing: 12
Image {
id: icon
source: ""
visible: source.toString() ? true : false
Layout.preferredWidth: 48
Layout.preferredHeight: 48
sourceSize.width: 128
sourceSize.height: 128
}
ColumnLayout {
Layout.fillWidth: true
spacing: 4
Label {
id: primaryText
text: ""
visible: text ? true : false
Layout.fillWidth: true
wrapMode: Text.WrapAnywhere
font.bold: true
font.pixelSize: 14
}
Label {
id: informativeText
text: ""
visible: text ? true : false
Layout.fillWidth: true
wrapMode: Text.WrapAnywhere
}
}
}
ColumnLayout {
id: details
visible: false
Layout.fillWidth: true
Layout.fillHeight: true
spacing: 12
Label {
id: detailedText
text: ""
visible: text ? true : false
Layout.fillWidth: true
wrapMode: Text.WrapAnywhere
}
Loader {
id: detailedContentLoader
visible: (source.toString() || sourceComponent) ? true : false
Layout.fillWidth: true
}
}
RowLayout {
Layout.fillWidth: true
spacing: 4
Button {
id: actionButton
text: ""
visible: text ? true : false
}
Item {
Layout.fillWidth: true
}
Button {
id: acceptButton
text: ""
visible: text ? true : false
}
Button {
id: rejectButton
text: ""
visible: text ? true : false
}
}
}
#include "confighandler.h"
#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();
}
QJsonObject ConfigHandler::getAppConfigApplication()
QJsonObject ConfigHandler::getAppConfigApplication() const
{
if (appConfigApplication_.isEmpty()) {
appConfigApplication_ = appConfig_.get("application");
}
return appConfigApplication_;
}
QJsonObject ConfigHandler::getAppConfigInstallTypes()
QJsonObject ConfigHandler::getAppConfigInstallTypes() const
{
if (appConfigInstallTypes_.isEmpty()) {
QJsonObject installTypes = appConfig_.get("install_types");
foreach (const QString &key, installTypes.keys()) {
QJsonObject installtype = installTypes[key].toObject();
installtype["destination"] = convertPathString(installtype["destination"].toString());
installtype["generic_destination"] = convertPathString(installtype["generic_destination"].toString());
installTypes[key] = installtype;
}
QJsonObject installTypesAlias = appConfig_.get("install_types_alias");
foreach (const QString &key, installTypesAlias.keys()) {
QJsonObject installTypeAlias = installTypesAlias[key].toObject();
QString baseKey = installTypeAlias["base"].toString();
if (installTypes.contains(baseKey)) {
QJsonObject installType = installTypes[baseKey].toObject();
installType["base"] = baseKey;
installType["name"] = installTypeAlias["name"].toString();
installTypes[key] = installType;
}
return appConfigInstallTypes_;
}
void ConfigHandler::importAppConfigApplication()
{
appConfigApplication_ = appConfig_.get("application");
}
void ConfigHandler::importAppConfigInstallTypes()
{
auto installTypes = appConfig_.get("install_types");
for (const auto &key : installTypes.keys()) {
auto installtype = installTypes[key].toObject();
installtype["destination"] = convertPathString(installtype["destination"].toString());
installtype["generic_destination"] = convertPathString(installtype["generic_destination"].toString());
installTypes[key] = installtype;
}
auto installTypesAlias = appConfig_.get("install_types_alias");
for (const auto &key : installTypesAlias.keys()) {
auto installTypeAlias = installTypesAlias[key].toObject();
auto baseKey = installTypeAlias["base"].toString();
if (installTypes.contains(baseKey)) {
auto installType = installTypes[baseKey].toObject();
installType["base"] = baseKey;
installType["name"] = installTypeAlias["name"].toString();
installTypes[key] = installType;
}
appConfigInstallTypes_ = installTypes;
}
return appConfigInstallTypes_;
appConfigInstallTypes_ = installTypes;
}
QString ConfigHandler::convertPathString(const QString &path)
QString ConfigHandler::convertPathString(const QString &path) const
{
QString newPath = path;
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));
}
else if (newPath.contains("$XDG_DOWNLOAD_DIR")) {
newPath.replace("$XDG_DOWNLOAD_DIR", QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
}
else if (newPath.contains("$XDG_PICTURES_DIR")) {
newPath.replace("$XDG_PICTURES_DIR", QStandardPaths::writableLocation(QStandardPaths::PicturesLocation));
}
else if (newPath.contains("$XDG_MUSIC_DIR")) {
newPath.replace("$XDG_MUSIC_DIR", QStandardPaths::writableLocation(QStandardPaths::MusicLocation));
}
else if (newPath.contains("$XDG_VIDEOS_DIR")) {
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,23 +3,25 @@
#include <QObject>
#include <QJsonObject>
#include "qtlib_config.h"
#include "qtil_config.h"
class ConfigHandler : public QObject
{
Q_OBJECT
public:
explicit ConfigHandler(QObject *parent = 0);
explicit ConfigHandler(QObject *parent = nullptr);
public slots:
QJsonObject getAppConfigApplication();
QJsonObject getAppConfigInstallTypes();
QJsonObject getAppConfigApplication() const;
QJsonObject getAppConfigInstallTypes() const;
private:
QString convertPathString(const QString &path);
void importAppConfigApplication();
void importAppConfigInstallTypes();
QString convertPathString(const QString &path) const;
qtlib::Config appConfig_;
Qtil::Config appConfig_;
QJsonObject appConfigApplication_;
QJsonObject appConfigInstallTypes_;
};
......@@ -3,10 +3,10 @@
#include <QUrlQuery>
#include <QDesktopServices>
#include "qtlib_file.h"
#include "qtlib_dir.h"
#include "qtlib_networkresource.h"
#include "qtlib_package.h"
#include "qtil_file.h"
#include "qtil_dir.h"
#include "qtil_networkresource.h"
#include "qtil_package.h"
#include "handlers/confighandler.h"
......@@ -39,15 +39,15 @@ void OcsUrlHandler::process()
return;
}
QString url = metadata_["url"].toString();
qtlib::NetworkResource *resource = new qtlib::NetworkResource(url, QUrl(url), true, this);
connect(resource, &qtlib::NetworkResource::downloadProgress, this, &OcsUrlHandler::downloadProgress);
connect(resource, &qtlib::NetworkResource::finished, this, &OcsUrlHandler::networkResourceFinished);
auto url = metadata_["url"].toString();
auto *resource = new Qtil::NetworkResource(url, QUrl(url), true, this);
connect(resource, &Qtil::NetworkResource::downloadProgress, this, &OcsUrlHandler::downloadProgress);
connect(resource, &Qtil::NetworkResource::finished, this, &OcsUrlHandler::networkResourceFinished);
resource->get();
emit started();
}
bool OcsUrlHandler::isValid()
bool OcsUrlHandler::isValid() const
{
QString scheme = metadata_["scheme"].toString();
QString command = metadata_["command"].toString();
......@@ -55,8 +55,7 @@ bool OcsUrlHandler::isValid()
QString type = metadata_["type"].toString();
QString filename = metadata_["filename"].toString();
// Still support xdg and xdgs schemes for backward compatibility
if ((scheme == "ocs" || scheme == "ocss" || scheme == "xdg" || scheme == "xdgs")
if ((scheme == "ocs" || scheme == "ocss")
&& (command == "download" || command == "install")
&& QUrl(url).isValid()
&& configHandler_->getAppConfigInstallTypes().contains(type)
......@@ -66,13 +65,13 @@ bool OcsUrlHandler::isValid()
return false;
}
void OcsUrlHandler::openDestination()
void OcsUrlHandler::openDestination() const
{
QString type = metadata_["type"].toString();
auto type = metadata_["type"].toString();
QDesktopServices::openUrl(QUrl("file://" + configHandler_->getAppConfigInstallTypes()[type].toObject()["destination"].toString()));
}
void OcsUrlHandler::networkResourceFinished(qtlib::NetworkResource *resource)
void OcsUrlHandler::networkResourceFinished(Qtil::NetworkResource *resource)
{
if (!resource->isFinishedWithNoError()) {
QJsonObject result;
......@@ -127,14 +126,14 @@ void OcsUrlHandler::parse()
}
}
void OcsUrlHandler::saveDownloadedFile(qtlib::NetworkResource *resource)
void OcsUrlHandler::saveDownloadedFile(Qtil::NetworkResource *resource)
{
QJsonObject result;
QString type = metadata_["type"].toString();
qtlib::Dir destDir(configHandler_->getAppConfigInstallTypes()[type].toObject()["destination"].toString());
auto type = metadata_["type"].toString();
Qtil::Dir destDir(configHandler_->getAppConfigInstallTypes()[type].toObject()["destination"].toString());
destDir.make();
qtlib::File destFile(destDir.path() + "/" + metadata_["filename"].toString());
Qtil::File destFile(destDir.path() + "/" + metadata_["filename"].toString());
if (!resource->saveData(destFile.path())) {
result["status"] = QString("error_save");
......@@ -151,11 +150,11 @@ void OcsUrlHandler::saveDownloadedFile(qtlib::NetworkResource *resource)
resource->deleteLater();
}
void OcsUrlHandler::installDownloadedFile(qtlib::NetworkResource *resource)
void OcsUrlHandler::installDownloadedFile(Qtil::NetworkResource *resource)
{
QJsonObject result;
qtlib::File tempFile(qtlib::Dir::tempPath() + "/" + metadata_["filename"].toString());
Qtil::File tempFile(Qtil::Dir::tempPath() + "/" + metadata_["filename"].toString());
if (!resource->saveData(tempFile.path())) {
result["status"] = QString("error_save");
......@@ -165,11 +164,11 @@ void OcsUrlHandler::installDownloadedFile(qtlib::NetworkResource *resource)
return;
}
qtlib::Package package(tempFile.path());
QString type = metadata_["type"].toString();
qtlib::Dir destDir(configHandler_->getAppConfigInstallTypes()[type].toObject()["destination"].toString());
Qtil::Package package(tempFile.path());
auto type = metadata_["type"].toString();
Qtil::Dir destDir(configHandler_->getAppConfigInstallTypes()[type].toObject()["destination"].toString());
destDir.make();
qtlib::File destFile(destDir.path() + "/" + metadata_["filename"].toString());
Qtil::File destFile(destDir.path() + "/" + metadata_["filename"].toString());
if (type == "bin"
&& package.installAsProgram(destFile.path())) {
......
......@@ -3,7 +3,7 @@
#include <QObject>
#include <QJsonObject>
namespace qtlib {
namespace Qtil {
class NetworkResource;
}
......@@ -14,7 +14,7 @@ class OcsUrlHandler : public QObject
Q_OBJECT
public:
explicit OcsUrlHandler(const QString &ocsUrl, ConfigHandler *configHandler, QObject *parent = 0);
explicit OcsUrlHandler(const QString &ocsUrl, ConfigHandler *configHandler, QObject *parent = nullptr);
signals:
void started();
......@@ -27,16 +27,16 @@ public slots:
QJsonObject metadata() const;
void process();
bool isValid();
void openDestination();
bool isValid() const;
void openDestination() const;
private slots:
void networkResourceFinished(qtlib::NetworkResource *resource);
void networkResourceFinished(Qtil::NetworkResource *resource);
private:
void parse();
void saveDownloadedFile(qtlib::NetworkResource *resource);
void installDownloadedFile(qtlib::NetworkResource *resource);
void saveDownloadedFile(Qtil::NetworkResource *resource);
void installDownloadedFile(Qtil::NetworkResource *resource);
QString ocsUrl_;
ConfigHandler *configHandler_;
......
......@@ -18,8 +18,8 @@ int main(int argc, char *argv[])
// Init
QApplication app(argc, argv);
ConfigHandler *configHandler = new ConfigHandler();
QJsonObject appConfigApplication = configHandler->getAppConfigApplication();
auto *configHandler = new ConfigHandler();
auto appConfigApplication = configHandler->getAppConfigApplication();
app.setApplicationName(appConfigApplication["name"].toString());
app.setApplicationVersion(appConfigApplication["version"].toString());
......@@ -41,17 +41,17 @@ int main(int argc, char *argv[])
clParser.addPositionalArgument("OCS-URL", "OCS-URL that starts with ocs://");
clParser.process(app);
QStringList args = clParser.positionalArguments();
auto args = clParser.positionalArguments();
if (args.size() != 1) {
clParser.showHelp(1);
}
QString ocsUrl = args.at(0);
auto ocsUrl = QString(args.at(0));
// Setup QML
QQmlApplicationEngine qmlAppEngine;
QQmlContext *qmlContext = qmlAppEngine.rootContext();
auto *qmlContext = qmlAppEngine.rootContext();
configHandler->setParent(&qmlAppEngine);
qmlContext->setContextProperty("configHandler", configHandler);
qmlContext->setContextProperty("ocsUrlHandler", new OcsUrlHandler(ocsUrl, configHandler, &qmlAppEngine));
......
pipelines:
custom:
build-ubuntu:
- step:
image: ubuntu:14.04
script:
- apt update -qq
- apt -y install sudo git curl
- apt -y install build-essential qt5-default libqt5svg5-dev qtdeclarative5-dev
- apt -y install devscripts debhelper fakeroot
- useradd -m pkgbuilder
- export HOME=/home/pkgbuilder
- chown -R pkgbuilder:pkgbuilder $(pwd)
- sudo -u pkgbuilder sh scripts/build.sh ubuntu
build-fedora:
- step:
image: fedora:20
script:
# dnf >= fedora:22
- yum -y install sudo git curl
- yum -y install make automake gcc gcc-c++ libtool qt5-qtbase-devel qt5-qtsvg-devel qt5-qtdeclarative-devel
- yum -y install rpm-build
- useradd -m pkgbuilder
- export HOME=/home/pkgbuilder
- chown -R pkgbuilder:pkgbuilder $(pwd)
- sudo -u pkgbuilder sh scripts/build.sh fedora
build-archlinux:
- step:
image: finalduty/archlinux:latest
script:
- pacman -Syu --noconfirm
- pacman -S --noconfirm sudo git curl
- pacman -S --noconfirm base-devel qt5-base qt5-svg qt5-declarative qt5-quickcontrols
- useradd -m pkgbuilder
- export HOME=/home/pkgbuilder
- chown -R pkgbuilder:pkgbuilder $(pwd)
- sudo -u pkgbuilder sh scripts/build.sh archlinux
build-snap:
- step:
image: ubuntu:16.04
script:
- apt update -qq
- apt -y install sudo git curl
- apt -y install build-essential qt5-default libqt5svg5-dev qtdeclarative5-dev
- apt -y install snapcraft
- useradd -m pkgbuilder
- export HOME=/home/pkgbuilder
- chown -R pkgbuilder:pkgbuilder $(pwd)
- sudo -u pkgbuilder sh scripts/build.sh snap
build-appimage:
- step:
image: ubuntu:14.04
script:
# Require docker run with --cap-add SYS_ADMIN --device /dev/fuse
- echo 'appimage build is disabled currently'
- exit 1
- apt update -qq
- apt -y install sudo git curl
- apt -y install build-essential qt5-default libqt5svg5-dev qtdeclarative5-dev
- apt -y install fuse zsync desktop-file-utils
#- modprobe fuse
- useradd -m pkgbuilder
- export HOME=/home/pkgbuilder
- chown -R pkgbuilder:pkgbuilder $(pwd)
- sudo -u pkgbuilder sh scripts/build.sh appimage