summaryrefslogtreecommitdiff
path: root/src/dalstorage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dalstorage.cpp')
-rw-r--r--src/dalstorage.cpp34
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;
}