mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[gnc-commodity.cpp] gnc_quote_source_set_fq_installed takes a StrVec
instead of a GList* of strdup'd chars
This commit is contained in:
parent
47a1a56f16
commit
346499ae04
@ -361,9 +361,8 @@ Gnucash::add_quotes (const bo_str& uri)
|
|||||||
{
|
{
|
||||||
GncQuotes quotes;
|
GncQuotes quotes;
|
||||||
std::cout << bl::format (bl::translate ("Found Finance::Quote version {1}.")) % quotes.version() << std::endl;
|
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);
|
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));
|
quotes.fetch(qof_session_get_book(session));
|
||||||
if (quotes.had_failures())
|
if (quotes.had_failures())
|
||||||
std::cerr << quotes.report_failures() << std::endl;
|
std::cerr << quotes.report_failures() << std::endl;
|
||||||
|
@ -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);
|
gnc_update_splash_screen (checking, GNC_SPLASH_PERCENTAGE_UNKNOWN);
|
||||||
GncQuotes quotes;
|
GncQuotes quotes;
|
||||||
auto found = (bl::format (std::string{_("Found Finance::Quote version {1}.")}) % quotes.version()).str();
|
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);
|
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);
|
gnc_update_splash_screen (found.c_str(), GNC_SPLASH_PERCENTAGE_UNKNOWN);
|
||||||
}
|
}
|
||||||
catch (const GncQuoteException& err)
|
catch (const GncQuoteException& err)
|
||||||
|
@ -127,9 +127,8 @@ protected:
|
|||||||
gnc_commodity_set_quote_source(fkcm, source);
|
gnc_commodity_set_quote_source(fkcm, source);
|
||||||
gnc_commodity_commit_edit(fkcm);
|
gnc_commodity_commit_edit(fkcm);
|
||||||
gnc_commodity_table_insert(comm_table, 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);
|
gnc_quote_source_set_fq_installed("TestSuite", sources);
|
||||||
g_list_free(sources);
|
|
||||||
}
|
}
|
||||||
~GncQuotesTest() {
|
~GncQuotesTest() {
|
||||||
gnc_clear_current_session();
|
gnc_clear_current_session();
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include <qofinstance-p.h>
|
#include <qofinstance-p.h>
|
||||||
|
|
||||||
|
#include "gnc-commodity.hpp"
|
||||||
#include "gnc-commodity.h"
|
#include "gnc-commodity.h"
|
||||||
#include "gnc-locale-utils.h"
|
#include "gnc-locale-utils.h"
|
||||||
#include "gnc-prefs.h"
|
#include "gnc-prefs.h"
|
||||||
@ -537,15 +538,11 @@ gnc_quote_source_get_internal_name (const gnc_quote_source *source)
|
|||||||
********************************************************************/
|
********************************************************************/
|
||||||
void
|
void
|
||||||
gnc_quote_source_set_fq_installed (const char* version_string,
|
gnc_quote_source_set_fq_installed (const char* version_string,
|
||||||
const GList *sources_list)
|
const std::vector<std::string>& sources_list)
|
||||||
{
|
{
|
||||||
gnc_quote_source *source;
|
|
||||||
char *source_name;
|
|
||||||
const GList *node;
|
|
||||||
|
|
||||||
ENTER(" ");
|
ENTER(" ");
|
||||||
|
|
||||||
if (!sources_list)
|
if (sources_list.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (version_string)
|
if (version_string)
|
||||||
@ -553,11 +550,11 @@ gnc_quote_source_set_fq_installed (const char* version_string,
|
|||||||
else
|
else
|
||||||
fq_version.clear();
|
fq_version.clear();
|
||||||
|
|
||||||
for (node = sources_list; node; node = node->next)
|
for (const auto& source_name_str : sources_list)
|
||||||
{
|
{
|
||||||
source_name = static_cast<char*>(node->data);
|
auto source_name = source_name_str.c_str();
|
||||||
|
auto source = gnc_quote_source_lookup_by_internal(source_name);
|
||||||
|
|
||||||
source = gnc_quote_source_lookup_by_internal(source_name);
|
|
||||||
if (source != NULL)
|
if (source != NULL)
|
||||||
{
|
{
|
||||||
DEBUG("Found source %s: %s", source_name, source->user_name);
|
DEBUG("Found source %s: %s", source_name, source->user_name);
|
||||||
|
@ -158,18 +158,6 @@ gboolean gnc_quote_source_fq_installed (void);
|
|||||||
*/
|
*/
|
||||||
const char* gnc_quote_source_fq_version (void);
|
const char* gnc_quote_source_fq_version (void);
|
||||||
|
|
||||||
/** Update gnucash internal tables based on what Finance::Quote
|
|
||||||
* sources are installed. Sources that have been explicitly coded
|
|
||||||
* into gnucash are marked sensitive/insensitive based upon whether
|
|
||||||
* they are present. New sources that gnucash doesn't know about are
|
|
||||||
* added to its internal tables.
|
|
||||||
*
|
|
||||||
* @param sources_list A list of strings containing the source names
|
|
||||||
* as they are known to F::Q.
|
|
||||||
*/
|
|
||||||
void gnc_quote_source_set_fq_installed (const char* version_string,
|
|
||||||
const GList *sources_list);
|
|
||||||
|
|
||||||
/** Return the number of entries for a given type of quote source.
|
/** Return the number of entries for a given type of quote source.
|
||||||
*
|
*
|
||||||
* @param type The quote source type whose count should be returned.
|
* @param type The quote source type whose count should be returned.
|
||||||
|
@ -39,6 +39,18 @@
|
|||||||
|
|
||||||
using CommVec = std::vector<gnc_commodity*>;
|
using CommVec = std::vector<gnc_commodity*>;
|
||||||
|
|
||||||
|
/** Update gnucash internal tables based on what Finance::Quote
|
||||||
|
* sources are installed. Sources that have been explicitly coded
|
||||||
|
* into gnucash are marked sensitive/insensitive based upon whether
|
||||||
|
* they are present. New sources that gnucash doesn't know about are
|
||||||
|
* added to its internal tables.
|
||||||
|
*
|
||||||
|
* @param sources_list A list of strings containing the source names
|
||||||
|
* as they are known to F::Q.
|
||||||
|
*/
|
||||||
|
void gnc_quote_source_set_fq_installed (const char* version_string,
|
||||||
|
const std::vector<std::string>& sources_list);
|
||||||
|
|
||||||
#endif /* GNC_COMMODITY_HPP */
|
#endif /* GNC_COMMODITY_HPP */
|
||||||
/** @} */
|
/** @} */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
Loading…
Reference in New Issue
Block a user