Port share plugin away from kDebug
This commit is contained in:
parent
008f082ac0
commit
af44187695
2 changed files with 38 additions and 7 deletions
28
plugins/share/share_debug.h
Normal file
28
plugins/share/share_debug.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* Copyright 2014 Alejandro Fiestas Olivares <afiestas@kde.org>
|
||||
*
|
||||
* 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 SHARE_DEBUG_H
|
||||
#define SHARE_DEBUG_H
|
||||
|
||||
#include <QLoggingCategory>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_PLUGIN_SHARE)
|
||||
|
||||
#endif //SHARE_DEBUG_H
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include "shareplugin.h"
|
||||
#include "share_debug.h"
|
||||
|
||||
#include <KGlobalSettings>
|
||||
#include <QIcon>
|
||||
|
@ -32,14 +33,16 @@
|
|||
#include <QDir>
|
||||
#include <QDesktopServices>
|
||||
#include <QDBusConnection>
|
||||
#include <QDebug>
|
||||
|
||||
#include <core/kdebugnamespace.h>
|
||||
#include <core/filetransferjob.h>
|
||||
#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<QString>("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<QString>("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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue