qDebug -> kDebug with namespaces

Added 3 namespaces: kdeconnect_kded, kdeconnect_kcm and libkdeconnect
This commit is contained in:
Albert Vaca 2013-11-06 22:16:55 +01:00
parent b1c8726cac
commit 6e5de6f437
45 changed files with 311 additions and 128 deletions

View file

@ -4,8 +4,10 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}) ${CMAKE_BINARY_DIR})
set(kcm_SRCS devicessortproxymodel.cpp set(kcm_SRCS
kcm.cpp kcm.cpp
devicessortproxymodel.cpp
kdebugnamespace.cpp
) )
kde4_add_ui_files(kcm_SRCS kcm.ui) kde4_add_ui_files(kcm_SRCS kcm.ui)

View file

@ -23,7 +23,7 @@
#include "libkdeconnect/dbusinterfaces.h" #include "libkdeconnect/dbusinterfaces.h"
#include "libkdeconnect/devicesmodel.h" #include "libkdeconnect/devicesmodel.h"
#include <QDebug> #include "kdebugnamespace.h"
DevicesSortProxyModel::DevicesSortProxyModel(DevicesModel* devicesModel) DevicesSortProxyModel::DevicesSortProxyModel(DevicesModel* devicesModel)
: QSortFilterProxyModel(devicesModel) : QSortFilterProxyModel(devicesModel)

View file

@ -28,7 +28,6 @@
#include <QtGui/QListView> #include <QtGui/QListView>
#include <QDBusConnection> #include <QDBusConnection>
#include <QDBusInterface> #include <QDBusInterface>
#include <QDebug>
#include <KServiceTypeTrader> #include <KServiceTypeTrader>
#include <KPluginInfo> #include <KPluginInfo>
@ -38,6 +37,7 @@
#include "ui_kcm.h" #include "ui_kcm.h"
#include "libkdeconnect/dbusinterfaces.h" #include "libkdeconnect/dbusinterfaces.h"
#include "devicessortproxymodel.h" #include "devicessortproxymodel.h"
#include "kdebugnamespace.h"
K_PLUGIN_FACTORY(KdeConnectKcmFactory, registerPlugin<KdeConnectKcm>();) K_PLUGIN_FACTORY(KdeConnectKcmFactory, registerPlugin<KdeConnectKcm>();)
K_EXPORT_PLUGIN(KdeConnectKcmFactory("kdeconnect-kcm", "kdeconnect-kcm")) 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 //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; delete kcmUi->pluginSelector;
kcmUi->pluginSelector = new KPluginSelector(this); kcmUi->pluginSelector = new KPluginSelector(this);

26
kcm/kdebugnamespace.cpp Normal file
View file

@ -0,0 +1,26 @@
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "kdebugnamespace.h"
int kdeconnect_kcm() {
static int s_area = KDebug::registerArea("kdeconnect_kcm", true);
return s_area;
}

29
kcm/kdebugnamespace.h Normal file
View file

@ -0,0 +1,29 @@
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef KDEBUG_KDECONNECT_KCM_H
#define KDEBUG_KDECONNECT_KCM_H
#include <KDebug>
int kdeconnect_kcm();
#endif

View file

@ -25,6 +25,7 @@ set(kded_kdeconnect_SRCS
filetransferjob.cpp filetransferjob.cpp
daemon.cpp daemon.cpp
device.cpp device.cpp
kdebugnamespace.cpp
) )
kde4_add_plugin(kded_kdeconnect ${kded_kdeconnect_SRCS}) kde4_add_plugin(kded_kdeconnect ${kded_kdeconnect_SRCS})

View file

@ -29,7 +29,7 @@ DownloadJob::DownloadJob(QHostAddress address, QVariantMap transferInfo): KJob()
void DownloadJob::start() void DownloadJob::start()
{ {
//qDebug() << "DownloadJob Start"; //kDebug(kdeconnect_kded()) << "DownloadJob Start";
mSocket->connectToHost(mAddress, mPort, QIODevice::ReadOnly); mSocket->connectToHost(mAddress, mPort, QIODevice::ReadOnly);
connect(mSocket.data(), SIGNAL(disconnected()), connect(mSocket.data(), SIGNAL(disconnected()),
this, SLOT(disconnected())); this, SLOT(disconnected()));
@ -38,12 +38,12 @@ void DownloadJob::start()
void DownloadJob::disconnected() void DownloadJob::disconnected()
{ {
//qDebug() << "DownloadJob End"; //kDebug(kdeconnect_kded()) << "DownloadJob End";
emitResult(); emitResult();
} }
QSharedPointer<QIODevice> DownloadJob::getPayload() QSharedPointer<QIODevice> DownloadJob::getPayload()
{ {
//qDebug() << "getPayload"; //kDebug(kdeconnect_kded()) << "getPayload";
return mSocket.staticCast<QIODevice>(); return mSocket.staticCast<QIODevice>();
} }

View file

@ -81,7 +81,7 @@ void LanDeviceLink::dataReceived()
QByteArray package = mSocketLineReader->readLine(); QByteArray package = mSocketLineReader->readLine();
//qDebug() << "LanDeviceLink dataReceived" << package; //kDebug(kdeconnect_kded()) << "LanDeviceLink dataReceived" << package;
NetworkPackage unserialized(QString::null); NetworkPackage unserialized(QString::null);
NetworkPackage::unserialize(package, &unserialized); NetworkPackage::unserialize(package, &unserialized);
@ -92,7 +92,7 @@ void LanDeviceLink::dataReceived()
unserialized.decrypt(mPrivateKey, &decrypted); unserialized.decrypt(mPrivateKey, &decrypted);
if (decrypted.hasPayloadTransferInfo()) { if (decrypted.hasPayloadTransferInfo()) {
qDebug() << "HasPayloadTransferInfo"; kDebug(kdeconnect_kded()) << "HasPayloadTransferInfo";
DownloadJob* job = new DownloadJob(mSocketLineReader->peerAddress(), decrypted.payloadTransferInfo()); DownloadJob* job = new DownloadJob(mSocketLineReader->peerAddress(), decrypted.payloadTransferInfo());
job->start(); job->start();
decrypted.setPayload(job->getPayload(), decrypted.payloadSize()); decrypted.setPayload(job->getPayload(), decrypted.payloadSize());

View file

@ -29,6 +29,7 @@
#include <QTcpServer> #include <QTcpServer>
#include <QUdpSocket> #include <QUdpSocket>
#include "../../kdebugnamespace.h"
#include "landevicelink.h" #include "landevicelink.h"
void LanLinkProvider::configureSocket(QTcpSocket* socket) void LanLinkProvider::configureSocket(QTcpSocket* socket)
@ -108,13 +109,13 @@ void LanLinkProvider::newUdpConnection()
NetworkPackage::createIdentityPackage(&np2); NetworkPackage::createIdentityPackage(&np2);
if (np->get<QString>("deviceId") == np2.get<QString>("deviceId")) { if (np->get<QString>("deviceId") == np2.get<QString>("deviceId")) {
//qDebug() << "Ignoring my own broadcast"; //kDebug(kdeconnect_kded()) << "Ignoring my own broadcast";
return; return;
} }
int tcpPort = np->get<int>("tcpPort",port); int tcpPort = np->get<int>("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); QTcpSocket* socket = new QTcpSocket(this);
receivedIdentityPackages[socket].np = np; receivedIdentityPackages[socket].np = np;
@ -140,7 +141,7 @@ void LanLinkProvider::connectError()
disconnect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectError())); disconnect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectError()));
disconnect(socket, SIGNAL(connected()), this, SLOT(connected())); disconnect(socket, SIGNAL(connected()), this, SLOT(connected()));
qDebug() << "Fallback (1), try reverse connection"; kDebug(kdeconnect_kded()) << "Fallback (1), try reverse connection";
NetworkPackage np(""); NetworkPackage np("");
NetworkPackage::createIdentityPackage(&np); NetworkPackage::createIdentityPackage(&np);
np.set("tcpPort",tcpPort); np.set("tcpPort",tcpPort);
@ -160,7 +161,7 @@ void LanLinkProvider::connected()
NetworkPackage* np = receivedIdentityPackages[socket].np; NetworkPackage* np = receivedIdentityPackages[socket].np;
const QString& id = np->get<QString>("deviceId"); const QString& id = np->get<QString>("deviceId");
//qDebug() << "Connected" << socket->isWritable(); //kDebug(kdeconnect_kded()) << "Connected" << socket->isWritable();
LanDeviceLink* dl = new LanDeviceLink(id, this, socket); 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) //TODO: Use reverse connection too to preffer connecting a unstable device (a phone) to a stable device (a computer)
if (success) { 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*)), connect(dl, SIGNAL(destroyed(QObject*)),
this, SLOT(deviceLinkDestroyed(QObject*))); this, SLOT(deviceLinkDestroyed(QObject*)));
@ -192,7 +193,7 @@ void LanLinkProvider::connected()
} else { } else {
//I think this will never happen //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); QUdpSocket().writeDatagram(np2.serialize(), receivedIdentityPackages[socket].sender, port);
delete dl; 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) //I'm the new device and this is the answer to my UDP introduction (no data received yet)
void LanLinkProvider::newConnection() void LanLinkProvider::newConnection()
{ {
//qDebug() << "LanLinkProvider newConnection"; //kDebug(kdeconnect_kded()) << "LanLinkProvider newConnection";
QTcpSocket* socket = mTcpServer->nextPendingConnection(); QTcpSocket* socket = mTcpServer->nextPendingConnection();
socket->setSocketOption(QAbstractSocket::KeepAliveOption, 1); socket->setSocketOption(QAbstractSocket::KeepAliveOption, 1);
@ -218,7 +219,7 @@ void LanLinkProvider::newConnection()
NetworkPackage::createIdentityPackage(&np); NetworkPackage::createIdentityPackage(&np);
int written = socket->write(np.serialize()); 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(); QByteArray data = socket->readLine();
//qDebug() << "LanLinkProvider received reply:" << data; //kDebug(kdeconnect_kded()) << "LanLinkProvider received reply:" << data;
NetworkPackage np(""); NetworkPackage np("");
bool success = NetworkPackage::unserialize(data,&np); bool success = NetworkPackage::unserialize(data,&np);
@ -240,7 +241,7 @@ void LanLinkProvider::dataReceived()
const QString& id = np.get<QString>("deviceId"); const QString& id = np.get<QString>("deviceId");
LanDeviceLink* dl = new LanDeviceLink(id, this, socket); 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*)), connect(dl, SIGNAL(destroyed(QObject*)),
this, SLOT(deviceLinkDestroyed(QObject*))); this, SLOT(deviceLinkDestroyed(QObject*)));
@ -261,14 +262,14 @@ void LanLinkProvider::dataReceived()
disconnect(socket,SIGNAL(readyRead()),this,SLOT(dataReceived())); disconnect(socket,SIGNAL(readyRead()),this,SLOT(dataReceived()));
} else { } else {
qDebug() << "LanLinkProvider/newConnection: Not an identification package (wuh?)"; kDebug(kdeconnect_kded()) << "LanLinkProvider/newConnection: Not an identification package (wuh?)";
} }
} }
void LanLinkProvider::deviceLinkDestroyed(QObject* uncastedDeviceLink) void LanLinkProvider::deviceLinkDestroyed(QObject* uncastedDeviceLink)
{ {
//qDebug() << "deviceLinkDestroyed"; //kDebug(kdeconnect_kded()) << "deviceLinkDestroyed";
DeviceLink* deviceLink = (DeviceLink*)uncastedDeviceLink; DeviceLink* deviceLink = (DeviceLink*)uncastedDeviceLink;
const QString& id = deviceLink->deviceId(); const QString& id = deviceLink->deviceId();

View file

@ -20,6 +20,7 @@
#include "socketlinereader.h" #include "socketlinereader.h"
#include "../../kdebugnamespace.h"
SocketLineReader::SocketLineReader(QTcpSocket* socket, QObject* parent) SocketLineReader::SocketLineReader(QTcpSocket* socket, QObject* parent)
: QObject(parent) : QObject(parent)
@ -64,7 +65,7 @@ void SocketLineReader::dataReceived()
if (mPackages.length() > 0) { if (mPackages.length() > 0) {
Q_EMIT readyRead(); Q_EMIT readyRead();
} else { } else {
qDebug() << "Received incomplete chunk of data, waiting for more"; kDebug(kdeconnect_kded()) << "Received incomplete chunk of data, waiting for more";
} }
} }

View file

@ -19,8 +19,8 @@
*/ */
#include <qalgorithms.h> #include <qalgorithms.h>
#include <QDebug>
#include "kdebugnamespace.h"
#include "uploadjob.h" #include "uploadjob.h"
UploadJob::UploadJob(const QSharedPointer<QIODevice>& source): KJob() UploadJob::UploadJob(const QSharedPointer<QIODevice>& source): KJob()
@ -36,7 +36,7 @@ void UploadJob::start()
while(!mServer->listen(QHostAddress::Any, mPort)) { while(!mServer->listen(QHostAddress::Any, mPort)) {
mPort++; mPort++;
if (mPort > 1764) { //No ports available? 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; mPort = 0;
return; return;
} }

View file

@ -20,7 +20,7 @@
#include "loopbacklinkprovider.h" #include "loopbacklinkprovider.h"
#include <QDebug> #include "kdebugnamespace.h"
LoopbackLinkProvider::LoopbackLinkProvider() LoopbackLinkProvider::LoopbackLinkProvider()
: identityPackage(PACKAGE_TYPE_IDENTITY) : identityPackage(PACKAGE_TYPE_IDENTITY)
@ -37,7 +37,7 @@ LoopbackLinkProvider::~LoopbackLinkProvider()
void LoopbackLinkProvider::onNetworkChange(QNetworkSession::State state) void LoopbackLinkProvider::onNetworkChange(QNetworkSession::State state)
{ {
Q_UNUSED(state); Q_UNUSED(state);
//qDebug() << "Echo Device discovery emitted"; //kDebug(kdeconnect_kded()) << "Echo Device discovery emitted";
LoopbackDeviceLink* newLoopbackDeviceLink = new LoopbackDeviceLink("loopback", this); LoopbackDeviceLink* newLoopbackDeviceLink = new LoopbackDeviceLink("loopback", this);
Q_EMIT onConnectionReceived(identityPackage, newLoopbackDeviceLink); Q_EMIT onConnectionReceived(identityPackage, newLoopbackDeviceLink);

View file

@ -20,20 +20,19 @@
#include "daemon.h" #include "daemon.h"
#include "networkpackage.h"
#include "backends/lan/lanlinkprovider.h"
#include "backends/loopback/loopbacklinkprovider.h"
#include <QUuid> #include <QUuid>
#include <QDBusConnection> #include <QDBusConnection>
#include <QNetworkSession> #include <QNetworkSession>
#include <QNetworkConfigurationManager> #include <QNetworkConfigurationManager>
#include <QDebug>
#include <KConfig> #include <KConfig>
#include <KConfigGroup> #include <KConfigGroup>
#include "kdebugnamespace.h"
#include "networkpackage.h"
#include "backends/lan/lanlinkprovider.h"
#include "backends/loopback/loopbacklinkprovider.h"
K_PLUGIN_FACTORY(KdeConnectFactory, registerPlugin<Daemon>();) K_PLUGIN_FACTORY(KdeConnectFactory, registerPlugin<Daemon>();)
K_EXPORT_PLUGIN(KdeConnectFactory("kdeconnect", "kdeconnect")) K_EXPORT_PLUGIN(KdeConnectFactory("kdeconnect", "kdeconnect"))
@ -48,10 +47,10 @@ Daemon::Daemon(QObject *parent, const QList<QVariant>&)
//uuids contain charcaters that are not exportable in dbus paths //uuids contain charcaters that are not exportable in dbus paths
uuid = uuid.mid(1, uuid.length() - 2).replace("-", "_"); uuid = uuid.mid(1, uuid.length() - 2).replace("-", "_");
config->group("myself").writeEntry("id", uuid); 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")) { if(!QCA::isSupported("rsa")) {
//TODO: Maybe display this in a more visible way? //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" 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<QVariant>&)
} }
//Debugging //Debugging
qDebug() << "Starting KdeConnect daemon"; kDebug(kdeconnect_kded()) << "Starting KdeConnect daemon";
//Load backends (hardcoded by now, should be plugins in a future) //Load backends (hardcoded by now, should be plugins in a future)
mLinkProviders.insert(new LanLinkProvider()); mLinkProviders.insert(new LanLinkProvider());
@ -143,14 +142,14 @@ void Daemon::onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink*
{ {
const QString& id = identityPackage.get<QString>("deviceId"); const QString& id = identityPackage.get<QString>("deviceId");
//qDebug() << "Device discovered" << id << "via" << dl->provider()->name(); //kDebug(kdeconnect_kded()) << "Device discovered" << id << "via" << dl->provider()->name();
if (mDevices.contains(id)) { if (mDevices.contains(id)) {
//qDebug() << "It is a known device"; //kDebug(kdeconnect_kded()) << "It is a known device";
Device* device = mDevices[id]; Device* device = mDevices[id];
device->addLink(identityPackage, dl); device->addLink(identityPackage, dl);
} else { } else {
//qDebug() << "It is a new device"; //kDebug(kdeconnect_kded()) << "It is a new device";
Device* device = new Device(identityPackage, dl); Device* device = new Device(identityPackage, dl);
connect(device, SIGNAL(reachableStatusChanged()), this, SLOT(onDeviceReachableStatusChanged())); connect(device, SIGNAL(reachableStatusChanged()), this, SLOT(onDeviceReachableStatusChanged()));
@ -171,12 +170,12 @@ void Daemon::onDeviceReachableStatusChanged()
Q_EMIT deviceVisibilityChanged(id, device->isReachable()); 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->isReachable()) {
if (!device->isPaired()) { if (!device->isPaired()) {
qDebug() << "Destroying device" << device->name(); kDebug(kdeconnect_kded()) << "Destroying device" << device->name();
Q_EMIT deviceRemoved(id); Q_EMIT deviceRemoved(id);
mDevices.remove(id); mDevices.remove(id);
device->deleteLater(); device->deleteLater();

View file

@ -1,5 +1,7 @@
#include "device.h" #include "device.h"
#include <QDBusConnection>
#include <KSharedConfig> #include <KSharedConfig>
#include <KConfigGroup> #include <KConfigGroup>
#include <KStandardDirs> #include <KStandardDirs>
@ -8,9 +10,7 @@
#include <KNotification> #include <KNotification>
#include <KIcon> #include <KIcon>
#include <QDBusConnection> #include "kdebugnamespace.h"
#include <QDebug>
#include "plugins/kdeconnectplugin.h" #include "plugins/kdeconnectplugin.h"
#include "plugins/pluginloader.h" #include "plugins/pluginloader.h"
#include "backends/devicelink.h" #include "backends/devicelink.h"
@ -186,7 +186,7 @@ static bool lessThan(DeviceLink* p1, DeviceLink* p2)
void Device::addLink(const NetworkPackage& identityPackage, DeviceLink* link) 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<int>("protocolVersion"); m_protocolVersion = identityPackage.get<int>("protocolVersion");
if (m_protocolVersion != NetworkPackage::ProtocolVersion) { if (m_protocolVersion != NetworkPackage::ProtocolVersion) {
@ -236,7 +236,7 @@ void Device::removeLink(DeviceLink* link)
{ {
m_deviceLinks.removeOne(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()) { if (m_deviceLinks.isEmpty()) {
reloadPlugins(); reloadPlugins();
@ -264,12 +264,12 @@ void Device::privateReceivedPackage(const NetworkPackage& np)
{ {
if (np.type() == PACKAGE_TYPE_PAIR) { if (np.type() == PACKAGE_TYPE_PAIR) {
//qDebug() << "Pair package"; //kDebug(kdeconnect_kded()) << "Pair package";
bool wantsPair = np.get<bool>("pair"); bool wantsPair = np.get<bool>("pair");
if (wantsPair == isPaired()) { if (wantsPair == isPaired()) {
qDebug() << "Already" << (wantsPair? "paired":"unpaired"); kDebug(kdeconnect_kded()) << "Already" << (wantsPair? "paired":"unpaired");
if (m_pairStatus == Device::Requested) { if (m_pairStatus == Device::Requested) {
m_pairStatus = Device::NotPaired; m_pairStatus = Device::NotPaired;
pairingTimer.stop(); pairingTimer.stop();
@ -284,7 +284,7 @@ void Device::privateReceivedPackage(const NetworkPackage& np)
const QString& key = np.get<QString>("publicKey"); const QString& key = np.get<QString>("publicKey");
m_publicKey = QCA::RSAPublicKey::fromPEM(key); m_publicKey = QCA::RSAPublicKey::fromPEM(key);
if (m_publicKey.isNull()) { if (m_publicKey.isNull()) {
qDebug() << "ERROR decoding key"; kDebug(kdeconnect_kded()) << "ERROR decoding key";
if (m_pairStatus == Device::Requested) { if (m_pairStatus == Device::Requested) {
m_pairStatus = Device::NotPaired; m_pairStatus = Device::NotPaired;
pairingTimer.stop(); pairingTimer.stop();
@ -295,12 +295,12 @@ void Device::privateReceivedPackage(const NetworkPackage& np)
if (m_pairStatus == Device::Requested) { //We started pairing if (m_pairStatus == Device::Requested) { //We started pairing
qDebug() << "Pair answer"; kDebug(kdeconnect_kded()) << "Pair answer";
setAsPaired(); setAsPaired();
} else { } else {
qDebug() << "Pair request"; kDebug(kdeconnect_kded()) << "Pair request";
KNotification* notification = new KNotification("pingReceived"); //KNotification::Persistent KNotification* notification = new KNotification("pingReceived"); //KNotification::Persistent
notification->setPixmap(KIcon("dialog-information").pixmap(48, 48)); notification->setPixmap(KIcon("dialog-information").pixmap(48, 48));
@ -318,7 +318,7 @@ void Device::privateReceivedPackage(const NetworkPackage& np)
} else { } else {
qDebug() << "Unpair request"; kDebug(kdeconnect_kded()) << "Unpair request";
if (m_pairStatus == Device::Requested) { if (m_pairStatus == Device::Requested) {
pairingTimer.stop(); pairingTimer.stop();
@ -341,7 +341,7 @@ void Device::privateReceivedPackage(const NetworkPackage& np)
} }
} else { } else {
//TODO: Notify the other side that we don't trust them //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() void Device::rejectPairing()
{ {
qDebug() << "Rejected pairing"; kDebug(kdeconnect_kded()) << "Rejected pairing";
m_pairStatus = Device::NotPaired; m_pairStatus = Device::NotPaired;
@ -375,7 +375,7 @@ void Device::acceptPairing()
{ {
if (m_pairStatus != Device::RequestedByPeer) return; if (m_pairStatus != Device::RequestedByPeer) return;
qDebug() << "Accepted pairing"; kDebug(kdeconnect_kded()) << "Accepted pairing";
bool success = sendOwnPublicKey(); bool success = sendOwnPublicKey();
@ -424,7 +424,7 @@ void Device::sendPing()
{ {
NetworkPackage np(PACKAGE_TYPE_PING); NetworkPackage np(PACKAGE_TYPE_PING);
bool success = sendPackage(np); bool success = sendPackage(np);
qDebug() << "sendPing:" << success; kDebug(kdeconnect_kded()) << "sendPing:" << success;
} }
Device::DeviceType Device::str2type(QString deviceType) { Device::DeviceType Device::str2type(QString deviceType) {

View file

@ -20,10 +20,11 @@
#include "filetransferjob.h" #include "filetransferjob.h"
#include <qalgorithms.h>
#include <KLocalizedString> #include <KLocalizedString>
#include <QDebug> #include "kdebugnamespace.h"
#include <qalgorithms.h>
FileTransferJob::FileTransferJob(const QSharedPointer<QIODevice>& origin, int size, const KUrl& destination): KJob() FileTransferJob::FileTransferJob(const QSharedPointer<QIODevice>& origin, int size, const KUrl& destination): KJob()
{ {
@ -36,17 +37,17 @@ FileTransferJob::FileTransferJob(const QSharedPointer<QIODevice>& origin, int si
mOrigin = origin; mOrigin = origin;
mSize = size; mSize = size;
mWritten = 0; mWritten = 0;
qDebug() << "FileTransferJob Downloading payload to" << destination; kDebug(kdeconnect_kded()) << "FileTransferJob Downloading payload to" << destination;
} }
void FileTransferJob::openFinished(KJob* job) void FileTransferJob::openFinished(KJob* job)
{ {
qDebug() << job->errorString(); kDebug(kdeconnect_kded()) << job->errorString();
} }
void FileTransferJob::start() void FileTransferJob::start()
{ {
//qDebug() << "FileTransferJob start"; //kDebug(kdeconnect_kded()) << "FileTransferJob start";
//Open destination file //Open destination file
mDestination->start(); mDestination->start();
@ -56,10 +57,10 @@ void FileTransferJob::open(KIO::Job* job)
{ {
Q_UNUSED(job); Q_UNUSED(job);
//qDebug() << "FileTransferJob open"; //kDebug(kdeconnect_kded()) << "FileTransferJob open";
if (!mOrigin) { if (!mOrigin) {
qDebug() << "FileTransferJob: Origin is null"; kDebug(kdeconnect_kded()) << "FileTransferJob: Origin is null";
return; return;
} }
@ -80,7 +81,7 @@ void FileTransferJob::readyRead()
mDestination->write(data); mDestination->write(data);
mWritten += bytes; mWritten += bytes;
//qDebug() << "readyRead" << mSize << mWritten << bytes; //kDebug(kdeconnect_kded()) << "readyRead" << mSize << mWritten << bytes;
if (mSize > -1) { if (mSize > -1) {
setPercent((mWritten*100)/mSize); setPercent((mWritten*100)/mSize);
@ -101,12 +102,12 @@ void FileTransferJob::sourceFinished()
//TODO: MD5 check the file //TODO: MD5 check the file
if (mSize > -1 && mWritten != mSize) { if (mSize > -1 && mWritten != mSize) {
qDebug() << "Received incomplete file"; kDebug(kdeconnect_kded()) << "Received incomplete file";
setError(1); setError(1);
setErrorText(i18n("Received incomplete file")); setErrorText(i18n("Received incomplete file"));
emitResult(); emitResult();
} else { } else {
qDebug() << "Finished transfer" << mDestination->url(); kDebug(kdeconnect_kded()) << "Finished transfer" << mDestination->url();
} }
mDestination->close(); mDestination->close();
mDestination->deleteLater(); mDestination->deleteLater();

28
kded/kdebugnamespace.cpp Normal file
View file

@ -0,0 +1,28 @@
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "kdebugnamespace.h"
int kdeconnect_kded() {
static int s_area = KDebug::registerArea("kdeconnect_kded", true);
return s_area;
}

29
kded/kdebugnamespace.h Normal file
View file

@ -0,0 +1,29 @@
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef KDEBUG_KDECONNECT_KDED_H
#define KDEBUG_KDECONNECT_KDED_H
#include <KDebug>
int kdeconnect_kded();
#endif

View file

@ -59,7 +59,7 @@ void NetworkPackage::createIdentityPackage(NetworkPackage* np)
np->set("protocolType", "desktop"); //TODO: Detect laptop, tablet, phone... np->set("protocolType", "desktop"); //TODO: Detect laptop, tablet, phone...
np->set("protocolVersion", NetworkPackage::ProtocolVersion); np->set("protocolVersion", NetworkPackage::ProtocolVersion);
//qDebug() << "createIdentityPackage" << np->serialize(); //kDebug(kdeconnect_kded()) << "createIdentityPackage" << np->serialize();
} }
QByteArray NetworkPackage::serialize() const QByteArray NetworkPackage::serialize() const
@ -72,7 +72,7 @@ QByteArray NetworkPackage::serialize() const
QVariantMap variant = QJson::QObjectHelper::qobject2qvariant(this); QVariantMap variant = QJson::QObjectHelper::qobject2qvariant(this);
if (hasPayload()) { if (hasPayload()) {
//qDebug() << "Serializing payloadTransferInfo"; //kDebug(kdeconnect_kded()) << "Serializing payloadTransferInfo";
variant["payloadSize"] = 0; variant["payloadSize"] = 0;
variant["payloadTransferInfo"] = mPayloadTransferInfo; variant["payloadTransferInfo"] = mPayloadTransferInfo;
} }
@ -82,10 +82,10 @@ QByteArray NetworkPackage::serialize() const
QJson::Serializer serializer; QJson::Serializer serializer;
QByteArray json = serializer.serialize(variant,&ok); QByteArray json = serializer.serialize(variant,&ok);
if (!ok) { if (!ok) {
qDebug() << "Serialization error:" << serializer.errorMessage(); kDebug(kdeconnect_kded()) << "Serialization error:" << serializer.errorMessage();
} else { } else {
if (!isEncrypted()) { if (!isEncrypted()) {
//qDebug() << "Serialized package:" << json; //kDebug(kdeconnect_kded()) << "Serialized package:" << json;
} }
json.append('\n'); json.append('\n');
} }
@ -100,7 +100,7 @@ bool NetworkPackage::unserialize(const QByteArray& a, NetworkPackage* np)
bool ok; bool ok;
QVariantMap variant = parser.parse(a, &ok).toMap(); QVariantMap variant = parser.parse(a, &ok).toMap();
if (!ok) { if (!ok) {
qDebug() << "Unserialization error:" << a; kDebug(kdeconnect_kded()) << "Unserialization error:" << a;
return false; return false;
} }
@ -108,7 +108,7 @@ bool NetworkPackage::unserialize(const QByteArray& a, NetworkPackage* np)
QJson::QObjectHelper::qvariant2qobject(variant, np); QJson::QObjectHelper::qvariant2qobject(variant, np);
if (!np->isEncrypted()) { 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 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() ); chunks.append( encryptedChunk.toBase64() );
} }
//qDebug() << chunks.size() << "chunks"; //kDebug(kdeconnect_kded()) << chunks.size() << "chunks";
mId = QString::number(QDateTime::currentMSecsSinceEpoch()); mId = QString::number(QDateTime::currentMSecsSinceEpoch());
mType = PACKAGE_TYPE_ENCRYPTED; mType = PACKAGE_TYPE_ENCRYPTED;

View file

@ -23,19 +23,18 @@
#include "networkpackagetypes.h" #include "networkpackagetypes.h"
#include <KUrl>
#include <QObject> #include <QObject>
#include <QDebug>
#include <QString> #include <QString>
#include <QVariant> #include <QVariant>
#include <QStringList> #include <QStringList>
#include <QIODevice> #include <QIODevice>
#include <QtCrypto> #include <QtCrypto>
#include <QSharedPointer> #include <QSharedPointer>
#include <qjson/parser.h> #include <qjson/parser.h>
#include <KUrl>
#include "kdebugnamespace.h"
#include "default_args.h" #include "default_args.h"
class FileTransferJob; class FileTransferJob;

View file

@ -19,6 +19,7 @@ set(kdeconnect_battery_SRCS
../../networkpackage.cpp ../../networkpackage.cpp
../../filetransferjob.cpp ../../filetransferjob.cpp
../../device.cpp ../../device.cpp
../../kdebugnamespace.cpp
) )
kde4_add_plugin(kdeconnect_battery ${kdeconnect_battery_SRCS}) kde4_add_plugin(kdeconnect_battery ${kdeconnect_battery_SRCS})

View file

@ -20,7 +20,7 @@
#include "batterydbusinterface.h" #include "batterydbusinterface.h"
#include <QDebug> #include "../../kdebugnamespace.h"
BatteryDbusInterface::BatteryDbusInterface(QObject *parent) BatteryDbusInterface::BatteryDbusInterface(QObject *parent)
: QDBusAbstractAdaptor(parent) : QDBusAbstractAdaptor(parent)
@ -29,7 +29,7 @@ BatteryDbusInterface::BatteryDbusInterface(QObject *parent)
BatteryDbusInterface::~BatteryDbusInterface() BatteryDbusInterface::~BatteryDbusInterface()
{ {
qDebug() << "Destroying BatteryDbusInterface"; kDebug(kdeconnect_kded()) << "Destroying BatteryDbusInterface";
} }
void BatteryDbusInterface::updateValues(bool isCharging, int currentCharge) void BatteryDbusInterface::updateValues(bool isCharging, int currentCharge)

View file

@ -20,11 +20,11 @@
#include "batteryplugin.h" #include "batteryplugin.h"
#include <QDebug>
#include <KNotification> #include <KNotification>
#include <KIcon> #include <KIcon>
#include <KLocalizedString> #include <KLocalizedString>
#include "../../kdebugnamespace.h"
#include "batterydbusinterface.h" #include "batterydbusinterface.h"
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< BatteryPlugin >(); ) K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< BatteryPlugin >(); )

View file

@ -18,6 +18,7 @@ set(kdeconnect_clipboard_SRCS
../../networkpackage.cpp ../../networkpackage.cpp
../../filetransferjob.cpp ../../filetransferjob.cpp
../../device.cpp ../../device.cpp
../../kdebugnamespace.cpp
) )
kde4_add_plugin(kdeconnect_clipboard ${kdeconnect_clipboard_SRCS}) kde4_add_plugin(kdeconnect_clipboard ${kdeconnect_clipboard_SRCS})

View file

@ -43,7 +43,7 @@ void ClipboardPlugin::clipboardChanged(QClipboard::Mode mode)
ignore_next_clipboard_change = false; ignore_next_clipboard_change = false;
return; return;
} }
//qDebug() << "ClipboardChanged"; //kDebug(kdeconnect_kded()) << "ClipboardChanged";
NetworkPackage np(PACKAGE_TYPE_CLIPBOARD); NetworkPackage np(PACKAGE_TYPE_CLIPBOARD);
np.set("content",clipboard->text()); np.set("content",clipboard->text());
device()->sendPackage(np); device()->sendPackage(np);

View file

@ -18,6 +18,7 @@ set(kdeconnect_mpriscontrol_SRCS
../../networkpackage.cpp ../../networkpackage.cpp
../../filetransferjob.cpp ../../filetransferjob.cpp
../../device.cpp ../../device.cpp
../../kdebugnamespace.cpp
) )
qt4_add_dbus_interface( qt4_add_dbus_interface(

View file

@ -20,17 +20,18 @@
#include "mpriscontrolplugin.h" #include "mpriscontrolplugin.h"
#include "mprisdbusinterface.h"
#include "propertiesdbusinterface.h"
#include <QDBusArgument> #include <QDBusArgument>
#include <QDebug>
#include <QDBusConnection> #include <QDBusConnection>
#include <QDBusInterface> #include <QDBusInterface>
#include <qdbusconnectioninterface.h> #include <qdbusconnectioninterface.h>
#include <QDBusReply> #include <QDBusReply>
#include <QDBusMessage> #include <QDBusMessage>
#include "../../kdebugnamespace.h"
#include "mprisdbusinterface.h"
#include "propertiesdbusinterface.h"
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< MprisControlPlugin >(); ) K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< MprisControlPlugin >(); )
K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_mpriscontrol", "kdeconnect_mpriscontrol") ) K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_mpriscontrol", "kdeconnect_mpriscontrol") )
@ -60,7 +61,7 @@ void MprisControlPlugin::serviceOwnerChanged(const QString &name,
if (name.startsWith("org.mpris.MediaPlayer2")) { 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()) { if (oldOwner.isEmpty()) {
addPlayer(name); 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! //FIXME: This call hangs and returns an empty string if KDED is still starting!
const QString& identity = mprisInterface.property("Identity").toString(); const QString& identity = mprisInterface.property("Identity").toString();
playerList[identity] = service; playerList[identity] = service;
qDebug() << "Mpris addPlayer" << service << "->" << identity; kDebug(kdeconnect_kded()) << "Mpris addPlayer" << service << "->" << identity;
sendPlayerList(); sendPlayerList();
OrgFreedesktopDBusPropertiesInterface* freedesktopInterface = new OrgFreedesktopDBusPropertiesInterface(service, "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus(), this); 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) void MprisControlPlugin::removePlayer(const QString& ifaceName)
{ {
QString identity = playerList.key(ifaceName); QString identity = playerList.key(ifaceName);
qDebug() << "Mpris removePlayer" << ifaceName << "->" << identity; kDebug(kdeconnect_kded()) << "Mpris removePlayer" << ifaceName << "->" << identity;
playerList.remove(identity); playerList.remove(identity);
sendPlayerList(); sendPlayerList();
} }
@ -155,18 +156,18 @@ bool MprisControlPlugin::receivePackage (const NetworkPackage& np)
OrgMprisMediaPlayer2PlayerInterface mprisInterface(playerList[player], "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus()); OrgMprisMediaPlayer2PlayerInterface mprisInterface(playerList[player], "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus());
if (np.has("action")) { if (np.has("action")) {
const QString& action = np.get<QString>("action"); const QString& action = np.get<QString>("action");
qDebug() << "Calling action" << action << "in" << playerList[player]; kDebug(kdeconnect_kded()) << "Calling action" << action << "in" << playerList[player];
//TODO: Check for valid actions //TODO: Check for valid actions
mprisInterface.call(action); mprisInterface.call(action);
} }
if (np.has("setVolume")) { if (np.has("setVolume")) {
double volume = np.get<int>("setVolume")/100.f; double volume = np.get<int>("setVolume")/100.f;
qDebug() << "Setting volume" << volume << "to" << playerList[player]; kDebug(kdeconnect_kded()) << "Setting volume" << volume << "to" << playerList[player];
mprisInterface.setVolume(volume); mprisInterface.setVolume(volume);
} }
if (np.has("Seek")) { if (np.has("Seek")) {
int offset = np.get<int>("Seek"); int offset = np.get<int>("Seek");
qDebug() << "Seeking" << offset << "to" << playerList[player]; kDebug(kdeconnect_kded()) << "Seeking" << offset << "to" << playerList[player];
mprisInterface.Seek(offset); mprisInterface.Seek(offset);
} }

View file

@ -20,6 +20,7 @@ set(kdeconnect_notifications_SRCS
../../networkpackage.cpp ../../networkpackage.cpp
../../filetransferjob.cpp ../../filetransferjob.cpp
../../device.cpp ../../device.cpp
../../kdebugnamespace.cpp
) )
kde4_add_plugin(kdeconnect_notifications ${kdeconnect_notifications_SRCS}) kde4_add_plugin(kdeconnect_notifications ${kdeconnect_notifications_SRCS})

View file

@ -21,7 +21,8 @@
#include "notification.h" #include "notification.h"
#include <QDBusConnection> #include <QDBusConnection>
#include <QDebug>
#include "../../kdebugnamespace.h"
Notification::Notification(const NetworkPackage& np, const QString& iconPath, QObject* parent) Notification::Notification(const NetworkPackage& np, const QString& iconPath, QObject* parent)
: QObject(parent) : QObject(parent)

View file

@ -20,16 +20,16 @@
#include "notificationsdbusinterface.h" #include "notificationsdbusinterface.h"
#include "../../filetransferjob.h"
#include <notificationsplugin.h>
#include <QDebug>
#include <QDBusConnection> #include <QDBusConnection>
#include <KNotification> #include <KNotification>
#include <KIcon> #include <KIcon>
#include <KMD5> #include <KMD5>
#include "../../kdebugnamespace.h"
#include "../../filetransferjob.h"
#include "notificationsplugin.h"
NotificationsDbusInterface::NotificationsDbusInterface(Device* device, QObject *parent) NotificationsDbusInterface::NotificationsDbusInterface(Device* device, QObject *parent)
: QDBusAbstractAdaptor(parent) : QDBusAbstractAdaptor(parent)
, mDevice(device) , mDevice(device)
@ -101,10 +101,10 @@ void NotificationsDbusInterface::addNotification(Notification* noti)
void NotificationsDbusInterface::removeNotification(const QString& internalId) void NotificationsDbusInterface::removeNotification(const QString& internalId)
{ {
qDebug() << "removeNotification" << internalId; kDebug(kdeconnect_kded()) << "removeNotification" << internalId;
if (!mInternalIdToPublicId.contains(internalId)) { if (!mInternalIdToPublicId.contains(internalId)) {
qDebug() << "Not found"; kDebug(kdeconnect_kded()) << "Not found";
return; return;
} }
@ -112,7 +112,7 @@ void NotificationsDbusInterface::removeNotification(const QString& internalId)
Notification* noti = mNotifications.take(publicId); Notification* noti = mNotifications.take(publicId);
if (!noti) { if (!noti) {
qDebug() << "Not found"; kDebug(kdeconnect_kded()) << "Not found";
return; return;
} }

View file

@ -20,10 +20,9 @@
#include "notificationsplugin.h" #include "notificationsplugin.h"
#include <QDebug>
#include <KIcon> #include <KIcon>
#include "../../kdebugnamespace.h"
#include "notificationsdbusinterface.h" #include "notificationsdbusinterface.h"
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< NotificationsPlugin >(); ) K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< NotificationsPlugin >(); )

View file

@ -14,6 +14,7 @@ include_directories(
set(kdeconnect_pausemusic_SRCS set(kdeconnect_pausemusic_SRCS
pausemusicplugin.cpp pausemusicplugin.cpp
../kdeconnectplugin.cpp ../kdeconnectplugin.cpp
../../kdebugnamespace.cpp
) )
kde4_add_plugin(kdeconnect_pausemusic ${kdeconnect_pausemusic_SRCS}) kde4_add_plugin(kdeconnect_pausemusic ${kdeconnect_pausemusic_SRCS})

View file

@ -20,13 +20,14 @@
#include "pausemusicplugin.h" #include "pausemusicplugin.h"
#include <QDebug>
#include <QDBusConnection> #include <QDBusConnection>
#include <QDBusInterface> #include <QDBusInterface>
#include <QDBusConnectionInterface> #include <QDBusConnectionInterface>
#include <QDBusReply> #include <QDBusReply>
#include <QDBusMessage> #include <QDBusMessage>
#include "../../kdebugnamespace.h"
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< PauseMusicPlugin >(); ) K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< PauseMusicPlugin >(); )
K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_pausemusic", "kdeconnect_pausemusic") ) K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_pausemusic", "kdeconnect_pausemusic") )

View file

@ -14,6 +14,7 @@ include_directories(
set(kdeconnect_ping_SRCS set(kdeconnect_ping_SRCS
pingplugin.cpp pingplugin.cpp
../kdeconnectplugin.cpp ../kdeconnectplugin.cpp
../../kdebugnamespace.cpp
) )
kde4_add_plugin(kdeconnect_ping ${kdeconnect_ping_SRCS}) kde4_add_plugin(kdeconnect_ping ${kdeconnect_ping_SRCS})

View file

@ -20,24 +20,24 @@
#include "pingplugin.h" #include "pingplugin.h"
#include <QDebug>
#include <KNotification> #include <KNotification>
#include <KIcon> #include <KIcon>
#include <KLocalizedString> #include <KLocalizedString>
#include "../../kdebugnamespace.h"
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< PingPlugin >(); ) K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< PingPlugin >(); )
K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_ping", "kdeconnect_ping") ) K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_ping", "kdeconnect_ping") )
PingPlugin::PingPlugin(QObject* parent, const QVariantList& args) PingPlugin::PingPlugin(QObject* parent, const QVariantList& args)
: KdeConnectPlugin(parent, args) : KdeConnectPlugin(parent, args)
{ {
//qDebug() << "Ping plugin constructor for device" << device()->name(); //kDebug(kdeconnect_kded()) << "Ping plugin constructor for device" << device()->name();
} }
PingPlugin::~PingPlugin() 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) bool PingPlugin::receivePackage(const NetworkPackage& np)

View file

@ -20,13 +20,11 @@
#include "pluginloader.h" #include "pluginloader.h"
#include "kdeconnectplugin.h"
#include <QDebug>
#include <KServiceTypeTrader> #include <KServiceTypeTrader>
#include "../kdebugnamespace.h"
#include "../device.h" #include "../device.h"
#include "kdeconnectplugin.h"
PluginLoader* PluginLoader::instance() PluginLoader* PluginLoader::instance()
{ {
@ -52,7 +50,7 @@ KPluginInfo PluginLoader::getPluginInfo(const QString& name) const
{ {
KService::Ptr service = plugins[name]; KService::Ptr service = plugins[name];
if (!service) { if (!service) {
qDebug() << "Plugin unknown" << name; kDebug(kdeconnect_kded()) << "Plugin unknown" << name;
return KPluginInfo(); return KPluginInfo();
} }
@ -65,13 +63,13 @@ PluginData PluginLoader::instantiatePluginForDevice(const QString& name, Device*
KService::Ptr service = plugins[name]; KService::Ptr service = plugins[name];
if (!service) { if (!service) {
qDebug() << "Plugin unknown" << name; kDebug(kdeconnect_kded()) << "Plugin unknown" << name;
return ret; return ret;
} }
KPluginFactory *factory = KPluginLoader(service->library()).factory(); KPluginFactory *factory = KPluginLoader(service->library()).factory();
if (!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; return ret;
} }
@ -81,11 +79,11 @@ PluginData PluginLoader::instantiatePluginForDevice(const QString& name, Device*
ret.plugin = (KdeConnectPlugin*) factory->create<QObject>(device, QVariantList() << deviceVariant); ret.plugin = (KdeConnectPlugin*) factory->create<QObject>(device, QVariantList() << deviceVariant);
if (!ret.plugin) { if (!ret.plugin) {
qDebug() << "Error loading plugin"; kDebug(kdeconnect_kded()) << "Error loading plugin";
return ret; return ret;
} }
qDebug() << "Loaded plugin:" << service->name(); kDebug(kdeconnect_kded()) << "Loaded plugin:" << service->name();
return ret; return ret;
} }

View file

@ -19,6 +19,7 @@ set(kdeconnect_sharereceiver_SRCS
../../filetransferjob.cpp ../../filetransferjob.cpp
../../networkpackage.cpp ../../networkpackage.cpp
../../device.cpp ../../device.cpp
../../kdebugnamespace.cpp
) )
kde4_add_plugin(kdeconnect_sharereceiver ${kdeconnect_sharereceiver_SRCS}) kde4_add_plugin(kdeconnect_sharereceiver ${kdeconnect_sharereceiver_SRCS})

View file

@ -22,7 +22,8 @@
#define AUTOCLOSINGQFILE_H #define AUTOCLOSINGQFILE_H
#include <QFile> #include <QFile>
#include <QDebug>
#include "../../kdebugnamespace.h"
class AutoClosingQFile : public QFile class AutoClosingQFile : public QFile
{ {

View file

@ -24,11 +24,11 @@
#include <KLocalizedString> #include <KLocalizedString>
#include <KStandardDirs> #include <KStandardDirs>
#include <QDebug>
#include <QFile> #include <QFile>
#include <qprocess.h> #include <qprocess.h>
#include <QDesktopServices> #include <QDesktopServices>
#include "../../kdebugnamespace.h"
#include "../../filetransferjob.h" #include "../../filetransferjob.h"
#include "autoclosingqfile.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 //TODO: Move this code to a test and add a diff between files
if (np.type() == PACKAGE_TYPE_PING) { 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); NetworkPackage out(PACKAGE_TYPE_SHARE);
out.set("filename", mDestinationDir + "itworks.txt"); 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()) { if (np.hasPayload()) {
//qDebug() << "receiving file"; //kDebug(kdeconnect_kded()) << "receiving file";
QString filename = np.get<QString>("filename", QString::number(QDateTime::currentMSecsSinceEpoch())); QString filename = np.get<QString>("filename", QString::number(QDateTime::currentMSecsSinceEpoch()));
//TODO: Ask before overwritting or rename file if it already exists //TODO: Ask before overwritting or rename file if it already exists
FileTransferJob* job = np.createPayloadTransferJob(mDestinationDir + filename); FileTransferJob* job = np.createPayloadTransferJob(mDestinationDir + filename);
@ -95,7 +95,7 @@ bool ShareReceiverPlugin::receivePackage(const NetworkPackage& np)
QUrl url(np.get<QString>("url")); QUrl url(np.get<QString>("url"));
QDesktopServices::openUrl(url); QDesktopServices::openUrl(url);
} else { } else {
qDebug() << "Error: Nothing attached!"; kDebug(kdeconnect_kded()) << "Error: Nothing attached!";
} }
return true; return true;
@ -104,7 +104,7 @@ bool ShareReceiverPlugin::receivePackage(const NetworkPackage& np)
void ShareReceiverPlugin::finished(KJob* job) void ShareReceiverPlugin::finished(KJob* job)
{ {
qDebug() << "File transfer finished"; kDebug(kdeconnect_kded()) << "File transfer finished";
FileTransferJob* transferJob = (FileTransferJob*)job; FileTransferJob* transferJob = (FileTransferJob*)job;
KNotification* notification = new KNotification("pingReceived"); //KNotification::Persistent KNotification* notification = new KNotification("pingReceived"); //KNotification::Persistent

View file

@ -13,6 +13,7 @@ include_directories(${KDE4_INCLUDES})
set(kdeconnect_telephony_SRCS set(kdeconnect_telephony_SRCS
telephonyplugin.cpp telephonyplugin.cpp
../kdeconnectplugin.cpp ../kdeconnectplugin.cpp
../../kdebugnamespace.cpp
) )
kde4_add_plugin(kdeconnect_telephony ${kdeconnect_telephony_SRCS}) kde4_add_plugin(kdeconnect_telephony ${kdeconnect_telephony_SRCS})

View file

@ -20,11 +20,11 @@
#include "telephonyplugin.h" #include "telephonyplugin.h"
#include <QDebug>
#include <KLocalizedString> #include <KLocalizedString>
#include <KIcon> #include <KIcon>
#include "../../kdebugnamespace.h"
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< TelephonyPlugin >(); ) K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< TelephonyPlugin >(); )
K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_telephony", "kdeconnect_telephony") ) 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); 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 KNotification* notification = new KNotification(type, KNotification::CloseOnTimeout, this); //, KNotification::Persistent
notification->setPixmap(KIcon(icon).pixmap(48, 48)); notification->setPixmap(KIcon(icon).pixmap(48, 48));

View file

@ -13,6 +13,7 @@ set(libkdeconnect_SRC
devicesmodel.cpp devicesmodel.cpp
notificationsmodel.cpp notificationsmodel.cpp
modeltest.cpp modeltest.cpp
kdebugnamespace.cpp
) )
set_source_files_properties( set_source_files_properties(

View file

@ -19,15 +19,16 @@
*/ */
#include "devicesmodel.h" #include "devicesmodel.h"
#include "modeltest.h"
#include <ksharedconfig.h>
#include <QDebug>
#include <QDBusInterface> #include <QDBusInterface>
#include <KSharedConfig>
#include <KConfigGroup> #include <KConfigGroup>
#include <KIcon> #include <KIcon>
#include "kdebugnamespace.h"
#include "modeltest.h"
DevicesModel::DevicesModel(QObject *parent) DevicesModel::DevicesModel(QObject *parent)
: QAbstractListModel(parent) : QAbstractListModel(parent)
, m_dbusInterface(new DaemonDbusInterface(this)) , m_dbusInterface(new DaemonDbusInterface(this))

View file

@ -0,0 +1,27 @@
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "kdebugnamespace.h"
int libkdeconnect() {
static int s_area = KDebug::registerArea("kdeconnect_libkdeconnect", true);
return s_area;
}

View file

@ -0,0 +1,29 @@
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef KDEBUG_LIBKDECONNECT_H
#define KDEBUG_LIBKDECONNECT_H
#include <KDebug>
int libkdeconnect();
#endif

View file

@ -19,14 +19,15 @@
*/ */
#include "notificationsmodel.h" #include "notificationsmodel.h"
#include <ksharedconfig.h>
#include <QDebug>
#include <QDBusInterface> #include <QDBusInterface>
#include <KSharedConfig>
#include <KConfigGroup> #include <KConfigGroup>
#include <KIcon> #include <KIcon>
#include "modeltest.h" #include "modeltest.h"
#include "kdebugnamespace.h"
NotificationsModel::NotificationsModel(QObject *parent) NotificationsModel::NotificationsModel(QObject *parent)
: QAbstractListModel(parent) : QAbstractListModel(parent)