From b40ba0cf91603b695f1f2380cbd39966a458f22f Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 27 Sep 2009 19:58:24 +0200 Subject: Use Unicode-aware String class instead of std::string --- src/Server/ConnectionManager.cpp | 22 +++--- src/Server/ConnectionManager.h | 16 ++--- .../ConnectionRequestHandlerGroup.cpp | 26 +++---- .../RequestHandlers/DaemonRequestHandlerGroup.cpp | 10 +-- .../RequestHandlers/DaemonRequestHandlerGroup.h | 10 +-- .../UserListDiffUploadRequestHandler.cpp | 8 +-- .../UserListDiffUploadRequestHandler.h | 2 +- .../UserListRequestHandlerGroup.cpp | 24 +++---- .../UserListUploadRequestHandler.cpp | 8 +-- .../RequestHandlers/UserListUploadRequestHandler.h | 2 +- .../RequestHandlers/UserRequestHandlerGroup.cpp | 80 +++++++++++----------- src/Server/Requests/DaemonStateUpdateRequest.h | 4 +- src/Server/UserListManager.cpp | 28 ++++---- src/Server/UserListManager.h | 33 ++++----- 14 files changed, 137 insertions(+), 136 deletions(-) (limited to 'src/Server') diff --git a/src/Server/ConnectionManager.cpp b/src/Server/ConnectionManager.cpp index 5836b32..f09f9e3 100644 --- a/src/Server/ConnectionManager.cpp +++ b/src/Server/ConnectionManager.cpp @@ -57,8 +57,8 @@ bool ConnectionManager::ServerConnection::disconnect() { return true; } -boost::shared_ptr ConnectionManager::ServerConnection::authenticate(const std::string &method, - const std::string &subMethod, const std::string &user, const std::vector &data, std::vector &response) { +boost::shared_ptr ConnectionManager::ServerConnection::authenticate(const Core::String &method, + const Core::String &subMethod, const Core::String &user, const std::vector &data, std::vector &response) { if(!isIdentified()) type = CLIENT; @@ -151,12 +151,12 @@ bool ConnectionManager::handleConfigEntry(const Core::ConfigEntry &entry, bool h else if(entry[0].getKey().matches("Daemon")) { if(entry[0].getSize() == 1) { if(entry[1].isEmpty()) { - daemonInfo.insert(std::make_pair(entry[0][0].extract(), Common::HostInfo(entry[0][0].extract()))); + daemonInfo.insert(std::make_pair(entry[0][0], Common::HostInfo(entry[0][0]))); return true; } else if(entry[1].getKey().matches("IpAddress") && entry[2].isEmpty()) { - daemonInfo[entry[0][0].extract()].setIP(entry[1][0].extract()); + daemonInfo[entry[0][0]].setIP(entry[1][0].extract()); return true; } @@ -231,10 +231,10 @@ ConnectionManager::~ConnectionManager() { application->getRequestManager()->unregisterPacketType("GetStatus"); } -boost::shared_ptr ConnectionManager::getDaemonConnection(const std::string &name) const throw (Core::Exception) { +boost::shared_ptr ConnectionManager::getDaemonConnection(const Core::String &name) const throw (Core::Exception) { - std::map::const_iterator hostIt = daemonInfo.find(name); + std::map::const_iterator hostIt = daemonInfo.find(name); if(hostIt == daemonInfo.end()) throw Core::Exception(Core::Exception::UNKNOWN_DAEMON); @@ -251,7 +251,7 @@ boost::shared_ptr ConnectionManager::getDaemonConnection(con throw Core::Exception(Core::Exception::NOT_AVAILABLE); } -std::string ConnectionManager::getDaemonName(const Common::Connection *con) const throw (Core::Exception) { +Core::String ConnectionManager::getDaemonName(const Common::Connection *con) const throw (Core::Exception) { const ServerConnection *connection = dynamic_cast(con); if(connection && connection->getConnectionType() == ServerConnection::DAEMON) @@ -260,7 +260,7 @@ std::string ConnectionManager::getDaemonName(const Common::Connection *con) cons throw Core::Exception(Core::Exception::UNKNOWN_DAEMON); } -void ConnectionManager::identifyDaemonConnection(Common::Connection *con, const std::string &name) throw (Core::Exception) { +void ConnectionManager::identifyDaemonConnection(Common::Connection *con, const Core::String &name) throw (Core::Exception) { // TODO Logging ServerConnection *connection = dynamic_cast(con); @@ -288,8 +288,8 @@ void ConnectionManager::identifyDaemonConnection(Common::Connection *con, const updateState(hostInfo, Common::HostInfo::RUNNING); } -boost::shared_ptr ConnectionManager::authenticateConnection(Common::Connection *con, const std::string &method, - const std::string &subMethod, const std::string &user, const std::vector &data, std::vector &response) { +boost::shared_ptr ConnectionManager::authenticateConnection(Common::Connection *con, const Core::String &method, + const Core::String &subMethod, const Core::String &user, const std::vector &data, std::vector &response) { // TODO Logging ServerConnection *connection = dynamic_cast(con); @@ -306,7 +306,7 @@ boost::shared_ptr ConnectionManager::authenticateConn std::vector ConnectionManager::getDaemonList() const { std::vector ret; - for(std::map::const_iterator daemon = daemonInfo.begin(); daemon != daemonInfo.end(); ++daemon) { + for(std::map::const_iterator daemon = daemonInfo.begin(); daemon != daemonInfo.end(); ++daemon) { ret.push_back(daemon->second); } diff --git a/src/Server/ConnectionManager.h b/src/Server/ConnectionManager.h index 8c989b9..dab1892 100644 --- a/src/Server/ConnectionManager.h +++ b/src/Server/ConnectionManager.h @@ -99,8 +99,8 @@ class MAD_SERVER_EXPORT ConnectionManager : public Core::Configurable, private b return (authContext.get() != 0 && authContext->isAuthenticated()); } - boost::shared_ptr authenticate(const std::string &method, const std::string &subMethod, - const std::string &user, const std::vector &data, std::vector &response); + boost::shared_ptr authenticate(const Core::String &method, const Core::String &subMethod, + const Core::String &user, const std::vector &data, std::vector &response); }; friend class Application; @@ -114,7 +114,7 @@ class MAD_SERVER_EXPORT ConnectionManager : public Core::Configurable, private b std::set > connections; - std::map daemonInfo; + std::map daemonInfo; boost::shared_ptr connectionRequestHandlerGroup; boost::shared_ptr daemonRequestHandlerGroup; @@ -135,13 +135,13 @@ class MAD_SERVER_EXPORT ConnectionManager : public Core::Configurable, private b virtual void configFinished(); public: - boost::shared_ptr getDaemonConnection(const std::string &name) const throw (Core::Exception); - std::string getDaemonName(const Common::Connection *con) const throw (Core::Exception); + boost::shared_ptr getDaemonConnection(const Core::String &name) const throw (Core::Exception); + Core::String getDaemonName(const Common::Connection *con) const throw (Core::Exception); - void identifyDaemonConnection(Common::Connection *con, const std::string &name) throw (Core::Exception); + void identifyDaemonConnection(Common::Connection *con, const Core::String &name) throw (Core::Exception); - boost::shared_ptr authenticateConnection(Common::Connection *con, const std::string &method, const std::string &subMethod, - const std::string &user, const std::vector &data, std::vector &response); + boost::shared_ptr authenticateConnection(Common::Connection *con, const Core::String &method, const Core::String &subMethod, + const Core::String &user, const std::vector &data, std::vector &response); std::vector getDaemonList() const; }; diff --git a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp index 1348541..d446485 100644 --- a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp @@ -37,17 +37,17 @@ void ConnectionRequestHandlerGroup::handleAuthMethodRequest(boost::shared_ptrcreateList("methods"); - std::set methods = application->getAuthManager()->getMethods(); + std::set methods = application->getAuthManager()->getMethods(); - for(std::set::iterator method = methods.begin(); method != methods.end(); ++method) { + for(std::set::iterator method = methods.begin(); method != methods.end(); ++method) { Common::XmlData::List::iterator entry = list->addEntry(); entry->set("name", *method); Common::XmlData::List *subList = entry->createList("subMethods"); - std::vector subMethods = application->getAuthManager()->getSubMethods(*method); + std::vector subMethods = application->getAuthManager()->getSubMethods(*method); - for(std::vector::iterator subMethod = subMethods.begin(); subMethod != subMethods.end(); ++subMethod) { + for(std::vector::iterator subMethod = subMethods.begin(); subMethod != subMethods.end(); ++subMethod) { Common::XmlData::List::iterator subEntry = subList->addEntry(); subEntry->set("name", *subMethod); @@ -59,8 +59,8 @@ void ConnectionRequestHandlerGroup::handleAuthRequest(boost::shared_ptr response; boost::shared_ptr authContext = application->getConnectionManager()->authenticateConnection(connection, - packet->get("method"), packet->get("subMethod"), - packet->get("user"), packet->get&>("data"), + packet->get("method"), packet->get("subMethod"), + packet->get("user"), packet->get&>("data"), response); if(!response.empty()) @@ -86,13 +86,13 @@ void ConnectionRequestHandlerGroup::handleDaemonListRequest(boost::shared_ptraddEntry(); entry->set("name", daemon->getName()); - entry->set("address", daemon->getIP()); + entry->set("address", daemon->getIP().c_str()); entry->set("state", daemon->getState()); } } void ConnectionRequestHandlerGroup::handleIdentifyRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection) { - application->getConnectionManager()->identifyDaemonConnection(connection, packet->get("hostname")); + application->getConnectionManager()->identifyDaemonConnection(connection, packet->get("hostname")); ret->setType("OK"); } @@ -102,10 +102,10 @@ void ConnectionRequestHandlerGroup::handleLogRequest(boost::shared_ptrget("timestamp"); - if(!timestr.empty()) { + const Core::String ×tr = packet->get("timestamp"); + if(!timestr.isEmpty()) { try { - timestamp = boost::posix_time::from_iso_string(timestr); + timestamp = boost::posix_time::from_iso_string(timestr.extract()); } catch(...) {} } @@ -115,8 +115,8 @@ void ConnectionRequestHandlerGroup::handleLogRequest(boost::shared_ptr(packet->get("category")), static_cast(packet->get("level")), timestamp, - packet->get("message"), - application->getConnectionManager()->getDaemonName(connection)); + packet->get("message").extract(), + application->getConnectionManager()->getDaemonName(connection).extract()); } catch(Core::Exception &e) { application->logf(Core::Logger::LOG_ERROR, "Can't determine daemon name: %s", e.what()); diff --git a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp index e258b89..8f6909e 100644 --- a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp @@ -50,11 +50,11 @@ void DaemonRequestHandlerGroup::DaemonRequestHandler::handlePacket(boost::shared try { ConnectionManager *connectionManager = dynamic_cast(*getApplication()).getConnectionManager(); - boost::shared_ptr daemonCon = connectionManager->getDaemonConnection(packet->get("daemon")); + boost::shared_ptr daemonCon = connectionManager->getDaemonConnection(packet->get("daemon")); boost::shared_ptr request; if(type == "DaemonCommand") - request.reset(new Requests::CommandRequest(getApplication(), (packet->get("command") == "reboot"))); + request.reset(new Requests::CommandRequest(getApplication(), packet->get("command").matches("reboot"))); else if(type == "DaemonFSInfo") request.reset(new Common::Requests::FSInfoRequest(getApplication())); else // type == "GetDaemonStatus" @@ -69,7 +69,7 @@ void DaemonRequestHandlerGroup::DaemonRequestHandler::handlePacket(boost::shared ret.set("ErrorCode", e.getErrorCode()); ret.set("SubCode", e.getSubCode()); ret.set("SubSubCode", e.getSubSubCode()); - ret.set("Where", e.getWhere()); + ret.set("Where", e.getWhere().c_str()); sendPacket(ret); signalFinished(); @@ -83,7 +83,7 @@ void DaemonRequestHandlerGroup::DaemonRequestHandler::requestFinished(boost::sha ret.set("ErrorCode", error.getErrorCode()); ret.set("SubCode", error.getSubCode()); ret.set("SubSubCode", error.getSubSubCode()); - ret.set("Where", error.getWhere()); + ret.set("Where", error.getWhere().c_str()); sendPacket(ret); } @@ -101,7 +101,7 @@ DaemonRequestHandlerGroup::DaemonRequestHandlerGroup() { types.insert("GetDaemonStatus"); } -boost::shared_ptr DaemonRequestHandlerGroup::createRequestHandler(Common::Application *application, const std::string &type) { +boost::shared_ptr DaemonRequestHandlerGroup::createRequestHandler(Common::Application *application, const Core::String &type) { if(types.find(type) == types.end()) return boost::shared_ptr(); else diff --git a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h index 48d8e2c..613e8f3 100644 --- a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h +++ b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h @@ -35,7 +35,7 @@ class MAD_SERVER_EXPORT DaemonRequestHandlerGroup : public Common::RequestHandle private: class DaemonRequestHandler : public Common::RequestHandler { private: - std::string type; + Core::String type; void requestFinished(boost::shared_ptr packet, Core::Exception error); @@ -43,20 +43,20 @@ class MAD_SERVER_EXPORT DaemonRequestHandlerGroup : public Common::RequestHandle virtual void handlePacket(boost::shared_ptr packet); public: - DaemonRequestHandler(Common::Application *application, const std::string &type0) + DaemonRequestHandler(Common::Application *application, const Core::String &type0) : Common::RequestHandler(application), type(type0) {} }; - std::set types; + std::set types; public: DaemonRequestHandlerGroup(); - virtual const std::set& getPacketTypes() { + virtual const std::set& getPacketTypes() { return types; } - virtual boost::shared_ptr createRequestHandler(Common::Application *application, const std::string &type); + virtual boost::shared_ptr createRequestHandler(Common::Application *application, const Core::String &type); }; } diff --git a/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.cpp b/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.cpp index 05aadf8..be9cc58 100644 --- a/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.cpp +++ b/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.cpp @@ -56,11 +56,11 @@ void UserListDiffUploadRequestHandler::handlePacket(boost::shared_ptr(getApplication())->getUserListManager(); - if(name.empty()) { // Request - name = packet->get("name"); + if(name.isEmpty()) { // Request + name = packet->get("name"); - if(name.empty()) - name = boost::posix_time::to_simple_string(boost::posix_time::second_clock::universal_time()); + if(name.isEmpty()) + name = boost::posix_time::to_simple_string(boost::posix_time::second_clock::universal_time()).c_str(); Common::XmlData ret; ret.setType("Continue"); diff --git a/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.h b/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.h index 3d74253..15196b5 100644 --- a/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.h +++ b/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.h @@ -31,7 +31,7 @@ namespace RequestHandlers { class UserListDiffUploadRequestHandler : public Common::RequestHandler { private: - std::string name; + Core::String name; protected: virtual void handlePacket(boost::shared_ptr packet); diff --git a/src/Server/RequestHandlers/UserListRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserListRequestHandlerGroup.cpp index bb18194..cfe2a28 100644 --- a/src/Server/RequestHandlers/UserListRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/UserListRequestHandlerGroup.cpp @@ -31,12 +31,12 @@ void UserListRequestHandlerGroup::handleUserListListRequest(boost::shared_ptrisAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - const std::set &userLists = application->getUserListManager()->getUserLists(); + const std::set &userLists = application->getUserListManager()->getUserLists(); ret->setType("OK"); Common::XmlData::List *list = ret->createList("userLists"); - for(std::set::const_iterator userList = userLists.begin(); userList != userLists.end(); ++userList) { + for(std::set::const_iterator userList = userLists.begin(); userList != userLists.end(); ++userList) { Common::XmlData::List::iterator entry = list->addEntry(); entry->set("name", *userList); @@ -48,7 +48,7 @@ void UserListRequestHandlerGroup::handleUserListDownloadRequest(boost::shared_pt if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::shared_ptr userList = application->getUserListManager()->loadUserList(packet->get("name")); + boost::shared_ptr userList = application->getUserListManager()->loadUserList(packet->get("name")); if(!userList) throw(Core::Exception(Core::Exception::NOT_FOUND)); @@ -60,7 +60,7 @@ void UserListRequestHandlerGroup::handleUserListCopyRequest(boost::shared_ptrisAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - application->getUserListManager()->copyUserList(packet->get("fromName"), packet->get("toName")); + application->getUserListManager()->copyUserList(packet->get("fromName"), packet->get("toName")); ret->setType("OK"); } @@ -69,7 +69,7 @@ void UserListRequestHandlerGroup::handleUserListRenameRequest(boost::shared_ptr< if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - application->getUserListManager()->renameUserList(packet->get("fromName"), packet->get("toName")); + application->getUserListManager()->renameUserList(packet->get("fromName"), packet->get("toName")); ret->setType("OK"); } @@ -78,7 +78,7 @@ void UserListRequestHandlerGroup::handleUserListRemoveRequest(boost::shared_ptr< if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - application->getUserListManager()->removeUserList(packet->get("name")); + application->getUserListManager()->removeUserList(packet->get("name")); ret->setType("OK"); } @@ -88,12 +88,12 @@ void UserListRequestHandlerGroup::handleUserListDiffListRequest(boost::shared_pt if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - const std::set &userListDiffs = application->getUserListManager()->getUserListDiffs(); + const std::set &userListDiffs = application->getUserListManager()->getUserListDiffs(); ret->setType("OK"); Common::XmlData::List *list = ret->createList("userListDiffs"); - for(std::set::const_iterator diff = userListDiffs.begin(); diff != userListDiffs.end(); ++diff) { + for(std::set::const_iterator diff = userListDiffs.begin(); diff != userListDiffs.end(); ++diff) { Common::XmlData::List::iterator entry = list->addEntry(); entry->set("name", *diff); @@ -105,7 +105,7 @@ void UserListRequestHandlerGroup::handleUserListDiffDownloadRequest(boost::share if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::shared_ptr diff = application->getUserListManager()->loadUserListDiff(packet->get("name")); + boost::shared_ptr diff = application->getUserListManager()->loadUserListDiff(packet->get("name")); if(!diff) throw(Core::Exception(Core::Exception::NOT_FOUND)); @@ -117,7 +117,7 @@ void UserListRequestHandlerGroup::handleUserListDiffCopyRequest(boost::shared_pt if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - application->getUserListManager()->copyUserListDiff(packet->get("fromName"), packet->get("toName")); + application->getUserListManager()->copyUserListDiff(packet->get("fromName"), packet->get("toName")); ret->setType("OK"); } @@ -126,7 +126,7 @@ void UserListRequestHandlerGroup::handleUserListDiffRenameRequest(boost::shared_ if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - application->getUserListManager()->renameUserListDiff(packet->get("fromName"), packet->get("toName")); + application->getUserListManager()->renameUserListDiff(packet->get("fromName"), packet->get("toName")); ret->setType("OK"); } @@ -135,7 +135,7 @@ void UserListRequestHandlerGroup::handleUserListDiffRemoveRequest(boost::shared_ if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - application->getUserListManager()->removeUserListDiff(packet->get("name")); + application->getUserListManager()->removeUserListDiff(packet->get("name")); ret->setType("OK"); } diff --git a/src/Server/RequestHandlers/UserListUploadRequestHandler.cpp b/src/Server/RequestHandlers/UserListUploadRequestHandler.cpp index 307863a..9de6257 100644 --- a/src/Server/RequestHandlers/UserListUploadRequestHandler.cpp +++ b/src/Server/RequestHandlers/UserListUploadRequestHandler.cpp @@ -57,11 +57,11 @@ void UserListUploadRequestHandler::handlePacket(boost::shared_ptr(getApplication())->getUserListManager(); - if(name.empty()) { // Request - name = packet->get("name"); + if(name.isEmpty()) { // Request + name = packet->get("name"); - if(name.empty()) - name = boost::posix_time::to_simple_string(boost::posix_time::second_clock::universal_time()); + if(name.isEmpty()) + name = boost::posix_time::to_simple_string(boost::posix_time::second_clock::universal_time()).c_str(); Common::XmlData ret; ret.setType("Continue"); diff --git a/src/Server/RequestHandlers/UserListUploadRequestHandler.h b/src/Server/RequestHandlers/UserListUploadRequestHandler.h index 4a20a4c..46672a5 100644 --- a/src/Server/RequestHandlers/UserListUploadRequestHandler.h +++ b/src/Server/RequestHandlers/UserListUploadRequestHandler.h @@ -31,7 +31,7 @@ namespace RequestHandlers { class UserListUploadRequestHandler : public Common::RequestHandler { private: - std::string name; + Core::String name; protected: virtual void handlePacket(boost::shared_ptr packet); diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp index 1d99c2e..f43ec86 100644 --- a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp @@ -36,10 +36,10 @@ void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptrget("timestamp"); - if(!timestr.empty()) { + const Core::String ×tr = packet->get("timestamp"); + if(!timestr.isEmpty()) { try { - timestamp = boost::posix_time::from_iso_string(timestr); + timestamp = boost::posix_time::from_iso_string(timestr.extract()); } catch(...) {} } @@ -49,7 +49,7 @@ void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptrsetType("OK"); if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp)); + ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); if(users) { Common::XmlData::List *list = ret->createList("users"); @@ -72,10 +72,10 @@ void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptrget("timestamp"); - if(!timestr.empty()) { + const Core::String ×tr = packet->get("timestamp"); + if(!timestr.isEmpty()) { try { - timestamp = boost::posix_time::from_iso_string(timestr); + timestamp = boost::posix_time::from_iso_string(timestr.extract()); } catch(...) {} } @@ -86,12 +86,12 @@ void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptrgetUserManager()->getUserInfo(uid, ×tamp); else - info = application->getUserManager()->getUserInfoByName(packet->get("name"), ×tamp); + info = application->getUserManager()->getUserInfoByName(packet->get("name"), ×tamp); ret->setType("OK"); if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp)); + ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); if(info) { ret->set("uid", info->getUid()); @@ -108,10 +108,10 @@ void UserRequestHandlerGroup::handleUserGroupListRequest(boost::shared_ptrget("timestamp"); - if(!timestr.empty()) { + const Core::String ×tr = packet->get("timestamp"); + if(!timestr.isEmpty()) { try { - timestamp = boost::posix_time::from_iso_string(timestr); + timestamp = boost::posix_time::from_iso_string(timestr.extract()); } catch(...) {} } @@ -121,7 +121,7 @@ void UserRequestHandlerGroup::handleUserGroupListRequest(boost::shared_ptrsetType("OK"); if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp)); + ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); if(groups) { Common::XmlData::List *list = ret->createList("groups"); @@ -141,10 +141,10 @@ void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptrget("timestamp"); - if(!timestr.empty()) { + const Core::String ×tr = packet->get("timestamp"); + if(!timestr.isEmpty()) { try { - timestamp = boost::posix_time::from_iso_string(timestr); + timestamp = boost::posix_time::from_iso_string(timestr.extract()); } catch(...) {} } @@ -154,7 +154,7 @@ void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptrsetType("OK"); if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp)); + ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); if(groups) { Common::XmlData::List *list = ret->createList("groups"); @@ -175,10 +175,10 @@ void UserRequestHandlerGroup::handleGroupInfoRequest(boost::shared_ptrget("timestamp"); - if(!timestr.empty()) { + const Core::String ×tr = packet->get("timestamp"); + if(!timestr.isEmpty()) { try { - timestamp = boost::posix_time::from_iso_string(timestr); + timestamp = boost::posix_time::from_iso_string(timestr.extract()); } catch(...) {} } @@ -189,12 +189,12 @@ void UserRequestHandlerGroup::handleGroupInfoRequest(boost::shared_ptrgetUserManager()->getGroupInfo(gid, ×tamp); else - info = application->getUserManager()->getGroupInfoByName(packet->get("name"), ×tamp); + info = application->getUserManager()->getGroupInfoByName(packet->get("name"), ×tamp); ret->setType("OK"); if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp)); + ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); if(info) { ret->set("gid", info->getGid()); @@ -209,10 +209,10 @@ void UserRequestHandlerGroup::handleGroupUserListRequest(boost::shared_ptrget("timestamp"); - if(!timestr.empty()) { + const Core::String ×tr = packet->get("timestamp"); + if(!timestr.isEmpty()) { try { - timestamp = boost::posix_time::from_iso_string(timestr); + timestamp = boost::posix_time::from_iso_string(timestr.extract()); } catch(...) {} } @@ -222,7 +222,7 @@ void UserRequestHandlerGroup::handleGroupUserListRequest(boost::shared_ptrsetType("OK"); if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp)); + ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); Common::XmlData::List *list = ret->createList("users"); @@ -240,10 +240,10 @@ void UserRequestHandlerGroup::handleFullUserGroupListRequest(boost::shared_ptrget("timestamp"); - if(!timestr.empty()) { + const Core::String ×tr = packet->get("timestamp"); + if(!timestr.isEmpty()) { try { - timestamp = boost::posix_time::from_iso_string(timestr); + timestamp = boost::posix_time::from_iso_string(timestr.extract()); } catch(...) {} } @@ -253,7 +253,7 @@ void UserRequestHandlerGroup::handleFullUserGroupListRequest(boost::shared_ptrsetType("OK"); if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp)); + ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); if(userGroups) { Common::XmlData::List *list = ret->createList("userGroupList"); @@ -273,9 +273,9 @@ void UserRequestHandlerGroup::handleUserInfoCheckRequest(boost::shared_ptrisAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - Common::UserInfo userInfo(packet->get("uid"), packet->get("username")); + Common::UserInfo userInfo(packet->get("uid"), packet->get("username")); userInfo.setGid(packet->get("gid")); - userInfo.setFullName(packet->get("fullName")); + userInfo.setFullName(packet->get("fullName")); application->getUserManager()->checkUserInfo(userInfo); @@ -287,9 +287,9 @@ void UserRequestHandlerGroup::handleUserAddRequest(boost::shared_ptrisAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - Common::UserInfo userInfo(packet->get("uid"), packet->get("username")); + Common::UserInfo userInfo(packet->get("uid"), packet->get("username")); userInfo.setGid(packet->get("gid")); - userInfo.setFullName(packet->get("fullName")); + userInfo.setFullName(packet->get("fullName")); application->getUserManager()->addUser(userInfo); @@ -301,9 +301,9 @@ void UserRequestHandlerGroup::handleUserUpdateRequest(boost::shared_ptrisAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - Common::UserInfo userInfo(packet->get("uid"), packet->get("username")); + Common::UserInfo userInfo(packet->get("uid"), packet->get("username")); userInfo.setGid(packet->get("gid")); - userInfo.setFullName(packet->get("fullName")); + userInfo.setFullName(packet->get("fullName")); application->getUserManager()->updateUser(packet->get("origUid"), userInfo); @@ -326,7 +326,7 @@ void UserRequestHandlerGroup::handleGroupInfoCheckRequest(boost::shared_ptrisAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - application->getUserManager()->checkGroupInfo(Common::GroupInfo(packet->get("gid"), packet->get("name"))); + application->getUserManager()->checkGroupInfo(Common::GroupInfo(packet->get("gid"), packet->get("name"))); ret->setType("OK"); } @@ -336,7 +336,7 @@ void UserRequestHandlerGroup::handleGroupAddRequest(boost::shared_ptrisAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - application->getUserManager()->addGroup(Common::GroupInfo(packet->get("gid"), packet->get("name"))); + application->getUserManager()->addGroup(Common::GroupInfo(packet->get("gid"), packet->get("name"))); ret->setType("OK"); } @@ -347,7 +347,7 @@ void UserRequestHandlerGroup::handleGroupUpdateRequest(boost::shared_ptrgetUserManager()->updateGroup(packet->get("origGid"), - Common::GroupInfo(packet->get("gid"), packet->get("name"))); + Common::GroupInfo(packet->get("gid"), packet->get("name"))); ret->setType("OK"); } @@ -388,7 +388,7 @@ void UserRequestHandlerGroup::handlePasswordSetRequest(boost::shared_ptrisAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - application->getUserManager()->setPassword(packet->get("uid"), packet->get("password")); + application->getUserManager()->setPassword(packet->get("uid"), packet->get("password")); ret->setType("OK"); } diff --git a/src/Server/Requests/DaemonStateUpdateRequest.h b/src/Server/Requests/DaemonStateUpdateRequest.h index 862e8ac..2fd3242 100644 --- a/src/Server/Requests/DaemonStateUpdateRequest.h +++ b/src/Server/Requests/DaemonStateUpdateRequest.h @@ -31,14 +31,14 @@ namespace Requests { class MAD_SERVER_EXPORT DaemonStateUpdateRequest : public Common::Request { private: - std::string name; + Core::String name; Common::HostInfo::State state; protected: virtual void sendRequest(); public: - DaemonStateUpdateRequest(Common::Application *application, const std::string &name0, Common::HostInfo::State state0) + DaemonStateUpdateRequest(Common::Application *application, const Core::String &name0, Common::HostInfo::State state0) : Common::Request(application), name(name0), state(state0) {} }; diff --git a/src/Server/UserListManager.cpp b/src/Server/UserListManager.cpp index d520c96..a8794fe 100644 --- a/src/Server/UserListManager.cpp +++ b/src/Server/UserListManager.cpp @@ -54,11 +54,11 @@ void UserListManager::configFinished() { application->getRequestManager()->registerPacketType("UploadUserListDiff"); } -bool UserListManager::existsUserList(const std::string &name) { +bool UserListManager::existsUserList(const Core::String &name) { return application->getStorageManager()->exists("UserList", name); } -boost::shared_ptr UserListManager::loadUserList(const std::string &name) { +boost::shared_ptr UserListManager::loadUserList(const Core::String &name) { boost::shared_ptr data = application->getStorageManager()->load("UserList", name); if(!data) @@ -67,31 +67,31 @@ boost::shared_ptr UserListManager::loadUserList(con return Common::UserLists::Util::deserializeUserList(data.get()); } -void UserListManager::storeUserList(const std::string &name, const Common::UserLists::UserList *list) { +void UserListManager::storeUserList(const Core::String &name, const Common::UserLists::UserList *list) { Common::XmlData data; Common::UserLists::Util::serializeUserList(list, &data); application->getStorageManager()->store("UserList", name, &data); } -void UserListManager::copyUserList(const std::string &fromName, const std::string &toName) { +void UserListManager::copyUserList(const Core::String &fromName, const Core::String &toName) { application->getStorageManager()->copy("UserList", fromName, toName); } -void UserListManager::renameUserList(const std::string &fromName, const std::string &toName) { +void UserListManager::renameUserList(const Core::String &fromName, const Core::String &toName) { application->getStorageManager()->rename("UserList", fromName, toName); } -void UserListManager::removeUserList(const std::string &name) { +void UserListManager::removeUserList(const Core::String &name) { application->getStorageManager()->remove("UserList", name); } -bool UserListManager::existsUserListDiff(const std::string &name) { +bool UserListManager::existsUserListDiff(const Core::String &name) { return application->getStorageManager()->exists("UserListDiff", name); } -boost::shared_ptr UserListManager::loadUserListDiff(const std::string &name) { +boost::shared_ptr UserListManager::loadUserListDiff(const Core::String &name) { boost::shared_ptr data = application->getStorageManager()->load("UserListDiff", name); if(!data) @@ -100,22 +100,22 @@ boost::shared_ptr UserListManager::loadUserList return Common::UserLists::Util::deserializeUserListDiff(data.get()); } -void UserListManager::storeUserListDiff(const std::string &name, const Common::UserLists::UserListDiff *list) { +void UserListManager::storeUserListDiff(const Core::String &name, const Common::UserLists::UserListDiff *list) { Common::XmlData data; Common::UserLists::Util::serializeUserListDiff(list, &data); application->getStorageManager()->store("UserListDiff", name, &data); } -void UserListManager::copyUserListDiff(const std::string &fromName, const std::string &toName) { +void UserListManager::copyUserListDiff(const Core::String &fromName, const Core::String &toName) { application->getStorageManager()->copy("UserListDiff", fromName, toName); } -void UserListManager::renameUserListDiff(const std::string &fromName, const std::string &toName) { +void UserListManager::renameUserListDiff(const Core::String &fromName, const Core::String &toName) { application->getStorageManager()->rename("UserListDiff", fromName, toName); } -void UserListManager::removeUserListDiff(const std::string &name) { +void UserListManager::removeUserListDiff(const Core::String &name) { application->getStorageManager()->remove("UserListDiff", name); } @@ -127,7 +127,7 @@ boost::shared_ptr UserListManager::getCurrentUserLi for(std::map::const_iterator user = userList->begin(); user != userList->end(); ++user) { std::map::const_iterator group = groupList->find(user->second.getGid()); - std::string groupname; + Core::String groupname; if(group != groupList->end()) { groupname = group->second.getName(); @@ -135,7 +135,7 @@ boost::shared_ptr UserListManager::getCurrentUserLi else { std::ostringstream stream; stream << user->second.getGid(); - groupname = stream.str(); + groupname = stream.str().c_str(); } Common::UserLists::UserListEntry entry(user->second.getUsername(), groupname); diff --git a/src/Server/UserListManager.h b/src/Server/UserListManager.h index 1651d42..65e8fdf 100644 --- a/src/Server/UserListManager.h +++ b/src/Server/UserListManager.h @@ -23,6 +23,7 @@ #include "export.h" #include +#include #include #include @@ -52,8 +53,8 @@ class MAD_SERVER_EXPORT UserListManager : private Core::Configurable, private bo boost::shared_ptr requestHandlerGroup; - std::set userLists; - std::set userListDiffs; + std::set userLists; + std::set userListDiffs; protected: virtual void configFinished(); @@ -64,27 +65,27 @@ class MAD_SERVER_EXPORT UserListManager : private Core::Configurable, private bo UserListManager(Application *application0); virtual ~UserListManager(); - const std::set& getUserLists() const { + const std::set& getUserLists() const { return userLists; } - bool existsUserList(const std::string &name); - boost::shared_ptr loadUserList(const std::string &name); - void storeUserList(const std::string &name, const Common::UserLists::UserList *list); - void copyUserList(const std::string &fromName, const std::string &toName); - void renameUserList(const std::string &fromName, const std::string &toName); - void removeUserList(const std::string &name); + bool existsUserList(const Core::String &name); + boost::shared_ptr loadUserList(const Core::String &name); + void storeUserList(const Core::String &name, const Common::UserLists::UserList *list); + void copyUserList(const Core::String &fromName, const Core::String &toName); + void renameUserList(const Core::String &fromName, const Core::String &toName); + void removeUserList(const Core::String &name); - const std::set& getUserListDiffs() const { + const std::set& getUserListDiffs() const { return userListDiffs; } - bool existsUserListDiff(const std::string &name); - boost::shared_ptr loadUserListDiff(const std::string &name); - void storeUserListDiff(const std::string &name, const Common::UserLists::UserListDiff *list); - void copyUserListDiff(const std::string &fromName, const std::string &toName); - void renameUserListDiff(const std::string &fromName, const std::string &toName); - void removeUserListDiff(const std::string &name); + bool existsUserListDiff(const Core::String &name); + boost::shared_ptr loadUserListDiff(const Core::String &name); + void storeUserListDiff(const Core::String &name, const Common::UserLists::UserListDiff *list); + void copyUserListDiff(const Core::String &fromName, const Core::String &toName); + void renameUserListDiff(const Core::String &fromName, const Core::String &toName); + void removeUserListDiff(const Core::String &name); boost::shared_ptr getCurrentUserList(); }; -- cgit v1.2.3