high-level API

APPLEMAIL-24 0.1
Volker Birk 4 years ago
parent e9e2e0a396
commit 76645b39e2

@ -19,8 +19,6 @@ namespace pEp {
using namespace std;
namespace io = boost::iostreams;
struct NoUpdateAvailable : runtime_error { };
struct product {
string name;
string url;

@ -2,24 +2,32 @@
// see LICENSE.txt
#include "downloadclient.hh"
#include "UpdateStream.hh"
#include <iostream>
#include <sstream>
namespace pEp {
namespace UpdateClient {
/*
istream update(const product& p)
string update(product p, PublicKey update_key)
{
UpdateStream us { UpdateDevice(p) };
try {
return UpdateStream(p);
}
catch (NoUpdateAvailable&) {
return stringstream(string(""));
us->open(update_key);
}
catch (exception&) { }
if (us->filename() == "")
throw DownloadError();
return us->filename();
}
string update(product p, string keyfile)
{
PublicKey update_key = load_key(keyfile);
return update(p, update_key);
}
*/
}
}

@ -10,7 +10,12 @@ namespace pEp {
namespace UpdateClient {
using namespace std;
istream update(const product& p);
struct DownloadError : runtime_error {
DownloadError() : runtime_error("download not possible") { }
};
string update(product p, PublicKey update_key);
string update(product p, string keyfile);
}
}

@ -3,14 +3,14 @@
#include <iostream>
#include <assert.h>
#include <cryptopp/files.h>
#include "UpdateStream.hh"
#include "downloadclient.cc"
using namespace std;
using namespace pEp::UpdateClient;
int main()
{
/*
product p { "pEp for Something", "https://fdik.org/cgidownload?hash=23232323234242" };
UpdateStream us { UpdateDevice(p) };
@ -30,6 +30,20 @@ int main()
str << us.rdbuf();
cout << str.str() << "\n";
}
*/
cout << "downloading...\n";
product p { "pEp for Something", "https://fdik.org/cgidownload?hash=23232323234242" };
try {
string filename = update(p, "public.der");
cout << "downloaded " << filename << "\n";
}
catch (DownloadError&)
{
cout << "cannot download\n";
}
return 0;
}

Loading…
Cancel
Save