uid_t uid;
struct passwd *passwd;
#else
- TCHAR *dir;
+ char *dir;
BOOL ret;
#endif
else
memcpy(dir + len, "/.vnc/\0", 7);
#else
- dir = new TCHAR[MAX_PATH];
+ dir = new char[MAX_PATH];
if (dir == NULL)
return -1;
if (userDir)
dir[strlen(dir)+1] = '\0';
else
- memcpy(dir+strlen(dir), (TCHAR *)"\\vnc\\\0", 6);
+ memcpy(dir+strlen(dir), "\\vnc\\\0", 6);
#endif
*dirp = dir;
return 0;
* If HOME environment variable is set then it is used.
* Otherwise home directory is obtained via getpwuid function.
*
- * Note for Windows:
- * This functions returns array of TCHARs, not array of chars.
- *
* Returns:
* 0 - Success
* -1 - Failure
* If HOME environment variable is set then it is used.
* Otherwise home directory is obtained via getpwuid function.
*
- * Note for Windows:
- * This functions returns array of TCHARs, not array of chars.
- *
* Returns:
* 0 - Success
* -1 - Failure
#include <rdr/Exception.h>
#include <rdr/TLSException.h>
#ifdef _WIN32
-#include <tchar.h>
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>
#include <rfb/WinPasswdValidator.h>
#include <windows.h>
-#include <tchar.h>
using namespace rfb;
const char* username,
const char* password)
{
- TCHAR* user = (TCHAR*) strDup(username);
- TCHAR* pass = (TCHAR*) strDup(password);
- TCHAR* domain = (TCHAR*) strDup(".");
+ char* user = strDup(username);
+ char* pass = strDup(password);
+ char* domain = strDup(".");
HANDLE handle;
BOOL ret = LogonUser(user, domain, pass, LOGON32_LOGON_NETWORK,
#ifdef _WIN32
#include <windows.h>
-#include <tchar.h>
#endif
#include "parameters.h"
#include <rfb_win32/AboutDialog.h>
#include <rfb_win32/Win32Util.h>
-#include <rfb_win32/TCharArray.h>
#include <rfb/LogWriter.h>
using namespace rfb;
void AboutDialog::initDialog() {
// Set the build time field
- SetWindowText(GetDlgItem(handle, BuildTime), TStr(buildTime));
+ SetWindowText(GetDlgItem(handle, BuildTime), buildTime);
// Get our executable's version info
FileVersionInfo verInfo;
- SetWindowText(GetDlgItem(handle, Version), verInfo.getVerString(_T("ProductVersion")));
- SetWindowText(GetDlgItem(handle, Copyright), verInfo.getVerString(_T("LegalCopyright")));
- SetWindowText(GetDlgItem(handle, Description), verInfo.getVerString(_T("ProductName")));
+ SetWindowText(GetDlgItem(handle, Version), verInfo.getVerString("ProductVersion"));
+ SetWindowText(GetDlgItem(handle, Copyright), verInfo.getVerString("LegalCopyright"));
+ SetWindowText(GetDlgItem(handle, Description), verInfo.getVerString("ProductName"));
}
Service.cxx
SInput.cxx
SocketManager.cxx
- TCharArray.cxx
TsSessions.cxx
Win32Util.cxx
WMCursor.cxx
return false;
}
item.fChecked = enable_;
- vlog.debug("%sbling %d: \"%s\"", enable_ ? "ena" : "disa", i, (const char*)CStr(item.wszFriendlyName));
hr = handle->ModifyDesktopItem(&item, COMP_ELEM_CHECKED);
return hr == S_OK;
vlog.debug("restore desktop effects");
RegKey desktopCfg;
- desktopCfg.openKey(HKEY_CURRENT_USER, _T("Control Panel\\Desktop"));
- SysParamsInfo(SPI_SETFONTSMOOTHING, desktopCfg.getInt(_T("FontSmoothing"), 0) != 0, 0, SPIF_SENDCHANGE);
+ desktopCfg.openKey(HKEY_CURRENT_USER, "Control Panel\\Desktop");
+ SysParamsInfo(SPI_SETFONTSMOOTHING, desktopCfg.getInt("FontSmoothing", 0) != 0, 0, SPIF_SENDCHANGE);
if (SysParamsInfo(SPI_SETUIEFFECTS, 0, (void*)(intptr_t)uiEffects, SPIF_SENDCHANGE) == ERROR_CALL_NOT_IMPLEMENTED) {
SysParamsInfo(SPI_SETCOMBOBOXANIMATION, 0, (void*)(intptr_t)comboBoxAnim, SPIF_SENDCHANGE);
SysParamsInfo(SPI_SETGRADIENTCAPTIONS, 0, (void*)(intptr_t)gradientCaptions, SPIF_SENDCHANGE);
#ifndef __RFB_WIN32_CLEANDESKTOP_H__
#define __RFB_WIN32_CLEANDESKTOP_H__
-#include <rfb_win32/TCharArray.h>
-
namespace rfb {
namespace win32 {
//
Clipboard::Clipboard()
- : MsgWindow(_T("Clipboard")), notifier(0), next_window(0) {
+ : MsgWindow("Clipboard"), notifier(0), next_window(0) {
next_window = SetClipboardViewer(getHandle());
vlog.debug("registered clipboard handler");
}
#define __RFB_WIN32_COMPUTERNAME_H__
#include <windows.h>
-#include <rfb_win32/TCharArray.h>
+#include <rfb/util.h>
namespace rfb {
namespace win32 {
// Get the computer name
- struct ComputerName : TCharArray {
- ComputerName() : TCharArray(MAX_COMPUTERNAME_LENGTH+1) {
+ struct ComputerName : CharArray {
+ ComputerName() : CharArray(MAX_COMPUTERNAME_LENGTH+1) {
ULONG namelength = MAX_COMPUTERNAME_LENGTH+1;
if (!GetComputerName(buf, &namelength))
- _tcscpy(buf, _T(""));
+ strcpy(buf, "");
}
};
static LogWriter vlog("CurrentUser");
-const TCHAR* shellIconClass = _T("Shell_TrayWnd");
+const char* shellIconClass = "Shell_TrayWnd";
BOOL CALLBACK enumWindows(HWND hwnd, LPARAM lParam) {
- TCHAR className[16];
+ char className[16];
if (GetClassName(hwnd, className, sizeof(className)) &&
- (_tcscmp(className, shellIconClass) == 0)) {
- vlog.debug("located tray icon window (%s)", (const char*)CStr(className));
+ (strcmp(className, shellIconClass) == 0)) {
+ vlog.debug("located tray icon window (%s)", className);
DWORD processId = 0;
GetWindowThreadProcessId(hwnd, &processId);
if (!processId)
HDESK desktop = OpenDesktop(lpszDesktop, 0, FALSE, DESKTOP_ENUMERATE);
vlog.debug("opening \"%s\"", lpszDesktop);
if (!desktop) {
- vlog.info("desktop \"%s\" inaccessible", (const char*)CStr(lpszDesktop));
+ vlog.info("desktop \"%s\" inaccessible", lpszDesktop);
return TRUE;
}
BOOL result = EnumDesktopWindows(desktop, enumWindows, lParam);
}
-UserName::UserName() : TCharArray(UNLEN+1) {
+UserName::UserName() : CharArray(UNLEN+1) {
DWORD len = UNLEN+1;
if (!GetUserName(buf, &len))
throw rdr::SystemException("GetUserName failed", GetLastError());
#ifndef __RFB_WIN32_CURRENT_USER_H__
#define __RFB_WIN32_CURRENT_USER_H__
+#include <rfb/util.h>
#include <rfb_win32/Handle.h>
#include <rfb_win32/Security.h>
// Returns the name of the user the thread is currently running as.
// Raises a SystemException in case of error.
- struct UserName : public TCharArray {
+ struct UserName : public CharArray {
UserName();
};
}
-DeviceDC::DeviceDC(const TCHAR* deviceName) {
- dc = ::CreateDC(_T("DISPLAY"), deviceName, NULL, NULL);
+DeviceDC::DeviceDC(const char* deviceName) {
+ dc = ::CreateDC("DISPLAY", deviceName, NULL, NULL);
if (!dc)
throw rdr::SystemException("failed to create DeviceDC", GetLastError());
}
#include <windows.h>
#include <rfb/PixelFormat.h>
#include <rfb/Rect.h>
-#include <rfb_win32/TCharArray.h>
namespace rfb {
// -=- DeviceContext that opens a specific display device
class DeviceDC : public DeviceContext {
public:
- DeviceDC(const TCHAR* deviceName);
+ DeviceDC(const char* deviceName);
~DeviceDC();
};
#endif
#include <rfb_win32/Dialog.h>
-#include <rfb_win32/TCharArray.h>
#include <rfb/LogWriter.h>
#include <rdr/Exception.h>
#include <rfb_win32/Win32Util.h>
}
-bool Dialog::showDialog(const TCHAR* resource, HWND owner)
+bool Dialog::showDialog(const char* resource, HWND owner)
{
if (alreadyShowing) return false;
handle = 0;
throw rdr::Exception("unable to read dialog Int");
return result;
}
-TCHAR* Dialog::getItemString(int id) {
- TCharArray tmp(256);
+char* Dialog::getItemString(int id) {
+ CharArray tmp(256);
if (!GetDlgItemText(handle, id, tmp.buf, 256))
tmp.buf[0] = 0;
return tmp.takeBuf();
void Dialog::setItemInt(int id, int value) {
SetDlgItemInt(handle, id, value, TRUE);
}
-void Dialog::setItemString(int id, const TCHAR* s) {
+void Dialog::setItemString(int id, const char* s) {
SetDlgItemText(handle, id, s);
}
}
-PropSheetPage::PropSheetPage(HINSTANCE inst, const TCHAR* id) : Dialog(inst), propSheet(0) {
+PropSheetPage::PropSheetPage(HINSTANCE inst, const char* id) : Dialog(inst), propSheet(0) {
page.dwSize = sizeof(page);
page.dwFlags = 0; // PSP_USECALLBACK;
page.hInstance = inst;
}
-PropSheet::PropSheet(HINSTANCE inst_, const TCHAR* title_, std::list<PropSheetPage*> pages_, HICON icon_)
-: icon(icon_), pages(pages_), inst(inst_), title(tstrDup(title_)), handle(0), alreadyShowing(0) {
+PropSheet::PropSheet(HINSTANCE inst_, const char* title_, std::list<PropSheetPage*> pages_, HICON icon_)
+: icon(icon_), pages(pages_), inst(inst_), title(strDup(title_)), handle(0), alreadyShowing(0) {
}
PropSheet::~PropSheet() {
(void)capture;
#ifdef _DIALOG_CAPTURE
if (capture) {
- plog.info("capturing \"%s\"", (const char*)CStr(title.buf));
+ plog.info("capturing \"%s\"", title.buf);
char* tmpdir = getenv("TEMP");
HDC dc = GetWindowDC(handle);
DeviceFrameBuffer fb(dc);
DispatchMessage(&msg);
}
fb.grabRect(fb.getRect());
- TCHAR title[128];
+ char title[128];
if (!GetWindowText(PropSheet_GetCurrentPageHwnd(handle), title, sizeof(title)))
- _stprintf(title, _T("capture%d"), i);
+ sprintf(title, "capture%d", i);
CharArray pageTitle(strDup(title));
for (int j=0; j<strlen(pageTitle.buf); j++) {
if (pageTitle.buf[j] == '/' || pageTitle.buf[j] == '\\' || pageTitle.buf[j] == ':')
#include <windows.h>
#include <prsht.h>
#include <list>
-#include <rfb_win32/TCharArray.h>
+
+#include <rfb/util.h>
namespace rfb {
// expansion), and owner is an optional window handle - the corresponding
// window is disabled while the dialog box is displayed.
- bool showDialog(const TCHAR* resource, HWND owner=0);
+ bool showDialog(const char* resource, HWND owner=0);
// initDialog() is called upon receipt of the WM_INITDIALOG message.
// Read the states of items
bool isItemChecked(int id);
int getItemInt(int id);
- TCHAR* getItemString(int id); // Recipient owns string storage
+ char* getItemString(int id); // Recipient owns string storage
// Set the states of items
void setItemChecked(int id, bool state);
void setItemInt(int id, int value);
- void setItemString(int id, const TCHAR* s);
+ void setItemString(int id, const char* s);
// enableItem is used to grey out an item, making it inaccessible, or to
// re-enable it.
class PropSheet {
public:
- PropSheet(HINSTANCE inst, const TCHAR* title, std::list<PropSheetPage*> pages, HICON icon=0);
+ PropSheet(HINSTANCE inst, const char* title, std::list<PropSheetPage*> pages, HICON icon=0);
virtual ~PropSheet();
// Display the PropertySheet
HICON icon;
std::list<PropSheetPage*> pages;
HINSTANCE inst;
- TCharArray title;
+ CharArray title;
HWND handle;
bool alreadyShowing;
};
class PropSheetPage : public Dialog {
public:
- PropSheetPage(HINSTANCE inst, const TCHAR* id);
+ PropSheetPage(HINSTANCE inst, const char* id);
virtual ~PropSheetPage();
void setChanged(bool changed);
#include <config.h>
#endif
+#include <windows.h>
+
#include <rfb_win32/EventManager.h>
#include <rdr/Exception.h>
#include <rfb/LogWriter.h>
using namespace win32;
-LaunchProcess::LaunchProcess(const TCHAR* exeName_, const TCHAR* params_)
-: exeName(tstrDup(exeName_)), params(tstrDup(params_)) {
+LaunchProcess::LaunchProcess(const char* exeName_, const char* params_)
+: exeName(strDup(exeName_)), params(strDup(params_)) {
memset(&procInfo, 0, sizeof(procInfo));
}
sinfo.lpDesktop = desktopName;
// - Concoct a suitable command-line
- TCharArray exePath;
- if (!tstrContains(exeName.buf, _T('\\'))) {
+ CharArray exePath;
+ if (!strContains(exeName.buf, '\\')) {
ModuleFileName filename;
- TCharArray path; splitPath(filename.buf, &path.buf, 0);
- exePath.buf = new TCHAR[_tcslen(path.buf) + _tcslen(exeName.buf) + 2];
- _stprintf(exePath.buf, _T("%s\\%s"), path.buf, exeName.buf);
+ CharArray path; splitPath(filename.buf, &path.buf, 0);
+ exePath.buf = new char[strlen(path.buf) + strlen(exeName.buf) + 2];
+ sprintf(exePath.buf, "%s\\%s", path.buf, exeName.buf);
} else {
- exePath.buf = tstrDup(exeName.buf);
+ exePath.buf = strDup(exeName.buf);
}
// - Start the process
// Note: We specify the exe's precise path in the ApplicationName parameter,
// AND include the name as the first part of the CommandLine parameter,
// because CreateProcess doesn't make ApplicationName argv[0] in C programs.
- TCharArray cmdLine(_tcslen(exeName.buf) + 3 + _tcslen(params.buf) + 1);
- _stprintf(cmdLine.buf, _T("\"%s\" %s"), exeName.buf, params.buf);
+ CharArray cmdLine(strlen(exeName.buf) + 3 + strlen(params.buf) + 1);
+ sprintf(cmdLine.buf, "\"%s\" %s", exeName.buf, params.buf);
DWORD flags = createConsole ? CREATE_NEW_CONSOLE : CREATE_NO_WINDOW;
BOOL success;
if (userToken != INVALID_HANDLE_VALUE)
#define __RFB_WIN32_LAUNCHPROCESS_H__
#include <windows.h>
-#include <rfb_win32/TCharArray.h>
+
+#include <rfb/util.h>
namespace rfb {
class LaunchProcess {
public:
- LaunchProcess(const TCHAR* exeName_, const TCHAR* params);
+ LaunchProcess(const char* exeName_, const char* params);
~LaunchProcess();
// start() starts the specified process with the supplied
PROCESS_INFORMATION procInfo;
DWORD returnCode;
protected:
- TCharArray exeName;
- TCharArray params;
+ CharArray exeName;
+ CharArray params;
};
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <tchar.h>
#include "ListViewControl.h"
#include "commctrl.h"
//////////////////////////////////////////////////////////////////////
}
BOOL ListViewControl::InitLVColumns(DWORD idListView, HWND hDlg, int width, int columns,
- TCHAR *title[], DWORD mask, DWORD LVStyle, DWORD format)
+ char *title[], DWORD mask, DWORD LVStyle, DWORD format)
{
(void)ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, idListView), LVStyle);
- TCHAR szText[256];
+ char szText[256];
LVCOLUMN lvc;
int iCol;
lvc.cx = width;
lvc.fmt = format;
- _tcscpy(szText, title[iCol]);
+ strcpy(szText, title[iCol]);
if (ListView_InsertColumn(GetDlgItem(hDlg, idListView), iCol, &lvc) == -1)
return FALSE;
}
return TRUE;
}
-BOOL ListViewControl::InsertLVItem(DWORD idListView, HWND hDlg, int number, TCHAR * texts[],
+BOOL ListViewControl::InsertLVItem(DWORD idListView, HWND hDlg, int number, char * texts[],
int columns)
{
int i;
}
void ListViewControl::SetLVItemText(DWORD idListView, HWND hDlg, int numberItem,
- int namberColumn, TCHAR * text)
+ int namberColumn, char * text)
{
ListView_SetItemText(
GetDlgItem(hDlg, idListView),
}
void ListViewControl::GetLVItemText(DWORD idListView, HWND hDlg, int numberItem,
- int namberColumn, TCHAR * text)
+ int namberColumn, char * text)
{
ListView_GetItemText(GetDlgItem(hDlg, idListView), numberItem,
namberColumn, text, 256);
bool IsSelectedLVItem(DWORD idListView, HWND hDlg, int numberItem);
void SelectLVItem(DWORD idListView, HWND hDlg, int numberItem);
BOOL InitLVColumns(DWORD idListView, HWND hDlg, int width, int columns,
- TCHAR * title[], DWORD mask, DWORD style, DWORD format);
- BOOL InsertLVItem(DWORD idListView, HWND hDlg, int number, TCHAR * texts[],
+ char * title[], DWORD mask, DWORD style, DWORD format);
+ BOOL InsertLVItem(DWORD idListView, HWND hDlg, int number, char * texts[],
int columns);
void SetLVItemText(DWORD idListView, HWND hDlg, int numberItem,
- int namberColumn, TCHAR * text);
+ int namberColumn, char * text);
void GetLVItemText(DWORD idListView, HWND hDlg, int numberItem,
- int namberColumn, TCHAR * text);
+ int namberColumn, char * text);
void DeleteLVItem(DWORD idListView, HWND hDlg, int number);
void DeleteAllLVItem(DWORD idListView, HWND hDlg);
virtual ~ListViewControl();
#define __RFB_WIN32_MODULE_FILENAME_H__
#include <windows.h>
-#include <rfb_win32/TCharArray.h>
+
+#include <rfb/util.h>
namespace rfb {
namespace win32 {
- struct ModuleFileName : public TCharArray {
- ModuleFileName(HMODULE module=0) : TCharArray(MAX_PATH) {
+ struct ModuleFileName : public CharArray {
+ ModuleFileName(HMODULE module=0) : CharArray(MAX_PATH) {
if (!module)
module = GetModuleHandle(0);
if (!GetModuleFileName(module, buf, MAX_PATH))
#include <config.h>
#endif
-#include <tchar.h>
#include <rfb_win32/MonitorInfo.h>
#include <rfb_win32/Win32Util.h>
#include <rdr/Exception.h>
#define __RFB_WIN32_MSGBOX_H__
#include <windows.h>
-#include <rfb_win32/TCharArray.h>
+
+#include <rfb/util.h>
namespace rfb {
namespace win32 {
// Message box titles are based on the (standard Win32) flags
// passed to the MsgBox helper function.
- extern TStr AppName;
+ extern const char* AppName;
// Wrapper around Win32 MessageBox()
- static int MsgBox(HWND parent, const TCHAR* msg, UINT flags) {
- const TCHAR* msgType = 0;
+ static int MsgBox(HWND parent, const char* msg, UINT flags) {
+ const char* msgType = 0;
UINT tflags = flags & 0x70;
if (tflags == MB_ICONHAND)
- msgType = _T("Error");
+ msgType = "Error";
else if (tflags == MB_ICONQUESTION)
- msgType = _T("Question");
+ msgType = "Question";
else if (tflags == MB_ICONEXCLAMATION)
- msgType = _T("Warning");
+ msgType = "Warning";
else if (tflags == MB_ICONASTERISK)
- msgType = _T("Information");
+ msgType = "Information";
flags |= MB_TOPMOST | MB_SETFOREGROUND;
- int len = _tcslen(AppName.buf) + 1;
- if (msgType) len += _tcslen(msgType) + 3;
- TCharArray title(new TCHAR[len]);
- _tcscpy(title.buf, AppName.buf);
+ int len = strlen(AppName) + 1;
+ if (msgType) len += strlen(msgType) + 3;
+ CharArray title(new char[len]);
+ strcpy(title.buf, AppName);
if (msgType) {
- _tcscat(title.buf, _T(" : "));
- _tcscat(title.buf, msgType);
+ strcat(title.buf, " : ");
+ strcat(title.buf, msgType);
}
return MessageBox(parent, msg, title.buf, flags);
}
#include <rfb/LogWriter.h>
#include <rdr/Exception.h>
#include <malloc.h>
-#include <tchar.h>
using namespace rfb;
using namespace rfb::win32;
wndClass.hCursor = 0;
wndClass.hbrBackground = 0;
wndClass.lpszMenuName = 0;
- wndClass.lpszClassName = _T("rfb::win32::MsgWindowClass");
+ wndClass.lpszClassName = "rfb::win32::MsgWindowClass";
classAtom = RegisterClass(&wndClass);
if (!classAtom) {
throw rdr::SystemException("unable to register MsgWindow window class", GetLastError());
MsgWindowClass::~MsgWindowClass() {
if (classAtom) {
- UnregisterClass((const TCHAR*)(intptr_t)classAtom, instance);
+ UnregisterClass((const char*)(intptr_t)classAtom, instance);
}
}
// -=- MsgWindow
//
-MsgWindow::MsgWindow(const TCHAR* name_) : name(tstrDup(name_)), handle(0) {
- vlog.debug("creating window \"%s\"", (const char*)CStr(name.buf));
- handle = CreateWindow((const TCHAR*)(intptr_t)baseClass.classAtom,
+MsgWindow::MsgWindow(const char* name_) : name(strDup(name_)), handle(0) {
+ vlog.debug("creating window \"%s\"", name.buf);
+ handle = CreateWindow((const char*)(intptr_t)baseClass.classAtom,
name.buf, WS_OVERLAPPED, 0, 0, 10, 10, 0, 0,
baseClass.instance, this);
if (!handle) {
throw rdr::SystemException("unable to create WMNotifier window instance", GetLastError());
}
- vlog.debug("created window \"%s\" (%p)", (const char*)CStr(name.buf), handle);
+ vlog.debug("created window \"%s\" (%p)", name.buf, handle);
}
MsgWindow::~MsgWindow() {
if (handle)
DestroyWindow(handle);
- vlog.debug("destroyed window \"%s\" (%p)", (const char*)CStr(name.buf), handle);
+ vlog.debug("destroyed window \"%s\" (%p)", name.buf, handle);
}
LRESULT
#define __RFB_WIN32_MSG_WINDOW_H__
#include <windows.h>
-#include <rfb_win32/TCharArray.h>
+
+#include <rfb/util.h>
namespace rfb {
class MsgWindow {
public:
- MsgWindow(const TCHAR* _name);
+ MsgWindow(const char* _name);
virtual ~MsgWindow();
- const TCHAR* getName() {return name.buf;}
+ const char* getName() {return name.buf;}
HWND getHandle() const {return handle;}
virtual LRESULT processMessage(UINT msg, WPARAM wParam, LPARAM lParam);
protected:
- TCharArray name;
+ CharArray name;
HWND handle;
};
eventMgr->removeEvent(event);
}
-bool RegConfig::setKey(const HKEY rootkey, const TCHAR* keyname) {
+bool RegConfig::setKey(const HKEY rootkey, const char* keyname) {
try {
key.createKey(rootkey, keyname);
processEvent(event);
DWORD i = 0;
try {
while (1) {
- TCharArray name(tstrDup(key.getValueName(i++)));
+ CharArray name(strDup(key.getValueName(i++)));
if (!name.buf) break;
- TCharArray value(key.getRepresentation(name.buf));
- if (!value.buf || !Configuration::setParam(CStr(name.buf), CStr(value.buf)))
+ CharArray value(key.getRepresentation(name.buf));
+ if (!value.buf || !Configuration::setParam(name.buf, value.buf))
vlog.info("unable to process %s", name.buf);
}
} catch (rdr::SystemException& e) {
wait();
}
-bool RegConfigThread::start(const HKEY rootKey, const TCHAR* keyname) {
+bool RegConfigThread::start(const HKEY rootKey, const char* keyname) {
if (config.setKey(rootKey, keyname)) {
Thread::start();
while (thread_id == (DWORD)-1)
~RegConfig();
// Specify the registry key to read Configuration items from
- bool setKey(const HKEY rootkey, const TCHAR* keyname);
+ bool setKey(const HKEY rootkey, const char* keyname);
// Support for a callback, run in the RegConfig host thread whenever
// the registry configuration changes
~RegConfigThread();
// Start the thread, reading from the specified key
- bool start(const HKEY rootkey, const TCHAR* keyname);
+ bool start(const HKEY rootkey, const char* keyname);
protected:
virtual void worker();
EventManager eventMgr;
}
-bool RegKey::createKey(const RegKey& root, const TCHAR* name) {
+bool RegKey::createKey(const RegKey& root, const char* name) {
close();
LONG result = RegCreateKey(root.key, name, &key);
if (result != ERROR_SUCCESS) {
vlog.error("RegCreateKey(%p, %s): %lx", root.key, name, result);
throw rdr::SystemException("RegCreateKeyEx", result);
}
- vlog.debug("createKey(%p,%s) = %p", root.key, (const char*)CStr(name), key);
+ vlog.debug("createKey(%p,%s) = %p", root.key, name, key);
freeKey = true;
return true;
}
-void RegKey::openKey(const RegKey& root, const TCHAR* name, bool readOnly) {
+void RegKey::openKey(const RegKey& root, const char* name, bool readOnly) {
close();
LONG result = RegOpenKeyEx(root.key, name, 0, readOnly ? KEY_READ : KEY_ALL_ACCESS, &key);
if (result != ERROR_SUCCESS)
throw rdr::SystemException("RegOpenKeyEx (open)", result);
- vlog.debug("openKey(%p,%s,%s) = %p", root.key, (const char*)CStr(name),
+ vlog.debug("openKey(%p,%s,%s) = %p", root.key, name,
readOnly ? "ro" : "rw", key);
freeKey = true;
}
}
}
-void RegKey::deleteKey(const TCHAR* name) const {
+void RegKey::deleteKey(const char* name) const {
LONG result = RegDeleteKey(key, name);
if (result != ERROR_SUCCESS)
throw rdr::SystemException("RegDeleteKey", result);
}
-void RegKey::deleteValue(const TCHAR* name) const {
+void RegKey::deleteValue(const char* name) const {
LONG result = RegDeleteValue(key, name);
if (result != ERROR_SUCCESS)
throw rdr::SystemException("RegDeleteValue", result);
RegKey::operator HKEY() const {return key;}
-void RegKey::setExpandString(const TCHAR* valname, const TCHAR* value) const {
- LONG result = RegSetValueEx(key, valname, 0, REG_EXPAND_SZ, (const BYTE*)value, (_tcslen(value)+1)*sizeof(TCHAR));
+void RegKey::setExpandString(const char* valname, const char* value) const {
+ LONG result = RegSetValueEx(key, valname, 0, REG_EXPAND_SZ, (const BYTE*)value, (strlen(value)+1)*sizeof(char));
if (result != ERROR_SUCCESS) throw rdr::SystemException("setExpandString", result);
}
-void RegKey::setString(const TCHAR* valname, const TCHAR* value) const {
- LONG result = RegSetValueEx(key, valname, 0, REG_SZ, (const BYTE*)value, (_tcslen(value)+1)*sizeof(TCHAR));
+void RegKey::setString(const char* valname, const char* value) const {
+ LONG result = RegSetValueEx(key, valname, 0, REG_SZ, (const BYTE*)value, (strlen(value)+1)*sizeof(char));
if (result != ERROR_SUCCESS) throw rdr::SystemException("setString", result);
}
-void RegKey::setBinary(const TCHAR* valname, const void* value, size_t length) const {
+void RegKey::setBinary(const char* valname, const void* value, size_t length) const {
LONG result = RegSetValueEx(key, valname, 0, REG_BINARY, (const BYTE*)value, length);
if (result != ERROR_SUCCESS) throw rdr::SystemException("setBinary", result);
}
-void RegKey::setInt(const TCHAR* valname, int value) const {
+void RegKey::setInt(const char* valname, int value) const {
LONG result = RegSetValueEx(key, valname, 0, REG_DWORD, (const BYTE*)&value, sizeof(value));
if (result != ERROR_SUCCESS) throw rdr::SystemException("setInt", result);
}
-void RegKey::setBool(const TCHAR* valname, bool value) const {
+void RegKey::setBool(const char* valname, bool value) const {
setInt(valname, value ? 1 : 0);
}
-TCHAR* RegKey::getString(const TCHAR* valname) const {return getRepresentation(valname);}
-TCHAR* RegKey::getString(const TCHAR* valname, const TCHAR* def) const {
+char* RegKey::getString(const char* valname) const {return getRepresentation(valname);}
+char* RegKey::getString(const char* valname, const char* def) const {
try {
return getString(valname);
} catch(rdr::Exception&) {
- return tstrDup(def);
+ return strDup(def);
}
}
-std::vector<uint8_t> RegKey::getBinary(const TCHAR* valname) const {
- TCharArray hex(getRepresentation(valname));
- return hexToBin(CStr(hex.buf), strlen(CStr(hex.buf)));
+std::vector<uint8_t> RegKey::getBinary(const char* valname) const {
+ CharArray hex(getRepresentation(valname));
+ return hexToBin(hex.buf, strlen(hex.buf));
}
-std::vector<uint8_t> RegKey::getBinary(const TCHAR* valname, const uint8_t* def, size_t deflen) const {
+std::vector<uint8_t> RegKey::getBinary(const char* valname, const uint8_t* def, size_t deflen) const {
try {
return getBinary(valname);
} catch(rdr::Exception&) {
}
}
-int RegKey::getInt(const TCHAR* valname) const {
- TCharArray tmp(getRepresentation(valname));
- return _ttoi(tmp.buf);
+int RegKey::getInt(const char* valname) const {
+ CharArray tmp(getRepresentation(valname));
+ return atoi(tmp.buf);
}
-int RegKey::getInt(const TCHAR* valname, int def) const {
+int RegKey::getInt(const char* valname, int def) const {
try {
return getInt(valname);
} catch(rdr::Exception&) {
}
}
-bool RegKey::getBool(const TCHAR* valname) const {
+bool RegKey::getBool(const char* valname) const {
return getInt(valname) > 0;
}
-bool RegKey::getBool(const TCHAR* valname, bool def) const {
+bool RegKey::getBool(const char* valname, bool def) const {
return getInt(valname, def ? 1 : 0) > 0;
}
-static inline TCHAR* terminateData(char* data, int length)
+static inline char* terminateData(char* data, int length)
{
// We must terminate the string, just to be sure. Stupid Win32...
- int len = length/sizeof(TCHAR);
- TCharArray str(len+1);
+ int len = length/sizeof(char);
+ CharArray str(len+1);
memcpy(str.buf, data, length);
str.buf[len] = 0;
return str.takeBuf();
}
-TCHAR* RegKey::getRepresentation(const TCHAR* valname) const {
+char* RegKey::getRepresentation(const char* valname) const {
DWORD type, length;
LONG result = RegQueryValueEx(key, valname, 0, &type, 0, &length);
if (result != ERROR_SUCCESS)
switch (type) {
case REG_BINARY:
{
- TCharArray hex(binToHex((const uint8_t*)data.buf, length));
+ CharArray hex(binToHex((const uint8_t*)data.buf, length));
return hex.takeBuf();
}
case REG_SZ:
if (length) {
return terminateData(data.buf, length);
} else {
- return tstrDup(_T(""));
+ return strDup("");
}
case REG_DWORD:
{
- TCharArray tmp(16);
- _stprintf(tmp.buf, _T("%lu"), *((DWORD*)data.buf));
+ CharArray tmp(16);
+ sprintf(tmp.buf, "%lu", *((DWORD*)data.buf));
return tmp.takeBuf();
}
case REG_EXPAND_SZ:
{
if (length) {
- TCharArray str(terminateData(data.buf, length));
+ CharArray str(terminateData(data.buf, length));
DWORD required = ExpandEnvironmentStrings(str.buf, 0, 0);
if (required==0)
throw rdr::SystemException("ExpandEnvironmentStrings", GetLastError());
- TCharArray result(required);
+ CharArray result(required);
length = ExpandEnvironmentStrings(str.buf, result.buf, required);
if (required<length)
throw rdr::Exception("unable to expand environment strings");
return result.takeBuf();
} else {
- return tstrDup(_T(""));
+ return strDup("");
}
}
default:
}
}
-bool RegKey::isValue(const TCHAR* valname) const {
+bool RegKey::isValue(const char* valname) const {
try {
- TCharArray tmp(getRepresentation(valname));
+ CharArray tmp(getRepresentation(valname));
return true;
} catch(rdr::Exception&) {
return false;
}
}
-const TCHAR* RegKey::getValueName(int i) {
+const char* RegKey::getValueName(int i) {
DWORD maxValueNameLen;
LONG result = RegQueryInfoKey(key, 0, 0, 0, 0, 0, 0, 0, &maxValueNameLen, 0, 0, 0);
if (result != ERROR_SUCCESS)
if (valueNameBufLen < maxValueNameLen + 1) {
valueNameBufLen = maxValueNameLen + 1;
delete [] valueName.buf;
- valueName.buf = new TCHAR[valueNameBufLen];
+ valueName.buf = new char[valueNameBufLen];
}
DWORD length = valueNameBufLen;
result = RegEnumValue(key, i, valueName.buf, &length, NULL, 0, 0, 0);
return valueName.buf;
}
-const TCHAR* RegKey::getKeyName(int i) {
+const char* RegKey::getKeyName(int i) {
DWORD maxValueNameLen;
LONG result = RegQueryInfoKey(key, 0, 0, 0, 0, &maxValueNameLen, 0, 0, 0, 0, 0, 0);
if (result != ERROR_SUCCESS)
if (valueNameBufLen < maxValueNameLen + 1) {
valueNameBufLen = maxValueNameLen + 1;
delete [] valueName.buf;
- valueName.buf = new TCHAR[valueNameBufLen];
+ valueName.buf = new char[valueNameBufLen];
}
DWORD length = valueNameBufLen;
result = RegEnumKeyEx(key, i, valueName.buf, &length, NULL, 0, 0, 0);
public:
// Returns true if key was created, false if already existed
- bool createKey(const RegKey& root, const TCHAR* name);
+ bool createKey(const RegKey& root, const char* name);
// Opens key if it exists, or raises an exception if not
- void openKey(const RegKey& root, const TCHAR* name, bool readOnly=false);
+ void openKey(const RegKey& root, const char* name, bool readOnly=false);
// Set the (discretionary) access control list for the key
void setDACL(const PACL acl, bool inheritFromParent=true);
void close();
// Delete a subkey/value
- void deleteKey(const TCHAR* name) const;
- void deleteValue(const TCHAR* name) const;
+ void deleteKey(const char* name) const;
+ void deleteValue(const char* name) const;
// Block waiting for a registry change, OR return immediately and notify the
// event when there is a change, if specified
void awaitChange(bool watchSubTree, DWORD filter, HANDLE event=0) const;
- void setExpandString(const TCHAR* valname, const TCHAR* s) const;
- void setString(const TCHAR* valname, const TCHAR* s) const;
- void setBinary(const TCHAR* valname, const void* data, size_t length) const;
- void setInt(const TCHAR* valname, int i) const;
- void setBool(const TCHAR* valname, bool b) const;
+ void setExpandString(const char* valname, const char* s) const;
+ void setString(const char* valname, const char* s) const;
+ void setBinary(const char* valname, const void* data, size_t length) const;
+ void setInt(const char* valname, int i) const;
+ void setBool(const char* valname, bool b) const;
- TCHAR* getString(const TCHAR* valname) const;
- TCHAR* getString(const TCHAR* valname, const TCHAR* def) const;
+ char* getString(const char* valname) const;
+ char* getString(const char* valname, const char* def) const;
- std::vector<uint8_t> getBinary(const TCHAR* valname) const;
- std::vector<uint8_t> getBinary(const TCHAR* valname, const uint8_t* def, size_t deflength) const;
+ std::vector<uint8_t> getBinary(const char* valname) const;
+ std::vector<uint8_t> getBinary(const char* valname, const uint8_t* def, size_t deflength) const;
- int getInt(const TCHAR* valname) const;
- int getInt(const TCHAR* valname, int def) const;
+ int getInt(const char* valname) const;
+ int getInt(const char* valname, int def) const;
- bool getBool(const TCHAR* valname) const;
- bool getBool(const TCHAR* valname, bool def) const;
+ bool getBool(const char* valname) const;
+ bool getBool(const char* valname, bool def) const;
- TCHAR* getRepresentation(const TCHAR* valname) const;
+ char* getRepresentation(const char* valname) const;
- bool isValue(const TCHAR* valname) const;
+ bool isValue(const char* valname) const;
// Get the name of value/key number "i"
// If there are fewer than "i" values then return 0
// NAME IS OWNED BY RegKey OBJECT!
- const TCHAR* getValueName(int i);
- const TCHAR* getKeyName(int i);
+ const char* getValueName(int i);
+ const char* getKeyName(int i);
operator HKEY() const;
protected:
HKEY key;
bool freeKey;
- TCharArray valueName;
+ CharArray valueName;
DWORD valueNameBufLen;
};
// Opening the whole display with CreateDC doesn't work on multi-monitor
// systems for some reason.
DeviceContext* new_device = 0;
- TCharArray deviceName(displayDevice.getData());
+ CharArray deviceName(displayDevice.getData());
if (deviceName.buf[0]) {
- vlog.info("Attaching to device %s", (const char*)CStr(deviceName.buf));
+ vlog.info("Attaching to device %s", deviceName.buf);
new_device = new DeviceDC(deviceName.buf);
}
if (!new_device) {
// Get the coordinates of the specified dispay device
Rect newScreenRect;
if (deviceName.buf[0]) {
- MonitorInfo info(CStr(deviceName.buf));
+ MonitorInfo info(deviceName.buf);
newScreenRect = Rect(info.rcMonitor.left, info.rcMonitor.top,
info.rcMonitor.right, info.rcMonitor.bottom);
} else {
const unsigned int SDisplayCorePolling::pollTimerId = 1;
SDisplayCorePolling::SDisplayCorePolling(SDisplay* d, UpdateTracker* ut, int pollInterval_)
- : MsgWindow(_T("rfb::win32::SDisplayCorePolling")),
+ : MsgWindow("rfb::win32::SDisplayCorePolling"),
pollTimer(getHandle(), pollTimerId), pollNextStrip(false), display(d), updateTracker(ut) {
pollInterval = __rfbmax(10, (pollInterval_ / POLLING_SEGMENTS));
copyrect.setUpdateTracker(ut);
#define XK_CURRENCY
#include <rfb/keysymdef.h>
-#include <tchar.h>
#include <rfb_win32/SInput.h>
#include <rfb_win32/MonitorInfo.h>
#include <rfb_win32/Service.h>
static LogWriter vlog("SecurityWin32");
-Trustee::Trustee(const TCHAR* name,
+Trustee::Trustee(const char* name,
TRUSTEE_FORM form,
TRUSTEE_TYPE type) {
pMultipleTrustee = 0;
MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
TrusteeForm = form;
TrusteeType = type;
- ptstrName = (TCHAR*)name;
+ ptstrName = (char*)name;
}
-ExplicitAccess::ExplicitAccess(const TCHAR* name,
+ExplicitAccess::ExplicitAccess(const char* name,
TRUSTEE_FORM type,
DWORD perms,
ACCESS_MODE mode,
}
}
-void AccessEntries::addEntry(const TCHAR* trusteeName,
+void AccessEntries::addEntry(const char* trusteeName,
DWORD permissions,
ACCESS_MODE mode) {
allocMinEntries(entry_count+1);
ACCESS_MODE mode) {
allocMinEntries(entry_count+1);
ZeroMemory(&entries[entry_count], sizeof(EXPLICIT_ACCESS));
- entries[entry_count] = ExplicitAccess((TCHAR*)sid, TRUSTEE_IS_SID, permissions, mode);
+ entries[entry_count] = ExplicitAccess((char*)sid, TRUSTEE_IS_SID, permissions, mode);
entry_count++;
}
throw rdr::SystemException("CopySid failed", GetLastError());
}
-void Sid::getUserNameAndDomain(TCHAR** name, TCHAR** domain) {
+void Sid::getUserNameAndDomain(char** name, char** domain) {
DWORD nameLen = 0;
DWORD domainLen = 0;
SID_NAME_USE use;
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
throw rdr::SystemException("Unable to determine SID name lengths", GetLastError());
vlog.info("nameLen=%lu, domainLen=%lu, use=%d", nameLen, domainLen, use);
- *name = new TCHAR[nameLen];
- *domain = new TCHAR[domainLen];
+ *name = new char[nameLen];
+ *domain = new char[domainLen];
if (!LookupAccountSid(0, (PSID)*this, *name, &nameLen, *domain, &domainLen, &use))
throw rdr::SystemException("Unable to lookup account SID", GetLastError());
}
#include <stdint.h>
#include <vector>
#include <rfb_win32/LocalMem.h>
-#include <rfb_win32/TCharArray.h>
#include <aclapi.h>
namespace rfb {
namespace win32 {
struct Trustee : public TRUSTEE {
- Trustee(const TCHAR* name,
+ Trustee(const char* name,
TRUSTEE_FORM form=TRUSTEE_IS_NAME,
TRUSTEE_TYPE type=TRUSTEE_IS_UNKNOWN);
};
struct ExplicitAccess : public EXPLICIT_ACCESS {
- ExplicitAccess(const TCHAR* name,
+ ExplicitAccess(const char* name,
TRUSTEE_FORM type,
DWORD perms,
ACCESS_MODE mode,
AccessEntries();
~AccessEntries();
void allocMinEntries(int count);
- void addEntry(const TCHAR* trusteeName,
+ void addEntry(const char* trusteeName,
DWORD permissions,
ACCESS_MODE mode);
void addEntry(const PSID sid,
void setSID(const PSID sid);
- void getUserNameAndDomain(TCHAR** name, TCHAR** domain);
+ void getUserNameAndDomain(char** name, char** domain);
struct Administrators;
struct SYSTEM;
// -=- Service
-Service::Service(const TCHAR* name_) : name(name_) {
+Service::Service(const char* name_) : name(name_) {
vlog.debug("Service");
status_handle = 0;
status.dwControlsAccepted = SERVICE_CONTROL_INTERROGATE | SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_STOP;
void
Service::start() {
SERVICE_TABLE_ENTRY entry[2];
- entry[0].lpServiceName = (TCHAR*)name;
+ entry[0].lpServiceName = (char*)name;
entry[0].lpServiceProc = serviceProc;
entry[1].lpServiceName = NULL;
entry[1].lpServiceProc = NULL;
class Logger_EventLog : public Logger {
public:
- Logger_EventLog(const TCHAR* srcname) : Logger("EventLog") {
+ Logger_EventLog(const char* srcname) : Logger("EventLog") {
eventlog = RegisterEventSource(NULL, srcname);
if (!eventlog)
printf("Unable to open event log:%ld\n", GetLastError());
virtual void write(int level, const char *logname, const char *message) {
if (!eventlog) return;
- TStr log(logname), msg(message);
- const TCHAR* strings[] = {log, msg};
+ const char* strings[] = {logname, message};
WORD type = EVENTLOG_INFORMATION_TYPE;
if (level == 0) type = EVENTLOG_ERROR_TYPE;
if (!ReportEvent(eventlog, type, 0, VNC4LogMessage, NULL, 2, 0, strings, NULL)) {
static Logger_EventLog* logger = 0;
-bool rfb::win32::initEventLogLogger(const TCHAR* srcname) {
+bool rfb::win32::initEventLogLogger(const char* srcname) {
if (logger)
return false;
logger = new Logger_EventLog(srcname);
// -=- Registering and unregistering the service
-bool rfb::win32::registerService(const TCHAR* name,
- const TCHAR* display,
- const TCHAR* desc,
+bool rfb::win32::registerService(const char* name,
+ const char* display,
+ const char* desc,
int argc, char** argv) {
// - Initialise the default service parameters
- const TCHAR* defaultcmdline;
- defaultcmdline = _T("-service");
+ const char* defaultcmdline;
+ defaultcmdline = "-service";
// - Get the full pathname of our executable
ModuleFileName buffer;
// - Calculate the command-line length
- int cmdline_len = _tcslen(buffer.buf) + 4;
+ int cmdline_len = strlen(buffer.buf) + 4;
int i;
for (i=0; i<argc; i++) {
cmdline_len += strlen(argv[i]) + 3;
}
// - Add the supplied extra parameters to the command line
- TCharArray cmdline(cmdline_len+_tcslen(defaultcmdline));
- _stprintf(cmdline.buf, _T("\"%s\" %s"), buffer.buf, defaultcmdline);
+ CharArray cmdline(cmdline_len+strlen(defaultcmdline));
+ sprintf(cmdline.buf, "\"%s\" %s", buffer.buf, defaultcmdline);
for (i=0; i<argc; i++) {
- _tcscat(cmdline.buf, _T(" \""));
- _tcscat(cmdline.buf, TStr(argv[i]));
- _tcscat(cmdline.buf, _T("\""));
+ strcat(cmdline.buf, " \"");
+ strcat(cmdline.buf, argv[i]);
+ strcat(cmdline.buf, "\"");
}
// - Register the service
// - Register the event log source
RegKey hk, hk2;
- hk2.createKey(HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application"));
+ hk2.createKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application");
hk.createKey(hk2, name);
- for (i=_tcslen(buffer.buf); i>0; i--) {
- if (buffer.buf[i] == _T('\\')) {
+ for (i=strlen(buffer.buf); i>0; i--) {
+ if (buffer.buf[i] == '\\') {
buffer.buf[i+1] = 0;
break;
}
}
- const TCHAR* dllFilename = _T("logmessages.dll");
- TCharArray dllPath(_tcslen(buffer.buf) + _tcslen(dllFilename) + 1);
- _tcscpy(dllPath.buf, buffer.buf);
- _tcscat(dllPath.buf, dllFilename);
+ const char* dllFilename = "logmessages.dll";
+ CharArray dllPath(strlen(buffer.buf) + strlen(dllFilename) + 1);
+ strcpy(dllPath.buf, buffer.buf);
+ strcat(dllPath.buf, dllFilename);
- hk.setExpandString(_T("EventMessageFile"), dllPath.buf);
- hk.setInt(_T("TypesSupported"), EVENTLOG_ERROR_TYPE | EVENTLOG_INFORMATION_TYPE);
+ hk.setExpandString("EventMessageFile", dllPath.buf);
+ hk.setInt("TypesSupported", EVENTLOG_ERROR_TYPE | EVENTLOG_INFORMATION_TYPE);
Sleep(500);
return true;
}
-bool rfb::win32::unregisterService(const TCHAR* name) {
+bool rfb::win32::unregisterService(const char* name) {
// - Open the SCM
ServiceHandle scm = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);
if (!scm)
// - Register the event log source
RegKey hk;
- hk.openKey(HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application"));
+ hk.openKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application");
hk.deleteKey(name);
Sleep(500);
// -=- Starting and stopping the service
-bool rfb::win32::startService(const TCHAR* name) {
+bool rfb::win32::startService(const char* name) {
// - Open the SCM
ServiceHandle scm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
return true;
}
-bool rfb::win32::stopService(const TCHAR* name) {
+bool rfb::win32::stopService(const char* name) {
// - Open the SCM
ServiceHandle scm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
if (!scm)
return true;
}
-DWORD rfb::win32::getServiceState(const TCHAR* name) {
+DWORD rfb::win32::getServiceState(const char* name) {
// - Open the SCM
ServiceHandle scm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
if (!scm)
class Service {
public:
- Service(const TCHAR* name_);
+ Service(const char* name_);
virtual ~Service();
- const TCHAR* getName() {return name;}
+ const char* getName() {return name;}
SERVICE_STATUS& getStatus() {return status;}
void setStatus(DWORD status);
void start();
// - Service main procedure - override to implement a service
- virtual DWORD serviceMain(int argc, TCHAR* argv[]) = 0;
+ virtual DWORD serviceMain(int argc, char* argv[]) = 0;
// - Service control notifications
SERVICE_STATUS_HANDLE status_handle;
SERVICE_STATUS status;
protected:
- const TCHAR* name;
+ const char* name;
};
class ServiceHandle {
bool emulateCtrlAltDel();
// -=- Routines to initialise the Event Log target Logger
- bool initEventLogLogger(const TCHAR* srcname);
+ bool initEventLogLogger(const char* srcname);
// -=- Routines to register/unregister the service
// These routines also take care of registering the required
// event source information, etc.
- // *** should really accept TCHAR argv
+ // *** should really accept char argv
- bool registerService(const TCHAR* name, const TCHAR* display,
- const TCHAR* desc, int argc, char** argv);
- bool unregisterService(const TCHAR* name);
+ bool registerService(const char* name, const char* display,
+ const char* desc, int argc, char** argv);
+ bool unregisterService(const char* name);
- bool startService(const TCHAR* name);
- bool stopService(const TCHAR* name);
+ bool startService(const char* name);
+ bool stopService(const char* name);
// -=- Get the state of the named service (one of the NT service state values)
- DWORD getServiceState(const TCHAR* name);
+ DWORD getServiceState(const char* name);
// -=- Convert a supplied service state value to a printable string e.g. Running, Stopped...
// The caller must delete the returned string buffer
+++ /dev/null
-/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
- *
- * This is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this software; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- * USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <rfb_win32/TCharArray.h>
-
-namespace rfb {
-
- WCHAR* wstrDup(const WCHAR* s) {
- if (!s) return 0;
- WCHAR* t = new WCHAR[wcslen(s)+1];
- memcpy(t, s, sizeof(WCHAR)*(wcslen(s)+1));
- return t;
- }
- void wstrFree(WCHAR* s) {delete [] s;}
-
- char* strDup(const WCHAR* s) {
- if (!s) return 0;
- int len = wcslen(s);
- char* t = new char[len+1];
- t[WideCharToMultiByte(CP_ACP, 0, s, len, t, len, 0, 0)] = 0;
- return t;
- }
-
- WCHAR* wstrDup(const char* s) {
- if (!s) return 0;
- int len = strlen(s);
- WCHAR* t = new WCHAR[len+1];
- t[MultiByteToWideChar(CP_ACP, 0, s, len, t, len)] = 0;
- return t;
- }
-
-
- bool wstrSplit(const WCHAR* src, const WCHAR limiter, WCHAR** out1, WCHAR** out2, bool fromEnd) {
- WCharArray out1old, out2old;
- if (out1) out1old.buf = *out1;
- if (out2) out2old.buf = *out2;
- int len = wcslen(src);
- int i=0, increment=1, limit=len;
- if (fromEnd) {
- i=len-1; increment = -1; limit = -1;
- }
- while (i!=limit) {
- if (src[i] == limiter) {
- if (out1) {
- *out1 = new WCHAR[i+1];
- if (i) memcpy(*out1, src, sizeof(WCHAR)*i);
- (*out1)[i] = 0;
- }
- if (out2) {
- *out2 = new WCHAR[len-i];
- if (len-i-1) memcpy(*out2, &src[i+1], sizeof(WCHAR)*(len-i-1));
- (*out2)[len-i-1] = 0;
- }
- return true;
- }
- i+=increment;
- }
- if (out1) *out1 = wstrDup(src);
- if (out2) *out2 = 0;
- return false;
- }
-
- bool wstrContains(const WCHAR* src, WCHAR c) {
- int l=wcslen(src);
- for (int i=0; i<l; i++)
- if (src[i] == c) return true;
- return false;
- }
-
-};
+++ /dev/null
-/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
- *
- * This is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this software; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- * USA.
- */
-
-// -=- TCharArray.h
-
-// This library contains the wide-character equivalent of CharArray, named
-// WCharArray. In addition to providing wide-character equivalents of
-// the char* string manipulation functions (strDup, strFree, etc), special
-// versions of those functions are provided which attempt to convert from
-// one format to the other.
-// e.g. char* t = "hello world"; WCHAR* w = wstrDup(t);
-// Results in w containing the wide-character text "hello world".
-// For convenience, the WStr and CStr classes are also provided. These
-// accept an existing (const) WCHAR* or char* null-terminated string and
-// create a read-only copy of that in the desired format. The new copy
-// will actually be the original copy if the format has not changed, otherwise
-// it will be a new buffer owned by the WStr/CStr.
-
-// In addition to providing wide character functions, this header defines
-// TCHAR* handling classes & functions. TCHAR is defined at compile time to
-// either char or WCHAR. Programs can treat this as a third data type and
-// call TStr() whenever a TCHAR* is required but a char* or WCHAR* is supplied,
-// and TStr will do the right thing.
-
-#ifndef __RFB_WIN32_TCHARARRAY_H__
-#define __RFB_WIN32_TCHARARRAY_H__
-
-#include <windows.h>
-#include <tchar.h>
-#include <rfb/util.h>
-#include <rfb/Password.h>
-
-namespace rfb {
-
- // -=- String duplication and cleanup functions.
- // These routines also handle conversion between WCHAR* and char*
-
- char* strDup(const WCHAR* s);
- WCHAR* wstrDup(const WCHAR* s);
- WCHAR* wstrDup(const char* s);
- void wstrFree(WCHAR* s);
-
- bool wstrSplit(const WCHAR* src, const WCHAR limiter, WCHAR** out1, WCHAR** out2, bool fromEnd=false);
- bool wstrContains(const WCHAR* src, WCHAR c);
-
- // -=- Temporary format conversion classes
- // CStr accepts WCHAR* or char* and behaves like a char*
- // WStr accepts WCHAR* or char* and behaves like a WCHAR*
-
- struct WStr {
- WStr(const char* s) : buf(wstrDup(s)), free_(true) {}
- WStr(const WCHAR* s) : buf(s), free_(false) {}
- ~WStr() {if (free_) wstrFree((WCHAR*)buf);}
- operator const WCHAR*() {return buf;}
- const WCHAR* buf;
- bool free_;
- };
-
- struct CStr {
- CStr(const char* s) : buf(s), free_(false) {}
- CStr(const WCHAR* s) : buf(strDup(s)), free_(true) {}
- ~CStr() {if (free_) strFree((char*)buf);}
- operator const char*() {return buf;}
- const char* buf;
- bool free_;
- };
-
- // -=- Class to handle cleanup of arrays of native Win32 characters
- class WCharArray {
- public:
- WCharArray() : buf(0) {}
- WCharArray(char* str) : buf(wstrDup(str)) {strFree(str);} // note: assumes ownership
- WCharArray(WCHAR* str) : buf(str) {} // note: assumes ownership
- WCharArray(int len) {
- buf = new WCHAR[len];
- }
- ~WCharArray() {
- delete [] buf;
- }
- // Get the buffer pointer & clear it (i.e. caller takes ownership)
- WCHAR* takeBuf() {WCHAR* tmp = buf; buf = 0; return tmp;}
- void replaceBuf(WCHAR* str) {delete [] buf; buf = str;}
- WCHAR* buf;
- };
-
- // -=- Wide-character-based password-buffer handler. Zeroes the password
- // buffer when deleted or replaced.
- class WPlainPasswd : public WCharArray {
- public:
- WPlainPasswd() {}
- WPlainPasswd(WCHAR* str) : WCharArray(str) {}
- ~WPlainPasswd() {replaceBuf(0);}
- void replaceBuf(WCHAR* str) {
- if (buf)
- memset(buf, 0, sizeof(WCHAR)*wcslen(buf));
- WCharArray::replaceBuf(str);
- }
- };
-
-#ifdef _UNICODE
-#define tstrDup wstrDup
-#define tstrFree wstrFree
-#define tstrSplit wstrSplit
-#define tstrContains wstrContains
- typedef WCharArray TCharArray;
- typedef WStr TStr;
- typedef WPlainPasswd TPlainPasswd;
-#else
-#define tstrDup strDup
-#define tstrFree strFree
-#define tstrSplit strSplit
-#define tstrContains strContains
- typedef CharArray TCharArray;
- typedef CStr TStr;
- typedef PlainPasswd TPlainPasswd;
-#endif
-
-};
-
-#endif
class TrayIcon : public MsgWindow {
public:
- TrayIcon() : MsgWindow(_T("VNCTray")) {
+ TrayIcon() : MsgWindow("VNCTray") {
#ifdef NOTIFYICONDATA_V1_SIZE
nid.cbSize = NOTIFYICONDATA_V1_SIZE;
#else
return refresh();
}
}
- bool setToolTip(const TCHAR* text) {
+ bool setToolTip(const char* text) {
if (text == 0) {
nid.uFlags &= ~NIF_TIP;
} else {
- const int tipLen = sizeof(nid.szTip)/sizeof(TCHAR);
- _tcsncpy(nid.szTip, text, tipLen);
+ const int tipLen = sizeof(nid.szTip)/sizeof(char);
+ strncpy(nid.szTip, text, tipLen);
nid.szTip[tipLen-1] = 0;
nid.uFlags |= NIF_TIP;
}
#include <rfb_win32/TsSessions.h>
#include <rfb/LogWriter.h>
#include <rdr/Exception.h>
-#include <tchar.h>
#include <wtsapi32.h>
static rfb::LogWriter vlog("TsSessions");
// Try to reconnect our session to the console
ConsoleSessionId console;
vlog.info("Console session is %lu", console.id);
- if (!WTSConnectSession(sessionId, console.id, (PTSTR)_T(""), 0))
+ if (!WTSConnectSession(sessionId, console.id, (PTSTR)"", 0))
throw rdr::SystemException("Unable to connect session to Console", GetLastError());
// Lock the newly connected session, for security
// actually complete them before we notify the hook callbacks & they go off
// capturing screen state.
const int updateDelayMs = 40;
- MsgWindow updateDelayWnd(_T("WMHooks::updateDelay"));
+ MsgWindow updateDelayWnd("WMHooks::updateDelay");
IntervalTimer updateDelayTimer(updateDelayWnd.getHandle(), 1);
Region updates[2];
int activeRgn = 0;
static LogWriter vlog("WMMonitor");
-WMMonitor::WMMonitor() : MsgWindow(_T("WMMonitor")), notifier(0) {
+WMMonitor::WMMonitor() : MsgWindow("WMMonitor"), notifier(0) {
}
WMMonitor::~WMMonitor() {
#include <rfb/LogWriter.h>
#include <rfb/Configuration.h>
-#include <tchar.h>
-
using namespace rfb;
using namespace rfb::win32;
bool
rfb::win32::WMPoller::checkPollWindow(HWND w) {
- TCHAR buffer[128];
+ char buffer[128];
if (!GetClassName(w, buffer, 128))
throw rdr::SystemException("unable to get window class:%u", GetLastError());
- if ((_tcscmp(buffer, _T("tty")) != 0) &&
- (_tcscmp(buffer, _T("ConsoleWindowClass")) != 0)) {
+ if ((strcmp(buffer, "tty") != 0) &&
+ (strcmp(buffer, "ConsoleWindowClass") != 0)) {
return false;
}
return true;
namespace win32 {
-FileVersionInfo::FileVersionInfo(const TCHAR* filename) {
+FileVersionInfo::FileVersionInfo(const char* filename) {
// Get executable name
ModuleFileName exeName;
if (!filename)
// Get version info size
DWORD handle;
- int size = GetFileVersionInfoSize((TCHAR*)filename, &handle);
+ int size = GetFileVersionInfoSize((char*)filename, &handle);
if (!size)
throw rdr::SystemException("GetVersionInfoSize failed", GetLastError());
// Get version info
- buf = new TCHAR[size];
- if (!GetFileVersionInfo((TCHAR*)filename, handle, size, buf))
+ buf = new char[size];
+ if (!GetFileVersionInfo((char*)filename, handle, size, buf))
throw rdr::SystemException("GetVersionInfo failed", GetLastError());
}
-const TCHAR* FileVersionInfo::getVerString(const TCHAR* name, DWORD langId) {
+const char* FileVersionInfo::getVerString(const char* name, DWORD langId) {
uint8_t langIdBuf[sizeof(langId)];
for (int i=sizeof(langIdBuf)-1; i>=0; i--) {
langIdBuf[i] = (langId & 0xff);
langId = langId >> 8;
}
- TCharArray langIdStr(binToHex(langIdBuf, sizeof(langId)));
- TCharArray infoName(_tcslen(_T("StringFileInfo")) + 4 + _tcslen(name) + _tcslen(langIdStr.buf));
- _stprintf(infoName.buf, _T("\\StringFileInfo\\%s\\%s"), langIdStr.buf, name);
+ CharArray langIdStr(binToHex(langIdBuf, sizeof(langId)));
+ CharArray infoName(strlen("StringFileInfo") + 4 + strlen(name) + strlen(langIdStr.buf));
+ sprintf(infoName.buf, "\\StringFileInfo\\%s\\%s", langIdStr.buf, name);
// Locate the required version string within the version info
- TCHAR* buffer = 0;
+ char* buffer = 0;
UINT length = 0;
if (!VerQueryValue(buf, infoName.buf, (void**)&buffer, &length)) {
printf("unable to find %s version string", infoName.buf);
}
-bool splitPath(const TCHAR* path, TCHAR** dir, TCHAR** file) {
- return tstrSplit(path, '\\', dir, file, true);
+bool splitPath(const char* path, char** dir, char** file) {
+ return strSplit(path, '\\', dir, file, true);
}
#ifndef __RFB_WIN32_GDIUTIL_H__
#define __RFB_WIN32_GDIUTIL_H__
-#include <rfb_win32/TCharArray.h>
+#include <rfb/util.h>
namespace rfb {
namespace win32 {
- struct FileVersionInfo : public TCharArray {
- FileVersionInfo(const TCHAR* filename=0);
- const TCHAR* getVerString(const TCHAR* name, DWORD langId = 0x080904b0);
+ struct FileVersionInfo : public CharArray {
+ FileVersionInfo(const char* filename=0);
+ const char* getVerString(const char* name, DWORD langId = 0x080904b0);
};
- bool splitPath(const TCHAR* path, TCHAR** dir, TCHAR** file);
+ bool splitPath(const char* path, char** dir, char** file);
// Center the window to a rectangle, or to a parent window.
// Optionally, resize the window to lay within the rect or parent window
PasswordDialog passwdDlg(regKey, registryInsecure);
passwdDlg.showDialog(handle);
} else if (id == IDC_LOAD_CERT) {
- const TCHAR* title = _T("X509Cert");
- const TCHAR* filter =
- _T("X.509 Certificates (*.crt;*.cer;*.pem)\0*.crt;*.cer;*.pem\0All\0*.*\0");
+ const char* title = "X509Cert";
+ const char* filter =
+ "X.509 Certificates (*.crt;*.cer;*.pem)\0*.crt;*.cer;*.pem\0All\0*.*\0";
showFileChooser(regKey, title, filter, handle);
} else if (id == IDC_LOAD_CERTKEY) {
- const TCHAR* title = _T("X509Key");
- const TCHAR* filter = _T("X.509 Keys (*.key;*.pem)\0*.key;*.pem\0All\0*.*\0");
+ const char* title = "X509Key";
+ const char* filter = "X.509 Keys (*.key;*.pem)\0*.key;*.pem\0All\0*.*\0";
showFileChooser(regKey, title, filter, handle);
} else if (id == IDC_QUERY_LOGGED_ON) {
enableItem(IDC_QUERY_LOGGED_ON, enableQueryOnlyIfLoggedOn());
if (isItemChecked(IDC_AUTH_VNC))
verifyVncPassword(regKey);
else if (haveVncPassword() &&
- MsgBox(0, _T("The VNC authentication method is disabled, but a password is still stored for it.\n")
- _T("Do you want to remove the VNC authentication password from the registry?"),
+ MsgBox(0, "The VNC authentication method is disabled, but a password is still stored for it.\n"
+ "Do you want to remove the VNC authentication password from the registry?",
MB_ICONWARNING | MB_YESNO) == IDYES) {
- regKey.setBinary(_T("Password"), 0, 0);
+ regKey.setBinary("Password", 0, 0);
}
#ifdef HAVE_GNUTLS
}
#endif
- regKey.setString(_T("SecurityTypes"), security->ToString());
- regKey.setBool(_T("QueryConnect"), isItemChecked(IDC_QUERY_CONNECT));
- regKey.setBool(_T("QueryOnlyIfLoggedOn"), isItemChecked(IDC_QUERY_LOGGED_ON));
+ regKey.setString("SecurityTypes", security->ToString());
+ regKey.setBool("QueryConnect", isItemChecked(IDC_QUERY_CONNECT));
+ regKey.setBool("QueryOnlyIfLoggedOn", isItemChecked(IDC_QUERY_LOGGED_ON));
return true;
}
static void verifyVncPassword(const RegKey& regKey) {
if (!haveVncPassword()) {
- MsgBox(0, _T("The VNC authentication method is enabled, but no password is specified.\n")
- _T("The password dialog will now be shown."), MB_ICONINFORMATION | MB_OK);
+ MsgBox(0, "The VNC authentication method is enabled, but no password is specified.\n"
+ "The password dialog will now be shown.", MB_ICONINFORMATION | MB_OK);
PasswordDialog passwd(regKey, registryInsecure);
passwd.showDialog();
}
class ConnHostDialog : public Dialog {
public:
ConnHostDialog() : Dialog(GetModuleHandle(0)) {}
- bool showDialog(const TCHAR* pat) {
- pattern.replaceBuf(tstrDup(pat));
+ bool showDialog(const char* pat) {
+ pattern.replaceBuf(strDup(pat));
return Dialog::showDialog(MAKEINTRESOURCE(IDD_CONN_HOST));
}
void initDialog() {
- if (_tcslen(pattern.buf) == 0)
- pattern.replaceBuf(tstrDup("+"));
+ if (strlen(pattern.buf) == 0)
+ pattern.replaceBuf(strDup("+"));
- if (pattern.buf[0] == _T('+'))
+ if (pattern.buf[0] == '+')
setItemChecked(IDC_ALLOW, true);
- else if (pattern.buf[0] == _T('?'))
+ else if (pattern.buf[0] == '?')
setItemChecked(IDC_QUERY, true);
else
setItemChecked(IDC_DENY, true);
pattern.replaceBuf(0);
}
bool onOk() {
- TCharArray host(getItemString(IDC_HOST_PATTERN));
- TCharArray newPat(_tcslen(host.buf)+2);
+ CharArray host(getItemString(IDC_HOST_PATTERN));
+ CharArray newPat(strlen(host.buf)+2);
if (isItemChecked(IDC_ALLOW))
- newPat.buf[0] = _T('+');
+ newPat.buf[0] = '+';
else if (isItemChecked(IDC_QUERY))
- newPat.buf[0] = _T('?');
+ newPat.buf[0] = '?';
else
- newPat.buf[0] = _T('-');
+ newPat.buf[0] = '-';
newPat.buf[1] = 0;
- _tcscat(newPat.buf, host.buf);
+ strcat(newPat.buf, host.buf);
try {
- network::TcpFilter::Pattern pat(network::TcpFilter::parsePattern(CStr(newPat.buf)));
- pattern.replaceBuf(TCharArray(network::TcpFilter::patternToStr(pat)).takeBuf());
+ network::TcpFilter::Pattern pat(network::TcpFilter::parsePattern(newPat.buf));
+ pattern.replaceBuf(CharArray(network::TcpFilter::patternToStr(pat)).takeBuf());
} catch(rdr::Exception& e) {
- MsgBox(NULL, TStr(e.str()), MB_ICONEXCLAMATION | MB_OK);
+ MsgBox(NULL, e.str(), MB_ICONEXCLAMATION | MB_OK);
return false;
}
return true;
}
- const TCHAR* getPattern() {return pattern.buf;}
+ const char* getPattern() {return pattern.buf;}
protected:
- TCharArray pattern;
+ CharArray pattern;
};
class ConnectionsPage : public PropSheetPage {
CharArray first;
strSplit(tmp.buf, ',', &first.buf, &tmp.buf);
if (strlen(first.buf))
- SendMessage(listBox, LB_ADDSTRING, 0, (LPARAM)(const TCHAR*)TStr(first.buf));
+ SendMessage(listBox, LB_ADDSTRING, 0, (LPARAM)first.buf);
}
onCommand(IDC_RFB_ENABLE, EN_CHANGE);
}
case IDC_HOST_ADD:
- if (hostDialog.showDialog(_T("")))
+ if (hostDialog.showDialog(""))
{
- const TCHAR* pattern = hostDialog.getPattern();
+ const char* pattern = hostDialog.getPattern();
if (pattern)
SendMessage(GetDlgItem(handle, IDC_HOSTS), LB_ADDSTRING, 0, (LPARAM)pattern);
}
{
HWND listBox = GetDlgItem(handle, IDC_HOSTS);
int item = SendMessage(listBox, LB_GETCURSEL, 0, 0);
- TCharArray pattern(SendMessage(listBox, LB_GETTEXTLEN, item, 0)+1);
+ CharArray pattern(SendMessage(listBox, LB_GETTEXTLEN, item, 0)+1);
SendMessage(listBox, LB_GETTEXT, item, (LPARAM)pattern.buf);
if (hostDialog.showDialog(pattern.buf)) {
- const TCHAR* newPat = hostDialog.getPattern();
+ const char* newPat = hostDialog.getPattern();
if (newPat) {
item = SendMessage(listBox, LB_FINDSTRINGEXACT, item, (LPARAM)pattern.buf);
if (item != LB_ERR) {
{
HWND listBox = GetDlgItem(handle, IDC_HOSTS);
int item = SendMessage(listBox, LB_GETCURSEL, 0, 0);
- TCharArray pattern(SendMessage(listBox, LB_GETTEXTLEN, item, 0)+1);
+ CharArray pattern(SendMessage(listBox, LB_GETTEXTLEN, item, 0)+1);
SendMessage(listBox, LB_GETTEXT, item, (LPARAM)pattern.buf);
SendMessage(listBox, LB_DELETESTRING, item, 0);
SendMessage(listBox, LB_INSERTSTRING, item-1, (LPARAM)pattern.buf);
{
HWND listBox = GetDlgItem(handle, IDC_HOSTS);
int item = SendMessage(listBox, LB_GETCURSEL, 0, 0);
- TCharArray pattern(SendMessage(listBox, LB_GETTEXTLEN, item, 0)+1);
+ CharArray pattern(SendMessage(listBox, LB_GETTEXTLEN, item, 0)+1);
SendMessage(listBox, LB_GETTEXT, item, (LPARAM)pattern.buf);
SendMessage(listBox, LB_DELETESTRING, item, 0);
SendMessage(listBox, LB_INSERTSTRING, item+1, (LPARAM)pattern.buf);
return false;
}
bool onOk() {
- regKey.setInt(_T("PortNumber"), isItemChecked(IDC_RFB_ENABLE) ? getItemInt(IDC_PORT) : 0);
- regKey.setInt(_T("IdleTimeout"), getItemInt(IDC_IDLE_TIMEOUT));
- regKey.setInt(_T("LocalHost"), isItemChecked(IDC_LOCALHOST));
- regKey.setString(_T("Hosts"), TCharArray(getHosts()).buf);
+ regKey.setInt("PortNumber", isItemChecked(IDC_RFB_ENABLE) ? getItemInt(IDC_PORT) : 0);
+ regKey.setInt("IdleTimeout", getItemInt(IDC_IDLE_TIMEOUT));
+ regKey.setInt("LocalHost", isItemChecked(IDC_LOCALHOST));
+ regKey.setString("Hosts", CharArray(getHosts()).buf);
return true;
}
bool isChanged() {
HWND listBox = GetDlgItem(handle, IDC_HOSTS);
for (i=0; i<SendMessage(listBox, LB_GETCOUNT, 0, 0); i++)
bufLen+=SendMessage(listBox, LB_GETTEXTLEN, i, 0)+1;
- TCharArray hosts_str(bufLen);
+ CharArray hosts_str(bufLen);
hosts_str.buf[0] = 0;
- TCHAR* outPos = hosts_str.buf;
+ char* outPos = hosts_str.buf;
for (i=0; i<SendMessage(listBox, LB_GETCOUNT, 0, 0); i++) {
outPos += SendMessage(listBox, LB_GETTEXT, i, (LPARAM)outPos);
outPos[0] = ',';
return false;
}
bool onOk() {
- const TCHAR* action = _T("None");
+ const char* action = "None";
if (isItemChecked(IDC_DISCONNECT_LOGOFF))
- action = _T("Logoff");
+ action = "Logoff";
else if (isItemChecked(IDC_DISCONNECT_LOCK))
- action = _T("Lock");
- regKey.setString(_T("DisconnectAction"), action);
- regKey.setBool(_T("RemoveWallpaper"), isItemChecked(IDC_REMOVE_WALLPAPER));
- regKey.setBool(_T("DisableEffects"), isItemChecked(IDC_DISABLE_EFFECTS));
+ action = "Lock";
+ regKey.setString("DisconnectAction", action);
+ regKey.setBool("RemoveWallpaper", isItemChecked(IDC_REMOVE_WALLPAPER));
+ regKey.setBool("DisableEffects", isItemChecked(IDC_DISABLE_EFFECTS));
return true;
}
protected:
}
bool onOk() {
if (isItemChecked(IDC_USEPOLLING))
- regKey.setInt(_T("UpdateMethod"), 0);
+ regKey.setInt("UpdateMethod", 0);
if (isItemChecked(IDC_USEHOOKS))
- regKey.setInt(_T("UpdateMethod"), 1);
- regKey.setBool(_T("PollConsoleWindows"), isItemChecked(IDC_POLLCONSOLES));
- regKey.setBool(_T("UseCaptureBlt"), isItemChecked(IDC_CAPTUREBLT));
+ regKey.setInt("UpdateMethod", 1);
+ regKey.setBool("PollConsoleWindows", isItemChecked(IDC_POLLCONSOLES));
+ regKey.setBool("UseCaptureBlt", isItemChecked(IDC_CAPTUREBLT));
// *** LEGACY compatibility ***
- regKey.setBool(_T("UseHooks"), isItemChecked(IDC_USEHOOKS));
+ regKey.setBool("UseHooks", isItemChecked(IDC_USEHOOKS));
return true;
}
protected:
return false;
}
bool onOk() {
- regKey.setBool(_T("AcceptKeyEvents"), isItemChecked(IDC_ACCEPT_KEYS));
- regKey.setBool(_T("RawKeyboard"), isItemChecked(IDC_RAW_KEYBOARD));
- regKey.setBool(_T("AcceptPointerEvents"), isItemChecked(IDC_ACCEPT_PTR));
- regKey.setBool(_T("AcceptCutText"), isItemChecked(IDC_ACCEPT_CUTTEXT));
- regKey.setBool(_T("SendCutText"), isItemChecked(IDC_SEND_CUTTEXT));
- regKey.setBool(_T("DisableLocalInputs"), isItemChecked(IDC_DISABLE_LOCAL_INPUTS));
+ regKey.setBool("AcceptKeyEvents", isItemChecked(IDC_ACCEPT_KEYS));
+ regKey.setBool("RawKeyboard", isItemChecked(IDC_RAW_KEYBOARD));
+ regKey.setBool("AcceptPointerEvents", isItemChecked(IDC_ACCEPT_PTR));
+ regKey.setBool("AcceptCutText", isItemChecked(IDC_ACCEPT_CUTTEXT));
+ regKey.setBool("SendCutText", isItemChecked(IDC_SEND_CUTTEXT));
+ regKey.setBool("DisableLocalInputs", isItemChecked(IDC_DISABLE_LOCAL_INPUTS));
if (enableAffectSSaver) {
BOOL blocked = !isItemChecked(IDC_AFFECT_SCREENSAVER);
SystemParametersInfo(SPI_SETBLOCKSENDINPUTRESETS, blocked, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
// settings from HKCU/Software/ORL/WinVNC3.
// Get the name of the current user
- TCharArray username;
+ CharArray username;
try {
UserName name;
username.buf = name.takeBuf();
allowProperties = true;
RegKey winvnc3;
try {
- winvnc3.openKey(HKEY_LOCAL_MACHINE, _T("Software\\ORL\\WinVNC3"));
- int debugMode = winvnc3.getInt(_T("DebugMode"), 0);
+ winvnc3.openKey(HKEY_LOCAL_MACHINE, "Software\\ORL\\WinVNC3");
+ int debugMode = winvnc3.getInt("DebugMode", 0);
const char* debugTarget = 0;
if (debugMode & 2) debugTarget = "file";
if (debugMode & 4) debugTarget = "stderr";
if (debugTarget) {
char logSetting[32];
- sprintf(logSetting, "*:%s:%d", debugTarget, winvnc3.getInt(_T("DebugLevel"), 0));
- regKey.setString(_T("Log"), TStr(logSetting));
+ sprintf(logSetting, "*:%s:%d", debugTarget, winvnc3.getInt("DebugLevel", 0));
+ regKey.setString("Log", logSetting);
}
- TCharArray authHosts;
- authHosts.buf = winvnc3.getString(_T("AuthHosts"), 0);
+ CharArray authHosts;
+ authHosts.buf = winvnc3.getString("AuthHosts", 0);
if (authHosts.buf) {
CharArray newHosts;
newHosts.buf = strDup("");
}
// Finally, save the Hosts value
- regKey.setString(_T("Hosts"), TStr(newHosts.buf));
+ regKey.setString("Hosts", newHosts.buf);
} catch (rdr::Exception&) {
- MsgBox(0, _T("Unable to convert AuthHosts setting to Hosts format."),
+ MsgBox(0, "Unable to convert AuthHosts setting to Hosts format.",
MB_ICONWARNING | MB_OK);
}
} else {
- regKey.setString(_T("Hosts"), _T("+"));
+ regKey.setString("Hosts", "+");
}
- regKey.setBool(_T("LocalHost"), winvnc3.getBool(_T("LoopbackOnly"), false));
+ regKey.setBool("LocalHost", winvnc3.getBool("LoopbackOnly", false));
// *** check AllowLoopback?
- if (winvnc3.getBool(_T("AuthRequired"), true))
- regKey.setString(_T("SecurityTypes"), _T("VncAuth"));
+ if (winvnc3.getBool("AuthRequired", true))
+ regKey.setString("SecurityTypes", "VncAuth");
else
- regKey.setString(_T("SecurityTypes"), _T("None"));
+ regKey.setString("SecurityTypes", "None");
- int connectPriority = winvnc3.getInt(_T("ConnectPriority"), 0);
- regKey.setBool(_T("DisconnectClients"), connectPriority == 0);
- regKey.setBool(_T("AlwaysShared"), connectPriority == 1);
- regKey.setBool(_T("NeverShared"), connectPriority == 2);
+ int connectPriority = winvnc3.getInt("ConnectPriority", 0);
+ regKey.setBool("DisconnectClients", connectPriority == 0);
+ regKey.setBool("AlwaysShared", connectPriority == 1);
+ regKey.setBool("NeverShared", connectPriority == 2);
} catch(rdr::Exception&) {
}
allowProperties = true;
try {
RegKey userKey;
- userKey.openKey(winvnc3, _T("Default"));
+ userKey.openKey(winvnc3, "Default");
vlog.info("loading Default prefs");
LoadUserPrefs(userKey);
} catch(rdr::Exception& e) {
if (allowProperties) {
try {
RegKey userKey;
- userKey.openKey(HKEY_CURRENT_USER, _T("Software\\ORL\\WinVNC3"));
+ userKey.openKey(HKEY_CURRENT_USER, "Software\\ORL\\WinVNC3");
vlog.info("loading global User prefs");
LoadUserPrefs(userKey);
} catch(rdr::Exception& e) {
}
// Disable the Options menu item if appropriate
- regKey.setBool(_T("DisableOptions"), !allowProperties);
+ regKey.setBool("DisableOptions", !allowProperties);
}
void LegacyPage::LoadUserPrefs(const RegKey& key)
{
- regKey.setInt(_T("PortNumber"), key.getBool(_T("SocketConnect")) ? key.getInt(_T("PortNumber"), 5900) : 0);
- if (key.getBool(_T("AutoPortSelect"), false)) {
- MsgBox(0, _T("The AutoPortSelect setting is not supported by this release.")
- _T("The port number will default to 5900."),
+ regKey.setInt("PortNumber", key.getBool("SocketConnect") ? key.getInt("PortNumber", 5900) : 0);
+ if (key.getBool("AutoPortSelect", false)) {
+ MsgBox(0, "The AutoPortSelect setting is not supported by this release."
+ "The port number will default to 5900.",
MB_ICONWARNING | MB_OK);
- regKey.setInt(_T("PortNumber"), 5900);
+ regKey.setInt("PortNumber", 5900);
}
- regKey.setInt(_T("IdleTimeout"), key.getInt(_T("IdleTimeout"), 0));
+ regKey.setInt("IdleTimeout", key.getInt("IdleTimeout", 0));
- regKey.setBool(_T("RemoveWallpaper"), key.getBool(_T("RemoveWallpaper")));
- regKey.setBool(_T("DisableEffects"), key.getBool(_T("DisableEffects")));
+ regKey.setBool("RemoveWallpaper", key.getBool("RemoveWallpaper"));
+ regKey.setBool("DisableEffects", key.getBool("DisableEffects"));
- if (key.getInt(_T("QuerySetting"), 2) != 2) {
- regKey.setBool(_T("QueryConnect"), key.getInt(_T("QuerySetting")) > 2);
- MsgBox(0, _T("The QuerySetting option has been replaced by QueryConnect.")
- _T("Please see the documentation for details of the QueryConnect option."),
+ if (key.getInt("QuerySetting", 2) != 2) {
+ regKey.setBool("QueryConnect", key.getInt("QuerySetting") > 2);
+ MsgBox(0, "The QuerySetting option has been replaced by QueryConnect."
+ "Please see the documentation for details of the QueryConnect option.",
MB_ICONWARNING | MB_OK);
}
- regKey.setInt(_T("QueryTimeout"), key.getInt(_T("QueryTimeout"), 10));
+ regKey.setInt("QueryTimeout", key.getInt("QueryTimeout", 10));
std::vector<uint8_t> passwd;
- passwd = key.getBinary(_T("Password"));
- regKey.setBinary(_T("Password"), passwd.data(), passwd.size());
-
- bool enableInputs = key.getBool(_T("InputsEnabled"), true);
- regKey.setBool(_T("AcceptKeyEvents"), enableInputs);
- regKey.setBool(_T("AcceptPointerEvents"), enableInputs);
- regKey.setBool(_T("AcceptCutText"), enableInputs);
- regKey.setBool(_T("SendCutText"), enableInputs);
-
- switch (key.getInt(_T("LockSetting"), 0)) {
- case 0: regKey.setString(_T("DisconnectAction"), _T("None")); break;
- case 1: regKey.setString(_T("DisconnectAction"), _T("Lock")); break;
- case 2: regKey.setString(_T("DisconnectAction"), _T("Logoff")); break;
+ passwd = key.getBinary("Password");
+ regKey.setBinary("Password", passwd.data(), passwd.size());
+
+ bool enableInputs = key.getBool("InputsEnabled", true);
+ regKey.setBool("AcceptKeyEvents", enableInputs);
+ regKey.setBool("AcceptPointerEvents", enableInputs);
+ regKey.setBool("AcceptCutText", enableInputs);
+ regKey.setBool("SendCutText", enableInputs);
+
+ switch (key.getInt("LockSetting", 0)) {
+ case 0: regKey.setString("DisconnectAction", "None"); break;
+ case 1: regKey.setString("DisconnectAction", "Lock"); break;
+ case 2: regKey.setString("DisconnectAction", "Logoff"); break;
};
- regKey.setBool(_T("DisableLocalInputs"), key.getBool(_T("LocalInputsDisabled"), false));
+ regKey.setBool("DisableLocalInputs", key.getBool("LocalInputsDisabled", false));
// *** ignore polling preferences
// PollUnderCursor, PollForeground, OnlyPollConsole, OnlyPollOnEvent
- regKey.setBool(_T("UseHooks"), !key.getBool(_T("PollFullScreen"), false));
+ regKey.setBool("UseHooks", !key.getBool("PollFullScreen", false));
- if (key.isValue(_T("AllowShutdown")))
- MsgBox(0, _T("The AllowShutdown option is not supported by this release."), MB_ICONWARNING | MB_OK);
- if (key.isValue(_T("AllowEditClients")))
- MsgBox(0, _T("The AllowEditClients option is not supported by this release."), MB_ICONWARNING | MB_OK);
+ if (key.isValue("AllowShutdown"))
+ MsgBox(0, "The AllowShutdown option is not supported by this release.", MB_ICONWARNING | MB_OK);
+ if (key.isValue("AllowEditClients"))
+ MsgBox(0, "The AllowEditClients option is not supported by this release.", MB_ICONWARNING | MB_OK);
- allowProperties = key.getBool(_T("AllowProperties"), allowProperties);
+ allowProperties = key.getBool("AllowProperties", allowProperties);
}
case IDC_LEGACY_IMPORT:
{
DWORD result = MsgBox(0,
- _T("Importing your legacy VNC 3.3 settings will overwrite your existing settings.\n")
- _T("Are you sure you wish to continue?"),
+ "Importing your legacy VNC 3.3 settings will overwrite your existing settings.\n"
+ "Are you sure you wish to continue?",
MB_ICONWARNING | MB_YESNO);
if (result == IDYES) {
LoadPrefs();
- MsgBox(0, _T("Imported VNC 3.3 settings successfully."),
+ MsgBox(0, "Imported VNC 3.3 settings successfully.",
MB_ICONINFORMATION | MB_OK);
// Sleep to allow RegConfig thread to reload settings
return false;
}
bool onOk() {
- regKey.setBool(_T("Protocol3.3"), isItemChecked(IDC_PROTOCOL_3_3));
+ regKey.setBool("Protocol3.3", isItemChecked(IDC_PROTOCOL_3_3));
return true;
}
}
bool PasswordDialog::onOk() {
- TPlainPasswd password1(getItemString(IDC_PASSWORD1));
- TPlainPasswd password2(getItemString(IDC_PASSWORD2));
- if (_tcscmp(password1.buf, password2.buf) != 0) {
- MsgBox(0, _T("The supplied passwords do not match"),
+ PlainPasswd password1(getItemString(IDC_PASSWORD1));
+ PlainPasswd password2(getItemString(IDC_PASSWORD2));
+ if (strcmp(password1.buf, password2.buf) != 0) {
+ MsgBox(0, "The supplied passwords do not match",
MB_ICONEXCLAMATION | MB_OK);
return false;
}
if (registryInsecure &&
- (MsgBox(0, _T("Please note that your password cannot be stored securely on this system. ")
- _T("Are you sure you wish to continue?"),
+ (MsgBox(0, "Please note that your password cannot be stored securely on this system. "
+ "Are you sure you wish to continue?",
MB_YESNO | MB_ICONWARNING) == IDNO))
return false;
PlainPasswd password(strDup(password1.buf));
ObfuscatedPasswd obfPwd(password);
- regKey.setBinary(_T("Password"), obfPwd.buf, obfPwd.length);
+ regKey.setBinary("Password", obfPwd.buf, obfPwd.length);
return true;
}
return true;
}
bool onOk() {
- regKey.setBool(_T("DisconnectClients"), isItemChecked(IDC_DISCONNECT_CLIENTS));
- regKey.setBool(_T("AlwaysShared"), isItemChecked(IDC_SHARE_ALWAYS));
- regKey.setBool(_T("NeverShared"), isItemChecked(IDC_SHARE_NEVER));
+ regKey.setBool("DisconnectClients", isItemChecked(IDC_DISCONNECT_CLIENTS));
+ regKey.setBool("AlwaysShared", isItemChecked(IDC_SHARE_ALWAYS));
+ regKey.setBool("NeverShared", isItemChecked(IDC_SHARE_NEVER));
return true;
}
protected:
#include <vncconfig/Desktop.h>
-TStr rfb::win32::AppName("TigerVNC Configuration");
+const char* rfb::win32::AppName = "TigerVNC Configuration";
#ifdef _DEBUG
// Create the required configuration registry key
RegKey rootKey;
- rootKey.createKey(configKey, _T("Software\\TigerVNC\\WinVNC4"));
+ rootKey.createKey(configKey, "Software\\TigerVNC\\WinVNC4");
// Override whatever security it already had (NT only)
bool warnOnChangePassword = false;
// Something weird happens on NT 4.0 SP5 but I can't reproduce it on other
// NT 4.0 service pack revisions.
if (e.err == ERROR_INVALID_PARAMETER) {
- MsgBox(0, _T("Windows reported an error trying to secure the VNC Server settings for this user. ")
- _T("Your settings may not be secure!"), MB_ICONWARNING | MB_OK);
+ MsgBox(0, "Windows reported an error trying to secure the VNC Server settings for this user. "
+ "Your settings may not be secure!", MB_ICONWARNING | MB_OK);
} else if (e.err != ERROR_CALL_NOT_IMPLEMENTED &&
e.err != ERROR_NOT_LOGGED_ON) {
// If the call is not implemented, ignore the error and continue
// Start a RegConfig thread, to load in existing settings
RegConfigThread config;
- config.start(configKey, _T("Software\\TigerVNC\\WinVNC4"));
+ config.start(configKey, "Software\\TigerVNC\\WinVNC4");
// Build the dialog
std::list<PropSheetPage*> pages;
HICON icon = (HICON)LoadImage(inst, MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 0, 0, LR_SHARED);
// Create the PropertySheet handler
- const TCHAR* propSheetTitle = _T("VNC Server Properties (Service-Mode)");
+ const char* propSheetTitle = "VNC Server Properties (Service-Mode)";
if (configKey == HKEY_CURRENT_USER)
- propSheetTitle = _T("VNC Server Properties (User-Mode)");
+ propSheetTitle = "VNC Server Properties (User-Mode)";
PropSheet sheet(inst, propSheetTitle, pages, icon);
#ifdef _DEBUG
} catch (rdr::SystemException& e) {
switch (e.err) {
case ERROR_ACCESS_DENIED:
- MsgBox(0, _T("You do not have sufficient access rights to run the VNC Configuration applet"),
+ MsgBox(0, "You do not have sufficient access rights to run the VNC Configuration applet",
MB_ICONSTOP | MB_OK);
return 1;
};
}
} catch (rdr::Exception& e) {
- MsgBox(NULL, TStr(e.str()), MB_ICONEXCLAMATION | MB_OK);
+ MsgBox(NULL, e.str(), MB_ICONEXCLAMATION | MB_OK);
return 1;
}
#include <winvnc/resource.h>
#include <rfb_win32/Dialog.h>
-//#include <rfb_win32/TCharArray.h>
namespace winvnc {
// Dialog methods (protected)
virtual void initDialog() {
if (hostName.buf)
- setItemString(IDC_HOST, rfb::TStr(hostName.buf));
+ setItemString(IDC_HOST, hostName.buf);
}
virtual bool onOk() {
- hostName.replaceBuf(rfb::strDup(rfb::CStr(getItemString(IDC_HOST))));
+ hostName.replaceBuf(rfb::strDup(getItemString(IDC_HOST)));
return true;
}
void ControlPanel::initDialog()
{
- TCHAR *ColumnsStrings[] = {
- (TCHAR *) "IP address",
- (TCHAR *) "Status"
+ const char *ColumnsStrings[] = {
+ "IP address",
+ "Status"
};
- InitLVColumns(IDC_LIST_CONNECTIONS, handle, 120, 2, ColumnsStrings,
+ InitLVColumns(IDC_LIST_CONNECTIONS, handle, 120, 2, (char **)ColumnsStrings,
LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM,
LVS_EX_FULLROWSELECT, LVCFMT_LEFT);
SendCommand(4, -1);
for (ListConn.iBegin(); !ListConn.iEnd(); ListConn.iNext()) {
ListConn.iGetCharInfo(ItemString);
- InsertLVItem(IDC_LIST_CONNECTIONS, handle, i, (TCHAR **) ItemString, 2);
+ InsertLVItem(IDC_LIST_CONNECTIONS, handle, i, (char **) ItemString, 2);
for (ListSelConn.iBegin(); !ListSelConn.iEnd(); ListSelConn.iNext()) {
if (ListSelConn.iGetConn() == ListConn.iGetConn())
SelectLVItem(IDC_LIST_CONNECTIONS, handle, i);
#include <winvnc/QueryConnectDialog.h>
#include <winvnc/resource.h>
#include <rfb_win32/Win32Util.h>
-#include <rfb_win32/TCharArray.h>
#include <rfb_win32/Service.h>
#include <rfb/LogWriter.h>
void QueryConnectDialog::initDialog() {
if (!SetTimer(handle, 1, 1000, 0))
throw rdr::SystemException("SetTimer", GetLastError());
- setItemString(IDC_QUERY_HOST, TStr(peerIp.buf));
+ setItemString(IDC_QUERY_HOST, peerIp.buf);
if (!userName.buf)
userName.buf = strDup("(anonymous)");
- setItemString(IDC_QUERY_USER, TStr(userName.buf));
+ setItemString(IDC_QUERY_USER, userName.buf);
setCountdownLabel();
}
void QueryConnectDialog::setCountdownLabel() {
- TCHAR buf[16];
- _stprintf(buf, _T("%d"), countdown);
+ char buf[16];
+ sprintf(buf, "%d", countdown);
setItemString(IDC_QUERY_COUNTDOWN, buf);
}
class STrayIcon : public TrayIcon {
public:
STrayIcon(STrayIconThread& t) :
- vncConfig(_T("vncconfig.exe"), isServiceProcess() ? _T("-noconsole -service") : _T("-noconsole")),
- vncConnect(_T("winvnc4.exe"), _T("-noconsole -connect")), thread(t) {
+ vncConfig("vncconfig.exe", isServiceProcess() ? "-noconsole -service" : "-noconsole"),
+ vncConnect("winvnc4.exe", "-noconsole -connect"), thread(t) {
// ***
- SetWindowText(getHandle(), _T("winvnc::IPC_Interface"));
+ SetWindowText(getHandle(), "winvnc::IPC_Interface");
// ***
SetTimer(getHandle(), 1, 3000, 0);
thread.server.disconnectClients("tray menu disconnect");
break;
case ID_CLOSE:
- if (MsgBox(0, _T("Are you sure you want to close the server?"),
+ if (MsgBox(0, "Are you sure you want to close the server?",
MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDYES) {
if (isServiceProcess()) {
try {
rfb::win32::stopService(VNCServerService::Name);
} catch (rdr::Exception& e) {
- MsgBox(0, TStr(e.str()), MB_ICONERROR | MB_OK);
+ MsgBox(0, e.str(), MB_ICONERROR | MB_OK);
}
} else {
thread.server.stop();
}
}
-void STrayIconThread::setToolTip(const TCHAR* text) {
+void STrayIconThread::setToolTip(const char* text) {
if (!windowHandle) return;
os::AutoMutex a(lock);
delete [] toolTip.buf;
- toolTip.buf = tstrDup(text);
+ toolTip.buf = strDup(text);
PostMessage(windowHandle, WM_SET_TOOLTIP, 0, 0);
}
#define WINVNC_TRAYICON_H
#include <winvnc/VNCServerWin32.h>
-#include <rfb_win32/TCharArray.h>
#include <rfb/Configuration.h>
namespace os {
UINT activeIcon, UINT dis_inactiveIcon, UINT dis_activeIcon, UINT menu);
virtual ~STrayIconThread();
- void setToolTip(const TCHAR* text);
+ void setToolTip(const char* text);
static rfb::BoolParameter disableOptions;
static rfb::BoolParameter disableClose;
os::Mutex* lock;
DWORD thread_id;
HWND windowHandle;
- rfb::TCharArray toolTip;
+ rfb::CharArray toolTip;
VNCServerWin32& server;
UINT inactiveIcon;
UINT activeIcon;
using namespace rfb;
using namespace win32;
-const TCHAR* winvnc::VNCServerService::Name = _T("TigerVNC");
+const char* winvnc::VNCServerService::Name = "TigerVNC";
// SendSAS is not available until Windows 7, and missing from MinGW
static HMODULE sasLibrary = NULL;
if (GetSessionUserTokenWin(&hToken))
{
ModuleFileName filename;
- TCharArray cmdLine;
+ CharArray cmdLine;
cmdLine.format("\"%s\" -noconsole -service_run", filename.buf);
STARTUPINFO si;
ZeroMemory(&si, sizeof si);
return hProcess;
}
-DWORD VNCServerService::serviceMain(int /*argc*/, TCHAR* /*argv*/ [])
+DWORD VNCServerService::serviceMain(int /*argc*/, char* /*argv*/ [])
{
ConsoleSessionId OlddwSessionId;
public:
VNCServerService();
- DWORD serviceMain(int argc, TCHAR* argv[]);
+ DWORD serviceMain(int argc, char* argv[]);
void stop();
- static const TCHAR* Name;
+ static const char* Name;
protected:
rfb::win32::Handle stopServiceEvent;
rfb::win32::Handle sessionEvent;
static LogWriter vlog("VNCServerWin32");
-const TCHAR* winvnc::VNCServerWin32::RegConfigPath = _T("Software\\TigerVNC\\WinVNC4");
+const char* winvnc::VNCServerWin32::RegConfigPath = "Software\\TigerVNC\\WinVNC4";
static IntParameter port_number("PortNumber",
commandEvent(CreateEvent(0, TRUE, FALSE, 0)),
sessionEvent(isServiceProcess() ?
CreateEvent(0, FALSE, FALSE, "Global\\SessionEventTigerVNC") : 0),
- vncServer(CStr(ComputerName().buf), &desktop),
+ vncServer(ComputerName().buf, &desktop),
thread_id(-1), runServer(false), isDesktopStarted(false),
config(&sockMgr), rfbSock(&sockMgr), trayIcon(0),
queryConnectDialog(0)
return;
// Tool-tip prefix depends on server mode
- const TCHAR* prefix = _T("VNC Server (User):");
+ const char* prefix = "VNC Server (User):";
if (isServiceProcess())
- prefix = _T("VNC Server (Service):");
+ prefix = "VNC Server (Service):";
// Fetch the list of addresses
std::list<char*> addrs;
// Allocate space for the new tip
std::list<char*>::iterator i, next_i;
- int length = _tcslen(prefix)+1;
+ int length = strlen(prefix)+1;
for (i=addrs.begin(); i!= addrs.end(); i++)
length += strlen(*i) + 1;
// Build the new tip
- TCharArray toolTip(length);
- _tcscpy(toolTip.buf, prefix);
+ CharArray toolTip(length);
+ strcpy(toolTip.buf, prefix);
for (i=addrs.begin(); i!= addrs.end(); i=next_i) {
next_i = i; next_i ++;
- TCharArray addr(*i); // Assumes ownership of string
- _tcscat(toolTip.buf, addr.buf);
+ CharArray addr(*i); // Assumes ownership of string
+ strcat(toolTip.buf, addr.buf);
if (next_i != addrs.end())
- _tcscat(toolTip.buf, _T(","));
+ strcat(toolTip.buf, ",");
}
// Pass the new tip to the tray icon
#include <rfb_win32/RegConfig.h>
#include <rfb_win32/SDisplay.h>
#include <rfb_win32/SocketManager.h>
-#include <rfb_win32/TCharArray.h>
#include <winvnc/QueryConnectDialog.h>
#include <winvnc/ManagedListener.h>
void queryConnectionComplete();
// Where to read the configuration settings from
- static const TCHAR* RegConfigPath;
+ static const char* RegConfigPath;
bool getClientsInfo(ListConnInfo* LCInfo);
static LogWriter vlog("main");
-TStr rfb::win32::AppName("TigerVNC Server");
+const char* rfb::win32::AppName = "TigerVNC Server";
extern bool runAsService;
static void programInfo() {
win32::FileVersionInfo inf;
- _tprintf(_T("%s - %s, Version %s\n"),
- inf.getVerString(_T("ProductName")),
- inf.getVerString(_T("FileDescription")),
- inf.getVerString(_T("FileVersion")));
+ printf("%s - %s, Version %s\n",
+ inf.getVerString("ProductName"),
+ inf.getVerString("FileDescription"),
+ inf.getVerString("FileVersion"));
printf("%s\n", buildTime);
- _tprintf(_T("%s\n\n"), inf.getVerString(_T("LegalCopyright")));
+ printf("%s\n\n", inf.getVerString("LegalCopyright"));
}
static void programUsage() {
static void MsgBoxOrLog(const char* msg, bool isError=false) {
if (close_console) {
- MsgBox(0, TStr(msg), (isError ? MB_ICONERROR : MB_ICONINFORMATION) | MB_OK);
+ MsgBox(0, msg, (isError ? MB_ICONERROR : MB_ICONINFORMATION) | MB_OK);
} else {
if (isError) {
try {
host.buf = strDup(ancd.getHostName());
}
if (host.buf) {
- HWND hwnd = FindWindow(0, _T("winvnc::IPC_Interface"));
+ HWND hwnd = FindWindow(0, "winvnc::IPC_Interface");
if (!hwnd)
throw rdr::Exception("Unable to locate existing VNC Server.");
COPYDATASTRUCT copyData;
}
} else if (strcasecmp(argv[i], "-disconnect") == 0) {
runServer = false;
- HWND hwnd = FindWindow(0, _T("winvnc::IPC_Interface"));
+ HWND hwnd = FindWindow(0, "winvnc::IPC_Interface");
if (!hwnd)
throw rdr::Exception("Unable to locate existing VNC Server.");
COPYDATASTRUCT copyData;
CharArray result;
DWORD state = rfb::win32::getServiceState(VNCServerService::Name);
result.format("The %s Service is in the %s state.",
- (const char*)CStr(VNCServerService::Name),
+ VNCServerService::Name,
rfb::win32::serviceStateName(state));
MsgBoxOrLog(result.buf);
} else if (strcasecmp(argv[i], "-service") == 0) {
}
if (rfb::win32::registerService(VNCServerService::Name,
- _T("TigerVNC Server"),
- _T("Provides remote access to this machine via the VNC/RFB protocol."),
+ "TigerVNC Server",
+ "Provides remote access to this machine via the VNC/RFB protocol.",
argc-(j+1), &argv[j+1]))
MsgBoxOrLog("Registered service successfully");
} else if (strcasecmp(argv[i], "-unregister") == 0) {
#include <config.h>
#endif
-#include <tchar.h>
-
#include <wm_hooks/wm_hooks.h>
#include <os/os.h>
#define SHARED __attribute__((section ("shared"), shared))
-UINT WM_HK_PingThread = RegisterWindowMessage(_T("RFB.WM_Hooks.PingThread"));
+UINT WM_HK_PingThread = RegisterWindowMessage("RFB.WM_Hooks.PingThread");
-UINT WM_HK_WindowChanged = RegisterWindowMessage(_T("RFB.WM_Hooks.WindowChanged"));
+UINT WM_HK_WindowChanged = RegisterWindowMessage("RFB.WM_Hooks.WindowChanged");
UINT WM_Hooks_WindowChanged() {
return WM_HK_WindowChanged;
}
-UINT WM_HK_WindowClientAreaChanged = RegisterWindowMessage(_T("RFB.WM_Hooks.WindowClientAreaChanged"));
+UINT WM_HK_WindowClientAreaChanged = RegisterWindowMessage("RFB.WM_Hooks.WindowClientAreaChanged");
UINT WM_Hooks_WindowClientAreaChanged() {
return WM_HK_WindowClientAreaChanged;
}
-UINT WM_HK_WindowBorderChanged = RegisterWindowMessage(_T("RFB.WM_Hooks.WindowBorderChanged"));
+UINT WM_HK_WindowBorderChanged = RegisterWindowMessage("RFB.WM_Hooks.WindowBorderChanged");
UINT WM_Hooks_WindowBorderChanged() {
return WM_HK_WindowBorderChanged;
}
-UINT WM_HK_RectangleChanged = RegisterWindowMessage(_T("RFB.WM_Hooks.RectangleChanged"));
+UINT WM_HK_RectangleChanged = RegisterWindowMessage("RFB.WM_Hooks.RectangleChanged");
UINT WM_Hooks_RectangleChanged() {
return WM_HK_RectangleChanged;
}
-UINT WM_HK_CursorChanged = RegisterWindowMessage(_T("RFB.WM_Hooks.CursorChanged"));
+UINT WM_HK_CursorChanged = RegisterWindowMessage("RFB.WM_Hooks.CursorChanged");
UINT WM_Hooks_CursorChanged() {
return WM_HK_CursorChanged;
}
#ifdef _DEBUG
-UINT WM_HK_Diagnostic = RegisterWindowMessage(_T("RFB.WM_Hooks.Diagnostic"));
+UINT WM_HK_Diagnostic = RegisterWindowMessage("RFB.WM_Hooks.Diagnostic");
UINT WM_Hooks_Diagnostic() {
return WM_HK_Diagnostic;
}
#endif
-ATOM ATOM_Popup_Selection = GlobalAddAtom(_T("RFB.WM_Hooks.PopupSelectionAtom"));
+ATOM ATOM_Popup_Selection = GlobalAddAtom("RFB.WM_Hooks.PopupSelectionAtom");
//
// -=- DLL entry point