Changeset View
Changeset View
Standalone View
Standalone View
plugins/sftp/mounter.cpp
Show All 33 Lines | |||||
34 | Mounter::Mounter(SftpPlugin* sftp) | 34 | Mounter::Mounter(SftpPlugin* sftp) | ||
35 | : QObject(sftp) | 35 | : QObject(sftp) | ||
36 | , m_sftp(sftp) | 36 | , m_sftp(sftp) | ||
37 | , m_proc(nullptr) | 37 | , m_proc(nullptr) | ||
38 | , m_mountPoint(sftp->mountPoint()) | 38 | , m_mountPoint(sftp->mountPoint()) | ||
39 | , m_started(false) | 39 | , m_started(false) | ||
40 | { | 40 | { | ||
41 | 41 | | |||
42 | connect(m_sftp, &SftpPlugin::packageReceived, this, &Mounter::onPakcageReceived); | 42 | connect(m_sftp, &SftpPlugin::packetReceived, this, &Mounter::onPakcageReceived); | ||
43 | 43 | | |||
44 | connect(&m_connectTimer, &QTimer::timeout, this, &Mounter::onMountTimeout); | 44 | connect(&m_connectTimer, &QTimer::timeout, this, &Mounter::onMountTimeout); | ||
45 | 45 | | |||
46 | connect(this, &Mounter::mounted, &m_connectTimer, &QTimer::stop); | 46 | connect(this, &Mounter::mounted, &m_connectTimer, &QTimer::stop); | ||
47 | connect(this, &Mounter::failed, &m_connectTimer, &QTimer::stop); | 47 | connect(this, &Mounter::failed, &m_connectTimer, &QTimer::stop); | ||
48 | 48 | | |||
49 | m_connectTimer.setInterval(10000); | 49 | m_connectTimer.setInterval(10000); | ||
50 | m_connectTimer.setSingleShot(true); | 50 | m_connectTimer.setSingleShot(true); | ||
Show All 18 Lines | 63 | { | |||
69 | qCDebug(KDECONNECT_PLUGIN_SFTP) << "Starting loop to wait for mount"; | 69 | qCDebug(KDECONNECT_PLUGIN_SFTP) << "Starting loop to wait for mount"; | ||
70 | 70 | | |||
71 | MountLoop loop; | 71 | MountLoop loop; | ||
72 | connect(this, &Mounter::mounted, &loop, &MountLoop::successed); | 72 | connect(this, &Mounter::mounted, &loop, &MountLoop::successed); | ||
73 | connect(this, &Mounter::failed, &loop, &MountLoop::failed); | 73 | connect(this, &Mounter::failed, &loop, &MountLoop::failed); | ||
74 | return loop.exec(); | 74 | return loop.exec(); | ||
75 | } | 75 | } | ||
76 | 76 | | |||
77 | void Mounter::onPakcageReceived(const NetworkPackage& np) | 77 | void Mounter::onPakcageReceived(const NetworkPacket& np) | ||
78 | { | 78 | { | ||
79 | if (np.get<bool>(QStringLiteral("stop"), false)) | 79 | if (np.get<bool>(QStringLiteral("stop"), false)) | ||
80 | { | 80 | { | ||
81 | qCDebug(KDECONNECT_PLUGIN_SFTP) << "SFTP server stopped"; | 81 | qCDebug(KDECONNECT_PLUGIN_SFTP) << "SFTP server stopped"; | ||
82 | unmount(false); | 82 | unmount(false); | ||
83 | return; | 83 | return; | ||
84 | } | 84 | } | ||
85 | 85 | | |||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Line(s) | |||||
199 | void Mounter::onMountTimeout() | 199 | void Mounter::onMountTimeout() | ||
200 | { | 200 | { | ||
201 | qCDebug(KDECONNECT_PLUGIN_SFTP) << "Timeout: device not responding"; | 201 | qCDebug(KDECONNECT_PLUGIN_SFTP) << "Timeout: device not responding"; | ||
202 | Q_EMIT failed(i18n("Failed to mount filesystem: device not responding")); | 202 | Q_EMIT failed(i18n("Failed to mount filesystem: device not responding")); | ||
203 | } | 203 | } | ||
204 | 204 | | |||
205 | void Mounter::start() | 205 | void Mounter::start() | ||
206 | { | 206 | { | ||
207 | NetworkPackage np(PACKAGE_TYPE_SFTP_REQUEST, {{"startBrowsing", true}}); | 207 | NetworkPacket np(PACKET_TYPE_SFTP_REQUEST, {{"startBrowsing", true}}); | ||
208 | m_sftp->sendPackage(np); | 208 | m_sftp->sendPacket(np); | ||
209 | 209 | | |||
210 | m_connectTimer.start(); | 210 | m_connectTimer.start(); | ||
211 | } | 211 | } | ||
212 | 212 | | |||
213 | void Mounter::unmount(bool finished) | 213 | void Mounter::unmount(bool finished) | ||
214 | { | 214 | { | ||
215 | qCDebug(KDECONNECT_PLUGIN_SFTP) << "Unmount" << m_proc; | 215 | qCDebug(KDECONNECT_PLUGIN_SFTP) << "Unmount" << m_proc; | ||
216 | if (m_proc) | 216 | if (m_proc) | ||
Show All 31 Lines |