diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,9 +12,29 @@ find_package(Qt5 5.2 REQUIRED COMPONENTS Quick) -find_package(KF5 5.42.0 REQUIRED COMPONENTS I18n ConfigWidgets DBusAddons) -find_package(KF5DocTools) -find_package(Qca-qt5 2.1.0 REQUIRED) +if (SAILFISHOS) + find_package(PkgConfig) + set(KF5_MIN_VERSION 5.31.0) + set(KF5_REQUIRED_COMPONENTS I18n DBusAddons CoreAddons) + set(QCA_MIN_VERSION 2.0.0) + pkg_search_module(SFOS REQUIRED sailfishapp) + pkg_check_modules(QCA2 qca2-qt5>=${QCA_MIN_VERSION} REQUIRED) + add_definitions(-DSAILFISHOS) + include_directories(${CMAKE_SOURCE_DIR} ${QCA2_INCLUDEDIR}) + add_definitions(-DQT_NO_URL_CAST_FROM_STRING) +else() + set(KF5_MIN_VERSION 5.42.0) + set(KF5_REQUIRED_COMPONENTS I18n ConfigWidgets DBusAddons) + set(QCA_MIN_VERSION 2.1.0) + find_package(Qca-qt5 ${QCA_MIN_VERSION} REQUIRED) + add_definitions(-DQT_NO_URL_CAST_FROM_STRING -DQT_NO_KEYWORDS) +endif() + +find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS ${KF5_REQUIRED_COMPONENTS}) + +if (NOT SAILFISHOS) + find_package(KF5DocTools) +endif() include_directories(${CMAKE_SOURCE_DIR}) @@ -30,15 +50,15 @@ include(KDEConnectMacros.cmake) -add_definitions(-DQT_NO_URL_CAST_FROM_STRING -DQT_NO_KEYWORDS) - include(GenerateExportHeader) include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_subdirectory(core) -add_subdirectory(kcm) -add_subdirectory(kcmplugin) -if(NOT WIN32) +if(NOT SAILFISHOS) + add_subdirectory(kcm) + add_subdirectory(kcmplugin) +endif() +if(NOT WIN32 AND NOT SAILFISHOS) add_subdirectory(kio) add_subdirectory(plasmoid) endif() @@ -52,16 +72,24 @@ add_subdirectory(daemon) add_subdirectory(plugins) add_subdirectory(cli) -add_subdirectory(indicator) -add_subdirectory(fileitemactionplugin) -add_subdirectory(urlhandler) + +if (NOT SAILFISHOS) + add_subdirectory(indicator) + add_subdirectory(fileitemactionplugin) + add_subdirectory(urlhandler) +else() + add_subdirectory(sfos) +endif() + if(KF5DocTools_FOUND) add_subdirectory(doc) endif() -if(BUILD_TESTING) +if(BUILD_TESTING AND NOT SAILFISHOS) add_subdirectory(tests) endif() -install(FILES org.kde.kdeconnect.kcm.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) +if(NOT SAILFISHOS) + install(FILES org.kde.kdeconnect.kcm.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) +endif() feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -15,7 +15,14 @@ add_subdirectory(backends/bluetooth) endif() -find_package(KF5Notifications 5.9 REQUIRED) +if (SAILFISHOS) + find_package(KF5Config 5.9 REQUIRED) + pkg_check_modules(NNQT5 REQUIRED nemonotifications-qt5) + set(NOTIFICATION_LIB ${NNQT5_LIBRARIES}) +else() + find_package(KF5Notifications 5.9 REQUIRED) + set(NOTIFICATION_LIB KF5::Notifications) +endif() set(kdeconnectcore_SRCS ${backends_kdeconnect_SRCS} diff --git a/core/backends/devicelink.h b/core/backends/devicelink.h --- a/core/backends/devicelink.h +++ b/core/backends/devicelink.h @@ -22,6 +22,7 @@ #define DEVICELINK_H #include +#include //Fix build on older QCA #include #include "core/networkpackage.h" diff --git a/core/daemon.cpp b/core/daemon.cpp --- a/core/daemon.cpp +++ b/core/daemon.cpp @@ -39,6 +39,11 @@ #include "backends/devicelink.h" #include "backends/linkprovider.h" +//In older Qt released, qAsConst isnt available +#ifdef SAILFISHOS +#define qAsConst +#endif + static Daemon* s_instance = nullptr; struct DaemonPrivate diff --git a/core/device.cpp b/core/device.cpp --- a/core/device.cpp +++ b/core/device.cpp @@ -41,6 +41,11 @@ #include "kdeconnectconfig.h" #include "daemon.h" +//In older Qt released, qAsConst isnt available +#ifdef SAILFISHOS +#define qAsConst +#endif + static void warn(const QString& info) { qWarning() << "Device pairing error" << info; diff --git a/core/pluginloader.cpp b/core/pluginloader.cpp --- a/core/pluginloader.cpp +++ b/core/pluginloader.cpp @@ -28,6 +28,11 @@ #include "device.h" #include "kdeconnectplugin.h" +//In older Qt released, qAsConst isnt available +#ifdef SAILFISHOS +#define qAsConst +#endif + PluginLoader* PluginLoader::instance() { static PluginLoader* instance = new PluginLoader(); diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -1,11 +1,18 @@ project(kdeconnectd) -find_package(KF5 REQUIRED COMPONENTS Notifications KIO) - add_definitions(-DTRANSLATION_DOMAIN="kdeconnect-kded") -add_executable(kdeconnectd kdeconnectd.cpp) -target_link_libraries(kdeconnectd kdeconnectcore KF5::KIOWidgets KF5::DBusAddons KF5::Notifications KF5::I18n Qt5::Widgets) +if (SAILFISHOS) + pkg_check_modules(NNQT5 REQUIRED nemonotifications-qt5) + include_directories(${NNQT5_INCLUDE_DIRS}) + qt5_generate_moc(${CMAKE_SOURCE_DIR}/sfos/sailfishdaemon.h moc_sailfishdaemon.cpp) + add_executable(kdeconnectd kdeconnectd.cpp moc_sailfishdaemon.cpp) + target_link_libraries(kdeconnectd kdeconnectcore KF5::DBusAddons ${NNQT5_LIBRARIES} KF5::I18n) +else() + find_package(KF5 REQUIRED COMPONENTS Notifications KIO) + add_executable(kdeconnectd kdeconnectd.cpp) + target_link_libraries(kdeconnectd kdeconnectcore KF5::KIOWidgets KF5::DBusAddons KF5::Notifications KF5::I18n Qt5::Widgets) +endif() ecm_mark_nongui_executable(kdeconnectd) diff --git a/daemon/kdeconnectd.cpp b/daemon/kdeconnectd.cpp --- a/daemon/kdeconnectd.cpp +++ b/daemon/kdeconnectd.cpp @@ -18,20 +18,31 @@ * along with this program. If not, see . */ +#ifdef SAILFISHOS +#include +#else #include +#endif + #include #include #include -#include #include + +#ifndef SAILFISHOS #include +#endif #include "core/daemon.h" #include "core/device.h" #include "core/backends/pairinghandler.h" #include "kdeconnect-version.h" +#ifdef SAILFISHOS +#include "sfos/sailfishdaemon.h" +#else +#include class DesktopDaemon : public Daemon { Q_OBJECT @@ -72,17 +83,32 @@ QNetworkAccessManager* m_nam; }; +#endif + int main(int argc, char* argv[]) { +#ifdef SAILFISHOS + QCoreApplication app(argc, argv); +#else QApplication app(argc, argv); +#endif + app.setApplicationName(QStringLiteral("kdeconnectd")); app.setApplicationVersion(QStringLiteral(KDECONNECT_VERSION_STRING)); app.setOrganizationDomain(QStringLiteral("kde.org")); + +#ifndef SAILFISHOS app.setQuitOnLastWindowClosed(false); +#endif KDBusService dbusService(KDBusService::Unique); +#ifdef SAILFISHOS + Daemon* daemon = new SailfishDaemon; +#else Daemon* daemon = new DesktopDaemon; +#endif + QObject::connect(daemon, SIGNAL(destroyed(QObject*)), &app, SLOT(quit())); return app.exec(); diff --git a/interfaces/CMakeLists.txt b/interfaces/CMakeLists.txt --- a/interfaces/CMakeLists.txt +++ b/interfaces/CMakeLists.txt @@ -12,6 +12,8 @@ set(libkdeconnect_HEADERS ${libkdeconnect_HEADERS} PARENT_SCOPE) endfunction() +find_package(KF5Config 5.9 REQUIRED) + set(libkdeconnect_SRC dbusinterfaces.cpp devicesmodel.cpp diff --git a/interfaces/notificationsmodel.h b/interfaces/notificationsmodel.h --- a/interfaces/notificationsmodel.h +++ b/interfaces/notificationsmodel.h @@ -68,6 +68,7 @@ public Q_SLOTS: void dismissAll(); + private Q_SLOTS: void notificationAdded(const QString& id); void notificationRemoved(const QString& id); diff --git a/interfaces/notificationsmodel.cpp b/interfaces/notificationsmodel.cpp --- a/interfaces/notificationsmodel.cpp +++ b/interfaces/notificationsmodel.cpp @@ -29,6 +29,11 @@ //#include "modeltest.h" +//In older Qt released, qAsConst isnt available +#ifdef SAILFISHOS +#define qAsConst +#endif + NotificationsModel::NotificationsModel(QObject* parent) : QAbstractListModel(parent) , m_dbusInterface(nullptr) diff --git a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.h b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.h --- a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.h +++ b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.h @@ -26,7 +26,9 @@ class KdeConnectDeclarativePlugin : public QQmlExtensionPlugin { Q_OBJECT - +#if SAILFISHOS +public: +#endif Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") void registerTypes(const char* uri) override; diff --git a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp --- a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp +++ b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp @@ -85,10 +85,12 @@ qmlRegisterType(uri, 1, 0, "NotificationsModel"); qmlRegisterType(uri, 1, 0, "DBusAsyncResponse"); qmlRegisterType(uri, 1, 0, "DevicesSortProxyModel"); +#ifndef SAILFISHOS qmlRegisterUncreatableType(uri, 1, 0, "MprisDbusInterface", QStringLiteral("You're not supposed to instantiate interfacess")); qmlRegisterUncreatableType(uri, 1, 0, "LockDeviceDbusInterface", QStringLiteral("You're not supposed to instantiate interfacess")); qmlRegisterUncreatableType(uri, 1, 0, "FindMyPhoneDbusInterface", QStringLiteral("You're not supposed to instantiate interfacess")); qmlRegisterUncreatableType(uri, 1, 0, "RemoteKeyboardDbusInterface", QStringLiteral("You're not supposed to instantiate interfacess")); +#endif qmlRegisterUncreatableType(uri, 1, 0, "DeviceDbusInterface", QStringLiteral("You're not supposed to instantiate interfacess")); qmlRegisterSingletonType(uri, 1, 0, "DaemonDbusInterface", [](QQmlEngine*, QJSEngine*) -> QObject* { @@ -100,13 +102,13 @@ void KdeConnectDeclarativePlugin::initializeEngine(QQmlEngine* engine, const char* uri) { QQmlExtensionPlugin::initializeEngine(engine, uri); - + engine->rootContext()->setContextProperty(QStringLiteral("DeviceDbusInterfaceFactory") , new ObjectFactory(engine, createDeviceDbusInterface)); - + engine->rootContext()->setContextProperty(QStringLiteral("DeviceBatteryDbusInterfaceFactory") , new ObjectFactory(engine, createDeviceBatteryDbusInterface)); - + engine->rootContext()->setContextProperty(QStringLiteral("FindMyPhoneDbusInterfaceFactory") , new ObjectFactory(engine, createFindMyPhoneInterface)); @@ -124,10 +126,10 @@ engine->rootContext()->setContextProperty(QStringLiteral("LockDeviceDbusInterfaceFactory") , new ObjectFactory(engine, createDeviceLockInterface)); - + engine->rootContext()->setContextProperty(QStringLiteral("DBusResponseFactory") - , new ObjectFactory(engine, createDBusResponse)); - + , new ObjectFactory(engine, createDBusResponse)); + engine->rootContext()->setContextProperty(QStringLiteral("DBusResponseWaiter") , DBusResponseWaiter::instance()); } diff --git a/plasmoid/declarativeplugin/responsewaiter.cpp b/plasmoid/declarativeplugin/responsewaiter.cpp --- a/plasmoid/declarativeplugin/responsewaiter.cpp +++ b/plasmoid/declarativeplugin/responsewaiter.cpp @@ -5,6 +5,11 @@ #include #include +//In older Qt released, qAsConst isnt available +#ifdef SAILFISHOS +#define qAsConst +#endif + Q_DECLARE_METATYPE(QDBusPendingReply<>) Q_DECLARE_METATYPE(QDBusPendingReply) Q_DECLARE_METATYPE(QDBusPendingReply) @@ -29,7 +34,7 @@ << qRegisterMetaType >("QDBusPendingReply<>") << qRegisterMetaType >("QDBusPendingReply") << qRegisterMetaType >("QDBusPendingReply") - << qRegisterMetaType >("QDBusPendingReply") + << qRegisterMetaType >("QDBusPendingReply") << qRegisterMetaType >("QDBusPendingReply") ; } @@ -39,13 +44,13 @@ if (QDBusPendingCall* call = const_cast(extractPendingCall(variant))) { call->waitForFinished(); - + if (call->isError()) { qWarning() << "error:" << call->error(); return QVariant("error"); } - + QDBusMessage reply = call->reply(); if (reply.arguments().count() > 0) @@ -69,7 +74,7 @@ void DBusAsyncResponse::setPendingCall(QVariant variant) { if (QDBusPendingCall* call = const_cast(DBusResponseWaiter::instance()->extractPendingCall(variant))) - { + { QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(*call); watcher->setProperty("pengingCallVariant", variant); connect(watcher, &QDBusPendingCallWatcher::finished, this, &DBusAsyncResponse::onCallFinished); @@ -83,7 +88,7 @@ { m_timeout.stop(); QVariant variant = watcher->property("pengingCallVariant"); - + if (QDBusPendingCall* call = const_cast(DBusResponseWaiter::instance()->extractPendingCall(variant))) { if (call->isError()) @@ -121,10 +126,10 @@ { if (variant.canConvert(QVariant::Type(type))) { - return reinterpret_cast(variant.constData()); + return reinterpret_cast(variant.constData()); } } - + return nullptr; } diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -3,29 +3,32 @@ install(FILES kdeconnect_plugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR}) add_subdirectory(ping) -add_subdirectory(clipboard) -add_subdirectory(telephony) -add_subdirectory(share) -add_subdirectory(notifications) -add_subdirectory(battery) -add_subdirectory(findmyphone) -add_subdirectory(remotekeyboard) -if(WIN32) - add_subdirectory(mousepad_windows) -else() - add_subdirectory(runcommand) - add_subdirectory(sendnotifications) - add_subdirectory(pausemusic) - add_subdirectory(mpriscontrol) - add_subdirectory(mousepad) - add_subdirectory(screensaver-inhibit) - add_subdirectory(sftp) -endif() -if(EXPERIMENTALAPP_ENABLED) - add_subdirectory(remotecommands) - add_subdirectory(mprisremote) - add_subdirectory(remotecontrol) - add_subdirectory(lockdevice) +if(NOT SAILFISHOS) + add_subdirectory(clipboard) + add_subdirectory(telephony) + add_subdirectory(share) + add_subdirectory(notifications) + add_subdirectory(battery) + add_subdirectory(findmyphone) + add_subdirectory(remotekeyboard) + + if(WIN32) + add_subdirectory(mousepad_windows) + else() + add_subdirectory(runcommand) + add_subdirectory(sendnotifications) + add_subdirectory(pausemusic) + add_subdirectory(mpriscontrol) + add_subdirectory(mousepad) + add_subdirectory(screensaver-inhibit) + add_subdirectory(sftp) + endif() + if(EXPERIMENTALAPP_ENABLED) + add_subdirectory(remotecommands) + add_subdirectory(mprisremote) + add_subdirectory(remotecontrol) + add_subdirectory(lockdevice) + endif() endif() #FIXME: If we split notifications in several files, they won't appear in the same group in the Notifications KCM diff --git a/plugins/ping/CMakeLists.txt b/plugins/ping/CMakeLists.txt --- a/plugins/ping/CMakeLists.txt +++ b/plugins/ping/CMakeLists.txt @@ -1,4 +1,11 @@ -find_package(KF5 REQUIRED COMPONENTS Notifications) +if (SAILFISHOS) + pkg_check_modules(NNQT5 REQUIRED nemonotifications-qt5) + set(NOTIFICATION_LIB ${NNQT5_LIBRARIES}) + include_directories(${NNQT5_INCLUDE_DIRS}) +else() + find_package(KF5 REQUIRED COMPONENTS Notifications) + set(NOTIFICATION_LIB ${NNQT5_LIBRARIES}) +endif() set(kdeconnect_ping_SRCS pingplugin.cpp @@ -10,5 +17,5 @@ kdeconnectcore Qt5::DBus KF5::I18n - KF5::Notifications + ${NOTIFICATION_LIB} ) diff --git a/plugins/ping/pingplugin.cpp b/plugins/ping/pingplugin.cpp --- a/plugins/ping/pingplugin.cpp +++ b/plugins/ping/pingplugin.cpp @@ -20,7 +20,12 @@ #include "pingplugin.h" +#ifdef SAILFISHOS +#include +#include +#else #include +#endif #include #include @@ -47,13 +52,22 @@ bool PingPlugin::receivePackage(const NetworkPackage& np) { +#ifdef SAILFISHOS + Notification *notification = new Notification(this); + + notification->setAppName(QCoreApplication::applicationName()); + notification->setPreviewSummary(device()->name()); + notification->setPreviewBody(np.get(QStringLiteral("message"),i18n("Ping!"))); + notification->setIcon("icon-s-alarm"); + notification->publish(); +#else KNotification* notification = new KNotification(QStringLiteral("pingReceived")); //KNotification::Persistent notification->setIconName(QStringLiteral("dialog-ok")); notification->setComponentName(QStringLiteral("kdeconnect")); notification->setTitle(device()->name()); notification->setText(np.get(QStringLiteral("message"),i18n("Ping!"))); //This can be a source of spam notification->sendEvent(); - +#endif return true; } diff --git a/sfos/CMakeLists.txt b/sfos/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/sfos/CMakeLists.txt @@ -0,0 +1,23 @@ +find_package(Qt5 5.2 REQUIRED COMPONENTS DBus) + + pkg_check_modules(NNQT5 REQUIRED nemonotifications-qt5) + include_directories(${NNQT5_INCLUDE_DIRS}) + +set(kdeconnectsfos_SRCS + kdeconnect-sfos.cpp + ../plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp + ../plasmoid/declarativeplugin/responsewaiter.cpp +) + +#find_package(KF5 COMPONENTS Declarative) + +#qt5_add_resources(kcapp_SRCS resources.qrc) +qt5_wrap_cpp(kdeconnectsfos_SRCS ../plasmoid/declarativeplugin/objectfactory.h) + +add_executable(kdeconnect-sfos ${kdeconnectsfos_SRCS}) +target_link_libraries(kdeconnect-sfos Qt5::Quick KF5::CoreAddons KF5::I18n sailfishapp Qt5::DBus kdeconnectinterfaces ${NNQT5_LIBRARIES}) + +install(TARGETS kdeconnect-sfos ${INSTALL_TARGETS_DEFAULT_ARGS}) +install(PROGRAMS kdeconnect-sfos.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) +INSTALL( DIRECTORY qml DESTINATION ${SHARE_INSTALL_PREFIX}/kdeconnect-sfos/ ) + diff --git a/sfos/kdeconnect-sfos.cpp b/sfos/kdeconnect-sfos.cpp new file mode 100644 --- /dev/null +++ b/sfos/kdeconnect-sfos.cpp @@ -0,0 +1,107 @@ +/* + Copyright (C) 2013 Jolla Ltd. + Contact: Thomas Perl + All rights reserved. + + You may use this file under the terms of BSD license as follows: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Jolla Ltd nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef QT_QML_DEBUG +#include +#endif + +#include +#include +#include +#include +#include +#include + +#include + +class Notify : public QObject +{ + Q_OBJECT +public: + Q_INVOKABLE void message(const QString &title, const QString &body) + { + Notification notification; + QVariantList remoteactions; + + + remoteactions << Notification::remoteAction("yes", + QString(), + "com.kimmoli.harbour.maira", + "/", + "com.kimmoli.harbour.maira", + "yes", + QVariantList()); + + //notification.setAppName("kdeconnect"); + notification.setSummary(title); + notification.setPreviewSummary(title); + notification.setBody(body); + notification.setPreviewBody(body); + //notification.setCategory("x-nemo.call.missed"); + //notification.setItemCount(0); + //notification.setReplacesId(0); + notification.setIcon("icon-s-sync"); + notification.setExpireTimeout(10000); + notification.setRemoteActions(remoteactions); + + notification.publish(); + }; +}; + +int main(int argc, char *argv[]) +{ + // SailfishApp::main() will display "qml/kdeconnect-sfos.qml", if you need more + // control over initialization, you can use: + // + // - SailfishApp::application(int, char *[]) to get the QGuiApplication * + // - SailfishApp::createView() to get a new QQuickView * instance + // - SailfishApp::pathTo(QString) to get a QUrl to a resource file + // - SailfishApp::pathToMainQml() to get a QUrl to the main QML file + // + // To display the view, call "show()" (will show fullscreen on device). + + //return SailfishApp::main(argc, argv); + QGuiApplication *app = SailfishApp::application(argc, argv); + QScopedPointer view(SailfishApp::createView()); + + KdeConnectDeclarativePlugin plugin; + plugin.registerTypes("ork.kde.kdeconnect"); + plugin.initializeEngine(view->engine(),"org.kde.kdeconnect"); + + Notify notif; + view->engine()->rootContext()->setContextProperty(QStringLiteral("Notify"), ¬if); + + view->setSource(SailfishApp::pathTo("qml/kdeconnect-sfos.qml")); + view->showFullScreen(); + + return app->exec(); +} + +#include "kdeconnect-sfos.moc" diff --git a/sfos/kdeconnect-sfos.desktop b/sfos/kdeconnect-sfos.desktop new file mode 100644 --- /dev/null +++ b/sfos/kdeconnect-sfos.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Type=Application +X-Nemo-Application-Type=generic +Icon=kdeconnect +Exec=kdeconnect-sfos +Name=KDE Connect +# translation example: +# your app name in German locale (de) +# +# Remember to comment out the following line, if you do not want to use +# a different app name in German locale (de). +Name[de]=kdeconnect-sfos diff --git a/sfos/qml/cover/CoverPage.qml b/sfos/qml/cover/CoverPage.qml new file mode 100644 --- /dev/null +++ b/sfos/qml/cover/CoverPage.qml @@ -0,0 +1,76 @@ +/* + Copyright (C) 2013 Jolla Ltd. + Contact: Thomas Perl + All rights reserved. + + You may use this file under the terms of BSD license as follows: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Jolla Ltd nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import org.kde.kdeconnect 1.0 + +CoverBackground { + Label { + id: label + anchors.top: parent.top + anchors.topMargin: Theme.paddingMedium + anchors.horizontalCenter: parent.horizontalCenter + text: qsTr("KDE Connect") + } + + SilicaListView { + id: devices + anchors.top: label.bottom + anchors.margins: Theme.paddingSmall + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + visible: count > 0 + + model: DevicesSortProxyModel { + sourceModel: DevicesModel { displayFilter: DevicesModel.Reachable | DevicesModel.Paired } + } + + width: parent.width + spacing: Theme.paddingLarge + + delegate: ListItem { + width: ListView.view.width + height: Theme.itemSizeMedium + + Label { text: display } + } + + + } + Label { + text: qsTr("No paired \ndevices in range") + anchors.centerIn: parent + visible: devices.count == 0 + } + +} + diff --git a/sfos/qml/kdeconnect-sfos.qml b/sfos/qml/kdeconnect-sfos.qml new file mode 100644 --- /dev/null +++ b/sfos/qml/kdeconnect-sfos.qml @@ -0,0 +1,41 @@ +/* + Copyright (C) 2013 Jolla Ltd. + Contact: Thomas Perl + All rights reserved. + + You may use this file under the terms of BSD license as follows: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Jolla Ltd nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import "pages" + +ApplicationWindow +{ + initialPage: Component { FirstPage { } } + cover: Qt.resolvedUrl("cover/CoverPage.qml") + allowedOrientations: defaultAllowedOrientations +} + diff --git a/sfos/qml/pages/DevicePage.qml b/sfos/qml/pages/DevicePage.qml new file mode 100644 --- /dev/null +++ b/sfos/qml/pages/DevicePage.qml @@ -0,0 +1,82 @@ +/* + Copyright (C) 2013 Jolla Ltd. + Contact: Thomas Perl + All rights reserved. + + You may use this file under the terms of BSD license as follows: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Jolla Ltd nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import org.kde.kdeconnect 1.0 + +Page { + id: page + property QtObject currentDevice + + // The effective value will be restricted by ApplicationWindow.allowedOrientations + allowedOrientations: Orientation.Portrait + + Column { + id: column + anchors.fill: parent + spacing: Theme.paddingMedium + + PageHeader { + title: currentDevice.name + } + + Label { + anchors.horizontalCenter: parent.horizontalCenter + text: "Device is " + (currentDevice.isTrusted ? "trusted" : "not trusted") + } + + Button { + id: text + anchors.horizontalCenter: parent.horizontalCenter + text: currentDevice.isTrusted ? "Un-Pair" : "Pair" + + onClicked: { + if (currentDevice.isTrusted) { + currentDevice.unpair() + } else { + currentDevice.requestPair() + } + } + } + + Button { + anchors.horizontalCenter: parent.horizontalCenter + visible: currentDevice.isTrusted + text: qsTr("Ping") + onClicked: { + currentDevice.pluginCall("ping", "sendPing"); + } + } + } + +} + + diff --git a/sfos/qml/pages/FindDevices.qml b/sfos/qml/pages/FindDevices.qml new file mode 100644 --- /dev/null +++ b/sfos/qml/pages/FindDevices.qml @@ -0,0 +1,77 @@ +/* + Copyright (C) 2013 Jolla Ltd. + Contact: Thomas Perl + All rights reserved. + + You may use this file under the terms of BSD license as follows: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Jolla Ltd nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import org.kde.kdeconnect 1.0 + +Page { + id: page + + // The effective value will be restricted by ApplicationWindow.allowedOrientations + allowedOrientations: Orientation.Portrait + + // To enable PullDownMenu, place our content in a SilicaFlickable + SilicaListView { + anchors.fill: parent + + header: PageHeader { + title: qsTr("Devices") + } + + // Place our content in a Column. The PageHeader is always placed at the top + // of the page, followed by our content. + + id: devices + model: DevicesModel { + id: devicesModel + } + + width: page.width + spacing: Theme.paddingLarge + + + delegate: ListItem { + width: ListView.view.width + height: Theme.itemSizeMedium + + Label { text: display + "\n" + toolTip } + + onClicked: { + var devicePage = pageStack.push(Qt.resolvedUrl("DevicePage.qml"), + {currentDevice: device} + ); + } + + + } + } +} + diff --git a/sfos/qml/pages/FirstPage.qml b/sfos/qml/pages/FirstPage.qml new file mode 100644 --- /dev/null +++ b/sfos/qml/pages/FirstPage.qml @@ -0,0 +1,61 @@ +/* +Copyright (C) 2013 Jolla Ltd. +Contact: Thomas Perl +All rights reserved. + +You may use this file under the terms of BSD license as follows: + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Jolla Ltd nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import org.kde.kdeconnect 1.0 +import Nemo.Notifications 1.0 + +Page { + allowedOrientations: Orientation.Portrait + + SilicaFlickable { + anchors.fill: parent + contentHeight: column.height + + // PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView + PullDownMenu { + MenuItem { + text: qsTr("Find Devices") + onClicked: pageStack.push(Qt.resolvedUrl("FindDevices.qml")) + } + } + + Column { + id: column + width: parent.width + spacing: 20 + + PageHeader { title: "KDE Connect" } + + } + } +} + diff --git a/sfos/rpm/kdeconnect-sfos.changes.in b/sfos/rpm/kdeconnect-sfos.changes.in new file mode 100644 --- /dev/null +++ b/sfos/rpm/kdeconnect-sfos.changes.in @@ -0,0 +1,18 @@ +# Rename this file as kdeconnect-sfos.changes to include changelog +# entries in your RPM file. +# +# Add new changelog entries following the format below. +# Add newest entries to the top of the list. +# Separate entries from eachother with a blank line. +# +# Alternatively, if your changelog is automatically generated (e.g. with +# the git-change-log command provided with Sailfish OS SDK), create a +# kdeconnect-sfos.changes.run script to let mb2 run the required commands for you. + +# * date Author's Name version-release +# - Summary of changes + +* Sun Apr 13 2014 Jack Tar 0.0.1-1 +- Scrubbed the deck +- Hoisted the sails + diff --git a/sfos/rpm/kdeconnect-sfos.changes.run.in b/sfos/rpm/kdeconnect-sfos.changes.run.in new file mode 100644 --- /dev/null +++ b/sfos/rpm/kdeconnect-sfos.changes.run.in @@ -0,0 +1,25 @@ +#!/bin/bash +# +# Rename this file as kdeconnect-sfos.changes.run to let mb2 automatically +# generate changelog from well formatted Git commit messages and tag +# annotations. + +git-change-log + +# Here are some basic examples how to change from the default behavior. Run +# git-change-log --help inside the Sailfish OS SDK chroot or build engine to +# learn all the options git-change-log accepts. + +# Use a subset of tags +#git-change-log --tags refs/tags/my-prefix/* + +# Group entries by minor revision, suppress headlines for patch-level revisions +#git-change-log --dense '/[0-9]\+\.[0-9\+$' + +# Trim very old changes +#git-change-log --since 2014-04-01 +#echo '[ Some changelog entries trimmed for brevity ]' + +# Use the subjects (first lines) of tag annotations when no entry would be +# included for a revision otherwise +#git-change-log --auto-add-annotations diff --git a/sfos/rpm/kdeconnect-sfos.spec b/sfos/rpm/kdeconnect-sfos.spec new file mode 100644 --- /dev/null +++ b/sfos/rpm/kdeconnect-sfos.spec @@ -0,0 +1,78 @@ +# +# Do NOT Edit the Auto-generated Part! +# Generated by: spectacle version 0.27 +# + +Name: kdeconnect-sfos + +# >> macros +# << macros + +Summary: KDEConnect client for Sailfish +Version: 0.1 +Release: 1 +Group: Qt/Qt +License: LICENSE +URL: http://example.org/ +Source0: %{name}-%{version}.tar.bz2 +Source100: kdeconnect-sfos.yaml +Requires: sailfishsilica-qt5 >= 0.10.9 +BuildRequires: pkgconfig(sailfishapp) >= 1.0.2 +BuildRequires: pkgconfig(Qt5Core) +BuildRequires: pkgconfig(Qt5Qml) +BuildRequires: pkgconfig(Qt5Quick) +BuildRequires: desktop-file-utils +BuildRequires: cmake >= 3.0 +BuildRequires: extra-cmake-modules >= %{_tar_path} + +%description +Short description of my Sailfish OS Application + + +%prep +%setup -q + +# >> setup +# << setup + +%build +# >> build pre +# << build pre +mkdir -p build +cd build +%cmake .. -DSAILFISHOS=YES +make %{?jobs:-j%jobs} + +# >> build post +# << build post + +%install +rm -rf %{buildroot} +# >> install pre +# << install pre +pushd build +%make_install +popd + + +# >> install post +# << install post + +desktop-file-install --delete-original \ + --dir %{buildroot}%{_datadir}/applications \ + %{buildroot}%{_datadir}/applications/*.desktop + +%files +%defattr(-,root,root,-) +%{_bindir} +%{_libdir} +%{_datadir}/%{name} +%{_datadir}/applications/%{name}.desktop +/etc/xdg/autostart/kdeconnectd.desktop +/usr/share/dbus-1/services/org.kde.kdeconnect.service +/usr/share/knotifications5/kdeconnect.notifyrc +/usr/share/kservicetypes5/kdeconnect_plugin.desktop +#%{_datadir}/icons/hicolor/*/apps/%{name}.png +/usr/share/icons/ +# >> files +# << files diff --git a/sfos/sailfishdaemon.h b/sfos/sailfishdaemon.h new file mode 100644 --- /dev/null +++ b/sfos/sailfishdaemon.h @@ -0,0 +1,85 @@ +/** + * Copyright 2018 Adam Pigg + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include +#include + +#include "core/daemon.h" +#include "core/device.h" +#include "core/backends/pairinghandler.h" +#include "kdeconnect-version.h" + +#include + +class SailfishDaemon : public Daemon +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.daemon") +public: + SailfishDaemon(QObject* parent = Q_NULLPTR) + : Daemon(parent) + , m_nam(Q_NULLPTR) + {} + + void askPairingConfirmation(Device* device) override + { + qDebug() << "Pairing request from " << device->name().toHtmlEscaped(); + + Notification *notification = new Notification(this); + + notification->setAppName(QCoreApplication::applicationName()); + notification->setPreviewSummary(i18n("Pairing request from %1", device->name().toHtmlEscaped())); + notification->setPreviewBody(i18n("Click here to pair")); + notification->setIcon("icon-s-sync"); + notification->setExpireTimeout(10000); + + connect(notification, &Notification::closed, + [=]( uint reason ) { + qDebug() << "Notification closed" << reason; + if (reason == 2) { //clicked + device->acceptPairing(); + } else { + device->rejectPairing(); + } + }); + + notification->publish(); + } + + void reportError(const QString & title, const QString & description) override + { + qDebug() << "Error: " << title << ":" << description; + } + + QNetworkAccessManager* networkAccessManager() override + { + if (!m_nam) { + m_nam = new QNetworkAccessManager(this); + } + return m_nam; + } + +private: + QNetworkAccessManager* m_nam; +};