2012-06-10 16:50:54 +00:00
|
|
|
/*
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
2014-11-02 12:12:05 +00:00
|
|
|
* Copyright (C) 2012 Synergy Si Ltd.
|
2012-09-04 02:09:56 +00:00
|
|
|
* Copyright (C) 2003 Chris Schoeneman
|
2012-06-10 16:50:54 +00:00
|
|
|
*
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* found in the file COPYING that should have accompanied this file.
|
|
|
|
*
|
|
|
|
* This package is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2014-02-28 12:36:45 +00:00
|
|
|
#include "synergy/ClientTaskBarReceiver.h"
|
|
|
|
#include "client/Client.h"
|
|
|
|
#include "mt/Lock.h"
|
2014-03-21 08:32:36 +00:00
|
|
|
#include "base/String.h"
|
2014-02-28 12:36:45 +00:00
|
|
|
#include "base/IEventQueue.h"
|
|
|
|
#include "arch/Arch.h"
|
|
|
|
#include "common/Version.h"
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
//
|
2014-11-11 13:51:47 +00:00
|
|
|
// ClientTaskBarReceiver
|
2012-06-10 16:50:54 +00:00
|
|
|
//
|
|
|
|
|
2014-11-11 13:51:47 +00:00
|
|
|
ClientTaskBarReceiver::ClientTaskBarReceiver(IEventQueue* events) :
|
2014-02-25 15:03:43 +00:00
|
|
|
m_state(kNotRunning),
|
|
|
|
m_events(events)
|
2012-06-10 16:50:54 +00:00
|
|
|
{
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
2014-11-11 13:51:47 +00:00
|
|
|
ClientTaskBarReceiver::~ClientTaskBarReceiver()
|
2012-06-10 16:50:54 +00:00
|
|
|
{
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-11-11 13:51:47 +00:00
|
|
|
ClientTaskBarReceiver::updateStatus(Client* client, const String& errorMsg)
|
2012-06-10 16:50:54 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
// update our status
|
|
|
|
m_errorMessage = errorMsg;
|
|
|
|
if (client == NULL) {
|
|
|
|
if (m_errorMessage.empty()) {
|
|
|
|
m_state = kNotRunning;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_state = kNotWorking;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_server = client->getServerAddress().getHostname();
|
|
|
|
|
|
|
|
if (client->isConnected()) {
|
|
|
|
m_state = kConnected;
|
|
|
|
}
|
|
|
|
else if (client->isConnecting()) {
|
|
|
|
m_state = kConnecting;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_state = kNotConnected;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// let subclasses have a go
|
|
|
|
onStatusChanged(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
// tell task bar
|
|
|
|
ARCH->updateReceiver(this);
|
|
|
|
}
|
|
|
|
|
2014-11-11 13:51:47 +00:00
|
|
|
ClientTaskBarReceiver::EState
|
|
|
|
ClientTaskBarReceiver::getStatus() const
|
2012-06-10 16:50:54 +00:00
|
|
|
{
|
|
|
|
return m_state;
|
|
|
|
}
|
|
|
|
|
2014-11-11 13:51:47 +00:00
|
|
|
const String&
|
|
|
|
ClientTaskBarReceiver::getErrorMessage() const
|
2012-06-10 16:50:54 +00:00
|
|
|
{
|
|
|
|
return m_errorMessage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-11-11 13:51:47 +00:00
|
|
|
ClientTaskBarReceiver::quit()
|
2012-06-10 16:50:54 +00:00
|
|
|
{
|
2014-11-11 13:51:47 +00:00
|
|
|
m_events->addEvent(Event(Event::kQuit));
|
2012-06-10 16:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-11-11 13:51:47 +00:00
|
|
|
ClientTaskBarReceiver::onStatusChanged(Client*)
|
2012-06-10 16:50:54 +00:00
|
|
|
{
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-11-11 13:51:47 +00:00
|
|
|
ClientTaskBarReceiver::lock() const
|
2012-06-10 16:50:54 +00:00
|
|
|
{
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-11-11 13:51:47 +00:00
|
|
|
ClientTaskBarReceiver::unlock() const
|
2012-06-10 16:50:54 +00:00
|
|
|
{
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string
|
2014-11-11 13:51:47 +00:00
|
|
|
ClientTaskBarReceiver::getToolTip() const
|
2012-06-10 16:50:54 +00:00
|
|
|
{
|
|
|
|
switch (m_state) {
|
|
|
|
case kNotRunning:
|
2014-03-21 08:32:36 +00:00
|
|
|
return synergy::string::sprintf("%s: Not running", kAppVersion);
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
case kNotWorking:
|
2014-03-21 08:32:36 +00:00
|
|
|
return synergy::string::sprintf("%s: %s",
|
2012-06-10 16:50:54 +00:00
|
|
|
kAppVersion, m_errorMessage.c_str());
|
|
|
|
|
|
|
|
case kNotConnected:
|
2014-03-21 08:32:36 +00:00
|
|
|
return synergy::string::sprintf("%s: Not connected: %s",
|
2012-06-10 16:50:54 +00:00
|
|
|
kAppVersion, m_errorMessage.c_str());
|
|
|
|
|
|
|
|
case kConnecting:
|
2014-03-21 08:32:36 +00:00
|
|
|
return synergy::string::sprintf("%s: Connecting to %s...",
|
2012-06-10 16:50:54 +00:00
|
|
|
kAppVersion, m_server.c_str());
|
|
|
|
|
|
|
|
case kConnected:
|
2014-03-21 08:32:36 +00:00
|
|
|
return synergy::string::sprintf("%s: Connected to %s",
|
2012-06-10 16:50:54 +00:00
|
|
|
kAppVersion, m_server.c_str());
|
|
|
|
|
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|