• Main Page
  • Classes
  • Files
  • File List

CClientTaskBarReceiver.cpp

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2012 Bolton Software Ltd.
00004  * Copyright (C) 2003 Chris Schoeneman
00005  * 
00006  * This package is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * found in the file COPYING that should have accompanied this file.
00009  * 
00010  * This package is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 
00019 #include "CClientTaskBarReceiver.h"
00020 #include "CClient.h"
00021 #include "CLock.h"
00022 #include "CStringUtil.h"
00023 #include "IEventQueue.h"
00024 #include "CArch.h"
00025 #include "Version.h"
00026 
00027 //
00028 // CClientTaskBarReceiver
00029 //
00030 
00031 CClientTaskBarReceiver::CClientTaskBarReceiver() :
00032     m_state(kNotRunning)
00033 {
00034     // do nothing
00035 }
00036 
00037 CClientTaskBarReceiver::~CClientTaskBarReceiver()
00038 {
00039     // do nothing
00040 }
00041 
00042 void
00043 CClientTaskBarReceiver::updateStatus(CClient* client, const CString& errorMsg)
00044 {
00045     {
00046         // update our status
00047         m_errorMessage = errorMsg;
00048         if (client == NULL) {
00049             if (m_errorMessage.empty()) {
00050                 m_state = kNotRunning;
00051             }
00052             else {
00053                 m_state = kNotWorking;
00054             }
00055         }
00056         else {
00057             m_server = client->getServerAddress().getHostname();
00058 
00059             if (client->isConnected()) {
00060                 m_state = kConnected;
00061             }
00062             else if (client->isConnecting()) {
00063                 m_state = kConnecting;
00064             }
00065             else {
00066                 m_state = kNotConnected;
00067             }
00068         }
00069 
00070         // let subclasses have a go
00071         onStatusChanged(client);
00072     }
00073 
00074     // tell task bar
00075     ARCH->updateReceiver(this);
00076 }
00077 
00078 CClientTaskBarReceiver::EState
00079 CClientTaskBarReceiver::getStatus() const
00080 {
00081     return m_state;
00082 }
00083 
00084 const CString&
00085 CClientTaskBarReceiver::getErrorMessage() const
00086 {
00087     return m_errorMessage;
00088 }
00089 
00090 void
00091 CClientTaskBarReceiver::quit()
00092 {
00093     EVENTQUEUE->addEvent(CEvent(CEvent::kQuit));
00094 }
00095 
00096 void
00097 CClientTaskBarReceiver::onStatusChanged(CClient*)
00098 {
00099     // do nothing
00100 }
00101 
00102 void
00103 CClientTaskBarReceiver::lock() const
00104 {
00105     // do nothing
00106 }
00107 
00108 void
00109 CClientTaskBarReceiver::unlock() const
00110 {
00111     // do nothing
00112 }
00113 
00114 std::string
00115 CClientTaskBarReceiver::getToolTip() const
00116 {
00117     switch (m_state) {
00118     case kNotRunning:
00119         return CStringUtil::print("%s:  Not running", kAppVersion);
00120 
00121     case kNotWorking:
00122         return CStringUtil::print("%s:  %s",
00123                                 kAppVersion, m_errorMessage.c_str());
00124 
00125     case kNotConnected:
00126         return CStringUtil::print("%s:  Not connected:  %s",
00127                                 kAppVersion, m_errorMessage.c_str());
00128 
00129     case kConnecting:
00130         return CStringUtil::print("%s:  Connecting to %s...",
00131                                 kAppVersion, m_server.c_str());
00132 
00133     case kConnected:
00134         return CStringUtil::print("%s:  Connected to %s",
00135                                 kAppVersion, m_server.c_str());
00136 
00137     default:
00138         return "";
00139     }
00140 }

Generated on Sun May 19 2013 00:00:04 for Synergy by  doxygen 1.7.1