Justina Mickonyte for Cendio. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@5041 3789f03b-4d11-0410-bbf8-ca57d06f2519tags/v1.2.90
@@ -67,8 +67,8 @@ static const PixelFormat lowColourPF(8, 6, false, true, | |||
// 256 colours (palette) | |||
static const PixelFormat mediumColourPF(8, 8, false, false); | |||
CConn::CConn(const char* vncServerName) | |||
: serverHost(0), serverPort(0), sock(NULL), desktop(NULL), | |||
CConn::CConn(const char* vncServerName, network::Socket* socket=NULL) | |||
: serverHost(0), serverPort(0), desktop(NULL), | |||
pendingPFChange(false), | |||
currentEncoding(encodingTight), lastServerEncoding((unsigned int)-1), | |||
formatChange(false), encodingChange(false), | |||
@@ -76,6 +76,7 @@ CConn::CConn(const char* vncServerName) | |||
forceNonincremental(true), supportsSyncFence(false) | |||
{ | |||
setShared(::shared); | |||
sock = socket; | |||
int encNum = encodingNum(preferredEncoding); | |||
if (encNum != -1) | |||
@@ -93,16 +94,18 @@ CConn::CConn(const char* vncServerName) | |||
cp.noJpeg = noJpeg; | |||
cp.qualityLevel = qualityLevel; | |||
try { | |||
getHostAndPort(vncServerName, &serverHost, &serverPort); | |||
sock = new network::TcpSocket(serverHost, serverPort); | |||
vlog.info(_("connected to host %s port %d"), serverHost, serverPort); | |||
} catch (rdr::Exception& e) { | |||
vlog.error("%s", e.str()); | |||
fl_alert("%s", e.str()); | |||
exit_vncviewer(); | |||
return; | |||
if(sock == NULL) { | |||
try { | |||
getHostAndPort(vncServerName, &serverHost, &serverPort); | |||
sock = new network::TcpSocket(serverHost, serverPort); | |||
vlog.info(_("connected to host %s port %d"), serverHost, serverPort); | |||
} catch (rdr::Exception& e) { | |||
vlog.error("%s", e.str()); | |||
fl_alert("%s", e.str()); | |||
exit_vncviewer(); | |||
return; | |||
} | |||
} | |||
Fl::add_fd(sock->getFd(), FL_READ | FL_EXCEPT, socketEvent, this); |
@@ -29,7 +29,7 @@ class CConn : public rfb::CConnection, | |||
public rdr::FdInStreamBlockCallback | |||
{ | |||
public: | |||
CConn(const char* vncServerName); | |||
CConn(const char* vncServerName, network::Socket* sock); | |||
~CConn(); | |||
void refreshFramebuffer(); |
@@ -102,6 +102,9 @@ StringParameter desktopSize("DesktopSize", | |||
"connect (if possible)", ""); | |||
StringParameter geometry("geometry", | |||
"Specify size and position of viewer window", ""); | |||
BoolParameter listenMode("listen", "Listen for connections from VNC servers", false); | |||
BoolParameter remoteResize("RemoteResize", | |||
"Dynamically resize the remote desktop size as " | |||
"the size of the local client window changes. " |
@@ -49,6 +49,8 @@ extern rfb::StringParameter desktopSize; | |||
extern rfb::StringParameter geometry; | |||
extern rfb::BoolParameter remoteResize; | |||
extern rfb::BoolParameter listenMode; | |||
extern rfb::BoolParameter viewOnly; | |||
extern rfb::BoolParameter shared; | |||
@@ -24,6 +24,7 @@ | |||
#include <string.h> | |||
#include <stdio.h> | |||
#include <ctype.h> | |||
#include <stdlib.h> | |||
#include <errno.h> | |||
#include <signal.h> | |||
@@ -441,18 +442,39 @@ int main(int argc, char** argv) | |||
CSecurityTLS::msg = &dlg; | |||
#endif | |||
if (vncServerName[0] == '\0') { | |||
ServerDialog::run(defaultServerName, vncServerName); | |||
if (vncServerName[0] == '\0') | |||
return 1; | |||
} | |||
Socket *sock = NULL; | |||
if(listenMode) { | |||
try { | |||
int port = 5500; | |||
if (isdigit(vncServerName[0])) | |||
port = atoi(vncServerName); | |||
TcpListener listener(NULL, port); | |||
vlog.info("Listening on port %d\n", port); | |||
sock = listener.accept(); | |||
} catch (rdr::Exception& e) { | |||
vlog.error("%s", e.str()); | |||
fl_alert("%s", e.str()); | |||
exit_vncviewer(); | |||
return 1; | |||
} | |||
} else { | |||
if (vncServerName[0] == '\0') { | |||
ServerDialog::run(defaultServerName, vncServerName); | |||
if (vncServerName[0] == '\0') | |||
return 1; | |||
} | |||
#ifndef WIN32 | |||
if (strlen (via.getValueStr()) > 0 && mktunnel() != 0) | |||
usage(argv[0]); | |||
if (strlen (via.getValueStr()) > 0 && mktunnel() != 0) | |||
usage(argv[0]); | |||
#endif | |||
} | |||
CConn *cc = new CConn(vncServerName); | |||
CConn *cc = new CConn(vncServerName, sock); | |||
while (!exitMainloop) { | |||
int next_timer; |