diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index d7c8d94..fa4637b 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -1,55 +1,56 @@ function(add_share_plugin name) kcoreaddons_add_plugin(${name} SOURCES ${ARGN} JSON "${name}.json" INSTALL_NAMESPACE "kf5/purpose") target_link_libraries(${name} Qt5::Core KF5::Purpose) set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/kf5/purpose") if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${name}_config.qml") install(FILES "${name}_config.qml" DESTINATION ${DATA_INSTALL_DIR}/purpose) endif() endfunction() set(KPACKAGE_RELATIVE_DATA_INSTALL_DIR "kpackage") function(kpackage_install_package dir component root) set(install_dir ${ARGV3}) if(NOT install_dir) set(install_dir ${KPACKAGE_RELATIVE_DATA_INSTALL_DIR}) endif() install(DIRECTORY ${dir}/ USE_SOURCE_PERMISSIONS DESTINATION ${DATA_INSTALL_DIR}/${install_dir}/${root}/${component} PATTERN Messages.sh EXCLUDE) endfunction() set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) include(QMLModules) find_qmlmodule(Ubuntu.OnlineAccounts 0.1) find_qmlmodule(org.kde.kdeconnect 1.0) find_qmlmodule(org.kde.kquickcontrolsaddons 2.0) find_package(KAccounts) find_package(KF5KIO ${KF5_DEP_VERSION} REQUIRED) set_package_properties(KAccounts PROPERTIES PURPOSE "Used to find your system-wide defined, for now only for YouTube." TYPE OPTIONAL ) set_package_properties(KF5KIO PROPERTIES TYPE REQUIRED) add_subdirectory(saveas) add_subdirectory(imgur) add_subdirectory(pastebin) add_subdirectory(ktp-sendfile) if (KAccounts_FOUND) add_subdirectory(youtube) file(COPY twitter DESTINATION ${CMAKE_CURRENT_BINARY_DIR} PATTERN "main.js.in" EXCLUDE) configure_file(twitter/contents/code/main.js.in ${CMAKE_CURRENT_BINARY_DIR}/twitter/contents/code/main.js @ONLY) kpackage_install_package(${CMAKE_CURRENT_BINARY_DIR}/twitter Twitter Purpose) kaccounts_add_service(${CMAKE_CURRENT_SOURCE_DIR}/twitter-microblog.service.in) add_subdirectory(nextcloud) endif() add_subdirectory(kdeconnect) add_subdirectory(reviewboard) add_subdirectory(phabricator) add_subdirectory(email) add_subdirectory(telegram) add_subdirectory(bluetooth) +add_subdirectory(kdeconnect_sms) diff --git a/src/plugins/kdeconnect_sms/CMakeLists.txt b/src/plugins/kdeconnect_sms/CMakeLists.txt new file mode 100644 index 0000000..0af9365 --- /dev/null +++ b/src/plugins/kdeconnect_sms/CMakeLists.txt @@ -0,0 +1,4 @@ +add_definitions(-DTRANSLATION_DOMAIN=\"purpose_kdeconnectsms\") +add_share_plugin(kdeconnectsmsplugin kdeconnectsmsplugin.cpp) +target_link_libraries(kdeconnectsmsplugin KF5::I18n) + diff --git a/src/plugins/kdeconnect_sms/Messages.sh b/src/plugins/kdeconnect_sms/Messages.sh new file mode 100644 index 0000000..00e2621 --- /dev/null +++ b/src/plugins/kdeconnect_sms/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_kdeconnectsms.pot diff --git a/src/plugins/kdeconnect_sms/kdeconnectsmsplugin.cpp b/src/plugins/kdeconnect_sms/kdeconnectsmsplugin.cpp new file mode 100644 index 0000000..b1f3e18 --- /dev/null +++ b/src/plugins/kdeconnect_sms/kdeconnectsmsplugin.cpp @@ -0,0 +1,73 @@ +/* + 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 +#include +#include +#include +#include +#include + +EXPORT_SHARE_VERSION + +class KDEConnectSMSJob : public Purpose::Job +{ + Q_OBJECT + public: + KDEConnectSMSJob(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(); + QString title = data().value(QStringLiteral("title")).toString(); + QString message = i18n("%1 - %2").arg(title).arg(arrayToList(urlsJson).join(QLatin1Char(' '))); + + QProcess::startDetached(QStringLiteral("kdeconnect-sms"), QStringList(QStringLiteral("--message")) << message); + QTimer::singleShot(0, this, &KDEConnectSMSJob::emitResult); + } +}; + +class Q_DECL_EXPORT KDEConnectSMSPlugin : public Purpose::PluginBase +{ + Q_OBJECT + public: + KDEConnectSMSPlugin(QObject* p, const QVariantList& ) : Purpose::PluginBase(p) {} + + Purpose::Job* createJob() const override + { + return new KDEConnectSMSJob(nullptr); + } +}; + +K_PLUGIN_FACTORY_WITH_JSON(KDEConnectSMS, "kdeconnectsmsplugin.json", registerPlugin();) + +#include "kdeconnectsmsplugin.moc" diff --git a/src/plugins/kdeconnect_sms/kdeconnectsmsplugin.json b/src/plugins/kdeconnect_sms/kdeconnectsmsplugin.json new file mode 100644 index 0000000..463212c --- /dev/null +++ b/src/plugins/kdeconnect_sms/kdeconnectsmsplugin.json @@ -0,0 +1,22 @@ +{ + "KPlugin": { + "Authors": [ + { + "Name": "Nicolas Fella" + } + ], + "Category": "Utilities", + "Description": "Send SMS via KDE Connect", + "Icon": "kdeconnect", + "License": "GPL", + "Name": "Send SMS via KDE Connect..." + }, + "X-Purpose-Configuration": [ + ], + "X-Purpose-Constraints": [ + "application:org.kde.kdeconnect.sms.desktop" + ], + "X-Purpose-PluginTypes": [ + "ShareUrl" + ] +}