Skip to content
Snippets Groups Projects
Commit 0b7c93e7 authored by akiraohgaki's avatar akiraohgaki
Browse files

xdgurl to ocs-url

parent 38e4c22d
No related branches found
No related tags found
No related merge requests found
Showing
with 103 additions and 85 deletions
# xdgurl
# ocs-url
An install helper program for desktop stuff.
......@@ -10,6 +10,6 @@ Download Linux package from:
https://www.linux-apps.com/p/1136805/
And please check the xdgurl wiki for more information.
And please check the ocs-url wiki for more information.
https://github.com/xdgurl/xdgurl/wiki
https://github.com/ocs-url/ocs-url/wiki
TARGET = xdgurl
TARGET = ocs-url
TEMPLATE = app
......@@ -10,18 +10,18 @@ RESOURCES += src/desktop/desktop.qrc
DISTFILES += \
README.md \
src/desktop/xdgurl.desktop \
src/desktop/ocs-url.desktop \
pkg/build.sh \
pkg/ubuntu/debian/changelog \
pkg/ubuntu/debian/compat \
pkg/ubuntu/debian/control \
pkg/ubuntu/debian/copyright \
pkg/ubuntu/debian/rules \
pkg/ubuntu/debian/xdgurl.install \
pkg/fedora/xdgurl.spec \
pkg/ubuntu/debian/ocs-url.install \
pkg/fedora/ocs-url.spec \
pkg/arch/PKGBUILD \
pkg/snap/snapcraft.yaml \
pkg/snap/setup/gui/xdgurl.desktop \
pkg/snap/setup/gui/ocs-url.desktop \
pkg/appimage/appimage-desktopintegration
include(deployment.pri)
......
......@@ -25,7 +25,7 @@ VENDORPREFIX=appimagekit
APPDIR="$(dirname "$(readlink -f "${THIS}")")"
BIN="${APPDIR}/xdgurl"
BIN="${APPDIR}/ocs-url"
export PATH="${APPDIR}/usr/bin:$PATH"
trap atexit EXIT
......
# Maintainer: Akira Ohgaki <akiraohgaki@gmail.com>
pkgname='xdgurl'
pkgname='ocs-url'
pkgver='2.0.3'
pkgrel='1'
pkgdesc='An install helper program for desktop stuff.'
arch=('i686' 'x86_64')
url='https://github.com/xdgurl/xdgurl'
url='https://github.com/ocs-url/ocs-url'
license=('GPL3')
depends=('qt5-base>=5.3.0' 'qt5-svg>=5.3.0' 'qt5-declarative>=5.3.0' 'qt5-quickcontrols>=5.3.0')
#source=("https://github.com/xdgurl/xdgurl/archive/release-${pkgver}.tar.gz")
#source=("https://github.com/ocs-url/ocs-url/archive/release-${pkgver}.tar.gz")
source=("${pkgname}.tar.gz")
md5sums=() #autofill using updpkgsums
......
#!/bin/bash
PKGNAME='xdgurl'
PKGNAME='ocs-url'
PROJDIR="$(cd "$(dirname "${0}")/../" && pwd)"
......@@ -47,9 +47,9 @@ build_fedora() {
mkdir "${BUILDDIR}/SOURCES"
mkdir "${BUILDDIR}/SPECS"
export_source "${BUILDDIR}/SOURCES"
cp "${PROJDIR}/pkg/fedora/xdgurl.spec" "${BUILDDIR}/SPECS"
cp "${PROJDIR}/pkg/fedora/ocs-url.spec" "${BUILDDIR}/SPECS"
rpmbuild --define "_topdir ${BUILDDIR}" -bb "${BUILDDIR}/SPECS/xdgurl.spec"
rpmbuild --define "_topdir ${BUILDDIR}" -bb "${BUILDDIR}/SPECS/ocs-url.spec"
}
build_arch() {
......@@ -103,18 +103,18 @@ build_appimage() {
#qmake
/opt/qt57/bin/qmake
make
strip ./xdgurl
strip ./ocs-url
cd "${BUILDDIR}"
mkdir -p "${BUILDDIR}/${PKGNAME}.AppDir/usr/bin"
install -m 755 -p "${BUILDDIR}/${PKGNAME}/xdgurl" "${BUILDDIR}/${PKGNAME}.AppDir/xdgurl"
install -m 644 -p "${BUILDDIR}/${PKGNAME}/src/desktop/xdgurl.desktop" "${BUILDDIR}/${PKGNAME}.AppDir/xdgurl.desktop"
install -m 644 -p "${BUILDDIR}/${PKGNAME}/src/desktop/xdgurl.svg" "${BUILDDIR}/${PKGNAME}.AppDir/xdgurl.svg"
install -m 755 -p "${BUILDDIR}/${PKGNAME}/ocs-url" "${BUILDDIR}/${PKGNAME}.AppDir/ocs-url"
install -m 644 -p "${BUILDDIR}/${PKGNAME}/src/desktop/ocs-url.desktop" "${BUILDDIR}/${PKGNAME}.AppDir/ocs-url.desktop"
install -m 644 -p "${BUILDDIR}/${PKGNAME}/src/desktop/ocs-url.svg" "${BUILDDIR}/${PKGNAME}.AppDir/ocs-url.svg"
install -m 755 -p /usr/bin/update-desktop-database "${BUILDDIR}/${PKGNAME}.AppDir/usr/bin/update-desktop-database"
install -m 755 -p /usr/bin/desktop-file-validate "${BUILDDIR}/${PKGNAME}.AppDir/usr/bin/desktop-file-validate"
install -m 755 -p /usr/bin/desktop-file-install "${BUILDDIR}/${PKGNAME}.AppDir/usr/bin/desktop-file-install"
linuxdeployqt "${BUILDDIR}/${PKGNAME}.AppDir/xdgurl" -qmldir="${BUILDDIR}/${PKGNAME}/src/app/qml" -verbose=2 -bundle-non-qt-libs # https://github.com/probonopd/linuxdeployqt/issues/25
linuxdeployqt "${BUILDDIR}/${PKGNAME}.AppDir/xdgurl" -qmldir="${BUILDDIR}/${PKGNAME}/src/app/qml" -verbose=2 -bundle-non-qt-libs # twice because of #25
linuxdeployqt "${BUILDDIR}/${PKGNAME}.AppDir/ocs-url" -qmldir="${BUILDDIR}/${PKGNAME}/src/app/qml" -verbose=2 -bundle-non-qt-libs # https://github.com/probonopd/linuxdeployqt/issues/25
linuxdeployqt "${BUILDDIR}/${PKGNAME}.AppDir/ocs-url" -qmldir="${BUILDDIR}/${PKGNAME}/src/app/qml" -verbose=2 -bundle-non-qt-libs # twice because of #25
rm "${BUILDDIR}/${PKGNAME}.AppDir/AppRun"
install -m 755 -p "${BUILDDIR}/${PKGNAME}/pkg/appimage/appimage-desktopintegration" "${BUILDDIR}/${PKGNAME}.AppDir/AppRun"
linuxdeployqt --appimage-extract
......
Summary: An install helper program for desktop stuff
Name: xdgurl
Name: ocs-url
Version: 2.0.3
Release: 1%{?dist}
License: GPLv3+
Group: Applications/Internet
URL: https://github.com/xdgurl/xdgurl
URL: https://github.com/ocs-url/ocs-url
#Source0: https://github.com/xdgurl/xdgurl/archive/release-%{version}.tar.gz
#Source0: https://github.com/ocs-url/ocs-url/archive/release-%{version}.tar.gz
Source0: %{name}.tar.gz
Requires: qt5-qtbase >= 5.3.0, qt5-qtbase-gui >= 5.3.0, qt5-qtsvg >= 5.3.0, qt5-qtdeclarative >= 5.3.0, qt5-qtquickcontrols >= 5.3.0
......
[Desktop Entry]
Name=xdgurl
Exec=xdgurl.xdgurl %u
Icon=${SNAP}/usr/share/icons/hicolor/scalable/apps/xdgurl.svg
Name=ocs-url
Exec=ocs-url.ocs-url %u
Icon=${SNAP}/usr/share/icons/hicolor/scalable/apps/ocs-url.svg
Type=Application
Terminal=false
NoDisplay=true
Categories=Network;Utility;
MimeType=x-scheme-handler/xdg;x-scheme-handler/xdgs;
MimeType=x-scheme-handler/ocs;x-scheme-handler/ocss;
name: xdgurl
name: ocs-url
version: '2.0.3'
summary: An install helper program for desktop stuff
description: |
......@@ -7,10 +7,10 @@ description: |
grade: devel
confinement: strict
#icon: ../../src/desktop/xdgurl.svg
#icon: ../../src/desktop/ocs-url.svg
parts:
xdgurl:
ocs-url:
plugin: qmake
source: ../../
qt-version: qt5
......@@ -30,8 +30,8 @@ parts:
- desktop-qt5
apps:
xdgurl:
command: usr/bin/xdgurl
ocs-url:
command: usr/bin/ocs-url
plugs:
- home
- network
......
Source: xdgurl
Source: ocs-url
Section: web
Priority: optional
Maintainer: Akira Ohgaki <akiraohgaki@gmail.com>
Build-Depends: build-essential (>= 11), qt5-default (>= 5.3.0), libqt5svg5-dev (>= 5.3.0), qtdeclarative5-dev (>= 5.3.0), devscripts (>= 2.14), debhelper (>= 9), fakeroot (>= 1.20)
Standards-Version: 3.9.4
Package: xdgurl
Package: ocs-url
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, libqt5svg5 (>= 5.3.0), qml-module-qtquick2 (>= 5.3.0) | qtdeclarative5-qtquick2-plugin (>= 5.3.0), qml-module-qtquick-window2 (>= 5.3.0) | qtdeclarative5-window-plugin (>= 5.3.0), qml-module-qtquick-controls (>= 5.3.0) | qtdeclarative5-controls-plugin (>= 5.3.0), qml-module-qtquick-dialogs (>= 5.3.0) | qtdeclarative5-dialogs-plugin (>= 5.3.0)
Description: An install helper program for desktop stuff
......
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: xdgurl
Upstream-Name: ocs-url
Upstream-Contact: Akira Ohgaki <akiraohgaki@gmail.com>
Source: https://github.com/xdgurl/xdgurl
Source: https://github.com/ocs-url/ocs-url
Files: *
Copyright: 2016-2017, Akira Ohgaki
......
usr/bin/ocs-url
usr/share/applications/ocs-url.desktop
usr/share/icons/hicolor/scalable/apps/ocs-url.svg
usr/bin/xdgurl
usr/share/applications/xdgurl.desktop
usr/share/icons/hicolor/scalable/apps/xdgurl.svg
......@@ -6,11 +6,11 @@ QT += \
svg
HEADERS += \
$${PWD}/handlers/xdgurlhandler.h
$${PWD}/handlers/ocsurlhandler.h
SOURCES += \
$${PWD}/main.cpp \
$${PWD}/handlers/xdgurlhandler.cpp
$${PWD}/handlers/ocsurlhandler.cpp
RESOURCES += \
$${PWD}/configs/configs.qrc \
......
{
"id": "xdgurl",
"name": "xdgurl",
"id": "ocs-url",
"name": "ocs-url",
"version": "2.0.3",
"organization": "xdgurl",
"domain": "com.xdgurl.xdgurl",
"icon": ":/desktop/xdgurl.svg",
"organization": "ocs-url",
"domain": "com.ocs-url.ocs-url",
"icon": ":/desktop/ocs-url.svg",
"description": "An install helper program for desktop stuff.",
"license": "GPL-3+",
"author": "Akira Ohgaki",
"contact": "akiraohgaki@gmail.com",
"homepage": "https://github.com/xdgurl/xdgurl"
"homepage": "https://github.com/ocs-url/ocs-url"
}
#include "xdgurlhandler.h"
#include "ocsurlhandler.h"
#include <QUrlQuery>
#include <QDesktopServices>
......@@ -8,45 +8,45 @@
#include "qtlib_networkresource.h"
#include "qtlib_package.h"
XdgUrlHandler::XdgUrlHandler(const QString &xdgUrl, const qtlib::Config &config, QObject *parent)
: QObject(parent), xdgUrl_(xdgUrl), config_(config)
OcsUrlHandler::OcsUrlHandler(const QString &ocsUrl, const qtlib::Config &config, QObject *parent)
: QObject(parent), ocsUrl_(ocsUrl), config_(config)
{
parse();
loadDestinations();
}
QString XdgUrlHandler::xdgUrl() const
QString OcsUrlHandler::ocsUrl() const
{
return xdgUrl_;
return ocsUrl_;
}
QJsonObject XdgUrlHandler::metadata() const
QJsonObject OcsUrlHandler::metadata() const
{
return metadata_;
}
void XdgUrlHandler::process()
void OcsUrlHandler::process()
{
// xdgs scheme is a reserved name, so the process of xdgs
// is the same process of the xdg scheme currently.
// ocss scheme is a reserved name, so the process of ocss
// is the same process of the ocs scheme currently.
if (!isValid()) {
QJsonObject result;
result["status"] = QString("error_validation");
result["message"] = QString("Invalid XDG-URL " + xdgUrl_);
result["message"] = QString("Invalid OCS-URL " + ocsUrl_);
emit finishedWithError(result);
return;
}
QString url = metadata_["url"].toString();
qtlib::NetworkResource *resource = new qtlib::NetworkResource(url, QUrl(url), true, this);
connect(resource, &qtlib::NetworkResource::downloadProgress, this, &XdgUrlHandler::downloadProgress);
connect(resource, &qtlib::NetworkResource::finished, this, &XdgUrlHandler::networkResourceFinished);
connect(resource, &qtlib::NetworkResource::downloadProgress, this, &OcsUrlHandler::downloadProgress);
connect(resource, &qtlib::NetworkResource::finished, this, &OcsUrlHandler::networkResourceFinished);
resource->get();
emit started();
}
bool XdgUrlHandler::isValid()
bool OcsUrlHandler::isValid()
{
QString scheme = metadata_["scheme"].toString();
QString command = metadata_["command"].toString();
......@@ -54,7 +54,7 @@ bool XdgUrlHandler::isValid()
QString type = metadata_["type"].toString();
QString filename = metadata_["filename"].toString();
if ((scheme == "xdg" || scheme == "xdgs")
if ((scheme == "ocs" || scheme == "ocss")
&& (command == "download" || command == "install")
&& QUrl(url).isValid()
&& destinations_.contains(type)
......@@ -64,13 +64,13 @@ bool XdgUrlHandler::isValid()
return false;
}
void XdgUrlHandler::openDestination()
void OcsUrlHandler::openDestination()
{
QString type = metadata_["type"].toString();
QDesktopServices::openUrl(QUrl("file://" + destinations_[type].toString()));
}
void XdgUrlHandler::networkResourceFinished(qtlib::NetworkResource *resource)
void OcsUrlHandler::networkResourceFinished(qtlib::NetworkResource *resource)
{
if (!resource->isFinishedWithNoError()) {
QJsonObject result;
......@@ -89,12 +89,12 @@ void XdgUrlHandler::networkResourceFinished(qtlib::NetworkResource *resource)
}
}
void XdgUrlHandler::parse()
void OcsUrlHandler::parse()
{
QUrl url(xdgUrl_);
QUrl url(ocsUrl_);
QUrlQuery query(url);
metadata_["scheme"] = QString("xdg");
metadata_["scheme"] = QString("ocs");
metadata_["command"] = QString("download");
metadata_["url"] = QString("");
metadata_["type"] = QString("downloads");
......@@ -125,7 +125,7 @@ void XdgUrlHandler::parse()
}
}
void XdgUrlHandler::loadDestinations()
void OcsUrlHandler::loadDestinations()
{
QJsonObject configDestinations = config_.get("destinations");
QJsonObject configDestinationsAlias = config_.get("destinations_alias");
......@@ -142,7 +142,7 @@ void XdgUrlHandler::loadDestinations()
}
}
QString XdgUrlHandler::convertPathString(const QString &path)
QString OcsUrlHandler::convertPathString(const QString &path)
{
QString newPath = path;
......@@ -159,7 +159,7 @@ QString XdgUrlHandler::convertPathString(const QString &path)
return newPath;
}
void XdgUrlHandler::saveDownloadedFile(qtlib::NetworkResource *resource)
void OcsUrlHandler::saveDownloadedFile(qtlib::NetworkResource *resource)
{
QJsonObject result;
......@@ -183,7 +183,7 @@ void XdgUrlHandler::saveDownloadedFile(qtlib::NetworkResource *resource)
resource->deleteLater();
}
void XdgUrlHandler::installDownloadedFile(qtlib::NetworkResource *resource)
void OcsUrlHandler::installDownloadedFile(qtlib::NetworkResource *resource)
{
QJsonObject result;
......
......@@ -9,12 +9,12 @@ namespace qtlib {
class NetworkResource;
}
class XdgUrlHandler : public QObject
class OcsUrlHandler : public QObject
{
Q_OBJECT
public:
explicit XdgUrlHandler(const QString &xdgUrl, const qtlib::Config &config, QObject *parent = 0);
explicit OcsUrlHandler(const QString &ocsUrl, const qtlib::Config &config, QObject *parent = 0);
signals:
void started();
......@@ -23,7 +23,7 @@ signals:
void downloadProgress(QString id, qint64 bytesReceived, qint64 bytesTotal);
public slots:
QString xdgUrl() const;
QString ocsUrl() const;
QJsonObject metadata() const;
void process();
......@@ -40,7 +40,7 @@ private:
void saveDownloadedFile(qtlib::NetworkResource *resource);
void installDownloadedFile(qtlib::NetworkResource *resource);
QString xdgUrl_;
QString ocsUrl_;
qtlib::Config config_;
QJsonObject metadata_;
QJsonObject destinations_;
......
......@@ -12,7 +12,7 @@
#include "qtlib_config.h"
#include "handlers/xdgurlhandler.h"
#include "handlers/ocsurlhandler.h"
int main(int argc, char *argv[])
{
......@@ -36,7 +36,7 @@ int main(int argc, char *argv[])
clParser.setApplicationDescription(configApplication["description"].toString());
clParser.addHelpOption();
clParser.addVersionOption();
clParser.addPositionalArgument("xdgurl", "XDG-URL");
clParser.addPositionalArgument("ocsurl", "OCS-URL");
clParser.process(app);
QStringList args = clParser.positionalArguments();
......@@ -45,12 +45,12 @@ int main(int argc, char *argv[])
clParser.showHelp(1);
}
QString xdgUrl = args.at(0);
QString ocsUrl = args.at(0);
// Setup QML
QQmlApplicationEngine qmlAppEngine;
QQmlContext *qmlContext = qmlAppEngine.rootContext();
qmlContext->setContextProperty("xdgUrlHandler", new XdgUrlHandler(xdgUrl, config, &qmlAppEngine));
qmlContext->setContextProperty("ocsUrlHandler", new OcsUrlHandler(ocsUrl, config, &qmlAppEngine));
qmlAppEngine.load(QUrl("qrc:/qml/main.qml"));
return app.exec();
......
......@@ -23,7 +23,7 @@ Window {
informativeText: ""
detailedText: ""
standardButtons: StandardButton.Ok | StandardButton.Cancel
onAccepted: xdgUrlHandler.process()
onAccepted: ocsUrlHandler.process()
onRejected: Qt.quit()
}
......@@ -36,7 +36,7 @@ Window {
detailedText: ""
standardButtons: StandardButton.Open | StandardButton.Close
onAccepted: {
xdgUrlHandler.openDestination();
ocsUrlHandler.openDestination();
Qt.quit();
}
onRejected: Qt.quit()
......@@ -100,7 +100,7 @@ Window {
}
Component.onCompleted: {
var metadata = xdgUrlHandler.metadata();
var metadata = ocsUrlHandler.metadata();
var primaryMessages = {
"success_download": qsTr("Download successfull"),
"success_install": qsTr("Installation successfull"),
......@@ -110,11 +110,11 @@ Window {
"error_install": qsTr("Installation failed")
};
xdgUrlHandler.started.connect(function() {
ocsUrlHandler.started.connect(function() {
progressDialog.open();
});
xdgUrlHandler.finishedWithSuccess.connect(function(result) {
ocsUrlHandler.finishedWithSuccess.connect(function(result) {
progressDialog.close();
infoDialog.text = primaryMessages[result.status];
infoDialog.informativeText = metadata.filename;
......@@ -122,7 +122,7 @@ Window {
infoDialog.open();
});
xdgUrlHandler.finishedWithError.connect(function(result) {
ocsUrlHandler.finishedWithError.connect(function(result) {
progressDialog.close();
errorDialog.text = primaryMessages[result.status];
errorDialog.informativeText = metadata.filename;
......@@ -130,7 +130,7 @@ Window {
errorDialog.open();
});
xdgUrlHandler.downloadProgress.connect(function(id, bytesReceived, bytesTotal) {
ocsUrlHandler.downloadProgress.connect(function(id, bytesReceived, bytesTotal) {
progressDialog.primaryLabel.text = qsTr("Downloading");
progressDialog.informativeLabel.text = metadata.filename;
progressDialog.progressBar.value = bytesReceived / bytesTotal;
......@@ -138,7 +138,7 @@ Window {
+ " / " + Utility.convertByteToHumanReadable(bytesTotal)
});
if (xdgUrlHandler.isValid()) {
if (ocsUrlHandler.isValid()) {
if (metadata.command === "download") {
confirmDialog.text = qsTr("Do you want to download?");
}
......@@ -153,7 +153,7 @@ Window {
}
else {
errorDialog.text = qsTr("Validation error");
errorDialog.detailedText = qsTr("Invalid XDG-URL") + " " + xdgUrlHandler.xdgUrl();
errorDialog.detailedText = qsTr("Invalid OCS-URL") + " " + ocsUrlHandler.ocsUrl();
errorDialog.open();
}
}
......
<RCC>
<qresource prefix="/desktop">
<file>xdgurl.svg</file>
<file>ocs-url.svg</file>
</qresource>
</RCC>
[Desktop Entry]
Name=xdgurl
Exec=xdgurl %u
Icon=xdgurl
Name=ocs-url
Exec=ocs-url %u
Icon=ocs-url
Type=Application
Terminal=false
NoDisplay=true
Categories=Network;Utility;
MimeType=x-scheme-handler/xdg;x-scheme-handler/xdgs;
MimeType=x-scheme-handler/ocs;x-scheme-handler/ocss;
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