From af4418769507e6d398a9764adb50bfa68c9e1084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=80lex=20Fiestas?= Date: Mon, 22 Sep 2014 00:46:19 +0200 Subject: [PATCH] Port share plugin away from kDebug --- plugins/share/share_debug.h | 28 ++++++++++++++++++++++++++++ plugins/share/shareplugin.cpp | 17 ++++++++++------- 2 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 plugins/share/share_debug.h diff --git a/plugins/share/share_debug.h b/plugins/share/share_debug.h new file mode 100644 index 000000000..d6cf4161e --- /dev/null +++ b/plugins/share/share_debug.h @@ -0,0 +1,28 @@ +/** + * Copyright 2014 Alejandro Fiestas Olivares + * + * 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 SHARE_DEBUG_H +#define SHARE_DEBUG_H + +#include + +Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_PLUGIN_SHARE) + +#endif //SHARE_DEBUG_H \ No newline at end of file diff --git a/plugins/share/shareplugin.cpp b/plugins/share/shareplugin.cpp index 09e2bb0bc..47497f763 100644 --- a/plugins/share/shareplugin.cpp +++ b/plugins/share/shareplugin.cpp @@ -19,6 +19,7 @@ */ #include "shareplugin.h" +#include "share_debug.h" #include #include @@ -32,14 +33,16 @@ #include #include #include +#include -#include #include #include "autoclosingqfile.h" K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< SharePlugin >(); ) K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_share", "kdeconnect-plugins") ) +Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_SHARE, "kdeconnect.plugin.share"); + SharePlugin::SharePlugin(QObject* parent, const QVariantList& args) : KdeConnectPlugin(parent, args) { @@ -61,7 +64,7 @@ QUrl SharePlugin::destinationDir() const url = url.arg(device()->name()); } - kDebug(debugArea()) << url; + qCDebug(KDECONNECT_PLUGIN_SHARE) << url; QDir().mkpath(url); return url; @@ -73,7 +76,7 @@ bool SharePlugin::receivePackage(const NetworkPackage& np) //TODO: Use this code to write a test if (np.type() == PACKAGE_TYPE_PING) { - kDebug(debugArea()) << "sending file" << (QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/.bashrc"); + qCDebug(KDECONNECT_PLUGIN_SHARE) << "sending file" << (QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/.bashrc"); NetworkPackage out(PACKAGE_TYPE_SHARE); out.set("filename", mDestinationDir + "itworks.txt"); @@ -89,10 +92,10 @@ bool SharePlugin::receivePackage(const NetworkPackage& np) } */ - kDebug(debugArea()) << "File transfer"; + qCDebug(KDECONNECT_PLUGIN_SHARE) << "File transfer"; if (np.hasPayload()) { - //kDebug(debugArea()) << "receiving file"; + //qCDebug(KDECONNECT_PLUGIN_SHARE) << "receiving file"; QString filename = np.get("filename", QString::number(QDateTime::currentMSecsSinceEpoch())); QUrl destination = destinationDir(); destination = destination.adjusted(QUrl::StripTrailingSlash); @@ -122,7 +125,7 @@ bool SharePlugin::receivePackage(const NetworkPackage& np) QUrl url(np.get("url")); QDesktopServices::openUrl(url); } else { - kDebug(debugArea()) << "Error: Nothing attached!"; + qCDebug(KDECONNECT_PLUGIN_SHARE) << "Error: Nothing attached!"; } return true; @@ -131,7 +134,7 @@ bool SharePlugin::receivePackage(const NetworkPackage& np) void SharePlugin::finished(KJob* job) { - kDebug(debugArea()) << "File transfer finished"; + qCDebug(KDECONNECT_PLUGIN_SHARE) << "File transfer finished"; bool error = (job->error() != 0);