aboutsummaryrefslogtreecommitdiffstats
path: root/vncviewer/vncviewer.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vncviewer/vncviewer.cxx')
-rw-r--r--vncviewer/vncviewer.cxx158
1 files changed, 82 insertions, 76 deletions
diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx
index 4efe6e93..324ec632 100644
--- a/vncviewer/vncviewer.cxx
+++ b/vncviewer/vncviewer.cxx
@@ -35,7 +35,7 @@
#include <sys/stat.h>
#ifdef WIN32
-#include <os/winerrno.h>
+#include <core/winerrno.h>
#include <direct.h>
#endif
@@ -48,16 +48,18 @@
#include <X11/XKBlib.h>
#endif
-#include <rfb/Logger_stdio.h>
+#include <core/Exception.h>
+#include <core/Logger_stdio.h>
+#include <core/LogWriter.h>
+#include <core/Timer.h>
+
#ifdef HAVE_GNUTLS
#include <rfb/CSecurityTLS.h>
#endif
-#include <rfb/Hostname.h>
-#include <rfb/LogWriter.h>
-#include <rfb/Timer.h>
-#include <rdr/Exception.h>
+
+#include <core/xdgdirs.h>
+
#include <network/TcpSocket.h>
-#include <os/os.h>
#include <FL/Fl_PNG_Image.H>
#include <FL/Fl_Sys_Menu_Bar.H>
@@ -79,10 +81,7 @@
#include "win32.h"
#endif
-static rfb::LogWriter vlog("main");
-
-using namespace network;
-using namespace rfb;
+static core::LogWriter vlog("main");
char vncServerName[VNCSERVERNAMELEN] = { '\0' };
@@ -101,11 +100,11 @@ static const char *about_text()
// encodings, so we need to make sure we get a fresh string every
// time.
snprintf(buffer, sizeof(buffer),
- _("TigerVNC viewer v%s\n"
+ _("TigerVNC v%s\n"
"Built on: %s\n"
"Copyright (C) 1999-%d TigerVNC team and many others (see README.rst)\n"
"See https://www.tigervnc.org for information on TigerVNC."),
- PACKAGE_VERSION, BUILD_TIMESTAMP, 2024);
+ PACKAGE_VERSION, BUILD_TIMESTAMP, 2025);
return buffer;
}
@@ -171,7 +170,7 @@ bool should_disconnect()
void about_vncviewer()
{
- fl_message_title(_("About TigerVNC Viewer"));
+ fl_message_title(_("About TigerVNC"));
fl_message("%s", about_text());
}
@@ -182,12 +181,13 @@ static void mainloop(const char* vncserver, network::Socket* sock)
exitMainloop = false;
- cc = new CConn(vncserver, sock);
+ cc = new CConn();
+ cc->connect(vncserver, sock);
while (!exitMainloop) {
int next_timer;
- next_timer = Timer::checkTimeouts();
+ next_timer = core::Timer::checkTimeouts();
if (next_timer < 0)
next_timer = INT_MAX;
@@ -242,7 +242,7 @@ static void new_connection_cb(Fl_Widget* /*widget*/, void* /*data*/)
pid = fork();
if (pid == -1) {
- vlog.error(_("Error starting new TigerVNC Viewer: %s"), strerror(errno));
+ vlog.error(_("Error starting new connection: %s"), strerror(errno));
return;
}
@@ -254,7 +254,7 @@ static void new_connection_cb(Fl_Widget* /*widget*/, void* /*data*/)
execvp(argv[0], (char * const *)argv);
- vlog.error(_("Error starting new TigerVNC Viewer: %s"), strerror(errno));
+ vlog.error(_("Error starting new connection: %s"), strerror(errno));
_exit(1);
}
#endif
@@ -263,7 +263,7 @@ static void CleanupSignalHandler(int sig)
{
// CleanupSignalHandler allows C++ object cleanup to happen because it calls
// exit() rather than the default which is to abort.
- vlog.info(_("Termination signal %d has been received. TigerVNC viewer will now exit."), sig);
+ vlog.info(_("Termination signal %d has been received. TigerVNC will now exit."), sig);
exit(1);
}
@@ -388,7 +388,7 @@ static void init_fltk()
fl_message_hotspot(false);
// Avoid empty titles for popups
- fl_message_title_default(_("TigerVNC viewer"));
+ fl_message_title_default("TigerVNC");
// FLTK exposes these so that we can translate them.
fl_no = _("No");
@@ -446,7 +446,7 @@ static void usage(const char *programName)
}
#endif
- fprintf(stderr,
+ fprintf(stderr, _(
"\n"
"Usage: %s [parameters] [host][:displayNum]\n"
" %s [parameters] [host][::port]\n"
@@ -454,7 +454,7 @@ static void usage(const char *programName)
" %s [parameters] [unix socket]\n"
#endif
" %s [parameters] -listen [port]\n"
- " %s [parameters] [.tigervnc file]\n",
+ " %s [parameters] [.tigervnc file]\n"),
programName, programName,
#ifndef WIN32
programName,
@@ -462,21 +462,21 @@ static void usage(const char *programName)
programName, programName);
#if !defined(WIN32) && !defined(__APPLE__)
- fprintf(stderr,"\n"
+ fprintf(stderr, _("\n"
"Options:\n\n"
" -display Xdisplay - Specifies the X display for the viewer window\n"
- " -geometry geometry - Initial position of the main VNC viewer window. See the\n"
- " man page for details.\n");
+ " -geometry geometry - Initial position of the main TigerVNC window. See the\n"
+ " man page for details.\n"));
#endif
- fprintf(stderr,"\n"
+ fprintf(stderr, _("\n"
"Parameters can be turned on with -<param> or off with -<param>=0\n"
"Parameters which take a value can be specified as "
"-<param> <value>\n"
"Other valid forms are <param>=<value> -<param>=<value> "
"--<param>=<value>\n"
- "Parameter names are case-insensitive. The parameters are:\n\n");
- Configuration::listParams(79, 14);
+ "Parameter names are case-insensitive. The parameters are:\n\n"));
+ core::Configuration::listParams(79, 14);
#ifdef WIN32
// Just wait for the user to kill the console window
@@ -528,6 +528,12 @@ migrateDeprecatedOptions()
fullScreenMode.setParam("all");
}
+ if (dotWhenNoCursor) {
+ vlog.info(_("DotWhenNoCursor is deprecated, set AlwaysCursor to 1 and CursorType to 'Dot' instead"));
+
+ alwaysCursor.setParam(true);
+ cursorType.setParam("Dot");
+ }
}
static void
@@ -535,7 +541,7 @@ create_base_dirs()
{
const char *dir;
- dir = os::getvncconfigdir();
+ dir = core::getvncconfigdir();
if (dir == nullptr) {
vlog.error(_("Could not determine VNC config directory path"));
return;
@@ -551,31 +557,31 @@ create_base_dirs()
vlog.info(_("%%APPDATA%%\\vnc is deprecated, please switch to the %%APPDATA%%\\TigerVNC location."));
#endif
- if (os::mkdir_p(dir, 0755) == -1) {
+ if (core::mkdir_p(dir, 0755) == -1) {
if (errno != EEXIST)
vlog.error(_("Could not create VNC config directory \"%s\": %s"),
dir, strerror(errno));
}
- dir = os::getvncdatadir();
+ dir = core::getvncdatadir();
if (dir == nullptr) {
vlog.error(_("Could not determine VNC data directory path"));
return;
}
- if (os::mkdir_p(dir, 0755) == -1) {
+ if (core::mkdir_p(dir, 0755) == -1) {
if (errno != EEXIST)
vlog.error(_("Could not create VNC data directory \"%s\": %s"),
dir, strerror(errno));
}
- dir = os::getvncstatedir();
+ dir = core::getvncstatedir();
if (dir == nullptr) {
vlog.error(_("Could not determine VNC state directory path"));
return;
}
- if (os::mkdir_p(dir, 0755) == -1) {
+ if (core::mkdir_p(dir, 0755) == -1) {
if (errno != EEXIST)
vlog.error(_("Could not create VNC state directory \"%s\": %s"),
dir, strerror(errno));
@@ -602,7 +608,9 @@ createTunnel(const char *gatewayHost, const char *remoteHost,
cmd2 = strdup(cmd);
while ((percent = strchr(cmd2, '%')) != nullptr)
*percent = '$';
- system(cmd2);
+ int res = system(cmd2);
+ if (res != 0)
+ fprintf(stderr, "Failed to create tunnel: '%s' returned %d\n", cmd2, res);
free(cmd2);
}
@@ -610,10 +618,10 @@ static void mktunnel()
{
const char *gatewayHost;
std::string remoteHost;
- int localPort = findFreeTcpPort();
+ int localPort = network::findFreeTcpPort();
int remotePort;
- getHostAndPort(vncServerName, &remoteHost, &remotePort);
+ network::getHostAndPort(vncServerName, &remoteHost, &remotePort);
snprintf(vncServerName, VNCSERVERNAMELEN, "localhost::%d", localPort);
vncServerName[VNCSERVERNAMELEN - 1] = '\0';
gatewayHost = (const char*)via;
@@ -645,13 +653,13 @@ int main(int argc, char** argv)
bind_textdomain_codeset(PACKAGE_NAME, "UTF-8");
bind_textdomain_codeset("libc", "UTF-8");
- rfb::initStdIOLoggers();
+ core::initStdIOLoggers();
#ifdef WIN32
- rfb::initFileLogger("C:\\temp\\vncviewer.log");
+ core::initFileLogger("C:\\temp\\vncviewer.log");
#else
- rfb::initFileLogger("/tmp/vncviewer.log");
+ core::initFileLogger("/tmp/vncviewer.log");
#endif
- rfb::LogWriter::setLogParams("*:stderr:30");
+ core::LogWriter::setLogParams("*:stderr:30");
#ifdef SIGHUP
signal(SIGHUP, CleanupSignalHandler);
@@ -659,8 +667,6 @@ int main(int argc, char** argv)
signal(SIGINT, CleanupSignalHandler);
signal(SIGTERM, CleanupSignalHandler);
- Configuration::enableViewerParams();
-
/* Load the default parameter settings */
char defaultServerName[VNCSERVERNAMELEN] = "";
try {
@@ -675,40 +681,40 @@ int main(int argc, char** argv)
}
for (int i = 1; i < argc;) {
- /* We need to resolve an ambiguity for booleans */
- if (argv[i][0] == '-' && i+1 < argc) {
- VoidParameter *param;
-
- param = Configuration::getParam(&argv[i][1]);
- if ((param != nullptr) &&
- (dynamic_cast<BoolParameter*>(param) != nullptr)) {
- if ((strcasecmp(argv[i+1], "0") == 0) ||
- (strcasecmp(argv[i+1], "1") == 0) ||
- (strcasecmp(argv[i+1], "true") == 0) ||
- (strcasecmp(argv[i+1], "false") == 0) ||
- (strcasecmp(argv[i+1], "yes") == 0) ||
- (strcasecmp(argv[i+1], "no") == 0)) {
- param->setParam(argv[i+1]);
- i += 2;
- continue;
- }
- }
- }
+ int ret;
- if (Configuration::setParam(argv[i])) {
- i++;
+ ret = core::Configuration::handleParamArg(argc, argv, i);
+ if (ret > 0) {
+ i += ret;
continue;
}
+ if (strcmp(argv[i], "-h") == 0 ||
+ strcmp(argv[i], "--help") == 0) {
+ usage(argv[0]);
+ }
+
+ if (strcmp(argv[i], "-v") == 0 ||
+ strcmp(argv[i], "--version") == 0) {
+ /* We already print version on every start */
+ return 0;
+ }
+
if (argv[i][0] == '-') {
- if (i+1 < argc) {
- if (Configuration::setParam(&argv[i][1], argv[i+1])) {
- i += 2;
- continue;
- }
- }
+ fprintf(stderr, "\n");
+ fprintf(stderr, _("%s: Unrecognized option '%s'\n"),
+ argv[0], argv[i]);
+ fprintf(stderr, _("See '%s --help' for more information.\n"),
+ argv[0]);
+ exit(1);
+ }
- usage(argv[0]);
+ if (vncServerName[0] != '\0') {
+ fprintf(stderr, "\n");
+ fprintf(stderr, _("%s: Extra argument '%s'\n"), argv[0], argv[i]);
+ fprintf(stderr, _("See '%s --help' for more information.\n"),
+ argv[0]);
+ exit(0);
}
strncpy(vncServerName, argv[i], VNCSERVERNAMELEN);
@@ -734,7 +740,7 @@ int main(int argc, char** argv)
create_base_dirs();
- Socket *sock = nullptr;
+ network::Socket* sock = nullptr;
#ifndef WIN32
/* Specifying -via and -listen together is nonsense */
@@ -748,7 +754,7 @@ int main(int argc, char** argv)
#endif
if (listenMode) {
- std::list<SocketListener*> listeners;
+ std::list<network::SocketListener*> listeners;
try {
int port = 5500;
if (isdigit(vncServerName[0]))
@@ -764,7 +770,7 @@ int main(int argc, char** argv)
while (sock == nullptr) {
fd_set rfds;
FD_ZERO(&rfds);
- for (SocketListener* listener : listeners)
+ for (network::SocketListener* listener : listeners)
FD_SET(listener->getFd(), &rfds);
int n = select(FD_SETSIZE, &rfds, nullptr, nullptr, nullptr);
@@ -773,11 +779,11 @@ int main(int argc, char** argv)
vlog.debug("Interrupted select() system call");
continue;
} else {
- throw rdr::socket_error("select", errno);
+ throw core::socket_error("select", errno);
}
}
- for (SocketListener* listener : listeners)
+ for (network::SocketListener* listener : listeners)
if (FD_ISSET(listener->getFd(), &rfds)) {
sock = listener->accept();
if (sock)