Skip to content

Commit

Permalink
Merge branch 'more-engine-cpp' into stable #1866
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Feb 21, 2024
2 parents 226bfea + 28cc26f commit 6cb2eee
Show file tree
Hide file tree
Showing 10 changed files with 240 additions and 347 deletions.
3 changes: 1 addition & 2 deletions gnucash/gnucash-commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,8 @@ Gnucash::add_quotes (const bo_str& uri)
{
GncQuotes quotes;
std::cout << bl::format (bl::translate ("Found Finance::Quote version {1}.")) % quotes.version() << std::endl;
auto quote_sources = quotes.sources_as_glist();
auto quote_sources = quotes.sources();
gnc_quote_source_set_fq_installed (quotes.version().c_str(), quote_sources);
g_list_free_full (quote_sources, g_free);
quotes.fetch(qof_session_get_book(session));
if (quotes.had_failures())
std::cerr << quotes.report_failures() << std::endl;
Expand Down
3 changes: 1 addition & 2 deletions gnucash/gnucash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,8 @@ scm_run_gnucash (void *data, [[maybe_unused]] int argc, [[maybe_unused]] char **
gnc_update_splash_screen (checking, GNC_SPLASH_PERCENTAGE_UNKNOWN);
GncQuotes quotes;
auto found = (bl::format (std::string{_("Found Finance::Quote version {1}.")}) % quotes.version()).str();
auto quote_sources = quotes.sources_as_glist();
auto quote_sources = quotes.sources();
gnc_quote_source_set_fq_installed (quotes.version().c_str(), quote_sources);
g_list_free_full (quote_sources, g_free);
gnc_update_splash_screen (found.c_str(), GNC_SPLASH_PERCENTAGE_UNKNOWN);
}
catch (const GncQuoteException& err)
Expand Down
16 changes: 0 additions & 16 deletions libgnucash/app-utils/gnc-quotes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ class GncQuotesImpl

const std::string& version() noexcept { return m_quotesource->get_version(); }
const QuoteSources& sources() noexcept { return m_sources; }
GList* sources_as_glist ();
bool had_failures() noexcept { return !m_failures.empty(); }
const QFVec& failures() noexcept;
std::string report_failures() noexcept;
Expand Down Expand Up @@ -296,16 +295,6 @@ m_sources{}, m_book{book}, m_dflt_curr{gnc_default_currency()}
m_sources = m_quotesource->get_sources();
}

GList*
GncQuotesImpl::sources_as_glist()
{
GList* slist = nullptr;
std::for_each (m_sources.rbegin(), m_sources.rend(),
[&slist](const std::string& source) { slist = g_list_prepend (slist, g_strdup(source.c_str())); });
return slist;
}


void
GncQuotesImpl::fetch (QofBook *book)
{
Expand Down Expand Up @@ -1081,11 +1070,6 @@ const QuoteSources& GncQuotes::sources() noexcept
return m_impl->sources ();
}

GList* GncQuotes::sources_as_glist ()
{
return m_impl->sources_as_glist ();
}

GncQuotes::~GncQuotes() = default;

bool
Expand Down
7 changes: 0 additions & 7 deletions libgnucash/app-utils/gnc-quotes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ class GncQuotes
*/
const QuoteSources& sources() noexcept;

/** Get the available Finance::Quote sources as a GList
*
* @return A double-linked list containing the names of the installed quote sources.
* @note the list and its contents are owned by the caller and should be freed with `g_list_free_full(list, g_free)`.
*/
GList* sources_as_glist () ;

/** Report if there were quotes requested but not retrieved.
*
* @returns True if there were quote failures.
Expand Down
3 changes: 1 addition & 2 deletions libgnucash/app-utils/test/gtest-gnc-quotes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,8 @@ class GncQuotesTest : public ::testing::Test
gnc_commodity_set_quote_source(fkcm, source);
gnc_commodity_commit_edit(fkcm);
gnc_commodity_table_insert(comm_table, fkcm);
GList *sources = g_list_prepend(nullptr, (void*)"alphavantage");
std::vector<std::string> sources = {"alphavantage"};
gnc_quote_source_set_fq_installed("TestSuite", sources);
g_list_free(sources);
}
~GncQuotesTest() {
gnc_clear_current_session();
Expand Down
2 changes: 1 addition & 1 deletion libgnucash/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ set (engine_SOURCES
gnc-accounting-period.c
gnc-aqbanking-templates.cpp
gnc-budget.cpp
gnc-commodity.c
gnc-commodity.cpp
gnc-date.cpp
gnc-datetime.cpp
gnc-engine.c
Expand Down
Loading

0 comments on commit 6cb2eee

Please sign in to comment.