From dff7c00a0c2c3fcb64efd611d70398d711ad861b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 24 Jun 2009 00:04:28 +0200 Subject: NetworkUserBackend implementiert --- src/modules/UserBackendMysql/UserBackendMysql.cpp | 36 +++++++++++------------ src/modules/UserBackendMysql/UserBackendMysql.h | 18 ++++++------ 2 files changed, 27 insertions(+), 27 deletions(-) (limited to 'src/modules/UserBackendMysql') diff --git a/src/modules/UserBackendMysql/UserBackendMysql.cpp b/src/modules/UserBackendMysql/UserBackendMysql.cpp index 904c9a6..e6e6dda 100644 --- a/src/modules/UserBackendMysql/UserBackendMysql.cpp +++ b/src/modules/UserBackendMysql/UserBackendMysql.cpp @@ -129,14 +129,14 @@ void UserBackendMysql::configFinished() { } -boost::shared_ptr > UserBackendMysql::getUserList() throw(Core::Exception) { +boost::shared_ptr > UserBackendMysql::getUserList() throw(Core::Exception) { application->getThreadManager()->detach(); if(!mysql || mysql_ping(mysql)) throw Core::Exception(Core::Exception::NOT_AVAILABLE); mysql_real_query(mysql, queryListUsers.c_str(), queryListUsers.length()); - MYSQL_RES *result = mysql_use_result(mysql); + MYSQL_RES *result = mysql_store_result(mysql); if(!result || mysql_num_fields(result) < 4) throw Core::Exception(Core::Exception::NOT_AVAILABLE); @@ -155,7 +155,7 @@ boost::shared_ptr > UserBackendMysql:: return users; } -boost::shared_ptr UserBackendMysql::getUserInfo(unsigned long uid) throw(Core::Exception) { +boost::shared_ptr UserBackendMysql::getUserInfo(unsigned long uid) throw(Core::Exception) { application->getThreadManager()->detach(); if(!mysql || mysql_ping(mysql)) @@ -171,7 +171,7 @@ boost::shared_ptr UserBackendMysql::getUserInfo(unsigned long query = boost::regex_replace(query, boost::regex("\\{UID\\}"), tmp.str(), boost::match_default); mysql_real_query(mysql, query.c_str(), query.length()); - MYSQL_RES *result = mysql_use_result(mysql); + MYSQL_RES *result = mysql_store_result(mysql); if(!result || mysql_num_fields(result) < 4) throw Core::Exception(Core::Exception::NOT_AVAILABLE); @@ -192,7 +192,7 @@ boost::shared_ptr UserBackendMysql::getUserInfo(unsigned long throw Core::Exception(Core::Exception::NOT_AVAILABLE); } -boost::shared_ptr UserBackendMysql::getUserInfoByName(const std::string &name) throw(Core::Exception) { +boost::shared_ptr UserBackendMysql::getUserInfoByName(const std::string &name) throw(Core::Exception) { application->getThreadManager()->detach(); if(!mysql || mysql_ping(mysql)) @@ -205,7 +205,7 @@ boost::shared_ptr UserBackendMysql::getUserInfoByName(const st std::string query = boost::regex_replace(queryUserByName, boost::regex("\\{USER\\}"), "\""+std::string(escapedName.get())+"\"", boost::match_default); mysql_real_query(mysql, query.c_str(), query.length()); - MYSQL_RES *result = mysql_use_result(mysql); + MYSQL_RES *result = mysql_store_result(mysql); if(!result || mysql_num_fields(result) < 4) throw Core::Exception(Core::Exception::NOT_AVAILABLE); @@ -226,7 +226,7 @@ boost::shared_ptr UserBackendMysql::getUserInfoByName(const st throw Core::Exception(Core::Exception::NOT_AVAILABLE); } -boost::shared_ptr > UserBackendMysql::getUserGroupList(unsigned long uid) throw(Core::Exception) { +boost::shared_ptr > UserBackendMysql::getUserGroupList(unsigned long uid) throw(Core::Exception) { application->getThreadManager()->detach(); if(!mysql || mysql_ping(mysql)) @@ -240,7 +240,7 @@ boost::shared_ptr > UserBackendMysql::getUserGroupList(u std::string query = boost::regex_replace(queryListUserGroups, boost::regex("\\{UID\\}"), tmp.str(), boost::match_default); mysql_real_query(mysql, query.c_str(), query.length()); - MYSQL_RES *result = mysql_use_result(mysql); + MYSQL_RES *result = mysql_store_result(mysql); if(!result || mysql_num_fields(result) < 1) throw Core::Exception(Core::Exception::NOT_AVAILABLE); @@ -254,14 +254,14 @@ boost::shared_ptr > UserBackendMysql::getUserGroupList(u } -boost::shared_ptr > UserBackendMysql::getGroupList() throw(Core::Exception) { +boost::shared_ptr > UserBackendMysql::getGroupList() throw(Core::Exception) { application->getThreadManager()->detach(); if(!mysql || mysql_ping(mysql)) throw Core::Exception(Core::Exception::NOT_AVAILABLE); mysql_real_query(mysql, queryListGroups.c_str(), queryListGroups.length()); - MYSQL_RES *result = mysql_use_result(mysql); + MYSQL_RES *result = mysql_store_result(mysql); if(!result || mysql_num_fields(result) < 2) throw Core::Exception(Core::Exception::NOT_AVAILABLE); @@ -277,7 +277,7 @@ boost::shared_ptr > UserBackendMysql: return groups; } -std::string UserBackendMysql::getGroupName(unsigned long gid) throw(Core::Exception) { +boost::shared_ptr UserBackendMysql::getGroupInfo(unsigned long gid) throw(Core::Exception) { application->getThreadManager()->detach(); if(!mysql || mysql_ping(mysql)) @@ -293,7 +293,7 @@ std::string UserBackendMysql::getGroupName(unsigned long gid) throw(Core::Except query = boost::regex_replace(query, boost::regex("\\{GID\\}"), tmp.str(), boost::match_default); mysql_real_query(mysql, query.c_str(), query.length()); - MYSQL_RES *result = mysql_use_result(mysql); + MYSQL_RES *result = mysql_store_result(mysql); if(!result || mysql_num_fields(result) < 2) throw Core::Exception(Core::Exception::NOT_AVAILABLE); @@ -301,12 +301,12 @@ std::string UserBackendMysql::getGroupName(unsigned long gid) throw(Core::Except MYSQL_ROW row = mysql_fetch_row(result); if(row) - return row[1]; + return boost::shared_ptr(new Common::GroupInfo(strtoul(row[0], 0, 10), row[1])); throw Core::Exception(Core::Exception::NOT_AVAILABLE); } -unsigned long UserBackendMysql::getGroupId(const std::string &name) throw(Core::Exception) { +boost::shared_ptr UserBackendMysql::getGroupInfoByName(const std::string &name) throw(Core::Exception) { application->getThreadManager()->detach(); if(!mysql || mysql_ping(mysql)) @@ -319,7 +319,7 @@ unsigned long UserBackendMysql::getGroupId(const std::string &name) throw(Core:: std::string query = boost::regex_replace(queryGroupByName, boost::regex("\\{GROUP\\}"), "\""+std::string(escapedName.get())+"\"", boost::match_default); mysql_real_query(mysql, query.c_str(), query.length()); - MYSQL_RES *result = mysql_use_result(mysql); + MYSQL_RES *result = mysql_store_result(mysql); if(!result || mysql_num_fields(result) < 2) throw Core::Exception(Core::Exception::NOT_AVAILABLE); @@ -327,12 +327,12 @@ unsigned long UserBackendMysql::getGroupId(const std::string &name) throw(Core:: MYSQL_ROW row = mysql_fetch_row(result); if(row) - return strtoul(row[0], 0, 10); + return boost::shared_ptr(new Common::GroupInfo(strtoul(row[0], 0, 10), row[1])); throw Core::Exception(Core::Exception::NOT_AVAILABLE); } -boost::shared_ptr > UserBackendMysql::getGroupUserList(unsigned long gid) throw(Core::Exception) { +boost::shared_ptr > UserBackendMysql::getGroupUserList(unsigned long gid) throw(Core::Exception) { application->getThreadManager()->detach(); if(!mysql || mysql_ping(mysql)) @@ -346,7 +346,7 @@ boost::shared_ptr > UserBackendMysql::getGroupUserList(u std::string query = boost::regex_replace(queryListGroupUsers, boost::regex("\\{GID\\}"), tmp.str(), boost::match_default); mysql_real_query(mysql, query.c_str(), query.length()); - MYSQL_RES *result = mysql_use_result(mysql); + MYSQL_RES *result = mysql_store_result(mysql); if(!result || mysql_num_fields(result) < 1) throw Core::Exception(Core::Exception::NOT_AVAILABLE); diff --git a/src/modules/UserBackendMysql/UserBackendMysql.h b/src/modules/UserBackendMysql/UserBackendMysql.h index 77f0700..7832e95 100644 --- a/src/modules/UserBackendMysql/UserBackendMysql.h +++ b/src/modules/UserBackendMysql/UserBackendMysql.h @@ -50,15 +50,15 @@ class UserBackendMysql : public Common::UserBackend, private Core::Configurable virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool); virtual void configFinished(); - virtual boost::shared_ptr > getUserList() throw(Core::Exception); - virtual boost::shared_ptr getUserInfo(unsigned long uid) throw(Core::Exception); - virtual boost::shared_ptr getUserInfoByName(const std::string &name) throw(Core::Exception); - virtual boost::shared_ptr > getUserGroupList(unsigned long uid) throw(Core::Exception); - - virtual boost::shared_ptr > getGroupList() throw(Core::Exception); - virtual std::string getGroupName(unsigned long gid) throw(Core::Exception); - virtual unsigned long getGroupId(const std::string &name) throw(Core::Exception); - virtual boost::shared_ptr > getGroupUserList(unsigned long gid) throw(Core::Exception); + virtual boost::shared_ptr > getUserList() throw(Core::Exception); + virtual boost::shared_ptr getUserInfo(unsigned long uid) throw(Core::Exception); + virtual boost::shared_ptr getUserInfoByName(const std::string &name) throw(Core::Exception); + virtual boost::shared_ptr > getUserGroupList(unsigned long uid) throw(Core::Exception); + + virtual boost::shared_ptr > getGroupList() throw(Core::Exception); + virtual boost::shared_ptr getGroupInfo(unsigned long gid) throw(Core::Exception); + virtual boost::shared_ptr getGroupInfoByName(const std::string &name) throw(Core::Exception); + virtual boost::shared_ptr > getGroupUserList(unsigned long gid) throw(Core::Exception); public: UserBackendMysql(Common::Application *application0) : application(application0), port(0), mysql(0) { -- cgit v1.2.3