3 @@ -146,102 +146,205 @@ bool RdpView::start()
7 + // Check the version of FreeRDP so we can use pre-1.1 switches if needed
8 + QProcess *xfreeRDPVersionCheck = new QProcess(this);
9 + xfreeRDPVersionCheck->start("xfreerdp", QStringList("--version"));
10 + xfreeRDPVersionCheck->waitForFinished();
11 + QString versionOutput = xfreeRDPVersionCheck->readAllStandardOutput();
12 + xfreeRDPVersionCheck->deleteLater();
14 m_process = new QProcess(m_container);
16 QStringList arguments;
19 - if (m_hostPreferences->width() > 0) {
20 - width = m_hostPreferences->width();
21 - height = m_hostPreferences->height();
23 - width = this->parentWidget()->size().width();
24 - height = this->parentWidget()->size().height();
26 - arguments << "-g" << QString::number(width) + 'x' + QString::number(height);
28 - arguments << "-k" << keymapToXfreerdp(m_hostPreferences->keyboardLayout());
29 + if (versionOutput.contains(QLatin1String(" 1.0"))) {
30 + kDebug(5012) << "Use FreeRDP 1.0 compatible arguments";
32 - if (!m_url.userName().isEmpty()) {
33 - // if username contains a domain, it needs to be set with another parameter
34 - if (m_url.userName().contains('\\')) {
35 - const QStringList splittedName = m_url.userName().split('\\');
36 - arguments << "-d" << splittedName.at(0);
37 - arguments << "-u" << splittedName.at(1);
39 + if (m_hostPreferences->width() > 0) {
40 + width = m_hostPreferences->width();
41 + height = m_hostPreferences->height();
43 - arguments << "-u" << m_url.userName();
44 + width = this->parentWidget()->size().width();
45 + height = this->parentWidget()->size().height();
47 + arguments << "-g" << QString::number(width) + 'x' + QString::number(height);
49 + arguments << "-k" << keymapToXfreerdp(m_hostPreferences->keyboardLayout());
51 + if (!m_url.userName().isEmpty()) {
52 + // if username contains a domain, it needs to be set with another parameter
53 + if (m_url.userName().contains('\\')) {
54 + const QStringList splittedName = m_url.userName().split('\\');
55 + arguments << "-d" << splittedName.at(0);
56 + arguments << "-u" << splittedName.at(1);
58 + arguments << "-u" << m_url.userName();
61 + arguments << "-u" << "";
64 + arguments << "-D"; // request the window has no decorations
65 + arguments << "-X" << QString::number(m_container->winId());
66 + arguments << "-a" << QString::number((m_hostPreferences->colorDepth() + 1) * 8);
68 + switch (m_hostPreferences->sound()) {
73 + arguments << "--plugin" << "rdpsnd";
80 + if (!m_hostPreferences->shareMedia().isEmpty()) {
81 + QStringList shareMedia;
82 + shareMedia << "--plugin" << "rdpdr" << "--data" << "disk:media:" + m_hostPreferences->shareMedia() << "--";
83 + arguments += shareMedia;
86 + QString performance;
87 + switch (m_hostPreferences->performance()) {
101 + arguments << "-x" << performance;
103 + if (m_hostPreferences->console()) {
107 + if (m_hostPreferences->remoteFX()) {
108 + arguments << "--rfx";
111 + if (!m_hostPreferences->extraOptions().isEmpty()) {
112 + const QStringList additionalArguments = KShell::splitArgs(m_hostPreferences->extraOptions());
113 + arguments += additionalArguments;
116 + // krdc has no support for certificate management yet; it would not be possbile to connect to any host:
117 + // "The host key for example.com has changed" ...
118 + // "Add correct host key in ~/.freerdp/known_hosts to get rid of this message."
119 + arguments << "--ignore-certificate";
121 + // clipboard sharing is activated in KRDC; user can disable it at runtime
122 + arguments << "--plugin" << "cliprdr";
124 + arguments << "-t" << QString::number(m_port);
125 + arguments << m_host;
127 + kDebug(5012) << "Starting xfreerdp with arguments: " << arguments.join(" ");
129 + arguments.removeLast(); // host must be last, remove and re-add it after the password
130 + if (!m_url.password().isNull())
131 + arguments << "-p" << m_url.password();
132 + arguments << m_host;
135 - arguments << "-u" << "";
137 + kDebug(5012) << "Use FreeRDP 1.1+ compatible arguments";
139 - if (!m_url.password().isNull())
140 - arguments << "-p" << m_url.password();
142 - arguments << "-D"; // request the window has no decorations
143 - arguments << "-X" << QString::number(m_container->winId());
144 - arguments << "-a" << QString::number((m_hostPreferences->colorDepth() + 1) * 8);
146 - switch (m_hostPreferences->sound()) {
151 - arguments << "--plugin" << "rdpsnd";
158 + if (m_hostPreferences->width() > 0) {
159 + width = m_hostPreferences->width();
160 + height = m_hostPreferences->height();
162 + width = this->parentWidget()->size().width();
163 + height = this->parentWidget()->size().height();
165 + arguments << "-decorations";
166 + arguments << "/w:" + QString::number(width);
167 + arguments << "/h:" + QString::number(height);
169 + arguments << "/kbd:" + keymapToXfreerdp(m_hostPreferences->keyboardLayout());
171 + if (!m_url.userName().isEmpty()) {
172 + // if username contains a domain, it needs to be set with another parameter
173 + if (m_url.userName().contains('\\')) {
174 + const QStringList splittedName = m_url.userName().split('\\');
175 + arguments << "/d:" + splittedName.at(0);
176 + arguments << "/u:" + splittedName.at(1);
178 + arguments << "/u:" + m_url.userName();
181 + arguments << "/u:";
184 - if (!m_hostPreferences->shareMedia().isEmpty()) {
185 - QStringList shareMedia;
186 - shareMedia << "--plugin" << "rdpdr" << "--data" << "disk:media:" + m_hostPreferences->shareMedia() << "--";
187 - arguments += shareMedia;
189 + arguments << "/parent-window:" + QString::number(m_container->winId());
190 + arguments << "/bpp:" + QString::number((m_hostPreferences->colorDepth() + 1) * 8);
191 + arguments << "/audio-mode:" + QString::number(m_hostPreferences->sound());
193 - QString performance;
194 - switch (m_hostPreferences->performance()) {
207 + if (!m_hostPreferences->shareMedia().isEmpty()) {
208 + QStringList shareMedia;
209 + shareMedia << "/drive:media," + m_hostPreferences->shareMedia();
210 + arguments += shareMedia;
213 - arguments << "-x" << performance;
214 + QString performance;
215 + switch (m_hostPreferences->performance()) {
217 + performance = "modem";
220 + performance = "broadband";
223 + performance = "lan";
229 - if (m_hostPreferences->console()) {
232 + arguments << "/network:" + performance;
234 - if (m_hostPreferences->remoteFX()) {
235 - arguments << "--rfx";
237 + if (m_hostPreferences->console()) {
238 + arguments << "/admin";
241 - if (!m_hostPreferences->extraOptions().isEmpty()) {
242 - const QStringList additionalArguments = KShell::splitArgs(m_hostPreferences->extraOptions());
243 - arguments += additionalArguments;
245 + if (m_hostPreferences->remoteFX()) {
246 + arguments << "/rfx";
249 + if (!m_hostPreferences->extraOptions().isEmpty()) {
250 + const QStringList additionalArguments = KShell::splitArgs(m_hostPreferences->extraOptions());
251 + arguments += additionalArguments;
254 + // krdc has no support for certificate management yet; it would not be possbile to connect to any host:
255 + // "The host key for example.com has changed" ...
256 + // "Add correct host key in ~/.freerdp/known_hosts to get rid of this message."
257 + arguments << "/cert-ignore";
259 + // clipboard sharing is activated in KRDC; user can disable it at runtime
260 + arguments << "+clipboard";
262 - // krdc has no support for certificate management yet; it would not be possbile to connect to any host:
263 - // "The host key for example.com has changed" ...
264 - // "Add correct host key in ~/.freerdp/known_hosts to get rid of this message."
265 - arguments << "--ignore-certificate";
266 + arguments << "/port:" + QString::number(m_port);
267 + arguments << "/v:" + m_host;
269 - // clipboard sharing is activated in KRDC; user can disable it at runtime
270 - arguments << "--plugin" << "cliprdr";
271 + kDebug(5012) << "Starting xfreerdp with arguments: " << arguments.join(" ");
273 - arguments << "-t" << QString::number(m_port);
274 - arguments << m_host;
275 + //avoid printing the password in debug
276 + if (!m_url.password().isNull()) {
277 + arguments << "/p:" + m_url.password();
279 + kDebug(5012) << "Starting xfreerdp with arguments: " << arguments.join(" ");
281 - kDebug(5012) << "Starting xfreerdp with arguments:" << arguments;
284 setStatus(Connecting);
286 @@ -302,7 +405,7 @@ void RdpView::connectionError()
288 void RdpView::processError(QProcess::ProcessError error)
290 - kDebug(5012) << "processError:" << error;
291 + kDebug(5012) << error;
292 if (m_quitFlag) // do not try to show error messages while quitting (prevent crashes)
295 @@ -319,11 +422,11 @@ void RdpView::processError(QProcess::ProcessError error)
296 void RdpView::receivedStandardError()
298 const QString output(m_process->readAllStandardError());
299 - kDebug(5012) << "receivedStandardError:" << output;
300 + kDebug(5012) << output;
303 while (!(line = output.section('\n', i, i)).isEmpty()) {
306 // the following error is issued by freerdp because of a bug in freerdp 1.0.1 and below;
307 // see: https://github.com/FreeRDP/FreeRDP/pull/576
308 //"X Error of failed request: BadWindow (invalid Window parameter)
309 @@ -345,7 +448,7 @@ void RdpView::receivedStandardError()
310 void RdpView::receivedStandardOutput()
312 const QString output(m_process->readAllStandardOutput());
313 - kDebug(5012) << "receivedStandardOutput:" << output;
314 + kDebug(5012) << output;
317 while (!(line = output.section('\n', i, i)).isEmpty()) {