File indexing completed on 2024-09-29 04:26:14

0001 /**
0002  * SPDX-FileCopyrightText: 2014 Samoilenko Yuri <kinnalru@gmail.com>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #pragma once
0008 
0009 #include <KJob>
0010 #include <KProcess>
0011 
0012 #include <QTimer>
0013 
0014 #include "sftpplugin.h"
0015 
0016 class Mounter : public QObject
0017 {
0018     Q_OBJECT
0019 public:
0020     explicit Mounter(SftpPlugin *sftp);
0021     ~Mounter() override;
0022 
0023     bool wait();
0024     bool isMounted() const
0025     {
0026         return m_started;
0027     }
0028     void onPacketReceived(const NetworkPacket &np);
0029 
0030 Q_SIGNALS:
0031     void mounted();
0032     void unmounted();
0033     void failed(const QString &message);
0034 
0035 private Q_SLOTS:
0036     void onStarted();
0037     void onError(QProcess::ProcessError error);
0038     void onFinished(int exitCode, QProcess::ExitStatus exitStatus);
0039     void onMountTimeout();
0040     void start();
0041 
0042 private:
0043     void unmount(bool finished);
0044 
0045 private:
0046     SftpPlugin *m_sftp;
0047     KProcess *m_proc;
0048     QTimer m_connectTimer;
0049     QString m_mountPoint;
0050     bool m_started;
0051 };