From bcb704366cb5e333a626c18c308c7e0448a8e69f Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- krdc/rdp/Makefile.am | 11 + krdc/rdp/README.patch | 12 ++ krdc/rdp/krdpview.cpp | 369 ++++++++++++++++++++++++++++++++++ krdc/rdp/krdpview.h | 113 +++++++++++ krdc/rdp/rdesktop.patch | 76 +++++++ krdc/rdp/rdphostpref.cpp | 180 +++++++++++++++++ krdc/rdp/rdphostpref.h | 127 ++++++++++++ krdc/rdp/rdpprefs.ui | 509 +++++++++++++++++++++++++++++++++++++++++++++++ krdc/rdp/rdpprefs.ui.h | 163 +++++++++++++++ 9 files changed, 1560 insertions(+) create mode 100644 krdc/rdp/Makefile.am create mode 100644 krdc/rdp/README.patch create mode 100644 krdc/rdp/krdpview.cpp create mode 100644 krdc/rdp/krdpview.h create mode 100644 krdc/rdp/rdesktop.patch create mode 100644 krdc/rdp/rdphostpref.cpp create mode 100644 krdc/rdp/rdphostpref.h create mode 100644 krdc/rdp/rdpprefs.ui create mode 100644 krdc/rdp/rdpprefs.ui.h (limited to 'krdc/rdp') 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: arend@auton.nl +*/ + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#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 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 hp, rdpDefaults; + bool useKWallet = false; + + if(!rdpAppDataConfigured) + { + HostPreferences *hps = HostPreferences::instance(); + hp = SmartPtr(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: arend@auton.nl +*/ + +#ifndef KRDPVIEW_H +#define KRDPVIEW_H + +#include + +#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 /* gettimeofday */ + #include /* times */ + #include ++#include /* 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: arend@auton.nl +*/ + +#include "rdphostpref.h" +#include +#include + +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: arend@auton.nl +*/ + +#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 @@ + +RdpPrefs + + + RdpPrefs + + + + 0 + 0 + 449 + 177 + + + + + unnamed + + + 0 + + + + rdpGroupBox + + + Connection + + + + unnamed + + + + spacer8 + + + Horizontal + + + Fixed + + + + 70 + 21 + + + + + + + Small (640x480) + + + + + Medium (800x600) + + + + + Big (1024x768) + + + + + Custom (...) + + + + cmbResolution + + + + 5 + 0 + 0 + 0 + + + + + 280 + 0 + + + + 1 + + + Here you can specify the resolution of the remote desktop. This resolution determines the size of the desktop that will be presented to you. + + + + + spinWidth + + + false + + + 9999 + + + 800 + + + This is the width of the remote desktop. You can only change this value manually if you select Custom as desktop resolution above. + + + + + heightLabel + + + false + + + H&eight: + + + AlignVCenter|AlignRight + + + spinHeight + + + + + spinHeight + + + false + + + 9999 + + + 600 + + + This is the height of the remote desktop. You can only change this value manually if you select Custom as desktop resolution above. + + + + + + Arabic (ar) + + + + + Czech (cs) + + + + + Danish (da) + + + + + German (de) + + + + + Swiss German (de-ch) + + + + + British English (en-gb) + + + + + US English (en-us) + + + + + Spanish (es) + + + + + Estonian (et) + + + + + Finnish (fi) + + + + + French (fr) + + + + + Belgium (fr-be) + + + + + French Canadian (fr-ca) + + + + + Swiss French (fr-ch) + + + + + Croatian (hr) + + + + + Hungarian (hu) + + + + + Icelandic (is) + + + + + Italian (it) + + + + + Japanese (ja) + + + + + Lithuanian (lt) + + + + + Latvian (lv) + + + + + Macedonian (mk) + + + + + Dutch (nl) + + + + + Belgian Dutch (nl-be) + + + + + Norwegian (no) + + + + + Polish (pl) + + + + + Portuguese (pt) + + + + + Brazilian (pt-br) + + + + + Russian (ru) + + + + + Slovenian (sl) + + + + + Swedish (sv) + + + + + Thai (th) + + + + + Turkish (tr) + + + + cmbKbLayout + + + + 5 + 0 + 0 + 0 + + + + + 280 + 0 + + + + false + + + 4 + + + Use this to specify your keyboard layout. This layout setting is used to send the correct keyboard codes to the server. + + + + + layoutLabel + + + + 0 + 1 + 0 + 0 + + + + &Keyboard layout: + + + cmbKbLayout + + + + + cbUseKWallet + + + true + + + Use K&Wallet for passwords + + + Enable this option to store your passwords with KWallet. + + + + + resolutionLabel + + + + 0 + 1 + 0 + 0 + + + + Desktop &resolution: + + + cmbResolution + + + + + colorDepthLabel + + + + 0 + 1 + 0 + 0 + + + + Color &depth: + + + cmbKbLayout + + + + + widthLabel + + + false + + + &Width: + + + AlignVCenter|AlignRight + + + spinWidth + + + + + + Low Color (8 Bit) + + + + + High Color (16 Bit) + + + + + True Color (24 Bit) + + + + cmbColorDepth + + + + + + + cbShowPrefs + + + &Show this dialog again for this host + + + 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. + + + + + + + cmbResolution + activated(int) + RdpPrefs + resolutionChanged(int) + + + cmbColorDepth + activated(int) + RdpPrefs + colorDepth() + + + + cmbResolution + spinWidth + spinHeight + cmbColorDepth + cmbKbLayout + cbShowPrefs + + + kdialog.h + rdpprefs.ui.h + + + resolutionChanged( int selection ) + colorDepth() + setColorDepth( int depth ) + + + setRdpWidth( int w ) + rdpWidth() + setRdpHeight( int h ) + rdpHeight() + setResolution() + resolution() + setKbLayout( int i ) + kbLayout() + setShowPrefs( bool b ) + showPrefs() + setUseKWallet( bool b ) + useKWallet() + + + + 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(); +} -- cgit v1.2.1