diff options
Diffstat (limited to 'krfb/libvncserver')
-rw-r--r-- | krfb/libvncserver/CMakeLists.txt | 10 | ||||
-rw-r--r-- | krfb/libvncserver/Makefile.am | 4 | ||||
-rw-r--r-- | krfb/libvncserver/cursor.c | 12 | ||||
-rw-r--r-- | krfb/libvncserver/main.cc (renamed from krfb/libvncserver/main.c) | 141 | ||||
-rw-r--r-- | krfb/libvncserver/main.h | 43 | ||||
-rw-r--r-- | krfb/libvncserver/rfb.h | 14 |
6 files changed, 165 insertions, 59 deletions
diff --git a/krfb/libvncserver/CMakeLists.txt b/krfb/libvncserver/CMakeLists.txt index 9f1009c6..fece6692 100644 --- a/krfb/libvncserver/CMakeLists.txt +++ b/krfb/libvncserver/CMakeLists.txt @@ -9,14 +9,20 @@ # ################################################# +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} +) + + add_definitions( -DHAVE_PTHREADS -DALLOW24BPP ) ##### vncserver (static) ######################## -tde_add_library( vncserver STATIC_PIC +tde_add_library( vncserver STATIC_PIC AUTOMOC SOURCES - main.c rfbserver.c sraRegion.c auth.c sockets.c stats.c corre.c + main.cc rfbserver.c sraRegion.c auth.c sockets.c stats.c corre.c hextile.c rre.c translate.c cutpaste.c zlib.c tight.c httpd.c cursor.c font.c draw.c selbox.c d3des.c vncauth.c cargs.c ) diff --git a/krfb/libvncserver/Makefile.am b/krfb/libvncserver/Makefile.am index ed8e22d2..2203dd7f 100644 --- a/krfb/libvncserver/Makefile.am +++ b/krfb/libvncserver/Makefile.am @@ -1,8 +1,10 @@ INCLUDES = $(all_includes) +METASOURCES = AUTO + noinst_LTLIBRARIES = libvncserver.la -libvncserver_la_SOURCES = main.c rfbserver.c sraRegion.c auth.c sockets.c \ +libvncserver_la_SOURCES = main.cc rfbserver.c sraRegion.c auth.c sockets.c \ stats.c corre.c hextile.c rre.c translate.c cutpaste.c \ zlib.c tight.c httpd.c cursor.c font.c \ draw.c selbox.c d3des.c vncauth.c cargs.c diff --git a/krfb/libvncserver/cursor.c b/krfb/libvncserver/cursor.c index a27a2fef..3609b18f 100644 --- a/krfb/libvncserver/cursor.c +++ b/krfb/libvncserver/cursor.c @@ -362,15 +362,15 @@ rfbCursorPtr rfbMakeXCursor(int width,int height,char* cursorString,char* maskSt cursor->source = (unsigned char*)calloc(w,height); for(j=0,cp=cursorString;j<height;j++) for(i=0,bit=0x80;i<width;i++,bit=(bit&1)?0x80:bit>>1,cp++) - if(*cp!=' ') cursor->source[j*w+i/8]|=bit; + if(*cp!=' ') ((char*)(cursor->source))[j*w+i/8]|=bit; if(maskString) { cursor->mask = (unsigned char*)calloc(w,height); for(j=0,cp=maskString;j<height;j++) for(i=0,bit=0x80;i<width;i++,bit=(bit&1)?0x80:bit>>1,cp++) - if(*cp!=' ') cursor->mask[j*w+i/8]|=bit; + if(*cp!=' ') ((char*)(cursor->mask))[j*w+i/8]|=bit; } else - cursor->mask = (unsigned char*)rfbMakeMaskForXCursor(width,height,cursor->source); + cursor->mask = (unsigned char*)rfbMakeMaskForXCursor(width,height,(char*)(cursor->source)); return(cursor); } @@ -403,8 +403,8 @@ void rfbFreeCursor(rfbCursorPtr cursor) if(cursor) { if(cursor->richSource) free(cursor->richSource); - free(cursor->source); - free(cursor->mask); + free((char*)(cursor->source)); + free((char*)(cursor->mask)); free(cursor); } @@ -431,7 +431,7 @@ void MakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor) for(j=0;j<cursor->height;j++) for(i=0,bit=0x80;i<cursor->width;i++,bit=(bit&1)?0x80:bit>>1) if(memcmp(cursor->richSource+j*width+i*bpp,back,bpp)) - cursor->source[j*w+i/8]|=bit; + ((char*)(cursor->source))[j*w+i/8]|=bit; } void MakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor) diff --git a/krfb/libvncserver/main.c b/krfb/libvncserver/main.cc index 207e512d..51cfaa5d 100644 --- a/krfb/libvncserver/main.c +++ b/krfb/libvncserver/main.cc @@ -10,30 +10,41 @@ * see GPL (latest version) for full details */ -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <errno.h> - -#ifndef false -#define false 0 -#define true -1 -#endif +extern "C" { + #include <stdio.h> + #include <stdlib.h> + #include <stdarg.h> + #include <errno.h> + + #ifndef false + #define false 0 + #define true -1 + #endif + + #include <sys/types.h> + #ifdef __osf__ + typedef int socklen_t; + #endif + #ifndef WIN32 + #include <sys/socket.h> + #include <netinet/in.h> + #include <unistd.h> + #endif + #include <signal.h> + #include <time.h> +} -#include <sys/types.h> -#ifdef __osf__ -typedef int socklen_t; -#endif -#ifndef WIN32 -#include <sys/socket.h> -#include <netinet/in.h> -#include <unistd.h> -#endif -#include <signal.h> -#include <time.h> +#include <ntqobject.h> +#include <ntqvariant.h> +#include <ntqtimer.h> +#include <ntqthread.h> -#include "rfb.h" -#include "sraRegion.h" +extern "C" { + #include "rfb.h" + #include "sraRegion.h" +} + +#include "main.h" /* minimum interval between attempts to send something */ #define PING_MS 10000 @@ -47,9 +58,17 @@ int rfbEnableLogging=1; defined, even if _BYTE_ORDER is not _LITTLE_ENDIAN */ char rfbEndianTest = (_BYTE_ORDER == 1234); -/* from rfbserver.c */ -void rfbIncrClientRef(rfbClientPtr cl); -void rfbDecrClientRef(rfbClientPtr cl); +extern "C" { + /* from rfbserver.c */ + void rfbIncrClientRef(rfbClientPtr cl); + void rfbDecrClientRef(rfbClientPtr cl); +} + +ControlPipeHandlerObject* mControlPipeHandler = NULL; +TQEventLoopThread* mControlPipeHandlerThread = NULL; + +OnHoldClientHandlerObject* mOnHoldClientHandler = NULL; +TQEventLoopThread* mOnHoldClientHandlerThread = NULL; void rfbLogEnable(int enabled) { rfbEnableLogging=enabled; @@ -339,7 +358,7 @@ listenerRun(void *data) /* TODO: this thread wont die by restarting the server */ while ((client_fd = accept(rfbScreen->rfbListenSock, - (struct sockaddr*)&peer, &len)) >= 0) { + (struct sockaddr*)&peer, (socklen_t*)(&len))) >= 0) { cl = rfbNewClient(rfbScreen,client_fd); len = sizeof(peer); @@ -352,7 +371,12 @@ listenerRun(void *data) void rfbStartOnHoldClient(rfbClientPtr cl) { - pthread_create(&cl->client_thread, NULL, clientInput, (void *)cl); + mOnHoldClientHandlerThread = new TQEventLoopThread(); + mOnHoldClientHandler = new OnHoldClientHandlerObject(); + mOnHoldClientHandler->d = cl; + mOnHoldClientHandler->moveToThread(mOnHoldClientHandlerThread); + TQTimer::singleShot(0, mOnHoldClientHandler, SLOT(run())); + mOnHoldClientHandlerThread->start(); } #else @@ -435,7 +459,7 @@ rfbCursorPtr defaultGetCursorPtr(rfbClientPtr cl) Bool defaultPasswordCheck(rfbClientPtr cl,const char* response,int len) { int i; - char *passwd=vncDecryptPasswdFromFile(cl->screen->rfbAuthPasswdData); + char *passwd = vncDecryptPasswdFromFile((char*)(cl->screen->rfbAuthPasswdData)); if(!passwd) { rfbLog("Couldn't read password file: %s\n",cl->screen->rfbAuthPasswdData); @@ -491,7 +515,7 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv, int width,int height,int bitsPerSample,int samplesPerPixel, int bytesPerPixel) { - rfbScreenInfoPtr rfbScreen=malloc(sizeof(rfbScreenInfo)); + rfbScreenInfoPtr rfbScreen=(rfbScreenInfoPtr)(malloc(sizeof(rfbScreenInfo))); rfbPixelFormat* format=&rfbScreen->rfbServerFormat; INIT_MUTEX(logMutex); @@ -707,23 +731,54 @@ rfbProcessEvents(rfbScreenInfoPtr rfbScreen,long usec) void rfbRunEventLoop(rfbScreenInfoPtr rfbScreen, long usec, Bool runInBackground) { - if(runInBackground) { + if (runInBackground) { #ifdef HAVE_PTHREADS - pthread_t listener_thread; - - rfbScreen->backgroundLoop = TRUE; - - pthread_create(&listener_thread, NULL, listenerRun, rfbScreen); - return; + rfbScreen->backgroundLoop = TRUE; + + mControlPipeHandlerThread = new TQEventLoopThread(); + mControlPipeHandler = new ControlPipeHandlerObject(); + mControlPipeHandler->d = rfbScreen; + mControlPipeHandler->moveToThread(mControlPipeHandlerThread); + TQTimer::singleShot(0, mControlPipeHandler, SLOT(run())); + mControlPipeHandlerThread->start(); + return; #else - fprintf(stderr,"Can't run in background, because I don't have PThreads!\n"); - exit(-1); + fprintf(stderr,"Can't run in background, because I don't have PThreads!\n"); + exit(-1); #endif - } + } - if(usec<0) - usec=rfbScreen->rfbDeferUpdateTime*1000; + if (usec<0) { + usec=rfbScreen->rfbDeferUpdateTime*1000; + } + + while (1) { + rfbProcessEvents(rfbScreen,usec); + } +} + +ControlPipeHandlerObject::ControlPipeHandlerObject() : TQObject() { + // +} + +ControlPipeHandlerObject::~ControlPipeHandlerObject() { + // +} - while(1) - rfbProcessEvents(rfbScreen,usec); +void ControlPipeHandlerObject::run(void) { + listenerRun(d); } + +OnHoldClientHandlerObject::OnHoldClientHandlerObject() : TQObject() { + // +} + +OnHoldClientHandlerObject::~OnHoldClientHandlerObject() { + // +} + +void OnHoldClientHandlerObject::run(void) { + clientInput(d); +} + +#include "main.moc"
\ No newline at end of file diff --git a/krfb/libvncserver/main.h b/krfb/libvncserver/main.h new file mode 100644 index 00000000..f662a212 --- /dev/null +++ b/krfb/libvncserver/main.h @@ -0,0 +1,43 @@ +/* + * LibVNCServer (C) 2001 Johannes E. Schindelin <Johannes.Schindelin@gmx.de> + * Original OSXvnc (C) 2001 Dan McGuirk <mcguirk@incompleteness.net>. + * Original Xvnc (C) 1999 AT&T Laboratories Cambridge. + * All Rights Reserved. + * + * see GPL (latest version) for full details + */ + +#ifndef _MAIN_H +#define _MAIN_H + +class ControlPipeHandlerObject : public TQObject +{ + Q_OBJECT + + public: + ControlPipeHandlerObject(); + ~ControlPipeHandlerObject(); + + public slots: + void run(); + + public: + rfbScreenInfoPtr d; +}; + +class OnHoldClientHandlerObject : public TQObject +{ + Q_OBJECT + + public: + OnHoldClientHandlerObject(); + ~OnHoldClientHandlerObject(); + + public slots: + void run(); + + public: + rfbClientPtr d; +}; + +#endif // _MAIN_H
\ No newline at end of file diff --git a/krfb/libvncserver/rfb.h b/krfb/libvncserver/rfb.h index e8dbfb65..55736af8 100644 --- a/krfb/libvncserver/rfb.h +++ b/krfb/libvncserver/rfb.h @@ -154,7 +154,7 @@ typedef unsigned long KeySym; #define TIMEDWAIT(cond,mutex,t) {struct timeval tv;\ tv.tv_sec = (t) / 1000;\ tv.tv_usec = ((t) % 1000) * 1000;\ - pthread_cond_timedwait(&(cond),&(mutex),&tv);} + pthread_cond_timedwait(&(cond),&(mutex),(const timespec*)(&tv));} #define COND(cond) pthread_cond_t (cond) #define INIT_COND(cond) pthread_cond_init(&(cond),NULL) #define TINI_COND(cond) pthread_cond_destroy(&(cond)) @@ -725,12 +725,12 @@ extern Bool rfbSendRectEncodingTight(rfbClientPtr cl, int x,int y,int w,int h); /* cursor.c */ typedef struct rfbCursor { - unsigned char *source; /* points to bits */ - unsigned char *mask; /* points to bits */ - unsigned short width, height, xhot, yhot; /* metrics */ - unsigned short foreRed, foreGreen, foreBlue; /* device-independent colour */ - unsigned short backRed, backGreen, backBlue; /* device-independent colour */ - unsigned char *richSource; /* source bytes for a rich cursor */ + const char *source; /* points to bits */ + const char *mask; /* points to bits */ + unsigned short width, height, xhot, yhot; /* metrics */ + unsigned short foreRed, foreGreen, foreBlue; /* device-independent colour */ + unsigned short backRed, backGreen, backBlue; /* device-independent colour */ + unsigned char *richSource; /* source bytes for a rich cursor */ } rfbCursor, *rfbCursorPtr; extern Bool rfbSendCursorShape(rfbClientPtr cl/*, rfbScreenInfoPtr pScreen*/); |