diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-08-18 15:58:17 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-08-18 15:58:17 +0200 |
commit | db5ad2e09a6b38e841463dbe7eb076492b62c948 (patch) | |
tree | 5907f6416e35cbd25432a5f1f6dc9664d36aa73c /src/Server | |
parent | 5da7b0847bac2a5abec95b9ac1701b74baae8964 (diff) | |
download | mad-db5ad2e09a6b38e841463dbe7eb076492b62c948.tar mad-db5ad2e09a6b38e841463dbe7eb076492b62c948.zip |
Mad funktioniert jetzt unter Windows
Diffstat (limited to 'src/Server')
-rw-r--r-- | src/Server/Application.h | 4 | ||||
-rw-r--r-- | src/Server/CMakeLists.txt | 16 | ||||
-rw-r--r-- | src/Server/ConnectionManager.cpp | 19 | ||||
-rw-r--r-- | src/Server/ConnectionManager.h | 6 | ||||
-rw-r--r-- | src/Server/RequestHandlers/CMakeLists.txt | 8 | ||||
-rw-r--r-- | src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp | 20 | ||||
-rw-r--r-- | src/Server/RequestHandlers/ConnectionRequestHandlerGroup.h | 4 | ||||
-rw-r--r-- | src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp | 2 | ||||
-rw-r--r-- | src/Server/RequestHandlers/DaemonRequestHandlerGroup.h | 4 | ||||
-rw-r--r-- | src/Server/RequestHandlers/UserRequestHandlerGroup.cpp | 2 | ||||
-rw-r--r-- | src/Server/RequestHandlers/UserRequestHandlerGroup.h | 4 | ||||
-rw-r--r-- | src/Server/Requests/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/Server/Requests/CommandRequest.h | 4 | ||||
-rw-r--r-- | src/Server/Requests/DaemonStateUpdateRequest.h | 4 | ||||
-rw-r--r-- | src/Server/export.h | 11 |
15 files changed, 71 insertions, 43 deletions
diff --git a/src/Server/Application.h b/src/Server/Application.h index 302d3be..205d398 100644 --- a/src/Server/Application.h +++ b/src/Server/Application.h @@ -20,6 +20,8 @@ #ifndef MAD_SERVER_APPLICATION_H_ #define MAD_SERVER_APPLICATION_H_ +#include "export.h" + #include <Common/Application.h> namespace Mad { @@ -27,7 +29,7 @@ namespace Server { class ConnectionManager; -class Application : public Common::Application { +class MAD_SERVER_EXPORT Application : public Common::Application { private: ConnectionManager *connectionManager; diff --git a/src/Server/CMakeLists.txt b/src/Server/CMakeLists.txt index 22a7826..b9bffa1 100644 --- a/src/Server/CMakeLists.txt +++ b/src/Server/CMakeLists.txt @@ -1,10 +1,16 @@ -add_subdirectory(RequestHandlers) -add_subdirectory(Requests) - include_directories(${INCLUDES}) -add_library(Server +mad_library(Server + export.h + + RequestHandlers/ConnectionRequestHandlerGroup.cpp RequestHandlers/ConnectionRequestHandlerGroup.h + RequestHandlers/DaemonRequestHandlerGroup.cpp RequestHandlers/DaemonRequestHandlerGroup.h + RequestHandlers/UserRequestHandlerGroup.cpp RequestHandlers/UserRequestHandlerGroup.h + + Requests/CommandRequest.cpp Requests/CommandRequest.h + Requests/DaemonStateUpdateRequest.cpp Requests/DaemonStateUpdateRequest.h + Application.cpp Application.h ConnectionManager.cpp ConnectionManager.h ) -target_link_libraries(Server ServerRequestHandlers ServerRequests Common) +target_link_libraries(Server Common) diff --git a/src/Server/ConnectionManager.cpp b/src/Server/ConnectionManager.cpp index 8fe6408..160f3c3 100644 --- a/src/Server/ConnectionManager.cpp +++ b/src/Server/ConnectionManager.cpp @@ -32,7 +32,7 @@ #include <Net/Packet.h> #include <Net/Listener.h> -#include <unistd.h> +//#include <unistd.h> #include <algorithm> namespace Mad { @@ -124,7 +124,7 @@ bool ConnectionManager::handleConfigEntry(const Core::ConfigEntry &entry, bool h listenerAddresses.push_back(parseAddress(entry[0][0])); } catch(Core::Exception &e) { - application->logf(Core::LoggerBase::WARNING, "ConnectionManager: Invalid listen address '%s'", entry[0][0].c_str()); + application->logf(Core::LoggerBase::LOG_WARNING, "ConnectionManager: Invalid listen address '%s'", entry[0][0].c_str()); } return true; @@ -229,14 +229,13 @@ ConnectionManager::~ConnectionManager() { } boost::shared_ptr<Common::Connection> ConnectionManager::getDaemonConnection(const std::string &name) const throw (Core::Exception&) { - const Common::HostInfo *hostInfo; - - try { - hostInfo = &daemonInfo.at(name); - } - catch(std::out_of_range&) { + + + std::map<std::string, Common::HostInfo>::const_iterator hostIt = daemonInfo.find(name); + if(hostIt == daemonInfo.end()) throw Core::Exception(Core::Exception::UNKNOWN_DAEMON); - } + + const Common::HostInfo *hostInfo = &hostIt->second; if(hostInfo->getState() != Common::HostInfo::INACTIVE) { for(std::set<boost::shared_ptr<ServerConnection> >::const_iterator it = connections.begin(); it != connections.end(); ++it) { @@ -277,7 +276,7 @@ void ConnectionManager::identifyDaemonConnection(Common::Connection *con, const if(hostInfo->getState() != Common::HostInfo::INACTIVE) { try { getDaemonConnection(name)->disconnect(); - application->log(Core::LoggerBase::WARNING, "Disconnecting old connection."); + application->log(Core::LoggerBase::LOG_WARNING, "Disconnecting old connection."); } catch(Core::Exception&) {} } diff --git a/src/Server/ConnectionManager.h b/src/Server/ConnectionManager.h index 6fc6013..bdf1b4d 100644 --- a/src/Server/ConnectionManager.h +++ b/src/Server/ConnectionManager.h @@ -20,6 +20,8 @@ #ifndef MAD_SERVER_CONNECTIONMANAGER_H_ #define MAD_SERVER_CONNECTIONMANAGER_H_ +#include "export.h" + #include <Core/Configurable.h> #include <Core/Exception.h> #include <Common/Connection.h> @@ -45,7 +47,7 @@ namespace Server { class Application; -class ConnectionManager : public Core::Configurable, private boost::noncopyable { +class MAD_SERVER_EXPORT ConnectionManager : public Core::Configurable, private boost::noncopyable { private: class ServerConnection : public Common::Connection { public: @@ -103,7 +105,7 @@ class ConnectionManager : public Core::Configurable, private boost::noncopyable std::set<boost::shared_ptr<ServerConnection> > connections; - std::map<std::string,Common::HostInfo> daemonInfo; + std::map<std::string, Common::HostInfo> daemonInfo; boost::shared_ptr<Common::RequestHandlerGroup> connectionRequestHandlerGroup; boost::shared_ptr<Common::RequestHandlerGroup> daemonRequestHandlerGroup; diff --git a/src/Server/RequestHandlers/CMakeLists.txt b/src/Server/RequestHandlers/CMakeLists.txt deleted file mode 100644 index cb44105..0000000 --- a/src/Server/RequestHandlers/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -include_directories(${INCLUDES}) - -add_library(ServerRequestHandlers STATIC - ConnectionRequestHandlerGroup.cpp ConnectionRequestHandlerGroup.h - DaemonRequestHandlerGroup.cpp DaemonRequestHandlerGroup.h - UserRequestHandlerGroup.cpp UserRequestHandlerGroup.h -) -#target_link_libraries(ServerRequestHandlers ${KRB5_LIBRARIES}) diff --git a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp index 0de73f9..e94853f 100644 --- a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp @@ -23,6 +23,8 @@ #include <Core/LogManager.h> +#include <boost/date_time/posix_time/posix_time.hpp> + namespace Mad { namespace Server { namespace RequestHandlers { @@ -56,17 +58,27 @@ void ConnectionRequestHandlerGroup::handleIdentifyRequest(boost::shared_ptr<cons void ConnectionRequestHandlerGroup::handleLogRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { // TODO Require authentication + + boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); + + const std::string ×tr = packet->get<const std::string&>("timestamp"); + if(!timestr.empty()) { + try { + timestamp = boost::posix_time::from_iso_string(timestr); + } + catch(...) {} + } try { application->getLogManager()->log( - packet->get<Core::LoggerBase::MessageCategory>("category"), - packet->get<Core::LoggerBase::MessageLevel>("level"), - packet->get<time_t>("timestamp"), + static_cast<Core::LoggerBase::MessageCategory>(packet->get<long>("category")), + static_cast<Core::LoggerBase::MessageLevel>(packet->get<long>("level")), + timestamp, packet->get<const std::string&>("message"), application->getConnectionManager()->getDaemonName(connection)); } catch(Core::Exception &e) { - application->logf(Core::LoggerBase::ERROR, "Can't determine daemon name: %s", e.strerror().c_str()); + application->logf(Core::LoggerBase::LOG_ERROR, "Can't determine daemon name: %s", e.strerror().c_str()); } ret->setType("OK"); diff --git a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.h b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.h index c3deed1..7f6b17c 100644 --- a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.h +++ b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.h @@ -20,6 +20,8 @@ #ifndef MAD_SERVER_REQUESTHANDLERS_CONNECTIONREQUESTHANDLERGROUP_H_ #define MAD_SERVER_REQUESTHANDLERS_CONNECTIONREQUESTHANDLERGROUP_H_ +#include "../export.h" + #include <Common/RequestHandlers/SimpleRequestHandlerGroup.h> namespace Mad { @@ -29,7 +31,7 @@ class Application; namespace RequestHandlers { -class ConnectionRequestHandlerGroup : public Common::RequestHandlers::SimpleRequestHandlerGroup { +class MAD_SERVER_EXPORT ConnectionRequestHandlerGroup : public Common::RequestHandlers::SimpleRequestHandlerGroup { private: Application *application; diff --git a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp index 4b2dd0c..0345d7b 100644 --- a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp @@ -32,7 +32,7 @@ namespace RequestHandlers { void DaemonRequestHandlerGroup::DaemonRequestHandler::handlePacket(boost::shared_ptr<const Common::XmlPacket> packet) { if(packet->getType() != type) { - getApplication()->log(Core::LoggerBase::ERROR, "Received an unexpected packet."); + getApplication()->log(Core::LoggerBase::LOG_ERROR, "Received an unexpected packet."); Common::XmlPacket ret; ret.setType("Error"); diff --git a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h index b32005f..086bf16 100644 --- a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h +++ b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h @@ -20,6 +20,8 @@ #ifndef MAD_SERVER_REQUESTHANDLERS_DAEMONREQUESTHANDLERGROUP_H_ #define MAD_SERVER_REQUESTHANDLERS_DAEMONREQUESTHANDLERGROUP_H_ +#include "../export.h" + #include <Common/RequestHandlerGroup.h> #include <Core/Exception.h> @@ -29,7 +31,7 @@ class ConnectionManager; namespace RequestHandlers { -class DaemonRequestHandlerGroup : public Common::RequestHandlerGroup { +class MAD_SERVER_EXPORT DaemonRequestHandlerGroup : public Common::RequestHandlerGroup { private: class DaemonRequestHandler : public Common::RequestHandler { private: diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp index a1aa829..873815a 100644 --- a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp @@ -236,7 +236,7 @@ void UserRequestHandlerGroup::handleFullUserGroupListRequest(boost::shared_ptr<c if(userGroups) { Common::XmlPacket::List *list = ret->createList("userGroupList"); - for(std::map<unsigned long, unsigned long>::const_iterator userGroup = userGroups->begin(); userGroup != userGroups->end(); ++userGroup) { + for(std::multimap<unsigned long, unsigned long>::const_iterator userGroup = userGroups->begin(); userGroup != userGroups->end(); ++userGroup) { Common::XmlPacket::List::iterator entry = list->addEntry(); entry->set("uid", userGroup->first); diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.h b/src/Server/RequestHandlers/UserRequestHandlerGroup.h index ee4b7f4..aed585f 100644 --- a/src/Server/RequestHandlers/UserRequestHandlerGroup.h +++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.h @@ -20,6 +20,8 @@ #ifndef MAD_SERVER_REQUESTHANDLERS_USERREQUESTHANDLERGROUP_H_ #define MAD_SERVER_REQUESTHANDLERS_USERREQUESTHANDLERGROUP_H_ +#include "../export.h" + #include <Common/RequestHandlers/SimpleRequestHandlerGroup.h> namespace Mad { @@ -29,7 +31,7 @@ class Application; namespace RequestHandlers { -class UserRequestHandlerGroup : public Common::RequestHandlers::SimpleRequestHandlerGroup { +class MAD_SERVER_EXPORT UserRequestHandlerGroup : public Common::RequestHandlers::SimpleRequestHandlerGroup { private: Application *application; diff --git a/src/Server/Requests/CMakeLists.txt b/src/Server/Requests/CMakeLists.txt deleted file mode 100644 index 6c5c8c5..0000000 --- a/src/Server/Requests/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -include_directories(${INCLUDES}) - -add_library(ServerRequests STATIC - CommandRequest.cpp CommandRequest.h - DaemonStateUpdateRequest.cpp DaemonStateUpdateRequest.h -) diff --git a/src/Server/Requests/CommandRequest.h b/src/Server/Requests/CommandRequest.h index 95748fd..40f23fa 100644 --- a/src/Server/Requests/CommandRequest.h +++ b/src/Server/Requests/CommandRequest.h @@ -20,13 +20,15 @@ #ifndef MAD_SERVER_REQUESTS_COMMANDREQUEST_H_ #define MAD_SERVER_REQUESTS_COMMANDREQUEST_H_ +#include "../export.h" + #include <Common/Request.h> namespace Mad { namespace Server { namespace Requests { -class CommandRequest : public Common::Request { +class MAD_SERVER_EXPORT CommandRequest : public Common::Request { private: bool reboot; diff --git a/src/Server/Requests/DaemonStateUpdateRequest.h b/src/Server/Requests/DaemonStateUpdateRequest.h index fc80920..862e8ac 100644 --- a/src/Server/Requests/DaemonStateUpdateRequest.h +++ b/src/Server/Requests/DaemonStateUpdateRequest.h @@ -20,6 +20,8 @@ #ifndef MAD_SERVER_REQUESTS_DAEMONSTATEUPDATEREQUEST_H_ #define MAD_SERVER_REQUESTS_DAEMONSTATEUPDATEREQUEST_H_ +#include "../export.h" + #include <Common/Request.h> #include <Common/HostInfo.h> @@ -27,7 +29,7 @@ namespace Mad { namespace Server { namespace Requests { -class DaemonStateUpdateRequest : public Common::Request { +class MAD_SERVER_EXPORT DaemonStateUpdateRequest : public Common::Request { private: std::string name; Common::HostInfo::State state; diff --git a/src/Server/export.h b/src/Server/export.h new file mode 100644 index 0000000..6ff9280 --- /dev/null +++ b/src/Server/export.h @@ -0,0 +1,11 @@ +#ifndef MAD_SERVER_EXPORT +# ifdef _WIN32 +# ifdef MAD_SERVER_EXPORTS +# define MAD_SERVER_EXPORT _declspec(dllexport) +# else +# define MAD_SERVER_EXPORT _declspec(dllimport) +# endif +# else +# define MAD_SERVER_EXPORT +# endif +#endif |