Browse Source

Reimplement -listen in the new FLTK vncviewer. Work done by

Justina Mickonyte for Cendio.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@5041 3789f03b-4d11-0410-bbf8-ca57d06f2519
tags/v1.2.90
Pierre Ossman 11 years ago
parent
commit
2a7a8d60c8
5 changed files with 51 additions and 21 deletions
  1. 15
    12
      vncviewer/CConn.cxx
  2. 1
    1
      vncviewer/CConn.h
  3. 3
    0
      vncviewer/parameters.cxx
  4. 2
    0
      vncviewer/parameters.h
  5. 30
    8
      vncviewer/vncviewer.cxx

+ 15
- 12
vncviewer/CConn.cxx View File

@@ -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);

+ 1
- 1
vncviewer/CConn.h View File

@@ -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();

+ 3
- 0
vncviewer/parameters.cxx View File

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

+ 2
- 0
vncviewer/parameters.h View File

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


+ 30
- 8
vncviewer/vncviewer.cxx View File

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

Loading…
Cancel
Save