[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:27:18 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=0f18b9c
The following commit has been merged in the master branch:
commit 0f18b9c79c2a868cc91e2f6478b692b1dd639574
Author: Samoilenko Yuri <kinnalru at gmail.com>
Date: Tue Jan 21 23:49:50 2014 +0400
blocking mount
---
kded/plugins/sftp/CMakeLists.txt | 2 +
.../{kdeconnectplugin.cpp => sftp/mountloop.cpp} | 27 ++++--
.../{ping/pingplugin.h => sftp/mountloop.h} | 28 +++---
kded/plugins/sftp/sftpplugin.cpp | 101 +++++++++------------
kded/plugins/sftp/sftpplugin.h | 21 +----
5 files changed, 79 insertions(+), 100 deletions(-)
diff --git a/kded/plugins/sftp/CMakeLists.txt b/kded/plugins/sftp/CMakeLists.txt
index 4c1ac46..9adfd55 100644
--- a/kded/plugins/sftp/CMakeLists.txt
+++ b/kded/plugins/sftp/CMakeLists.txt
@@ -13,6 +13,7 @@ include_directories(
set(kdeconnect_sftp_SRCS
sftpplugin.cpp
+ mountloop.cpp
../kdeconnectplugin.cpp
../pluginloader.cpp
../../networkpackage.cpp
@@ -41,6 +42,7 @@ include(../../../macros.cmake)
generate_and_install_dbus_interface(
kdeconnect_sftp
sftpplugin.h
+ mountloop.h
org.kde.kdeconnect.device.sftp.xml
OPTIONS -a
)
diff --git a/kded/plugins/kdeconnectplugin.cpp b/kded/plugins/sftp/mountloop.cpp
similarity index 69%
copy from kded/plugins/kdeconnectplugin.cpp
copy to kded/plugins/sftp/mountloop.cpp
index 4971c49..0f981b3 100644
--- a/kded/plugins/kdeconnectplugin.cpp
+++ b/kded/plugins/sftp/mountloop.cpp
@@ -18,22 +18,31 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "kdeconnectplugin.h"
+#include "mountloop.h"
-#include "../device.h"
+MountLoop::MountLoop()
+ : QEventLoop()
+{}
-KdeConnectPlugin::KdeConnectPlugin(QObject* parent, const QVariantList& args)
- : QObject(parent)
+bool MountLoop::exec(QEventLoop::ProcessEventsFlags flags)
{
- mDevice = qvariant_cast< Device* >(args.first());
+ return QEventLoop::exec(flags) == 0;
}
-Device* KdeConnectPlugin::device()
+void MountLoop::failed()
{
- return mDevice;
+ Q_EMIT(result(false));
+ exit(1);
}
-Device const* KdeConnectPlugin::device() const
+void MountLoop::successed()
{
- return mDevice;
+ Q_EMIT(result(true));
+ exit(0);
+}
+
+void MountLoop::exitWith(bool status)
+{
+ Q_EMIT(result(status));
+ exit(status ? 0 : 1);
}
diff --git a/kded/plugins/ping/pingplugin.h b/kded/plugins/sftp/mountloop.h
similarity index 73%
copy from kded/plugins/ping/pingplugin.h
copy to kded/plugins/sftp/mountloop.h
index 334a353..bcbf7db 100644
--- a/kded/plugins/ping/pingplugin.h
+++ b/kded/plugins/sftp/mountloop.h
@@ -18,26 +18,28 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef PINGPLUGIN_H
-#define PINGPLUGIN_H
+#ifndef SFTPPLUGIN_MOUNTLOOP_H
+#define SFTPPLUGIN_MOUNTLOOP_H
-#include <QObject>
+#include <QEventLoop>
-#include "../kdeconnectplugin.h"
-
-class KDE_EXPORT PingPlugin
- : public KdeConnectPlugin
+class MountLoop : public QEventLoop
{
Q_OBJECT
-
public:
- explicit PingPlugin(QObject *parent, const QVariantList &args);
- virtual ~PingPlugin();
+ MountLoop();
+
+ bool exec(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents);
+
+Q_SIGNALS:
+ void result(bool status);
public Q_SLOTS:
- virtual bool receivePackage(const NetworkPackage& np);
- virtual void connected() { };
-
+ void failed();
+ void successed();
+ void exitWith(bool status);
};
+
+
#endif
diff --git a/kded/plugins/sftp/sftpplugin.cpp b/kded/plugins/sftp/sftpplugin.cpp
index 036b3e3..80f956d 100644
--- a/kded/plugins/sftp/sftpplugin.cpp
+++ b/kded/plugins/sftp/sftpplugin.cpp
@@ -37,55 +37,41 @@
#include <kfileplacesmodel.h>
#include "sftp_config.h"
+#include "mountloop.h"
#include "../../kdebugnamespace.h"
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< SftpPlugin >(); )
K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_sftp", "kdeconnect_sftp") )
-static const char* timestamp_c = "timestamp";
+static const char* lastaccess_c = "lastaccess";
static const QSet<QString> fields_c = QSet<QString>() << "ip" << "port" << "user" << "port" << "path";
inline bool isTimeout(QObject* o, const KConfigGroup& cfg)
{
if (!o) return false;
- int duration = o->property(timestamp_c).toDateTime().secsTo(QDateTime::currentDateTime());
+ int duration = o->property(lastaccess_c).toDateTime().secsTo(QDateTime::currentDateTime());
return cfg.readEntry("idle", true) && duration > (cfg.readEntry("idletimeout", 60) * 60);
}
-MountLoop::MountLoop()
- : QEventLoop()
-{
-}
-
-bool MountLoop::exec(QEventLoop::ProcessEventsFlags flags)
-{
- return QEventLoop::exec(flags) == 0;
-}
-
-void MountLoop::failed()
-{
- Q_EMIT(result(false));
- exit(1);
-}
-
-void MountLoop::successed()
-{
- Q_EMIT(result(true));
- exit(0);
-}
-
-void MountLoop::exitWith(bool status)
-{
- Q_EMIT(result(status));
- exit(status ? 0 : 1);
-}
struct SftpPlugin::Pimpl
{
+ Pimpl()
+ {
+ connectTimer.setInterval(10 * 1000);
+ connectTimer.setSingleShot(true);
+
+ //Add KIO entry to Dolphin's Places
+ placesModel = new KFilePlacesModel();
+ }
+
QPointer<KProcess> mountProc;
- KFilePlacesModel* m_placesModel;
- int idleTimer;
+ KFilePlacesModel* placesModel;
+
+ QTimer connectTimer;
+ int idleTimerId;
+
MountLoop loop;
};
@@ -95,13 +81,16 @@ SftpPlugin::SftpPlugin(QObject *parent, const QVariantList &args)
{
kDebug(kdeconnect_kded()) << "creating [" << device()->name() << "]...";
- m_d->idleTimer = startTimer(20 * 1000);
-
+
+ m_d->idleTimerId = startTimer(20 * 1000);
+
+ connect(&m_d->connectTimer, SIGNAL(timeout()), this, SLOT(mountTimeout()));
+ connect(&m_d->connectTimer, SIGNAL(timeout()), &m_d->loop, SLOT(failed()));
+
connect(this, SIGNAL(mount_succesed()), &m_d->loop, SLOT(successed()));
connect(this, SIGNAL(mount_failed()), &m_d->loop, SLOT(failed()));
- //Add KIO entry to Dolphin's Places
- m_d->m_placesModel = new KFilePlacesModel();
+
addToDolphin();
kDebug(kdeconnect_kded()) << "created [" << device()->name() << "]";
}
@@ -120,17 +109,17 @@ void SftpPlugin::addToDolphin()
{
removeFromDolphin();
KUrl kioUrl("kdeconnect://"+device()->id()+"/");
- m_d->m_placesModel->addPlace(device()->name(), kioUrl, "smartphone");
+ m_d->placesModel->addPlace(device()->name(), kioUrl, "smartphone");
kDebug(kdeconnect_kded()) << "add to dolphin";
}
void SftpPlugin::removeFromDolphin()
{
KUrl kioUrl("kdeconnect://"+device()->id()+"/");
- QModelIndex index = m_d->m_placesModel->closestItem(kioUrl);
+ QModelIndex index = m_d->placesModel->closestItem(kioUrl);
while (index.row() != -1) {
- m_d->m_placesModel->removePlace(index);
- index = m_d->m_placesModel->closestItem(kioUrl);
+ m_d->placesModel->removePlace(index);
+ index = m_d->placesModel->closestItem(kioUrl);
}
}
@@ -148,6 +137,8 @@ void SftpPlugin::mount()
return;
}
+ m_d->connectTimer.start();
+
NetworkPackage np(PACKAGE_TYPE_SFTP);
np.set("startBrowsing", true);
device()->sendPackage(np);
@@ -164,20 +155,18 @@ bool SftpPlugin::mountAndWait()
if (m_d->loop.isRunning())
{
+ kDebug(kdeconnect_kded()) << "start secondary loop";
MountLoop loop;
connect(&m_d->loop, SIGNAL(result(bool)), &loop, SLOT(exitWith(bool)));
return loop.exec();
}
- kDebug(kdeconnect_kded()) << "call mounting" << device()->name();
-
mount();
QTimer mt;
connect(&mt, SIGNAL(timeout()), &m_d->loop, SLOT(failed()));
- connect(&mt, SIGNAL(timeout()), this, SLOT(mountTimeout()));
- kDebug(kdeconnect_kded()) << "stargting timer";
mt.start(15000);
+ kDebug(kdeconnect_kded()) << "start primary loop";
return m_d->loop.exec();
}
@@ -217,8 +206,10 @@ bool SftpPlugin::receivePackage(const NetworkPackage& np)
return true;
}
+ m_d->connectTimer.stop();
+
m_d->mountProc = new KProcess(this);
- m_d->mountProc->setOutputChannelMode(KProcess::SeparateChannels);
+ m_d->mountProc->setOutputChannelMode(KProcess::MergedChannels);
connect(m_d->mountProc, SIGNAL(started()), SLOT(onStarted()));
connect(m_d->mountProc, SIGNAL(error(QProcess::ProcessError)), SLOT(onError(QProcess::ProcessError)));
@@ -257,7 +248,7 @@ QString SftpPlugin::mountPoint()
void SftpPlugin::timerEvent(QTimerEvent* event)
{
- if (event->timerId() == m_d->idleTimer)
+ if (event->timerId() == m_d->idleTimerId)
{
if (isTimeout(m_d->mountProc, SftpConfig::config()->group("main")))
{
@@ -270,9 +261,9 @@ void SftpPlugin::timerEvent(QTimerEvent* event)
void SftpPlugin::onStarted()
{
- kDebug(kdeconnect_kded()) << qobject_cast<KProcess*>(sender())->program();
+ kDebug(kdeconnect_kded()) << qobject_cast<KProcess*>(sender())->program().join(" ");
- m_d->mountProc->setProperty(timestamp_c, QDateTime::currentDateTime());
+ m_d->mountProc->setProperty(lastaccess_c, QDateTime::currentDateTime());
knotify(KNotification::Notification
, i18n("Filesystem mounted at %1").arg(mountPoint())
@@ -282,8 +273,8 @@ void SftpPlugin::onStarted()
//Used to notify MountLoop about success.
Q_EMIT mount_succesed();
- connect(m_d->mountProc, SIGNAL(readyReadStandardError()), this, SLOT(readProcessStderr()));
- connect(m_d->mountProc, SIGNAL(readyReadStandardOutput()), this, SLOT(readProcessStdout()));
+ connect(m_d->mountProc, SIGNAL(readyReadStandardError()), this, SLOT(readProcessOut()));
+ connect(m_d->mountProc, SIGNAL(readyReadStandardOutput()), this, SLOT(readProcessOut()));
}
void SftpPlugin::onError(QProcess::ProcessError error)
@@ -360,16 +351,10 @@ void SftpPlugin::mountTimeout()
);
}
-void SftpPlugin::readProcessStderr()
-{
- m_d->mountProc->setProperty(timestamp_c, QDateTime::currentDateTime());
- m_d->mountProc->readAllStandardError();
-}
-
-void SftpPlugin::readProcessStdout()
+void SftpPlugin::readProcessOut()
{
- m_d->mountProc->setProperty(timestamp_c, QDateTime::currentDateTime());
- m_d->mountProc->readAllStandardOutput();
+ m_d->mountProc->setProperty(lastaccess_c, QDateTime::currentDateTime());
+ m_d->mountProc->readAll();
}
bool SftpPlugin::waitForMount()
diff --git a/kded/plugins/sftp/sftpplugin.h b/kded/plugins/sftp/sftpplugin.h
index ddf4e89..b3edfed 100644
--- a/kded/plugins/sftp/sftpplugin.h
+++ b/kded/plugins/sftp/sftpplugin.h
@@ -30,24 +30,6 @@
class KNotification;
-//TODO move to private
-class MountLoop : public QEventLoop
-{
- Q_OBJECT
-public:
- MountLoop();
-
- bool exec(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents);
-
-Q_SIGNALS:
- void result(bool status);
-
-public Q_SLOTS:
- void failed();
- void successed();
- void exitWith(bool status);
-};
-
class SftpPlugin
: public KdeConnectPlugin
{
@@ -92,8 +74,7 @@ private Q_SLOTS:
void onFinished(int exitCode, QProcess::ExitStatus exitStatus);
void mountTimeout();
- void readProcessStderr();
- void readProcessStdout();
+ void readProcessOut();
bool waitForMount();
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list