|
|
|
@ -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"
|