diff options
Diffstat (limited to 'unix/vncconfig')
-rw-r--r-- | unix/vncconfig/CMakeLists.txt | 2 | ||||
-rw-r--r-- | unix/vncconfig/QueryConnectDialog.cxx | 15 | ||||
-rw-r--r-- | unix/vncconfig/QueryConnectDialog.h | 9 | ||||
-rw-r--r-- | unix/vncconfig/vncExt.c | 10 | ||||
-rw-r--r-- | unix/vncconfig/vncExt.h | 153 | ||||
-rw-r--r-- | unix/vncconfig/vncconfig.cxx | 106 | ||||
-rw-r--r-- | unix/vncconfig/vncconfig.man | 28 |
7 files changed, 184 insertions, 139 deletions
diff --git a/unix/vncconfig/CMakeLists.txt b/unix/vncconfig/CMakeLists.txt index 0589f161..4882dc71 100644 --- a/unix/vncconfig/CMakeLists.txt +++ b/unix/vncconfig/CMakeLists.txt @@ -9,7 +9,7 @@ target_include_directories(vncconfig SYSTEM PUBLIC ${X11_INCLUDE_DIR}) target_include_directories(vncconfig PUBLIC ${CMAKE_SOURCE_DIR}/common) target_include_directories(vncconfig PUBLIC ${CMAKE_SOURCE_DIR}/unix/tx) -target_link_libraries(vncconfig tx rfb network rdr ${X11_LIBRARIES}) +target_link_libraries(vncconfig core tx rfb ${X11_LIBRARIES}) install(TARGETS vncconfig DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}) install(FILES vncconfig.man DESTINATION ${CMAKE_INSTALL_FULL_MANDIR}/man1 RENAME vncconfig.1) diff --git a/unix/vncconfig/QueryConnectDialog.cxx b/unix/vncconfig/QueryConnectDialog.cxx index a265356f..1d495ea5 100644 --- a/unix/vncconfig/QueryConnectDialog.cxx +++ b/unix/vncconfig/QueryConnectDialog.cxx @@ -21,7 +21,9 @@ #endif #include <stdio.h> -#include <rdr/Exception.h> + +#include <algorithm> + #include "QueryConnectDialog.h" #include "vncExt.h" @@ -43,7 +45,7 @@ QueryConnectDialog::QueryConnectDialog(Display* dpy_, { const int pad = 4; int y=pad; - int lblWidth = __rfbmax(addressLbl.width(), userLbl.width()); + int lblWidth = std::max(addressLbl.width(), userLbl.width()); userLbl.move(pad+lblWidth-userLbl.width(), y); user.move(pad+lblWidth, y); addressLbl.move(pad+lblWidth-addressLbl.width(), y+=userLbl.height()); @@ -51,9 +53,9 @@ QueryConnectDialog::QueryConnectDialog(Display* dpy_, timeoutLbl.move(pad, y+=addressLbl.height()); timeout.move(pad+timeoutLbl.width(), y); accept.move(pad, y+=addressLbl.height()); - int maxWidth = __rfbmax(user.width(), address.width()+pad+lblWidth); - maxWidth = __rfbmax(maxWidth, accept.width()*3); - maxWidth = __rfbmax(maxWidth, timeoutLbl.width()+timeout.width()+pad); + int maxWidth = std::max(user.width(), address.width()+pad+lblWidth); + maxWidth = std::max(maxWidth, accept.width()*3); + maxWidth = std::max(maxWidth, timeoutLbl.width()+timeout.width()+pad); reject.move(maxWidth-reject.width(), y); resize(maxWidth + pad, y+reject.height()+pad); setBorderWidth(1); @@ -74,7 +76,8 @@ void QueryConnectDialog::buttonActivate(TXButton* b) { callback->queryRejected(); } -void QueryConnectDialog::handleTimeout(rfb::Timer* t) { +void QueryConnectDialog::handleTimeout(core::Timer* t) +{ if (timeUntilReject-- == 0) { unmap(); callback->queryTimedOut(); diff --git a/unix/vncconfig/QueryConnectDialog.h b/unix/vncconfig/QueryConnectDialog.h index 5763e1ce..7e9450b0 100644 --- a/unix/vncconfig/QueryConnectDialog.h +++ b/unix/vncconfig/QueryConnectDialog.h @@ -19,7 +19,8 @@ #ifndef __QUERYCONNECTDIALOG_H__ #define __QUERYCONNECTDIALOG_H__ -#include <rfb/Timer.h> +#include <core/Timer.h> + #include "TXLabel.h" #include "TXButton.h" #include "TXDialog.h" @@ -34,7 +35,7 @@ class QueryResultCallback { class QueryConnectDialog : public TXDialog, public TXEventHandler, public TXButtonCallback, - public rfb::Timer::Callback + public core::Timer::Callback { public: QueryConnectDialog(Display* dpy, const char* address_, @@ -43,14 +44,14 @@ class QueryConnectDialog : public TXDialog, public TXEventHandler, void handleEvent(TXWindow*, XEvent* ) override { } void deleteWindow(TXWindow*) override; void buttonActivate(TXButton* b) override; - void handleTimeout(rfb::Timer* t) override; + void handleTimeout(core::Timer* t) override; private: void refreshTimeout(); TXLabel addressLbl, address, userLbl, user, timeoutLbl, timeout; TXButton accept, reject; QueryResultCallback* callback; int timeUntilReject; - rfb::Timer timer; + core::Timer timer; }; #endif diff --git a/unix/vncconfig/vncExt.c b/unix/vncconfig/vncExt.c index 4ec671b8..482af829 100644 --- a/unix/vncconfig/vncExt.c +++ b/unix/vncconfig/vncExt.c @@ -55,22 +55,26 @@ Bool XVncExtQueryExtension(Display* dpy, int* event_basep, int* error_basep) return True; } -Bool XVncExtSetParam(Display* dpy, const char* param) +Bool XVncExtSetParam(Display* dpy, const char* param, const char* value) { xVncExtSetParamReq* req; xVncExtSetParamReply rep; int paramLen = strlen(param); - if (paramLen > 255) return False; + if (paramLen > 65535) return False; + int valueLen = strlen(value); + if (valueLen > 65535) return False; if (!checkExtension(dpy)) return False; LockDisplay(dpy); GetReq(VncExtSetParam, req); req->reqType = codes->major_opcode; req->vncExtReqType = X_VncExtSetParam; - req->length += (paramLen + 3) >> 2; + req->length += ((paramLen + 3) >> 2) + ((valueLen + 3) >> 2); req->paramLen = paramLen; + req->valueLen = valueLen; Data(dpy, param, paramLen); + Data(dpy, value, valueLen); if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); diff --git a/unix/vncconfig/vncExt.h b/unix/vncconfig/vncExt.h index 5de1685d..ca8df699 100644 --- a/unix/vncconfig/vncExt.h +++ b/unix/vncconfig/vncExt.h @@ -40,7 +40,7 @@ extern "C" { #ifndef _VNCEXT_SERVER_ Bool XVncExtQueryExtension(Display* dpy, int* event_basep, int* error_basep); -Bool XVncExtSetParam(Display* dpy, const char* param); +Bool XVncExtSetParam(Display* dpy, const char* param, const char* value); Bool XVncExtGetParam(Display* dpy, const char* param, char** value, int* len); char* XVncExtGetParamDesc(Display* dpy, const char* param); char** XVncExtListParams(Display* dpy, int* nParams); @@ -69,24 +69,23 @@ typedef struct { typedef struct { CARD8 reqType; /* always VncExtReqCode */ CARD8 vncExtReqType; /* always VncExtSetParam */ - CARD16 length B16; - CARD8 paramLen; - CARD8 pad0; - CARD16 pad1 B16; + CARD16 length; + CARD16 paramLen; + CARD16 valueLen; } xVncExtSetParamReq; #define sz_xVncExtSetParamReq 8 typedef struct { BYTE type; /* X_Reply */ BYTE success; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 pad0 B32; - CARD32 pad1 B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; + CARD16 sequenceNumber; + CARD32 length; + CARD32 pad0; + CARD32 pad1; + CARD32 pad2; + CARD32 pad3; + CARD32 pad4; + CARD32 pad5; } xVncExtSetParamReply; #define sz_xVncExtSetParamReply 32 @@ -94,25 +93,25 @@ typedef struct { typedef struct { CARD8 reqType; /* always VncExtReqCode */ CARD8 vncExtReqType; /* always VncExtGetParam */ - CARD16 length B16; + CARD16 length; CARD8 paramLen; CARD8 pad0; - CARD16 pad1 B16; + CARD16 pad1; } xVncExtGetParamReq; #define sz_xVncExtGetParamReq 8 typedef struct { BYTE type; /* X_Reply */ BYTE success; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 valueLen B16; - CARD16 pad0 B16; - CARD32 pad1 B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; + CARD16 sequenceNumber; + CARD32 length; + CARD16 valueLen; + CARD16 pad0; + CARD32 pad1; + CARD32 pad2; + CARD32 pad3; + CARD32 pad4; + CARD32 pad5; } xVncExtGetParamReply; #define sz_xVncExtGetParamReply 32 @@ -120,25 +119,25 @@ typedef struct { typedef struct { CARD8 reqType; /* always VncExtReqCode */ CARD8 vncExtReqType; /* always VncExtGetParamDesc */ - CARD16 length B16; + CARD16 length; CARD8 paramLen; CARD8 pad0; - CARD16 pad1 B16; + CARD16 pad1; } xVncExtGetParamDescReq; #define sz_xVncExtGetParamDescReq 8 typedef struct { BYTE type; /* X_Reply */ BYTE success; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 descLen B16; - CARD16 pad0 B16; - CARD32 pad1 B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; + CARD16 sequenceNumber; + CARD32 length; + CARD16 descLen; + CARD16 pad0; + CARD32 pad1; + CARD32 pad2; + CARD32 pad3; + CARD32 pad4; + CARD32 pad5; } xVncExtGetParamDescReply; #define sz_xVncExtGetParamDescReply 32 @@ -146,22 +145,22 @@ typedef struct { typedef struct { CARD8 reqType; /* always VncExtReqCode */ CARD8 vncExtReqType; /* always VncExtListParams */ - CARD16 length B16; + CARD16 length; } xVncExtListParamsReq; #define sz_xVncExtListParamsReq 4 typedef struct { BYTE type; /* X_Reply */ BYTE pad0; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 nParams B16; - CARD16 pad1 B16; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; + CARD16 sequenceNumber; + CARD32 length; + CARD16 nParams; + CARD16 pad1; + CARD32 pad2; + CARD32 pad3; + CARD32 pad4; + CARD32 pad5; + CARD32 pad6; } xVncExtListParamsReply; #define sz_xVncExtListParamsReply 32 @@ -169,9 +168,9 @@ typedef struct { typedef struct { CARD8 reqType; /* always VncExtReqCode */ CARD8 vncExtReqType; /* always VncExtSelectInput */ - CARD16 length B16; - CARD32 window B32; - CARD32 mask B32; + CARD16 length; + CARD32 window; + CARD32 mask; } xVncExtSelectInputReq; #define sz_xVncExtSelectInputReq 12 @@ -179,24 +178,24 @@ typedef struct { typedef struct { CARD8 reqType; /* always VncExtReqCode */ CARD8 vncExtReqType; /* always VncExtConnect */ - CARD16 length B16; + CARD16 length; CARD8 strLen; CARD8 viewOnly; - CARD16 pad1 B16; + CARD16 pad1; } xVncExtConnectReq; #define sz_xVncExtConnectReq 8 typedef struct { BYTE type; /* X_Reply */ BYTE success; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 pad0 B32; - CARD32 pad1 B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; + CARD16 sequenceNumber; + CARD32 length; + CARD32 pad0; + CARD32 pad1; + CARD32 pad2; + CARD32 pad3; + CARD32 pad4; + CARD32 pad5; } xVncExtConnectReply; #define sz_xVncExtConnectReply 32 @@ -204,32 +203,32 @@ typedef struct { typedef struct { CARD8 reqType; /* always VncExtReqCode */ CARD8 vncExtReqType; /* always VncExtGetQueryConnect */ - CARD16 length B16; + CARD16 length; } xVncExtGetQueryConnectReq; #define sz_xVncExtGetQueryConnectReq 4 typedef struct { BYTE type; /* X_Reply */ BYTE pad0; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 addrLen B32; - CARD32 userLen B32; - CARD32 timeout B32; - CARD32 opaqueId B32; - CARD32 pad4 B32; - CARD32 pad5 B32; + CARD16 sequenceNumber; + CARD32 length; + CARD32 addrLen; + CARD32 userLen; + CARD32 timeout; + CARD32 opaqueId; + CARD32 pad4; + CARD32 pad5; } xVncExtGetQueryConnectReply; #define sz_xVncExtGetQueryConnectReply 32 typedef struct { CARD8 reqType; /* always VncExtReqCode */ CARD8 vncExtReqType; /* always VncExtApproveConnect */ - CARD16 length B16; + CARD16 length; CARD8 approve; CARD8 pad0; CARD16 pad1; - CARD32 opaqueId B32; + CARD32 opaqueId; } xVncExtApproveConnectReq; #define sz_xVncExtApproveConnectReq 12 @@ -238,14 +237,14 @@ typedef struct { typedef struct { BYTE type; /* always eventBase + VncExtQueryConnectNotify */ BYTE pad0; - CARD16 sequenceNumber B16; - CARD32 window B32; - CARD32 pad6 B32; - CARD32 pad1 B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; + CARD16 sequenceNumber; + CARD32 window; + CARD32 pad6; + CARD32 pad1; + CARD32 pad2; + CARD32 pad3; + CARD32 pad4; + CARD32 pad5; } xVncExtQueryConnectNotifyEvent; #define sz_xVncExtQueryConnectNotifyEvent 32 diff --git a/unix/vncconfig/vncconfig.cxx b/unix/vncconfig/vncconfig.cxx index bacbfb3f..b1a5232b 100644 --- a/unix/vncconfig/vncconfig.cxx +++ b/unix/vncconfig/vncconfig.cxx @@ -39,22 +39,22 @@ #include <X11/Xutil.h> #include <X11/keysym.h> #include "vncExt.h" -#include <rdr/Exception.h> -#include <rfb/Configuration.h> -#include <rfb/Logger_stdio.h> -#include <rfb/LogWriter.h> + +#include <core/Configuration.h> +#include <core/Exception.h> +#include <core/Logger_stdio.h> +#include <core/LogWriter.h> + #include "TXWindow.h" #include "TXCheckbox.h" #include "TXLabel.h" #include "QueryConnectDialog.h" -using namespace rfb; - -static LogWriter vlog("vncconfig"); +static core::LogWriter vlog("vncconfig"); -StringParameter displayname("display", "The X display", ""); -BoolParameter noWindow("nowin", "Don't display a window", 0); -BoolParameter iconic("iconic", "Start with window iconified", 0); +core::StringParameter displayname("display", "The X display", ""); +core::BoolParameter noWindow("nowin", "Don't display a window", 0); +core::BoolParameter iconic("iconic", "Start with window iconified", 0); #define ACCEPT_CUT_TEXT "AcceptCutText" #define SEND_CUT_TEXT "SendCutText" @@ -141,19 +141,19 @@ public: // TXCheckboxCallback method void checkboxSelect(TXCheckbox* checkbox) override { if (checkbox == &acceptClipboard) { - XVncExtSetParam(dpy, (acceptClipboard.checked() - ? ACCEPT_CUT_TEXT "=1" : ACCEPT_CUT_TEXT "=0")); + XVncExtSetParam(dpy, ACCEPT_CUT_TEXT, + acceptClipboard.checked() ? "1" : "0"); setPrimaryCB.disabled(!acceptClipboard.checked()); } else if (checkbox == &sendClipboard) { - XVncExtSetParam(dpy, (sendClipboard.checked() - ? SEND_CUT_TEXT "=1" : SEND_CUT_TEXT "=0")); + XVncExtSetParam(dpy, SEND_CUT_TEXT, + sendClipboard.checked() ? "1" : "0"); sendPrimaryCB.disabled(!sendClipboard.checked()); } else if (checkbox == &setPrimaryCB) { - XVncExtSetParam(dpy, (setPrimaryCB.checked() - ? SET_PRIMARY "=1" : SET_PRIMARY "=0")); + XVncExtSetParam(dpy, SET_PRIMARY, + setPrimaryCB.checked() ? "1" : "0"); } else if (checkbox == &sendPrimaryCB) { - XVncExtSetParam(dpy, (sendPrimaryCB.checked() - ? SEND_PRIMARY "=1" : SEND_PRIMARY "=0")); + XVncExtSetParam(dpy, SEND_PRIMARY, + sendPrimaryCB.checked() ? "1" : "0"); } } @@ -192,7 +192,7 @@ static void usage() "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); + core::Configuration::listParams(79, 14); exit(1); } @@ -207,21 +207,30 @@ void removeArgs(int* argc, char** argv, int first, int n) int main(int argc, char** argv) { programName = argv[0]; - rfb::initStdIOLoggers(); - rfb::LogWriter::setLogParams("*:stderr:30"); + core::initStdIOLoggers(); + core::LogWriter::setLogParams("*:stderr:30"); // Process vncconfig's own parameters first, then we process the // other arguments when we have the X display. int i; - for (i = 1; i < argc; i++) { - if (Configuration::setParam(argv[i])) - continue; + for (i = 1; i < argc;) { + int ret; - if (argv[i][0] == '-' && i+1 < argc && - Configuration::setParam(&argv[i][1], argv[i+1])) { - i++; + ret = core::Configuration::handleParamArg(argc, argv, i); + if (ret > 0) { + i += ret; continue; } + + if (strcmp(argv[i], "-help") == 0) { + usage(); + } + + if (strcmp(argv[i], "-version") == 0) { + fprintf(stderr, "vncconfig (TigerVNC) %s\n", PACKAGE_VERSION); + exit(0); + } + break; } @@ -285,13 +294,42 @@ int main(int argc, char** argv) } else if (strcmp(argv[i], "-set") == 0) { i++; if (i >= argc) usage(); - if (!XVncExtSetParam(dpy, argv[i])) { - fprintf(stderr, "Setting param %s failed\n",argv[i]); + + char* equal = strchr(argv[i], '='); + if (!equal) { + fprintf(stderr, "%s: Invalid parameter syntax '%s'\n", + programName, argv[i]); + fprintf(stderr, "See '%s -help' for more information.\n", + programName); + exit(1); } - } else if (XVncExtSetParam(dpy, argv[i])) { - fprintf(stderr, "Set parameter %s\n",argv[i]); + + std::string name(argv[i], equal-argv[i]); + std::string value(equal+1); + + if (!XVncExtSetParam(dpy, name.c_str(), value.c_str())) + fprintf(stderr, "Setting param %s failed\n",argv[i]); + } else if (argv[i][0] == '-') { + fprintf(stderr, "%s: Unrecognized option '%s'\n", + programName, argv[i]); + fprintf(stderr, "See '%s -help' for more information.\n", + programName); + exit(1); } else { - usage(); + char* equal = strchr(argv[i], '='); + if (!equal) { + fprintf(stderr, "%s: Invalid parameter syntax '%s'\n", + programName, argv[i]); + fprintf(stderr, "See '%s -help' for more information.\n", + programName); + exit(1); + } + + std::string name(argv[i], equal-argv[i]); + std::string value(equal+1); + + if (!XVncExtSetParam(dpy, name.c_str(), value.c_str())) + fprintf(stderr, "Setting param %s failed\n",argv[i]); } } @@ -312,7 +350,7 @@ int main(int argc, char** argv) TXWindow::handleXEvents(dpy); // Process expired timers and get the time until the next one - int timeoutMs = Timer::checkTimeouts(); + int timeoutMs = core::Timer::checkTimeouts(); if (timeoutMs >= 0) { tv.tv_sec = timeoutMs / 1000; tv.tv_usec = (timeoutMs % 1000) * 1000; @@ -330,7 +368,7 @@ int main(int argc, char** argv) FD_ZERO(&rfds); FD_SET(ConnectionNumber(dpy), &rfds); int n = select(FD_SETSIZE, &rfds, nullptr, nullptr, tvp); - if (n < 0) throw rdr::socket_error("select", errno); + if (n < 0) throw core::socket_error("select", errno); } XCloseDisplay(dpy); diff --git a/unix/vncconfig/vncconfig.man b/unix/vncconfig/vncconfig.man index b07c02f4..7c26dff6 100644 --- a/unix/vncconfig/vncconfig.man +++ b/unix/vncconfig/vncconfig.man @@ -64,27 +64,27 @@ instead. The \fB-view-only\fP option specifies that the server must ignore all keyboard or mouse events sent by the client. . .TP +.B \-desc \fIXvnc-param\fP +Prints a short description of the given Xvnc parameter. +. +.TP .B \-disconnect This causes Xvnc to disconnect from all viewers so that the VNC desktop is not displayed anywhere. . .TP -[\fB-set\fP] \fIXvnc-param\fP=\fIvalue\fP -Sets an Xvnc parameter to the given value. Note that some of Xvnc's parameters -are read only once at startup so that changing them in this way may not have -any effect. +.B \-get \fIXvnc-param\fP +Prints the current value of the given Xvnc parameter. . .TP .B \-list Lists all the parameters supported by Xvnc. . .TP -.B \-get \fIXvnc-param\fP -Prints the current value of the given Xvnc parameter. -. -.TP -.B \-desc \fIXvnc-param\fP -Prints a short description of the given Xvnc parameter. +[\fB-set\fP] \fIXvnc-param\fP=\fIvalue\fP +Sets an Xvnc parameter to the given value. Note that some of Xvnc's parameters +are read only once at startup so that changing them in this way may not have +any effect. .SH PARAMETERS .B vncconfig @@ -102,12 +102,12 @@ Other valid forms are \fIparam\fP\fB=\fP\fIvalue\fP -\fIparam\fP=\fIvalue\fP Specifies the Xvnc server to control. . .TP -.B \-nowin -When run as a "helper" app, don't put up a window. -. -.TP .B \-iconic When run as a "helper" app, make the window iconified at startup. +. +.TP +.B \-nowin +When run as a "helper" app, don't put up a window. .SH SEE ALSO .BR vncpasswd (1), |