diff options
Diffstat (limited to 'src/Common')
-rw-r--r-- | src/Common/ActionManager.cpp | 87 | ||||
-rw-r--r-- | src/Common/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Common/ClientConnection.cpp | 8 | ||||
-rw-r--r-- | src/Common/ClientConnection.h | 9 | ||||
-rw-r--r-- | src/Common/Connection.h | 4 | ||||
-rw-r--r-- | src/Common/Requests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Common/Requests/IdentifyRequest.cpp | 38 | ||||
-rw-r--r-- | src/Common/Requests/IdentifyRequest.h (renamed from src/Common/ActionManager.h) | 40 |
8 files changed, 64 insertions, 126 deletions
diff --git a/src/Common/ActionManager.cpp b/src/Common/ActionManager.cpp deleted file mode 100644 index fc3c034..0000000 --- a/src/Common/ActionManager.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * ActionManager.cpp - * - * Copyright (C) 2008 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/>. - */ - -#include "ActionManager.h" -#include <Net/FdManager.h> - -#include <fcntl.h> -#include <signal.h> - -namespace Mad { -namespace Common { - -ActionManager ActionManager::actionManager; - - -void ActionManager::doInit() { - // TODO Error handling - - pipe(notifyPipe); - - fcntl(notifyPipe[0], F_SETFL, fcntl(notifyPipe[0], F_GETFL) | O_NONBLOCK); - fcntl(notifyPipe[1], F_SETFL, fcntl(notifyPipe[1], F_GETFL) | O_NONBLOCK); - - Net::FdManager::get()->registerFd(notifyPipe[0], boost::bind(&ActionManager::run, this), POLLIN); -} - -void ActionManager::doDeinit() { - Net::FdManager::get()->unregisterFd(notifyPipe[0]); - - close(notifyPipe[0]); - close(notifyPipe[1]); -} - - -void ActionManager::run() { - // Empty pipe - char buf[16]; - while(read(notifyPipe[0], buf, sizeof(buf)) > 0) {} - - while(true) { - sigset_t set, oldset; - sigfillset(&set); - sigprocmask(SIG_SETMASK, &set, &oldset); - - if(actions.empty()) { - sigprocmask(SIG_SETMASK, &oldset, 0); - return; - } - - boost::function0<void> action = actions.front(); - actions.pop(); - - sigprocmask(SIG_SETMASK, &oldset, 0); - - action(); - } -} - -void ActionManager::add(const boost::function0<void> &action) { - sigset_t set, oldset; - sigfillset(&set); - sigprocmask(SIG_SETMASK, &set, &oldset); - - actions.push(action); - write(notifyPipe[1], "", 1); - - sigprocmask(SIG_SETMASK, &oldset, 0); -} - -} -} diff --git a/src/Common/CMakeLists.txt b/src/Common/CMakeLists.txt index e2f7b4b..fe18760 100644 --- a/src/Common/CMakeLists.txt +++ b/src/Common/CMakeLists.txt @@ -6,7 +6,7 @@ include_directories(${INCLUDES}) link_directories(${LTDL_LIBRARY_DIR}) add_library(Common - ActionManager.cpp Base64Encoder.cpp ClientConnection.cpp ConfigEntry.cpp + Base64Encoder.cpp ClientConnection.cpp ConfigEntry.cpp ConfigManager.cpp Connection.cpp Initializable.cpp Logger.cpp LogManager.cpp ModuleManager.cpp Request.cpp RequestManager.cpp SystemManager.cpp Tokenizer.cpp XmlPacket.cpp diff --git a/src/Common/ClientConnection.cpp b/src/Common/ClientConnection.cpp index 381f822..d061c8d 100644 --- a/src/Common/ClientConnection.cpp +++ b/src/Common/ClientConnection.cpp @@ -33,8 +33,8 @@ bool ClientConnection::send(const Net::Packet &packet) { return connection->send(packet); } -void ClientConnection::connect(const Net::IPAddress &address, bool daemon) throw(Net::Exception) { - connection->connect(address, daemon); +void ClientConnection::connect(const boost::asio::ip::tcp::endpoint &address) throw(Net::Exception) { + connection->connect(address); } bool ClientConnection::isConnecting() const { @@ -50,7 +50,7 @@ bool ClientConnection::disconnect() { return true; } -void* ClientConnection::getCertificate(size_t *size) const { +/*void* ClientConnection::getCertificate(size_t *size) const { const gnutls_datum_t *cert = connection->getCertificate(); *size = cert->size; @@ -62,7 +62,7 @@ void* ClientConnection::getPeerCertificate(size_t *size) const { *size = cert->size; return cert->data; -} +}*/ } } diff --git a/src/Common/ClientConnection.h b/src/Common/ClientConnection.h index 09ca4db..4710bd4 100644 --- a/src/Common/ClientConnection.h +++ b/src/Common/ClientConnection.h @@ -23,11 +23,12 @@ #include "Connection.h" #include <Net/Exception.h> +#include <boost/asio.hpp> + namespace Mad { namespace Net { class ClientConnection; -class IPAddress; } namespace Common { @@ -43,14 +44,14 @@ class ClientConnection : public Connection { ClientConnection(); virtual ~ClientConnection() {} - void connect(const Net::IPAddress &address, bool daemon = false) throw(Net::Exception); + void connect(const boost::asio::ip::tcp::endpoint &address) throw(Net::Exception); bool isConnecting() const; bool isConnected() const; virtual bool disconnect(); - virtual void* getCertificate(size_t *size) const; - virtual void* getPeerCertificate(size_t *size) const; + //virtual void* getCertificate(size_t *size) const; + //virtual void* getPeerCertificate(size_t *size) const; }; } diff --git a/src/Common/Connection.h b/src/Common/Connection.h index ea90c4c..0cfc742 100644 --- a/src/Common/Connection.h +++ b/src/Common/Connection.h @@ -62,8 +62,8 @@ class Connection { } virtual bool disconnect() = 0; - virtual void* getCertificate(size_t *size) const = 0; - virtual void* getPeerCertificate(size_t *size) const = 0; + //virtual void* getCertificate(size_t *size) const = 0; + //virtual void* getPeerCertificate(size_t *size) const = 0; virtual diff --git a/src/Common/Requests/CMakeLists.txt b/src/Common/Requests/CMakeLists.txt index 1b632e2..1d49f0e 100644 --- a/src/Common/Requests/CMakeLists.txt +++ b/src/Common/Requests/CMakeLists.txt @@ -1,6 +1,6 @@ include_directories(${INCLUDES}) add_library(Requests - DisconnectRequest.cpp GSSAPIAuthRequest.cpp SimpleRequest.cpp UserInfoRequest.cpp + DisconnectRequest.cpp IdentifyRequest.cpp SimpleRequest.cpp UserInfoRequest.cpp ) target_link_libraries(Requests ${KRB5_LIBRARIES}) diff --git a/src/Common/Requests/IdentifyRequest.cpp b/src/Common/Requests/IdentifyRequest.cpp new file mode 100644 index 0000000..6cf09d1 --- /dev/null +++ b/src/Common/Requests/IdentifyRequest.cpp @@ -0,0 +1,38 @@ +/* + * IdentifyRequest.cpp + * + * Copyright (C) 2008 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/>. + */ + +#include "IdentifyRequest.h" + +namespace Mad { +namespace Common { +namespace Requests { + +void IdentifyRequest::sendRequest() { + Common::XmlPacket packet; + packet.setType("Identify"); + + if(!hostname.empty()) + packet.add("hostname", hostname); + + sendPacket(packet); +} + +} +} +} diff --git a/src/Common/ActionManager.h b/src/Common/Requests/IdentifyRequest.h index 5d3dc15..3798909 100644 --- a/src/Common/ActionManager.h +++ b/src/Common/Requests/IdentifyRequest.h @@ -1,5 +1,5 @@ /* - * ActionManager.h + * IdentifyRequest.h * * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de> * @@ -17,45 +17,31 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef MAD_COMMON_ACTIONMANAGER_H_ -#define MAD_COMMON_ACTIONMANAGER_H_ +#ifndef MAD_DAEMON_REQUESTS_IDENTIFYREQUEST_H_ +#define MAD_DAEMON_REQUESTS_IDENTIFYREQUEST_H_ -#include "Initializable.h" +#include "../Request.h" -#include <queue> -#include <unistd.h> - -#include <boost/function.hpp> +#include <string> namespace Mad { namespace Common { +namespace Requests { -class ActionManager : public Initializable { +class IdentifyRequest : public Common::Request { private: - std::queue<boost::function0<void> > actions; - int notifyPipe[2]; - - static ActionManager actionManager; - - ActionManager() {} + std::string hostname; protected: - void doInit(); - void doDeinit(); + virtual void sendRequest(); public: - void run(); - void add(const boost::function0<void> &action); - - static ActionManager *get() { - if(!actionManager.isInitialized()) - actionManager.init(); - - return &actionManager; - } + IdentifyRequest(Common::Connection *connection, uint16_t requestId, slot_type slot, const std::string &hostname0 = std::string()) + : Common::Request(connection, requestId, slot), hostname(hostname0) {} }; } } +} -#endif /* MAD_COMMON_ACTIONMANAGER_H_ */ +#endif /* MAD_DAEMON_REQUESTS_IDENTIFYREQUEST_H_ */ |