version 0.2.12
authorSomeDude <SomeDude@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw>
Mon, 28 Apr 2008 14:42:00 +0000 (16:42 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Mon, 28 Apr 2008 14:42:00 +0000 (16:42 +0200)
include/global.h
include/message.h
src/freenet/fileinserter.cpp
src/global.cpp
src/http/pages/insertedfilespage.cpp
src/http/pages/peerdetailspage.cpp
src/message.cpp

index 59d9dd2..6258372 100644 (file)
@@ -5,7 +5,7 @@
 #include <vector>\r
 #include "pthreadwrapper/thread.h"\r
 \r
-#define FMS_VERSION    "0.2.11"\r
+#define FMS_VERSION    "0.2.12"\r
 \r
 // opens database and creates tables and initial inserts if necessary\r
 void SetupDB();\r
@@ -17,6 +17,7 @@ void ConvertDB0105To0106();
 void ConvertDB0106To0107();\r
 void ConvertDB0107To0108();\r
 void ConvertDB0108To0109();\r
+void ConvertDB0109To0110();\r
 // inserts default options into the database\r
 void SetupDefaultOptions();\r
 // opens logfile and sets it up\r
index 625aa22..4b4cb6e 100644 (file)
@@ -61,8 +61,9 @@ private:
 \r
        struct fileattachment\r
        {\r
-               fileattachment(const std::string &filename, const std::vector<unsigned char> &data):m_filename(filename),m_data(data)   {}\r
+               fileattachment(const std::string &filename, const std::string &mimetype, const std::vector<unsigned char> &data):m_filename(filename),m_mimetype(mimetype),m_data(data) {}\r
                std::string m_filename;\r
+               std::string m_mimetype;\r
                std::vector<unsigned char> m_data;\r
        };\r
 \r
index d8d2721..4a82bda 100644 (file)
@@ -55,7 +55,7 @@ const bool FileInserter::HandlePutSuccessful(FCPMessage &message)
        StringFunctions::Convert(idparts[1],fileinsertid);\r
 \r
        SQLite3DB::Statement st=m_db->Prepare("UPDATE tblFileInserts SET Key=?, Data=NULL WHERE FileInsertID=?;");\r
-       st.Bind(0,message["URI"]);\r
+       st.Bind(0,StringFunctions::UriDecode(message["URI"]));\r
        st.Bind(1,fileinsertid);\r
        st.Step();\r
 \r
@@ -75,13 +75,14 @@ void FileInserter::StartInsert(const long &fileinsertid)
        std::string fileinsertidstr="";\r
        std::string sizestr="";\r
        std::string filename="";\r
+       std::string mimetype="";\r
        int datalen=-1;\r
        std::vector<char> data;\r
 \r
        StringFunctions::Convert(fileinsertid,fileinsertidstr);\r
 \r
 \r
-       SQLite3DB::Statement st=m_db->Prepare("SELECT FileName,Size,Data FROM tblFileInserts WHERE FileInsertID=?;");\r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT FileName,Size,Data,MimeType FROM tblFileInserts WHERE FileInsertID=?;");\r
        st.Bind(0,fileinsertid);\r
        st.Step();\r
 \r
@@ -90,12 +91,17 @@ void FileInserter::StartInsert(const long &fileinsertid)
        data.resize(datalen,0);\r
        st.ResultBlob(2,&data[0],datalen);\r
        data.resize(datalen);\r
+       st.ResultText(3,mimetype);\r
 \r
        StringFunctions::Convert(data.size(),sizestr);\r
 \r
        message.SetName("ClientPut");\r
        message["URI"]="CHK@";\r
        message["TargetFilename"]=filename;\r
+       if(mimetype!="")\r
+       {\r
+               message["Metadata.ContentType"]=mimetype;\r
+       }\r
        message["Identifier"]=m_fcpuniquename+"|"+fileinsertidstr;\r
        message["UploadFrom"]="direct";\r
        message["DataLength"]=sizestr;\r
index 7e6d842..aed8c3e 100644 (file)
@@ -107,13 +107,19 @@ void SetupDB()
                        major=1;\r
                        minor=9;\r
                }\r
+               if(major==1 && minor==9)\r
+               {\r
+                       ConvertDB0109To0110();\r
+                       major=1;\r
+                       minor=10;\r
+               }\r
        }\r
        else\r
        {\r
-               db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,9);");\r
+               db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,10);");\r
        }\r
 \r
-       db->Execute("UPDATE tblDBVersion SET Major=1, Minor=9;");\r
+       db->Execute("UPDATE tblDBVersion SET Major=1, Minor=10;");\r
 \r
        db->Execute("CREATE TABLE IF NOT EXISTS tblOption(\\r
                                Option                          TEXT UNIQUE,\\r
@@ -340,6 +346,7 @@ void SetupDB()
                                FileName                        TEXT,\\r
                                Key                                     TEXT,\\r
                                Size                            INTEGER,\\r
+                               MimeType                        TEXT,\\r
                                Data                            BLOB\\r
                                );");\r
 \r
@@ -491,6 +498,16 @@ void SetupDB()
        db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('SSK@~mimyB1kmH4f7Cgsd2wM2Qv2NxrZHRMM6IY8~7EWRVQ,fxTKkR0TYhgMYb-vEGAv55sMOxCGD2xhE4ZxWHxdPz4,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"','Initial Identity');");\r
        // insert garfield's public key\r
        db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('SSK@T8l1IEGU4-PoASFzgc2GYhIgRzUvZsKdoQWeuLHuTmM,QLxAPfkGis8l5NafNpSCdbxzXhBlu9WL8svcqJw9Mpo,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"','Initial Identity');");\r
+       // insert alek's public key\r
+       db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('SSK@lTjeI6V0lQsktXqaqJ6Iwk4TdsHduQI54rdUpHfhGbg,0oTYfrxxx8OmdU1~60gqpf3781qzEicM4Sz97mJsBM4,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"','Initial Identity');");\r
+       // insert Luke771's public key\r
+       db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('SSK@mdXK~ZVlfTZhF1SLBrvZ--i0vOsOpa~w9wv~~psQ-04,gXonsXKc7aexKSO8Gt8Fwre4Qgmmbt2WueO7VzxNKkk,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"','Initial Identity');");\r
+       // insert falafel's public key\r
+       db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('SSK@IxVqeqM0LyYdTmYAf5z49SJZUxr7NtQkOqVYG0hvITw,RM2wnMn5zAufCMt5upkkgq25B1elfBAxc7htapIWg1c,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"','Initial Identity');");\r
+       // insert cptn_insano's public key\r
+       db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('SSK@bloE1LJ~qzSYUkU2nt7sB9kq060D4HTQC66pk5Q8NpA,DOOASUnp0kj6tOdhZJ-h5Tk7Ka50FSrUgsH7tCG1usU,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"','Initial Identity');");\r
+       // insert Flink's public key\r
+       db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('SSK@q2TtkNBOuuniyJ56~8NSopCs3ttwe5KlB31ugZtWmXA,6~PzIupS8YK7L6oFNpXGKJmHT2kBMDfwTg73nHdNur8,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"','Initial Identity');");\r
 \r
        // TODO remove sometime after 0.1.17\r
        FixCapitalBoardNames();\r
@@ -627,6 +644,13 @@ void ConvertDB0108To0109()
        db->Execute("UPDATE tblDBVersion SET Major=1, Minor=9;");\r
 }\r
 \r
+void ConvertDB0109To0110()\r
+{\r
+       SQLite3DB::DB *db=SQLite3DB::DB::Instance();\r
+       db->Execute("ALTER TABLE tblFileInserts ADD COLUMN MimeType TEXT;");\r
+       db->Execute("UPDATE tblDBVersion SET Major=1, Minor=10;");\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
@@ -685,7 +709,7 @@ void SetupDefaultOptions()
 \r
        st.Bind(0,"HTTPAccessControl");\r
        st.Bind(1,"-0.0.0.0/0,+127.0.0.1");\r
-       st.Bind(2,"Comma separated list of addresses and/or subnet masks that are allowed access to the administration pages.  Default is localhost only. + allows a host, - denies as host.");\r
+       st.Bind(2,"Comma separated list of addresses and/or subnet masks that are allowed access to the administration pages.  Default is localhost only. + allows a host, - denies a host.");\r
        st.Step();\r
        st.Reset();\r
 \r
@@ -710,6 +734,12 @@ void SetupDefaultOptions()
        st.Step();\r
        st.Reset();\r
 \r
+       st.Bind(0,"FProxyPort");\r
+       st.Bind(1,"8888");\r
+       st.Bind(2,"The port that Freenet is listening for http connections on.");\r
+       st.Step();\r
+       st.Reset();\r
+\r
        st.Bind(0,"MessageBase");\r
        st.Bind(1,"fms");\r
        st.Bind(2,"A unique string shared by all clients who want to communicate with each other.  This should not be changed unless you want to create your own separate communications network.");\r
index 13abc3d..c9d4684 100644 (file)
@@ -15,6 +15,8 @@ const std::string InsertedFilesPage::GeneratePage(const std::string &method, con
 \r
        std::string node="localhost";\r
        Option::Instance()->Get("FCPHost",node);\r
+       std::string fproxyport="8888";\r
+       Option::Instance()->Get("FProxyPort",fproxyport);\r
 \r
        while(st.RowReturned())\r
        {\r
@@ -26,7 +28,7 @@ const std::string InsertedFilesPage::GeneratePage(const std::string &method, con
                st.ResultText(1,filename);\r
                st.ResultText(2,sizestr);\r
 \r
-               content+="<a href=\"http://"+node+":8888/"+StringFunctions::UriEncode(key)+"\">"+SanitizeOutput(filename)+"</a> - "+sizestr+" bytes";\r
+               content+="<a href=\"http://"+node+":"+fproxyport+"/"+StringFunctions::UriEncode(key)+"\">"+SanitizeOutput(filename)+"</a> - "+sizestr+" bytes";\r
                content+="<br>";\r
 \r
                st.Step();\r
index 842df31..afb1c42 100644 (file)
@@ -24,6 +24,9 @@ const std::string PeerDetailsPage::GeneratePage(const std::string &method, const
        std::string hidden="";\r
        int freesiteedition=-1;\r
 \r
+       std::string fproxyport="8888";\r
+       Option::Instance()->Get("FProxyPort",fproxyport);\r
+\r
        if(queryvars.find("identityid")!=queryvars.end() && (*queryvars.find("identityid")).second!="")\r
        {\r
                identityidstr=(*queryvars.find("identityid")).second;\r
@@ -90,7 +93,7 @@ const std::string PeerDetailsPage::GeneratePage(const std::string &method, const
                content+="<tr><td>Public Key</td><td class=\"smaller\">"+SanitizeOutput(publickey)+"</td></tr>";\r
                if(usk!="")\r
                {\r
-                       content+="<tr><td>Freesite</td><td class=\"smaller\"><a href=\"http://"+fcphost+":8888/"+SanitizeOutput(usk)+"\">"+SanitizeOutput(usk)+"</a></td></tr>";\r
+                       content+="<tr><td>Freesite</td><td class=\"smaller\"><a href=\"http://"+fcphost+":"+fproxyport+"/"+SanitizeOutput(usk)+"\">"+SanitizeOutput(usk)+"</a></td></tr>";\r
                }\r
                content+="<tr><td>Date Added</td><td>"+dateadded+"</td></tr>";\r
                content+="<tr><td>Last Seen</td><td>"+lastseen+"</td></tr>";\r
index 5905021..c0bed87 100644 (file)
@@ -698,8 +698,19 @@ const bool Message::ParseNNTPMessage(const std::string &nntpmessage)
                // add a binary file attachment\r
                else if((*i)->GetName()!="" && (*i)->GetLength()>0 && (*i)->GetContent())\r
                {\r
+                       std::string contenttype="";\r
                        std::vector<unsigned char> data((*i)->GetContent(),(*i)->GetContent()+(*i)->GetContentLength());\r
-                       m_fileattachments.push_back(fileattachment((*i)->GetName(),data));\r
+                       if((*i)->GetContentType())\r
+                       {\r
+                               contenttype=(*i)->GetContentType();\r
+                               // find first ; tab cr or lf and erase it and everything after it\r
+                               std::string::size_type endpos=contenttype.find_first_of(";\t\r\n ");\r
+                               if(endpos!=std::string::npos)\r
+                               {\r
+                                       contenttype.erase(endpos);\r
+                               }\r
+                       }\r
+                       m_fileattachments.push_back(fileattachment((*i)->GetName(),contenttype,data));\r
                }\r
        }\r
 \r
@@ -743,13 +754,14 @@ const bool Message::StartFreenetInsert()
        st.Step();\r
 \r
        // insert file attachments into database\r
-       st=m_db->Prepare("INSERT INTO tblFileInserts(MessageUUID,FileName,Size,Data) VALUES(?,?,?,?);");\r
+       st=m_db->Prepare("INSERT INTO tblFileInserts(MessageUUID,FileName,Size,MimeType,Data) VALUES(?,?,?,?,?);");\r
        for(std::vector<fileattachment>::iterator i=m_fileattachments.begin(); i!=m_fileattachments.end(); i++)\r
        {\r
                st.Bind(0,m_messageuuid);\r
                st.Bind(1,(*i).m_filename);\r
                st.Bind(2,(long)(*i).m_data.size());\r
-               st.Bind(3,&((*i).m_data[0]),(*i).m_data.size());\r
+               st.Bind(3,(*i).m_mimetype);\r
+               st.Bind(4,&((*i).m_data[0]),(*i).m_data.size());\r
                st.Step();\r
                st.Reset();\r
        }\r