diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2005-12-05 22:45:43 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2005-12-05 22:45:43 +0000 |
commit | e33d204e20f8659999b85d6d0e66e4dc43555a56 (patch) | |
tree | bafd315cd6f13b47c31333ff0bfe771965e95103 /src/dalstorage.cpp | |
parent | 48f42f1c4330cc719a8e1658a20505073a4f6386 (diff) | |
download | manaserv-e33d204e20f8659999b85d6d0e66e4dc43555a56.tar.gz manaserv-e33d204e20f8659999b85d6d0e66e4dc43555a56.tar.bz2 manaserv-e33d204e20f8659999b85d6d0e66e4dc43555a56.tar.xz manaserv-e33d204e20f8659999b85d6d0e66e4dc43555a56.zip |
Made the getEmailList() work. Now the accounthandler tests if the mail already exists.
Diffstat (limited to 'src/dalstorage.cpp')
-rw-r--r-- | src/dalstorage.cpp | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/dalstorage.cpp b/src/dalstorage.cpp index 447e3a88..c62b0dc4 100644 --- a/src/dalstorage.cpp +++ b/src/dalstorage.cpp @@ -29,7 +29,6 @@ #include "utils/logger.h" #include "dalstorage.h" -#include "dalstoragesql.h" namespace tmwserv { @@ -346,15 +345,32 @@ DALStorage::delAccount(const std::string& userName) std::list<std::string> DALStorage::getEmailList() { + // If not opened already + open(); + std::list <std::string> emailList; - Accounts::iterator it = mAccounts.begin(); - Accounts::iterator it_end = mAccounts.end(); - for (; it != it_end; ) - { - emailList.push_front( ((it->first).get())->getEmail() ); - std::cout << ((it->first).get())->getEmail() << std::endl; - ++it; - } + try { + std::string sql("select email from "); + sql += ACCOUNTS_TBL_NAME; + sql += ";"; + const dal::RecordSet& accountInfo = mDb->execSql(sql); + + // if the account is not even in the database then + // we have no choice but to return nothing. + if (accountInfo.isEmpty()) { + return emailList; + } + for (unsigned int i = 0; i < accountInfo.rows(); i++) + { + // We add all these addresses to the list + emailList.push_front(accountInfo(i, 0)); + } + } + catch (const dal::DbSqlQueryExecFailure& e) { + // TODO: throw an exception. + LOG_ERROR("SQL query failure: " << e.what()) + } + return emailList; } |