diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 154 | ||||
-rw-r--r-- | src/dalstorage.cpp | 74 | ||||
-rw-r--r-- | src/dalstorage.h | 2 | ||||
-rw-r--r-- | src/storage.h | 8 | ||||
-rw-r--r-- | src/utils/logger.h | 6 |
5 files changed, 126 insertions, 118 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index ad8c046e..a9dd5cde 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,97 +1,103 @@ # $Id$ +bin_PROGRAMS = tmwclient tmwserv -bin_PROGRAMS = tmwserv +tmwclient_SOURCES = client.cpp \ + defines.h \ + messageout.h \ + messageout.cpp \ + packet.h \ + packet.cpp tmwserv_SOURCES = main.cpp \ - configuration.h \ - configuration.cpp \ - accounthandler.h \ - accounthandler.cpp \ - chathandler.h \ - chathandler.cpp \ - connectionhandler.h \ - connectionhandler.cpp \ - gamehandler.h \ - gamehandler.cpp \ - state.h \ - state.cpp \ - debug.h \ - debug.cpp \ - defines.h \ - items.h \ - items.cpp \ - map.cpp \ - map.h \ - mapmanager.h \ - mapmanager.cpp \ - mapreader.cpp \ - mapreader.h \ - messagehandler.h \ - messagehandler.cpp \ - messagein.h \ - messagein.cpp \ - messageout.h \ - messageout.cpp \ - netcomputer.h \ - netcomputer.cpp \ - netsession.h \ - netsession.cpp \ - packet.h \ - packet.cpp \ - skill.h \ - skill.cpp \ - resourcemanager.cpp \ - resourcemanager.h \ - storage.h \ - storage.cpp \ - account.h \ - account.cpp \ - object.h \ - object.cpp \ - being.h \ - being.cpp \ - dalstorage.h \ - dalstorage.cpp \ - dal/dalexcept.h \ - dal/dataprovider.h \ - dal/dataprovider.cpp \ - dal/dataproviderfactory.h \ - dal/dataproviderfactory.cpp \ - dal/recordset.h \ - dal/recordset.cpp \ - utils/base64.h \ - utils/base64.cpp \ - utils/countedptr.h \ - utils/functors.h \ - utils/singleton.h \ - utils/cipher.h \ - utils/cipher.cpp \ - utils/logger.h \ - utils/logger.cpp \ - utils/slangsfilter.h \ - utils/slangsfilter.cpp + configuration.h \ + configuration.cpp \ + accounthandler.h \ + accounthandler.cpp \ + chathandler.h \ + chathandler.cpp \ + connectionhandler.h \ + connectionhandler.cpp \ + gamehandler.h \ + gamehandler.cpp \ + state.h \ + state.cpp \ + debug.h \ + debug.cpp \ + defines.h \ + items.h \ + items.cpp \ + map.cpp \ + map.h \ + mapmanager.h \ + mapmanager.cpp \ + mapreader.cpp \ + mapreader.h \ + messagehandler.h \ + messagehandler.cpp \ + messagein.h \ + messagein.cpp \ + messageout.h \ + messageout.cpp \ + netcomputer.h \ + netcomputer.cpp \ + netsession.h \ + netsession.cpp \ + packet.h \ + packet.cpp \ + skill.h \ + skill.cpp \ + resourcemanager.cpp \ + resourcemanager.h \ + storage.h \ + storage.cpp \ + account.h \ + account.cpp \ + object.h \ + object.cpp \ + being.h \ + being.cpp \ + dalstorage.h \ + dalstorage.cpp \ + dal/dalexcept.h \ + dal/dataprovider.h \ + dal/dataprovider.cpp \ + dal/dataproviderfactory.h \ + dal/dataproviderfactory.cpp \ + dal/recordset.h \ + dal/recordset.cpp \ + utils/base64.h \ + utils/base64.cpp \ + utils/countedptr.h \ + utils/functors.h \ + utils/singleton.h \ + utils/cipher.h \ + utils/cipher.cpp \ + utils/logger.h \ + utils/logger.cpp \ + utils/slangsfilter.h \ + utils/slangsfilter.cpp if BUILD_MYSQL tmwserv_SOURCES += dal/mysqldataprovider.h \ - dal/mysqldataprovider.cpp + dal/mysqldataprovider.cpp endif if BUILD_POSTGRESQL tmwserv_SOURCES += dal/pqdataprovider.h \ - dal/pqdataprovider.cpp + dal/pqdataprovider.cpp endif if BUILD_SQLITE tmwserv_SOURCES += dal/sqlitedataprovider.h \ - dal/sqlitedataprovider.cpp + dal/sqlitedataprovider.cpp endif if BUILD_SQUIRREL tmwserv_SOURCES += script.h \ - script.cpp \ - script-squirrel.h \ - script-squirrel.cpp + script.cpp \ + script-squirrel.h \ + script-squirrel.cpp endif if BUILD_RUBY diff --git a/src/dalstorage.cpp b/src/dalstorage.cpp index fc3a70d9..5723a040 100644 --- a/src/dalstorage.cpp +++ b/src/dalstorage.cpp @@ -20,7 +20,6 @@ * $Id$ */ - #include <sstream> #include <vector> @@ -66,7 +65,7 @@ DALStorage::~DALStorage() void DALStorage::open(void) { - // do nothing if already connected. + // Do nothing if already connected. if (mDb->isConnected()) { return; } @@ -379,6 +378,7 @@ DALStorage::getEmailList() open(); std::list <std::string> emailList; + try { std::string sql("select email from "); sql += ACCOUNTS_TBL_NAME; @@ -390,16 +390,16 @@ DALStorage::getEmailList() 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)); - } + 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) { + } + catch (const dal::DbSqlQueryExecFailure& e) { // TODO: throw an exception. - LOG_ERROR("SQL query failure: " << e.what(), 0) - } + LOG_ERROR("SQL query failure: " << e.what(), 0); + } return emailList; } @@ -408,41 +408,39 @@ DALStorage::getEmailList() * Tells if Email already exists. */ bool -DALStorage::doesEmailAlreadyExists(std::string email) +DALStorage::doesEmailAlreadyExists(const std::string &email) { // If not opened already open(); try { - std::string sql("select count(email) from "); - sql += ACCOUNTS_TBL_NAME; - sql += " where upper(email) = upper('"; - sql += email; - sql += "');"; - const dal::RecordSet& accountInfo = mDb->execSql(sql); - - // if the account is empty then - // we have no choice but to return false. - if (accountInfo.isEmpty()) { - return false; - } - - std::stringstream ssStream(accountInfo(0,0)); - int iReturn = -1; - ssStream >> iReturn; - if ( iReturn > 0 ) - { - return true; - } - else - { - return false; - } + std::string sql("select count(email) from "); + sql += ACCOUNTS_TBL_NAME; + sql += " where upper(email) = upper('" + email + "');"; + + const dal::RecordSet& accountInfo = mDb->execSql(sql); + + // If the account is empty then we have no choice but to return false. + if (accountInfo.isEmpty()) { + return false; } - catch (const dal::DbSqlQueryExecFailure& e) { - // TODO: throw an exception. - LOG_ERROR("SQL query failure: " << e.what(), 0) + + std::stringstream ssStream(accountInfo(0,0)); + int iReturn = -1; + ssStream >> iReturn; + if ( iReturn > 0 ) + { + return true; } + else + { + return false; + } + } + catch (const dal::DbSqlQueryExecFailure& e) { + // TODO: throw an exception. + LOG_ERROR("SQL query failure: " << e.what(), 0); + } return false; } diff --git a/src/dalstorage.h b/src/dalstorage.h index 6e3eb7fb..af109dc2 100644 --- a/src/dalstorage.h +++ b/src/dalstorage.h @@ -104,7 +104,7 @@ class DALStorage: public Storage * @return true if Email is already in database */ bool - doesEmailAlreadyExists(std::string email); + doesEmailAlreadyExists(const std::string &email); /** * Tells if the character's name already exists diff --git a/src/storage.h b/src/storage.h index 3ee59e70..6381fea7 100644 --- a/src/storage.h +++ b/src/storage.h @@ -283,6 +283,10 @@ class Storage /** * Get the list of Emails in the accounts list. * @return the list of Email's Addresses. + * + * @deprecated The only purpose of using this list inside the server is + * for checking for existing email addresses, which is + * covered by Storage::doesEmailAlreadyExists(). */ virtual std::list<std::string> getEmailList() = 0; @@ -291,8 +295,8 @@ class Storage * Return if an Email is already in account's table. * @return true if Email already exists. */ - virtual - bool doesEmailAlreadyExists(std::string email) = 0; + virtual bool + doesEmailAlreadyExists(const std::string &email) = 0; /** * Tells if the character's name already exists diff --git a/src/utils/logger.h b/src/utils/logger.h index f730600b..75c86593 100644 --- a/src/utils/logger.h +++ b/src/utils/logger.h @@ -53,8 +53,8 @@ namespace utils * * Example of use: * - * <code> - * #include "logger.h" + * <pre> + * \#include "logger.h" * * int main(void) * { @@ -85,7 +85,7 @@ namespace utils * * return 0; * } - * </code> + * </pre> */ class Logger: public Singleton<Logger> { |