Url support #462

- Added TransportCurl for http, https and ftp
- Added url support for import command
This commit is contained in:
Johannes Schlatow
2010-10-04 02:17:08 +02:00
parent adc7992608
commit bf316974d9
10 changed files with 352 additions and 98 deletions

View File

@@ -34,6 +34,7 @@
#include <text.h>
#include <util.h>
#include <main.h>
#include "Transport.h"
extern Context context;
@@ -1267,10 +1268,25 @@ int handleImport (std::string &outs)
if (context.hooks.trigger ("pre-import-command"))
{
std::stringstream out;
// Use the description as a file name.
std::stringstream out;
// Use the description as a file name.
std::string file = trim (context.task.get ("description"));
#if FEATURE_URL > 0
std::string tmpfile = "";
Transport* transport;
if ((transport = Transport::getTransport (file)) != NULL )
{
std::string location (context.config.get ("data.location"));
tmpfile = location + "/import.data";
transport->recv (tmpfile);
delete transport;
file = tmpfile;
}
#endif
if (file.length () > 0)
{
// Load the file.
@@ -1325,6 +1341,13 @@ int handleImport (std::string &outs)
case text: out << importText (lines); break;
case not_a_clue: /* to stop the compiler from complaining. */ break;
}
#if FEATURE_URL > 0
if (tmpfile != "")
{
remove (tmpfile.c_str ());
}
#endif
}
else
throw std::string ("You must specify a file to import.");