summaryrefslogtreecommitdiffstats
path: root/src/Common
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-08-18 15:58:17 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-08-18 15:58:17 +0200
commitdb5ad2e09a6b38e841463dbe7eb076492b62c948 (patch)
tree5907f6416e35cbd25432a5f1f6dc9664d36aa73c /src/Common
parent5da7b0847bac2a5abec95b9ac1701b74baae8964 (diff)
downloadmad-db5ad2e09a6b38e841463dbe7eb076492b62c948.tar
mad-db5ad2e09a6b38e841463dbe7eb076492b62c948.zip
Mad funktioniert jetzt unter Windows
Diffstat (limited to 'src/Common')
-rw-r--r--src/Common/Application.h4
-rw-r--r--src/Common/Backends/CMakeLists.txt5
-rw-r--r--src/Common/Backends/NetworkUserBackend.h22
-rw-r--r--src/Common/Base64Encoder.h4
-rw-r--r--src/Common/CMakeLists.txt25
-rw-r--r--src/Common/ClientConnection.h4
-rw-r--r--src/Common/Connection.cpp2
-rw-r--r--src/Common/Connection.h12
-rw-r--r--src/Common/GroupInfo.h2
-rw-r--r--src/Common/HostInfo.h2
-rw-r--r--src/Common/Module.h2
-rw-r--r--src/Common/ModuleManager.cpp40
-rw-r--r--src/Common/ModuleManager.h14
-rw-r--r--src/Common/Request.cpp2
-rw-r--r--src/Common/Request.h4
-rw-r--r--src/Common/RequestHandler.h4
-rw-r--r--src/Common/RequestHandlerGroup.h2
-rw-r--r--src/Common/RequestHandlers/CMakeLists.txt13
-rw-r--r--src/Common/RequestHandlers/DisconnectRequestHandler.cpp2
-rw-r--r--src/Common/RequestHandlers/DisconnectRequestHandler.h4
-rw-r--r--src/Common/RequestHandlers/FSInfoRequestHandler.h4
-rw-r--r--src/Common/RequestHandlers/SimpleRequestHandler.cpp2
-rw-r--r--src/Common/RequestHandlers/SimpleRequestHandler.h4
-rw-r--r--src/Common/RequestHandlers/SimpleRequestHandlerGroup.cpp2
-rw-r--r--src/Common/RequestHandlers/SimpleRequestHandlerGroup.h6
-rw-r--r--src/Common/RequestHandlers/StatusRequestHandler.h4
-rw-r--r--src/Common/RequestManager.cpp10
-rw-r--r--src/Common/RequestManager.h6
-rw-r--r--src/Common/Requests/CMakeLists.txt10
-rw-r--r--src/Common/Requests/DisconnectRequest.cpp2
-rw-r--r--src/Common/Requests/DisconnectRequest.h4
-rw-r--r--src/Common/Requests/FSInfoRequest.h2
-rw-r--r--src/Common/Requests/IdentifyRequest.h10
-rw-r--r--src/Common/Requests/SimpleRequest.h4
-rw-r--r--src/Common/Requests/StatusRequest.h2
-rw-r--r--src/Common/SystemBackend.h10
-rw-r--r--src/Common/SystemManager.cpp12
-rw-r--r--src/Common/SystemManager.h6
-rw-r--r--src/Common/UserCache.cpp12
-rw-r--r--src/Common/UserCache.h4
-rw-r--r--src/Common/UserConfigBackend.h2
-rw-r--r--src/Common/UserDBBackend.h2
-rw-r--r--src/Common/UserInfo.h2
-rw-r--r--src/Common/UserManager.cpp28
-rw-r--r--src/Common/UserManager.h4
-rw-r--r--src/Common/XmlPacket.cpp38
-rw-r--r--src/Common/XmlPacket.h23
-rw-r--r--src/Common/export.h22
48 files changed, 265 insertions, 141 deletions
diff --git a/src/Common/Application.h b/src/Common/Application.h
index b0aa521..6de3b07 100644
--- a/src/Common/Application.h
+++ b/src/Common/Application.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_APPLICATION_H_
#define MAD_COMMON_APPLICATION_H_
+#include "export.h"
+
#include <Core/Application.h>
namespace Mad {
@@ -30,7 +32,7 @@ class RequestManager;
class SystemManager;
class UserManager;
-class Application : public Core::Application {
+class MAD_COMMON_EXPORT Application : public Core::Application {
private:
ModuleManager *moduleManager;
RequestManager *requestManager;
diff --git a/src/Common/Backends/CMakeLists.txt b/src/Common/Backends/CMakeLists.txt
deleted file mode 100644
index 631af52..0000000
--- a/src/Common/Backends/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-include_directories(${INCLUDES})
-
-add_library(Backends STATIC
- NetworkUserBackend.cpp NetworkUserBackend.h
-)
diff --git a/src/Common/Backends/NetworkUserBackend.h b/src/Common/Backends/NetworkUserBackend.h
index 1ab0b58..6ae9747 100644
--- a/src/Common/Backends/NetworkUserBackend.h
+++ b/src/Common/Backends/NetworkUserBackend.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_BACKENDS_NETWORKUSERBACKEND_H_
#define MAD_COMMON_BACKENDS_NETWORKUSERBACKEND_H_
+#include "../export.h"
+
#include "../UserDBBackend.h"
#include "../Request.h"
@@ -27,9 +29,9 @@ namespace Mad {
namespace Common {
namespace Backends {
-class NetworkUserBackend : public UserDBBackend {
+class MAD_COMMON_EXPORT NetworkUserBackend : public UserDBBackend {
private:
- class SimpleUserRequest : public Request {
+ class MAD_COMMON_EXPORT SimpleUserRequest : public Request {
private:
std::string type;
boost::posix_time::ptime timestamp;
@@ -42,7 +44,7 @@ class NetworkUserBackend : public UserDBBackend {
: Request(application), type(type0), timestamp(timestamp0 ? *timestamp0 : boost::posix_time::not_a_date_time) {}
};
- class IdUserRequest : public Request {
+ class MAD_COMMON_EXPORT IdUserRequest : public Request {
private:
std::string type;
std::string idType;
@@ -57,7 +59,7 @@ class NetworkUserBackend : public UserDBBackend {
: Request(application), type(type0), idType(idType0), id(id0), timestamp(timestamp0 ? *timestamp0 : boost::posix_time::not_a_date_time) {}
};
- class NameUserRequest : public Request {
+ class MAD_COMMON_EXPORT NameUserRequest : public Request {
private:
std::string type;
std::string name;
@@ -71,7 +73,7 @@ class NetworkUserBackend : public UserDBBackend {
: Request(application), type(type0), name(name0), timestamp(timestamp0 ? *timestamp0 : boost::posix_time::not_a_date_time) {}
};
- class UserAddRequest : public Request {
+ class MAD_COMMON_EXPORT UserAddRequest : public Request {
private:
UserInfo userInfo;
bool check;
@@ -84,7 +86,7 @@ class NetworkUserBackend : public UserDBBackend {
: Request(application), userInfo(userInfo0), check(checkOnly) {}
};
- class UserUpdateRequest : public Request {
+ class MAD_COMMON_EXPORT UserUpdateRequest : public Request {
private:
unsigned long uid;
UserInfo userInfo;
@@ -97,7 +99,7 @@ class NetworkUserBackend : public UserDBBackend {
: Request(application), uid(uid0), userInfo(userInfo0) {}
};
- class GroupAddRequest : public Request {
+ class MAD_COMMON_EXPORT GroupAddRequest : public Request {
private:
GroupInfo groupInfo;
bool check;
@@ -110,7 +112,7 @@ class NetworkUserBackend : public UserDBBackend {
: Request(application), groupInfo(groupInfo0), check(checkOnly) {}
};
- class GroupUpdateRequest : public Request {
+ class MAD_COMMON_EXPORT GroupUpdateRequest : public Request {
private:
unsigned long gid;
GroupInfo groupInfo;
@@ -123,7 +125,7 @@ class NetworkUserBackend : public UserDBBackend {
: Request(application), gid(gid0), groupInfo(groupInfo0) {}
};
- class UserGroupRequest : public Request {
+ class MAD_COMMON_EXPORT UserGroupRequest : public Request {
private:
std::string type;
unsigned long uid;
@@ -137,7 +139,7 @@ class NetworkUserBackend : public UserDBBackend {
: Request(application), type(type0), uid(uid0), gid(gid0) {}
};
- class PasswordRequest : public Request {
+ class MAD_COMMON_EXPORT PasswordRequest : public Request {
private:
unsigned long uid;
std::string password;
diff --git a/src/Common/Base64Encoder.h b/src/Common/Base64Encoder.h
index 2d921d1..5534a62 100644
--- a/src/Common/Base64Encoder.h
+++ b/src/Common/Base64Encoder.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_BASE64ENCODER_H_
#define MAD_COMMON_BASE64ENCODER_H_
+#include "export.h"
+
#include <string>
#include <vector>
@@ -28,7 +30,7 @@
namespace Mad {
namespace Common {
-class Base64Encoder {
+class MAD_COMMON_EXPORT Base64Encoder {
private:
Base64Encoder();
diff --git a/src/Common/CMakeLists.txt b/src/Common/CMakeLists.txt
index e8e3152..016bf78 100644
--- a/src/Common/CMakeLists.txt
+++ b/src/Common/CMakeLists.txt
@@ -1,11 +1,22 @@
-add_subdirectory(Backends)
-add_subdirectory(RequestHandlers)
-add_subdirectory(Requests)
-
-
include_directories(${INCLUDES})
-add_library(Common
+mad_library(Common
+ export.h
+
+ Backends/NetworkUserBackend.cpp Backends/NetworkUserBackend.h
+
+ RequestHandlers/DisconnectRequestHandler.cpp RequestHandlers/DisconnectRequestHandler.h
+ RequestHandlers/FSInfoRequestHandler.cpp RequestHandlers/FSInfoRequestHandler.h
+ RequestHandlers/SimpleRequestHandler.cpp RequestHandlers/SimpleRequestHandler.h
+ RequestHandlers/SimpleRequestHandlerGroup.cpp RequestHandlers/SimpleRequestHandlerGroup.h
+ RequestHandlers/StatusRequestHandler.cpp RequestHandlers/StatusRequestHandler.h
+
+ Requests/DisconnectRequest.cpp Requests/DisconnectRequest.h
+ Requests/FSInfoRequest.h
+ Requests/IdentifyRequest.cpp Requests/IdentifyRequest.h
+ Requests/SimpleRequest.cpp Requests/SimpleRequest.h
+ Requests/StatusRequest.h
+
Application.cpp Application.h
Base64Encoder.cpp Base64Encoder.h
ClientConnection.cpp ClientConnection.h
@@ -27,4 +38,4 @@ add_library(Common
UserManager.cpp UserManager.h
XmlPacket.cpp XmlPacket.h
)
-target_link_libraries(Common Backends RequestHandlers Requests Net modules ${LIBXML2_LIBRARIES} ${DL_LIBRARY})
+target_link_libraries(Common Net modules ${LIBXML2_LIBRARIES} ${DL_LIBRARY})
diff --git a/src/Common/ClientConnection.h b/src/Common/ClientConnection.h
index acdd28a..b50f163 100644
--- a/src/Common/ClientConnection.h
+++ b/src/Common/ClientConnection.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_CLIENTCONNECTION_H_
#define MAD_COMMON_CLIENTCONNECTION_H_
+#include "export.h"
+
#include "Connection.h"
#include <Core/Exception.h>
@@ -33,7 +35,7 @@ class ClientConnection;
namespace Common {
-class ClientConnection : public Connection {
+class MAD_COMMON_EXPORT ClientConnection : public Connection {
private:
Net::ClientConnection *connection;
diff --git a/src/Common/Connection.cpp b/src/Common/Connection.cpp
index 87381f2..b2bb835 100644
--- a/src/Common/Connection.cpp
+++ b/src/Common/Connection.cpp
@@ -27,7 +27,7 @@ void Connection::receive(boost::shared_ptr<Net::Packet> packet) {
signalReceive.emit(boost::shared_ptr<XmlPacket>(new XmlPacket(*packet)), packet->getRequestId());
}
-bool Connection::sendPacket(const XmlPacket &packet, uint16_t requestId) {
+bool Connection::sendPacket(const XmlPacket &packet, boost::uint16_t requestId) {
return send(packet.encode(requestId));
}
diff --git a/src/Common/Connection.h b/src/Common/Connection.h
index 73a4ecc..e0c9ce6 100644
--- a/src/Common/Connection.h
+++ b/src/Common/Connection.h
@@ -20,9 +20,11 @@
#ifndef MAD_COMMON_CONNECTION_H_
#define MAD_COMMON_CONNECTION_H_
+#include "export.h"
+
#include <Core/Signals.h>
-#include <stdint.h>
+#include <boost/cstdint.hpp>
#include <sys/types.h>
namespace Mad {
@@ -35,11 +37,11 @@ namespace Common {
class XmlPacket;
-class Connection : private boost::noncopyable {
+class MAD_COMMON_EXPORT Connection : private boost::noncopyable {
private:
bool authenticated;
- Core::Signals::Signal2<boost::shared_ptr<const XmlPacket>, uint16_t> signalReceive;
+ Core::Signals::Signal2<boost::shared_ptr<const XmlPacket>, boost::uint16_t> signalReceive;
protected:
Connection(Core::Application *application) : authenticated(0), signalReceive(application) {}
@@ -51,9 +53,9 @@ class Connection : private boost::noncopyable {
public:
virtual ~Connection() {}
- bool sendPacket(const XmlPacket &packet, uint16_t requestId);
+ bool sendPacket(const XmlPacket &packet, boost::uint16_t requestId);
- Core::Signals::Connection connectSignalReceive(const Core::Signals::Signal2<boost::shared_ptr<const XmlPacket>, uint16_t>::slot_type &slot) {
+ Core::Signals::Connection connectSignalReceive(const Core::Signals::Signal2<boost::shared_ptr<const XmlPacket>, boost::uint16_t>::slot_type &slot) {
return signalReceive.connect(slot);
}
void disconnectSignalReceive(const Core::Signals::Connection &con) {
diff --git a/src/Common/GroupInfo.h b/src/Common/GroupInfo.h
index c9c4baf..c1a2274 100644
--- a/src/Common/GroupInfo.h
+++ b/src/Common/GroupInfo.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_GROUPINFO_H_
#define MAD_COMMON_GROUPINFO_H_
+#include "export.h"
+
#include <string>
namespace Mad {
diff --git a/src/Common/HostInfo.h b/src/Common/HostInfo.h
index ae25e39..4a6c3f3 100644
--- a/src/Common/HostInfo.h
+++ b/src/Common/HostInfo.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_HOSTINFO_H_
#define MAD_COMMON_HOSTINFO_H_
+#include "export.h"
+
#include <string>
namespace Mad {
diff --git a/src/Common/Module.h b/src/Common/Module.h
index 4bd58d2..fad295b 100644
--- a/src/Common/Module.h
+++ b/src/Common/Module.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_MODULE_H_
#define MAD_COMMON_MODULE_H_
+#include "export.h"
+
namespace Mad {
namespace Common {
diff --git a/src/Common/ModuleManager.cpp b/src/Common/ModuleManager.cpp
index 551229c..057af1f 100644
--- a/src/Common/ModuleManager.cpp
+++ b/src/Common/ModuleManager.cpp
@@ -28,8 +28,11 @@
#include <modules/modules.h>
-#include <dlfcn.h>
+#include <boost/thread/locks.hpp>
+#ifndef _WIN32
+# include <dlfcn.h>
+#endif
namespace Mad {
namespace Common {
@@ -61,7 +64,7 @@ bool ModuleManager::handleConfigEntry(const Core::ConfigEntry &entry, bool handl
if(entry[0].getKey().matches("LoadModule") && entry[1].empty()) {
if(!loadModule(entry[0][0].c_str()))
- application->logf(Core::LoggerBase::ERROR, "Can't load module '%s'.", entry[0][0].c_str());
+ application->logf(Core::LoggerBase::LOG_ERROR, "Can't load module '%s'.", entry[0][0].c_str());
return true;
}
@@ -79,27 +82,43 @@ bool ModuleManager::loadModule(const std::string &name) {
ModuleHandle handle = STATIC_MODULE;
Module *mod = Modules::loadStaticModule(application, name);
+
+ std::string libname = name + MODULE_SUFFIX;
if(!mod) {
- handle = dlopen((name + MODULE_SUFFIX).c_str(), RTLD_NOW | RTLD_GLOBAL);
+#ifdef WIN32
+ handle = LoadLibrary(libname.c_str());
+#else
+ handle = dlopen(libname.c_str(), RTLD_NOW | RTLD_GLOBAL);
+#endif
if(!handle) {
- application->log(Core::LoggerBase::VERBOSE, std::string("loadModule: Can't open module: ") + std::string(dlerror()));
+#ifdef WIN32
+ application->logf(Core::LoggerBase::LOG_VERBOSE, "loadModule: Can't open module: Error %u", GetLastError());
+#else
+ application->log(Core::LoggerBase::LOG_VERBOSE, std::string("loadModule: Can't open module: ") + std::string(dlerror()));
+#endif
return false;
}
ModuleLoadFunc loader;
- *(void**)&loader = dlsym(handle, (name + "_create").c_str());
+ std::string loadername = name + "_create";
+
+#ifdef WIN32
+ loader = (ModuleLoadFunc)GetProcAddress(handle, loadername.c_str());
+#else
+ *(void**)&loader = dlsym(handle, loadername.c_str());
+#endif
if(!loader) {
- application->log(Core::LoggerBase::VERBOSE, "loadModule: Can't open module: Invalid module");
+ application->log(Core::LoggerBase::LOG_VERBOSE, "loadModule: Can't open module: Invalid module");
return false;
}
Module *mod = loader(application);
if(!mod) {
- application->log(Core::LoggerBase::VERBOSE, "loadModule: Can't open module: Internal module error");
+ application->log(Core::LoggerBase::LOG_VERBOSE, "loadModule: Can't open module: Internal module error");
return false;
}
}
@@ -121,8 +140,13 @@ void ModuleManager::unloadModule(const std::string &name) {
delete mod->second.second;
- if(mod->second.first != STATIC_MODULE)
+ if(mod->second.first != STATIC_MODULE) {
+#ifdef WIN32
+ FreeLibrary(mod->second.first);
+#else
dlclose(mod->second.first);
+#endif
+ }
modules.erase(mod);
}
diff --git a/src/Common/ModuleManager.h b/src/Common/ModuleManager.h
index 0f30d3a..1c6a195 100644
--- a/src/Common/ModuleManager.h
+++ b/src/Common/ModuleManager.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_MODULEMANAGER_H_
#define MAD_COMMON_MODULEMANAGER_H_
+#include "export.h"
+
#include "Module.h"
#include <Core/Configurable.h>
@@ -29,16 +31,26 @@
#include <stack>
#include <string>
+#ifdef _WIN32
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+#endif
+
namespace Mad {
namespace Common {
class Application;
-class ModuleManager : public Core::Configurable, private boost::noncopyable {
+class MAD_COMMON_EXPORT ModuleManager : public Core::Configurable, private boost::noncopyable {
private:
friend class Application;
+#ifdef WIN32
+ typedef HMODULE ModuleHandle;
+#else
typedef void *ModuleHandle;
+#endif
+
typedef Module *(*ModuleLoadFunc)(Application*);
static const ModuleHandle STATIC_MODULE;
diff --git a/src/Common/Request.cpp b/src/Common/Request.cpp
index 94734d9..9325d46 100644
--- a/src/Common/Request.cpp
+++ b/src/Common/Request.cpp
@@ -24,7 +24,7 @@ namespace Common {
void Request::handlePacket(boost::shared_ptr<const XmlPacket> packet) {
if(packet->getType() == "Error") {
- signalFinished(Core::Exception(packet->get<const std::string&>("Where"), packet->get<Core::Exception::ErrorCode>("ErrorCode"),
+ signalFinished(Core::Exception(packet->get<const std::string&>("Where"), static_cast<Core::Exception::ErrorCode>(packet->get<long>("ErrorCode")),
packet->get<long>("SubCode"), packet->get<long>("SubSubCode")));
return;
}
diff --git a/src/Common/Request.h b/src/Common/Request.h
index 381344d..268a196 100644
--- a/src/Common/Request.h
+++ b/src/Common/Request.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_REQUEST_H_
#define MAD_COMMON_REQUEST_H_
+#include "export.h"
+
#include "RequestHandler.h"
#include <Core/Exception.h>
@@ -33,7 +35,7 @@
namespace Mad {
namespace Common {
-class Request : public RequestHandler {
+class MAD_COMMON_EXPORT Request : public RequestHandler {
private:
friend class RequestManager;
diff --git a/src/Common/RequestHandler.h b/src/Common/RequestHandler.h
index 1bd41c2..6d15c09 100644
--- a/src/Common/RequestHandler.h
+++ b/src/Common/RequestHandler.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_REQUESTHANDLER_H_
#define MAD_COMMON_REQUESTHANDLER_H_
+#include "export.h"
+
#include "Application.h"
#include "Connection.h"
#include "XmlPacket.h"
@@ -33,7 +35,7 @@ namespace Common {
class Connection;
-class RequestHandler : private boost::noncopyable {
+class MAD_COMMON_EXPORT RequestHandler : private boost::noncopyable {
private:
friend class RequestManager;
diff --git a/src/Common/RequestHandlerGroup.h b/src/Common/RequestHandlerGroup.h
index a32c327..d1b7b25 100644
--- a/src/Common/RequestHandlerGroup.h
+++ b/src/Common/RequestHandlerGroup.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_REQUESTHANDLERGROUP_H_
#define MAD_COMMON_REQUESTHANDLERGROUP_H_
+#include "export.h"
+
#include "RequestHandler.h"
#include <set>
diff --git a/src/Common/RequestHandlers/CMakeLists.txt b/src/Common/RequestHandlers/CMakeLists.txt
deleted file mode 100644
index 7c5fa8f..0000000
--- a/src/Common/RequestHandlers/CMakeLists.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-include_directories(${INCLUDES})
-
-add_library(RequestHandlers STATIC
- DisconnectRequestHandler.cpp DisconnectRequestHandler.h
- FSInfoRequestHandler.cpp FSInfoRequestHandler.h
- SimpleRequestHandler.cpp SimpleRequestHandler.h
- SimpleRequestHandlerGroup.cpp SimpleRequestHandlerGroup.h
- StatusRequestHandler.cpp StatusRequestHandler.h
-)
-
-if(NOT BUILD_SHARED_LIBS)
- target_link_libraries(RequestHandlers Common)
-endif(NOT BUILD_SHARED_LIBS)
diff --git a/src/Common/RequestHandlers/DisconnectRequestHandler.cpp b/src/Common/RequestHandlers/DisconnectRequestHandler.cpp
index 5d90855..a1ecd5a 100644
--- a/src/Common/RequestHandlers/DisconnectRequestHandler.cpp
+++ b/src/Common/RequestHandlers/DisconnectRequestHandler.cpp
@@ -26,7 +26,7 @@ namespace RequestHandlers {
void DisconnectRequestHandler::handlePacket(boost::shared_ptr<const XmlPacket> packet) {
if(packet->getType() != "Disconnect") {
- getApplication()->log(Core::LoggerBase::ERROR, "Received an unexpected packet.");
+ getApplication()->log(Core::LoggerBase::LOG_ERROR, "Received an unexpected packet.");
XmlPacket ret;
ret.setType("Error");
diff --git a/src/Common/RequestHandlers/DisconnectRequestHandler.h b/src/Common/RequestHandlers/DisconnectRequestHandler.h
index d0e76c5..f4bc827 100644
--- a/src/Common/RequestHandlers/DisconnectRequestHandler.h
+++ b/src/Common/RequestHandlers/DisconnectRequestHandler.h
@@ -20,13 +20,15 @@
#ifndef MAD_COMMON_REQUESTHANDLERS_DISCONNECTREQUESTHANDLER_H_
#define MAD_COMMON_REQUESTHANDLERS_DISCONNECTREQUESTHANDLER_H_
+#include "../export.h"
+
#include "../RequestHandler.h"
namespace Mad {
namespace Common {
namespace RequestHandlers {
-class DisconnectRequestHandler : public RequestHandler {
+class MAD_COMMON_EXPORT DisconnectRequestHandler : public RequestHandler {
protected:
virtual void handlePacket(boost::shared_ptr<const XmlPacket> packet);
diff --git a/src/Common/RequestHandlers/FSInfoRequestHandler.h b/src/Common/RequestHandlers/FSInfoRequestHandler.h
index caaaffa..17c1d8e 100644
--- a/src/Common/RequestHandlers/FSInfoRequestHandler.h
+++ b/src/Common/RequestHandlers/FSInfoRequestHandler.h
@@ -20,13 +20,15 @@
#ifndef MAD_COMMON_REQUESTHANDLERS_FSINFOREQUESTHANDLER_H_
#define MAD_COMMON_REQUESTHANDLERS_FSINFOREQUESTHANDLER_H_
+#include "../export.h"
+
#include "SimpleRequestHandler.h"
namespace Mad {
namespace Common {
namespace RequestHandlers {
-class FSInfoRequestHandler : public SimpleRequestHandler {
+class MAD_COMMON_EXPORT FSInfoRequestHandler : public SimpleRequestHandler {
private:
void handleRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret);
diff --git a/src/Common/RequestHandlers/SimpleRequestHandler.cpp b/src/Common/RequestHandlers/SimpleRequestHandler.cpp
index 1972214..84258a6 100644
--- a/src/Common/RequestHandlers/SimpleRequestHandler.cpp
+++ b/src/Common/RequestHandlers/SimpleRequestHandler.cpp
@@ -27,7 +27,7 @@ namespace RequestHandlers {
void SimpleRequestHandler::handlePacket(boost::shared_ptr<const 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.");
XmlPacket ret;
ret.setType("Error");
diff --git a/src/Common/RequestHandlers/SimpleRequestHandler.h b/src/Common/RequestHandlers/SimpleRequestHandler.h
index faccc6f..3cf0f52 100644
--- a/src/Common/RequestHandlers/SimpleRequestHandler.h
+++ b/src/Common/RequestHandlers/SimpleRequestHandler.h
@@ -20,13 +20,15 @@
#ifndef MAD_COMMON_REQUESTHANDLERS_SIMPLEREQUESTHANDLER_H_
#define MAD_COMMON_REQUESTHANDLERS_SIMPLEREQUESTHANDLER_H_
+#include "../export.h"
+
#include "../RequestHandler.h"
namespace Mad {
namespace Common {
namespace RequestHandlers {
-class SimpleRequestHandler : public RequestHandler {
+class MAD_COMMON_EXPORT SimpleRequestHandler : public RequestHandler {
private:
std::string type;
boost::function2<void, boost::shared_ptr<const XmlPacket>, XmlPacket*> handler;
diff --git a/src/Common/RequestHandlers/SimpleRequestHandlerGroup.cpp b/src/Common/RequestHandlers/SimpleRequestHandlerGroup.cpp
index fd8db07..f084ac1 100644
--- a/src/Common/RequestHandlers/SimpleRequestHandlerGroup.cpp
+++ b/src/Common/RequestHandlers/SimpleRequestHandlerGroup.cpp
@@ -28,7 +28,7 @@ namespace RequestHandlers {
void SimpleRequestHandlerGroup::GroupRequestHandler::handlePacket(boost::shared_ptr<const 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.");
XmlPacket ret;
ret.setType("Error");
diff --git a/src/Common/RequestHandlers/SimpleRequestHandlerGroup.h b/src/Common/RequestHandlers/SimpleRequestHandlerGroup.h
index 18e5dba..0a702f8 100644
--- a/src/Common/RequestHandlers/SimpleRequestHandlerGroup.h
+++ b/src/Common/RequestHandlers/SimpleRequestHandlerGroup.h
@@ -20,15 +20,17 @@
#ifndef MAD_COMMON_REQUESTHANDLERS_SIMPLEREQUESTHANDLERGROUP_H_
#define MAD_COMMON_REQUESTHANDLERS_SIMPLEREQUESTHANDLERGROUP_H_
+#include "../export.h"
+
#include "../RequestHandlerGroup.h"
namespace Mad {
namespace Common {
namespace RequestHandlers {
-class SimpleRequestHandlerGroup : public RequestHandlerGroup {
+class MAD_COMMON_EXPORT SimpleRequestHandlerGroup : public RequestHandlerGroup {
private:
- class GroupRequestHandler : public RequestHandler {
+ class MAD_COMMON_EXPORT GroupRequestHandler : public RequestHandler {
private:
std::string type;
boost::function3<void, boost::shared_ptr<const XmlPacket>, XmlPacket*, Connection*> handler;
diff --git a/src/Common/RequestHandlers/StatusRequestHandler.h b/src/Common/RequestHandlers/StatusRequestHandler.h
index 2c2f87e..4e79da8 100644
--- a/src/Common/RequestHandlers/StatusRequestHandler.h
+++ b/src/Common/RequestHandlers/StatusRequestHandler.h
@@ -20,13 +20,15 @@
#ifndef MAD_COMMON_REQUESTHANDLERS_STATUSREQUESTHANDLER_H_
#define MAD_COMMON_REQUESTHANDLERS_STATUSREQUESTHANDLER_H_
+#include "../export.h"
+
#include "SimpleRequestHandler.h"
namespace Mad {
namespace Common {
namespace RequestHandlers {
-class StatusRequestHandler : public SimpleRequestHandler {
+class MAD_COMMON_EXPORT StatusRequestHandler : public SimpleRequestHandler {
private:
void handleRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret);
diff --git a/src/Common/RequestManager.cpp b/src/Common/RequestManager.cpp
index 271ab0a..c30ddc2 100644
--- a/src/Common/RequestManager.cpp
+++ b/src/Common/RequestManager.cpp
@@ -99,7 +99,7 @@ void RequestManager::receiveHandler(Connection *connection, boost::shared_ptr<co
if(!requestMap.isConnectionRegistered(connection)) {
// TODO: Error
- application->log(Core::LoggerBase::ERROR, "Received a packet from an unregistered connection.");
+ application->log(Core::LoggerBase::LOG_ERROR, "Received a packet from an unregistered connection.");
return;
}
@@ -126,7 +126,7 @@ void RequestManager::receiveHandler(Connection *connection, boost::shared_ptr<co
lock.unlock();
- application->logf(Core::LoggerBase::ERROR, "Received an unexpected packet with type '%s'.", packet->getType().c_str());
+ application->logf(Core::LoggerBase::LOG_ERROR, "Received an unexpected packet with type '%s'.", packet->getType().c_str());
XmlPacket ret;
ret.setType("Error");
@@ -139,14 +139,14 @@ bool RequestManager::sendRequest(Connection *connection, boost::shared_ptr<Reque
boost::unique_lock<boost::shared_mutex> lock(mutex);
if(!requestMap.isConnectionRegistered(connection)) {
- application->log(Core::LoggerBase::CRITICAL, "Trying to send a request over an unregistered connecion.");
+ application->log(Core::LoggerBase::LOG_CRITICAL, "Trying to send a request over an unregistered connecion.");
return false;
}
- uint16_t requestId = _getUnusedRequestId(connection);
+ boost::uint16_t requestId = _getUnusedRequestId(connection);
if(request->isFinished || !requestMap.addRequest(connection, requestId, request)) {
- application->log(Core::LoggerBase::CRITICAL, "Trying resend a request.");
+ application->log(Core::LoggerBase::LOG_CRITICAL, "Trying resend a request.");
return false;
}
request->connectSignalFinished(boost::bind(&RequestManager::handleRequestFinished, this, connection, requestId));
diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h
index 0c50881..3b16ec6 100644
--- a/src/Common/RequestManager.h
+++ b/src/Common/RequestManager.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_REQUESTMANAGER_H_
#define MAD_COMMON_REQUESTMANAGER_H_
+#include "export.h"
+
#include "Request.h"
#include "RequestHandlerGroup.h"
@@ -35,12 +37,12 @@ namespace Common {
class Application;
-class RequestManager : private boost::noncopyable {
+class MAD_COMMON_EXPORT RequestManager : private boost::noncopyable {
private:
friend class Application;
friend class RequestHandler;
- class RequestMap : private boost::noncopyable {
+ class MAD_COMMON_EXPORT RequestMap : private boost::noncopyable {
private:
typedef std::map<boost::uint16_t, boost::shared_ptr<RequestHandler> > IdMap;
typedef std::map<const RequestHandler*, std::pair<Connection*, boost::uint16_t> > HandlerMap;
diff --git a/src/Common/Requests/CMakeLists.txt b/src/Common/Requests/CMakeLists.txt
deleted file mode 100644
index 972a47c..0000000
--- a/src/Common/Requests/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-include_directories(${INCLUDES})
-
-add_library(Requests STATIC
- DisconnectRequest.cpp DisconnectRequest.h
- FSInfoRequest.h
- IdentifyRequest.cpp IdentifyRequest.h
- SimpleRequest.cpp SimpleRequest.h
- StatusRequest.h
-)
-#target_link_libraries(Requests ${KRB5_LIBRARIES})
diff --git a/src/Common/Requests/DisconnectRequest.cpp b/src/Common/Requests/DisconnectRequest.cpp
index 11786b6..523ef2a 100644
--- a/src/Common/Requests/DisconnectRequest.cpp
+++ b/src/Common/Requests/DisconnectRequest.cpp
@@ -32,7 +32,7 @@ void DisconnectRequest::sendRequest() {
void DisconnectRequest::handlePacket(boost::shared_ptr<const XmlPacket> packet) {
if(packet->getType() == "Error") {
- signalFinished(Core::Exception(packet->get<const std::string&>("Where"), packet->get<Core::Exception::ErrorCode>("ErrorCode"),
+ signalFinished(Core::Exception(packet->get<const std::string&>("Where"), static_cast<Core::Exception::ErrorCode>(packet->get<long>("ErrorCode")),
packet->get<long>("SubCode"), packet->get<long>("SubSubCode")));
return;
}
diff --git a/src/Common/Requests/DisconnectRequest.h b/src/Common/Requests/DisconnectRequest.h
index 9ba1005..a92c7e7 100644
--- a/src/Common/Requests/DisconnectRequest.h
+++ b/src/Common/Requests/DisconnectRequest.h
@@ -20,13 +20,15 @@
#ifndef MAD_COMMON_REQUESTS_DISCONNECTREQUEST_H_
#define MAD_COMMON_REQUESTS_DISCONNECTREQUEST_H_
+#include "../export.h"
+
#include "../Request.h"
namespace Mad {
namespace Common {
namespace Requests {
-class DisconnectRequest : public Request {
+class MAD_COMMON_EXPORT DisconnectRequest : public Request {
protected:
virtual void sendRequest();
virtual void handlePacket(boost::shared_ptr<const XmlPacket> packet);
diff --git a/src/Common/Requests/FSInfoRequest.h b/src/Common/Requests/FSInfoRequest.h
index 223b7a4..14aff57 100644
--- a/src/Common/Requests/FSInfoRequest.h
+++ b/src/Common/Requests/FSInfoRequest.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_REQUESTS_FSINFOREQUEST_H_
#define MAD_COMMON_REQUESTS_FSINFOREQUEST_H_
+#include "../export.h"
+
#include "SimpleRequest.h"
namespace Mad {
diff --git a/src/Common/Requests/IdentifyRequest.h b/src/Common/Requests/IdentifyRequest.h
index 7c7aaaf..e2e1399 100644
--- a/src/Common/Requests/IdentifyRequest.h
+++ b/src/Common/Requests/IdentifyRequest.h
@@ -17,8 +17,10 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_DAEMON_REQUESTS_IDENTIFYREQUEST_H_
-#define MAD_DAEMON_REQUESTS_IDENTIFYREQUEST_H_
+#ifndef MAD_COMMON_REQUESTS_IDENTIFYREQUEST_H_
+#define MAD_COMMON_REQUESTS_IDENTIFYREQUEST_H_
+
+#include "../export.h"
#include "../Request.h"
@@ -28,7 +30,7 @@ namespace Mad {
namespace Common {
namespace Requests {
-class IdentifyRequest : public Common::Request {
+class MAD_COMMON_EXPORT IdentifyRequest : public Common::Request {
private:
std::string hostname;
@@ -43,4 +45,4 @@ class IdentifyRequest : public Common::Request {
}
}
-#endif /* MAD_DAEMON_REQUESTS_IDENTIFYREQUEST_H_ */
+#endif /* MAD_COMMON_REQUESTS_IDENTIFYREQUEST_H_ */
diff --git a/src/Common/Requests/SimpleRequest.h b/src/Common/Requests/SimpleRequest.h
index 5cae38c..4bff997 100644
--- a/src/Common/Requests/SimpleRequest.h
+++ b/src/Common/Requests/SimpleRequest.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_REQUESTS_SIMPLEREQUEST_H_
#define MAD_COMMON_REQUESTS_SIMPLEREQUEST_H_
+#include "../export.h"
+
#include "../Request.h"
#include <string>
@@ -28,7 +30,7 @@ namespace Mad {
namespace Common {
namespace Requests {
-class SimpleRequest : public Request {
+class MAD_COMMON_EXPORT SimpleRequest : public Request {
protected:
const std::string type;
diff --git a/src/Common/Requests/StatusRequest.h b/src/Common/Requests/StatusRequest.h
index 09f4d90..0569a72 100644
--- a/src/Common/Requests/StatusRequest.h
+++ b/src/Common/Requests/StatusRequest.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_REQUESTS_STATUSREQUEST_H_
#define MAD_COMMON_REQUESTS_STATUSREQUEST_H_
+#include "../export.h"
+
#include "SimpleRequest.h"
namespace Mad {
diff --git a/src/Common/SystemBackend.h b/src/Common/SystemBackend.h
index aba83f8..673265a 100644
--- a/src/Common/SystemBackend.h
+++ b/src/Common/SystemBackend.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_SYSTEMBACKEND_H_
#define MAD_COMMON_SYSTEMBACKEND_H_
+#include "export.h"
+
#include "SystemManager.h"
namespace Mad {
@@ -29,19 +31,19 @@ class SystemBackend {
protected:
friend class SystemManager;
- virtual void getUptimeInfo(unsigned long */*uptime*/, unsigned long */*idleTime*/) throw(Core::Exception) {
+ virtual void getUptimeInfo(unsigned long* /*uptime*/, unsigned long* /*idleTime*/) throw(Core::Exception) {
throw Core::Exception(Core::Exception::NOT_IMPLEMENTED);
}
- virtual void getMemoryInfo(unsigned long */*totalMem*/, unsigned long */*freeMem*/, unsigned long */*totalSwap*/, unsigned long */*freeSwap*/) throw(Core::Exception) {
+ virtual void getMemoryInfo(unsigned long* /*totalMem*/, unsigned long* /*freeMem*/, unsigned long* /*totalSwap*/, unsigned long* /*freeSwap*/) throw(Core::Exception) {
throw Core::Exception(Core::Exception::NOT_IMPLEMENTED);
}
- virtual void getLoadInfo(unsigned long */*currentLoad*/, unsigned long */*nProcesses*/, float */*loadAvg1*/, float */*loadAvg5*/, float */*loadAvg15*/) throw(Core::Exception) {
+ virtual void getLoadInfo(unsigned long* /*currentLoad*/, unsigned long* /*nProcesses*/, float* /*loadAvg1*/, float* /*loadAvg5*/, float* /*loadAvg15*/) throw(Core::Exception) {
throw Core::Exception(Core::Exception::NOT_IMPLEMENTED);
}
- virtual void getFSInfo(std::vector<SystemManager::FSInfo> */*fsInfo*/) throw(Core::Exception) {
+ virtual void getFSInfo(std::vector<SystemManager::FSInfo>* /*fsInfo*/) throw(Core::Exception) {
throw Core::Exception(Core::Exception::NOT_IMPLEMENTED);
}
diff --git a/src/Common/SystemManager.cpp b/src/Common/SystemManager.cpp
index 02e55cc..572c510 100644
--- a/src/Common/SystemManager.cpp
+++ b/src/Common/SystemManager.cpp
@@ -34,7 +34,7 @@ bool SystemManager::Compare::operator() (boost::shared_ptr<SystemBackend> b1, bo
void SystemManager::getUptimeInfo(unsigned long *uptime, unsigned long *idleTime) throw(Core::Exception) {
Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
- for(std::set<boost::shared_ptr<SystemBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
+ for(std::set<boost::shared_ptr<SystemBackend>, Compare>::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
(*backend)->getUptimeInfo(uptime, idleTime);
return;
@@ -51,7 +51,7 @@ void SystemManager::getUptimeInfo(unsigned long *uptime, unsigned long *idleTime
void SystemManager::getMemoryInfo(unsigned long *totalMem, unsigned long *freeMem, unsigned long *totalSwap, unsigned long *freeSwap) throw(Core::Exception) {
Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
- for(std::set<boost::shared_ptr<SystemBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
+ for(std::set<boost::shared_ptr<SystemBackend>, Compare>::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
(*backend)->getMemoryInfo(totalMem, freeMem, totalSwap, freeSwap);
return;
@@ -68,7 +68,7 @@ void SystemManager::getMemoryInfo(unsigned long *totalMem, unsigned long *freeMe
void SystemManager::getLoadInfo(unsigned long *currentLoad, unsigned long *nProcesses, float *loadAvg1, float *loadAvg5, float *loadAvg15) throw(Core::Exception) {
Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
- for(std::set<boost::shared_ptr<SystemBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
+ for(std::set<boost::shared_ptr<SystemBackend>, Compare>::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
(*backend)->getLoadInfo(currentLoad, nProcesses, loadAvg1, loadAvg5, loadAvg15);
return;
@@ -85,7 +85,7 @@ void SystemManager::getLoadInfo(unsigned long *currentLoad, unsigned long *nProc
void SystemManager::getFSInfo(std::vector<FSInfo> *fsInfo) throw(Core::Exception) {
Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
- for(std::set<boost::shared_ptr<SystemBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
+ for(std::set<boost::shared_ptr<SystemBackend>, Compare>::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
(*backend)->getFSInfo(fsInfo);
return;
@@ -102,7 +102,7 @@ void SystemManager::getFSInfo(std::vector<FSInfo> *fsInfo) throw(Core::Exception
void SystemManager::shutdown() throw(Core::Exception) {
Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
- for(std::set<boost::shared_ptr<SystemBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
+ for(std::set<boost::shared_ptr<SystemBackend>, Compare>::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
(*backend)->shutdown();
return;
@@ -119,7 +119,7 @@ void SystemManager::shutdown() throw(Core::Exception) {
void SystemManager::reboot() throw(Core::Exception) {
Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
- for(std::set<boost::shared_ptr<SystemBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
+ for(std::set<boost::shared_ptr<SystemBackend>, Compare>::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
(*backend)->reboot();
return;
diff --git a/src/Common/SystemManager.h b/src/Common/SystemManager.h
index c17642f..4a8472b 100644
--- a/src/Common/SystemManager.h
+++ b/src/Common/SystemManager.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_SYSTEMMANAGER_H_
#define MAD_COMMON_SYSTEMMANAGER_H_
+#include "export.h"
+
#include <set>
#include <string>
#include <vector>
@@ -35,11 +37,11 @@ namespace Common {
class Application;
class SystemBackend;
-class SystemManager : private boost::noncopyable {
+class MAD_COMMON_EXPORT SystemManager : private boost::noncopyable {
private:
friend class Application;
- struct Compare {
+ struct MAD_COMMON_EXPORT Compare {
bool operator() (boost::shared_ptr<SystemBackend> b1, boost::shared_ptr<SystemBackend> b2);
};
diff --git a/src/Common/UserCache.cpp b/src/Common/UserCache.cpp
index 4058c4c..1367041 100644
--- a/src/Common/UserCache.cpp
+++ b/src/Common/UserCache.cpp
@@ -42,9 +42,9 @@ boost::shared_ptr<const std::map<unsigned long, UserInfo> > UserCache::getUserLi
}
else {
if(users)
- application->log(Core::LoggerBase::USER, Core::LoggerBase::DEBUG, "Using cached user list");
+ application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_DEBUG, "Using cached user list");
else
- application->log(Core::LoggerBase::USER, Core::LoggerBase::DEBUG, "Error cached");
+ application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_DEBUG, "Error cached");
}
}
catch(Core::Exception e) {
@@ -133,9 +133,9 @@ boost::shared_ptr<const std::map<unsigned long, GroupInfo> > UserCache::getGroup
}
else {
if(groups)
- application->log(Core::LoggerBase::USER, Core::LoggerBase::DEBUG, "Using cached group list");
+ application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_DEBUG, "Using cached group list");
else
- application->log(Core::LoggerBase::USER, Core::LoggerBase::DEBUG, "Error cached");
+ application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_DEBUG, "Error cached");
}
}
catch(Core::Exception e) {
@@ -223,9 +223,9 @@ boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > UserCache:
}
else {
if(userGroups)
- application->log(Core::LoggerBase::USER, Core::LoggerBase::DEBUG, "Using cached user-group table");
+ application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_DEBUG, "Using cached user-group table");
else
- application->log(Core::LoggerBase::USER, Core::LoggerBase::DEBUG, "Error cached");
+ application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_DEBUG, "Error cached");
}
}
catch(Core::Exception e) {
diff --git a/src/Common/UserCache.h b/src/Common/UserCache.h
index bec3328..c579221 100644
--- a/src/Common/UserCache.h
+++ b/src/Common/UserCache.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_USERCACHE_H_
#define MAD_COMMON_USERCACHE_H_
+#include "export.h"
+
#include "UserDBBackend.h"
#include <limits>
@@ -32,7 +34,7 @@ namespace Common {
class Application;
class UserManager;
-class UserCache : public UserDBBackend, private boost::noncopyable {
+class MAD_COMMON_EXPORT UserCache : public UserDBBackend, private boost::noncopyable {
private:
friend class UserManager;
diff --git a/src/Common/UserConfigBackend.h b/src/Common/UserConfigBackend.h
index 94550eb..e7c6245 100644
--- a/src/Common/UserConfigBackend.h
+++ b/src/Common/UserConfigBackend.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_USERCONFIGBACKEND_H_
#define MAD_COMMON_USERCONFIGBACKEND_H_
+#include "export.h"
+
#include <Core/Exception.h>
#include "UserInfo.h"
diff --git a/src/Common/UserDBBackend.h b/src/Common/UserDBBackend.h
index 664739c..8d4c95a 100644
--- a/src/Common/UserDBBackend.h
+++ b/src/Common/UserDBBackend.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_USERDBBACKEND_H_
#define MAD_COMMON_USERDBBACKEND_H_
+#include "export.h"
+
#include <Core/Exception.h>
#include "UserInfo.h"
diff --git a/src/Common/UserInfo.h b/src/Common/UserInfo.h
index 2d64299..6859904 100644
--- a/src/Common/UserInfo.h
+++ b/src/Common/UserInfo.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_USERINFO_H_
#define MAD_COMMON_USERINFO_H_
+#include "export.h"
+
#include <string>
namespace Mad {
diff --git a/src/Common/UserManager.cpp b/src/Common/UserManager.cpp
index d04a644..d4467ee 100644
--- a/src/Common/UserManager.cpp
+++ b/src/Common/UserManager.cpp
@@ -43,7 +43,7 @@ bool UserManager::handleConfigEntry(const Core::ConfigEntry &entry, bool /*handl
char *endptr;
unsigned long val = std::strtoul(entry[1][0].c_str(), &endptr, 10);
if(entry[1][0].empty() || *endptr) {
- application->logf(Core::LoggerBase::WARNING, "UserBackendHome: Invalid configuration: MinUid '%s'", entry[1][0].c_str());
+ application->logf(Core::LoggerBase::LOG_WARNING, "UserBackendHome: Invalid configuration: MinUid '%s'", entry[1][0].c_str());
}
else {
minUid = val;
@@ -55,7 +55,7 @@ bool UserManager::handleConfigEntry(const Core::ConfigEntry &entry, bool /*handl
char *endptr;
unsigned long val = std::strtoul(entry[1][0].c_str(), &endptr, 10);
if(entry[1][0].empty() || *endptr) {
- application->logf(Core::LoggerBase::WARNING, "UserBackendHome: Invalid configuration: MaxUid '%s'", entry[1][0].c_str());
+ application->logf(Core::LoggerBase::LOG_WARNING, "UserBackendHome: Invalid configuration: MaxUid '%s'", entry[1][0].c_str());
}
else {
maxUid = val;
@@ -67,7 +67,7 @@ bool UserManager::handleConfigEntry(const Core::ConfigEntry &entry, bool /*handl
char *endptr;
unsigned long val = std::strtoul(entry[1][0].c_str(), &endptr, 10);
if(entry[1][0].empty() || *endptr) {
- application->logf(Core::LoggerBase::WARNING, "UserBackendHome: Invalid configuration: MinGid '%s'", entry[1][0].c_str());
+ application->logf(Core::LoggerBase::LOG_WARNING, "UserBackendHome: Invalid configuration: MinGid '%s'", entry[1][0].c_str());
}
else {
minGid = val;
@@ -79,7 +79,7 @@ bool UserManager::handleConfigEntry(const Core::ConfigEntry &entry, bool /*handl
char *endptr;
unsigned long val = std::strtoul(entry[1][0].c_str(), &endptr, 10);
if(entry[1][0].empty() || *endptr) {
- application->logf(Core::LoggerBase::WARNING, "UserBackendHome: Invalid configuration: MaxGid '%s'", entry[1][0].c_str());
+ application->logf(Core::LoggerBase::LOG_WARNING, "UserBackendHome: Invalid configuration: MaxGid '%s'", entry[1][0].c_str());
}
else {
maxGid = val;
@@ -234,7 +234,7 @@ void UserManager::addUser(const UserInfo &userInfo) throw(Core::Exception) {
(*configBackend)->addUser(userInfo);
}
catch(Core::Exception e) {
- application->log(Core::LoggerBase::USER, Core::LoggerBase::WARNING, e.strerror());
+ application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_WARNING, e.strerror());
}
}
}
@@ -258,7 +258,7 @@ void UserManager::updateUser(unsigned long uid, const UserInfo &userInfo) throw(
(*configBackend)->updateUser(*oldUserInfo, userInfo);
}
catch(Core::Exception e) {
- application->log(Core::LoggerBase::USER, Core::LoggerBase::WARNING, e.strerror());
+ application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_WARNING, e.strerror());
}
}
}
@@ -280,7 +280,7 @@ void UserManager::deleteUser(unsigned long uid) throw(Core::Exception) {
(*configBackend)->deleteUser(*userInfo);
}
catch(Core::Exception e) {
- application->log(Core::LoggerBase::USER, Core::LoggerBase::WARNING, e.strerror());
+ application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_WARNING, e.strerror());
}
}
}
@@ -317,7 +317,7 @@ void UserManager::addGroup(const GroupInfo &groupInfo) throw(Core::Exception) {
(*configBackend)->addGroup(groupInfo);
}
catch(Core::Exception e) {
- application->log(Core::LoggerBase::USER, Core::LoggerBase::WARNING, e.strerror());
+ application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_WARNING, e.strerror());
}
}
}
@@ -341,7 +341,7 @@ void UserManager::updateGroup(unsigned long gid, const GroupInfo &groupInfo) thr
(*configBackend)->updateGroup(*oldGroupInfo, groupInfo);
}
catch(Core::Exception e) {
- application->log(Core::LoggerBase::USER, Core::LoggerBase::WARNING, e.strerror());
+ application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_WARNING, e.strerror());
}
}
}
@@ -363,7 +363,7 @@ void UserManager::deleteGroup(unsigned long gid) throw(Core::Exception) {
(*configBackend)->deleteGroup(*groupInfo);
}
catch(Core::Exception e) {
- application->log(Core::LoggerBase::USER, Core::LoggerBase::WARNING, e.strerror());
+ application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_WARNING, e.strerror());
}
}
}
@@ -388,7 +388,7 @@ void UserManager::addUserToGroup(unsigned long uid, unsigned long gid) throw(Cor
(*configBackend)->addUserToGroup(*userInfo, *groupInfo);
}
catch(Core::Exception e) {
- application->log(Core::LoggerBase::USER, Core::LoggerBase::WARNING, e.strerror());
+ application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_WARNING, e.strerror());
}
}
}
@@ -413,7 +413,7 @@ void UserManager::deleteUserFromGroup(unsigned long uid, unsigned long gid) thro
(*configBackend)->deleteUserFromGroup(*userInfo, *groupInfo);
}
catch(Core::Exception e) {
- application->log(Core::LoggerBase::USER, Core::LoggerBase::WARNING, e.strerror());
+ application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_WARNING, e.strerror());
}
}
}
@@ -439,7 +439,7 @@ void UserManager::setPassword(unsigned long uid, const std::string &password) th
exception = e;
if(e.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
- application->log(Core::LoggerBase::USER, Core::LoggerBase::WARNING, e.strerror());
+ application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_WARNING, e.strerror());
}
for(std::set<boost::shared_ptr<UserConfigBackend> >::iterator configBackend = configBackends.begin(); configBackend != configBackends.end(); ++configBackend) {
@@ -449,7 +449,7 @@ void UserManager::setPassword(unsigned long uid, const std::string &password) th
}
catch(Core::Exception e) {
if(e.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
- application->log(Core::LoggerBase::USER, Core::LoggerBase::WARNING, e.strerror());
+ application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_WARNING, e.strerror());
}
}
diff --git a/src/Common/UserManager.h b/src/Common/UserManager.h
index b966662..6da5af4 100644
--- a/src/Common/UserManager.h
+++ b/src/Common/UserManager.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_USERMANAGER_H_
#define MAD_COMMON_USERMANAGER_H_
+#include "export.h"
+
#include "UserInfo.h"
#include "GroupInfo.h"
@@ -40,7 +42,7 @@ class UserConfigBackend;
class UserDBBackend;
class UserCache;
-class UserManager : public Core::Configurable, private boost::noncopyable {
+class MAD_COMMON_EXPORT UserManager : public Core::Configurable, private boost::noncopyable {
private:
friend class Application;
diff --git a/src/Common/XmlPacket.cpp b/src/Common/XmlPacket.cpp
index dbd3fc7..ff8ca6a 100644
--- a/src/Common/XmlPacket.cpp
+++ b/src/Common/XmlPacket.cpp
@@ -101,6 +101,7 @@ XmlPacket::Element::Element(xmlNodePtr node) : elementNode(node), type(NONE) {
}
str = (char*)content;
+ std::istringstream buf(str);
if(!xmlStrcmp(typestr, (xmlChar*)"binary")) {
type = BINARY;
@@ -109,31 +110,52 @@ XmlPacket::Element::Element(xmlNodePtr node) : elementNode(node), type(NONE) {
}
else if(!xmlStrcmp(typestr, (xmlChar*)"int")) {
type = INT;
- value = std::strtol((char*)content, 0, 10);
+
+ long tmp;
+ buf >> tmp;
+ value = tmp;
}
else if(!xmlStrcmp(typestr, (xmlChar*)"uint")) {
type = UINT;
- value = std::strtoul((char*)content, 0, 10);
+
+ unsigned long tmp;
+ buf >> tmp;
+ value = tmp;
}
else if(!xmlStrcmp(typestr, (xmlChar*)"int64")) {
type = INT64;
- value = std::strtoll((char*)content, 0, 10);
+
+ long long tmp;
+ buf >> tmp;
+ value = tmp;
}
else if(!xmlStrcmp(typestr, (xmlChar*)"uint64")) {
type = UINT64;
- value = std::strtoull((char*)content, 0, 10);
+
+ unsigned long long tmp;
+ buf >> tmp;
+ value = tmp;
}
else if(!xmlStrcmp(typestr, (xmlChar*)"float")) {
type = FLOAT;
- value = std::strtof((char*)content, 0);
+
+ float tmp;
+ buf >> tmp;
+ value = tmp;
}
else if(!xmlStrcmp(typestr, (xmlChar*)"double")) {
type = DOUBLE;
- value = std::strtod((char*)content, 0);
+
+ double tmp;
+ buf >> tmp;
+ value = tmp;
}
else if(!xmlStrcmp(typestr, (xmlChar*)"longdouble")) {
type = LONGDOUBLE;
- value = std::strtold((char*)content, 0);
+
+ long double tmp;
+ buf >> tmp;
+ value = tmp;
}
else if(!xmlStrcmp(typestr, (xmlChar*)"string")) {
type = STRING;
@@ -272,7 +294,7 @@ void XmlPacket::setType(const std::string &type) {
xmlSetProp(packetNode, (xmlChar*)"type", (xmlChar*)type.c_str());
}
-Net::Packet XmlPacket::encode(uint16_t requestId) const {
+Net::Packet XmlPacket::encode(boost::uint16_t requestId) const {
xmlChar *buf;
int length;
diff --git a/src/Common/XmlPacket.h b/src/Common/XmlPacket.h
index 546525a..9d63075 100644
--- a/src/Common/XmlPacket.h
+++ b/src/Common/XmlPacket.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_XMLPACKET_H_
#define MAD_COMMON_XMLPACKET_H_
+#include "export.h"
+
#include <Net/Packet.h>
#include <map>
@@ -40,7 +42,7 @@
namespace Mad {
namespace Common {
-class XmlPacket {
+class MAD_COMMON_EXPORT XmlPacket {
public:
class Entry;
class List;
@@ -50,7 +52,7 @@ class XmlPacket {
xmlNodePtr packetNode;
Entry *entry;
- class Element : private boost::noncopyable {
+ class MAD_COMMON_EXPORT Element : private boost::noncopyable {
private:
friend class Entry;
@@ -130,7 +132,7 @@ class XmlPacket {
};
public:
- class Entry : private boost::noncopyable {
+ class MAD_COMMON_EXPORT Entry : private boost::noncopyable {
private:
friend class List;
friend class XmlPacket;
@@ -284,7 +286,7 @@ class XmlPacket {
}
};
- class List : private boost::noncopyable {
+ class MAD_COMMON_EXPORT List : private boost::noncopyable {
private:
friend class Entry;
@@ -302,7 +304,8 @@ class XmlPacket {
typedef value_type &reference;
typedef value_type *pointer;
- typedef ssize_t difference_type;
+ typedef long difference_type;
+
private:
IteratorType it;
@@ -476,14 +479,14 @@ class XmlPacket {
entry->unset(name);
}
- Net::Packet encode(uint16_t requestId) const;
+ Net::Packet encode(boost::uint16_t requestId) const;
};
-template <> std::string XmlPacket::Entry::get<std::string>(const std::string &name) const;
-template <> const std::string& XmlPacket::Entry::get<const std::string&>(const std::string &name) const;
+template <> MAD_COMMON_EXPORT std::string XmlPacket::Entry::get<std::string>(const std::string &name) const;
+template <> MAD_COMMON_EXPORT const std::string& XmlPacket::Entry::get<const std::string&>(const std::string &name) const;
-template <> std::vector<boost::uint8_t> XmlPacket::Entry::get<std::vector<unsigned char> >(const std::string &name) const;
-template <> const std::vector<boost::uint8_t>& XmlPacket::Entry::get<const std::vector<unsigned char>&>(const std::string &name) const;
+template <> MAD_COMMON_EXPORT std::vector<boost::uint8_t> XmlPacket::Entry::get<std::vector<unsigned char> >(const std::string &name) const;
+template <> MAD_COMMON_EXPORT const std::vector<boost::uint8_t>& XmlPacket::Entry::get<const std::vector<unsigned char>&>(const std::string &name) const;
}
}
diff --git a/src/Common/export.h b/src/Common/export.h
new file mode 100644
index 0000000..71207d3
--- /dev/null
+++ b/src/Common/export.h
@@ -0,0 +1,22 @@
+#ifndef MAD_COMMON_EXPORT
+# ifdef _WIN32
+# ifdef MAD_COMMON_EXPORTS
+# define MAD_COMMON_EXPORT _declspec(dllexport)
+# else
+# define MAD_COMMON_EXPORT _declspec(dllimport)
+# endif
+# else
+# define MAD_COMMON_EXPORT
+# endif
+
+# ifdef MAD_COMMON_EXPORTS
+# ifndef MAD_NET_EXPORTS
+# define MAD_NET_EXPORTS
+# endif
+# else
+# undef MAD_NET_EXPORTS
+# endif
+
+# include <Net/export.h>
+
+#endif