summaryrefslogtreecommitdiff
path: root/net/krdc/files/patch-git8436cc62
blob: d568be962d4a3241df210fe9faeab728cbb56dde (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
--- rdp/rdpview.cpp
+++ rdp/rdpview.cpp
@@ -146,102 +146,205 @@ bool RdpView::start()
         }
     }
 
+    // Check the version of FreeRDP so we can use pre-1.1 switches if needed
+    QProcess *xfreeRDPVersionCheck = new QProcess(this);
+    xfreeRDPVersionCheck->start("xfreerdp", QStringList("--version"));
+    xfreeRDPVersionCheck->waitForFinished();
+    QString versionOutput = xfreeRDPVersionCheck->readAllStandardOutput();
+    xfreeRDPVersionCheck->deleteLater();
+
     m_process = new QProcess(m_container);
 
     QStringList arguments;
 
-    int width, height;
-    if (m_hostPreferences->width() > 0) {
-        width = m_hostPreferences->width();
-        height = m_hostPreferences->height();
-    } else {
-        width = this->parentWidget()->size().width();
-        height = this->parentWidget()->size().height();
-    }
-    arguments << "-g" << QString::number(width) + 'x' + QString::number(height);
-
-    arguments << "-k" << keymapToXfreerdp(m_hostPreferences->keyboardLayout());
+    if (versionOutput.contains(QLatin1String(" 1.0"))) {
+        kDebug(5012) << "Use FreeRDP 1.0 compatible arguments";
 
-    if (!m_url.userName().isEmpty()) {
-        // if username contains a domain, it needs to be set with another parameter
-        if (m_url.userName().contains('\\')) {
-            const QStringList splittedName = m_url.userName().split('\\');
-            arguments << "-d" << splittedName.at(0);
-            arguments << "-u" << splittedName.at(1);
+        int width, height;
+        if (m_hostPreferences->width() > 0) {
+            width = m_hostPreferences->width();
+            height = m_hostPreferences->height();
         } else {
-            arguments << "-u" << m_url.userName();
+            width = this->parentWidget()->size().width();
+            height = this->parentWidget()->size().height();
         }
+        arguments << "-g" << QString::number(width) + 'x' + QString::number(height);
+
+        arguments << "-k" << keymapToXfreerdp(m_hostPreferences->keyboardLayout());
+
+        if (!m_url.userName().isEmpty()) {
+            // if username contains a domain, it needs to be set with another parameter
+            if (m_url.userName().contains('\\')) {
+                const QStringList splittedName = m_url.userName().split('\\');
+                arguments << "-d" << splittedName.at(0);
+                arguments << "-u" << splittedName.at(1);
+            } else {
+                arguments << "-u" << m_url.userName();
+            }
+        } else {
+            arguments << "-u" << "";
+        }
+
+        arguments << "-D";  // request the window has no decorations
+        arguments << "-X" << QString::number(m_container->winId());
+        arguments << "-a" << QString::number((m_hostPreferences->colorDepth() + 1) * 8);
+
+        switch (m_hostPreferences->sound()) {
+        case 1:
+            arguments << "-o";
+            break;
+        case 0:
+            arguments << "--plugin" << "rdpsnd";
+            break;
+        case 2:
+        default:
+            break;
+        }
+
+        if (!m_hostPreferences->shareMedia().isEmpty()) {
+            QStringList shareMedia;
+            shareMedia << "--plugin" << "rdpdr" << "--data" << "disk:media:" + m_hostPreferences->shareMedia() << "--";
+            arguments += shareMedia;
+        }
+
+        QString performance;
+        switch (m_hostPreferences->performance()) {
+        case 0:
+            performance = 'm';
+            break;
+        case 1:
+            performance = 'b';
+            break;
+        case 2:
+            performance = 'l';
+            break;
+        default:
+            break;
+        }
+
+        arguments << "-x" << performance;
+
+        if (m_hostPreferences->console()) {
+            arguments << "-0";
+        }
+
+        if (m_hostPreferences->remoteFX()) {
+            arguments << "--rfx";
+        }
+
+        if (!m_hostPreferences->extraOptions().isEmpty()) {
+            const QStringList additionalArguments = KShell::splitArgs(m_hostPreferences->extraOptions());
+            arguments += additionalArguments;
+        }
+
+        // krdc has no support for certificate management yet; it would not be possbile to connect to any host:
+        // "The host key for example.com has changed" ...
+        // "Add correct host key in ~/.freerdp/known_hosts to get rid of this message."
+        arguments << "--ignore-certificate";
+
+        // clipboard sharing is activated in KRDC; user can disable it at runtime
+        arguments << "--plugin" << "cliprdr";
+
+        arguments << "-t" << QString::number(m_port);
+        arguments << m_host;
+
+        kDebug(5012) << "Starting xfreerdp with arguments: " << arguments.join(" ");
+
+        arguments.removeLast(); // host must be last, remove and re-add it after the password
+        if (!m_url.password().isNull())
+            arguments << "-p" << m_url.password();
+        arguments << m_host;
+
     } else {
-        arguments << "-u" << "";
-    }
+        kDebug(5012) << "Use FreeRDP 1.1+ compatible arguments";
 
-    if (!m_url.password().isNull())
-        arguments << "-p" << m_url.password();
-
-    arguments << "-D";  // request the window has no decorations
-    arguments << "-X" << QString::number(m_container->winId());
-    arguments << "-a" << QString::number((m_hostPreferences->colorDepth() + 1) * 8);
-
-    switch (m_hostPreferences->sound()) {
-    case 1:
-        arguments << "-o";
-        break;
-    case 0:
-        arguments << "--plugin" << "rdpsnd";
-        break;
-    case 2:
-    default:
-        break;
-    }
+        int width, height;
+        if (m_hostPreferences->width() > 0) {
+            width = m_hostPreferences->width();
+            height = m_hostPreferences->height();
+        } else {
+            width = this->parentWidget()->size().width();
+            height = this->parentWidget()->size().height();
+        }
+        arguments << "-decorations";
+        arguments << "/w:" + QString::number(width);
+        arguments << "/h:" + QString::number(height);
+
+        arguments << "/kbd:" + keymapToXfreerdp(m_hostPreferences->keyboardLayout());
+
+        if (!m_url.userName().isEmpty()) {
+            // if username contains a domain, it needs to be set with another parameter
+            if (m_url.userName().contains('\\')) {
+                const QStringList splittedName = m_url.userName().split('\\');
+                arguments << "/d:" + splittedName.at(0);
+                arguments << "/u:" + splittedName.at(1);
+            } else {
+                arguments << "/u:" + m_url.userName();
+            }
+        } else {
+            arguments << "/u:";
+        }
 
-    if (!m_hostPreferences->shareMedia().isEmpty()) {
-        QStringList shareMedia;
-        shareMedia << "--plugin" << "rdpdr" << "--data" << "disk:media:" + m_hostPreferences->shareMedia() << "--";
-        arguments += shareMedia;
-    }
+        arguments << "/parent-window:" + QString::number(m_container->winId());
+        arguments << "/bpp:" + QString::number((m_hostPreferences->colorDepth() + 1) * 8);
+        arguments << "/audio-mode:" + QString::number(m_hostPreferences->sound());
 
-    QString performance;
-    switch (m_hostPreferences->performance()) {
-    case 0:
-        performance = 'm';
-        break;
-    case 1:
-        performance = 'b';
-        break;
-    case 2:
-        performance = 'l';
-        break;
-    default:
-        break;
-    }
+        if (!m_hostPreferences->shareMedia().isEmpty()) {
+            QStringList shareMedia;
+            shareMedia << "/drive:media," + m_hostPreferences->shareMedia();
+            arguments += shareMedia;
+        }
 
-    arguments << "-x" << performance;
+        QString performance;
+        switch (m_hostPreferences->performance()) {
+        case 0:
+            performance = "modem";
+            break;
+        case 1:
+            performance = "broadband";
+            break;
+        case 2:
+            performance = "lan";
+            break;
+        default:
+            break;
+        }
 
-    if (m_hostPreferences->console()) {
-        arguments << "-0";
-    }
+        arguments << "/network:" + performance;
 
-    if (m_hostPreferences->remoteFX()) {
-        arguments << "--rfx";
-    }
+        if (m_hostPreferences->console()) {
+            arguments << "/admin";
+        }
 
-    if (!m_hostPreferences->extraOptions().isEmpty()) {
-        const QStringList additionalArguments = KShell::splitArgs(m_hostPreferences->extraOptions());
-        arguments += additionalArguments;
-    }
+        if (m_hostPreferences->remoteFX()) {
+            arguments << "/rfx";
+        }
+
+        if (!m_hostPreferences->extraOptions().isEmpty()) {
+            const QStringList additionalArguments = KShell::splitArgs(m_hostPreferences->extraOptions());
+            arguments += additionalArguments;
+        }
+
+        // krdc has no support for certificate management yet; it would not be possbile to connect to any host:
+        // "The host key for example.com has changed" ...
+        // "Add correct host key in ~/.freerdp/known_hosts to get rid of this message."
+        arguments << "/cert-ignore";
+
+        // clipboard sharing is activated in KRDC; user can disable it at runtime
+        arguments << "+clipboard";
 
-    // krdc has no support for certificate management yet; it would not be possbile to connect to any host:
-    // "The host key for example.com has changed" ...
-    // "Add correct host key in ~/.freerdp/known_hosts to get rid of this message."
-    arguments << "--ignore-certificate";
+        arguments << "/port:" + QString::number(m_port);
+        arguments << "/v:" + m_host;
 
-    // clipboard sharing is activated in KRDC; user can disable it at runtime
-    arguments << "--plugin" << "cliprdr";
+        kDebug(5012) << "Starting xfreerdp with arguments: " << arguments.join(" ");
 
-    arguments << "-t" << QString::number(m_port);
-    arguments << m_host;
+        //avoid printing the password in debug
+        if (!m_url.password().isNull()) {
+            arguments << "/p:" + m_url.password();
+        }
+        kDebug(5012) << "Starting xfreerdp with arguments: " << arguments.join(" ");
 
-    kDebug(5012) << "Starting xfreerdp with arguments:" << arguments;
+    }
 
     setStatus(Connecting);
 
@@ -302,7 +405,7 @@ void RdpView::connectionError()
 
 void RdpView::processError(QProcess::ProcessError error)
 {
-    kDebug(5012) << "processError:" << error;
+    kDebug(5012) << error;
     if (m_quitFlag) // do not try to show error messages while quitting (prevent crashes)
         return;
 
@@ -319,11 +422,11 @@ void RdpView::processError(QProcess::ProcessError error)
 void RdpView::receivedStandardError()
 {
     const QString output(m_process->readAllStandardError());
-    kDebug(5012) << "receivedStandardError:" << output;
+    kDebug(5012) << output;
     QString line;
     int i = 0;
     while (!(line = output.section('\n', i, i)).isEmpty()) {
-        
+
         // the following error is issued by freerdp because of a bug in freerdp 1.0.1 and below;
         // see: https://github.com/FreeRDP/FreeRDP/pull/576
         //"X Error of failed request:  BadWindow (invalid Window parameter)
@@ -345,7 +448,7 @@ void RdpView::receivedStandardError()
 void RdpView::receivedStandardOutput()
 {
     const QString output(m_process->readAllStandardOutput());
-    kDebug(5012) << "receivedStandardOutput:" << output;
+    kDebug(5012) << output;
     QString line;
     int i = 0;
     while (!(line = output.section('\n', i, i)).isEmpty()) {