The attached patch has two purposes. One is to add a new field 'timestamp'
that will be filled in on upload with the number of seconds since the unix
epoch as a decimal at the time of the upload.
The second is when returning a campaign download, the persistant attributes
(not size, downloads or passphrase) attached to the campaign (in the config
file) are returned as attributes of the response. This allows the client
to save information about the version of the campaign actually downloaded,
rather than the version that existed when the campaign list request was
made.
This should not break anything for existing clients.
I have already changed campaign web interface to make use of this information
if it is available. This will allow sorting campaigns by when they were
last updated.
Only src/campaign_server/campaign_server.cpp is touched by this patch.
*** campaign_server.cpp 2005-10-05 22:39:25.000000000 -0500
--- campaign_server.cpp.orig    2005-10-05 21:39:37.000000000 -0500
***************
*** 118,124 ****
  
                                } else if(data.child("request_terms") != NULL) {
                                        
network::send_data(construct_message("All campaigns uploaded to this server 
must be licensed under the terms of the GNU General Public License (GPL). By 
uploading content to this server, you certify that you have the right to place 
the content under the conditions of the GPL, and choose to do so."),sock);
!                               } else if(config* upload = 
data.child("upload")) {
                                        config* campaign = 
campaigns().find_child("campaign","name",(*upload)["name"]);
                                        if(campaign != NULL && 
(*campaign)["passphrase"] != (*upload)["passphrase"]) {
                                                
network::send_data(construct_error("The campaign already exists, and your 
passphrase was incorrect."),sock);
--- 118,124 ----
  
                                } else if(data.child("request_terms") != NULL) {
                                        
network::send_data(construct_message("All campaigns uploaded to this server 
must be licensed under the terms of the GNU General Public License (GPL). By 
uploading content to this server, you certify that you have the right to place 
the content under the conditions of the GPL, and choose to do so."),sock);
!                               } else if(const config* upload = 
data.child("upload")) {
                                        config* campaign = 
campaigns().find_child("campaign","name",(*upload)["name"]);
                                        if(campaign != NULL && 
(*campaign)["passphrase"] != (*upload)["passphrase"]) {
                                                
network::send_data(construct_error("The campaign already exists, and your 
passphrase was incorrect."),sock);
***************
*** 141,158 ****
                                                
if((*campaign)["downloads"].empty()) {
                                                        
(*campaign)["downloads"] = "0";
                                                }
-                                               (*campaign)["timestamp"] = 
lexical_cast<std::string>(time(NULL));
  
!                                               config* data = 
upload->child("data");
                                                if(data != NULL) {
                                                        std::string filename = 
(*campaign)["filename"];
-                                                       (*data)["title"] = 
(*campaign)["title"];
-                                                       (*data)["name"] = 
(*campaign)["name"];
-                                                       (*data)["author"] = 
(*campaign)["author"];
-                                                       (*data)["description"] 
= (*campaign)["description"];
-                                                       (*data)["version"] = 
(*campaign)["version"];
-                                                       (*data)["timestamp"] = 
(*campaign)["timestamp"];
-                                                       (*data)["icon"] = 
(*campaign)["icon"];
                                                        {
                                                                scoped_ostream 
campaign_file = ostream_file(filename);
                                                                
write_compressed(*campaign_file, *data);
--- 141,150 ----
                                                
if((*campaign)["downloads"].empty()) {
                                                        
(*campaign)["downloads"] = "0";
                                                }
  
!                                               const config* const data = 
upload->child("data");
                                                if(data != NULL) {
                                                        std::string filename = 
(*campaign)["filename"];
                                                        {
                                                                scoped_ostream 
campaign_file = ostream_file(filename);
                                                                
write_compressed(*campaign_file, *data);

Reply via email to