library downloading: continue to improve backend API and implementation

This commit is contained in:
Paul Davis 2022-09-07 17:00:23 -06:00
parent 5563117a1b
commit fabd111b1f
2 changed files with 27 additions and 23 deletions

View File

@ -8,6 +8,8 @@
#include <vector>
#include <thread>
#include <boost/function.hpp>
#include <curl/curl.h>
namespace ARDOUR {
@ -15,8 +17,8 @@ namespace ARDOUR {
class LibraryDescription
{
public:
LibraryDescription (std::string const & n, std::string const & a, std::string const & d, std::string const & u, std::string const & l, std::string const & td)
: _name (n), _author (a), _description (d), _url (u), _license (l), _toplevel_dir (td), _installed (false) {}
LibraryDescription (std::string const & n, std::string const & a, std::string const & d, std::string const & u, std::string const & l, std::string const & td, std::string const & s)
: _name (n), _author (a), _description (d), _url (u), _license (l), _toplevel_dir (td), _size (s), _installed (false) {}
std::string const & name() const { return _name; }
std::string const & description() const { return _description; }
@ -24,6 +26,7 @@ class LibraryDescription
std::string const & url() const { return _url; }
std::string const & license() const { return _license; }
std::string const & toplevel_dir() const { return _toplevel_dir; }
std::string const & size() const { return _size; }
bool installed() const { return _installed; }
void set_installed (bool yn) { _installed = yn; }
@ -35,6 +38,7 @@ class LibraryDescription
std::string _url;
std::string _license;
std::string _toplevel_dir;
std::string _size;
bool _installed;
};

View File

@ -6,6 +6,8 @@
#include "pbd/i18n.h"
#include "pbd/file_archive.h"
#include "pbd/replace_all.h"
#include "pbd/whitespace.h"
#include "pbd/xml++.h"
#include "ardour/rc_configuration.h"
@ -61,35 +63,33 @@ LibraryFetcher::get_descriptions ()
XMLNode const & root (*tree.root());
for (auto const & node : root.children()) {
string n, d, u, l, td, a;
if (!node->get_property (X_("name"), n)) {
std::cerr << "no name\n";
continue;
}
if (!node->get_property (X_("author"), a)) {
std::cerr << "no author\n";
continue;
}
if (!node->get_property (X_("url"), u)) {
std::cerr << "no urln";
continue;
}
if (!node->get_property (X_("license"), l)) {
std::cerr << "no license\n";
string n, d, u, l, td, a, sz;
std::cerr << "See child node: " << node->name() << std::endl;
if (!node->get_property (X_("name"), n) ||
!node->get_property (X_("author"), a) ||
!node->get_property (X_("url"), u) ||
!node->get_property (X_("license"), l) ||
!node->get_property (X_("toplevel"), td) ||
!node->get_property (X_("size"), sz)) {
continue;
}
if (!node->get_property (X_("toplevel"), td)) {
std::cerr << "no topevel\n";
continue;
for (auto const & cnode : node->children()) {
if (cnode->is_content()) {
d = cnode->content();
break;
}
}
d = node->content();
string ds;
remove_extra_whitespace (d, ds);
strip_whitespace_edges (ds);
replace_all (ds, "\n", "");
_descriptions.push_back (LibraryDescription (n, a, d, u, l, td));
_descriptions.push_back (LibraryDescription (n, a, ds, u, l, td, sz));
_descriptions.back().set_installed (installed (_descriptions.back()));
std::cerr << "got description for " << _descriptions.back().name() << std::endl;
std::cerr << "got description for " << _descriptions.back().name() << " installed ? " << _descriptions.back().installed() << std::endl;
}
return 0;