diff options
Diffstat (limited to 'vncviewer')
-rw-r--r-- | vncviewer/CConn.cxx | 17 | ||||
-rw-r--r-- | vncviewer/CConn.h | 2 | ||||
-rw-r--r-- | vncviewer/DesktopWindow.cxx | 10 | ||||
-rw-r--r-- | vncviewer/UserDialog.cxx | 16 | ||||
-rw-r--r-- | vncviewer/UserDialog.h | 3 | ||||
-rw-r--r-- | vncviewer/Viewport.cxx | 8 |
6 files changed, 26 insertions, 30 deletions
diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx index ef4252a7..780214f2 100644 --- a/vncviewer/CConn.cxx +++ b/vncviewer/CConn.cxx @@ -75,8 +75,7 @@ static const PixelFormat mediumColourPF(8, 8, false, true, static const unsigned bpsEstimateWindow = 1000; CConn::CConn(const char* vncServerName, network::Socket* socket=NULL) - : serverHost(0), serverPort(0), desktop(NULL), - updateCount(0), pixelCount(0), + : serverPort(0), desktop(NULL), updateCount(0), pixelCount(0), lastServerEncoding((unsigned int)-1), bpsEstimate(20000000) { setShared(::shared); @@ -98,15 +97,16 @@ CConn::CConn(const char* vncServerName, network::Socket* socket=NULL) #ifndef WIN32 if (strchr(vncServerName, '/') != NULL) { sock = new network::UnixSocket(vncServerName); - serverHost = strDup(sock->getPeerAddress()); - vlog.info(_("Connected to socket %s"), serverHost); + serverHost = sock->getPeerAddress(); + vlog.info(_("Connected to socket %s"), serverHost.c_str()); } else #endif { getHostAndPort(vncServerName, &serverHost, &serverPort); - sock = new network::TcpSocket(serverHost, serverPort); - vlog.info(_("Connected to host %s port %d"), serverHost, serverPort); + sock = new network::TcpSocket(serverHost.c_str(), serverPort); + vlog.info(_("Connected to host %s port %d"), + serverHost.c_str(), serverPort); } } catch (rdr::Exception& e) { vlog.error("%s", e.str()); @@ -118,7 +118,7 @@ CConn::CConn(const char* vncServerName, network::Socket* socket=NULL) Fl::add_fd(sock->getFd(), FL_READ | FL_EXCEPT, socketEvent, this); - setServerName(serverHost); + setServerName(serverHost.c_str()); setStreams(&sock->inStream(), &sock->outStream()); initialiseProtocol(); @@ -136,7 +136,6 @@ CConn::~CConn() if (desktop) delete desktop; - delete [] serverHost; if (sock) Fl::remove_fd(sock->getFd()); delete sock; @@ -160,7 +159,7 @@ const char *CConn::connectionInfo() strcat(infoText, "\n"); snprintf(scratch, sizeof(scratch), - _("Host: %.80s port: %d"), serverHost, serverPort); + _("Host: %.80s port: %d"), serverHost.c_str(), serverPort); strcat(infoText, scratch); strcat(infoText, "\n"); diff --git a/vncviewer/CConn.h b/vncviewer/CConn.h index 4f0e86fe..0d8d7789 100644 --- a/vncviewer/CConn.h +++ b/vncviewer/CConn.h @@ -85,7 +85,7 @@ private: static void handleUpdateTimeout(void *data); private: - char* serverHost; + std::string serverHost; int serverPort; network::Socket* sock; diff --git a/vncviewer/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx index 3584845e..318e9f4e 100644 --- a/vncviewer/DesktopWindow.cxx +++ b/vncviewer/DesktopWindow.cxx @@ -1710,14 +1710,12 @@ void DesktopWindow::handleStatsTimeout(void *data) fl_draw(buffer, 5, statsHeight - 5); fl_color(FL_YELLOW); - siPrefix(self->stats[statsCount-1].pps, "pix/s", - buffer, sizeof(buffer), 3); - fl_draw(buffer, 5 + (statsWidth-10)/3, statsHeight - 5); + fl_draw(siPrefix(self->stats[statsCount-1].pps, "pix/s").c_str(), + 5 + (statsWidth-10)/3, statsHeight - 5); fl_color(FL_RED); - siPrefix(self->stats[statsCount-1].bps * 8, "bps", - buffer, sizeof(buffer), 3); - fl_draw(buffer, 5 + (statsWidth-10)*2/3, statsHeight - 5); + fl_draw(siPrefix(self->stats[statsCount-1].bps * 8, "bps").c_str(), + 5 + (statsWidth-10)*2/3, statsHeight - 5); image = surface->image(); delete surface; diff --git a/vncviewer/UserDialog.cxx b/vncviewer/UserDialog.cxx index ea5a8053..ff5b6123 100644 --- a/vncviewer/UserDialog.cxx +++ b/vncviewer/UserDialog.cxx @@ -34,7 +34,6 @@ #include <FL/Fl_Return_Button.H> #include <FL/Fl_Pixmap.H> -#include <rfb/util.h> #include <rfb/Password.h> #include <rfb/Exception.h> @@ -71,7 +70,8 @@ UserDialog::~UserDialog() { } -void UserDialog::getUserPasswd(bool secure, char** user, char** password) +void UserDialog::getUserPasswd(bool secure, std::string* user, + std::string* password) { const char *passwordFileName(passwordFile); @@ -80,13 +80,13 @@ void UserDialog::getUserPasswd(bool secure, char** user, char** password) char *envPassword = getenv("VNC_PASSWORD"); if(user && envUsername && envPassword) { - *user = strdup(envUsername); - *password = strdup(envPassword); + *user = envUsername; + *password = envPassword; return; } if (!user && envPassword) { - *password = strdup(envPassword); + *password = envPassword; return; } @@ -102,7 +102,7 @@ void UserDialog::getUserPasswd(bool secure, char** user, char** password) fclose(fp); PlainPasswd passwd(obfPwd); - *password = passwd.takeBuf(); + *password = passwd.buf; return; } @@ -198,8 +198,8 @@ void UserDialog::getUserPasswd(bool secure, char** user, char** password) if (ret_val == 0) { if (user) - *user = strDup(username->value()); - *password = strDup(passwd->value()); + *user = username->value(); + *password = passwd->value(); } delete win; diff --git a/vncviewer/UserDialog.h b/vncviewer/UserDialog.h index b62ba7f3..913af841 100644 --- a/vncviewer/UserDialog.h +++ b/vncviewer/UserDialog.h @@ -31,7 +31,8 @@ public: // UserPasswdGetter callbacks - void getUserPasswd(bool secure, char** user, char** password); + void getUserPasswd(bool secure, std::string* user, + std::string* password); // UserMsgBox callbacks diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index c12394ab..66903c5f 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -560,7 +560,7 @@ void Viewport::resize(int x, int y, int w, int h) int Viewport::handle(int event) { - char *filtered; + std::string filtered; int buttonMask, wheelMask; DownMap::const_iterator iter; @@ -568,17 +568,15 @@ int Viewport::handle(int event) case FL_PASTE: filtered = convertLF(Fl::event_text(), Fl::event_length()); - vlog.debug("Sending clipboard data (%d bytes)", (int)strlen(filtered)); + vlog.debug("Sending clipboard data (%d bytes)", (int)filtered.size()); try { - cc->sendClipboardData(filtered); + cc->sendClipboardData(filtered.c_str()); } catch (rdr::Exception& e) { vlog.error("%s", e.str()); abort_connection_with_unexpected_error(e); } - strFree(filtered); - return 1; case FL_ENTER: |