chore: use nullptr where possible in place of NULL
This commit is contained in:
@ -26,7 +26,7 @@ int main(int argc, char **argv)
|
||||
ArchMiscWindows::guardRuntimeVersion();
|
||||
|
||||
// record window instance for tray icon, etc
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(nullptr));
|
||||
#endif
|
||||
|
||||
Arch arch;
|
||||
|
||||
@ -44,7 +44,7 @@ int main(int argc, char **argv)
|
||||
QCoreApplication m(argc, argv);
|
||||
m.deleteLater();
|
||||
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(nullptr));
|
||||
#endif
|
||||
|
||||
Arch arch;
|
||||
|
||||
@ -123,7 +123,7 @@ int main(int argc, char *argv[])
|
||||
"Please drag %1 to the Applications folder, "
|
||||
"and open it from there."
|
||||
);
|
||||
QMessageBox::information(NULL, kAppName, msgBody.arg(kAppName));
|
||||
QMessageBox::information(nullptr, kAppName, msgBody.arg(kAppName));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ bool checkMacAssistiveDevices()
|
||||
|
||||
const void *keys[] = {kAXTrustedCheckOptionPrompt};
|
||||
const void *trueValue[] = {kCFBooleanTrue};
|
||||
CFDictionaryRef options = CFDictionaryCreate(NULL, keys, trueValue, 1, NULL, NULL);
|
||||
CFDictionaryRef options = CFDictionaryCreate(nullptr, keys, trueValue, 1, nullptr, nullptr);
|
||||
|
||||
bool result = AXIsProcessTrustedWithOptions(options);
|
||||
CFRelease(options);
|
||||
|
||||
@ -26,7 +26,7 @@ int main(int argc, char **argv)
|
||||
ArchMiscWindows::guardRuntimeVersion();
|
||||
|
||||
// record window instance for tray icon, etc
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(nullptr));
|
||||
#endif
|
||||
|
||||
Arch arch;
|
||||
|
||||
@ -15,11 +15,11 @@
|
||||
// Arch
|
||||
//
|
||||
|
||||
Arch *Arch::s_instance = NULL;
|
||||
Arch *Arch::s_instance = nullptr;
|
||||
|
||||
Arch::Arch()
|
||||
{
|
||||
assert(s_instance == NULL);
|
||||
assert(s_instance == nullptr);
|
||||
s_instance = this;
|
||||
}
|
||||
|
||||
@ -42,6 +42,6 @@ void Arch::init()
|
||||
|
||||
Arch *Arch::getInstance()
|
||||
{
|
||||
assert(s_instance != NULL);
|
||||
assert(s_instance != nullptr);
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ public:
|
||||
\c commandLine should \b not include the name of program as the
|
||||
first argument. If \c allUsers is true then the daemon will be
|
||||
installed to start at boot time, otherwise it will be installed to
|
||||
start when the current user logs in. If \p dependencies is not NULL
|
||||
start when the current user logs in. If \p dependencies is not nullptr
|
||||
then it's a concatenation of NUL terminated other daemon names
|
||||
followed by a NUL; the daemon will be configured to startup after
|
||||
the listed daemons. Throws an \c XArchDaemon exception on failure.
|
||||
|
||||
@ -247,7 +247,7 @@ public:
|
||||
//! Set the interrupt handler
|
||||
/*!
|
||||
Sets the function to call on receipt of an external interrupt.
|
||||
By default and when \p func is NULL, the main thread is cancelled.
|
||||
By default and when \p func is nullptr, the main thread is cancelled.
|
||||
*/
|
||||
virtual void setSignalHandler(ESignal, SignalFunc func, void *userData) = 0;
|
||||
|
||||
|
||||
@ -149,10 +149,10 @@ public:
|
||||
/*!
|
||||
Accepts a connection on socket \c s, returning a new socket for the
|
||||
connection and filling in \c addr with the address of the remote
|
||||
end. \c addr may be NULL if the remote address isn't required.
|
||||
end. \c addr may be nullptr if the remote address isn't required.
|
||||
The original socket \c s is unaffected and remains in the listening
|
||||
state. The new socket shares most of the properties of \c s except
|
||||
it's not in the listening state and it's connected. Returns NULL
|
||||
it's not in the listening state and it's connected. Returns nullptr
|
||||
if there are no pending connection requests.
|
||||
*/
|
||||
virtual ArchSocket acceptSocket(ArchSocket s, ArchNetAddress *addr) = 0;
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
static ArchMutex s_mutex = NULL;
|
||||
static ArchMutex s_mutex = nullptr;
|
||||
|
||||
//
|
||||
// use C library non-reentrant multibyte conversion with mutex
|
||||
@ -21,9 +21,9 @@ static ArchMutex s_mutex = NULL;
|
||||
|
||||
IArchString::~IArchString()
|
||||
{
|
||||
if (s_mutex != NULL) {
|
||||
if (s_mutex != nullptr) {
|
||||
ARCH->closeMutex(s_mutex);
|
||||
s_mutex = NULL;
|
||||
s_mutex = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,18 +32,18 @@ int IArchString::convStringWCToMB(char *dst, const wchar_t *src, uint32_t n, boo
|
||||
ptrdiff_t len = 0;
|
||||
|
||||
bool dummyErrors;
|
||||
if (errors == NULL) {
|
||||
if (errors == nullptr) {
|
||||
errors = &dummyErrors;
|
||||
}
|
||||
*errors = false;
|
||||
|
||||
if (s_mutex == NULL) {
|
||||
if (s_mutex == nullptr) {
|
||||
s_mutex = ARCH->newMutex();
|
||||
}
|
||||
|
||||
ARCH->lockMutex(s_mutex);
|
||||
|
||||
if (dst == NULL) {
|
||||
if (dst == nullptr) {
|
||||
char dummy[MB_LEN_MAX];
|
||||
const wchar_t *scan = src;
|
||||
for (; n > 0; --n) {
|
||||
@ -90,18 +90,18 @@ int IArchString::convStringMBToWC(wchar_t *dst, const char *src, uint32_t n, boo
|
||||
wchar_t dummy;
|
||||
|
||||
bool dummyErrors;
|
||||
if (errors == NULL) {
|
||||
if (errors == nullptr) {
|
||||
errors = &dummyErrors;
|
||||
}
|
||||
*errors = false;
|
||||
|
||||
if (s_mutex == NULL) {
|
||||
if (s_mutex == nullptr) {
|
||||
s_mutex = ARCH->newMutex();
|
||||
}
|
||||
|
||||
ARCH->lockMutex(s_mutex);
|
||||
|
||||
if (dst == NULL) {
|
||||
if (dst == nullptr) {
|
||||
const char *scan = src;
|
||||
while (n > 0) {
|
||||
ptrdiff_t mblen = mbtowc(&dummy, scan, n);
|
||||
|
||||
@ -49,7 +49,7 @@ int execSelfNonDaemonized()
|
||||
|
||||
bool alreadyDaemonized()
|
||||
{
|
||||
return getenv("_DESKFLOW_DAEMONIZED") != NULL;
|
||||
return getenv("_DESKFLOW_DAEMONIZED") != nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -70,13 +70,13 @@ public:
|
||||
ArchThreadImpl::ArchThreadImpl()
|
||||
: m_refCount(1),
|
||||
m_id(0),
|
||||
m_func(NULL),
|
||||
m_userData(NULL),
|
||||
m_func(nullptr),
|
||||
m_userData(nullptr),
|
||||
m_cancel(false),
|
||||
m_cancelling(false),
|
||||
m_exited(false),
|
||||
m_result(NULL),
|
||||
m_networkData(NULL)
|
||||
m_result(nullptr),
|
||||
m_networkData(nullptr)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
@ -85,18 +85,18 @@ ArchThreadImpl::ArchThreadImpl()
|
||||
// ArchMultithreadPosix
|
||||
//
|
||||
|
||||
ArchMultithreadPosix *ArchMultithreadPosix::s_instance = NULL;
|
||||
ArchMultithreadPosix *ArchMultithreadPosix::s_instance = nullptr;
|
||||
|
||||
ArchMultithreadPosix::ArchMultithreadPosix() : m_newThreadCalled(false), m_nextID(0)
|
||||
{
|
||||
assert(s_instance == NULL);
|
||||
assert(s_instance == nullptr);
|
||||
|
||||
s_instance = this;
|
||||
|
||||
// no signal handlers
|
||||
for (size_t i = 0; i < kNUM_SIGNALS; ++i) {
|
||||
m_signalFunc[i] = NULL;
|
||||
m_signalUserData[i] = NULL;
|
||||
m_signalFunc[i] = nullptr;
|
||||
m_signalUserData[i] = nullptr;
|
||||
}
|
||||
|
||||
// create mutex for thread list
|
||||
@ -121,25 +121,25 @@ ArchMultithreadPosix::ArchMultithreadPosix() : m_newThreadCalled(false), m_nextI
|
||||
act.sa_flags = 0;
|
||||
#endif
|
||||
act.sa_handler = &threadCancel;
|
||||
sigaction(SIGWAKEUP, &act, NULL);
|
||||
sigaction(SIGWAKEUP, &act, nullptr);
|
||||
|
||||
// set desired signal dispositions. let SIGWAKEUP through but
|
||||
// ignore SIGPIPE (we'll handle EPIPE).
|
||||
sigset_t sigset;
|
||||
sigemptyset(&sigset);
|
||||
sigaddset(&sigset, SIGWAKEUP);
|
||||
pthread_sigmask(SIG_UNBLOCK, &sigset, NULL);
|
||||
pthread_sigmask(SIG_UNBLOCK, &sigset, nullptr);
|
||||
sigemptyset(&sigset);
|
||||
sigaddset(&sigset, SIGPIPE);
|
||||
pthread_sigmask(SIG_BLOCK, &sigset, NULL);
|
||||
pthread_sigmask(SIG_BLOCK, &sigset, nullptr);
|
||||
}
|
||||
|
||||
ArchMultithreadPosix::~ArchMultithreadPosix()
|
||||
{
|
||||
assert(s_instance != NULL);
|
||||
assert(s_instance != nullptr);
|
||||
|
||||
closeMutex(m_threadMutex);
|
||||
s_instance = NULL;
|
||||
s_instance = nullptr;
|
||||
}
|
||||
|
||||
void ArchMultithreadPosix::setNetworkDataForCurrentThread(void *data)
|
||||
@ -166,7 +166,7 @@ ArchMultithreadPosix *ArchMultithreadPosix::getInstance()
|
||||
ArchCond ArchMultithreadPosix::newCondVar()
|
||||
{
|
||||
ArchCondImpl *cond = new ArchCondImpl;
|
||||
int status = pthread_cond_init(&cond->m_cond, NULL);
|
||||
int status = pthread_cond_init(&cond->m_cond, nullptr);
|
||||
(void)status;
|
||||
assert(status == 0);
|
||||
return cond;
|
||||
@ -214,7 +214,7 @@ bool ArchMultithreadPosix::waitCondVar(ArchCond cond, ArchMutex mutex, double ti
|
||||
|
||||
// get final time
|
||||
struct timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
gettimeofday(&now, nullptr);
|
||||
struct timespec finalTime;
|
||||
finalTime.tv_sec = now.tv_sec;
|
||||
finalTime.tv_nsec = now.tv_usec * 1000;
|
||||
@ -312,7 +312,7 @@ void ArchMultithreadPosix::unlockMutex(ArchMutex mutex)
|
||||
|
||||
ArchThread ArchMultithreadPosix::newThread(ThreadFunc func, void *data)
|
||||
{
|
||||
assert(func != NULL);
|
||||
assert(func != nullptr);
|
||||
|
||||
// initialize signal handler. we do this here instead of the
|
||||
// constructor so we can avoid daemonizing (using fork())
|
||||
@ -336,7 +336,7 @@ ArchThread ArchMultithreadPosix::newThread(ThreadFunc func, void *data)
|
||||
thread->m_userData = data;
|
||||
|
||||
// create the thread. pthread_create() on RedHat 7.2 smp fails
|
||||
// if passed a NULL attr so use a default attr.
|
||||
// if passed a nullptr attr so use a default attr.
|
||||
pthread_attr_t attr;
|
||||
int status = pthread_attr_init(&attr);
|
||||
if (status == 0) {
|
||||
@ -348,7 +348,7 @@ ArchThread ArchMultithreadPosix::newThread(ThreadFunc func, void *data)
|
||||
if (status != 0) {
|
||||
// failed to start thread so clean up
|
||||
delete thread;
|
||||
thread = NULL;
|
||||
thread = nullptr;
|
||||
} else {
|
||||
// add thread to list
|
||||
insert(thread);
|
||||
@ -368,18 +368,18 @@ ArchThread ArchMultithreadPosix::newCurrentThread()
|
||||
lockMutex(m_threadMutex);
|
||||
ArchThreadImpl *thread = find(pthread_self());
|
||||
unlockMutex(m_threadMutex);
|
||||
assert(thread != NULL);
|
||||
assert(thread != nullptr);
|
||||
return thread;
|
||||
}
|
||||
|
||||
void ArchMultithreadPosix::closeThread(ArchThread thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
assert(thread != nullptr);
|
||||
|
||||
// decrement ref count and clean up thread if no more references
|
||||
if (--thread->m_refCount == 0) {
|
||||
// detach from thread (unless it's the main thread)
|
||||
if (thread->m_func != NULL) {
|
||||
if (thread->m_func != nullptr) {
|
||||
pthread_detach(thread->m_thread);
|
||||
}
|
||||
|
||||
@ -402,7 +402,7 @@ ArchThread ArchMultithreadPosix::copyThread(ArchThread thread)
|
||||
|
||||
void ArchMultithreadPosix::cancelThread(ArchThread thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
assert(thread != nullptr);
|
||||
|
||||
// set cancel and wakeup flags if thread can be cancelled
|
||||
bool wakeup = false;
|
||||
@ -421,7 +421,7 @@ void ArchMultithreadPosix::cancelThread(ArchThread thread)
|
||||
|
||||
void ArchMultithreadPosix::setPriorityOfThread(ArchThread thread, int /*n*/)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
assert(thread != nullptr);
|
||||
|
||||
// FIXME
|
||||
}
|
||||
@ -439,7 +439,7 @@ void ArchMultithreadPosix::testCancelThread()
|
||||
|
||||
bool ArchMultithreadPosix::wait(ArchThread target, double timeout)
|
||||
{
|
||||
assert(target != NULL);
|
||||
assert(target != nullptr);
|
||||
|
||||
lockMutex(m_threadMutex);
|
||||
|
||||
@ -528,7 +528,7 @@ void ArchMultithreadPosix::setSignalHandler(ESignal signal, SignalFunc func, voi
|
||||
void ArchMultithreadPosix::raiseSignal(ESignal signal)
|
||||
{
|
||||
lockMutex(m_threadMutex);
|
||||
if (m_signalFunc[signal] != NULL) {
|
||||
if (m_signalFunc[signal] != nullptr) {
|
||||
m_signalFunc[signal](signal, m_signalUserData[signal]);
|
||||
pthread_kill(m_mainThread->m_thread, SIGWAKEUP);
|
||||
} else if (signal == kINTERRUPT || signal == kTERMINATE) {
|
||||
@ -552,20 +552,20 @@ void ArchMultithreadPosix::startSignalHandler()
|
||||
pthread_attr_t attr;
|
||||
int status = pthread_attr_init(&attr);
|
||||
if (status == 0) {
|
||||
status = pthread_create(&m_signalThread, &attr, &ArchMultithreadPosix::threadSignalHandler, NULL);
|
||||
status = pthread_create(&m_signalThread, &attr, &ArchMultithreadPosix::threadSignalHandler, nullptr);
|
||||
pthread_attr_destroy(&attr);
|
||||
}
|
||||
if (status != 0) {
|
||||
// can't create thread to wait for signal so don't block
|
||||
// the signals.
|
||||
pthread_sigmask(SIG_UNBLOCK, &oldsigset, NULL);
|
||||
pthread_sigmask(SIG_UNBLOCK, &oldsigset, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
ArchThreadImpl *ArchMultithreadPosix::find(pthread_t thread)
|
||||
{
|
||||
ArchThreadImpl *impl = findNoRef(thread);
|
||||
if (impl != NULL) {
|
||||
if (impl != nullptr) {
|
||||
refThread(impl);
|
||||
}
|
||||
return impl;
|
||||
@ -579,15 +579,15 @@ ArchThreadImpl *ArchMultithreadPosix::findNoRef(pthread_t thread)
|
||||
return *index;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ArchMultithreadPosix::insert(ArchThreadImpl *thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
assert(thread != nullptr);
|
||||
|
||||
// thread shouldn't already be on the list
|
||||
assert(findNoRef(thread->m_thread) == NULL);
|
||||
assert(findNoRef(thread->m_thread) == nullptr);
|
||||
|
||||
// set thread id. note that we don't worry about m_nextID
|
||||
// wrapping back to 0 and duplicating thread ID's since the
|
||||
@ -611,14 +611,14 @@ void ArchMultithreadPosix::erase(ArchThreadImpl *thread)
|
||||
|
||||
void ArchMultithreadPosix::refThread(ArchThreadImpl *thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
assert(findNoRef(thread->m_thread) != NULL);
|
||||
assert(thread != nullptr);
|
||||
assert(findNoRef(thread->m_thread) != nullptr);
|
||||
++thread->m_refCount;
|
||||
}
|
||||
|
||||
void ArchMultithreadPosix::testCancelThreadImpl(ArchThreadImpl *thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
assert(thread != nullptr);
|
||||
|
||||
// update cancel state
|
||||
lockMutex(m_threadMutex);
|
||||
@ -642,14 +642,14 @@ void *ArchMultithreadPosix::threadFunc(void *vrep)
|
||||
ArchThreadImpl *thread = static_cast<ArchThreadImpl *>(vrep);
|
||||
|
||||
// setup pthreads
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
|
||||
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, nullptr);
|
||||
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, nullptr);
|
||||
|
||||
// run thread
|
||||
s_instance->doThreadFunc(thread);
|
||||
|
||||
// terminate the thread
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ArchMultithreadPosix::doThreadFunc(ArchThread thread)
|
||||
@ -748,5 +748,5 @@ void *ArchMultithreadPosix::threadSignalHandler(void *)
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ ArchSocket ArchNetworkBSD::newSocket(EAddressFamily family, ESocketType type)
|
||||
|
||||
ArchSocket ArchNetworkBSD::copySocket(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
// ref the socket and return it
|
||||
ARCH->lockMutex(m_mutex);
|
||||
@ -142,7 +142,7 @@ ArchSocket ArchNetworkBSD::copySocket(ArchSocket s)
|
||||
|
||||
void ArchNetworkBSD::closeSocket(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
// unref the socket and note if it should be released
|
||||
ARCH->lockMutex(m_mutex);
|
||||
@ -165,7 +165,7 @@ void ArchNetworkBSD::closeSocket(ArchSocket s)
|
||||
|
||||
void ArchNetworkBSD::closeSocketForRead(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
if (shutdown(s->m_fd, 0) == -1) {
|
||||
if (errno != ENOTCONN) {
|
||||
@ -176,7 +176,7 @@ void ArchNetworkBSD::closeSocketForRead(ArchSocket s)
|
||||
|
||||
void ArchNetworkBSD::closeSocketForWrite(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
if (shutdown(s->m_fd, 1) == -1) {
|
||||
if (errno != ENOTCONN) {
|
||||
@ -187,8 +187,8 @@ void ArchNetworkBSD::closeSocketForWrite(ArchSocket s)
|
||||
|
||||
void ArchNetworkBSD::bindSocket(ArchSocket s, ArchNetAddress addr)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(addr != NULL);
|
||||
assert(s != nullptr);
|
||||
assert(addr != nullptr);
|
||||
|
||||
if (bind(s->m_fd, TYPED_ADDR(struct sockaddr, addr), addr->m_len) == -1) {
|
||||
throwError(errno);
|
||||
@ -197,7 +197,7 @@ void ArchNetworkBSD::bindSocket(ArchSocket s, ArchNetAddress addr)
|
||||
|
||||
void ArchNetworkBSD::listenOnSocket(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
// hardcoding backlog
|
||||
if (listen(s->m_fd, 3) == -1) {
|
||||
@ -207,9 +207,9 @@ void ArchNetworkBSD::listenOnSocket(ArchSocket s)
|
||||
|
||||
ArchSocket ArchNetworkBSD::acceptSocket(ArchSocket s, ArchNetAddress *addr)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
// if user passed NULL in addr then use scratch space
|
||||
// if user passed nullptr in addr then use scratch space
|
||||
ArchNetAddress dummy;
|
||||
if (addr == nullptr) {
|
||||
addr = &dummy;
|
||||
@ -258,8 +258,8 @@ ArchSocket ArchNetworkBSD::acceptSocket(ArchSocket s, ArchNetAddress *addr)
|
||||
|
||||
bool ArchNetworkBSD::connectSocket(ArchSocket s, ArchNetAddress addr)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(addr != NULL);
|
||||
assert(s != nullptr);
|
||||
assert(addr != nullptr);
|
||||
|
||||
if (connect(s->m_fd, TYPED_ADDR(struct sockaddr, addr), addr->m_len) == -1) {
|
||||
if (errno == EISCONN) {
|
||||
@ -372,7 +372,7 @@ void ArchNetworkBSD::unblockPollSocket(ArchThread thread)
|
||||
|
||||
size_t ArchNetworkBSD::readSocket(ArchSocket s, void *buf, size_t len)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
ssize_t n = read(s->m_fd, buf, len);
|
||||
if (n == -1) {
|
||||
@ -386,7 +386,7 @@ size_t ArchNetworkBSD::readSocket(ArchSocket s, void *buf, size_t len)
|
||||
|
||||
size_t ArchNetworkBSD::writeSocket(ArchSocket s, const void *buf, size_t len)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
ssize_t n = write(s->m_fd, buf, len);
|
||||
if (n == -1) {
|
||||
@ -400,7 +400,7 @@ size_t ArchNetworkBSD::writeSocket(ArchSocket s, const void *buf, size_t len)
|
||||
|
||||
void ArchNetworkBSD::throwErrorOnSocket(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
// get the error from the socket layer
|
||||
int err = 0;
|
||||
@ -435,7 +435,7 @@ void ArchNetworkBSD::setBlockingOnSocket(int fd, bool blocking)
|
||||
|
||||
bool ArchNetworkBSD::setNoDelayOnSocket(ArchSocket s, bool noDelay)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
// get old state
|
||||
int oflag;
|
||||
@ -455,7 +455,7 @@ bool ArchNetworkBSD::setNoDelayOnSocket(ArchSocket s, bool noDelay)
|
||||
|
||||
bool ArchNetworkBSD::setReuseAddrOnSocket(ArchSocket s, bool reuse)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
// get old state
|
||||
int oflag;
|
||||
@ -518,7 +518,7 @@ ArchNetAddress ArchNetworkBSD::newAnyAddr(EAddressFamily family)
|
||||
|
||||
ArchNetAddress ArchNetworkBSD::copyAddr(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
assert(addr != nullptr);
|
||||
|
||||
// allocate and copy address
|
||||
return new ArchNetAddressImpl(*addr);
|
||||
@ -572,14 +572,14 @@ std::vector<ArchNetAddress> ArchNetworkBSD::nameToAddr(const std::string &name)
|
||||
|
||||
void ArchNetworkBSD::closeAddr(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
assert(addr != nullptr);
|
||||
|
||||
delete addr;
|
||||
}
|
||||
|
||||
std::string ArchNetworkBSD::addrToName(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
assert(addr != nullptr);
|
||||
|
||||
// mutexed name lookup (ugh)
|
||||
ARCH->lockMutex(m_mutex);
|
||||
@ -603,7 +603,7 @@ std::string ArchNetworkBSD::addrToName(ArchNetAddress addr)
|
||||
|
||||
std::string ArchNetworkBSD::addrToString(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
assert(addr != nullptr);
|
||||
|
||||
switch (getAddrFamily(addr)) {
|
||||
case kINET: {
|
||||
@ -631,7 +631,7 @@ std::string ArchNetworkBSD::addrToString(ArchNetAddress addr)
|
||||
|
||||
IArchNetwork::EAddressFamily ArchNetworkBSD::getAddrFamily(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
assert(addr != nullptr);
|
||||
|
||||
switch (addr->m_addr.ss_family) {
|
||||
case AF_INET:
|
||||
@ -646,7 +646,7 @@ IArchNetwork::EAddressFamily ArchNetworkBSD::getAddrFamily(ArchNetAddress addr)
|
||||
|
||||
void ArchNetworkBSD::setAddrPort(ArchNetAddress addr, int port)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
assert(addr != nullptr);
|
||||
|
||||
switch (getAddrFamily(addr)) {
|
||||
case kINET: {
|
||||
@ -669,7 +669,7 @@ void ArchNetworkBSD::setAddrPort(ArchNetAddress addr, int port)
|
||||
|
||||
int ArchNetworkBSD::getAddrPort(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
assert(addr != nullptr);
|
||||
|
||||
switch (getAddrFamily(addr)) {
|
||||
case kINET: {
|
||||
@ -690,7 +690,7 @@ int ArchNetworkBSD::getAddrPort(ArchNetAddress addr)
|
||||
|
||||
bool ArchNetworkBSD::isAnyAddr(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
assert(addr != nullptr);
|
||||
|
||||
switch (getAddrFamily(addr)) {
|
||||
case kINET: {
|
||||
|
||||
@ -70,7 +70,7 @@ void ArchSleepUnix::sleep(double timeout)
|
||||
timeout2.tv_sec = static_cast<int>(timeLeft);
|
||||
timeout2.tv_usec = static_cast<int>(1.0e+6 * (timeLeft - timeout2.tv_sec));
|
||||
select(
|
||||
(SELECT_TYPE_ARG1)0, SELECT_TYPE_ARG234 NULL, SELECT_TYPE_ARG234 NULL, SELECT_TYPE_ARG234 NULL,
|
||||
(SELECT_TYPE_ARG1)0, SELECT_TYPE_ARG234 nullptr, SELECT_TYPE_ARG234 nullptr, SELECT_TYPE_ARG234 nullptr,
|
||||
SELECT_TYPE_ARG5 & timeout2
|
||||
);
|
||||
ARCH->testCancelThread();
|
||||
|
||||
@ -35,6 +35,6 @@ ArchTimeUnix::~ArchTimeUnix()
|
||||
double ArchTimeUnix::time()
|
||||
{
|
||||
struct timeval t;
|
||||
gettimeofday(&t, NULL);
|
||||
gettimeofday(&t, nullptr);
|
||||
return (double)t.tv_sec + 1.0e-6 * (double)t.tv_usec;
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
// ArchDaemonWindows
|
||||
//
|
||||
|
||||
ArchDaemonWindows *ArchDaemonWindows::s_daemon = NULL;
|
||||
ArchDaemonWindows *ArchDaemonWindows::s_daemon = nullptr;
|
||||
|
||||
ArchDaemonWindows::ArchDaemonWindows() : m_daemonThreadID(0)
|
||||
{
|
||||
@ -30,20 +30,20 @@ ArchDaemonWindows::~ArchDaemonWindows()
|
||||
|
||||
int ArchDaemonWindows::runDaemon(RunFunc runFunc)
|
||||
{
|
||||
assert(s_daemon != NULL);
|
||||
assert(s_daemon != nullptr);
|
||||
return s_daemon->doRunDaemon(runFunc);
|
||||
}
|
||||
|
||||
void ArchDaemonWindows::daemonRunning(bool running)
|
||||
{
|
||||
if (s_daemon != NULL) {
|
||||
if (s_daemon != nullptr) {
|
||||
s_daemon->doDaemonRunning(running);
|
||||
}
|
||||
}
|
||||
|
||||
UINT ArchDaemonWindows::getDaemonQuitMessage()
|
||||
{
|
||||
if (s_daemon != NULL) {
|
||||
if (s_daemon != nullptr) {
|
||||
return s_daemon->doGetDaemonQuitMessage();
|
||||
} else {
|
||||
return 0;
|
||||
@ -52,7 +52,7 @@ UINT ArchDaemonWindows::getDaemonQuitMessage()
|
||||
|
||||
void ArchDaemonWindows::daemonFailed(int result)
|
||||
{
|
||||
assert(s_daemon != NULL);
|
||||
assert(s_daemon != nullptr);
|
||||
throw XArchDaemonRunFailed(result);
|
||||
}
|
||||
|
||||
@ -63,8 +63,8 @@ void ArchDaemonWindows::installDaemon(
|
||||
LOG_DEBUG("installing windows service: %s", name);
|
||||
|
||||
// open service manager
|
||||
SC_HANDLE mgr = OpenSCManager(NULL, NULL, GENERIC_WRITE);
|
||||
if (mgr == NULL) {
|
||||
SC_HANDLE mgr = OpenSCManager(nullptr, nullptr, GENERIC_WRITE);
|
||||
if (mgr == nullptr) {
|
||||
// can't open service manager
|
||||
throw XArchDaemonInstallFailed(new XArchEvalWindows);
|
||||
}
|
||||
@ -72,10 +72,10 @@ void ArchDaemonWindows::installDaemon(
|
||||
// create the service
|
||||
SC_HANDLE service = CreateService(
|
||||
mgr, name, name, 0, SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS, SERVICE_AUTO_START,
|
||||
SERVICE_ERROR_NORMAL, pathname, NULL, NULL, dependencies, NULL, NULL
|
||||
SERVICE_ERROR_NORMAL, pathname, nullptr, nullptr, dependencies, nullptr, nullptr
|
||||
);
|
||||
|
||||
if (service == NULL) {
|
||||
if (service == nullptr) {
|
||||
// can't create service
|
||||
DWORD err = GetLastError();
|
||||
if (err != ERROR_SERVICE_EXISTS) {
|
||||
@ -93,7 +93,7 @@ void ArchDaemonWindows::installDaemon(
|
||||
// open the registry key for this service
|
||||
HKEY key = openNTServicesKey();
|
||||
key = ArchMiscWindows::addKey(key, name);
|
||||
if (key == NULL) {
|
||||
if (key == nullptr) {
|
||||
// can't open key
|
||||
DWORD err = GetLastError();
|
||||
try {
|
||||
@ -109,7 +109,7 @@ void ArchDaemonWindows::installDaemon(
|
||||
|
||||
// set command line
|
||||
key = ArchMiscWindows::addKey(key, _T("Parameters"));
|
||||
if (key == NULL) {
|
||||
if (key == nullptr) {
|
||||
// can't open key
|
||||
DWORD err = GetLastError();
|
||||
ArchMiscWindows::closeKey(key);
|
||||
@ -133,21 +133,21 @@ void ArchDaemonWindows::uninstallDaemon(const char *name)
|
||||
// remove parameters for this service. ignore failures.
|
||||
HKEY key = openNTServicesKey();
|
||||
key = ArchMiscWindows::openKey(key, name);
|
||||
if (key != NULL) {
|
||||
if (key != nullptr) {
|
||||
ArchMiscWindows::deleteKey(key, _T("Parameters"));
|
||||
ArchMiscWindows::closeKey(key);
|
||||
}
|
||||
|
||||
// open service manager
|
||||
SC_HANDLE mgr = OpenSCManager(NULL, NULL, GENERIC_WRITE);
|
||||
if (mgr == NULL) {
|
||||
SC_HANDLE mgr = OpenSCManager(nullptr, nullptr, GENERIC_WRITE);
|
||||
if (mgr == nullptr) {
|
||||
// can't open service manager
|
||||
throw XArchDaemonUninstallFailed(new XArchEvalWindows);
|
||||
}
|
||||
|
||||
// open the service. oddly, you must open a service to delete it.
|
||||
SC_HANDLE service = OpenService(mgr, name, DELETE | SERVICE_STOP);
|
||||
if (service == NULL) {
|
||||
if (service == nullptr) {
|
||||
DWORD err = GetLastError();
|
||||
CloseServiceHandle(mgr);
|
||||
if (err != ERROR_SERVICE_DOES_NOT_EXIST) {
|
||||
@ -194,8 +194,8 @@ void ArchDaemonWindows::uninstallDaemon(const char *name)
|
||||
|
||||
int ArchDaemonWindows::daemonize(const char *name, DaemonFunc func)
|
||||
{
|
||||
assert(name != NULL);
|
||||
assert(func != NULL);
|
||||
assert(name != nullptr);
|
||||
assert(func != nullptr);
|
||||
|
||||
// save daemon function
|
||||
m_daemonFunc = func;
|
||||
@ -204,27 +204,27 @@ int ArchDaemonWindows::daemonize(const char *name, DaemonFunc func)
|
||||
SERVICE_TABLE_ENTRY entry[2];
|
||||
entry[0].lpServiceName = const_cast<char *>(name);
|
||||
entry[0].lpServiceProc = &ArchDaemonWindows::serviceMainEntry;
|
||||
entry[1].lpServiceName = NULL;
|
||||
entry[1].lpServiceProc = NULL;
|
||||
entry[1].lpServiceName = nullptr;
|
||||
entry[1].lpServiceProc = nullptr;
|
||||
|
||||
// hook us up to the service control manager. this won't return
|
||||
// (if successful) until the processes have terminated.
|
||||
s_daemon = this;
|
||||
if (StartServiceCtrlDispatcher(entry) == 0) {
|
||||
// StartServiceCtrlDispatcher failed
|
||||
s_daemon = NULL;
|
||||
s_daemon = nullptr;
|
||||
throw XArchDaemonFailed(new XArchEvalWindows);
|
||||
}
|
||||
|
||||
s_daemon = NULL;
|
||||
s_daemon = nullptr;
|
||||
return m_daemonResult;
|
||||
}
|
||||
|
||||
bool ArchDaemonWindows::canInstallDaemon(const char * /*name*/)
|
||||
{
|
||||
// check if we can open service manager for write
|
||||
SC_HANDLE mgr = OpenSCManager(NULL, NULL, GENERIC_WRITE);
|
||||
if (mgr == NULL) {
|
||||
SC_HANDLE mgr = OpenSCManager(nullptr, nullptr, GENERIC_WRITE);
|
||||
if (mgr == nullptr) {
|
||||
return false;
|
||||
}
|
||||
CloseServiceHandle(mgr);
|
||||
@ -233,14 +233,14 @@ bool ArchDaemonWindows::canInstallDaemon(const char * /*name*/)
|
||||
HKEY key = openNTServicesKey();
|
||||
ArchMiscWindows::closeKey(key);
|
||||
|
||||
return (key != NULL);
|
||||
return (key != nullptr);
|
||||
}
|
||||
|
||||
bool ArchDaemonWindows::isDaemonInstalled(const char *name)
|
||||
{
|
||||
// open service manager
|
||||
SC_HANDLE mgr = OpenSCManager(NULL, NULL, GENERIC_READ);
|
||||
if (mgr == NULL) {
|
||||
SC_HANDLE mgr = OpenSCManager(nullptr, nullptr, GENERIC_READ);
|
||||
if (mgr == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -248,17 +248,17 @@ bool ArchDaemonWindows::isDaemonInstalled(const char *name)
|
||||
SC_HANDLE service = OpenService(mgr, name, GENERIC_READ);
|
||||
|
||||
// clean up
|
||||
if (service != NULL) {
|
||||
if (service != nullptr) {
|
||||
CloseServiceHandle(service);
|
||||
}
|
||||
CloseServiceHandle(mgr);
|
||||
|
||||
return (service != NULL);
|
||||
return (service != nullptr);
|
||||
}
|
||||
|
||||
HKEY ArchDaemonWindows::openNTServicesKey()
|
||||
{
|
||||
static const char *s_keyNames[] = {_T("SYSTEM"), _T("CurrentControlSet"), _T("Services"), NULL};
|
||||
static const char *s_keyNames[] = {_T("SYSTEM"), _T("CurrentControlSet"), _T("Services"), nullptr};
|
||||
|
||||
return ArchMiscWindows::addKey(HKEY_LOCAL_MACHINE, s_keyNames);
|
||||
}
|
||||
@ -279,12 +279,12 @@ bool ArchDaemonWindows::isRunState(DWORD state)
|
||||
int ArchDaemonWindows::doRunDaemon(RunFunc run)
|
||||
{
|
||||
// should only be called from DaemonFunc
|
||||
assert(m_serviceMutex != NULL);
|
||||
assert(run != NULL);
|
||||
assert(m_serviceMutex != nullptr);
|
||||
assert(run != nullptr);
|
||||
|
||||
// create message queue for this thread
|
||||
MSG dummy;
|
||||
PeekMessage(&dummy, NULL, 0, 0, PM_NOREMOVE);
|
||||
PeekMessage(&dummy, nullptr, 0, 0, PM_NOREMOVE);
|
||||
|
||||
int result = 0;
|
||||
ARCH->lockMutex(m_serviceMutex);
|
||||
@ -348,7 +348,7 @@ void ArchDaemonWindows::setStatus(DWORD state)
|
||||
|
||||
void ArchDaemonWindows::setStatus(DWORD state, DWORD step, DWORD waitHint)
|
||||
{
|
||||
assert(s_daemon != NULL);
|
||||
assert(s_daemon != nullptr);
|
||||
|
||||
LOG_DEBUG("setting service status: state=%d, step=%d, waitHint=%d", state, step, waitHint);
|
||||
|
||||
@ -365,7 +365,7 @@ void ArchDaemonWindows::setStatus(DWORD state, DWORD step, DWORD waitHint)
|
||||
|
||||
void ArchDaemonWindows::setStatusError(DWORD error)
|
||||
{
|
||||
assert(s_daemon != NULL);
|
||||
assert(s_daemon != nullptr);
|
||||
|
||||
SERVICE_STATUS status;
|
||||
status.dwServiceType = SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS;
|
||||
@ -413,7 +413,7 @@ void ArchDaemonWindows::serviceMain(DWORD argc, LPTSTR *argvIn)
|
||||
HKEY key = openNTServicesKey();
|
||||
key = ArchMiscWindows::openKey(key, argvIn[0]);
|
||||
key = ArchMiscWindows::openKey(key, _T("Parameters"));
|
||||
if (key != NULL) {
|
||||
if (key != nullptr) {
|
||||
commandLine = ArchMiscWindows::readValueString(key, _T("CommandLine"));
|
||||
}
|
||||
|
||||
@ -498,14 +498,14 @@ void WINAPI ArchDaemonWindows::serviceMainEntry(DWORD argc, LPTSTR *argv)
|
||||
|
||||
void ArchDaemonWindows::serviceHandler(DWORD ctrl)
|
||||
{
|
||||
assert(m_serviceMutex != NULL);
|
||||
assert(m_serviceCondVar != NULL);
|
||||
assert(m_serviceMutex != nullptr);
|
||||
assert(m_serviceCondVar != nullptr);
|
||||
|
||||
ARCH->lockMutex(m_serviceMutex);
|
||||
|
||||
// ignore request if service is already stopped
|
||||
if (s_daemon == NULL || m_serviceState == SERVICE_STOPPED) {
|
||||
if (s_daemon != NULL) {
|
||||
if (s_daemon == nullptr || m_serviceState == SERVICE_STOPPED) {
|
||||
if (s_daemon != nullptr) {
|
||||
setStatus(m_serviceState);
|
||||
}
|
||||
ARCH->unlockMutex(m_serviceMutex);
|
||||
@ -560,21 +560,21 @@ void WINAPI ArchDaemonWindows::serviceHandlerEntry(DWORD ctrl)
|
||||
void ArchDaemonWindows::start(const char *name)
|
||||
{
|
||||
// open service manager
|
||||
SC_HANDLE mgr = OpenSCManager(NULL, NULL, GENERIC_READ);
|
||||
if (mgr == NULL) {
|
||||
SC_HANDLE mgr = OpenSCManager(nullptr, nullptr, GENERIC_READ);
|
||||
if (mgr == nullptr) {
|
||||
throw XArchDaemonFailed(new XArchEvalWindows());
|
||||
}
|
||||
|
||||
// open the service
|
||||
SC_HANDLE service = OpenService(mgr, name, SERVICE_START);
|
||||
|
||||
if (service == NULL) {
|
||||
if (service == nullptr) {
|
||||
CloseServiceHandle(mgr);
|
||||
throw XArchDaemonFailed(new XArchEvalWindows());
|
||||
}
|
||||
|
||||
// start the service
|
||||
if (!StartService(service, 0, NULL)) {
|
||||
if (!StartService(service, 0, nullptr)) {
|
||||
throw XArchDaemonFailed(new XArchEvalWindows());
|
||||
}
|
||||
}
|
||||
@ -582,15 +582,15 @@ void ArchDaemonWindows::start(const char *name)
|
||||
void ArchDaemonWindows::stop(const char *name)
|
||||
{
|
||||
// open service manager
|
||||
SC_HANDLE mgr = OpenSCManager(NULL, NULL, GENERIC_READ);
|
||||
if (mgr == NULL) {
|
||||
SC_HANDLE mgr = OpenSCManager(nullptr, nullptr, GENERIC_READ);
|
||||
if (mgr == nullptr) {
|
||||
throw XArchDaemonFailed(new XArchEvalWindows());
|
||||
}
|
||||
|
||||
// open the service
|
||||
SC_HANDLE service = OpenService(mgr, name, SERVICE_STOP | SERVICE_QUERY_STATUS);
|
||||
|
||||
if (service == NULL) {
|
||||
if (service == nullptr) {
|
||||
CloseServiceHandle(mgr);
|
||||
throw XArchDaemonFailed(new XArchEvalWindows());
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
// ArchLogWindows
|
||||
//
|
||||
|
||||
ArchLogWindows::ArchLogWindows() : m_eventLog(NULL)
|
||||
ArchLogWindows::ArchLogWindows() : m_eventLog(nullptr)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
@ -26,16 +26,16 @@ ArchLogWindows::~ArchLogWindows()
|
||||
|
||||
void ArchLogWindows::openLog(const char *name)
|
||||
{
|
||||
if (m_eventLog == NULL) {
|
||||
m_eventLog = RegisterEventSource(NULL, name);
|
||||
if (m_eventLog == nullptr) {
|
||||
m_eventLog = RegisterEventSource(nullptr, name);
|
||||
}
|
||||
}
|
||||
|
||||
void ArchLogWindows::closeLog()
|
||||
{
|
||||
if (m_eventLog != NULL) {
|
||||
if (m_eventLog != nullptr) {
|
||||
DeregisterEventSource(m_eventLog);
|
||||
m_eventLog = NULL;
|
||||
m_eventLog = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ void ArchLogWindows::showLog(bool)
|
||||
|
||||
void ArchLogWindows::writeLog(ELevel level, const char *msg)
|
||||
{
|
||||
if (m_eventLog != NULL) {
|
||||
if (m_eventLog != nullptr) {
|
||||
// convert priority
|
||||
WORD type;
|
||||
switch (level) {
|
||||
@ -72,9 +72,9 @@ void ArchLogWindows::writeLog(ELevel level, const char *msg)
|
||||
ReportEvent(
|
||||
m_eventLog, type, static_cast<WORD>(level),
|
||||
0, // event ID
|
||||
NULL, 0,
|
||||
nullptr, 0,
|
||||
(DWORD)strlen(msg) + 1, // raw data size
|
||||
NULL,
|
||||
nullptr,
|
||||
const_cast<char *>(msg)
|
||||
); // raw data
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ void errorMessageBox(const char *message, const char *title = "Fatal Error");
|
||||
std::string getBinaryName()
|
||||
{
|
||||
std::array<char, MAX_PATH> buffer;
|
||||
if (!GetModuleFileNameA(NULL, buffer.data(), MAX_PATH)) {
|
||||
if (!GetModuleFileNameA(nullptr, buffer.data(), MAX_PATH)) {
|
||||
errorMessageBox("Failed to get binary name.");
|
||||
abort();
|
||||
}
|
||||
@ -52,10 +52,10 @@ const std::string s_binaryName = getBinaryName();
|
||||
//
|
||||
|
||||
DWORD ArchMiscWindows::s_busyState = 0;
|
||||
ArchMiscWindows::STES_t ArchMiscWindows::s_stes = NULL;
|
||||
HICON ArchMiscWindows::s_largeIcon = NULL;
|
||||
HICON ArchMiscWindows::s_smallIcon = NULL;
|
||||
HINSTANCE ArchMiscWindows::s_instanceWin32 = NULL;
|
||||
ArchMiscWindows::STES_t ArchMiscWindows::s_stes = nullptr;
|
||||
HICON ArchMiscWindows::s_largeIcon = nullptr;
|
||||
HICON ArchMiscWindows::s_smallIcon = nullptr;
|
||||
HINSTANCE ArchMiscWindows::s_instanceWin32 = nullptr;
|
||||
|
||||
void ArchMiscWindows::init()
|
||||
{
|
||||
@ -105,9 +105,9 @@ HKEY ArchMiscWindows::addKey(HKEY key, const TCHAR *const *keyNames)
|
||||
|
||||
HKEY ArchMiscWindows::openKey(HKEY key, const TCHAR *keyName, bool create)
|
||||
{
|
||||
// ignore if parent is NULL
|
||||
if (key == NULL) {
|
||||
return NULL;
|
||||
// ignore if parent is nullptr
|
||||
if (key == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// open next key
|
||||
@ -115,11 +115,11 @@ HKEY ArchMiscWindows::openKey(HKEY key, const TCHAR *keyName, bool create)
|
||||
LSTATUS result = RegOpenKeyEx(key, keyName, 0, KEY_WRITE | KEY_QUERY_VALUE, &newKey);
|
||||
if (result != ERROR_SUCCESS && create) {
|
||||
DWORD disp;
|
||||
result = RegCreateKeyEx(key, keyName, 0, NULL, 0, KEY_WRITE | KEY_QUERY_VALUE, NULL, &newKey, &disp);
|
||||
result = RegCreateKeyEx(key, keyName, 0, nullptr, 0, KEY_WRITE | KEY_QUERY_VALUE, nullptr, &newKey, &disp);
|
||||
}
|
||||
if (result != ERROR_SUCCESS) {
|
||||
RegCloseKey(key);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// switch to new key
|
||||
@ -129,7 +129,7 @@ HKEY ArchMiscWindows::openKey(HKEY key, const TCHAR *keyName, bool create)
|
||||
|
||||
HKEY ArchMiscWindows::openKey(HKEY key, const TCHAR *const *keyNames, bool create)
|
||||
{
|
||||
for (size_t i = 0; key != NULL && keyNames[i] != NULL; ++i) {
|
||||
for (size_t i = 0; key != nullptr && keyNames[i] != nullptr; ++i) {
|
||||
// open next key
|
||||
key = openKey(key, keyNames[i], create);
|
||||
}
|
||||
@ -138,17 +138,17 @@ HKEY ArchMiscWindows::openKey(HKEY key, const TCHAR *const *keyNames, bool creat
|
||||
|
||||
void ArchMiscWindows::closeKey(HKEY key)
|
||||
{
|
||||
assert(key != NULL);
|
||||
if (key == NULL)
|
||||
assert(key != nullptr);
|
||||
if (key == nullptr)
|
||||
return;
|
||||
RegCloseKey(key);
|
||||
}
|
||||
|
||||
void ArchMiscWindows::deleteKey(HKEY key, const TCHAR *name)
|
||||
{
|
||||
assert(key != NULL);
|
||||
assert(name != NULL);
|
||||
if (key == NULL || name == NULL)
|
||||
assert(key != nullptr);
|
||||
assert(name != nullptr);
|
||||
if (key == nullptr || name == nullptr)
|
||||
return;
|
||||
RegDeleteKey(key, name);
|
||||
}
|
||||
@ -156,7 +156,7 @@ void ArchMiscWindows::deleteKey(HKEY key, const TCHAR *name)
|
||||
ArchMiscWindows::EValueType ArchMiscWindows::typeOfValue(HKEY key, const TCHAR *name)
|
||||
{
|
||||
DWORD type;
|
||||
LONG result = RegQueryValueEx(key, name, 0, &type, NULL, NULL);
|
||||
LONG result = RegQueryValueEx(key, name, 0, &type, nullptr, nullptr);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
return kNO_VALUE;
|
||||
}
|
||||
@ -177,8 +177,8 @@ ArchMiscWindows::EValueType ArchMiscWindows::typeOfValue(HKEY key, const TCHAR *
|
||||
|
||||
void ArchMiscWindows::setValue(HKEY key, const TCHAR *name, const std::string &value)
|
||||
{
|
||||
assert(key != NULL);
|
||||
if (key == NULL) {
|
||||
assert(key != nullptr);
|
||||
if (key == nullptr) {
|
||||
// TODO: throw exception
|
||||
return;
|
||||
}
|
||||
@ -187,8 +187,8 @@ void ArchMiscWindows::setValue(HKEY key, const TCHAR *name, const std::string &v
|
||||
|
||||
void ArchMiscWindows::setValue(HKEY key, const TCHAR *name, DWORD value)
|
||||
{
|
||||
assert(key != NULL);
|
||||
if (key == NULL) {
|
||||
assert(key != nullptr);
|
||||
if (key == nullptr) {
|
||||
// TODO: throw exception
|
||||
return;
|
||||
}
|
||||
@ -200,7 +200,7 @@ std::string ArchMiscWindows::readBinaryOrString(HKEY key, const TCHAR *name, DWO
|
||||
// get the size of the string
|
||||
DWORD actualType;
|
||||
DWORD size = 0;
|
||||
LONG result = RegQueryValueEx(key, name, 0, &actualType, NULL, &size);
|
||||
LONG result = RegQueryValueEx(key, name, 0, &actualType, nullptr, &size);
|
||||
if (result != ERROR_SUCCESS || actualType != type) {
|
||||
return std::string();
|
||||
}
|
||||
@ -263,12 +263,12 @@ void ArchMiscWindows::removeBusyState(DWORD busyModes)
|
||||
void ArchMiscWindows::setThreadExecutionState(DWORD busyModes)
|
||||
{
|
||||
// look up function dynamically so we work on older systems
|
||||
if (s_stes == NULL) {
|
||||
if (s_stes == nullptr) {
|
||||
HINSTANCE kernel = LoadLibrary("kernel32.dll");
|
||||
if (kernel != NULL) {
|
||||
if (kernel != nullptr) {
|
||||
s_stes = reinterpret_cast<STES_t>(GetProcAddress(kernel, "SetThreadExecutionState"));
|
||||
}
|
||||
if (s_stes == NULL) {
|
||||
if (s_stes == nullptr) {
|
||||
s_stes = &ArchMiscWindows::dummySetThreadExecutionState;
|
||||
}
|
||||
}
|
||||
@ -301,12 +301,12 @@ void ArchMiscWindows::wakeupDisplay()
|
||||
// We can't use ::setThreadExecutionState here because it sets
|
||||
// ES_CONTINUOUS, which we don't want.
|
||||
|
||||
if (s_stes == NULL) {
|
||||
if (s_stes == nullptr) {
|
||||
HINSTANCE kernel = LoadLibrary("kernel32.dll");
|
||||
if (kernel != NULL) {
|
||||
if (kernel != nullptr) {
|
||||
s_stes = reinterpret_cast<STES_t>(GetProcAddress(kernel, "SetThreadExecutionState"));
|
||||
}
|
||||
if (s_stes == NULL) {
|
||||
if (s_stes == nullptr) {
|
||||
s_stes = &ArchMiscWindows::dummySetThreadExecutionState;
|
||||
}
|
||||
}
|
||||
@ -394,13 +394,13 @@ BOOL WINAPI ArchMiscWindows::getProcessEntry(PROCESSENTRY32 &entry, DWORD proces
|
||||
HINSTANCE
|
||||
ArchMiscWindows::instanceWin32()
|
||||
{
|
||||
assert(s_instanceWin32 != NULL);
|
||||
assert(s_instanceWin32 != nullptr);
|
||||
return s_instanceWin32;
|
||||
}
|
||||
|
||||
void ArchMiscWindows::setInstanceWin32(HINSTANCE instance)
|
||||
{
|
||||
assert(instance != NULL);
|
||||
assert(instance != nullptr);
|
||||
s_instanceWin32 = instance;
|
||||
}
|
||||
|
||||
|
||||
@ -50,16 +50,16 @@ public:
|
||||
|
||||
ArchThreadImpl::ArchThreadImpl()
|
||||
: m_refCount(1),
|
||||
m_thread(NULL),
|
||||
m_thread(nullptr),
|
||||
m_id(0),
|
||||
m_func(NULL),
|
||||
m_userData(NULL),
|
||||
m_func(nullptr),
|
||||
m_userData(nullptr),
|
||||
m_cancelling(false),
|
||||
m_result(NULL),
|
||||
m_networkData(NULL)
|
||||
m_result(nullptr),
|
||||
m_networkData(nullptr)
|
||||
{
|
||||
m_exit = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
m_cancel = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
m_exit = CreateEvent(nullptr, TRUE, FALSE, nullptr);
|
||||
m_cancel = CreateEvent(nullptr, TRUE, FALSE, nullptr);
|
||||
}
|
||||
|
||||
ArchThreadImpl::~ArchThreadImpl()
|
||||
@ -72,17 +72,17 @@ ArchThreadImpl::~ArchThreadImpl()
|
||||
// ArchMultithreadWindows
|
||||
//
|
||||
|
||||
ArchMultithreadWindows *ArchMultithreadWindows::s_instance = NULL;
|
||||
ArchMultithreadWindows *ArchMultithreadWindows::s_instance = nullptr;
|
||||
|
||||
ArchMultithreadWindows::ArchMultithreadWindows()
|
||||
{
|
||||
assert(s_instance == NULL);
|
||||
assert(s_instance == nullptr);
|
||||
s_instance = this;
|
||||
|
||||
// no signal handlers
|
||||
for (size_t i = 0; i < kNUM_SIGNALS; ++i) {
|
||||
m_signalFunc[i] = NULL;
|
||||
m_signalUserData[i] = NULL;
|
||||
m_signalFunc[i] = nullptr;
|
||||
m_signalUserData[i] = nullptr;
|
||||
}
|
||||
|
||||
// create mutex for thread list
|
||||
@ -91,14 +91,14 @@ ArchMultithreadWindows::ArchMultithreadWindows()
|
||||
// create thread for calling (main) thread and add it to our
|
||||
// list. no need to lock the mutex since we're the only thread.
|
||||
m_mainThread = new ArchThreadImpl;
|
||||
m_mainThread->m_thread = NULL;
|
||||
m_mainThread->m_thread = nullptr;
|
||||
m_mainThread->m_id = GetCurrentThreadId();
|
||||
insert(m_mainThread);
|
||||
}
|
||||
|
||||
ArchMultithreadWindows::~ArchMultithreadWindows()
|
||||
{
|
||||
s_instance = NULL;
|
||||
s_instance = nullptr;
|
||||
|
||||
// clean up thread list
|
||||
for (ThreadList::iterator index = m_threadList.begin(); index != m_threadList.end(); ++index) {
|
||||
@ -142,8 +142,8 @@ ArchMultithreadWindows *ArchMultithreadWindows::getInstance()
|
||||
ArchCond ArchMultithreadWindows::newCondVar()
|
||||
{
|
||||
ArchCondImpl *cond = new ArchCondImpl;
|
||||
cond->m_events[ArchCondImpl::kSignal] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
cond->m_events[ArchCondImpl::kBroadcast] = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
cond->m_events[ArchCondImpl::kSignal] = CreateEvent(nullptr, FALSE, FALSE, nullptr);
|
||||
cond->m_events[ArchCondImpl::kBroadcast] = CreateEvent(nullptr, TRUE, FALSE, nullptr);
|
||||
cond->m_waitCountMutex = newMutex();
|
||||
cond->m_waitCount = 0;
|
||||
return cond;
|
||||
@ -272,14 +272,14 @@ ArchThread ArchMultithreadWindows::newThread(ThreadFunc func, void *data)
|
||||
|
||||
// create thread
|
||||
unsigned int id = 0;
|
||||
thread->m_thread = reinterpret_cast<HANDLE>(_beginthreadex(NULL, 0, threadFunc, (void *)thread, 0, &id));
|
||||
thread->m_thread = reinterpret_cast<HANDLE>(_beginthreadex(nullptr, 0, threadFunc, (void *)thread, 0, &id));
|
||||
thread->m_id = static_cast<DWORD>(id);
|
||||
|
||||
// check if thread was started
|
||||
if (thread->m_thread == 0) {
|
||||
// failed to start thread so clean up
|
||||
delete thread;
|
||||
thread = NULL;
|
||||
thread = nullptr;
|
||||
} else {
|
||||
// add thread to list
|
||||
insert(thread);
|
||||
@ -299,18 +299,18 @@ ArchThread ArchMultithreadWindows::newCurrentThread()
|
||||
lockMutex(m_threadMutex);
|
||||
ArchThreadImpl *thread = find(GetCurrentThreadId());
|
||||
unlockMutex(m_threadMutex);
|
||||
assert(thread != NULL);
|
||||
assert(thread != nullptr);
|
||||
return thread;
|
||||
}
|
||||
|
||||
void ArchMultithreadWindows::closeThread(ArchThread thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
assert(thread != nullptr);
|
||||
|
||||
// decrement ref count and clean up thread if no more references
|
||||
if (--thread->m_refCount == 0) {
|
||||
// close the handle (main thread has a NULL handle)
|
||||
if (thread->m_thread != NULL) {
|
||||
// close the handle (main thread has a nullptr handle)
|
||||
if (thread->m_thread != nullptr) {
|
||||
CloseHandle(thread->m_thread);
|
||||
}
|
||||
|
||||
@ -333,7 +333,7 @@ ArchThread ArchMultithreadWindows::copyThread(ArchThread thread)
|
||||
|
||||
void ArchMultithreadWindows::cancelThread(ArchThread thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
assert(thread != nullptr);
|
||||
|
||||
// set cancel flag
|
||||
SetEvent(thread->m_cancel);
|
||||
@ -380,7 +380,7 @@ void ArchMultithreadWindows::setPriorityOfThread(ArchThread thread, int n)
|
||||
#endif
|
||||
static const size_t s_pBase = 8; // index of normal priority
|
||||
|
||||
assert(thread != NULL);
|
||||
assert(thread != nullptr);
|
||||
|
||||
size_t index;
|
||||
if (n > 0 && s_pBase < (size_t)n) {
|
||||
@ -410,7 +410,7 @@ void ArchMultithreadWindows::testCancelThread()
|
||||
|
||||
bool ArchMultithreadWindows::wait(ArchThread target, double timeout)
|
||||
{
|
||||
assert(target != NULL);
|
||||
assert(target != nullptr);
|
||||
|
||||
lockMutex(m_threadMutex);
|
||||
|
||||
@ -502,7 +502,7 @@ void ArchMultithreadWindows::setSignalHandler(ESignal signal, SignalFunc func, v
|
||||
void ArchMultithreadWindows::raiseSignal(ESignal signal)
|
||||
{
|
||||
lockMutex(m_threadMutex);
|
||||
if (m_signalFunc[signal] != NULL) {
|
||||
if (m_signalFunc[signal] != nullptr) {
|
||||
m_signalFunc[signal](signal, m_signalUserData[signal]);
|
||||
ARCH->unblockPollSocket(m_mainThread);
|
||||
} else if (signal == kINTERRUPT || signal == kTERMINATE) {
|
||||
@ -514,7 +514,7 @@ void ArchMultithreadWindows::raiseSignal(ESignal signal)
|
||||
ArchThreadImpl *ArchMultithreadWindows::find(DWORD id)
|
||||
{
|
||||
ArchThreadImpl *impl = findNoRef(id);
|
||||
if (impl != NULL) {
|
||||
if (impl != nullptr) {
|
||||
refThread(impl);
|
||||
}
|
||||
return impl;
|
||||
@ -523,13 +523,13 @@ ArchThreadImpl *ArchMultithreadWindows::find(DWORD id)
|
||||
ArchThreadImpl *ArchMultithreadWindows::findNoRef(DWORD id)
|
||||
{
|
||||
ArchThreadImpl *impl = findNoRefOrCreate(id);
|
||||
if (impl == NULL) {
|
||||
if (impl == nullptr) {
|
||||
// create thread for calling thread which isn't in our list and
|
||||
// add it to the list. this won't normally happen but it can if
|
||||
// the system calls us under a new thread, like it does when we
|
||||
// run as a service.
|
||||
impl = new ArchThreadImpl;
|
||||
impl->m_thread = NULL;
|
||||
impl->m_thread = nullptr;
|
||||
impl->m_id = GetCurrentThreadId();
|
||||
insert(impl);
|
||||
}
|
||||
@ -544,15 +544,15 @@ ArchThreadImpl *ArchMultithreadWindows::findNoRefOrCreate(DWORD id)
|
||||
return *index;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ArchMultithreadWindows::insert(ArchThreadImpl *thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
assert(thread != nullptr);
|
||||
|
||||
// thread shouldn't already be on the list
|
||||
assert(findNoRefOrCreate(thread->m_id) == NULL);
|
||||
assert(findNoRefOrCreate(thread->m_id) == nullptr);
|
||||
|
||||
// append to list
|
||||
m_threadList.push_back(thread);
|
||||
@ -570,14 +570,14 @@ void ArchMultithreadWindows::erase(ArchThreadImpl *thread)
|
||||
|
||||
void ArchMultithreadWindows::refThread(ArchThreadImpl *thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
assert(findNoRefOrCreate(thread->m_id) != NULL);
|
||||
assert(thread != nullptr);
|
||||
assert(findNoRefOrCreate(thread->m_id) != nullptr);
|
||||
++thread->m_refCount;
|
||||
}
|
||||
|
||||
void ArchMultithreadWindows::testCancelThreadImpl(ArchThreadImpl *thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
assert(thread != nullptr);
|
||||
|
||||
// poll cancel event. return if not set.
|
||||
const DWORD result = WaitForSingleObject(thread->m_cancel, 0);
|
||||
@ -616,7 +616,7 @@ void ArchMultithreadWindows::doThreadFunc(ArchThread thread)
|
||||
lockMutex(m_threadMutex);
|
||||
unlockMutex(m_threadMutex);
|
||||
|
||||
void *result = NULL;
|
||||
void *result = nullptr;
|
||||
try {
|
||||
// go
|
||||
result = (*thread->m_func)(thread->m_userData);
|
||||
|
||||
@ -58,7 +58,7 @@ static int(PASCAL FAR *WSAEnumNetworkEvents_winsock)(SOCKET, WSAEVENT, LPWSANETW
|
||||
|
||||
#define setfunc(var, name, type) var = (type)netGetProcAddress(module, #name)
|
||||
|
||||
static HMODULE s_networkModule = NULL;
|
||||
static HMODULE s_networkModule = nullptr;
|
||||
|
||||
static FARPROC netGetProcAddress(HMODULE module, LPCSTR name)
|
||||
{
|
||||
@ -81,20 +81,20 @@ ArchNetAddressImpl *ArchNetAddressImpl::alloc(size_t size)
|
||||
// ArchNetworkWinsock
|
||||
//
|
||||
|
||||
ArchNetworkWinsock::ArchNetworkWinsock() : m_mutex(NULL)
|
||||
ArchNetworkWinsock::ArchNetworkWinsock() : m_mutex(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
ArchNetworkWinsock::~ArchNetworkWinsock()
|
||||
{
|
||||
if (s_networkModule != NULL) {
|
||||
if (s_networkModule != nullptr) {
|
||||
WSACleanup_winsock();
|
||||
::FreeLibrary(s_networkModule);
|
||||
|
||||
WSACleanup_winsock = NULL;
|
||||
s_networkModule = NULL;
|
||||
WSACleanup_winsock = nullptr;
|
||||
s_networkModule = nullptr;
|
||||
}
|
||||
if (m_mutex != NULL) {
|
||||
if (m_mutex != nullptr) {
|
||||
ARCH->closeMutex(m_mutex);
|
||||
}
|
||||
|
||||
@ -108,8 +108,8 @@ void ArchNetworkWinsock::init()
|
||||
{
|
||||
static const char *s_library[] = {"ws2_32.dll"};
|
||||
|
||||
assert(WSACleanup_winsock == NULL);
|
||||
assert(s_networkModule == NULL);
|
||||
assert(WSACleanup_winsock == nullptr);
|
||||
assert(s_networkModule == nullptr);
|
||||
|
||||
// try each winsock library
|
||||
for (size_t i = 0; i < sizeof(s_library) / sizeof(s_library[0]); ++i) {
|
||||
@ -128,7 +128,7 @@ void ArchNetworkWinsock::init()
|
||||
|
||||
void ArchNetworkWinsock::initModule(HMODULE module)
|
||||
{
|
||||
if (module == NULL) {
|
||||
if (module == nullptr) {
|
||||
throw XArchNetworkSupport("");
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@ ArchSocket ArchNetworkWinsock::newSocket(EAddressFamily family, ESocketType type
|
||||
|
||||
ArchSocket ArchNetworkWinsock::copySocket(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
// ref the socket and return it
|
||||
ARCH->lockMutex(m_mutex);
|
||||
@ -240,7 +240,7 @@ ArchSocket ArchNetworkWinsock::copySocket(ArchSocket s)
|
||||
|
||||
void ArchNetworkWinsock::closeSocket(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
// unref the socket and note if it should be released
|
||||
ARCH->lockMutex(m_mutex);
|
||||
@ -264,7 +264,7 @@ void ArchNetworkWinsock::closeSocket(ArchSocket s)
|
||||
|
||||
void ArchNetworkWinsock::closeSocketForRead(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
if (shutdown_winsock(s->m_socket, SD_RECEIVE) == SOCKET_ERROR) {
|
||||
if (getsockerror_winsock() != WSAENOTCONN) {
|
||||
@ -275,7 +275,7 @@ void ArchNetworkWinsock::closeSocketForRead(ArchSocket s)
|
||||
|
||||
void ArchNetworkWinsock::closeSocketForWrite(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
if (shutdown_winsock(s->m_socket, SD_SEND) == SOCKET_ERROR) {
|
||||
if (getsockerror_winsock() != WSAENOTCONN) {
|
||||
@ -286,8 +286,8 @@ void ArchNetworkWinsock::closeSocketForWrite(ArchSocket s)
|
||||
|
||||
void ArchNetworkWinsock::bindSocket(ArchSocket s, ArchNetAddress addr)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(addr != NULL);
|
||||
assert(s != nullptr);
|
||||
assert(addr != nullptr);
|
||||
|
||||
if (bind_winsock(s->m_socket, TYPED_ADDR(struct sockaddr, addr), addr->m_len) == SOCKET_ERROR) {
|
||||
throwError(getsockerror_winsock());
|
||||
@ -296,7 +296,7 @@ void ArchNetworkWinsock::bindSocket(ArchSocket s, ArchNetAddress addr)
|
||||
|
||||
void ArchNetworkWinsock::listenOnSocket(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
// hardcoding backlog
|
||||
if (listen_winsock(s->m_socket, 3) == SOCKET_ERROR) {
|
||||
@ -306,7 +306,7 @@ void ArchNetworkWinsock::listenOnSocket(ArchSocket s)
|
||||
|
||||
ArchSocket ArchNetworkWinsock::acceptSocket(ArchSocket s, ArchNetAddress *const addr)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
// create new socket and temporary address
|
||||
ArchSocketImpl *socket = new ArchSocketImpl;
|
||||
@ -319,10 +319,10 @@ ArchSocket ArchNetworkWinsock::acceptSocket(ArchSocket s, ArchNetAddress *const
|
||||
delete socket;
|
||||
free(tmp);
|
||||
if (addr) {
|
||||
*addr = NULL;
|
||||
*addr = nullptr;
|
||||
}
|
||||
if (err == WSAEWOULDBLOCK) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
throwError(err);
|
||||
}
|
||||
@ -334,7 +334,7 @@ ArchSocket ArchNetworkWinsock::acceptSocket(ArchSocket s, ArchNetAddress *const
|
||||
delete socket;
|
||||
free(tmp);
|
||||
if (addr) {
|
||||
*addr = NULL;
|
||||
*addr = nullptr;
|
||||
}
|
||||
throw;
|
||||
}
|
||||
@ -346,7 +346,7 @@ ArchSocket ArchNetworkWinsock::acceptSocket(ArchSocket s, ArchNetAddress *const
|
||||
socket->m_pollWrite = true;
|
||||
|
||||
// copy address if requested
|
||||
if (addr != NULL) {
|
||||
if (addr != nullptr) {
|
||||
*addr = ARCH->copyAddr(tmp);
|
||||
}
|
||||
|
||||
@ -356,8 +356,8 @@ ArchSocket ArchNetworkWinsock::acceptSocket(ArchSocket s, ArchNetAddress *const
|
||||
|
||||
bool ArchNetworkWinsock::connectSocket(ArchSocket s, ArchNetAddress addr)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(addr != NULL);
|
||||
assert(s != nullptr);
|
||||
assert(addr != nullptr);
|
||||
|
||||
if (connect_winsock(s->m_socket, TYPED_ADDR(struct sockaddr, addr), addr->m_len) == SOCKET_ERROR) {
|
||||
if (getsockerror_winsock() == WSAEISCONN) {
|
||||
@ -384,7 +384,7 @@ int ArchNetworkWinsock::pollSocket(PollEntry pe[], int num, double timeout)
|
||||
pe[i].m_revents = 0;
|
||||
|
||||
// set invalid flag if socket is bogus then go to next socket
|
||||
if (pe[i].m_socket == NULL) {
|
||||
if (pe[i].m_socket == nullptr) {
|
||||
pe[i].m_revents |= kPOLLNVAL;
|
||||
continue;
|
||||
}
|
||||
@ -428,7 +428,7 @@ int ArchNetworkWinsock::pollSocket(PollEntry pe[], int num, double timeout)
|
||||
ArchThread thread = mt->newCurrentThread();
|
||||
WSAEVENT *unblockEvent = (WSAEVENT *)mt->getNetworkDataForThread(thread);
|
||||
ARCH->closeThread(thread);
|
||||
if (unblockEvent == NULL) {
|
||||
if (unblockEvent == nullptr) {
|
||||
unblockEvent = new WSAEVENT;
|
||||
m_unblockEvents.push_back(unblockEvent);
|
||||
*unblockEvent = WSACreateEvent_winsock();
|
||||
@ -467,7 +467,7 @@ int ArchNetworkWinsock::pollSocket(PollEntry pe[], int num, double timeout)
|
||||
}
|
||||
for (i = 0, n = 0; i < num; ++i) {
|
||||
// skip events we didn't check
|
||||
if (pe[i].m_socket == NULL || (pe[i].m_events & (kPOLLIN | kPOLLOUT)) == 0) {
|
||||
if (pe[i].m_socket == nullptr || (pe[i].m_events & (kPOLLIN | kPOLLOUT)) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -522,14 +522,14 @@ void ArchNetworkWinsock::unblockPollSocket(ArchThread thread)
|
||||
// set the unblock event
|
||||
ArchMultithreadWindows *mt = ArchMultithreadWindows::getInstance();
|
||||
WSAEVENT *unblockEvent = (WSAEVENT *)mt->getNetworkDataForThread(thread);
|
||||
if (unblockEvent != NULL) {
|
||||
if (unblockEvent != nullptr) {
|
||||
WSASetEvent_winsock(*unblockEvent);
|
||||
}
|
||||
}
|
||||
|
||||
size_t ArchNetworkWinsock::readSocket(ArchSocket s, void *buf, size_t len)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
int n = recv_winsock(s->m_socket, buf, (int)len, 0);
|
||||
if (n == SOCKET_ERROR) {
|
||||
@ -544,7 +544,7 @@ size_t ArchNetworkWinsock::readSocket(ArchSocket s, void *buf, size_t len)
|
||||
|
||||
size_t ArchNetworkWinsock::writeSocket(ArchSocket s, const void *buf, size_t len)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
int n = send_winsock(s->m_socket, buf, (int)len, 0);
|
||||
if (n == SOCKET_ERROR) {
|
||||
@ -563,7 +563,7 @@ size_t ArchNetworkWinsock::writeSocket(ArchSocket s, const void *buf, size_t len
|
||||
|
||||
void ArchNetworkWinsock::throwErrorOnSocket(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
// get the error from the socket layer
|
||||
int err = 0;
|
||||
@ -590,7 +590,7 @@ void ArchNetworkWinsock::setBlockingOnSocket(SOCKET s, bool blocking)
|
||||
|
||||
bool ArchNetworkWinsock::setNoDelayOnSocket(ArchSocket s, bool noDelay)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
// get old state
|
||||
BOOL oflag;
|
||||
@ -611,7 +611,7 @@ bool ArchNetworkWinsock::setNoDelayOnSocket(ArchSocket s, bool noDelay)
|
||||
|
||||
bool ArchNetworkWinsock::setReuseAddrOnSocket(ArchSocket s, bool reuse)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(s != nullptr);
|
||||
|
||||
// get old state
|
||||
BOOL oflag;
|
||||
@ -643,7 +643,7 @@ std::string ArchNetworkWinsock::getHostName()
|
||||
|
||||
ArchNetAddress ArchNetworkWinsock::newAnyAddr(EAddressFamily family)
|
||||
{
|
||||
ArchNetAddressImpl *addr = NULL;
|
||||
ArchNetAddressImpl *addr = nullptr;
|
||||
switch (family) {
|
||||
case kINET: {
|
||||
addr = ArchNetAddressImpl::alloc(sizeof(struct sockaddr_in));
|
||||
@ -671,7 +671,7 @@ ArchNetAddress ArchNetworkWinsock::newAnyAddr(EAddressFamily family)
|
||||
|
||||
ArchNetAddress ArchNetworkWinsock::copyAddr(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
assert(addr != nullptr);
|
||||
|
||||
ArchNetAddressImpl *copy = ArchNetAddressImpl::alloc(addr->m_len);
|
||||
memcpy(TYPED_ADDR(void, copy), TYPED_ADDR(void, addr), addr->m_len);
|
||||
@ -690,7 +690,7 @@ std::vector<ArchNetAddress> ArchNetworkWinsock::nameToAddr(const std::string &na
|
||||
int ret = -1;
|
||||
|
||||
ARCH->lockMutex(m_mutex);
|
||||
if ((ret = getaddrinfo(name.c_str(), NULL, &hints, &pResult)) != 0) {
|
||||
if ((ret = getaddrinfo(name.c_str(), nullptr, &hints, &pResult)) != 0) {
|
||||
ARCH->unlockMutex(m_mutex);
|
||||
throwNameError(ret);
|
||||
}
|
||||
@ -713,21 +713,21 @@ std::vector<ArchNetAddress> ArchNetworkWinsock::nameToAddr(const std::string &na
|
||||
|
||||
void ArchNetworkWinsock::closeAddr(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
assert(addr != nullptr);
|
||||
|
||||
free(addr);
|
||||
}
|
||||
|
||||
std::string ArchNetworkWinsock::addrToName(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
assert(addr != nullptr);
|
||||
|
||||
char host[1024];
|
||||
char service[20];
|
||||
int ret =
|
||||
getnameinfo(TYPED_ADDR(struct sockaddr, addr), addr->m_len, host, sizeof(host), service, sizeof(service), 0);
|
||||
|
||||
if (ret != NULL) {
|
||||
if (ret != 0) {
|
||||
throwNameError(ret);
|
||||
}
|
||||
|
||||
@ -738,7 +738,7 @@ std::string ArchNetworkWinsock::addrToName(ArchNetAddress addr)
|
||||
|
||||
std::string ArchNetworkWinsock::addrToString(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
assert(addr != nullptr);
|
||||
|
||||
switch (getAddrFamily(addr)) {
|
||||
case kINET: {
|
||||
@ -761,7 +761,7 @@ std::string ArchNetworkWinsock::addrToString(ArchNetAddress addr)
|
||||
|
||||
IArchNetwork::EAddressFamily ArchNetworkWinsock::getAddrFamily(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
assert(addr != nullptr);
|
||||
|
||||
switch (addr->m_addr.ss_family) {
|
||||
case AF_INET:
|
||||
@ -777,7 +777,7 @@ IArchNetwork::EAddressFamily ArchNetworkWinsock::getAddrFamily(ArchNetAddress ad
|
||||
|
||||
void ArchNetworkWinsock::setAddrPort(ArchNetAddress addr, int port)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
assert(addr != nullptr);
|
||||
|
||||
switch (getAddrFamily(addr)) {
|
||||
case kINET: {
|
||||
@ -800,7 +800,7 @@ void ArchNetworkWinsock::setAddrPort(ArchNetAddress addr, int port)
|
||||
|
||||
int ArchNetworkWinsock::getAddrPort(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
assert(addr != nullptr);
|
||||
|
||||
switch (getAddrFamily(addr)) {
|
||||
case kINET: {
|
||||
@ -821,7 +821,7 @@ int ArchNetworkWinsock::getAddrPort(ArchNetAddress addr)
|
||||
|
||||
bool ArchNetworkWinsock::isAnyAddr(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
assert(addr != nullptr);
|
||||
|
||||
switch (getAddrFamily(addr)) {
|
||||
case kINET: {
|
||||
|
||||
@ -35,7 +35,7 @@ void ArchSleepWindows::sleep(double timeout)
|
||||
// this is windows so that's pretty certain; we'll get a
|
||||
// link error if we're not, though.
|
||||
ArchMultithreadWindows *mt = ArchMultithreadWindows::getInstance();
|
||||
if (mt != NULL) {
|
||||
if (mt != nullptr) {
|
||||
HANDLE cancelEvent = mt->getCancelEventForCurrentThread();
|
||||
WaitForSingleObject(cancelEvent, (DWORD)(1000.0 * timeout));
|
||||
if (timeout == 0.0) {
|
||||
|
||||
@ -25,8 +25,8 @@
|
||||
typedef WINMMAPI DWORD(WINAPI *PTimeGetTime)(void);
|
||||
|
||||
static double s_freq = 0.0;
|
||||
static HINSTANCE s_mmInstance = NULL;
|
||||
static PTimeGetTime s_tgt = NULL;
|
||||
static HINSTANCE s_mmInstance = nullptr;
|
||||
static PTimeGetTime s_tgt = nullptr;
|
||||
|
||||
//
|
||||
// ArchTimeWindows
|
||||
@ -34,7 +34,7 @@ static PTimeGetTime s_tgt = NULL;
|
||||
|
||||
ArchTimeWindows::ArchTimeWindows()
|
||||
{
|
||||
assert(s_freq == 0.0 || s_mmInstance == NULL);
|
||||
assert(s_freq == 0.0 || s_mmInstance == nullptr);
|
||||
|
||||
LARGE_INTEGER freq;
|
||||
if (QueryPerformanceFrequency(&freq) && freq.QuadPart != 0) {
|
||||
@ -42,7 +42,7 @@ ArchTimeWindows::ArchTimeWindows()
|
||||
} else {
|
||||
// load winmm.dll and get timeGetTime
|
||||
s_mmInstance = LoadLibrary("winmm");
|
||||
if (s_mmInstance != NULL) {
|
||||
if (s_mmInstance != nullptr) {
|
||||
s_tgt = (PTimeGetTime)GetProcAddress(s_mmInstance, "timeGetTime");
|
||||
}
|
||||
}
|
||||
@ -51,10 +51,10 @@ ArchTimeWindows::ArchTimeWindows()
|
||||
ArchTimeWindows::~ArchTimeWindows()
|
||||
{
|
||||
s_freq = 0.0;
|
||||
if (s_mmInstance == NULL) {
|
||||
if (s_mmInstance == nullptr) {
|
||||
FreeLibrary(static_cast<HMODULE>(s_mmInstance));
|
||||
s_tgt = NULL;
|
||||
s_mmInstance = NULL;
|
||||
s_tgt = nullptr;
|
||||
s_mmInstance = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ double ArchTimeWindows::time()
|
||||
LARGE_INTEGER c;
|
||||
QueryPerformanceCounter(&c);
|
||||
return s_freq * static_cast<double>(c.QuadPart);
|
||||
} else if (s_tgt != NULL) {
|
||||
} else if (s_tgt != nullptr) {
|
||||
return 0.001 * static_cast<double>(s_tgt());
|
||||
} else {
|
||||
return 0.001 * static_cast<double>(GetTickCount());
|
||||
|
||||
@ -18,9 +18,9 @@ std::string XArchEvalWindows::eval() const throw()
|
||||
char *cmsg;
|
||||
if (FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, 0, m_error,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&cmsg, 0, NULL
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&cmsg, 0, nullptr
|
||||
) == 0) {
|
||||
cmsg = NULL;
|
||||
cmsg = nullptr;
|
||||
return deskflow::string::sprintf("Unknown error, code %d", m_error);
|
||||
}
|
||||
std::string smsg(cmsg);
|
||||
@ -200,7 +200,7 @@ std::string XArchEvalWinsock::eval() const throw()
|
||||
{WSANO_DATA, "The requested name is valid but does not have an IP address"},
|
||||
|
||||
// end
|
||||
{0, NULL}
|
||||
{0, nullptr}
|
||||
};
|
||||
|
||||
for (unsigned int i = 0; s_netErrorCodes[i].m_code != 0; ++i) {
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
// Event
|
||||
//
|
||||
|
||||
Event::Event() : m_type(kUnknown), m_target(NULL), m_data(NULL), m_flags(0), m_dataObject(nullptr)
|
||||
Event::Event() : m_type(kUnknown), m_target(nullptr), m_data(nullptr), m_flags(0), m_dataObject(nullptr)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ public:
|
||||
\p target is the intended recipient of the event.
|
||||
\p flags is any combination of \c Flags.
|
||||
*/
|
||||
Event(Type type, void *target = NULL, void *data = NULL, Flags flags = kNone);
|
||||
Event(Type type, void *target = nullptr, void *data = nullptr, Flags flags = kNone);
|
||||
|
||||
//! Create \c Event with non-POD data
|
||||
/*!
|
||||
|
||||
@ -48,23 +48,23 @@ static void interrupt(Arch::ESignal, void *data)
|
||||
EventQueue::EventQueue()
|
||||
: m_systemTarget(0),
|
||||
m_nextType(Event::kLast),
|
||||
m_typesForClient(NULL),
|
||||
m_typesForIStream(NULL),
|
||||
m_typesForIDataSocket(NULL),
|
||||
m_typesForIListenSocket(NULL),
|
||||
m_typesForISocket(NULL),
|
||||
m_typesForOSXScreen(NULL),
|
||||
m_typesForClientListener(NULL),
|
||||
m_typesForClientProxy(NULL),
|
||||
m_typesForClientProxyUnknown(NULL),
|
||||
m_typesForServer(NULL),
|
||||
m_typesForServerApp(NULL),
|
||||
m_typesForIKeyState(NULL),
|
||||
m_typesForIPrimaryScreen(NULL),
|
||||
m_typesForIScreen(NULL),
|
||||
m_typesForClipboard(NULL),
|
||||
m_typesForFile(NULL),
|
||||
m_typesForEi(NULL),
|
||||
m_typesForClient(nullptr),
|
||||
m_typesForIStream(nullptr),
|
||||
m_typesForIDataSocket(nullptr),
|
||||
m_typesForIListenSocket(nullptr),
|
||||
m_typesForISocket(nullptr),
|
||||
m_typesForOSXScreen(nullptr),
|
||||
m_typesForClientListener(nullptr),
|
||||
m_typesForClientProxy(nullptr),
|
||||
m_typesForClientProxyUnknown(nullptr),
|
||||
m_typesForServer(nullptr),
|
||||
m_typesForServerApp(nullptr),
|
||||
m_typesForIKeyState(nullptr),
|
||||
m_typesForIPrimaryScreen(nullptr),
|
||||
m_typesForIScreen(nullptr),
|
||||
m_typesForClipboard(nullptr),
|
||||
m_typesForFile(nullptr),
|
||||
m_typesForEi(nullptr),
|
||||
m_readyMutex(new Mutex),
|
||||
m_readyCondVar(new CondVar<bool>(m_readyMutex, false))
|
||||
{
|
||||
@ -80,8 +80,8 @@ EventQueue::~EventQueue()
|
||||
delete m_readyCondVar;
|
||||
delete m_readyMutex;
|
||||
|
||||
ARCH->setSignalHandler(Arch::kINTERRUPT, NULL, NULL);
|
||||
ARCH->setSignalHandler(Arch::kTERMINATE, NULL, NULL);
|
||||
ARCH->setSignalHandler(Arch::kINTERRUPT, nullptr, nullptr);
|
||||
ARCH->setSignalHandler(Arch::kTERMINATE, nullptr, nullptr);
|
||||
ARCH->closeMutex(m_mutex);
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ void EventQueue::adoptBuffer(IEventQueueBuffer *buffer)
|
||||
|
||||
// use new buffer
|
||||
m_buffer = buffer;
|
||||
if (m_buffer == NULL) {
|
||||
if (m_buffer == nullptr) {
|
||||
m_buffer = new SimpleEventQueueBuffer;
|
||||
}
|
||||
}
|
||||
@ -235,10 +235,10 @@ bool EventQueue::dispatchEvent(const Event &event)
|
||||
{
|
||||
void *target = event.getTarget();
|
||||
IEventJob *job = getHandler(event.getType(), target);
|
||||
if (job == NULL) {
|
||||
if (job == nullptr) {
|
||||
job = getHandler(Event::kUnknown, target);
|
||||
}
|
||||
if (job != NULL) {
|
||||
if (job != nullptr) {
|
||||
job->run(event);
|
||||
return true;
|
||||
}
|
||||
@ -288,7 +288,7 @@ EventQueueTimer *EventQueue::newTimer(double duration, void *target)
|
||||
assert(duration > 0.0);
|
||||
|
||||
EventQueueTimer *timer = m_buffer->newTimer(duration, false);
|
||||
if (target == NULL) {
|
||||
if (target == nullptr) {
|
||||
target = timer;
|
||||
}
|
||||
ArchMutexLock lock(m_mutex);
|
||||
@ -305,7 +305,7 @@ EventQueueTimer *EventQueue::newOneShotTimer(double duration, void *target)
|
||||
assert(duration > 0.0);
|
||||
|
||||
EventQueueTimer *timer = m_buffer->newTimer(duration, true);
|
||||
if (target == NULL) {
|
||||
if (target == nullptr) {
|
||||
target = timer;
|
||||
}
|
||||
ArchMutexLock lock(m_mutex);
|
||||
@ -343,7 +343,7 @@ void EventQueue::adoptHandler(Event::Type type, void *target, IEventJob *handler
|
||||
|
||||
void EventQueue::removeHandler(Event::Type type, void *target)
|
||||
{
|
||||
IEventJob *handler = NULL;
|
||||
IEventJob *handler = nullptr;
|
||||
{
|
||||
ArchMutexLock lock(m_mutex);
|
||||
HandlerTable::iterator index = m_handlers.find(target);
|
||||
@ -397,7 +397,7 @@ IEventJob *EventQueue::getHandler(Event::Type type, void *target) const
|
||||
return index2->second;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t EventQueue::saveEvent(const Event &event)
|
||||
|
||||
@ -171,7 +171,7 @@ private:
|
||||
type_##Events& \
|
||||
EventQueue::for##type_() \
|
||||
{ \
|
||||
if (m_typesFor##type_ == NULL) { \
|
||||
if (m_typesFor##type_ == nullptr) { \
|
||||
m_typesFor##type_ = new type_##Events(); \
|
||||
m_typesFor##type_->setEvents(dynamic_cast<IEventQueue *>(this)); \
|
||||
} \
|
||||
|
||||
@ -9,13 +9,13 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
EventTypes::EventTypes() : m_events(NULL)
|
||||
EventTypes::EventTypes() : m_events(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
IEventQueue *EventTypes::getEvents() const
|
||||
{
|
||||
assert(m_events != NULL);
|
||||
assert(m_events != nullptr);
|
||||
return m_events;
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ FunctionEventJob::~FunctionEventJob()
|
||||
|
||||
void FunctionEventJob::run(const Event &event)
|
||||
{
|
||||
if (m_func != NULL) {
|
||||
if (m_func != nullptr) {
|
||||
m_func(event, m_arg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ class FunctionEventJob : public IEventJob
|
||||
{
|
||||
public:
|
||||
//! run() invokes \c func(arg)
|
||||
FunctionEventJob(void (*func)(const Event &, void *), void *arg = NULL);
|
||||
FunctionEventJob(void (*func)(const Event &, void *), void *arg = nullptr);
|
||||
~FunctionEventJob() override;
|
||||
|
||||
// IEventJob overrides
|
||||
|
||||
@ -23,7 +23,7 @@ FunctionJob::~FunctionJob()
|
||||
|
||||
void FunctionJob::run()
|
||||
{
|
||||
if (m_func != NULL) {
|
||||
if (m_func != nullptr) {
|
||||
m_func(m_arg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ class FunctionJob : public IJob
|
||||
{
|
||||
public:
|
||||
//! run() invokes \c func(arg)
|
||||
FunctionJob(void (*func)(void *), void *arg = NULL);
|
||||
FunctionJob(void (*func)(void *), void *arg = nullptr);
|
||||
~FunctionJob() override;
|
||||
|
||||
// IJob overrides
|
||||
|
||||
@ -98,7 +98,7 @@ public:
|
||||
is returned the data points to a \c TimerEvent. The client must pass
|
||||
the returned timer to \c deleteTimer() (whether or not the timer has
|
||||
expired) to release the timer. The returned timer event uses the
|
||||
given \p target. If \p target is NULL it uses the returned timer as
|
||||
given \p target. If \p target is nullptr it uses the returned timer as
|
||||
the target.
|
||||
|
||||
Events for a single timer don't accumulate in the queue, even if the
|
||||
@ -117,7 +117,7 @@ public:
|
||||
The c_count member of the \c TimerEvent is always 1. The client
|
||||
must pass the returned timer to \c deleteTimer() (whether or not the
|
||||
timer has expired) to release the timer. The returned timer event
|
||||
uses the given \p target. If \p target is NULL it uses the returned
|
||||
uses the given \p target. If \p target is nullptr it uses the returned
|
||||
timer as the target.
|
||||
*/
|
||||
virtual EventQueueTimer *newOneShotTimer(double duration, void *target) = 0;
|
||||
@ -181,7 +181,7 @@ public:
|
||||
//! Get an event handler
|
||||
/*!
|
||||
Finds and returns the event handler for the \p type, \p target pair
|
||||
if it exists, otherwise it returns NULL.
|
||||
if it exists, otherwise it returns nullptr.
|
||||
*/
|
||||
virtual IEventJob *getHandler(Event::Type type, void *target) const = 0;
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ public:
|
||||
/*!
|
||||
Create and return a timer object. The object is opaque and is
|
||||
used only by the buffer but it must be a valid object (i.e.
|
||||
not NULL).
|
||||
not nullptr).
|
||||
*/
|
||||
virtual EventQueueTimer *newTimer(double duration, bool oneShot) const = 0;
|
||||
|
||||
|
||||
@ -115,12 +115,12 @@ std::vector<char> makeMessage(const char *filename, int lineNumber, const char *
|
||||
// Log
|
||||
//
|
||||
|
||||
Log *Log::s_log = NULL;
|
||||
Log *Log::s_log = nullptr;
|
||||
|
||||
Log::Log(bool singleton)
|
||||
{
|
||||
if (singleton) {
|
||||
assert(s_log == NULL);
|
||||
assert(s_log == nullptr);
|
||||
}
|
||||
|
||||
// create mutex for multithread safe operation
|
||||
@ -154,7 +154,7 @@ Log::~Log()
|
||||
|
||||
Log *Log::getInstance()
|
||||
{
|
||||
assert(s_log != NULL);
|
||||
assert(s_log != nullptr);
|
||||
return s_log;
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ void Log::print(const char *file, int line, const char *fmt, ...)
|
||||
|
||||
void Log::insert(ILogOutputter *adoptedOutputter, bool alwaysAtHead)
|
||||
{
|
||||
assert(adoptedOutputter != NULL);
|
||||
assert(adoptedOutputter != nullptr);
|
||||
|
||||
ArchMutexLock lock(m_mutex);
|
||||
if (alwaysAtHead) {
|
||||
@ -241,7 +241,7 @@ void Log::pop_front(bool alwaysAtHead)
|
||||
|
||||
bool Log::setFilter(const char *maxPriority)
|
||||
{
|
||||
if (maxPriority != NULL) {
|
||||
if (maxPriority != nullptr) {
|
||||
for (int i = 0; i < g_numPriority; ++i) {
|
||||
if (strcmp(maxPriority, g_priority[i]) == 0) {
|
||||
setFilter(i);
|
||||
@ -268,7 +268,7 @@ int Log::getFilter() const
|
||||
void Log::output(ELevel priority, char *msg)
|
||||
{
|
||||
assert(priority >= -1 && priority < g_numPriority);
|
||||
assert(msg != NULL);
|
||||
assert(msg != nullptr);
|
||||
if (!msg)
|
||||
return;
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ public:
|
||||
Set the filter. Messages below this priority are discarded.
|
||||
The default priority is 4 (INFO) (unless built without NDEBUG
|
||||
in which case it's 5 (DEBUG)). setFilter(const char*) returns
|
||||
true if the priority \c name was recognized; if \c name is NULL
|
||||
true if the priority \c name was recognized; if \c name is nullptr
|
||||
then it simply returns true.
|
||||
*/
|
||||
bool setFilter(const char *name);
|
||||
@ -94,7 +94,7 @@ public:
|
||||
//! Print a log message
|
||||
/*!
|
||||
Print a log message using the printf-like \c format and arguments
|
||||
preceded by the filename and line number. If \c file is NULL then
|
||||
preceded by the filename and line number. If \c file is nullptr then
|
||||
neither the file nor the line are printed.
|
||||
*/
|
||||
void print(const char *file, int line, const char *format, ...);
|
||||
@ -182,7 +182,7 @@ otherwise it expands to a call that doesn't.
|
||||
#define LOGC(_a1, _a2) \
|
||||
if (_a1) \
|
||||
CLOG->print _a2
|
||||
#define CLOG_TRACE NULL, 0,
|
||||
#define CLOG_TRACE nullptr, 0,
|
||||
#else
|
||||
#define LOG(_a1) CLOG->print _a1
|
||||
#define LOGC(_a1, _a2) \
|
||||
|
||||
@ -128,7 +128,7 @@ bool SystemLogOutputter::write(ELevel level, const char *msg)
|
||||
// SystemLogger
|
||||
//
|
||||
|
||||
SystemLogger::SystemLogger(const char *title, bool blockConsole) : m_stop(NULL)
|
||||
SystemLogger::SystemLogger(const char *title, bool blockConsole) : m_stop(nullptr)
|
||||
{
|
||||
// redirect log messages
|
||||
if (blockConsole) {
|
||||
@ -144,7 +144,7 @@ SystemLogger::~SystemLogger()
|
||||
{
|
||||
CLOG->remove(m_syslog);
|
||||
delete m_syslog;
|
||||
if (m_stop != NULL) {
|
||||
if (m_stop != nullptr) {
|
||||
CLOG->remove(m_stop);
|
||||
delete m_stop;
|
||||
}
|
||||
@ -165,7 +165,7 @@ FileLogOutputter::~FileLogOutputter()
|
||||
|
||||
void FileLogOutputter::setLogFilename(const char *logFile)
|
||||
{
|
||||
assert(logFile != NULL);
|
||||
assert(logFile != nullptr);
|
||||
m_fileName = logFile;
|
||||
}
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ std::wstring path(const std::string &filePath)
|
||||
{
|
||||
std::wstring result;
|
||||
|
||||
auto length = MultiByteToWideChar(CP_UTF8, 0, filePath.c_str(), static_cast<int>(filePath.length()), NULL, 0);
|
||||
auto length = MultiByteToWideChar(CP_UTF8, 0, filePath.c_str(), static_cast<int>(filePath.length()), nullptr, 0);
|
||||
if (length > 0) {
|
||||
result.resize(length);
|
||||
MultiByteToWideChar(CP_UTF8, 0, filePath.c_str(), static_cast<int>(filePath.length()), &result[0], length);
|
||||
|
||||
@ -109,7 +109,7 @@ std::string sprintf(const char *fmt, ...)
|
||||
char *buffer = tmp;
|
||||
int len = (int)(sizeof(tmp) / sizeof(tmp[0]));
|
||||
std::string result;
|
||||
while (buffer != NULL) {
|
||||
while (buffer != nullptr) {
|
||||
// try printing into the buffer
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
@ -131,7 +131,7 @@ std::string sprintf(const char *fmt, ...)
|
||||
if (buffer != tmp) {
|
||||
delete[] buffer;
|
||||
}
|
||||
buffer = NULL;
|
||||
buffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ template <class T> class TMethodEventJob : public IEventJob
|
||||
{
|
||||
public:
|
||||
//! run(event) invokes \c object->method(event, arg)
|
||||
TMethodEventJob(T *object, void (T::*method)(const Event &, void *), void *arg = NULL);
|
||||
TMethodEventJob(T *object, void (T::*method)(const Event &, void *), void *arg = nullptr);
|
||||
~TMethodEventJob() override;
|
||||
|
||||
// IJob overrides
|
||||
@ -45,7 +45,7 @@ template <class T> inline TMethodEventJob<T>::~TMethodEventJob()
|
||||
|
||||
template <class T> inline void TMethodEventJob<T>::run(const Event &event)
|
||||
{
|
||||
if (m_object != NULL) {
|
||||
if (m_object != nullptr) {
|
||||
(m_object->*m_method)(event, m_arg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ template <class T> class TMethodJob : public IJob
|
||||
{
|
||||
public:
|
||||
//! run() invokes \c object->method(arg)
|
||||
TMethodJob(T *object, void (T::*method)(void *), void *arg = NULL);
|
||||
TMethodJob(T *object, void (T::*method)(void *), void *arg = nullptr);
|
||||
~TMethodJob() override;
|
||||
|
||||
// IJob overrides
|
||||
@ -45,7 +45,7 @@ template <class T> inline TMethodJob<T>::~TMethodJob()
|
||||
|
||||
template <class T> inline void TMethodJob<T>::run()
|
||||
{
|
||||
if (m_object != NULL) {
|
||||
if (m_object != nullptr) {
|
||||
(m_object->*m_method)(m_arg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,14 +52,14 @@ inline static uint32_t decode32(const uint8_t *n, bool byteSwapped)
|
||||
|
||||
inline static void resetError(bool *errors)
|
||||
{
|
||||
if (errors != NULL) {
|
||||
if (errors != nullptr) {
|
||||
*errors = false;
|
||||
}
|
||||
}
|
||||
|
||||
inline static void setError(bool *errors)
|
||||
{
|
||||
if (errors != NULL) {
|
||||
if (errors != nullptr) {
|
||||
*errors = true;
|
||||
}
|
||||
}
|
||||
@ -204,7 +204,7 @@ std::string Unicode::UTF8ToText(const std::string &src, bool *errors)
|
||||
wchar_t *tmp = UTF8ToWideChar(src, size, errors);
|
||||
|
||||
// convert string to multibyte
|
||||
int len = ARCH->convStringWCToMB(NULL, tmp, size, errors);
|
||||
int len = ARCH->convStringWCToMB(nullptr, tmp, size, errors);
|
||||
char *mbs = new char[len + 1];
|
||||
ARCH->convStringWCToMB(mbs, tmp, size, errors);
|
||||
std::string text(mbs, len);
|
||||
@ -263,7 +263,7 @@ std::string Unicode::textToUTF8(const std::string &src, bool *errors, IArchStrin
|
||||
|
||||
// convert string to wide characters
|
||||
uint32_t n = (uint32_t)src.size();
|
||||
int len = ARCH->convStringMBToWC(NULL, src.c_str(), n, errors);
|
||||
int len = ARCH->convStringMBToWC(nullptr, src.c_str(), n, errors);
|
||||
wchar_t *wcs = new wchar_t[len + 1];
|
||||
ARCH->convStringMBToWC(wcs, src.c_str(), n, errors);
|
||||
|
||||
@ -445,7 +445,7 @@ std::string Unicode::doUTF16ToUTF8(const uint8_t *data, uint32_t n, bool *errors
|
||||
} else if (n == 1) {
|
||||
// error -- missing second word
|
||||
setError(errors);
|
||||
toUTF8(dst, s_replacement, NULL);
|
||||
toUTF8(dst, s_replacement, nullptr);
|
||||
} else if (c >= 0x0000d800 && c <= 0x0000dbff) {
|
||||
data += 2;
|
||||
--n;
|
||||
@ -453,7 +453,7 @@ std::string Unicode::doUTF16ToUTF8(const uint8_t *data, uint32_t n, bool *errors
|
||||
if (c2 < 0x0000dc00 || c2 > 0x0000dfff) {
|
||||
// error -- [d800,dbff] not followed by [dc00,dfff]
|
||||
setError(errors);
|
||||
toUTF8(dst, s_replacement, NULL);
|
||||
toUTF8(dst, s_replacement, nullptr);
|
||||
} else {
|
||||
c = (((c - 0x0000d800) << 10) | (c2 - 0x0000dc00)) + 0x00010000;
|
||||
toUTF8(dst, c, errors);
|
||||
@ -461,7 +461,7 @@ std::string Unicode::doUTF16ToUTF8(const uint8_t *data, uint32_t n, bool *errors
|
||||
} else {
|
||||
// error -- [dc00,dfff] without leading [d800,dbff]
|
||||
setError(errors);
|
||||
toUTF8(dst, s_replacement, NULL);
|
||||
toUTF8(dst, s_replacement, nullptr);
|
||||
}
|
||||
data += 2;
|
||||
--n;
|
||||
@ -512,7 +512,7 @@ std::string Unicode::doUTF32ToUTF8(const uint8_t *data, uint32_t n, bool *errors
|
||||
|
||||
uint32_t Unicode::fromUTF8(const uint8_t *&data, uint32_t &n)
|
||||
{
|
||||
assert(data != NULL);
|
||||
assert(data != nullptr);
|
||||
assert(n != 0);
|
||||
|
||||
// compute character encoding length, checking for overlong
|
||||
|
||||
@ -31,76 +31,76 @@ public:
|
||||
|
||||
//! Convert from UTF-8 to UCS-2 encoding
|
||||
/*!
|
||||
Convert from UTF-8 to UCS-2. If errors is not NULL then *errors
|
||||
Convert from UTF-8 to UCS-2. If errors is not nullptr then *errors
|
||||
is set to true iff any character could not be encoded in UCS-2.
|
||||
Decoding errors do not set *errors.
|
||||
*/
|
||||
static std::string UTF8ToUCS2(const std::string &, bool *errors = NULL);
|
||||
static std::string UTF8ToUCS2(const std::string &, bool *errors = nullptr);
|
||||
|
||||
//! Convert from UTF-8 to UCS-4 encoding
|
||||
/*!
|
||||
Convert from UTF-8 to UCS-4. If errors is not NULL then *errors
|
||||
Convert from UTF-8 to UCS-4. If errors is not nullptr then *errors
|
||||
is set to true iff any character could not be encoded in UCS-4.
|
||||
Decoding errors do not set *errors.
|
||||
*/
|
||||
static std::string UTF8ToUCS4(const std::string &, bool *errors = NULL);
|
||||
static std::string UTF8ToUCS4(const std::string &, bool *errors = nullptr);
|
||||
|
||||
//! Convert from UTF-8 to UTF-16 encoding
|
||||
/*!
|
||||
Convert from UTF-8 to UTF-16. If errors is not NULL then *errors
|
||||
Convert from UTF-8 to UTF-16. If errors is not nullptr then *errors
|
||||
is set to true iff any character could not be encoded in UTF-16.
|
||||
Decoding errors do not set *errors.
|
||||
*/
|
||||
static std::string UTF8ToUTF16(const std::string &, bool *errors = NULL);
|
||||
static std::string UTF8ToUTF16(const std::string &, bool *errors = nullptr);
|
||||
|
||||
//! Convert from UTF-8 to UTF-32 encoding
|
||||
/*!
|
||||
Convert from UTF-8 to UTF-32. If errors is not NULL then *errors
|
||||
Convert from UTF-8 to UTF-32. If errors is not nullptr then *errors
|
||||
is set to true iff any character could not be encoded in UTF-32.
|
||||
Decoding errors do not set *errors.
|
||||
*/
|
||||
static std::string UTF8ToUTF32(const std::string &, bool *errors = NULL);
|
||||
static std::string UTF8ToUTF32(const std::string &, bool *errors = nullptr);
|
||||
|
||||
//! Convert from UTF-8 to the current locale encoding
|
||||
/*!
|
||||
Convert from UTF-8 to the current locale encoding. If errors is not
|
||||
NULL then *errors is set to true iff any character could not be encoded.
|
||||
nullptr then *errors is set to true iff any character could not be encoded.
|
||||
Decoding errors do not set *errors.
|
||||
*/
|
||||
static std::string UTF8ToText(const std::string &, bool *errors = NULL);
|
||||
static std::string UTF8ToText(const std::string &, bool *errors = nullptr);
|
||||
|
||||
//! Convert from UCS-2 to UTF-8
|
||||
/*!
|
||||
Convert from UCS-2 to UTF-8. If errors is not NULL then *errors is
|
||||
Convert from UCS-2 to UTF-8. If errors is not nullptr then *errors is
|
||||
set to true iff any character could not be decoded.
|
||||
*/
|
||||
static std::string UCS2ToUTF8(const std::string &, bool *errors = NULL);
|
||||
static std::string UCS2ToUTF8(const std::string &, bool *errors = nullptr);
|
||||
|
||||
//! Convert from UCS-4 to UTF-8
|
||||
/*!
|
||||
Convert from UCS-4 to UTF-8. If errors is not NULL then *errors is
|
||||
Convert from UCS-4 to UTF-8. If errors is not nullptr then *errors is
|
||||
set to true iff any character could not be decoded.
|
||||
*/
|
||||
static std::string UCS4ToUTF8(const std::string &, bool *errors = NULL);
|
||||
static std::string UCS4ToUTF8(const std::string &, bool *errors = nullptr);
|
||||
|
||||
//! Convert from UTF-16 to UTF-8
|
||||
/*!
|
||||
Convert from UTF-16 to UTF-8. If errors is not NULL then *errors is
|
||||
Convert from UTF-16 to UTF-8. If errors is not nullptr then *errors is
|
||||
set to true iff any character could not be decoded.
|
||||
*/
|
||||
static std::string UTF16ToUTF8(const std::string &, bool *errors = NULL);
|
||||
static std::string UTF16ToUTF8(const std::string &, bool *errors = nullptr);
|
||||
|
||||
//! Convert from UTF-32 to UTF-8
|
||||
/*!
|
||||
Convert from UTF-32 to UTF-8. If errors is not NULL then *errors is
|
||||
Convert from UTF-32 to UTF-8. If errors is not nullptr then *errors is
|
||||
set to true iff any character could not be decoded.
|
||||
*/
|
||||
static std::string UTF32ToUTF8(const std::string &, bool *errors = NULL);
|
||||
static std::string UTF32ToUTF8(const std::string &, bool *errors = nullptr);
|
||||
|
||||
//! Convert from the current locale encoding to UTF-8
|
||||
/*!
|
||||
Convert from the current locale encoding to UTF-8. If errors is not
|
||||
NULL then *errors is set to true iff any character could not be decoded.
|
||||
nullptr then *errors is set to true iff any character could not be decoded.
|
||||
*/
|
||||
static std::string textToUTF8(
|
||||
const std::string &, bool *errors = nullptr,
|
||||
|
||||
@ -55,9 +55,9 @@ Client::Client(
|
||||
m_serverAddress(address),
|
||||
m_socketFactory(socketFactory),
|
||||
m_screen(screen),
|
||||
m_stream(NULL),
|
||||
m_timer(NULL),
|
||||
m_server(NULL),
|
||||
m_stream(nullptr),
|
||||
m_timer(nullptr),
|
||||
m_server(nullptr),
|
||||
m_ready(false),
|
||||
m_active(false),
|
||||
m_suspended(false),
|
||||
@ -70,8 +70,8 @@ Client::Client(
|
||||
m_enableClipboard(true),
|
||||
m_maximumClipboardSize(INT_MAX)
|
||||
{
|
||||
assert(m_socketFactory != NULL);
|
||||
assert(m_screen != NULL);
|
||||
assert(m_socketFactory != nullptr);
|
||||
assert(m_screen != nullptr);
|
||||
|
||||
// register suspend/resume event handlers
|
||||
m_events->adoptHandler(
|
||||
@ -123,7 +123,7 @@ Client::~Client()
|
||||
|
||||
void Client::connect(size_t addressIndex)
|
||||
{
|
||||
if (m_stream != NULL) {
|
||||
if (m_stream != nullptr) {
|
||||
return;
|
||||
}
|
||||
if (m_suspended) {
|
||||
@ -179,7 +179,7 @@ void Client::disconnect(const char *msg)
|
||||
if (msg) {
|
||||
sendConnectionFailedEvent(msg);
|
||||
} else {
|
||||
sendEvent(m_events->forClient().disconnected(), NULL);
|
||||
sendEvent(m_events->forClient().disconnected(), nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,17 +199,17 @@ void Client::handshakeComplete()
|
||||
{
|
||||
m_ready = true;
|
||||
m_screen->enable();
|
||||
sendEvent(m_events->forClient().connected(), NULL);
|
||||
sendEvent(m_events->forClient().connected(), nullptr);
|
||||
}
|
||||
|
||||
bool Client::isConnected() const
|
||||
{
|
||||
return (m_server != NULL);
|
||||
return (m_server != nullptr);
|
||||
}
|
||||
|
||||
bool Client::isConnecting() const
|
||||
{
|
||||
return (m_timer != NULL);
|
||||
return (m_timer != nullptr);
|
||||
}
|
||||
|
||||
NetworkAddress Client::getServerAddress() const
|
||||
@ -373,8 +373,8 @@ std::string Client::getName() const
|
||||
void Client::sendClipboard(ClipboardID id)
|
||||
{
|
||||
// note -- m_mutex must be locked on entry
|
||||
assert(m_screen != NULL);
|
||||
assert(m_server != NULL);
|
||||
assert(m_screen != nullptr);
|
||||
assert(m_server != nullptr);
|
||||
|
||||
// get clipboard data. set the clipboard time to the last
|
||||
// clipboard time before getting the data from the screen
|
||||
@ -427,7 +427,7 @@ void Client::sendFileChunk(const void *data)
|
||||
{
|
||||
FileChunk *chunk = static_cast<FileChunk *>(const_cast<void *>(data));
|
||||
LOG((CLOG_DEBUG1 "send file chunk"));
|
||||
assert(m_server != NULL);
|
||||
assert(m_server != nullptr);
|
||||
|
||||
// relay
|
||||
m_server->fileChunkSending(chunk->m_chunk[0], &chunk->m_chunk[1], chunk->m_dataSize);
|
||||
@ -435,7 +435,7 @@ void Client::sendFileChunk(const void *data)
|
||||
|
||||
void Client::setupConnecting()
|
||||
{
|
||||
assert(m_stream != NULL);
|
||||
assert(m_stream != nullptr);
|
||||
|
||||
if (m_args.m_enableCrypto) {
|
||||
m_events->adoptHandler(
|
||||
@ -457,7 +457,7 @@ void Client::setupConnecting()
|
||||
|
||||
void Client::setupConnection()
|
||||
{
|
||||
assert(m_stream != NULL);
|
||||
assert(m_stream != nullptr);
|
||||
|
||||
m_events->adoptHandler(
|
||||
m_events->forISocket().disconnected(), m_stream->getEventTarget(),
|
||||
@ -488,7 +488,7 @@ void Client::setupConnection()
|
||||
|
||||
void Client::setupScreen()
|
||||
{
|
||||
assert(m_server == NULL);
|
||||
assert(m_server == nullptr);
|
||||
|
||||
m_ready = false;
|
||||
m_server = new ServerProxy(this, m_stream, m_events);
|
||||
@ -504,8 +504,8 @@ void Client::setupScreen()
|
||||
|
||||
void Client::setupTimer()
|
||||
{
|
||||
assert(m_timer == NULL);
|
||||
m_timer = m_events->newOneShotTimer(2.0, NULL);
|
||||
assert(m_timer == nullptr);
|
||||
m_timer = m_events->newOneShotTimer(2.0, nullptr);
|
||||
m_events->adoptHandler(Event::kTimer, m_timer, new TMethodEventJob<Client>(this, &Client::handleConnectTimeout));
|
||||
}
|
||||
|
||||
@ -520,7 +520,7 @@ void Client::cleanup()
|
||||
|
||||
void Client::cleanupConnecting()
|
||||
{
|
||||
if (m_stream != NULL) {
|
||||
if (m_stream != nullptr) {
|
||||
m_events->removeHandler(m_events->forIDataSocket().connected(), m_stream->getEventTarget());
|
||||
m_events->removeHandler(m_events->forIDataSocket().connectionFailed(), m_stream->getEventTarget());
|
||||
}
|
||||
@ -528,7 +528,7 @@ void Client::cleanupConnecting()
|
||||
|
||||
void Client::cleanupConnection()
|
||||
{
|
||||
if (m_stream != NULL) {
|
||||
if (m_stream != nullptr) {
|
||||
m_events->removeHandler(m_events->forIStream().inputReady(), m_stream->getEventTarget());
|
||||
m_events->removeHandler(m_events->forIStream().outputError(), m_stream->getEventTarget());
|
||||
m_events->removeHandler(m_events->forIStream().inputShutdown(), m_stream->getEventTarget());
|
||||
@ -541,7 +541,7 @@ void Client::cleanupConnection()
|
||||
|
||||
void Client::cleanupScreen()
|
||||
{
|
||||
if (m_server != NULL) {
|
||||
if (m_server != nullptr) {
|
||||
if (m_ready) {
|
||||
m_screen->disable();
|
||||
m_ready = false;
|
||||
@ -549,23 +549,23 @@ void Client::cleanupScreen()
|
||||
m_events->removeHandler(m_events->forIScreen().shapeChanged(), getEventTarget());
|
||||
m_events->removeHandler(m_events->forClipboard().clipboardGrabbed(), getEventTarget());
|
||||
delete m_server;
|
||||
m_server = NULL;
|
||||
m_server = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Client::cleanupTimer()
|
||||
{
|
||||
if (m_timer != NULL) {
|
||||
if (m_timer != nullptr) {
|
||||
m_events->removeHandler(Event::kTimer, m_timer);
|
||||
m_events->deleteTimer(m_timer);
|
||||
m_timer = NULL;
|
||||
m_timer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Client::cleanupStream()
|
||||
{
|
||||
delete m_stream;
|
||||
m_stream = NULL;
|
||||
m_stream = nullptr;
|
||||
}
|
||||
|
||||
void Client::handleConnected(const Event &, void *)
|
||||
@ -610,7 +610,7 @@ void Client::handleOutputError(const Event &, void *)
|
||||
cleanupScreen();
|
||||
cleanupConnection();
|
||||
LOG((CLOG_WARN "error sending to server"));
|
||||
sendEvent(m_events->forClient().disconnected(), NULL);
|
||||
sendEvent(m_events->forClient().disconnected(), nullptr);
|
||||
}
|
||||
|
||||
void Client::handleDisconnected(const Event &, void *)
|
||||
@ -619,7 +619,7 @@ void Client::handleDisconnected(const Event &, void *)
|
||||
cleanupScreen();
|
||||
cleanupConnection();
|
||||
LOG((CLOG_DEBUG1 "disconnected"));
|
||||
sendEvent(m_events->forClient().disconnected(), NULL);
|
||||
sendEvent(m_events->forClient().disconnected(), nullptr);
|
||||
}
|
||||
|
||||
void Client::handleShapeChanged(const Event &, void *)
|
||||
@ -673,7 +673,7 @@ void Client::handleSuspend(const Event &, void *)
|
||||
LOG((CLOG_INFO "suspend"));
|
||||
m_suspended = true;
|
||||
bool wasConnected = isConnected();
|
||||
disconnect(NULL);
|
||||
disconnect(nullptr);
|
||||
m_connectOnResume = wasConnected;
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,12 +43,12 @@ ServerProxy::ServerProxy(Client *client, deskflow::IStream *stream, IEventQueue
|
||||
m_dyMouse(0),
|
||||
m_ignoreMouse(false),
|
||||
m_keepAliveAlarm(0.0),
|
||||
m_keepAliveAlarmTimer(NULL),
|
||||
m_keepAliveAlarmTimer(nullptr),
|
||||
m_parser(&ServerProxy::parseHandshakeMessage),
|
||||
m_events(events)
|
||||
{
|
||||
assert(m_client != NULL);
|
||||
assert(m_stream != NULL);
|
||||
assert(m_client != nullptr);
|
||||
assert(m_stream != nullptr);
|
||||
|
||||
// initialize modifier translation table
|
||||
for (KeyModifierID id = 0; id < kKeyModifierIDLast; ++id)
|
||||
@ -77,13 +77,13 @@ ServerProxy::~ServerProxy()
|
||||
|
||||
void ServerProxy::resetKeepAliveAlarm()
|
||||
{
|
||||
if (m_keepAliveAlarmTimer != NULL) {
|
||||
if (m_keepAliveAlarmTimer != nullptr) {
|
||||
m_events->removeHandler(Event::kTimer, m_keepAliveAlarmTimer);
|
||||
m_events->deleteTimer(m_keepAliveAlarmTimer);
|
||||
m_keepAliveAlarmTimer = NULL;
|
||||
m_keepAliveAlarmTimer = nullptr;
|
||||
}
|
||||
if (m_keepAliveAlarm > 0.0) {
|
||||
m_keepAliveAlarmTimer = m_events->newOneShotTimer(m_keepAliveAlarm, NULL);
|
||||
m_keepAliveAlarmTimer = m_events->newOneShotTimer(m_keepAliveAlarm, nullptr);
|
||||
m_events->adoptHandler(
|
||||
Event::kTimer, m_keepAliveAlarmTimer, new TMethodEventJob<ServerProxy>(this, &ServerProxy::handleKeepAliveAlarm)
|
||||
);
|
||||
@ -177,7 +177,7 @@ ServerProxy::EResult ServerProxy::parseHandshakeMessage(const uint8_t *code)
|
||||
else if (memcmp(code, kMsgCClose, 4) == 0) {
|
||||
// server wants us to hangup
|
||||
LOG((CLOG_DEBUG1 "recv close"));
|
||||
m_client->disconnect(NULL);
|
||||
m_client->disconnect(nullptr);
|
||||
return kDisconnect;
|
||||
}
|
||||
|
||||
@ -324,7 +324,7 @@ ServerProxy::EResult ServerProxy::parseMessage(const uint8_t *code)
|
||||
else if (memcmp(code, kMsgCClose, 4) == 0) {
|
||||
// server wants us to hangup
|
||||
LOG((CLOG_DEBUG1 "recv close"));
|
||||
m_client->disconnect(NULL);
|
||||
m_client->disconnect(nullptr);
|
||||
return kDisconnect;
|
||||
} else if (memcmp(code, kMsgEBad, 4) == 0) {
|
||||
LOG((CLOG_ERR "server disconnected due to a protocol error"));
|
||||
|
||||
@ -60,7 +60,7 @@ public:
|
||||
#ifdef TEST_ENV
|
||||
void handleDataForTest()
|
||||
{
|
||||
handleData(Event(), NULL);
|
||||
handleData(Event(), nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
#error "config.h missing"
|
||||
#endif
|
||||
|
||||
// define NULL
|
||||
// define nullptr
|
||||
#include <stddef.h>
|
||||
|
||||
// make assert available since we use it a lot
|
||||
|
||||
@ -131,7 +131,7 @@ int App::daemonMainLoop(int, const char **)
|
||||
|
||||
void App::setupFileLogging()
|
||||
{
|
||||
if (argsBase().m_logFile != NULL) {
|
||||
if (argsBase().m_logFile != nullptr) {
|
||||
m_fileLog = new FileLogOutputter(argsBase().m_logFile); // NOSONAR - Adopted by `Log`
|
||||
CLOG->insert(m_fileLog);
|
||||
LOG((CLOG_DEBUG1 "logging to file (%s) enabled", argsBase().m_logFile));
|
||||
@ -141,7 +141,7 @@ void App::setupFileLogging()
|
||||
void App::loggingFilterWarning()
|
||||
{
|
||||
if (CLOG->getFilter() > CLOG->getConsoleMaxLevel()) {
|
||||
if (argsBase().m_logFile == NULL) {
|
||||
if (argsBase().m_logFile == nullptr) {
|
||||
LOG(
|
||||
(CLOG_WARN "log messages above %s are NOT sent to console (use file logging)",
|
||||
CLOG->getFilterName(CLOG->getConsoleMaxLevel()))
|
||||
@ -206,7 +206,7 @@ void App::runEventsLoop(void *)
|
||||
// MinimalApp
|
||||
//
|
||||
|
||||
MinimalApp::MinimalApp() : App(NULL, new deskflow::ArgsBase())
|
||||
MinimalApp::MinimalApp() : App(nullptr, new deskflow::ArgsBase())
|
||||
{
|
||||
m_arch.init();
|
||||
setEvents(m_events);
|
||||
@ -242,7 +242,7 @@ int MinimalApp::foregroundStartup(int argc, char **argv)
|
||||
|
||||
deskflow::Screen *MinimalApp::createScreen()
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void MinimalApp::loadConfig()
|
||||
|
||||
@ -62,9 +62,9 @@
|
||||
|
||||
ClientApp::ClientApp(IEventQueue *events)
|
||||
: App(events, new deskflow::ClientArgs()),
|
||||
m_client(NULL),
|
||||
m_clientScreen(NULL),
|
||||
m_serverAddress(NULL)
|
||||
m_client(nullptr),
|
||||
m_clientScreen(nullptr),
|
||||
m_serverAddress(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@ -258,7 +258,7 @@ deskflow::Screen *ClientApp::openClientScreen()
|
||||
|
||||
void ClientApp::closeClientScreen(deskflow::Screen *screen)
|
||||
{
|
||||
if (screen != NULL) {
|
||||
if (screen != nullptr) {
|
||||
m_events->removeHandler(m_events->forIScreen().error(), screen->getEventTarget());
|
||||
delete screen;
|
||||
}
|
||||
@ -279,7 +279,7 @@ void ClientApp::scheduleClientRestart(double retryTime)
|
||||
{
|
||||
// install a timer and handler to retry later
|
||||
LOG((CLOG_DEBUG "retry in %.0f seconds", retryTime));
|
||||
EventQueueTimer *timer = m_events->newOneShotTimer(retryTime, NULL);
|
||||
EventQueueTimer *timer = m_events->newOneShotTimer(retryTime, nullptr);
|
||||
m_events->adoptHandler(
|
||||
Event::kTimer, timer, new TMethodEventJob<ClientApp>(this, &ClientApp::handleClientRestart, timer)
|
||||
);
|
||||
@ -370,7 +370,7 @@ Client *ClientApp::openClient(const std::string &name, const NetworkAddress &add
|
||||
|
||||
void ClientApp::closeClient(Client *client)
|
||||
{
|
||||
if (client == NULL) {
|
||||
if (client == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -392,9 +392,9 @@ int ClientApp::foregroundStartup(int argc, char **argv)
|
||||
bool ClientApp::startClient()
|
||||
{
|
||||
double retryTime;
|
||||
deskflow::Screen *clientScreen = NULL;
|
||||
deskflow::Screen *clientScreen = nullptr;
|
||||
try {
|
||||
if (m_clientScreen == NULL) {
|
||||
if (m_clientScreen == nullptr) {
|
||||
clientScreen = openClientScreen();
|
||||
m_client = openClient(args().m_name, *m_serverAddress, clientScreen);
|
||||
m_clientScreen = clientScreen;
|
||||
@ -433,8 +433,8 @@ void ClientApp::stopClient()
|
||||
{
|
||||
closeClient(m_client);
|
||||
closeClientScreen(m_clientScreen);
|
||||
m_client = NULL;
|
||||
m_clientScreen = NULL;
|
||||
m_client = nullptr;
|
||||
m_clientScreen = nullptr;
|
||||
}
|
||||
|
||||
int ClientApp::mainLoop()
|
||||
@ -454,7 +454,7 @@ int ClientApp::mainLoop()
|
||||
|
||||
#if WINAPI_CARBON
|
||||
|
||||
Thread thread(new TMethodJob<ClientApp>(this, &ClientApp::runEventsLoop, NULL));
|
||||
Thread thread(new TMethodJob<ClientApp>(this, &ClientApp::runEventsLoop, nullptr));
|
||||
|
||||
// wait until carbon loop is ready
|
||||
OSXScreen *screen = dynamic_cast<OSXScreen *>(m_clientScreen->getPlatformScreen());
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
void IClipboard::unmarshall(IClipboard *clipboard, const std::string &data, Time time)
|
||||
{
|
||||
assert(clipboard != NULL);
|
||||
assert(clipboard != nullptr);
|
||||
|
||||
const char *index = data.data();
|
||||
|
||||
@ -60,7 +60,7 @@ std::string IClipboard::marshall(const IClipboard *clipboard)
|
||||
// n bytes => clipboard data
|
||||
// back to the second 4 bytes if there is another format
|
||||
|
||||
assert(clipboard != NULL);
|
||||
assert(clipboard != nullptr);
|
||||
|
||||
std::string data;
|
||||
|
||||
@ -100,16 +100,16 @@ std::string IClipboard::marshall(const IClipboard *clipboard)
|
||||
|
||||
bool IClipboard::copy(IClipboard *dst, const IClipboard *src)
|
||||
{
|
||||
assert(dst != NULL);
|
||||
assert(src != NULL);
|
||||
assert(dst != nullptr);
|
||||
assert(src != nullptr);
|
||||
|
||||
return copy(dst, src, src->getTime());
|
||||
}
|
||||
|
||||
bool IClipboard::copy(IClipboard *dst, const IClipboard *src, Time time)
|
||||
{
|
||||
assert(dst != NULL);
|
||||
assert(src != NULL);
|
||||
assert(dst != nullptr);
|
||||
assert(src != nullptr);
|
||||
|
||||
bool success = false;
|
||||
if (src->open(time)) {
|
||||
|
||||
@ -30,7 +30,7 @@ IKeyState::KeyInfo *IKeyState::KeyInfo::alloc(KeyID id, KeyModifierMask mask, Ke
|
||||
info->m_mask = mask;
|
||||
info->m_button = button;
|
||||
info->m_count = count;
|
||||
info->m_screens = NULL;
|
||||
info->m_screens = nullptr;
|
||||
info->m_screensBuffer[0] = '\0';
|
||||
return info;
|
||||
}
|
||||
@ -61,14 +61,14 @@ IKeyState::KeyInfo *IKeyState::KeyInfo::alloc(const KeyInfo &x)
|
||||
info->m_mask = x.m_mask;
|
||||
info->m_button = x.m_button;
|
||||
info->m_count = x.m_count;
|
||||
info->m_screens = x.m_screens ? info->m_screensBuffer : NULL;
|
||||
info->m_screens = x.m_screens ? info->m_screensBuffer : nullptr;
|
||||
memcpy(info->m_screensBuffer, x.m_screensBuffer, bufferLen + 1);
|
||||
return info;
|
||||
}
|
||||
|
||||
bool IKeyState::KeyInfo::isDefault(const char *screens)
|
||||
{
|
||||
return (screens == NULL || screens[0] == '\0');
|
||||
return (screens == nullptr || screens[0] == '\0');
|
||||
}
|
||||
|
||||
bool IKeyState::KeyInfo::contains(const char *screens, const std::string &name)
|
||||
@ -87,7 +87,7 @@ bool IKeyState::KeyInfo::contains(const char *screens, const std::string &name)
|
||||
match += ":";
|
||||
match += name;
|
||||
match += ":";
|
||||
return (strstr(screens, match.c_str()) != NULL);
|
||||
return (strstr(screens, match.c_str()) != nullptr);
|
||||
}
|
||||
|
||||
bool IKeyState::KeyInfo::equal(const KeyInfo *a, const KeyInfo *b)
|
||||
|
||||
@ -17,10 +17,10 @@
|
||||
|
||||
namespace deskflow {
|
||||
|
||||
KeyMap::NameToKeyMap *KeyMap::s_nameToKeyMap = NULL;
|
||||
KeyMap::NameToModifierMap *KeyMap::s_nameToModifierMap = NULL;
|
||||
KeyMap::KeyToNameMap *KeyMap::s_keyToNameMap = NULL;
|
||||
KeyMap::ModifierToNameMap *KeyMap::s_modifierToNameMap = NULL;
|
||||
KeyMap::NameToKeyMap *KeyMap::s_nameToKeyMap = nullptr;
|
||||
KeyMap::NameToModifierMap *KeyMap::s_nameToModifierMap = nullptr;
|
||||
KeyMap::KeyToNameMap *KeyMap::s_keyToNameMap = nullptr;
|
||||
KeyMap::ModifierToNameMap *KeyMap::s_modifierToNameMap = nullptr;
|
||||
|
||||
KeyMap::KeyMap() : m_numGroups(0), m_composeAcrossGroups(false)
|
||||
{
|
||||
@ -104,7 +104,7 @@ void KeyMap::addKeyAliasEntry(
|
||||
)
|
||||
{
|
||||
// if we can already generate the target as desired then we're done.
|
||||
if (findCompatibleKey(targetID, group, targetRequired, targetSensitive) != NULL) {
|
||||
if (findCompatibleKey(targetID, group, targetRequired, targetSensitive) != nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ void KeyMap::addKeyAliasEntry(
|
||||
for (int32_t gd = 0, n = getNumGroups(); gd < n; ++gd) {
|
||||
int32_t eg = getEffectiveGroup(group, gd);
|
||||
const KeyItemList *sourceEntry = findCompatibleKey(sourceID, eg, sourceRequired, sourceSensitive);
|
||||
if (sourceEntry != NULL && sourceEntry->size() == 1) {
|
||||
if (sourceEntry != nullptr && sourceEntry->size() == 1) {
|
||||
KeyMap::KeyItem targetItem = sourceEntry->back();
|
||||
targetItem.m_id = targetID;
|
||||
targetItem.m_group = eg;
|
||||
@ -243,10 +243,10 @@ const KeyMap::KeyItem *KeyMap::mapKey(
|
||||
// handle group change
|
||||
if (id == kKeyNextGroup) {
|
||||
keys.push_back(Keystroke(1, false, false));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else if (id == kKeyPrevGroup) {
|
||||
keys.push_back(Keystroke(-1, false, false));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const KeyItem *item;
|
||||
@ -271,7 +271,7 @@ const KeyMap::KeyItem *KeyMap::mapKey(
|
||||
case kKeySetModifiers:
|
||||
if (!keysForModifierState(0, group, activeModifiers, currentState, desiredMask, desiredMask, 0, keys)) {
|
||||
LOG((CLOG_DEBUG1 "unable to set modifiers %04x", desiredMask));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return &m_modifierKeyItem;
|
||||
|
||||
@ -280,7 +280,7 @@ const KeyMap::KeyItem *KeyMap::mapKey(
|
||||
0, group, activeModifiers, currentState, currentState & ~desiredMask, desiredMask, 0, keys
|
||||
)) {
|
||||
LOG((CLOG_DEBUG1 "unable to clear modifiers %04x", desiredMask));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return &m_modifierKeyItem;
|
||||
|
||||
@ -293,7 +293,7 @@ const KeyMap::KeyItem *KeyMap::mapKey(
|
||||
break;
|
||||
}
|
||||
|
||||
if (item != NULL) {
|
||||
if (item != nullptr) {
|
||||
LOG((CLOG_DEBUG1 "mapped to %03x, new state %04x", item->m_button, currentState));
|
||||
}
|
||||
return item;
|
||||
@ -336,7 +336,7 @@ KeyMap::findCompatibleKey(KeyID id, int32_t group, KeyModifierMask required, Key
|
||||
|
||||
KeyIDMap::const_iterator i = m_keyIDMap.find(id);
|
||||
if (i == m_keyIDMap.end()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const KeyEntryList &entries = i->second[group];
|
||||
@ -347,7 +347,7 @@ KeyMap::findCompatibleKey(KeyID id, int32_t group, KeyModifierMask required, Key
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool KeyMap::isHalfDuplex(KeyID key, KeyButton button) const
|
||||
@ -487,12 +487,12 @@ const KeyMap::KeyItem *KeyMap::mapCommandKey(
|
||||
if (i == m_keyIDMap.end()) {
|
||||
// unknown key
|
||||
LOG((CLOG_DEBUG1 "key %04x is not on keyboard", id));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
const KeyGroupTable &keyGroupTable = i->second;
|
||||
|
||||
// find the first key that generates this KeyID
|
||||
const KeyItem *keyItem = NULL;
|
||||
const KeyItem *keyItem = nullptr;
|
||||
int32_t numGroups = getNumGroups();
|
||||
for (int32_t groupOffset = 0; groupOffset < numGroups; ++groupOffset) {
|
||||
int32_t effectiveGroup = getEffectiveGroup(group, groupOffset);
|
||||
@ -518,14 +518,14 @@ const KeyMap::KeyItem *KeyMap::mapCommandKey(
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (keyItem != NULL) {
|
||||
if (keyItem != nullptr) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (keyItem == NULL) {
|
||||
if (keyItem == nullptr) {
|
||||
// no mapping for this keysym
|
||||
LOG((CLOG_DEBUG1 "no mapping for key %04x", id));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// make working copy of modifiers
|
||||
@ -542,14 +542,14 @@ const KeyMap::KeyItem *KeyMap::mapCommandKey(
|
||||
)) {
|
||||
LOG((CLOG_DEBUG1 "can't map key"));
|
||||
keys.clear();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// add keystrokes to restore modifier keys
|
||||
if (!keysToRestoreModifiers(*keyItem, group, newModifiers, newState, activeModifiers, keys)) {
|
||||
LOG((CLOG_DEBUG1 "modifiers were not restored"));
|
||||
keys.clear();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// save new modifiers
|
||||
@ -589,7 +589,7 @@ const KeyMap::KeyItem *KeyMap::mapCharacterKey(
|
||||
// unknown key
|
||||
LOG((CLOG_DEBUG1 "key %04x is not on keyboard", id));
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// get keys to press for key
|
||||
@ -597,7 +597,7 @@ const KeyMap::KeyItem *KeyMap::mapCharacterKey(
|
||||
if (!itemList || itemList->empty()) {
|
||||
// no mapping for this keysym
|
||||
LOG((CLOG_DEBUG1 "no mapping for key %04x", id));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const KeyItem &keyItem = itemList->back();
|
||||
@ -612,7 +612,7 @@ const KeyMap::KeyItem *KeyMap::mapCharacterKey(
|
||||
if (!keysForKeyItem(itemList->at(j), newGroup, newModifiers, newState, desiredMask, 0, isAutoRepeat, keys, lang)) {
|
||||
LOG((CLOG_DEBUG1 "can't map key"));
|
||||
keys.clear();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -620,7 +620,7 @@ const KeyMap::KeyItem *KeyMap::mapCharacterKey(
|
||||
if (!keysToRestoreModifiers(keyItem, group, newModifiers, newState, activeModifiers, keys)) {
|
||||
LOG((CLOG_DEBUG1 "modifiers were not restored"));
|
||||
keys.clear();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// save new modifiers
|
||||
@ -691,7 +691,7 @@ const KeyMap::KeyItem *KeyMap::keyForModifier(KeyButton button, int32_t group, i
|
||||
return (*i);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool KeyMap::keysForKeyItem(
|
||||
@ -852,7 +852,7 @@ bool KeyMap::keysForModifierState(
|
||||
|
||||
// get the KeyItem for the modifier in the group
|
||||
const KeyItem *keyItem = keyForModifier(button, group, bit);
|
||||
if (keyItem == NULL) {
|
||||
if (keyItem == nullptr) {
|
||||
if ((mask & notRequiredMask) == 0) {
|
||||
LOG((CLOG_DEBUG1 "no key for modifier %04x", mask));
|
||||
return false;
|
||||
@ -1199,18 +1199,18 @@ bool KeyMap::parseModifiers(std::string &x, KeyModifierMask &mask)
|
||||
void KeyMap::initKeyNameMaps()
|
||||
{
|
||||
// initialize tables
|
||||
if (s_nameToKeyMap == NULL) {
|
||||
if (s_nameToKeyMap == nullptr) {
|
||||
s_nameToKeyMap = new NameToKeyMap;
|
||||
s_keyToNameMap = new KeyToNameMap;
|
||||
for (const KeyNameMapEntry *i = kKeyNameMap; i->m_name != NULL; ++i) {
|
||||
for (const KeyNameMapEntry *i = kKeyNameMap; i->m_name != nullptr; ++i) {
|
||||
(*s_nameToKeyMap)[i->m_name] = i->m_id;
|
||||
(*s_keyToNameMap)[i->m_id] = i->m_name;
|
||||
}
|
||||
}
|
||||
if (s_nameToModifierMap == NULL) {
|
||||
if (s_nameToModifierMap == nullptr) {
|
||||
s_nameToModifierMap = new NameToModifierMap;
|
||||
s_modifierToNameMap = new ModifierToNameMap;
|
||||
for (const KeyModifierNameMapEntry *i = kModifierNameMap; i->m_name != NULL; ++i) {
|
||||
for (const KeyModifierNameMapEntry *i = kModifierNameMap; i->m_name != nullptr; ++i) {
|
||||
(*s_nameToModifierMap)[i->m_name] = i->m_mask;
|
||||
(*s_modifierToNameMap)[i->m_mask] = i->m_name;
|
||||
}
|
||||
|
||||
@ -211,7 +211,7 @@ public:
|
||||
modifiers as given in \p currentState and the desired modifiers in
|
||||
\p desiredMask into the keystrokes necessary to synthesize that key
|
||||
event in \p keys. It returns the \c KeyItem of the key being
|
||||
pressed/repeated, or NULL if the key cannot be mapped.
|
||||
pressed/repeated, or nullptr if the key cannot be mapped.
|
||||
*/
|
||||
virtual const KeyItem *mapKey(
|
||||
Keystrokes &keys, KeyID id, int32_t group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
||||
@ -235,7 +235,7 @@ public:
|
||||
//! Find key entry compatible with modifiers
|
||||
/*!
|
||||
Returns the \c KeyItemList for the first entry for \p id in group
|
||||
\p group that is compatible with the given modifiers, or NULL
|
||||
\p group that is compatible with the given modifiers, or nullptr
|
||||
if there isn't one. A button list is compatible with a modifiers
|
||||
if it is either insensitive to all modifiers in \p sensitive or
|
||||
it requires the modifiers to be in the state indicated by \p required
|
||||
|
||||
@ -855,7 +855,7 @@ bool KeyState::fakeKeyRepeat(KeyID id, KeyModifierMask mask, int32_t count, KeyB
|
||||
ModifierToKeys oldActiveModifiers = m_activeModifiers;
|
||||
const deskflow::KeyMap::KeyItem *keyItem =
|
||||
m_keyMap.mapKey(keys, id, pollActiveGroup(), m_activeModifiers, getActiveModifiersRValue(), mask, true, lang);
|
||||
if (keyItem == NULL) {
|
||||
if (keyItem == nullptr) {
|
||||
return false;
|
||||
}
|
||||
KeyButton localID = (KeyButton)(keyItem->m_button & kButtonMask);
|
||||
@ -996,7 +996,7 @@ bool KeyState::isIgnoredKey(KeyID key, KeyModifierMask) const
|
||||
KeyButton KeyState::getButton(KeyID id, int32_t group) const
|
||||
{
|
||||
const deskflow::KeyMap::KeyItemList *items = m_keyMap.findCompatibleKey(id, group, 0, 0);
|
||||
if (items == NULL) {
|
||||
if (items == nullptr) {
|
||||
return 0;
|
||||
} else {
|
||||
return items->back().m_button;
|
||||
|
||||
@ -180,7 +180,7 @@ const KeyNameMapEntry kKeyNameMap[] = {
|
||||
{"Bar", 0x007c},
|
||||
{"BraceR", 0x007d},
|
||||
{"Tilde", 0x007e},
|
||||
{NULL, 0},
|
||||
{nullptr, 0},
|
||||
};
|
||||
|
||||
const KeyModifierNameMapEntry kModifierNameMap[] = {
|
||||
@ -193,5 +193,5 @@ const KeyModifierNameMapEntry kModifierNameMap[] = {
|
||||
// { "ScrollLock", KeyModifierScrollLock },
|
||||
{"Shift", KeyModifierShift},
|
||||
{"Super", KeyModifierSuper},
|
||||
{NULL, 0},
|
||||
{nullptr, 0},
|
||||
};
|
||||
|
||||
@ -310,13 +310,13 @@ struct KeyModifierNameMapEntry
|
||||
/*!
|
||||
A table of key names to the corresponding KeyID. Only the keys listed
|
||||
above plus non-alphanumeric ASCII characters are in the table. The end
|
||||
of the table is the first pair with a NULL m_name.
|
||||
of the table is the first pair with a nullptr m_name.
|
||||
*/
|
||||
extern const struct KeyNameMapEntry kKeyNameMap[];
|
||||
|
||||
//! Modifier key name to KeyModifierMask table
|
||||
/*!
|
||||
A table of modifier key names to the corresponding KeyModifierMask.
|
||||
The end of the table is the first pair with a NULL m_name.
|
||||
The end of the table is the first pair with a nullptr m_name.
|
||||
*/
|
||||
extern const struct KeyModifierNameMapEntry kModifierNameMap[];
|
||||
|
||||
@ -59,7 +59,7 @@ uint32_t PacketStreamFilter::read(void *buffer, uint32_t n)
|
||||
}
|
||||
|
||||
// read it
|
||||
if (buffer != NULL) {
|
||||
if (buffer != nullptr) {
|
||||
memcpy(buffer, m_buffer.peek(n), n);
|
||||
}
|
||||
m_buffer.pop(n);
|
||||
|
||||
@ -58,7 +58,7 @@ template <typename T> void writeVectorInt(const std::vector<T> *VectorData, std:
|
||||
|
||||
void writeString(const std::string *StringData, std::vector<uint8_t> &Buffer)
|
||||
{
|
||||
const uint32_t len = (StringData != NULL) ? (uint32_t)StringData->size() : 0;
|
||||
const uint32_t len = (StringData != nullptr) ? (uint32_t)StringData->size() : 0;
|
||||
writeInt(len, sizeof(len), Buffer);
|
||||
if (len != 0) {
|
||||
std::copy(StringData->begin(), StringData->end(), std::back_inserter(Buffer));
|
||||
@ -69,8 +69,8 @@ void writeString(const std::string *StringData, std::vector<uint8_t> &Buffer)
|
||||
|
||||
void ProtocolUtil::writef(deskflow::IStream *stream, const char *fmt, ...)
|
||||
{
|
||||
assert(stream != NULL);
|
||||
assert(fmt != NULL);
|
||||
assert(stream != nullptr);
|
||||
assert(fmt != nullptr);
|
||||
LOG((CLOG_DEBUG2 "writef(%s)", fmt));
|
||||
|
||||
va_list args;
|
||||
@ -106,8 +106,8 @@ bool ProtocolUtil::readf(deskflow::IStream *stream, const char *fmt, ...)
|
||||
|
||||
void ProtocolUtil::vwritef(deskflow::IStream *stream, const char *fmt, uint32_t size, va_list args)
|
||||
{
|
||||
assert(stream != NULL);
|
||||
assert(fmt != NULL);
|
||||
assert(stream != nullptr);
|
||||
assert(fmt != nullptr);
|
||||
|
||||
// done if nothing to write
|
||||
if (size == 0) {
|
||||
@ -130,8 +130,8 @@ void ProtocolUtil::vwritef(deskflow::IStream *stream, const char *fmt, uint32_t
|
||||
|
||||
void ProtocolUtil::vreadf(deskflow::IStream *stream, const char *fmt, va_list args)
|
||||
{
|
||||
assert(stream != NULL);
|
||||
assert(fmt != NULL);
|
||||
assert(stream != nullptr);
|
||||
assert(fmt != nullptr);
|
||||
|
||||
// begin scanning
|
||||
while (*fmt) {
|
||||
@ -415,8 +415,8 @@ uint32_t ProtocolUtil::eatLength(const char **pfmt)
|
||||
|
||||
void ProtocolUtil::read(deskflow::IStream *stream, void *vbuffer, uint32_t count)
|
||||
{
|
||||
assert(stream != NULL);
|
||||
assert(vbuffer != NULL);
|
||||
assert(stream != nullptr);
|
||||
assert(vbuffer != nullptr);
|
||||
|
||||
uint8_t *buffer = static_cast<uint8_t *>(vbuffer);
|
||||
while (count > 0) {
|
||||
|
||||
@ -29,7 +29,7 @@ Screen::Screen(IPlatformScreen *platformScreen, IEventQueue *events)
|
||||
m_mock(false),
|
||||
m_enableDragDrop(false)
|
||||
{
|
||||
assert(m_screen != NULL);
|
||||
assert(m_screen != nullptr);
|
||||
|
||||
// reset options
|
||||
resetOptions();
|
||||
@ -179,7 +179,7 @@ void Screen::setClipboard(ClipboardID id, const IClipboard *clipboard)
|
||||
|
||||
void Screen::grabClipboard(ClipboardID id)
|
||||
{
|
||||
m_screen->setClipboard(id, NULL);
|
||||
m_screen->setClipboard(id, nullptr);
|
||||
}
|
||||
|
||||
void Screen::screensaver(bool) const
|
||||
|
||||
@ -70,13 +70,13 @@ using namespace deskflow::server;
|
||||
|
||||
ServerApp::ServerApp(IEventQueue *events)
|
||||
: App(events, new deskflow::ServerArgs()),
|
||||
m_server(NULL),
|
||||
m_server(nullptr),
|
||||
m_serverState(kUninitialized),
|
||||
m_serverScreen(NULL),
|
||||
m_primaryClient(NULL),
|
||||
m_listener(NULL),
|
||||
m_timer(NULL),
|
||||
m_deskflowAddress(NULL)
|
||||
m_serverScreen(nullptr),
|
||||
m_primaryClient(nullptr),
|
||||
m_listener(nullptr),
|
||||
m_timer(nullptr),
|
||||
m_deskflowAddress(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ void ServerApp::reloadConfig(const Event &, void *)
|
||||
{
|
||||
LOG((CLOG_DEBUG "reload configuration"));
|
||||
if (loadConfig(args().m_configFile)) {
|
||||
if (m_server != NULL) {
|
||||
if (m_server != nullptr) {
|
||||
m_server->setConfig(*args().m_config);
|
||||
}
|
||||
LOG((CLOG_NOTE "reloaded configuration"));
|
||||
@ -209,7 +209,7 @@ bool ServerApp::loadConfig(const std::string &pathname)
|
||||
|
||||
void ServerApp::forceReconnect(const Event &, void *)
|
||||
{
|
||||
if (m_server != NULL) {
|
||||
if (m_server != nullptr) {
|
||||
m_server->disconnect();
|
||||
}
|
||||
}
|
||||
@ -218,7 +218,7 @@ void ServerApp::handleClientConnected(const Event &, void *vlistener)
|
||||
{
|
||||
ClientListener *listener = static_cast<ClientListener *>(vlistener);
|
||||
ClientProxy *client = listener->getNextClient();
|
||||
if (client != NULL) {
|
||||
if (client != nullptr) {
|
||||
m_server->adoptClient(client);
|
||||
updateStatus();
|
||||
}
|
||||
@ -231,7 +231,7 @@ void ServerApp::handleClientsDisconnected(const Event &, void *)
|
||||
|
||||
void ServerApp::closeServer(Server *server)
|
||||
{
|
||||
if (server == NULL) {
|
||||
if (server == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -240,7 +240,7 @@ void ServerApp::closeServer(Server *server)
|
||||
|
||||
// wait for clients to disconnect for up to timeout seconds
|
||||
double timeout = 3.0;
|
||||
EventQueueTimer *timer = m_events->newOneShotTimer(timeout, NULL);
|
||||
EventQueueTimer *timer = m_events->newOneShotTimer(timeout, nullptr);
|
||||
m_events->adoptHandler(
|
||||
Event::kTimer, timer, new TMethodEventJob<ServerApp>(this, &ServerApp::handleClientsDisconnected)
|
||||
);
|
||||
@ -261,10 +261,10 @@ void ServerApp::closeServer(Server *server)
|
||||
|
||||
void ServerApp::stopRetryTimer()
|
||||
{
|
||||
if (m_timer != NULL) {
|
||||
if (m_timer != nullptr) {
|
||||
m_events->removeHandler(Event::kTimer, m_timer);
|
||||
m_events->deleteTimer(m_timer);
|
||||
m_timer = NULL;
|
||||
m_timer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -279,7 +279,7 @@ void ServerApp::updateStatus(const std::string &msg)
|
||||
|
||||
void ServerApp::closeClientListener(ClientListener *listen)
|
||||
{
|
||||
if (listen != NULL) {
|
||||
if (listen != nullptr) {
|
||||
m_events->removeHandler(m_events->forClientListener().connected(), listen);
|
||||
delete listen;
|
||||
}
|
||||
@ -290,15 +290,15 @@ void ServerApp::stopServer()
|
||||
if (m_serverState == kStarted) {
|
||||
closeServer(m_server);
|
||||
closeClientListener(m_listener);
|
||||
m_server = NULL;
|
||||
m_listener = NULL;
|
||||
m_server = nullptr;
|
||||
m_listener = nullptr;
|
||||
m_serverState = kInitialized;
|
||||
} else if (m_serverState == kStarting) {
|
||||
stopRetryTimer();
|
||||
m_serverState = kInitialized;
|
||||
}
|
||||
assert(m_server == NULL);
|
||||
assert(m_listener == NULL);
|
||||
assert(m_server == nullptr);
|
||||
assert(m_listener == nullptr);
|
||||
}
|
||||
|
||||
void ServerApp::closePrimaryClient(PrimaryClient *primaryClient)
|
||||
@ -308,7 +308,7 @@ void ServerApp::closePrimaryClient(PrimaryClient *primaryClient)
|
||||
|
||||
void ServerApp::closeServerScreen(deskflow::Screen *screen)
|
||||
{
|
||||
if (screen != NULL) {
|
||||
if (screen != nullptr) {
|
||||
m_events->removeHandler(m_events->forIScreen().error(), screen->getEventTarget());
|
||||
m_events->removeHandler(m_events->forIScreen().suspend(), screen->getEventTarget());
|
||||
m_events->removeHandler(m_events->forIScreen().resume(), screen->getEventTarget());
|
||||
@ -322,22 +322,22 @@ void ServerApp::cleanupServer()
|
||||
if (m_serverState == kInitialized) {
|
||||
closePrimaryClient(m_primaryClient);
|
||||
closeServerScreen(m_serverScreen);
|
||||
m_primaryClient = NULL;
|
||||
m_serverScreen = NULL;
|
||||
m_primaryClient = nullptr;
|
||||
m_serverScreen = nullptr;
|
||||
m_serverState = kUninitialized;
|
||||
} else if (m_serverState == kInitializing || m_serverState == kInitializingToStart) {
|
||||
stopRetryTimer();
|
||||
m_serverState = kUninitialized;
|
||||
}
|
||||
assert(m_primaryClient == NULL);
|
||||
assert(m_serverScreen == NULL);
|
||||
assert(m_primaryClient == nullptr);
|
||||
assert(m_serverScreen == nullptr);
|
||||
assert(m_serverState == kUninitialized);
|
||||
}
|
||||
|
||||
void ServerApp::retryHandler(const Event &, void *)
|
||||
{
|
||||
// discard old timer
|
||||
assert(m_timer != NULL);
|
||||
assert(m_timer != nullptr);
|
||||
stopRetryTimer();
|
||||
|
||||
// try initializing/starting the server again
|
||||
@ -387,8 +387,8 @@ bool ServerApp::initServer()
|
||||
}
|
||||
|
||||
double retryTime;
|
||||
deskflow::Screen *serverScreen = NULL;
|
||||
PrimaryClient *primaryClient = NULL;
|
||||
deskflow::Screen *serverScreen = nullptr;
|
||||
PrimaryClient *primaryClient = nullptr;
|
||||
try {
|
||||
std::string name = args().m_config->getCanonicalName(args().m_name);
|
||||
serverScreen = openServerScreen();
|
||||
@ -418,9 +418,9 @@ bool ServerApp::initServer()
|
||||
|
||||
if (args().m_restartable) {
|
||||
// install a timer and handler to retry later
|
||||
assert(m_timer == NULL);
|
||||
assert(m_timer == nullptr);
|
||||
LOG((CLOG_DEBUG "retry in %.0f seconds", retryTime));
|
||||
m_timer = m_events->newOneShotTimer(retryTime, NULL);
|
||||
m_timer = m_events->newOneShotTimer(retryTime, nullptr);
|
||||
m_events->adoptHandler(Event::kTimer, m_timer, new TMethodEventJob<ServerApp>(this, &ServerApp::retryHandler));
|
||||
m_serverState = kInitializing;
|
||||
return true;
|
||||
@ -470,7 +470,7 @@ bool ServerApp::startServer()
|
||||
assert(m_serverState == kInitialized);
|
||||
}
|
||||
|
||||
ClientListener *listener = NULL;
|
||||
ClientListener *listener = nullptr;
|
||||
try {
|
||||
listener = openClientListener(args().m_config->getDeskflowAddress());
|
||||
m_server = openServer(*args().m_config, m_primaryClient);
|
||||
@ -497,10 +497,10 @@ bool ServerApp::startServer()
|
||||
|
||||
if (args().m_restartable) {
|
||||
// install a timer and handler to retry later
|
||||
assert(m_timer == NULL);
|
||||
assert(m_timer == nullptr);
|
||||
const auto retryTime = 10.0;
|
||||
LOG((CLOG_DEBUG "retry in %.0f seconds", retryTime));
|
||||
m_timer = m_events->newOneShotTimer(retryTime, NULL);
|
||||
m_timer = m_events->newOneShotTimer(retryTime, nullptr);
|
||||
m_events->adoptHandler(Event::kTimer, m_timer, new TMethodEventJob<ServerApp>(this, &ServerApp::retryHandler));
|
||||
m_serverState = kStarting;
|
||||
return true;
|
||||
@ -655,7 +655,7 @@ int ServerApp::mainLoop()
|
||||
appUtil().startNode();
|
||||
|
||||
// handle hangup signal by reloading the server's configuration
|
||||
ARCH->setSignalHandler(Arch::kHANGUP, &reloadSignalHandler, NULL);
|
||||
ARCH->setSignalHandler(Arch::kHANGUP, &reloadSignalHandler, nullptr);
|
||||
m_events->adoptHandler(
|
||||
m_events->forServerApp().reloadConfig(), m_events->getSystemTarget(),
|
||||
new TMethodEventJob<ServerApp>(this, &ServerApp::reloadConfig)
|
||||
@ -682,7 +682,7 @@ int ServerApp::mainLoop()
|
||||
|
||||
#if WINAPI_CARBON
|
||||
|
||||
Thread thread(new TMethodJob<ServerApp>(this, &ServerApp::runEventsLoop, NULL));
|
||||
Thread thread(new TMethodJob<ServerApp>(this, &ServerApp::runEventsLoop, nullptr));
|
||||
|
||||
// wait until carbon loop is ready
|
||||
OSXScreen *screen = dynamic_cast<OSXScreen *>(m_serverScreen->getPlatformScreen());
|
||||
|
||||
@ -27,7 +27,7 @@ static const size_t g_chunkSize = 512 * 1024; // 512kb
|
||||
|
||||
bool StreamChunker::s_isChunkingFile = false;
|
||||
bool StreamChunker::s_interruptFile = false;
|
||||
Mutex *StreamChunker::s_interruptMutex = NULL;
|
||||
Mutex *StreamChunker::s_interruptMutex = nullptr;
|
||||
|
||||
void StreamChunker::sendFile(char *filename, IEventQueue *events, void *eventTarget)
|
||||
{
|
||||
|
||||
@ -60,7 +60,9 @@ std::vector<std::string> AppUtilUnix::getKeyboardLayoutList()
|
||||
#elif WINAPI_CARBON
|
||||
CFStringRef keys[] = {kTISPropertyInputSourceCategory};
|
||||
CFStringRef values[] = {kTISCategoryKeyboardInputSource};
|
||||
AutoCFDictionary dict(CFDictionaryCreate(NULL, (const void **)keys, (const void **)values, 1, NULL, NULL), CFRelease);
|
||||
AutoCFDictionary dict(
|
||||
CFDictionaryCreate(nullptr, (const void **)keys, (const void **)values, 1, nullptr, nullptr), CFRelease
|
||||
);
|
||||
AutoCFArray kbds(TISCreateInputSourceList(dict.get(), false), CFRelease);
|
||||
|
||||
for (CFIndex i = 0; i < CFArrayGetCount(kbds.get()); ++i) {
|
||||
|
||||
@ -109,7 +109,7 @@ int AppUtilWindows::run(int argc, char **argv)
|
||||
}
|
||||
|
||||
// record window instance for tray icon, etc
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(nullptr));
|
||||
|
||||
MSWindowsScreen::init(ArchMiscWindows::instanceWin32());
|
||||
Thread::getCurrentThread().setPriority(-14);
|
||||
@ -139,7 +139,7 @@ std::vector<std::string> AppUtilWindows::getKeyboardLayoutList()
|
||||
{
|
||||
std::vector<std::string> layoutLangCodes;
|
||||
{
|
||||
auto uLayouts = GetKeyboardLayoutList(0, NULL);
|
||||
auto uLayouts = GetKeyboardLayoutList(0, nullptr);
|
||||
auto lpList = (HKL *)LocalAlloc(LPTR, (uLayouts * sizeof(HKL)));
|
||||
uLayouts = GetKeyboardLayoutList(uLayouts, lpList);
|
||||
|
||||
@ -178,7 +178,7 @@ HKL AppUtilWindows::getCurrentKeyboardLayout() const
|
||||
|
||||
GUITHREADINFO gti = {sizeof(GUITHREADINFO)};
|
||||
if (GetGUIThreadInfo(0, >i) && gti.hwndActive) {
|
||||
layout = GetKeyboardLayout(GetWindowThreadProcessId(gti.hwndActive, NULL));
|
||||
layout = GetKeyboardLayout(GetWindowThreadProcessId(gti.hwndActive, nullptr));
|
||||
} else {
|
||||
LOG((CLOG_WARN "failed to determine current keyboard layout"));
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
const QString ScreenSetupModel::m_MimeType = "application/x-deskflow-screen";
|
||||
|
||||
ScreenSetupModel::ScreenSetupModel(ScreenList &screens, int numColumns, int numRows)
|
||||
: QAbstractTableModel(NULL),
|
||||
: QAbstractTableModel(nullptr),
|
||||
m_Screens(screens),
|
||||
m_NumColumns(numColumns),
|
||||
m_NumRows(numRows)
|
||||
|
||||
@ -122,7 +122,7 @@ void ScreenSetupView::startDrag(Qt::DropActions)
|
||||
return;
|
||||
|
||||
QMimeData *pData = model()->mimeData(indexes);
|
||||
if (pData == NULL)
|
||||
if (pData == nullptr)
|
||||
return;
|
||||
|
||||
const QPixmap &pixmap = model()->screen(indexes[0]).pixmap();
|
||||
|
||||
@ -44,7 +44,7 @@ public:
|
||||
/*!
|
||||
Read up to \p n bytes into \p buffer, returning the number read
|
||||
(zero if no data is available or input is shutdown). \p buffer
|
||||
may be NULL in which case the data is discarded.
|
||||
may be nullptr in which case the data is discarded.
|
||||
*/
|
||||
virtual uint32_t read(void *buffer, uint32_t n) = 0;
|
||||
|
||||
|
||||
@ -28,10 +28,10 @@ const void *StreamBuffer::peek(uint32_t n)
|
||||
{
|
||||
assert(n <= m_size);
|
||||
|
||||
// if requesting no data then return NULL so we don't try to access
|
||||
// if requesting no data then return nullptr so we don't try to access
|
||||
// an empty list.
|
||||
if (n == 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// reserve space in first chunk
|
||||
@ -80,7 +80,7 @@ void StreamBuffer::pop(uint32_t n)
|
||||
|
||||
void StreamBuffer::write(const void *vdata, uint32_t n)
|
||||
{
|
||||
assert(vdata != NULL);
|
||||
assert(vdata != nullptr);
|
||||
|
||||
// ignore if no data, otherwise update size
|
||||
if (n == 0) {
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
CondVarBase::CondVarBase(Mutex *mutex) : m_mutex(mutex)
|
||||
{
|
||||
assert(m_mutex != NULL);
|
||||
assert(m_mutex != nullptr);
|
||||
m_cond = ARCH->newCondVar();
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ class CondVarBase
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
\c mutex must not be NULL. All condition variables have an
|
||||
\c mutex must not be nullptr. All condition variables have an
|
||||
associated mutex. The mutex needn't be unique to one condition
|
||||
variable.
|
||||
*/
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
Thread::Thread(IJob *job)
|
||||
{
|
||||
m_thread = ARCH->newThread(&Thread::threadFunc, job);
|
||||
if (m_thread == NULL) {
|
||||
if (m_thread == nullptr) {
|
||||
// couldn't create thread
|
||||
delete job;
|
||||
throw XMTThreadUnavailable();
|
||||
@ -95,7 +95,7 @@ void *Thread::getResult() const
|
||||
if (wait())
|
||||
return ARCH->getResultOfThread(m_thread);
|
||||
else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IArchMultithread::ThreadID Thread::getID() const
|
||||
@ -127,7 +127,7 @@ void *Thread::threadFunc(void *vjob)
|
||||
IJob *job = static_cast<IJob *>(vjob);
|
||||
|
||||
// run job
|
||||
void *result = NULL;
|
||||
void *result = nullptr;
|
||||
try {
|
||||
// go
|
||||
LOG((CLOG_DEBUG1 "thread 0x%08x entry", id));
|
||||
|
||||
@ -160,7 +160,7 @@ public:
|
||||
//! Get the exit result
|
||||
/*!
|
||||
Returns the exit result. This does an implicit wait(). It returns
|
||||
NULL immediately if called by a thread on itself or on a thread that
|
||||
nullptr immediately if called by a thread on itself or on a thread that
|
||||
was cancelled.
|
||||
|
||||
(cancellation point)
|
||||
|
||||
@ -22,5 +22,5 @@ void *IDataSocket::getEventTarget() const
|
||||
{
|
||||
// this is here to work around a VC++6 bug. see the header file.
|
||||
assert(0 && "bad call");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ public:
|
||||
//! Accept connection
|
||||
/*!
|
||||
Accept a connection, returning a socket representing the full-duplex
|
||||
data stream. Returns NULL if no socket is waiting to be accepted.
|
||||
data stream. Returns nullptr if no socket is waiting to be accepted.
|
||||
This is only valid after a call to \c bind().
|
||||
*/
|
||||
virtual IDataSocket *accept() = 0;
|
||||
|
||||
@ -25,7 +25,7 @@ public:
|
||||
Called by a socket multiplexer when the socket becomes readable,
|
||||
writable, or has an error. It should return itself if the same
|
||||
job can continue to service events, a new job if the socket must
|
||||
be serviced differently, or NULL if the socket should no longer
|
||||
be serviced differently, or nullptr if the socket should no longer
|
||||
be serviced. The socket is readable if \p readable is true,
|
||||
writable if \p writable is true, and in error if \p error is
|
||||
true.
|
||||
|
||||
@ -33,12 +33,12 @@ SecureListenSocket::SecureListenSocket(
|
||||
|
||||
IDataSocket *SecureListenSocket::accept()
|
||||
{
|
||||
SecureSocket *socket = NULL;
|
||||
SecureSocket *socket = nullptr;
|
||||
try {
|
||||
socket = new SecureSocket(m_events, m_socketMultiplexer, ARCH->acceptSocket(m_socket, NULL), m_securityLevel);
|
||||
socket = new SecureSocket(m_events, m_socketMultiplexer, ARCH->acceptSocket(m_socket, nullptr), m_securityLevel);
|
||||
socket->initSsl(true);
|
||||
|
||||
if (socket != NULL) {
|
||||
if (socket != nullptr) {
|
||||
setListeningJob();
|
||||
}
|
||||
|
||||
@ -53,20 +53,20 @@ IDataSocket *SecureListenSocket::accept()
|
||||
bool loaded = socket->loadCertificates(certificateFilename);
|
||||
if (!loaded) {
|
||||
delete socket;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
socket->secureAccept();
|
||||
|
||||
return dynamic_cast<IDataSocket *>(socket);
|
||||
} catch (XArchNetwork &) {
|
||||
if (socket != NULL) {
|
||||
if (socket != nullptr) {
|
||||
delete socket;
|
||||
setListeningJob();
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} catch (std::exception &ex) {
|
||||
if (socket != NULL) {
|
||||
if (socket != nullptr) {
|
||||
delete socket;
|
||||
setListeningJob();
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ ISocketMultiplexerJob *SecureSocket::newJob()
|
||||
// after TCP connection is established, SecureSocket will pick up
|
||||
// connected event and do secureConnect
|
||||
if (m_connected && !m_secureReady) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return TCPSocket::newJob();
|
||||
@ -184,7 +184,7 @@ TCPSocket::EJobResult SecureSocket::doWrite()
|
||||
static bool s_retry = false;
|
||||
static int s_retrySize = 0;
|
||||
static int s_staticBufferSize = 0;
|
||||
static void *s_staticBuffer = NULL;
|
||||
static void *s_staticBuffer = nullptr;
|
||||
|
||||
// write data
|
||||
int bufferSize = 0;
|
||||
@ -236,7 +236,7 @@ int SecureSocket::secureRead(void *buffer, int size, int &read)
|
||||
{
|
||||
std::lock_guard ssl_lock{ssl_mutex_};
|
||||
|
||||
if (m_ssl->m_ssl != NULL) {
|
||||
if (m_ssl->m_ssl != nullptr) {
|
||||
LOG((CLOG_DEBUG2 "reading secure socket"));
|
||||
read = SSL_read(m_ssl->m_ssl, buffer, size);
|
||||
|
||||
@ -263,7 +263,7 @@ int SecureSocket::secureWrite(const void *buffer, int size, int &wrote)
|
||||
{
|
||||
std::lock_guard ssl_lock{ssl_mutex_};
|
||||
|
||||
if (m_ssl->m_ssl != NULL) {
|
||||
if (m_ssl->m_ssl != nullptr) {
|
||||
LOG((CLOG_DEBUG2 "writing secure socket: %p", this));
|
||||
|
||||
wrote = SSL_write(m_ssl->m_ssl, buffer, size);
|
||||
@ -297,8 +297,8 @@ void SecureSocket::initSsl(bool server)
|
||||
std::lock_guard ssl_lock{ssl_mutex_};
|
||||
|
||||
m_ssl = new Ssl();
|
||||
m_ssl->m_context = NULL;
|
||||
m_ssl->m_ssl = NULL;
|
||||
m_ssl->m_context = nullptr;
|
||||
m_ssl->m_ssl = nullptr;
|
||||
|
||||
initContext(server);
|
||||
}
|
||||
@ -372,7 +372,7 @@ void SecureSocket::initContext(bool server)
|
||||
// be vulnerable
|
||||
SSL_CTX_set_options(m_ssl->m_context, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1);
|
||||
|
||||
if (m_ssl->m_context == NULL) {
|
||||
if (m_ssl->m_context == nullptr) {
|
||||
SslLogger::logError();
|
||||
}
|
||||
|
||||
@ -388,8 +388,8 @@ void SecureSocket::createSSL()
|
||||
{
|
||||
// I assume just one instance is needed
|
||||
// get new SSL state with context
|
||||
if (m_ssl->m_ssl == NULL) {
|
||||
assert(m_ssl->m_context != NULL);
|
||||
if (m_ssl->m_ssl == nullptr) {
|
||||
assert(m_ssl->m_context != nullptr);
|
||||
m_ssl->m_ssl = SSL_new(m_ssl->m_context);
|
||||
}
|
||||
}
|
||||
@ -402,17 +402,17 @@ void SecureSocket::freeSSL()
|
||||
// take socket from multiplexer ASAP otherwise the race condition
|
||||
// could cause events to get called on a dead object. TCPSocket
|
||||
// will do this, too, but the double-call is harmless
|
||||
setJob(NULL);
|
||||
setJob(nullptr);
|
||||
if (m_ssl) {
|
||||
if (m_ssl->m_ssl != NULL) {
|
||||
if (m_ssl->m_ssl != nullptr) {
|
||||
SSL_shutdown(m_ssl->m_ssl);
|
||||
|
||||
SSL_free(m_ssl->m_ssl);
|
||||
m_ssl->m_ssl = NULL;
|
||||
m_ssl->m_ssl = nullptr;
|
||||
}
|
||||
if (m_ssl->m_context != NULL) {
|
||||
if (m_ssl->m_context != nullptr) {
|
||||
SSL_CTX_free(m_ssl->m_context);
|
||||
m_ssl->m_context = NULL;
|
||||
m_ssl->m_context = nullptr;
|
||||
}
|
||||
delete m_ssl;
|
||||
m_ssl = nullptr;
|
||||
@ -546,7 +546,7 @@ bool SecureSocket::showCertificate() const
|
||||
|
||||
// get the server's certificate
|
||||
cert = SSL_get_peer_certificate(m_ssl->m_ssl);
|
||||
if (cert != NULL) {
|
||||
if (cert != nullptr) {
|
||||
line = X509_NAME_oneline(X509_get_subject_name(cert), 0, 0);
|
||||
LOG((CLOG_INFO "server tls certificate info: %s", line));
|
||||
OPENSSL_free(line);
|
||||
@ -704,7 +704,7 @@ ISocketMultiplexerJob *SecureSocket::serviceConnect(ISocketMultiplexerJob *job,
|
||||
|
||||
// If status < 0, error happened
|
||||
if (status < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// If status > 0, success
|
||||
@ -731,7 +731,7 @@ ISocketMultiplexerJob *SecureSocket::serviceAccept(ISocketMultiplexerJob *job, b
|
||||
#endif
|
||||
// If status < 0, error happened
|
||||
if (status < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// If status > 0, success
|
||||
|
||||
@ -136,7 +136,7 @@ int getCertLength(const std::string &path)
|
||||
return -1;
|
||||
}
|
||||
|
||||
EVP_PKEY *privateKey = PEM_read_PrivateKey(fp, NULL, NULL, NULL);
|
||||
EVP_PKEY *privateKey = PEM_read_PrivateKey(fp, nullptr, nullptr, nullptr);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
|
||||
@ -25,15 +25,15 @@
|
||||
|
||||
SocketMultiplexer::SocketMultiplexer()
|
||||
: m_mutex(new Mutex),
|
||||
m_thread(NULL),
|
||||
m_thread(nullptr),
|
||||
m_update(false),
|
||||
m_jobsReady(new CondVar<bool>(m_mutex, false)),
|
||||
m_jobListLock(new CondVar<bool>(m_mutex, false)),
|
||||
m_jobListLockLocked(new CondVar<bool>(m_mutex, false)),
|
||||
m_jobListLocker(NULL),
|
||||
m_jobListLockLocker(NULL)
|
||||
m_jobListLocker(nullptr),
|
||||
m_jobListLockLocker(nullptr)
|
||||
{
|
||||
// this pointer just has to be unique and not NULL. it will
|
||||
// this pointer just has to be unique and not nullptr. it will
|
||||
// never be dereferenced. it's used to identify cursor nodes
|
||||
// in the jobs list.
|
||||
// TODO: Remove this evilness
|
||||
@ -64,8 +64,8 @@ SocketMultiplexer::~SocketMultiplexer()
|
||||
|
||||
void SocketMultiplexer::addSocket(ISocket *socket, ISocketMultiplexerJob *job)
|
||||
{
|
||||
assert(socket != NULL);
|
||||
assert(job != NULL);
|
||||
assert(socket != nullptr);
|
||||
assert(job != nullptr);
|
||||
|
||||
// prevent other threads from locking the job list
|
||||
lockJobListLock();
|
||||
@ -100,7 +100,7 @@ void SocketMultiplexer::addSocket(ISocket *socket, ISocketMultiplexerJob *job)
|
||||
|
||||
void SocketMultiplexer::removeSocket(ISocket *socket)
|
||||
{
|
||||
assert(socket != NULL);
|
||||
assert(socket != nullptr);
|
||||
|
||||
// prevent other threads from locking the job list
|
||||
lockJobListLock();
|
||||
@ -111,14 +111,14 @@ void SocketMultiplexer::removeSocket(ISocket *socket)
|
||||
// lock the job list
|
||||
lockJobList();
|
||||
|
||||
// remove job. rather than removing it from the map we put NULL
|
||||
// remove job. rather than removing it from the map we put nullptr
|
||||
// in the list instead so the order of jobs in the list continues
|
||||
// to match the order of jobs in pfds in serviceThread().
|
||||
SocketJobMap::iterator i = m_socketJobMap.find(socket);
|
||||
if (i != m_socketJobMap.end()) {
|
||||
if (*(i->second) != NULL) {
|
||||
if (*(i->second) != nullptr) {
|
||||
delete *(i->second);
|
||||
*(i->second) = NULL;
|
||||
*(i->second) = nullptr;
|
||||
m_update = true;
|
||||
}
|
||||
}
|
||||
@ -158,7 +158,7 @@ void SocketMultiplexer::serviceThread(void *)
|
||||
JobCursor jobCursor = nextCursor(cursor);
|
||||
while (jobCursor != m_socketJobs.end()) {
|
||||
ISocketMultiplexerJob *job = *jobCursor;
|
||||
if (job != NULL) {
|
||||
if (job != nullptr) {
|
||||
pfd.m_socket = job->getSocket();
|
||||
pfd.m_events = 0;
|
||||
if (job->isReadable()) {
|
||||
@ -194,7 +194,7 @@ void SocketMultiplexer::serviceThread(void *)
|
||||
JobCursor cursor = newCursor();
|
||||
JobCursor jobCursor = nextCursor(cursor);
|
||||
while (i < pfds.size() && jobCursor != m_socketJobs.end()) {
|
||||
if (*jobCursor != NULL) {
|
||||
if (*jobCursor != nullptr) {
|
||||
// get poll state
|
||||
unsigned short revents = pfds[i].m_revents;
|
||||
bool read = ((revents & IArchNetwork::kPOLLIN) != 0);
|
||||
@ -223,7 +223,7 @@ void SocketMultiplexer::serviceThread(void *)
|
||||
|
||||
// delete any removed socket jobs
|
||||
for (SocketJobMap::iterator i = m_socketJobMap.begin(); i != m_socketJobMap.end();) {
|
||||
if (*(i->second) == NULL) {
|
||||
if (*(i->second) == nullptr) {
|
||||
m_socketJobs.erase(i->second);
|
||||
m_socketJobMap.erase(i++);
|
||||
m_update = true;
|
||||
@ -296,7 +296,7 @@ void SocketMultiplexer::lockJobList()
|
||||
// take ownership of the lock
|
||||
*m_jobListLock = true;
|
||||
m_jobListLocker = m_jobListLockLocker;
|
||||
m_jobListLockLocker = NULL;
|
||||
m_jobListLockLocker = nullptr;
|
||||
|
||||
// release the lock on the lock
|
||||
*m_jobListLockLocked = false;
|
||||
@ -312,7 +312,7 @@ void SocketMultiplexer::unlockJobList()
|
||||
|
||||
// release the lock
|
||||
delete m_jobListLocker;
|
||||
m_jobListLocker = NULL;
|
||||
m_jobListLocker = nullptr;
|
||||
*m_jobListLock = false;
|
||||
m_jobListLock->signal();
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ TCPListenSocket::TCPListenSocket(
|
||||
TCPListenSocket::~TCPListenSocket()
|
||||
{
|
||||
try {
|
||||
if (m_socket != NULL) {
|
||||
if (m_socket != nullptr) {
|
||||
m_socketMultiplexer->removeSocket(this);
|
||||
ARCH->closeSocket(m_socket);
|
||||
}
|
||||
@ -74,13 +74,13 @@ void TCPListenSocket::bind(const NetworkAddress &addr)
|
||||
void TCPListenSocket::close()
|
||||
{
|
||||
Lock lock(m_mutex);
|
||||
if (m_socket == NULL) {
|
||||
if (m_socket == nullptr) {
|
||||
throw XIOClosed();
|
||||
}
|
||||
try {
|
||||
m_socketMultiplexer->removeSocket(this);
|
||||
ARCH->closeSocket(m_socket);
|
||||
m_socket = NULL;
|
||||
m_socket = nullptr;
|
||||
} catch (XArchNetwork &e) {
|
||||
throw XSocketIOClose(e.what());
|
||||
}
|
||||
@ -93,21 +93,21 @@ void *TCPListenSocket::getEventTarget() const
|
||||
|
||||
IDataSocket *TCPListenSocket::accept()
|
||||
{
|
||||
IDataSocket *socket = NULL;
|
||||
IDataSocket *socket = nullptr;
|
||||
try {
|
||||
socket = new TCPSocket(m_events, m_socketMultiplexer, ARCH->acceptSocket(m_socket, NULL));
|
||||
if (socket != NULL) {
|
||||
socket = new TCPSocket(m_events, m_socketMultiplexer, ARCH->acceptSocket(m_socket, nullptr));
|
||||
if (socket != nullptr) {
|
||||
setListeningJob();
|
||||
}
|
||||
return socket;
|
||||
} catch (XArchNetwork &) {
|
||||
if (socket != NULL) {
|
||||
if (socket != nullptr) {
|
||||
delete socket;
|
||||
setListeningJob();
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} catch (std::exception &ex) {
|
||||
if (socket != NULL) {
|
||||
if (socket != nullptr) {
|
||||
delete socket;
|
||||
setListeningJob();
|
||||
}
|
||||
@ -127,12 +127,12 @@ ISocketMultiplexerJob *TCPListenSocket::serviceListening(ISocketMultiplexerJob *
|
||||
{
|
||||
if (error) {
|
||||
close();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (read) {
|
||||
m_events->addEvent(Event(m_events->forIListenSocket().connecting(), this));
|
||||
// stop polling on this socket until the client accepts
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return job;
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ IDataSocket *TCPSocketFactory::create(IArchNetwork::EAddressFamily family, Secur
|
||||
|
||||
IListenSocket *TCPSocketFactory::createListen(IArchNetwork::EAddressFamily family, SecurityLevel securityLevel) const
|
||||
{
|
||||
IListenSocket *socket = NULL;
|
||||
IListenSocket *socket = nullptr;
|
||||
if (securityLevel != SecurityLevel::PlainText) {
|
||||
socket = new SecureListenSocket(m_events, m_socketMultiplexer, family, securityLevel);
|
||||
} else {
|
||||
|
||||
@ -63,10 +63,10 @@ template <class T> inline TSocketMultiplexerMethodJob<T>::~TSocketMultiplexerMet
|
||||
|
||||
template <class T> inline ISocketMultiplexerJob *TSocketMultiplexerMethodJob<T>::run(bool read, bool write, bool error)
|
||||
{
|
||||
if (m_object != NULL) {
|
||||
if (m_object != nullptr) {
|
||||
return (m_object->*m_method)(this, read, write, error);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <class T> inline ArchSocket TSocketMultiplexerMethodJob<T>::getSocket() const
|
||||
|
||||
@ -68,7 +68,7 @@ void EiEventQueueBuffer::waitForEvent(double timeout_in_ms)
|
||||
std::lock_guard lock(mutex_);
|
||||
|
||||
// libei doesn't allow ei_event_ref() because events are
|
||||
// supposed to be short-lived only. So instead, we create an NULL-data
|
||||
// supposed to be short-lived only. So instead, we create an nullptr-data
|
||||
// kSystemEvent whenever there's data on the fd, shove that event
|
||||
// into our event queue and once we process the event (see
|
||||
// getEvent()), the EiScreen will call ei_dispatch() and process
|
||||
|
||||
@ -107,10 +107,10 @@ KeyID IOSXKeyResource::getKeyID(uint8_t c)
|
||||
// convert to unicode
|
||||
CFStringRef cfString = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, str, encoding, kCFAllocatorNull);
|
||||
|
||||
// sometimes CFStringCreate...() returns NULL (e.g. Apple Korean
|
||||
// sometimes CFStringCreate...() returns nullptr (e.g. Apple Korean
|
||||
// encoding with char value 214). if it did then make no key,
|
||||
// otherwise CFStringCreateMutableCopy() will crash.
|
||||
if (cfString == NULL) {
|
||||
if (cfString == nullptr) {
|
||||
return kKeyNone;
|
||||
}
|
||||
|
||||
|
||||
@ -74,7 +74,7 @@ bool MSWindowsClipboard::empty()
|
||||
|
||||
// mark clipboard as being owned by deskflow
|
||||
HGLOBAL data = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, 1);
|
||||
if (NULL == SetClipboardData(getOwnershipFormat(), data)) {
|
||||
if (nullptr == SetClipboardData(getOwnershipFormat(), data)) {
|
||||
LOG((CLOG_WARN "failed to set clipboard data"));
|
||||
GlobalFree(data);
|
||||
return false;
|
||||
@ -98,7 +98,7 @@ void MSWindowsClipboard::add(EFormat format, const std::string &data)
|
||||
// skip converters for other formats
|
||||
if (converter->getFormat() == format) {
|
||||
HANDLE win32Data = converter->fromIClipboard(data);
|
||||
if (win32Data != NULL) {
|
||||
if (win32Data != nullptr) {
|
||||
LOG((CLOG_DEBUG "add %d bytes to clipboard format: %d", data.size(), format));
|
||||
m_facade->write(win32Data, converter->getWin32Format());
|
||||
isSucceeded = true;
|
||||
@ -155,25 +155,25 @@ bool MSWindowsClipboard::has(EFormat format) const
|
||||
std::string MSWindowsClipboard::get(EFormat format) const
|
||||
{
|
||||
// find the converter for the first clipboard format we can handle
|
||||
IMSWindowsClipboardConverter *converter = NULL;
|
||||
IMSWindowsClipboardConverter *converter = nullptr;
|
||||
for (ConverterList::const_iterator index = m_converters.begin(); index != m_converters.end(); ++index) {
|
||||
|
||||
converter = *index;
|
||||
if (converter->getFormat() == format) {
|
||||
break;
|
||||
}
|
||||
converter = NULL;
|
||||
converter = nullptr;
|
||||
}
|
||||
|
||||
// if no converter then we don't recognize any formats
|
||||
if (converter == NULL) {
|
||||
if (converter == nullptr) {
|
||||
LOG((CLOG_WARN "no converter for format %d", format));
|
||||
return std::string();
|
||||
}
|
||||
|
||||
// get a handle to the clipboard data
|
||||
HANDLE win32Data = GetClipboardData(converter->getWin32Format());
|
||||
if (win32Data == NULL) {
|
||||
if (win32Data == nullptr) {
|
||||
// nb: can't cause this using integ tests; this is only caused when
|
||||
// the selected converter returns an invalid format -- which you
|
||||
// cannot cause using public functions.
|
||||
|
||||
@ -35,15 +35,15 @@ MSWindowsClipboardAnyTextConverter::fromIClipboard(const std::string &data) cons
|
||||
|
||||
// copy to memory handle
|
||||
HGLOBAL gData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, size);
|
||||
if (gData != NULL) {
|
||||
if (gData != nullptr) {
|
||||
// get a pointer to the allocated memory
|
||||
char *dst = (char *)GlobalLock(gData);
|
||||
if (dst != NULL) {
|
||||
if (dst != nullptr) {
|
||||
memcpy(dst, text.data(), size);
|
||||
GlobalUnlock(gData);
|
||||
} else {
|
||||
GlobalFree(gData);
|
||||
gData = NULL;
|
||||
gData = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ std::string MSWindowsClipboardAnyTextConverter::toIClipboard(HANDLE data) const
|
||||
// get datator
|
||||
const char *src = (const char *)GlobalLock(data);
|
||||
uint32_t srcSize = (uint32_t)GlobalSize(data);
|
||||
if (src == NULL || srcSize <= 1) {
|
||||
if (src == nullptr || srcSize <= 1) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
|
||||
@ -38,15 +38,15 @@ MSWindowsClipboardBitmapConverter::fromIClipboard(const std::string &data) const
|
||||
{
|
||||
// copy to memory handle
|
||||
HGLOBAL gData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, data.size());
|
||||
if (gData != NULL) {
|
||||
if (gData != nullptr) {
|
||||
// get a pointer to the allocated memory
|
||||
char *dst = (char *)GlobalLock(gData);
|
||||
if (dst != NULL) {
|
||||
if (dst != nullptr) {
|
||||
memcpy(dst, data.data(), data.size());
|
||||
GlobalUnlock(gData);
|
||||
} else {
|
||||
GlobalFree(gData);
|
||||
gData = NULL;
|
||||
gData = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ std::string MSWindowsClipboardBitmapConverter::toIClipboard(HANDLE data) const
|
||||
{
|
||||
// get datator
|
||||
LPVOID src = GlobalLock(data);
|
||||
if (src == NULL) {
|
||||
if (src == nullptr) {
|
||||
return std::string();
|
||||
}
|
||||
uint32_t srcSize = (uint32_t)GlobalSize(data);
|
||||
@ -94,8 +94,8 @@ std::string MSWindowsClipboardBitmapConverter::toIClipboard(HANDLE data) const
|
||||
info.biYPelsPerMeter = 1000;
|
||||
info.biClrUsed = 0;
|
||||
info.biClrImportant = 0;
|
||||
HDC dc = GetDC(NULL);
|
||||
HBITMAP dst = CreateDIBSection(dc, (BITMAPINFO *)&info, DIB_RGB_COLORS, &raw, NULL, 0);
|
||||
HDC dc = GetDC(nullptr);
|
||||
HBITMAP dst = CreateDIBSection(dc, (BITMAPINFO *)&info, DIB_RGB_COLORS, &raw, nullptr, 0);
|
||||
|
||||
// find the start of the pixel data
|
||||
const char *srcBits = (const char *)bitmap + bitmap->bmiHeader.biSize;
|
||||
@ -125,7 +125,7 @@ std::string MSWindowsClipboardBitmapConverter::toIClipboard(HANDLE data) const
|
||||
|
||||
// clean up GDI
|
||||
DeleteObject(dst);
|
||||
ReleaseDC(NULL, dc);
|
||||
ReleaseDC(nullptr, dc);
|
||||
|
||||
// release handle
|
||||
GlobalUnlock(data);
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
void MSWindowsClipboardFacade::write(HANDLE win32Data, UINT win32Format)
|
||||
{
|
||||
if (SetClipboardData(win32Format, win32Data) == NULL) {
|
||||
if (SetClipboardData(win32Format, win32Data) == nullptr) {
|
||||
// free converted data if we couldn't put it on
|
||||
// the clipboard.
|
||||
// nb: couldn't cause this in integ tests.
|
||||
|
||||
@ -119,10 +119,10 @@ MSWindowsDesks::MSWindowsDesks(
|
||||
m_xCenter(0),
|
||||
m_yCenter(0),
|
||||
m_multimon(false),
|
||||
m_timer(NULL),
|
||||
m_timer(nullptr),
|
||||
m_screensaver(screensaver),
|
||||
m_screensaverNotify(false),
|
||||
m_activeDesk(NULL),
|
||||
m_activeDesk(nullptr),
|
||||
m_activeDeskName(),
|
||||
m_mutex(),
|
||||
m_deskReady(&m_mutex, false),
|
||||
@ -155,7 +155,7 @@ void MSWindowsDesks::enable()
|
||||
// which desk is active and reinstalls the hooks as necessary.
|
||||
// we wouldn't need this if windows notified us of a desktop
|
||||
// change but as far as i can tell it doesn't.
|
||||
m_timer = m_events->newTimer(0.2, NULL);
|
||||
m_timer = m_events->newTimer(0.2, nullptr);
|
||||
m_events->adoptHandler(
|
||||
Event::kTimer, m_timer, new TMethodEventJob<MSWindowsDesks>(this, &MSWindowsDesks::handleCheckDesk)
|
||||
);
|
||||
@ -166,10 +166,10 @@ void MSWindowsDesks::enable()
|
||||
void MSWindowsDesks::disable()
|
||||
{
|
||||
// remove timer
|
||||
if (m_timer != NULL) {
|
||||
if (m_timer != nullptr) {
|
||||
m_events->removeHandler(Event::kTimer, m_timer);
|
||||
m_events->deleteTimer(m_timer);
|
||||
m_timer = NULL;
|
||||
m_timer = nullptr;
|
||||
}
|
||||
|
||||
// destroy desks
|
||||
@ -321,7 +321,7 @@ void MSWindowsDesks::fakeMouseWheel(int32_t xDelta, int32_t yDelta) const
|
||||
|
||||
void MSWindowsDesks::sendMessage(UINT msg, WPARAM wParam, LPARAM lParam) const
|
||||
{
|
||||
if (m_activeDesk != NULL && m_activeDesk->m_window != NULL) {
|
||||
if (m_activeDesk != nullptr && m_activeDesk->m_window != nullptr) {
|
||||
PostThreadMessage(m_activeDesk->m_threadID, msg, wParam, lParam);
|
||||
waitForDesk();
|
||||
}
|
||||
@ -345,7 +345,7 @@ MSWindowsDesks::createBlankCursor() const
|
||||
|
||||
void MSWindowsDesks::destroyCursor(HCURSOR cursor) const
|
||||
{
|
||||
if (cursor != NULL) {
|
||||
if (cursor != nullptr) {
|
||||
DestroyCursor(cursor);
|
||||
}
|
||||
}
|
||||
@ -359,12 +359,12 @@ ATOM MSWindowsDesks::createDeskWindowClass(bool isPrimary) const
|
||||
classInfo.cbClsExtra = 0;
|
||||
classInfo.cbWndExtra = 0;
|
||||
classInfo.hInstance = MSWindowsScreen::getWindowInstance();
|
||||
classInfo.hIcon = NULL;
|
||||
classInfo.hIcon = nullptr;
|
||||
classInfo.hCursor = m_cursor;
|
||||
classInfo.hbrBackground = NULL;
|
||||
classInfo.lpszMenuName = NULL;
|
||||
classInfo.hbrBackground = nullptr;
|
||||
classInfo.lpszMenuName = nullptr;
|
||||
classInfo.lpszClassName = "DeskflowDesk";
|
||||
classInfo.hIconSm = NULL;
|
||||
classInfo.hIconSm = nullptr;
|
||||
return RegisterClassEx(&classInfo);
|
||||
}
|
||||
|
||||
@ -378,10 +378,10 @@ void MSWindowsDesks::destroyClass(ATOM windowClass) const
|
||||
HWND MSWindowsDesks::createWindow(ATOM windowClass, const char *name) const
|
||||
{
|
||||
HWND window = CreateWindowEx(
|
||||
WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW, MAKEINTATOM(windowClass), name, WS_POPUP, 0, 0, 1, 1, NULL, NULL,
|
||||
MSWindowsScreen::getWindowInstance(), NULL
|
||||
WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW, MAKEINTATOM(windowClass), name, WS_POPUP, 0, 0, 1, 1, nullptr, nullptr,
|
||||
MSWindowsScreen::getWindowInstance(), nullptr
|
||||
);
|
||||
if (window == NULL) {
|
||||
if (window == nullptr) {
|
||||
LOG((CLOG_ERR "failed to create window: %d", GetLastError()));
|
||||
throw XScreenOpenFailure();
|
||||
}
|
||||
@ -390,7 +390,7 @@ HWND MSWindowsDesks::createWindow(ATOM windowClass, const char *name) const
|
||||
|
||||
void MSWindowsDesks::destroyWindow(HWND hwnd) const
|
||||
{
|
||||
if (hwnd != NULL) {
|
||||
if (hwnd != nullptr) {
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
}
|
||||
@ -481,13 +481,13 @@ void MSWindowsDesks::deskEnter(Desk *desk)
|
||||
// (mouse over activation) but i've no idea how to do that.
|
||||
// the obvious workaround of using SetWindowPos() to move it back
|
||||
// after being raised doesn't work.
|
||||
DWORD thisThread = GetWindowThreadProcessId(desk->m_window, NULL);
|
||||
DWORD thatThread = GetWindowThreadProcessId(desk->m_foregroundWindow, NULL);
|
||||
DWORD thisThread = GetWindowThreadProcessId(desk->m_window, nullptr);
|
||||
DWORD thatThread = GetWindowThreadProcessId(desk->m_foregroundWindow, nullptr);
|
||||
AttachThreadInput(thatThread, thisThread, TRUE);
|
||||
SetForegroundWindow(desk->m_foregroundWindow);
|
||||
AttachThreadInput(thatThread, thisThread, FALSE);
|
||||
EnableWindow(desk->m_window, desk->m_lowLevel ? FALSE : TRUE);
|
||||
desk->m_foregroundWindow = NULL;
|
||||
desk->m_foregroundWindow = nullptr;
|
||||
}
|
||||
|
||||
void MSWindowsDesks::deskLeave(Desk *desk, HKL keyLayout)
|
||||
@ -537,11 +537,11 @@ void MSWindowsDesks::deskLeave(Desk *desk, HKL keyLayout)
|
||||
// need to disable the window on deskEnter.
|
||||
else {
|
||||
desk->m_foregroundWindow = getForegroundWindow();
|
||||
if (desk->m_foregroundWindow != NULL) {
|
||||
if (desk->m_foregroundWindow != nullptr) {
|
||||
EnableWindow(desk->m_window, TRUE);
|
||||
SetActiveWindow(desk->m_window);
|
||||
DWORD thisThread = GetWindowThreadProcessId(desk->m_window, NULL);
|
||||
DWORD thatThread = GetWindowThreadProcessId(desk->m_foregroundWindow, NULL);
|
||||
DWORD thisThread = GetWindowThreadProcessId(desk->m_window, nullptr);
|
||||
DWORD thatThread = GetWindowThreadProcessId(desk->m_foregroundWindow, nullptr);
|
||||
|
||||
AttachThreadInput(thatThread, thisThread, TRUE);
|
||||
SetForegroundWindow(desk->m_window);
|
||||
@ -571,11 +571,11 @@ void MSWindowsDesks::deskThread(void *vdesk)
|
||||
// use given desktop for this thread
|
||||
Desk *desk = static_cast<Desk *>(vdesk);
|
||||
desk->m_threadID = GetCurrentThreadId();
|
||||
desk->m_window = NULL;
|
||||
desk->m_foregroundWindow = NULL;
|
||||
if (desk->m_desk != NULL && SetThreadDesktop(desk->m_desk) != 0) {
|
||||
desk->m_window = nullptr;
|
||||
desk->m_foregroundWindow = nullptr;
|
||||
if (desk->m_desk != nullptr && SetThreadDesktop(desk->m_desk) != 0) {
|
||||
// create a message queue
|
||||
PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
|
||||
PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE);
|
||||
|
||||
// create a window. we use this window to hide the cursor.
|
||||
try {
|
||||
@ -594,7 +594,7 @@ void MSWindowsDesks::deskThread(void *vdesk)
|
||||
m_deskReady.broadcast();
|
||||
}
|
||||
|
||||
while (GetMessage(&msg, NULL, 0, 0)) {
|
||||
while (GetMessage(&msg, nullptr, 0, 0)) {
|
||||
switch (msg.message) {
|
||||
default:
|
||||
TranslateMessage(&msg);
|
||||
@ -705,10 +705,10 @@ void MSWindowsDesks::deskThread(void *vdesk)
|
||||
|
||||
// clean up
|
||||
deskEnter(desk);
|
||||
if (desk->m_window != NULL) {
|
||||
if (desk->m_window != nullptr) {
|
||||
DestroyWindow(desk->m_window);
|
||||
}
|
||||
if (desk->m_desk != NULL) {
|
||||
if (desk->m_desk != nullptr) {
|
||||
closeDesktop(desk->m_desk);
|
||||
}
|
||||
}
|
||||
@ -735,7 +735,7 @@ void MSWindowsDesks::removeDesks()
|
||||
delete desk;
|
||||
}
|
||||
m_desks.clear();
|
||||
m_activeDesk = NULL;
|
||||
m_activeDesk = nullptr;
|
||||
m_activeDeskName = "";
|
||||
}
|
||||
|
||||
@ -805,7 +805,7 @@ void MSWindowsDesks::checkDesk()
|
||||
|
||||
bool MSWindowsDesks::isDeskAccessible(const Desk *desk) const
|
||||
{
|
||||
return (desk != NULL && desk->m_desk != NULL);
|
||||
return (desk != nullptr && desk->m_desk != nullptr);
|
||||
}
|
||||
|
||||
void MSWindowsDesks::waitForDesk() const
|
||||
@ -840,18 +840,18 @@ MSWindowsDesks::openInputDesktop()
|
||||
|
||||
void MSWindowsDesks::closeDesktop(HDESK desk)
|
||||
{
|
||||
if (desk != NULL) {
|
||||
if (desk != nullptr) {
|
||||
CloseDesktop(desk);
|
||||
}
|
||||
}
|
||||
|
||||
std::string MSWindowsDesks::getDesktopName(HDESK desk)
|
||||
{
|
||||
if (desk == NULL) {
|
||||
if (desk == nullptr) {
|
||||
return std::string();
|
||||
} else {
|
||||
DWORD size;
|
||||
GetUserObjectInformation(desk, UOI_NAME, NULL, 0, &size);
|
||||
GetUserObjectInformation(desk, UOI_NAME, nullptr, 0, &size);
|
||||
TCHAR *name = (TCHAR *)alloca(size + sizeof(TCHAR));
|
||||
GetUserObjectInformation(desk, UOI_NAME, name, size, &size);
|
||||
std::string result(name);
|
||||
@ -861,12 +861,12 @@ std::string MSWindowsDesks::getDesktopName(HDESK desk)
|
||||
|
||||
HWND MSWindowsDesks::getForegroundWindow() const
|
||||
{
|
||||
// Ideally we'd return NULL as much as possible, only returning
|
||||
// Ideally we'd return nullptr as much as possible, only returning
|
||||
// the actual foreground window when we know it's going to mess
|
||||
// up our keyboard input. For now we'll just let the user
|
||||
// decide.
|
||||
if (m_leaveForegroundOption) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return GetForegroundWindow();
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
void getDropData(IDataObject *pDataObject);
|
||||
|
||||
MSWindowsDropTarget *MSWindowsDropTarget::s_instance = NULL;
|
||||
MSWindowsDropTarget *MSWindowsDropTarget::s_instance = nullptr;
|
||||
|
||||
MSWindowsDropTarget::MSWindowsDropTarget() : m_refCount(1), m_allowDrop(false)
|
||||
{
|
||||
@ -27,7 +27,7 @@ MSWindowsDropTarget::~MSWindowsDropTarget()
|
||||
|
||||
MSWindowsDropTarget &MSWindowsDropTarget::instance()
|
||||
{
|
||||
assert(s_instance != NULL);
|
||||
assert(s_instance != nullptr);
|
||||
return *s_instance;
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ MSWindowsEventQueueBuffer::MSWindowsEventQueueBuffer(IEventQueue *events) : m_ev
|
||||
|
||||
// make sure this thread has a message queue
|
||||
MSG dummy;
|
||||
PeekMessage(&dummy, NULL, WM_USER, WM_USER, PM_NOREMOVE);
|
||||
PeekMessage(&dummy, nullptr, WM_USER, WM_USER, PM_NOREMOVE);
|
||||
}
|
||||
|
||||
MSWindowsEventQueueBuffer::~MSWindowsEventQueueBuffer()
|
||||
@ -77,12 +77,12 @@ IEventQueueBuffer::Type MSWindowsEventQueueBuffer::getEvent(Event &event, uint32
|
||||
// if a message has been sent to our window but GetMessage will
|
||||
// dispatch that message behind our backs and block. PeekMessage
|
||||
// will also dispatch behind our backs but won't block.
|
||||
if (!PeekMessage(&m_event, NULL, 0, 0, PM_NOREMOVE) && !PeekMessage(&m_event, (HWND)-1, 0, 0, PM_NOREMOVE)) {
|
||||
if (!PeekMessage(&m_event, nullptr, 0, 0, PM_NOREMOVE) && !PeekMessage(&m_event, (HWND)-1, 0, 0, PM_NOREMOVE)) {
|
||||
return kNone;
|
||||
}
|
||||
|
||||
// BOOL. yeah, right.
|
||||
BOOL result = GetMessage(&m_event, NULL, 0, 0);
|
||||
BOOL result = GetMessage(&m_event, nullptr, 0, 0);
|
||||
if (result == -1) {
|
||||
return kNone;
|
||||
} else if (result == 0) {
|
||||
|
||||
@ -14,9 +14,9 @@ static const char *g_name = "dfwhook";
|
||||
|
||||
static DWORD g_processID = 0;
|
||||
static DWORD g_threadID = 0;
|
||||
static HHOOK g_getMessage = NULL;
|
||||
static HHOOK g_keyboardLL = NULL;
|
||||
static HHOOK g_mouseLL = NULL;
|
||||
static HHOOK g_getMessage = nullptr;
|
||||
static HHOOK g_keyboardLL = nullptr;
|
||||
static HHOOK g_mouseLL = nullptr;
|
||||
static bool g_screenSaver = false;
|
||||
static EHookMode g_mode = kHOOK_DISABLE;
|
||||
static uint32_t g_zoneSides = 0;
|
||||
@ -69,7 +69,7 @@ int MSWindowsHook::init(DWORD threadID)
|
||||
// still running or if it died without cleaning up.
|
||||
if (g_processID != 0 && g_processID != GetCurrentProcessId()) {
|
||||
HANDLE process = OpenProcess(STANDARD_RIGHTS_REQUIRED, FALSE, g_processID);
|
||||
if (process != NULL) {
|
||||
if (process != nullptr) {
|
||||
// old process (probably) still exists so refuse to
|
||||
// reinitialize this DLL (and thus steal it from the
|
||||
// old process).
|
||||
@ -83,9 +83,9 @@ int MSWindowsHook::init(DWORD threadID)
|
||||
// removed the hooks so we just need to reset our state.
|
||||
g_processID = GetCurrentProcessId();
|
||||
g_threadID = 0;
|
||||
g_getMessage = NULL;
|
||||
g_keyboardLL = NULL;
|
||||
g_mouseLL = NULL;
|
||||
g_getMessage = nullptr;
|
||||
g_keyboardLL = nullptr;
|
||||
g_mouseLL = nullptr;
|
||||
g_screenSaver = false;
|
||||
}
|
||||
|
||||
@ -589,7 +589,7 @@ static LRESULT CALLBACK mouseLLHook(int code, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
EHookResult MSWindowsHook::install()
|
||||
{
|
||||
assert(g_getMessage == NULL || g_screenSaver);
|
||||
assert(g_getMessage == nullptr || g_screenSaver);
|
||||
|
||||
// must be initialized
|
||||
if (g_threadID == 0) {
|
||||
@ -604,32 +604,32 @@ EHookResult MSWindowsHook::install()
|
||||
g_fakeServerInput = false;
|
||||
|
||||
// install low-level hooks. we require that they both get installed.
|
||||
g_mouseLL = SetWindowsHookEx(WH_MOUSE_LL, &mouseLLHook, NULL, 0);
|
||||
g_mouseLL = SetWindowsHookEx(WH_MOUSE_LL, &mouseLLHook, nullptr, 0);
|
||||
#if !NO_GRAB_KEYBOARD
|
||||
g_keyboardLL = SetWindowsHookEx(WH_KEYBOARD_LL, &keyboardLLHook, NULL, 0);
|
||||
if (g_mouseLL == NULL || g_keyboardLL == NULL) {
|
||||
if (g_keyboardLL != NULL) {
|
||||
g_keyboardLL = SetWindowsHookEx(WH_KEYBOARD_LL, &keyboardLLHook, nullptr, 0);
|
||||
if (g_mouseLL == nullptr || g_keyboardLL == nullptr) {
|
||||
if (g_keyboardLL != nullptr) {
|
||||
UnhookWindowsHookEx(g_keyboardLL);
|
||||
g_keyboardLL = NULL;
|
||||
g_keyboardLL = nullptr;
|
||||
}
|
||||
if (g_mouseLL != NULL) {
|
||||
if (g_mouseLL != nullptr) {
|
||||
UnhookWindowsHookEx(g_mouseLL);
|
||||
g_mouseLL = NULL;
|
||||
g_mouseLL = nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// check that we got all the hooks we wanted
|
||||
if ((g_mouseLL == NULL) ||
|
||||
if ((g_mouseLL == nullptr) ||
|
||||
#if !NO_GRAB_KEYBOARD
|
||||
(g_keyboardLL == NULL)
|
||||
(g_keyboardLL == nullptr)
|
||||
#endif
|
||||
) {
|
||||
uninstall();
|
||||
return kHOOK_FAILED;
|
||||
}
|
||||
|
||||
if (g_keyboardLL != NULL || g_mouseLL != NULL) {
|
||||
if (g_keyboardLL != nullptr || g_mouseLL != nullptr) {
|
||||
g_hookThread = GetCurrentThreadId();
|
||||
return kHOOK_OKAY_LL;
|
||||
}
|
||||
@ -644,17 +644,17 @@ int MSWindowsHook::uninstall()
|
||||
g_deadLParam = 0;
|
||||
|
||||
// uninstall hooks
|
||||
if (g_keyboardLL != NULL) {
|
||||
if (g_keyboardLL != nullptr) {
|
||||
UnhookWindowsHookEx(g_keyboardLL);
|
||||
g_keyboardLL = NULL;
|
||||
g_keyboardLL = nullptr;
|
||||
}
|
||||
if (g_mouseLL != NULL) {
|
||||
if (g_mouseLL != nullptr) {
|
||||
UnhookWindowsHookEx(g_mouseLL);
|
||||
g_mouseLL = NULL;
|
||||
g_mouseLL = nullptr;
|
||||
}
|
||||
if (g_getMessage != NULL && !g_screenSaver) {
|
||||
if (g_getMessage != nullptr && !g_screenSaver) {
|
||||
UnhookWindowsHookEx(g_getMessage);
|
||||
g_getMessage = NULL;
|
||||
g_getMessage = nullptr;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -686,19 +686,19 @@ int MSWindowsHook::installScreenSaver()
|
||||
g_screenSaver = true;
|
||||
|
||||
// install hook unless it's already installed
|
||||
if (g_getMessage == NULL) {
|
||||
g_getMessage = SetWindowsHookEx(WH_GETMESSAGE, &getMessageHook, NULL, 0);
|
||||
if (g_getMessage == nullptr) {
|
||||
g_getMessage = SetWindowsHookEx(WH_GETMESSAGE, &getMessageHook, nullptr, 0);
|
||||
}
|
||||
|
||||
return (g_getMessage != NULL) ? 1 : 0;
|
||||
return (g_getMessage != nullptr) ? 1 : 0;
|
||||
}
|
||||
|
||||
int MSWindowsHook::uninstallScreenSaver()
|
||||
{
|
||||
// uninstall hook unless the mouse wheel hook is installed
|
||||
if (g_getMessage != NULL) {
|
||||
if (g_getMessage != nullptr) {
|
||||
UnhookWindowsHookEx(g_getMessage);
|
||||
g_getMessage = NULL;
|
||||
g_getMessage = nullptr;
|
||||
}
|
||||
|
||||
// screen saver hook is no longer installed
|
||||
|
||||
@ -562,7 +562,7 @@ MSWindowsKeyState::MSWindowsKeyState(
|
||||
m_eventTarget(eventTarget),
|
||||
m_desks(desks),
|
||||
m_keyLayout(GetKeyboardLayout(0)),
|
||||
m_fixTimer(NULL),
|
||||
m_fixTimer(nullptr),
|
||||
m_lastDown(0),
|
||||
m_useSavedModifiers(false),
|
||||
m_savedModifiers(0),
|
||||
@ -580,7 +580,7 @@ MSWindowsKeyState::MSWindowsKeyState(
|
||||
m_eventTarget(eventTarget),
|
||||
m_desks(desks),
|
||||
m_keyLayout(GetKeyboardLayout(0)),
|
||||
m_fixTimer(NULL),
|
||||
m_fixTimer(nullptr),
|
||||
m_lastDown(0),
|
||||
m_useSavedModifiers(false),
|
||||
m_savedModifiers(0),
|
||||
@ -604,10 +604,10 @@ void MSWindowsKeyState::init()
|
||||
|
||||
void MSWindowsKeyState::disable()
|
||||
{
|
||||
if (m_fixTimer != NULL) {
|
||||
if (m_fixTimer != nullptr) {
|
||||
m_events->removeHandler(Event::kTimer, m_fixTimer);
|
||||
m_events->deleteTimer(m_fixTimer);
|
||||
m_fixTimer = NULL;
|
||||
m_fixTimer = nullptr;
|
||||
}
|
||||
m_lastDown = 0;
|
||||
}
|
||||
@ -672,7 +672,7 @@ KeyID MSWindowsKeyState::mapKeyFromEvent(WPARAM charAndVirtKey, LPARAM info, Key
|
||||
}
|
||||
|
||||
// set modifier mask
|
||||
if (maskOut != NULL) {
|
||||
if (maskOut != nullptr) {
|
||||
KeyModifierMask active = getActiveModifiers();
|
||||
if (!noAltGr && (active & s_controlAlt) == s_controlAlt) {
|
||||
// if !noAltGr then we're only interested in matching the
|
||||
@ -813,7 +813,7 @@ int32_t MSWindowsKeyState::pollActiveGroup() const
|
||||
{
|
||||
// determine the thread that'll receive this event
|
||||
HWND targetWindow = GetForegroundWindow();
|
||||
DWORD targetThread = GetWindowThreadProcessId(targetWindow, NULL);
|
||||
DWORD targetThread = GetWindowThreadProcessId(targetWindow, nullptr);
|
||||
|
||||
// get keyboard layout for the thread
|
||||
HKL hkl = GetKeyboardLayout(targetThread);
|
||||
@ -822,7 +822,7 @@ int32_t MSWindowsKeyState::pollActiveGroup() const
|
||||
// GetKeyboardLayout failed. Maybe targetWindow is a console window.
|
||||
// We're getting the keyboard layout of the desktop instead.
|
||||
targetWindow = GetDesktopWindow();
|
||||
targetThread = GetWindowThreadProcessId(targetWindow, NULL);
|
||||
targetThread = GetWindowThreadProcessId(targetWindow, nullptr);
|
||||
hkl = GetKeyboardLayout(targetThread);
|
||||
}
|
||||
|
||||
@ -1225,7 +1225,7 @@ KeyModifierMask &MSWindowsKeyState::getActiveModifiersRValue()
|
||||
bool MSWindowsKeyState::getGroups(GroupList &groups) const
|
||||
{
|
||||
// get keyboard layouts
|
||||
uint32_t newNumLayouts = GetKeyboardLayoutList(0, NULL);
|
||||
uint32_t newNumLayouts = GetKeyboardLayoutList(0, nullptr);
|
||||
if (newNumLayouts == 0) {
|
||||
LOG((CLOG_DEBUG1 "can't get keyboard layouts"));
|
||||
return false;
|
||||
|
||||
@ -216,7 +216,7 @@ private:
|
||||
KeyModifierMask m_savedModifiers;
|
||||
KeyModifierMask m_originalSavedModifiers;
|
||||
|
||||
// pointer to ToUnicodeEx. on win95 family this will be NULL.
|
||||
// pointer to ToUnicodeEx. on win95 family this will be nullptr.
|
||||
typedef int(WINAPI *ToUnicodeEx_t)(
|
||||
UINT wVirtKey, UINT wScanCode, PBYTE lpKeyState, LPWSTR pwszBuff, int cchBuff, UINT wFlags, HKL dwhkl
|
||||
);
|
||||
|
||||
@ -78,8 +78,8 @@
|
||||
// MSWindowsScreen
|
||||
//
|
||||
|
||||
HINSTANCE MSWindowsScreen::s_windowInstance = NULL;
|
||||
MSWindowsScreen *MSWindowsScreen::s_screen = NULL;
|
||||
HINSTANCE MSWindowsScreen::s_windowInstance = nullptr;
|
||||
MSWindowsScreen *MSWindowsScreen::s_screen = nullptr;
|
||||
|
||||
MSWindowsScreen::MSWindowsScreen(
|
||||
bool isPrimary, bool noHooks, IEventQueue *events, bool enableLangSync,
|
||||
@ -102,24 +102,24 @@ MSWindowsScreen::MSWindowsScreen(
|
||||
m_sequenceNumber(0),
|
||||
m_mark(0),
|
||||
m_markReceived(0),
|
||||
m_fixTimer(NULL),
|
||||
m_keyLayout(NULL),
|
||||
m_screensaver(NULL),
|
||||
m_fixTimer(nullptr),
|
||||
m_keyLayout(nullptr),
|
||||
m_screensaver(nullptr),
|
||||
m_screensaverNotify(false),
|
||||
m_screensaverActive(false),
|
||||
m_window(NULL),
|
||||
m_window(nullptr),
|
||||
m_clipboardSequenceNumber(0),
|
||||
m_ownClipboard(false),
|
||||
m_desks(NULL),
|
||||
m_keyState(NULL),
|
||||
m_desks(nullptr),
|
||||
m_keyState(nullptr),
|
||||
m_hasMouse(GetSystemMetrics(SM_MOUSEPRESENT) != 0),
|
||||
m_showingMouse(false),
|
||||
m_events(events),
|
||||
m_dropWindow(NULL),
|
||||
m_dropWindow(nullptr),
|
||||
m_dropWindowSize(20)
|
||||
{
|
||||
assert(s_windowInstance != NULL);
|
||||
assert(s_screen == NULL);
|
||||
assert(s_windowInstance != nullptr);
|
||||
assert(s_screen == nullptr);
|
||||
|
||||
s_screen = this;
|
||||
try {
|
||||
@ -145,7 +145,7 @@ MSWindowsScreen::MSWindowsScreen(
|
||||
|
||||
// SHGetFolderPath is deprecated in vista, but use it for xp support.
|
||||
char desktopPath[MAX_PATH];
|
||||
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, 0, desktopPath))) {
|
||||
if (SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_DESKTOP, nullptr, 0, desktopPath))) {
|
||||
m_desktopPath = std::string(desktopPath);
|
||||
LOG((CLOG_DEBUG "using desktop for file drag-drop target: %s", m_desktopPath.c_str()));
|
||||
} else {
|
||||
@ -166,7 +166,7 @@ MSWindowsScreen::MSWindowsScreen(
|
||||
delete m_screensaver;
|
||||
destroyWindow(m_window);
|
||||
destroyClass(m_class);
|
||||
s_screen = NULL;
|
||||
s_screen = nullptr;
|
||||
throw;
|
||||
}
|
||||
|
||||
@ -182,10 +182,10 @@ MSWindowsScreen::MSWindowsScreen(
|
||||
|
||||
MSWindowsScreen::~MSWindowsScreen()
|
||||
{
|
||||
assert(s_screen != NULL);
|
||||
assert(s_screen != nullptr);
|
||||
|
||||
disable();
|
||||
m_events->adoptBuffer(NULL);
|
||||
m_events->adoptBuffer(nullptr);
|
||||
m_events->removeHandler(Event::kSystem, m_events->getSystemTarget());
|
||||
delete m_keyState;
|
||||
delete m_desks;
|
||||
@ -198,13 +198,13 @@ MSWindowsScreen::~MSWindowsScreen()
|
||||
OleUninitialize();
|
||||
destroyWindow(m_dropWindow);
|
||||
|
||||
s_screen = NULL;
|
||||
s_screen = nullptr;
|
||||
}
|
||||
|
||||
void MSWindowsScreen::init(HINSTANCE windowInstance)
|
||||
{
|
||||
assert(s_windowInstance == NULL);
|
||||
assert(windowInstance != NULL);
|
||||
assert(s_windowInstance == nullptr);
|
||||
assert(windowInstance != nullptr);
|
||||
|
||||
s_windowInstance = windowInstance;
|
||||
}
|
||||
@ -220,7 +220,7 @@ void MSWindowsScreen::enable()
|
||||
assert(m_isOnScreen == m_isPrimary);
|
||||
|
||||
// we need to poll some things to fix them
|
||||
m_fixTimer = m_events->newTimer(1.0, NULL);
|
||||
m_fixTimer = m_events->newTimer(1.0, nullptr);
|
||||
m_events->adoptHandler(
|
||||
Event::kTimer, m_fixTimer, new TMethodEventJob<MSWindowsScreen>(this, &MSWindowsScreen::handleFixes)
|
||||
);
|
||||
@ -264,10 +264,10 @@ void MSWindowsScreen::disable()
|
||||
}
|
||||
|
||||
// uninstall fix timer
|
||||
if (m_fixTimer != NULL) {
|
||||
if (m_fixTimer != nullptr) {
|
||||
m_events->removeHandler(Event::kTimer, m_fixTimer);
|
||||
m_events->deleteTimer(m_fixTimer);
|
||||
m_fixTimer = NULL;
|
||||
m_fixTimer = nullptr;
|
||||
}
|
||||
|
||||
m_isOnScreen = m_isPrimary;
|
||||
@ -293,7 +293,7 @@ void MSWindowsScreen::enter()
|
||||
// and that the screen is not in powersave mode.
|
||||
ArchMiscWindows::wakeupDisplay();
|
||||
|
||||
if (m_screensaver != NULL && m_screensaverActive) {
|
||||
if (m_screensaver != nullptr && m_screensaverActive) {
|
||||
m_screensaver->deactivate();
|
||||
m_screensaverActive = 0;
|
||||
}
|
||||
@ -386,7 +386,7 @@ void MSWindowsScreen::sendDragThread(void *)
|
||||
bool MSWindowsScreen::setClipboard(ClipboardID, const IClipboard *src)
|
||||
{
|
||||
MSWindowsClipboard dst(m_window);
|
||||
if (src != NULL) {
|
||||
if (src != nullptr) {
|
||||
// save clipboard data
|
||||
return Clipboard::copy(&dst, src);
|
||||
} else {
|
||||
@ -423,7 +423,7 @@ void MSWindowsScreen::checkClipboards()
|
||||
|
||||
void MSWindowsScreen::openScreensaver(bool notify)
|
||||
{
|
||||
assert(m_screensaver != NULL);
|
||||
assert(m_screensaver != nullptr);
|
||||
|
||||
m_screensaverNotify = notify;
|
||||
if (m_screensaverNotify) {
|
||||
@ -435,7 +435,7 @@ void MSWindowsScreen::openScreensaver(bool notify)
|
||||
|
||||
void MSWindowsScreen::closeScreensaver()
|
||||
{
|
||||
if (m_screensaver != NULL) {
|
||||
if (m_screensaver != nullptr) {
|
||||
if (m_screensaverNotify) {
|
||||
m_desks->installScreensaverHooks(false);
|
||||
} else {
|
||||
@ -447,8 +447,8 @@ void MSWindowsScreen::closeScreensaver()
|
||||
|
||||
void MSWindowsScreen::screensaver(bool activate)
|
||||
{
|
||||
assert(m_screensaver != NULL);
|
||||
if (m_screensaver == NULL)
|
||||
assert(m_screensaver != nullptr);
|
||||
if (m_screensaver == nullptr)
|
||||
return;
|
||||
|
||||
if (activate) {
|
||||
@ -557,7 +557,7 @@ void MSWindowsScreen::updateDesktopThread()
|
||||
LOG_DEBUG("updating desktop thread");
|
||||
|
||||
HDESK hDesk = OpenInputDesktop(0, true, GENERIC_ALL);
|
||||
if (hDesk == NULL) {
|
||||
if (hDesk == nullptr) {
|
||||
XArchEvalWindows error1;
|
||||
LOG_DEBUG("could not open input desktop, error: %s", error1.eval().c_str());
|
||||
return;
|
||||
@ -589,7 +589,7 @@ void MSWindowsScreen::warpCursor(int32_t x, int32_t y)
|
||||
|
||||
// remove all input events before and including warp
|
||||
MSG msg;
|
||||
while (PeekMessage(&msg, NULL, DESKFLOW_MSG_INPUT_FIRST, DESKFLOW_MSG_INPUT_LAST, PM_REMOVE)) {
|
||||
while (PeekMessage(&msg, nullptr, DESKFLOW_MSG_INPUT_FIRST, DESKFLOW_MSG_INPUT_LAST, PM_REMOVE)) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@ -660,7 +660,7 @@ uint32_t MSWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask)
|
||||
err = (m_hotKeyToIDMap.count(HotKeyItem(vk, modifiers)) > 0);
|
||||
} else {
|
||||
// register with OS
|
||||
err = (RegisterHotKey(NULL, id, modifiers, vk) == 0);
|
||||
err = (RegisterHotKey(nullptr, id, modifiers, vk) == 0);
|
||||
}
|
||||
|
||||
if (!err) {
|
||||
@ -694,7 +694,7 @@ void MSWindowsScreen::unregisterHotKey(uint32_t id)
|
||||
// unregister with OS
|
||||
bool err;
|
||||
if (i->second.getVirtualKey() != 0) {
|
||||
err = !UnregisterHotKey(NULL, id);
|
||||
err = !UnregisterHotKey(nullptr, id);
|
||||
} else {
|
||||
err = false;
|
||||
}
|
||||
@ -844,7 +844,7 @@ MSWindowsScreen::createBlankCursor() const
|
||||
|
||||
void MSWindowsScreen::destroyCursor(HCURSOR cursor) const
|
||||
{
|
||||
if (cursor != NULL) {
|
||||
if (cursor != nullptr) {
|
||||
DestroyCursor(cursor);
|
||||
}
|
||||
}
|
||||
@ -858,12 +858,12 @@ ATOM MSWindowsScreen::createWindowClass() const
|
||||
classInfo.cbClsExtra = 0;
|
||||
classInfo.cbWndExtra = 0;
|
||||
classInfo.hInstance = s_windowInstance;
|
||||
classInfo.hIcon = NULL;
|
||||
classInfo.hCursor = NULL;
|
||||
classInfo.hbrBackground = NULL;
|
||||
classInfo.lpszMenuName = NULL;
|
||||
classInfo.hIcon = nullptr;
|
||||
classInfo.hCursor = nullptr;
|
||||
classInfo.hbrBackground = nullptr;
|
||||
classInfo.lpszMenuName = nullptr;
|
||||
classInfo.lpszClassName = kAppName;
|
||||
classInfo.hIconSm = NULL;
|
||||
classInfo.hIconSm = nullptr;
|
||||
return RegisterClassEx(&classInfo);
|
||||
}
|
||||
|
||||
@ -877,10 +877,10 @@ void MSWindowsScreen::destroyClass(ATOM windowClass) const
|
||||
HWND MSWindowsScreen::createWindow(ATOM windowClass, const char *name) const
|
||||
{
|
||||
HWND window = CreateWindowEx(
|
||||
WS_EX_TOPMOST | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW, MAKEINTATOM(windowClass), name, WS_POPUP, 0, 0, 1, 1, NULL,
|
||||
NULL, s_windowInstance, NULL
|
||||
WS_EX_TOPMOST | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW, MAKEINTATOM(windowClass), name, WS_POPUP, 0, 0, 1, 1,
|
||||
nullptr, nullptr, s_windowInstance, nullptr
|
||||
);
|
||||
if (window == NULL) {
|
||||
if (window == nullptr) {
|
||||
LOG((CLOG_ERR "failed to create window: %d", GetLastError()));
|
||||
throw XScreenOpenFailure();
|
||||
}
|
||||
@ -891,10 +891,10 @@ HWND MSWindowsScreen::createDropWindow(ATOM windowClass, const char *name) const
|
||||
{
|
||||
HWND window = CreateWindowEx(
|
||||
WS_EX_TOPMOST | WS_EX_TRANSPARENT | WS_EX_ACCEPTFILES, MAKEINTATOM(m_class), name, WS_POPUP, 0, 0,
|
||||
m_dropWindowSize, m_dropWindowSize, NULL, NULL, s_windowInstance, NULL
|
||||
m_dropWindowSize, m_dropWindowSize, nullptr, nullptr, s_windowInstance, nullptr
|
||||
);
|
||||
|
||||
if (window == NULL) {
|
||||
if (window == nullptr) {
|
||||
LOG((CLOG_ERR "failed to create drop window: %d", GetLastError()));
|
||||
throw XScreenOpenFailure();
|
||||
}
|
||||
@ -904,7 +904,7 @@ HWND MSWindowsScreen::createDropWindow(ATOM windowClass, const char *name) const
|
||||
|
||||
void MSWindowsScreen::destroyWindow(HWND hwnd) const
|
||||
{
|
||||
if (hwnd != NULL) {
|
||||
if (hwnd != nullptr) {
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
}
|
||||
@ -917,7 +917,7 @@ void MSWindowsScreen::sendEvent(Event::Type type, void *data)
|
||||
void MSWindowsScreen::sendClipboardEvent(Event::Type type, ClipboardID id)
|
||||
{
|
||||
ClipboardInfo *info = (ClipboardInfo *)malloc(sizeof(ClipboardInfo));
|
||||
if (info == NULL) {
|
||||
if (info == nullptr) {
|
||||
LOG((CLOG_ERR "malloc failed on %s:%s", __FILE__, __LINE__));
|
||||
return;
|
||||
}
|
||||
@ -929,7 +929,7 @@ void MSWindowsScreen::sendClipboardEvent(Event::Type type, ClipboardID id)
|
||||
void MSWindowsScreen::handleSystemEvent(const Event &event, void *)
|
||||
{
|
||||
MSG *msg = static_cast<MSG *>(event.getData());
|
||||
assert(msg != NULL);
|
||||
assert(msg != nullptr);
|
||||
|
||||
if (onPreDispatch(msg->hwnd, msg->message, msg->wParam, msg->lParam)) {
|
||||
return;
|
||||
@ -1006,7 +1006,7 @@ bool MSWindowsScreen::onPreDispatchPrimary(HWND, UINT message, WPARAM wParam, LP
|
||||
// event.
|
||||
MSG msg;
|
||||
do {
|
||||
GetMessage(&msg, NULL, DESKFLOW_MSG_MOUSE_MOVE, DESKFLOW_MSG_POST_WARP);
|
||||
GetMessage(&msg, nullptr, DESKFLOW_MSG_MOUSE_MOVE, DESKFLOW_MSG_POST_WARP);
|
||||
} while (msg.message != DESKFLOW_MSG_POST_WARP);
|
||||
}
|
||||
return true;
|
||||
@ -1050,7 +1050,7 @@ bool MSWindowsScreen::onEvent(HWND, UINT msg, WPARAM wParam, LPARAM lParam, LRES
|
||||
/* On windows 10 we don't receive WM_POWERBROADCAST after sleep.
|
||||
We receive only WM_TIMECHANGE hence this message is used to resume.*/
|
||||
case WM_TIMECHANGE:
|
||||
m_events->addEvent(Event(m_events->forIScreen().resume(), getEventTarget(), NULL, Event::kDeliverImmediately));
|
||||
m_events->addEvent(Event(m_events->forIScreen().resume(), getEventTarget(), nullptr, Event::kDeliverImmediately));
|
||||
break;
|
||||
|
||||
case WM_POWERBROADCAST:
|
||||
@ -1058,11 +1058,12 @@ bool MSWindowsScreen::onEvent(HWND, UINT msg, WPARAM wParam, LPARAM lParam, LRES
|
||||
case PBT_APMRESUMEAUTOMATIC:
|
||||
case PBT_APMRESUMECRITICAL:
|
||||
case PBT_APMRESUMESUSPEND:
|
||||
m_events->addEvent(Event(m_events->forIScreen().resume(), getEventTarget(), NULL, Event::kDeliverImmediately));
|
||||
m_events->addEvent(Event(m_events->forIScreen().resume(), getEventTarget(), nullptr, Event::kDeliverImmediately));
|
||||
break;
|
||||
|
||||
case PBT_APMSUSPEND:
|
||||
m_events->addEvent(Event(m_events->forIScreen().suspend(), getEventTarget(), NULL, Event::kDeliverImmediately));
|
||||
m_events->addEvent(Event(m_events->forIScreen().suspend(), getEventTarget(), nullptr, Event::kDeliverImmediately)
|
||||
);
|
||||
break;
|
||||
}
|
||||
*result = TRUE;
|
||||
@ -1383,7 +1384,7 @@ bool MSWindowsScreen::onScreensaver(bool activated)
|
||||
// send SC_SCREENSAVE until the screen saver starts, even if
|
||||
// the screen saver is disabled!
|
||||
MSG msg;
|
||||
if (PeekMessage(&msg, NULL, DESKFLOW_MSG_SCREEN_SAVER, DESKFLOW_MSG_SCREEN_SAVER, PM_NOREMOVE)) {
|
||||
if (PeekMessage(&msg, nullptr, DESKFLOW_MSG_SCREEN_SAVER, DESKFLOW_MSG_SCREEN_SAVER, PM_NOREMOVE)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1553,12 +1554,12 @@ void MSWindowsScreen::fixClipboardViewer()
|
||||
// recursion in the WM_DRAWCLIPBOARD handler. either we're sending
|
||||
// the message to our own window or some window farther down the chain
|
||||
// forwards the message to our window or a window farther up the chain.
|
||||
// i'm not sure how that could happen. the m_nextClipboardWindow = NULL
|
||||
// i'm not sure how that could happen. the m_nextClipboardWindow = nullptr
|
||||
// was not in the code that infinite loops and may fix the bug but i
|
||||
// doubt it.
|
||||
/*
|
||||
ChangeClipboardChain(m_window, m_nextClipboardWindow);
|
||||
m_nextClipboardWindow = NULL;
|
||||
m_nextClipboardWindow = nullptr;
|
||||
m_nextClipboardWindow = SetClipboardViewer(m_window);
|
||||
*/
|
||||
}
|
||||
@ -1735,7 +1736,7 @@ void MSWindowsScreen::updateForceShowCursor()
|
||||
|
||||
LRESULT CALLBACK MSWindowsScreen::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
assert(s_screen != NULL);
|
||||
assert(s_screen != nullptr);
|
||||
|
||||
LRESULT result = 0;
|
||||
if (!s_screen->onEvent(hwnd, msg, wParam, lParam, &result)) {
|
||||
|
||||
@ -152,7 +152,7 @@ private:
|
||||
|
||||
// convenience function to send events
|
||||
public: // HACK
|
||||
void sendEvent(Event::Type type, void * = NULL);
|
||||
void sendEvent(Event::Type type, void * = nullptr);
|
||||
|
||||
private: // HACK
|
||||
void sendClipboardEvent(Event::Type type, ClipboardID id);
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
static const TCHAR *g_isSecureNT = "ScreenSaverIsSecure";
|
||||
static const TCHAR *g_isSecure9x = "ScreenSaveUsePassword";
|
||||
static const TCHAR *const g_pathScreenSaverIsSecure[] = {"Control Panel", "Desktop", NULL};
|
||||
static const TCHAR *const g_pathScreenSaverIsSecure[] = {"Control Panel", "Desktop", nullptr};
|
||||
|
||||
//
|
||||
// MSWindowsScreenSaver
|
||||
@ -32,8 +32,8 @@ static const TCHAR *const g_pathScreenSaverIsSecure[] = {"Control Panel", "Deskt
|
||||
MSWindowsScreenSaver::MSWindowsScreenSaver()
|
||||
: m_wasSecure(false),
|
||||
m_wasSecureAnInt(false),
|
||||
m_process(NULL),
|
||||
m_watch(NULL),
|
||||
m_process(nullptr),
|
||||
m_watch(nullptr),
|
||||
m_threadID(0),
|
||||
m_msg(0),
|
||||
m_wParam(0),
|
||||
@ -116,11 +116,11 @@ void MSWindowsScreenSaver::activate()
|
||||
if (!isActive()) {
|
||||
// activate
|
||||
HWND hwnd = GetForegroundWindow();
|
||||
if (hwnd != NULL) {
|
||||
if (hwnd != nullptr) {
|
||||
PostMessage(hwnd, WM_SYSCOMMAND, SC_SCREENSAVE, 0);
|
||||
} else {
|
||||
// no foreground window. pretend we got the event instead.
|
||||
DefWindowProc(NULL, WM_SYSCOMMAND, SC_SCREENSAVE, 0);
|
||||
DefWindowProc(nullptr, WM_SYSCOMMAND, SC_SCREENSAVE, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -131,7 +131,7 @@ void MSWindowsScreenSaver::deactivate()
|
||||
|
||||
// NT runs screen saver in another desktop
|
||||
HDESK desktop = OpenDesktop("Screen-saver", 0, FALSE, DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS);
|
||||
if (desktop != NULL) {
|
||||
if (desktop != nullptr) {
|
||||
EnumDesktopWindows(desktop, &MSWindowsScreenSaver::killScreenSaverFunc, reinterpret_cast<LPARAM>(&killed));
|
||||
CloseDesktop(desktop);
|
||||
}
|
||||
@ -139,12 +139,12 @@ void MSWindowsScreenSaver::deactivate()
|
||||
// if above failed or wasn't tried, try the windows 95 way
|
||||
if (!killed) {
|
||||
// find screen saver window and close it
|
||||
HWND hwnd = FindWindow("WindowsScreenSaverClass", NULL);
|
||||
if (hwnd == NULL) {
|
||||
HWND hwnd = FindWindow("WindowsScreenSaverClass", nullptr);
|
||||
if (hwnd == nullptr) {
|
||||
// win2k may use a different class
|
||||
hwnd = FindWindow("Default Screen Saver", NULL);
|
||||
hwnd = FindWindow("Default Screen Saver", nullptr);
|
||||
}
|
||||
if (hwnd != NULL) {
|
||||
if (hwnd != nullptr) {
|
||||
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
||||
}
|
||||
}
|
||||
@ -191,7 +191,7 @@ void MSWindowsScreenSaver::watchProcess(HANDLE process)
|
||||
unwatchProcess();
|
||||
|
||||
// watch new process in another thread
|
||||
if (process != NULL) {
|
||||
if (process != nullptr) {
|
||||
LOG((CLOG_DEBUG "watching screen saver process"));
|
||||
m_process = process;
|
||||
m_active = true;
|
||||
@ -201,24 +201,24 @@ void MSWindowsScreenSaver::watchProcess(HANDLE process)
|
||||
|
||||
void MSWindowsScreenSaver::unwatchProcess()
|
||||
{
|
||||
if (m_watch != NULL) {
|
||||
if (m_watch != nullptr) {
|
||||
LOG((CLOG_DEBUG "stopped watching screen saver process/desktop"));
|
||||
m_watch->cancel();
|
||||
m_watch->wait();
|
||||
delete m_watch;
|
||||
m_watch = NULL;
|
||||
m_watch = nullptr;
|
||||
m_active = false;
|
||||
}
|
||||
if (m_process != NULL) {
|
||||
if (m_process != nullptr) {
|
||||
CloseHandle(m_process);
|
||||
m_process = NULL;
|
||||
m_process = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MSWindowsScreenSaver::watchDesktopThread(void *)
|
||||
{
|
||||
DWORD reserved = 0;
|
||||
TCHAR *name = NULL;
|
||||
TCHAR *name = nullptr;
|
||||
|
||||
for (;;) {
|
||||
// wait a bit
|
||||
@ -256,7 +256,7 @@ void MSWindowsScreenSaver::watchProcessThread(void *)
|
||||
void MSWindowsScreenSaver::setSecure(bool secure, bool saveSecureAsInt)
|
||||
{
|
||||
HKEY hkey = ArchMiscWindows::addKey(HKEY_CURRENT_USER, g_pathScreenSaverIsSecure);
|
||||
if (hkey == NULL) {
|
||||
if (hkey == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ bool MSWindowsScreenSaver::isSecure(bool *wasSecureFlagAnInt) const
|
||||
{
|
||||
// get the password protection setting key
|
||||
HKEY hkey = ArchMiscWindows::openKey(HKEY_CURRENT_USER, g_pathScreenSaverIsSecure);
|
||||
if (hkey == NULL) {
|
||||
if (hkey == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ MSWindowsSession::~MSWindowsSession()
|
||||
{
|
||||
}
|
||||
|
||||
bool MSWindowsSession::isProcessInSession(const char *name, PHANDLE process = NULL)
|
||||
bool MSWindowsSession::isProcessInSession(const char *name, PHANDLE process = nullptr)
|
||||
{
|
||||
// first we need to take a snapshot of the running processes
|
||||
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
@ -91,7 +91,7 @@ bool MSWindowsSession::isProcessInSession(const char *name, PHANDLE process = NU
|
||||
CloseHandle(snapshot);
|
||||
|
||||
if (pid) {
|
||||
if (process != NULL) {
|
||||
if (process != nullptr) {
|
||||
// now get the process, which we'll use to get the process token.
|
||||
LOG((CLOG_DEBUG "found %s in session %i", name, m_activeSessionId));
|
||||
*process = OpenProcess(MAXIMUM_ALLOWED, FALSE, pid);
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
std::string MSWindowsUtil::getString(HINSTANCE instance, DWORD id)
|
||||
{
|
||||
char *msg = NULL;
|
||||
char *msg = nullptr;
|
||||
int n = LoadString(instance, id, reinterpret_cast<LPSTR>(&msg), 0);
|
||||
|
||||
if (n <= 0) {
|
||||
@ -32,7 +32,7 @@ std::string MSWindowsUtil::getErrorString(HINSTANCE hinstance, DWORD error, DWOR
|
||||
char *buffer;
|
||||
if (FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, 0, error,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&buffer, 0, NULL
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&buffer, 0, nullptr
|
||||
) == 0) {
|
||||
std::string errorString = deskflow::string::sprintf("%d", error);
|
||||
return deskflow::string::format(getString(hinstance, id).c_str(), errorString.c_str());
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
// OSXClipboard
|
||||
//
|
||||
|
||||
OSXClipboard::OSXClipboard() : m_time(0), m_pboard(NULL)
|
||||
OSXClipboard::OSXClipboard() : m_time(0), m_pboard(nullptr)
|
||||
{
|
||||
m_converters.push_back(new OSXClipboardHTMLConverter);
|
||||
m_converters.push_back(new OSXClipboardBMPConverter);
|
||||
@ -32,7 +32,7 @@ OSXClipboard::OSXClipboard() : m_time(0), m_pboard(NULL)
|
||||
if (createErr != noErr) {
|
||||
LOG((CLOG_WARN "failed to create clipboard reference: error %i", createErr));
|
||||
LOG((CLOG_ERR "unable to connect to pasteboard, clipboard sharing disabled", createErr));
|
||||
m_pboard = NULL;
|
||||
m_pboard = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ OSXClipboard::~OSXClipboard()
|
||||
bool OSXClipboard::empty()
|
||||
{
|
||||
LOG((CLOG_DEBUG "emptying clipboard"));
|
||||
if (m_pboard == NULL)
|
||||
if (m_pboard == nullptr)
|
||||
return false;
|
||||
|
||||
OSStatus err = PasteboardClear(m_pboard);
|
||||
@ -64,7 +64,7 @@ bool OSXClipboard::empty()
|
||||
|
||||
bool OSXClipboard::synchronize()
|
||||
{
|
||||
if (m_pboard == NULL)
|
||||
if (m_pboard == nullptr)
|
||||
return false;
|
||||
|
||||
PasteboardSyncFlags flags = PasteboardSynchronize(m_pboard);
|
||||
@ -78,7 +78,7 @@ bool OSXClipboard::synchronize()
|
||||
|
||||
void OSXClipboard::add(EFormat format, const std::string &data)
|
||||
{
|
||||
if (m_pboard == NULL)
|
||||
if (m_pboard == nullptr)
|
||||
return;
|
||||
|
||||
LOG((CLOG_DEBUG "add %d bytes to clipboard format: %d", data.size(), format));
|
||||
@ -113,7 +113,7 @@ void OSXClipboard::add(EFormat format, const std::string &data)
|
||||
|
||||
bool OSXClipboard::open(Time time) const
|
||||
{
|
||||
if (m_pboard == NULL)
|
||||
if (m_pboard == nullptr)
|
||||
return false;
|
||||
|
||||
LOG((CLOG_DEBUG "opening clipboard"));
|
||||
@ -134,7 +134,7 @@ IClipboard::Time OSXClipboard::getTime() const
|
||||
|
||||
bool OSXClipboard::has(EFormat format) const
|
||||
{
|
||||
if (m_pboard == NULL)
|
||||
if (m_pboard == nullptr)
|
||||
return false;
|
||||
|
||||
PasteboardItemID item;
|
||||
@ -163,13 +163,13 @@ std::string OSXClipboard::get(EFormat format) const
|
||||
PasteboardItemID item;
|
||||
std::string result;
|
||||
|
||||
if (m_pboard == NULL)
|
||||
if (m_pboard == nullptr)
|
||||
return result;
|
||||
|
||||
PasteboardGetItemIdentifier(m_pboard, (CFIndex)1, &item);
|
||||
|
||||
// find the converter for the first clipboard format we can handle
|
||||
IOSXClipboardConverter *converter = NULL;
|
||||
IOSXClipboardConverter *converter = nullptr;
|
||||
for (ConverterList::const_iterator index = m_converters.begin(); index != m_converters.end(); ++index) {
|
||||
converter = *index;
|
||||
|
||||
@ -179,17 +179,17 @@ std::string OSXClipboard::get(EFormat format) const
|
||||
if (converter->getFormat() == format && PasteboardGetItemFlavorFlags(m_pboard, item, type, &flags) == noErr) {
|
||||
break;
|
||||
}
|
||||
converter = NULL;
|
||||
converter = nullptr;
|
||||
}
|
||||
|
||||
// if no converter then we don't recognize any formats
|
||||
if (converter == NULL) {
|
||||
if (converter == nullptr) {
|
||||
LOG((CLOG_DEBUG "unable to find converter for data"));
|
||||
return result;
|
||||
}
|
||||
|
||||
// get the clipboard data.
|
||||
CFDataRef buffer = NULL;
|
||||
CFDataRef buffer = nullptr;
|
||||
try {
|
||||
OSStatus err = PasteboardCopyItemFlavorData(m_pboard, item, type, &buffer);
|
||||
|
||||
@ -205,7 +205,7 @@ std::string OSXClipboard::get(EFormat format) const
|
||||
RETHROW_XTHREAD
|
||||
}
|
||||
|
||||
if (buffer != NULL)
|
||||
if (buffer != nullptr)
|
||||
CFRelease(buffer);
|
||||
|
||||
return converter->toIClipboard(result);
|
||||
@ -213,7 +213,7 @@ std::string OSXClipboard::get(EFormat format) const
|
||||
|
||||
void OSXClipboard::clearConverters()
|
||||
{
|
||||
if (m_pboard == NULL)
|
||||
if (m_pboard == nullptr)
|
||||
return;
|
||||
|
||||
for (ConverterList::iterator index = m_converters.begin(); index != m_converters.end(); ++index) {
|
||||
|
||||
@ -35,23 +35,23 @@ std::string OSXClipboardHTMLConverter::convertString(
|
||||
{
|
||||
CFStringRef stringRef = CFStringCreateWithCString(kCFAllocatorDefault, data.c_str(), fromEncoding);
|
||||
|
||||
if (stringRef == NULL) {
|
||||
if (stringRef == nullptr) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
CFIndex buffSize;
|
||||
CFRange entireString = CFRangeMake(0, CFStringGetLength(stringRef));
|
||||
|
||||
CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, NULL, 0, &buffSize);
|
||||
CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, nullptr, 0, &buffSize);
|
||||
|
||||
char *buffer = new char[buffSize];
|
||||
|
||||
if (buffer == NULL) {
|
||||
if (buffer == nullptr) {
|
||||
CFRelease(stringRef);
|
||||
return std::string();
|
||||
}
|
||||
|
||||
CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, (uint8_t *)buffer, buffSize, NULL);
|
||||
CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, (uint8_t *)buffer, buffSize, nullptr);
|
||||
|
||||
std::string result(buffer, buffSize);
|
||||
|
||||
|
||||
@ -34,23 +34,23 @@ std::string OSXClipboardTextConverter::convertString(
|
||||
{
|
||||
CFStringRef stringRef = CFStringCreateWithCString(kCFAllocatorDefault, data.c_str(), fromEncoding);
|
||||
|
||||
if (stringRef == NULL) {
|
||||
if (stringRef == nullptr) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
CFIndex buffSize;
|
||||
CFRange entireString = CFRangeMake(0, CFStringGetLength(stringRef));
|
||||
|
||||
CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, NULL, 0, &buffSize);
|
||||
CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, nullptr, 0, &buffSize);
|
||||
|
||||
char *buffer = new char[buffSize];
|
||||
|
||||
if (buffer == NULL) {
|
||||
if (buffer == nullptr) {
|
||||
CFRelease(stringRef);
|
||||
return std::string();
|
||||
}
|
||||
|
||||
CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, (uint8_t *)buffer, buffSize, NULL);
|
||||
CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, (uint8_t *)buffer, buffSize, nullptr);
|
||||
|
||||
std::string result(buffer, buffSize);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user