Remove unused/never implemented QofBackend functions.

Note that the QofQuery functions that sort-of used them are ifdefed out
instead of deleted to serve as place-holders since we'll be bringing
back backend querying later.
This commit is contained in:
John Ralls
2016-07-18 09:49:41 -07:00
parent eed4a012c3
commit c0a193c593
9 changed files with 18 additions and 116 deletions

View File

@@ -1766,22 +1766,11 @@ init_sql_backend (GncDbiBackend* dbi_be)
be->commit = gnc_dbi_commit_edit;
be->rollback = gnc_dbi_rollback_edit;
/* The gda backend will not be multi-user (for now)... */
be->events_pending = nullptr;
be->process_events = nullptr;
/* The SQL/DBI backend doesn't need to be synced until it is
* configured for multiuser access. */
be->sync = gnc_dbi_safe_sync_all;
be->safe_sync = gnc_dbi_safe_sync_all;
// be->compile_query = gnc_sql_compile_query;
// be->run_query = gnc_sql_run_query;
// be->free_query = gnc_sql_free_query;
be->compile_query = nullptr;
be->run_query = nullptr;
be->free_query = nullptr;
/* CoA Export function not implemented for the SQL backend. */
be->export_fn = nullptr;
gnc_sql_init (&dbi_be->sql_be);

View File

@@ -634,8 +634,8 @@ test_gnc_sql_convert_timespec_to_string ()
{
GncSqlBackend be = {{
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, ERR_BACKEND_NO_ERR, nullptr, 0, nullptr, nullptr
nullptr, nullptr, nullptr, nullptr, ERR_BACKEND_NO_ERR, nullptr,
0, nullptr
},
nullptr, nullptr, FALSE, FALSE, FALSE, 0, 0, nullptr,
"%4d-%02d-%02d %02d:%02d:%02d"

View File

@@ -1243,15 +1243,6 @@ QofXmlBackendProvider::create_backend(void)
be->commit = NULL;
be->rollback = xml_rollback_edit;
/* The file backend always loads all data ... */
be->compile_query = NULL;
be->free_query = NULL;
be->run_query = NULL;
/* The file backend will never be multi-user... */
be->events_pending = NULL;
be->process_events = NULL;
be->sync = xml_sync_all;
be->export_fn = gnc_xml_be_write_accounts_to_file;

View File

@@ -259,16 +259,12 @@ struct QofBackend_s
void (*commit) (QofBackend *, QofInstance *);
void (*rollback) (QofBackend *, QofInstance *);
gpointer (*compile_query) (QofBackend *, QofQuery *);
void (*free_query) (QofBackend *, gpointer);
void (*run_query) (QofBackend *, gpointer);
void (*sync) (QofBackend *, /*@ dependent @*/ QofBook *);
void (*safe_sync) (QofBackend *, /*@ dependent @*/ QofBook *);
gboolean (*events_pending) (QofBackend *);
gboolean (*process_events) (QofBackend *);
/* This is implented only in the XML backend where it exports only a chart
* of accounts.
*/
void (*export_fn) (QofBackend *, QofBook *);
QofBePercentageFunc percentage;
QofBackendError last_err;
@@ -279,24 +275,6 @@ struct QofBackend_s
* This holds the filepath and communicates it to the frontends.
*/
char * fullpath;
/** \deprecated price_lookup should be removed during the redesign
* of the SQL backend... prices can now be queried using
* the generic query mechanism.
*
* Note the correct signature for this call is
* void (*price_lookup) (QofBackend *, GNCPriceLookup *);
* we use gpointer to avoid an unwanted include file dependency.
*/
void (*price_lookup) (QofBackend *, gpointer);
/** \deprecated Export should really _NOT_ be here, but is left here for now.
* I'm not sure where this should be going to. It should be
* removed ASAP. This is a temporary hack-around until period-closing
* is fully implemented.
*/
void (*export_fn) (QofBackend *, QofBook *);
};
#ifdef __cplusplus

View File

@@ -150,24 +150,15 @@ qof_backend_init(QofBackend *be)
be->commit = NULL;
be->rollback = NULL;
be->compile_query = NULL;
be->free_query = NULL;
be->run_query = NULL;
be->sync = NULL;
be->safe_sync = NULL;
be->events_pending = NULL;
be->process_events = NULL;
be->export_fn = NULL;
be->last_err = ERR_BACKEND_NO_ERR;
if (be->error_msg) g_free (be->error_msg);
be->error_msg = NULL;
be->percentage = NULL;
/* to be removed */
be->price_lookup = NULL;
be->export_fn = NULL;
}
void

View File

@@ -548,7 +548,7 @@ static void compile_terms (QofQuery *q)
compile_sort (&(q->tertiary_sort), q->search_for);
q->defaultSort = qof_class_get_default_sort (q->search_for);
#ifdef QOF_BACKEND_QUERY
/* Now compile the backend instances */
for (node = q->books; node; node = node->next)
{
@@ -561,7 +561,9 @@ static void compile_terms (QofQuery *q)
if (result)
g_hash_table_insert (q->be_compiled, book, result);
}
}
#endif
LEAVE (" query=%p", q);
}
@@ -621,12 +623,13 @@ static GList * merge_books (GList *l1, GList *l2)
static gboolean
query_free_compiled (gpointer key, gpointer value, gpointer not_used)
{
#ifdef QOF_BACKEND_QUERY
QofBook* book = static_cast<QofBook*>(key);
QofBackend* be = book->backend;
if (be && be->free_query)
(be->free_query)(be, value);
#endif
return TRUE;
}
@@ -822,9 +825,10 @@ static void qof_query_run_cb(QofQueryCB* qcb, gpointer cb_arg)
for (node = qcb->query->books; node; node = node->next)
{
QofBook* book = static_cast<QofBook*>(node->data);
#ifdef QOF_BACKEND_QUERY
QofBackend* be = book->backend;
/* run the query in the backend */
if (be)
{
gpointer compiled_query = g_hash_table_lookup (qcb->query->be_compiled,
@@ -835,7 +839,7 @@ static void qof_query_run_cb(QofQueryCB* qcb, gpointer cb_arg)
(be->run_query) (be, compiled_query);
}
}
#endif
/* And then iterate over all the objects */
qof_object_foreach (qcb->query->search_for, book,
(QofInstanceForeachCB) check_item_cb, qcb);

View File

@@ -538,19 +538,13 @@ QofSessionImpl::swap_books (QofSessionImpl & other) noexcept
bool
QofSessionImpl::events_pending () const noexcept
{
auto backend = qof_book_get_backend (m_book);
if (!backend) return false;
if (!backend->events_pending) return false;
return backend->events_pending (backend);
return false;
}
bool
QofSessionImpl::process_events () const noexcept
{
auto backend = qof_book_get_backend (m_book);
if (!backend) return false;
if (!backend->process_events) return false;
return backend->process_events (backend);
return false;
}
/* XXX This exports the list of accounts to a file. It does not

View File

@@ -681,44 +681,6 @@ mock_events_fn (QofBackend *be)
return TRUE;
}
static void
test_qof_session_events (Fixture *fixture, gconstpointer pData)
{
QofBackend *be = NULL;
g_test_message ("Test pending events null checks");
g_assert (!qof_session_events_pending (NULL));
g_assert (!qof_book_get_backend (qof_session_get_book (fixture->session)));
g_assert (!qof_session_events_pending (fixture->session));
be = g_new0 (QofBackend, 1);
g_assert (be);
be->events_pending = NULL;
qof_book_set_backend (qof_session_get_book (fixture->session), be);
g_assert (!qof_session_events_pending (fixture->session));
g_test_message ("Test pending events callback");
be->events_pending = mock_events_fn;
events_struct.called = FALSE;
events_struct.be = be;
g_assert (qof_session_events_pending (fixture->session));
g_assert (events_struct.called);
g_test_message ("Test process events null checks");
g_assert (!qof_session_process_events (NULL));
qof_book_set_backend (qof_session_get_book (fixture->session), NULL);
g_assert (!qof_session_process_events (fixture->session));
be->process_events = NULL;
qof_book_set_backend (qof_session_get_book (fixture->session), be);
g_assert (!qof_session_process_events (fixture->session));
g_test_message ("Test process events callback");
be->process_events = mock_events_fn;
events_struct.called = FALSE;
events_struct.be = be;
g_assert (qof_session_process_events (fixture->session));
g_assert (events_struct.called);
}
static struct
{
QofBackend *be;
@@ -854,7 +816,6 @@ test_suite_qofsession ( void )
GNC_TEST_ADD (suitename, "qof session end", Fixture, NULL, setup, test_qof_session_end, teardown);
GNC_TEST_ADD (suitename, "qof session export", Fixture, NULL, setup, test_qof_session_export, teardown);
GNC_TEST_ADD (suitename, "qof session swap data", Fixture, NULL, setup, test_qof_session_swap_data, teardown);
GNC_TEST_ADD (suitename, "qof session events", Fixture, NULL, setup, test_qof_session_events, teardown);
GNC_TEST_ADD (suitename, "qof session data loaded", Fixture, NULL, setup, test_qof_session_data_loaded, teardown);
GNC_TEST_ADD (suitename, "qof session get book", Fixture, NULL, setup, test_qof_session_get_book, teardown);
GNC_TEST_ADD (suitename, "qof session get error", Fixture, NULL, setup, test_qof_session_get_error, teardown);

View File

@@ -77,14 +77,8 @@ QofBackend * test_backend_factory ()
ret->begin = nullptr;
ret->commit = nullptr;
ret->rollback = nullptr;
ret->compile_query = nullptr;
ret->free_query = nullptr;
ret->run_query = nullptr;
ret->events_pending = nullptr;
ret->process_events = nullptr;
ret->percentage = nullptr;
ret->config_count = 0;
ret->price_lookup = nullptr;
return ret;
}