From 6e5de6f43715087bbf09e8e93d0a273a0255fa8e Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Wed, 6 Nov 2013 22:16:55 +0100 Subject: [PATCH] qDebug -> kDebug with namespaces Added 3 namespaces: kdeconnect_kded, kdeconnect_kcm and libkdeconnect --- kcm/CMakeLists.txt | 4 ++- kcm/devicessortproxymodel.cpp | 2 +- kcm/kcm.cpp | 3 +- kcm/kdebugnamespace.cpp | 26 ++++++++++++++++ kcm/kdebugnamespace.h | 29 ++++++++++++++++++ kded/CMakeLists.txt | 1 + kded/backends/lan/downloadjob.cpp | 6 ++-- kded/backends/lan/landevicelink.cpp | 4 +-- kded/backends/lan/lanlinkprovider.cpp | 25 ++++++++-------- kded/backends/lan/socketlinereader.cpp | 3 +- kded/backends/lan/uploadjob.cpp | 4 +-- .../loopback/loopbacklinkprovider.cpp | 4 +-- kded/daemon.cpp | 27 ++++++++--------- kded/device.cpp | 30 +++++++++---------- kded/filetransferjob.cpp | 21 ++++++------- kded/kdebugnamespace.cpp | 28 +++++++++++++++++ kded/kdebugnamespace.h | 29 ++++++++++++++++++ kded/networkpackage.cpp | 14 ++++----- kded/networkpackage.h | 7 ++--- kded/plugins/battery/CMakeLists.txt | 1 + kded/plugins/battery/batterydbusinterface.cpp | 4 +-- kded/plugins/battery/batteryplugin.cpp | 2 +- kded/plugins/clipboard/CMakeLists.txt | 1 + kded/plugins/clipboard/clipboardplugin.cpp | 2 +- kded/plugins/mpriscontrol/CMakeLists.txt | 1 + .../mpriscontrol/mpriscontrolplugin.cpp | 19 ++++++------ kded/plugins/notifications/CMakeLists.txt | 1 + kded/plugins/notifications/notification.cpp | 3 +- .../notificationsdbusinterface.cpp | 14 ++++----- .../notifications/notificationsplugin.cpp | 3 +- kded/plugins/pausemusic/CMakeLists.txt | 1 + kded/plugins/pausemusic/pausemusicplugin.cpp | 3 +- kded/plugins/ping/CMakeLists.txt | 1 + kded/plugins/ping/pingplugin.cpp | 8 ++--- kded/plugins/pluginloader.cpp | 16 +++++----- kded/plugins/sharereceiver/CMakeLists.txt | 1 + kded/plugins/sharereceiver/autoclosingqfile.h | 3 +- .../sharereceiver/sharereceiverplugin.cpp | 12 ++++---- kded/plugins/telephony/CMakeLists.txt | 1 + kded/plugins/telephony/telephonyplugin.cpp | 6 ++-- libkdeconnect/CMakeLists.txt | 1 + libkdeconnect/devicesmodel.cpp | 7 +++-- libkdeconnect/kdebugnamespace.cpp | 27 +++++++++++++++++ libkdeconnect/kdebugnamespace.h | 29 ++++++++++++++++++ libkdeconnect/notificationsmodel.cpp | 5 ++-- 45 files changed, 311 insertions(+), 128 deletions(-) create mode 100644 kcm/kdebugnamespace.cpp create mode 100644 kcm/kdebugnamespace.h create mode 100644 kded/kdebugnamespace.cpp create mode 100644 kded/kdebugnamespace.h create mode 100644 libkdeconnect/kdebugnamespace.cpp create mode 100644 libkdeconnect/kdebugnamespace.h diff --git a/kcm/CMakeLists.txt b/kcm/CMakeLists.txt index 9ed031175..ed482187f 100644 --- a/kcm/CMakeLists.txt +++ b/kcm/CMakeLists.txt @@ -4,8 +4,10 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) -set(kcm_SRCS devicessortproxymodel.cpp +set(kcm_SRCS kcm.cpp + devicessortproxymodel.cpp + kdebugnamespace.cpp ) kde4_add_ui_files(kcm_SRCS kcm.ui) diff --git a/kcm/devicessortproxymodel.cpp b/kcm/devicessortproxymodel.cpp index d1041ce00..68c11fdbe 100644 --- a/kcm/devicessortproxymodel.cpp +++ b/kcm/devicessortproxymodel.cpp @@ -23,7 +23,7 @@ #include "libkdeconnect/dbusinterfaces.h" #include "libkdeconnect/devicesmodel.h" -#include +#include "kdebugnamespace.h" DevicesSortProxyModel::DevicesSortProxyModel(DevicesModel* devicesModel) : QSortFilterProxyModel(devicesModel) diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp index 7ad6814bc..9344dfd7a 100644 --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -38,6 +37,7 @@ #include "ui_kcm.h" #include "libkdeconnect/dbusinterfaces.h" #include "devicessortproxymodel.h" +#include "kdebugnamespace.h" K_PLUGIN_FACTORY(KdeConnectKcmFactory, registerPlugin();) K_EXPORT_PLUGIN(KdeConnectKcmFactory("kdeconnect-kcm", "kdeconnect-kcm")) @@ -134,7 +134,6 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current) } } - //FIXME: KPluginSelector has no way to remove a list of plugins and load another, so we need to destroy and recreate it each time delete kcmUi->pluginSelector; kcmUi->pluginSelector = new KPluginSelector(this); diff --git a/kcm/kdebugnamespace.cpp b/kcm/kdebugnamespace.cpp new file mode 100644 index 000000000..c38db0fbe --- /dev/null +++ b/kcm/kdebugnamespace.cpp @@ -0,0 +1,26 @@ +/** + * Copyright 2013 Albert Vaca + * + * 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 "kdebugnamespace.h" + +int kdeconnect_kcm() { + static int s_area = KDebug::registerArea("kdeconnect_kcm", true); + return s_area; +} diff --git a/kcm/kdebugnamespace.h b/kcm/kdebugnamespace.h new file mode 100644 index 000000000..47a7d4374 --- /dev/null +++ b/kcm/kdebugnamespace.h @@ -0,0 +1,29 @@ +/** + * Copyright 2013 Albert Vaca + * + * 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 . + */ + +#ifndef KDEBUG_KDECONNECT_KCM_H +#define KDEBUG_KDECONNECT_KCM_H + +#include + +int kdeconnect_kcm(); + +#endif + diff --git a/kded/CMakeLists.txt b/kded/CMakeLists.txt index 46ef58afb..152232bf8 100644 --- a/kded/CMakeLists.txt +++ b/kded/CMakeLists.txt @@ -25,6 +25,7 @@ set(kded_kdeconnect_SRCS filetransferjob.cpp daemon.cpp device.cpp + kdebugnamespace.cpp ) kde4_add_plugin(kded_kdeconnect ${kded_kdeconnect_SRCS}) diff --git a/kded/backends/lan/downloadjob.cpp b/kded/backends/lan/downloadjob.cpp index fe03aeb96..bba2e988b 100644 --- a/kded/backends/lan/downloadjob.cpp +++ b/kded/backends/lan/downloadjob.cpp @@ -29,7 +29,7 @@ DownloadJob::DownloadJob(QHostAddress address, QVariantMap transferInfo): KJob() void DownloadJob::start() { - //qDebug() << "DownloadJob Start"; + //kDebug(kdeconnect_kded()) << "DownloadJob Start"; mSocket->connectToHost(mAddress, mPort, QIODevice::ReadOnly); connect(mSocket.data(), SIGNAL(disconnected()), this, SLOT(disconnected())); @@ -38,12 +38,12 @@ void DownloadJob::start() void DownloadJob::disconnected() { - //qDebug() << "DownloadJob End"; + //kDebug(kdeconnect_kded()) << "DownloadJob End"; emitResult(); } QSharedPointer DownloadJob::getPayload() { - //qDebug() << "getPayload"; + //kDebug(kdeconnect_kded()) << "getPayload"; return mSocket.staticCast(); } diff --git a/kded/backends/lan/landevicelink.cpp b/kded/backends/lan/landevicelink.cpp index 706077bcc..48860712b 100644 --- a/kded/backends/lan/landevicelink.cpp +++ b/kded/backends/lan/landevicelink.cpp @@ -81,7 +81,7 @@ void LanDeviceLink::dataReceived() QByteArray package = mSocketLineReader->readLine(); - //qDebug() << "LanDeviceLink dataReceived" << package; + //kDebug(kdeconnect_kded()) << "LanDeviceLink dataReceived" << package; NetworkPackage unserialized(QString::null); NetworkPackage::unserialize(package, &unserialized); @@ -92,7 +92,7 @@ void LanDeviceLink::dataReceived() unserialized.decrypt(mPrivateKey, &decrypted); if (decrypted.hasPayloadTransferInfo()) { - qDebug() << "HasPayloadTransferInfo"; + kDebug(kdeconnect_kded()) << "HasPayloadTransferInfo"; DownloadJob* job = new DownloadJob(mSocketLineReader->peerAddress(), decrypted.payloadTransferInfo()); job->start(); decrypted.setPayload(job->getPayload(), decrypted.payloadSize()); diff --git a/kded/backends/lan/lanlinkprovider.cpp b/kded/backends/lan/lanlinkprovider.cpp index 32ddb6f5f..2d0658b5d 100644 --- a/kded/backends/lan/lanlinkprovider.cpp +++ b/kded/backends/lan/lanlinkprovider.cpp @@ -29,6 +29,7 @@ #include #include +#include "../../kdebugnamespace.h" #include "landevicelink.h" void LanLinkProvider::configureSocket(QTcpSocket* socket) @@ -108,13 +109,13 @@ void LanLinkProvider::newUdpConnection() NetworkPackage::createIdentityPackage(&np2); if (np->get("deviceId") == np2.get("deviceId")) { - //qDebug() << "Ignoring my own broadcast"; + //kDebug(kdeconnect_kded()) << "Ignoring my own broadcast"; return; } int tcpPort = np->get("tcpPort",port); - //qDebug() << "Received Udp presentation from" << sender << "asking for a tcp connection on port " << tcpPort; + //kDebug(kdeconnect_kded()) << "Received Udp presentation from" << sender << "asking for a tcp connection on port " << tcpPort; QTcpSocket* socket = new QTcpSocket(this); receivedIdentityPackages[socket].np = np; @@ -140,7 +141,7 @@ void LanLinkProvider::connectError() disconnect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectError())); disconnect(socket, SIGNAL(connected()), this, SLOT(connected())); - qDebug() << "Fallback (1), try reverse connection"; + kDebug(kdeconnect_kded()) << "Fallback (1), try reverse connection"; NetworkPackage np(""); NetworkPackage::createIdentityPackage(&np); np.set("tcpPort",tcpPort); @@ -160,7 +161,7 @@ void LanLinkProvider::connected() NetworkPackage* np = receivedIdentityPackages[socket].np; const QString& id = np->get("deviceId"); - //qDebug() << "Connected" << socket->isWritable(); + //kDebug(kdeconnect_kded()) << "Connected" << socket->isWritable(); LanDeviceLink* dl = new LanDeviceLink(id, this, socket); @@ -172,7 +173,7 @@ void LanLinkProvider::connected() //TODO: Use reverse connection too to preffer connecting a unstable device (a phone) to a stable device (a computer) if (success) { - //qDebug() << "Handshaking done (i'm the existing device)"; + //kDebug(kdeconnect_kded()) << "Handshaking done (i'm the existing device)"; connect(dl, SIGNAL(destroyed(QObject*)), this, SLOT(deviceLinkDestroyed(QObject*))); @@ -192,7 +193,7 @@ void LanLinkProvider::connected() } else { //I think this will never happen - qDebug() << "Fallback (2), try reverse connection"; + kDebug(kdeconnect_kded()) << "Fallback (2), try reverse connection"; QUdpSocket().writeDatagram(np2.serialize(), receivedIdentityPackages[socket].sender, port); delete dl; } @@ -206,7 +207,7 @@ void LanLinkProvider::connected() //I'm the new device and this is the answer to my UDP introduction (no data received yet) void LanLinkProvider::newConnection() { - //qDebug() << "LanLinkProvider newConnection"; + //kDebug(kdeconnect_kded()) << "LanLinkProvider newConnection"; QTcpSocket* socket = mTcpServer->nextPendingConnection(); socket->setSocketOption(QAbstractSocket::KeepAliveOption, 1); @@ -218,7 +219,7 @@ void LanLinkProvider::newConnection() NetworkPackage::createIdentityPackage(&np); int written = socket->write(np.serialize()); - qDebug() << "LanLinkProvider sent package." << written << " bytes written, waiting for reply"; + kDebug(kdeconnect_kded()) << "LanLinkProvider sent package." << written << " bytes written, waiting for reply"; */ } @@ -230,7 +231,7 @@ void LanLinkProvider::dataReceived() QByteArray data = socket->readLine(); - //qDebug() << "LanLinkProvider received reply:" << data; + //kDebug(kdeconnect_kded()) << "LanLinkProvider received reply:" << data; NetworkPackage np(""); bool success = NetworkPackage::unserialize(data,&np); @@ -240,7 +241,7 @@ void LanLinkProvider::dataReceived() const QString& id = np.get("deviceId"); LanDeviceLink* dl = new LanDeviceLink(id, this, socket); - //qDebug() << "Handshaking done (i'm the new device)"; + //kDebug(kdeconnect_kded()) << "Handshaking done (i'm the new device)"; connect(dl, SIGNAL(destroyed(QObject*)), this, SLOT(deviceLinkDestroyed(QObject*))); @@ -261,14 +262,14 @@ void LanLinkProvider::dataReceived() disconnect(socket,SIGNAL(readyRead()),this,SLOT(dataReceived())); } else { - qDebug() << "LanLinkProvider/newConnection: Not an identification package (wuh?)"; + kDebug(kdeconnect_kded()) << "LanLinkProvider/newConnection: Not an identification package (wuh?)"; } } void LanLinkProvider::deviceLinkDestroyed(QObject* uncastedDeviceLink) { - //qDebug() << "deviceLinkDestroyed"; + //kDebug(kdeconnect_kded()) << "deviceLinkDestroyed"; DeviceLink* deviceLink = (DeviceLink*)uncastedDeviceLink; const QString& id = deviceLink->deviceId(); diff --git a/kded/backends/lan/socketlinereader.cpp b/kded/backends/lan/socketlinereader.cpp index 91ff97ed5..4cd8ef042 100644 --- a/kded/backends/lan/socketlinereader.cpp +++ b/kded/backends/lan/socketlinereader.cpp @@ -20,6 +20,7 @@ #include "socketlinereader.h" +#include "../../kdebugnamespace.h" SocketLineReader::SocketLineReader(QTcpSocket* socket, QObject* parent) : QObject(parent) @@ -64,7 +65,7 @@ void SocketLineReader::dataReceived() if (mPackages.length() > 0) { Q_EMIT readyRead(); } else { - qDebug() << "Received incomplete chunk of data, waiting for more"; + kDebug(kdeconnect_kded()) << "Received incomplete chunk of data, waiting for more"; } } diff --git a/kded/backends/lan/uploadjob.cpp b/kded/backends/lan/uploadjob.cpp index a5c739e65..ae055cbb4 100644 --- a/kded/backends/lan/uploadjob.cpp +++ b/kded/backends/lan/uploadjob.cpp @@ -19,8 +19,8 @@ */ #include -#include +#include "kdebugnamespace.h" #include "uploadjob.h" UploadJob::UploadJob(const QSharedPointer& source): KJob() @@ -36,7 +36,7 @@ void UploadJob::start() while(!mServer->listen(QHostAddress::Any, mPort)) { mPort++; if (mPort > 1764) { //No ports available? - qDebug() << "Error opening a port in range 1739-1764 for file transfer"; + kDebug(kdeconnect_kded()) << "Error opening a port in range 1739-1764 for file transfer"; mPort = 0; return; } diff --git a/kded/backends/loopback/loopbacklinkprovider.cpp b/kded/backends/loopback/loopbacklinkprovider.cpp index 961a1bb18..df793a6dd 100644 --- a/kded/backends/loopback/loopbacklinkprovider.cpp +++ b/kded/backends/loopback/loopbacklinkprovider.cpp @@ -20,7 +20,7 @@ #include "loopbacklinkprovider.h" -#include +#include "kdebugnamespace.h" LoopbackLinkProvider::LoopbackLinkProvider() : identityPackage(PACKAGE_TYPE_IDENTITY) @@ -37,7 +37,7 @@ LoopbackLinkProvider::~LoopbackLinkProvider() void LoopbackLinkProvider::onNetworkChange(QNetworkSession::State state) { Q_UNUSED(state); - //qDebug() << "Echo Device discovery emitted"; + //kDebug(kdeconnect_kded()) << "Echo Device discovery emitted"; LoopbackDeviceLink* newLoopbackDeviceLink = new LoopbackDeviceLink("loopback", this); Q_EMIT onConnectionReceived(identityPackage, newLoopbackDeviceLink); diff --git a/kded/daemon.cpp b/kded/daemon.cpp index 8a8ae5b17..1700ddee1 100644 --- a/kded/daemon.cpp +++ b/kded/daemon.cpp @@ -20,20 +20,19 @@ #include "daemon.h" -#include "networkpackage.h" - -#include "backends/lan/lanlinkprovider.h" -#include "backends/loopback/loopbacklinkprovider.h" - #include #include #include #include -#include #include #include +#include "kdebugnamespace.h" +#include "networkpackage.h" +#include "backends/lan/lanlinkprovider.h" +#include "backends/loopback/loopbacklinkprovider.h" + K_PLUGIN_FACTORY(KdeConnectFactory, registerPlugin();) K_EXPORT_PLUGIN(KdeConnectFactory("kdeconnect", "kdeconnect")) @@ -48,10 +47,10 @@ Daemon::Daemon(QObject *parent, const QList&) //uuids contain charcaters that are not exportable in dbus paths uuid = uuid.mid(1, uuid.length() - 2).replace("-", "_"); config->group("myself").writeEntry("id", uuid); - qDebug() << "My id:" << uuid; + kDebug(kdeconnect_kded()) << "My id:" << uuid; } - //qDebug() << "QCA supported capabilities:" << QCA::supportedFeatures().join(","); + //kDebug(kdeconnect_kded()) << "QCA supported capabilities:" << QCA::supportedFeatures().join(","); if(!QCA::isSupported("rsa")) { //TODO: Maybe display this in a more visible way? qWarning() << "Error: KDE Connect could not find support for RSA in your QCA installation, if your distribution provides" @@ -72,7 +71,7 @@ Daemon::Daemon(QObject *parent, const QList&) } //Debugging - qDebug() << "Starting KdeConnect daemon"; + kDebug(kdeconnect_kded()) << "Starting KdeConnect daemon"; //Load backends (hardcoded by now, should be plugins in a future) mLinkProviders.insert(new LanLinkProvider()); @@ -143,14 +142,14 @@ void Daemon::onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink* { const QString& id = identityPackage.get("deviceId"); - //qDebug() << "Device discovered" << id << "via" << dl->provider()->name(); + //kDebug(kdeconnect_kded()) << "Device discovered" << id << "via" << dl->provider()->name(); if (mDevices.contains(id)) { - //qDebug() << "It is a known device"; + //kDebug(kdeconnect_kded()) << "It is a known device"; Device* device = mDevices[id]; device->addLink(identityPackage, dl); } else { - //qDebug() << "It is a new device"; + //kDebug(kdeconnect_kded()) << "It is a new device"; Device* device = new Device(identityPackage, dl); connect(device, SIGNAL(reachableStatusChanged()), this, SLOT(onDeviceReachableStatusChanged())); @@ -171,12 +170,12 @@ void Daemon::onDeviceReachableStatusChanged() Q_EMIT deviceVisibilityChanged(id, device->isReachable()); - //qDebug() << "Device" << device->name() << "reachable status changed:" << device->isReachable(); + //kDebug(kdeconnect_kded()) << "Device" << device->name() << "reachable status changed:" << device->isReachable(); if (!device->isReachable()) { if (!device->isPaired()) { - qDebug() << "Destroying device" << device->name(); + kDebug(kdeconnect_kded()) << "Destroying device" << device->name(); Q_EMIT deviceRemoved(id); mDevices.remove(id); device->deleteLater(); diff --git a/kded/device.cpp b/kded/device.cpp index bf31bafaa..ded0b8f2a 100644 --- a/kded/device.cpp +++ b/kded/device.cpp @@ -1,5 +1,7 @@ #include "device.h" +#include + #include #include #include @@ -8,9 +10,7 @@ #include #include -#include -#include - +#include "kdebugnamespace.h" #include "plugins/kdeconnectplugin.h" #include "plugins/pluginloader.h" #include "backends/devicelink.h" @@ -186,7 +186,7 @@ static bool lessThan(DeviceLink* p1, DeviceLink* p2) void Device::addLink(const NetworkPackage& identityPackage, DeviceLink* link) { - //qDebug() << "Adding link to" << id() << "via" << link->provider(); + //kDebug(kdeconnect_kded()) << "Adding link to" << id() << "via" << link->provider(); m_protocolVersion = identityPackage.get("protocolVersion"); if (m_protocolVersion != NetworkPackage::ProtocolVersion) { @@ -236,7 +236,7 @@ void Device::removeLink(DeviceLink* link) { m_deviceLinks.removeOne(link); - //qDebug() << "RemoveLink" << m_deviceLinks.size() << "links remaining"; + //kDebug(kdeconnect_kded()) << "RemoveLink" << m_deviceLinks.size() << "links remaining"; if (m_deviceLinks.isEmpty()) { reloadPlugins(); @@ -264,12 +264,12 @@ void Device::privateReceivedPackage(const NetworkPackage& np) { if (np.type() == PACKAGE_TYPE_PAIR) { - //qDebug() << "Pair package"; + //kDebug(kdeconnect_kded()) << "Pair package"; bool wantsPair = np.get("pair"); if (wantsPair == isPaired()) { - qDebug() << "Already" << (wantsPair? "paired":"unpaired"); + kDebug(kdeconnect_kded()) << "Already" << (wantsPair? "paired":"unpaired"); if (m_pairStatus == Device::Requested) { m_pairStatus = Device::NotPaired; pairingTimer.stop(); @@ -284,7 +284,7 @@ void Device::privateReceivedPackage(const NetworkPackage& np) const QString& key = np.get("publicKey"); m_publicKey = QCA::RSAPublicKey::fromPEM(key); if (m_publicKey.isNull()) { - qDebug() << "ERROR decoding key"; + kDebug(kdeconnect_kded()) << "ERROR decoding key"; if (m_pairStatus == Device::Requested) { m_pairStatus = Device::NotPaired; pairingTimer.stop(); @@ -295,12 +295,12 @@ void Device::privateReceivedPackage(const NetworkPackage& np) if (m_pairStatus == Device::Requested) { //We started pairing - qDebug() << "Pair answer"; + kDebug(kdeconnect_kded()) << "Pair answer"; setAsPaired(); } else { - qDebug() << "Pair request"; + kDebug(kdeconnect_kded()) << "Pair request"; KNotification* notification = new KNotification("pingReceived"); //KNotification::Persistent notification->setPixmap(KIcon("dialog-information").pixmap(48, 48)); @@ -318,7 +318,7 @@ void Device::privateReceivedPackage(const NetworkPackage& np) } else { - qDebug() << "Unpair request"; + kDebug(kdeconnect_kded()) << "Unpair request"; if (m_pairStatus == Device::Requested) { pairingTimer.stop(); @@ -341,7 +341,7 @@ void Device::privateReceivedPackage(const NetworkPackage& np) } } else { //TODO: Notify the other side that we don't trust them - qDebug() << "device" << name() << "not paired, ignoring package" << np.type(); + kDebug(kdeconnect_kded()) << "device" << name() << "not paired, ignoring package" << np.type(); } } @@ -359,7 +359,7 @@ bool Device::sendOwnPublicKey() void Device::rejectPairing() { - qDebug() << "Rejected pairing"; + kDebug(kdeconnect_kded()) << "Rejected pairing"; m_pairStatus = Device::NotPaired; @@ -375,7 +375,7 @@ void Device::acceptPairing() { if (m_pairStatus != Device::RequestedByPeer) return; - qDebug() << "Accepted pairing"; + kDebug(kdeconnect_kded()) << "Accepted pairing"; bool success = sendOwnPublicKey(); @@ -424,7 +424,7 @@ void Device::sendPing() { NetworkPackage np(PACKAGE_TYPE_PING); bool success = sendPackage(np); - qDebug() << "sendPing:" << success; + kDebug(kdeconnect_kded()) << "sendPing:" << success; } Device::DeviceType Device::str2type(QString deviceType) { diff --git a/kded/filetransferjob.cpp b/kded/filetransferjob.cpp index bc4036683..cbc068af8 100644 --- a/kded/filetransferjob.cpp +++ b/kded/filetransferjob.cpp @@ -20,10 +20,11 @@ #include "filetransferjob.h" +#include + #include -#include -#include +#include "kdebugnamespace.h" FileTransferJob::FileTransferJob(const QSharedPointer& origin, int size, const KUrl& destination): KJob() { @@ -36,17 +37,17 @@ FileTransferJob::FileTransferJob(const QSharedPointer& origin, int si mOrigin = origin; mSize = size; mWritten = 0; - qDebug() << "FileTransferJob Downloading payload to" << destination; + kDebug(kdeconnect_kded()) << "FileTransferJob Downloading payload to" << destination; } void FileTransferJob::openFinished(KJob* job) { - qDebug() << job->errorString(); + kDebug(kdeconnect_kded()) << job->errorString(); } void FileTransferJob::start() { - //qDebug() << "FileTransferJob start"; + //kDebug(kdeconnect_kded()) << "FileTransferJob start"; //Open destination file mDestination->start(); @@ -56,10 +57,10 @@ void FileTransferJob::open(KIO::Job* job) { Q_UNUSED(job); - //qDebug() << "FileTransferJob open"; + //kDebug(kdeconnect_kded()) << "FileTransferJob open"; if (!mOrigin) { - qDebug() << "FileTransferJob: Origin is null"; + kDebug(kdeconnect_kded()) << "FileTransferJob: Origin is null"; return; } @@ -80,7 +81,7 @@ void FileTransferJob::readyRead() mDestination->write(data); mWritten += bytes; - //qDebug() << "readyRead" << mSize << mWritten << bytes; + //kDebug(kdeconnect_kded()) << "readyRead" << mSize << mWritten << bytes; if (mSize > -1) { setPercent((mWritten*100)/mSize); @@ -101,12 +102,12 @@ void FileTransferJob::sourceFinished() //TODO: MD5 check the file if (mSize > -1 && mWritten != mSize) { - qDebug() << "Received incomplete file"; + kDebug(kdeconnect_kded()) << "Received incomplete file"; setError(1); setErrorText(i18n("Received incomplete file")); emitResult(); } else { - qDebug() << "Finished transfer" << mDestination->url(); + kDebug(kdeconnect_kded()) << "Finished transfer" << mDestination->url(); } mDestination->close(); mDestination->deleteLater(); diff --git a/kded/kdebugnamespace.cpp b/kded/kdebugnamespace.cpp new file mode 100644 index 000000000..a2c8e8799 --- /dev/null +++ b/kded/kdebugnamespace.cpp @@ -0,0 +1,28 @@ +/** + * Copyright 2013 Albert Vaca + * + * 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 "kdebugnamespace.h" + +int kdeconnect_kded() { + static int s_area = KDebug::registerArea("kdeconnect_kded", true); + return s_area; +} + + diff --git a/kded/kdebugnamespace.h b/kded/kdebugnamespace.h new file mode 100644 index 000000000..4b23d6683 --- /dev/null +++ b/kded/kdebugnamespace.h @@ -0,0 +1,29 @@ +/** + * Copyright 2013 Albert Vaca + * + * 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 . + */ + +#ifndef KDEBUG_KDECONNECT_KDED_H +#define KDEBUG_KDECONNECT_KDED_H + +#include + +int kdeconnect_kded(); + +#endif + diff --git a/kded/networkpackage.cpp b/kded/networkpackage.cpp index 89815d822..cca7929c1 100644 --- a/kded/networkpackage.cpp +++ b/kded/networkpackage.cpp @@ -59,7 +59,7 @@ void NetworkPackage::createIdentityPackage(NetworkPackage* np) np->set("protocolType", "desktop"); //TODO: Detect laptop, tablet, phone... np->set("protocolVersion", NetworkPackage::ProtocolVersion); - //qDebug() << "createIdentityPackage" << np->serialize(); + //kDebug(kdeconnect_kded()) << "createIdentityPackage" << np->serialize(); } QByteArray NetworkPackage::serialize() const @@ -72,7 +72,7 @@ QByteArray NetworkPackage::serialize() const QVariantMap variant = QJson::QObjectHelper::qobject2qvariant(this); if (hasPayload()) { - //qDebug() << "Serializing payloadTransferInfo"; + //kDebug(kdeconnect_kded()) << "Serializing payloadTransferInfo"; variant["payloadSize"] = 0; variant["payloadTransferInfo"] = mPayloadTransferInfo; } @@ -82,10 +82,10 @@ QByteArray NetworkPackage::serialize() const QJson::Serializer serializer; QByteArray json = serializer.serialize(variant,&ok); if (!ok) { - qDebug() << "Serialization error:" << serializer.errorMessage(); + kDebug(kdeconnect_kded()) << "Serialization error:" << serializer.errorMessage(); } else { if (!isEncrypted()) { - //qDebug() << "Serialized package:" << json; + //kDebug(kdeconnect_kded()) << "Serialized package:" << json; } json.append('\n'); } @@ -100,7 +100,7 @@ bool NetworkPackage::unserialize(const QByteArray& a, NetworkPackage* np) bool ok; QVariantMap variant = parser.parse(a, &ok).toMap(); if (!ok) { - qDebug() << "Unserialization error:" << a; + kDebug(kdeconnect_kded()) << "Unserialization error:" << a; return false; } @@ -108,7 +108,7 @@ bool NetworkPackage::unserialize(const QByteArray& a, NetworkPackage* np) QJson::QObjectHelper::qvariant2qobject(variant, np); if (!np->isEncrypted()) { - //qDebug() << "Unserialized: " << a; + //kDebug(kdeconnect_kded()) << "Unserialized: " << a; } np->mPayloadSize = variant["payloadSize"].toInt(); //Will return 0 if was not present, which is ok @@ -133,7 +133,7 @@ void NetworkPackage::encrypt(QCA::PublicKey& key) chunks.append( encryptedChunk.toBase64() ); } - //qDebug() << chunks.size() << "chunks"; + //kDebug(kdeconnect_kded()) << chunks.size() << "chunks"; mId = QString::number(QDateTime::currentMSecsSinceEpoch()); mType = PACKAGE_TYPE_ENCRYPTED; diff --git a/kded/networkpackage.h b/kded/networkpackage.h index 5d6ce6774..07d8987df 100644 --- a/kded/networkpackage.h +++ b/kded/networkpackage.h @@ -23,19 +23,18 @@ #include "networkpackagetypes.h" -#include - #include -#include #include #include #include #include #include #include - #include +#include + +#include "kdebugnamespace.h" #include "default_args.h" class FileTransferJob; diff --git a/kded/plugins/battery/CMakeLists.txt b/kded/plugins/battery/CMakeLists.txt index a5176a1bc..d623141ef 100644 --- a/kded/plugins/battery/CMakeLists.txt +++ b/kded/plugins/battery/CMakeLists.txt @@ -19,6 +19,7 @@ set(kdeconnect_battery_SRCS ../../networkpackage.cpp ../../filetransferjob.cpp ../../device.cpp + ../../kdebugnamespace.cpp ) kde4_add_plugin(kdeconnect_battery ${kdeconnect_battery_SRCS}) diff --git a/kded/plugins/battery/batterydbusinterface.cpp b/kded/plugins/battery/batterydbusinterface.cpp index 4efdd3777..4a7ee2917 100644 --- a/kded/plugins/battery/batterydbusinterface.cpp +++ b/kded/plugins/battery/batterydbusinterface.cpp @@ -20,7 +20,7 @@ #include "batterydbusinterface.h" -#include +#include "../../kdebugnamespace.h" BatteryDbusInterface::BatteryDbusInterface(QObject *parent) : QDBusAbstractAdaptor(parent) @@ -29,7 +29,7 @@ BatteryDbusInterface::BatteryDbusInterface(QObject *parent) BatteryDbusInterface::~BatteryDbusInterface() { - qDebug() << "Destroying BatteryDbusInterface"; + kDebug(kdeconnect_kded()) << "Destroying BatteryDbusInterface"; } void BatteryDbusInterface::updateValues(bool isCharging, int currentCharge) diff --git a/kded/plugins/battery/batteryplugin.cpp b/kded/plugins/battery/batteryplugin.cpp index 2d9ccac2f..2f5314a35 100644 --- a/kded/plugins/battery/batteryplugin.cpp +++ b/kded/plugins/battery/batteryplugin.cpp @@ -20,11 +20,11 @@ #include "batteryplugin.h" -#include #include #include #include +#include "../../kdebugnamespace.h" #include "batterydbusinterface.h" K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< BatteryPlugin >(); ) diff --git a/kded/plugins/clipboard/CMakeLists.txt b/kded/plugins/clipboard/CMakeLists.txt index 1a39f06a4..426cfef2c 100644 --- a/kded/plugins/clipboard/CMakeLists.txt +++ b/kded/plugins/clipboard/CMakeLists.txt @@ -18,6 +18,7 @@ set(kdeconnect_clipboard_SRCS ../../networkpackage.cpp ../../filetransferjob.cpp ../../device.cpp + ../../kdebugnamespace.cpp ) kde4_add_plugin(kdeconnect_clipboard ${kdeconnect_clipboard_SRCS}) diff --git a/kded/plugins/clipboard/clipboardplugin.cpp b/kded/plugins/clipboard/clipboardplugin.cpp index 055926e3e..40000ebdb 100644 --- a/kded/plugins/clipboard/clipboardplugin.cpp +++ b/kded/plugins/clipboard/clipboardplugin.cpp @@ -43,7 +43,7 @@ void ClipboardPlugin::clipboardChanged(QClipboard::Mode mode) ignore_next_clipboard_change = false; return; } - //qDebug() << "ClipboardChanged"; + //kDebug(kdeconnect_kded()) << "ClipboardChanged"; NetworkPackage np(PACKAGE_TYPE_CLIPBOARD); np.set("content",clipboard->text()); device()->sendPackage(np); diff --git a/kded/plugins/mpriscontrol/CMakeLists.txt b/kded/plugins/mpriscontrol/CMakeLists.txt index 7332fdac6..dd2a2a3e1 100644 --- a/kded/plugins/mpriscontrol/CMakeLists.txt +++ b/kded/plugins/mpriscontrol/CMakeLists.txt @@ -18,6 +18,7 @@ set(kdeconnect_mpriscontrol_SRCS ../../networkpackage.cpp ../../filetransferjob.cpp ../../device.cpp + ../../kdebugnamespace.cpp ) qt4_add_dbus_interface( diff --git a/kded/plugins/mpriscontrol/mpriscontrolplugin.cpp b/kded/plugins/mpriscontrol/mpriscontrolplugin.cpp index 76b535c2c..2c847030b 100644 --- a/kded/plugins/mpriscontrol/mpriscontrolplugin.cpp +++ b/kded/plugins/mpriscontrol/mpriscontrolplugin.cpp @@ -20,17 +20,18 @@ #include "mpriscontrolplugin.h" -#include "mprisdbusinterface.h" -#include "propertiesdbusinterface.h" #include -#include #include #include #include #include #include +#include "../../kdebugnamespace.h" +#include "mprisdbusinterface.h" +#include "propertiesdbusinterface.h" + K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< MprisControlPlugin >(); ) K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_mpriscontrol", "kdeconnect_mpriscontrol") ) @@ -60,7 +61,7 @@ void MprisControlPlugin::serviceOwnerChanged(const QString &name, if (name.startsWith("org.mpris.MediaPlayer2")) { - qDebug() << "Mpris (un)registered in bus" << name << oldOwner << newOwner; + kDebug(kdeconnect_kded()) << "Mpris (un)registered in bus" << name << oldOwner << newOwner; if (oldOwner.isEmpty()) { addPlayer(name); @@ -76,7 +77,7 @@ void MprisControlPlugin::addPlayer(const QString& service) //FIXME: This call hangs and returns an empty string if KDED is still starting! const QString& identity = mprisInterface.property("Identity").toString(); playerList[identity] = service; - qDebug() << "Mpris addPlayer" << service << "->" << identity; + kDebug(kdeconnect_kded()) << "Mpris addPlayer" << service << "->" << identity; sendPlayerList(); OrgFreedesktopDBusPropertiesInterface* freedesktopInterface = new OrgFreedesktopDBusPropertiesInterface(service, "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus(), this); @@ -130,7 +131,7 @@ void MprisControlPlugin::propertiesChanged(const QString& propertyInterface, con void MprisControlPlugin::removePlayer(const QString& ifaceName) { QString identity = playerList.key(ifaceName); - qDebug() << "Mpris removePlayer" << ifaceName << "->" << identity; + kDebug(kdeconnect_kded()) << "Mpris removePlayer" << ifaceName << "->" << identity; playerList.remove(identity); sendPlayerList(); } @@ -155,18 +156,18 @@ bool MprisControlPlugin::receivePackage (const NetworkPackage& np) OrgMprisMediaPlayer2PlayerInterface mprisInterface(playerList[player], "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus()); if (np.has("action")) { const QString& action = np.get("action"); - qDebug() << "Calling action" << action << "in" << playerList[player]; + kDebug(kdeconnect_kded()) << "Calling action" << action << "in" << playerList[player]; //TODO: Check for valid actions mprisInterface.call(action); } if (np.has("setVolume")) { double volume = np.get("setVolume")/100.f; - qDebug() << "Setting volume" << volume << "to" << playerList[player]; + kDebug(kdeconnect_kded()) << "Setting volume" << volume << "to" << playerList[player]; mprisInterface.setVolume(volume); } if (np.has("Seek")) { int offset = np.get("Seek"); - qDebug() << "Seeking" << offset << "to" << playerList[player]; + kDebug(kdeconnect_kded()) << "Seeking" << offset << "to" << playerList[player]; mprisInterface.Seek(offset); } diff --git a/kded/plugins/notifications/CMakeLists.txt b/kded/plugins/notifications/CMakeLists.txt index dddb6b5dd..a6ed32a60 100644 --- a/kded/plugins/notifications/CMakeLists.txt +++ b/kded/plugins/notifications/CMakeLists.txt @@ -20,6 +20,7 @@ set(kdeconnect_notifications_SRCS ../../networkpackage.cpp ../../filetransferjob.cpp ../../device.cpp + ../../kdebugnamespace.cpp ) kde4_add_plugin(kdeconnect_notifications ${kdeconnect_notifications_SRCS}) diff --git a/kded/plugins/notifications/notification.cpp b/kded/plugins/notifications/notification.cpp index b85cf53b9..e30b6ba9a 100644 --- a/kded/plugins/notifications/notification.cpp +++ b/kded/plugins/notifications/notification.cpp @@ -21,7 +21,8 @@ #include "notification.h" #include -#include + +#include "../../kdebugnamespace.h" Notification::Notification(const NetworkPackage& np, const QString& iconPath, QObject* parent) : QObject(parent) diff --git a/kded/plugins/notifications/notificationsdbusinterface.cpp b/kded/plugins/notifications/notificationsdbusinterface.cpp index cbaba5261..1552a50be 100644 --- a/kded/plugins/notifications/notificationsdbusinterface.cpp +++ b/kded/plugins/notifications/notificationsdbusinterface.cpp @@ -20,16 +20,16 @@ #include "notificationsdbusinterface.h" -#include "../../filetransferjob.h" -#include - -#include #include #include #include #include +#include "../../kdebugnamespace.h" +#include "../../filetransferjob.h" +#include "notificationsplugin.h" + NotificationsDbusInterface::NotificationsDbusInterface(Device* device, QObject *parent) : QDBusAbstractAdaptor(parent) , mDevice(device) @@ -101,10 +101,10 @@ void NotificationsDbusInterface::addNotification(Notification* noti) void NotificationsDbusInterface::removeNotification(const QString& internalId) { - qDebug() << "removeNotification" << internalId; + kDebug(kdeconnect_kded()) << "removeNotification" << internalId; if (!mInternalIdToPublicId.contains(internalId)) { - qDebug() << "Not found"; + kDebug(kdeconnect_kded()) << "Not found"; return; } @@ -112,7 +112,7 @@ void NotificationsDbusInterface::removeNotification(const QString& internalId) Notification* noti = mNotifications.take(publicId); if (!noti) { - qDebug() << "Not found"; + kDebug(kdeconnect_kded()) << "Not found"; return; } diff --git a/kded/plugins/notifications/notificationsplugin.cpp b/kded/plugins/notifications/notificationsplugin.cpp index 77eb5d6bf..5ff419857 100644 --- a/kded/plugins/notifications/notificationsplugin.cpp +++ b/kded/plugins/notifications/notificationsplugin.cpp @@ -20,10 +20,9 @@ #include "notificationsplugin.h" -#include - #include +#include "../../kdebugnamespace.h" #include "notificationsdbusinterface.h" K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< NotificationsPlugin >(); ) diff --git a/kded/plugins/pausemusic/CMakeLists.txt b/kded/plugins/pausemusic/CMakeLists.txt index ac8d2e26b..d49cb7b2b 100644 --- a/kded/plugins/pausemusic/CMakeLists.txt +++ b/kded/plugins/pausemusic/CMakeLists.txt @@ -14,6 +14,7 @@ include_directories( set(kdeconnect_pausemusic_SRCS pausemusicplugin.cpp ../kdeconnectplugin.cpp + ../../kdebugnamespace.cpp ) kde4_add_plugin(kdeconnect_pausemusic ${kdeconnect_pausemusic_SRCS}) diff --git a/kded/plugins/pausemusic/pausemusicplugin.cpp b/kded/plugins/pausemusic/pausemusicplugin.cpp index b4ab54880..5844ea6c1 100644 --- a/kded/plugins/pausemusic/pausemusicplugin.cpp +++ b/kded/plugins/pausemusic/pausemusicplugin.cpp @@ -20,13 +20,14 @@ #include "pausemusicplugin.h" -#include #include #include #include #include #include +#include "../../kdebugnamespace.h" + K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< PauseMusicPlugin >(); ) K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_pausemusic", "kdeconnect_pausemusic") ) diff --git a/kded/plugins/ping/CMakeLists.txt b/kded/plugins/ping/CMakeLists.txt index 7e36276fc..f8093a817 100644 --- a/kded/plugins/ping/CMakeLists.txt +++ b/kded/plugins/ping/CMakeLists.txt @@ -14,6 +14,7 @@ include_directories( set(kdeconnect_ping_SRCS pingplugin.cpp ../kdeconnectplugin.cpp + ../../kdebugnamespace.cpp ) kde4_add_plugin(kdeconnect_ping ${kdeconnect_ping_SRCS}) diff --git a/kded/plugins/ping/pingplugin.cpp b/kded/plugins/ping/pingplugin.cpp index cd05f6a14..effbb8e43 100644 --- a/kded/plugins/ping/pingplugin.cpp +++ b/kded/plugins/ping/pingplugin.cpp @@ -20,24 +20,24 @@ #include "pingplugin.h" -#include - #include #include #include +#include "../../kdebugnamespace.h" + K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< PingPlugin >(); ) K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_ping", "kdeconnect_ping") ) PingPlugin::PingPlugin(QObject* parent, const QVariantList& args) : KdeConnectPlugin(parent, args) { - //qDebug() << "Ping plugin constructor for device" << device()->name(); + //kDebug(kdeconnect_kded()) << "Ping plugin constructor for device" << device()->name(); } PingPlugin::~PingPlugin() { - //qDebug() << "Ping plugin destructor for device" << device()->name(); + //kDebug(kdeconnect_kded()) << "Ping plugin destructor for device" << device()->name(); } bool PingPlugin::receivePackage(const NetworkPackage& np) diff --git a/kded/plugins/pluginloader.cpp b/kded/plugins/pluginloader.cpp index 49e117035..0207bcf6b 100644 --- a/kded/plugins/pluginloader.cpp +++ b/kded/plugins/pluginloader.cpp @@ -20,13 +20,11 @@ #include "pluginloader.h" -#include "kdeconnectplugin.h" - -#include - #include +#include "../kdebugnamespace.h" #include "../device.h" +#include "kdeconnectplugin.h" PluginLoader* PluginLoader::instance() { @@ -52,7 +50,7 @@ KPluginInfo PluginLoader::getPluginInfo(const QString& name) const { KService::Ptr service = plugins[name]; if (!service) { - qDebug() << "Plugin unknown" << name; + kDebug(kdeconnect_kded()) << "Plugin unknown" << name; return KPluginInfo(); } @@ -65,13 +63,13 @@ PluginData PluginLoader::instantiatePluginForDevice(const QString& name, Device* KService::Ptr service = plugins[name]; if (!service) { - qDebug() << "Plugin unknown" << name; + kDebug(kdeconnect_kded()) << "Plugin unknown" << name; return ret; } KPluginFactory *factory = KPluginLoader(service->library()).factory(); if (!factory) { - qDebug() << "KPluginFactory could not load the plugin:" << service->library(); + kDebug(kdeconnect_kded()) << "KPluginFactory could not load the plugin:" << service->library(); return ret; } @@ -81,11 +79,11 @@ PluginData PluginLoader::instantiatePluginForDevice(const QString& name, Device* ret.plugin = (KdeConnectPlugin*) factory->create(device, QVariantList() << deviceVariant); if (!ret.plugin) { - qDebug() << "Error loading plugin"; + kDebug(kdeconnect_kded()) << "Error loading plugin"; return ret; } - qDebug() << "Loaded plugin:" << service->name(); + kDebug(kdeconnect_kded()) << "Loaded plugin:" << service->name(); return ret; } diff --git a/kded/plugins/sharereceiver/CMakeLists.txt b/kded/plugins/sharereceiver/CMakeLists.txt index 7b321572a..aca6c007f 100644 --- a/kded/plugins/sharereceiver/CMakeLists.txt +++ b/kded/plugins/sharereceiver/CMakeLists.txt @@ -19,6 +19,7 @@ set(kdeconnect_sharereceiver_SRCS ../../filetransferjob.cpp ../../networkpackage.cpp ../../device.cpp + ../../kdebugnamespace.cpp ) kde4_add_plugin(kdeconnect_sharereceiver ${kdeconnect_sharereceiver_SRCS}) diff --git a/kded/plugins/sharereceiver/autoclosingqfile.h b/kded/plugins/sharereceiver/autoclosingqfile.h index ab25be8e1..680e9ad11 100644 --- a/kded/plugins/sharereceiver/autoclosingqfile.h +++ b/kded/plugins/sharereceiver/autoclosingqfile.h @@ -22,7 +22,8 @@ #define AUTOCLOSINGQFILE_H #include -#include + +#include "../../kdebugnamespace.h" class AutoClosingQFile : public QFile { diff --git a/kded/plugins/sharereceiver/sharereceiverplugin.cpp b/kded/plugins/sharereceiver/sharereceiverplugin.cpp index e389eb669..357753108 100644 --- a/kded/plugins/sharereceiver/sharereceiverplugin.cpp +++ b/kded/plugins/sharereceiver/sharereceiverplugin.cpp @@ -24,11 +24,11 @@ #include #include -#include #include #include #include +#include "../../kdebugnamespace.h" #include "../../filetransferjob.h" #include "autoclosingqfile.h" @@ -50,7 +50,7 @@ bool ShareReceiverPlugin::receivePackage(const NetworkPackage& np) //TODO: Move this code to a test and add a diff between files if (np.type() == PACKAGE_TYPE_PING) { - qDebug() << "sending file" << (QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/.bashrc"); + kDebug(kdeconnect_kded()) << "sending file" << (QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/.bashrc"); NetworkPackage out(PACKAGE_TYPE_SHARE); out.set("filename", mDestinationDir + "itworks.txt"); @@ -66,10 +66,10 @@ bool ShareReceiverPlugin::receivePackage(const NetworkPackage& np) } */ - qDebug() << "File transfer"; + kDebug(kdeconnect_kded()) << "File transfer"; if (np.hasPayload()) { - //qDebug() << "receiving file"; + //kDebug(kdeconnect_kded()) << "receiving file"; QString filename = np.get("filename", QString::number(QDateTime::currentMSecsSinceEpoch())); //TODO: Ask before overwritting or rename file if it already exists FileTransferJob* job = np.createPayloadTransferJob(mDestinationDir + filename); @@ -95,7 +95,7 @@ bool ShareReceiverPlugin::receivePackage(const NetworkPackage& np) QUrl url(np.get("url")); QDesktopServices::openUrl(url); } else { - qDebug() << "Error: Nothing attached!"; + kDebug(kdeconnect_kded()) << "Error: Nothing attached!"; } return true; @@ -104,7 +104,7 @@ bool ShareReceiverPlugin::receivePackage(const NetworkPackage& np) void ShareReceiverPlugin::finished(KJob* job) { - qDebug() << "File transfer finished"; + kDebug(kdeconnect_kded()) << "File transfer finished"; FileTransferJob* transferJob = (FileTransferJob*)job; KNotification* notification = new KNotification("pingReceived"); //KNotification::Persistent diff --git a/kded/plugins/telephony/CMakeLists.txt b/kded/plugins/telephony/CMakeLists.txt index e775afa71..2be4afb4e 100644 --- a/kded/plugins/telephony/CMakeLists.txt +++ b/kded/plugins/telephony/CMakeLists.txt @@ -13,6 +13,7 @@ include_directories(${KDE4_INCLUDES}) set(kdeconnect_telephony_SRCS telephonyplugin.cpp ../kdeconnectplugin.cpp + ../../kdebugnamespace.cpp ) kde4_add_plugin(kdeconnect_telephony ${kdeconnect_telephony_SRCS}) diff --git a/kded/plugins/telephony/telephonyplugin.cpp b/kded/plugins/telephony/telephonyplugin.cpp index ecc43e11d..fe031b5a1 100644 --- a/kded/plugins/telephony/telephonyplugin.cpp +++ b/kded/plugins/telephony/telephonyplugin.cpp @@ -20,11 +20,11 @@ #include "telephonyplugin.h" -#include - #include #include +#include "../../kdebugnamespace.h" + K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< TelephonyPlugin >(); ) K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_telephony", "kdeconnect_telephony") ) @@ -66,7 +66,7 @@ KNotification* TelephonyPlugin::createNotification(const NetworkPackage& np) content = i18n("Unknown telephony event: %2", event); } - qDebug() << "Creating notification with type:" << type; + kDebug(kdeconnect_kded()) << "Creating notification with type:" << type; KNotification* notification = new KNotification(type, KNotification::CloseOnTimeout, this); //, KNotification::Persistent notification->setPixmap(KIcon(icon).pixmap(48, 48)); diff --git a/libkdeconnect/CMakeLists.txt b/libkdeconnect/CMakeLists.txt index ceb6658d3..c937b04e2 100644 --- a/libkdeconnect/CMakeLists.txt +++ b/libkdeconnect/CMakeLists.txt @@ -13,6 +13,7 @@ set(libkdeconnect_SRC devicesmodel.cpp notificationsmodel.cpp modeltest.cpp + kdebugnamespace.cpp ) set_source_files_properties( diff --git a/libkdeconnect/devicesmodel.cpp b/libkdeconnect/devicesmodel.cpp index 915bf623f..0f717fcad 100644 --- a/libkdeconnect/devicesmodel.cpp +++ b/libkdeconnect/devicesmodel.cpp @@ -19,15 +19,16 @@ */ #include "devicesmodel.h" -#include "modeltest.h" -#include -#include #include +#include #include #include +#include "kdebugnamespace.h" +#include "modeltest.h" + DevicesModel::DevicesModel(QObject *parent) : QAbstractListModel(parent) , m_dbusInterface(new DaemonDbusInterface(this)) diff --git a/libkdeconnect/kdebugnamespace.cpp b/libkdeconnect/kdebugnamespace.cpp new file mode 100644 index 000000000..749e63253 --- /dev/null +++ b/libkdeconnect/kdebugnamespace.cpp @@ -0,0 +1,27 @@ +/** + * Copyright 2013 Albert Vaca + * + * 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 "kdebugnamespace.h" + +int libkdeconnect() { + static int s_area = KDebug::registerArea("kdeconnect_libkdeconnect", true); + return s_area; +} + diff --git a/libkdeconnect/kdebugnamespace.h b/libkdeconnect/kdebugnamespace.h new file mode 100644 index 000000000..322c8adca --- /dev/null +++ b/libkdeconnect/kdebugnamespace.h @@ -0,0 +1,29 @@ +/** + * Copyright 2013 Albert Vaca + * + * 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 . + */ + +#ifndef KDEBUG_LIBKDECONNECT_H +#define KDEBUG_LIBKDECONNECT_H + +#include + +int libkdeconnect(); + +#endif + diff --git a/libkdeconnect/notificationsmodel.cpp b/libkdeconnect/notificationsmodel.cpp index 9efce0fb1..46dc8ee5c 100644 --- a/libkdeconnect/notificationsmodel.cpp +++ b/libkdeconnect/notificationsmodel.cpp @@ -19,14 +19,15 @@ */ #include "notificationsmodel.h" -#include -#include #include +#include #include #include + #include "modeltest.h" +#include "kdebugnamespace.h" NotificationsModel::NotificationsModel(QObject *parent) : QAbstractListModel(parent)