diff options
Diffstat (limited to 'vncviewer')
-rw-r--r-- | vncviewer/EmulateMB.cxx | 6 | ||||
-rw-r--r-- | vncviewer/PlatformPixelBuffer.cxx | 7 | ||||
-rw-r--r-- | vncviewer/ServerDialog.cxx | 11 | ||||
-rw-r--r-- | vncviewer/Surface_OSX.cxx | 12 | ||||
-rw-r--r-- | vncviewer/Surface_X11.cxx | 10 | ||||
-rw-r--r-- | vncviewer/Viewport.cxx | 5 | ||||
-rw-r--r-- | vncviewer/Win32TouchHandler.cxx | 5 | ||||
-rw-r--r-- | vncviewer/parameters.cxx | 77 | ||||
-rw-r--r-- | vncviewer/vncviewer.cxx | 3 |
9 files changed, 72 insertions, 64 deletions
diff --git a/vncviewer/EmulateMB.cxx b/vncviewer/EmulateMB.cxx index fef8b3d9..8eeed568 100644 --- a/vncviewer/EmulateMB.cxx +++ b/vncviewer/EmulateMB.cxx @@ -54,7 +54,7 @@ #include <assert.h> -#include <rfb/Exception.h> +#include <stdexcept> #include "parameters.h" #include "i18n.h" @@ -223,7 +223,7 @@ void EmulateMB::filterPointerEvent(const rfb::Point& pos, uint8_t buttonMask) btstate |= 0x2; if ((state > 10) || (state < 0)) - throw rfb::Exception(_("Invalid state for 3 button emulation")); + throw std::runtime_error(_("Invalid state for 3 button emulation")); action1 = stateTab[state][btstate][0]; @@ -286,7 +286,7 @@ void EmulateMB::handleTimeout(rfb::Timer *t) return; if ((state > 10) || (state < 0)) - throw rfb::Exception(_("Invalid state for 3 button emulation")); + throw std::runtime_error(_("Invalid state for 3 button emulation")); // Timeout shouldn't trigger when there's no timeout action assert(stateTab[state][4][2] >= 0); diff --git a/vncviewer/PlatformPixelBuffer.cxx b/vncviewer/PlatformPixelBuffer.cxx index bcb4cb23..0f152e11 100644 --- a/vncviewer/PlatformPixelBuffer.cxx +++ b/vncviewer/PlatformPixelBuffer.cxx @@ -28,11 +28,12 @@ #include <sys/shm.h> #endif +#include <stdexcept> + #include <FL/Fl.H> #include <FL/x.H> #include <rfb/LogWriter.h> -#include <rdr/Exception.h> #include "PlatformPixelBuffer.h" @@ -52,11 +53,11 @@ PlatformPixelBuffer::PlatformPixelBuffer(int width, int height) : xim = XCreateImage(fl_display, (Visual*)CopyFromParent, 32, ZPixmap, 0, nullptr, width, height, 32, 0); if (!xim) - throw rdr::Exception("XCreateImage"); + throw std::runtime_error("XCreateImage"); xim->data = (char*)malloc(xim->bytes_per_line * xim->height); if (!xim->data) - throw rdr::Exception("malloc"); + throw std::bad_alloc(); vlog.debug("Using standard XImage"); } diff --git a/vncviewer/ServerDialog.cxx b/vncviewer/ServerDialog.cxx index 3de4e388..d4ec2006 100644 --- a/vncviewer/ServerDialog.cxx +++ b/vncviewer/ServerDialog.cxx @@ -346,7 +346,7 @@ void ServerDialog::loadServerHistory() const char* stateDir = os::getvncstatedir(); if (stateDir == nullptr) - throw Exception(_("Could not determine VNC state directory path")); + throw std::runtime_error(_("Could not determine VNC state directory path")); char filepath[PATH_MAX]; snprintf(filepath, sizeof(filepath), "%s/%s", stateDir, SERVER_HISTORY); @@ -382,8 +382,11 @@ void ServerDialog::loadServerHistory() if (len == (sizeof(line) - 1)) { fclose(f); - throw Exception(format(_("Failed to read line %d in file %s: %s"), - lineNr, filepath, _("Line too long"))); + throw std::runtime_error(format("%s: %s", + format(_("Failed to read line %d " + "in file %s"), + lineNr, filepath).c_str(), + _("Line too long"))); } if ((len > 0) && (line[len-1] == '\n')) { @@ -422,7 +425,7 @@ void ServerDialog::saveServerHistory() const char* stateDir = os::getvncstatedir(); if (stateDir == nullptr) - throw Exception(_("Could not determine VNC state directory path")); + throw std::runtime_error(_("Could not determine VNC state directory path")); char filepath[PATH_MAX]; snprintf(filepath, sizeof(filepath), "%s/%s", stateDir, SERVER_HISTORY); diff --git a/vncviewer/Surface_OSX.cxx b/vncviewer/Surface_OSX.cxx index 673f37e9..dcc3d857 100644 --- a/vncviewer/Surface_OSX.cxx +++ b/vncviewer/Surface_OSX.cxx @@ -22,14 +22,14 @@ #include <assert.h> +#include <stdexcept> + #include <ApplicationServices/ApplicationServices.h> #include <FL/Fl_RGB_Image.H> #include <FL/Fl_Window.H> #include <FL/x.H> -#include <rdr/Exception.h> - #include "cocoa.h" #include "Surface.h" @@ -47,7 +47,7 @@ static CGImageRef create_image(CGColorSpaceRef lut, provider = CGDataProviderCreateWithData(nullptr, data, w * h * 4, nullptr); if (!provider) - throw rdr::Exception("CGDataProviderCreateWithData"); + throw std::runtime_error("CGDataProviderCreateWithData"); // FIXME: This causes a performance hit, but is necessary to avoid // artifacts in the edges of the window @@ -62,7 +62,7 @@ static CGImageRef create_image(CGColorSpaceRef lut, kCGRenderingIntentDefault); CGDataProviderRelease(provider); if (!image) - throw rdr::Exception("CGImageCreate"); + throw std::runtime_error("CGImageCreate"); return image; } @@ -85,7 +85,7 @@ static void render(CGContextRef gc, CGColorSpaceRef lut, subimage = CGImageCreateWithImageInRect(image, rect); if (!subimage) - throw rdr::Exception("CGImageCreateImageWithImageInRect"); + throw std::runtime_error("CGImageCreateImageWithImageInRect"); CGContextSaveGState(gc); @@ -112,7 +112,7 @@ static CGContextRef make_bitmap(int width, int height, unsigned char* data) bitmap = CGBitmapContextCreate(data, width, height, 8, width*4, srgb, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little); if (!bitmap) - throw rdr::Exception("CGBitmapContextCreate"); + throw std::runtime_error("CGBitmapContextCreate"); return bitmap; } diff --git a/vncviewer/Surface_X11.cxx b/vncviewer/Surface_X11.cxx index d27fcd26..e73985f0 100644 --- a/vncviewer/Surface_X11.cxx +++ b/vncviewer/Surface_X11.cxx @@ -23,11 +23,11 @@ #include <assert.h> #include <stdlib.h> +#include <stdexcept> + #include <FL/Fl_RGB_Image.H> #include <FL/x.H> -#include <rdr/Exception.h> - #include "Surface.h" void Surface::clear(unsigned char r, unsigned char g, unsigned char b, unsigned char a) @@ -156,7 +156,7 @@ void Surface::alloc() &templ, 0); if (!format) - throw rdr::Exception("XRenderFindFormat"); + throw std::runtime_error("XRenderFindFormat"); picture = XRenderCreatePicture(fl_display, pixmap, format, 0, nullptr); @@ -185,11 +185,11 @@ void Surface::update(const Fl_RGB_Image* image) ZPixmap, 0, nullptr, width(), height(), 32, 0); if (!img) - throw rdr::Exception("XCreateImage"); + throw std::runtime_error("XCreateImage"); img->data = (char*)malloc(img->bytes_per_line * img->height); if (!img->data) - throw rdr::Exception("malloc"); + throw std::bad_alloc(); // Convert data and pre-multiply alpha in = (const unsigned char*)image->data()[0]; diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index 42a5d002..52fde49c 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -27,7 +27,6 @@ #include <rfb/CMsgWriter.h> #include <rfb/LogWriter.h> -#include <rfb/Exception.h> #include <rfb/KeysymStr.h> #include <rfb/ledStates.h> #include <rfb/util.h> @@ -130,11 +129,11 @@ Viewport::Viewport(int w, int h, const rfb::PixelFormat& /*serverPF*/, CConn* cc xkb = XkbGetMap(fl_display, 0, XkbUseCoreKbd); if (!xkb) - throw rfb::Exception("XkbGetMap"); + throw std::runtime_error("XkbGetMap"); status = XkbGetNames(fl_display, XkbKeyNamesMask, xkb); if (status != Success) - throw rfb::Exception("XkbGetNames"); + throw std::runtime_error("XkbGetNames"); memset(code_map_keycode_to_qnum, 0, sizeof(code_map_keycode_to_qnum)); for (KeyCode keycode = xkb->min_key_code; diff --git a/vncviewer/Win32TouchHandler.cxx b/vncviewer/Win32TouchHandler.cxx index e21768f9..2be27ede 100644 --- a/vncviewer/Win32TouchHandler.cxx +++ b/vncviewer/Win32TouchHandler.cxx @@ -22,9 +22,10 @@ #include <math.h> +#include <stdexcept> + #define XK_MISCELLANY #include <rfb/keysymdef.h> -#include <rfb/Exception.h> #include <rfb/LogWriter.h> #include "i18n.h" @@ -44,7 +45,7 @@ Win32TouchHandler::Win32TouchHandler(HWND hWnd_) : // If window is registered as touch we can not receive gestures, // this should not happen if (IsTouchWindow(hWnd, nullptr)) - throw rfb::Exception(_("Window is registered for touch instead of gestures")); + throw std::runtime_error(_("Window is registered for touch instead of gestures")); // We will not receive any touch/gesture events if this service // isn't running - Logging is enough diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx index f1b5a852..de728987 100644 --- a/vncviewer/parameters.cxx +++ b/vncviewer/parameters.cxx @@ -305,16 +305,16 @@ static void setKeyString(const char *_name, const char *_value, HKEY* hKey) { wchar_t name[buffersize]; unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize); if (size >= buffersize) - throw Exception(_("The name of the parameter is too large")); + throw std::invalid_argument(_("The name of the parameter is too large")); char encodingBuffer[buffersize]; if (!encodeValue(_value, encodingBuffer, buffersize)) - throw Exception(_("The parameter is too large")); + throw std::invalid_argument(_("The parameter is too large")); wchar_t value[buffersize]; size = fl_utf8towc(encodingBuffer, strlen(encodingBuffer)+1, value, buffersize); if (size >= buffersize) - throw Exception(_("The parameter is too large")); + throw std::invalid_argument(_("The parameter is too large")); LONG res = RegSetValueExW(*hKey, name, 0, REG_SZ, (BYTE*)&value, (wcslen(value)+1)*2); if (res != ERROR_SUCCESS) @@ -330,7 +330,7 @@ static void setKeyInt(const char *_name, const int _value, HKEY* hKey) { unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize); if (size >= buffersize) - throw Exception(_("The name of the parameter is too large")); + throw std::out_of_range(_("The name of the parameter is too large")); LONG res = RegSetValueExW(*hKey, name, 0, REG_DWORD, (BYTE*)&value, sizeof(DWORD)); if (res != ERROR_SUCCESS) @@ -347,7 +347,7 @@ static bool getKeyString(const char* _name, char* dest, size_t destSize, HKEY* h unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize); if (size >= buffersize) - throw Exception(_("The name of the parameter is too large")); + throw std::out_of_range(_("The name of the parameter is too large")); value = new WCHAR[destSize]; valuesize = destSize; @@ -365,14 +365,14 @@ static bool getKeyString(const char* _name, char* dest, size_t destSize, HKEY* h delete [] value; if (size >= destSize) { delete [] utf8val; - throw Exception(_("The parameter is too large")); + throw std::out_of_range(_("The parameter is too large")); } bool ret = decodeValue(utf8val, dest, destSize); delete [] utf8val; if (!ret) - throw Exception(_("Invalid format or too large value")); + throw std::invalid_argument(_("Invalid format or too large value")); return true; } @@ -387,7 +387,7 @@ static bool getKeyInt(const char* _name, int* dest, HKEY* hKey) { unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize); if (size >= buffersize) - throw Exception(_("The name of the parameter is too large")); + throw std::out_of_range(_("The name of the parameter is too large")); LONG res = RegQueryValueExW(*hKey, name, nullptr, nullptr, (LPBYTE)&value, &dwordsize); if (res != ERROR_SUCCESS){ @@ -407,7 +407,7 @@ static void removeValue(const char* _name, HKEY* hKey) { unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize); if (size >= buffersize) - throw Exception(_("The name of the parameter is too large")); + throw std::out_of_range(_("The name of the parameter is too large")); LONG res = RegDeleteValueW(*hKey, name); if (res != ERROR_SUCCESS) { @@ -465,8 +465,8 @@ static void saveToReg(const char* servername) { setKeyString("ServerName", servername, &hKey); } catch (std::exception& e) { RegCloseKey(hKey); - throw Exception(format(_("Failed to save \"%s\": %s"), - "ServerName", e.what())); + throw std::runtime_error(format(_("Failed to save \"%s\": %s"), + "ServerName", e.what())); } for (size_t i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) { @@ -478,12 +478,13 @@ static void saveToReg(const char* servername) { } else if (dynamic_cast<BoolParameter*>(parameterArray[i]) != nullptr) { setKeyInt(parameterArray[i]->getName(), (int)*(BoolParameter*)parameterArray[i], &hKey); } else { - throw Exception(_("Unknown parameter type")); + throw std::logic_error(_("Unknown parameter type")); } } catch (std::exception& e) { RegCloseKey(hKey); - throw Exception(format(_("Failed to save \"%s\": %s"), - parameterArray[i]->getName(), e.what())); + throw std::runtime_error(format(_("Failed to save \"%s\": %s"), + parameterArray[i]->getName(), + e.what())); } } @@ -495,9 +496,9 @@ static void saveToReg(const char* servername) { removeValue(readOnlyParameterArray[i]->getName(), &hKey); } catch (std::exception& e) { RegCloseKey(hKey); - throw Exception(format(_("Failed to remove \"%s\": %s"), - readOnlyParameterArray[i]->getName(), - e.what())); + throw std::runtime_error(format(_("Failed to remove \"%s\": %s"), + readOnlyParameterArray[i]->getName(), + e.what())); } } @@ -570,7 +571,7 @@ static void getParametersFromReg(VoidParameter* parameters[], if (getKeyInt(parameters[i]->getName(), &intValue, hKey)) ((BoolParameter*)parameters[i])->setParam(intValue); } else { - throw Exception(_("Unknown parameter type")); + throw std::logic_error(_("Unknown parameter type")); } } catch(std::exception& e) { // Just ignore this entry and continue with the rest @@ -638,7 +639,7 @@ void saveViewerParameters(const char *filename, const char *servername) { const char* configDir = os::getvncconfigdir(); if (configDir == nullptr) - throw Exception(_("Could not determine VNC config directory path")); + throw std::runtime_error(_("Could not determine VNC config directory path")); snprintf(filepath, sizeof(filepath), "%s/default.tigervnc", configDir); } else { @@ -657,9 +658,9 @@ void saveViewerParameters(const char *filename, const char *servername) { if (!encodeValue(servername, encodingBuffer, buffersize)) { fclose(f); - throw Exception(format(_("Failed to save \"%s\": %s"), - "ServerName", - _("Could not encode parameter"))); + throw std::runtime_error(format(_("Failed to save \"%s\": %s"), + "ServerName", + _("Could not encode parameter"))); } fprintf(f, "ServerName=%s\n", encodingBuffer); @@ -668,9 +669,9 @@ void saveViewerParameters(const char *filename, const char *servername) { if (!encodeValue(*(StringParameter*)param, encodingBuffer, buffersize)) { fclose(f); - throw Exception(format(_("Failed to save \"%s\": %s"), - param->getName(), - _("Could not encode parameter"))); + throw std::runtime_error(format(_("Failed to save \"%s\": %s"), + param->getName(), + _("Could not encode parameter"))); } fprintf(f, "%s=%s\n", ((StringParameter*)param)->getName(), encodingBuffer); } else if (dynamic_cast<IntParameter*>(param) != nullptr) { @@ -679,9 +680,9 @@ void saveViewerParameters(const char *filename, const char *servername) { fprintf(f, "%s=%d\n", ((BoolParameter*)param)->getName(), (int)*(BoolParameter*)param); } else { fclose(f); - throw Exception(format(_("Failed to save \"%s\": %s"), - param->getName(), - _("Unknown parameter type"))); + throw std::logic_error(format(_("Failed to save \"%s\": %s"), + param->getName(), + _("Unknown parameter type"))); } } fclose(f); @@ -700,7 +701,7 @@ static bool findAndSetViewerParameterFromValue( if (dynamic_cast<StringParameter*>(parameters[i]) != nullptr) { if (strcasecmp(line, ((StringParameter*)parameters[i])->getName()) == 0) { if(!decodeValue(value, decodingBuffer, sizeof(decodingBuffer))) - throw Exception(_("Invalid format or too large value")); + throw std::runtime_error(_("Invalid format or too large value")); ((StringParameter*)parameters[i])->setParam(decodingBuffer); return false; } @@ -718,7 +719,7 @@ static bool findAndSetViewerParameterFromValue( } } else { - throw Exception(_("Unknown parameter type")); + throw std::logic_error(_("Unknown parameter type")); } } @@ -744,7 +745,7 @@ char* loadViewerParameters(const char *filename) { const char* configDir = os::getvncconfigdir(); if (configDir == nullptr) - throw Exception(_("Could not determine VNC config directory path")); + throw std::runtime_error(_("Could not determine VNC config directory path")); snprintf(filepath, sizeof(filepath), "%s/default.tigervnc", configDir); } else { @@ -777,8 +778,11 @@ char* loadViewerParameters(const char *filename) { if (strlen(line) == (sizeof(line) - 1)) { fclose(f); - throw Exception(format(_("Failed to read line %d in file %s: %s"), - lineNr, filepath, _("Line too long"))); + throw std::runtime_error(format("%s: %s", + format(_("Failed to read line %d " + "in file \"%s\""), + lineNr, filepath).c_str(), + _("Line too long"))); } // Make sure that the first line of the file has the file identifier string @@ -787,8 +791,9 @@ char* loadViewerParameters(const char *filename) { continue; fclose(f); - throw Exception(format(_("Configuration file %s is in an invalid " - "format"), filepath)); + throw std::runtime_error(format(_("Configuration file %s is in " + "an invalid format"), + filepath)); } // Skip empty lines and comments @@ -822,7 +827,7 @@ char* loadViewerParameters(const char *filename) { if (strcasecmp(line, "ServerName") == 0) { if(!decodeValue(value, decodingBuffer, sizeof(decodingBuffer))) - throw Exception(_("Invalid format or too large value")); + throw std::runtime_error(_("Invalid format or too large value")); snprintf(servername, sizeof(decodingBuffer), "%s", decodingBuffer); invalidParameterName = false; diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx index 78a44f12..df3b8964 100644 --- a/vncviewer/vncviewer.cxx +++ b/vncviewer/vncviewer.cxx @@ -55,7 +55,6 @@ #include <rfb/Hostname.h> #include <rfb/LogWriter.h> #include <rfb/Timer.h> -#include <rfb/Exception.h> #include <rdr/Exception.h> #include <network/TcpSocket.h> #include <os/os.h> @@ -757,7 +756,7 @@ int main(int argc, char** argv) createTcpListeners(&listeners, nullptr, port); if (listeners.empty()) - throw Exception(_("Unable to listen for incoming connections")); + throw std::runtime_error(_("Unable to listen for incoming connections")); vlog.info(_("Listening on port %d"), port); |