From 59a5414ec47a2932a7802fcd1d98c4d80166564f Mon Sep 17 00:00:00 2001 From: SomeDude Date: Sat, 17 Jan 2009 09:40:00 +0100 Subject: [PATCH] version 0.3.29 --- CMakeLists.txt | 6 + include/board.h | 8 +- include/boardlist.h | 1 + include/db/sqlite3db/sqlite3db.h | 6 +- include/db/sqlite3db/sqlite3statement.h | 3 + include/dbconversions.h | 31 ++-- include/dbmaintenancethread.h | 4 +- include/dbsetup.h | 8 +- include/fmsapp.h | 3 +- include/freenet/boardlistinserter.h | 4 +- include/freenet/boardlistrequester.h | 4 +- include/freenet/fcpv2.h | 10 +- include/freenet/fileinserter.h | 4 +- include/freenet/fmsversionrequester.h | 4 +- include/freenet/freenetmasterthread.h | 3 +- include/freenet/identityinserter.h | 4 +- include/freenet/identityintroductioninserter.h | 4 +- include/freenet/identityintroductionrequester.h | 4 +- include/freenet/identityrequester.h | 4 +- include/freenet/iindexinserter.h | 11 +- include/freenet/iindexrequester.h | 11 +- include/freenet/inactivemessagelistrequester.h | 4 +- include/freenet/introductionpuzzleinserter.h | 4 +- include/freenet/introductionpuzzlerequester.h | 4 +- include/freenet/messageinserter.h | 4 +- include/freenet/messagelistinserter.h | 4 +- include/freenet/messagelistrequester.h | 4 +- include/freenet/messagerequester.h | 4 +- include/freenet/siteinserter.h | 4 +- include/freenet/trustlistinserter.h | 4 +- include/freenet/trustlistrequester.h | 4 +- include/freenet/unkeyedidcreator.h | 4 +- include/freenet/unknownidentityrequester.h | 4 +- include/global.h | 6 +- include/http/fmshttprequesthandlerfactory.h | 5 +- include/http/httpthread.h | 4 +- include/http/ipagehandler.h | 7 +- include/http/pages/addpeerpage.h | 7 +- include/http/pages/announceidentitypage.h | 7 +- include/http/pages/boardspage.h | 7 +- include/http/pages/confirmpage.h | 4 +- include/http/pages/controlboardpage.h | 7 +- include/http/pages/createidentitypage.h | 7 +- include/http/pages/execquerypage.h | 7 +- include/http/pages/forumcreatepostpage.h | 4 +- include/http/pages/forummainpage.h | 4 +- include/http/pages/forumpage.h | 5 +- include/http/pages/forumthreadspage.h | 4 +- include/http/pages/forumviewthreadpage.h | 4 +- include/http/pages/homepage.h | 7 +- include/http/pages/insertedfilespage.h | 7 +- include/http/pages/localidentitiespage.h | 7 +- include/http/pages/optionspage.h | 16 +- include/http/pages/peerdetailspage.h | 7 +- include/http/pages/peermaintenancepage.h | 7 +- include/http/pages/peertrustpage.h | 7 +- include/http/pages/recentlyaddedpage.h | 7 +- include/http/pages/showcaptchapage.h | 5 +- include/http/pages/showimagepage.h | 3 +- include/http/pages/showpendingmessagepage.h | 17 ++ include/http/pages/versioninfopage.h | 7 +- include/idatabase.h | 4 +- include/ithreaddatabase.h | 50 ++++++ include/localidentity.h | 2 +- include/message.h | 6 +- include/messagelist.h | 1 + include/messagethread.h | 2 + include/nntp/extensiontrust.h | 4 +- include/nntp/nntpconnection.h | 5 +- include/nntp/nntplistener.h | 6 +- include/option.h | 11 +- include/optionssetup.h | 4 +- include/threadbuilder.h | 1 + readme.txt | 6 + src/board.cpp | 8 +- src/boardlist.cpp | 4 +- src/db/sqlite3db.cpp | 37 +++- src/db/sqlite3recordset.cpp | 1 - src/db/sqlite3statement.cpp | 25 ++- src/dbconversions.cpp | 53 +++--- src/dbmaintenancethread.cpp | 48 +++-- src/dbsetup.cpp | 105 +++++------ src/fmsapp.cpp | 51 ++++-- src/freenet/boardlistinserter.cpp | 4 +- src/freenet/boardlistrequester.cpp | 11 +- src/freenet/fcpv2.cpp | 2 + src/freenet/fileinserter.cpp | 4 +- src/freenet/fmsversionrequester.cpp | 15 +- src/freenet/freenetmasterthread.cpp | 87 ++++----- src/freenet/identityinserter.cpp | 7 +- src/freenet/identityintroductioninserter.cpp | 7 +- src/freenet/identityintroductionrequester.cpp | 9 +- src/freenet/identityrequester.cpp | 7 +- src/freenet/inactivemessagelistrequester.cpp | 13 +- src/freenet/introductionpuzzleinserter.cpp | 7 +- src/freenet/introductionpuzzlerequester.cpp | 7 +- src/freenet/messageinserter.cpp | 4 +- src/freenet/messagelistinserter.cpp | 11 +- src/freenet/messagelistrequester.cpp | 21 ++- src/freenet/messagerequester.cpp | 25 +-- src/freenet/siteinserter.cpp | 5 +- src/freenet/trustlistinserter.cpp | 7 +- src/freenet/trustlistrequester.cpp | 13 +- src/freenet/unkeyedidcreator.cpp | 4 +- src/freenet/unknownidentityrequester.cpp | 8 +- src/http/fmshttprequesthandlerfactory.cpp | 56 +++--- src/http/httpthread.cpp | 12 +- src/http/ipagehandler.cpp | 7 +- src/http/pages/forumcreatepostpage.cpp | 2 +- src/http/pages/homepage.cpp | 14 +- src/http/pages/insertedfilespage.cpp | 6 +- src/http/pages/optionspage.cpp | 135 ++++++++++++-- src/http/pages/peerdetailspage.cpp | 8 +- src/http/pages/showimagepage.cpp | 2 + src/http/pages/showpendingmessagepage.cpp | 78 ++++++++ src/localidentity.cpp | 2 +- src/message.cpp | 14 +- src/messagelist.cpp | 2 +- src/nntp/extensiontrust.cpp | 4 +- src/nntp/mime/Mime.cpp | 1 + src/nntp/nntpconnection.cpp | 58 +++--- src/nntp/nntplistener.cpp | 15 +- src/nntp/uwildmat.cpp | 3 + src/option.cpp | 2 +- src/optionssetup.cpp | 225 ++++++++++++++++++++---- src/threadbuilder.cpp | 56 +----- src/unicode/unicodeformatter.cpp | 27 +-- template.htm | 15 +- 128 files changed, 1164 insertions(+), 663 deletions(-) create mode 100644 include/http/pages/showpendingmessagepage.h create mode 100644 include/ithreaddatabase.h create mode 100644 src/http/pages/showpendingmessagepage.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 6412e14..e874c91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ ENDIF(APPLE) OPTION(DO_CHARSET_CONVERSION "Do charset conversion on sent messages to UTF-8. This requires libiconv." ON) OPTION(I_HAVE_READ_THE_README "I have fully read and understood the readme.txt." OFF) OPTION(ALTERNATE_CAPTCHA "Use alternate captcha. This requires the FreeImage library." OFF) +OPTION(QUERY_LOG "Log all database queries made by FMS." OFF) SET(FMS_SRC src/base64.cpp @@ -99,6 +100,7 @@ src/http/pages/peertrustpage.cpp src/http/pages/recentlyaddedpage.cpp src/http/pages/showcaptchapage.cpp src/http/pages/showimagepage.cpp +src/http/pages/showpendingmessagepage.cpp src/http/pages/versioninfopage.cpp src/nntp/extensiontrust.cpp src/nntp/nntpconnection.cpp @@ -274,3 +276,7 @@ ENDIF(ALTERNATE_CAPTCHA) IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") INCLUDE_DIRECTORIES(AFTER /usr/local/include) ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + +IF(QUERY_LOG) + ADD_DEFINITIONS(-DQUERY_LOG) +ENDIF(QUERY_LOG) diff --git a/include/board.h b/include/board.h index f70e4f8..bf9eb09 100644 --- a/include/board.h +++ b/include/board.h @@ -10,10 +10,10 @@ class Board:public ILogger,public IDatabase { public: - Board(); - Board(const long boardid); - Board(const std::string &boardname); - Board(const long boardid, const std::string &boardname, const std::string &boarddescription, const std::string datecreated, const long lowmessageid, const long highmessageid, const long messagecount, const bool savereceivedmessages, const std::string &addedmethod); + Board(SQLite3DB::DB *db); + Board(SQLite3DB::DB *db, const long boardid); + Board(SQLite3DB::DB *db, const std::string &boardname); + Board(SQLite3DB::DB *db, const long boardid, const std::string &boardname, const std::string &boarddescription, const std::string datecreated, const long lowmessageid, const long highmessageid, const long messagecount, const bool savereceivedmessages, const std::string &addedmethod); const bool Load(const long boardid); const bool Load(const std::string &boardname); diff --git a/include/boardlist.h b/include/boardlist.h index a5c9508..697ecb6 100644 --- a/include/boardlist.h +++ b/include/boardlist.h @@ -13,6 +13,7 @@ class BoardList:public std::vector,public ILogger,public IDatabase { public: + BoardList(SQLite3DB::DB *db):IDatabase(db) {} /** \brief Loads all known boards diff --git a/include/db/sqlite3db/sqlite3db.h b/include/db/sqlite3db/sqlite3db.h index f60961b..59fb89d 100644 --- a/include/db/sqlite3db/sqlite3db.h +++ b/include/db/sqlite3db/sqlite3db.h @@ -1,11 +1,9 @@ #ifndef _sqlite3db_ #define _sqlite3db_ -#include #include #include #include "../sqlite3db.h" -#include "../../threadwrapper/singleton.h" #if SQLITE_VERSION_NUMBER<3006006 #error "Your version of SQLite is too old! 3.6.6.2 or later is required." @@ -14,7 +12,7 @@ namespace SQLite3DB { -class DB:public Singleton +class DB { public: DB(); @@ -38,8 +36,6 @@ public: sqlite3 *GetDB() { return m_db; } - Poco::FastMutex m_mutex; // public so that recordset and statment can lock this mutex themselves - private: void Initialize(); diff --git a/include/db/sqlite3db/sqlite3statement.h b/include/db/sqlite3db/sqlite3statement.h index d245d49..e57fbe5 100644 --- a/include/db/sqlite3db/sqlite3statement.h +++ b/include/db/sqlite3db/sqlite3statement.h @@ -3,6 +3,8 @@ #include "sqlite3db.h" +#include + #include #include @@ -57,6 +59,7 @@ private: long m_lastinsertrowid; static std::map m_statementcount; + static Poco::FastMutex m_mutex; // protect all access to m_statementcount }; //class diff --git a/include/dbconversions.h b/include/dbconversions.h index 4db308c..597e171 100644 --- a/include/dbconversions.h +++ b/include/dbconversions.h @@ -1,21 +1,24 @@ #ifndef _dbconversions_ #define _dbconversions_ -void ConvertDB0100To0101(); -void ConvertDB0101To0103(); -void ConvertDB0103To0104(); -void ConvertDB0104To0105(); -void ConvertDB0105To0106(); -void ConvertDB0106To0107(); -void ConvertDB0107To0108(); -void ConvertDB0108To0109(); -void ConvertDB0109To0110(); -void ConvertDB0110To0111(); -void ConvertDB0111To0112(); -void ConvertDB0112To0113(); -void ConvertDB0113To0114(); +#include "db/sqlite3db.h" + +void ConvertDB0100To0101(SQLite3DB::DB *db); +void ConvertDB0101To0103(SQLite3DB::DB *db); +void ConvertDB0103To0104(SQLite3DB::DB *db); +void ConvertDB0104To0105(SQLite3DB::DB *db); +void ConvertDB0105To0106(SQLite3DB::DB *db); +void ConvertDB0106To0107(SQLite3DB::DB *db); +void ConvertDB0107To0108(SQLite3DB::DB *db); +void ConvertDB0108To0109(SQLite3DB::DB *db); +void ConvertDB0109To0110(SQLite3DB::DB *db); +void ConvertDB0110To0111(SQLite3DB::DB *db); +void ConvertDB0111To0112(SQLite3DB::DB *db); +void ConvertDB0112To0113(SQLite3DB::DB *db); +void ConvertDB0113To0114(SQLite3DB::DB *db); +void ConvertDB0114To0115(SQLite3DB::DB *db); // TODO remove sometime after 0.1.17 -void FixCapitalBoardNames(); +void FixCapitalBoardNames(SQLite3DB::DB *db); #endif // _dbconversions_ diff --git a/include/dbmaintenancethread.h b/include/dbmaintenancethread.h index 74a7fd8..e7c3dd6 100644 --- a/include/dbmaintenancethread.h +++ b/include/dbmaintenancethread.h @@ -3,11 +3,11 @@ #include "threadwrapper/cancelablerunnable.h" #include "ilogger.h" -#include "idatabase.h" +#include "ithreaddatabase.h" #include -class DBMaintenanceThread:public CancelableRunnable,public ILogger,public IDatabase +class DBMaintenanceThread:public CancelableRunnable,public ILogger,public IThreadDatabase { public: DBMaintenanceThread(); diff --git a/include/dbsetup.h b/include/dbsetup.h index 84ae815..4b61a50 100644 --- a/include/dbsetup.h +++ b/include/dbsetup.h @@ -3,12 +3,14 @@ #include +#include "db/sqlite3db.h" + // opens database and creates tables and initial inserts if necessary -void SetupDB(); +void SetupDB(SQLite3DB::DB *db); // verifies DB isn't corrupt -const bool VerifyDB(); +const bool VerifyDB(SQLite3DB::DB *db); // returns result of PRAGMA integrity_check -const std::string TestDBIntegrity(); +const std::string TestDBIntegrity(SQLite3DB::DB *db); #endif // _dbsetup_ diff --git a/include/fmsapp.h b/include/fmsapp.h index 56b6125..810325d 100644 --- a/include/fmsapp.h +++ b/include/fmsapp.h @@ -2,13 +2,14 @@ #define _fmsapp_ #include "threadwrapper/threadedexecutor.h" +#include "ithreaddatabase.h" #include #include // main FMS application class -class FMSApp:public Poco::Util::ServerApplication +class FMSApp:public Poco::Util::ServerApplication,public IThreadDatabase { public: FMSApp(); diff --git a/include/freenet/boardlistinserter.h b/include/freenet/boardlistinserter.h index f0883a1..f66f4b4 100644 --- a/include/freenet/boardlistinserter.h +++ b/include/freenet/boardlistinserter.h @@ -6,8 +6,8 @@ class BoardListInserter:public IIndexInserter { public: - BoardListInserter(); - BoardListInserter(FCPv2::Connection *fcp); + BoardListInserter(SQLite3DB::DB *db); + BoardListInserter(SQLite3DB::DB *db, FCPv2::Connection *fcp); private: void Initialize(); diff --git a/include/freenet/boardlistrequester.h b/include/freenet/boardlistrequester.h index 3eb7823..c0a124f 100644 --- a/include/freenet/boardlistrequester.h +++ b/include/freenet/boardlistrequester.h @@ -6,8 +6,8 @@ class BoardListRequester:public IIndexRequester { public: - BoardListRequester(); - BoardListRequester(FCPv2::Connection *fcp); + BoardListRequester(SQLite3DB::DB *db); + BoardListRequester(SQLite3DB::DB *db, FCPv2::Connection *fcp); private: void Initialize(); diff --git a/include/freenet/fcpv2.h b/include/freenet/fcpv2.h index 1f033a9..f83d73a 100644 --- a/include/freenet/fcpv2.h +++ b/include/freenet/fcpv2.h @@ -115,6 +115,8 @@ public: \brief Gets the string representing this message in FCP This string is what is actually sent/received from the node through FCP + + \return The FCP message string */ const std::string GetFCPString() const; @@ -138,13 +140,13 @@ public: /** \brief Construct connection with an existing socket - \param sock An existing socket connection to a Freenet node + \param sock An existing open socket connection to a Freenet node */ Connection(const int sock); /** - \brief Default constructor + \brief Default destructor - The deconstructor will close the connection if it is open + The destructor will close the connection if it is open */ ~Connection(); @@ -265,7 +267,7 @@ public: \brief Waits until the receive buffer contains a specified number of bytes This will continuously call Update until either the specific number of bytes have been received, - or the connection becomes disconnected + or the connection becomes disconnected. \param ms The number of milliseconds for each call to Update \param len The number of bytes to wait for diff --git a/include/freenet/fileinserter.h b/include/freenet/fileinserter.h index 6ac76bd..cb5da95 100644 --- a/include/freenet/fileinserter.h +++ b/include/freenet/fileinserter.h @@ -6,8 +6,8 @@ class FileInserter:public IIndexInserter { public: - FileInserter(); - FileInserter(FCPv2::Connection *fcp); + FileInserter(SQLite3DB::DB *db); + FileInserter(SQLite3DB::DB *db, FCPv2::Connection *fcp); private: void Initialize(); diff --git a/include/freenet/fmsversionrequester.h b/include/freenet/fmsversionrequester.h index afe18ca..e784d03 100644 --- a/include/freenet/fmsversionrequester.h +++ b/include/freenet/fmsversionrequester.h @@ -13,8 +13,8 @@ class FMSVersionRequester:public IFreenetRegistrable,public IFCPConnected,public IFCPMessageHandler,public IPeriodicProcessor,public IDatabase,public ILogger { public: - FMSVersionRequester(); - FMSVersionRequester(FCPv2::Connection *fcp); + FMSVersionRequester(SQLite3DB::DB *db); + FMSVersionRequester(SQLite3DB::DB *db, FCPv2::Connection *fcp); void FCPConnected() {} void FCPDisconnected() {} diff --git a/include/freenet/freenetmasterthread.h b/include/freenet/freenetmasterthread.h index 3e9cae5..f7f176c 100644 --- a/include/freenet/freenetmasterthread.h +++ b/include/freenet/freenetmasterthread.h @@ -2,6 +2,7 @@ #define _freenetmasterthread_ #include "../ilogger.h" +#include "../ithreaddatabase.h" #include "ifreenetregistrable.h" #include "ifcpmessagehandler.h" #include "ifcpconnected.h" @@ -12,7 +13,7 @@ // forward declaration class IFreenetRegistrable; -class FreenetMasterThread:public CancelableRunnable,public ILogger, public IFCPMessageHandler +class FreenetMasterThread:public CancelableRunnable,public ILogger, public IFCPMessageHandler, public IThreadDatabase { public: FreenetMasterThread(); diff --git a/include/freenet/identityinserter.h b/include/freenet/identityinserter.h index 1170e99..d3bfb4f 100644 --- a/include/freenet/identityinserter.h +++ b/include/freenet/identityinserter.h @@ -13,8 +13,8 @@ class IdentityInserter:public IFreenetRegistrable,public IFCPConnected,public IFCPMessageHandler,public IPeriodicProcessor,public IDatabase,public ILogger { public: - IdentityInserter(); - IdentityInserter(FCPv2::Connection *fcp); + IdentityInserter(SQLite3DB::DB *db); + IdentityInserter(SQLite3DB::DB *db, FCPv2::Connection *fcp); void FCPConnected(); void FCPDisconnected(); diff --git a/include/freenet/identityintroductioninserter.h b/include/freenet/identityintroductioninserter.h index 77f2bba..1cd4265 100644 --- a/include/freenet/identityintroductioninserter.h +++ b/include/freenet/identityintroductioninserter.h @@ -13,8 +13,8 @@ class IdentityIntroductionInserter:public IFreenetRegistrable,public IFCPConnected,public IFCPMessageHandler,public IPeriodicProcessor,public IDatabase,public ILogger { public: - IdentityIntroductionInserter(); - IdentityIntroductionInserter(FCPv2::Connection *fcp); + IdentityIntroductionInserter(SQLite3DB::DB *db); + IdentityIntroductionInserter(SQLite3DB::DB *db, FCPv2::Connection *fcp); void FCPConnected(); void FCPDisconnected(); diff --git a/include/freenet/identityintroductionrequester.h b/include/freenet/identityintroductionrequester.h index cd66727..2f419ea 100644 --- a/include/freenet/identityintroductionrequester.h +++ b/include/freenet/identityintroductionrequester.h @@ -13,8 +13,8 @@ class IdentityIntroductionRequester:public IFreenetRegistrable,public IFCPConnected,public IFCPMessageHandler,public IPeriodicProcessor,public IDatabase,public ILogger { public: - IdentityIntroductionRequester(); - IdentityIntroductionRequester(FCPv2::Connection *fcp); + IdentityIntroductionRequester(SQLite3DB::DB *db); + IdentityIntroductionRequester(SQLite3DB::DB *db, FCPv2::Connection *fcp); void FCPDisconnected(); void FCPConnected(); diff --git a/include/freenet/identityrequester.h b/include/freenet/identityrequester.h index 0b70abd..601bdc9 100644 --- a/include/freenet/identityrequester.h +++ b/include/freenet/identityrequester.h @@ -6,8 +6,8 @@ class IdentityRequester:public IIndexRequester { public: - IdentityRequester(); - IdentityRequester(FCPv2::Connection *fcp); + IdentityRequester(SQLite3DB::DB *db); + IdentityRequester(SQLite3DB::DB *db, FCPv2::Connection *fcp); private: virtual void Initialize(); diff --git a/include/freenet/iindexinserter.h b/include/freenet/iindexinserter.h index fb65b0e..2135e45 100644 --- a/include/freenet/iindexinserter.h +++ b/include/freenet/iindexinserter.h @@ -22,8 +22,8 @@ template class IIndexInserter:public IFreenetRegistrable,public IFCPConnected,public IFCPMessageHandler,public IPeriodicProcessor,public IDatabase,public ILogger { public: - IIndexInserter(); - IIndexInserter(FCPv2::Connection *fcp); + IIndexInserter(SQLite3DB::DB *db); + IIndexInserter(SQLite3DB::DB *db, FCPv2::Connection *fcp); virtual ~IIndexInserter() {} virtual void FCPConnected(); @@ -52,13 +52,13 @@ protected: }; template -IIndexInserter::IIndexInserter() +IIndexInserter::IIndexInserter(SQLite3DB::DB *db):IDatabase(db) { InitializeIIndexInserter(); } template -IIndexInserter::IIndexInserter(FCPv2::Connection *fcp):IFCPConnected(fcp) +IIndexInserter::IIndexInserter(SQLite3DB::DB *db, FCPv2::Connection *fcp):IDatabase(db),IFCPConnected(fcp) { InitializeIIndexInserter(); } @@ -127,8 +127,9 @@ const bool IIndexInserter::HandleMessage(FCPv2::Message &message) template void IIndexInserter::InitializeIIndexInserter() { + Option option(m_db); m_fcpuniquename=""; - Option::Instance()->Get("MessageBase",m_messagebase); + option.Get("MessageBase",m_messagebase); m_lastchecked=Poco::Timestamp(); } diff --git a/include/freenet/iindexrequester.h b/include/freenet/iindexrequester.h index 37dcdda..1966407 100644 --- a/include/freenet/iindexrequester.h +++ b/include/freenet/iindexrequester.h @@ -24,8 +24,8 @@ template class IIndexRequester:public IFreenetRegistrable,public IFCPConnected,public IFCPMessageHandler,public IPeriodicProcessor,public IDatabase,public ILogger { public: - IIndexRequester(); - IIndexRequester(FCPv2::Connection *fcp); + IIndexRequester(SQLite3DB::DB *db); + IIndexRequester(SQLite3DB::DB *db, FCPv2::Connection *fcp); virtual ~IIndexRequester() {} virtual void FCPConnected(); @@ -59,13 +59,13 @@ protected: }; template -IIndexRequester::IIndexRequester() +IIndexRequester::IIndexRequester(SQLite3DB::DB *db):IDatabase(db) { InitializeIIndexRequester(); } template -IIndexRequester::IIndexRequester(FCPv2::Connection *fcp):IFCPConnected(fcp) +IIndexRequester::IIndexRequester(SQLite3DB::DB *db, FCPv2::Connection *fcp):IDatabase(db),IFCPConnected(fcp) { InitializeIIndexRequester(); } @@ -143,8 +143,9 @@ void IIndexRequester::InitializeIIndexRequester() { m_maxrequests=-1; m_fcpuniquename=""; + Option option(m_db); - Option::Instance()->Get("MessageBase",m_messagebase); + option.Get("MessageBase",m_messagebase); m_tempdate=Poco::Timestamp(); m_lastreceived=Poco::Timestamp(); m_lastpopulated=Poco::Timestamp(); diff --git a/include/freenet/inactivemessagelistrequester.h b/include/freenet/inactivemessagelistrequester.h index f7787a9..95ab173 100644 --- a/include/freenet/inactivemessagelistrequester.h +++ b/include/freenet/inactivemessagelistrequester.h @@ -8,8 +8,8 @@ class InactiveMessageListRequester:public MessageListRequester { public: - InactiveMessageListRequester(); - InactiveMessageListRequester(FCPv2::Connection *fcp); + InactiveMessageListRequester(SQLite3DB::DB *db); + InactiveMessageListRequester(SQLite3DB::DB *db, FCPv2::Connection *fcp); private: virtual void Initialize(); diff --git a/include/freenet/introductionpuzzleinserter.h b/include/freenet/introductionpuzzleinserter.h index a65d96d..e376dbf 100644 --- a/include/freenet/introductionpuzzleinserter.h +++ b/include/freenet/introductionpuzzleinserter.h @@ -9,8 +9,8 @@ class IntroductionPuzzleInserter:public IIndexInserter { public: - IntroductionPuzzleInserter(); - IntroductionPuzzleInserter(FCPv2::Connection *fcp); + IntroductionPuzzleInserter(SQLite3DB::DB *db); + IntroductionPuzzleInserter(SQLite3DB::DB *db, FCPv2::Connection *fcp); private: void Initialize(); diff --git a/include/freenet/introductionpuzzlerequester.h b/include/freenet/introductionpuzzlerequester.h index e2ca076..46108df 100644 --- a/include/freenet/introductionpuzzlerequester.h +++ b/include/freenet/introductionpuzzlerequester.h @@ -8,8 +8,8 @@ class IntroductionPuzzleRequester:public IIndexRequester { public: - IntroductionPuzzleRequester(); - IntroductionPuzzleRequester(FCPv2::Connection *fcp); + IntroductionPuzzleRequester(SQLite3DB::DB *db); + IntroductionPuzzleRequester(SQLite3DB::DB *db, FCPv2::Connection *fcp); private: void Initialize(); diff --git a/include/freenet/messageinserter.h b/include/freenet/messageinserter.h index 04d6169..0b8e970 100644 --- a/include/freenet/messageinserter.h +++ b/include/freenet/messageinserter.h @@ -7,8 +7,8 @@ class MessageInserter:public IIndexInserter { public: - MessageInserter(); - MessageInserter(FCPv2::Connection *fcp); + MessageInserter(SQLite3DB::DB *db); + MessageInserter(SQLite3DB::DB *db, FCPv2::Connection *fcp); private: void Initialize(); diff --git a/include/freenet/messagelistinserter.h b/include/freenet/messagelistinserter.h index 4afed68..c13383a 100644 --- a/include/freenet/messagelistinserter.h +++ b/include/freenet/messagelistinserter.h @@ -6,8 +6,8 @@ class MessageListInserter:public IIndexInserter { public: - MessageListInserter(); - MessageListInserter(FCPv2::Connection *fcp); + MessageListInserter(SQLite3DB::DB *db); + MessageListInserter(SQLite3DB::DB *db, FCPv2::Connection *fcp); private: void Initialize(); diff --git a/include/freenet/messagelistrequester.h b/include/freenet/messagelistrequester.h index 1b324e2..079fbe7 100644 --- a/include/freenet/messagelistrequester.h +++ b/include/freenet/messagelistrequester.h @@ -8,8 +8,8 @@ class MessageListRequester:public IIndexRequester { public: - MessageListRequester(); - MessageListRequester(FCPv2::Connection *fcp); + MessageListRequester(SQLite3DB::DB *db); + MessageListRequester(SQLite3DB::DB *db, FCPv2::Connection *fcp); private: virtual void Initialize(); diff --git a/include/freenet/messagerequester.h b/include/freenet/messagerequester.h index 76feb71..b9c6c96 100644 --- a/include/freenet/messagerequester.h +++ b/include/freenet/messagerequester.h @@ -6,8 +6,8 @@ class MessageRequester:public IIndexRequester { public: - MessageRequester(); - MessageRequester(FCPv2::Connection *fcp); + MessageRequester(SQLite3DB::DB *db); + MessageRequester(SQLite3DB::DB *db, FCPv2::Connection *fcp); private: void Initialize(); diff --git a/include/freenet/siteinserter.h b/include/freenet/siteinserter.h index 5c17e79..2fe4af4 100644 --- a/include/freenet/siteinserter.h +++ b/include/freenet/siteinserter.h @@ -6,8 +6,8 @@ class SiteInserter:public IIndexInserter { public: - SiteInserter(); - SiteInserter(FCPv2::Connection *fcp); + SiteInserter(SQLite3DB::DB *db); + SiteInserter(SQLite3DB::DB *db, FCPv2::Connection *fcp); private: void Initialize(); diff --git a/include/freenet/trustlistinserter.h b/include/freenet/trustlistinserter.h index 26cdd52..5cfe1c1 100644 --- a/include/freenet/trustlistinserter.h +++ b/include/freenet/trustlistinserter.h @@ -13,8 +13,8 @@ class TrustListInserter:public IFreenetRegistrable,public IFCPConnected,public IFCPMessageHandler,public IPeriodicProcessor,public IDatabase,public ILogger { public: - TrustListInserter(); - TrustListInserter(FCPv2::Connection *fcp); + TrustListInserter(SQLite3DB::DB *db); + TrustListInserter(SQLite3DB::DB *db, FCPv2::Connection *fcp); void FCPConnected(); void FCPDisconnected(); diff --git a/include/freenet/trustlistrequester.h b/include/freenet/trustlistrequester.h index 0bbf69f..3ae1c2e 100644 --- a/include/freenet/trustlistrequester.h +++ b/include/freenet/trustlistrequester.h @@ -6,8 +6,8 @@ class TrustListRequester:public IIndexRequester//public IFreenetRegistrable,public IFCPConnected,public IFCPMessageHandler,public IPeriodicProcessor,public IDatabase,public ILogger { public: - TrustListRequester(); - TrustListRequester(FCPv2::Connection *fcp); + TrustListRequester(SQLite3DB::DB *db); + TrustListRequester(SQLite3DB::DB *db, FCPv2::Connection *fcp); private: void Initialize(); diff --git a/include/freenet/unkeyedidcreator.h b/include/freenet/unkeyedidcreator.h index 054a95d..1cdd7b9 100644 --- a/include/freenet/unkeyedidcreator.h +++ b/include/freenet/unkeyedidcreator.h @@ -17,8 +17,8 @@ class UnkeyedIDCreator:public IFreenetRegistrable,public IFCPConnected,public IFCPMessageHandler,public IDatabase,public IPeriodicProcessor,public ILogger { public: - UnkeyedIDCreator(); - UnkeyedIDCreator(FCPv2::Connection *fcp); + UnkeyedIDCreator(SQLite3DB::DB *db); + UnkeyedIDCreator(SQLite3DB::DB *db, FCPv2::Connection *fcp); const bool HandleMessage(FCPv2::Message &message); diff --git a/include/freenet/unknownidentityrequester.h b/include/freenet/unknownidentityrequester.h index 67c8372..d0357fd 100644 --- a/include/freenet/unknownidentityrequester.h +++ b/include/freenet/unknownidentityrequester.h @@ -6,8 +6,8 @@ class UnknownIdentityRequester:public IdentityRequester { public: - UnknownIdentityRequester(); - UnknownIdentityRequester(FCPv2::Connection *fcp); + UnknownIdentityRequester(SQLite3DB::DB *db); + UnknownIdentityRequester(SQLite3DB::DB *db, FCPv2::Connection *fcp); private: void Initialize(); diff --git a/include/global.h b/include/global.h index eb0deae..4fc4ad5 100644 --- a/include/global.h +++ b/include/global.h @@ -7,10 +7,10 @@ #define VERSION_MAJOR "0" #define VERSION_MINOR "3" -#define VERSION_RELEASE "28" +#define VERSION_RELEASE "29" #define FMS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_RELEASE -#define FMS_FREESITE_USK "USK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/90/" -#define FMS_VERSION_EDITION "30" +#define FMS_FREESITE_USK "USK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/91/" +#define FMS_VERSION_EDITION "31" typedef Poco::ScopedLock Guard; diff --git a/include/http/fmshttprequesthandlerfactory.h b/include/http/fmshttprequesthandlerfactory.h index 3e42513..b6c163d 100644 --- a/include/http/fmshttprequesthandlerfactory.h +++ b/include/http/fmshttprequesthandlerfactory.h @@ -4,14 +4,15 @@ #include "ipagehandler.h" #include "../ipaddressacl.h" #include "../ilogger.h" +#include "../idatabase.h" #include #include -class FMSHTTPRequestHandlerFactory:public Poco::Net::HTTPRequestHandlerFactory,public ILogger +class FMSHTTPRequestHandlerFactory:public Poco::Net::HTTPRequestHandlerFactory,public ILogger,public IDatabase { public: - FMSHTTPRequestHandlerFactory(); + FMSHTTPRequestHandlerFactory(SQLite3DB::DB *db); ~FMSHTTPRequestHandlerFactory(); Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &request); diff --git a/include/http/httpthread.h b/include/http/httpthread.h index b6d7035..b57906d 100644 --- a/include/http/httpthread.h +++ b/include/http/httpthread.h @@ -3,11 +3,11 @@ #include "../threadwrapper/cancelablerunnable.h" #include "../ilogger.h" -#include "../idatabase.h" +#include "../ithreaddatabase.h" #include -class HTTPThread:public CancelableRunnable,public ILogger, public IDatabase +class HTTPThread:public CancelableRunnable,public ILogger, public IThreadDatabase { public: HTTPThread(); diff --git a/include/http/ipagehandler.h b/include/http/ipagehandler.h index f6f2cc0..d0c5856 100644 --- a/include/http/ipagehandler.h +++ b/include/http/ipagehandler.h @@ -2,6 +2,7 @@ #define _ipagehandler_ #include "../ilogger.h" +#include "../idatabase.h" #include #include @@ -12,11 +13,11 @@ #include #include -class IPageHandler:public Poco::Net::HTTPRequestHandler,public ILogger +class IPageHandler:public Poco::Net::HTTPRequestHandler,public ILogger,public IDatabase { public: - IPageHandler() {} - IPageHandler(const std::string &templatestr, const std::string &pagename):m_template(templatestr),m_pagename(pagename) { } + IPageHandler(SQLite3DB::DB *db):IDatabase(db) {} + IPageHandler(SQLite3DB::DB *db, const std::string &templatestr, const std::string &pagename):IDatabase(db),m_template(templatestr),m_pagename(pagename) { } virtual ~IPageHandler() {} virtual const bool WillHandleURI(const std::string &uri); diff --git a/include/http/pages/addpeerpage.h b/include/http/pages/addpeerpage.h index 1425b10..1176a51 100644 --- a/include/http/pages/addpeerpage.h +++ b/include/http/pages/addpeerpage.h @@ -2,14 +2,13 @@ #define _addpeerpage_ #include "../ipagehandler.h" -#include "../../idatabase.h" -class AddPeerPage:public IPageHandler,public IDatabase +class AddPeerPage:public IPageHandler { public: - AddPeerPage(const std::string &templatestr):IPageHandler(templatestr,"addpeer.htm") {} + AddPeerPage(SQLite3DB::DB *db, const std::string &templatestr):IPageHandler(db,templatestr,"addpeer.htm") {} - IPageHandler *New() { return new AddPeerPage(m_template); } + IPageHandler *New() { return new AddPeerPage(m_db,m_template); } private: const bool WillHandleURI(const std::string &uri); diff --git a/include/http/pages/announceidentitypage.h b/include/http/pages/announceidentitypage.h index b4bf78a..e84ff85 100644 --- a/include/http/pages/announceidentitypage.h +++ b/include/http/pages/announceidentitypage.h @@ -2,14 +2,13 @@ #define _announceidentitypage_ #include "../ipagehandler.h" -#include "../../idatabase.h" -class AnnounceIdentityPage:public IPageHandler,public IDatabase +class AnnounceIdentityPage:public IPageHandler { public: - AnnounceIdentityPage(const std::string &templatestr):IPageHandler(templatestr,"announceidentity.htm") {} + AnnounceIdentityPage(SQLite3DB::DB *db, const std::string &templatestr):IPageHandler(db,templatestr,"announceidentity.htm") {} - IPageHandler *New() { return new AnnounceIdentityPage(m_template); } + IPageHandler *New() { return new AnnounceIdentityPage(m_db,m_template); } private: const bool WillHandleURI(const std::string &uri); diff --git a/include/http/pages/boardspage.h b/include/http/pages/boardspage.h index 0e4383c..9583a60 100644 --- a/include/http/pages/boardspage.h +++ b/include/http/pages/boardspage.h @@ -2,14 +2,13 @@ #define _boardspage_ #include "../ipagehandler.h" -#include "../../idatabase.h" -class BoardsPage:public IPageHandler,public IDatabase +class BoardsPage:public IPageHandler { public: - BoardsPage(const std::string &templatestr):IPageHandler(templatestr,"boards.htm") {} + BoardsPage(SQLite3DB::DB *db, const std::string &templatestr):IPageHandler(db,templatestr,"boards.htm") {} - IPageHandler *New() { return new BoardsPage(m_template); } + IPageHandler *New() { return new BoardsPage(m_db,m_template); } private: const bool WillHandleURI(const std::string &uri); diff --git a/include/http/pages/confirmpage.h b/include/http/pages/confirmpage.h index aaf0c78..5236d10 100644 --- a/include/http/pages/confirmpage.h +++ b/include/http/pages/confirmpage.h @@ -6,9 +6,9 @@ class ConfirmPage:public IPageHandler { public: - ConfirmPage(const std::string &templatestr):IPageHandler(templatestr,"confirm.htm") {} + ConfirmPage(SQLite3DB::DB *db, const std::string &templatestr):IPageHandler(db,templatestr,"confirm.htm") {} - IPageHandler *New() { return new ConfirmPage(m_template); } + IPageHandler *New() { return new ConfirmPage(m_db,m_template); } private: const bool WillHandleURI(const std::string &uri); diff --git a/include/http/pages/controlboardpage.h b/include/http/pages/controlboardpage.h index 0f8fcde..3021edc 100644 --- a/include/http/pages/controlboardpage.h +++ b/include/http/pages/controlboardpage.h @@ -2,14 +2,13 @@ #define _controlboardpage_ #include "../ipagehandler.h" -#include "../../idatabase.h" -class ControlBoardPage:public IPageHandler,public IDatabase +class ControlBoardPage:public IPageHandler { public: - ControlBoardPage(const std::string &templatestr):IPageHandler(templatestr,"controlboard.htm") {} + ControlBoardPage(SQLite3DB::DB *db, const std::string &templatestr):IPageHandler(db,templatestr,"controlboard.htm") {} - IPageHandler *New() { return new ControlBoardPage(m_template); } + IPageHandler *New() { return new ControlBoardPage(m_db,m_template); } private: const bool WillHandleURI(const std::string &uri); diff --git a/include/http/pages/createidentitypage.h b/include/http/pages/createidentitypage.h index a1a912f..9583c7a 100644 --- a/include/http/pages/createidentitypage.h +++ b/include/http/pages/createidentitypage.h @@ -2,14 +2,13 @@ #define _createidentitypage_ #include "../ipagehandler.h" -#include "../../idatabase.h" -class CreateIdentityPage:public IPageHandler,public IDatabase +class CreateIdentityPage:public IPageHandler { public: - CreateIdentityPage(const std::string &templatestr):IPageHandler(templatestr,"createidentity.htm") {} + CreateIdentityPage(SQLite3DB::DB *db, const std::string &templatestr):IPageHandler(db,templatestr,"createidentity.htm") {} - IPageHandler *New() { return new CreateIdentityPage(m_template); } + IPageHandler *New() { return new CreateIdentityPage(m_db,m_template); } private: const bool WillHandleURI(const std::string &uri); diff --git a/include/http/pages/execquerypage.h b/include/http/pages/execquerypage.h index caedd08..3ba8423 100644 --- a/include/http/pages/execquerypage.h +++ b/include/http/pages/execquerypage.h @@ -2,14 +2,13 @@ #define _execquerypage_ #include "../ipagehandler.h" -#include "../../idatabase.h" -class ExecQueryPage:public IPageHandler,public IDatabase +class ExecQueryPage:public IPageHandler { public: - ExecQueryPage(const std::string &templatestr):IPageHandler(templatestr,"execquery.htm") {} + ExecQueryPage(SQLite3DB::DB *db, const std::string &templatestr):IPageHandler(db,templatestr,"execquery.htm") {} - IPageHandler *New() { return new ExecQueryPage(m_template); } + IPageHandler *New() { return new ExecQueryPage(m_db,m_template); } private: const bool WillHandleURI(const std::string &uri); diff --git a/include/http/pages/forumcreatepostpage.h b/include/http/pages/forumcreatepostpage.h index 7f2b592..fb057cd 100644 --- a/include/http/pages/forumcreatepostpage.h +++ b/include/http/pages/forumcreatepostpage.h @@ -6,9 +6,9 @@ class ForumCreatePostPage:public ForumPage { public: - ForumCreatePostPage(const std::string &templatestr):ForumPage(templatestr,"forumcreatepost.htm") {} + ForumCreatePostPage(SQLite3DB::DB *db, const std::string &templatestr):ForumPage(db,templatestr,"forumcreatepost.htm") {} - IPageHandler *New() { return new ForumCreatePostPage(m_template); } + IPageHandler *New() { return new ForumCreatePostPage(m_db,m_template); } private: const std::string GeneratePage(const std::string &method, const std::map &queryvars); diff --git a/include/http/pages/forummainpage.h b/include/http/pages/forummainpage.h index 63af3c5..1c28b6d 100644 --- a/include/http/pages/forummainpage.h +++ b/include/http/pages/forummainpage.h @@ -6,9 +6,9 @@ class ForumMainPage:public ForumPage { public: - ForumMainPage(const std::string &templatestr):ForumPage(templatestr,"forummain.htm") {} + ForumMainPage(SQLite3DB::DB *db,const std::string &templatestr):ForumPage(db,templatestr,"forummain.htm") {} - IPageHandler *New() { return new ForumMainPage(m_template); } + IPageHandler *New() { return new ForumMainPage(m_db,m_template); } private: const std::string GeneratePage(const std::string &method, const std::map &queryvars); diff --git a/include/http/pages/forumpage.h b/include/http/pages/forumpage.h index 3124b9e..7a52204 100644 --- a/include/http/pages/forumpage.h +++ b/include/http/pages/forumpage.h @@ -2,12 +2,11 @@ #define _forumpage_ #include "../ipagehandler.h" -#include "../../idatabase.h" -class ForumPage:public IPageHandler,public IDatabase +class ForumPage:public IPageHandler { public: - ForumPage(const std::string &templatestr, const std::string &pagename):IPageHandler(templatestr,pagename) {} + ForumPage(SQLite3DB::DB *db, const std::string &templatestr, const std::string &pagename):IPageHandler(db,templatestr,pagename) {} virtual IPageHandler *New()=0; // returns a new instance of the object diff --git a/include/http/pages/forumthreadspage.h b/include/http/pages/forumthreadspage.h index 71131c1..37fef3e 100644 --- a/include/http/pages/forumthreadspage.h +++ b/include/http/pages/forumthreadspage.h @@ -6,9 +6,9 @@ class ForumThreadsPage:public ForumPage { public: - ForumThreadsPage(const std::string &templatestr):ForumPage(templatestr,"forumthreads.htm") {} + ForumThreadsPage(SQLite3DB::DB *db, const std::string &templatestr):ForumPage(db,templatestr,"forumthreads.htm") {} - IPageHandler *New() { return new ForumThreadsPage(m_template); } + IPageHandler *New() { return new ForumThreadsPage(m_db,m_template); } private: const std::string GeneratePage(const std::string &method, const std::map &queryvars); diff --git a/include/http/pages/forumviewthreadpage.h b/include/http/pages/forumviewthreadpage.h index 78c2e2c..6374105 100644 --- a/include/http/pages/forumviewthreadpage.h +++ b/include/http/pages/forumviewthreadpage.h @@ -6,9 +6,9 @@ class ForumViewThreadPage:public ForumPage { public: - ForumViewThreadPage(const std::string &templatestr):ForumPage(templatestr,"forumviewthread.htm") {} + ForumViewThreadPage(SQLite3DB::DB *db,const std::string &templatestr):ForumPage(db,templatestr,"forumviewthread.htm") {} - IPageHandler *New() { return new ForumViewThreadPage(m_template); } + IPageHandler *New() { return new ForumViewThreadPage(m_db,m_template); } private: const std::string GeneratePage(const std::string &method, const std::map &queryvars); diff --git a/include/http/pages/homepage.h b/include/http/pages/homepage.h index 0b8c5e2..cfdbb4b 100644 --- a/include/http/pages/homepage.h +++ b/include/http/pages/homepage.h @@ -2,14 +2,13 @@ #define _homepage_ #include "../ipagehandler.h" -#include "../../idatabase.h" -class HomePage:public IPageHandler,public IDatabase +class HomePage:public IPageHandler { public: - HomePage(const std::string &templatestr):IPageHandler(templatestr,"index.htm") {} + HomePage(SQLite3DB::DB *db, const std::string &templatestr):IPageHandler(db,templatestr,"index.htm") {} - IPageHandler *New() { return new HomePage(m_template); } + IPageHandler *New() { return new HomePage(m_db,m_template); } private: const bool WillHandleURI(const std::string &uri); diff --git a/include/http/pages/insertedfilespage.h b/include/http/pages/insertedfilespage.h index d9d4832..e187288 100644 --- a/include/http/pages/insertedfilespage.h +++ b/include/http/pages/insertedfilespage.h @@ -2,14 +2,13 @@ #define _insertedfilespage_ #include "../ipagehandler.h" -#include "../../idatabase.h" -class InsertedFilesPage:public IPageHandler,public IDatabase +class InsertedFilesPage:public IPageHandler { public: - InsertedFilesPage(const std::string &templatestr):IPageHandler(templatestr,"insertedfiles.htm") {} + InsertedFilesPage(SQLite3DB::DB *db, const std::string &templatestr):IPageHandler(db,templatestr,"insertedfiles.htm") {} - IPageHandler *New() { return new InsertedFilesPage(m_template); } + IPageHandler *New() { return new InsertedFilesPage(m_db,m_template); } private: const bool WillHandleURI(const std::string &uri); diff --git a/include/http/pages/localidentitiespage.h b/include/http/pages/localidentitiespage.h index 162777c..bc0ae7c 100644 --- a/include/http/pages/localidentitiespage.h +++ b/include/http/pages/localidentitiespage.h @@ -2,14 +2,13 @@ #define _localidentitiespage_ #include "../ipagehandler.h" -#include "../../idatabase.h" -class LocalIdentitiesPage:public IPageHandler,public IDatabase +class LocalIdentitiesPage:public IPageHandler { public: - LocalIdentitiesPage(const std::string &templatestr):IPageHandler(templatestr,"localidentities.htm") {} + LocalIdentitiesPage(SQLite3DB::DB *db, const std::string &templatestr):IPageHandler(db,templatestr,"localidentities.htm") {} - IPageHandler *New() { return new LocalIdentitiesPage(m_template); } + IPageHandler *New() { return new LocalIdentitiesPage(m_db,m_template); } void handleRequest(Poco::Net::HTTPServerRequest &request, Poco::Net::HTTPServerResponse &response); diff --git a/include/http/pages/optionspage.h b/include/http/pages/optionspage.h index 9589205..8aa13b0 100644 --- a/include/http/pages/optionspage.h +++ b/include/http/pages/optionspage.h @@ -2,19 +2,25 @@ #define _optionspage_ #include "../ipagehandler.h" -#include "../../idatabase.h" -class OptionsPage:public IPageHandler,public IDatabase +class OptionsPage:public IPageHandler { public: - OptionsPage(const std::string &templatestr):IPageHandler(templatestr,"options.htm") {} + OptionsPage(SQLite3DB::DB *db, const std::string &templatestr):IPageHandler(db,templatestr,"options.htm") {} - IPageHandler *New() { return new OptionsPage(m_template); } + IPageHandler *New() { return new OptionsPage(m_db,m_template); } private: const bool WillHandleURI(const std::string &uri); const std::string GeneratePage(const std::string &method, const std::map &queryvars); - const std::string CreateDropDown(const std::string &name, const std::vector &items, const std::string &selecteditem); + + const std::string CreateTextBox(const std::string &name, const std::string ¤tvalue, const std::string ¶m1, const std::string ¶m2); + const std::string CreateDropDown(const std::string &name, const std::vector &items, const std::string &selecteditem, const std::string ¶m1, const std::string ¶m2); + const std::string CreateTextArea(const std::string &name, const std::string ¤tvalue, const std::string ¶m1, const std::string ¶m2); + + + static int m_mode; + }; #endif // _optionspage_ diff --git a/include/http/pages/peerdetailspage.h b/include/http/pages/peerdetailspage.h index 1c69303..00672cc 100644 --- a/include/http/pages/peerdetailspage.h +++ b/include/http/pages/peerdetailspage.h @@ -2,14 +2,13 @@ #define _peerdetailspage_ #include "../ipagehandler.h" -#include "../../idatabase.h" -class PeerDetailsPage:public IPageHandler,public IDatabase +class PeerDetailsPage:public IPageHandler { public: - PeerDetailsPage(const std::string templatestr):IPageHandler(templatestr,"peerdetails.htm") {} + PeerDetailsPage(SQLite3DB::DB *db, const std::string templatestr):IPageHandler(db,templatestr,"peerdetails.htm") {} - IPageHandler *New() { return new PeerDetailsPage(m_template); } + IPageHandler *New() { return new PeerDetailsPage(m_db,m_template); } private: const bool WillHandleURI(const std::string &uri); diff --git a/include/http/pages/peermaintenancepage.h b/include/http/pages/peermaintenancepage.h index efacffa..9022504 100644 --- a/include/http/pages/peermaintenancepage.h +++ b/include/http/pages/peermaintenancepage.h @@ -2,14 +2,13 @@ #define _peermaintenancepage_ #include "../ipagehandler.h" -#include "../../idatabase.h" -class PeerMaintenancePage:public IPageHandler,public IDatabase +class PeerMaintenancePage:public IPageHandler { public: - PeerMaintenancePage(const std::string &templatestr):IPageHandler(templatestr,"peermaintenance.htm") {} + PeerMaintenancePage(SQLite3DB::DB *db, const std::string &templatestr):IPageHandler(db,templatestr,"peermaintenance.htm") {} - IPageHandler *New() { return new PeerMaintenancePage(m_template); } + IPageHandler *New() { return new PeerMaintenancePage(m_db,m_template); } private: const bool WillHandleURI(const std::string &uri); diff --git a/include/http/pages/peertrustpage.h b/include/http/pages/peertrustpage.h index a62ad68..0fb6dd3 100644 --- a/include/http/pages/peertrustpage.h +++ b/include/http/pages/peertrustpage.h @@ -2,14 +2,13 @@ #define _peertrustpage_ #include "../ipagehandler.h" -#include "../../idatabase.h" -class PeerTrustPage:public IPageHandler,public IDatabase +class PeerTrustPage:public IPageHandler { public: - PeerTrustPage(const std::string &templatestr):IPageHandler(templatestr,"peertrust.htm") {} + PeerTrustPage(SQLite3DB::DB *db, const std::string &templatestr):IPageHandler(db,templatestr,"peertrust.htm") {} - IPageHandler *New() { return new PeerTrustPage(m_template); } + IPageHandler *New() { return new PeerTrustPage(m_db,m_template); } private: const std::string GeneratePage(const std::string &method, const std::map &queryvars); diff --git a/include/http/pages/recentlyaddedpage.h b/include/http/pages/recentlyaddedpage.h index 9f00760..1ed00e1 100644 --- a/include/http/pages/recentlyaddedpage.h +++ b/include/http/pages/recentlyaddedpage.h @@ -2,14 +2,13 @@ #define _recentlyaddedpage_ #include "../ipagehandler.h" -#include "../../idatabase.h" -class RecentlyAddedPage:public IPageHandler,public IDatabase +class RecentlyAddedPage:public IPageHandler { public: - RecentlyAddedPage(const std::string &templatestr):IPageHandler(templatestr,"recentlyadded.htm") {} + RecentlyAddedPage(SQLite3DB::DB *db, const std::string &templatestr):IPageHandler(db,templatestr,"recentlyadded.htm") {} - IPageHandler *New() { return new RecentlyAddedPage(m_template); } + IPageHandler *New() { return new RecentlyAddedPage(m_db,m_template); } private: const std::string GeneratePage(const std::string &method, const std::map &queryvars); diff --git a/include/http/pages/showcaptchapage.h b/include/http/pages/showcaptchapage.h index 739e412..58af3f0 100644 --- a/include/http/pages/showcaptchapage.h +++ b/include/http/pages/showcaptchapage.h @@ -4,13 +4,14 @@ #include "../ipagehandler.h" #include "../../idatabase.h" -class ShowCaptchaPage:public IPageHandler,public IDatabase +class ShowCaptchaPage:public IPageHandler { public: + ShowCaptchaPage(SQLite3DB::DB *db):IPageHandler(db) {} void handleRequest(Poco::Net::HTTPServerRequest &request, Poco::Net::HTTPServerResponse &response); - IPageHandler *New() { return new ShowCaptchaPage; } + IPageHandler *New() { return new ShowCaptchaPage(m_db); } private: const bool WillHandleURI(const std::string &uri); diff --git a/include/http/pages/showimagepage.h b/include/http/pages/showimagepage.h index 2c8c648..15aa304 100644 --- a/include/http/pages/showimagepage.h +++ b/include/http/pages/showimagepage.h @@ -6,10 +6,11 @@ class ShowImagePage:public IPageHandler { public: + ShowImagePage(SQLite3DB::DB *db):IPageHandler(m_db) {} void handleRequest(Poco::Net::HTTPServerRequest &request, Poco::Net::HTTPServerResponse &response); - IPageHandler *New() { return new ShowImagePage; } + IPageHandler *New() { return new ShowImagePage(m_db); } private: const bool WillHandleURI(const std::string &uri); diff --git a/include/http/pages/showpendingmessagepage.h b/include/http/pages/showpendingmessagepage.h new file mode 100644 index 0000000..2e99dab --- /dev/null +++ b/include/http/pages/showpendingmessagepage.h @@ -0,0 +1,17 @@ +#ifndef _showpmessagepage_ +#define _showpmessagepage_ + +#include "../ipagehandler.h" + +class ShowPendingMessagePage:public IPageHandler +{ +public: + ShowPendingMessagePage(SQLite3DB::DB *db, const std::string &templatestr):IPageHandler(db,templatestr,"showpendingmessage.htm") {} + + IPageHandler *New() { return new ShowPendingMessagePage(m_db,m_template); } + +private: + const std::string GeneratePage(const std::string &method, const std::map &queryvars); +}; + +#endif // _showpmessage_ diff --git a/include/http/pages/versioninfopage.h b/include/http/pages/versioninfopage.h index 9f22d4e..0f2176a 100644 --- a/include/http/pages/versioninfopage.h +++ b/include/http/pages/versioninfopage.h @@ -2,14 +2,13 @@ #define _versioninfopage_ #include "../ipagehandler.h" -#include "../../idatabase.h" -class VersionInfoPage:public IPageHandler,public IDatabase +class VersionInfoPage:public IPageHandler { public: - VersionInfoPage(const std::string &templatestr):IPageHandler(templatestr,"versioninfo.htm") {} + VersionInfoPage(SQLite3DB::DB *db, const std::string &templatestr):IPageHandler(db,templatestr,"versioninfo.htm") {} - IPageHandler *New() { return new VersionInfoPage(m_template); } + IPageHandler *New() { return new VersionInfoPage(m_db,m_template); } private: const std::string GeneratePage(const std::string &method, const std::map &queryvars); diff --git a/include/idatabase.h b/include/idatabase.h index ddf9ba9..1696b9c 100644 --- a/include/idatabase.h +++ b/include/idatabase.h @@ -9,7 +9,9 @@ class IDatabase { public: - IDatabase():m_db(SQLite3DB::DB::Instance()) {} + IDatabase(SQLite3DB::DB *db):m_db(db) {} + + void SetDB(SQLite3DB::DB *db) { m_db=db; } protected: SQLite3DB::DB *m_db; diff --git a/include/ithreaddatabase.h b/include/ithreaddatabase.h new file mode 100644 index 0000000..b5d303a --- /dev/null +++ b/include/ithreaddatabase.h @@ -0,0 +1,50 @@ +#ifndef _ithreaddatabase_ +#define _ithreaddatabase_ + +#include "db/sqlite3db.h" + +// each thread using the database must inherit from this class +class IThreadDatabase +{ +public: + IThreadDatabase():m_db(0) {} + virtual ~IThreadDatabase() + { + delete m_db; + } + + void LoadDatabase() + { + if(m_db) + { + delete m_db; + } + m_db=new SQLite3DB::DB("fms.db3"); + m_db->SetBusyTimeout(40000); // set timeout to 40 seconds + m_db->Execute("PRAGMA synchronous = FULL;"); + + // MessageInserter will insert a record into this temp table which the MessageListInserter will query for and insert a MessageList when needed + m_db->Execute("CREATE TEMPORARY TABLE IF NOT EXISTS tmpMessageListInsert(\ + MessageListInsertID INTEGER PRIMARY KEY,\ + LocalIdentityID INTEGER,\ + Date DATETIME\ + );"); + + // A temporary table that will hold a local identity id of the last identity who was loaded in the trust list page + m_db->Execute("CREATE TEMPORARY TABLE IF NOT EXISTS tmpLocalIdentityPeerTrustPage(\ + LocalIdentityID INTEGER\ + );"); + + // Temporary table for form passwords + m_db->Execute("CREATE TEMPORARY TABLE IF NOT EXISTS tmpFormPassword(\ + Date DATETIME,\ + Password TEXT\ + );"); + + } + +protected: + SQLite3DB::DB *m_db; +}; + +#endif // _ithreaddatabase_ diff --git a/include/localidentity.h b/include/localidentity.h index 4a0598e..830b288 100644 --- a/include/localidentity.h +++ b/include/localidentity.h @@ -6,7 +6,7 @@ class LocalIdentity:public IDatabase { public: - LocalIdentity(); + LocalIdentity(SQLite3DB::DB *db); const bool Load(const int id); const bool Load(const std::string &name); diff --git a/include/message.h b/include/message.h index 8c56633..3c4c666 100644 --- a/include/message.h +++ b/include/message.h @@ -9,9 +9,9 @@ class Message:public IDatabase,public ILogger { public: - Message(); - Message(const long messageid); - Message(const std::string &messageuuid); + Message(SQLite3DB::DB *db); + Message(SQLite3DB::DB *db, const long messageid); + Message(SQLite3DB::DB *db, const std::string &messageuuid); const long GetMessageID() const { return m_messageid; } const std::string GetMessageUUID() const { return m_messageuuid; } diff --git a/include/messagelist.h b/include/messagelist.h index be1df9e..6688200 100644 --- a/include/messagelist.h +++ b/include/messagelist.h @@ -8,6 +8,7 @@ class MessageList:public std::vector,public ILogger,public IDatabase { public: + MessageList(SQLite3DB::DB *db):IDatabase(db) {} /** \brief Loads all messages with an id between lowmessageid and highmessageid inclusive diff --git a/include/messagethread.h b/include/messagethread.h index 0dfe628..50cde62 100644 --- a/include/messagethread.h +++ b/include/messagethread.h @@ -6,6 +6,8 @@ class MessageThread:public IDatabase { public: + MessageThread(SQLite3DB::DB *db):IDatabase(db) {} + struct threadnode { long m_messageid; diff --git a/include/nntp/extensiontrust.h b/include/nntp/extensiontrust.h index b916fc7..8a67bc1 100644 --- a/include/nntp/extensiontrust.h +++ b/include/nntp/extensiontrust.h @@ -6,8 +6,8 @@ class TrustExtension:public IDatabase { public: - TrustExtension(); - TrustExtension(const int &localidentityid); + TrustExtension(SQLite3DB::DB *db); + TrustExtension(SQLite3DB::DB *db, const int &localidentityid); struct trust { diff --git a/include/nntp/nntpconnection.h b/include/nntp/nntpconnection.h index 15c2080..d048375 100644 --- a/include/nntp/nntpconnection.h +++ b/include/nntp/nntpconnection.h @@ -6,6 +6,7 @@ #include "../ilogger.h" #include "../message.h" #include "../localidentity.h" +#include "../ithreaddatabase.h" #include #include @@ -21,7 +22,7 @@ #include #endif -class NNTPConnection:public CancelableRunnable,public ILogger +class NNTPConnection:public CancelableRunnable,public ILogger,public IThreadDatabase { public: NNTPConnection(SOCKET sock); @@ -46,6 +47,8 @@ private: }; struct ClientStatus { + ClientStatus(SQLite3DB::DB *db):m_authuser(db) {} + ClientMode m_mode; bool m_allowpost; bool m_isposting; diff --git a/include/nntp/nntplistener.h b/include/nntp/nntplistener.h index 0bcca8f..065b013 100644 --- a/include/nntp/nntplistener.h +++ b/include/nntp/nntplistener.h @@ -6,21 +6,23 @@ #include "../threadwrapper/threadedexecutor.h" #include "../socketdefines.h" #include "../ilogger.h" +#include "../ithreaddatabase.h" /** \brief Listens for NNTP connections */ -class NNTPListener:public CancelableRunnable,public ILogger +class NNTPListener:public CancelableRunnable,public ILogger,public IThreadDatabase { public: NNTPListener(); ~NNTPListener(); void run(); - void StartListen(); private: + void StartListen(); + unsigned short m_listenport; std::vector m_listensockets; diff --git a/include/option.h b/include/option.h index 9de5adf..c0dff16 100644 --- a/include/option.h +++ b/include/option.h @@ -1,15 +1,16 @@ #ifndef _option_ #define _option_ -#include "db/sqlite3db.h" +#include "idatabase.h" #include -#include "threadwrapper/singleton.h" //just a wrapper around the database for the options table -class Option:public Singleton