int sock;
if ((sock = socket (listenaddr->sa_family, SOCK_STREAM, 0)) < 0)
- throw socket_error("unable to create listening socket", errorNumber);
- throw SocketException("Unable to create listening socket", errorNumber);
++ throw socket_error("Unable to create listening socket", errorNumber);
memcpy (&sa, listenaddr, listenaddrlen);
#ifdef IPV6_V6ONLY
if (setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&one, sizeof(one))) {
int e = errorNumber;
closesocket(sock);
- throw socket_error("unable to set IPV6_V6ONLY", e);
- throw SocketException("Unable to set IPV6_V6ONLY", e);
++ throw socket_error("Unable to set IPV6_V6ONLY", e);
}
}
#endif /* defined(IPV6_V6ONLY) */
(char *)&one, sizeof(one)) < 0) {
int e = errorNumber;
closesocket(sock);
- throw socket_error("unable to create listening socket", e);
- throw SocketException("Unable to create listening socket", e);
++ throw socket_error("Unable to create listening socket", e);
}
#endif
if (bind(sock, &sa.u.sa, listenaddrlen) == -1) {
int e = errorNumber;
closesocket(sock);
- throw socket_error("failed to bind socket", e);
- throw SocketException("Failed to bind socket", e);
++ throw socket_error("Failed to bind socket", e);
}
listen(sock);
snprintf (service, sizeof (service) - 1, "%d", port);
service[sizeof (service) - 1] = '\0';
if ((result = getaddrinfo(addr, service, &hints, &ai)) != 0)
- throw getaddrinfo_error("unable to resolve listening address", result);
- throw GAIException("Unable to resolve listening address", result);
++ throw getaddrinfo_error("Unable to resolve listening address", result);
try {
createTcpListeners(listeners, ai);
}
if ((result = getaddrinfo (parts[0].c_str(), nullptr, &hints, &ai)) != 0) {
- throw getaddrinfo_error("unable to resolve host by name", result);
- throw GAIException("Unable to resolve host by name", result);
++ throw getaddrinfo_error("Unable to resolve host by name", result);
}
memcpy (&pattern.address.u.sa, ai->ai_addr, ai->ai_addrlen);
if (parts.size() > 1) {
if (family == AF_INET &&
(parts[1].find('.') != std::string::npos)) {
- throw std::invalid_argument("mask no longer supported for "
- throw Exception("Mask no longer supported for filter, "
- "use prefix instead");
++ throw std::invalid_argument("Mask no longer supported for "
+ "filter, use prefix instead");
}
pattern.prefixlen = (unsigned int) atoi(parts[1].c_str());
}
if (result == -1)
- throw socket_error("unable to connect to socket", err);
- throw SocketException("Unable to connect to socket", err);
++ throw socket_error("Unable to connect to socket", err);
setFd(sock);
}
// - Create a socket
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
- throw socket_error("unable to create listening socket", errno);
- throw SocketException("Unable to create listening socket", errno);
++ throw socket_error("Unable to create listening socket", errno);
// - Delete existing socket (ignore result)
unlink(path);
umask(saved_umask);
if (result < 0) {
close(fd);
- throw socket_error("unable to bind listening socket", err);
- throw SocketException("Unable to bind listening socket", err);
++ throw socket_error("Unable to bind listening socket", err);
}
// - Set socket mode
if (chmod(path, mode) < 0) {
err = errno;
close(fd);
- throw socket_error("unable to set socket mode", err);
- throw SocketException("Unable to set socket mode", err);
++ throw socket_error("Unable to set socket mode", err);
}
listen(fd);
#ifdef RFB_HAVE_WINCRYPT
if (provider) {
if (!CryptGenRandom(provider, availSpace(), (uint8_t*)end))
- throw rdr::win32_error("unable to CryptGenRandom", GetLastError());
- throw rdr::Win32Exception("Unable to CryptGenRandom", GetLastError());
++ throw rdr::win32_error("Unable to CryptGenRandom", GetLastError());
end += availSpace();
} else {
#else
if (fp) {
size_t n = fread((uint8_t*)end, 1, availSpace(), fp);
if (n <= 0)
- throw rdr::posix_error("reading /dev/urandom or /dev/random "
- throw rdr::PosixException("Reading /dev/urandom or /dev/random failed",
- errno);
++ throw rdr::posix_error("Reading /dev/urandom or /dev/random "
+ "failed", errno);
end += n;
} else {
#else
securityCompleted();
return true;
case secResultFailed:
- vlog.debug("auth failed");
+ vlog.debug("Auth failed");
break;
case secResultTooMany:
- vlog.debug("auth failed - too many tries");
+ vlog.debug("Auth failed: Too many tries");
break;
default:
- throw Exception("Unknown security result from server");
+ throw protocol_error("Unknown security result from server");
}
if (server.beforeVersion(3,8)) {
err = gnutls_certificate_verify_peers2(session, &status);
if (err != 0) {
- vlog.error("server certificate verification failed: %s", gnutls_strerror(err));
+ vlog.error("Server certificate verification failed: %s", gnutls_strerror(err));
- throw rdr::TLSException("server certificate verification()", err);
+ throw rdr::tls_error("server certificate verification()", err);
}
if (status != 0) {
LOCK_CONFIG;
if (immutable) return true;
if (!v)
- throw rfb::Exception("setParam(<null>) not allowed");
+ throw std::invalid_argument("setParam(<null>) not allowed");
- vlog.debug("set %s(String) to %s", getName(), v);
+ vlog.debug("Set %s(String) to %s", getName(), v);
value = v;
return true;
}
// - Set the new clipboard data
if (!SetClipboardData(CF_UNICODETEXT, clip_handle))
- throw rdr::Win32Exception("unable to set Win32 clipboard", GetLastError());
+ throw rdr::win32_error("unable to set Win32 clipboard", GetLastError());
clip_handle = nullptr;
- vlog.debug("set clipboard");
+ vlog.debug("Set clipboard");
- } catch (rdr::Exception& e) {
- vlog.debug("%s", e.str());
+ } catch (std::exception& e) {
+ vlog.debug("%s", e.what());
}
// - Close the clipboard
bMask = 0x0000ff;
break;
default:
- vlog.error("bits per pixel %u not supported", bi.bmiHeader.biBitCount);
+ vlog.error("Bits per pixel %u not supported", bi.bmiHeader.biBitCount);
- throw rdr::Exception("unknown bits per pixel specified");
+ throw std::invalid_argument("unknown bits per pixel specified");
};
break;
case BI_BITFIELDS:
memset(mi, 0, sizeof(MONITORINFOEXA));
mi->cbSize = sizeof(MONITORINFOEXA);
if (!GetMonitorInfo(monitor, mi))
- throw rdr::Win32Exception("failed to GetMonitorInfo", GetLastError());
+ throw rdr::win32_error("failed to GetMonitorInfo", GetLastError());
- vlog.debug("monitor is %ld,%ld-%ld,%ld", mi->rcMonitor.left, mi->rcMonitor.top, mi->rcMonitor.right, mi->rcMonitor.bottom);
- vlog.debug("work area is %ld,%ld-%ld,%ld", mi->rcWork.left, mi->rcWork.top, mi->rcWork.right, mi->rcWork.bottom);
- vlog.debug("device is \"%s\"", mi->szDevice);
+ vlog.debug("Monitor is %ld,%ld-%ld,%ld", mi->rcMonitor.left, mi->rcMonitor.top, mi->rcMonitor.right, mi->rcMonitor.bottom);
+ vlog.debug("Work area is %ld,%ld-%ld,%ld", mi->rcWork.left, mi->rcWork.top, mi->rcWork.right, mi->rcWork.bottom);
+ vlog.debug("Device is \"%s\"", mi->szDevice);
}
try {
result = _this->processMessage(msg, wParam, lParam);
- } catch (rdr::Exception& e) {
- vlog.error("Untrapped: %s", e.str());
+ } catch (std::exception& e) {
- vlog.error("untrapped: %s", e.what());
++ vlog.error("Untrapped: %s", e.what());
}
return result;
name.c_str(), WS_OVERLAPPED, 0, 0, 10, 10,
nullptr, nullptr, baseClass.instance, this);
if (!handle) {
- throw rdr::Win32Exception("unable to create WMNotifier window instance", GetLastError());
+ throw rdr::win32_error("unable to create WMNotifier window instance", GetLastError());
}
- vlog.debug("created window \"%s\" (%p)", name.c_str(), handle);
+ vlog.debug("Created window \"%s\" (%p)", name.c_str(), handle);
}
MsgWindow::~MsgWindow() {
if (!name) break;
std::string value = key.getRepresentation(name);
if (!Configuration::setParam(name, value.c_str()))
- vlog.info("unable to process %s", name);
+ vlog.info("Unable to process %s", name);
}
- } catch (rdr::Win32Exception& e) {
+ } catch (rdr::win32_error& e) {
if (e.err != ERROR_INVALID_HANDLE)
- vlog.error("%s", e.str());
+ vlog.error("%s", e.what());
}
}
RegKey::RegKey(const HKEY k) : key(nullptr), freeKey(false), valueName(nullptr), valueNameBufLen(0) {
LONG result = RegOpenKeyEx(k, nullptr, 0, KEY_ALL_ACCESS, &key);
if (result != ERROR_SUCCESS)
- throw rdr::Win32Exception("RegOpenKeyEx(HKEY)", result);
+ throw rdr::win32_error("RegOpenKeyEx(HKEY)", result);
- vlog.debug("duplicated %p to %p", k, key);
+ vlog.debug("Duplicated %p to %p", k, key);
freeKey = true;
}
RegKey::RegKey(const RegKey& k) : key(nullptr), freeKey(false), valueName(nullptr), valueNameBufLen(0) {
LONG result = RegOpenKeyEx(k.key, nullptr, 0, KEY_ALL_ACCESS, &key);
if (result != ERROR_SUCCESS)
- throw rdr::Win32Exception("RegOpenKeyEx(RegKey&)", result);
+ throw rdr::win32_error("RegOpenKeyEx(RegKey&)", result);
- vlog.debug("duplicated %p to %p", k.key, key);
+ vlog.debug("Duplicated %p to %p", k.key, key);
freeKey = true;
}
try {
// Start a new Core if possible
startCore();
- vlog.info("restarted");
+ vlog.info("Restarted");
- } catch (rdr::Exception& e) {
+ } catch (std::exception& e) {
// If startCore() fails then we MUST disconnect all clients,
// to cause the server to stop() the desktop.
// Otherwise, the SDesktop is in an inconsistent state
entry[0].lpServiceProc = serviceProc;
entry[1].lpServiceName = nullptr;
entry[1].lpServiceProc = nullptr;
- vlog.debug("entering dispatcher");
+ vlog.debug("Entering dispatcher");
if (!SetProcessShutdownParameters(0x100, 0))
- vlog.error("unable to set shutdown parameters: %lu", GetLastError());
+ vlog.error("Unable to set shutdown parameters: %lu", GetLastError());
service = this;
if (!StartServiceCtrlDispatcher(entry))
- throw win32_error("unable to start service", GetLastError());
- throw Win32Exception("Unable to start service", GetLastError());
++ throw win32_error("Unable to start service", GetLastError());
}
void
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CREATE_SERVICE);
if (!scm)
- throw rdr::win32_error("unable to open Service Control Manager", GetLastError());
- throw rdr::Win32Exception("Unable to open service control manager", GetLastError());
++ throw rdr::win32_error("Unable to open Service Control Manager", GetLastError());
// - Add the service
ServiceHandle handle = CreateService(scm,
SERVICE_AUTO_START, SERVICE_ERROR_IGNORE,
cmdline.c_str(), nullptr, nullptr, nullptr, nullptr, nullptr);
if (!handle)
- throw rdr::win32_error("unable to create service", GetLastError());
- throw rdr::Win32Exception("Unable to create service", GetLastError());
++ throw rdr::win32_error("Unable to create service", GetLastError());
// - Set a description
SERVICE_DESCRIPTION sdesc = {(LPTSTR)desc};
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CREATE_SERVICE);
if (!scm)
- throw rdr::win32_error("unable to open Service Control Manager", GetLastError());
- throw rdr::Win32Exception("Unable to open service control manager", GetLastError());
++ throw rdr::win32_error("Unable to open Service Control Manager", GetLastError());
// - Create the service
ServiceHandle handle = OpenService(scm, name, SC_MANAGER_ALL_ACCESS);
if (!handle)
- throw rdr::win32_error("unable to locate the service", GetLastError());
- throw rdr::Win32Exception("Unable to locate the service", GetLastError());
++ throw rdr::win32_error("Unable to locate the service", GetLastError());
if (!DeleteService(handle))
- throw rdr::win32_error("unable to remove the service", GetLastError());
- throw rdr::Win32Exception("Unable to remove the service", GetLastError());
++ throw rdr::win32_error("Unable to remove the service", GetLastError());
// - Register the event log source
RegKey hk;
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
if (!scm)
- throw rdr::win32_error("unable to open Service Control Manager", GetLastError());
- throw rdr::Win32Exception("Unable to open service control manager", GetLastError());
++ throw rdr::win32_error("Unable to open Service Control Manager", GetLastError());
// - Locate the service
ServiceHandle handle = OpenService(scm, name, SERVICE_START);
if (!handle)
- throw rdr::win32_error("unable to open the service", GetLastError());
- throw rdr::Win32Exception("Unable to open the service", GetLastError());
++ throw rdr::win32_error("Unable to open the service", GetLastError());
// - Start the service
if (!StartService(handle, 0, nullptr))
- throw rdr::win32_error("unable to start the service", GetLastError());
- throw rdr::Win32Exception("Unable to start the service", GetLastError());
++ throw rdr::win32_error("Unable to start the service", GetLastError());
Sleep(500);
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
if (!scm)
- throw rdr::win32_error("unable to open Service Control Manager", GetLastError());
- throw rdr::Win32Exception("Unable to open service control manager", GetLastError());
++ throw rdr::win32_error("Unable to open Service Control Manager", GetLastError());
// - Locate the service
ServiceHandle handle = OpenService(scm, name, SERVICE_STOP);
if (!handle)
- throw rdr::win32_error("unable to open the service", GetLastError());
- throw rdr::Win32Exception("Unable to open the service", GetLastError());
++ throw rdr::win32_error("Unable to open the service", GetLastError());
// - Start the service
SERVICE_STATUS status;
if (!ControlService(handle, SERVICE_CONTROL_STOP, &status))
- throw rdr::win32_error("unable to stop the service", GetLastError());
- throw rdr::Win32Exception("Unable to stop the service", GetLastError());
++ throw rdr::win32_error("Unable to stop the service", GetLastError());
Sleep(500);
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
if (!scm)
- throw rdr::win32_error("unable to open Service Control Manager", GetLastError());
- throw rdr::Win32Exception("Unable to open service control manager", GetLastError());
++ throw rdr::win32_error("Unable to open Service Control Manager", GetLastError());
// - Locate the service
ServiceHandle handle = OpenService(scm, name, SERVICE_INTERROGATE);
if (!handle)
- throw rdr::win32_error("unable to open the service", GetLastError());
- throw rdr::Win32Exception("Unable to open the service", GetLastError());
++ throw rdr::win32_error("Unable to open the service", GetLastError());
// - Get the service status
SERVICE_STATUS status;
if (!ControlService(handle, SERVICE_CONTROL_INTERROGATE, (SERVICE_STATUS*)&status))
- throw rdr::win32_error("unable to query the service", GetLastError());
- throw rdr::Win32Exception("Unable to query the service", GetLastError());
++ throw rdr::win32_error("Unable to query the service", GetLastError());
return status.dwCurrentState;
}
// Fetch why this event notification triggered
if (WSAEnumNetworkEvents(ci.sock->getFd(), event, &network_events) == SOCKET_ERROR)
- throw rdr::socket_error("unable to get WSAEnumNetworkEvents:%u", WSAGetLastError());
- throw rdr::SocketException("Unable to get WSAEnumNetworkEvents:%u", WSAGetLastError());
++ throw rdr::socket_error("Unable to get WSAEnumNetworkEvents:%u", WSAGetLastError());
// Cancel event notification for this socket
if (WSAEventSelect(ci.sock->getFd(), event, 0) == SOCKET_ERROR)
try {
RegKey userKey;
userKey.openKey(winvnc3, "Default");
- vlog.info("loading Default prefs");
+ vlog.info("Loading default prefs");
LoadUserPrefs(userKey);
- } catch(rdr::Exception& e) {
- vlog.error("Error reading default settings:%s", e.str());
+ } catch(std::exception& e) {
- vlog.error("error reading Default settings:%s", e.what());
++ vlog.error("Error reading Default settings:%s", e.what());
}
// Open the local, user-specific settings
try {
RegKey userKey;
userKey.openKey(winvnc3, username.c_str());
- vlog.info("loading local User prefs");
+ vlog.info("Loading local user prefs");
LoadUserPrefs(userKey);
- } catch(rdr::Exception& e) {
- vlog.error("Error reading local user settings:%s", e.str());
+ } catch(std::exception& e) {
- vlog.error("error reading local User settings:%s", e.what());
++ vlog.error("Error reading local User settings:%s", e.what());
}
// Open the user's own settings
try {
RegKey userKey;
userKey.openKey(HKEY_CURRENT_USER, "Software\\ORL\\WinVNC3");
- vlog.info("loading global User prefs");
+ vlog.info("Loading global user prefs");
LoadUserPrefs(userKey);
- } catch(rdr::Exception& e) {
- vlog.error("Error reading global user settings:%s", e.str());
+ } catch(std::exception& e) {
- vlog.error("error reading global User settings:%s", e.what());
++ vlog.error("Error reading global User settings:%s", e.what());
}
}
}