// 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),
forceNonincremental(true), supportsSyncFence(false)
{
setShared(::shared);
+ sock = socket;
int encNum = encodingNum(preferredEncoding);
if (encNum != -1)
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);
public rdr::FdInStreamBlockCallback
{
public:
- CConn(const char* vncServerName);
+ CConn(const char* vncServerName, network::Socket* sock);
~CConn();
void refreshFramebuffer();
"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. "
extern rfb::StringParameter geometry;
extern rfb::BoolParameter remoteResize;
+extern rfb::BoolParameter listenMode;
+
extern rfb::BoolParameter viewOnly;
extern rfb::BoolParameter shared;
#include <string.h>
#include <stdio.h>
+#include <ctype.h>
#include <stdlib.h>
#include <errno.h>
#include <signal.h>
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;