version 0.2.10
[fms.git] / src / freenet / identityinserter.cpp
index aa1f4ab..f246d66 100644 (file)
@@ -84,10 +84,14 @@ const bool IdentityInserter::HandleMessage(FCPMessage &message)
                        // If this is the case, we will skip updating LastInsertedIdentity so that we can insert this identity again for today\r
                        DateTime lastdate;\r
                        lastdate.Set(idparts[4]);\r
-                       if(lastdate.GetDay()!=now.GetDay())\r
+                       if(lastdate.GetDay()==now.GetDay())\r
                        {\r
                                m_db->Execute("UPDATE tblLocalIdentity SET InsertingIdentity='false', LastInsertedIdentity='"+now.Format("%Y-%m-%d %H:%M:%S")+"' WHERE LocalIdentityID="+idparts[1]+";");\r
                        }\r
+                       else\r
+                       {\r
+                               m_db->Execute("UPDATE tblLocalIdentity SET InsertingIdentity='false' WHERE LocalIdentityID="+idparts[1]+";");\r
+                       }\r
                        m_db->Execute("INSERT INTO tblLocalIdentityInserts(LocalIdentityID,Day,InsertIndex) VALUES("+idparts[1]+",'"+idparts[4]+"',"+idparts[2]+");");\r
                        m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"IdentityInserter::HandleMessage inserted Identity xml");\r
                        return true;\r
@@ -146,7 +150,7 @@ void IdentityInserter::StartInsert(const long localidentityid)
        StringFunctions::Convert(localidentityid,idstring);\r
        date.SetToGMTime();\r
 \r
-       SQLite3DB::Recordset rs=m_db->Query("SELECT Name,PrivateKey,SingleUse,PublishTrustList,PublishBoardList FROM tblLocalIdentity WHERE LocalIdentityID="+idstring+";");\r
+       SQLite3DB::Recordset rs=m_db->Query("SELECT Name,PrivateKey,SingleUse,PublishTrustList,PublishBoardList,PublishFreesite,FreesiteEdition FROM tblLocalIdentity WHERE LocalIdentityID="+idstring+";");\r
 \r
        if(rs.Empty()==false)\r
        {\r
@@ -162,6 +166,8 @@ void IdentityInserter::StartInsert(const long localidentityid)
                std::string singleuse="false";\r
                std::string publishtrustlist="false";\r
                std::string publishboardlist="false";\r
+               std::string freesiteedition="";\r
+               int edition=-1;\r
 \r
                now.SetToGMTime();\r
 \r
@@ -179,7 +185,7 @@ void IdentityInserter::StartInsert(const long localidentityid)
                }\r
                StringFunctions::Convert(index,indexstr);\r
 \r
-               Option::instance()->Get("MessageBase",messagebase);\r
+               Option::Instance()->Get("MessageBase",messagebase);\r
 \r
                if(rs.GetField(0))\r
                {\r
@@ -209,6 +215,16 @@ void IdentityInserter::StartInsert(const long localidentityid)
                }\r
                publishboardlist=="true" ? idxml.SetPublishBoardList(true) : idxml.SetPublishBoardList(false);\r
 \r
+               if(rs.GetField(5) && rs.GetField(6))\r
+               {\r
+                       if(std::string(rs.GetField(5))=="true")\r
+                       {\r
+                               freesiteedition=rs.GetField(6);\r
+                               StringFunctions::Convert(freesiteedition,edition);\r
+                               idxml.SetFreesiteEdition(edition);\r
+                       }\r
+               }\r
+\r
                data=idxml.GetXML();\r
                StringFunctions::Convert(data.size(),datasizestr);\r
 \r