[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:28:04 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=21ab5a4
The following commit has been merged in the master branch:
commit 21ab5a4f81a69821ac61bad344015c79fb40b38c
Merge: 1a1969f42f24b73334064590ca7d774b7e57042e 3b192ea18e150f55f69a61bb3c155a9257130a5b
Author: Aleix Pol <aleixpol at kde.org>
Date: Tue Nov 4 19:12:29 2014 +0100
Merge branch 'master' into frameworks
Mostly kDebug -> qCDebug
Also some KCmdLineArgs -> QCommandLineParser
Conflicts:
cli/kdeconnect-cli.cpp
core/CMakeLists.txt
core/backends/lan/lanlinkprovider.cpp
core/daemon.cpp
core/pluginloader.cpp
interfaces/CMakeLists.txt
kio/kiokdeconnect.cpp
plugins/mousepad/CMakeLists.txt
plugins/mousepad/mousepadplugin.h
plugins/mpriscontrol/mpriscontrolplugin.cpp
plugins/sftp/sftpplugin.cpp
cli/kdeconnect-cli.cpp | 10 +-
cmake/FindLibFakeKey.cmake | 59 ++++++++++
core/CMakeLists.txt | 1 +
core/backends/devicelink.cpp | 1 -
core/backends/lan/lanlinkprovider.cpp | 30 +++--
core/backends/linkprovider.h | 2 +-
core/daemon.cpp | 36 +++---
core/{backends/linkprovider.cpp => dbushelper.cpp} | 14 ++-
core/{backends/linkprovider.cpp => dbushelper.h} | 12 +-
core/default_args.h | 8 --
core/device.cpp | 26 ++++-
core/device.h | 3 +
core/filetransferjob.cpp | 2 +-
core/networkpackage.cpp | 14 ++-
core/networkpackage.h | 2 +-
core/pluginloader.cpp | 34 ++++--
core/pluginloader.h | 13 +--
fileitemactionplugin/kdeconnectsendfile.desktop | 6 +
interfaces/CMakeLists.txt | 5 +-
kcm/devicessortproxymodel.h | 2 +-
kcm/kcm.cpp | 9 +-
kcm/kcm.h | 1 +
kcm/kcm.ui | 10 +-
kcm/kcm_kdeconnect.desktop | 3 +
kcm/kdeconnect.desktop | 2 +
kded/kdeconnect.desktop | 2 +
kded/kdeconnect.notifyrc | 16 +++
kio/kiokdeconnect.cpp | 49 ++++----
plasmoid/package/metadata.desktop | 2 +
plugins/battery/kdeconnect_battery.desktop | 4 +-
plugins/clipboard/kdeconnect_clipboard.desktop | 2 +
plugins/kdeconnect_plugin.desktop | 3 +-
plugins/mousepad/CMakeLists.txt | 5 +-
plugins/mousepad/kdeconnect_mousepad.desktop | 32 +++++
plugins/mousepad/mousepadplugin.cpp | 129 ++++++++++++++++-----
plugins/mousepad/mousepadplugin.h | 12 +-
.../mpriscontrol/kdeconnect_mpriscontrol.desktop | 2 +
plugins/mpriscontrol/mpriscontrolplugin.cpp | 3 +-
.../notifications/kdeconnect_notifications.desktop | 2 +
plugins/pausemusic/kdeconnect_pausemusic.desktop | 2 +
.../kdeconnect_pausemusic_config.desktop | 1 +
plugins/pausemusic/pausemusic_config.cpp | 15 ++-
plugins/pausemusic/pausemusic_config.ui | 50 +++++---
plugins/pausemusic/pausemusicplugin.cpp | 28 +++--
plugins/pausemusic/pausemusicplugin.h | 1 +
plugins/ping/README | 3 +-
plugins/ping/kdeconnect_ping.desktop | 2 +
plugins/ping/pingplugin.cpp | 11 +-
plugins/ping/pingplugin.h | 1 +
plugins/sftp/kdeconnect_sftp.desktop | 4 +-
plugins/sftp/kdeconnect_sftp_config.desktop | 1 +
plugins/sftp/mounter.cpp | 8 +-
plugins/sftp/sftp_config.cpp | 1 -
plugins/sftp/sftpplugin.cpp | 24 +++-
plugins/sftp/sftpplugin.h | 9 +-
plugins/share/kdeconnect_share.desktop | 2 +
plugins/share/kdeconnect_share_config.desktop | 1 +
plugins/share/shareplugin.cpp | 2 +-
plugins/telephony/kdeconnect_telephony.desktop | 2 +
plugins/telephony/telephonyplugin.cpp | 5 +-
tests/testsocketlinereader.cpp | 3 +
61 files changed, 550 insertions(+), 194 deletions(-)
diff --cc cli/kdeconnect-cli.cpp
index d899968,e7779c4..8d6d698
--- a/cli/kdeconnect-cli.cpp
+++ b/cli/kdeconnect-cli.cpp
@@@ -30,27 -31,26 +30,28 @@@
int main(int argc, char** argv)
{
- KAboutData about("kdeconnect-cli", "kdeconnect-cli", ki18n(("kdeconnect-cli")), "1.0", ki18n("KDE Connect CLI tool"),
- KAboutData::License_GPL, ki18n("(C) 2013 Aleix Pol Gonzalez"));
- about.addAuthor( ki18n("Aleix Pol Gonzalez"), KLocalizedString(), "aleixpol at kde.org" );
- about.addAuthor( ki18n("Albert Vaca Cintora"), KLocalizedString(), "albertvaka at gmail.com" );
- KCmdLineArgs::init(argc, argv, &about);
- KCmdLineOptions options;
- options.add("l")
- .add("list-devices", ki18n("List all devices."));
- options.add("refresh", ki18n("Search for devices in the network and re-establish connections."));
- options.add("pair", ki18n("Request pairing to a said device."));
- options.add("unpair", ki18n("Stop pairing to a said device."));
- options.add("ping", ki18n("Send a ping to said device."));
- options.add("ping-msg <message>", ki18n("Same as ping but you can customize the shown message."));
- options.add("share <path>", ki18n("Share a file to a said device."));
- options.add("list-notifications", ki18n("Display the notifications on a said device."));
- options.add("device <dev>", ki18n("Device ID."));
- KCmdLineArgs::addCmdLineOptions( options );
- KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
- KApplication app;
- if(args->isSet("l")) {
+ QGuiApplication app(argc, argv);
+ KAboutData about("kdeconnect-cli", i18n("kdeconnect-cli"), "1.0", i18n("KDE Connect CLI tool"),
+ KAboutLicense::GPL, i18n("(C) 2013 Aleix Pol Gonzalez"));
+ KAboutData::setApplicationData(about);
+
+ about.addAuthor( i18n("Aleix Pol Gonzalez"), QString(), "aleixpol at kde.org" );
+ QCommandLineParser parser;
+ parser.addOption(QCommandLineOption(QStringList("l") << "list-devices", i18n("List all devices")));
+ parser.addOption(QCommandLineOption("share", i18n("Share a file to a said device"), "path"));
+ parser.addOption(QCommandLineOption("pair", i18n("Request pairing to a said device")));
+ parser.addOption(QCommandLineOption("unpair", i18n("Stop pairing to a said device")));
+ parser.addOption(QCommandLineOption("ping", i18n("Sends a ping to said device")));
+ parser.addOption(QCommandLineOption("list-notifications", i18n("Display the notifications on a said device")));
++ parser.addOption(QCommandLineOption("ping-msg <message>", i18n("Same as ping but you can customize the shown message."), i18n("message")));
+ parser.addOption(QCommandLineOption("device", i18n("Device ID"), "dev"));
+ about.setupCommandLine(&parser);
+
+ parser.addHelpOption();
+ parser.process(app);
+ about.processCommandLine(&parser);
+
+ if(parser.isSet("l")) {
DevicesModel devices;
for(int i=0, rows=devices.rowCount(); i<rows; ++i) {
QModelIndex idx = devices.index(i);
@@@ -70,16 -70,19 +71,19 @@@
<< ": " << idx.data(DevicesModel::IdModelRole).toString().toStdString() << ' ' << statusInfo.toStdString() << std::endl;
}
std::cout << devices.rowCount() << " devices found" << std::endl;
- } else if(args->isSet("refresh")) {
++ } else if(parser.isSet("refresh")) {
+ QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect", "org.kde.kdeconnect.daemon", "forceOnNetworkChange");
+ QDBusConnection::sessionBus().call(msg);
} else {
QString device;
- if(!args->isSet("device")) {
- KCmdLineArgs::usageError(i18n("No device specified"));
+ if(!parser.isSet("device")) {
+ qCritical() << (i18n("No device specified"));
}
- device = args->getOption("device");
+ device = parser.value("device");
QUrl url;
- if(args->isSet("share")) {
- url = args->makeURL(args->getOption("share").toLatin1());
- args->clear();
+ if(parser.isSet("share")) {
+ url = QUrl::fromUserInput(parser.value("share"));
+ parser.clearPositionalArguments();
if(!url.isEmpty() && !device.isEmpty()) {
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+device+"/share", "org.kde.kdeconnect.device.share", "shareUrl");
msg.setArguments(QVariantList() << url.toString());
@@@ -102,10 -105,14 +106,14 @@@
QDBusPendingReply<void> req = dev.unpair();
req.waitForFinished();
}
- } else if(parser.isSet("ping")) {
- } else if(args->isSet("ping") || args->isSet("ping-msg")) {
++ } else if(parser.isSet("ping") || parser.isSet("ping-msg")) {
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+device+"/ping", "org.kde.kdeconnect.device.ping", "sendPing");
- if (args->isSet("ping-msg")) {
- QString message = args->getOption("ping-msg");
++ if (parser.isSet("ping-msg")) {
++ QString message = parser.value("ping-msg");
+ msg.setArguments(QVariantList() << message);
+ }
QDBusConnection::sessionBus().call(msg);
- } else if(args->isSet("list-notifications")) {
+ } else if(parser.isSet("list-notifications")) {
NotificationsModel notifications;
notifications.setDeviceId(device);
for(int i=0, rows=notifications.rowCount(); i<rows; ++i) {
diff --cc core/backends/lan/lanlinkprovider.cpp
index f352aea,39d3037..b77101f
--- a/core/backends/lan/lanlinkprovider.cpp
+++ b/core/backends/lan/lanlinkprovider.cpp
@@@ -30,6 -29,10 +30,9 @@@
#include <QTcpServer>
#include <QUdpSocket>
+ #include <KSharedConfig>
+ #include <KConfigGroup>
+
-#include "../../kdebugnamespace.h"
#include "landevicelink.h"
void LanLinkProvider::configureSocket(QTcpSocket* socket)
@@@ -181,10 -193,9 +192,9 @@@ void LanLinkProvider::connected(
bool success = deviceLink->sendPackage(np2);
- //TODO: Use reverse connection too to preffer connecting a unstable device (a phone) to a stable device (a computer)
if (success) {
- //kDebug(debugArea()) << "Handshaking done (i'm the existing device)";
+ //qCDebug(KDECONNECT_CORE) << "Handshaking done (i'm the existing device)";
connect(deviceLink, SIGNAL(destroyed(QObject*)),
this, SLOT(deviceLinkDestroyed(QObject*)));
diff --cc core/daemon.cpp
index 20afff2,57548e5..3bf4d1c
--- a/core/daemon.cpp
+++ b/core/daemon.cpp
@@@ -27,13 -27,14 +27,15 @@@
#include <QNetworkSession>
#include <QNetworkConfigurationManager>
#include <QtCrypto>
+#include <QStandardPaths>
+ #include <QNetworkAccessManager>
#include <KConfig>
#include <KConfigGroup>
-#include <KStandardDirs>
+#include <KSharedConfig>
+#include "core_debug.h"
+ #include "dbushelper.h"
-#include "kdebugnamespace.h"
#include "networkpackage.h"
#include "backends/lan/lanlinkprovider.h"
#include "backends/loopback/loopbacklinkprovider.h"
@@@ -60,22 -63,23 +62,23 @@@ Daemon::Daemon(QObject *parent
: QObject(parent)
, d(new DaemonPrivate)
{
- kDebug(debugArea()) << "KdeConnect daemon starting";
++ qCDebug(KDECONNECT_CORE) << "KdeConnect daemon starting";
+
KSharedConfigPtr config = KSharedConfig::openConfig("kdeconnectrc");
if (!config->group("myself").hasKey("id")) {
QString uuid = QUuid::createUuid().toString();
- //uuids contain charcaters that are not exportable in dbus paths
- uuid = uuid.mid(1, uuid.length() - 2).replace("-", "_");
+ DbusHelper::filterNonExportableCharacters(uuid);
config->group("myself").writeEntry("id", uuid);
config->sync();
- kDebug(debugArea()) << "My id:" << uuid;
+ qCDebug(KDECONNECT_CORE) << "My id:" << uuid;
}
- //kDebug(debugArea()) << "QCA supported capabilities:" << QCA::supportedFeatures().join(",");
+ //qCDebug(KDECONNECT_CORE) << "QCA supported capabilities:" << QCA::supportedFeatures().join(",");
if(!QCA::isSupported("rsa")) {
- //TODO: Maybe display this in a more visible way?
+ //TODO: Display this in a notification or another visible way
- kWarning(debugArea()) << "Error: KDE Connect could not find support for RSA in your QCA installation, if your distribution provides"
- << "separate packages for QCA-ossl and QCA-gnupg plugins, make sure you have them installed and try again.";
+ qCDebug(KDECONNECT_CORE) << "Error: KDE Connect could not find support for RSA in your QCA installation, if your distribution provides"
+ << "separate packages for QCA-ossl and QCA-gnupg plugins, make sure you have them installed and try again";
return;
}
@@@ -109,14 -114,14 +113,15 @@@
config->group("myself").writeEntry("privateKeyPath", privateKeyPath);
config->sync();
}
+
if (QFile::permissions(config->group("myself").readEntry("privateKeyPath")) != strict)
{
- kWarning(debugArea()) << "Error: KDE Connect detects wrong permissions for private file " << config->group("myself").readEntry("privateKeyPath");
+ qCDebug(KDECONNECT_CORE) << "Error: KDE Connect detects wrong permissions for private file " << config->group("myself").readEntry("privateKeyPath");
}
- //Debugging
- qCDebug(KDECONNECT_CORE) << "Starting KdeConnect daemon";
+ //Register on DBus
+ QDBusConnection::sessionBus().registerService("org.kde.kdeconnect");
+ QDBusConnection::sessionBus().registerObject("/modules/kdeconnect", this, QDBusConnection::ExportScriptableContents);
//Load backends (hardcoded by now, should be plugins in a future)
d->mLinkProviders.insert(new LanLinkProvider());
@@@ -139,14 -143,19 +143,19 @@@
connect(a, SIGNAL(onConnectionReceived(NetworkPackage, DeviceLink*)),
this, SLOT(onNewDeviceLink(NetworkPackage, DeviceLink*)));
}
-
- QDBusConnection::sessionBus().registerService("org.kde.kdeconnect");
- QDBusConnection::sessionBus().registerObject("/modules/kdeconnect", this, QDBusConnection::ExportScriptableContents);
-
setDiscoveryEnabled(true);
+ //Listen to connectivity changes
+ QNetworkConfigurationManager* manager = new QNetworkConfigurationManager();
+ QNetworkSession* network = new QNetworkSession(manager->defaultConfiguration());
+ connect(manager, SIGNAL(configurationAdded(QNetworkConfiguration)),
+ this, SLOT(forceOnNetworkChange()));
+ Q_FOREACH (LinkProvider* a, d->mLinkProviders) {
+ connect(network, SIGNAL(stateChanged(QNetworkSession::State)),
+ a, SLOT(onNetworkChange(QNetworkSession::State)));
+ }
+
- kDebug(debugArea()) << "KdeConnect daemon started";
++ qCDebug(KDECONNECT_CORE) << "KdeConnect daemon started";
}
void Daemon::setDiscoveryEnabled(bool b)
diff --cc core/device.h
index d154300,82ecd81..2ebb403
--- a/core/device.h
+++ b/core/device.h
@@@ -24,6 -24,6 +24,7 @@@
#include <QObject>
#include <QString>
#include <QMap>
++#include <QSet>
#include <QSslKey>
#include <QTimer>
#include <QtCrypto>
diff --cc core/filetransferjob.cpp
index acb7d45,8d1cb69..7e0b2a8
--- a/core/filetransferjob.cpp
+++ b/core/filetransferjob.cpp
@@@ -190,9 -190,9 +190,9 @@@ void FileTransferJob::sourceFinished(
//Make sure we do not enter this function again
disconnect(mOrigin.data(), SIGNAL(aboutToClose()),this, SLOT(sourceFinished()));
- //TODO: MD5 check the file
+ //TODO: MD5-check the file
if (mSize > -1 && mWritten != mSize) {
- kDebug(debugArea()) << "Received incomplete file (" << mWritten << " of " << mSize << " bytes)";
+ qCDebug(KDECONNECT_CORE) << "Received incomplete file (" << mWritten << " of " << mSize << " bytes)";
setError(1);
setErrorText(i18n("Received incomplete file"));
} else {
diff --cc core/networkpackage.cpp
index bea3eaa,db44658..02a1945
--- a/core/networkpackage.cpp
+++ b/core/networkpackage.cpp
@@@ -31,11 -28,13 +31,13 @@@
#include <QHostInfo>
#include <QSslKey>
#include <QDateTime>
+#include <qjsondocument.h>
#include <QtCrypto>
-#include <qjson/serializer.h>
-#include <qjson/qobjecthelper.h>
+#include <QDebug>
+ #include "dbushelper.h"
#include "filetransferjob.h"
+ #include "pluginloader.h"
const QCA::EncryptionAlgorithm NetworkPackage::EncryptionAlgorithm = QCA::EME_PKCS1v15;
const int NetworkPackage::ProtocolVersion = 5;
diff --cc core/pluginloader.cpp
index b374ac7,12d7864..37bd4ba
--- a/core/pluginloader.cpp
+++ b/core/pluginloader.cpp
@@@ -78,10 -77,9 +77,9 @@@ KdeConnectPlugin* PluginLoader::instant
QVariant deviceVariant = QVariant::fromValue<Device*>(device);
- //FIXME any reason to use QObject in template param instead KdeConnectPlugin?
- ret.plugin = factory->create<KdeConnectPlugin>(device, QVariantList() << deviceVariant << ret.outgoingInterfaces);
- if (!ret.plugin) {
+ ret = factory->create<KdeConnectPlugin>(device, QVariantList() << deviceVariant << outgoingInterfaces);
+ if (!ret) {
- kDebug(debugArea()) << "Error loading plugin";
+ qCDebug(KDECONNECT_CORE) << "Error loading plugin";
return ret;
}
diff --cc interfaces/CMakeLists.txt
index bf2662f,174c659..9a3dd71
--- a/interfaces/CMakeLists.txt
+++ b/interfaces/CMakeLists.txt
@@@ -69,10 -69,13 +69,11 @@@ add_dependencies(kdeconnectinterface
)
target_link_libraries(kdeconnectinterfaces
- Qt5::Core
- Qt5::DBus
+ LINK_PUBLIC
- ${QT_QTCORE_LIBRARY}
- ${QT_QTDBUS_LIBRARY}
+ Qt5::Gui
++ Qt5::DBus
+ LINK_PRIVATE
- ${KDE4_KDEUI_LIBS}
- ${KDE4_KDECORE_LIBS}
- ${QJSON_LIBRARIES}
+ KF5::ConfigCore
)
configure_file(KDEConnectConfig.cmake.in ${CMAKE_BINARY_DIR}/interfaces/KDEConnectConfig.cmake @ONLY)
diff --cc kio/kiokdeconnect.cpp
index 0d393ca,b742093..707d19d
--- a/kio/kiokdeconnect.cpp
+++ b/kio/kiokdeconnect.cpp
@@@ -143,27 -151,25 +141,24 @@@ void KioKdeconnect::listDevice(
return;
}
- QString url = urlreply.value();
+ QVariantMap urls = urlreply.value();
- KIO::UDSEntry entry;
- entry.insert(KIO::UDSEntry::UDS_NAME, "files");
- entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, i18n("Camera pictures"));
- entry.insert(KIO::UDSEntry::UDS_ICON_NAME, "folder");
- entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
- entry.insert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IRGRP | S_IROTH);
- entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, "");
- entry.insert(KIO::UDSEntry::UDS_URL, url + "/DCIM/Camera");
- listEntry(entry);
-
- entry.insert(KIO::UDSEntry::UDS_NAME, "files");
- entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, i18n("All files"));
- entry.insert(KIO::UDSEntry::UDS_ICON_NAME, "folder");
- entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
- entry.insert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IRGRP | S_IROTH);
- entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, "");
- entry.insert(KIO::UDSEntry::UDS_URL, url);
- listEntry(entry);
+ for (QVariantMap::iterator it = urls.begin(); it != urls.end(); it++) {
+
+ QString path = it.key();
+ QString name = it.value().toString();
+
+ KIO::UDSEntry entry;
+ entry.insert(KIO::UDSEntry::UDS_NAME, "files");
+ entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, name);
+ entry.insert(KIO::UDSEntry::UDS_ICON_NAME, "folder");
+ entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
+ entry.insert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IRGRP | S_IROTH);
+ entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, "");
+ entry.insert(KIO::UDSEntry::UDS_URL, path);
+ listEntry(entry, false);
+ }
- listEntry(KIO::UDSEntry(), true);
infoMessage("");
finished();
diff --cc plugins/mousepad/CMakeLists.txt
index abba697,02f36ab..a0994fb
--- a/plugins/mousepad/CMakeLists.txt
+++ b/plugins/mousepad/CMakeLists.txt
@@@ -4,12 -4,18 +4,13 @@@ set(kdeconnect_mousepad_SRC
find_package(XTest REQUIRED)
find_package(X11 REQUIRED)
+ find_package(LibFakeKey REQUIRED)
-kde4_add_plugin(kdeconnect_mousepad ${kdeconnect_mousepad_SRCS})
+add_library(kdeconnect_mousepad MODULE ${kdeconnect_mousepad_SRCS})
- include_directories(${XTEST_INCLUDE_DIRS} ${X11_INCLUDE_DIR})
+ include_directories(${XTEST_INCLUDE_DIRS} ${X11_INCLUDE_DIR} ${LibFakeKey_INCLUDE_DIRS})
- target_link_libraries(kdeconnect_mousepad KF5::Service kdeconnectcore Qt5::Gui ${X11_LIBRARIES} ${XTEST_LIBRARIES})
-target_link_libraries(kdeconnect_mousepad kdeconnectcore
- ${QT_QTGUI_LIBRARY}
- ${X11_LIBRARIES}
- ${XTEST_LIBRARIES}
- ${LibFakeKey_LIBRARIES}
-)
++target_link_libraries(kdeconnect_mousepad KF5::Service kdeconnectcore Qt5::Gui ${X11_LIBRARIES} ${XTEST_LIBRARIES} ${LibFakeKey_LIBRARIES})
install(TARGETS kdeconnect_mousepad DESTINATION ${PLUGIN_INSTALL_DIR} )
install(FILES kdeconnect_mousepad.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
diff --cc plugins/mousepad/mousepadplugin.cpp
index 507522d,69fba1a..fea2078
--- a/plugins/mousepad/mousepadplugin.cpp
+++ b/plugins/mousepad/mousepadplugin.cpp
@@@ -19,16 -19,47 +19,46 @@@
*/
#include "mousepadplugin.h"
- #include <X11/extensions/XTest.h>
--
-#include <core/networkpackage.h>
+#include <KPluginFactory>
++#include <QDebug>
+ #include <X11/extensions/XTest.h>
+ #include <X11/keysym.h>
+ #include <fakekey/fakekey.h>
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< MousepadPlugin >(); )
-K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_mousepad", "kdeconnect-plugins") )
- // Source: http://bharathisubramanian.wordpress.com/2010/04/01/x11-fake-mouse-events-generation-using-xtest/
+ enum MouseButtons {
+ LeftMouseButton = 1,
+ MiddleMouseButton = 2,
+ RightMouseButton = 3,
+ MouseWheelUp = 4,
+ MouseWheelDown = 5
+ };
+
+ //Translation table to keep in sync within all the implementations
+ int SpecialKeysMap[] = {
+ 0, // Invalid
+ XK_BackSpace, // 1
+ XK_Tab, // 2
+ XK_Linefeed, // 3
+ XK_Left, // 4
+ XK_Up, // 5
+ XK_Right, // 6
+ XK_Down, // 7
+ XK_Page_Up, // 8
+ XK_Page_Down, // 9
+ XK_Home, // 10
+ XK_End, // 11
+ XK_Return, // 12
+ XK_Delete, // 13
+ XK_Escape, // 14
+ };
+
+ template <typename T, size_t N>
+ size_t arraySize(T(&arr)[N]) { (void)arr; return N; }
MousepadPlugin::MousepadPlugin(QObject* parent, const QVariantList& args)
- : KdeConnectPlugin(parent, args), m_display(0)
+ : KdeConnectPlugin(parent, args), m_display(0), m_fakekey(0)
{
}
@@@ -51,39 -88,74 +87,74 @@@ bool MousepadPlugin::receivePackage(con
bool isMiddleClick = np.get<bool>("middleclick", false);
bool isRightClick = np.get<bool>("rightclick", false);
bool isScroll = np.get<bool>("scroll", false);
+ QString key = np.get<QString>("key", "");
+ int specialKey = np.get<int>("specialKey", 0);
+
+ if (isSingleClick || isDoubleClick || isMiddleClick || isRightClick || isScroll || !key.isEmpty() || specialKey) {
- if (isSingleClick || isDoubleClick || isMiddleClick || isRightClick || isScroll) {
if(!m_display) {
m_display = XOpenDisplay(NULL);
+ if(!m_display) {
- kDebug(debugArea()) << "Failed to open X11 display";
++ qWarning() << "Failed to open X11 display";
+ return false;
+ }
}
- if(m_display) {
- if (isSingleClick) {
- XTestFakeButtonEvent(m_display, LeftMouseButton, true, CurrentTime);
- XTestFakeButtonEvent(m_display, LeftMouseButton, false, CurrentTime);
- } else if (isDoubleClick) {
- XTestFakeButtonEvent(m_display, LeftMouseButton, true, CurrentTime);
- XTestFakeButtonEvent(m_display, LeftMouseButton, false, CurrentTime);
- XTestFakeButtonEvent(m_display, LeftMouseButton, true, CurrentTime);
- XTestFakeButtonEvent(m_display, LeftMouseButton, false, CurrentTime);
- } else if (isMiddleClick) {
- XTestFakeButtonEvent(m_display, MiddleMouseButton, true, CurrentTime);
- XTestFakeButtonEvent(m_display, MiddleMouseButton, false, CurrentTime);
- } else if (isRightClick) {
- XTestFakeButtonEvent(m_display, RightMouseButton, true, CurrentTime);
- XTestFakeButtonEvent(m_display, RightMouseButton, false, CurrentTime);
- } else if( isScroll ) {
- if (dy < 0) {
- XTestFakeButtonEvent(m_display, MouseWheelDown, true, CurrentTime);
- XTestFakeButtonEvent(m_display, MouseWheelDown, false, CurrentTime);
- } else if (dy > 0) {
- XTestFakeButtonEvent(m_display, MouseWheelUp, true, CurrentTime);
- XTestFakeButtonEvent(m_display, MouseWheelUp, false, CurrentTime);
+ if (isSingleClick) {
+ XTestFakeButtonEvent(m_display, LeftMouseButton, True, 0);
+ XTestFakeButtonEvent(m_display, LeftMouseButton, False, 0);
+ } else if (isDoubleClick) {
+ XTestFakeButtonEvent(m_display, LeftMouseButton, True, 0);
+ XTestFakeButtonEvent(m_display, LeftMouseButton, False, 0);
+ XTestFakeButtonEvent(m_display, LeftMouseButton, True, 0);
+ XTestFakeButtonEvent(m_display, LeftMouseButton, False, 0);
+ } else if (isMiddleClick) {
+ XTestFakeButtonEvent(m_display, MiddleMouseButton, True, 0);
+ XTestFakeButtonEvent(m_display, MiddleMouseButton, False, 0);
+ } else if (isRightClick) {
+ XTestFakeButtonEvent(m_display, RightMouseButton, True, 0);
+ XTestFakeButtonEvent(m_display, RightMouseButton, False, 0);
+ } else if( isScroll ) {
+ if (dy < 0) {
+ XTestFakeButtonEvent(m_display, MouseWheelDown, True, 0);
+ XTestFakeButtonEvent(m_display, MouseWheelDown, False, 0);
+ } else if (dy > 0) {
+ XTestFakeButtonEvent(m_display, MouseWheelUp, True, 0);
+ XTestFakeButtonEvent(m_display, MouseWheelUp, False, 0);
+ }
+ } else if (!key.isEmpty() || specialKey) {
+
+ if (specialKey)
+ {
+ if (specialKey > (int)arraySize(SpecialKeysMap)) {
- kDebug(debugArea()) << "Unsupported special key identifier";
++ qWarning() << "Unsupported special key identifier";
+ return false;
+ }
+
+ int keycode = XKeysymToKeycode(m_display, SpecialKeysMap[specialKey]);
+ XTestFakeKeyEvent (m_display, keycode, True, 0);
+ XTestFakeKeyEvent (m_display, keycode, False, 0);
+
+ } else {
+
+ if (!m_fakekey) {
+ m_fakekey = fakekey_init(m_display);
+ if (!m_fakekey) {
- kDebug(debugArea()) << "Failed to initialize libfakekey";
++ qWarning() << "Failed to initialize libfakekey";
+ return false;
+ }
}
+
+ //We use fakekey here instead of XTest (above) because it can handle utf characters instead of keycodes.
+ fakekey_press(m_fakekey, (const unsigned char*)key.toUtf8().constData(), -1, 0);
+ fakekey_release(m_fakekey);
}
- XFlush(m_display);
+
}
- } else {
+
+ XFlush(m_display);
+
+ } else { //Is a mouse move event
QPoint point = QCursor::pos();
QCursor::setPos(point.x() + (int)dx, point.y() + (int)dy);
}
diff --cc plugins/mpriscontrol/mpriscontrolplugin.cpp
index 104c65a,2b7564d..65b44b1
--- a/plugins/mpriscontrol/mpriscontrolplugin.cpp
+++ b/plugins/mpriscontrol/mpriscontrolplugin.cpp
@@@ -159,8 -156,8 +158,8 @@@ bool MprisControlPlugin::receivePackag
OrgMprisMediaPlayer2PlayerInterface mprisInterface(playerList[player], "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus());
if (np.has("action")) {
const QString& action = np.get<QString>("action");
- kDebug(debugArea()) << "Calling action" << action << "in" << playerList[player];
+ qCDebug(KDECONNECT_PLUGIN_MPRIS) << "Calling action" << action << "in" << playerList[player];
- //TODO: Check for valid actions
+ //TODO: Check for valid actions, currently we trust anything the other end sends us
mprisInterface.call(action);
}
if (np.has("setVolume")) {
diff --cc plugins/ping/pingplugin.cpp
index 5421479,042a953..d1de135
--- a/plugins/ping/pingplugin.cpp
+++ b/plugins/ping/pingplugin.cpp
@@@ -61,9 -58,19 +60,19 @@@ void PingPlugin::sendPing(
{
NetworkPackage np(PACKAGE_TYPE_PING);
bool success = sendPackage(np);
- kDebug(debugArea()) << "sendPing:" << success;
+ qCDebug(KDECONNECT_PLUGIN_PING) << "sendPing:" << success;
}
+ void PingPlugin::sendPing(const QString& customMessage)
+ {
+ NetworkPackage np(PACKAGE_TYPE_PING);
+ if (!customMessage.isEmpty()) {
+ np.set("message", customMessage);
+ }
+ bool success = sendPackage(np);
- kDebug(debugArea()) << "sendPing:" << success;
++ qCDebug(KDECONNECT_PLUGIN_PING) << "sendPing:" << success;
+ }
+
void PingPlugin::connected()
{
QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportAllContents);
diff --cc plugins/ping/pingplugin.h
index 54b17d6,6893ce5..146db57
--- a/plugins/ping/pingplugin.h
+++ b/plugins/ping/pingplugin.h
@@@ -37,8 -34,9 +37,9 @@@ class Q_DECL_EXPORT PingPlugi
public:
explicit PingPlugin(QObject *parent, const QVariantList &args);
virtual ~PingPlugin();
-
+
Q_SCRIPTABLE void sendPing();
+ Q_SCRIPTABLE void sendPing(const QString& customMessage);
public Q_SLOTS:
virtual bool receivePackage(const NetworkPackage& np);
diff --cc plugins/sftp/sftpplugin.cpp
index 20273c1,53b818a..9564ad2
--- a/plugins/sftp/sftpplugin.cpp
+++ b/plugins/sftp/sftpplugin.cpp
@@@ -55,10 -53,10 +55,10 @@@ struct SftpPlugin::Pimp
SftpPlugin::SftpPlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
- , m_d(new Pimpl)
+ , m_d(new Pimpl())
{
addToDolphin();
- kDebug(debugArea()) << "Created device:" << device()->name();
+ qCDebug(KDECONNECT_PLUGIN_SFTP) << "Created device:" << device()->name();
}
SftpPlugin::~SftpPlugin()
@@@ -199,4 -208,9 +210,9 @@@ void SftpPlugin::knotify(int type, cons
, KNotification::CloseOnTimeout);
}
+ QVariantMap SftpPlugin::getDirectories()
+ {
+ return remoteDirectories;
+ }
+
-
+#include "sftpplugin.moc"
diff --cc plugins/share/shareplugin.cpp
index c6a55ed,ba2559d..906bf1b
--- a/plugins/share/shareplugin.cpp
+++ b/plugins/share/shareplugin.cpp
@@@ -73,10 -64,10 +73,10 @@@ QUrl SharePlugin::destinationDir() cons
bool SharePlugin::receivePackage(const NetworkPackage& np)
{
/*
- //TODO: Use this code to write a test
+ //TODO: Write a test like this
if (np.type() == PACKAGE_TYPE_PING) {
- kDebug(debugArea()) << "sending file" << (QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/.bashrc");
+ qCDebug(KDECONNECT_PLUGIN_SHARE) << "sending file" << (QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/.bashrc");
NetworkPackage out(PACKAGE_TYPE_SHARE);
out.set("filename", mDestinationDir + "itworks.txt");
diff --cc plugins/telephony/telephonyplugin.cpp
index d122740,491c1f7..0c51e63
--- a/plugins/telephony/telephonyplugin.cpp
+++ b/plugins/telephony/telephonyplugin.cpp
@@@ -66,13 -66,14 +68,14 @@@ KNotification* TelephonyPlugin::createN
type = "unknownEvent";
icon = "pda";
content = i18n("Unknown telephony event: %2", event);
+ #endif
}
- kDebug(debugArea()) << "Creating notification with type:" << type;
+ qCDebug(KDECONNECT_PLUGIN_TELEPHONY) << "Creating notification with type:" << type;
KNotification* notification = new KNotification(type, KNotification::CloseOnTimeout, this); //, KNotification::Persistent
- notification->setPixmap(KIcon(icon).pixmap(48, 48));
- notification->setComponentData(KComponentData("kdeconnect", "kdeconnect-kded"));
+ notification->setPixmap(QIcon::fromTheme(icon).pixmap(48, 48));
+ notification->setComponentName("kdeconnect");
notification->setTitle(title);
notification->setText(content);
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list