diff options
Diffstat (limited to 'vncviewer')
-rw-r--r-- | vncviewer/CConn.cxx | 19 | ||||
-rw-r--r-- | vncviewer/CConn.h | 12 | ||||
-rw-r--r-- | vncviewer/ServerDialog.cxx | 4 | ||||
-rw-r--r-- | vncviewer/UserDialog.cxx | 4 | ||||
-rw-r--r-- | vncviewer/UserDialog.h | 13 | ||||
-rw-r--r-- | vncviewer/Viewport.cxx | 2 | ||||
-rw-r--r-- | vncviewer/parameters.cxx | 4 | ||||
-rw-r--r-- | vncviewer/vncviewer.cxx | 90 | ||||
-rw-r--r-- | vncviewer/vncviewer.h | 1 |
9 files changed, 96 insertions, 53 deletions
diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx index e1c75962..81bea534 100644 --- a/vncviewer/CConn.cxx +++ b/vncviewer/CConn.cxx @@ -275,7 +275,7 @@ void CConn::socketEvent(FL_SOCKET fd, void *data) vlog.info("%s", e.str()); disconnect(); } catch (rfb::AuthFailureException& e) { - reset_password_data(); + cc->resetPassword(); vlog.error(_("Authentication failed: %s"), e.str()); abort_connection(_("Failed to authenticate with the server. Reason " "given by the server:\n\n%s"), e.str()); @@ -292,8 +292,25 @@ void CConn::socketEvent(FL_SOCKET fd, void *data) recursing = false; } +void CConn::resetPassword() +{ + dlg.resetPassword(); +} + ////////////////////// CConnection callback methods ////////////////////// +bool CConn::showMsgBox(MsgBoxFlags flags, const char *title, + const char *text) +{ + return dlg.showMsgBox(flags, title, text); +} + +void CConn::getUserPasswd(bool secure, std::string *user, + std::string *password) +{ + dlg.getUserPasswd(secure, user, password); +} + // initDone() is called when the serverInit message has been received. At // this point we create the desktop window and display it. We also tell the // server the pixel format and encodings to use and request the first update. diff --git a/vncviewer/CConn.h b/vncviewer/CConn.h index fcaf49f6..1e71be94 100644 --- a/vncviewer/CConn.h +++ b/vncviewer/CConn.h @@ -24,6 +24,7 @@ #include <rfb/CConnection.h> #include <rdr/FdInStream.h> +#include "UserDialog.h" namespace network { class Socket; } @@ -44,7 +45,16 @@ public: // Callback when socket is ready (or broken) static void socketEvent(FL_SOCKET fd, void *data); + // Forget any saved password + void resetPassword(); + // CConnection callback methods + + bool showMsgBox(rfb::MsgBoxFlags flags, const char *title, + const char *text) override; + void getUserPasswd(bool secure, std::string *user, + std::string *password) override; + void initDone() override; void setDesktopSize(int w, int h) override; @@ -105,6 +115,8 @@ private: struct timeval updateStartTime; size_t updateStartPos; unsigned long long bpsEstimate; + + UserDialog dlg; }; #endif diff --git a/vncviewer/ServerDialog.cxx b/vncviewer/ServerDialog.cxx index 3bce2b51..d51b8713 100644 --- a/vncviewer/ServerDialog.cxx +++ b/vncviewer/ServerDialog.cxx @@ -317,7 +317,7 @@ void ServerDialog::loadServerHistory() const char* stateDir = os::getvncstatedir(); if (stateDir == nullptr) - throw Exception(_("Could not obtain the state directory path")); + throw Exception(_("Could not determine VNC state directory path")); char filepath[PATH_MAX]; snprintf(filepath, sizeof(filepath), "%s/%s", stateDir, SERVER_HISTORY); @@ -383,7 +383,7 @@ void ServerDialog::saveServerHistory() const char* stateDir = os::getvncstatedir(); if (stateDir == nullptr) - throw Exception(_("Could not obtain the state directory path")); + throw Exception(_("Could not determine VNC state directory path")); char filepath[PATH_MAX]; snprintf(filepath, sizeof(filepath), "%s/%s", stateDir, SERVER_HISTORY); diff --git a/vncviewer/UserDialog.cxx b/vncviewer/UserDialog.cxx index a3767857..13821a9c 100644 --- a/vncviewer/UserDialog.cxx +++ b/vncviewer/UserDialog.cxx @@ -109,7 +109,7 @@ void UserDialog::getUserPasswd(bool secure_, std::string* user, } if (!user && passwordFileName[0]) { - std::vector<uint8_t> obfPwd(256); + std::vector<uint8_t> obfPwd(8); FILE* fp; fp = fopen(passwordFileName, "rb"); @@ -248,7 +248,7 @@ void UserDialog::getUserPasswd(bool secure_, std::string* user, throw rfb::AuthCancelledException(); } -bool UserDialog::showMsgBox(int flags, const char* title, const char* text) +bool UserDialog::showMsgBox(MsgBoxFlags flags, const char* title, const char* text) { char buffer[1024]; diff --git a/vncviewer/UserDialog.h b/vncviewer/UserDialog.h index aa50127e..c16923c1 100644 --- a/vncviewer/UserDialog.h +++ b/vncviewer/UserDialog.h @@ -19,11 +19,9 @@ #ifndef __USERDIALOG_H__ #define __USERDIALOG_H__ -#include <rfb/UserPasswdGetter.h> -#include <rfb/UserMsgBox.h> +#include <rfb/CConnection.h> -class UserDialog : public rfb::UserPasswdGetter, - public rfb::UserMsgBox +class UserDialog { public: UserDialog(); @@ -32,15 +30,14 @@ public: // UserPasswdGetter callbacks void getUserPasswd(bool secure, std::string* user, - std::string* password) override; + std::string* password); // UserMsgBox callbacks - - bool showMsgBox(int flags, const char* title, const char* text) override; + bool showMsgBox(rfb::MsgBoxFlags flags, const char* title, const char* text); void resetPassword(); - private: +private: std::string savedUsername; std::string savedPassword; }; diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index ed5f9899..ad7a6e8d 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -1316,6 +1316,8 @@ void Viewport::popupContextMenu() break; case ID_MINIMIZE: #ifdef __APPLE__ + // FIXME: Workaround for not being able to minimize in fullscreen + // https://github.com/TigerVNC/tigervnc/pull/1813 if (window()->fullscreen_active()) window()->fullscreen_off(); #endif diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx index a03623db..2e8ad7a1 100644 --- a/vncviewer/parameters.cxx +++ b/vncviewer/parameters.cxx @@ -631,7 +631,7 @@ void saveViewerParameters(const char *filename, const char *servername) { const char* configDir = os::getvncconfigdir(); if (configDir == nullptr) - throw Exception(_("Could not obtain the config directory path")); + throw Exception(_("Could not determine VNC config directory path")); snprintf(filepath, sizeof(filepath), "%s/default.tigervnc", configDir); } else { @@ -735,7 +735,7 @@ char* loadViewerParameters(const char *filename) { const char* configDir = os::getvncconfigdir(); if (configDir == nullptr) - throw Exception(_("Could not obtain the config directory path")); + throw Exception(_("Could not determine VNC config directory path")); snprintf(filepath, sizeof(filepath), "%s/default.tigervnc", configDir); } else { diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx index 27946f3f..ab95c0c6 100644 --- a/vncviewer/vncviewer.cxx +++ b/vncviewer/vncviewer.cxx @@ -93,8 +93,6 @@ static bool exitMainloop = false; static char *exitError = nullptr; static bool fatalError = false; -static UserDialog dlg; - static const char *about_text() { static char buffer[1024]; @@ -171,11 +169,6 @@ bool should_disconnect() return exitMainloop; } -void reset_password_data() -{ - dlg.resetPassword(); -} - void about_vncviewer() { fl_message_title(_("About TigerVNC Viewer")); @@ -537,6 +530,58 @@ migrateDeprecatedOptions() } } +static void +create_base_dirs() +{ + const char *dir; + + dir = os::getvncconfigdir(); + if (dir == nullptr) { + vlog.error(_("Could not determine VNC config directory path")); + return; + } + +#ifndef WIN32 + const char *dotdir = strrchr(dir, '.'); + if (dotdir != nullptr && strcmp(dotdir, ".vnc") == 0) + vlog.info(_("~/.vnc is deprecated, please consult 'man vncviewer' for paths to migrate to.")); +#else + const char *vncdir = strrchr(dir, '\\'); + if (vncdir != nullptr && strcmp(vncdir, "vnc") == 0) + vlog.info(_("%%APPDATA%%\\vnc is deprecated, please switch to the %%APPDATA%%\\TigerVNC location.")); +#endif + + if (os::mkdir_p(dir, 0755) == -1) { + if (errno != EEXIST) + vlog.error(_("Could not create VNC config directory \"%s\": %s"), + dir, strerror(errno)); + } + + dir = os::getvncdatadir(); + if (dir == nullptr) { + vlog.error(_("Could not determine VNC data directory path")); + return; + } + + if (os::mkdir_p(dir, 0755) == -1) { + if (errno != EEXIST) + vlog.error(_("Could not create VNC data directory \"%s\": %s"), + dir, strerror(errno)); + } + + dir = os::getvncstatedir(); + if (dir == nullptr) { + vlog.error(_("Could not determine VNC state directory path")); + return; + } + + if (os::mkdir_p(dir, 0755) == -1) { + if (errno != EEXIST) + vlog.error(_("Could not create VNC state directory \"%s\": %s"), + dir, strerror(errno)); + } +} + #ifndef WIN32 static int interpretViaParam(char *remoteHost, int *remotePort, int localPort) @@ -722,36 +767,7 @@ int main(int argc, char** argv) migrateDeprecatedOptions(); - char *confdir = strdup(os::getvncconfigdir()); -#ifndef WIN32 - char *dotdir = strrchr(confdir, '.'); - if (dotdir != nullptr && strcmp(dotdir, ".vnc") == 0) - vlog.info(_("~/.vnc is deprecated, please consult 'man vncviewer' for paths to migrate to.")); -#else - char *vncdir = strrchr(confdir, '\\'); - if (vncdir != nullptr && strcmp(vncdir, "vnc") == 0) - vlog.info(_("%%APPDATA%%\\vnc is deprecated, please switch to the %%APPDATA%%\\TigerVNC location.")); -#endif - - if (os::mkdir_p(os::getvncconfigdir(), 0755) == -1) { - if (errno != EEXIST) - vlog.error(_("Could not create VNC config directory: %s"), strerror(errno)); - } - - if (os::mkdir_p(os::getvncdatadir(), 0755) == -1) { - if (errno != EEXIST) - vlog.error(_("Could not create VNC data directory: %s"), strerror(errno)); - } - - if (os::mkdir_p(os::getvncstatedir(), 0755) == -1) { - if (errno != EEXIST) - vlog.error(_("Could not create VNC state directory: %s"), strerror(errno)); - } - - CSecurity::upg = &dlg; -#if defined(HAVE_GNUTLS) || defined(HAVE_NETTLE) - CSecurity::msg = &dlg; -#endif + create_base_dirs(); Socket *sock = nullptr; diff --git a/vncviewer/vncviewer.h b/vncviewer/vncviewer.h index c864805c..f39a5776 100644 --- a/vncviewer/vncviewer.h +++ b/vncviewer/vncviewer.h @@ -33,7 +33,6 @@ void abort_connection_with_unexpected_error(const rdr::Exception &); void disconnect(); bool should_disconnect(); -void reset_password_data(); void about_vncviewer(); |