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,18 +50,22 @@ 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 SAILFISHOS) + add_subdirectory(kcm) + add_subdirectory(kcmplugin) +endif() + if(NOT WIN32) - add_subdirectory(kio) + if (NOT SAILFISHOS) + add_subdirectory(kio) + endif() add_subdirectory(plasmoid) endif() + add_subdirectory(icon) add_subdirectory(interfaces) @@ -52,16 +76,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 +#if QT_VERSION < 0x050700 +#include "qasconst.h" +#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 +#if QT_VERSION < 0x050700 +#include "qasconst.h" +#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 +#if QT_VERSION < 0x050700 +#include "qasconst.h" +#endif + PluginLoader* PluginLoader::instance() { static PluginLoader* instance = new PluginLoader(); diff --git a/core/qasconst.h b/core/qasconst.h new file mode 100644 --- /dev/null +++ b/core/qasconst.h @@ -0,0 +1,11 @@ +#ifndef QASCONST_H +#define QASCONST_H + +// this adds const to non-const objects (like std::as_const) +template +Q_DECL_CONSTEXPR typename std::add_const::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; } +// prevent rvalue arguments: +template +void qAsConst(const T &&) Q_DECL_EQ_DELETE; + +#endif 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/CMakeLists.txt b/plasmoid/CMakeLists.txt --- a/plasmoid/CMakeLists.txt +++ b/plasmoid/CMakeLists.txt @@ -1,9 +1,11 @@ add_subdirectory(declarativeplugin) +if (NOT SAILFISHOS) install(DIRECTORY package/ DESTINATION ${DATA_INSTALL_DIR}/plasma/plasmoids/org.kde.kdeconnect) install(FILES package/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME plasma-kdeconnect.desktop) +endif() 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,25 +3,30 @@ 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) +add_subdirectory(sendnotifications) + +if(NOT SAILFISHOS) + add_subdirectory(clipboard) + add_subdirectory(share) + add_subdirectory(remotekeyboard) + add_subdirectory(notifications) + add_subdirectory(findmyphone) + add_subdirectory(telephony) + + if(WIN32) + add_subdirectory(mousepad_windows) + else() + add_subdirectory(runcommand) + add_subdirectory(pausemusic) + add_subdirectory(mpriscontrol) + add_subdirectory(mousepad) + add_subdirectory(screensaver-inhibit) + add_subdirectory(sftp) + endif() endif() -if(EXPERIMENTALAPP_ENABLED) + +if(SAILFISHOS OR EXPERIMENTALAPP_ENABLED) add_subdirectory(remotecommands) add_subdirectory(mprisremote) add_subdirectory(remotecontrol) diff --git a/plugins/battery/CMakeLists.txt b/plugins/battery/CMakeLists.txt --- a/plugins/battery/CMakeLists.txt +++ b/plugins/battery/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_battery_SRCS batteryplugin.cpp @@ -11,5 +18,5 @@ kdeconnectcore Qt5::DBus KF5::I18n - KF5::Notifications + ${NOTIFICATION_LIB} ) diff --git a/plugins/battery/batteryplugin.cpp b/plugins/battery/batteryplugin.cpp --- a/plugins/battery/batteryplugin.cpp +++ b/plugins/battery/batteryplugin.cpp @@ -20,8 +20,13 @@ #include "batteryplugin.h" +#ifdef SAILFISHOS +#include +#include +#else #include -#include +#endif + #include #include @@ -71,12 +76,22 @@ } if ( thresholdEvent == ThresholdBatteryLow && !isCharging ) { +#ifdef SAILFISHOS + Notification *notification = new Notification(this); + + notification->setAppName(QCoreApplication::applicationName()); + notification->setPreviewSummary(i18nc("device name: low battery", "%1: Low Battery", device()->name())); + notification->setPreviewBody(i18n("Battery at %1%", currentCharge)); + notification->setIcon("icon-m-battery"); + notification->publish(); +#else KNotification* notification = new KNotification(QStringLiteral("batteryLow")); notification->setIconName(QStringLiteral("battery-040")); notification->setComponentName(QStringLiteral("kdeconnect")); notification->setTitle(i18nc("device name: low battery", "%1: Low Battery", device()->name())); notification->setText(i18n("Battery at %1%", currentCharge)); notification->sendEvent(); +#endif } return true; 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/plugins/sendnotifications/CMakeLists.txt b/plugins/sendnotifications/CMakeLists.txt --- a/plugins/sendnotifications/CMakeLists.txt +++ b/plugins/sendnotifications/CMakeLists.txt @@ -1,4 +1,13 @@ +if (SAILFISHOS) +find_package(KF5 REQUIRED COMPONENTS I18n Config IconThemes) +pkg_check_modules(NNQT5 REQUIRED nemonotifications-qt5) +set(NOTIFICATION_LIB ${NNQT5_LIBRARIES}) +include_directories(${NNQT5_INCLUDE_DIRS}) + +else() find_package(KF5 REQUIRED COMPONENTS Notifications KCMUtils I18n IconThemes) +set(NOTIFICATION_LIB KF5::Notifications) +endif() set(kdeconnect_sendnotifications_SRCS sendnotificationsplugin.cpp @@ -11,15 +20,16 @@ target_link_libraries(kdeconnect_sendnotifications kdeconnectcore Qt5::DBus - KF5::Notifications + ${NOTIFICATION_LIB} KF5::I18n + Qt5::Gui KF5::IconThemes KF5::ConfigCore ) ####################################### # Config - +if (NOT SAILFISHOS) set( kdeconnect_sendnotifications_config_SRCS sendnotifications_config.cpp notifyingapplication.cpp @@ -37,3 +47,4 @@ install( TARGETS kdeconnect_sendnotifications_config DESTINATION ${PLUGIN_INSTALL_DIR} ) install( FILES kdeconnect_sendnotifications_config.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) +endif() diff --git a/plugins/sendnotifications/kdeconnect_sendnotifications_sfos.json b/plugins/sendnotifications/kdeconnect_sendnotifications_sfos.json new file mode 100644 --- /dev/null +++ b/plugins/sendnotifications/kdeconnect_sendnotifications_sfos.json @@ -0,0 +1,96 @@ +{ + "Encoding": "UTF-8", + "KPlugin": { + "Authors": [ + { + "Email": "holger.k@elberer.de", + "Name": "Holger Kaelberer", + "Name[sr@ijekavian]": "Холгер Келберер", + "Name[sr@ijekavianlatin]": "Holger Kelberer", + "Name[sr@latin]": "Holger Kelberer", + "Name[sr]": "Холгер Келберер", + "Name[x-test]": "xxHolger Kaelbererxx" + } + ], + "Description": "Broadcast this computer's notifications, so they can be shown on other devices.", + "Description[ar]": "بُثّ إخطارات هذا الحاسوب، لتظهر على الأجهزة الأخرى.", + "Description[ca@valencia]": "Transmet les notificacions d'este ordinador, perquè puguen mostrar-se en altres dispositius.", + "Description[ca]": "Transmet les notificacions d'aquest ordinador, perquè puguin mostrar-se en altres dispositius.", + "Description[cs]": "Posílat upozornění tohoto počítače, takže mohou být zobrazena na jiných zařízeních.", + "Description[da]": "Udsend denne computers bekendtgørelser, så de kan vises på andre enheder.", + "Description[de]": "Die Benachrichtigungen dieses Rechners aussenden, sodass sie auf anderen Geräten angezeigt werden können.", + "Description[el]": "Μεταδώστε την ειδοποίηση αυτού του υπολογιστή, ώστε να εμφανιστεί σε άλλες συσκευές.", + "Description[es]": "Difundir las notificaciones de este equipo, para que puedan mostrarse en otros dispositivos.", + "Description[et]": "Arvuti märguannete levitamine, et neid oleks näha ka teistes seadmetes", + "Description[eu]": "Hedatu ordenagailu honen jakinarazpenak, beste gailuetan erakutsi ahal izateko", + "Description[fi]": "Lähetä tämän tietokoneen ilmoitukset, jotta ne voidaan näyttää muilla laitteilla.", + "Description[fr]": "Diffuser les notifications de cet ordinateur pour qu'elles puissent être vues par d'autres périphériques.", + "Description[gl]": "Emitir as notificacións deste computador para que se mostren noutros dispositivos.", + "Description[it]": "Trasmetti le notifiche di questo computer, affinché possano essere mostrate su altri dispositivi.", + "Description[ko]": "이 컴퓨터의 알림을 다른 장치에도 표시합니다.", + "Description[nl]": "De meldingen van deze computer rondsturen, zodat ze op andere apparaten getoond kunnen worden.", + "Description[nn]": "Vidaresend varslingar frå datamaskina til andre einingar.", + "Description[pl]": "Rozgłaszaj powiadomienia tego komputera, tak aby można je było wyświetlać na innych urządzeniach.", + "Description[pt]": "Difunde as notificações deste computador, para que possam ser apresentadas noutros dispositivos.", + "Description[ru]": "Трансляция уведомления с этого компьютера, чтобы они могли быть видны на других устройствах", + "Description[sk]": "Vysielať upozornenia tohto počítača, aby sa zobrazili na druhom zariadení.", + "Description[sr@ijekavian]": "Одашиље обавештења са овог рачунара, да се приказују на осталим уређајима.", + "Description[sr@ijekavianlatin]": "Odašilje obaveštenja sa ovog računara, da se prikazuju na ostalim uređajima.", + "Description[sr@latin]": "Odašilje obaveštenja sa ovog računara, da se prikazuju na ostalim uređajima.", + "Description[sr]": "Одашиље обавештења са овог рачунара, да се приказују на осталим уређајима.", + "Description[sv]": "Sänd ut datorns underrättelser så att de kan visas på andra enheter.", + "Description[tr]": "Bu bilgisayarın bildirimlerini yayınlayın, böylece diğer cihazlarda gösterilebilirler.", + "Description[uk]": "Транслювати сповіщення з цього комп’ютера так, щоб їх було показано на інших пристроях.", + "Description[x-test]": "xxBroadcast this computer's notifications, so they can be shown on other devices.xx", + "Description[zh_CN]": "广播此计算机的通知,以被其他设备显示。", + "Description[zh_TW]": "廣播此電腦的通知,這樣可以顯示在其他裝置上。", + "EnabledByDefault": true, + "Icon": "preferences-desktop-notification", + "Id": "kdeconnect_sendnotifications", + "License": "GPL", + "Name": "Send notifications", + "Name[ar]": "أرسل إخطارات", + "Name[ca@valencia]": "Envia les notificacions", + "Name[ca]": "Envia les notificacions", + "Name[cs]": "Posílat oznamování", + "Name[da]": "Send bekendtgørelser", + "Name[de]": "Benachrichtigungen senden", + "Name[el]": "Αποστολή ειδοποιήσεων", + "Name[es]": "Enviar notificaciones", + "Name[et]": "Märguannete saatmine", + "Name[eu]": "Bidali jakinarazpenak", + "Name[fi]": "Lähetä ilmoituksia", + "Name[fr]": "Envoyer les notifications", + "Name[gl]": "Enviar notificacións", + "Name[it]": "Invia notifiche", + "Name[ko]": "알림 보내기", + "Name[nl]": "Stuur meldingen", + "Name[nn]": "Send varslingar", + "Name[pl]": "Wysyłaj powiadomienia", + "Name[pt]": "Enviar as notificações", + "Name[pt_BR]": "Enviar notificações", + "Name[ru]": "Отправка уведомлений", + "Name[sk]": "Posielať upozornenia", + "Name[sr@ijekavian]": "Шаљи обавештења", + "Name[sr@ijekavianlatin]": "Šalji obaveštenja", + "Name[sr@latin]": "Šalji obaveštenja", + "Name[sr]": "Шаљи обавештења", + "Name[sv]": "Skicka underrättelser", + "Name[tr]": "Bildirim gönder", + "Name[uk]": "Надіслати сповіщення", + "Name[x-test]": "xxSend notificationsxx", + "Name[zh_CN]": "发送通知", + "Name[zh_TW]": "傳送通知", + "ServiceTypes": [ + "KdeConnect/Plugin" + ], + "Version": "0.1", + "Website": "http://albertvaka.wordpress.com" + }, + "X-KdeConnect-OutgoingPackageType": [ + "kdeconnect.notification" + ], + "X-KdeConnect-SupportedPackageType": [ + "kdeconnect.notification.request" + ] +} diff --git a/plugins/sendnotifications/notificationslistener.cpp b/plugins/sendnotifications/notificationslistener.cpp --- a/plugins/sendnotifications/notificationslistener.cpp +++ b/plugins/sendnotifications/notificationslistener.cpp @@ -27,7 +27,6 @@ #include #include #include - #include #include @@ -39,6 +38,11 @@ #include "sendnotification_debug.h" #include "notifyingapplication.h" +//In older Qt released, qAsConst isnt available +#if QT_VERSION < 0x050700 +#include "qasconst.h" +#endif + NotificationsListener::NotificationsListener(KdeConnectPlugin* aPlugin) : QDBusAbstractAdaptor(aPlugin), m_plugin(aPlugin) @@ -179,6 +183,7 @@ return QSharedPointer(new QFile(iconPath)); return QSharedPointer(); } + uint NotificationsListener::Notify(const QString& appName, uint replacesId, const QString& appIcon, const QString& summary, const QString& body, diff --git a/plugins/sendnotifications/sendnotificationsplugin.cpp b/plugins/sendnotifications/sendnotificationsplugin.cpp --- a/plugins/sendnotifications/sendnotificationsplugin.cpp +++ b/plugins/sendnotifications/sendnotificationsplugin.cpp @@ -25,7 +25,11 @@ #include +#ifdef SAILFISHOS +K_PLUGIN_FACTORY_WITH_JSON( KdeConnectPluginFactory, "kdeconnect_sendnotifications_sfos.json", registerPlugin< SendNotificationsPlugin >(); ) +#else K_PLUGIN_FACTORY_WITH_JSON( KdeConnectPluginFactory, "kdeconnect_sendnotifications.json", registerPlugin< SendNotificationsPlugin >(); ) +#endif Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_SENDNOTIFICATION, "kdeconnect.plugin.sendnotification") 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,66 @@ +/* + 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 + +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()); + + 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,48 @@ +/* + 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 + + Keys.onPressed: { + if (event.key == Qt.Key_Back) { + console.log("back"); + pageStack.pop(); + } + } +} + 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; +};