Minor cleanup.
This commit is contained in:
parent
1861f21fb5
commit
901a76df0d
|
@ -33,7 +33,6 @@ CServerTaskBarReceiver::~CServerTaskBarReceiver()
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "CLog.h"
|
|
||||||
void
|
void
|
||||||
CServerTaskBarReceiver::updateStatus(CServer* server, const CString& errorMsg)
|
CServerTaskBarReceiver::updateStatus(CServer* server, const CString& errorMsg)
|
||||||
{
|
{
|
||||||
|
@ -62,7 +61,6 @@ CServerTaskBarReceiver::updateStatus(CServer* server, const CString& errorMsg)
|
||||||
|
|
||||||
// let subclasses have a go
|
// let subclasses have a go
|
||||||
onStatusChanged(server);
|
onStatusChanged(server);
|
||||||
LOG((CLOG_INFO "### status: %s", getToolTip().c_str()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// tell task bar
|
// tell task bar
|
||||||
|
|
|
@ -118,6 +118,7 @@ createScreen()
|
||||||
//
|
//
|
||||||
|
|
||||||
static CServer* s_server = NULL;
|
static CServer* s_server = NULL;
|
||||||
|
static CScreen* s_serverScreen = NULL;
|
||||||
static CPrimaryClient* s_primaryClient = NULL;
|
static CPrimaryClient* s_primaryClient = NULL;
|
||||||
static CClientListener* s_listener = NULL;
|
static CClientListener* s_listener = NULL;
|
||||||
static CServerTaskBarReceiver* s_taskBarReceiver = NULL;
|
static CServerTaskBarReceiver* s_taskBarReceiver = NULL;
|
||||||
|
@ -170,6 +171,20 @@ closeClientListener(CClientListener* listen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
CScreen*
|
||||||
|
openServerScreen()
|
||||||
|
{
|
||||||
|
return createScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
closeServerScreen(CScreen* screen)
|
||||||
|
{
|
||||||
|
delete screen;
|
||||||
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
handleScreenError(const CEvent&, void*)
|
handleScreenError(const CEvent&, void*)
|
||||||
|
@ -179,10 +194,9 @@ handleScreenError(const CEvent&, void*)
|
||||||
|
|
||||||
static
|
static
|
||||||
CPrimaryClient*
|
CPrimaryClient*
|
||||||
openPrimaryClient(const CString& name)
|
openPrimaryClient(const CString& name, CScreen* screen)
|
||||||
{
|
{
|
||||||
LOG((CLOG_DEBUG1 "creating primary screen"));
|
LOG((CLOG_DEBUG1 "creating primary screen"));
|
||||||
CScreen* screen = createScreen();
|
|
||||||
CPrimaryClient* primaryClient = new CPrimaryClient(name, screen);
|
CPrimaryClient* primaryClient = new CPrimaryClient(name, screen);
|
||||||
EVENTQUEUE->adoptHandler(IScreen::getErrorEvent(),
|
EVENTQUEUE->adoptHandler(IScreen::getErrorEvent(),
|
||||||
primaryClient->getEventTarget(),
|
primaryClient->getEventTarget(),
|
||||||
|
@ -280,13 +294,16 @@ bool
|
||||||
startServer()
|
startServer()
|
||||||
{
|
{
|
||||||
double retryTime;
|
double retryTime;
|
||||||
|
CScreen* serverScreen = NULL;
|
||||||
CPrimaryClient* primaryClient = NULL;
|
CPrimaryClient* primaryClient = NULL;
|
||||||
CClientListener* listener = NULL;
|
CClientListener* listener = NULL;
|
||||||
try {
|
try {
|
||||||
CString name = ARG->m_config.getCanonicalName(ARG->m_name);
|
CString name = ARG->m_config.getCanonicalName(ARG->m_name);
|
||||||
primaryClient = openPrimaryClient(name);
|
serverScreen = openServerScreen();
|
||||||
|
primaryClient = openPrimaryClient(name, serverScreen);
|
||||||
listener = openClientListener(ARG->m_config.getSynergyAddress());
|
listener = openClientListener(ARG->m_config.getSynergyAddress());
|
||||||
s_server = openServer(ARG->m_config, primaryClient);
|
s_server = openServer(ARG->m_config, primaryClient);
|
||||||
|
s_serverScreen = serverScreen;
|
||||||
s_primaryClient = primaryClient;
|
s_primaryClient = primaryClient;
|
||||||
s_listener = listener;
|
s_listener = listener;
|
||||||
updateStatus();
|
updateStatus();
|
||||||
|
@ -297,6 +314,7 @@ startServer()
|
||||||
LOG((CLOG_WARN "cannot open primary screen: %s", e.what()));
|
LOG((CLOG_WARN "cannot open primary screen: %s", e.what()));
|
||||||
closeClientListener(listener);
|
closeClientListener(listener);
|
||||||
closePrimaryClient(primaryClient);
|
closePrimaryClient(primaryClient);
|
||||||
|
closeServerScreen(serverScreen);
|
||||||
updateStatus(CString("cannot open primary screen: ") + e.what());
|
updateStatus(CString("cannot open primary screen: ") + e.what());
|
||||||
retryTime = e.getRetryTime();
|
retryTime = e.getRetryTime();
|
||||||
}
|
}
|
||||||
|
@ -304,6 +322,7 @@ startServer()
|
||||||
LOG((CLOG_WARN "cannot listen for clients: %s", e.what()));
|
LOG((CLOG_WARN "cannot listen for clients: %s", e.what()));
|
||||||
closeClientListener(listener);
|
closeClientListener(listener);
|
||||||
closePrimaryClient(primaryClient);
|
closePrimaryClient(primaryClient);
|
||||||
|
closeServerScreen(serverScreen);
|
||||||
updateStatus(CString("cannot listen for clients: ") + e.what());
|
updateStatus(CString("cannot listen for clients: ") + e.what());
|
||||||
retryTime = 10.0;
|
retryTime = 10.0;
|
||||||
}
|
}
|
||||||
|
@ -311,12 +330,14 @@ startServer()
|
||||||
LOG((CLOG_CRIT "cannot open primary screen: %s", e.what()));
|
LOG((CLOG_CRIT "cannot open primary screen: %s", e.what()));
|
||||||
closeClientListener(listener);
|
closeClientListener(listener);
|
||||||
closePrimaryClient(primaryClient);
|
closePrimaryClient(primaryClient);
|
||||||
|
closeServerScreen(serverScreen);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
catch (XBase& e) {
|
catch (XBase& e) {
|
||||||
LOG((CLOG_CRIT "failed to start server: %s", e.what()));
|
LOG((CLOG_CRIT "failed to start server: %s", e.what()));
|
||||||
closeClientListener(listener);
|
closeClientListener(listener);
|
||||||
closePrimaryClient(primaryClient);
|
closePrimaryClient(primaryClient);
|
||||||
|
closeServerScreen(serverScreen);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,6 +355,20 @@ startServer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
stopServer()
|
||||||
|
{
|
||||||
|
closeClientListener(s_listener);
|
||||||
|
closeServer(s_server);
|
||||||
|
closePrimaryClient(s_primaryClient);
|
||||||
|
closeServerScreen(s_serverScreen);
|
||||||
|
s_server = NULL;
|
||||||
|
s_listener = NULL;
|
||||||
|
s_primaryClient = NULL;
|
||||||
|
s_serverScreen = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int
|
int
|
||||||
realMain()
|
realMain()
|
||||||
|
@ -383,12 +418,7 @@ realMain()
|
||||||
|
|
||||||
// close down
|
// close down
|
||||||
LOG((CLOG_DEBUG1 "stopping server"));
|
LOG((CLOG_DEBUG1 "stopping server"));
|
||||||
closeClientListener(s_listener);
|
stopServer();
|
||||||
closeServer(s_server);
|
|
||||||
closePrimaryClient(s_primaryClient);
|
|
||||||
s_server = NULL;
|
|
||||||
s_listener = NULL;
|
|
||||||
s_primaryClient = NULL;
|
|
||||||
updateStatus();
|
updateStatus();
|
||||||
LOG((CLOG_NOTE "stopped server"));
|
LOG((CLOG_NOTE "stopped server"));
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ CPrimaryClient::CPrimaryClient(const CString& name, CScreen* screen) :
|
||||||
|
|
||||||
CPrimaryClient::~CPrimaryClient()
|
CPrimaryClient::~CPrimaryClient()
|
||||||
{
|
{
|
||||||
delete m_screen;
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -24,12 +24,12 @@ class CScreen;
|
||||||
/*!
|
/*!
|
||||||
The primary screen does not have a client associated with it. This
|
The primary screen does not have a client associated with it. This
|
||||||
class provides a pseudo-client to allow the primary screen to be
|
class provides a pseudo-client to allow the primary screen to be
|
||||||
treated as if it was on a client.
|
treated as if it was a client.
|
||||||
*/
|
*/
|
||||||
class CPrimaryClient : public IClient {
|
class CPrimaryClient : public IClient {
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
\c name is the name of the server. \p screen is adopted.
|
\c name is the name of the server and \p screen is primary screen.
|
||||||
*/
|
*/
|
||||||
CPrimaryClient(const CString& name, CScreen* screen);
|
CPrimaryClient(const CString& name, CScreen* screen);
|
||||||
~CPrimaryClient();
|
~CPrimaryClient();
|
||||||
|
|
Loading…
Reference in New Issue