30 #include <KInputDialog>
31 #include <KMessageBox>
32 #include <KPasswordDialog>
35 #include <QX11EmbedContainer>
40 KConfigGroup configGroup,
72 if (event->
type() == QEvent::KeyPress ||
73 event->type() == QEvent::KeyRelease ||
74 event->type() == QEvent::MouseButtonDblClick ||
75 event->type() == QEvent::MouseButtonPress ||
76 event->type() == QEvent::MouseButtonRelease ||
77 event->type() == QEvent::MouseMove)
95 kDebug(5012) <<
"About to quit";
113 if (
m_url.userName().isEmpty()) {
117 userName = KInputDialog::getText(i18n(
"Enter Username"),
118 i18n(
"Please enter the username you would like to use for login."),
122 m_url.setUserName(userName);
126 if (!
m_url.userName().isEmpty()) {
128 kDebug(5012) <<
"Is LDAP login:" << useLdapLogin <<
m_url.userName();
134 if (!walletPassword.
isNull()) {
135 m_url.setPassword(walletPassword);
137 KPasswordDialog dialog(
this);
138 dialog.setPrompt(i18n(
"Access to the system requires a password."));
139 if (dialog.exec() == KPasswordDialog::Accepted) {
140 m_url.setPassword(dialog.password());
149 m_process =
new QProcess(m_container);
154 if (m_hostPreferences->
width() > 0) {
155 width = m_hostPreferences->
width();
156 height = m_hostPreferences->
height();
163 arguments <<
"-k" << keymapToXfreerdp(m_hostPreferences->
keyboardLayout());
165 if (!
m_url.userName().isEmpty()) {
167 if (
m_url.userName().contains(
'\\')) {
169 arguments <<
"-d" << splittedName.
at(0);
170 arguments <<
"-u" << splittedName.
at(1);
172 arguments <<
"-u" <<
m_url.userName();
175 arguments <<
"-u" <<
"";
178 if (!
m_url.password().isNull())
179 arguments <<
"-p" <<
m_url.password();
185 switch (m_hostPreferences->
sound()) {
190 arguments <<
"--plugin" <<
"rdpsnd";
199 shareMedia <<
"--plugin" <<
"rdpdr" <<
"--data" <<
"disk:media:" + m_hostPreferences->
shareMedia() <<
"--";
200 arguments += shareMedia;
218 arguments <<
"-x" << performance;
220 if (m_hostPreferences->
console()) {
224 if (m_hostPreferences->
remoteFX()) {
225 arguments <<
"--rfx";
230 arguments += additionalArguments;
236 arguments <<
"--ignore-certificate";
239 arguments <<
"--plugin" <<
"cliprdr";
244 kDebug(5012) <<
"Starting xfreerdp with arguments:" << arguments;
248 connect(m_process, SIGNAL(error(QProcess::ProcessError)), SLOT(processError(QProcess::ProcessError)));
249 connect(m_process, SIGNAL(readyReadStandardError()), SLOT(receivedStandardError()));
250 connect(m_process, SIGNAL(readyReadStandardOutput()), SLOT(receivedStandardOutput()));
251 connect(m_container, SIGNAL(clientClosed()), SLOT(connectionClosed()));
252 connect(m_container, SIGNAL(clientIsEmbedded()), SLOT(connectionOpened()));
254 m_process->
start(
"xfreerdp", arguments);
261 return m_hostPreferences;
271 void RdpView::connectionOpened()
273 kDebug(5012) <<
"Connection opened";
275 kDebug(5012) <<
"Size hint: " << size.
width() <<
" " << size.
height();
290 void RdpView::connectionClosed()
297 void RdpView::connectionError()
303 void RdpView::processError(QProcess::ProcessError error)
305 kDebug(5012) <<
"processError:" << error;
310 if (error == QProcess::FailedToStart) {
311 KMessageBox::error(0, i18n(
"Could not start \"xfreerdp\"; make sure xfreerdp is properly installed."),
312 i18n(
"RDP Failure"));
319 void RdpView::receivedStandardError()
322 kDebug(5012) <<
"receivedStandardError:" << output;
325 while (!(line = output.
section(
'\n', i, i)).isEmpty()) {
335 KMessageBox::error(0, i18n(
"The version of \"xfreerdp\" you are using is too old.\n"
336 "xfreerdp 1.0.2 or greater is required."),
337 i18n(
"RDP Failure"));
345 void RdpView::receivedStandardOutput()
348 kDebug(5012) <<
"receivedStandardOutput:" << output;
351 while (!(line = output.
section(
'\n', i, i)).isEmpty()) {
355 KMessageBox::error(0, i18n(
"Name or service not known."),
356 i18n(
"Connection Failure"));
362 KMessageBox::error(0, i18n(
"Connection attempt to host failed."),
363 i18n(
"Connection Failure"));
370 KMessageBox::error(0, i18n(
"Connection attempt to host failed."),
371 i18n(
"Connection Failure"));
382 Q_UNUSED(grabAllKeys);
402 keymapToXfreerdpHash[
"ar"] =
"0x00000401";
405 keymapToXfreerdpHash[
"cs"] =
"0x00000405";
406 keymapToXfreerdpHash[
"da"] =
"0x00000406";
407 keymapToXfreerdpHash[
"fo"] =
"0x00000406";
408 keymapToXfreerdpHash[
"de"] =
"0x00000407";
410 keymapToXfreerdpHash[
"en-us"] =
"0x00000409";
411 keymapToXfreerdpHash[
"es"] =
"0x0000040A";
412 keymapToXfreerdpHash[
"fi"] =
"0x0000040B";
413 keymapToXfreerdpHash[
"fr"] =
"0x0000040C";
414 keymapToXfreerdpHash[
"he"] =
"0x0000040D";
415 keymapToXfreerdpHash[
"hu"] =
"0x0000040E";
416 keymapToXfreerdpHash[
"is"] =
"0x0000040F";
417 keymapToXfreerdpHash[
"it"] =
"0x00000410";
418 keymapToXfreerdpHash[
"ja"] =
"0x00000411";
419 keymapToXfreerdpHash[
"ko"] =
"0x00000412";
420 keymapToXfreerdpHash[
"nl"] =
"0x00000413";
421 keymapToXfreerdpHash[
"no"] =
"0x00000414";
422 keymapToXfreerdpHash[
"pl"] =
"0x00000415";
423 keymapToXfreerdpHash[
"pt-br"] =
"0x00000416";
425 keymapToXfreerdpHash[
"ru"] =
"0x00000419";
426 keymapToXfreerdpHash[
"hr"] =
"0x0000041A";
429 keymapToXfreerdpHash[
"sv"] =
"0x0000041D";
430 keymapToXfreerdpHash[
"th"] =
"0x0000041E";
431 keymapToXfreerdpHash[
"tr"] =
"0x0000041F";
435 keymapToXfreerdpHash[
"sl"] =
"0x00000424";
436 keymapToXfreerdpHash[
"et"] =
"0x00000425";
437 keymapToXfreerdpHash[
"lv"] =
"0x00000426";
438 keymapToXfreerdpHash[
"lt"] =
"0x00000427";
443 keymapToXfreerdpHash[
"mk"] =
"0x0000042F";
469 keymapToXfreerdpHash[
"de-ch"] =
"0x00000807";
470 keymapToXfreerdpHash[
"en-gb"] =
"0x00000809";
472 keymapToXfreerdpHash[
"fr-be"] =
"0x0000080C";
473 keymapToXfreerdpHash[
"nl-be"] =
"0x00000813";
474 keymapToXfreerdpHash[
"pt"] =
"0x00000816";
482 keymapToXfreerdpHash[
"fr-ca"] =
"0x00001009";
483 keymapToXfreerdpHash[
"fr-ch"] =
"0x0000100C";
494 keymapToXfreerdpHash[
"en-dv"] =
"0x00010409";
555 #include "rdpview.moc"
HostPreferences * hostPreferences()
Returns the current host preferences of this view.
virtual bool start()
Initialize the view (for example by showing configuration dialogs to the user) and start connecting...
bool eventFilter(QObject *obj, QEvent *event)
QString keyboardLayout() const
const T & at(int i) const
QPixmap grabWindow(WId window, int x, int y, int width, int height)
QString readWalletPassword(bool fromUserNameOnly=false)
void connected()
Emitted when the view connected successfully.
void disconnectedError()
Emitted when the view disconnected with error.
Generic widget that displays a remote framebuffer.
void disconnected()
Emitted when the view disconnected without error.
QString number(int n, int base)
void installEventFilter(QObject *filterObj)
void framebufferSizeChanged(int w, int h)
Emitted when the size of the remote screen changes.
virtual QSize framebufferSize()
Returns the resolution of the remote framebuffer.
virtual bool isQuitting()
Checks whether the view is currently quitting.
virtual QPixmap takeScreenshot()
virtual bool eventFilter(QObject *watched, QEvent *event)
int height()
Saved height.
static QString defaultRdpUserName()
Get DefaultRdpUserName.
static bool recognizeLdapLogins()
Get RecognizeLdapLogins.
virtual void switchFullscreen(bool on)
static QHash< QString, QString > keymapToXfreerdpHash
bool contains(QChar ch, Qt::CaseSensitivity cs) const
void saveWalletPassword(const QString &password, bool fromUserNameOnly=false)
RemoteStatus m_status
The status of the remote view.
RdpView(QWidget *parent=0, const KUrl &url=KUrl(), KConfigGroup configGroup=KConfigGroup(), const QString &user=QString(), const QString &password=QString())
QString shareMedia() const
virtual void startQuitting()
Initiate the disconnection.
virtual void setStatus(RemoteStatus s)
Set the status of the connection.
void setGrabAllKeys(bool grabAllKeys)
Enables/disables grabbing all possible keys.
QString section(QChar sep, int start, int end, QFlags< QString::SectionFlag > flags) const
QString extraOptions() const
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QByteArray readAllStandardOutput()
void start(const QString &program, const QStringList &arguments, QFlags< QIODevice::OpenModeFlag > mode)
QByteArray readAllStandardError()
bool waitForFinished(int msecs)