version 0.3.0
[fms.git] / src / freenet / identityintroductioninserter.cpp
index 05fe782..7537c91 100644 (file)
@@ -1,10 +1,11 @@
 #include "../../include/freenet/identityintroductioninserter.h"\r
 #include "../../include/freenet/identityintroductionxml.h"\r
-#include "../../include/xyssl/sha1.h"\r
 #include "../../include/stringfunctions.h"\r
 #include "../../include/hex.h"\r
 #include "../../include/option.h"\r
 \r
+#include <Poco/SHA1Engine.h>\r
+\r
 #ifdef XMEM\r
        #include <xmem.h>\r
 #endif\r
@@ -63,7 +64,7 @@ const bool IdentityIntroductionInserter::HandleMessage(FCPMessage &message)
                                m_db->Execute("DELETE FROM tblIdentityIntroductionInserts WHERE UUID='"+idparts[3]+"';");\r
                                // update the puzzle from the request table (set to not found) because we don't need it anymore and don't want to user tyring to solve it again\r
                                m_db->Execute("UPDATE tblIntroductionPuzzleRequests SET Found='false' WHERE UUID='"+idparts[3]+"';");\r
-                               m_log->WriteLog(LogFile::LOGLEVEL_WARNING,"IdentityIntroductionInserter::HandleMessage received fatal error trying to insert IdentityIntroduction "+idparts[3]);\r
+                               m_log->warning("IdentityIntroductionInserter::HandleMessage received fatal error trying to insert IdentityIntroduction "+idparts[3]);\r
                        }\r
                        m_inserting=false;\r
                        return true;\r
@@ -73,7 +74,7 @@ const bool IdentityIntroductionInserter::HandleMessage(FCPMessage &message)
                {\r
                        m_db->Execute("UPDATE tblIdentityIntroductionInserts SET Inserted='true' WHERE UUID='"+idparts[3]+"';");\r
                        m_inserting=false;\r
-                       m_log->WriteLog(LogFile::LOGLEVEL_INFO,"IdentityIntroductionInserter::HandleMessage successfully inserted IdentityIntroduction "+idparts[3]);\r
+                       m_log->information("IdentityIntroductionInserter::HandleMessage successfully inserted IdentityIntroduction "+idparts[3]);\r
                        return true;\r
                }\r
 \r
@@ -95,11 +96,10 @@ void IdentityIntroductionInserter::Initialize()
 \r
 void IdentityIntroductionInserter::Process()\r
 {\r
-       DateTime now;\r
-       now.SetToGMTime();\r
+       Poco::DateTime now;\r
 \r
        // only do 1 insert at a time\r
-       if(!m_inserting && m_lastchecked<(now-(1.0/1440.0)))\r
+       if(!m_inserting && m_lastchecked<(now-Poco::Timespan(0,0,1,0,0)))\r
        {\r
                CheckForNewInserts();\r
                m_lastchecked=now;\r
@@ -120,7 +120,7 @@ void IdentityIntroductionInserter::StartInsert(const long localidentityid, const
        std::string publickey;\r
        std::string data;\r
        std::string datasizestr;\r
-       std::vector<unsigned char> hash;\r
+//     std::vector<unsigned char> hash;\r
        std::string encodedhash;\r
        \r
        SQLite3DB::Statement st=m_db->Prepare("SELECT PublicKey FROM tblLocalIdentity WHERE PublicKey IS NOT NULL AND PublicKey<>'' AND LocalIdentityID=?;");\r
@@ -135,9 +135,14 @@ void IdentityIntroductionInserter::StartInsert(const long localidentityid, const
                data=xml.GetXML();\r
                StringFunctions::Convert(data.size(),datasizestr);\r
 \r
-               hash.resize(20);\r
-               sha1((unsigned char *)solution.c_str(),solution.size(),&hash[0]);\r
-               Hex::Encode(hash,encodedhash);\r
+               Poco::SHA1Engine sha1;\r
+               sha1.update(solution);\r
+               encodedhash=Poco::DigestEngine::digestToHex(sha1.digest());\r
+               StringFunctions::UpperCase(encodedhash,encodedhash);\r
+\r
+//             hash.resize(20);\r
+//             sha1((unsigned char *)solution.c_str(),solution.size(),&hash[0]);\r
+//             Hex::Encode(hash,encodedhash);\r
 \r
                message.SetName("ClientPut");\r
                message["URI"]="KSK@"+m_messagebase+"|"+day+"|"+UUID+"|"+encodedhash+".xml";\r
@@ -152,7 +157,7 @@ void IdentityIntroductionInserter::StartInsert(const long localidentityid, const
        }\r
        else\r
        {\r
-               m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"IdentityIntroductionInserter::StartInsert could not find a public key for identity.  It is probably a new identity that doesn't have a key yet.");\r
+               m_log->debug("IdentityIntroductionInserter::StartInsert could not find a public key for identity.  It is probably a new identity that doesn't have a key yet.");\r
        }\r
 \r
 }\r