version 0.2.17
[fms.git] / src / freenet / trustlistinserter.cpp
index 8962d5e..d316790 100644 (file)
@@ -72,23 +72,30 @@ const bool TrustListInserter::HandleMessage(FCPMessage &message)
 \r
                if(message.GetName()=="PutSuccessful")\r
                {\r
-                       m_db->Execute("UPDATE tblLocalIdentity SET InsertingTrustList='false', LastInsertedTrustList='"+now.Format("%Y-%m-%d %H:%M:%S")+"' WHERE LocalIdentityID="+idparts[1]+";");\r
-                       m_db->Execute("INSERT INTO tblTrustListInserts(LocalIdentityID,Day,InsertIndex) VALUES("+idparts[1]+",'"+idparts[4]+"',"+idparts[2]+");");\r
-                       m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"TrustListInserter::HandleMessage inserted TrustList xml");\r
+                       // non USK\r
+                       if(idparts[0]=="TrustListInserter")\r
+                       {\r
+                               m_db->Execute("UPDATE tblLocalIdentity SET InsertingTrustList='false', LastInsertedTrustList='"+now.Format("%Y-%m-%d %H:%M:%S")+"' WHERE LocalIdentityID="+idparts[1]+";");\r
+                               m_db->Execute("INSERT INTO tblTrustListInserts(LocalIdentityID,Day,InsertIndex) VALUES("+idparts[1]+",'"+idparts[4]+"',"+idparts[2]+");");\r
+                               m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"TrustListInserter::HandleMessage inserted TrustList xml");\r
+                       }\r
                        return true;\r
                }\r
 \r
-               if(message.GetName()=="PutFailed")\r
+               if(message.GetName()=="PutFailed" && idparts[0]=="TrustListInserter")\r
                {\r
-                       m_db->Execute("UPDATE tblLocalIdentity SET InsertingTrustList='false' WHERE LocalIdentityID="+idparts[1]+";");\r
-                       m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"TrustListInserter::HandleMessage failure inserting TrustList xml.  Code="+message["Code"]+" Description="+message["CodeDescription"]);\r
-                       \r
-                       // if code 9 (collision), then insert index into inserted table\r
-                       if(message["Code"]=="9")\r
+                       // non USK\r
+                       if(idparts[0]=="TrustListInserter")\r
                        {\r
-                               m_db->Execute("INSERT INTO tblTrustListInserts(LocalIdentityID,Day,InsertIndex) VALUES("+idparts[1]+",'"+idparts[4]+"',"+idparts[2]+");");\r
-                       }\r
+                               m_db->Execute("UPDATE tblLocalIdentity SET InsertingTrustList='false' WHERE LocalIdentityID="+idparts[1]+";");\r
+                               m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"TrustListInserter::HandleMessage failure inserting TrustList xml.  Code="+message["Code"]+" Description="+message["CodeDescription"]);\r
                        \r
+                               // if code 9 (collision), then insert index into inserted table\r
+                               if(message["Code"]=="9")\r
+                               {\r
+                                       m_db->Execute("INSERT INTO tblTrustListInserts(LocalIdentityID,Day,InsertIndex) VALUES("+idparts[1]+",'"+idparts[4]+"',"+idparts[2]+");");\r
+                               }\r
+                       }\r
                        return true;\r
                }\r
 \r
@@ -205,6 +212,18 @@ void TrustListInserter::StartInsert(const long localidentityid, const std::strin
        m_fcp->SendMessage(message);\r
        m_fcp->SendRaw(data.c_str(),data.size());\r
 \r
+       // insert to USK\r
+       message.Reset();\r
+       message.SetName("ClientPutComplexDir");\r
+       message["URI"]="USK"+privatekey.substr(3)+m_messagebase+"|"+now.Format("%Y.%m.%d")+"|TrustList/0/";\r
+       message["Identifier"]="TrustListInserterUSK|"+message["URI"];\r
+       message["DefaultName"]="TrustList.xml";\r
+       message["Files.0.Name"]="TrustList.xml";\r
+       message["Files.0.UplaodFrom"]="direct";\r
+       message["Files.0.DataLength"]=datasizestr;\r
+       m_fcp->SendMessage(message);\r
+       m_fcp->SendRaw(data.c_str(),data.size());\r
+\r
        m_db->Execute("UPDATE tblLocalIdentity SET InsertingTrustList='true' WHERE LocalIdentityID="+localidentityidstr+";");\r
 \r
 }\r