File 0001-RDP-Warn-if-trying-to-share-a-non-existing-folder.patch of Package krdc
From e5b42510a39c876c5c33feee20d9d40012fd4eb8 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <aacid@kde.org>
Date: Sun, 1 Dec 2019 00:35:43 +0100
Subject: [PATCH] RDP: Warn if trying to share a non existing folder
Summary: More xfreerdp just bails out if you try to share a non existing folder and you get a :o face without knowing what went wrong
Subscribers: pino, luc4, uwolfer, volkov, #kde_applications
Differential Revision: https://phabricator.kde.org/D25640
---
rdp/rdpview.cpp | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/rdp/rdpview.cpp b/rdp/rdpview.cpp
index ab4e83e..44b6096 100644
--- a/rdp/rdpview.cpp
+++ b/rdp/rdpview.cpp
@@ -33,6 +33,7 @@
#include <KShell>
#include <QWindow>
+#include <QDir>
#include <QEvent>
#include <QInputDialog>
@@ -112,6 +113,14 @@ bool RdpView::start()
{
m_containerWidget->show();
+ const QString shareMediaPath = m_hostPreferences->shareMedia();
+ if (!shareMediaPath.isEmpty()) {
+ if (!QDir(shareMediaPath).exists()) {
+ QMessageBox::critical(this, i18n("Media Folder does not Exist"), i18n("The folder %1 does not exist.\nPlease set an existing folder to share or empty the \"Share Media\" option if you do not want to share any folder.", shareMediaPath));
+ return false;
+ }
+ }
+
if (m_url.userName().isEmpty()) {
QString userName;
bool ok = false;
@@ -206,11 +215,11 @@ bool RdpView::start()
break;
}
- if (!m_hostPreferences->shareMedia().isEmpty()) {
+ if (!shareMediaPath.isEmpty()) {
QStringList shareMedia;
shareMedia << QStringLiteral("--plugin") << QStringLiteral("rdpdr")
<< QStringLiteral("--data") << QStringLiteral("disk:media:")
- + m_hostPreferences->shareMedia() << QStringLiteral("--");
+ + shareMediaPath << QStringLiteral("--");
arguments += shareMedia;
}
@@ -299,9 +308,9 @@ bool RdpView::start()
break;
}
- if (!m_hostPreferences->shareMedia().isEmpty()) {
+ if (!shareMediaPath.isEmpty()) {
QStringList shareMedia;
- shareMedia << QStringLiteral("/drive:media,") + m_hostPreferences->shareMedia();
+ shareMedia << QStringLiteral("/drive:media,") + shareMediaPath;
arguments += shareMedia;
}