1
0
mirror of https://github.com/KDE/krfb synced 2026-07-02 00:01:18 -07:00

Compare commits

...

13 Commits

Author SHA1 Message Date
nobody
7fe6211328 This commit was manufactured by cvs2svn to create tag
'KDE_3_1_1_RELEASE'.

svn path=/tags/KDE_3_1_1_RELEASE/kdenetwork/krfb/; revision=218032
2003-04-03 11:45:55 +00:00
Tim Jansen
98debc4910 Make krfb work on thin-clients without XShm. You need a lot of bandwidth
though...

svn path=/branches/KDE_3_1_BRANCH/kdenetwork/krfb/; revision=205753
2003-02-09 01:10:59 +00:00
Tim Jansen
a65c5fd148 Fix #52126 (krfb mangles colours when serving 8-bit displays)
svn path=/branches/KDE_3_1_BRANCH/kdenetwork/krfb/; revision=205627
2003-02-08 13:04:33 +00:00
Tim Jansen
1405623863 fix krfb on machines with big-endian framebuffers
svn path=/branches/KDE_3_1_BRANCH/kdenetwork/krfb/; revision=205094
2003-02-05 18:49:51 +00:00
Tim Jansen
612e3b8aab Fix behaviour for clients that support soft cursor and rich cursor encodings (like krdc will soon): soft cursor has the higher priority
svn path=/branches/KDE_3_1_BRANCH/kdenetwork/krfb/; revision=204221
2003-02-01 19:35:40 +00:00
Tim Jansen
f80311e260 #53620: krfb did not compile on Solaris 7
svn path=/branches/KDE_3_1_BRANCH/kdenetwork/krfb/; revision=203810
2003-01-30 22:39:31 +00:00
Tim Jansen
caab1aad51 Backport from HEAD:
Remove read timeouts. Instead make sure to send something at least every
10 seconds (empty framebuffer requests if nothing else has been sent).
This fixes problems with the windows vnc client which had been kicked after
a minute of inactivity without losing the capability to detect dead
clients.

svn path=/branches/KDE_3_1_BRANCH/kdenetwork/krfb/; revision=201809
2003-01-21 21:31:43 +00:00
Tim Jansen
9a4432a0fd #51792: Compile patch for solaris versions without IPv6
svn path=/branches/KDE_3_1_BRANCH/kdenetwork/krfb/; revision=201807
2003-01-21 21:15:28 +00:00
Dirk Mueller
fefe8c1a11 don't interpret format strings here (backport)
svn path=/branches/KDE_3_1_BRANCH/kdenetwork/krfb/; revision=199229
2003-01-12 13:14:55 +00:00
Waldo Bastian
6b36501ba0 CCMAIL: peter@hawkins.emu.id.au
string fixes, patches by Peter Hawkins <peter@hawkins.emu.id.au>

svn path=/branches/KDE_3_1_BRANCH/kdenetwork/krfb/; revision=194091
2002-12-15 15:44:47 +00:00
Luboš Luňák
7426b84321 Max size limits for scanf().
Correct arguments to scanf() - people, can't you read the warnings?
Got rid of two more warnings.

svn path=/branches/KDE_3_1_BRANCH/kdenetwork/krfb/; revision=192448
2002-12-06 16:01:45 +00:00
Lauri Watts
b04b1591e5 Fixing Date
svn path=/branches/KDE_3_1_BRANCH/kdenetwork/doc/krfb/; revision=191476
2002-12-01 18:57:36 +00:00
Andy Fawcett
42f9c6e578 +#ifndef _BYTE_ORDER
#define _BYTE_ORDER BYTE_ORDER
+#endif
+#ifndef _LITTLE_ENDIAN
 #define _LITTLE_ENDIAN LITTLE_ENDIAN
+#endif

These are already defined on FreeBSD, so don't try and do it again.

Previously applied to HEAD, these didn't make it to the release or the branch.

svn path=/branches/KDE_3_1_BRANCH/kdenetwork/krfb/; revision=191459
2002-12-01 17:13:07 +00:00
13 changed files with 180 additions and 88 deletions

View File

@@ -360,14 +360,15 @@ void RFBController::startServer(int inetdFd, bool xtestGrab)
server->rfbServerFormat.depth = framebufferImage->depth;
//rfbEndianTest = framebufferImage->bitmap_bit_order != MSBFirst;
server->rfbServerFormat.trueColour = (CARD8) TRUE;
server->rfbServerFormat.bigEndian = (CARD8) ((framebufferImage->bitmap_bit_order == MSBFirst) ? TRUE : FALSE);
if ( server->rfbServerFormat.bitsPerPixel == 8 ) {
server->rfbServerFormat.redShift = 0;
server->rfbServerFormat.greenShift = 2;
server->rfbServerFormat.blueShift = 5;
server->rfbServerFormat.redMax = 3;
server->rfbServerFormat.greenMax = 7;
server->rfbServerFormat.blueMax = 3;
server->rfbServerFormat.redShift = 0;
server->rfbServerFormat.greenShift = 3;
server->rfbServerFormat.blueShift = 6;
server->rfbServerFormat.redMax = 7;
server->rfbServerFormat.greenMax = 7;
server->rfbServerFormat.blueMax = 3;
} else {
server->rfbServerFormat.redShift = 0;
if ( framebufferImage->red_mask )
@@ -729,10 +730,6 @@ void RFBController::sendSessionEstablished()
emit sessionEstablished();
}
#ifdef __osf__
extern "C" Bool XShmQueryExtension(Display*);
#endif
bool RFBController::checkX11Capabilities() {
int bp1, bp2, majorv, minorv;
Bool r = XTestQueryExtension(qt_xdisplay(), &bp1, &bp2,
@@ -744,13 +741,6 @@ bool RFBController::checkX11Capabilities() {
return false;
}
r = XShmQueryExtension(qt_xdisplay());
if (!r) {
KMessageBox::error(0,
i18n("Your X11 Server does not support the required XShm extension. You can only share a local desktop."),
i18n("Desktop Sharing Error"));
return false;
}
return true;
}

View File

@@ -31,6 +31,7 @@
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/XShm.h>
@@ -72,23 +73,42 @@ XUpdateScanner::XUpdateScanner(Display *_dpy,
scanline(NULL),
tile(NULL)
{
tile = XShmCreateImage(dpy,
DefaultVisual( dpy, 0 ),
bitsPerPixel,
ZPixmap,
NULL,
&shminfo_tile,
tileWidth,
tileHeight);
useShm = XShmQueryExtension(dpy);
if (useShm) {
tile = XShmCreateImage(dpy,
DefaultVisual( dpy, 0 ),
bitsPerPixel,
ZPixmap,
NULL,
&shminfo_tile,
tileWidth,
tileHeight);
shminfo_tile.shmid = shmget(IPC_PRIVATE,
tile->bytes_per_line * tile->height,
IPC_CREAT | 0777);
shminfo_tile.shmaddr = tile->data = (char *)
shmat(shminfo_tile.shmid, 0, 0);
shminfo_tile.readOnly = False;
shminfo_tile.shmid = shmget(IPC_PRIVATE,
tile->bytes_per_line * tile->height,
IPC_CREAT | 0777);
shminfo_tile.shmaddr = tile->data = (char *)
shmat(shminfo_tile.shmid, 0, 0);
shminfo_tile.readOnly = False;
XShmAttach(dpy, &shminfo_tile);
XShmAttach(dpy, &shminfo_tile);
}
else {
int tlen = tileWidth*(bitsPerPixel/8);
void *data = malloc(tlen*tileHeight);
tile = XCreateImage(dpy,
DefaultVisual(dpy, 0),
bitsPerPixel,
ZPixmap,
0,
(char*)data,
tileWidth,
tileHeight,
8,
tlen);
}
tilesX = (width + tileWidth - 1) / tileWidth;
tilesY = (height + tileHeight - 1) / tileHeight;
@@ -99,38 +119,62 @@ XUpdateScanner::XUpdateScanner(Display *_dpy,
for (i = 0; i < tilesX * tilesY; i++)
tileMap[i] = false;
scanline = XShmCreateImage(dpy,
DefaultVisual(dpy, 0),
bitsPerPixel,
ZPixmap,
NULL,
&shminfo_scanline,
width,
1);
if (useShm) {
scanline = XShmCreateImage(dpy,
DefaultVisual(dpy, 0),
bitsPerPixel,
ZPixmap,
NULL,
&shminfo_scanline,
width,
1);
shminfo_scanline.shmid = shmget(IPC_PRIVATE,
scanline->bytes_per_line,
IPC_CREAT | 0777);
shminfo_scanline.shmaddr = scanline->data = (char *)
shmat( shminfo_scanline.shmid, 0, 0 );
shminfo_scanline.readOnly = False;
shminfo_scanline.shmid = shmget(IPC_PRIVATE,
scanline->bytes_per_line,
IPC_CREAT | 0777);
shminfo_scanline.shmaddr = scanline->data = (char *)
shmat( shminfo_scanline.shmid, 0, 0 );
shminfo_scanline.readOnly = False;
XShmAttach(dpy, &shminfo_scanline);
XShmAttach(dpy, &shminfo_scanline);
}
else {
int slen = width*(bitsPerPixel/8);
void *data = malloc(slen);
scanline = XCreateImage(dpy,
DefaultVisual(dpy, 0),
bitsPerPixel,
ZPixmap,
0,
(char*)data,
width,
1,
8,
slen);
}
};
XUpdateScanner::~XUpdateScanner()
{
XShmDetach(dpy, &shminfo_scanline);
XDestroyImage(scanline);
shmdt(shminfo_scanline.shmaddr);
shmctl(shminfo_scanline.shmid, IPC_RMID, 0);
if (useShm) {
XShmDetach(dpy, &shminfo_scanline);
XDestroyImage(scanline);
shmdt(shminfo_scanline.shmaddr);
shmctl(shminfo_scanline.shmid, IPC_RMID, 0);
XShmDetach(dpy, &shminfo_tile);
XDestroyImage(tile);
shmdt(shminfo_tile.shmaddr);
shmctl(shminfo_tile.shmid, IPC_RMID, 0);
}
else {
free(tile->data);
free(scanline->data);
XDestroyImage(scanline);
XDestroyImage(tile);
}
delete tileMap;
delete tileRegionMap;
XShmDetach(dpy, &shminfo_tile);
XDestroyImage(tile);
shmdt(shminfo_tile.shmaddr);
shmctl(shminfo_tile.shmid, IPC_RMID, 0);
}
@@ -145,12 +189,17 @@ bool XUpdateScanner::copyTile(int x, int y, int tx, int ty)
if (maxHeight > tileHeight)
maxHeight = tileHeight;
if ((maxWidth == tileWidth) && (maxHeight == tileHeight)) {
XShmGetImage(dpy, window, tile, x, y, AllPlanes);
} else {
if (useShm) {
if ((maxWidth == tileWidth) && (maxHeight == tileHeight)) {
XShmGetImage(dpy, window, tile, x, y, AllPlanes);
} else {
XGetSubImage(dpy, window, x, y, maxWidth, maxHeight,
AllPlanes, ZPixmap, tile, 0, 0);
}
}
else
XGetSubImage(dpy, window, x, y, maxWidth, maxHeight,
AllPlanes, ZPixmap, tile, 0, 0);
}
unsigned int line;
int pixelsize = bitsPerPixel >> 3;
unsigned char *src = (unsigned char*) tile->data;
@@ -338,7 +387,11 @@ void XUpdateScanner::searchUpdates(QPtrList<Hint> &hintList)
y = scanlines[count];
while (y < height) {
XShmGetImage(dpy, window, scanline, 0, y, AllPlanes);
if (useShm)
XShmGetImage(dpy, window, scanline, 0, y, AllPlanes);
else
XGetSubImage(dpy, window, 0, y, width, 1,
AllPlanes, ZPixmap, scanline, 0, 0);
x = 0;
while (x < width) {
int pixelsize = bitsPerPixel >> 3;

View File

@@ -93,6 +93,7 @@ class XUpdateScanner
int bitsPerPixel, bytesPerLine;
unsigned int tileWidth, tileHeight;
unsigned int count;
bool useShm;
XImage *scanline;
XShmSegmentInfo shminfo_scanline;

View File

@@ -552,7 +552,7 @@ int main(int argc,char *argv[])
for(i=argc-1;i>0;i--)
#ifdef LOCAL_CONTROL
if(i<argc-1 && !strcmp(argv[i],"-toggleviewonly")) {
sprintf(message,"t%s",argv[i+1]);
snprintf(message, sizeof(message), "t%s",argv[i+1]);
send_message(&single_instance,message);
exit(0);
} else if(!strcmp(argv[i],"-listclients")) {
@@ -562,7 +562,7 @@ int main(int argc,char *argv[])
} else
#ifdef BACKCHANNEL
if(i<argc-1 && !strcmp(argv[i],"-backchannel")) {
sprintf(message,"b%s",argv[i+1]);
snprintf(message, sizeof(message), "b%s",argv[i+1]);
send_message(&single_instance,message);
exit(0);
} else

View File

@@ -35,6 +35,9 @@ typedef int socklen_t;
#include "rfb.h"
#include "sraRegion.h"
/* minimum interval between attempts to send something */
#define PING_MS 10000
MUTEX(logMutex);
int rfbEnableLogging=1;
@@ -257,11 +260,13 @@ clientOutput(void *data)
UNLOCK(cl->updateMutex);
if (!haveUpdate) {
WAIT(cl->updateCond, cl->updateMutex);
TIMEDWAIT(cl->updateCond, cl->updateMutex, PING_MS);
UNLOCK(cl->updateMutex); /* we really needn't lock now. */
if (!haveUpdate)
rfbSendPing(cl);
}
}
/* OK, now, to save bandwidth, wait a little while for more
updates to come along. */
usleep(cl->screen->rfbDeferUpdateTime * 1000);

View File

@@ -65,8 +65,12 @@ typedef unsigned long KeySym;
#elif defined(__APPLE__) || defined(__FreeBSD__)
#include <sys/types.h>
#include <machine/endian.h>
#ifndef _BYTE_ORDER
#define _BYTE_ORDER BYTE_ORDER
#endif
#ifndef _LITTLE_ENDIAN
#define _LITTLE_ENDIAN LITTLE_ENDIAN
#endif
#elif defined (__SVR4) && defined (__sun) /* Solaris */
#include <sys/types.h>
#if defined(__sparc)
@@ -147,6 +151,10 @@ typedef unsigned long KeySym;
#define TINI_MUTEX(mutex) pthread_mutex_destroy(&(mutex))
#define TSIGNAL(cond) pthread_cond_signal(&(cond))
#define WAIT(cond,mutex) pthread_cond_wait(&(cond),&(mutex))
#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);}
#define COND(cond) pthread_cond_t (cond)
#define INIT_COND(cond) pthread_cond_init(&(cond),NULL)
#define TINI_COND(cond) pthread_cond_destroy(&(cond))
@@ -616,6 +624,7 @@ extern void rfbProcessClientMessage(rfbClientPtr cl);
extern void rfbClientConnFailed(rfbClientPtr cl, char *reason);
extern void rfbNewUDPConnection(rfbScreenInfoPtr rfbScreen,int sock);
extern void rfbProcessUDPInput(rfbScreenInfoPtr rfbScreen);
extern Bool rfbSendPing(rfbClientPtr cl);
extern Bool rfbSendFramebufferUpdate(rfbClientPtr cl, sraRegionPtr updateRegion);
extern Bool rfbSendRectEncodingRaw(rfbClientPtr cl, int x,int y,int w,int h);
extern Bool rfbSendUpdateBuf(rfbClientPtr cl);

View File

@@ -721,6 +721,8 @@ rfbProcessClientNormalMessage(cl)
}
break;
case rfbEncodingXCursor:
if (cl->enableSoftCursorUpdates)
break;
if(!cl->screen->dontConvertRichCursorToXCursor) {
rfbLog("Enabling X-style cursor updates for client %s\n",
cl->host);
@@ -731,9 +733,11 @@ rfbProcessClientNormalMessage(cl)
case rfbEncodingRichCursor:
rfbLog("Enabling full-color cursor updates for client "
"%s\n", cl->host);
cl->enableCursorShapeUpdates = TRUE;
cl->useRichCursorEncoding = TRUE;
cl->cursorWasChanged = TRUE;
if (cl->enableSoftCursorUpdates)
break;
cl->enableCursorShapeUpdates = TRUE;
cl->useRichCursorEncoding = TRUE;
cl->cursorWasChanged = TRUE;
break;
case rfbEncodingSoftCursor:
rfbLog("Enabling soft cursor updates for client "
@@ -741,6 +745,8 @@ rfbProcessClientNormalMessage(cl)
cl->enableSoftCursorUpdates = TRUE;
cl->cursorWasChanged = TRUE;
cl->cursorWasMoved = TRUE;
cl->enableCursorShapeUpdates = FALSE;
cl->useRichCursorEncoding = FALSE;
break;
case rfbEncodingLastRect:
if (!cl->enableLastRectEncoding) {
@@ -909,6 +915,22 @@ rfbProcessClientNormalMessage(cl)
}
/*
* rfbSendPing - send an empty framebuffer request
*/
Bool
rfbSendPing(cl)
rfbClientPtr cl;
{
rfbFramebufferUpdateMsg *fu = (rfbFramebufferUpdateMsg *)cl->updateBuf;
cl->rfbFramebufferUpdateMessagesSent++;
fu->type = rfbFramebufferUpdate;
fu->nRects = Swap16IfLE((CARD16)0);
cl->ublen = sz_rfbFramebufferUpdateMsg;
return TRUE;
}
/*
* rfbSendFramebufferUpdate - send the currently pending framebuffer update to

View File

@@ -369,7 +369,8 @@ rfbConnect(rfbScreen, host, port)
/*
* ReadExact reads an exact number of bytes from a client. Returns 1 if
* those bytes have been read, 0 if the other end has closed, or -1 if an error
* occurred (errno is set to ETIMEDOUT if it timed out).
* occurred (errno is set to ETIMEDOUT if it timed out).
* timeout is the timeout in ms, 0 for no timeout.
*/
int
@@ -379,6 +380,9 @@ ReadExactTimeout(rfbClientPtr cl, char* buf, int len, int timeout)
int n;
fd_set fds;
struct timeval tv;
int to = 20000;
if (timeout)
to = timeout;
while (len > 0) {
n = read(sock, buf, len);
@@ -402,14 +406,14 @@ ReadExactTimeout(rfbClientPtr cl, char* buf, int len, int timeout)
FD_ZERO(&fds);
FD_SET(sock, &fds);
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
tv.tv_sec = to / 1000;
tv.tv_usec = (to % 1000) * 1000;
n = select(sock+1, &fds, NULL, &fds, &tv);
if (n < 0) {
rfbLogPerror("ReadExact: select");
return n;
}
if (n == 0) {
if ((n == 0) && timeout) {
errno = ETIMEDOUT;
return -1;
}
@@ -420,7 +424,7 @@ ReadExactTimeout(rfbClientPtr cl, char* buf, int len, int timeout)
int ReadExact(rfbClientPtr cl,char* buf,int len)
{
return(ReadExactTimeout(cl,buf,len,rfbMaxClientWait));
return ReadExactTimeout(cl, buf, len, 0);
}
/*

View File

@@ -83,8 +83,7 @@ void
sraSpanCheck(const sraSpan *span, const char *text) {
/* Check the span is valid! */
if (span->start == span->end) {
printf(text);
printf(":%d-%d\n", span->start, span->end);
printf("%s:%d-%d\n", text, span->start, span->end);
exit(0);
}
}

View File

@@ -338,7 +338,7 @@ int main(int argc,char** argv)
for(i=argc-1;i>0;i--)
#ifdef LOCAL_CONTROL
if(i<argc-1 && !strcmp(argv[i],"-toggleviewonly")) {
sprintf(message,"t%s",argv[i+1]);
snprintf(message, sizeof(message), "t%s",argv[i+1]);
send_message(&single_instance,message);
exit(0);
} else if(!strcmp(argv[i],"-listclients")) {
@@ -348,7 +348,7 @@ int main(int argc,char** argv)
} else
#ifdef BACKCHANNEL
if(i<argc-1 && !strcmp(argv[i],"-backchannel")) {
sprintf(message,"b%s",argv[i+1]);
snprintf(message, sizeof(message), "b%s",argv[i+1]);
send_message(&single_instance,message);
exit(0);
} else

View File

@@ -34,6 +34,10 @@
#include "kinetaddr.h"
#include <netdb.h>
#ifdef sun
#include <sys/socket.h>
#endif
#if defined(__osf__) && defined(AF_INET6)
#undef AF_INET6
#endif
@@ -125,19 +129,21 @@ const struct in_addr *KInetAddress::addressV4() const {
return &d->in;
}
#ifdef AF_INET6
const struct in6_addr *KInetAddress::addressV6() const {
#ifdef AF_INET6
if (d->sockfamily != AF_INET6)
return 0;
return &d->in6;
}
#else
return 0;
#endif
}
QString KInetAddress::nodeName() const
{
char buf[INET6_ADDRSTRLEN+1]; // INET6_ADDRSTRLEN > INET_ADDRSTRLEN
#ifdef __osf__
#ifdef __osf__ || defined(sun)
if (d->sockfamily == AF_INET) {
char *p = inet_ntoa(d->in);
strncpy(buf, p, sizeof(buf));

View File

@@ -114,14 +114,16 @@ public:
* This will be NULL if this is not a v6 address.
* @see addressV4
*/
#ifdef AF_INET6
const struct in6_addr* addressV6() const;
#endif
operator const struct in_addr*() const
{ return addressV4(); }
#ifdef AF_INET6
operator const struct in6_addr*() const
{ return addressV6(); }
#endif
/**
* Returns an address that can be used for communication with
* other computers on the internet.

View File

@@ -61,8 +61,8 @@
#endif
static char *local_address = NULL;
static char *inet_address = NULL;
static const char *local_address = NULL;
static const char *inet_address = NULL;
/* max number of network interfaces*/
#define MAX_IF 8
@@ -85,7 +85,8 @@ char *getdefaultdev()
FILE *fp = fopen( PROCROUTE, "r");
char buff[4096], gate_addr[128], net_addr[128];
char mask_addr[128];
int irtt, window, mss, num, metric, iflags, refcnt, use;
int irtt, window, mss, num, metric, refcnt, use;
unsigned int iflags;
char i;
if( !fp ) {
return NULL;
@@ -93,9 +94,9 @@ char *getdefaultdev()
i=0;
// cruise through the list, and find the gateway interface
while( fgets(buff, 1023, fp) ) {
num = sscanf(buff, "%s %s %s %X %d %d %d %s %d %d %d\n",
num = sscanf(buff, "%15s %127s %127s %X %d %d %d %127s %d %d %d\n",
iface, net_addr, gate_addr, &iflags, &refcnt, &use, &metric,
&mask_addr, &mss, &window, &irtt);
mask_addr, &mss, &window, &irtt);
i++;
if( i == 1) continue;