2012-06-28 07:29:06 +00:00
|
|
|
/*
|
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
|
|
|
|
* Copyright (C) 2012 Nick Bolton
|
|
|
|
|
*
|
|
|
|
|
* 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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2012-06-29 11:33:21 +00:00
|
|
|
#include "CNetworkAddress.h"
|
|
|
|
|
#include "CTCPSocket.h"
|
2012-07-02 15:28:23 +00:00
|
|
|
|
|
|
|
|
class CIpcServerProxy;
|
|
|
|
|
class CIpcMessage;
|
2012-06-29 11:33:21 +00:00
|
|
|
|
2012-06-28 07:29:06 +00:00
|
|
|
//! IPC client for communication between daemon and GUI.
|
|
|
|
|
/*!
|
|
|
|
|
* See \ref CIpcServer description.
|
|
|
|
|
*/
|
|
|
|
|
class CIpcClient {
|
|
|
|
|
public:
|
|
|
|
|
CIpcClient();
|
2012-07-11 12:07:13 +00:00
|
|
|
CIpcClient(int port);
|
2012-06-28 07:29:06 +00:00
|
|
|
virtual ~CIpcClient();
|
|
|
|
|
|
2012-07-05 18:05:35 +00:00
|
|
|
//! @name manipulators
|
|
|
|
|
//@{
|
|
|
|
|
|
2012-06-28 07:29:06 +00:00
|
|
|
//! Connects to the IPC server at localhost.
|
2012-07-02 13:45:52 +00:00
|
|
|
void connect();
|
2012-07-10 01:51:51 +00:00
|
|
|
|
|
|
|
|
//! Disconnects from the IPC server.
|
|
|
|
|
void disconnect();
|
2012-07-02 13:45:52 +00:00
|
|
|
|
|
|
|
|
//! Sends a message to the server.
|
|
|
|
|
void send(const CIpcMessage& message);
|
2012-06-29 11:33:21 +00:00
|
|
|
|
2012-07-05 18:05:35 +00:00
|
|
|
//@}
|
|
|
|
|
//! @name accessors
|
|
|
|
|
//@{
|
|
|
|
|
|
|
|
|
|
//! Raised when the socket is connected.
|
|
|
|
|
static CEvent::Type getConnectedEvent();
|
2012-07-10 01:51:51 +00:00
|
|
|
static CEvent::Type getMessageReceivedEvent();
|
2012-07-05 18:05:35 +00:00
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
2012-06-29 11:33:21 +00:00
|
|
|
private:
|
2012-07-11 12:07:13 +00:00
|
|
|
void init();
|
2012-07-05 18:05:35 +00:00
|
|
|
void handleConnected(const CEvent&, void*);
|
2012-07-10 01:51:51 +00:00
|
|
|
void handleMessageReceived(const CEvent&, void*);
|
2012-07-05 18:05:35 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
CNetworkAddress m_serverAddress;
|
|
|
|
|
CTCPSocket m_socket;
|
|
|
|
|
CIpcServerProxy* m_server;
|
2012-07-10 01:51:51 +00:00
|
|
|
|
2012-07-05 18:05:35 +00:00
|
|
|
static CEvent::Type s_connectedEvent;
|
2012-07-10 01:51:51 +00:00
|
|
|
static CEvent::Type s_messageReceivedEvent;
|
2012-06-28 07:29:06 +00:00
|
|
|
};
|