From a7a285eb61dd83afc892bc1d64ffe14b9f1426a3 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 27 Sep 2009 23:51:34 +0200 Subject: Completely migrate to Unicode String class --- src/Server/ConnectionManager.cpp | 14 ++-- src/Server/ConnectionManager.h | 2 +- .../ConnectionRequestHandlerGroup.cpp | 16 +--- .../RequestHandlers/DaemonRequestHandlerGroup.cpp | 4 +- .../RequestHandlers/UserRequestHandlerGroup.cpp | 98 ++++------------------ 5 files changed, 27 insertions(+), 107 deletions(-) (limited to 'src/Server') diff --git a/src/Server/ConnectionManager.cpp b/src/Server/ConnectionManager.cpp index f09f9e3..25e088a 100644 --- a/src/Server/ConnectionManager.cpp +++ b/src/Server/ConnectionManager.cpp @@ -120,31 +120,31 @@ bool ConnectionManager::handleConfigEntry(const Core::ConfigEntry &entry, bool h if(entry[0].getKey().matches("Listen") && entry[1].isEmpty()) { try { - listenerAddresses.push_back(parseAddress(entry[0][0].extract())); + listenerAddresses.push_back(parseAddress(entry[0][0].toString())); } catch(Core::Exception &e) { - application->logf(Core::Logger::LOG_WARNING, "ConnectionManager: Invalid listen address '%s'", entry[0][0].extract().c_str()); + application->logf(Core::Logger::LOG_WARNING, "ConnectionManager: Invalid listen address '%s'", entry[0][0].toLocale().c_str()); } return true; } else if(entry[0].getKey().matches("X509TrustFile") && entry[1].isEmpty()) { - x509TrustFile = entry[0][0].extract(); + x509TrustFile = entry[0][0]; return true; } else if(entry[0].getKey().matches("X509CrlFile") && entry[1].isEmpty()) { - x509CrlFile = entry[0][0].extract(); + x509CrlFile = entry[0][0]; return true; } else if(entry[0].getKey().matches("X509CertFile") && entry[1].isEmpty()) { - x509CertFile = entry[0][0].extract(); + x509CertFile = entry[0][0]; return true; } else if(entry[0].getKey().matches("X509KeyFile") && entry[1].isEmpty()) { - x509KeyFile = entry[0][0].extract(); + x509KeyFile = entry[0][0]; return true; } @@ -156,7 +156,7 @@ bool ConnectionManager::handleConfigEntry(const Core::ConfigEntry &entry, bool h return true; } else if(entry[1].getKey().matches("IpAddress") && entry[2].isEmpty()) { - daemonInfo[entry[0][0]].setIP(entry[1][0].extract()); + daemonInfo[entry[0][0]].setIP(entry[1][0].toString()); return true; } diff --git a/src/Server/ConnectionManager.h b/src/Server/ConnectionManager.h index dab1892..7e9dab0 100644 --- a/src/Server/ConnectionManager.h +++ b/src/Server/ConnectionManager.h @@ -107,7 +107,7 @@ class MAD_SERVER_EXPORT ConnectionManager : public Core::Configurable, private b Application *application; - std::string x509TrustFile, x509CrlFile, x509CertFile, x509KeyFile; + Core::String x509TrustFile, x509CrlFile, x509CertFile, x509KeyFile; std::vector listenerAddresses; std::list > listeners; diff --git a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp index d446485..a1c492b 100644 --- a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp @@ -100,23 +100,13 @@ void ConnectionRequestHandlerGroup::handleIdentifyRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection) { // TODO Require authentication - boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - - const Core::String ×tr = packet->get("timestamp"); - if(!timestr.isEmpty()) { - try { - timestamp = boost::posix_time::from_iso_string(timestr.extract()); - } - catch(...) {} - } - try { application->getLogManager()->log( static_cast(packet->get("category")), static_cast(packet->get("level")), - timestamp, - packet->get("message").extract(), - application->getConnectionManager()->getDaemonName(connection).extract()); + packet->get("timestamp"), + packet->get("message"), + application->getConnectionManager()->getDaemonName(connection)); } 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 8f6909e..c80f493 100644 --- a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp @@ -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().c_str()); + ret.set("Where", e.getWhere()); 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().c_str()); + ret.set("Where", error.getWhere()); sendPacket(ret); } diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp index f43ec86..5a7e3f9 100644 --- a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp @@ -34,22 +34,12 @@ void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptrisAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - - const Core::String ×tr = packet->get("timestamp"); - if(!timestr.isEmpty()) { - try { - timestamp = boost::posix_time::from_iso_string(timestr.extract()); - } - catch(...) {} - } + boost::posix_time::ptime timestamp = packet->get("timestamp"); boost::shared_ptr > users = application->getUserManager()->getUserList(×tamp); ret->setType("OK"); - - if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); + ret->set("timestamp", timestamp); if(users) { Common::XmlData::List *list = ret->createList("users"); @@ -70,15 +60,7 @@ void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptrisAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - - const Core::String ×tr = packet->get("timestamp"); - if(!timestr.isEmpty()) { - try { - timestamp = boost::posix_time::from_iso_string(timestr.extract()); - } - catch(...) {} - } + boost::posix_time::ptime timestamp = packet->get("timestamp"); boost::shared_ptr info; @@ -89,9 +71,7 @@ void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptrgetUserManager()->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).c_str()); + ret->set("timestamp", timestamp); if(info) { ret->set("uid", info->getUid()); @@ -106,22 +86,12 @@ void UserRequestHandlerGroup::handleUserGroupListRequest(boost::shared_ptrisAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - - const Core::String ×tr = packet->get("timestamp"); - if(!timestr.isEmpty()) { - try { - timestamp = boost::posix_time::from_iso_string(timestr.extract()); - } - catch(...) {} - } + boost::posix_time::ptime timestamp = packet->get("timestamp"); boost::shared_ptr > groups = application->getUserManager()->getUserGroupList(packet->get("uid"), ×tamp); ret->setType("OK"); - - if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); + ret->set("timestamp", timestamp); if(groups) { Common::XmlData::List *list = ret->createList("groups"); @@ -139,22 +109,12 @@ void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptrisAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - - const Core::String ×tr = packet->get("timestamp"); - if(!timestr.isEmpty()) { - try { - timestamp = boost::posix_time::from_iso_string(timestr.extract()); - } - catch(...) {} - } + boost::posix_time::ptime timestamp = packet->get("timestamp"); boost::shared_ptr > groups = application->getUserManager()->getGroupList(×tamp); ret->setType("OK"); - - if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); + ret->set("timestamp", timestamp); if(groups) { Common::XmlData::List *list = ret->createList("groups"); @@ -173,15 +133,7 @@ void UserRequestHandlerGroup::handleGroupInfoRequest(boost::shared_ptrisAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - - const Core::String ×tr = packet->get("timestamp"); - if(!timestr.isEmpty()) { - try { - timestamp = boost::posix_time::from_iso_string(timestr.extract()); - } - catch(...) {} - } + boost::posix_time::ptime timestamp = packet->get("timestamp"); boost::shared_ptr info; @@ -192,9 +144,7 @@ void UserRequestHandlerGroup::handleGroupInfoRequest(boost::shared_ptrgetUserManager()->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).c_str()); + ret->set("timestamp", timestamp); if(info) { ret->set("gid", info->getGid()); @@ -207,22 +157,12 @@ void UserRequestHandlerGroup::handleGroupUserListRequest(boost::shared_ptrisAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - - const Core::String ×tr = packet->get("timestamp"); - if(!timestr.isEmpty()) { - try { - timestamp = boost::posix_time::from_iso_string(timestr.extract()); - } - catch(...) {} - } + boost::posix_time::ptime timestamp = packet->get("timestamp"); boost::shared_ptr > users = application->getUserManager()->getGroupUserList(packet->get("gid"), ×tamp); ret->setType("OK"); - - if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); + ret->set("timestamp", timestamp); Common::XmlData::List *list = ret->createList("users"); @@ -238,22 +178,12 @@ void UserRequestHandlerGroup::handleFullUserGroupListRequest(boost::shared_ptrisAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - - const Core::String ×tr = packet->get("timestamp"); - if(!timestr.isEmpty()) { - try { - timestamp = boost::posix_time::from_iso_string(timestr.extract()); - } - catch(...) {} - } + boost::posix_time::ptime timestamp = packet->get("timestamp"); boost::shared_ptr > userGroups = application->getUserManager()->getFullUserGroupList(×tamp); ret->setType("OK"); - - if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); + ret->set("timestamp", timestamp); if(userGroups) { Common::XmlData::List *list = ret->createList("userGroupList"); -- cgit v1.2.3