summaryrefslogtreecommitdiffstats
path: root/libvncserver/rfbserver.c
diff options
context:
space:
mode:
authordscho <dscho>2005-09-27 15:18:22 +0000
committerdscho <dscho>2005-09-27 15:18:22 +0000
commit93be927b1c1c74bc4da6f6d5978ba8e6e52f3cc2 (patch)
tree0ec66825e92a2cf60e0f32b7ab74bc5777318bd6 /libvncserver/rfbserver.c
parent94fcd86cc20dd2ccf7e2299a7dfbcc255c6cc771 (diff)
downloadlibtdevnc-93be927b1c1c74bc4da6f6d5978ba8e6e52f3cc2.tar.gz
libtdevnc-93be927b1c1c74bc4da6f6d5978ba8e6e52f3cc2.zip
Introduce generic protocol extension method. Deprecate
the processCustomClientMessage() method.
Diffstat (limited to 'libvncserver/rfbserver.c')
-rw-r--r--libvncserver/rfbserver.c43
1 files changed, 36 insertions, 7 deletions
diff --git a/libvncserver/rfbserver.c b/libvncserver/rfbserver.c
index 1f71a18..730c789 100644
--- a/libvncserver/rfbserver.c
+++ b/libvncserver/rfbserver.c
@@ -3,6 +3,7 @@
*/
/*
+ * Copyright (C) 2005 Rohit Kumar, Johannes E. Schindelin
* Copyright (C) 2002 RealVNC Ltd.
* OSXvnc Copyright (C) 2001 Dan McGuirk <mcguirk@incompleteness.net>.
* Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge.
@@ -347,6 +348,8 @@ rfbNewTCPOrUDPClient(rfbScreenInfoPtr rfbScreen,
cl->progressiveSliceY = 0;
+ cl->extensions = NULL;
+
sprintf(pv,rfbProtocolVersionFormat,rfbProtocolMajorVersion,
rfbProtocolMinorVersion);
@@ -603,6 +606,7 @@ rfbProcessClientInitMessage(rfbClientPtr cl)
int len, n;
rfbClientIteratorPtr iterator;
rfbClientPtr otherCl;
+ rfbProtocolExtension* extension;
if ((n = rfbReadExact(cl, (char *)&ci,sz_rfbClientInitMsg)) <= 0) {
if (n == 0)
@@ -613,7 +617,7 @@ rfbProcessClientInitMessage(rfbClientPtr cl)
return;
}
- memset(buf,0,256);
+ memset(buf,0,sizeof(buf));
si->framebufferWidth = Swap16IfLE(cl->screen->width);
si->framebufferHeight = Swap16IfLE(cl->screen->height);
@@ -632,6 +636,19 @@ rfbProcessClientInitMessage(rfbClientPtr cl)
return;
}
+ for(extension=rfbGetExtensionIterator();extension;extension=extension->next)
+ if(extension->init) {
+ void* data;
+ if(extension->init(cl, &data)) {
+ rfbExtensionData* extensionData=calloc(sizeof(rfbExtensionData),1);
+ extensionData->extension=extension;
+ extensionData->data=data;
+ extensionData->next=cl->extensions;
+ cl->extensions=extensionData;
+ }
+ }
+ rfbReleaseExtensionIterator();
+
cl->state = RFB_NORMAL;
if (!cl->reverseConnection &&
@@ -1046,15 +1063,27 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)
default:
+ {
+ rfbExtensionData* extension;
+
+ for(extension=cl->extensions; extension; extension=extension->next)
+ if(extension->extension->handleMessage &&
+ extension->extension->handleMessage(cl, extension->data, msg))
+ return;
- if(cl->screen->processCustomClientMessage(cl,msg.type))
+ if(cl->screen->processCustomClientMessage(cl,msg.type)) {
+ rfbLog("Warning: this program uses processCustomClientMessage, "
+ "which is deprecated.\n"
+ "Please use rfbRegisterProtocolExtension instead.\n");
return;
+ }
- rfbLog("rfbProcessClientNormalMessage: unknown message type %d\n",
- msg.type);
- rfbLog(" ... closing connection\n");
- rfbCloseClient(cl);
- return;
+ rfbLog("rfbProcessClientNormalMessage: unknown message type %d\n",
+ msg.type);
+ rfbLog(" ... closing connection\n");
+ rfbCloseClient(cl);
+ return;
+ }
}
}