summaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/Makefile.am2
-rw-r--r--src/modules/Makefile.in16
-rw-r--r--src/modules/UserBackendMysql.cpp50
3 files changed, 54 insertions, 14 deletions
diff --git a/src/modules/Makefile.am b/src/modules/Makefile.am
index ee11f5c..93b54b3 100644
--- a/src/modules/Makefile.am
+++ b/src/modules/Makefile.am
@@ -31,7 +31,7 @@ SystemBackendProc_la_SOURCES = SystemBackendProc.cpp
SystemBackendProc_la_LDFLAGS = $(static_ldflags) -export-symbols-regex '^SystemBackendProc_LTX_'
UserBackendMysql_la_SOURCES = UserBackendMysql.cpp
-UserBackendMysql_la_LIBADD = $(MYSQL_LDFLAGS)
+UserBackendMysql_la_LIBADD = $(MYSQL_LDFLAGS) $(pcrecpp_LIBS)
UserBackendMysql_la_LDFLAGS = $(default_ldflags) -export-symbols-regex '^UserBackendMysql_LTX_'
noinst_HEADERS = FileLogger.h SystemBackendPosix.h SystemBackendProc.h UserBackendMysql.h
diff --git a/src/modules/Makefile.in b/src/modules/Makefile.in
index 7ea2f4f..3913566 100644
--- a/src/modules/Makefile.in
+++ b/src/modules/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -83,7 +83,8 @@ SystemBackendProc_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(SystemBackendProc_la_LDFLAGS) $(LDFLAGS) -o $@
@SYSTEMBACKEND_PROC_TRUE@am_SystemBackendProc_la_rpath =
-UserBackendMysql_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+UserBackendMysql_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
am_UserBackendMysql_la_OBJECTS = UserBackendMysql.lo
UserBackendMysql_la_OBJECTS = $(am_UserBackendMysql_la_OBJECTS)
UserBackendMysql_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
@@ -248,6 +249,8 @@ ltdl_LTLIBOBJS = @ltdl_LTLIBOBJS@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
+pcrecpp_CFLAGS = @pcrecpp_CFLAGS@
+pcrecpp_LIBS = @pcrecpp_LIBS@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
@@ -260,6 +263,7 @@ srcdir = @srcdir@
sys_symbol_underscore = @sys_symbol_underscore@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
moddir = ${pkglibdir}/modules
@@ -276,7 +280,7 @@ SystemBackendPosix_la_LDFLAGS = $(static_ldflags) -export-symbols-regex '^System
SystemBackendProc_la_SOURCES = SystemBackendProc.cpp
SystemBackendProc_la_LDFLAGS = $(static_ldflags) -export-symbols-regex '^SystemBackendProc_LTX_'
UserBackendMysql_la_SOURCES = UserBackendMysql.cpp
-UserBackendMysql_la_LIBADD = $(MYSQL_LDFLAGS)
+UserBackendMysql_la_LIBADD = $(MYSQL_LDFLAGS) $(pcrecpp_LIBS)
UserBackendMysql_la_LDFLAGS = $(default_ldflags) -export-symbols-regex '^UserBackendMysql_LTX_'
noinst_HEADERS = FileLogger.h SystemBackendPosix.h SystemBackendProc.h UserBackendMysql.h
all: all-am
@@ -287,8 +291,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
- && exit 0; \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
@@ -400,7 +404,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
- $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
diff --git a/src/modules/UserBackendMysql.cpp b/src/modules/UserBackendMysql.cpp
index 0b028fb..db3c32b 100644
--- a/src/modules/UserBackendMysql.cpp
+++ b/src/modules/UserBackendMysql.cpp
@@ -17,14 +17,17 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <config.h>
+
#include "UserBackendMysql.h"
#include <Common/ActionManager.h>
#include <Common/ConfigEntry.h>
#include <Common/Logger.h>
-#include <sigc++/bind.h>
+#include <sstream>
-#include <cstdlib>
+#include <sigc++/bind.h>
+#include <pcrecpp.h>
#define init UserBackendMysql_LTX_init
#define deinit UserBackendMysql_LTX_deinit
@@ -61,7 +64,7 @@ bool UserBackendMysql::handleConfigEntry(const Common::ConfigEntry &entry, bool
char *endptr;
long val;
- val = std::strtol(entry[1][0].c_str(), &endptr, 10);
+ val = strtol(entry[1][0].c_str(), &endptr, 10);
if(endptr != 0 || val < 0 || val > 65535)
Common::Logger::log(Common::Logger::WARNING, "UserBackendMysql: Invalid port");
@@ -143,9 +146,9 @@ bool UserBackendMysql::userList(const sigc::slot<void, const std::map<unsigned l
std::map<unsigned long, Common::UserInfo> users;
while(MYSQL_ROW row = mysql_fetch_row(result)) {
- Common::UserInfo user(std::strtoul(row[0], 0, 10), row[2]);
+ Common::UserInfo user(strtoul(row[0], 0, 10), row[2]);
- user.setGid(std::strtoul(row[1], 0, 10));
+ user.setGid(strtoul(row[1], 0, 10));
user.setFullName(row[3]);
users.insert(std::make_pair(user.getUid(), user));
@@ -157,10 +160,43 @@ bool UserBackendMysql::userList(const sigc::slot<void, const std::map<unsigned l
}
bool UserBackendMysql::userInfo(unsigned long uid, const sigc::slot<void, const Common::UserInfo&> &callback) {
- return false;
+ mysql_ping(mysql);
+
+ std::string query = queryUserById;
+
+ std::ostringstream tmp;
+ tmp << '"';
+ tmp << uid;
+ tmp << '"';
+
+ pcrecpp::RE("\\{ID\\}").GlobalReplace(tmp.str(), &query);
+
+ mysql_real_query(mysql, query.c_str(), query.length());
+ MYSQL_RES *result = mysql_use_result(mysql);
+
+ if(mysql_num_fields(result) < 4)
+ return true; // TODO Error
+
+ MYSQL_ROW row = mysql_fetch_row(result);
+
+ if(row) {
+ Common::UserInfo user(strtoul(row[0], 0, 10), row[2]);
+
+ user.setGid(strtoul(row[1], 0, 10));
+ user.setFullName(row[3]);
+
+ Common::ActionManager::get()->add(sigc::bind(callback, user));
+
+ while((row = mysql_fetch_row(result)) != 0) {}
+ }
+ else {
+ Common::ActionManager::get()->add(sigc::bind(callback, Common::UserInfo()));
+ }
+
+ return true;
}
-bool UserBackendMysql::password(unsigned long uid, const std::string &password, const sigc::slot<void, bool> &callback) {
+bool UserBackendMysql::password(unsigned long uid _UNUSED_PARAMETER_, const std::string &password _UNUSED_PARAMETER_, const sigc::slot<void, bool> &callback _UNUSED_PARAMETER_) {
return false;
}