Commit cabb0f2f authored by Albert Vaca Cintora's avatar Albert Vaca Cintora

Simplified debug areas so we only have one, called "kdeconnect"

parent 3147067f
......@@ -28,7 +28,6 @@ set(kded_kdeconnect_SRCS
filetransferjob.cpp
daemon.cpp
device.cpp
kdebugnamespace.cpp
)
kde4_add_library(kdeconnectcore SHARED ${kded_kdeconnect_SRCS})
......
......@@ -80,7 +80,7 @@ void LanDeviceLink::dataReceived()
const QByteArray package = mSocketLineReader->readLine();
//kDebug(kdeconnect_kded()) << "LanDeviceLink dataReceived" << package;
//kDebug(debugArea()) << "LanDeviceLink dataReceived" << package;
NetworkPackage unserialized(QString::null);
NetworkPackage::unserialize(package, &unserialized);
......@@ -90,7 +90,7 @@ void LanDeviceLink::dataReceived()
unserialized.decrypt(mPrivateKey, &decrypted);
if (decrypted.hasPayloadTransferInfo()) {
kDebug(kdeconnect_kded()) << "HasPayloadTransferInfo";
kDebug(debugArea()) << "HasPayloadTransferInfo";
DownloadJob* job = new DownloadJob(mSocketLineReader->peerAddress(), decrypted.payloadTransferInfo());
job->start();
decrypted.setPayload(job->getPayload(), decrypted.payloadSize());
......
......@@ -151,7 +151,7 @@ void LanLinkProvider::connectError()
disconnect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectError()));
disconnect(socket, SIGNAL(connected()), this, SLOT(connected()));
kDebug(kdeconnect_kded()) << "Fallback (1), try reverse connection";
kDebug(debugArea()) << "Fallback (1), try reverse connection";
NetworkPackage np("");
NetworkPackage::createIdentityPackage(&np);
np.set("tcpPort", mTcpPort);
......@@ -173,7 +173,7 @@ void LanLinkProvider::connected()
NetworkPackage* receivedPackage = receivedIdentityPackages[socket].np;
const QString& deviceId = receivedPackage->get<QString>("deviceId");
//kDebug(kdeconnect_kded()) << "Connected" << socket->isWritable();
//kDebug(debugArea()) << "Connected" << socket->isWritable();
LanDeviceLink* deviceLink = new LanDeviceLink(deviceId, this, socket);
......@@ -185,7 +185,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) {
//kDebug(kdeconnect_kded()) << "Handshaking done (i'm the existing device)";
//kDebug(debugArea()) << "Handshaking done (i'm the existing device)";
connect(deviceLink, SIGNAL(destroyed(QObject*)),
this, SLOT(deviceLinkDestroyed(QObject*)));
......@@ -206,7 +206,7 @@ void LanLinkProvider::connected()
} else {
//I think this will never happen
kDebug(kdeconnect_kded()) << "Fallback (2), try reverse connection";
kDebug(debugArea()) << "Fallback (2), try reverse connection";
mUdpSocket.writeDatagram(np2.serialize(), receivedIdentityPackages[socket].sender, port);
delete deviceLink;
}
......@@ -220,7 +220,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()
{
//kDebug(kdeconnect_kded()) << "LanLinkProvider newConnection";
//kDebug(debugArea()) << "LanLinkProvider newConnection";
while(mTcpServer->hasPendingConnections()) {
QTcpSocket* socket = mTcpServer->nextPendingConnection();
......@@ -234,7 +234,7 @@ void LanLinkProvider::newConnection()
NetworkPackage::createIdentityPackage(&np);
int written = socket->write(np.serialize());
kDebug(kdeconnect_kded()) << "LanLinkProvider sent package." << written << " bytes written, waiting for reply";
kDebug(debugArea()) << "LanLinkProvider sent package." << written << " bytes written, waiting for reply";
*/
}
......@@ -246,20 +246,20 @@ void LanLinkProvider::dataReceived()
const QByteArray data = socket->readLine();
//kDebug(kdeconnect_kded()) << "LanLinkProvider received reply:" << data;
//kDebug(debugArea()) << "LanLinkProvider received reply:" << data;
NetworkPackage np("");
bool success = NetworkPackage::unserialize(data, &np);
if (!success || np.type() != PACKAGE_TYPE_IDENTITY) {
kDebug(kdeconnect_kded()) << "LanLinkProvider/newConnection: Not an identification package (wuh?)";
kDebug(debugArea()) << "LanLinkProvider/newConnection: Not an identification package (wuh?)";
return;
}
const QString& deviceId = np.get<QString>("deviceId");
LanDeviceLink* deviceLink = new LanDeviceLink(deviceId, this, socket);
//kDebug(kdeconnect_kded()) << "Handshaking done (i'm the new device)";
//kDebug(debugArea()) << "Handshaking done (i'm the new device)";
connect(deviceLink, SIGNAL(destroyed(QObject*)),
this, SLOT(deviceLinkDestroyed(QObject*)));
......@@ -282,7 +282,7 @@ void LanLinkProvider::dataReceived()
void LanLinkProvider::deviceLinkDestroyed(QObject* destroyedDeviceLink)
{
//kDebug(kdeconnect_kded()) << "deviceLinkDestroyed";
//kDebug(debugArea()) << "deviceLinkDestroyed";
const QString id = destroyedDeviceLink->property("deviceId").toString();
QMap< QString, DeviceLink* >::iterator oldLinkIterator = mLinks.find(id);
if (oldLinkIterator != mLinks.end() && oldLinkIterator.value() == destroyedDeviceLink) {
......
......@@ -39,7 +39,7 @@ void UploadJob::start()
while(!mServer->listen(QHostAddress::Any, mPort)) {
mPort++;
if (mPort > 1764) { //No ports available?
kDebug(kdeconnect_kded()) << "Error opening a port in range 1739-1764 for file transfer";
kDebug(debugArea()) << "Error opening a port in range 1739-1764 for file transfer";
mPort = 0;
return;
}
......
......@@ -69,13 +69,13 @@ Daemon::Daemon(QObject *parent)
uuid = uuid.mid(1, uuid.length() - 2).replace("-", "_");
config->group("myself").writeEntry("id", uuid);
config->sync();
kDebug(kdeconnect_kded()) << "My id:" << uuid;
kDebug(debugArea()) << "My id:" << uuid;
}
//kDebug(kdeconnect_kded()) << "QCA supported capabilities:" << QCA::supportedFeatures().join(",");
//kDebug(debugArea()) << "QCA supported capabilities:" << QCA::supportedFeatures().join(",");
if(!QCA::isSupported("rsa")) {
//TODO: Maybe display this in a more visible way?
kWarning(kdeconnect_kded()) << "Error: KDE Connect could not find support for RSA in your QCA installation, if your distribution provides"
kWarning(debugArea()) << "Error: KDE Connect could not find support for RSA in your QCA installation, if your distribution provides"
<< "separate packages for QCA-ossl and QCA-gnupg plugins, make sure you have them installed and try again";
return;
}
......@@ -89,13 +89,13 @@ Daemon::Daemon(QObject *parent)
if (!privKey.open(QIODevice::ReadWrite | QIODevice::Truncate))
{
kWarning(kdeconnect_kded()) << "Error: KDE Connect could not create private keys file: " << privateKeyPath;
kWarning(debugArea()) << "Error: KDE Connect could not create private keys file: " << privateKeyPath;
return;
}
if (!privKey.setPermissions(strict))
{
kWarning(kdeconnect_kded()) << "Error: KDE Connect could not set permissions for private file: " << privateKeyPath;
kWarning(debugArea()) << "Error: KDE Connect could not set permissions for private file: " << privateKeyPath;
}
//http://delta.affinix.com/docs/qca/rsatest_8cpp-example.html
......@@ -113,11 +113,11 @@ Daemon::Daemon(QObject *parent)
if (QFile::permissions(config->group("myself").readEntry("privateKeyPath")) != strict)
{
kWarning(kdeconnect_kded()) << "Error: KDE Connect detects wrong permissions for private file " << config->group("myself").readEntry("privateKeyPath");
kWarning(debugArea()) << "Error: KDE Connect detects wrong permissions for private file " << config->group("myself").readEntry("privateKeyPath");
}
//Debugging
kDebug(kdeconnect_kded()) << "Starting KdeConnect daemon";
kDebug(debugArea()) << "Starting KdeConnect daemon";
//Load backends (hardcoded by now, should be plugins in a future)
d->mLinkProviders.insert(new LanLinkProvider());
......@@ -185,14 +185,14 @@ void Daemon::onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink*
const QString& id = identityPackage.get<QString>("deviceId");
//kDebug(kdeconnect_kded()) << "Device discovered" << id << "via" << dl->provider()->name();
//kDebug(debugArea()) << "Device discovered" << id << "via" << dl->provider()->name();
if (d->mDevices.contains(id)) {
//kDebug(kdeconnect_kded()) << "It is a known device";
//kDebug(debugArea()) << "It is a known device";
Device* device = d->mDevices[id];
device->addLink(identityPackage, dl);
} else {
//kDebug(kdeconnect_kded()) << "It is a new device";
//kDebug(debugArea()) << "It is a new device";
Device* device = new Device(this, identityPackage, dl);
connect(device, SIGNAL(reachableStatusChanged()), this, SLOT(onDeviceReachableStatusChanged()));
......@@ -213,12 +213,12 @@ void Daemon::onDeviceReachableStatusChanged()
Q_EMIT deviceVisibilityChanged(id, device->isReachable());
//kDebug(kdeconnect_kded()) << "Device" << device->name() << "reachable status changed:" << device->isReachable();
//kDebug(debugArea()) << "Device" << device->name() << "reachable status changed:" << device->isReachable();
if (!device->isReachable()) {
if (!device->isPaired()) {
kDebug(kdeconnect_kded()) << "Destroying device" << device->name();
kDebug(debugArea()) << "Destroying device" << device->name();
Q_EMIT deviceRemoved(id);
d->mDevices.remove(id);
device->deleteLater();
......
......@@ -233,7 +233,7 @@ static bool lessThan(DeviceLink* p1, DeviceLink* p2)
void Device::addLink(const NetworkPackage& identityPackage, DeviceLink* link)
{
//kDebug(kdeconnect_kded()) << "Adding link to" << id() << "via" << link->provider();
//kDebug(debugArea()) << "Adding link to" << id() << "via" << link->provider();
m_protocolVersion = identityPackage.get<int>("protocolVersion");
if (m_protocolVersion != NetworkPackage::ProtocolVersion) {
......@@ -280,7 +280,7 @@ void Device::removeLink(DeviceLink* link)
{
m_deviceLinks.removeOne(link);
//kDebug(kdeconnect_kded()) << "RemoveLink" << m_deviceLinks.size() << "links remaining";
//kDebug(debugArea()) << "RemoveLink" << m_deviceLinks.size() << "links remaining";
if (m_deviceLinks.isEmpty()) {
reloadPlugins();
......@@ -313,12 +313,12 @@ void Device::privateReceivedPackage(const NetworkPackage& np)
{
if (np.type() == PACKAGE_TYPE_PAIR) {
//kDebug(kdeconnect_kded()) << "Pair package";
//kDebug(debugArea()) << "Pair package";
bool wantsPair = np.get<bool>("pair");
if (wantsPair == isPaired()) {
kDebug(kdeconnect_kded()) << "Already" << (wantsPair? "paired":"unpaired");
kDebug(debugArea()) << "Already" << (wantsPair? "paired":"unpaired");
if (m_pairStatus == Device::Requested) {
m_pairStatus = Device::NotPaired;
m_pairingTimeut.stop();
......@@ -333,7 +333,7 @@ void Device::privateReceivedPackage(const NetworkPackage& np)
const QString& key = np.get<QString>("publicKey");
m_publicKey = QCA::RSAPublicKey::fromPEM(key);
if (m_publicKey.isNull()) {
kDebug(kdeconnect_kded()) << "ERROR decoding key";
kDebug(debugArea()) << "ERROR decoding key";
if (m_pairStatus == Device::Requested) {
m_pairStatus = Device::NotPaired;
m_pairingTimeut.stop();
......@@ -344,12 +344,12 @@ void Device::privateReceivedPackage(const NetworkPackage& np)
if (m_pairStatus == Device::Requested) { //We started pairing
kDebug(kdeconnect_kded()) << "Pair answer";
kDebug(debugArea()) << "Pair answer";
setAsPaired();
} else {
kDebug(kdeconnect_kded()) << "Pair request";
kDebug(debugArea()) << "Pair request";
KNotification* notification = new KNotification("pingReceived"); //KNotification::Persistent
notification->setPixmap(KIcon("dialog-information").pixmap(48, 48));
......@@ -367,7 +367,7 @@ void Device::privateReceivedPackage(const NetworkPackage& np)
} else {
kDebug(kdeconnect_kded()) << "Unpair request";
kDebug(debugArea()) << "Unpair request";
PairStatus prevPairStatus = m_pairStatus;
m_pairStatus = Device::NotPaired;
......@@ -390,7 +390,7 @@ void Device::privateReceivedPackage(const NetworkPackage& np)
plugin->receivePackage(np);
}
} else {
kDebug(kdeconnect_kded()) << "device" << name() << "not paired, ignoring package" << np.type();
kDebug(debugArea()) << "device" << name() << "not paired, ignoring package" << np.type();
unpair();
}
......@@ -408,7 +408,7 @@ bool Device::sendOwnPublicKey()
void Device::rejectPairing()
{
kDebug(kdeconnect_kded()) << "Rejected pairing";
kDebug(debugArea()) << "Rejected pairing";
m_pairStatus = Device::NotPaired;
......@@ -424,7 +424,7 @@ void Device::acceptPairing()
{
if (m_pairStatus != Device::RequestedByPeer) return;
kDebug(kdeconnect_kded()) << "Accepted pairing";
kDebug(debugArea()) << "Accepted pairing";
bool success = sendOwnPublicKey();
......
......@@ -41,18 +41,18 @@ FileTransferJob::FileTransferJob(const QSharedPointer<QIODevice>& origin, int si
mDeviceName = i18nc("Device name that will appear on the jobs", "KDE-Connect");
setCapabilities(Killable);
kDebug(kdeconnect_kded()) << "FileTransferJob Downloading payload to" << destination;
kDebug(debugArea()) << "FileTransferJob Downloading payload to" << destination;
}
void FileTransferJob::openFinished(KJob* job)
{
kDebug(kdeconnect_kded()) << job->errorString();
kDebug(debugArea()) << job->errorString();
}
void FileTransferJob::start()
{
QMetaObject::invokeMethod(this, "doStart", Qt::QueuedConnection);
//kDebug(kdeconnect_kded()) << "FileTransferJob start";
//kDebug(debugArea()) << "FileTransferJob start";
}
void FileTransferJob::doStart()
......@@ -136,10 +136,10 @@ void FileTransferJob::open(KIO::Job* job)
{
Q_UNUSED(job);
//kDebug(kdeconnect_kded()) << "FileTransferJob open";
//kDebug(debugArea()) << "FileTransferJob open";
if (!mOrigin) {
kDebug(kdeconnect_kded()) << "FileTransferJob: Origin is null";
kDebug(debugArea()) << "FileTransferJob: Origin is null";
return;
}
......@@ -161,7 +161,7 @@ void FileTransferJob::readyRead()
mWritten += data.size();
setProcessedAmount(Bytes, mWritten);
//kDebug(kdeconnect_kded()) << "readyRead" << mSize << mWritten << bytes;
//kDebug(debugArea()) << "readyRead" << mSize << mWritten << bytes;
if (mSize > -1) {
//If a least 1 second has passed since last update
......@@ -192,11 +192,11 @@ void FileTransferJob::sourceFinished()
//TODO: MD5 check the file
if (mSize > -1 && mWritten != mSize) {
kDebug(kdeconnect_kded()) << "Received incomplete file (" << mWritten << " of " << mSize << " bytes)";
kDebug(debugArea()) << "Received incomplete file (" << mWritten << " of " << mSize << " bytes)";
setError(1);
setErrorText(i18n("Received incomplete file"));
} else {
kDebug(kdeconnect_kded()) << "Finished transfer" << mDestinationJob->url();
kDebug(debugArea()) << "Finished transfer" << mDestinationJob->url();
}
mDestinationJob->close();
mDestinationJob->deleteLater();
......
/**
* 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;
}
......@@ -23,7 +23,11 @@
#include <KDebug>
KDE_EXPORT int kdeconnect_kded();
inline int debugArea()
{
static int theArea = KDebug::registerArea("kdeconnect");
return theArea;
};
#endif
......@@ -82,10 +82,10 @@ QByteArray NetworkPackage::serialize() const
QJson::Serializer serializer;
QByteArray json = serializer.serialize(variant,&ok);
if (!ok) {
kDebug(kdeconnect_kded()) << "Serialization error:" << serializer.errorMessage();
kDebug(debugArea()) << "Serialization error:" << serializer.errorMessage();
} else {
if (!isEncrypted()) {
//kDebug(kdeconnect_kded()) << "Serialized package:" << json;
//kDebug(kDebugArea) << "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) {
kDebug(kdeconnect_kded()) << "Unserialization error:" << a;
kDebug(debugArea()) << "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()) {
//kDebug(kdeconnect_kded()) << "Unserialized: " << a;
//kDebug(kDebugArea) << "Unserialized: " << a;
}
np->mPayloadSize = variant["payloadSize"].toInt(); //Will return 0 if was not present, which is ok
......
......@@ -50,7 +50,7 @@ KPluginInfo PluginLoader::getPluginInfo(const QString& name) const
{
KService::Ptr service = plugins[name];
if (!service) {
kDebug(kdeconnect_kded()) << "Plugin unknown" << name;
kDebug(debugArea()) << "Plugin unknown" << name;
return KPluginInfo();
}
......@@ -63,13 +63,13 @@ PluginData PluginLoader::instantiatePluginForDevice(const QString& name, Device*
KService::Ptr service = plugins[name];
if (!service) {
kDebug(kdeconnect_kded()) << "Plugin unknown" << name;
kDebug(debugArea()) << "Plugin unknown" << name;
return ret;
}
KPluginFactory *factory = KPluginLoader(service->library()).factory();
if (!factory) {
kDebug(kdeconnect_kded()) << "KPluginFactory could not load the plugin:" << service->library();
kDebug(debugArea()) << "KPluginFactory could not load the plugin:" << service->library();
return ret;
}
......@@ -81,11 +81,11 @@ PluginData PluginLoader::instantiatePluginForDevice(const QString& name, Device*
//FIXME any reason to use QObject in template param instead KdeConnectPlugin?
ret.plugin = factory->create<KdeConnectPlugin>(device, QVariantList() << deviceVariant << ret.outgoingInterfaces);
if (!ret.plugin) {
kDebug(kdeconnect_kded()) << "Error loading plugin";
kDebug(debugArea()) << "Error loading plugin";
return ret;
}
kDebug(kdeconnect_kded()) << "Loaded plugin:" << service->name();
kDebug(debugArea()) << "Loaded plugin:" << service->name();
return ret;
}
......@@ -15,7 +15,6 @@ set(libkdeconnect_SRC
devicesmodel.cpp
notificationsmodel.cpp
modeltest.cpp
kdebugnamespace.cpp
)
set(libkdeconnect_public_HEADERS
......
/**
* 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;
}
/**
* 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
......@@ -7,7 +7,6 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}
set(kcm_SRCS
kcm.cpp
devicessortproxymodel.cpp
kdebugnamespace.cpp
)
kde4_add_ui_files(kcm_SRCS kcm.ui)
......
......@@ -20,10 +20,9 @@
#include "devicessortproxymodel.h"
#include "interfaces/dbusinterfaces.h"
#include "interfaces/devicesmodel.h"
#include "kdebugnamespace.h"
#include <core/kdebugnamespace.h>
#include <interfaces/dbusinterfaces.h>
#include <interfaces/devicesmodel.h>
DevicesSortProxyModel::DevicesSortProxyModel(DevicesModel* devicesModel)
: QSortFilterProxyModel(devicesModel)
......
......@@ -34,11 +34,12 @@
#include <KPluginFactory>
#include <KStandardDirs>
#include <core/kdebugnamespace.h>
#include "ui_kcm.h"
#include "interfaces/dbusinterfaces.h"
#include "interfaces/devicesmodel.h"
#include "devicessortproxymodel.h"
#include "kdebugnamespace.h"
K_PLUGIN_FACTORY(KdeConnectKcmFactory, registerPlugin<KdeConnectKcm>();)
K_EXPORT_PLUGIN(KdeConnectKcmFactory("kdeconnect-kcm", "kdeconnect-kcm"))
......
/**
* 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;
}
/**
* 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
......@@ -27,8 +27,6 @@
#include "core/kdebugnamespace.h"
int theArea = KDebug::registerArea("kdeconnect-kded");
K_PLUGIN_FACTORY(KdeConnectFactory, registerPlugin<Kded>();)
K_EXPORT_PLUGIN(KdeConnectFactory("kdeconnect", "kdeconnect-kded"))
......@@ -37,13 +35,13 @@ Kded::Kded(QObject *parent, const QList<QVariant>&)
, m_daemon(0)
{
QMetaObject::invokeMethod(this, "start", Qt::QueuedConnection);
kDebug(theArea) << "kded_kdeconnect started";
kDebug(debugArea()) << "kded_kdeconnect started";
}
Kded::~Kded()
{
stop();
kDebug(theArea) << "kded_kdeconnect stopped";
kDebug(debugArea()) << "kded_kdeconnect stopped";
}
void Kded::start()
......@@ -53,7 +51,7 @@ void Kded::start()
}
const QString daemon = KStandardDirs::locate("exe", "kdeconnectd");
kDebug(theArea) << "Starting daemon " << daemon;
kDebug(debugArea()) << "Starting daemon " << daemon;
m_daemon = new KProcess(this);
connect(m_daemon, SIGNAL(started()), SLOT(daemonStarted()));
connect(m_daemon, SIGNAL(error(QProcess::ProcessError)), this, SLOT(onError(QProcess::ProcessError)));
......@@ -85,24 +83,24 @@ void Kded::restart()
void Kded::onError(QProcess::ProcessError errorCode)
{
kError(theArea) << "Process error code=" << errorCode;
kError(debugArea()) << "Process error code=" << errorCode;
}
void Kded::daemonStarted()
{
kDebug(theArea) << "Daemon successfuly started";
kDebug(debugArea()) << "Daemon successfuly started";
Q_EMIT started();
}
void Kded::onFinished(int exitCode, QProcess::ExitStatus status)
{
if (status == QProcess::CrashExit) {
kError(theArea) << "Process crashed with code=" << exitCode;
kError(theArea) << m_daemon->readAllStandardError();
kWarning(theArea) << "Restarting in 5 sec...";
kError(debugArea()) << "Process crashed with code=" << exitCode;
kError(debugArea()) << m_daemon->readAllStandardError();
kWarning(debugArea()) << "Restarting in 5 sec...";
QTimer::singleShot(5000, this, SLOT(start()));
} else {
kWarning(theArea) << "Process finished with code=" << exitCode;
kWarning(debugArea()) << "Process finished with code=" << exitCode;
}
Q_EMIT stopped();
......@@ -116,5 +114,5 @@ void Kded::checkIfDaemonTerminated()
}
m_daemon->kill();
kWarning(theArea) << "Daemon killed";
kWarning(debugArea()) << "Daemon killed";
}
......@@ -2,7 +2,7 @@ include_directories(${CMAKE_SOURCE_DIR})
set(kio_kdeconnect_PART_SRCS
kiokdeconnect.cpp
kdebugnamespace.cpp)
)
kde4_add_plugin(kio_kdeconnect ${kio_kdeconnect_PART_SRCS})
......
/**
* 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_kio() {
static int s_area = KDebug::registerArea("kdeconnect_kio", true);
return s_area;
}
/**
* 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