summaryrefslogtreecommitdiffstats
path: root/src/modules/UserBackendMysql/UserBackendMysql.h
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-07-07 18:51:35 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-07-07 18:51:35 +0200
commitc4cbe4a94fd63e0da6e291a481b9a9ccc71e7843 (patch)
tree54fc3c43aec1b08f6918add662574b35a355e363 /src/modules/UserBackendMysql/UserBackendMysql.h
parentf2f1d5b1da4f985bcbb0c075cf42efcacecae2a6 (diff)
downloadmad-c4cbe4a94fd63e0da6e291a481b9a9ccc71e7843.tar
mad-c4cbe4a94fd63e0da6e291a481b9a9ccc71e7843.zip
Added add_user command to client & UserBackendMysql
Diffstat (limited to 'src/modules/UserBackendMysql/UserBackendMysql.h')
-rw-r--r--src/modules/UserBackendMysql/UserBackendMysql.h51
1 files changed, 50 insertions, 1 deletions
diff --git a/src/modules/UserBackendMysql/UserBackendMysql.h b/src/modules/UserBackendMysql/UserBackendMysql.h
index 52a134a..25c3837 100644
--- a/src/modules/UserBackendMysql/UserBackendMysql.h
+++ b/src/modules/UserBackendMysql/UserBackendMysql.h
@@ -34,8 +34,54 @@ namespace Mad {
namespace Modules {
namespace UserBackendMysql {
-class UserBackendMysql : public Common::UserBackend, private Core::Configurable {
+class UserBackendMysql : public Common::UserBackend, private Core::Configurable, private boost::noncopyable {
private:
+ class Result : private boost::noncopyable {
+ private:
+ MYSQL_RES *result;
+
+ unsigned int mysqlErrno;
+ const char *error;
+
+ public:
+ Result(MYSQL *mysql) {
+ result = mysql_store_result(mysql);
+
+ mysqlErrno = mysql_errno(mysql);
+ error = mysql_error(mysql);
+ }
+
+ ~Result() {
+ if(result) {
+ mysql_free_result(result);
+ }
+ }
+
+ operator bool() const {
+ return result;
+ }
+
+ unsigned int getErrno() const {
+ return mysqlErrno;
+ }
+
+ const char* getError() const {
+ return error;
+ }
+
+ unsigned int getFieldNumber() const {
+ return mysql_num_fields(result);
+ }
+
+ my_ulonglong getRowNumber() const {
+ return mysql_num_rows(result);
+ }
+
+ MYSQL_ROW getNextRow() {
+ return mysql_fetch_row(result);
+ }
+ };
+
Common::Application *application;
std::string host, username, passwd, db, unixSocket;
@@ -46,6 +92,7 @@ class UserBackendMysql : public Common::UserBackend, private Core::Configurable
std::string queryUserById, queryUserByName;
std::string queryGroupById, queryGroupByName;
std::string queryUserGroupTable;
+ std::string queryAddUser;
MYSQL *mysql;
@@ -69,6 +116,8 @@ class UserBackendMysql : public Common::UserBackend, private Core::Configurable
virtual boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > getFullUserGroupList(boost::posix_time::ptime *timestamp) throw(Core::Exception);
+ virtual void addUser(const Common::UserInfo &userInfo) throw(Core::Exception);
+
public:
UserBackendMysql(Common::Application *application0) : application(application0), port(0), mysql(0), lastUpdate(boost::posix_time::microsec_clock::universal_time()) {
application->getConfigManager()->registerConfigurable(this);