diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -53,3 +53,4 @@ add_subdirectory(email) add_subdirectory(telegram) add_subdirectory(bluetooth) +add_subdirectory(itinerary) diff --git a/src/plugins/itinerary/CMakeLists.txt b/src/plugins/itinerary/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/src/plugins/itinerary/CMakeLists.txt @@ -0,0 +1,3 @@ +add_definitions(-DTRANSLATION_DOMAIN=\"purpose_itinerary\") +add_share_plugin(itineraryplugin itineraryplugin.cpp) + diff --git a/src/plugins/itinerary/Messages.sh b/src/plugins/itinerary/Messages.sh new file mode 100644 --- /dev/null +++ b/src/plugins/itinerary/Messages.sh @@ -0,0 +1,2 @@ +#!/bin/sh +$XGETTEXT `find . -not -path \*/tests/\* -name \*.cpp -o -name \*.qml -o -name \*.cc -o -name \*.h` -o $podir/purpose_itinerary.pot diff --git a/src/plugins/itinerary/itineraryplugin.cpp b/src/plugins/itinerary/itineraryplugin.cpp new file mode 100644 --- /dev/null +++ b/src/plugins/itinerary/itineraryplugin.cpp @@ -0,0 +1,65 @@ +/* + Copyright 2018 Nicolas Fella + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . +*/ + +#include +#include +#include +#include +#include + +EXPORT_SHARE_VERSION + +class ItineraryJob : public Purpose::Job +{ + Q_OBJECT + public: + ItineraryJob(QObject* parent) + : Purpose::Job(parent) + {} + + QStringList arrayToList(const QJsonArray& array) + { + QStringList ret; + foreach(const QJsonValue& val, array) { + ret += val.toString(); + } + return ret; + } + + void start() override + { + QJsonArray urlsJson = data().value(QStringLiteral("urls")).toArray(); + QProcess::startDetached(QStringLiteral("itinerary"), arrayToList(urlsJson)); + QTimer::singleShot(0, this, &ItineraryJob::emitResult); + } +}; + +class Q_DECL_EXPORT ItineraryPlugin : public Purpose::PluginBase +{ + Q_OBJECT + public: + ItineraryPlugin(QObject* p, const QVariantList& ) : Purpose::PluginBase(p) {} + + Purpose::Job* createJob() const override + { + return new ItineraryJob(nullptr); + } +}; + +K_PLUGIN_FACTORY_WITH_JSON(Itinerary, "itineraryplugin.json", registerPlugin();) + +#include "itineraryplugin.moc" diff --git a/src/plugins/itinerary/itineraryplugin.json b/src/plugins/itinerary/itineraryplugin.json new file mode 100644 --- /dev/null +++ b/src/plugins/itinerary/itineraryplugin.json @@ -0,0 +1,23 @@ +{ + "KPlugin": { + "Authors": [ + { + "Name": "Nicolas Fella" + } + ], + "Category": "Utilities", + "Description": "Import into Itinerary", + "Icon": "map-globe", + "License": "GPL", + "Name": "Import into Itinerary" + }, + "X-Purpose-Configuration": [ + ], + "X-Purpose-Constraints": [ + "application:org.kde.itinerary.desktop", + "mimeType:application/pdf;application/ld+json;application/vnd.apple.pkpass" + ], + "X-Purpose-PluginTypes": [ + "Export" + ] +}