gnucash-commands.cpp (gnucash-5.0.tar.bz2) | : | gnucash-commands.cpp (gnucash-5.1.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 343 | skipping to change at line 343 | |||
{ | { | |||
gnc_prefs_init (); | gnc_prefs_init (); | |||
qof_event_suspend(); | qof_event_suspend(); | |||
auto session = gnc_get_current_session(); | auto session = gnc_get_current_session(); | |||
if (!session) | if (!session) | |||
return 1; | return 1; | |||
qof_session_begin(session, uri->c_str(), SESSION_NORMAL_OPEN); | qof_session_begin(session, uri->c_str(), SESSION_NORMAL_OPEN); | |||
if (qof_session_get_error(session) != ERR_BACKEND_NO_ERR) | if (qof_session_get_error(session) != ERR_BACKEND_NO_ERR) | |||
cleanup_and_exit_with_failure (session); | return cleanup_and_exit_with_failure (session); | |||
qof_session_load(session, NULL); | qof_session_load(session, NULL); | |||
if (qof_session_get_error(session) != ERR_BACKEND_NO_ERR) | if (qof_session_get_error(session) != ERR_BACKEND_NO_ERR) | |||
cleanup_and_exit_with_failure (session); | return cleanup_and_exit_with_failure (session); | |||
try | try | |||
{ | { | |||
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_as_glist(); | |||
gnc_quote_source_set_fq_installed (quotes.version().c_str(), quote_sourc es); | gnc_quote_source_set_fq_installed (quotes.version().c_str(), quote_sourc es); | |||
g_list_free_full (quote_sources, g_free); | 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; | |||
} | } | |||
catch (const GncQuoteException& err) | catch (const GncQuoteException& err) | |||
{ | { | |||
std::cerr << bl::translate("Price retrieval failed: ") << err.what() << std::endl; | std::cerr << bl::translate("Price retrieval failed: ") << err.what() << std::endl; | |||
} | } | |||
qof_session_save(session, NULL); | qof_session_save(session, NULL); | |||
if (qof_session_get_error(session) != ERR_BACKEND_NO_ERR) | if (qof_session_get_error(session) != ERR_BACKEND_NO_ERR) | |||
cleanup_and_exit_with_failure (session); | return cleanup_and_exit_with_failure (session); | |||
qof_session_destroy(session); | qof_session_destroy(session); | |||
qof_event_resume(); | qof_event_resume(); | |||
return 0; | return 0; | |||
} | } | |||
int | int | |||
Gnucash::report_quotes (const char* source, const StrVec& commodities, bool verb ose) | Gnucash::report_quotes (const char* source, const StrVec& commodities, bool verb ose) | |||
{ | { | |||
gnc_prefs_init(); | gnc_prefs_init(); | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 3 lines changed or added |