From 2aac6a48baefef3cce8234d5d37e4ec1ed8e4874 Mon Sep 17 00:00:00 2001 From: Tim Jansen Date: Thu, 14 Feb 2002 23:20:39 +0000 Subject: [PATCH] added dcop stuff from greiser svn path=/trunk/kdenetwork/krfb/; revision=136620 --- AUTHORS | 1 + ChangeLog | 5 ++++ Makefile.am | 2 +- NOTES | 11 ------- ROADMAP | 2 +- kinetd/Makefile.am | 10 +++---- krfb/Makefile.am | 11 +++++-- krfb/configuration.cc | 39 ++++++++++++++++++++++++ krfb/configuration.h | 7 ++++- krfb/krfbiface.h | 24 +++++++++++++++ krfb/krfbifaceimpl.cc | 69 +++++++++++++++++++++++++++++++++++++++++++ krfb/main.cpp | 11 ++++++- krfb/rfbcontroller.cc | 52 ++++++++++++++++---------------- 13 files changed, 194 insertions(+), 50 deletions(-) create mode 100644 krfb/krfbiface.h create mode 100644 krfb/krfbifaceimpl.cc diff --git a/AUTHORS b/AUTHORS index d985398..adf3d01 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1 +1,2 @@ Tim Jansen +Ian Reinhart Geiser \ No newline at end of file diff --git a/ChangeLog b/ChangeLog index 3387860..e676f4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-02-14 Tim Jansen + + * krfb/krfbiface.h: integrated DCOP interface patch by + Ian Reinhart Geiser . Thanks! + 2002-02-04 Tim Jansen * replaced x0rfbserver's library with libvncserver diff --git a/Makefile.am b/Makefile.am index 63bc3e4..0bb212d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ SUBDIRS = libvncserver krfb po doc EXTRA_DIST = admin AUTHORS COPYING ChangeLog INSTALL README TODO NOTES \ - README_KDE3 krfb.lsm + krfb.lsm # not a GNU package. You can remove this line, if # have all needed files, that a GNU package needs diff --git a/NOTES b/NOTES index d9258d2..4df23dd 100644 --- a/NOTES +++ b/NOTES @@ -15,17 +15,6 @@ Some comments on various aspects of KRfb: issues like setting a password - design goal of KRfb is to make it as easy to use as possible. I tried to limit functionality whereever possible. -- to limit the required testing efforts I try to limit the number of provided - codecs. - As far as I can tell there are three major classes of VNC clients: the - original ones that support RRE, CoRRE and Hextiles, the Tridia ones - with additional ZLib and sometimes HexZLib support and the TightVNC one - with additional TightVNC encoding. So I will have four primary codecs to - support: Raw as a fall-back and for local traffic, Hextiles for original - VNC clients, ZLib for the Tridia ones and TightVNC. RRE and CoRRE won't be - supported, and probably neither HexZLib. 4 codecs ought to be enough for - everybody. TightVNC is the preferred codec and the one that clients should - use. - the original x0rfbserver has a features for selecting the port number automatically. I skipped that because it is too complicated on the client side, but I this will change when there are mechanisms for inviting people. diff --git a/ROADMAP b/ROADMAP index 4c9054f..7b1fe6a 100644 --- a/ROADMAP +++ b/ROADMAP @@ -3,7 +3,7 @@ Version 0.5 (2002/01/02): First release - port x0rfbserver with simplified KDE/Qt interface -Version 0.6 (2002/02/??): Improve RFB backend +Version 0.6 (2002/02/20): Improve RFB backend - replace x0rfbserver's backend with libvncserver <- knotify diff --git a/kinetd/Makefile.am b/kinetd/Makefile.am index 5df0882..b789bd5 100644 --- a/kinetd/Makefile.am +++ b/kinetd/Makefile.am @@ -1,17 +1,17 @@ METASOURCES = AUTO # Code -noinst_LIBRARIES = kinetd.a +noinst_LIBRARIES = libkinetd.a -kinetd_a_SOURCES = kinetd.cpp -kinetd_a_LDADD = $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) +libkinetd_a_SOURCES = kinetd.cpp kinetd.h +libkinetd_a_LIBADD = $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) # Services kdedir = $(kde_servicesdir)/kded kde_DATA = kdeprintd.desktop -EXTRA_DIST = $(krfb_SOURCES) $(kde_DATA) kinetd.h +EXTRA_DIST = $(libkinetd_a_SOURCES) $(kde_DATA) KDE_ICON = kinetd @@ -19,8 +19,6 @@ KDE_ICON = kinetd # set the include path for X, qt and KDE INCLUDES= $(all_includes) -# the library search path. -kinetd_a_LDFLAGS = $(all_libraries) $(KDE_RPATH) CXXFLAGS = @CXXFLAGS@ diff --git a/krfb/Makefile.am b/krfb/Makefile.am index b89eff6..adc7089 100644 --- a/krfb/Makefile.am +++ b/krfb/Makefile.am @@ -1,10 +1,15 @@ METASOURCES = AUTO bin_PROGRAMS = krfb -krfb_SOURCES = rfbcontroller.cc configuration.cc trayicon.cpp XUpdateScanner.cc main.cpp configurationdialog.ui newconnectiondialog.ui -krfb_LDADD = ../libvncserver/libvncserver.a -lz -lpthread -ljpeg -lXtst $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIBSOCKET) +krfb_SOURCES = rfbcontroller.cc configuration.cc trayicon.cpp \ + XUpdateScanner.cc main.cpp configurationdialog.ui newconnectiondialog.ui \ + krfbifaceimpl.cc krfbiface.skel +krfb_LDADD = ../libvncserver/libvncserver.a -lz -lpthread -ljpeg -lXtst \ + $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIBSOCKET) -EXTRA_DIST = $(krfb_SOURCES) krfb.desktop lo32-app-krfb.png lo16-app-krfb.png rfbcontroller.h eyes-closed24.png eyes-open24.png XUpdateScanner.h trayicon.h configuration.h +EXTRA_DIST = $(krfb_SOURCES) krfb.desktop lo32-app-krfb.png \ + lo16-app-krfb.png rfbcontroller.h eyes-closed24.png eyes-open24.png \ + XUpdateScanner.h trayicon.h configuration.h krfbiface.h krfbiface.kidl install-data-local: $(mkinstalldirs) $(kde_appsdir)/Applications/ diff --git a/krfb/configuration.cc b/krfb/configuration.cc index 1735b4a..e987b0c 100644 --- a/krfb/configuration.cc +++ b/krfb/configuration.cc @@ -131,6 +131,45 @@ int Configuration::port() const { return (portNumber < 100) ? (portNumber + 5900) : portNumber; } +void Configuration::setOnceConnection(bool oneConnection) +{ + oneConnectionFlag = oneConnection; + saveToKConfig(); + saveToDialog(); +} + +void Configuration::setAskOnConnect(bool askOnConnect) +{ + askOnConnectFlag = askOnConnect; + saveToKConfig(); + saveToDialog(); +} + +void Configuration::setAllowDesktopControl(bool allowDesktopControl) +{ + allowDesktopControlFlag = allowDesktopControl; + saveToKConfig(); + saveToDialog(); +} + +void Configuration::setPassword(QString password) +{ + passwordString = password; + saveToKConfig(); + saveToDialog(); +} + +void Configuration::setPort(int port) +{ + if ((port >= 5900) && (port < 6000)) + portNumber = port-5900; + else + portNumber = port; + emit portChanged(); + saveToKConfig(); + saveToDialog(); +} + void Configuration::showDialog() { confDlg.show(); } diff --git a/krfb/configuration.h b/krfb/configuration.h index 593bbaa..d6734f6 100644 --- a/krfb/configuration.h +++ b/krfb/configuration.h @@ -49,10 +49,15 @@ public: bool oneConnection() const; bool askOnConnect() const; bool allowDesktopControl() const; - QString password() const; int port() const; + void setOnceConnection(bool oneConnection); + void setAskOnConnect(bool askOnConnect); + void setAllowDesktopControl(bool allowDesktopControl); + void setPassword(QString password); + void setPort(int port); + signals: void portChanged(); diff --git a/krfb/krfbiface.h b/krfb/krfbiface.h new file mode 100644 index 0000000..76cbf62 --- /dev/null +++ b/krfb/krfbiface.h @@ -0,0 +1,24 @@ +#ifndef __KRFB_IFACE_H +#define __KRFB_IFACE_H + +#include + +class krfbIface : virtual public DCOPObject +{ + K_DCOP +k_dcop: + virtual void disconnect() = 0; +// virtual void setWindowID(int) = 0; + virtual void exit() = 0; + + virtual bool oneConnection() = 0; + virtual void setOneConnection(bool) = 0; + virtual bool askOnConnect() = 0; + virtual void setAskOnConnect(bool) = 0; + virtual bool allowDesktopControl() = 0; + virtual void setAllowDesktopControl(bool) = 0; + virtual void setPassword(QString) = 0; + virtual int port() = 0; + virtual void setPort(int) = 0; +}; +#endif diff --git a/krfb/krfbifaceimpl.cc b/krfb/krfbifaceimpl.cc new file mode 100644 index 0000000..c0eccb4 --- /dev/null +++ b/krfb/krfbifaceimpl.cc @@ -0,0 +1,69 @@ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "krfbifaceimpl.h" + +KRfbIfaceImpl::KRfbIfaceImpl(Configuration *c) : + DCOPObject("krfbIface"), + configuration(c) +{ +} + +void KRfbIfaceImpl::disconnect() +{ + emit connectionClosed(); +} + +/* +void KRfbIfaceImpl::setWindowID(int) +{ +} +*/ + +void KRfbIfaceImpl::exit() +{ + emit exitApp(); +} +bool KRfbIfaceImpl::oneConnection() +{ + return configuration->oneConnection(); +} +void KRfbIfaceImpl::setOneConnection(bool b) +{ + configuration->setOnceConnection(b); +} +bool KRfbIfaceImpl::askOnConnect() +{ + return configuration->askOnConnect(); +} +void KRfbIfaceImpl::setAskOnConnect(bool b) +{ + configuration->setAskOnConnect(b); +} +bool KRfbIfaceImpl::allowDesktopControl() +{ + return configuration->allowDesktopControl(); +} +void KRfbIfaceImpl::setAllowDesktopControl(bool b) +{ + configuration->setAllowDesktopControl(b); +} +void KRfbIfaceImpl::setPassword(QString password) +{ + configuration->setPassword(password); +} +int KRfbIfaceImpl::port() +{ + return configuration->port(); +} +void KRfbIfaceImpl::setPort(int port) +{ + configuration->setPort(port); +} + diff --git a/krfb/main.cpp b/krfb/main.cpp index 78852d2..c4ac76a 100644 --- a/krfb/main.cpp +++ b/krfb/main.cpp @@ -17,12 +17,13 @@ #include "trayicon.h" #include "configuration.h" +#include "krfbifaceimpl.h" #include "rfbcontroller.h" #include #include #include -#include +#include #include #include #include @@ -73,6 +74,7 @@ int main(int argc, char *argv[]) "(c) 1999, AT&T Laboratories Cambridge\n", 0, "http://www.tjansen.de/krfb", "ml@tjansen.de"); aboutData.addAuthor("Tim Jansen", "", "tim@tjansen.de"); + aboutData.addAuthor("Ian Reinhart Geiser", "DCOP interface", "geiseri@kde.org"); aboutData.addCredit("Johannes E. Schindelin", I18N_NOOP("libvncserver")); aboutData.addCredit("Const Kaplinsky", @@ -117,6 +119,7 @@ int main(int argc, char *argv[]) TrayIcon trayicon(new KAboutApplication(&aboutData), config); + KRfbIfaceImpl dcopiface(config); RFBController controller(config); QObject::connect(&app, SIGNAL(lastWindowClosed()), @@ -131,6 +134,12 @@ int main(int argc, char *argv[]) QObject::connect(&trayicon, SIGNAL(showConfigure()), config, SLOT(showDialog())); + QObject::connect(&dcopiface, SIGNAL(connectionClosed()), + &controller, SLOT(closeConnection())); + + QObject::connect(&dcopiface, SIGNAL(exitApp()), + &controller, SLOT(quit())); + QObject::connect(config, SIGNAL(portChanged()), &controller, SLOT(rebind())); diff --git a/krfb/rfbcontroller.cc b/krfb/rfbcontroller.cc index e3ed0d1..ac86b8a 100644 --- a/krfb/rfbcontroller.cc +++ b/krfb/rfbcontroller.cc @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include @@ -119,6 +119,31 @@ KeyboardEvent::KeyboardEvent(bool d, KeySym k) : } } +void KeyboardEvent::initKeycodes() { + KeySym key,*keymap; + int i,j,minkey,maxkey,syms_per_keycode; + + memset(modifiers,-1,sizeof(modifiers)); + + XDisplayKeycodes(dpy,&minkey,&maxkey); + keymap=XGetKeyboardMapping(dpy,minkey,(maxkey - minkey + 1),&syms_per_keycode); + + for (i = minkey; i <= maxkey; i++) + for(j=0;j=' ' && key<0x100 && i==XKeysymToKeycode(dpy,key)) { + keycodes[key]=i; + modifiers[key]=j; + } + } + + leftShiftCode = XKeysymToKeycode(dpy,XK_Shift_L); + rightShiftCode = XKeysymToKeycode(dpy,XK_Shift_R); + altGrCode = XKeysymToKeycode(dpy,XK_Mode_switch); + + XFree ((char *)keymap); +} + /* this function adjusts the modifiers according to mod (as from modifiers) and ModifierState */ void KeyboardEvent::tweakModifiers(char mod, bool down) { @@ -147,31 +172,6 @@ void KeyboardEvent::tweakModifiers(char mod, bool down) { down, CurrentTime); } -void KeyboardEvent::initKeycodes() { - KeySym key,*keymap; - int i,j,minkey,maxkey,syms_per_keycode; - - memset(modifiers,-1,sizeof(modifiers)); - - XDisplayKeycodes(dpy,&minkey,&maxkey); - keymap=XGetKeyboardMapping(dpy,minkey,(maxkey - minkey + 1),&syms_per_keycode); - - for (i = minkey; i <= maxkey; i++) - for(j=0;j=' ' && key<0x100 && i==XKeysymToKeycode(dpy,key)) { - keycodes[key]=i; - modifiers[key]=j; - } - } - - leftShiftCode = XKeysymToKeycode(dpy,XK_Shift_L); - rightShiftCode = XKeysymToKeycode(dpy,XK_Shift_R); - altGrCode = XKeysymToKeycode(dpy,XK_Mode_switch); - - XFree ((char *)keymap); -} - void KeyboardEvent::exec() { #define ADJUSTMOD(sym,state) \ if(keySym==sym) { if(down) ModifierState|=state; else ModifierState&=~state; }