mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Collapse the various "version" and "version_check" fields into a
single pair of fields attached to the QofInstance object. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16041 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
62dce55fb8
commit
cad2164810
@ -56,6 +56,8 @@ enum {
|
||||
PROP_DESTROYING,
|
||||
PROP_DIRTY,
|
||||
PROP_INFANT,
|
||||
PROP_VERSION,
|
||||
PROP_VERSION_CHECK,
|
||||
};
|
||||
|
||||
typedef struct QofInstancePrivate
|
||||
@ -94,6 +96,11 @@ typedef struct QofInstancePrivate
|
||||
|
||||
/* True iff this instance has never been committed. */
|
||||
gboolean infant;
|
||||
|
||||
/* version number, used for tracking multiuser updates */
|
||||
gint32 version;
|
||||
guint32 version_check; /* data aging timestamp */
|
||||
|
||||
} QofInstancePrivate;
|
||||
|
||||
#define GET_PRIVATE(o) \
|
||||
@ -211,6 +218,28 @@ static void qof_instance_class_init(QofInstanceClass *klass)
|
||||
"state of the data file.",
|
||||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class,
|
||||
PROP_VERSION,
|
||||
g_param_spec_int ("version",
|
||||
"Version",
|
||||
"The version number of the current instance state.",
|
||||
0,
|
||||
G_MAXINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class,
|
||||
PROP_VERSION_CHECK,
|
||||
g_param_spec_uint ("version-check",
|
||||
"Version Check",
|
||||
"The version check number of the current instance state.",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -343,6 +372,12 @@ qof_instance_get_property (GObject *object,
|
||||
case PROP_INFANT:
|
||||
g_value_set_boolean(value, priv->infant);
|
||||
break;
|
||||
case PROP_VERSION:
|
||||
g_value_set_int(value, priv->version);
|
||||
break;
|
||||
case PROP_VERSION_CHECK:
|
||||
g_value_set_uint(value, priv->version_check);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
@ -387,6 +422,12 @@ qof_instance_set_property (GObject *object,
|
||||
case PROP_DIRTY:
|
||||
qof_instance_set_dirty(inst);
|
||||
break;
|
||||
case PROP_VERSION:
|
||||
qof_instance_set_version(inst, g_value_get_int(value));
|
||||
break;
|
||||
case PROP_VERSION_CHECK:
|
||||
qof_instance_set_version_check(inst, g_value_get_uint(value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
@ -427,8 +468,6 @@ qof_instance_set_guid (gpointer ptr, const GUID *guid)
|
||||
void
|
||||
qof_instance_copy_guid (gpointer to, gconstpointer from)
|
||||
{
|
||||
QofInstancePrivate *to_priv, *from_priv;
|
||||
|
||||
g_return_if_fail(QOF_IS_INSTANCE(to));
|
||||
g_return_if_fail(QOF_IS_INSTANCE(from));
|
||||
|
||||
@ -677,6 +716,70 @@ qof_instance_get_infant(const QofInstance *inst)
|
||||
return GET_PRIVATE(inst)->infant;
|
||||
}
|
||||
|
||||
gint32
|
||||
qof_instance_get_version (gconstpointer inst)
|
||||
{
|
||||
g_return_val_if_fail(QOF_IS_INSTANCE(inst), 0);
|
||||
return GET_PRIVATE(inst)->version;
|
||||
}
|
||||
|
||||
gint
|
||||
qof_instance_compare_version (gconstpointer inst1, gconstpointer inst2)
|
||||
{
|
||||
g_return_val_if_fail(QOF_IS_INSTANCE(inst1), 1);
|
||||
g_return_val_if_fail(QOF_IS_INSTANCE(inst2), -1);
|
||||
return GET_PRIVATE(inst2)->version - GET_PRIVATE(inst1)->version;
|
||||
}
|
||||
|
||||
void
|
||||
qof_instance_set_version (gpointer inst, gint32 vers)
|
||||
{
|
||||
g_return_if_fail(QOF_IS_INSTANCE(inst));
|
||||
GET_PRIVATE(inst)->version = vers;
|
||||
}
|
||||
|
||||
void
|
||||
qof_instance_copy_version (gpointer to, gconstpointer from)
|
||||
{
|
||||
g_return_if_fail(QOF_IS_INSTANCE(to));
|
||||
g_return_if_fail(QOF_IS_INSTANCE(from));
|
||||
GET_PRIVATE(to)->version = GET_PRIVATE(from)->version;
|
||||
}
|
||||
|
||||
void
|
||||
qof_instance_increment_version (gpointer inst, guint32 new_check)
|
||||
{
|
||||
QofInstancePrivate *priv;
|
||||
|
||||
g_return_if_fail(QOF_IS_INSTANCE(inst));
|
||||
|
||||
priv = GET_PRIVATE(inst);
|
||||
priv->version++;
|
||||
priv->version_check = new_check;
|
||||
}
|
||||
|
||||
guint32
|
||||
qof_instance_get_version_check (gconstpointer inst)
|
||||
{
|
||||
g_return_val_if_fail(QOF_IS_INSTANCE(inst), 0);
|
||||
return GET_PRIVATE(inst)->version_check;
|
||||
}
|
||||
|
||||
void
|
||||
qof_instance_set_version_check (gpointer inst, guint32 value)
|
||||
{
|
||||
g_return_if_fail(QOF_IS_INSTANCE(inst));
|
||||
GET_PRIVATE(inst)->version_check = value;
|
||||
}
|
||||
|
||||
void
|
||||
qof_instance_copy_version_check (gpointer to, gconstpointer from)
|
||||
{
|
||||
g_return_if_fail(QOF_IS_INSTANCE(to));
|
||||
g_return_if_fail(QOF_IS_INSTANCE(from));
|
||||
GET_PRIVATE(to)->version_check = GET_PRIVATE(from)->version_check;
|
||||
}
|
||||
|
||||
/* ========================================================== */
|
||||
|
||||
void
|
||||
|
@ -198,6 +198,26 @@ gboolean qof_instance_check_edit(const QofInstance *inst);
|
||||
|
||||
gboolean qof_instance_get_infant(const QofInstance *inst);
|
||||
|
||||
/** Get the version number on this instance. The version number is
|
||||
* used to manage multi-user updates. */
|
||||
gint32 qof_instance_get_version (gconstpointer inst);
|
||||
/** Compare the version numbers of two instances. */
|
||||
gint qof_instance_compare_version (gconstpointer inst1, gconstpointer inst2);
|
||||
/** Set the version number on this instance. The version number is
|
||||
* used to manage multi-user updates. */
|
||||
void qof_instance_set_version (gpointer inst, gint32 value);
|
||||
/** Copy the version number on this instance. The version number is
|
||||
* used to manage multi-user updates. */
|
||||
void qof_instance_copy_version (gpointer to, gconstpointer from);
|
||||
/** Increment the instance version number */
|
||||
void qof_instance_increment_version (gpointer inst, guint32 new_check);
|
||||
/** Get the instance version_check number */
|
||||
guint32 qof_instance_get_version_check (gconstpointer inst);
|
||||
/** Set the instance version_check number */
|
||||
void qof_instance_set_version_check (gpointer inst, guint32 value);
|
||||
/** copy the instance version_check number */
|
||||
void qof_instance_copy_version_check (gpointer to, gconstpointer from);
|
||||
|
||||
/** Pair things up. This routine inserts a kvp value into each instance
|
||||
* containing the guid of the other. In this way, if one has one of the
|
||||
* pair, one can always find the other by looking up it's guid. Typically,
|
||||
|
@ -445,7 +445,7 @@ query_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
{
|
||||
gint32 db_version, cache_version;
|
||||
db_version = atoi (DB_GET_VAL("version",j));
|
||||
cache_version = xaccTransGetVersion (trans);
|
||||
cache_version = qof_instance_get_version (trans);
|
||||
if (db_version <= cache_version) {
|
||||
return qd;
|
||||
}
|
||||
@ -465,7 +465,7 @@ query_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
xaccTransSetDatePostedTS (trans, &ts);
|
||||
ts = gnc_iso8601_to_timespec_gmt (DB_GET_VAL("date_entered",j));
|
||||
xaccTransSetDateEnteredTS (trans, &ts);
|
||||
xaccTransSetVersion (trans, atoi(DB_GET_VAL("version",j)));
|
||||
qof_instance_set_version (trans, atoi(DB_GET_VAL("version",j)));
|
||||
trans->idata = atoi(DB_GET_VAL("iguid",j));
|
||||
|
||||
currency = gnc_string_to_commodity (DB_GET_VAL("currency",j),
|
||||
|
@ -102,8 +102,8 @@ pgendStoreAccountNoLock (PGBackend *be, Account *acct,
|
||||
{
|
||||
if (0 < pgendAccountCompareVersion (be, acct)) return;
|
||||
}
|
||||
gnc_account_increment_version(acct); /* be sure to update the version !! */
|
||||
gnc_account_set_version_check(acct, be->version_check);
|
||||
/* be sure to update the version !! */
|
||||
qof_instance_increment_version(acct, be->version_check);
|
||||
|
||||
if ((0 == acct->idata) &&
|
||||
(FALSE == kvp_frame_is_empty (xaccAccountGetSlots(acct))))
|
||||
@ -300,7 +300,7 @@ get_account_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
xaccAccountSetType(acc, xaccAccountStringToEnum(DB_GET_VAL("type",j)));
|
||||
if (commodity)
|
||||
xaccAccountSetCommodity(acc, commodity);
|
||||
xaccAccountSetVersion(acc, atoi(DB_GET_VAL("version",j)));
|
||||
qof_instance_set_version(acc, atoi(DB_GET_VAL("version",j)));
|
||||
acc->idata = atoi(DB_GET_VAL("iguid",j));
|
||||
|
||||
/* try to find the parent account */
|
||||
@ -494,7 +494,7 @@ pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid)
|
||||
{
|
||||
/* save some performance, don't go to the
|
||||
* backend if the data is recent. */
|
||||
guint32 value = gnc_account_get_version_check(acc);
|
||||
guint32 value = qof_instance_get_version_check(acc);
|
||||
if (MAX_VERSION_AGE >= be->version_check - value)
|
||||
{
|
||||
PINFO ("fresh data, skip check");
|
||||
@ -528,7 +528,7 @@ pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid)
|
||||
acc->inst.kvp_data = pgendKVPFetch (be, acc->idata, acc->inst.kvp_data);
|
||||
}
|
||||
|
||||
gnc_account_set_version_check(acc, be->version_check);
|
||||
qof_instance_set_version_check(acc, be->version_check);
|
||||
}
|
||||
}
|
||||
|
||||
@ -591,8 +591,8 @@ pgend_account_commit_edit (QofBackend * bend,
|
||||
LEAVE ("rolled back");
|
||||
return;
|
||||
}
|
||||
gnc_account_increment_version(acct); /* be sure to update the version !! */
|
||||
gnc_account_set_version_check(acct, be->version_check);
|
||||
/* be sure to update the version !! */
|
||||
qof_instance_increment_version(acct, be->version_check);
|
||||
|
||||
if (qof_instance_get_destroying(acct))
|
||||
{
|
||||
|
@ -143,8 +143,8 @@ pgendStorePriceNoLock (PGBackend *be, GNCPrice *pr,
|
||||
{
|
||||
if (0 < pgendPriceCompareVersion (be, pr)) return;
|
||||
}
|
||||
pr->version ++; /* be sure to update the version !! */
|
||||
pr->version_check = be->version_check;
|
||||
/* be sure to update the version !! */
|
||||
qof_instance_increment_version(pr, be->version_check);
|
||||
|
||||
/* make sure that we've stored the commodity
|
||||
* and currency before we store the price.
|
||||
@ -287,7 +287,7 @@ get_price_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
|
||||
/* compare versions. Hack alert -- Not sure how to handle failures */
|
||||
sql_vers = atoi (DB_GET_VAL("version",j));
|
||||
local_vers = gnc_price_get_version(pr);
|
||||
local_vers = qof_instance_get_version(pr);
|
||||
if (sql_vers < local_vers) {
|
||||
PERR ("local price version is higher than db !!! local=%d sql=%d",
|
||||
local_vers, sql_vers);
|
||||
@ -295,7 +295,7 @@ get_price_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
gnc_price_unref (pr);
|
||||
return data;
|
||||
}
|
||||
gnc_price_set_version (pr, sql_vers);
|
||||
qof_instance_set_version (pr, sql_vers);
|
||||
|
||||
modity = gnc_string_to_commodity (DB_GET_VAL("commodity",j), book);
|
||||
gnc_price_set_commodity (pr, modity);
|
||||
@ -493,8 +493,8 @@ pgend_price_commit_edit (QofBackend * bend, GNCPrice *pr)
|
||||
qof_backend_set_error (&be->be, ERR_BACKEND_MODIFIED);
|
||||
return;
|
||||
}
|
||||
pr->version ++; /* be sure to update the version !! */
|
||||
pr->version_check = be->version_check;
|
||||
/* be sure to update the version !! */
|
||||
qof_instance_increment_version(pr, be->version_check);
|
||||
|
||||
if (qof_instance_get_destroying(pr))
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ define(`account', `gncAccount, Account, Account, a,
|
||||
description, , char *, xaccAccountGetDescription(ptr),
|
||||
type, , char *, xaccAccountTypeEnumAsString(xaccAccountGetType(ptr)),
|
||||
commodity, , char *, gnc_commodity_get_unique_name(xaccAccountGetCommodity(ptr)),
|
||||
version, , int32, xaccAccountGetVersion(ptr),
|
||||
version, , int32, qof_instance_get_version(ptr),
|
||||
iguid, , int32, ptr->idata,
|
||||
bookGUID, , GUID *, qof_instance_get_guid((QofInstance*)gnc_account_get_book(ptr)),
|
||||
parentGUID, , GUID *, xaccAccountGetGUID(gnc_account_get_parent(ptr)),
|
||||
@ -52,7 +52,7 @@ define(`transaction', `gncTransaction, Transaction, Transaction, t,
|
||||
last_modified, , now, "NOW",
|
||||
date_entered, , Timespec, xaccTransRetDateEnteredTS(ptr),
|
||||
date_posted, , Timespec, xaccTransRetDatePostedTS(ptr),
|
||||
version, , int32, xaccTransGetVersion(ptr),
|
||||
version, , int32, qof_instance_get_version(ptr),
|
||||
iguid, , int32, ptr->idata,
|
||||
transGUID, KEY, GUID *, xaccTransGetGUID(ptr),
|
||||
')
|
||||
@ -76,7 +76,7 @@ define(`price', `gncPrice, Price, GNCPrice, p,
|
||||
type, , char *, gnc_price_get_typestr(ptr),
|
||||
valueNum, , int64, gnc_numeric_num(gnc_price_get_value(ptr)),
|
||||
valueDenom, , int64, gnc_numeric_denom(gnc_price_get_value(ptr)),
|
||||
version, , int32, gnc_price_get_version(ptr),
|
||||
version, , int32, qof_instance_get_version(ptr),
|
||||
bookGUID, , GUID *, qof_book_get_guid(gnc_price_get_book(ptr)),
|
||||
priceGUID, KEY, GUID *, gnc_price_get_guid(ptr),
|
||||
')
|
||||
|
@ -759,7 +759,7 @@ test_trans_update(Transaction * trans, gpointer data)
|
||||
|
||||
ok = xaccTransEqual(trans, trans_2, TRUE, TRUE, TRUE, FALSE);
|
||||
if (trans && trans_2)
|
||||
ok = ok && (trans->version == trans_2->version);
|
||||
ok = ok && (qof_instance_compare_version(trans, trans_2));
|
||||
|
||||
/*
|
||||
ok = ok && (qof_session_get_error (td->session_2) == ERR_BACKEND_MODIFIED);
|
||||
|
@ -143,8 +143,8 @@ pgendStoreTransactionNoLock (PGBackend *be, Transaction *trans,
|
||||
{
|
||||
if (0 < pgendTransactionCompareVersion (be, trans)) return;
|
||||
}
|
||||
trans->version ++; /* be sure to update the version !! */
|
||||
trans->version_check = be->version_check;
|
||||
/* be sure to update the version !! */
|
||||
qof_instance_increment_version(trans, be->version_check);
|
||||
|
||||
/* first, we need to see which splits are in the database
|
||||
* since what is there may not match what we have cached in
|
||||
@ -652,7 +652,7 @@ pgendCopyTransactionToEngine (PGBackend *be, const GUID *trans_guid)
|
||||
{
|
||||
/* save some performance, don't go to the
|
||||
backend if the data is recent. */
|
||||
if (MAX_VERSION_AGE >= be->version_check - trans->version_check)
|
||||
if (MAX_VERSION_AGE >= be->version_check - qof_instance_get_version_check(trans))
|
||||
{
|
||||
PINFO ("fresh data, skip check");
|
||||
pgendEnable(be);
|
||||
@ -715,7 +715,7 @@ pgendCopyTransactionToEngine (PGBackend *be, const GUID *trans_guid)
|
||||
{
|
||||
gint32 db_version, cache_version;
|
||||
db_version = atoi (DB_GET_VAL("version",j));
|
||||
cache_version = xaccTransGetVersion (trans);
|
||||
cache_version = qof_instance_get_version (trans);
|
||||
if (db_version == cache_version) {
|
||||
engine_data_is_newer = 0;
|
||||
} else
|
||||
@ -753,7 +753,7 @@ pgendCopyTransactionToEngine (PGBackend *be, const GUID *trans_guid)
|
||||
xaccTransSetDatePostedTS (trans, &ts);
|
||||
ts = gnc_iso8601_to_timespec_gmt (DB_GET_VAL("date_entered",j));
|
||||
xaccTransSetDateEnteredTS (trans, &ts);
|
||||
xaccTransSetVersion (trans, atoi(DB_GET_VAL("version",j)));
|
||||
qof_instance_set_version (trans, atoi(DB_GET_VAL("version",j)));
|
||||
xaccTransSetCurrency (trans, currency);
|
||||
trans->idata = atoi(DB_GET_VAL("iguid",j));
|
||||
}
|
||||
@ -762,7 +762,7 @@ pgendCopyTransactionToEngine (PGBackend *be, const GUID *trans_guid)
|
||||
PQclear (result);
|
||||
|
||||
/* set timestamp as 'recent' for this data */
|
||||
trans->version_check = be->version_check;
|
||||
qof_instance_set_version_check(trans, be->version_check);
|
||||
|
||||
/* if engine data was newer, we are done */
|
||||
if (0 <= engine_data_is_newer)
|
||||
|
@ -71,7 +71,7 @@ get_mass_trans_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
|
||||
gint32 db_version, cache_version;
|
||||
db_version = atoi (DB_GET_VAL("version",j));
|
||||
cache_version = xaccTransGetVersion (trans);
|
||||
cache_version = qof_instance_get_version (trans);
|
||||
if (db_version < cache_version) {
|
||||
xaccTransBeginEdit (trans);
|
||||
xaction_list = g_list_prepend (xaction_list, trans);
|
||||
@ -93,7 +93,7 @@ get_mass_trans_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
xaccTransSetDatePostedTS (trans, &ts);
|
||||
ts = gnc_iso8601_to_timespec_gmt (DB_GET_VAL("date_entered",j));
|
||||
xaccTransSetDateEnteredTS (trans, &ts);
|
||||
xaccTransSetVersion (trans, atoi(DB_GET_VAL("version",j)));
|
||||
qof_instance_set_version (trans, atoi(DB_GET_VAL("version",j)));
|
||||
trans->idata = atoi (DB_GET_VAL("iguid",j));
|
||||
|
||||
currency = gnc_string_to_commodity (DB_GET_VAL("currency",j), book);
|
||||
@ -101,7 +101,7 @@ get_mass_trans_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
xaccTransSetCurrency (trans, currency);
|
||||
|
||||
/* set timestamp as 'recent' for this data */
|
||||
trans->version_check = be->version_check;
|
||||
qof_instance_set_version_check(trans, be->version_check);
|
||||
|
||||
xaction_list = g_list_prepend (xaction_list, trans);
|
||||
|
||||
|
@ -73,8 +73,6 @@ enum {
|
||||
PROP_END_CLEARED_BALANCE,
|
||||
PROP_END_RECONCILED_BALANCE,
|
||||
|
||||
PROP_ACCT_VERSION,
|
||||
PROP_ACCT_VERSION_CHECK,
|
||||
PROP_POLICY,
|
||||
PROP_MARK,
|
||||
PROP_TAX_RELATED,
|
||||
@ -140,10 +138,6 @@ typedef struct AccountPrivate
|
||||
|
||||
gboolean balance_dirty; /* balances in splits incorrect */
|
||||
|
||||
/* version number, used for tracking multiuser updates */
|
||||
gint32 version;
|
||||
guint32 version_check; /* data aging timestamp */
|
||||
|
||||
GList *splits; /* list of split pointers */
|
||||
gboolean sort_dirty; /* sort order of splits is bad */
|
||||
|
||||
@ -237,8 +231,6 @@ gnc_account_init(Account* acc)
|
||||
|
||||
priv->type = ACCT_TYPE_NONE;
|
||||
|
||||
priv->version = 0;
|
||||
priv->version_check = 0;
|
||||
priv->mark = 0;
|
||||
|
||||
priv->policy = xaccGetFIFOPolicy();
|
||||
@ -338,12 +330,6 @@ gnc_account_get_property (GObject *object,
|
||||
case PROP_END_RECONCILED_BALANCE:
|
||||
g_value_set_boxed(value, &priv->reconciled_balance);
|
||||
break;
|
||||
case PROP_ACCT_VERSION:
|
||||
g_value_set_int(value, priv->version);
|
||||
break;
|
||||
case PROP_ACCT_VERSION_CHECK:
|
||||
g_value_set_uint(value, priv->version_check);
|
||||
break;
|
||||
case PROP_POLICY:
|
||||
/* MAKE THIS A BOXED VALUE */
|
||||
g_value_set_pointer(value, priv->policy);
|
||||
@ -421,12 +407,6 @@ gnc_account_set_property (GObject *object,
|
||||
number = g_value_get_boxed(value);
|
||||
gnc_account_set_start_reconciled_balance(account, *number);
|
||||
break;
|
||||
case PROP_ACCT_VERSION:
|
||||
xaccAccountSetVersion(account, g_value_get_int(value));
|
||||
break;
|
||||
case PROP_ACCT_VERSION_CHECK:
|
||||
gnc_account_set_version_check(account, g_value_get_uint(value));
|
||||
break;
|
||||
case PROP_POLICY:
|
||||
gnc_account_set_policy(account, g_value_get_pointer(value));
|
||||
break;
|
||||
@ -689,28 +669,6 @@ gnc_account_class_init (AccountClass *klass)
|
||||
GNC_TYPE_NUMERIC,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property
|
||||
(gobject_class,
|
||||
PROP_ACCT_VERSION,
|
||||
g_param_spec_int ("acct-version",
|
||||
"Version",
|
||||
"The version number of the current account state.",
|
||||
0,
|
||||
G_MAXINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property
|
||||
(gobject_class,
|
||||
PROP_ACCT_VERSION_CHECK,
|
||||
g_param_spec_uint ("acct-version-check",
|
||||
"Version Check",
|
||||
"The version check number of the current account state.",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property
|
||||
(gobject_class,
|
||||
PROP_POLICY,
|
||||
@ -1050,7 +1008,6 @@ xaccFreeAccount (Account *acc)
|
||||
priv->type = ACCT_TYPE_NONE;
|
||||
priv->commodity = NULL;
|
||||
|
||||
priv->version = 0;
|
||||
priv->balance_dirty = FALSE;
|
||||
priv->sort_dirty = FALSE;
|
||||
|
||||
@ -1178,56 +1135,6 @@ xaccAccountDestroy (Account *acc)
|
||||
xaccAccountCommitEdit (acc);
|
||||
}
|
||||
|
||||
void
|
||||
xaccAccountSetVersion (Account *acc, gint32 vers)
|
||||
{
|
||||
AccountPrivate *priv;
|
||||
|
||||
g_return_if_fail(GNC_IS_ACCOUNT(acc));
|
||||
|
||||
priv = GET_PRIVATE(acc);
|
||||
priv->version = vers;
|
||||
}
|
||||
|
||||
gint32
|
||||
xaccAccountGetVersion (const Account *acc)
|
||||
{
|
||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 0);
|
||||
|
||||
return GET_PRIVATE(acc)->version;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_account_increment_version (Account *acc)
|
||||
{
|
||||
AccountPrivate *priv;
|
||||
|
||||
g_return_if_fail(GNC_IS_ACCOUNT(acc));
|
||||
|
||||
priv = GET_PRIVATE(acc);
|
||||
priv->version++;
|
||||
}
|
||||
|
||||
guint32
|
||||
gnc_account_get_version_check (const Account *acc)
|
||||
{
|
||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 0);
|
||||
|
||||
return GET_PRIVATE(acc)->version_check;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_account_set_version_check (Account *acc, guint32 value)
|
||||
{
|
||||
AccountPrivate *priv;
|
||||
|
||||
g_return_if_fail(GNC_IS_ACCOUNT(acc));
|
||||
|
||||
priv = GET_PRIVATE(acc);
|
||||
priv->version_check = value;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
|
@ -263,13 +263,6 @@ void xaccAccountSetNotes (Account *account, const char *notes);
|
||||
void xaccAccountSetLastNum (Account *account, const char *num);
|
||||
/** Set the account's lot order policy */
|
||||
void gnc_account_set_policy (Account *account, GNCPolicy *policy);
|
||||
/** Set the version numbers on this account. The version number is
|
||||
* used to manage multi-user updates. */
|
||||
void xaccAccountSetVersion (Account*, gint32);
|
||||
/** Increment the account version number */
|
||||
void gnc_account_increment_version (Account *acc);
|
||||
/** Set the account version_check number */
|
||||
void gnc_account_set_version_check (Account *acc, guint32 value);
|
||||
/** Get the account's type */
|
||||
GNCAccountType xaccAccountGetType (const Account *account);
|
||||
/** Is the account a stock, mutual fund or currency? */
|
||||
@ -361,11 +354,6 @@ const char * xaccAccountGetNotes (const Account *account);
|
||||
const char * xaccAccountGetLastNum (const Account *account);
|
||||
/** Get the account's lot order policy */
|
||||
GNCPolicy *gnc_account_get_policy (Account *account);
|
||||
/** Get the version numbers on this account. The version number is
|
||||
* used to manage multi-user updates. */
|
||||
gint32 xaccAccountGetVersion (const Account* acc);
|
||||
/** Get the account version_check number */
|
||||
guint32 gnc_account_get_version_check (const Account *acc);
|
||||
/** Retrieve the starting commodity balance for this account. */
|
||||
gnc_numeric gnc_account_get_start_balance (Account *acc);
|
||||
|
||||
|
@ -271,8 +271,6 @@ xaccInitTransaction (Transaction * trans, QofBook *book)
|
||||
trans->date_posted.tv_sec = 0;
|
||||
trans->date_posted.tv_nsec = 0;
|
||||
|
||||
trans->version = 0;
|
||||
trans->version_check = 0;
|
||||
trans->marker = 0;
|
||||
trans->orig = NULL;
|
||||
|
||||
@ -312,8 +310,8 @@ xaccTransDump (const Transaction *trans, const char *tag)
|
||||
trans->description ? trans->description : "(null)");
|
||||
printf(" Currency: %s\n",
|
||||
gnc_commodity_get_printname(trans->common_currency));
|
||||
printf(" version: %x\n", trans->version);
|
||||
printf(" version_chk: %x\n", trans->version_check);
|
||||
printf(" version: %x\n", qof_instance_get_version(trans));
|
||||
printf(" version_chk: %x\n", qof_instance_get_version_check(trans));
|
||||
printf(" editlevel: %x\n", qof_instance_get_editlevel(trans));
|
||||
printf(" orig: %p\n", trans->orig);
|
||||
printf(" idata: %x\n", trans->idata);
|
||||
@ -386,7 +384,7 @@ xaccDupeTransaction (const Transaction *t)
|
||||
|
||||
trans->date_entered = t->date_entered;
|
||||
trans->date_posted = t->date_posted;
|
||||
trans->version = t->version;
|
||||
qof_instance_copy_version(trans, t);
|
||||
trans->orig = NULL;
|
||||
|
||||
trans->common_currency = t->common_currency;
|
||||
@ -422,8 +420,8 @@ xaccTransClone (const Transaction *t)
|
||||
trans->num = CACHE_INSERT (t->num);
|
||||
trans->description = CACHE_INSERT (t->description);
|
||||
trans->common_currency = t->common_currency;
|
||||
trans->version = t->version;
|
||||
trans->version_check = t->version_check;
|
||||
qof_instance_copy_version(trans, t);
|
||||
qof_instance_copy_version_check(trans, t);
|
||||
|
||||
trans->orig = NULL;
|
||||
trans->idata = 0;
|
||||
@ -483,7 +481,6 @@ xaccFreeTransaction (Transaction *trans)
|
||||
trans->date_entered.tv_nsec = 0;
|
||||
trans->date_posted.tv_sec = 0;
|
||||
trans->date_posted.tv_nsec = 0;
|
||||
trans->version = 0;
|
||||
|
||||
if (trans->orig)
|
||||
{
|
||||
@ -1217,20 +1214,6 @@ xaccTransIsOpen (const Transaction *trans)
|
||||
return trans ? (0 < qof_instance_get_editlevel(trans)) : FALSE;
|
||||
}
|
||||
|
||||
/* Only used by postgres backend. Not sure if it should dirty the trans. */
|
||||
void
|
||||
xaccTransSetVersion (Transaction *trans, gint32 vers)
|
||||
{
|
||||
if (trans)
|
||||
trans->version = vers;
|
||||
}
|
||||
|
||||
gint32
|
||||
xaccTransGetVersion (const Transaction *trans)
|
||||
{
|
||||
return trans ? trans->version : 0;
|
||||
}
|
||||
|
||||
#define SECS_PER_DAY 86400
|
||||
|
||||
int
|
||||
|
@ -95,10 +95,6 @@ struct transaction_s
|
||||
* splits can be valued. */
|
||||
gnc_commodity *common_currency;
|
||||
|
||||
/* version number, used for tracking multiuser updates */
|
||||
gint32 version;
|
||||
guint32 version_check; /* data aging timestamp */
|
||||
|
||||
GList * splits; /* list of splits */
|
||||
|
||||
/* marker is used to track the progress of transaction traversals.
|
||||
|
@ -42,8 +42,6 @@ struct gnc_price_s
|
||||
char *source;
|
||||
char *type;
|
||||
gnc_numeric value;
|
||||
gint32 version; /* version number, for syncing with backend */
|
||||
guint32 version_check; /* data aging timestamp */
|
||||
|
||||
/* 'private' object management fields */
|
||||
guint32 refcount; /* garbage collection reference count */
|
||||
|
@ -68,8 +68,6 @@ gnc_price_create (QofBook *book)
|
||||
p = g_object_new(GNC_TYPE_PRICE, NULL);
|
||||
|
||||
p->refcount = 1;
|
||||
p->version = 0;
|
||||
p->version_check = 0;
|
||||
p->value = gnc_numeric_zero();
|
||||
p->type = NULL;
|
||||
p->source = NULL;
|
||||
@ -136,7 +134,7 @@ gnc_price_clone (GNCPrice* p, QofBook *book)
|
||||
new_p = gnc_price_create(book);
|
||||
if(!new_p) { LEAVE (" "); return NULL; }
|
||||
|
||||
new_p->version = p->version;
|
||||
qof_instance_copy_version(new_p, p);
|
||||
|
||||
gnc_price_begin_edit(new_p);
|
||||
/* never ever clone guid's */
|
||||
@ -307,15 +305,6 @@ gnc_price_set_value(GNCPrice *p, gnc_numeric value)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gnc_price_set_version(GNCPrice *p, gint32 vers)
|
||||
{
|
||||
/* begin/end edit is inappropriate here, this is a backend thing only. */
|
||||
if(!p) return;
|
||||
p->version = vers;
|
||||
}
|
||||
|
||||
|
||||
/* ==================================================================== */
|
||||
/* getters */
|
||||
|
||||
@ -379,13 +368,6 @@ gnc_price_get_currency(const GNCPrice *p)
|
||||
return p->currency;
|
||||
}
|
||||
|
||||
gint32
|
||||
gnc_price_get_version(const GNCPrice *p)
|
||||
{
|
||||
if(!p) return 0;
|
||||
return (p->version);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnc_price_equal (const GNCPrice *p1, const GNCPrice *p2)
|
||||
{
|
||||
|
@ -210,7 +210,6 @@ void gnc_price_set_time(GNCPrice *p, Timespec t);
|
||||
void gnc_price_set_source(GNCPrice *p, const char *source);
|
||||
void gnc_price_set_typestr(GNCPrice *p, const char* type);
|
||||
void gnc_price_set_value(GNCPrice *p, gnc_numeric value);
|
||||
void gnc_price_set_version(GNCPrice *p, gint32 versn);
|
||||
/** @} */
|
||||
|
||||
/* ------------------ */
|
||||
@ -226,7 +225,6 @@ Timespec gnc_price_get_time(const GNCPrice *p);
|
||||
const char * gnc_price_get_source(const GNCPrice *p);
|
||||
const char * gnc_price_get_typestr(const GNCPrice *p);
|
||||
gnc_numeric gnc_price_get_value(const GNCPrice *p);
|
||||
gint32 gnc_price_get_version(const GNCPrice *p);
|
||||
gboolean gnc_price_equal(const GNCPrice *p1, const GNCPrice *p2);
|
||||
|
||||
#define gnc_price_get_guid(X) qof_instance_get_guid(QOF_INSTANCE(X))
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include <glib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "qof.h"
|
||||
#include "test-stuff.h"
|
||||
@ -504,6 +505,7 @@ test_rule_loop (QofBookMergeData *mergeData, QofBookMergeRule *rule, guint remai
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
sleep(10);
|
||||
qof_init();
|
||||
myobjRegister();
|
||||
test_merge();
|
||||
|
Loading…
Reference in New Issue
Block a user