Commit 59c6af95 authored by llyzs's avatar llyzs Committed by llyzs

Merge the latest libvncserver codes

git-svn-id: https://remmina.svn.sourceforge.net/svnroot/remmina/trunk@23 b6cfa94a-2857-405c-b0d6-536ef9fc39e1
parent 23e9fa1b
......@@ -135,7 +135,6 @@ AC_CHECK_LIB(pthread, pthread_create, [
])
# Check LibVNCClient
AX_PREFIX_CONFIG_H([libvncserver/rfb/rfbconfig.h], [LIBVNCSERVER])
AC_ARG_ENABLE(vnc,
[AS_HELP_STRING([--disable-vnc], [Disable VNC])],
[vnc_support=$enableval],
......@@ -146,7 +145,9 @@ if test "x$vnc_support" != "xno"; then
AC_CHECK_LIB(vncclient, rfbGetClient, [
AC_CHECK_HEADER(rfb/rfbclient.h, [
vnc_support="link to libvncclient externally"
VNC_CFLAGS=""
VNC_LIBS="-lvncclient"
AC_SUBST(VNC_CFLAGS)
AC_SUBST(VNC_LIBS)
AC_DEFINE([HAVE_LIBVNCCLIENT], [1], [Define to 1 if you have libvncclient.])
], vnc_support="no. libvncclient(libvncserver)-dev required.")
......@@ -175,10 +176,13 @@ if test "x$vnc_support" = "x"; then
PKG_CHECK_MODULES(GNUTLS, gnutls >= 2.8.0, , vnc_support="no. libgnutls-dev required.")
fi
if test "x$vnc_support" = "x"; then
AX_PREFIX_CONFIG_H([libvncserver/rfb/rfbconfig.h], [LIBVNCSERVER])
remmina_pkgs="$remmina_pkgs gnutls"
LIBS="-ljpeg -lz $LIBS"
REMMINA_SUBDIRS="libvncserver $REMMINA_SUBDIRS"
VNC_CFLAGS="-I../libvncserver"
VNC_LIBS="../libvncserver/libvncclient.la"
AC_SUBST(VNC_CFLAGS)
AC_SUBST(VNC_LIBS)
AC_SUBST(GNUTLS_CFLAGS)
AC_SUBST(GNUTLS_LIBS)
......
......@@ -27,6 +27,7 @@
#include <unistd.h>
#include <sys/types.h>
#ifdef __MINGW32__
#define close closesocket
#include <winsock2.h>
#else
#include <sys/wait.h>
......@@ -108,3 +109,59 @@ listenForIncomingConnections(rfbClient* client)
}
/*
* listenForIncomingConnectionsNoFork() - listen for incoming connections
* from servers, but DON'T fork, instead just wait timeout microseconds.
* If timeout is negative, block indefinitly.
*/
rfbBool
listenForIncomingConnectionsNoFork(rfbClient* client, int timeout)
{
fd_set fds;
struct timeval to;
to.tv_sec= timeout / 1000000;
to.tv_usec= timeout % 1000000;
client->listenSpecified = TRUE;
if (! client->listenSock)
{
client->listenSock = ListenAtTcpPort(client->listenPort);
if (client->listenSock < 0)
return FALSE;
rfbClientLog("%s -listennofork: Listening on port %d\n",
client->programName,client->listenPort);
rfbClientLog("%s -listennofork: Command line errors are not reported until "
"a connection comes in.\n", client->programName);
}
FD_ZERO(&fds);
FD_SET(client->listenSock, &fds);
if (timeout < 0)
select(FD_SETSIZE, &fds, NULL, NULL, NULL);
else
select(FD_SETSIZE, &fds, NULL, NULL, &to);
if (FD_ISSET(client->listenSock, &fds))
{
client->sock = AcceptTcpConnection(client->listenSock);
if (client->sock < 0)
return FALSE;
if (!SetNonBlocking(client->sock))
return FALSE;
close(client->listenSock);
return TRUE;
}
return FALSE;
}
......@@ -75,7 +75,7 @@ rfbDefaultClientLog(const char *format, ...)
time(&log_clock);
strftime(buf, 255, "%d/%m/%Y %X ", localtime(&log_clock));
fprintf(stderr,buf);
fprintf(stderr, "%s", buf);
vfprintf(stderr, format, args);
fflush(stderr);
......@@ -345,6 +345,7 @@ DefaultSupportedMessagesTightVNC(rfbClient* client)
SetServer2Client(client, rfbTextChat);
}
#ifndef WIN32
static rfbBool
IsUnixSocket(const char *name)
{
......@@ -353,6 +354,7 @@ IsUnixSocket(const char *name)
return TRUE;
return FALSE;
}
#endif
/*
* ConnectToRFBServer.
......@@ -679,6 +681,8 @@ HandleMSLogonAuth(rfbClient *client)
rfbClientLog("GetCredential callback is not set.\n");
return FALSE;
}
rfbClientLog("WARNING! MSLogon security type has very low password encryption! "\
"Use it only with SSH tunnel or trusted network.\n");
cred = client->GetCredential(client, rfbCredentialTypeUser);
if (!cred)
{
......@@ -1781,6 +1785,9 @@ HandleRFBServerMessage(rfbClient* client)
if (!SendIncrementalFramebufferUpdateRequest(client))
return FALSE;
if (client->FinishedFrameBufferUpdate)
client->FinishedFrameBufferUpdate(client);
break;
}
......
......@@ -30,6 +30,7 @@
#include <assert.h>
#include <rfb/rfbclient.h>
#ifdef WIN32
#undef SOCKET
#include <winsock2.h>
#define EWOULDBLOCK WSAEWOULDBLOCK
#define close closesocket
......@@ -274,29 +275,36 @@ WriteToRFBServer(rfbClient* client, char *buf, int n)
}
/*
* ConnectToTcpAddr connects to the given TCP port.
*/
int
ConnectClientToTcpAddr(unsigned int host, int port)
{
int sock;
struct sockaddr_in addr;
int one = 1;
static int initSockets() {
#ifdef WIN32
WSADATA trash;
static rfbBool WSAinitted=FALSE;
if(!WSAinitted) {
WSAinitted=TRUE;
int i=WSAStartup(MAKEWORD(2,0),&trash);
if(i!=0) {
rfbClientErr("Couldn't init Windows Sockets\n");
return -1;
return 0;
}
WSAinitted=TRUE;
}
#endif
return 1;
}
/*
* ConnectToTcpAddr connects to the given TCP port.
*/
int
ConnectClientToTcpAddr(unsigned int host, int port)
{
int sock;
struct sockaddr_in addr;
int one = 1;
if (!initSockets())
return -1;
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
......@@ -371,6 +379,9 @@ FindFreeTcpPort(void)
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_ANY);
if (!initSockets())
return -1;
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
rfbClientErr(": FindFreeTcpPort: socket\n");
......@@ -405,6 +416,9 @@ ListenAtTcpPort(int port)
addr.sin_port = htons(port);
addr.sin_addr.s_addr = htonl(INADDR_ANY);
if (!initSockets())
return -1;
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
rfbClientErr("ListenAtTcpPort: socket\n");
......@@ -492,7 +506,7 @@ StringToIPAddr(const char *str, unsigned int *addr)
struct hostent *hp;
if (strcmp(str,"") == 0) {
*addr = 0; /* local */
*addr = htonl(INADDR_LOOPBACK); /* local */
return TRUE;
}
......@@ -501,6 +515,9 @@ StringToIPAddr(const char *str, unsigned int *addr)
if (*addr != -1)
return TRUE;
if (!initSockets())
return -1;
hp = gethostbyname(str);
if (hp) {
......
......@@ -44,6 +44,7 @@ static void DummyRect(rfbClient* client, int x, int y, int w, int h) {
static char* NoPassword(rfbClient* client) {
return strdup("");
}
#define close closesocket
#else
#include <stdio.h>
#include <termios.h>
......@@ -174,6 +175,7 @@ rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel,
client->SoftCursorLockArea = DummyRect;
client->SoftCursorUnlockScreen = Dummy;
client->GotFrameBufferUpdate = DummyRect;
client->FinishedFrameBufferUpdate = NULL;
client->GetPassword = ReadPassword;
client->MallocFrameBuffer = MallocFrameBuffer;
client->Bell = Dummy;
......@@ -254,6 +256,9 @@ rfbBool rfbInitClient(rfbClient* client,int* argc,char** argv) {
if (strcmp(argv[i], "-listen") == 0) {
listenForIncomingConnections(client);
break;
} else if (strcmp(argv[i], "-listennofork") == 0) {
listenForIncomingConnectionsNoFork(client, -1);
break;
} else if (strcmp(argv[i], "-play") == 0) {
client->serverPort = -1;
j++;
......
......@@ -141,6 +141,7 @@ typedef rfbBool (*HandleCursorPosProc)(struct _rfbClient* client, int x, int y);
typedef void (*SoftCursorLockAreaProc)(struct _rfbClient* client, int x, int y, int w, int h);
typedef void (*SoftCursorUnlockScreenProc)(struct _rfbClient* client);
typedef void (*GotFrameBufferUpdateProc)(struct _rfbClient* client, int x, int y, int w, int h);
typedef void (*FinishedFrameBufferUpdateProc)(struct _rfbClient* client);
typedef char* (*GetPasswordProc)(struct _rfbClient* client);
typedef rfbCredential* (*GetCredentialProc)(struct _rfbClient* client, int credentialType);
typedef rfbBool (*MallocFrameBufferProc)(struct _rfbClient* client);
......@@ -185,6 +186,9 @@ typedef struct _rfbClient {
rfbPixelFormat format;
rfbServerInitMsg si;
/* listen.c */
int listenSock;
/* sockets.c */
#define RFB_BUF_SIZE 8192
char buf[RFB_BUF_SIZE];
......@@ -263,6 +267,7 @@ typedef struct _rfbClient {
SoftCursorLockAreaProc SoftCursorLockArea;
SoftCursorUnlockScreenProc SoftCursorUnlockScreen;
GotFrameBufferUpdateProc GotFrameBufferUpdate;
FinishedFrameBufferUpdateProc FinishedFrameBufferUpdate;
/* the pointer returned by GetPassword will be freed after use! */
GetPasswordProc GetPassword;
MallocFrameBufferProc MallocFrameBuffer;
......@@ -309,6 +314,7 @@ extern rfbBool HandleCursorShape(rfbClient* client,int xhot, int yhot, int width
/* listen.c */
extern void listenForIncomingConnections(rfbClient* viewer);
extern rfbBool listenForIncomingConnectionsNoFork(rfbClient* viewer, int usec_timeout);
/* rfbproto.c */
......
......@@ -2,7 +2,7 @@
#define _RFB_RFBINT_H 1
#ifndef _GENERATED_STDINT_H
#define _GENERATED_STDINT_H "LibVNCServer 0.9.7"
/* generated using a gnu compiler version gcc (Debian 4.3.4-2) 4.3.4 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */
/* generated using a gnu compiler version gcc (Debian 4.3.4-5) 4.3.4 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */
#include <stdint.h>
......
## Process this file with automake to produce Makefile.in
bin_PROGRAMS = remmina
INCLUDES = @REMMINA_CFLAGS@ @LIBGCRYPT_CFLAGS@ \
-I$(top_builddir)/libvncserver \
INCLUDES = @REMMINA_CFLAGS@ @LIBGCRYPT_CFLAGS@ @VNC_CFLAGS@ \
-DREMMINA_LOCALEDIR=\"$(remmina_localedir)\" \
-DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
-DREMMINA_DATADIR=\"$(pkgdatadir)\"
......
......@@ -280,10 +280,6 @@ typedef struct _RemminaKeyVal
/***************************** LibVNCClient related codes *********************************/
#include <rfb/rfbclient.h>
/* same as SupportsClient2Server */
#define rfbSupportsClient2Server(client,messageType) \
((client)->supportedMessages.client2server[((messageType & 0xFF)/8)] & (1<<(messageType % 8)))
static void
remmina_plug_vnc_process_vnc_event (RemminaPlugVnc *gp_vnc)
{
......@@ -1522,8 +1518,6 @@ remmina_plug_vnc_open_connection (RemminaPlug *gp)
static gboolean
remmina_plug_vnc_close_connection_timeout (RemminaPlugVnc *gp_vnc)
{
gint sock;
/* wait until the running attribute is set to false by the VNC thread */
if (gp_vnc->running) return TRUE;
......@@ -1556,11 +1550,6 @@ remmina_plug_vnc_close_connection_timeout (RemminaPlugVnc *gp_vnc)
}
if (gp_vnc->client)
{
sock = ((rfbClient*) gp_vnc->client)->sock;
if (sock >= 0)
{
close (sock);
}
rfbClientCleanup((rfbClient*) gp_vnc->client);
gp_vnc->client = NULL;
}
......@@ -1632,10 +1621,10 @@ remmina_plug_vnc_query_feature (RemminaPlug *gp, RemminaPlugFeature feature)
case REMMINA_PLUG_FEATURE_SCALE:
return GINT_TO_POINTER (1);
case REMMINA_PLUG_FEATURE_PREF_DISABLESERVERINPUT:
return (rfbSupportsClient2Server ((rfbClient*) (REMMINA_PLUG_VNC (gp)->client), rfbSetServerInput) ?
return (SupportsClient2Server ((rfbClient*) (REMMINA_PLUG_VNC (gp)->client), rfbSetServerInput) ?
GINT_TO_POINTER (1) : NULL);
case REMMINA_PLUG_FEATURE_TOOL_CHAT:
return (rfbSupportsClient2Server ((rfbClient*) (REMMINA_PLUG_VNC (gp)->client), rfbTextChat) ?
return (SupportsClient2Server ((rfbClient*) (REMMINA_PLUG_VNC (gp)->client), rfbTextChat) ?
GINT_TO_POINTER (1) : NULL);
default:
return NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment