From 76805933f794915a72b7f0a21b12af6654759f4f Mon Sep 17 00:00:00 2001
From: SomeDude
Date: Sun, 29 Jun 2008 19:26:00 +0200
Subject: [PATCH] version 0.3.2
---
CMakeLists.txt | 2 +
include/freenet/fmsversionrequester.h | 37 ++++++
include/freenet/fmsversionxml.h | 36 ++++++
include/global.h | 5 +-
include/ifmsxmldocument.h | 24 ++--
src/dbmaintenancethread.cpp | 3 +
src/dbsetup.cpp | 14 +-
src/freenet/boardlistxml.cpp | 70 +---------
src/freenet/fmsversionrequester.cpp | 176 +++++++++++++++++++++++++
src/freenet/fmsversionxml.cpp | 104 +++++++++++++++
src/freenet/freenetmasterthread.cpp | 2 +
src/freenet/identityintroductionrequester.cpp | 7 +-
src/freenet/identityintroductionxml.cpp | 44 +------
src/freenet/identityxml.cpp | 61 +--------
src/freenet/introductionpuzzlexml.cpp | 59 +--------
src/freenet/messagelistxml.cpp | 150 +---------------------
src/freenet/messagexml.cpp | 178 ++------------------------
src/freenet/trustlistxml.cpp | 109 +---------------
src/http/httpthread.cpp | 5 +-
src/http/identityexportxml.cpp | 96 +-------------
src/http/pages/createidentitypage.cpp | 3 +
src/http/pages/homepage.cpp | 34 ++++-
src/ipaddressacl.cpp | 15 ++-
src/optionssetup.cpp | 23 ++++
src/threadwrapper/threadedexector.cpp | 6 +-
25 files changed, 498 insertions(+), 765 deletions(-)
create mode 100644 include/freenet/fmsversionrequester.h
create mode 100644 include/freenet/fmsversionxml.h
create mode 100644 src/freenet/fmsversionrequester.cpp
create mode 100644 src/freenet/fmsversionxml.cpp
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 56d8174..03af9bd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -46,6 +46,8 @@ src/freenet/boardlistxml.cpp
src/freenet/captcha
src/freenet/fcpv2.cpp
src/freenet/fileinserter.cpp
+src/freenet/fmsversionrequester.cpp
+src/freenet/fmsversionxml.cpp
src/freenet/freenetmasterthread.cpp
src/freenet/freenetssk.cpp
src/freenet/identityinserter.cpp
diff --git a/include/freenet/fmsversionrequester.h b/include/freenet/fmsversionrequester.h
new file mode 100644
index 0000000..6a6d5f7
--- /dev/null
+++ b/include/freenet/fmsversionrequester.h
@@ -0,0 +1,37 @@
+#ifndef _fmsversionrequester_
+#define _fmsversionrequester_
+
+#include "ifreenetregistrable.h"
+#include "ifcpconnected.h"
+#include "ifcpmessagehandler.h"
+#include "iperiodicprocessor.h"
+#include "../idatabase.h"
+#include "../ilogger.h"
+
+#include
+
+class FMSVersionRequester:public IFreenetRegistrable,public IFCPConnected,public IFCPMessageHandler,public IPeriodicProcessor,public IDatabase,public ILogger
+{
+public:
+ FMSVersionRequester();
+ FMSVersionRequester(FCPv2 *fcp);
+
+ void FCPConnected() {}
+ void FCPDisconnected() {}
+ const bool HandleMessage(FCPMessage &message);
+
+ void Process();
+
+ void RegisterWithThread(FreenetMasterThread *thread);
+
+private:
+ const bool HandleAllData(FCPMessage &message);
+ const bool HandleGetFailed(FCPMessage &message);
+ void Initialize();
+ void StartRequest();
+
+ Poco::DateTime m_lastchecked;
+ std::string m_fcpuniquename;
+};
+
+#endif // _fmsversionrequester_
diff --git a/include/freenet/fmsversionxml.h b/include/freenet/fmsversionxml.h
new file mode 100644
index 0000000..5219bb0
--- /dev/null
+++ b/include/freenet/fmsversionxml.h
@@ -0,0 +1,36 @@
+#ifndef _fmsversionxml_
+#define _fmsversionxml_
+
+#include "../ifmsxmldocument.h"
+
+class FMSVersionXML:public IFMSXMLDocument
+{
+public:
+ FMSVersionXML();
+
+ std::string GetXML();
+
+ const bool ParseXML(const std::string &xml);
+
+ const int GetMajor() { return m_major; }
+ const int GetMinor() { return m_minor; }
+ const int GetRelease() { return m_release; }
+ const std::string GetNotes() { return m_notes; }
+ const std::string GetChanges() { return m_changes; }
+ const std::string GetPageKey() { return m_pagekey; }
+ const std::string GetSourceKey() { return m_sourcekey; }
+
+private:
+ void Initialize();
+
+ int m_major;
+ int m_minor;
+ int m_release;
+ std::string m_notes;
+ std::string m_changes;
+ std::string m_pagekey;
+ std::string m_sourcekey;
+
+};
+
+#endif // _fmsversionxml_
diff --git a/include/global.h b/include/global.h
index 1576e55..d6ba0df 100644
--- a/include/global.h
+++ b/include/global.h
@@ -5,7 +5,10 @@
#include
#include
-#define FMS_VERSION "0.3.0"
+#define VERSION_MAJOR "0"
+#define VERSION_MINOR "3"
+#define VERSION_RELEASE "2"
+#define FMS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_RELEASE
typedef Poco::ScopedLock Guard;
diff --git a/include/ifmsxmldocument.h b/include/ifmsxmldocument.h
index 6358e8f..ae3f4e6 100644
--- a/include/ifmsxmldocument.h
+++ b/include/ifmsxmldocument.h
@@ -77,12 +77,12 @@ protected:
/**
\brief Creates and returns an element with a boolean value
*/
- virtual Poco::XML::Element *XMLCreateBooleanElement(Poco::XML::Document *doc, const std::string &name, const bool value)
+ virtual Poco::AutoPtr XMLCreateBooleanElement(Poco::AutoPtr doc, const std::string &name, const bool value)
{
if(doc)
{
- Poco::XML::Text *txt=doc->createTextNode(value ? "true" : "false");
- Poco::XML::Element *el=doc->createElement(name);
+ Poco::AutoPtr txt=doc->createTextNode(value ? "true" : "false");
+ Poco::AutoPtr el=doc->createElement(name);
el->appendChild(txt);
return el;
}
@@ -95,15 +95,15 @@ protected:
/**
\brief Creates and returns an element with a CDATA value
*/
- virtual Poco::XML::Element *XMLCreateCDATAElement(Poco::XML::Document *doc, const std::string &name, const std::string &data)
+ virtual Poco::AutoPtr XMLCreateCDATAElement(Poco::AutoPtr doc, const std::string &name, const std::string &data)
{
if(doc)
{
// Poco XML won't break up CDATA sections correctly when assigned a string with the
// end tag is present. However, it will parse it correctly, so we will manually break the
// CDATA into separate parts
- Poco::XML::CDATASection *sec=doc->createCDATASection(StringFunctions::Replace(data,"]]>","]]]>"));
- Poco::XML::Element *el=doc->createElement(name);
+ Poco::AutoPtr sec=doc->createCDATASection(StringFunctions::Replace(data,"]]>","]]]>"));
+ Poco::AutoPtr el=doc->createElement(name);
el->appendChild(sec);
return el;
}
@@ -116,12 +116,12 @@ protected:
/**
\brief Creates and returns a text element
*/
- virtual Poco::XML::Element *XMLCreateTextElement(Poco::XML::Document *doc, const std::string &name, const std::string &data)
+ virtual Poco::AutoPtr XMLCreateTextElement(Poco::AutoPtr doc, const std::string &name, const std::string &data)
{
if(doc)
{
- Poco::XML::Text *txt=doc->createTextNode(data);
- Poco::XML::Element *el=doc->createElement(name);
+ Poco::AutoPtr txt=doc->createTextNode(data);
+ Poco::AutoPtr el=doc->createElement(name);
el->appendChild(txt);
return el;
}
@@ -131,7 +131,7 @@ protected:
}
}
- virtual Poco::XML::Element *XMLCreateTextElement(Poco::XML::Document *doc, const std::string &name, const long data)
+ virtual Poco::AutoPtr XMLCreateTextElement(Poco::AutoPtr doc, const std::string &name, const long data)
{
if(doc)
{
@@ -171,6 +171,7 @@ protected:
{
child=child->nextSibling();
}
+ //return child.cast();
return static_cast(child);
}
else
@@ -188,6 +189,7 @@ protected:
{
next=next->nextSibling();
}
+ //return next.cast();
return static_cast(next);
}
else
@@ -207,7 +209,7 @@ protected:
return returntext;
}
- const std::string GenerateXML(Poco::XML::Document *doc)
+ const std::string GenerateXML(Poco::AutoPtr doc)
{
std::ostringstream str;
if(doc)
diff --git a/src/dbmaintenancethread.cpp b/src/dbmaintenancethread.cpp
index 0309414..b613715 100644
--- a/src/dbmaintenancethread.cpp
+++ b/src/dbmaintenancethread.cpp
@@ -95,6 +95,9 @@ void DBMaintenanceThread::Do1HourMaintenance()
st.Step();
}
+ // insert all identities not in trust list already
+ m_db->Execute("INSERT INTO tblIdentityTrust(LocalIdentityID,IdentityID) SELECT LocalIdentityID,IdentityID FROM tblLocalIdentity,tblIdentity WHERE LocalIdentityID || '_' || IdentityID NOT IN (SELECT LocalIdentityID || '_' || IdentityID FROM tblIdentityTrust);");
+
m_log->debug("PeriodicDBMaintenance::Do1HourMaintenance");
}
diff --git a/src/dbsetup.cpp b/src/dbsetup.cpp
index bc197cc..68ee676 100644
--- a/src/dbsetup.cpp
+++ b/src/dbsetup.cpp
@@ -15,7 +15,7 @@ void SetupDB()
SQLite3DB::DB *db=SQLite3DB::DB::Instance();
db->Open("fms.db3");
- db->SetBusyTimeout(10000); // set timeout to 10 seconds
+ db->SetBusyTimeout(20000); // set timeout to 20 seconds
tempval="";
Option::Instance()->Get("VacuumOnStartup",tempval);
@@ -112,6 +112,18 @@ void SetupDB()
db->Execute("UPDATE tblDBVersion SET Major=1, Minor=12;");
+ db->Execute("CREATE TABLE IF NOT EXISTS tblFMSVersion(\
+ Major INTEGER,\
+ Minor INTEGER,\
+ Release INTEGER,\
+ Notes TEXT,\
+ Changes TEXT,\
+ PageKey TEXT,\
+ SourceKey TEXT\
+ );");
+
+ db->Execute("CREATE UNIQUE INDEX IF NOT EXISTS idxFMSVersion_Version ON tblFMSVersion(Major,Minor,Release);");
+
db->Execute("CREATE TABLE IF NOT EXISTS tblOption(\
Option TEXT UNIQUE,\
OptionValue TEXT NOT NULL,\
diff --git a/src/freenet/boardlistxml.cpp b/src/freenet/boardlistxml.cpp
index b4c3985..55d877b 100644
--- a/src/freenet/boardlistxml.cpp
+++ b/src/freenet/boardlistxml.cpp
@@ -50,33 +50,20 @@ const std::string BoardListXML::GetName(const long index)
std::string BoardListXML::GetXML()
{
Poco::AutoPtr doc=new Poco::XML::Document;
- //TiXmlDocument td;
- //TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8","");
- Poco::XML::Element *root=doc->createElement("BoardList");
- //TiXmlElement *tid;
- //TiXmlPrinter tp;
+ Poco::AutoPtr root=doc->createElement("BoardList");
doc->appendChild(root);
- //td.LinkEndChild(tdec);
- //tid=new TiXmlElement("BoardList");
- //td.LinkEndChild(tid);
for(std::vector::iterator i=m_boards.begin(); i!=m_boards.end(); i++)
{
std::string boardname=(*i).m_name;
StringFunctions::LowerCase(boardname,boardname);
- Poco::XML::Element *tr=doc->createElement("Board");
- //TiXmlElement *tr=new TiXmlElement("Board");
+ Poco::AutoPtr tr=doc->createElement("Board");
root->appendChild(tr);
- //tid->LinkEndChild(tr);
tr->appendChild(XMLCreateCDATAElement(doc,"Name",boardname));
- //tr->LinkEndChild(XMLCreateCDATAElement("Name",boardname));
tr->appendChild(XMLCreateCDATAElement(doc,"Description",(*i).m_description));
- //tr->LinkEndChild(XMLCreateCDATAElement("Description",(*i).m_description));
}
- //td.Accept(&tp);
- //return std::string(tp.CStr());
return GenerateXML(doc);
}
@@ -136,57 +123,4 @@ const bool BoardListXML::ParseXML(const std::string &xml)
}
return parsed;
-
- /*
- std::string name;
- std::string description;
- TiXmlDocument td;
- td.Parse(xml.c_str());
-
- if(!td.Error())
- {
- TiXmlText *txt;
- TiXmlHandle hnd(&td);
- TiXmlNode *node;
-
- Initialize();
-
- node=hnd.FirstChild("BoardList").FirstChild("Board").ToElement();
- while(node)
- {
- name="";
- description="";
-
- TiXmlHandle hnd2(node);
- txt=hnd2.FirstChild("Name").FirstChild().ToText();
- if(txt)
- {
- name=txt->ValueStr();
- StringFunctions::LowerCase(name,name);
- if(name.size()>40)
- {
- name.erase(40);
- }
- }
- txt=hnd2.FirstChild("Description").FirstChild().ToText();
- if(txt)
- {
- description=txt->ValueStr();
- }
-
- if(name!="" && description!="")
- {
- m_boards.push_back(board(name,description));
- }
-
- node=node->NextSibling("Board");
- }
- return true;
-
- }
- else
- {
- return false;
- }
- */
}
diff --git a/src/freenet/fmsversionrequester.cpp b/src/freenet/fmsversionrequester.cpp
new file mode 100644
index 0000000..027d530
--- /dev/null
+++ b/src/freenet/fmsversionrequester.cpp
@@ -0,0 +1,176 @@
+#include "../../include/freenet/fmsversionrequester.h"
+#include "../../include/freenet/fmsversionxml.h"
+#include "../../include/option.h"
+#include "../../include/stringfunctions.h"
+
+#include
+#include
+
+FMSVersionRequester::FMSVersionRequester()
+{
+ Initialize();
+}
+
+FMSVersionRequester::FMSVersionRequester(FCPv2 *fcp):IFCPConnected(fcp)
+{
+ Initialize();
+}
+
+const bool FMSVersionRequester::HandleAllData(FCPMessage &message)
+{
+ std::vector data;
+ long datalength;
+ FMSVersionXML xml;
+
+ StringFunctions::Convert(message["DataLength"],datalength);
+
+ // wait for all data to be received from connection
+ while(m_fcp->Connected() && m_fcp->ReceiveBufferSize()Update(1);
+ }
+
+ // if we got disconnected- return immediately
+ if(m_fcp->Connected()==false)
+ {
+ return false;
+ }
+
+ // receive the file
+ data.resize(datalength);
+ m_fcp->ReceiveRaw(&data[0],datalength);
+
+ // update latest edition #
+ std::vector parts;
+ StringFunctions::Split(message["Identifier"],"/",parts);
+ if(parts.size()>2)
+ {
+ std::string editionstr=parts[2];
+ Option::Instance()->Set("FMSVersionEdition",editionstr);
+ }
+
+ // parse file into xml and update the database
+ if(xml.ParseXML(std::string(data.begin(),data.end()))==true)
+ {
+
+ SQLite3DB::Statement st=m_db->Prepare("REPLACE INTO tblFMSVersion(Major,Minor,Release,Notes,Changes,PageKey,SourceKey) VALUES(?,?,?,?,?,?,?);");
+ st.Bind(0,xml.GetMajor());
+ st.Bind(1,xml.GetMinor());
+ st.Bind(2,xml.GetRelease());
+ st.Bind(3,xml.GetNotes());
+ st.Bind(4,xml.GetChanges());
+ st.Bind(5,xml.GetPageKey());
+ st.Bind(6,xml.GetSourceKey());
+ st.Step();
+
+ m_log->debug("FMSVersionRequester::HandleAllData parsed FMSVersion XML file : "+message["Identifier"]);
+ }
+ else
+ {
+ m_log->error("FMSVersionRequester::HandleAllData error parsing FMSVersion XML file : "+message["Identifier"]);
+ }
+
+ return true;
+}
+
+const bool FMSVersionRequester::HandleGetFailed(FCPMessage &message)
+{
+ std::vector parts;
+ StringFunctions::Split(message["Identifier"],"/",parts);
+
+ // fatal error - don't try to download again
+ if(message["Fatal"]=="true")
+ {
+ if(parts.size()>2)
+ {
+ std::string editionstr=parts[2];
+ Option::Instance()->Set("FMSVersionEdition",editionstr);
+ }
+ m_log->debug("FMSVersionRequester::HandleGetFailed Fatal GetFailed for "+message["Identifier"]);
+ }
+
+ return true;
+}
+
+const bool FMSVersionRequester::HandleMessage(FCPMessage &message)
+{
+ if(message["Identifier"].find(m_fcpuniquename)==0)
+ {
+
+ // ignore DataFound
+ if(message.GetName()=="DataFound")
+ {
+ return true;
+ }
+
+ if(message.GetName()=="AllData")
+ {
+ return HandleAllData(message);
+ }
+
+ if(message.GetName()=="GetFailed")
+ {
+ return HandleGetFailed(message);
+ }
+
+ if(message.GetName()=="IdentifierCollision")
+ {
+ return true;
+ }
+
+ }
+
+ return false;
+}
+
+void FMSVersionRequester::Initialize()
+{
+ m_fcpuniquename="FMSVersionRequester";
+ m_lastchecked=Poco::Timestamp();
+ m_lastchecked-=Poco::Timespan(0,6,0,0,0);
+}
+
+void FMSVersionRequester::Process()
+{
+ Poco::DateTime now;
+
+ // check every 6 hours
+ if((m_lastchecked+Poco::Timespan(0,5,45,0,0))<=now)
+ {
+ StartRequest();
+ m_lastchecked=now;
+ }
+}
+
+void FMSVersionRequester::RegisterWithThread(FreenetMasterThread *thread)
+{
+ thread->RegisterFCPConnected(this);
+ thread->RegisterFCPMessageHandler(this);
+ thread->RegisterPeriodicProcessor(this);
+}
+
+void FMSVersionRequester::StartRequest()
+{
+ FCPMessage message;
+ std::string key="";
+ std::string editionstr="0";
+ int edition=0;
+
+ Option::Instance()->Get("FMSVersionKey",key);
+ if(Option::Instance()->Get("FMSVersionEdition",editionstr))
+ {
+ StringFunctions::Convert(editionstr,edition);
+ edition++;
+ StringFunctions::Convert(edition,editionstr);
+ }
+
+ //start request
+ message.SetName("ClientGet");
+ message["URI"]=key+editionstr+"/FMSVersion.xml";
+ message["Identifier"]=m_fcpuniquename+"|"+message["URI"];
+ message["ReturnType"]="direct";
+ message["MaxSize"]="30000"; // 30K
+
+ m_fcp->SendMessage(message);
+
+}
diff --git a/src/freenet/fmsversionxml.cpp b/src/freenet/fmsversionxml.cpp
new file mode 100644
index 0000000..655faa5
--- /dev/null
+++ b/src/freenet/fmsversionxml.cpp
@@ -0,0 +1,104 @@
+#include "../../include/freenet/fmsversionxml.h"
+
+FMSVersionXML::FMSVersionXML()
+{
+ Initialize();
+}
+
+std::string FMSVersionXML::GetXML()
+{
+ Poco::AutoPtr doc=new Poco::XML::Document;
+ Poco::AutoPtr root=doc->createElement("FMSVersion");
+
+ doc->appendChild(root);
+
+ root->appendChild(XMLCreateTextElement(doc,"Major",m_major));
+
+ root->appendChild(XMLCreateTextElement(doc,"Minor",m_minor));
+
+ root->appendChild(XMLCreateTextElement(doc,"Release",m_release));
+
+ root->appendChild(XMLCreateCDATAElement(doc,"Notes",m_notes));
+
+ root->appendChild(XMLCreateCDATAElement(doc,"Changes",m_changes));
+
+ root->appendChild(XMLCreateCDATAElement(doc,"PageKey",m_pagekey));
+
+ root->appendChild(XMLCreateCDATAElement(doc,"SourceKey",m_sourcekey));
+
+ return GenerateXML(doc);
+}
+
+void FMSVersionXML::Initialize()
+{
+ m_major=0;
+ m_minor=0;
+ m_release=0;
+ m_notes="";
+ m_changes="";
+ m_pagekey="";
+ m_sourcekey="";
+}
+
+const bool FMSVersionXML::ParseXML(const std::string &xml)
+{
+
+ bool parsed=false;
+ Poco::XML::DOMParser dp;
+
+ Initialize();
+
+ try
+ {
+ Poco::AutoPtr doc=dp.parseString(FixCDATA(xml));
+ Poco::XML::Element *root=XMLGetFirstChild(doc,"FMSVersion");
+ Poco::XML::Element *txt=NULL;
+
+ txt=XMLGetFirstChild(root,"Major");
+ if(txt && txt->firstChild())
+ {
+ std::string tempstr=txt->firstChild()->getNodeValue();
+ StringFunctions::Convert(tempstr,m_major);
+ }
+ txt=XMLGetFirstChild(root,"Minor");
+ if(txt && txt->firstChild())
+ {
+ std::string tempstr=txt->firstChild()->getNodeValue();
+ StringFunctions::Convert(tempstr,m_minor);
+ }
+ txt=XMLGetFirstChild(root,"Release");
+ if(txt && txt->firstChild())
+ {
+ std::string tempstr=txt->firstChild()->getNodeValue();
+ StringFunctions::Convert(tempstr,m_release);
+ }
+ txt=XMLGetFirstChild(root,"Notes");
+ if(txt && txt->firstChild())
+ {
+ m_notes=txt->firstChild()->getNodeValue();
+ }
+ txt=XMLGetFirstChild(root,"Changes");
+ if(txt && txt->firstChild())
+ {
+ m_changes=txt->firstChild()->getNodeValue();
+ }
+ txt=XMLGetFirstChild(root,"PageKey");
+ if(txt && txt->firstChild())
+ {
+ m_pagekey=txt->firstChild()->getNodeValue();
+ }
+ txt=XMLGetFirstChild(root,"SourceKey");
+ if(txt && txt->firstChild())
+ {
+ m_sourcekey=txt->firstChild()->getNodeValue();
+ }
+
+ parsed=true;
+
+ }
+ catch(...)
+ {
+ }
+
+ return parsed;
+}
diff --git a/src/freenet/freenetmasterthread.cpp b/src/freenet/freenetmasterthread.cpp
index 9e0670c..4d16043 100644
--- a/src/freenet/freenetmasterthread.cpp
+++ b/src/freenet/freenetmasterthread.cpp
@@ -18,6 +18,7 @@
#include "../../include/freenet/boardlistrequester.h"
#include "../../include/freenet/siteinserter.h"
#include "../../include/freenet/fileinserter.h"
+#include "../../include/freenet/fmsversionrequester.h"
#include
#include
@@ -297,6 +298,7 @@ void FreenetMasterThread::Setup()
m_registrables.push_back(new BoardListRequester(&m_fcp));
m_registrables.push_back(new SiteInserter(&m_fcp));
m_registrables.push_back(new FileInserter(&m_fcp));
+ m_registrables.push_back(new FMSVersionRequester(&m_fcp));
for(std::vector::iterator i=m_registrables.begin(); i!=m_registrables.end(); i++)
{
diff --git a/src/freenet/identityintroductionrequester.cpp b/src/freenet/identityintroductionrequester.cpp
index 7def9f2..6552770 100644
--- a/src/freenet/identityintroductionrequester.cpp
+++ b/src/freenet/identityintroductionrequester.cpp
@@ -277,7 +277,6 @@ void IdentityIntroductionRequester::StartRequest(const std::string &UUID)
{
std::string day;
std::string solution;
-// std::vector solutionhash;
std::string encodedhash;
FCPMessage message;
SQLite3DB::Statement st=m_db->Prepare("SELECT Day, PuzzleSolution FROM tblIntroductionPuzzleInserts WHERE FoundSolution='false' AND UUID=?;");
@@ -289,16 +288,12 @@ void IdentityIntroductionRequester::StartRequest(const std::string &UUID)
st.ResultText(0,day);
st.ResultText(1,solution);
+ // get the hash of the solution
Poco::SHA1Engine sha1;
sha1.update(solution);
encodedhash=Poco::DigestEngine::digestToHex(sha1.digest());
StringFunctions::UpperCase(encodedhash,encodedhash);
- // get the hash of the solution
-// solutionhash.resize(20);
-// sha1((unsigned char *)solution.c_str(),solution.size(),&solutionhash[0]);
-// Hex::Encode(solutionhash,encodedhash);
-
//start request for the solution
message.SetName("ClientGet");
message["URI"]="KSK@"+m_messagebase+"|"+day+"|"+UUID+"|"+encodedhash+".xml";
diff --git a/src/freenet/identityintroductionxml.cpp b/src/freenet/identityintroductionxml.cpp
index 82ed285..f6b8a2e 100644
--- a/src/freenet/identityintroductionxml.cpp
+++ b/src/freenet/identityintroductionxml.cpp
@@ -13,22 +13,12 @@ IdentityIntroductionXML::IdentityIntroductionXML()
std::string IdentityIntroductionXML::GetXML()
{
Poco::AutoPtr doc=new Poco::XML::Document;
- //TiXmlDocument td;
- //TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8","");
- Poco::XML::Element *root=doc->createElement("IdentityIntroduction");
- //TiXmlElement *tid;
- //TiXmlPrinter tp;
+ Poco::AutoPtr root=doc->createElement("IdentityIntroduction");
doc->appendChild(root);
- //td.LinkEndChild(tdec);
- //tid=new TiXmlElement("IdentityIntroduction");
- //td.LinkEndChild(tid);
root->appendChild(XMLCreateCDATAElement(doc,"Identity",m_identity));
- //tid->LinkEndChild(XMLCreateCDATAElement("Identity",m_identity));
- //td.Accept(&tp);
- //return std::string(tp.CStr());
return GenerateXML(doc);
}
@@ -73,36 +63,4 @@ const bool IdentityIntroductionXML::ParseXML(const std::string &xml)
}
return parsed;
-
- /*
- TiXmlDocument td;
- td.Parse(xml.c_str());
-
- if(!td.Error())
- {
- TiXmlText *txt;
- TiXmlHandle hnd(&td);
-
- Initialize();
-
- txt=hnd.FirstChild("IdentityIntroduction").FirstChild("Identity").FirstChild().ToText();
- if(txt)
- {
- m_identity=SanitizeSingleString(txt->ValueStr());
- }
- ssk.SetPublicKey(m_identity);
- if(ssk.ValidPublicKey()==false)
- {
- return false;
- }
-
- return true;
-
- }
- else
- {
- return false;
- }
- */
-
}
diff --git a/src/freenet/identityxml.cpp b/src/freenet/identityxml.cpp
index a440573..e30989a 100644
--- a/src/freenet/identityxml.cpp
+++ b/src/freenet/identityxml.cpp
@@ -12,39 +12,24 @@ IdentityXML::IdentityXML()
std::string IdentityXML::GetXML()
{
Poco::AutoPtr doc=new Poco::XML::Document;
- //TiXmlDocument td;
- //TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8","");
- Poco::XML::Element *root=doc->createElement("Identity");
- //TiXmlElement *tid;
- //TiXmlPrinter tp;
+ Poco::AutoPtr root=doc->createElement("Identity");
doc->appendChild(root);
- //td.LinkEndChild(tdec);
- //tid=new TiXmlElement("Identity");
- //td.LinkEndChild(tid);
root->appendChild(XMLCreateCDATAElement(doc,"Name",m_name));
- //tid->LinkEndChild(XMLCreateCDATAElement("Name",m_name));
root->appendChild(XMLCreateBooleanElement(doc,"SingleUse",m_singleuse));
- //tid->LinkEndChild(XMLCreateBooleanElement("SingleUse",m_singleuse));
root->appendChild(XMLCreateBooleanElement(doc,"PublishTrustList",m_publishtrustlist));
- //tid->LinkEndChild(XMLCreateBooleanElement("PublishTrustList",m_publishtrustlist));
root->appendChild(XMLCreateBooleanElement(doc,"PublishBoardList",m_publishboardlist));
- //tid->LinkEndChild(XMLCreateBooleanElement("PublishBoardList",m_publishboardlist));
// freesite edition will be -1 if identity isn't publishing a freesite
if(m_freesiteedition>=0)
{
root->appendChild(XMLCreateTextElement(doc,"FreesiteEdition",m_freesiteedition));
- //tid->LinkEndChild(XMLCreateTextElement("FreesiteEdition",m_freesiteedition));
}
- //td.Accept(&tp);
- //return std::string(tp.CStr());
-
return GenerateXML(doc);
}
@@ -106,48 +91,4 @@ const bool IdentityXML::ParseXML(const std::string &xml)
}
return parsed;
-
- /*
- TiXmlDocument td;
- td.Parse(xml.c_str());
-
- if(!td.Error())
- {
- TiXmlText *txt;
- TiXmlHandle hnd(&td);
-
- Initialize();
-
- txt=hnd.FirstChild("Identity").FirstChild("Name").FirstChild().ToText();
- if(txt)
- {
- m_name=txt->ValueStr();
- }
-
- if(m_name.size()>40)
- {
- m_name.erase(40);
- }
-
- m_singleuse=XMLGetBooleanElement(hnd.FirstChild("Identity").ToElement(),"SingleUse");
-
- m_publishtrustlist=XMLGetBooleanElement(hnd.FirstChild("Identity").ToElement(),"PublishTrustList");
-
- m_publishboardlist=XMLGetBooleanElement(hnd.FirstChild("Identity").ToElement(),"PublishBoardList");
-
- txt=hnd.FirstChild("Identity").FirstChild("FreesiteEdition").FirstChild().ToText();
- if(txt)
- {
- std::string editionstr=SanitizeSingleString(txt->ValueStr());
- StringFunctions::Convert(editionstr,m_freesiteedition);
- }
-
- return true;
-
- }
- else
- {
- return false;
- }
-*/
}
diff --git a/src/freenet/introductionpuzzlexml.cpp b/src/freenet/introductionpuzzlexml.cpp
index bb45722..735ddf9 100644
--- a/src/freenet/introductionpuzzlexml.cpp
+++ b/src/freenet/introductionpuzzlexml.cpp
@@ -12,31 +12,18 @@ IntroductionPuzzleXML::IntroductionPuzzleXML()
std::string IntroductionPuzzleXML::GetXML()
{
Poco::AutoPtr doc=new Poco::XML::Document;
- //TiXmlDocument td;
- //TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8","");
- Poco::XML::Element *root=doc->createElement("IntroductionPuzzle");
- //TiXmlElement *tid;
- //TiXmlPrinter tp;
+ Poco::AutoPtr root=doc->createElement("IntroductionPuzzle");
doc->appendChild(root);
- //td.LinkEndChild(tdec);
- //tid=new TiXmlElement("IntroductionPuzzle");
- //td.LinkEndChild(tid);
root->appendChild(XMLCreateTextElement(doc,"Type",m_type));
- //tid->LinkEndChild(XMLCreateTextElement("Type",m_type));
root->appendChild(XMLCreateCDATAElement(doc,"UUID",m_uuid));
- //tid->LinkEndChild(XMLCreateCDATAElement("UUID",m_uuid));
root->appendChild(XMLCreateTextElement(doc,"MimeType",m_mimetype));
- //tid->LinkEndChild(XMLCreateTextElement("MimeType",m_mimetype));
root->appendChild(XMLCreateTextElement(doc,"PuzzleData",m_puzzledata));
- //tid->LinkEndChild(XMLCreateTextElement("PuzzleData",m_puzzledata));
- //td.Accept(&tp);
- //return std::string(tp.CStr());
return GenerateXML(doc);
}
@@ -101,48 +88,4 @@ const bool IntroductionPuzzleXML::ParseXML(const std::string &xml)
}
return parsed;
-
- /*
- TiXmlDocument td;
- td.Parse(xml.c_str());
-
- if(!td.Error())
- {
- TiXmlText *txt;
- TiXmlHandle hnd(&td);
-
- Initialize();
-
- txt=hnd.FirstChild("IntroductionPuzzle").FirstChild("Type").FirstChild().ToText();
- if(txt)
- {
- m_type=SanitizeSingleString(txt->ValueStr());
- }
-
- txt=hnd.FirstChild("IntroductionPuzzle").FirstChild("UUID").FirstChild().ToText();
- if(txt)
- {
- m_uuid=SanitizeSingleString(txt->ValueStr());
- }
-
- txt=hnd.FirstChild("IntroductionPuzzle").FirstChild("MimeType").FirstChild().ToText();
- if(txt)
- {
- m_mimetype=SanitizeSingleString(txt->ValueStr());
- }
-
- txt=hnd.FirstChild("IntroductionPuzzle").FirstChild("PuzzleData").FirstChild().ToText();
- if(txt)
- {
- m_puzzledata=txt->ValueStr();
- }
-
- return true;
-
- }
- else
- {
- return false;
- }
- */
}
diff --git a/src/freenet/messagelistxml.cpp b/src/freenet/messagelistxml.cpp
index c35e10f..eb57240 100644
--- a/src/freenet/messagelistxml.cpp
+++ b/src/freenet/messagelistxml.cpp
@@ -135,73 +135,49 @@ const long MessageListXML::GetIndex(const long index)
std::string MessageListXML::GetXML()
{
Poco::AutoPtr doc=new Poco::XML::Document;
- //TiXmlDocument td;
- //TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8","");
- Poco::XML::Element *root=doc->createElement("MessageList");
- //TiXmlElement *tid;
- //TiXmlPrinter tp;
+ Poco::AutoPtr root=doc->createElement("MessageList");
doc->appendChild(root);
- //td.LinkEndChild(tdec);
- //tid=new TiXmlElement("MessageList");
- //td.LinkEndChild(tid);
for(std::vector::iterator i=m_messages.begin(); i!=m_messages.end(); i++)
{
- Poco::XML::Element *tr=doc->createElement("Message");
- //TiXmlElement *tr=new TiXmlElement("Message");
+ Poco::AutoPtr tr=doc->createElement("Message");
root->appendChild(tr);
- //tid->LinkEndChild(tr);
tr->appendChild(XMLCreateTextElement(doc,"Date",(*i).m_date));
- //tr->LinkEndChild(XMLCreateTextElement("Date",(*i).m_date));
tr->appendChild(XMLCreateTextElement(doc,"Index",(*i).m_index));
- //tr->LinkEndChild(XMLCreateTextElement("Index",(*i).m_index));
- Poco::XML::Element *boards=doc->createElement("Boards");
- //TiXmlElement *brds=new TiXmlElement("Boards");
+
+ Poco::AutoPtr boards=doc->createElement("Boards");
tr->appendChild(boards);
- //tr->LinkEndChild(brds);
for(std::vector::iterator j=(*i).m_boards.begin(); j!=(*i).m_boards.end(); j++)
{
boards->appendChild(XMLCreateCDATAElement(doc,"Board",(*j)));
- //brds->LinkEndChild(XMLCreateCDATAElement("Board",(*j)));
}
}
for(std::vector::iterator i=m_externalmessages.begin(); i!=m_externalmessages.end(); i++)
{
- Poco::XML::Element *tr=doc->createElement("ExternalMessage");
- //TiXmlElement *tr=new TiXmlElement("ExternalMessage");
+ Poco::AutoPtr tr=doc->createElement("ExternalMessage");
root->appendChild(tr);
- //tid->LinkEndChild(tr);
tr->appendChild(XMLCreateTextElement(doc,"Type",(*i).m_type));
- //tr->LinkEndChild(XMLCreateTextElement("Type",(*i).m_type));
if((*i).m_type=="Keyed")
{
tr->appendChild(XMLCreateCDATAElement(doc,"Identity",(*i).m_identity));
- //tr->LinkEndChild(XMLCreateCDATAElement("Identity",(*i).m_identity));
tr->appendChild(XMLCreateTextElement(doc,"Index",(*i).m_index));
- //tr->LinkEndChild(XMLCreateTextElement("Index",(*i).m_index));
}
else
{
tr->appendChild(XMLCreateCDATAElement(doc,"MessageKey",(*i).m_messagekey));
- //tr->LinkEndChild(XMLCreateCDATAElement("MessageKey",(*i).m_messagekey));
}
tr->appendChild(XMLCreateTextElement(doc,"Date",(*i).m_date));
- //tr->LinkEndChild(XMLCreateTextElement("Date",(*i).m_date));
- Poco::XML::Element *boards=doc->createElement("Boards");
- //TiXmlElement *brds=new TiXmlElement("Boards");
+
+ Poco::AutoPtr boards=doc->createElement("Boards");
tr->appendChild(boards);
- //tr->LinkEndChild(brds);
for(std::vector::iterator j=(*i).m_boards.begin(); j!=(*i).m_boards.end(); j++)
{
boards->appendChild(XMLCreateCDATAElement(doc,"Board",(*j)));
- //brds->LinkEndChild(XMLCreateCDATAElement("Board",(*j)));
}
}
- //td.Accept(&tp);
- //return std::string(tp.CStr());
return GenerateXML(doc);
}
@@ -331,116 +307,4 @@ const bool MessageListXML::ParseXML(const std::string &xml)
}
return parsed;
-
- /*
- TiXmlDocument td;
- td.Parse(xml.c_str());
-
- if(!td.Error())
- {
- std::string tempstr;
- std::string date;
- long index;
- std::vector boards;
- TiXmlText *txt;
- TiXmlHandle hnd(&td);
- TiXmlNode *node;
- TiXmlNode *node2;
-
- Initialize();
-
- node=hnd.FirstChild("MessageList").FirstChild("Message").ToNode();
- while(node)
- {
- date="";
- index=-1;
- boards.clear();
-
- TiXmlHandle hnd2(node);
- txt=hnd2.FirstChild("Date").FirstChild().ToText();
- if(txt)
- {
- date=SanitizeSingleString(txt->ValueStr());
- }
- txt=hnd2.FirstChild("Index").FirstChild().ToText();
- if(txt)
- {
- tempstr=SanitizeSingleString(txt->ValueStr());
- StringFunctions::Convert(tempstr,index);
- }
- node2=hnd2.FirstChild("Boards").FirstChild("Board").ToNode();
- while(node2)
- {
- if(node2->FirstChild())
- {
- std::string boardname=SanitizeSingleString(node2->FirstChild()->ValueStr());
- StringFunctions::LowerCase(boardname,boardname);
- boards.push_back(boardname);
- }
- node2=node2->NextSibling("Board");
- }
-
- m_messages.push_back(message(date,index,boards));
-
- node=node->NextSibling("Message");
- }
-
- node=hnd.FirstChild("MessageList").FirstChild("ExternalMessage").ToNode();
- while(node)
- {
- std::string type="";
- std::string identity="";
- date="";
- index=-1;
- boards.clear();
-
- TiXmlHandle hnd2(node);
- txt=hnd2.FirstChild("Type").FirstChild().ToText();
- if(txt)
- {
- type=SanitizeSingleString(txt->ValueStr());
- }
-
- if(type=="Keyed")
- {
- txt=hnd2.FirstChild("Identity").FirstChild().ToText();
- if(txt)
- {
- identity=SanitizeSingleString(txt->ValueStr());
- }
- txt=hnd2.FirstChild("Date").FirstChild().ToText();
- if(txt)
- {
- date=SanitizeSingleString(txt->ValueStr());
- }
- txt=hnd2.FirstChild("Index").FirstChild().ToText();
- if(txt)
- {
- tempstr=SanitizeSingleString(txt->ValueStr());
- StringFunctions::Convert(tempstr,index);
- }
- node2=hnd2.FirstChild("Boards").FirstChild("Board").ToNode();
- while(node2)
- {
- if(node2->FirstChild())
- {
- std::string boardname=SanitizeSingleString(node2->FirstChild()->ValueStr());
- StringFunctions::LowerCase(boardname,boardname);
- boards.push_back(boardname);
- }
- node2=node2->NextSibling("Board");
- }
- m_externalmessages.push_back(externalmessage("Keyed",identity,date,index,boards));
- }
-
- node=node->NextSibling("ExternalMessage");
- }
-
- return true;
- }
- else
- {
- return false;
- }
- */
}
diff --git a/src/freenet/messagexml.cpp b/src/freenet/messagexml.cpp
index 70b660d..7105da1 100644
--- a/src/freenet/messagexml.cpp
+++ b/src/freenet/messagexml.cpp
@@ -12,87 +12,58 @@ MessageXML::MessageXML()
std::string MessageXML::GetXML()
{
Poco::AutoPtr doc=new Poco::XML::Document;
- //TiXmlDocument td;
- //TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8","");
- Poco::XML::Element *root=doc->createElement("Message");
- //TiXmlElement *tid;
- //TiXmlPrinter tp;
+ Poco::AutoPtr root=doc->createElement("Message");
doc->appendChild(root);
- //td.LinkEndChild(tdec);
- //tid=new TiXmlElement("Message");
- //td.LinkEndChild(tid);
root->appendChild(XMLCreateTextElement(doc,"Date",m_date));
root->appendChild(XMLCreateTextElement(doc,"Time",m_time));
root->appendChild(XMLCreateCDATAElement(doc,"Subject",m_subject));
root->appendChild(XMLCreateCDATAElement(doc,"MessageID",m_messageid));
root->appendChild(XMLCreateCDATAElement(doc,"ReplyBoard",m_replyboard));
- /*
- tid->LinkEndChild(XMLCreateTextElement("Date",m_date));
- tid->LinkEndChild(XMLCreateTextElement("Time",m_time));
- tid->LinkEndChild(XMLCreateCDATAElement("Subject",m_subject));
- tid->LinkEndChild(XMLCreateCDATAElement("MessageID",m_messageid));
- tid->LinkEndChild(XMLCreateCDATAElement("ReplyBoard",m_replyboard));
- */
root->appendChild(XMLCreateCDATAElement(doc,"Body",m_body));
- // a little hack because TinyXML doesn't handle ]]> inside a CDATA section - manually separate into multiple CDATA sections
- // TinyXML still won't be able to parse past the 1st CDATA section, but other implementations might
- //tid->LinkEndChild(XMLCreateCDATAElement("Body",StringFunctions::Replace(m_body,"]]>","]]]]>")));
- Poco::XML::Element *brds=doc->createElement("Boards");
- //TiXmlElement *brds=new TiXmlElement("Boards");
+ Poco::AutoPtr brds=doc->createElement("Boards");
+
root->appendChild(brds);
- //tid->LinkEndChild(brds);
+
+ // attach boards
for(std::vector::iterator i=m_boards.begin(); i!=m_boards.end(); i++)
{
std::string boardname=(*i);
StringFunctions::Convert(boardname,boardname);
brds->appendChild(XMLCreateCDATAElement(doc,"Board",boardname));
- //brds->LinkEndChild(XMLCreateCDATAElement("Board",boardname));
}
+ // attach inreplyto ids
if(m_inreplyto.size()>0)
{
- Poco::XML::Element *rply=doc->createElement("InReplyTo");
- //TiXmlElement *rply=new TiXmlElement("InReplyTo");
+ Poco::AutoPtr rply=doc->createElement("InReplyTo");
root->appendChild(rply);
- //tid->LinkEndChild(rply);
for(std::map::iterator j=m_inreplyto.begin(); j!=m_inreplyto.end(); j++)
{
- Poco::XML::Element *mess=doc->createElement("Message");
- //TiXmlElement *mess=new TiXmlElement("Message");
+ Poco::AutoPtr mess=doc->createElement("Message");
rply->appendChild(mess);
mess->appendChild(XMLCreateTextElement(doc,"Order",(*j).first));
mess->appendChild(XMLCreateCDATAElement(doc,"MessageID",(*j).second));
- //mess->LinkEndChild(XMLCreateTextElement("Order",(*j).first));
- //mess->LinkEndChild(XMLCreateCDATAElement("MessageID",(*j).second));
}
}
// add attachemnt node if we have attachments
if(m_fileattachments.size()>0)
{
- Poco::XML::Element *attachments=doc->createElement("Attachments");
- //TiXmlElement *attachments=new TiXmlElement("Attachments");
+ Poco::AutoPtr attachments=doc->createElement("Attachments");
root->appendChild(attachments);
- //tid->LinkEndChild(attachments);
for(std::vector::iterator j=m_fileattachments.begin(); j!=m_fileattachments.end(); j++)
{
- Poco::XML::Element *f=doc->createElement("File");
- //TiXmlElement *f=new TiXmlElement("File");
+ Poco::AutoPtr f=doc->createElement("File");
attachments->appendChild(f);
- //attachments->LinkEndChild(f);
f->appendChild(XMLCreateCDATAElement(doc,"Key",(*j).m_key));
f->appendChild(XMLCreateTextElement(doc,"Size",(*j).m_size));
- //f->LinkEndChild(XMLCreateCDATAElement("Key",(*j).m_key));
- //f->LinkEndChild(XMLCreateTextElement("Size",(*j).m_size));
}
}
- //td.Accept(&tp);
- //return std::string(tp.CStr());
return GenerateXML(doc);
}
@@ -252,133 +223,4 @@ const bool MessageXML::ParseXML(const std::string &xml)
}
return parsed;
-
-/*
- TiXmlDocument td;
- td.Parse(xml.c_str());
-
- if(!td.Error())
- {
- TiXmlHandle hnd(&td);
- TiXmlNode *node2;
- TiXmlText *txt;
-
- Initialize();
-
- txt=hnd.FirstChild("Message").FirstChild("Date").FirstChild().ToText();
- if(txt)
- {
- m_date=SanitizeSingleString(txt->ValueStr());
- }
- txt=hnd.FirstChild("Message").FirstChild("Time").FirstChild().ToText();
- if(txt)
- {
- m_time=SanitizeSingleString(txt->ValueStr());
- }
- txt=hnd.FirstChild("Message").FirstChild("Subject").FirstChild().ToText();
- if(txt)
- {
- m_subject=SanitizeSingleString(txt->ValueStr());
- }
- txt=hnd.FirstChild("Message").FirstChild("MessageID").FirstChild().ToText();
- if(txt)
- {
- m_messageid=SanitizeSingleString(txt->ValueStr());
- }
- txt=hnd.FirstChild("Message").FirstChild("ReplyBoard").FirstChild().ToText();
- if(txt)
- {
- m_replyboard=SanitizeSingleString(txt->ValueStr());
- StringFunctions::LowerCase(m_replyboard,m_replyboard);
- if(m_replyboard.size()>40)
- {
- m_replyboard.erase(40);
- }
- }
- txt=hnd.FirstChild("Message").FirstChild("Body").FirstChild().ToText();
- if(txt)
- {
- m_body=txt->ValueStr();
- }
-
- node2=hnd.FirstChild("Message").FirstChild("Boards").FirstChild("Board").ToNode();
- while(node2)
- {
- if(node2->FirstChild())
- {
- std::string boardname=SanitizeSingleString(node2->FirstChild()->ValueStr());
- StringFunctions::LowerCase(boardname,boardname);
- if(boardname.size()>40)
- {
- boardname.erase(40);
- }
- m_boards.push_back(boardname);
- }
- node2=node2->NextSibling("Board");
- }
-
- node2=hnd.FirstChild("Message").FirstChild("InReplyTo").FirstChild("Message").ToNode();
- while(node2)
- {
- std::string orderstr;
- long order=-1;
- std::string messageid="";
- TiXmlHandle hnd2(node2);
- txt=hnd2.FirstChild("Order").FirstChild().ToText();
- if(txt)
- {
- orderstr=SanitizeSingleString(txt->ValueStr());
- StringFunctions::Convert(orderstr,order);
- }
- txt=hnd2.FirstChild("MessageID").FirstChild().ToText();
- if(txt)
- {
- messageid=SanitizeSingleString(txt->ValueStr());
- }
-
- if(order!=-1 && messageid!="")
- {
- m_inreplyto[order]=messageid;
- }
-
- node2=node2->NextSibling("Message");
- }
-
- node2=hnd.FirstChild("Message").FirstChild("Attachments").FirstChild("File").ToNode();
- while(node2)
- {
- std::string key="";
- std::string sizestr="-1";
- int size=-1;
-
- TiXmlHandle hnd2(node2);
-
- txt=hnd2.FirstChild("Key").FirstChild().ToText();
- if(txt)
- {
- key=SanitizeSingleString(txt->ValueStr());
- }
-
- txt=hnd2.FirstChild("Size").FirstChild().ToText();
- if(txt)
- {
- sizestr=SanitizeSingleString(txt->ValueStr());
- StringFunctions::Convert(sizestr,size);
- }
-
- if(key!="" && size>0)
- {
- m_fileattachments.push_back(fileattachment(key,size));
- }
-
- node2=node2->NextSibling("File");
- }
-
- return true;
- }
- else
- {
- return false;
- }
- */
}
diff --git a/src/freenet/trustlistxml.cpp b/src/freenet/trustlistxml.cpp
index 9132427..95d3c5e 100644
--- a/src/freenet/trustlistxml.cpp
+++ b/src/freenet/trustlistxml.cpp
@@ -80,16 +80,9 @@ std::string TrustListXML::GetTrustListTrustComment(const long index)
std::string TrustListXML::GetXML()
{
Poco::AutoPtr doc=new Poco::XML::Document;
- //TiXmlDocument td;
- //TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8","");
- Poco::XML::Element *root=doc->createElement("TrustList");
- //TiXmlElement *tid;
- //TiXmlPrinter tp;
+ Poco::AutoPtr root=doc->createElement("TrustList");
doc->appendChild(root);
- //td.LinkEndChild(tdec);
- //tid=new TiXmlElement("TrustList");
- //td.LinkEndChild(tid);
for(std::vector::iterator i=m_trust.begin(); i!=m_trust.end(); i++)
{
@@ -97,36 +90,27 @@ std::string TrustListXML::GetXML()
std::string trustlisttrust;
StringFunctions::Convert((*i).m_messagetrust,messagetrust);
StringFunctions::Convert((*i).m_trustlisttrust,trustlisttrust);
- Poco::XML::Element *tr=doc->createElement("Trust");
- //TiXmlElement *tr=new TiXmlElement("Trust");
+ Poco::AutoPtr tr=doc->createElement("Trust");
root->appendChild(tr);
- //tid->LinkEndChild(tr);
tr->appendChild(XMLCreateCDATAElement(doc,"Identity",(*i).m_identity));
- //tr->LinkEndChild(XMLCreateCDATAElement("Identity",(*i).m_identity));
if((*i).m_messagetrust>=0)
{
tr->appendChild(XMLCreateTextElement(doc,"MessageTrustLevel",messagetrust));
- //tr->LinkEndChild(XMLCreateTextElement("MessageTrustLevel",messagetrust));
}
if((*i).m_trustlisttrust>=0)
{
tr->appendChild(XMLCreateTextElement(doc,"TrustListTrustLevel",trustlisttrust));
- //tr->LinkEndChild(XMLCreateTextElement("TrustListTrustLevel",trustlisttrust));
}
if((*i).m_messagetrustcomment!="")
{
tr->appendChild(XMLCreateTextElement(doc,"MessageTrustComment",(*i).m_messagetrustcomment));
- //tr->LinkEndChild(XMLCreateCDATAElement("MessageTrustComment",(*i).m_messagetrustcomment));
}
if((*i).m_trustlisttrustcomment!="")
{
tr->appendChild(XMLCreateTextElement(doc,"TrustListTrustComment",(*i).m_trustlisttrustcomment));
- //tr->LinkEndChild(XMLCreateCDATAElement("TrustListTrustComment",(*i).m_trustlisttrustcomment));
}
}
- //td.Accept(&tp);
- //return std::string(tp.CStr());
return GenerateXML(doc);
}
@@ -228,93 +212,4 @@ const bool TrustListXML::ParseXML(const std::string &xml)
}
return parsed;
-
- /*
- TiXmlDocument td;
- td.Parse(xml.c_str());
-
- if(!td.Error())
- {
- std::string identity;
- std::string messagetruststr;
- std::string trustlisttruststr;
- std::string messagetrustcomment="";
- std::string trustlisttrustcomment="";
- long messagetrust;
- long trustlisttrust;
- TiXmlText *txt;
- TiXmlHandle hnd(&td);
- TiXmlNode *node;
- std::vector m_foundkeys;
-
- Initialize();
-
- node=hnd.FirstChild("TrustList").FirstChild("Trust").ToElement();
- while(node)
- {
- identity="";
- messagetrust=-1;
- trustlisttrust=-1;
- messagetrustcomment="";
- trustlisttrustcomment="";
-
- TiXmlHandle hnd2(node);
- txt=hnd2.FirstChild("Identity").FirstChild().ToText();
- if(txt)
- {
- identity=SanitizeSingleString(txt->ValueStr());
- }
- txt=hnd2.FirstChild("MessageTrustLevel").FirstChild().ToText();
- if(txt)
- {
- messagetruststr=SanitizeSingleString(txt->ValueStr());
- if(messagetruststr!="")
- {
- StringFunctions::Convert(messagetruststr,messagetrust);
- }
- }
- txt=hnd2.FirstChild("TrustListTrustLevel").FirstChild().ToText();
- if(txt)
- {
- trustlisttruststr=SanitizeSingleString(txt->ValueStr());
- if(trustlisttruststr!="")
- {
- StringFunctions::Convert(trustlisttruststr,trustlisttrust);
- }
- }
- txt=hnd2.FirstChild("MessageTrustComment").FirstChild().ToText();
- if(txt)
- {
- messagetrustcomment=txt->ValueStr();
- }
- txt=hnd2.FirstChild("TrustListTrustComment").FirstChild().ToText();
- if(txt)
- {
- trustlisttrustcomment=txt->ValueStr();
- }
-
- if(identity!="" && messagetrust>=-1 && messagetrust<=100 && trustlisttrust>=-1 && trustlisttrust<=100)
- {
- // check so we don't add the same identity multiple times from a trust list
- if(std::find(m_foundkeys.begin(),m_foundkeys.end(),identity)==m_foundkeys.end())
- {
- m_foundkeys.push_back(identity);
- m_trust.push_back(trust(identity,messagetrust,trustlisttrust,messagetrustcomment,trustlisttrustcomment));
- }
- }
- else
- {
- m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"TrustListXML::ParseXML malformed Trust in TrustList.xml");
- }
-
- node=node->NextSibling("Trust");
- }
- return true;
-
- }
- else
- {
- return false;
- }
- */
}
diff --git a/src/http/httpthread.cpp b/src/http/httpthread.cpp
index ceaad4f..ecc4cf5 100644
--- a/src/http/httpthread.cpp
+++ b/src/http/httpthread.cpp
@@ -68,18 +68,21 @@ void HTTPThread::run()
Poco::Net::ServerSocket sock(m_listenport);
Poco::Net::HTTPServerParams* pParams = new Poco::Net::HTTPServerParams;
- pParams->setMaxQueued(10);
+ pParams->setMaxQueued(30);
pParams->setMaxThreads(5);
Poco::Net::HTTPServer srv(new FMSHTTPRequestHandlerFactory,sock,pParams);
srv.start();
+ m_log->trace("Started HTTPServer");
do
{
Poco::Thread::sleep(1000);
}while(!IsCancelled());
+ m_log->trace("Trying to stop HTTPServer");
srv.stop();
+ m_log->trace("Stopped HTTPServer");
m_log->debug("HTTPThread::run thread exiting.");
diff --git a/src/http/identityexportxml.cpp b/src/http/identityexportxml.cpp
index aff7623..521c4ca 100644
--- a/src/http/identityexportxml.cpp
+++ b/src/http/identityexportxml.cpp
@@ -101,24 +101,15 @@ const bool IdentityExportXML::GetSingleUse(const long index)
std::string IdentityExportXML::GetXML()
{
Poco::AutoPtr doc=new Poco::XML::Document;
- Poco::XML::Element *root=doc->createElement("IdentityExport");
- Poco::XML::Element *el=NULL;
- //TiXmlDocument td;
- //TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8","");
- //TiXmlElement *tid;
- //TiXmlPrinter tp;
+ Poco::AutoPtr root=doc->createElement("IdentityExport");
+ Poco::AutoPtr el=NULL;
doc->appendChild(root);
- //td.LinkEndChild(tdec);
- //tid=new TiXmlElement("IdentityExport");
- //td.LinkEndChild(tid);
for(std::vector::iterator i=m_identities.begin(); i!=m_identities.end(); i++)
{
el=doc->createElement("Identity");
- //TiXmlElement *tr=new TiXmlElement("Identity");
root->appendChild(el);
- //tid->LinkEndChild(tr);
el->appendChild(XMLCreateCDATAElement(doc,"Name",(*i).m_name));
el->appendChild(XMLCreateTextElement(doc,"PublicKey",(*i).m_publickey));
@@ -127,23 +118,9 @@ std::string IdentityExportXML::GetXML()
el->appendChild(XMLCreateBooleanElement(doc,"PublishTrustList",(*i).m_publishtrustlist));
el->appendChild(XMLCreateBooleanElement(doc,"PublishBoardList",(*i).m_publishboardlist));
el->appendChild(XMLCreateBooleanElement(doc,"PublishFreesite",(*i).m_publishfreesite));
-
- //tr->LinkEndChild(XMLCreateCDATAElement("Name",(*i).m_name));
- //tr->LinkEndChild(XMLCreateTextElement("PublicKey",(*i).m_publickey));
- //tr->LinkEndChild(XMLCreateTextElement("PrivateKey",(*i).m_privatekey));
- //tr->LinkEndChild(XMLCreateBooleanElement("SingleUse",(*i).m_singleuse));
- //tr->LinkEndChild(XMLCreateBooleanElement("PublishTrustList",(*i).m_publishtrustlist));
- //tr->LinkEndChild(XMLCreateBooleanElement("PublishBoardList",(*i).m_publishboardlist));
- //tr->LinkEndChild(XMLCreateBooleanElement("PublishFreesite",(*i).m_publishfreesite));
}
- //td.Accept(&tp);
- //return std::string(tp.CStr());
-
- std::string xml;
- xml=GenerateXML(doc);
-
- return xml;
+ return GenerateXML(doc);
}
void IdentityExportXML::Initialize()
@@ -221,71 +198,4 @@ const bool IdentityExportXML::ParseXML(const std::string &xml)
}
return parsed;
-
- //TiXmlDocument td;
- //td.Parse(xml.c_str());
-/*
- if(!td.Error())
- {
- std::string name;
- std::string publickey;
- std::string privatekey;
- bool singleuse=false;
- bool publishtrustlist=false;
- bool publishboardlist=false;
- bool publishfreesite=false;
- TiXmlText *txt;
- TiXmlHandle hnd(&td);
- TiXmlNode *node;
-
- Initialize();
-
- node=hnd.FirstChild("IdentityExport").FirstChild("Identity").ToElement();
- while(node)
- {
- name="";
- publickey="";
- privatekey="";
- singleuse=false;
- publishtrustlist=false;
- publishboardlist=false;
- publishfreesite=false;
-
- TiXmlHandle hnd2(node);
- txt=hnd2.FirstChild("Name").FirstChild().ToText();
- if(txt)
- {
- name=txt->ValueStr();
- }
- txt=hnd2.FirstChild("PublicKey").FirstChild().ToText();
- if(txt)
- {
- publickey=txt->ValueStr();
- }
- txt=hnd2.FirstChild("PrivateKey").FirstChild().ToText();
- if(txt)
- {
- privatekey=txt->ValueStr();
- }
-
- singleuse=XMLGetBooleanElement(node->ToElement(),"SingleUse");
- publishtrustlist=XMLGetBooleanElement(node->ToElement(),"PublishTrustList");
- publishboardlist=XMLGetBooleanElement(node->ToElement(),"PublishBoardList");
- publishfreesite=XMLGetBooleanElement(node->ToElement(),"PublishFreesite");
-
- if(name!="" && publickey!="" && privatekey!="")
- {
- m_identities.push_back(identity(name,publickey,privatekey,singleuse,publishtrustlist,publishboardlist,publishfreesite));
- }
-
- node=node->NextSibling("Identity");
- }
- return true;
-
- }
- else
- {
- return false;
- }
-*/
}
diff --git a/src/http/pages/createidentitypage.cpp b/src/http/pages/createidentitypage.cpp
index 165b22d..8a65914 100644
--- a/src/http/pages/createidentitypage.cpp
+++ b/src/http/pages/createidentitypage.cpp
@@ -27,6 +27,9 @@ const std::string CreateIdentityPage::GeneratePage(const std::string &method, co
st.Bind(1,Poco::DateTimeFormatter::format(date,"%Y-%m-%d %H:%M:%S"));
st.Step();
+ // insert all identities not in trust list already
+ m_db->Execute("INSERT INTO tblIdentityTrust(LocalIdentityID,IdentityID) SELECT LocalIdentityID,IdentityID FROM tblLocalIdentity,tblIdentity WHERE LocalIdentityID || '_' || IdentityID NOT IN (SELECT LocalIdentityID || '_' || IdentityID FROM tblIdentityTrust);");
+
content+="Created Identity
";
}
else
diff --git a/src/http/pages/homepage.cpp b/src/http/pages/homepage.cpp
index 37d8dc6..b295f45 100644
--- a/src/http/pages/homepage.cpp
+++ b/src/http/pages/homepage.cpp
@@ -30,11 +30,41 @@ const std::string HomePage::GeneratePage(const std::string &method, const std::m
content+="FMS version ";
content+=FMS_VERSION;
content+="
";
- content+="Check for new versions at the FMS Freesite
";
+
+ bool showgenericupdate=true;
+ SQLite3DB::Statement st=m_db->Prepare("SELECT Major, Minor, Release, PageKey FROM tblFMSVersion ORDER BY Major DESC, Minor DESC, Release DESC;");
+ st.Step();
+ if(st.RowReturned())
+ {
+ std::string currentmajor=VERSION_MAJOR;
+ std::string currentminor=VERSION_MINOR;
+ std::string currentrelease=VERSION_RELEASE;
+ std::string major="";
+ std::string minor="";
+ std::string release="";
+ std::string freesite="";
+ st.ResultText(0,major);
+ st.ResultText(1,minor);
+ st.ResultText(2,release);
+ st.ResultText(3,freesite);
+
+ if(currentmajorYou are running an old version of FMS. Please update here: FMS "+major+"."+minor+"."+release+"
";
+ showgenericupdate=false;
+ }
+
+ }
+
+ if(showgenericupdate)
+ {
+ content+="Check for new versions at the FMS Freesite
";
+ }
+
content+="Use these pages to administer your FMS installation.";
content+="
";
- SQLite3DB::Statement st=m_db->Prepare("SELECT COUNT(*) FROM tblMessageInserts WHERE Inserted='false';");
+ st=m_db->Prepare("SELECT COUNT(*) FROM tblMessageInserts WHERE Inserted='false';");
st.Step();
if(st.RowReturned())
{
diff --git a/src/ipaddressacl.cpp b/src/ipaddressacl.cpp
index 0516c1d..64ca979 100644
--- a/src/ipaddressacl.cpp
+++ b/src/ipaddressacl.cpp
@@ -64,9 +64,11 @@ const bool IPAddressACL::Add(const std::string &aclentry)
const std::string IPAddressACL::CreateMask(const int maskbits)
{
int bitsleft=maskbits;
- int parts[4]={255,255,255,255};
+ //int parts[4]={255,255,255,255};
+ int parts[4]={0,0,0,0};
std::ostringstream ipstr;
+ /*
for(int i=3; i>=0; i--)
{
for(int b=0; b<8 && bitsleft>0; b++)
@@ -75,6 +77,15 @@ const std::string IPAddressACL::CreateMask(const int maskbits)
bitsleft--;
}
}
+ */
+ for(int i=0; i<4; i++)
+ {
+ for(int b=7; b>=0 && bitsleft>0; b--)
+ {
+ parts[i]+=pow((float)2,b);
+ bitsleft--;
+ }
+ }
ipstr << parts[0] << "." << parts[1] << "." << parts[2] << "." << parts[3];
@@ -86,7 +97,7 @@ const bool IPAddressACL::IsAllowed(const Poco::Net::IPAddress &addr)
bool found=false;
bool rval=m_allowbydefault;
- for(std::vector::iterator i=m_entries.begin(); i!=m_entries.end() && found==false; i++)
+ for(std::vector::reverse_iterator i=m_entries.rbegin(); i!=m_entries.rend() && found==false; i++)
{
Poco::Net::IPAddress ip1=addr;
Poco::Net::IPAddress ip2=(*i).m_addr;
diff --git a/src/optionssetup.cpp b/src/optionssetup.cpp
index 2d646f0..e9fc7ce 100644
--- a/src/optionssetup.cpp
+++ b/src/optionssetup.cpp
@@ -55,6 +55,29 @@ void SetupDefaultOptions()
upd.Step();
upd.Reset();
+ st.Bind(0,"FMSVersionKey");
+ st.Bind(1,"USK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fmsversion/");
+ st.Step();
+ st.Reset();
+ upd.Bind(0,"Program");
+ upd.Bind(1,order++);
+ upd.Bind(2);
+ upd.Bind(3,"The USK key which contains information about the latest version of FMS.");
+ upd.Bind(4,"FMSVersionKey");
+ upd.Step();
+ upd.Reset();
+
+ st.Bind(0,"FMSVersionEdition");
+ st.Bind(1,"0");
+ st.Step();
+ upd.Bind(0,"Program");
+ upd.Bind(1,order++);
+ upd.Bind(2);
+ upd.Bind(3,"The latest found edition of the FMS version USK.");
+ upd.Bind(4,"FMSVersionEdition");
+ upd.Step();
+ upd.Reset();
+
// StartNNTP
st.Bind(0,"StartNNTP");
st.Bind(1,"true");
diff --git a/src/threadwrapper/threadedexector.cpp b/src/threadwrapper/threadedexector.cpp
index 72c04c2..c9eaf33 100644
--- a/src/threadwrapper/threadedexector.cpp
+++ b/src/threadwrapper/threadedexector.cpp
@@ -39,9 +39,13 @@ void ThreadedExecutor::CleanupCompleted()
void ThreadedExecutor::Join()
{
+ CleanupCompleted();
for(std::vector::iterator i=m_threads.begin(); i!=m_threads.end(); i++)
{
- (*i)->join();
+ if((*i)->isRunning())
+ {
+ (*i)->join();
+ }
}
CleanupCompleted();
}
--
2.7.4