diff options
Diffstat (limited to 'krdc/rdp')
-rw-r--r-- | krdc/rdp/Makefile.am | 11 | ||||
-rw-r--r-- | krdc/rdp/README.patch | 12 | ||||
-rw-r--r-- | krdc/rdp/krdpview.cpp | 369 | ||||
-rw-r--r-- | krdc/rdp/krdpview.h | 113 | ||||
-rw-r--r-- | krdc/rdp/rdesktop.patch | 76 | ||||
-rw-r--r-- | krdc/rdp/rdphostpref.cpp | 180 | ||||
-rw-r--r-- | krdc/rdp/rdphostpref.h | 127 | ||||
-rw-r--r-- | krdc/rdp/rdpprefs.ui | 509 | ||||
-rw-r--r-- | krdc/rdp/rdpprefs.ui.h | 163 |
9 files changed, 1560 insertions, 0 deletions
diff --git a/krdc/rdp/Makefile.am b/krdc/rdp/Makefile.am new file mode 100644 index 00000000..51f35e89 --- /dev/null +++ b/krdc/rdp/Makefile.am @@ -0,0 +1,11 @@ +INCLUDES=-I$(top_srcdir)/krdc $(all_includes) + +METASOURCES = AUTO + +noinst_LTLIBRARIES = librdp.la + +librdp_la_SOURCES = krdpview.cpp rdphostpref.cpp rdpprefs.ui + +noinst_HEADERS = krdpview.h rdphostpref.h +librdp_la_LIBADD = $(LIB_KDEUI) $(LIBJPEG) +librdp_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) diff --git a/krdc/rdp/README.patch b/krdc/rdp/README.patch new file mode 100644 index 00000000..a3e705d8 --- /dev/null +++ b/krdc/rdp/README.patch @@ -0,0 +1,12 @@ +Read this for how to use the rdesktop patch: + +This patch is intended for rdesktop 1.3.1 only. It has not been tested +with other versions, and future versions should (hopefully) include it +by default. + +- Get a copy of the rdesktop 1.3.1 sources and unpack it. +- Place the rdesktop.patch file in the top directory of the unpacked + sources. +- Go to the directory where you placed the patch and type the following + command: patch -p 0 -i rdesktop.patch +- You can now compile the sources as usual. diff --git a/krdc/rdp/krdpview.cpp b/krdc/rdp/krdpview.cpp new file mode 100644 index 00000000..dc388e29 --- /dev/null +++ b/krdc/rdp/krdpview.cpp @@ -0,0 +1,369 @@ +/* + krdpview.h, implementation of the KRdpView class + Copyright (C) 2002 Arend van Beelen jr. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + For any questions, comments or whatever, you may mail me at: [email protected] +*/ + +#include <kdialogbase.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kprocess.h> +#include <kwallet.h> +#include <kpassdlg.h> + +#include <qvbox.h> +#include <qxembed.h> + +#include <X11/Xlib.h> +#include <X11/keysym.h> + +#undef Bool + +#include "krdpview.h" +#include "rdphostpref.h" +#include "rdpprefs.h" + +bool rdpAppDataConfigured = false; +extern KWallet::Wallet *wallet; + +static KRdpView *krdpview; + +RdpContainer::RdpContainer(QWidget *parent, const char *name, WFlags f) : + QXEmbed(parent, name, f), + m_viewOnly(false) +{ +} + +RdpContainer::~RdpContainer() +{ +} + +void RdpContainer::windowChanged(WId window) +{ + if(window == 0) + { + emit embeddedWindowDestroyed(); + } + else + { + emit newEmbeddedWindow(window); + } +} + +bool RdpContainer::x11Event(XEvent *e) +{ + // FIXME: mouse events still get through in view-only + if(m_viewOnly && (e->type == KeyPress || e->type == KeyRelease || e->type == ButtonPress || + e->type == ButtonRelease || e->type == MotionNotify || e->type == FocusIn || + e->type == FocusOut || e->type == EnterNotify || e->type == LeaveNotify)) + { + return true; + } + + return QXEmbed::x11Event(e); +} + + +// constructor +KRdpView::KRdpView(QWidget *parent, const char *name, + const QString &host, int port, + const QString &user, const QString &password, + int flags, const QString &domain, + const QString &shell, const QString &directory) : + KRemoteView(parent, name, Qt::WResizeNoErase | Qt::WRepaintNoErase | Qt::WStaticContents), + m_name(name), + m_host(host), + m_port(port), + m_user(user), + m_password(password), + m_flags(flags), + m_domain(domain), + m_shell(shell), + m_directory(directory), + m_quitFlag(false), + m_process(NULL) +{ + krdpview = this; + setFixedSize(16, 16); + if(m_port == 0) + { + m_port = TCP_PORT_RDP; + } + + m_container = new RdpContainer(this); +} + +// destructor +KRdpView::~KRdpView() +{ + startQuitting(); + delete m_container; +} + +// returns the size of the framebuffer +QSize KRdpView::framebufferSize() +{ + return m_container->sizeHint(); +} + +// returns the suggested size +QSize KRdpView::sizeHint() +{ + return maximumSize(); +} + +// start closing the connection +void KRdpView::startQuitting() +{ + m_quitFlag = true; + if(m_process != NULL) + { + m_container->sendDelete(); + } +} + +// are we currently closing the connection? +bool KRdpView::isQuitting() +{ + return m_quitFlag; +} + +// return the host we're connected to +QString KRdpView::host() +{ + return m_host; +} + +// return the port number we're connected on +int KRdpView::port() +{ + return m_port; +} + +bool KRdpView::editPreferences( HostPrefPtr host ) +{ + SmartPtr<RdpHostPref> hp( host ); + + int wv = hp->width(); + int hv = hp->height(); + int cd = hp->colorDepth(); + QString kl = hp->layout(); + bool kwallet = hp->useKWallet(); + + // show preferences dialog + KDialogBase *dlg = new KDialogBase( 0L, "dlg", true, + i18n( "RDP Host Preferences for %1" ).arg( host->host() ), + KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, true ); + + QVBox *vbox = dlg->makeVBoxMainWidget(); + RdpPrefs *prefs = new RdpPrefs( vbox ); + QWidget *spacer = new QWidget( vbox ); + vbox->setStretchFactor( spacer, 10 ); + + prefs->setRdpWidth( wv ); + prefs->setRdpHeight( hv ); + prefs->setResolution(); + prefs->setColorDepth(cd); + prefs->setKbLayout( keymap2int( kl ) ); + prefs->setShowPrefs( true ); + prefs->setUseKWallet(kwallet); + + if ( dlg->exec() == QDialog::Rejected ) + return false; + + wv = prefs->rdpWidth(); + hv = prefs->rdpHeight(); + kl = int2keymap( prefs->kbLayout() ); + hp->setAskOnConnect( prefs->showPrefs() ); + hp->setWidth(wv); + hp->setHeight(hv); + hp->setColorDepth( prefs->colorDepth() ); + hp->setLayout(kl); + hp->setUseKWallet(prefs->useKWallet()); + + delete dlg; + return true; +} + +// open a connection +bool KRdpView::start() +{ + SmartPtr<RdpHostPref> hp, rdpDefaults; + bool useKWallet = false; + + if(!rdpAppDataConfigured) + { + HostPreferences *hps = HostPreferences::instance(); + hp = SmartPtr<RdpHostPref>(hps->createHostPref(m_host, + RdpHostPref::RdpType)); + if(hp->askOnConnect()) + { + if( !editPreferences( hp )) + return false; + hps->sync(); + } + + useKWallet = hp->useKWallet(); + } + + m_container->show(); + + m_process = new KProcess(m_container); + *m_process << "rdesktop"; + *m_process << "-g" << (QString::number(hp->width()) + "x" + QString::number(hp->height())); + *m_process << "-k" << hp->layout(); + if(!m_user.isEmpty()) { *m_process << "-u" << m_user; } + + if(m_password.isEmpty() && useKWallet ) { + QString krdc_folder = "KRDC-RDP"; + + // Bugfix: Check if wallet has been closed by an outside source + if ( wallet && !wallet->isOpen() ) { + delete wallet; wallet=0; + } + + // Do we need to open the wallet? + if ( !wallet ) { + QString walletName = KWallet::Wallet::NetworkWallet(); + wallet = KWallet::Wallet::openWallet(walletName); + } + + if (wallet && wallet->isOpen()) { + bool walletOK = wallet->hasFolder(krdc_folder); + if (walletOK == false) { + walletOK = wallet->createFolder(krdc_folder); + } + + if (walletOK == true) { + wallet->setFolder(krdc_folder); + if ( wallet->hasEntry(m_host) ) { + wallet->readPassword(m_host, m_password); + } + } + + if ( m_password.isEmpty() ) { + //There must not be an existing entry. Let's make one. + QCString newPassword; + if (KPasswordDialog::getPassword(newPassword, i18n("Please enter the password.")) == KPasswordDialog::Accepted) { + m_password = newPassword; + wallet->writePassword(m_host, m_password); + } + } + } + } + + if(!m_password.isEmpty()) { + *m_process << "-p" << m_password; + } + + *m_process << "-X" << ("0x" + QString::number(m_container->winId(), 16)); + *m_process << "-a" << QString::number(hp->colorDepth()); + *m_process << (m_host + ":" + QString::number(m_port)); + connect(m_process, SIGNAL(processExited(KProcess *)), SLOT(processDied(KProcess *))); + connect(m_process, SIGNAL(receivedStderr(KProcess *, char *, int)), SLOT(receivedStderr(KProcess *, char *, int))); + connect(m_container, SIGNAL(embeddedWindowDestroyed()), SLOT(connectionClosed())); + connect(m_container, SIGNAL(newEmbeddedWindow(WId)), SLOT(connectionOpened(WId))); + qDebug("Color depth: %d", hp->colorDepth()); + if(!m_process->start(KProcess::NotifyOnExit, KProcess::Stderr)) + { + KMessageBox::error(0, i18n("Could not start rdesktop; make sure rdesktop is properly installed."), + i18n("rdesktop Failure")); + return false; + } + + setStatus(REMOTE_VIEW_CONNECTING); + + return true; +} + +void KRdpView::switchFullscreen(bool on) +{ + if(on == true) + { + m_container->grabKeyboard(); + } +} + +// captures pressed keys +void KRdpView::pressKey(XEvent *e) +{ + m_container->x11Event(e); + m_container->grabKeyboard(); +} + +bool KRdpView::viewOnly() +{ + return m_container->m_viewOnly; +} + +void KRdpView::setViewOnly(bool s) +{ + m_container->m_viewOnly = s; +} + +void KRdpView::connectionOpened(WId /*window*/) +{ + QSize size = m_container->sizeHint(); + + setStatus(REMOTE_VIEW_CONNECTED); + setFixedSize(size); + m_container->setFixedSize(size); + emit changeSize(size.width(), size.height()); + emit connected(); + setFocus(); +} + +void KRdpView::connectionClosed() +{ + emit disconnected(); + setStatus(REMOTE_VIEW_DISCONNECTED); + m_quitFlag = true; +} + +void KRdpView::processDied(KProcess */*proc*/) +{ + if(m_status == REMOTE_VIEW_CONNECTING) + { + setStatus(REMOTE_VIEW_DISCONNECTED); + if(m_clientVersion.isEmpty()) + { + KMessageBox::error(0, i18n("Connection attempt to host failed."), + i18n("Connection Failure")); + } + emit disconnectedError(); + } +} + +void KRdpView::receivedStderr(KProcess */*proc*/, char *buffer, int /*buflen*/) +{ + QString output(buffer); + QString line; + int i = 0; + while(!(line = output.section('\n', i, i)).isEmpty()) + { + if(line.startsWith("Version ")) + { + m_clientVersion = line.section(' ', 1, 1); + m_clientVersion = m_clientVersion.left(m_clientVersion.length() - 1); + return; + } + i++; + } +} + +#include "krdpview.moc" diff --git a/krdc/rdp/krdpview.h b/krdc/rdp/krdpview.h new file mode 100644 index 00000000..a54c2d96 --- /dev/null +++ b/krdc/rdp/krdpview.h @@ -0,0 +1,113 @@ +/* + krdpview.h, declaration of the KRdpView class + Copyright (C) 2002 Arend van Beelen jr. + + This program is free software; you can redistribute it and/or modify it under the terms of the + GNU General Public License as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See + the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program; if + not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307 USA + + For any questions, comments or whatever, you may mail me at: [email protected] +*/ + +#ifndef KRDPVIEW_H +#define KRDPVIEW_H + +#include <qxembed.h> + +#include "hostpreferences.h" +#include "kremoteview.h" + +#define TCP_PORT_RDP 3389 +#define RDP_LOGON_NORMAL 0x33 + +class KProcess; +class KRdpView; + +class RdpContainer : public QXEmbed +{ + Q_OBJECT + + friend class KRdpView; + + public: + RdpContainer(QWidget *parent = 0, const char *name = 0, WFlags f = 0); + ~RdpContainer(); + + signals: + void newEmbeddedWindow(WId window); + + protected: + virtual void windowChanged(WId window); + virtual bool x11Event(XEvent *e); + + private: + bool m_viewOnly; // if set: ignore all input +}; + +class KRdpView : public KRemoteView +{ + Q_OBJECT + + public: + // constructor and destructor + KRdpView(QWidget *parent = 0, const char *name = 0, + const QString &host = QString::null, int port = TCP_PORT_RDP, + const QString &user = QString::null, const QString &password = QString::null, + int flags = RDP_LOGON_NORMAL, const QString &domain = QString::null, + const QString &shell = QString::null, const QString &directory = QString::null); + virtual ~KRdpView(); + + // functions regarding the window + virtual QSize framebufferSize(); // returns the size of the remote view + QSize sizeHint(); // returns the suggested size + virtual bool viewOnly(); + + // functions regarding the connection + virtual void startQuitting(); // start closing the connection + virtual bool isQuitting(); // are we currently closing the connection? + virtual QString host(); // return the host we're connected to + virtual int port(); // return the port number we're connected on + virtual bool start(); // open a connection + + static bool editPreferences( HostPrefPtr ); + + public slots: + virtual void switchFullscreen(bool on); + virtual void pressKey(XEvent *k); // send a generated key to the server + virtual void setViewOnly(bool s); + + private: + // properties used for setting up the connection + QString m_name; // name of the connection + QString m_host; // the host to connect to + int m_port; // the port on the host + QString m_user; // the user to use to log in + QString m_password; // the password to use + int m_flags; // flags which determine how the connection is set up + QString m_domain; // the domain where the host is on + QString m_shell; // the shell to use + QString m_directory; // the working directory on the server + + // other properties + bool m_quitFlag; // if set: die + QString m_clientVersion; // version number returned by rdesktop + RdpContainer *m_container; // container for the rdesktop window + KProcess *m_process; // rdesktop process + + private slots: + void connectionOpened(WId window); // called if rdesktop started + void connectionClosed(); // called if rdesktop quits + void processDied(KProcess *); // called if rdesktop dies + void receivedStderr(KProcess *proc, char *buffer, int buflen); + // catches rdesktop debug output +}; + +#endif diff --git a/krdc/rdp/rdesktop.patch b/krdc/rdp/rdesktop.patch new file mode 100644 index 00000000..a027799c --- /dev/null +++ b/krdc/rdp/rdesktop.patch @@ -0,0 +1,76 @@ +--- rdesktop.c.orig 2004-03-08 18:02:58.000000000 +0100 ++++ rdesktop.c 2004-03-09 22:32:19.000000000 +0100 +@@ -27,6 +27,7 @@ + #include <sys/time.h> /* gettimeofday */ + #include <sys/times.h> /* times */ + #include <errno.h> ++#include <X11/Xlib.h> /* Window */ + #include "rdesktop.h" + + #ifdef EGD_SOCKET +@@ -68,6 +69,7 @@ + BOOL g_console_session = False; + BOOL g_numlock_sync = False; + extern BOOL g_owncolmap; ++extern Window g_embed_wnd; + + #ifdef WITH_RDPSND + BOOL g_rdpsnd = False; +@@ -112,6 +114,7 @@ + fprintf(stderr, " -S: caption button size (single application mode)\n"); + fprintf(stderr, " -T: window title\n"); + fprintf(stderr, " -N: enable numlock synchronisation\n"); ++ fprintf(stderr, " -X: embed into another window with a given id.\n"); + fprintf(stderr, " -a: connection colour depth\n"); + fprintf(stderr, " -r: enable specified device redirection (currently: sound)\n"); + fprintf(stderr, " -0: attach to console\n"); +@@ -224,6 +227,7 @@ + prompt_password = False; + domain[0] = password[0] = shell[0] = directory[0] = 0; + strcpy(keymapname, "en-us"); ++ g_embed_wnd = 0; + + #ifdef RDP2VNC + #define VNCOPT "V:Q:" +@@ -231,7 +235,7 @@ + #define VNCOPT + #endif + +- while ((c = getopt(argc, argv, VNCOPT "u:d:s:c:p:n:k:g:fbeEmCDKS:T:Na:r:045h?")) != -1) ++ while ((c = getopt(argc, argv, VNCOPT "u:d:s:c:p:n:k:g:fbeEmCDKS:T:NX:a:r:045h?")) != -1) + { + switch (c) + { +@@ -374,6 +378,10 @@ + g_numlock_sync = True; + break; + ++ case 'X': ++ g_embed_wnd = strtod(optarg, NULL); ++ break; ++ + case 'a': + g_server_bpp = strtol(optarg, NULL, 10); + if (g_server_bpp != 8 && g_server_bpp != 16 && g_server_bpp != 15 +--- xwin.c.orig 2004-03-08 18:02:58.000000000 +0100 ++++ xwin.c 2004-03-10 16:17:59.000000000 +0100 +@@ -41,6 +41,7 @@ + static int g_x_socket; + static Screen *g_screen; + Window g_wnd; ++Window g_embed_wnd; + BOOL g_enable_compose = False; + static GC g_gc; + static BOOL g_gc_initialized = False; +@@ -929,6 +930,11 @@ + XFree(sizehints); + } + ++ if ( g_embed_wnd ) ++ { ++ XReparentWindow(g_display, g_wnd, g_embed_wnd, 0, 0); ++ } ++ + input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | + VisibilityChangeMask | FocusChangeMask; + diff --git a/krdc/rdp/rdphostpref.cpp b/krdc/rdp/rdphostpref.cpp new file mode 100644 index 00000000..783c41e4 --- /dev/null +++ b/krdc/rdp/rdphostpref.cpp @@ -0,0 +1,180 @@ +/* + rdphostpref.cpp, handles preferences for RDP hosts + Copyright (C) 2003 Arend van Beelen jr. + + This program is free software; you can redistribute it and/or modify it under the terms of the + GNU General Public License as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See + the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program; if + not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307 USA + + For any questions, comments or whatever, you may mail me at: [email protected] +*/ + +#include "rdphostpref.h" +#include <kconfig.h> +#include <klocale.h> + +const QString RdpHostPref::RdpType = "RDP"; + +RdpHostPref::RdpHostPref(KConfig *conf, const QString &host, const QString &type) : + HostPref(conf, host, type), + m_width(800), + m_height(600), + m_colorDepth(8), + m_layout("en-us"), + m_askOnConnect(true), + m_useKWallet(true) +{ +} + +RdpHostPref::~RdpHostPref() +{ +} + +void RdpHostPref::save() +{ + if ( !m_host.isEmpty() && !m_type.isEmpty() ) + { + m_config->setGroup("PerHostSettings"); + QString p = prefix(); + m_config->writeEntry(p+"exists", true); + m_config->writeEntry(p+"width", m_width); + m_config->writeEntry(p+"height", m_height); + m_config->writeEntry(p+"colorDepth", m_colorDepth); + m_config->writeEntry(p+"layout", m_layout); + m_config->writeEntry(p+"askOnConnect", m_askOnConnect); + m_config->writeEntry(p+"useKWallet", m_useKWallet); + } + else + { + m_config->setGroup( "RdpDefaultSettings" ); + m_config->writeEntry( "rdpWidth", m_width ); + m_config->writeEntry( "rdpHeight", m_height ); + m_config->writeEntry( "rdpColorDepth", m_colorDepth); + m_config->writeEntry( "rdpKeyboardLayout", m_layout ); + m_config->writeEntry( "rdpShowHostPreferences", m_askOnConnect ); + m_config->writeEntry( "rdpUseKWallet", m_useKWallet ); + } +} + +void RdpHostPref::load() +{ + if ( !m_host.isEmpty() && !m_type.isEmpty() ) + { + m_config->setGroup("PerHostSettings"); + QString p = prefix(); + m_width = m_config->readNumEntry(p+"width", 800); + m_height = m_config->readNumEntry(p+"height", 600); + m_colorDepth = m_config->readNumEntry(p+"colorDepth", 8); + m_layout = m_config->readEntry(p+"layout", "en-us"); + m_askOnConnect = m_config->readBoolEntry(p+"askOnConnect", true); + m_useKWallet = m_config->readBoolEntry(p+"useKWallet", true); + } + else + { + setDefaults(); + } +} + +void RdpHostPref::remove() +{ + m_config->setGroup("PerHostSettings"); + QString p = prefix(); + m_config->deleteEntry(p+"exists"); + m_config->deleteEntry(p+"width"); + m_config->deleteEntry(p+"height"); + m_config->deleteEntry(p+"colorDepth"); + m_config->deleteEntry(p+"layout"); + m_config->deleteEntry(p+"askOnConnect"); + m_config->deleteEntry(p+"useKWallet"); +} + +void RdpHostPref::setDefaults() +{ + m_config->setGroup("RdpDefaultSettings"); + m_width = m_config->readNumEntry("rdpWidth", 800); + m_height = m_config->readNumEntry("rdpHeight", 600); + m_colorDepth = m_config->readNumEntry("rdpColorDepth", 8); + m_layout = m_config->readEntry("rdpKeyboardLayout", "en-us"); + m_askOnConnect = m_config->readBoolEntry("rdpShowHostPreferences", true); + m_useKWallet = m_config->readBoolEntry("rdpUseKWallet", true); +} + +QString RdpHostPref::prefDescription() const +{ + return i18n("Show Preferences: %1, Resolution: %2x%3, Color Depth: %4, Keymap: %5, KWallet: %6") + .arg(m_askOnConnect ? i18n("yes") : i18n("no")).arg(m_width).arg(m_height) + .arg(m_colorDepth).arg(m_layout).arg(m_useKWallet ? i18n("yes") : i18n("no")); +} + +void RdpHostPref::setWidth(int w) +{ + m_width = w; + save(); +} + +int RdpHostPref::width() const +{ + return m_width; +} + +void RdpHostPref::setHeight(int h) +{ + m_height = h; + save(); +} + +int RdpHostPref::height() const +{ + return m_height; +} + +void RdpHostPref::setColorDepth(int d) +{ + m_colorDepth = d; + save(); +} + +int RdpHostPref::colorDepth() const +{ + return m_colorDepth; +} + + +void RdpHostPref::setLayout(const QString &l) +{ + m_layout = l; + save(); +} + +QString RdpHostPref::layout() const +{ + return m_layout; +} + +void RdpHostPref::setAskOnConnect(bool ask) +{ + m_askOnConnect = ask; + save(); +} + +bool RdpHostPref::askOnConnect() const +{ + return m_askOnConnect; +} + +void RdpHostPref::setUseKWallet(bool use) { + m_useKWallet = use; + save(); +} + +bool RdpHostPref::useKWallet() const { + return m_useKWallet; +} diff --git a/krdc/rdp/rdphostpref.h b/krdc/rdp/rdphostpref.h new file mode 100644 index 00000000..355102f3 --- /dev/null +++ b/krdc/rdp/rdphostpref.h @@ -0,0 +1,127 @@ +/* + rdphostpref.h, handles preferences for RDP hosts + Copyright (C) 2003 Arend van Beelen jr. + + This program is free software; you can redistribute it and/or modify it under the terms of the + GNU General Public License as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See + the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program; if + not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307 USA + + For any questions, comments or whatever, you may mail me at: [email protected] +*/ + +#ifndef RDPHOSTPREF_H +#define RDPHOSTPREF_H + +#include "hostpreferences.h" + +static const QString rdpKeymaps[] = { "ar", + "cs", + "da", + "de", + "de-ch", + "en-gb", + "en-us", + "es", + "et", + "fi", + "fr", + "fr-be", + "fr-ca", + "fr-ch", + "hr", + "hu", + "is", + "it", + "ja", + "lt", + "lv", + "mk", + "nl", + "nl-be", + "no", + "pl", + "pt", + "pt-br", + "ru", + "sl", + "sv", + "th", + "tr" }; +static const int rdpNumKeymaps = 33; +static const int rdpDefaultKeymap = 6; // en-us + +inline int keymap2int(const QString &keymap) +{ + int layout; + for(layout = 0; layout < rdpNumKeymaps; layout++) + { + if(keymap == rdpKeymaps[layout]) + { + break; + } + } + if(layout == rdpNumKeymaps) + { + layout = rdpDefaultKeymap; + } + return layout; +} + +inline QString int2keymap(int layout) +{ + if(layout < 0 || layout >= rdpNumKeymaps) + { + return rdpKeymaps[rdpDefaultKeymap]; + } + + return rdpKeymaps[layout]; +} + +class RdpHostPref : public HostPref +{ + protected: + friend class HostPreferences; + + int m_width; + int m_height; + int m_colorDepth; + QString m_layout; + bool m_askOnConnect; + bool m_useKWallet; + + virtual void load(); + virtual void setDefaults(); + virtual void save(); + virtual void remove(); + + public: + static const QString RdpType; + + RdpHostPref(KConfig *conf, const QString &host=QString::null, + const QString &type=QString::null); + virtual ~RdpHostPref(); + + virtual QString prefDescription() const; + void setWidth(int w); + int width() const; + void setHeight(int h); + int height() const; + void setColorDepth(int depth); + int colorDepth() const; + void setLayout(const QString &l); + QString layout() const; + void setAskOnConnect(bool ask); + bool askOnConnect() const; + bool useKWallet() const; + void setUseKWallet(bool); +}; + +#endif diff --git a/krdc/rdp/rdpprefs.ui b/krdc/rdp/rdpprefs.ui new file mode 100644 index 00000000..8e493d7a --- /dev/null +++ b/krdc/rdp/rdpprefs.ui @@ -0,0 +1,509 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>RdpPrefs</class> +<widget class="QWidget"> + <property name="name"> + <cstring>RdpPrefs</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>449</width> + <height>177</height> + </rect> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <widget class="QGroupBox"> + <property name="name"> + <cstring>rdpGroupBox</cstring> + </property> + <property name="title"> + <string>Connection</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer row="1" column="0"> + <property name="name"> + <cstring>spacer8</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Fixed</enum> + </property> + <property name="sizeHint"> + <size> + <width>70</width> + <height>21</height> + </size> + </property> + </spacer> + <widget class="QComboBox" row="0" column="1" rowspan="1" colspan="4"> + <item> + <property name="text"> + <string>Small (640x480)</string> + </property> + </item> + <item> + <property name="text"> + <string>Medium (800x600)</string> + </property> + </item> + <item> + <property name="text"> + <string>Big (1024x768)</string> + </property> + </item> + <item> + <property name="text"> + <string>Custom (...)</string> + </property> + </item> + <property name="name"> + <cstring>cmbResolution</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>280</width> + <height>0</height> + </size> + </property> + <property name="currentItem"> + <number>1</number> + </property> + <property name="whatsThis" stdset="0"> + <string>Here you can specify the resolution of the remote desktop. This resolution determines the size of the desktop that will be presented to you.</string> + </property> + </widget> + <widget class="QSpinBox" row="1" column="2"> + <property name="name"> + <cstring>spinWidth</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="maxValue"> + <number>9999</number> + </property> + <property name="value"> + <number>800</number> + </property> + <property name="whatsThis" stdset="0"> + <string>This is the width of the remote desktop. You can only change this value manually if you select Custom as desktop resolution above.</string> + </property> + </widget> + <widget class="QLabel" row="1" column="3"> + <property name="name"> + <cstring>heightLabel</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>H&eight:</string> + </property> + <property name="alignment"> + <set>AlignVCenter|AlignRight</set> + </property> + <property name="buddy" stdset="0"> + <cstring>spinHeight</cstring> + </property> + </widget> + <widget class="QSpinBox" row="1" column="4"> + <property name="name"> + <cstring>spinHeight</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="maxValue"> + <number>9999</number> + </property> + <property name="value"> + <number>600</number> + </property> + <property name="whatsThis" stdset="0"> + <string>This is the height of the remote desktop. You can only change this value manually if you select Custom as desktop resolution above.</string> + </property> + </widget> + <widget class="QComboBox" row="3" column="1" rowspan="1" colspan="4"> + <item> + <property name="text"> + <string>Arabic (ar)</string> + </property> + </item> + <item> + <property name="text" > + <string>Czech (cs)</string> + </property> + </item> + <item> + <property name="text"> + <string>Danish (da)</string> + </property> + </item> + <item> + <property name="text"> + <string>German (de)</string> + </property> + </item> + <item> + <property name="text" > + <string>Swiss German (de-ch)</string> + </property> + </item> + <item> + <property name="text"> + <string>British English (en-gb)</string> + </property> + </item> + <item> + <property name="text"> + <string>US English (en-us)</string> + </property> + </item> + <item> + <property name="text"> + <string>Spanish (es)</string> + </property> + </item> + <item> + <property name="text" > + <string>Estonian (et)</string> + </property> + </item> + <item> + <property name="text"> + <string>Finnish (fi)</string> + </property> + </item> + <item> + <property name="text"> + <string>French (fr)</string> + </property> + </item> + <item> + <property name="text"> + <string>Belgium (fr-be)</string> + </property> + </item> + <item> + <property name="text" > + <string>French Canadian (fr-ca)</string> + </property> + </item> + <item> + <property name="text" > + <string>Swiss French (fr-ch)</string> + </property> + </item> + <item> + <property name="text"> + <string>Croatian (hr)</string> + </property> + </item> + <item> + <property name="text"> + <string>Hungarian (hu)</string> + </property> + </item> + <item> + <property name="text" > + <string>Icelandic (is)</string> + </property> + </item> + <item> + <property name="text"> + <string>Italian (it)</string> + </property> + </item> + <item> + <property name="text"> + <string>Japanese (ja)</string> + </property> + </item> + <item> + <property name="text"> + <string>Lithuanian (lt)</string> + </property> + </item> + <item> + <property name="text"> + <string>Latvian (lv)</string> + </property> + </item> + <item> + <property name="text"> + <string>Macedonian (mk)</string> + </property> + </item> + <item> + <property name="text" > + <string>Dutch (nl)</string> + </property> + </item> + <item> + <property name="text" > + <string>Belgian Dutch (nl-be)</string> + </property> + </item> + <item> + <property name="text"> + <string>Norwegian (no)</string> + </property> + </item> + <item> + <property name="text"> + <string>Polish (pl)</string> + </property> + </item> + <item> + <property name="text"> + <string>Portuguese (pt)</string> + </property> + </item> + <item> + <property name="text"> + <string>Brazilian (pt-br)</string> + </property> + </item> + <item> + <property name="text"> + <string>Russian (ru)</string> + </property> + </item> + <item> + <property name="text"> + <string>Slovenian (sl)</string> + </property> + </item> + <item> + <property name="text"> + <string>Swedish (sv)</string> + </property> + </item> + <item> + <property name="text"> + <string>Thai (th)</string> + </property> + </item> + <item> + <property name="text"> + <string>Turkish (tr)</string> + </property> + </item> + <property name="name"> + <cstring>cmbKbLayout</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>280</width> + <height>0</height> + </size> + </property> + <property name="editable"> + <bool>false</bool> + </property> + <property name="currentItem"> + <number>4</number> + </property> + <property name="whatsThis" stdset="0"> + <string>Use this to specify your keyboard layout. This layout setting is used to send the correct keyboard codes to the server.</string> + </property> + </widget> + <widget class="QLabel" row="3" column="0"> + <property name="name"> + <cstring>layoutLabel</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Keyboard layout:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>cmbKbLayout</cstring> + </property> + </widget> + <widget class="QCheckBox" row="4" column="0"> + <property name="name"> + <cstring>cbUseKWallet</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Use K&Wallet for passwords</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enable this option to store your passwords with KWallet.</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>resolutionLabel</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Desktop &resolution:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>cmbResolution</cstring> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>colorDepthLabel</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Color &depth:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>cmbKbLayout</cstring> + </property> + </widget> + <widget class="QLabel" row="1" column="1"> + <property name="name"> + <cstring>widthLabel</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>&Width:</string> + </property> + <property name="alignment"> + <set>AlignVCenter|AlignRight</set> + </property> + <property name="buddy" stdset="0"> + <cstring>spinWidth</cstring> + </property> + </widget> + <widget class="QComboBox" row="2" column="1" rowspan="1" colspan="4"> + <item> + <property name="text"> + <string>Low Color (8 Bit)</string> + </property> + </item> + <item> + <property name="text"> + <string>High Color (16 Bit)</string> + </property> + </item> + <item> + <property name="text"> + <string>True Color (24 Bit)</string> + </property> + </item> + <property name="name"> + <cstring>cmbColorDepth</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>cbShowPrefs</cstring> + </property> + <property name="text"> + <string>&Show this dialog again for this host</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Select this option if you do not want to be asked for the settings when connecting to a host. For hosts with existing profiles these profiles will be taken. New hosts will be configured with the defaults.</string> + </property> + </widget> + </vbox> +</widget> +<connections> + <connection> + <sender>cmbResolution</sender> + <signal>activated(int)</signal> + <receiver>RdpPrefs</receiver> + <slot>resolutionChanged(int)</slot> + </connection> + <connection> + <sender>cmbColorDepth</sender> + <signal>activated(int)</signal> + <receiver>RdpPrefs</receiver> + <slot>colorDepth()</slot> + </connection> +</connections> +<tabstops> + <tabstop>cmbResolution</tabstop> + <tabstop>spinWidth</tabstop> + <tabstop>spinHeight</tabstop> + <tabstop>cmbColorDepth</tabstop> + <tabstop>cmbKbLayout</tabstop> + <tabstop>cbShowPrefs</tabstop> +</tabstops> +<includes> + <include location="global" impldecl="in implementation">kdialog.h</include> + <include location="local" impldecl="in implementation">rdpprefs.ui.h</include> +</includes> +<slots> + <slot access="protected" specifier="non virtual">resolutionChanged( int selection )</slot> + <slot returnType="int">colorDepth()</slot> + <slot>setColorDepth( int depth )</slot> +</slots> +<functions> + <function specifier="non virtual">setRdpWidth( int w )</function> + <function specifier="non virtual" returnType="int">rdpWidth()</function> + <function specifier="non virtual">setRdpHeight( int h )</function> + <function specifier="non virtual" returnType="int">rdpHeight()</function> + <function specifier="non virtual">setResolution()</function> + <function specifier="non virtual" returnType="int">resolution()</function> + <function specifier="non virtual">setKbLayout( int i )</function> + <function specifier="non virtual" returnType="int">kbLayout()</function> + <function specifier="non virtual">setShowPrefs( bool b )</function> + <function specifier="non virtual" returnType="bool">showPrefs()</function> + <function specifier="non virtual">setUseKWallet( bool b )</function> + <function specifier="non virtual" returnType="bool">useKWallet()</function> +</functions> +<layoutdefaults spacing="6" margin="11"/> +<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> +</UI> diff --git a/krdc/rdp/rdpprefs.ui.h b/krdc/rdp/rdpprefs.ui.h new file mode 100644 index 00000000..06efe7f4 --- /dev/null +++ b/krdc/rdp/rdpprefs.ui.h @@ -0,0 +1,163 @@ +/**************************************************************************** +** ui.h extension file, included from the uic-generated form implementation. +** +** If you wish to add, delete or rename functions or slots use +** Qt Designer which will update this file, preserving your code. Create an +** init() function in place of a constructor, and a destroy() function in +** place of a destructor. +*****************************************************************************/ + + +void RdpPrefs::resolutionChanged( int selection ) +{ + bool enable = (selection==3); + spinWidth->setEnabled(enable); + spinHeight->setEnabled(enable); + widthLabel->setEnabled(enable); + heightLabel->setEnabled(enable); + + switch(selection) + { + case 0: + spinWidth->setValue(640); + spinHeight->setValue(480); + break; + + case 1: + spinWidth->setValue(800); + spinHeight->setValue(600); + break; + + case 2: + spinWidth->setValue(1024); + spinHeight->setValue(768); + break; + + case 3: + default: + break; + } +} + + +void RdpPrefs::setRdpWidth( int w ) +{ + spinWidth->setValue(w); +} + + +int RdpPrefs::rdpWidth() +{ + return spinWidth->value(); +} + + +void RdpPrefs::setRdpHeight( int h ) +{ + spinHeight->setValue(h); +} + + +int RdpPrefs::rdpHeight() +{ + return spinHeight->value(); +} + + +int RdpPrefs::colorDepth() +{ + qDebug("current depth: %i", cmbColorDepth->currentItem() ); + switch (cmbColorDepth->currentItem()) + { + case 0: + return 8; + case 1: + return 16; + case 2: + return 24; + default: + // shouldn't happen, but who knows.. + return 8; + break; + } +} + + +void RdpPrefs::setColorDepth(int depth) +{ + switch (depth) + { + case 8: + cmbColorDepth->setCurrentItem(0); + break; + case 16: + cmbColorDepth->setCurrentItem(1); + break; + case 24: + cmbColorDepth->setCurrentItem(2); + break; + default: + break; + } +} + +void RdpPrefs::setResolution() +{ + if (rdpWidth()==640 && rdpHeight()==480) + { + cmbResolution->setCurrentItem(0); + } + else if (rdpWidth()==800 && rdpHeight()==600) + { + cmbResolution->setCurrentItem(1); + } + else if (rdpWidth()==1024 && rdpHeight()==768) + { + cmbResolution->setCurrentItem(2); + } + else + { + cmbResolution->setCurrentItem(3); + } + resolutionChanged( cmbResolution->currentItem() ); +} + + +int RdpPrefs::resolution() +{ + return cmbResolution->currentItem(); +} + + +void RdpPrefs::setKbLayout( int i ) +{ + cmbKbLayout->setCurrentItem( i ); +} + + +int RdpPrefs::kbLayout() +{ + return cmbKbLayout->currentItem(); +} + + +void RdpPrefs::setShowPrefs( bool b ) +{ + cbShowPrefs->setChecked( b ); +} + + +bool RdpPrefs::showPrefs() +{ + return cbShowPrefs->isChecked(); +} + +void RdpPrefs::setUseKWallet( bool b ) +{ + cbUseKWallet->setChecked(b); +} + +bool RdpPrefs::useKWallet() +{ + return cbUseKWallet->isChecked(); +} |