version 0.1.14
authorSomeDude <SomeDude@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw>
Thu, 28 Feb 2008 18:16:00 +0000 (19:16 +0100)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Thu, 28 Feb 2008 18:16:00 +0000 (19:16 +0100)
22 files changed:
CMakeLists.txt
include/board.h
include/freenet/messagelistxml.h
include/global.h
include/message.h
include/stringfunctions.h
src/board.cpp
src/boardlist.cpp
src/freenet/boardlistxml.cpp
src/freenet/messagelistinserter.cpp
src/freenet/messagelistrequester.cpp
src/freenet/messagelistxml.cpp
src/freenet/messagerequester.cpp
src/freenet/messagexml.cpp
src/freenet/periodicdbmaintenance.cpp
src/global.cpp
src/http/pages/boardspage.cpp
src/http/pages/createidentitypage.cpp
src/http/pages/peerdetailspage.cpp
src/message.cpp
src/nntp/nntpconnection.cpp
src/stringfunctions.cpp

index 5f976ac..9c0e66a 100644 (file)
@@ -100,7 +100,7 @@ ADD_EXECUTABLE(fms ${FMS_SRC} ${FMS_PLATFORM_SRC})
 # link dl - For SQLite3 and shttpd - not for FreeBSD\r
 IF(CMAKE_COMPILER_IS_GNUCC)\r
        IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
-       ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
+       ELSE(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
                TARGET_LINK_LIBRARIES(fms dl)\r
        ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
 ENDIF(CMAKE_COMPILER_IS_GNUCC)\r
@@ -108,7 +108,7 @@ ENDIF(CMAKE_COMPILER_IS_GNUCC)
 # add -lcompat only for FreeBSD\r
 IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
        IF(CMAKE_COMPILER_IS_GNUCXX)\r
-               ADD_DEFINITIONS(-lcompat)\r
+               TARGET_LINK_LIBRARIES(fms compat)\r
        ENDIF(CMAKE_COMPILER_IS_GNUCXX)\r
 ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
 \r
@@ -119,7 +119,8 @@ ENDIF(WIN32)
 \r
 # add -lxnet and -lsocket on solaris\r
 IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")\r
-       ADD_DEFINITIONS(-lxnet -lsocket)\r
+       TARGET_LINK_LIBRARIES(fms xnet)\r
+       TARGET_LINK_LIBRARIES(fms socket)\r
 ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")\r
 \r
 FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite3 sqlite3_s)\r
index 64797ae..a5479d3 100644 (file)
@@ -13,6 +13,7 @@ public:
        Board();\r
        Board(const long boardid);\r
        Board(const std::string &boardname);\r
+       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);\r
 \r
        const bool Load(const long boardid);\r
        const bool Load(const std::string &boardname);\r
@@ -24,8 +25,11 @@ public:
        const long GetLowMessageID() const { return m_lowmessageid; }\r
        const long GetHighMessageID() const { return m_highmessageid; }\r
        const long GetMessageCount() const { return m_messagecount; }\r
+       const bool GetSaveReceivedMessages() const { return m_savereceivedmessages; }\r
 \r
 private:\r
+       void SetDateFromString(const std::string &datestring);\r
+\r
        long m_boardid;\r
        std::string m_boardname;\r
        std::string m_boarddescription;\r
@@ -33,6 +37,7 @@ private:
        long m_lowmessageid;            // lowest id of all message currently in this board\r
        long m_highmessageid;           // highest id of all message currently in this board\r
        long m_messagecount;            // number of messages in this board\r
+       bool m_savereceivedmessages;\r
 };\r
 \r
 #endif // _board_\r
index 3d3f993..1cbf861 100644 (file)
@@ -15,6 +15,17 @@ private:
                long m_index;\r
                std::vector<std::string> m_boards;\r
        };\r
+       struct externalmessage\r
+       {\r
+               externalmessage(const std::string &type, const std::string identity, const std::string &date, const long index, const std::vector<std::string> &boards):m_type(type),m_identity(identity),m_date(date),m_index(index),m_boards(boards)  {}\r
+               externalmessage(const std::string &type, const std::string messagekey, const std::string &date, const std::vector<std::string> &boards):m_type(type),m_messagekey(messagekey),m_date(date),m_boards(boards)                                                             {}\r
+               std::string m_type;\r
+               std::string m_identity;\r
+               std::string m_messagekey;\r
+               long m_index;\r
+               std::string m_date;\r
+               std::vector<std::string> m_boards;\r
+       };\r
 public:\r
        MessageListXML();\r
 \r
@@ -23,17 +34,28 @@ public:
 \r
        void ClearMessages()    { m_messages.clear(); }\r
 \r
-       void AddMessage(const std::string &date, const long index, const std::vector<std::string> boards);\r
+       void AddMessage(const std::string &date, const long index, const std::vector<std::string> &boards);\r
+       void AddExternalMessage(const std::string &identity, const std::string &date, const long index, const std::vector<std::string> &boards);\r
+       void AddExternalMessage(const std::string &messagekey, const std::string &date, const std::vector<std::string> &boards);\r
 \r
        const std::vector<message>::size_type MessageCount()    { return m_messages.size(); }\r
        std::string GetDate(const long index);\r
        const long GetIndex(const long index);\r
        std::vector<std::string> GetBoards(const long index);\r
 \r
+       const std::vector<externalmessage>::size_type ExternalMessageCount()    { return m_externalmessages.size(); }\r
+       std::string GetExternalType(const long index);\r
+       std::string GetExternalIdentity(const long index);\r
+       std::string GetExternalMessageKey(const long index);\r
+       const long GetExternalIndex(const long index);\r
+       std::string GetExternalDate(const long index);\r
+       std::vector<std::string> GetExternalBoards(const long index);\r
+\r
 private:\r
        void Initialize();\r
 \r
        std::vector<message> m_messages;\r
+       std::vector<externalmessage> m_externalmessages;\r
 \r
 };\r
 \r
index 3abb065..55a1e63 100644 (file)
@@ -5,12 +5,13 @@
 //#include <zthread/Thread.h>\r
 #include "pthreadwrapper/thread.h"\r
 \r
-#define FMS_VERSION    "0.1.13"\r
+#define FMS_VERSION    "0.1.14"\r
 \r
 // opens database and creates tables and initial inserts if necessary\r
 void SetupDB();\r
 void ConvertDB0100To0101();\r
 void ConvertDB0101To0103();\r
+void ConvertDB0103To0104();\r
 // inserts default options into the database\r
 void SetupDefaultOptions();\r
 // opens logfile and sets it up\r
index c99b96d..9cda4a9 100644 (file)
@@ -54,6 +54,7 @@ private:
        // checks vector of boards for any special administration boards - if it finds one true is returned, otherwise false\r
        const bool CheckForAdministrationBoard(const std::vector<std::string> &boards);\r
        void HandleChangeTrust();\r
+       void StripAdministrationBoards();       // removes administration boards from boards vector\r
 \r
        long m_messageid;\r
        bool m_addnewpostfromidentities;\r
index ac803c9..bf5119d 100644 (file)
@@ -91,6 +91,13 @@ std::string TrimWhitespace(const std::string &str);
 void UpperCase(const std::string &str, std::string &output);\r
 \r
 /**\r
+       \brief Converts a string to lower case\r
+       \param str string to convert to lower case\r
+       \param[out] string converted to lower case\r
+*/\r
+void LowerCase(const std::string &str, std::string &output);\r
+\r
+/**\r
        \brief Decodes a URI encoded string\r
        \param aSrc string that is URI encoded\r
        \return URI decoded input string\r
index e256dcb..aee9339 100644 (file)
@@ -14,6 +14,7 @@ Board::Board()
        m_lowmessageid=0;\r
        m_highmessageid=0;\r
        m_messagecount=0;\r
+       m_savereceivedmessages=true;\r
 }\r
 \r
 Board::Board(const long boardid)\r
@@ -26,6 +27,21 @@ Board::Board(const std::string &boardname)
        Load(boardname);\r
 }\r
 \r
+Board::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)\r
+{\r
+       m_boardid=boardid;\r
+       m_boardname=boardname;\r
+       m_boarddescription=boarddescription;\r
+       m_lowmessageid=lowmessageid;\r
+       m_highmessageid=highmessageid;\r
+       m_messagecount=messagecount;\r
+       m_savereceivedmessages=savereceivedmessages;\r
+\r
+       SetDateFromString(datecreated);\r
+\r
+}\r
+\r
+\r
 const bool Board::Load(const long boardid)\r
 {\r
        // clear current values\r
@@ -37,7 +53,7 @@ const bool Board::Load(const long boardid)
        m_highmessageid=0;\r
        m_messagecount=0;\r
 \r
-       SQLite3DB::Statement st=m_db->Prepare("SELECT BoardName, BoardDescription, DateAdded FROM tblBoard WHERE BoardID=?;");\r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT BoardName, BoardDescription, DateAdded, HighMessageID, LowMessageID, MessageCount, SaveReceivedMessages FROM tblBoard LEFT JOIN vwBoardStats ON tblBoard.BoardID=vwBoardStats.BoardID WHERE tblBoard.BoardID=?;");\r
        st.Bind(0,boardid);\r
        st.Step();\r
 \r
@@ -52,53 +68,25 @@ const bool Board::Load(const long boardid)
                st.ResultText(1,m_boarddescription);\r
                st.ResultText(2,tempstr);\r
 \r
-               // break out date created  - date should be in format yyyy-mm-dd HH:MM:SS, so we split on "-", " " (space), and ":"\r
-               StringFunctions::SplitMultiple(tempstr,"- :",dateparts);\r
-               if(dateparts.size()>0)\r
-               {\r
-                       StringFunctions::Convert(dateparts[0],tempint);\r
-                       m_datecreated.SetYear(tempint);\r
-               }\r
-               if(dateparts.size()>1)\r
-               {\r
-                       StringFunctions::Convert(dateparts[1],tempint);\r
-                       m_datecreated.SetMonth(tempint);\r
-               }\r
-               if(dateparts.size()>2)\r
-               {\r
-                       StringFunctions::Convert(dateparts[2],tempint);\r
-                       m_datecreated.SetDay(tempint);\r
-               }\r
-               if(dateparts.size()>3)\r
-               {\r
-                       StringFunctions::Convert(dateparts[3],tempint);\r
-                       m_datecreated.SetHour(tempint);\r
-               }\r
-               if(dateparts.size()>4)\r
-               {\r
-                       StringFunctions::Convert(dateparts[4],tempint);\r
-                       m_datecreated.SetMinute(tempint);\r
-               }\r
-               if(dateparts.size()>5)\r
+               SetDateFromString(tempstr);\r
+\r
+               tempint=0;\r
+               st.ResultInt(3,tempint);\r
+               m_highmessageid=tempint;\r
+               tempint=0;\r
+               st.ResultInt(4,tempint);\r
+               m_lowmessageid=tempint;\r
+               tempint=0;\r
+               st.ResultInt(5,tempint);\r
+               m_messagecount=tempint;\r
+               st.ResultText(6,tempstr);\r
+               if(tempstr=="true")\r
                {\r
-                       StringFunctions::Convert(dateparts[5],tempint);\r
-                       m_datecreated.SetSecond(tempint);\r
+                       m_savereceivedmessages=true;\r
                }\r
-\r
-               // get max and min ids and message count in this board\r
-               SQLite3DB::Statement bounds=m_db->Prepare("SELECT HighMessageID, LowMessageID, MessageCount FROM vwBoardStats WHERE BoardID=?;");\r
-               bounds.Bind(0,boardid);\r
-               bounds.Step();\r
-\r
-               if(bounds.RowReturned())\r
+               else\r
                {\r
-                       int tempint;\r
-                       bounds.ResultInt(0,tempint);\r
-                       m_highmessageid=tempint;\r
-                       bounds.ResultInt(1,tempint);\r
-                       m_lowmessageid=tempint;\r
-                       bounds.ResultInt(2,tempint);\r
-                       m_messagecount=tempint;\r
+                       m_savereceivedmessages=false;\r
                }\r
 \r
                return true;\r
@@ -125,3 +113,41 @@ const bool Board::Load(const std::string &boardname)
                return false;\r
        }\r
 }\r
+\r
+void Board::SetDateFromString(const std::string &datestring)\r
+{\r
+       // break out date created  - date should be in format yyyy-mm-dd HH:MM:SS, so we split on "-", " " (space), and ":"\r
+       int tempint=0;\r
+       std::vector<std::string> dateparts;\r
+       StringFunctions::SplitMultiple(datestring,"- :",dateparts);\r
+       if(dateparts.size()>0)\r
+       {\r
+               StringFunctions::Convert(dateparts[0],tempint);\r
+               m_datecreated.SetYear(tempint);\r
+       }\r
+       if(dateparts.size()>1)\r
+       {\r
+               StringFunctions::Convert(dateparts[1],tempint);\r
+               m_datecreated.SetMonth(tempint);\r
+       }\r
+       if(dateparts.size()>2)\r
+       {\r
+               StringFunctions::Convert(dateparts[2],tempint);\r
+               m_datecreated.SetDay(tempint);\r
+       }\r
+       if(dateparts.size()>3)\r
+       {\r
+               StringFunctions::Convert(dateparts[3],tempint);\r
+               m_datecreated.SetHour(tempint);\r
+       }\r
+       if(dateparts.size()>4)\r
+       {\r
+               StringFunctions::Convert(dateparts[4],tempint);\r
+               m_datecreated.SetMinute(tempint);\r
+       }\r
+       if(dateparts.size()>5)\r
+       {\r
+               StringFunctions::Convert(dateparts[5],tempint);\r
+               m_datecreated.SetSecond(tempint);\r
+       }\r
+}\r
index 71c5e46..cd6e071 100644 (file)
@@ -8,14 +8,40 @@ void BoardList::Load()
 {\r
        clear();\r
        \r
-       int tempint;\r
-       SQLite3DB::Statement st=m_db->Prepare("SELECT BoardID FROM tblBoard ORDER BY BoardName;");\r
+       int boardid=0;\r
+       std::string boardname="";\r
+       std::string boarddescription="";\r
+       std::string dateadded="";\r
+       std::string savereceivedstr="";\r
+       bool savereceived=false;\r
+       int highmessageid=0;\r
+       int lowmessageid=0;\r
+       int messagecount=0;\r
+\r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT tblBoard.BoardID, BoardName, BoardDescription, DateAdded, HighMessageID, LowMessageID, MessageCount, SaveReceivedMessages FROM tblBoard LEFT JOIN vwBoardStats ON tblBoard.BoardID=vwBoardStats.BoardID ORDER BY BoardName COLLATE NOCASE;");\r
        st.Step();\r
        \r
        while(st.RowReturned())\r
        {\r
-               st.ResultInt(0,tempint);\r
-               push_back(Board(tempint));\r
+               st.ResultInt(0,boardid);\r
+               st.ResultText(1,boardname);\r
+               st.ResultText(2,boarddescription);\r
+               st.ResultText(3,dateadded);\r
+               st.ResultInt(4,highmessageid);\r
+               st.ResultInt(5,lowmessageid);\r
+               st.ResultInt(6,messagecount);\r
+               st.ResultText(7,savereceivedstr);\r
+\r
+               if(savereceivedstr=="true")\r
+               {\r
+                       savereceived=true;\r
+               }               \r
+               else\r
+               {\r
+                       savereceived=false;\r
+               }\r
+\r
+               push_back(Board(boardid,boardname,boarddescription,dateadded,lowmessageid,highmessageid,messagecount,savereceived));\r
                st.Step();\r
        }\r
 }\r
index 4307c71..954a5b4 100644 (file)
@@ -13,7 +13,9 @@ void BoardListXML::AddBoard(const std::string &name, const std::string &descript
 {\r
        if(name!="" && description!="")\r
        {\r
-               m_boards.push_back(board(name,description));\r
+               std::string lowername=name;\r
+               StringFunctions::Convert(lowername,lowername);\r
+               m_boards.push_back(board(lowername,description));\r
        }\r
 }\r
 \r
@@ -95,6 +97,7 @@ const bool BoardListXML::ParseXML(const std::string &xml)
                        if(txt)\r
                        {\r
                                name=txt->ValueStr();\r
+                               StringFunctions::LowerCase(name,name);\r
                        }\r
                        txt=hnd2.FirstChild("Description").FirstChild().ToText();\r
                        if(txt)\r
index b608145..6fda244 100644 (file)
@@ -165,6 +165,40 @@ void MessageListInserter::StartInsert(const long &localidentityid)
        }\r
        st.Finalize();\r
 \r
+\r
+       st=m_db->Prepare("SELECT MessageDate, MessageIndex, PublicKey, MessageID FROM tblMessage INNER JOIN tblIdentity ON tblMessage.IdentityID=tblIdentity.IdentityID WHERE MessageIndex IS NOT NULL ORDER BY MessageDate DESC, MessageTime DESC LIMIT 100;");\r
+       SQLite3DB::Statement st2=m_db->Prepare("SELECT BoardName FROM tblBoard INNER JOIN tblMessageBoard ON tblBoard.BoardID=tblMessageBoard.BoardID WHERE tblMessageBoard.MessageID=?;");\r
+       st.Step();\r
+       while(st.RowReturned())\r
+       {\r
+               std::string day;\r
+               int index;\r
+               std::string publickey;\r
+               std::vector<std::string> boardlist;\r
+               int messageid;\r
+               \r
+               st.ResultText(0,day);\r
+               st.ResultInt(1,index);\r
+               st.ResultText(2,publickey);\r
+               st.ResultInt(3,messageid);\r
+\r
+               st2.Bind(0,messageid);\r
+               st2.Step();\r
+               while(st2.RowReturned())\r
+               {\r
+                       std::string boardname="";\r
+                       st2.ResultText(0,boardname);\r
+                       StringFunctions::LowerCase(boardname,boardname);\r
+                       boardlist.push_back(boardname);\r
+                       st2.Step();\r
+               }\r
+               st2.Reset();\r
+\r
+               mlxml.AddExternalMessage(publickey,day,index,boardlist);\r
+\r
+               st.Step();\r
+       }\r
+\r
        // get last inserted messagelist index for this day\r
        index=0;\r
        st=m_db->Prepare("SELECT MAX(InsertIndex) FROM tblMessageListInserts WHERE LocalIdentityID=? AND Day=?;");\r
index 242d292..bbf8650 100644 (file)
@@ -54,6 +54,7 @@ const bool MessageListRequester::HandleAllData(FCPMessage &message)
        {\r
 \r
                SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID FROM tblMessageRequests WHERE IdentityID=? AND Day=? AND RequestIndex=?;");\r
+               SQLite3DB::Statement spk=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey=?;");\r
                SQLite3DB::Statement mst=m_db->Prepare("INSERT INTO tblMessageRequests(IdentityID,Day,RequestIndex,FromMessageList) VALUES(?,?,?,'true');");\r
                for(long i=0; i<xml.MessageCount(); i++)\r
                {\r
@@ -71,8 +72,24 @@ const bool MessageListRequester::HandleAllData(FCPMessage &message)
                        }\r
                        st.Reset();\r
                }\r
-               mst.Finalize();\r
-               st.Finalize();\r
+\r
+               // insert external message indexes\r
+               for(long i=0; i<xml.ExternalMessageCount(); i++)\r
+               {\r
+                       spk.Bind(0,xml.GetExternalIdentity(i));\r
+                       spk.Step();\r
+                       if(spk.RowReturned())\r
+                       {\r
+                               int thisidentityid=0;\r
+                               spk.ResultInt(0,thisidentityid);\r
+                               mst.Bind(0,thisidentityid);\r
+                               mst.Bind(1,xml.GetExternalDate(i));\r
+                               mst.Bind(2,xml.GetExternalIndex(i));\r
+                               mst.Step();\r
+                               mst.Reset();\r
+                       }\r
+                       spk.Reset();\r
+               }\r
 \r
                st=m_db->Prepare("INSERT INTO tblMessageListRequests(IdentityID,Day,RequestIndex,Found) VALUES(?,?,?,'true');");\r
                st.Bind(0,identityid);\r
index c05bb66..c2a9c82 100644 (file)
@@ -9,11 +9,21 @@ MessageListXML::MessageListXML()
        Initialize();\r
 }\r
 \r
-void MessageListXML::AddMessage(const std::string &date, const long index, const std::vector<std::string> boards)\r
+void MessageListXML::AddMessage(const std::string &date, const long index, const std::vector<std::string> &boards)\r
 {\r
        m_messages.push_back(message(date,index,boards));\r
 }\r
 \r
+void MessageListXML::AddExternalMessage(const std::string &identity, const std::string &date, const long index, const std::vector<std::string> &boards)\r
+{\r
+       m_externalmessages.push_back(externalmessage("Keyed",identity,date,index,boards));\r
+}\r
+\r
+void MessageListXML::AddExternalMessage(const std::string &messagekey, const std::string &date, const std::vector<std::string> &boards)\r
+{\r
+       m_externalmessages.push_back(externalmessage("Anonymous",messagekey,date,boards));\r
+}\r
+\r
 std::vector<std::string> MessageListXML::GetBoards(const long index)\r
 {\r
        if(index>=0 && index<m_messages.size())\r
@@ -38,6 +48,78 @@ std::string MessageListXML::GetDate(const long index)
        }\r
 }\r
 \r
+std::vector<std::string> MessageListXML::GetExternalBoards(const long index)\r
+{\r
+       if(index>=0 && index<m_externalmessages.size())\r
+       {\r
+               return m_externalmessages[index].m_boards;\r
+       }\r
+       else\r
+       {\r
+               return std::vector<std::string>();\r
+       }\r
+}\r
+\r
+std::string MessageListXML::GetExternalDate(const long index)\r
+{\r
+       if(index>=0 && index<m_externalmessages.size())\r
+       {\r
+               return m_externalmessages[index].m_date;\r
+       }\r
+       else\r
+       {\r
+               return "";\r
+       }\r
+}\r
+\r
+std::string MessageListXML::GetExternalIdentity(const long index)\r
+{\r
+       if(index>=0 && index<m_externalmessages.size())\r
+       {\r
+               return m_externalmessages[index].m_identity;\r
+       }\r
+       else\r
+       {\r
+               return "";\r
+       }\r
+}\r
+\r
+const long MessageListXML::GetExternalIndex(const long index)\r
+{\r
+       if(index>=0 && index<m_externalmessages.size())\r
+       {\r
+               return m_externalmessages[index].m_index;\r
+       }\r
+       else\r
+       {\r
+               return-1;\r
+       }\r
+}\r
+\r
+std::string MessageListXML::GetExternalMessageKey(const long index)\r
+{\r
+       if(index>=0 && index<m_externalmessages.size())\r
+       {\r
+               return m_externalmessages[index].m_messagekey;\r
+       }\r
+       else\r
+       {\r
+               return "";\r
+       }\r
+}\r
+\r
+std::string MessageListXML::GetExternalType(const long index)\r
+{\r
+       if(index>=0 && index<m_externalmessages.size())\r
+       {\r
+               return m_externalmessages[index].m_type;\r
+       }\r
+       else\r
+       {\r
+               return "";\r
+       }\r
+}\r
+\r
 const long MessageListXML::GetIndex(const long index)\r
 {\r
        if(index>=0 && index<m_messages.size())\r
@@ -75,6 +157,29 @@ std::string MessageListXML::GetXML()
                }\r
        }\r
 \r
+       for(std::vector<externalmessage>::iterator i=m_externalmessages.begin(); i!=m_externalmessages.end(); i++)\r
+       {\r
+               TiXmlElement *tr=new TiXmlElement("ExternalMessage");\r
+               tid->LinkEndChild(tr);\r
+               tr->LinkEndChild(XMLCreateTextElement("Type",(*i).m_type));\r
+               if((*i).m_type=="Keyed")\r
+               {\r
+                       tr->LinkEndChild(XMLCreateCDATAElement("Identity",(*i).m_identity));\r
+                       tr->LinkEndChild(XMLCreateTextElement("Index",(*i).m_index));\r
+               }\r
+               else\r
+               {\r
+                       tr->LinkEndChild(XMLCreateCDATAElement("MessageKey",(*i).m_messagekey));\r
+               }\r
+               tr->LinkEndChild(XMLCreateTextElement("Date",(*i).m_date));\r
+               TiXmlElement *brds=new TiXmlElement("Boards");\r
+               tr->LinkEndChild(brds);\r
+               for(std::vector<std::string>::iterator j=(*i).m_boards.begin(); j!=(*i).m_boards.end(); j++)\r
+               {\r
+                       brds->LinkEndChild(XMLCreateCDATAElement("Board",(*j)));\r
+               }\r
+       }\r
+\r
        td.Accept(&tp);\r
        return std::string(tp.CStr());\r
 }\r
@@ -82,6 +187,7 @@ std::string MessageListXML::GetXML()
 void MessageListXML::Initialize()\r
 {\r
        m_messages.clear();\r
+       m_externalmessages.clear();\r
 }\r
 \r
 const bool MessageListXML::ParseXML(const std::string &xml)\r
index ac56c5c..adf8168 100644 (file)
@@ -191,7 +191,7 @@ const bool MessageRequester::HandleAllData(FCPMessage &message)
 \r
                if(validmessage && savetoboardcount>0)\r
                {\r
-                       st=m_db->Prepare("INSERT INTO tblMessage(IdentityID,FromName,MessageDate,MessageTime,Subject,MessageUUID,ReplyBoardID,Body) VALUES(?,?,?,?,?,?,?,?);");\r
+                       st=m_db->Prepare("INSERT INTO tblMessage(IdentityID,FromName,MessageDate,MessageTime,Subject,MessageUUID,ReplyBoardID,Body,MessageIndex) VALUES(?,?,?,?,?,?,?,?,?);");\r
                        st.Bind(0,identityid);\r
                        st.Bind(1,GetIdentityName(identityid));\r
                        st.Bind(2,xml.GetDate());\r
@@ -200,6 +200,7 @@ const bool MessageRequester::HandleAllData(FCPMessage &message)
                        st.Bind(5,xml.GetMessageID());\r
                        st.Bind(6,GetBoardID(xml.GetReplyBoard()));\r
                        st.Bind(7,xml.GetBody());\r
+                       st.Bind(8,index);\r
                        inserted=st.Step(true);\r
                        int messageid=st.GetLastInsertRowID();\r
 \r
index 0de84c3..4b3252a 100644 (file)
@@ -113,7 +113,9 @@ const bool MessageXML::ParseXML(const std::string &xml)
                {\r
                        if(node2->FirstChild())\r
                        {\r
-                               m_boards.push_back(node2->FirstChild()->ValueStr());\r
+                               std::string boardname=node2->FirstChild()->ValueStr();\r
+                               StringFunctions::LowerCase(boardname,boardname);\r
+                               m_boards.push_back(boardname);\r
                        }\r
                        node2=node2->NextSibling("Board");\r
                }\r
index c615d60..63863f8 100644 (file)
@@ -133,6 +133,20 @@ void PeriodicDBMaintenance::Do1DayMaintenance()
                st.Step();\r
        }\r
 \r
+       // delete single use identities that are older than 7 days\r
+       date.SetToGMTime();\r
+       date.Add(0,0,0,-7);\r
+       st=m_db->Prepare("DELETE FROM tblIdentity WHERE SingleUse='true' AND DateAdded<?;");\r
+       st.Bind(0,date.Format("%Y-%m-%d %H:%M:%S"));\r
+       st.Step();\r
+\r
+       // delete local single use identities that are older than 7 days\r
+       date.SetToGMTime();\r
+       date.Add(0,0,0,-7);\r
+       st=m_db->Prepare("DELETE FROM tblLocalIdentity WHERE SingleUse='true' AND DateCreated<?;");\r
+       st.Bind(0,date.Format("%Y-%m-%d %H:%M:%S"));\r
+       st.Step();\r
+\r
 }\r
 \r
 void PeriodicDBMaintenance::Process()\r
index 5515e1a..a947767 100644 (file)
@@ -58,13 +58,19 @@ void SetupDB()
                        major=1;\r
                        minor=3;\r
                }\r
+               if(major==1 && minor==3)\r
+               {\r
+                       ConvertDB0103To0104();\r
+                       major=1;\r
+                       minor=4;\r
+               }\r
        }\r
        else\r
        {\r
-               db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,1);");\r
+               db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,4);");\r
        }\r
 \r
-       db->Execute("UPDATE tblDBVersion SET Major=1, Minor=3;");\r
+       db->Execute("UPDATE tblDBVersion SET Major=1, Minor=4;");\r
 \r
        db->Execute("CREATE TABLE IF NOT EXISTS tblOption(\\r
                                Option                          TEXT UNIQUE,\\r
@@ -89,7 +95,8 @@ void SetupDB()
                                InsertingBoardList              BOOL CHECK(InsertingBoardList IN('true','false')) DEFAULT 'false',\\r
                                LastInsertedBoardList   DATETIME,\\r
                                InsertingMessageList    BOOL CHECK(InsertingMessageList IN('true','false')) DEFAULT 'false',\\r
-                               LastInsertedMessageList DATETIME\\r
+                               LastInsertedMessageList DATETIME,\\r
+                               DateCreated                             DATETIME\\r
                                );");\r
 \r
        db->Execute("CREATE TABLE IF NOT EXISTS tblLocalIdentityInserts(\\r
@@ -193,7 +200,8 @@ void SetupDB()
                                Subject                         TEXT,\\r
                                MessageUUID                     TEXT UNIQUE,\\r
                                ReplyBoardID            INTEGER,\\r
-                               Body                            TEXT\\r
+                               Body                            TEXT,\\r
+                               MessageIndex            INTEGER\\r
                                );");\r
 \r
        db->Execute("CREATE TABLE IF NOT EXISTS tblMessageReplyTo(\\r
@@ -222,6 +230,8 @@ void SetupDB()
                                Found                           BOOL CHECK(Found IN('true','false')) DEFAULT 'false'\\r
                                );");\r
 \r
+       db->Execute("CREATE UNIQUE INDEX IF NOT EXISTS idxMessageRequest ON tblMessageRequests(IdentityID,Day,RequestIndex);");\r
+\r
        db->Execute("CREATE TABLE IF NOT EXISTS tblMessageInserts(\\r
                                LocalIdentityID         INTEGER,\\r
                                Day                                     DATE,\\r
@@ -437,6 +447,19 @@ void ConvertDB0101To0103()
        db->Execute("UPDATE tblDBVersion SET Major=1, Minor=3;");\r
 }\r
 \r
+void ConvertDB0103To0104()\r
+{\r
+       // add MessageIndex to tblMessage\r
+       DateTime date;\r
+       SQLite3DB::DB *db=SQLite3DB::DB::Instance();\r
+       db->Execute("ALTER TABLE tblMessage ADD COLUMN MessageIndex     INTEGER;");\r
+       db->Execute("CREATE UNIQUE INDEX IF NOT EXISTS idxMessageRequest ON tblMessageRequests(IdentityID,Day,RequestIndex);");\r
+       db->Execute("ALTER TABLE tblLocalIdentity ADD COLUMN DateCreated DATETIME;");\r
+       date.SetToGMTime();\r
+       db->Execute("UPDATE tblLocalIdentity SET DateCreated='"+date.Format("%Y-%m-%d %H:%M:%S")+"' WHERE DateCreated IS NULL;");\r
+       db->Execute("UPDATE tblDBVersion SET Major=1, Minor=4;");\r
+}\r
+\r
 void SetupDefaultOptions()\r
 {\r
        // OptionValue should always be inserted as a string, even if the option really isn't a string - just to keep the field data type consistent\r
index 8d10aa6..f143d32 100644 (file)
@@ -177,7 +177,7 @@ const std::string BoardsPage::GeneratePage(const std::string &method, const std:
 \r
        content+="<tr><td colspan=\"3\"><hr><form name=\"frmboards\" method=\"POST\"><input type=\"hidden\" name=\"formaction\" value=\"update\"></td></tr>";\r
        content+="<tr>";\r
-       content+="<th>Name</th><th>Description</th><th>Save Received Messages</th>";\r
+       content+="<th>Name</th><th>Description</th><th>Save Received Messages *</th>";\r
        content+="</tr>";       \r
        while(st.RowReturned() && rownum<rowsperpage)\r
        {\r
@@ -241,6 +241,9 @@ const std::string BoardsPage::GeneratePage(const std::string &method, const std:
        content+="<td colspan=\"3\"><center><input type=\"submit\" value=\"Update\"></center></form></td>";\r
        content+="</tr>";\r
        content+="</table>";\r
+       content+="<p class=\"paragraph\">";\r
+       content+="* If you uncheck this box, any new messages you download that are posted to this board will be discarded.";\r
+       content+="</p>";\r
 \r
        return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content);\r
 }\r
index 2c55c02..c28fa64 100644 (file)
@@ -1,5 +1,6 @@
 #include "../../../include/http/pages/createidentitypage.h"\r
 #include "../../../include/stringfunctions.h"\r
+#include "../../../include/datetime.h"\r
 \r
 #ifdef XMEM\r
        #include <xmem.h>\r
@@ -11,8 +12,10 @@ const std::string CreateIdentityPage::GeneratePage(const std::string &method, co
 \r
        if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="create")\r
        {\r
-               SQLite3DB::Statement st=m_db->Prepare("INSERT INTO tblLocalIdentity(Name,PublishTrustList) VALUES(?,'true');");\r
+               SQLite3DB::Statement st=m_db->Prepare("INSERT INTO tblLocalIdentity(Name,PublishTrustList,DateCreated) VALUES(?,'true',?);");\r
                std::string name="";\r
+               DateTime date;\r
+               date.SetToGMTime();\r
 \r
                if(queryvars.find("name")!=queryvars.end())\r
                {\r
@@ -20,6 +23,7 @@ const std::string CreateIdentityPage::GeneratePage(const std::string &method, co
                }\r
 \r
                st.Bind(0,name);\r
+               st.Bind(1,date.Format("%Y-%m-%d %H:%M:%S"));\r
                st.Step();\r
 \r
                content+="<h2>Created Identity</h2>";\r
index 83b1b34..7f06fd2 100644 (file)
@@ -9,35 +9,70 @@ const std::string PeerDetailsPage::GeneratePage(const std::string &method, const
 {\r
        std::string content="";\r
        int identityid=0;\r
+       std::string identityidstr="";\r
        std::string name;\r
        std::string publickey;\r
        std::string messagetrust;\r
        std::string trustlisttrust;\r
        std::string keypart="";\r
        std::string lastseen="";\r
+       std::string dateadded="";\r
 \r
        if(queryvars.find("identityid")!=queryvars.end() && (*queryvars.find("identityid")).second!="")\r
        {\r
+               identityidstr=(*queryvars.find("identityid")).second;\r
                StringFunctions::Convert((*queryvars.find("identityid")).second,identityid);\r
        }\r
 \r
-       SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey,LastSeen FROM tblIdentity WHERE IdentityID=?;");\r
+       if(identityid!=0 && queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="deletemessages")\r
+       {\r
+               SQLite3DB::Statement del=m_db->Prepare("DELETE FROM tblMessage WHERE IdentityID=?;");\r
+               del.Bind(0,identityid);\r
+               del.Step();\r
+       }\r
+\r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey,DateAdded,LastSeen FROM tblIdentity WHERE IdentityID=?;");\r
        st.Bind(0,identityid);\r
        st.Step();\r
 \r
+       content+="<table>";\r
        if(st.RowReturned())\r
        {\r
                st.ResultText(0,name);\r
                st.ResultText(1,publickey);\r
-               st.ResultText(2,lastseen);\r
+               st.ResultText(2,dateadded);\r
+               st.ResultText(3,lastseen);\r
 \r
-               content+="<table>";\r
                content+="<tr><td>Name</td><td>"+SanitizeOutput(name)+"</td></tr>";\r
-               content+="<tr><td>Public Key</td><td>"+SanitizeOutput(publickey)+"</td></tr>";\r
+               content+="<tr><td>Public Key</td><td class=\"smaller\">"+SanitizeOutput(publickey)+"</td></tr>";\r
+               content+="<tr><td>Date Added</td><td>"+dateadded+"</td></tr>";\r
                content+="<tr><td>Last Seen</td><td>"+lastseen+"</td></tr>";\r
-               content+="</table>";\r
        }\r
 \r
+       // get message count posted by this identity\r
+       st=m_db->Prepare("SELECT COUNT(MessageID) FROM tblMessage WHERE IdentityID=?;");\r
+       st.Bind(0,identityid);\r
+       st.Step();\r
+\r
+       if(st.RowReturned())\r
+       {\r
+               std::string messagecountstr="0";\r
+               st.ResultText(0,messagecountstr);\r
+               content+="<tr>";\r
+               content+="<td>Message Count</td>";\r
+               content+="<td>"+messagecountstr;\r
+               content+="&nbsp;&nbsp;<form name=\"frmdeletemessages\" method=\"POST\">";\r
+               content+="<input type=\"hidden\" name=\"identityid\" value=\""+identityidstr+"\">";\r
+               content+="<input type=\"hidden\" name=\"formaction\" value=\"deletemessages\">";\r
+               content+="<input type=\"submit\" value=\"Delete Messages\">";\r
+               content+="</form>";\r
+               content+="</td>";\r
+               content+="</tr>";\r
+       }\r
+\r
+       content+="</table>";\r
+\r
+\r
        st=m_db->Prepare("SELECT Name,PublicKey,MessageTrust,TrustListTrust,tblIdentity.IdentityID FROM tblPeerTrust INNER JOIN tblIdentity ON tblPeerTrust.TargetIdentityID=tblIdentity.IdentityID WHERE tblPeerTrust.IdentityID=? ORDER BY Name COLLATE NOCASE;");\r
        st.Bind(0,identityid);\r
        st.Step();\r
index d8adc87..f4a6ea6 100644 (file)
@@ -630,6 +630,7 @@ const bool Message::StartFreenetInsert()
        xml.SetDate(m_datetime.Format("%Y-%m-%d"));\r
        xml.SetTime(m_datetime.Format("%H:%M:%S"));\r
        \r
+       StripAdministrationBoards();\r
        for(std::vector<std::string>::iterator i=m_boards.begin(); i!=m_boards.end(); i++)\r
        {\r
                xml.AddBoard((*i));\r
@@ -678,3 +679,22 @@ const bool Message::StartFreenetInsert()
        return true;\r
 \r
 }\r
+\r
+void Message::StripAdministrationBoards()\r
+{\r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT tblBoard.BoardID FROM tblBoard INNER JOIN tblAdministrationBoard ON tblBoard.BoardID=tblAdministrationBoard.BoardID WHERE BoardName=?;");\r
+       for(std::vector<std::string>::iterator i=m_boards.begin(); i!=m_boards.end(); )\r
+       {\r
+               st.Bind(0,(*i));\r
+               st.Step();\r
+               if(st.RowReturned())\r
+               {\r
+                       i=m_boards.erase(i);\r
+               }\r
+               else\r
+               {\r
+                       i++;\r
+               }\r
+               st.Reset();\r
+       }\r
+}\r
index fa35f4f..cc5cffe 100644 (file)
@@ -317,7 +317,7 @@ const bool NNTPConnection::HandleListCommand(const NNTPCommand &command)
                                show=uwildmat((*i).GetBoardName().c_str(),arg2.c_str());\r
                        }\r
 \r
-                       if(show==true)\r
+                       if(show==true && (*i).GetSaveReceivedMessages()==true)\r
                        {\r
                                tempstr << (*i).GetBoardName() << " " << (*i).GetHighMessageID() << " " << (*i).GetLowMessageID() << " " << (m_status.m_allowpost ? "y" : "n");\r
                                SendBufferedLine(tempstr.str());\r
@@ -348,7 +348,7 @@ const bool NNTPConnection::HandleListCommand(const NNTPCommand &command)
                                show=uwildmat((*i).GetBoardName().c_str(),arg2.c_str());\r
                        }\r
 \r
-                       if(show==true)\r
+                       if(show==true && (*i).GetSaveReceivedMessages()==true)\r
                        {\r
                                tempstr << (*i).GetBoardName() << "\t" << (*i).GetBoardDescription();\r
                                SendBufferedLine(tempstr.str());\r
@@ -559,9 +559,12 @@ const bool NNTPConnection::HandleNewGroupsCommand(const NNTPCommand &command)
 \r
                for(BoardList::iterator i=bl.begin(); i!=bl.end(); i++)\r
                {\r
-                       std::ostringstream tempstr;\r
-                       tempstr << (*i).GetBoardName() << " " << (*i).GetHighMessageID() << " " << (*i).GetLowMessageID() << " " << m_status.m_allowpost ? "y" : "n";\r
-                       SendBufferedLine(tempstr.str());\r
+                       if((*i).GetSaveReceivedMessages()==true)\r
+                       {\r
+                               std::ostringstream tempstr;\r
+                               tempstr << (*i).GetBoardName() << " " << (*i).GetHighMessageID() << " " << (*i).GetLowMessageID() << " " << m_status.m_allowpost ? "y" : "n";\r
+                               SendBufferedLine(tempstr.str());\r
+                       }\r
                }\r
 \r
                SendBufferedLine(".");\r
@@ -784,16 +787,13 @@ void NNTPConnection::HandlePostedMessage(const std::string &message)
                {\r
                        mess.HandleAdministrationMessage();\r
                }\r
+               if(mess.StartFreenetInsert())\r
+               {\r
+                       SendBufferedLine("240 Article received OK");\r
+               }\r
                else\r
                {\r
-                       if(mess.StartFreenetInsert())\r
-                       {\r
-                               SendBufferedLine("240 Article received OK");\r
-                       }\r
-                       else\r
-                       {\r
-                               SendBufferedLine("441 Posting failed.  Make sure the identity you are sending with exists!");\r
-                       }\r
+                       SendBufferedLine("441 Posting failed.  Make sure the identity you are sending with exists!");\r
                }\r
        }\r
        else\r
index bed3622..bd757aa 100644 (file)
@@ -9,6 +9,12 @@
 namespace StringFunctions\r
 {\r
 \r
+void LowerCase(const std::string &str, std::string &output)\r
+{\r
+       output=str;\r
+       std::transform(str.begin(),str.end(),output.begin(),tolower);\r
+}\r
+\r
 std::string Replace(const std::string &input, const std::string &find, const std::string &replace)\r
 {\r
        std::string returnstr=input;\r