From db5ad2e09a6b38e841463dbe7eb076492b62c948 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 18 Aug 2009 15:58:17 +0200 Subject: Mad funktioniert jetzt unter Windows --- src/Server/Application.h | 4 +++- src/Server/CMakeLists.txt | 16 +++++++++++----- src/Server/ConnectionManager.cpp | 19 +++++++++---------- src/Server/ConnectionManager.h | 6 ++++-- src/Server/RequestHandlers/CMakeLists.txt | 8 -------- .../ConnectionRequestHandlerGroup.cpp | 20 ++++++++++++++++---- .../RequestHandlers/ConnectionRequestHandlerGroup.h | 4 +++- .../RequestHandlers/DaemonRequestHandlerGroup.cpp | 2 +- .../RequestHandlers/DaemonRequestHandlerGroup.h | 4 +++- .../RequestHandlers/UserRequestHandlerGroup.cpp | 2 +- src/Server/RequestHandlers/UserRequestHandlerGroup.h | 4 +++- src/Server/Requests/CMakeLists.txt | 6 ------ src/Server/Requests/CommandRequest.h | 4 +++- src/Server/Requests/DaemonStateUpdateRequest.h | 4 +++- src/Server/export.h | 11 +++++++++++ 15 files changed, 71 insertions(+), 43 deletions(-) delete mode 100644 src/Server/RequestHandlers/CMakeLists.txt delete mode 100644 src/Server/Requests/CMakeLists.txt create mode 100644 src/Server/export.h (limited to 'src/Server') 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 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 #include -#include +//#include #include 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 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::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 >::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 #include #include @@ -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 > connections; - std::map daemonInfo; + std::map daemonInfo; boost::shared_ptr connectionRequestHandlerGroup; boost::shared_ptr 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 +#include + namespace Mad { namespace Server { namespace RequestHandlers { @@ -56,17 +58,27 @@ void ConnectionRequestHandlerGroup::handleIdentifyRequest(boost::shared_ptr 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("timestamp"); + if(!timestr.empty()) { + try { + timestamp = boost::posix_time::from_iso_string(timestr); + } + catch(...) {} + } try { application->getLogManager()->log( - packet->get("category"), - packet->get("level"), - packet->get("timestamp"), + static_cast(packet->get("category")), + static_cast(packet->get("level")), + timestamp, packet->get("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 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 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 #include @@ -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_ptrcreateList("userGroupList"); - for(std::map::const_iterator userGroup = userGroups->begin(); userGroup != userGroups->end(); ++userGroup) { + for(std::multimap::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 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 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 #include @@ -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 -- cgit v1.2.3