summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Client/CommandManager.h10
-rw-r--r--src/Client/InformationManager.cpp4
-rw-r--r--src/Common/ClientConnection.cpp2
-rw-r--r--src/Common/Connection.cpp2
-rw-r--r--src/Common/Connection.h16
-rw-r--r--src/Common/Request.h12
-rw-r--r--src/Common/RequestHandler.h9
-rw-r--r--src/Common/RequestHandlers/DisconnectRequestHandler.cpp4
-rw-r--r--src/Common/RequestHandlers/FSInfoRequestHandler.cpp4
-rw-r--r--src/Common/RequestHandlers/StatusRequestHandler.cpp4
-rw-r--r--src/Common/RequestManager.cpp4
-rw-r--r--src/Daemon/RequestHandlers/CommandRequestHandler.cpp4
-rw-r--r--src/Net/Connection.cpp8
-rw-r--r--src/Net/Connection.h32
-rw-r--r--src/Net/Listener.cpp15
-rw-r--r--src/Net/Listener.h11
-rw-r--r--src/Net/Signals/Connection.h45
-rw-r--r--src/Net/Signals/Signal0.h43
-rw-r--r--src/Net/Signals/Signal1.h41
-rw-r--r--src/Net/Signals/Signal2.h41
-rw-r--r--src/Net/Signals/SignalBase.h80
-rw-r--r--src/Net/Signals/Signals.h27
-rw-r--r--src/Server/ConnectionManager.cpp8
-rw-r--r--src/Server/RequestHandlers/DaemonCommandRequestHandler.cpp4
-rw-r--r--src/Server/RequestHandlers/DaemonFSInfoRequestHandler.cpp4
-rw-r--r--src/Server/RequestHandlers/DaemonListRequestHandler.cpp4
-rw-r--r--src/Server/RequestHandlers/DaemonStatusRequestHandler.cpp4
-rw-r--r--src/Server/RequestHandlers/GSSAPIAuthRequestHandler.cpp4
-rw-r--r--src/Server/RequestHandlers/GroupListRequestHandler.cpp4
-rw-r--r--src/Server/RequestHandlers/GroupUserListRequestHandler.cpp4
-rw-r--r--src/Server/RequestHandlers/IdentifyRequestHandler.cpp4
-rw-r--r--src/Server/RequestHandlers/LogRequestHandler.cpp4
-rw-r--r--src/Server/RequestHandlers/UserGroupListRequestHandler.cpp4
-rw-r--r--src/Server/RequestHandlers/UserInfoRequestHandler.cpp4
-rw-r--r--src/Server/RequestHandlers/UserListRequestHandler.cpp4
-rw-r--r--src/madc.cpp2
36 files changed, 389 insertions, 87 deletions
diff --git a/src/Client/CommandManager.h b/src/Client/CommandManager.h
index 137ec8e..3ab5d9c 100644
--- a/src/Client/CommandManager.h
+++ b/src/Client/CommandManager.h
@@ -20,7 +20,7 @@
#ifndef MAD_CLIENT_COMMANDMANAGER_H_
#define MAD_CLIENT_COMMANDMANAGER_H_
-#include <boost/signal.hpp>
+#include <Net/Signals/Signals.h>
namespace Mad {
@@ -39,14 +39,14 @@ class CommandManager {
unsigned int activeRequests;
- boost::signal0<void> finished;
+ Net::Signals::Signal0<void> finished;
bool disconnect;
void requestFinished() {
activeRequests--;
- finished();
+ finished.emit();
}
void printFSInfo(const Common::XmlPacket &packet);
@@ -74,7 +74,9 @@ class CommandManager {
bool requestsActive() {return (activeRequests > 0);}
bool willDisconnect() {return disconnect;}
- boost::signal0<void>& signalFinished() {return finished;}
+ Net::Signals::Connection connectSignalFinished(const Net::Signals::Signal0<void>::slot_type &slot) {
+ return finished.connect(slot);
+ }
};
}
diff --git a/src/Client/InformationManager.cpp b/src/Client/InformationManager.cpp
index 8fde6f7..b878b94 100644
--- a/src/Client/InformationManager.cpp
+++ b/src/Client/InformationManager.cpp
@@ -39,7 +39,7 @@ void InformationManager::DaemonStateUpdateRequestHandler::handlePacket(const Com
sendPacket(ret);
- signalFinished()();
+ signalFinished();
return;
}
@@ -59,7 +59,7 @@ void InformationManager::DaemonStateUpdateRequestHandler::handlePacket(const Com
ret.setType("OK");
sendPacket(ret);
- signalFinished()();
+ signalFinished();
}
diff --git a/src/Common/ClientConnection.cpp b/src/Common/ClientConnection.cpp
index ee9f5cf..b9a6721 100644
--- a/src/Common/ClientConnection.cpp
+++ b/src/Common/ClientConnection.cpp
@@ -26,7 +26,7 @@ namespace Mad {
namespace Common {
ClientConnection::ClientConnection() : connection(new Net::ClientConnection) {
- connection->signalReceive().connect(boost::bind(&ClientConnection::receive, this, _1));
+ connection->connectSignalReceive(boost::bind(&ClientConnection::receive, this, _1));
}
bool ClientConnection::send(const Net::Packet &packet) {
diff --git a/src/Common/Connection.cpp b/src/Common/Connection.cpp
index f476a68..5b2eee9 100644
--- a/src/Common/Connection.cpp
+++ b/src/Common/Connection.cpp
@@ -24,7 +24,7 @@ namespace Mad {
namespace Common {
void Connection::receive(const Net::Packet &packet) {
- signal(XmlPacket(packet), packet.getRequestId());
+ signalReceive.emit(XmlPacket(packet), packet.getRequestId());
}
bool Connection::sendPacket(const XmlPacket &packet, uint16_t requestId) {
diff --git a/src/Common/Connection.h b/src/Common/Connection.h
index 5ac46a2..2d74548 100644
--- a/src/Common/Connection.h
+++ b/src/Common/Connection.h
@@ -20,11 +20,11 @@
#ifndef MAD_COMMON_CONNECTION_H_
#define MAD_COMMON_CONNECTION_H_
+#include <Net/Signals/Signals.h>
+
#include <stdint.h>
#include <sys/types.h>
-#include <boost/signal.hpp>
-
namespace Mad {
namespace Net {
@@ -35,15 +35,11 @@ namespace Common {
class XmlPacket;
-class Connection {
+class Connection : private boost::noncopyable {
private:
bool authenticated;
- boost::signal2<void, const XmlPacket&, uint16_t> signal;
-
- // Prevent shallow copy
- Connection(const Connection &o);
- Connection& operator=(const Connection &o);
+ Net::Signals::Signal2<void, const XmlPacket&, uint16_t> signalReceive;
protected:
Connection() : authenticated(0) {}
@@ -57,8 +53,8 @@ class Connection {
bool sendPacket(const XmlPacket &packet, uint16_t requestId);
- boost::signal2<void, const XmlPacket&, uint16_t>& signalReceive() {
- return signal;
+ Net::Signals::Connection connectSignalReceive(const Net::Signals::Signal2<void, const XmlPacket&, uint16_t>::slot_type &slot) {
+ return signalReceive.connect(slot);
}
virtual bool disconnect() = 0;
diff --git a/src/Common/Request.h b/src/Common/Request.h
index 3979e0c..6f72667 100644
--- a/src/Common/Request.h
+++ b/src/Common/Request.h
@@ -34,24 +34,24 @@ class Request : public RequestHandler {
private:
friend class RequestManager;
- boost::signal1<void, const Request&> finished;
+ Net::Signals::Signal1<void, const Request&> finished;
std::auto_ptr<XmlPacket> res;
Net::Exception exp;
public:
- typedef boost::function1<void, const Request&> slot_type;
+ typedef Net::Signals::Signal1<void, const Request&>::slot_type slot_type;
protected:
Request(Connection *connection, uint16_t requestId, slot_type slot)
: RequestHandler(connection, requestId), exp(Net::Exception::NOT_FINISHED) {
finished.connect(slot);
- finished.connect(boost::bind((void(boost::signal0<void>::*)())&boost::signal0<void>::operator(), &signalFinished()));
+ finished.connect(boost::bind(&Request::signalFinished, this));
}
- void finish(std::auto_ptr<XmlPacket> result) {res = result; finished(*this);}
- void finish(const XmlPacket& result) {res.reset(new XmlPacket(result)); finished(*this);}
- void finishWithError(const Net::Exception &e) {exp = e; finished(*this);}
+ void finish(std::auto_ptr<XmlPacket> result) {res = result; finished.emit(*this);}
+ void finish(const XmlPacket& result) {res.reset(new XmlPacket(result)); finished.emit(*this);}
+ void finishWithError(const Net::Exception &e) {exp = e; finished.emit(*this);}
virtual void sendRequest() = 0;
virtual void handlePacket(const XmlPacket &packet);
diff --git a/src/Common/RequestHandler.h b/src/Common/RequestHandler.h
index d4a591a..58ffeb7 100644
--- a/src/Common/RequestHandler.h
+++ b/src/Common/RequestHandler.h
@@ -23,6 +23,8 @@
#include "Connection.h"
#include "XmlPacket.h"
+#include <Net/Signals/Signals.h>
+
#include <boost/cstdint.hpp>
namespace Mad {
@@ -33,7 +35,7 @@ class RequestManager;
class RequestHandler {
private:
- boost::signal0<void> finished;
+ Net::Signals::Signal0<void> finished;
Connection *connection;
boost::uint16_t requestId;
@@ -45,7 +47,10 @@ class RequestHandler {
protected:
RequestHandler(Connection *connection0, boost::uint16_t requestId0) : connection(connection0), requestId(requestId0) {}
- boost::signal0<void>& signalFinished() {return finished;}
+ void signalFinished() {finished.emit();}
+ Net::Signals::Connection connectSignalFinished(const Net::Signals::Signal0<void>::slot_type &slot) {
+ return finished.connect(slot);
+ }
Connection* getConnection() const {
return connection;
diff --git a/src/Common/RequestHandlers/DisconnectRequestHandler.cpp b/src/Common/RequestHandlers/DisconnectRequestHandler.cpp
index 163aa75..ac8e7dc 100644
--- a/src/Common/RequestHandlers/DisconnectRequestHandler.cpp
+++ b/src/Common/RequestHandlers/DisconnectRequestHandler.cpp
@@ -35,7 +35,7 @@ void DisconnectRequestHandler::handlePacket(const XmlPacket &packet) {
sendPacket(ret);
- signalFinished()();
+ signalFinished();
return;
}
@@ -47,7 +47,7 @@ void DisconnectRequestHandler::handlePacket(const XmlPacket &packet) {
getConnection()->disconnect();
- signalFinished()();
+ signalFinished();
}
}
diff --git a/src/Common/RequestHandlers/FSInfoRequestHandler.cpp b/src/Common/RequestHandlers/FSInfoRequestHandler.cpp
index 94756b5..9044c68 100644
--- a/src/Common/RequestHandlers/FSInfoRequestHandler.cpp
+++ b/src/Common/RequestHandlers/FSInfoRequestHandler.cpp
@@ -37,7 +37,7 @@ void FSInfoRequestHandler::handlePacket(const XmlPacket &packet) {
sendPacket(ret);
- signalFinished()();
+ signalFinished();
return;
}
@@ -73,7 +73,7 @@ void FSInfoRequestHandler::handlePacket(const XmlPacket &packet) {
}
sendPacket(ret);
- signalFinished()();
+ signalFinished();
}
}
diff --git a/src/Common/RequestHandlers/StatusRequestHandler.cpp b/src/Common/RequestHandlers/StatusRequestHandler.cpp
index c564680..e766670 100644
--- a/src/Common/RequestHandlers/StatusRequestHandler.cpp
+++ b/src/Common/RequestHandlers/StatusRequestHandler.cpp
@@ -38,7 +38,7 @@ void StatusRequestHandler::handlePacket(const XmlPacket &packet) {
sendPacket(ret);
- signalFinished()();
+ signalFinished();
return;
}
@@ -74,7 +74,7 @@ void StatusRequestHandler::handlePacket(const XmlPacket &packet) {
ret.add("loadAvg15", loadAvg15);
sendPacket(ret);
- signalFinished()();
+ signalFinished();
}
}
diff --git a/src/Common/RequestManager.cpp b/src/Common/RequestManager.cpp
index 8940339..f328bf7 100644
--- a/src/Common/RequestManager.cpp
+++ b/src/Common/RequestManager.cpp
@@ -33,7 +33,7 @@ bool RequestManager::RequestMap::addRequest(boost::uint16_t id, boost::shared_pt
if(!insert(std::make_pair(id, info)).second)
return false;
- info->signalFinished().connect(boost::bind(&RequestManager::RequestMap::deleteRequest, this, id));
+ info->connectSignalFinished(boost::bind(&RequestManager::RequestMap::deleteRequest, this, id));
return true;
}
@@ -120,7 +120,7 @@ void RequestManager::registerConnection(Connection *connection) {
requestMaps.insert(std::make_pair(connection, new RequestMap()));
- connection->signalReceive().connect(boost::bind(&RequestManager::receiveHandler, this, connection, _1, _2));
+ connection->connectSignalReceive(boost::bind(&RequestManager::receiveHandler, this, connection, _1, _2));
}
RequestManager::RequestManager() : server(false), lastRequestId(-1) {
diff --git a/src/Daemon/RequestHandlers/CommandRequestHandler.cpp b/src/Daemon/RequestHandlers/CommandRequestHandler.cpp
index f8b7c31..95e57f1 100644
--- a/src/Daemon/RequestHandlers/CommandRequestHandler.cpp
+++ b/src/Daemon/RequestHandlers/CommandRequestHandler.cpp
@@ -36,7 +36,7 @@ void CommandRequestHandler::handlePacket(const Common::XmlPacket &packet) {
sendPacket(ret);
- signalFinished()();
+ signalFinished();
return;
}
@@ -64,7 +64,7 @@ void CommandRequestHandler::handlePacket(const Common::XmlPacket &packet) {
}
sendPacket(ret);
- signalFinished()();
+ signalFinished();
}
}
diff --git a/src/Net/Connection.cpp b/src/Net/Connection.cpp
index 2f65bb0..1ff9926 100644
--- a/src/Net/Connection.cpp
+++ b/src/Net/Connection.cpp
@@ -55,7 +55,7 @@ void Connection::handleHandshake(const boost::system::error_code& error) {
received = 0;
}
- ThreadManager::get()->pushWork(boost::bind((void (boost::signal0<void>::*)())&boost::signal0<void>::operator(), &connectedSignal));
+ ThreadManager::get()->pushWork(boost::bind(&Signals::Signal0<void>::emit, &connectedSignal));
enterReceiveLoop();
}
@@ -69,7 +69,7 @@ void Connection::handleShutdown(const boost::system::error_code& error) {
_setState(DISCONNECTED);
- ThreadManager::get()->pushWork(boost::bind((void (boost::signal0<void>::*)())&boost::signal0<void>::operator(), &disconnectedSignal));
+ ThreadManager::get()->pushWork(boost::bind(&Signals::Signal0<void>::emit, &disconnectedSignal));
}
void Connection::enterReceiveLoop() {
@@ -91,7 +91,7 @@ void Connection::handleHeaderReceive(const std::vector<boost::uint8_t> &data) {
}
if(header.length == 0) {
- ThreadManager::get()->pushWork(boost::bind((void (boost::signal1<void, const Packet&>::*)(const Packet&))&boost::signal1<void, const Packet&>::operator(), &receiveSignal, Packet(ntohs(header.requestId))));
+ ThreadManager::get()->pushWork(boost::bind(&Signals::Signal1<void, const Packet&>::emit, &receiveSignal, Packet(ntohs(header.requestId))));
enterReceiveLoop();
}
@@ -105,7 +105,7 @@ void Connection::handleDataReceive(const std::vector<boost::uint8_t> &data) {
boost::upgrade_lock<boost::shared_mutex> lock(connectionLock);
Packet packet(ntohs(header.requestId), data.data(), ntohs(header.length));
- ThreadManager::get()->pushWork(boost::bind((void (boost::signal1<void, const Packet&>::*)(const Packet&))&boost::signal1<void, const Packet&>::operator(), &receiveSignal, packet));
+ ThreadManager::get()->pushWork(boost::bind(&Signals::Signal1<void, const Packet&>::emit, &receiveSignal, packet));
}
enterReceiveLoop();
diff --git a/src/Net/Connection.h b/src/Net/Connection.h
index 6678bd9..cda8bfe 100644
--- a/src/Net/Connection.h
+++ b/src/Net/Connection.h
@@ -23,12 +23,11 @@
#include <config.h>
#include "Packet.h"
+#include "Signals/Signals.h"
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
-#include <boost/signal.hpp>
-
#include <boost/thread/shared_mutex.hpp>
namespace Mad {
@@ -71,9 +70,9 @@ class Connection : boost::noncopyable {
Packet::Data header;
- boost::signal1<void, const Packet&> receiveSignal;
- boost::signal0<void> connectedSignal;
- boost::signal0<void> disconnectedSignal;
+ Signals::Signal1<void, const Packet&> receiveSignal;
+ Signals::Signal0<void> connectedSignal;
+ Signals::Signal0<void> disconnectedSignal;
bool receiving;
unsigned long sending;
@@ -172,9 +171,26 @@ class Connection : boost::noncopyable {
bool send(const Packet &packet);
- boost::signal1<void, const Packet&>& signalReceive() {return receiveSignal;}
- boost::signal0<void>& signalConnected() {return connectedSignal;}
- boost::signal0<void>& signalDisconnected() {return disconnectedSignal;}
+ Signals::Connection connectSignalReceive(const Signals::Signal1<void, const Packet&>::slot_type &slot) {
+ return receiveSignal.connect(slot);
+ }
+ void disconnectSignalReceive(const Signals::Connection &connection) {
+ receiveSignal.disconnect(connection);
+ }
+
+ Signals::Connection connectSignalConnected(const Signals::Signal0<void>::slot_type &slot) {
+ return connectedSignal.connect(slot);
+ }
+ void disconnectSignalConnected(const Signals::Connection &connection) {
+ connectedSignal.disconnect(connection);
+ }
+
+ Signals::Connection connectSignalDisconnected(const Signals::Signal0<void>::slot_type &slot) {
+ return disconnectedSignal.connect(slot);
+ }
+ void disconnectSignalDisconnected(const Signals::Connection &connection) {
+ disconnectedSignal.disconnect(connection);
+ }
};
}
diff --git a/src/Net/Listener.cpp b/src/Net/Listener.cpp
index be227fd..6da2762 100644
--- a/src/Net/Listener.cpp
+++ b/src/Net/Listener.cpp
@@ -39,8 +39,8 @@ void Listener::handleAccept(const boost::system::error_code &error, boost::share
con->_setState(Connection::CONNECT);
- boost::signals::connection con1 = con->signalConnected().connect(boost::bind(&Listener::handleConnect, this, con));
- boost::signals::connection con2 = con->signalDisconnected().connect(boost::bind(&Listener::handleDisconnect, this, con));
+ Signals::Connection con1 = con->connectSignalConnected(boost::bind(&Listener::handleConnect, this, con));
+ Signals::Connection con2 = con->connectSignalDisconnected(boost::bind(&Listener::handleDisconnect, this, con));
connections.insert(std::make_pair(con, std::make_pair(con1, con2)));
@@ -54,18 +54,19 @@ void Listener::handleAccept(const boost::system::error_code &error, boost::share
void Listener::handleConnect(boost::shared_ptr<Connection> con) {
{
boost::lock_guard<boost::mutex> lock(mutex);
- std::map<boost::shared_ptr<Connection>, std::pair<boost::signals::connection, boost::signals::connection> >::iterator it = connections.find(con);
+ std::map<boost::shared_ptr<Connection>, std::pair<Signals::Connection, Signals::Connection> >::iterator it = connections.find(con);
if(it == connections.end())
return;
// Disconnect signal handlers
- it->second.first.disconnect();
- it->second.second.disconnect();
+
+ con->disconnectSignalConnected(it->second.first);
+ con->disconnectSignalDisconnected(it->second.second);
connections.erase(it);
}
- signal(con);
+ signal.emit(con);
}
void Listener::handleDisconnect(boost::shared_ptr<Connection> con) {
@@ -92,7 +93,7 @@ sslContext(Connection::ioService, boost::asio::ssl::context::sslv23)
}
Listener::~Listener() {
- for(std::map<boost::shared_ptr<Connection>,std::pair<boost::signals::connection, boost::signals::connection> >::iterator con = connections.begin(); con != connections.end(); ++con) {
+ for(std::map<boost::shared_ptr<Connection>,std::pair<Signals::Connection, Signals::Connection> >::iterator con = connections.begin(); con != connections.end(); ++con) {
con->first->disconnect();
// TODO wait...
}
diff --git a/src/Net/Listener.h b/src/Net/Listener.h
index 903c907..ec0cd22 100644
--- a/src/Net/Listener.h
+++ b/src/Net/Listener.h
@@ -38,9 +38,9 @@ class Listener : boost::noncopyable {
boost::asio::ip::tcp::acceptor acceptor;
boost::asio::ssl::context sslContext;
- std::map<boost::shared_ptr<Connection>, std::pair<boost::signals::connection, boost::signals::connection> > connections;
+ std::map<boost::shared_ptr<Connection>, std::pair<Signals::Connection, Signals::Connection> > connections;
- boost::signal1<void, boost::shared_ptr<Connection> > signal;
+ Signals::Signal1<void, boost::shared_ptr<Connection> > signal;
void handleAccept(const boost::system::error_code &error, boost::shared_ptr<Connection> con);
@@ -52,7 +52,12 @@ class Listener : boost::noncopyable {
const boost::asio::ip::tcp::endpoint &address0 = boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 6666)) throw(Exception);
virtual ~Listener();
- boost::signal1<void, boost::shared_ptr<Connection> >& signalNewConnection() {return signal;}
+ Signals::Connection connectSignalNewConnection(const Signals::Signal1<void, boost::shared_ptr<Connection> >::slot_type &slot) {
+ return signal.connect(slot);
+ }
+ void disconnectSignalNewConnection(const Signals::Connection &connection) {
+ signal.disconnect(connection);
+ }
};
}
diff --git a/src/Net/Signals/Connection.h b/src/Net/Signals/Connection.h
new file mode 100644
index 0000000..0e66611
--- /dev/null
+++ b/src/Net/Signals/Connection.h
@@ -0,0 +1,45 @@
+/*
+ * Connection.h
+ *
+ * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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/>.
+ */
+
+#ifndef MAD_NET_SIGNALS_CONNECTION_H_
+#define MAD_NET_SIGNALS_CONNECTION_H_
+
+#include <boost/signals/connection.hpp>
+
+namespace Mad {
+namespace Net {
+namespace Signals {
+
+template <typename SignalType, typename FunctionType> class SignalBase;
+
+class Connection {
+ private:
+ template <typename SignalType, typename FunctionType> friend class SignalBase;
+
+ boost::signals::connection connection;
+
+ Connection(const boost::signals::connection &connection0)
+ : connection(connection0) {}
+};
+
+}
+}
+}
+
+#endif /* MAD_NET_SIGNALS_CONNECTION_H_ */
diff --git a/src/Net/Signals/Signal0.h b/src/Net/Signals/Signal0.h
new file mode 100644
index 0000000..32859ab
--- /dev/null
+++ b/src/Net/Signals/Signal0.h
@@ -0,0 +1,43 @@
+/*
+ * Signal0.h
+ *
+ * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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/>.
+ */
+
+#ifndef MAD_NET_SIGNALS_SIGNAL0_H_
+#define MAD_NET_SIGNALS_SIGNAL0_H_
+
+#include "SignalBase.h"
+
+namespace Mad {
+namespace Net {
+namespace Signals {
+
+template <typename R>
+class Signal0 : public SignalBase<boost::signal0<R>, boost::function0<R> > {
+ public:
+ R emit() {
+ boost::lock_guard<boost::recursive_mutex> lock(SignalBase<boost::signal0<R>, boost::function0<R> >::mutex);
+
+ return SignalBase<boost::signal0<R>, boost::function0<R> >::signal();
+ }
+};
+
+}
+}
+}
+
+#endif /* MAD_NET_SIGNALS_SIGNAL0_H_ */
diff --git a/src/Net/Signals/Signal1.h b/src/Net/Signals/Signal1.h
new file mode 100644
index 0000000..78eaa47
--- /dev/null
+++ b/src/Net/Signals/Signal1.h
@@ -0,0 +1,41 @@
+/*
+ * Signal1.h
+ *
+ * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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/>.
+ */
+
+#ifndef MAD_NET_SIGNALS_SIGNAL1_H_
+#define MAD_NET_SIGNALS_SIGNAL1_H_
+
+namespace Mad {
+namespace Net {
+namespace Signals {
+
+template <typename R, typename T1>
+class Signal1 : public SignalBase<boost::signal1<R, T1>, boost::function1<R, T1> > {
+ public:
+ R emit(T1 arg1) {
+ boost::lock_guard<boost::recursive_mutex> lock(SignalBase<boost::signal1<R, T1>, boost::function1<R, T1> >::mutex);
+
+ return SignalBase<boost::signal1<R, T1>, boost::function1<R, T1> >::signal(arg1);
+ }
+};
+
+}
+}
+}
+
+#endif /* MAD_NET_SIGNALS_SIGNAL1_H_ */
diff --git a/src/Net/Signals/Signal2.h b/src/Net/Signals/Signal2.h
new file mode 100644
index 0000000..afa528e
--- /dev/null
+++ b/src/Net/Signals/Signal2.h
@@ -0,0 +1,41 @@
+/*
+ * Signal2.h
+ *
+ * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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/>.
+ */
+
+#ifndef MAD_NET_SIGNALS_SIGNAL2_H_
+#define MAD_NET_SIGNALS_SIGNAL2_H_
+
+namespace Mad {
+namespace Net {
+namespace Signals {
+
+template <typename R, typename T1, typename T2>
+class Signal2 : public SignalBase<boost::signal2<R, T1, T2>, boost::function2<R, T1, T2> > {
+ public:
+ R emit(T1 arg1, T2 arg2) {
+ boost::lock_guard<boost::recursive_mutex> lock(SignalBase<boost::signal2<R, T1, T2>, boost::function2<R, T1, T2> >::mutex);
+
+ return SignalBase<boost::signal2<R, T1, T2>, boost::function2<R, T1, T2> >::signal(arg1, arg2);
+ }
+};
+
+}
+}
+}
+
+#endif /* MAD_NET_SIGNALS_SIGNAL2_H_ */
diff --git a/src/Net/Signals/SignalBase.h b/src/Net/Signals/SignalBase.h
new file mode 100644
index 0000000..fc5f2c6
--- /dev/null
+++ b/src/Net/Signals/SignalBase.h
@@ -0,0 +1,80 @@
+/*
+ * SignalBase.h
+ *
+ * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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/>.
+ */
+
+#ifndef MAD_SIGNALS_SIGNALBASE_H_
+#define MAD_SIGNALS_SIGNALBASE_H_
+
+#include "Connection.h"
+
+#include <set>
+#include <boost/signals.hpp>
+#include <boost/thread/locks.hpp>
+#include <boost/thread/recursive_mutex.hpp>
+
+namespace Mad {
+namespace Net {
+namespace Signals {
+
+template <typename SignalType, typename FunctionType>
+class SignalBase : private boost::noncopyable {
+ public:
+ typedef boost::slot<FunctionType> slot_type;
+
+ protected:
+ typedef SignalType signal_type;
+
+ std::set<boost::signals::connection> connections;
+ boost::recursive_mutex mutex;
+
+ signal_type signal;
+
+ SignalBase() {}
+ ~SignalBase() {
+ // Wait for other threads
+ boost::lock_guard<boost::recursive_mutex> lock(mutex);
+ }
+
+ public:
+ Connection connect(const slot_type &slot) {
+ boost::lock_guard<boost::recursive_mutex> lock(mutex);
+
+ boost::signals::connection con(signal.connect(slot));
+
+ connections.insert(con);
+ return con;
+ }
+
+ void disconnect(const Connection &connection) {
+ boost::lock_guard<boost::recursive_mutex> lock(mutex);
+
+ std::set<boost::signals::connection>::iterator it = connections.find(connection.connection);
+
+ if(it == connections.end())
+ return;
+
+ it->disconnect();
+ connections.erase(it);
+ }
+};
+
+}
+}
+}
+
+#endif /* MAD_SIGNALS_SIGNALBASE_H_ */
diff --git a/src/Net/Signals/Signals.h b/src/Net/Signals/Signals.h
new file mode 100644
index 0000000..4ee4f95
--- /dev/null
+++ b/src/Net/Signals/Signals.h
@@ -0,0 +1,27 @@
+/*
+ * Signals.h
+ *
+ * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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/>.
+ */
+
+#ifndef MAD_SIGNALS_SIGNALS_H_
+#define MAD_SIGNALS_SIGNALS_H_
+
+#include "Signal0.h"
+#include "Signal1.h"
+#include "Signal2.h"
+
+#endif /* MAD_SIGNALS_SIGNALS_H_ */
diff --git a/src/Server/ConnectionManager.cpp b/src/Server/ConnectionManager.cpp
index 2ce2bb5..37e04d2 100644
--- a/src/Server/ConnectionManager.cpp
+++ b/src/Server/ConnectionManager.cpp
@@ -53,7 +53,7 @@ bool ConnectionManager::ServerConnection::send(const Net::Packet &packet) {
ConnectionManager::ServerConnection::ServerConnection(boost::shared_ptr<Net::Connection> connection0)
: connection(connection0), type(UNKNOWN), hostInfo(0) {
- connection->signalReceive().connect(boost::bind(&ServerConnection::receive, this, _1));
+ connection->connectSignalReceive(boost::bind(&ServerConnection::receive, this, _1));
}
bool ConnectionManager::ServerConnection::isConnected() const {
@@ -146,7 +146,7 @@ void ConnectionManager::configFinished() {
if(listenerAddresses.empty()) {
try {
boost::shared_ptr<Net::Listener> listener(new Net::Listener(x509CertFile, x509KeyFile));
- listener->signalNewConnection().connect(boost::bind(&ConnectionManager::handleNewConnection, this, _1));
+ listener->connectSignalNewConnection(boost::bind(&ConnectionManager::handleNewConnection, this, _1));
listeners.push_back(listener);
}
catch(Net::Exception &e) {
@@ -157,7 +157,7 @@ void ConnectionManager::configFinished() {
for(std::vector<boost::asio::ip::tcp::endpoint>::const_iterator address = listenerAddresses.begin(); address != listenerAddresses.end(); ++address) {
try {
boost::shared_ptr<Net::Listener> listener(new Net::Listener(x509CertFile, x509KeyFile, *address));
- listener->signalNewConnection().connect(boost::bind(&ConnectionManager::handleNewConnection, this, _1));
+ listener->connectSignalNewConnection(boost::bind(&ConnectionManager::handleNewConnection, this, _1));
listeners.push_back(listener);
}
catch(Net::Exception &e) {
@@ -169,7 +169,7 @@ void ConnectionManager::configFinished() {
void ConnectionManager::handleNewConnection(boost::shared_ptr<Net::Connection> con) {
boost::shared_ptr<ServerConnection> connection(new ServerConnection(con));
- con->signalDisconnected().connect(boost::bind(&ConnectionManager::handleDisconnect, this, connection));
+ con->connectSignalDisconnected(boost::bind(&ConnectionManager::handleDisconnect, this, connection));
connections.insert(connection);
Common::RequestManager::get()->registerConnection(connection.get());
diff --git a/src/Server/RequestHandlers/DaemonCommandRequestHandler.cpp b/src/Server/RequestHandlers/DaemonCommandRequestHandler.cpp
index e4b511e..3a09de7 100644
--- a/src/Server/RequestHandlers/DaemonCommandRequestHandler.cpp
+++ b/src/Server/RequestHandlers/DaemonCommandRequestHandler.cpp
@@ -37,7 +37,7 @@ void DaemonCommandRequestHandler::handlePacket(const Common::XmlPacket &packet)
sendPacket(ret);
- signalFinished()();
+ signalFinished();
return;
}
@@ -77,7 +77,7 @@ void DaemonCommandRequestHandler::requestFinished(const Common::Request &request
sendPacket(ret);
}
- signalFinished()();
+ signalFinished();
}
}
diff --git a/src/Server/RequestHandlers/DaemonFSInfoRequestHandler.cpp b/src/Server/RequestHandlers/DaemonFSInfoRequestHandler.cpp
index 11a3f09..2bb316b 100644
--- a/src/Server/RequestHandlers/DaemonFSInfoRequestHandler.cpp
+++ b/src/Server/RequestHandlers/DaemonFSInfoRequestHandler.cpp
@@ -37,7 +37,7 @@ void DaemonFSInfoRequestHandler::handlePacket(const Common::XmlPacket &packet) {
sendPacket(ret);
- signalFinished()();
+ signalFinished();
return;
}
@@ -75,7 +75,7 @@ void DaemonFSInfoRequestHandler::requestFinished(const Common::Request &request)
sendPacket(ret);
}
- signalFinished()();
+ signalFinished();
}
}
diff --git a/src/Server/RequestHandlers/DaemonListRequestHandler.cpp b/src/Server/RequestHandlers/DaemonListRequestHandler.cpp
index 541148d..f960eaa 100644
--- a/src/Server/RequestHandlers/DaemonListRequestHandler.cpp
+++ b/src/Server/RequestHandlers/DaemonListRequestHandler.cpp
@@ -35,7 +35,7 @@ void DaemonListRequestHandler::handlePacket(const Common::XmlPacket &packet) {
sendPacket(ret);
- signalFinished()();
+ signalFinished();
return;
}
@@ -57,7 +57,7 @@ void DaemonListRequestHandler::handlePacket(const Common::XmlPacket &packet) {
sendPacket(ret);
- signalFinished()();
+ signalFinished();
}
}
diff --git a/src/Server/RequestHandlers/DaemonStatusRequestHandler.cpp b/src/Server/RequestHandlers/DaemonStatusRequestHandler.cpp
index c1e2fcd..15f63c7 100644
--- a/src/Server/RequestHandlers/DaemonStatusRequestHandler.cpp
+++ b/src/Server/RequestHandlers/DaemonStatusRequestHandler.cpp
@@ -37,7 +37,7 @@ void DaemonStatusRequestHandler::handlePacket(const Common::XmlPacket &packet) {
sendPacket(ret);
- signalFinished()();
+ signalFinished();
return;
}
@@ -77,7 +77,7 @@ void DaemonStatusRequestHandler::requestFinished(const Common::Request &request)
sendPacket(ret);
}
- signalFinished()();
+ signalFinished();
}
}
diff --git a/src/Server/RequestHandlers/GSSAPIAuthRequestHandler.cpp b/src/Server/RequestHandlers/GSSAPIAuthRequestHandler.cpp
index ade8329..dba92c7 100644
--- a/src/Server/RequestHandlers/GSSAPIAuthRequestHandler.cpp
+++ b/src/Server/RequestHandlers/GSSAPIAuthRequestHandler.cpp
@@ -39,7 +39,7 @@ void GSSAPIAuthRequestHandler::handlePacket(const Common::XmlPacket &packet) {
sendPacket(ret);
- signalFinished()();
+ signalFinished();
return;
}
@@ -118,7 +118,7 @@ void GSSAPIAuthRequestHandler::handlePacket(const Common::XmlPacket &packet) {
if(majStat != GSS_S_COMPLETE)
return;
- signalFinished()();
+ signalFinished();
}
}
diff --git a/src/Server/RequestHandlers/GroupListRequestHandler.cpp b/src/Server/RequestHandlers/GroupListRequestHandler.cpp
index 356e105..5d8c9be 100644
--- a/src/Server/RequestHandlers/GroupListRequestHandler.cpp
+++ b/src/Server/RequestHandlers/GroupListRequestHandler.cpp
@@ -36,7 +36,7 @@ void GroupListRequestHandler::handlePacket(const Common::XmlPacket &packet) {
sendPacket(ret);
- signalFinished()();
+ signalFinished();
return;
}
@@ -69,7 +69,7 @@ void GroupListRequestHandler::handlePacket(const Common::XmlPacket &packet) {
}
sendPacket(ret);
- signalFinished()();
+ signalFinished();
}
}
diff --git a/src/Server/RequestHandlers/GroupUserListRequestHandler.cpp b/src/Server/RequestHandlers/GroupUserListRequestHandler.cpp
index df1253a..07ed446 100644
--- a/src/Server/RequestHandlers/GroupUserListRequestHandler.cpp
+++ b/src/Server/RequestHandlers/GroupUserListRequestHandler.cpp
@@ -36,7 +36,7 @@ void GroupUserListRequestHandler::handlePacket(const Common::XmlPacket &packet)
sendPacket(ret);
- signalFinished()();
+ signalFinished();
return;
}
@@ -66,7 +66,7 @@ void GroupUserListRequestHandler::handlePacket(const Common::XmlPacket &packet)
}
sendPacket(ret);
- signalFinished()();
+ signalFinished();
}
}
diff --git a/src/Server/RequestHandlers/IdentifyRequestHandler.cpp b/src/Server/RequestHandlers/IdentifyRequestHandler.cpp
index b47b505..5300c19 100644
--- a/src/Server/RequestHandlers/IdentifyRequestHandler.cpp
+++ b/src/Server/RequestHandlers/IdentifyRequestHandler.cpp
@@ -36,7 +36,7 @@ void IdentifyRequestHandler::handlePacket(const Common::XmlPacket &packet) {
sendPacket(ret);
- signalFinished()();
+ signalFinished();
return;
}
@@ -62,7 +62,7 @@ void IdentifyRequestHandler::handlePacket(const Common::XmlPacket &packet) {
sendPacket(ret);
}
- signalFinished()();
+ signalFinished();
}
}
diff --git a/src/Server/RequestHandlers/LogRequestHandler.cpp b/src/Server/RequestHandlers/LogRequestHandler.cpp
index f4547e4..019a7f2 100644
--- a/src/Server/RequestHandlers/LogRequestHandler.cpp
+++ b/src/Server/RequestHandlers/LogRequestHandler.cpp
@@ -36,7 +36,7 @@ void LogRequestHandler::handlePacket(const Common::XmlPacket &packet) {
sendPacket(ret);
- signalFinished()();
+ signalFinished();
return;
}
@@ -55,7 +55,7 @@ void LogRequestHandler::handlePacket(const Common::XmlPacket &packet) {
sendPacket(ret);
- signalFinished()();
+ signalFinished();
}
}
diff --git a/src/Server/RequestHandlers/UserGroupListRequestHandler.cpp b/src/Server/RequestHandlers/UserGroupListRequestHandler.cpp
index e127649..435a507 100644
--- a/src/Server/RequestHandlers/UserGroupListRequestHandler.cpp
+++ b/src/Server/RequestHandlers/UserGroupListRequestHandler.cpp
@@ -36,7 +36,7 @@ void UserGroupListRequestHandler::handlePacket(const Common::XmlPacket &packet)
sendPacket(ret);
- signalFinished()();
+ signalFinished();
return;
}
@@ -66,7 +66,7 @@ void UserGroupListRequestHandler::handlePacket(const Common::XmlPacket &packet)
}
sendPacket(ret);
- signalFinished()();
+ signalFinished();
}
}
diff --git a/src/Server/RequestHandlers/UserInfoRequestHandler.cpp b/src/Server/RequestHandlers/UserInfoRequestHandler.cpp
index e4ef447..1773658 100644
--- a/src/Server/RequestHandlers/UserInfoRequestHandler.cpp
+++ b/src/Server/RequestHandlers/UserInfoRequestHandler.cpp
@@ -36,7 +36,7 @@ void UserInfoRequestHandler::handlePacket(const Common::XmlPacket &packet) {
sendPacket(ret);
- signalFinished()();
+ signalFinished();
return;
}
@@ -63,7 +63,7 @@ void UserInfoRequestHandler::handlePacket(const Common::XmlPacket &packet) {
}
sendPacket(ret);
- signalFinished()();
+ signalFinished();
}
}
diff --git a/src/Server/RequestHandlers/UserListRequestHandler.cpp b/src/Server/RequestHandlers/UserListRequestHandler.cpp
index 37db6d5..519ba6f 100644
--- a/src/Server/RequestHandlers/UserListRequestHandler.cpp
+++ b/src/Server/RequestHandlers/UserListRequestHandler.cpp
@@ -36,7 +36,7 @@ void UserListRequestHandler::handlePacket(const Common::XmlPacket &packet) {
sendPacket(ret);
- signalFinished()();
+ signalFinished();
return;
}
@@ -69,7 +69,7 @@ void UserListRequestHandler::handlePacket(const Common::XmlPacket &packet) {
}
sendPacket(ret);
- signalFinished()();
+ signalFinished();
}
}
diff --git a/src/madc.cpp b/src/madc.cpp
index fd6b547..017b486 100644
--- a/src/madc.cpp
+++ b/src/madc.cpp
@@ -92,7 +92,7 @@ int main(int argc, char *argv[]) {
std::cerr << " done." << std::endl << std::endl;
Client::CommandParser::get()->setConnection(connection);
- Client::CommandManager::get()->signalFinished().connect(&commandFinished);
+ Client::CommandManager::get()->connectSignalFinished(&commandFinished);
while(connection->isConnected() && !Client::CommandManager::get()->willDisconnect()) {
char *cmd = readline("mad> ");