mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
First step of QOF/Object GObjectification.
- Merge QofEntity into QofInstance - Derive QofInstance from GObject - Convert all QofInstance-derived objects to use GObject framework - renamed qof_instance_init() to qof_instance_init_data() - removed qof_instance_release() because it's no longer needed Merge from branches/gobject-engine-dev-warlord (r15827) git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15846 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
commit
18c4cbf122
@ -80,7 +80,7 @@ in the QSF QofBackend to contain the reference data so that when the book is
|
||||
written out, the reference can be included. When the file is imported back in, a
|
||||
little extra code then rebuilds those references during the merge.
|
||||
|
||||
Copying entites from an existing QofBook using the qof_entity_copy routines will
|
||||
Copying entites from an existing QofBook using the qof_instance_copy routines will
|
||||
automatically create the reference table. If your QOF objects use references to other
|
||||
entities, books that are created manually also need to create a reference table.
|
||||
|
||||
|
@ -295,12 +295,12 @@ qsf_destroy_backend (QofBackend *be)
|
||||
}
|
||||
|
||||
static void
|
||||
ent_ref_cb (QofEntity* ent, gpointer user_data)
|
||||
ent_ref_cb (QofInstance* ent, gpointer user_data)
|
||||
{
|
||||
qsf_param *params;
|
||||
QofEntityReference *ref;
|
||||
void (*reference_setter) (QofEntity*, QofEntity*);
|
||||
QofEntity *reference;
|
||||
QofInstanceReference *ref;
|
||||
void (*reference_setter) (QofInstance*, QofInstance*);
|
||||
QofInstance *reference;
|
||||
QofCollection *coll;
|
||||
QofIdType type;
|
||||
|
||||
@ -308,12 +308,12 @@ ent_ref_cb (QofEntity* ent, gpointer user_data)
|
||||
g_return_if_fail(params);
|
||||
while(params->referenceList)
|
||||
{
|
||||
ref = (QofEntityReference*)params->referenceList->data;
|
||||
ref = (QofInstanceReference*)params->referenceList->data;
|
||||
if(qof_object_is_choice(ent->e_type)) { type = ref->choice_type; }
|
||||
else { type = ref->type; }
|
||||
coll = qof_book_get_collection(params->book, type);
|
||||
reference = qof_collection_lookup_entity(coll, ref->ref_guid);
|
||||
reference_setter = (void(*)(QofEntity*, QofEntity*))ref->param->param_setfcn;
|
||||
reference_setter = (void(*)(QofInstance*, QofInstance*))ref->param->param_setfcn;
|
||||
if(reference_setter != NULL)
|
||||
{
|
||||
qof_begin_edit((QofInstance*)ent);
|
||||
@ -337,7 +337,7 @@ insert_ref_cb(QofObject *obj, gpointer user_data)
|
||||
}
|
||||
|
||||
/*================================================
|
||||
Load QofEntity into QofBook from XML in memory
|
||||
Load QofInstance into QofBook from XML in memory
|
||||
==================================================*/
|
||||
|
||||
static gboolean
|
||||
@ -370,7 +370,7 @@ qsfdoc_to_qofbook(xmlDocPtr doc, qsf_param *params)
|
||||
if(!qof_class_is_registered(params->object_set->object_type)) { continue; }
|
||||
inst = (QofInstance*)qof_object_new_instance(params->object_set->object_type, book);
|
||||
g_return_val_if_fail(inst != NULL, FALSE);
|
||||
params->qsf_ent = &inst->entity;
|
||||
params->qsf_ent = inst;
|
||||
qof_begin_edit(inst);
|
||||
g_hash_table_foreach(params->qsf_parameter_hash, qsf_object_commitCB, params);
|
||||
qof_commit_edit(inst);
|
||||
@ -644,7 +644,7 @@ qsf_from_kvp_helper(const gchar *path, KvpValue *content, gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
qsf_from_coll_cb (QofEntity *ent, gpointer user_data)
|
||||
qsf_from_coll_cb (QofInstance *ent, gpointer user_data)
|
||||
{
|
||||
qsf_param *params;
|
||||
QofParam *qof_param;
|
||||
@ -654,7 +654,7 @@ qsf_from_coll_cb (QofEntity *ent, gpointer user_data)
|
||||
params = (qsf_param*)user_data;
|
||||
if(!ent || !params) { return; }
|
||||
qof_param = params->qof_param;
|
||||
guid_to_string_buff(qof_entity_get_guid(ent), qsf_guid);
|
||||
guid_to_string_buff(qof_instance_get_guid(ent), qsf_guid);
|
||||
node = xmlAddChild(params->output_node, xmlNewNode(params->qsf_ns,
|
||||
BAD_CAST qof_param->param_type));
|
||||
xmlNodeAddContent(node, BAD_CAST qsf_guid);
|
||||
@ -666,11 +666,11 @@ qsf_from_coll_cb (QofEntity *ent, gpointer user_data)
|
||||
static gint
|
||||
qof_reference_list_cb(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
const QofEntityReference *aa;
|
||||
const QofEntityReference *bb;
|
||||
const QofInstanceReference *aa;
|
||||
const QofInstanceReference *bb;
|
||||
|
||||
aa = (QofEntityReference*) a;
|
||||
bb = (QofEntityReference*) b;
|
||||
aa = (QofInstanceReference*) a;
|
||||
bb = (QofInstanceReference*) b;
|
||||
if(aa == NULL) { return 1; }
|
||||
g_return_val_if_fail((bb != NULL), 1);
|
||||
g_return_val_if_fail((aa->type != NULL), 1);
|
||||
@ -683,11 +683,11 @@ qof_reference_list_cb(gconstpointer a, gconstpointer b)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static QofEntityReference*
|
||||
qof_reference_lookup(GList *referenceList, QofEntityReference *find)
|
||||
static QofInstanceReference*
|
||||
qof_reference_lookup(GList *referenceList, QofInstanceReference *find)
|
||||
{
|
||||
GList *single_ref;
|
||||
QofEntityReference *ent_ref;
|
||||
QofInstanceReference *ent_ref;
|
||||
|
||||
if(referenceList == NULL) { return NULL; }
|
||||
g_return_val_if_fail(find != NULL, NULL);
|
||||
@ -695,7 +695,7 @@ qof_reference_lookup(GList *referenceList, QofEntityReference *find)
|
||||
ent_ref = NULL;
|
||||
single_ref = g_list_find_custom(referenceList, find, qof_reference_list_cb);
|
||||
if(single_ref == NULL) { return ent_ref; }
|
||||
ent_ref = (QofEntityReference*)single_ref->data;
|
||||
ent_ref = (QofInstanceReference*)single_ref->data;
|
||||
g_list_free(single_ref);
|
||||
return ent_ref;
|
||||
}
|
||||
@ -703,9 +703,9 @@ qof_reference_lookup(GList *referenceList, QofEntityReference *find)
|
||||
static void
|
||||
reference_list_lookup(gpointer data, gpointer user_data)
|
||||
{
|
||||
QofEntity *ent;
|
||||
QofInstance *ent;
|
||||
QofParam *ref_param;
|
||||
QofEntityReference *reference, *starter;
|
||||
QofInstanceReference *reference, *starter;
|
||||
qsf_param *params;
|
||||
const GUID *guid;
|
||||
xmlNodePtr node, object_node;
|
||||
@ -718,8 +718,8 @@ reference_list_lookup(gpointer data, gpointer user_data)
|
||||
object_node = params->output_node;
|
||||
ent = params->qsf_ent;
|
||||
ns = params->qsf_ns;
|
||||
starter = g_new(QofEntityReference, 1);
|
||||
starter->ent_guid = qof_entity_get_guid(ent);
|
||||
starter = g_new(QofInstanceReference, 1);
|
||||
starter->ent_guid = qof_instance_get_guid(ent);
|
||||
starter->type = g_strdup(ent->e_type);
|
||||
starter->param = ref_param;
|
||||
starter->ref_guid = NULL;
|
||||
@ -739,13 +739,13 @@ reference_list_lookup(gpointer data, gpointer user_data)
|
||||
g_free(ref_name);
|
||||
}
|
||||
else {
|
||||
ent = (QofEntity*)ref_param->param_getfcn(ent, ref_param);
|
||||
ent = QOF_INSTANCE(ref_param->param_getfcn(ent, ref_param));
|
||||
if(!ent) { return; }
|
||||
if((0 == safe_strcmp(ref_param->param_type, QOF_TYPE_COLLECT)) ||
|
||||
(0 == safe_strcmp(ref_param->param_type, QOF_TYPE_CHOICE)))
|
||||
{ return; }
|
||||
node = xmlAddChild(object_node, xmlNewNode(ns, BAD_CAST QOF_TYPE_GUID));
|
||||
guid = qof_entity_get_guid(ent);
|
||||
guid = qof_instance_get_guid(ent);
|
||||
guid_to_string_buff(guid, qsf_guid);
|
||||
xmlNodeAddContent(node, BAD_CAST qsf_guid);
|
||||
xmlNewProp(node, BAD_CAST QSF_OBJECT_TYPE, BAD_CAST ref_param->param_name);
|
||||
@ -753,11 +753,11 @@ reference_list_lookup(gpointer data, gpointer user_data)
|
||||
}
|
||||
|
||||
/*=====================================
|
||||
Convert QofEntity to QSF XML node
|
||||
Convert QofInstance to QSF XML node
|
||||
qof_param holds the parameter sequence.
|
||||
=======================================*/
|
||||
static void
|
||||
qsf_entity_foreach(QofEntity *ent, gpointer data)
|
||||
qsf_entity_foreach(QofInstance *ent, gpointer data)
|
||||
{
|
||||
qsf_param *params;
|
||||
GSList *param_list, *supported;
|
||||
@ -766,7 +766,7 @@ qsf_entity_foreach(QofEntity *ent, gpointer data)
|
||||
xmlNsPtr ns;
|
||||
gchar *string_buffer;
|
||||
QofParam *qof_param;
|
||||
QofEntity *choice_ent;
|
||||
QofInstance *choice_ent;
|
||||
KvpFrame *qsf_kvp;
|
||||
QofCollection *qsf_coll;
|
||||
gint param_count;
|
||||
@ -795,7 +795,7 @@ qsf_entity_foreach(QofEntity *ent, gpointer data)
|
||||
{
|
||||
if(!own_guid)
|
||||
{
|
||||
cm_guid = qof_entity_get_guid(ent);
|
||||
cm_guid = qof_instance_get_guid(ent);
|
||||
node = xmlAddChild(object_node, xmlNewNode(ns, BAD_CAST QOF_TYPE_GUID));
|
||||
guid_to_string_buff(cm_guid, cm_sa);
|
||||
string_buffer = g_strdup(cm_sa);
|
||||
@ -827,13 +827,13 @@ qsf_entity_foreach(QofEntity *ent, gpointer data)
|
||||
if(0 == safe_strcmp(qof_param->param_type, QOF_TYPE_CHOICE))
|
||||
{
|
||||
/** \todo use the reference list here. */
|
||||
choice_ent = (QofEntity*)qof_param->param_getfcn(ent, qof_param);
|
||||
choice_ent = QOF_INSTANCE(qof_param->param_getfcn(ent, qof_param));
|
||||
if(!choice_ent) {
|
||||
param_list = g_slist_next(param_list);
|
||||
continue;
|
||||
}
|
||||
node = xmlAddChild(object_node, xmlNewNode(ns, BAD_CAST qof_param->param_type));
|
||||
cm_guid = qof_entity_get_guid(choice_ent);
|
||||
cm_guid = qof_instance_get_guid(choice_ent);
|
||||
guid_to_string_buff(cm_guid, cm_sa);
|
||||
string_buffer = g_strdup(cm_sa);
|
||||
xmlNodeAddContent(node, BAD_CAST string_buffer);
|
||||
@ -1047,7 +1047,7 @@ string_to_kvp_value(const gchar *content, KvpValueType type)
|
||||
}
|
||||
|
||||
/* ======================================================
|
||||
Commit XML data from file to QofEntity in a QofBook
|
||||
Commit XML data from file to QofInstance in a QofBook
|
||||
========================================================= */
|
||||
void
|
||||
qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
|
||||
@ -1055,8 +1055,8 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
|
||||
qsf_param *params;
|
||||
qsf_objects *object_set;
|
||||
xmlNodePtr node;
|
||||
QofEntityReference *reference;
|
||||
QofEntity *qsf_ent;
|
||||
QofInstanceReference *reference;
|
||||
QofInstance *qsf_ent;
|
||||
QofBook *targetBook;
|
||||
const char *qof_type, *parameter_name, *timechk;
|
||||
QofIdType obj_type, reference_type;
|
||||
@ -1077,14 +1077,14 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
|
||||
KvpValueType cm_type;
|
||||
QofSetterFunc cm_setter;
|
||||
const QofParam *cm_param;
|
||||
void (*string_setter) (QofEntity*, const gchar*);
|
||||
void (*date_setter) (QofEntity*, Timespec);
|
||||
void (*numeric_setter) (QofEntity*, gnc_numeric);
|
||||
void (*double_setter) (QofEntity*, double);
|
||||
void (*boolean_setter) (QofEntity*, gboolean);
|
||||
void (*i32_setter) (QofEntity*, gint32);
|
||||
void (*i64_setter) (QofEntity*, gint64);
|
||||
void (*char_setter) (QofEntity*, gchar);
|
||||
void (*string_setter) (QofInstance*, const gchar*);
|
||||
void (*date_setter) (QofInstance*, Timespec);
|
||||
void (*numeric_setter) (QofInstance*, gnc_numeric);
|
||||
void (*double_setter) (QofInstance*, double);
|
||||
void (*boolean_setter) (QofInstance*, gboolean);
|
||||
void (*i32_setter) (QofInstance*, gint32);
|
||||
void (*i64_setter) (QofInstance*, gint64);
|
||||
void (*char_setter) (QofInstance*, gchar);
|
||||
|
||||
g_return_if_fail(data && value && key);
|
||||
params = (qsf_param*)data;
|
||||
@ -1102,11 +1102,11 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
|
||||
cm_param = qof_class_get_parameter(obj_type, parameter_name);
|
||||
object_set = params->object_set;
|
||||
if(safe_strcmp(qof_type, QOF_TYPE_STRING) == 0) {
|
||||
string_setter = (void(*)(QofEntity*, const gchar*))cm_setter;
|
||||
string_setter = (void(*)(QofInstance*, const gchar*))cm_setter;
|
||||
if(string_setter != NULL) { string_setter(qsf_ent, (gchar*)xmlNodeGetContent(node)); }
|
||||
}
|
||||
if(safe_strcmp(qof_type, QOF_TYPE_DATE) == 0) {
|
||||
date_setter = (void(*)(QofEntity*, Timespec))cm_setter;
|
||||
date_setter = (void(*)(QofInstance*, Timespec))cm_setter;
|
||||
timechk = NULL;
|
||||
timechk = strptime((char*)xmlNodeGetContent(node), QSF_XSD_TIME, &qsf_time);
|
||||
g_return_if_fail(timechk != NULL);
|
||||
@ -1119,7 +1119,7 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
|
||||
}
|
||||
if((safe_strcmp(qof_type, QOF_TYPE_NUMERIC) == 0) ||
|
||||
(safe_strcmp(qof_type, QOF_TYPE_DEBCRED) == 0)) {
|
||||
numeric_setter = (void(*)(QofEntity*, gnc_numeric))cm_setter;
|
||||
numeric_setter = (void(*)(QofInstance*, gnc_numeric))cm_setter;
|
||||
string_to_gnc_numeric((char*)xmlNodeGetContent(node), &cm_numeric);
|
||||
if(numeric_setter != NULL) { numeric_setter(qsf_ent, cm_numeric); }
|
||||
}
|
||||
@ -1135,10 +1135,10 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
|
||||
reference_type = (char*)xmlGetProp(node, BAD_CAST QSF_OBJECT_TYPE);
|
||||
if(0 == safe_strcmp(QOF_PARAM_GUID, reference_type))
|
||||
{
|
||||
qof_entity_set_guid(qsf_ent, cm_guid);
|
||||
qof_instance_set_guid(qsf_ent, cm_guid);
|
||||
}
|
||||
else {
|
||||
reference = qof_entity_get_reference_from(qsf_ent, cm_param);
|
||||
reference = qof_instance_get_reference_from(qsf_ent, cm_param);
|
||||
if(reference) {
|
||||
params->referenceList = g_list_append(params->referenceList, reference);
|
||||
}
|
||||
@ -1148,7 +1148,7 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
|
||||
errno = 0;
|
||||
cm_i32 = (gint32)strtol ((char*)xmlNodeGetContent(node), &tail, 0);
|
||||
if(errno == 0) {
|
||||
i32_setter = (void(*)(QofEntity*, gint32))cm_setter;
|
||||
i32_setter = (void(*)(QofInstance*, gint32))cm_setter;
|
||||
if(i32_setter != NULL) { i32_setter(qsf_ent, cm_i32); }
|
||||
}
|
||||
else { qof_backend_set_error(params->be, ERR_QSF_OVERFLOW); }
|
||||
@ -1157,7 +1157,7 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
|
||||
errno = 0;
|
||||
cm_i64 = strtoll((gchar*)xmlNodeGetContent(node), &tail, 0);
|
||||
if(errno == 0) {
|
||||
i64_setter = (void(*)(QofEntity*, gint64))cm_setter;
|
||||
i64_setter = (void(*)(QofInstance*, gint64))cm_setter;
|
||||
if(i64_setter != NULL) { i64_setter(qsf_ent, cm_i64); }
|
||||
}
|
||||
else { qof_backend_set_error(params->be, ERR_QSF_OVERFLOW); }
|
||||
@ -1166,7 +1166,7 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
|
||||
errno = 0;
|
||||
cm_double = strtod((gchar*)xmlNodeGetContent(node), &tail);
|
||||
if(errno == 0) {
|
||||
double_setter = (void(*)(QofEntity*, double))cm_setter;
|
||||
double_setter = (void(*)(QofInstance*, double))cm_setter;
|
||||
if(double_setter != NULL) { double_setter(qsf_ent, cm_double); }
|
||||
}
|
||||
}
|
||||
@ -1176,7 +1176,7 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
|
||||
cm_boolean = TRUE;
|
||||
}
|
||||
else { cm_boolean = FALSE; }
|
||||
boolean_setter = (void(*)(QofEntity*, gboolean))cm_setter;
|
||||
boolean_setter = (void(*)(QofInstance*, gboolean))cm_setter;
|
||||
if(boolean_setter != NULL) { boolean_setter(qsf_ent, cm_boolean); }
|
||||
}
|
||||
if(safe_strcmp(qof_type, QOF_TYPE_KVP) == 0) {
|
||||
@ -1190,7 +1190,7 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
|
||||
if(safe_strcmp(qof_type, QOF_TYPE_COLLECT) == 0) {
|
||||
QofCollection *qsf_coll;
|
||||
QofIdType type;
|
||||
QofEntityReference *reference;
|
||||
QofInstanceReference *reference;
|
||||
QofParam *copy_param;
|
||||
/* retrieve the *type* of the collection, ignore any contents. */
|
||||
qsf_coll = cm_param->param_getfcn(qsf_ent, cm_param);
|
||||
@ -1202,11 +1202,11 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
|
||||
PINFO (" string to guid collect failed for %s", xmlNodeGetContent(node));
|
||||
return;
|
||||
}
|
||||
/* create a QofEntityReference with this type and GUID.
|
||||
/* create a QofInstanceReference with this type and GUID.
|
||||
there is only one entity each time.
|
||||
cm_guid contains the GUID of the reference.
|
||||
type is the type of the reference. */
|
||||
reference = g_new0(QofEntityReference, 1);
|
||||
reference = g_new0(QofInstanceReference, 1);
|
||||
reference->type = g_strdup(qsf_ent->e_type);
|
||||
reference->ref_guid = cm_guid;
|
||||
reference->ent_guid = &qsf_ent->guid;
|
||||
@ -1219,7 +1219,7 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
|
||||
if(safe_strcmp(qof_type, QOF_TYPE_CHAR) == 0) {
|
||||
char_getter = (gchar (*)(xmlNodePtr))xmlNodeGetContent;
|
||||
cm_char = char_getter(node);
|
||||
char_setter = (void(*)(QofEntity*, gchar))cm_setter;
|
||||
char_setter = (void(*)(QofInstance*, gchar))cm_setter;
|
||||
if(char_setter != NULL) { char_setter(qsf_ent, cm_char); }
|
||||
}
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ qsf_book_node_handler(xmlNodePtr child, xmlNsPtr ns, qsf_param *params)
|
||||
DEBUG (" trying to set book GUID");
|
||||
buffer = g_strdup((gchar*)xmlNodeGetContent(child_node));
|
||||
g_return_if_fail(TRUE == string_to_guid(buffer, &book_guid));
|
||||
qof_entity_set_guid((QofEntity*)params->book, &book_guid);
|
||||
qof_instance_set_guid(QOF_INSTANCE(params->book), &book_guid);
|
||||
xmlNewChild(params->output_node, params->qsf_ns,
|
||||
BAD_CAST QSF_BOOK_GUID, BAD_CAST buffer);
|
||||
g_free(buffer);
|
||||
|
@ -344,7 +344,7 @@ typedef struct qsf_metadata
|
||||
gint count; /**< sequential counter for each object in the book */
|
||||
GList *qsf_object_list; /**< list of qsf_objects */
|
||||
GSList *qsf_sequence; /**< Parameter list sorted into QSF order */
|
||||
GList *referenceList; /**< Table of references, ::QofEntityReference. */
|
||||
GList *referenceList; /**< Table of references, ::QofInstanceReference. */
|
||||
GHashTable *qsf_parameter_hash; /**< Hashtable of parameters for each object */
|
||||
GHashTable *qsf_calculate_hash, *qsf_default_hash, *qsf_define_hash;
|
||||
GSList *supported_types; /**< The list of QOF types currently supported, in QSF order. */
|
||||
@ -362,7 +362,7 @@ typedef struct qsf_metadata
|
||||
QofIdType qof_obj_type; /**< current QofObject type (e_type) for the parameters. */
|
||||
QofIdType qof_foreach; /**< How to iterate over hierarchical entities. */
|
||||
gint foreach_limit; /**< How many iterations are found in the QSF */
|
||||
QofEntity *qsf_ent; /**< Current entity in the book. */
|
||||
QofInstance *qsf_ent; /**< Current entity in the book. */
|
||||
QofBackend *be; /**< the current QofBackend for this operation. */
|
||||
gboolean knowntype; /**< detect references by comparing with known QOF types. */
|
||||
QofParam *qof_param; /**< used by kvp to handle the frame hash table */
|
||||
|
@ -57,7 +57,7 @@ void gnc_engine_resume_events (void)
|
||||
{
|
||||
qof_event_resume();
|
||||
}
|
||||
void gnc_engine_gen_event (QofEntity *entity, GNCEngineEventType event_type)
|
||||
void gnc_engine_gen_event (QofInstance *entity, GNCEngineEventType event_type)
|
||||
{
|
||||
qof_event_gen(entity, event_type, NULL);
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ gint gnc_engine_register_event_handler (GNCEngineEventHandler handler,
|
||||
/** \deprecated use qof_event_unregister_handler instead. */
|
||||
void gnc_engine_unregister_event_handler (gint handler_id);
|
||||
/** \deprecated use qof_event_gen instead. */
|
||||
void gnc_engine_gen_event (QofEntity *entity, GNCEngineEventType event_type);
|
||||
void gnc_engine_gen_event (QofInstance *entity, GNCEngineEventType event_type);
|
||||
/** \deprecated use qof_event_suspend instead. */
|
||||
void gnc_engine_suspend_events (void);
|
||||
/** \deprecated use qof_event_resume instead. */
|
||||
|
98
lib/libqof/qof/qof-gobject.h
Normal file
98
lib/libqof/qof/qof-gobject.h
Normal file
@ -0,0 +1,98 @@
|
||||
/********************************************************************\
|
||||
* qof-gobject.h -- helper macros for qof objects using gobject *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#ifndef QOF_GOBJECT_H
|
||||
#define QOF_GOBJECT_H
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
/**
|
||||
* This is a simple macro for use in your QOF header files.
|
||||
* In addition to using this macro (which you don't need to use,
|
||||
* you can define the get_type() function directory if you wish)
|
||||
* you also need to define the gobject type cast macros. For example,
|
||||
* for the QofInstance type you would need to define the following
|
||||
* macros:
|
||||
*
|
||||
* #define QOF_TYPE_INSTANCE (qof_instance_get_type ())
|
||||
* #define QOF_INSTANCE(o) \
|
||||
* (G_TYPE_CHECK_INSTANCE_CAST ((o), QOF_TYPE_INSTANCE, QofInstance))
|
||||
* #define QOF_INSTANCE_CLASS(k) \
|
||||
* (G_TYPE_CHECK_CLASS_CAST((k), QOF_TYPE_INSTANCE, QofInstanceClass))
|
||||
* #define QOF_IS_INSTANCE(o) \
|
||||
* (G_TYPE_CHECK_INSTANCE_TYPE ((o), QOF_TYPE_INSTANCE))
|
||||
* #define QOF_IS_INSTANCE_CLASS(k) \
|
||||
* (G_TYPE_CHECK_CLASS_TYPE ((k), QOF_TYPE_INSTANCE))
|
||||
* #define QOF_INSTANCE_GET_CLASS(o) \
|
||||
* (G_TYPE_INSTANCE_GET_CLASS ((o), QOF_TYPE_INSTANCE, QofInstanceClass))
|
||||
*
|
||||
* @param type_name The function type_name for this type
|
||||
*/
|
||||
#define QOF_GOBJECT_DECL(type_name) \
|
||||
GType type_name##_get_type(void);
|
||||
|
||||
/**
|
||||
* The following macros are for convenience in your QOF object
|
||||
* implementation files. Generally you only need to use
|
||||
* QOF_GOBJECT_IMPL() or QOF_GOBJECT_IMPL_WITH_CODE()
|
||||
*/
|
||||
|
||||
#define QOF_GOBJECT_GET_TYPE(TypeName, type_name, TYPE_PARENT, CODE) \
|
||||
G_DEFINE_TYPE_WITH_CODE(TypeName, type_name, TYPE_PARENT, CODE);
|
||||
|
||||
#define QOF_GOBJECT_CLASS_INIT(type_name, TypeName) \
|
||||
static void type_name##_dispose(GObject *object); \
|
||||
static void type_name##_finalize(GObject *object); \
|
||||
static void type_name##_class_init(TypeName##Class *klass) \
|
||||
{ \
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass); \
|
||||
object_class->dispose = type_name##_dispose; \
|
||||
object_class->finalize = type_name##_finalize; \
|
||||
}
|
||||
|
||||
#define QOF_GOBJECT_DISPOSE(type_name) \
|
||||
static void type_name##_dispose_real(GObject* object); \
|
||||
static void type_name##_dispose(GObject *object) \
|
||||
{ \
|
||||
type_name##_dispose_real(object); \
|
||||
G_OBJECT_CLASS(type_name##_parent_class)->dispose(object); \
|
||||
}
|
||||
|
||||
#define QOF_GOBJECT_FINALIZE(type_name) \
|
||||
static void type_name##_finalize_real(GObject* object); \
|
||||
static void type_name##_finalize(GObject *object) \
|
||||
{ \
|
||||
type_name##_finalize_real(object); \
|
||||
G_OBJECT_CLASS(type_name##_parent_class)->finalize(object); \
|
||||
}
|
||||
|
||||
#define QOF_GOBJECT_IMPL_WITH_CODE(type_name, TypeName, TYPE_PARENT, CODE) \
|
||||
QOF_GOBJECT_GET_TYPE(TypeName, type_name, TYPE_PARENT, CODE); \
|
||||
QOF_GOBJECT_CLASS_INIT(type_name, TypeName); \
|
||||
QOF_GOBJECT_DISPOSE(type_name); \
|
||||
QOF_GOBJECT_FINALIZE(type_name);
|
||||
|
||||
#define QOF_GOBJECT_IMPL(type_name, TypeName, TYPE_PARENT) \
|
||||
QOF_GOBJECT_IMPL_WITH_CODE(type_name, TypeName, TYPE_PARENT, {})
|
||||
|
||||
|
||||
#endif /* QOF_GOBJECT_H */
|
@ -43,65 +43,6 @@
|
||||
#include "qofid-p.h"
|
||||
#include "qofinstance-p.h"
|
||||
|
||||
/* Book structure */
|
||||
struct _QofBook
|
||||
{
|
||||
QofInstance inst; /* Unique guid for this book. */
|
||||
|
||||
/* The time when the book was first dirtied. This is a secondary
|
||||
* indicator. It should only be used when inst.dirty is TRUE. */
|
||||
time_t dirty_time;
|
||||
|
||||
/* This callback function is called any time the book dirty flag
|
||||
* changes state. Both clean->dirty and dirty->clean transitions
|
||||
* trigger a callback. */
|
||||
QofBookDirtyCB dirty_cb;
|
||||
|
||||
/* This is the user supplied data that is returned in the dirty
|
||||
* callback function.*/
|
||||
gpointer dirty_data;
|
||||
|
||||
/* The entity table associates the GUIDs of all the objects
|
||||
* belonging to this book, with their pointers to the respective
|
||||
* objects. This allows a lookup of objects based on thier guid.
|
||||
*/
|
||||
GHashTable * hash_of_collections;
|
||||
|
||||
/* In order to store arbitrary data, for extensibility, add a table
|
||||
* that will be used to hold arbitrary pointers.
|
||||
*/
|
||||
GHashTable *data_tables;
|
||||
|
||||
/* Hash table of destroy callbacks for the data table. */
|
||||
GHashTable *data_table_finalizers;
|
||||
|
||||
/* state flag: 'y' means 'open for editing',
|
||||
* 'n' means 'book is closed'
|
||||
* xxxxx shouldn't this be replaced by the instance editlevel ???
|
||||
*/
|
||||
char book_open;
|
||||
|
||||
/* a flag denoting whether the book is closing down, used to
|
||||
* help the QOF objects shut down cleanly without maintaining
|
||||
* internal consistency.
|
||||
* XXX shouldn't this be replaced by instance->do_free ???
|
||||
*/
|
||||
gboolean shutting_down;
|
||||
|
||||
/* version number, used for tracking multiuser updates */
|
||||
gint32 version;
|
||||
|
||||
/* To be technically correct, backends belong to sessions and
|
||||
* not books. So the pointer below "really shouldn't be here",
|
||||
* except that it provides a nice convenience, avoiding a lookup
|
||||
* from the session. Better solutions welcome ... */
|
||||
QofBackend *backend;
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
/* Backend private expansion data */
|
||||
guint32 idata; /* used by the sql backend for kvp management */
|
||||
};
|
||||
|
||||
/*
|
||||
* qof_book_set_backend() is used by backends to
|
||||
* initialize the pointers in the book structure to
|
||||
@ -115,10 +56,10 @@ void qof_book_set_backend (QofBook *book, QofBackend *be);
|
||||
/* Register books with the engine */
|
||||
gboolean qof_book_register (void);
|
||||
|
||||
/** @deprecated use qof_entity_set_guid instead but only in
|
||||
/** @deprecated use qof_instance_set_guid instead but only in
|
||||
backends (when reading the GUID from the data source). */
|
||||
#define qof_book_set_guid(book,guid) \
|
||||
qof_entity_set_guid(QOF_ENTITY(book), guid)
|
||||
qof_instance_set_guid(QOF_INSTANCE(book), guid)
|
||||
|
||||
/* @} */
|
||||
/* @} */
|
||||
|
@ -48,6 +48,8 @@
|
||||
|
||||
static QofLogModule log_module = QOF_MOD_ENGINE;
|
||||
|
||||
QOF_GOBJECT_IMPL(qof_book, QofBook, QOF_TYPE_INSTANCE);
|
||||
|
||||
/* ====================================================================== */
|
||||
/* constructor / destructor */
|
||||
|
||||
@ -66,7 +68,7 @@ qof_book_init (QofBook *book)
|
||||
(GDestroyNotify)qof_util_string_cache_remove, /* key_destroy_func */
|
||||
coll_destroy); /* value_destroy_func */
|
||||
|
||||
qof_instance_init (&book->inst, QOF_ID_BOOK, book);
|
||||
qof_instance_init_data (&book->inst, QOF_ID_BOOK, book);
|
||||
|
||||
book->data_tables = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
book->data_table_finalizers = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
@ -82,11 +84,10 @@ qof_book_new (void)
|
||||
QofBook *book;
|
||||
|
||||
ENTER (" ");
|
||||
book = g_new0(QofBook, 1);
|
||||
qof_book_init(book);
|
||||
book = g_object_new(QOF_TYPE_BOOK, NULL);
|
||||
qof_object_book_begin (book);
|
||||
|
||||
qof_event_gen (&book->inst.entity, QOF_EVENT_CREATE, NULL);
|
||||
qof_event_gen (&book->inst, QOF_EVENT_CREATE, NULL);
|
||||
LEAVE ("book=%p", book);
|
||||
return book;
|
||||
}
|
||||
@ -101,14 +102,26 @@ book_final (gpointer key, gpointer value, gpointer booq)
|
||||
(*cb) (book, key, user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
qof_book_dispose_real (GObject *bookp)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
qof_book_finalize_real (GObject *bookp)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
qof_book_destroy (QofBook *book)
|
||||
{
|
||||
GHashTable* cols;
|
||||
|
||||
if (!book) return;
|
||||
ENTER ("book=%p", book);
|
||||
|
||||
book->shutting_down = TRUE;
|
||||
qof_event_force (&book->inst.entity, QOF_EVENT_DESTROY, NULL);
|
||||
qof_event_force (&book->inst, QOF_EVENT_DESTROY, NULL);
|
||||
|
||||
/* Call the list of finalizers, let them do their thing.
|
||||
* Do this before tearing into the rest of the book.
|
||||
@ -122,12 +135,18 @@ qof_book_destroy (QofBook *book)
|
||||
g_hash_table_destroy (book->data_tables);
|
||||
book->data_tables = NULL;
|
||||
|
||||
qof_instance_release (&book->inst);
|
||||
/* qof_instance_release (&book->inst); */
|
||||
|
||||
g_hash_table_destroy (book->hash_of_collections);
|
||||
/* Note: we need to save this hashtable until after we remove ourself
|
||||
* from it, otherwise we'll crash in our dispose() function when we
|
||||
* DO remove ourself from the collection but the collection had already
|
||||
* been destroyed.
|
||||
*/
|
||||
cols = book->hash_of_collections;
|
||||
g_object_unref (book);
|
||||
g_hash_table_destroy (cols);
|
||||
book->hash_of_collections = NULL;
|
||||
|
||||
g_free (book);
|
||||
LEAVE ("book=%p", book);
|
||||
}
|
||||
|
||||
@ -411,7 +430,7 @@ qof_book_get_counter (QofBook *book, const char *counter_name)
|
||||
gboolean qof_book_register (void)
|
||||
{
|
||||
static QofParam params[] = {
|
||||
{ QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, NULL },
|
||||
{ QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
|
||||
{ QOF_PARAM_KVP, QOF_TYPE_KVP, (QofAccessFunc)qof_instance_get_slots, NULL },
|
||||
{ NULL },
|
||||
};
|
||||
|
@ -40,8 +40,92 @@
|
||||
#ifndef QOF_BOOK_H
|
||||
#define QOF_BOOK_H
|
||||
|
||||
typedef struct _QofBookClass QofBookClass;
|
||||
|
||||
#include "qofid.h"
|
||||
#include "kvp_frame.h"
|
||||
#include "qofinstance.h"
|
||||
|
||||
/* --- type macros --- */
|
||||
#define QOF_TYPE_BOOK (qof_book_get_type ())
|
||||
#define QOF_BOOK(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((o), QOF_TYPE_BOOK, QofBook))
|
||||
#define QOF_BOOK_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((k), QOF_TYPE_BOOK, QofBookClass))
|
||||
#define QOF_IS_BOOK(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((o), QOF_TYPE_BOOK))
|
||||
#define QOF_IS_BOOK_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((k), QOF_TYPE_BOOK))
|
||||
#define QOF_BOOK_GET_CLASS(o) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((o), QOF_TYPE_BOOK, QofBookClass))
|
||||
|
||||
typedef void (*QofBookDirtyCB) (QofBook *, gboolean dirty, gpointer user_data);
|
||||
|
||||
/* Book structure */
|
||||
struct _QofBook
|
||||
{
|
||||
QofInstance inst; /* Unique guid for this book. */
|
||||
|
||||
/* The time when the book was first dirtied. This is a secondary
|
||||
* indicator. It should only be used when inst.dirty is TRUE. */
|
||||
time_t dirty_time;
|
||||
|
||||
/* This callback function is called any time the book dirty flag
|
||||
* changes state. Both clean->dirty and dirty->clean transitions
|
||||
* trigger a callback. */
|
||||
QofBookDirtyCB dirty_cb;
|
||||
|
||||
/* This is the user supplied data that is returned in the dirty
|
||||
* callback function.*/
|
||||
gpointer dirty_data;
|
||||
|
||||
/* The entity table associates the GUIDs of all the objects
|
||||
* belonging to this book, with their pointers to the respective
|
||||
* objects. This allows a lookup of objects based on thier guid.
|
||||
*/
|
||||
GHashTable * hash_of_collections;
|
||||
|
||||
/* In order to store arbitrary data, for extensibility, add a table
|
||||
* that will be used to hold arbitrary pointers.
|
||||
*/
|
||||
GHashTable *data_tables;
|
||||
|
||||
/* Hash table of destroy callbacks for the data table. */
|
||||
GHashTable *data_table_finalizers;
|
||||
|
||||
/* state flag: 'y' means 'open for editing',
|
||||
* 'n' means 'book is closed'
|
||||
* xxxxx shouldn't this be replaced by the instance editlevel ???
|
||||
*/
|
||||
char book_open;
|
||||
|
||||
/* a flag denoting whether the book is closing down, used to
|
||||
* help the QOF objects shut down cleanly without maintaining
|
||||
* internal consistency.
|
||||
* XXX shouldn't this be replaced by instance->do_free ???
|
||||
*/
|
||||
gboolean shutting_down;
|
||||
|
||||
/* version number, used for tracking multiuser updates */
|
||||
gint32 version;
|
||||
|
||||
/* To be technically correct, backends belong to sessions and
|
||||
* not books. So the pointer below "really shouldn't be here",
|
||||
* except that it provides a nice convenience, avoiding a lookup
|
||||
* from the session. Better solutions welcome ... */
|
||||
QofBackend *backend;
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
/* Backend private expansion data */
|
||||
guint32 idata; /* used by the sql backend for kvp management */
|
||||
};
|
||||
|
||||
struct _QofBookClass
|
||||
{
|
||||
QofInstanceClass parent_class;
|
||||
};
|
||||
|
||||
GType qof_book_get_type(void);
|
||||
|
||||
/** @brief Encapsulates all the information about a dataset
|
||||
* manipulated by QOF. This is the top-most structure
|
||||
@ -50,7 +134,7 @@
|
||||
|
||||
/** Lookup an entity by guid, returning pointer to the entity */
|
||||
#define QOF_BOOK_LOOKUP_ENTITY(book,guid,e_type,c_type) ({ \
|
||||
QofEntity *val = NULL; \
|
||||
QofInstance *val = NULL; \
|
||||
if (guid && book) { \
|
||||
QofCollection *col; \
|
||||
col = qof_book_get_collection (book, e_type); \
|
||||
@ -59,14 +143,10 @@
|
||||
(c_type *) val; \
|
||||
})
|
||||
|
||||
/** \brief QofBook reference */
|
||||
typedef struct _QofBook QofBook;
|
||||
|
||||
/** GList of QofBook */
|
||||
typedef GList QofBookList;
|
||||
|
||||
typedef void (*QofBookFinalCB) (QofBook *, gpointer key, gpointer user_data);
|
||||
typedef void (*QofBookDirtyCB) (QofBook *, gboolean dirty, gpointer user_data);
|
||||
|
||||
/** Register the book object with the QOF object system. */
|
||||
gboolean qof_book_register (void);
|
||||
@ -191,7 +271,7 @@ gboolean qof_book_equal (const QofBook *book_1, const QofBook *book_2);
|
||||
gint64 qof_book_get_counter (QofBook *book, const char *counter_name);
|
||||
|
||||
/** deprecated */
|
||||
#define qof_book_get_guid(X) qof_entity_get_guid (QOF_ENTITY(X))
|
||||
#define qof_book_get_guid(X) qof_instance_get_guid (QOF_INSTANCE(X))
|
||||
|
||||
#endif /* QOF_BOOK_H */
|
||||
/** @} */
|
||||
|
@ -74,7 +74,7 @@ struct collect_list_s
|
||||
};
|
||||
|
||||
static void
|
||||
collect_reference_cb (QofEntity *ent, gpointer user_data)
|
||||
collect_reference_cb (QofInstance *ent, gpointer user_data)
|
||||
{
|
||||
struct collect_list_s *s;
|
||||
|
||||
@ -89,7 +89,7 @@ qof_book_merge_compare(QofBookMergeData *mergeData )
|
||||
QofBookMergeRule *currentRule;
|
||||
QofCollection *mergeColl, *targetColl;
|
||||
gchar *stringImport, *stringTarget;
|
||||
QofEntity *mergeEnt, *targetEnt, *referenceEnt;
|
||||
QofInstance *mergeEnt, *targetEnt, *referenceEnt;
|
||||
const GUID *guidImport, *guidTarget;
|
||||
QofParam *qtparam;
|
||||
KvpFrame *kvpImport, *kvpTarget;
|
||||
@ -97,13 +97,13 @@ qof_book_merge_compare(QofBookMergeData *mergeData )
|
||||
QofType mergeType;
|
||||
GSList *paramList;
|
||||
gboolean absolute, mergeError, knowntype, mergeMatch, booleanImport, booleanTarget,
|
||||
(*boolean_getter) (QofEntity*, QofParam*);
|
||||
Timespec tsImport, tsTarget, (*date_getter) (QofEntity*, QofParam*);
|
||||
gnc_numeric numericImport, numericTarget, (*numeric_getter) (QofEntity*, QofParam*);
|
||||
double doubleImport, doubleTarget, (*double_getter) (QofEntity*, QofParam*);
|
||||
gint32 i32Import, i32Target, (*int32_getter) (QofEntity*, QofParam*);
|
||||
gint64 i64Import, i64Target, (*int64_getter) (QofEntity*, QofParam*);
|
||||
gchar charImport, charTarget, (*char_getter) (QofEntity*, QofParam*);
|
||||
(*boolean_getter) (QofInstance*, QofParam*);
|
||||
Timespec tsImport, tsTarget, (*date_getter) (QofInstance*, QofParam*);
|
||||
gnc_numeric numericImport, numericTarget, (*numeric_getter) (QofInstance*, QofParam*);
|
||||
double doubleImport, doubleTarget, (*double_getter) (QofInstance*, QofParam*);
|
||||
gint32 i32Import, i32Target, (*int32_getter) (QofInstance*, QofParam*);
|
||||
gint64 i64Import, i64Target, (*int64_getter) (QofInstance*, QofParam*);
|
||||
gchar charImport, charTarget, (*char_getter) (QofInstance*, QofParam*);
|
||||
|
||||
g_return_val_if_fail((mergeData != NULL), -1);
|
||||
currentRule = mergeData->currentRule;
|
||||
@ -140,7 +140,7 @@ qof_book_merge_compare(QofBookMergeData *mergeData )
|
||||
knowntype= TRUE;
|
||||
}
|
||||
if(safe_strcmp(mergeType, QOF_TYPE_DATE) == 0) {
|
||||
date_getter = (Timespec (*)(QofEntity*, QofParam*))qtparam->param_getfcn;
|
||||
date_getter = (Timespec (*)(QofInstance*, QofParam*))qtparam->param_getfcn;
|
||||
tsImport = date_getter(mergeEnt, qtparam);
|
||||
tsTarget = date_getter(targetEnt, qtparam);
|
||||
if(timespec_cmp(&tsImport, &tsTarget) == 0) { mergeMatch = TRUE; }
|
||||
@ -150,7 +150,7 @@ qof_book_merge_compare(QofBookMergeData *mergeData )
|
||||
}
|
||||
if((safe_strcmp(mergeType, QOF_TYPE_NUMERIC) == 0) ||
|
||||
(safe_strcmp(mergeType, QOF_TYPE_DEBCRED) == 0)) {
|
||||
numeric_getter = (gnc_numeric (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
|
||||
numeric_getter = (gnc_numeric (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
|
||||
numericImport = numeric_getter(mergeEnt,qtparam);
|
||||
numericTarget = numeric_getter(targetEnt,qtparam);
|
||||
if(gnc_numeric_compare (numericImport, numericTarget) == 0) { mergeMatch = TRUE; }
|
||||
@ -167,7 +167,7 @@ qof_book_merge_compare(QofBookMergeData *mergeData )
|
||||
knowntype= TRUE;
|
||||
}
|
||||
if(safe_strcmp(mergeType, QOF_TYPE_INT32) == 0) {
|
||||
int32_getter = (gint32 (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
|
||||
int32_getter = (gint32 (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
|
||||
i32Import = int32_getter(mergeEnt, qtparam);
|
||||
i32Target = int32_getter(targetEnt, qtparam);
|
||||
if(i32Target == i32Import) { mergeMatch = TRUE; }
|
||||
@ -176,7 +176,7 @@ qof_book_merge_compare(QofBookMergeData *mergeData )
|
||||
knowntype= TRUE;
|
||||
}
|
||||
if(safe_strcmp(mergeType, QOF_TYPE_INT64) == 0) {
|
||||
int64_getter = (gint64 (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
|
||||
int64_getter = (gint64 (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
|
||||
i64Import = int64_getter(mergeEnt, qtparam);
|
||||
i64Target = int64_getter(targetEnt, qtparam);
|
||||
if(i64Target == i64Import) { mergeMatch = TRUE; }
|
||||
@ -185,7 +185,7 @@ qof_book_merge_compare(QofBookMergeData *mergeData )
|
||||
knowntype= TRUE;
|
||||
}
|
||||
if(safe_strcmp(mergeType, QOF_TYPE_DOUBLE) == 0) {
|
||||
double_getter = (double (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
|
||||
double_getter = (double (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
|
||||
doubleImport = double_getter(mergeEnt, qtparam);
|
||||
doubleTarget = double_getter(mergeEnt, qtparam);
|
||||
if(doubleImport == doubleTarget) { mergeMatch = TRUE; }
|
||||
@ -194,7 +194,7 @@ qof_book_merge_compare(QofBookMergeData *mergeData )
|
||||
knowntype= TRUE;
|
||||
}
|
||||
if(safe_strcmp(mergeType, QOF_TYPE_BOOLEAN) == 0){
|
||||
boolean_getter = (gboolean (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
|
||||
boolean_getter = (gboolean (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
|
||||
booleanImport = boolean_getter(mergeEnt, qtparam);
|
||||
booleanTarget = boolean_getter(targetEnt, qtparam);
|
||||
if(booleanImport != FALSE && booleanImport != TRUE) { booleanImport = FALSE; }
|
||||
@ -213,7 +213,7 @@ qof_book_merge_compare(QofBookMergeData *mergeData )
|
||||
knowntype= TRUE;
|
||||
}
|
||||
if(safe_strcmp(mergeType, QOF_TYPE_CHAR) == 0) {
|
||||
char_getter = (gchar (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
|
||||
char_getter = (gchar (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
|
||||
charImport = char_getter(mergeEnt, qtparam);
|
||||
charTarget = char_getter(targetEnt, qtparam);
|
||||
if(charImport == charTarget) { mergeMatch = TRUE; }
|
||||
@ -325,7 +325,7 @@ The next mergeEnt may be a much better match for that targetEnt and the target_t
|
||||
is designed to solve the issues that result from this conflict. The previous match
|
||||
must be re-assigned because if two mergeEnt's are matched with only one targetEnt,
|
||||
data loss \b WILL follow. Equally, the current mergeEnt must replace the previous
|
||||
one as it is a better match. qof_entity_rating holds the details required to identify
|
||||
one as it is a better match. qof_instance_rating holds the details required to identify
|
||||
the correct mergeEnt to be re-assigned and these mergeEnt entities are therefore
|
||||
orphaned - to be re-matched later.
|
||||
|
||||
@ -372,7 +372,7 @@ qof_book_merge_match_orphans(QofBookMergeData *mergeData)
|
||||
{
|
||||
GSList *orphans, *targets;
|
||||
QofBookMergeRule *rule, *currentRule;
|
||||
QofEntity *best_matchEnt;
|
||||
QofInstance *best_matchEnt;
|
||||
double difference;
|
||||
|
||||
g_return_if_fail(mergeData != NULL);
|
||||
@ -409,7 +409,7 @@ qof_book_merge_match_orphans(QofBookMergeData *mergeData)
|
||||
}
|
||||
|
||||
static void
|
||||
qof_book_merge_foreach_target (QofEntity* targetEnt, gpointer user_data)
|
||||
qof_book_merge_foreach_target (QofInstance* targetEnt, gpointer user_data)
|
||||
{
|
||||
QofBookMergeData *mergeData;
|
||||
|
||||
@ -437,11 +437,11 @@ qof_book_merge_foreach_type_target ( QofObject* merge_obj, gpointer user_data)
|
||||
}
|
||||
|
||||
static void
|
||||
qof_book_merge_foreach ( QofEntity* mergeEnt, gpointer user_data)
|
||||
qof_book_merge_foreach ( QofInstance* mergeEnt, gpointer user_data)
|
||||
{
|
||||
QofBookMergeRule *mergeRule, *currentRule;
|
||||
QofBookMergeData *mergeData;
|
||||
QofEntity *targetEnt, *best_matchEnt;
|
||||
QofInstance *targetEnt, *best_matchEnt;
|
||||
GUID *g;
|
||||
double difference;
|
||||
GSList *c;
|
||||
@ -592,7 +592,7 @@ qof_book_merge_commit_rule_loop(
|
||||
{
|
||||
QofInstance *inst;
|
||||
gboolean registered_type;
|
||||
QofEntity *referenceEnt;
|
||||
QofInstance *referenceEnt;
|
||||
/* cm_ prefix used for variables that hold the data to commit */
|
||||
QofCollection *cm_coll;
|
||||
QofParam *cm_param;
|
||||
@ -600,26 +600,26 @@ qof_book_merge_commit_rule_loop(
|
||||
const GUID *cm_guid;
|
||||
KvpFrame *cm_kvp;
|
||||
/* function pointers and variables for parameter getters that don't use pointers normally */
|
||||
gnc_numeric cm_numeric, (*numeric_getter) (QofEntity*, QofParam*);
|
||||
double cm_double, (*double_getter) (QofEntity*, QofParam*);
|
||||
gboolean cm_boolean, (*boolean_getter) (QofEntity*, QofParam*);
|
||||
gint32 cm_i32, (*int32_getter) (QofEntity*, QofParam*);
|
||||
gint64 cm_i64, (*int64_getter) (QofEntity*, QofParam*);
|
||||
Timespec cm_date, (*date_getter) (QofEntity*, QofParam*);
|
||||
gchar cm_char, (*char_getter) (QofEntity*, QofParam*);
|
||||
gnc_numeric cm_numeric, (*numeric_getter) (QofInstance*, QofParam*);
|
||||
double cm_double, (*double_getter) (QofInstance*, QofParam*);
|
||||
gboolean cm_boolean, (*boolean_getter) (QofInstance*, QofParam*);
|
||||
gint32 cm_i32, (*int32_getter) (QofInstance*, QofParam*);
|
||||
gint64 cm_i64, (*int64_getter) (QofInstance*, QofParam*);
|
||||
Timespec cm_date, (*date_getter) (QofInstance*, QofParam*);
|
||||
gchar cm_char, (*char_getter) (QofInstance*, QofParam*);
|
||||
/* function pointers to the parameter setters */
|
||||
void (*string_setter) (QofEntity*, const gchar*);
|
||||
void (*date_setter) (QofEntity*, Timespec);
|
||||
void (*numeric_setter) (QofEntity*, gnc_numeric);
|
||||
void (*guid_setter) (QofEntity*, const GUID*);
|
||||
void (*double_setter) (QofEntity*, double);
|
||||
void (*boolean_setter) (QofEntity*, gboolean);
|
||||
void (*i32_setter) (QofEntity*, gint32);
|
||||
void (*i64_setter) (QofEntity*, gint64);
|
||||
void (*char_setter) (QofEntity*, gchar);
|
||||
void (*kvp_frame_setter) (QofEntity*, KvpFrame*);
|
||||
void (*reference_setter) (QofEntity*, QofEntity*);
|
||||
void (*collection_setter)(QofEntity*, QofCollection*);
|
||||
void (*string_setter) (QofInstance*, const gchar*);
|
||||
void (*date_setter) (QofInstance*, Timespec);
|
||||
void (*numeric_setter) (QofInstance*, gnc_numeric);
|
||||
void (*guid_setter) (QofInstance*, const GUID*);
|
||||
void (*double_setter) (QofInstance*, double);
|
||||
void (*boolean_setter) (QofInstance*, gboolean);
|
||||
void (*i32_setter) (QofInstance*, gint32);
|
||||
void (*i64_setter) (QofInstance*, gint64);
|
||||
void (*char_setter) (QofInstance*, gchar);
|
||||
void (*kvp_frame_setter) (QofInstance*, KvpFrame*);
|
||||
void (*reference_setter) (QofInstance*, QofInstance*);
|
||||
void (*collection_setter)(QofInstance*, QofCollection*);
|
||||
|
||||
g_return_if_fail(rule != NULL);
|
||||
g_return_if_fail(mergeData != NULL);
|
||||
@ -630,8 +630,8 @@ qof_book_merge_commit_rule_loop(
|
||||
if(rule->mergeResult == MERGE_NEW) {
|
||||
inst = (QofInstance*)qof_object_new_instance(rule->importEnt->e_type, mergeData->targetBook);
|
||||
g_return_if_fail(inst != NULL);
|
||||
rule->targetEnt = &inst->entity;
|
||||
qof_entity_set_guid(rule->targetEnt, qof_entity_get_guid(rule->importEnt));
|
||||
rule->targetEnt = inst;
|
||||
qof_instance_set_guid(rule->targetEnt, qof_instance_get_guid(rule->importEnt));
|
||||
}
|
||||
/* currentRule->targetEnt is now set,
|
||||
1. by an absolute GUID match or
|
||||
@ -645,81 +645,81 @@ qof_book_merge_commit_rule_loop(
|
||||
rule->mergeType = cm_param->param_type;
|
||||
if(safe_strcmp(rule->mergeType, QOF_TYPE_STRING) == 0) {
|
||||
cm_string = cm_param->param_getfcn(rule->importEnt, cm_param);
|
||||
string_setter = (void(*)(QofEntity*, const gchar*))cm_param->param_setfcn;
|
||||
string_setter = (void(*)(QofInstance*, const gchar*))cm_param->param_setfcn;
|
||||
if(string_setter != NULL) { string_setter(rule->targetEnt, cm_string); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(rule->mergeType, QOF_TYPE_DATE) == 0) {
|
||||
date_getter = (Timespec (*)(QofEntity*, QofParam*))cm_param->param_getfcn;
|
||||
date_getter = (Timespec (*)(QofInstance*, QofParam*))cm_param->param_getfcn;
|
||||
cm_date = date_getter(rule->importEnt, cm_param);
|
||||
date_setter = (void(*)(QofEntity*, Timespec))cm_param->param_setfcn;
|
||||
date_setter = (void(*)(QofInstance*, Timespec))cm_param->param_setfcn;
|
||||
if(date_setter != NULL) { date_setter(rule->targetEnt, cm_date); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if((safe_strcmp(rule->mergeType, QOF_TYPE_NUMERIC) == 0) ||
|
||||
(safe_strcmp(rule->mergeType, QOF_TYPE_DEBCRED) == 0)) {
|
||||
numeric_getter = (gnc_numeric (*)(QofEntity*, QofParam*))cm_param->param_getfcn;
|
||||
numeric_getter = (gnc_numeric (*)(QofInstance*, QofParam*))cm_param->param_getfcn;
|
||||
cm_numeric = numeric_getter(rule->importEnt, cm_param);
|
||||
numeric_setter = (void(*)(QofEntity*, gnc_numeric))cm_param->param_setfcn;
|
||||
numeric_setter = (void(*)(QofInstance*, gnc_numeric))cm_param->param_setfcn;
|
||||
if(numeric_setter != NULL) { numeric_setter(rule->targetEnt, cm_numeric); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(rule->mergeType, QOF_TYPE_GUID) == 0) {
|
||||
cm_guid = cm_param->param_getfcn(rule->importEnt, cm_param);
|
||||
guid_setter = (void(*)(QofEntity*, const GUID*))cm_param->param_setfcn;
|
||||
guid_setter = (void(*)(QofInstance*, const GUID*))cm_param->param_setfcn;
|
||||
if(guid_setter != NULL) { guid_setter(rule->targetEnt, cm_guid); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(rule->mergeType, QOF_TYPE_INT32) == 0) {
|
||||
int32_getter = (gint32 (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
|
||||
int32_getter = (gint32 (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
|
||||
cm_i32 = int32_getter(rule->importEnt, cm_param);
|
||||
i32_setter = (void(*)(QofEntity*, gint32))cm_param->param_setfcn;
|
||||
i32_setter = (void(*)(QofInstance*, gint32))cm_param->param_setfcn;
|
||||
if(i32_setter != NULL) { i32_setter(rule->targetEnt, cm_i32); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(rule->mergeType, QOF_TYPE_INT64) == 0) {
|
||||
int64_getter = (gint64 (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
|
||||
int64_getter = (gint64 (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
|
||||
cm_i64 = int64_getter(rule->importEnt, cm_param);
|
||||
i64_setter = (void(*)(QofEntity*, gint64))cm_param->param_setfcn;
|
||||
i64_setter = (void(*)(QofInstance*, gint64))cm_param->param_setfcn;
|
||||
if(i64_setter != NULL) { i64_setter(rule->targetEnt, cm_i64); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(rule->mergeType, QOF_TYPE_DOUBLE) == 0) {
|
||||
double_getter = (double (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
|
||||
double_getter = (double (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
|
||||
cm_double = double_getter(rule->importEnt, cm_param);
|
||||
double_setter = (void(*)(QofEntity*, double))cm_param->param_setfcn;
|
||||
double_setter = (void(*)(QofInstance*, double))cm_param->param_setfcn;
|
||||
if(double_setter != NULL) { double_setter(rule->targetEnt, cm_double); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(rule->mergeType, QOF_TYPE_BOOLEAN) == 0){
|
||||
boolean_getter = (gboolean (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
|
||||
boolean_getter = (gboolean (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
|
||||
cm_boolean = boolean_getter(rule->importEnt, cm_param);
|
||||
boolean_setter = (void(*)(QofEntity*, gboolean))cm_param->param_setfcn;
|
||||
boolean_setter = (void(*)(QofInstance*, gboolean))cm_param->param_setfcn;
|
||||
if(boolean_setter != NULL) { boolean_setter(rule->targetEnt, cm_boolean); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(rule->mergeType, QOF_TYPE_KVP) == 0) {
|
||||
cm_kvp = kvp_frame_copy(cm_param->param_getfcn(rule->importEnt,cm_param));
|
||||
kvp_frame_setter = (void(*)(QofEntity*, KvpFrame*))cm_param->param_setfcn;
|
||||
kvp_frame_setter = (void(*)(QofInstance*, KvpFrame*))cm_param->param_setfcn;
|
||||
if(kvp_frame_setter != NULL) { kvp_frame_setter(rule->targetEnt, cm_kvp); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(rule->mergeType, QOF_TYPE_CHAR) == 0) {
|
||||
char_getter = (gchar (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
|
||||
char_getter = (gchar (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
|
||||
cm_char = char_getter(rule->importEnt,cm_param);
|
||||
char_setter = (void(*)(QofEntity*, gchar))cm_param->param_setfcn;
|
||||
char_setter = (void(*)(QofInstance*, gchar))cm_param->param_setfcn;
|
||||
if(char_setter != NULL) { char_setter(rule->targetEnt, cm_char); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(rule->mergeType, QOF_TYPE_COLLECT) == 0) {
|
||||
cm_coll = cm_param->param_getfcn(rule->importEnt, cm_param);
|
||||
collection_setter = (void(*)(QofEntity*, QofCollection*))cm_param->param_setfcn;
|
||||
collection_setter = (void(*)(QofInstance*, QofCollection*))cm_param->param_setfcn;
|
||||
if(collection_setter != NULL) { collection_setter(rule->targetEnt, cm_coll); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(rule->mergeType, QOF_TYPE_CHOICE) == 0) {
|
||||
referenceEnt = cm_param->param_getfcn(rule->importEnt, cm_param);
|
||||
reference_setter = (void(*)(QofEntity*, QofEntity*))cm_param->param_setfcn;
|
||||
reference_setter = (void(*)(QofInstance*, QofInstance*))cm_param->param_setfcn;
|
||||
if(reference_setter != NULL)
|
||||
{
|
||||
reference_setter(rule->targetEnt, referenceEnt);
|
||||
@ -729,7 +729,7 @@ qof_book_merge_commit_rule_loop(
|
||||
if(registered_type == FALSE) {
|
||||
referenceEnt = cm_param->param_getfcn(rule->importEnt, cm_param);
|
||||
if(referenceEnt) {
|
||||
reference_setter = (void(*)(QofEntity*, QofEntity*))cm_param->param_setfcn;
|
||||
reference_setter = (void(*)(QofInstance*, QofInstance*))cm_param->param_setfcn;
|
||||
if(reference_setter != NULL)
|
||||
{
|
||||
reference_setter(rule->targetEnt, referenceEnt);
|
||||
@ -819,20 +819,20 @@ and then add
|
||||
gchar* qof_class_get_param_as_string(QofIdTypeConst, QofInstance*); ?
|
||||
*/
|
||||
gchar*
|
||||
qof_book_merge_param_as_string(QofParam *qtparam, QofEntity *qtEnt)
|
||||
qof_book_merge_param_as_string(QofParam *qtparam, QofInstance *qtEnt)
|
||||
{
|
||||
gchar *param_string, param_date[QOF_DATE_STRING_LENGTH];
|
||||
gchar param_sa[GUID_ENCODING_LENGTH + 1];
|
||||
QofType paramType;
|
||||
const GUID *param_guid;
|
||||
time_t param_t;
|
||||
gnc_numeric param_numeric, (*numeric_getter) (QofEntity*, QofParam*);
|
||||
Timespec param_ts, (*date_getter) (QofEntity*, QofParam*);
|
||||
double param_double, (*double_getter) (QofEntity*, QofParam*);
|
||||
gboolean param_boolean, (*boolean_getter) (QofEntity*, QofParam*);
|
||||
gint32 param_i32, (*int32_getter) (QofEntity*, QofParam*);
|
||||
gint64 param_i64, (*int64_getter) (QofEntity*, QofParam*);
|
||||
gchar param_char, (*char_getter) (QofEntity*, QofParam*);
|
||||
gnc_numeric param_numeric, (*numeric_getter) (QofInstance*, QofParam*);
|
||||
Timespec param_ts, (*date_getter) (QofInstance*, QofParam*);
|
||||
double param_double, (*double_getter) (QofInstance*, QofParam*);
|
||||
gboolean param_boolean, (*boolean_getter) (QofInstance*, QofParam*);
|
||||
gint32 param_i32, (*int32_getter) (QofInstance*, QofParam*);
|
||||
gint64 param_i64, (*int64_getter) (QofInstance*, QofParam*);
|
||||
gchar param_char, (*char_getter) (QofInstance*, QofParam*);
|
||||
|
||||
param_string = NULL;
|
||||
paramType = qtparam->param_type;
|
||||
@ -842,7 +842,7 @@ qof_book_merge_param_as_string(QofParam *qtparam, QofEntity *qtEnt)
|
||||
return param_string;
|
||||
}
|
||||
if(safe_strcmp(paramType, QOF_TYPE_DATE) == 0) {
|
||||
date_getter = (Timespec (*)(QofEntity*, QofParam*))qtparam->param_getfcn;
|
||||
date_getter = (Timespec (*)(QofInstance*, QofParam*))qtparam->param_getfcn;
|
||||
param_ts = date_getter(qtEnt, qtparam);
|
||||
param_t = timespecToTime_t(param_ts);
|
||||
qof_strftime(param_date, QOF_DATE_STRING_LENGTH, QOF_UTC_DATE_FORMAT, gmtime(¶m_t));
|
||||
@ -851,7 +851,7 @@ qof_book_merge_param_as_string(QofParam *qtparam, QofEntity *qtEnt)
|
||||
}
|
||||
if((safe_strcmp(paramType, QOF_TYPE_NUMERIC) == 0) ||
|
||||
(safe_strcmp(paramType, QOF_TYPE_DEBCRED) == 0)) {
|
||||
numeric_getter = (gnc_numeric (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
|
||||
numeric_getter = (gnc_numeric (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
|
||||
param_numeric = numeric_getter(qtEnt,qtparam);
|
||||
param_string = g_strdup(gnc_numeric_to_string(param_numeric));
|
||||
return param_string;
|
||||
@ -863,25 +863,25 @@ qof_book_merge_param_as_string(QofParam *qtparam, QofEntity *qtEnt)
|
||||
return param_string;
|
||||
}
|
||||
if(safe_strcmp(paramType, QOF_TYPE_INT32) == 0) {
|
||||
int32_getter = (gint32 (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
|
||||
int32_getter = (gint32 (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
|
||||
param_i32 = int32_getter(qtEnt, qtparam);
|
||||
param_string = g_strdup_printf("%d", param_i32);
|
||||
return param_string;
|
||||
}
|
||||
if(safe_strcmp(paramType, QOF_TYPE_INT64) == 0) {
|
||||
int64_getter = (gint64 (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
|
||||
int64_getter = (gint64 (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
|
||||
param_i64 = int64_getter(qtEnt, qtparam);
|
||||
param_string = g_strdup_printf("%" G_GINT64_FORMAT, param_i64);
|
||||
return param_string;
|
||||
}
|
||||
if(safe_strcmp(paramType, QOF_TYPE_DOUBLE) == 0) {
|
||||
double_getter = (double (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
|
||||
double_getter = (double (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
|
||||
param_double = double_getter(qtEnt, qtparam);
|
||||
param_string = g_strdup_printf("%f", param_double);
|
||||
return param_string;
|
||||
}
|
||||
if(safe_strcmp(paramType, QOF_TYPE_BOOLEAN) == 0){
|
||||
boolean_getter = (gboolean (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
|
||||
boolean_getter = (gboolean (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
|
||||
param_boolean = boolean_getter(qtEnt, qtparam);
|
||||
/* Boolean values need to be lowercase for QSF validation. */
|
||||
if(param_boolean == TRUE) { param_string = g_strdup("true"); }
|
||||
@ -891,7 +891,7 @@ qof_book_merge_param_as_string(QofParam *qtparam, QofEntity *qtEnt)
|
||||
/* "kvp" contains repeating values, cannot be a single string for the frame. */
|
||||
if(safe_strcmp(paramType, QOF_TYPE_KVP) == 0) { return param_string; }
|
||||
if(safe_strcmp(paramType, QOF_TYPE_CHAR) == 0) {
|
||||
char_getter = (gchar (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
|
||||
char_getter = (gchar (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
|
||||
param_char = char_getter(qtEnt, qtparam);
|
||||
param_string = g_strdup_printf("%c", param_char);
|
||||
return param_string;
|
||||
|
@ -175,7 +175,7 @@ typedef struct
|
||||
GSList *mergeParam; /**< list of usable parameters for the object type */
|
||||
GSList *linkedEntList; /**< list of complex data types included in this object.
|
||||
|
||||
linkedEntList contains an ::QofEntity reference to any parameter that is not
|
||||
linkedEntList contains an ::QofInstance reference to any parameter that is not
|
||||
one of the core QOF_TYPE data types. This entity must be already
|
||||
registered with QOF and the results of the comparison for the linked entity
|
||||
will modulate the mergeResult of this object. e.g. if an invoice is the
|
||||
@ -183,8 +183,8 @@ typedef struct
|
||||
MERGE_REPORT and the customer as MERGE_NEW.
|
||||
*/
|
||||
QofBookMergeResult mergeResult; /**< result of comparison with main ::QofBook */
|
||||
QofEntity *importEnt; /**< pointer to the current entity in the import book. */
|
||||
QofEntity *targetEnt; /**< pointer to the corresponding entity in the
|
||||
QofInstance *importEnt; /**< pointer to the current entity in the import book. */
|
||||
QofInstance *targetEnt; /**< pointer to the corresponding entity in the
|
||||
target book, if any. */
|
||||
}QofBookMergeRule;
|
||||
|
||||
@ -194,7 +194,7 @@ typedef struct
|
||||
Used to dictate what to merge, how to merge it, where to get the new data and
|
||||
where to put the amended data.
|
||||
|
||||
Combines lists of \a ::QofParam, \a ::QofEntity and \a ::QofBookMergeRule
|
||||
Combines lists of \a ::QofParam, \a ::QofInstance and \a ::QofBookMergeRule
|
||||
into one struct that can be easily passed between callbacks. Also holds the
|
||||
pointers to the import and target ::QofBook structures.
|
||||
|
||||
@ -209,7 +209,7 @@ typedef struct
|
||||
parameter in the current object. */
|
||||
GList *mergeList; /**< GList of all ::qof_book_mergeRule rules
|
||||
for the merge operation. */
|
||||
GSList *targetList; /**< GSList of ::QofEntity * for each object
|
||||
GSList *targetList; /**< GSList of ::QofInstance * for each object
|
||||
of this type in the target book */
|
||||
QofBook *mergeBook; /**< pointer to the import book for this
|
||||
merge operation. */
|
||||
@ -218,16 +218,16 @@ typedef struct
|
||||
gboolean abort; /**< set to TRUE if MERGE_INVALID is set. */
|
||||
QofBookMergeRule *currentRule; /**< placeholder for the rule currently
|
||||
being tested or applied. */
|
||||
GSList *orphan_list; /**< List of QofEntity's that need to be rematched.
|
||||
GSList *orphan_list; /**< List of QofInstance's that need to be rematched.
|
||||
|
||||
When one QofEntity has a lower difference to the targetEnt than the
|
||||
When one QofInstance has a lower difference to the targetEnt than the
|
||||
previous best_match, the new match takes precedence. This list holds those
|
||||
orphaned entities that are not a good enough match so that these can be
|
||||
rematched later. The ranking is handled using the private QofEntityRating
|
||||
rematched later. The ranking is handled using the private QofInstanceRating
|
||||
struct and the GHashTable ::QofBookMergeData::target_table.
|
||||
*/
|
||||
GHashTable *target_table; /**< The GHashTable to hold the
|
||||
QofEntityRating values. */
|
||||
QofInstanceRating values. */
|
||||
|
||||
}QofBookMergeData;
|
||||
|
||||
@ -335,7 +335,7 @@ process must handle the NULL targetEnt and NOT call any param_getfcn
|
||||
routines for the target entity. The import entity is available for display.
|
||||
|
||||
Uses ::qof_book_get_collection with the QofBookMergeRule::mergeType object
|
||||
type to return a collection of ::QofEntity entities from either the
|
||||
type to return a collection of ::QofInstance entities from either the
|
||||
QofBookMergeData::mergeBook or QofBookMergeData::targetBook. Then
|
||||
uses ::qof_collection_lookup_entity to lookup the QofBookMergeRule::importEnt
|
||||
and again the qof_book_mergeRule::targetEnt to return the two specific entities.
|
||||
@ -359,7 +359,7 @@ This allows the dialog to display the description of the object and all
|
||||
parameter data.
|
||||
|
||||
*/
|
||||
gchar* qof_book_merge_param_as_string(QofParam *qtparam, QofEntity *qtEnt);
|
||||
gchar* qof_book_merge_param_as_string(QofParam *qtparam, QofInstance *qtEnt);
|
||||
|
||||
/** \brief called by dialogue callback to set the result of user intervention
|
||||
|
||||
|
@ -267,7 +267,7 @@ void qof_class_param_foreach (QofIdTypeConst obj_name,
|
||||
|
||||
Simple check to return a GList of all parameters
|
||||
of this object type that are not known QOF data types.
|
||||
Used for partial QofBook support, see ::QofEntityReference
|
||||
Used for partial QofBook support, see ::QofInstanceReference
|
||||
*/
|
||||
GList* qof_class_get_referenceList(QofIdTypeConst type);
|
||||
|
||||
|
@ -48,6 +48,6 @@ qof_event_generate (const GUID *guid, QofIdType e_type,
|
||||
QofEventId event_id);
|
||||
|
||||
/* generates an event even when events are suspended! */
|
||||
void qof_event_force (QofEntity *entity, QofEventId event_id, gpointer event_data);
|
||||
void qof_event_force (QofInstance *entity, QofEventId event_id, gpointer event_data);
|
||||
|
||||
#endif
|
||||
|
@ -203,7 +203,7 @@ qof_event_resume (void)
|
||||
}
|
||||
|
||||
static void
|
||||
qof_event_generate_internal (QofEntity *entity, QofEventId event_id,
|
||||
qof_event_generate_internal (QofInstance *entity, QofEventId event_id,
|
||||
gpointer event_data)
|
||||
{
|
||||
GList *node;
|
||||
@ -275,7 +275,7 @@ qof_event_generate_internal (QofEntity *entity, QofEventId event_id,
|
||||
}
|
||||
|
||||
void
|
||||
qof_event_force (QofEntity *entity, QofEventId event_id, gpointer event_data)
|
||||
qof_event_force (QofInstance *entity, QofEventId event_id, gpointer event_data)
|
||||
{
|
||||
if (!entity)
|
||||
return;
|
||||
@ -284,7 +284,7 @@ qof_event_force (QofEntity *entity, QofEventId event_id, gpointer event_data)
|
||||
}
|
||||
|
||||
void
|
||||
qof_event_gen (QofEntity *entity, QofEventId event_id, gpointer event_data)
|
||||
qof_event_gen (QofInstance *entity, QofEventId event_id, gpointer event_data)
|
||||
{
|
||||
if (!entity)
|
||||
return;
|
||||
@ -300,7 +300,7 @@ void
|
||||
qof_event_generate (const GUID *guid, QofIdType e_type,
|
||||
QofEventId event_id)
|
||||
{
|
||||
QofEntity ent;
|
||||
QofInstance ent;
|
||||
ent.guid = *guid;
|
||||
ent.e_type = e_type;
|
||||
if (suspend_counter) return;
|
||||
|
@ -81,7 +81,7 @@ for future libqof1 or libqof2 usage.
|
||||
* @param handler_data: data supplied when handler was registered.
|
||||
* @param event_data: data to be supplied when handler is invoked.
|
||||
*/
|
||||
typedef void (*QofEventHandler) (QofEntity *ent, QofEventId event_type,
|
||||
typedef void (*QofEventHandler) (QofInstance *ent, QofEventId event_type,
|
||||
gpointer handler_data, gpointer event_data);
|
||||
|
||||
/** \brief Register a handler for events.
|
||||
@ -113,14 +113,14 @@ void qof_event_unregister_handler (gint handler_id);
|
||||
Any other events are entirely the concern of the application.
|
||||
|
||||
\note QofEventHandler routines do \b NOT support generating
|
||||
events from a GUID and QofIdType - you must specify a genuine QofEntity.
|
||||
events from a GUID and QofIdType - you must specify a genuine QofInstance.
|
||||
|
||||
@param entity: the entity generating the event
|
||||
@param event_type: the name of the event.
|
||||
@param event_data: Data to be passed to the event handler just for
|
||||
this one event. Can be NULL.
|
||||
*/
|
||||
void qof_event_gen (QofEntity *entity, QofEventId event_type,
|
||||
void qof_event_gen (QofInstance *entity, QofEventId event_type,
|
||||
gpointer event_data);
|
||||
|
||||
/** \brief Suspend all engine events.
|
||||
|
@ -202,7 +202,7 @@ qof_gobject_double_getter (gpointer data, QofParam *getter)
|
||||
* of instances that we have on hand.
|
||||
*/
|
||||
static void
|
||||
qof_gobject_foreach (QofCollection *coll, QofEntityForeachCB cb, gpointer ud)
|
||||
qof_gobject_foreach (QofCollection *coll, QofInstanceForeachCB cb, gpointer ud)
|
||||
{
|
||||
GSList *n;
|
||||
n = qof_collection_get_data (coll);
|
||||
|
@ -38,13 +38,13 @@
|
||||
/** Set the ID of the entity, over-riding the previous ID.
|
||||
* Very dangerous, use only for file i/o work.
|
||||
*/
|
||||
void qof_entity_set_guid (QofEntity *ent, const GUID *guid);
|
||||
void qof_instance_set_guid (QofInstance *ent, const GUID *guid);
|
||||
|
||||
/** Take entity, remove it from whatever collection its currently
|
||||
* in, and place it in a new collection. To be used only for
|
||||
* moving entity from one book to another.
|
||||
*/
|
||||
void qof_collection_insert_entity (QofCollection *, QofEntity *);
|
||||
void qof_collection_insert_entity (QofCollection *, QofInstance *);
|
||||
|
||||
/** reset value of dirty flag */
|
||||
void qof_collection_mark_clean (QofCollection *);
|
||||
|
@ -58,10 +58,8 @@ qof_set_alt_dirty_mode (gboolean enabled)
|
||||
|
||||
/* =============================================================== */
|
||||
|
||||
static void qof_collection_remove_entity (QofEntity *ent);
|
||||
|
||||
void
|
||||
qof_entity_init (QofEntity *ent, QofIdType type, QofCollection * tab)
|
||||
qof_entity_init (QofInstance *ent, QofIdType type, QofCollection * tab)
|
||||
{
|
||||
g_return_if_fail (NULL != tab);
|
||||
|
||||
@ -75,7 +73,7 @@ qof_entity_init (QofEntity *ent, QofIdType type, QofCollection * tab)
|
||||
ent->e_type = CACHE_INSERT (type);
|
||||
|
||||
do
|
||||
{
|
||||
{
|
||||
guid_new(&ent->guid);
|
||||
|
||||
if (NULL == qof_collection_lookup_entity (tab, &ent->guid)) break;
|
||||
@ -89,7 +87,7 @@ qof_entity_init (QofEntity *ent, QofIdType type, QofCollection * tab)
|
||||
}
|
||||
|
||||
void
|
||||
qof_entity_release (QofEntity *ent)
|
||||
qof_entity_release (QofInstance *ent)
|
||||
{
|
||||
if (!ent->collection) return;
|
||||
qof_collection_remove_entity (ent);
|
||||
@ -101,7 +99,7 @@ qof_entity_release (QofEntity *ent)
|
||||
/* This is a restricted function, should be used only during
|
||||
* read from file */
|
||||
void
|
||||
qof_entity_set_guid (QofEntity *ent, const GUID *guid)
|
||||
qof_instance_set_guid (QofInstance *ent, const GUID *guid)
|
||||
{
|
||||
QofCollection *col;
|
||||
if (guid_equal (guid, &ent->guid)) return;
|
||||
@ -112,13 +110,6 @@ qof_entity_set_guid (QofEntity *ent, const GUID *guid)
|
||||
qof_collection_insert_entity (col, ent);
|
||||
}
|
||||
|
||||
const GUID *
|
||||
qof_entity_get_guid (const QofEntity *ent)
|
||||
{
|
||||
if (!ent) return guid_null();
|
||||
return &ent->guid;
|
||||
}
|
||||
|
||||
/* =============================================================== */
|
||||
|
||||
static guint
|
||||
@ -189,8 +180,8 @@ qof_collection_get_type (const QofCollection *col)
|
||||
|
||||
/* =============================================================== */
|
||||
|
||||
static void
|
||||
qof_collection_remove_entity (QofEntity *ent)
|
||||
void
|
||||
qof_collection_remove_entity (QofInstance *ent)
|
||||
{
|
||||
QofCollection *col;
|
||||
if (!ent) return;
|
||||
@ -203,7 +194,7 @@ qof_collection_remove_entity (QofEntity *ent)
|
||||
}
|
||||
|
||||
void
|
||||
qof_collection_insert_entity (QofCollection *col, QofEntity *ent)
|
||||
qof_collection_insert_entity (QofCollection *col, QofInstance *ent)
|
||||
{
|
||||
if (!col || !ent) return;
|
||||
if (guid_equal(&ent->guid, guid_null())) return;
|
||||
@ -216,9 +207,9 @@ qof_collection_insert_entity (QofCollection *col, QofEntity *ent)
|
||||
}
|
||||
|
||||
gboolean
|
||||
qof_collection_add_entity (QofCollection *coll, QofEntity *ent)
|
||||
qof_collection_add_entity (QofCollection *coll, QofInstance *ent)
|
||||
{
|
||||
QofEntity *e;
|
||||
QofInstance *e;
|
||||
|
||||
e = NULL;
|
||||
if (!coll || !ent) { return FALSE; }
|
||||
@ -233,7 +224,7 @@ qof_collection_add_entity (QofCollection *coll, QofEntity *ent)
|
||||
}
|
||||
|
||||
static void
|
||||
collection_merge_cb (QofEntity *ent, gpointer data)
|
||||
collection_merge_cb (QofInstance *ent, gpointer data)
|
||||
{
|
||||
QofCollection *target;
|
||||
|
||||
@ -251,10 +242,10 @@ qof_collection_merge (QofCollection *target, QofCollection *merge)
|
||||
}
|
||||
|
||||
static void
|
||||
collection_compare_cb (QofEntity *ent, gpointer user_data)
|
||||
collection_compare_cb (QofInstance *ent, gpointer user_data)
|
||||
{
|
||||
QofCollection *target;
|
||||
QofEntity *e;
|
||||
QofInstance *e;
|
||||
gint value;
|
||||
|
||||
e = NULL;
|
||||
@ -302,10 +293,10 @@ qof_collection_compare (QofCollection *target, QofCollection *merge)
|
||||
return value;
|
||||
}
|
||||
|
||||
QofEntity *
|
||||
QofInstance *
|
||||
qof_collection_lookup_entity (const QofCollection *col, const GUID * guid)
|
||||
{
|
||||
QofEntity *ent;
|
||||
QofInstance *ent;
|
||||
g_return_val_if_fail (col, NULL);
|
||||
if (guid == NULL) return NULL;
|
||||
ent = g_hash_table_lookup (col->hash_of_entities, guid);
|
||||
@ -316,13 +307,13 @@ QofCollection *
|
||||
qof_collection_from_glist (QofIdType type, GList *glist)
|
||||
{
|
||||
QofCollection *coll;
|
||||
QofEntity *ent;
|
||||
QofInstance *ent;
|
||||
GList *list;
|
||||
|
||||
coll = qof_collection_new(type);
|
||||
for(list = glist; list != NULL; list = list->next)
|
||||
{
|
||||
ent = (QofEntity*)list->data;
|
||||
ent = QOF_INSTANCE(list->data);
|
||||
if(FALSE == qof_collection_add_entity(coll, ent))
|
||||
{
|
||||
return NULL;
|
||||
@ -365,7 +356,7 @@ qof_collection_print_dirty (const QofCollection *col, gpointer dummy)
|
||||
{
|
||||
if (col->is_dirty)
|
||||
printf("%s collection is dirty.\n", col->e_type);
|
||||
qof_collection_foreach(col, (QofEntityForeachCB)qof_instance_print_dirty, NULL);
|
||||
qof_collection_foreach(col, (QofInstanceForeachCB)qof_instance_print_dirty, NULL);
|
||||
}
|
||||
|
||||
/* =============================================================== */
|
||||
@ -385,20 +376,20 @@ qof_collection_set_data (QofCollection *col, gpointer user_data)
|
||||
/* =============================================================== */
|
||||
|
||||
struct _iterate {
|
||||
QofEntityForeachCB fcn;
|
||||
QofInstanceForeachCB fcn;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
static void foreach_cb (gpointer key, gpointer item, gpointer arg)
|
||||
{
|
||||
struct _iterate *iter = arg;
|
||||
QofEntity *ent = item;
|
||||
QofInstance *ent = item;
|
||||
|
||||
iter->fcn (ent, iter->data);
|
||||
}
|
||||
|
||||
void
|
||||
qof_collection_foreach (const QofCollection *col, QofEntityForeachCB cb_func,
|
||||
qof_collection_foreach (const QofCollection *col, QofInstanceForeachCB cb_func,
|
||||
gpointer user_data)
|
||||
{
|
||||
struct _iterate iter;
|
||||
|
@ -83,15 +83,16 @@ typedef const gchar * QofIdTypeConst;
|
||||
/** QofLogModule declaration */
|
||||
typedef const gchar* QofLogModule;
|
||||
|
||||
typedef struct QofCollection_s QofCollection;
|
||||
|
||||
#include "qofinstance.h"
|
||||
|
||||
#define QOF_ID_NONE NULL
|
||||
#define QOF_ID_NULL "null"
|
||||
|
||||
#define QOF_ID_BOOK "Book"
|
||||
#define QOF_ID_SESSION "Session"
|
||||
|
||||
/** simple,cheesy cast but holds water for now */
|
||||
#define QOF_ENTITY(object) ((QofEntity *)(object))
|
||||
|
||||
/** Inline string comparision; compiler will optimize away most of this */
|
||||
#define QSTRCMP(da,db) ({ \
|
||||
gint val = 0; \
|
||||
@ -111,7 +112,7 @@ typedef const gchar* QofLogModule;
|
||||
|
||||
/** return TRUE if object is of the given type */
|
||||
#define QOF_CHECK_TYPE(obj,type) (((obj) != NULL) && \
|
||||
(0 == QSTRCMP((type),(((QofEntity *)(obj))->e_type))))
|
||||
(0 == QSTRCMP((type),(((QofInstance *)(obj))->e_type))))
|
||||
|
||||
/** cast object to the indicated type,
|
||||
print error message if its bad */
|
||||
@ -120,12 +121,11 @@ print error message if its bad */
|
||||
(c_type *) (obj) : \
|
||||
(c_type *) ({ \
|
||||
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \
|
||||
"Error: Bad QofEntity at %s:%d", __FILE__, __LINE__); \
|
||||
"Error: Bad QofInstance at %s:%d", __FILE__, __LINE__); \
|
||||
(obj); \
|
||||
}))
|
||||
|
||||
/** QofEntity declaration */
|
||||
typedef struct QofEntity_s QofEntity;
|
||||
|
||||
/** QofCollection declaration
|
||||
|
||||
@param e_type QofIdType
|
||||
@ -134,31 +134,9 @@ typedef struct QofEntity_s QofEntity;
|
||||
@param data gpointer, place where object class can hang arbitrary data
|
||||
|
||||
*/
|
||||
typedef struct QofCollection_s QofCollection;
|
||||
|
||||
/** QofEntity structure
|
||||
|
||||
@param e_type Entity type
|
||||
@param guid GUID for the entity
|
||||
@param collection Entity collection
|
||||
*/
|
||||
|
||||
struct QofEntity_s
|
||||
{
|
||||
QofIdType e_type;
|
||||
GUID guid;
|
||||
QofCollection * collection;
|
||||
};
|
||||
|
||||
/** @name QOF Entity Initialization & Shutdown
|
||||
@{ */
|
||||
/** Initialise the memory associated with an entity */
|
||||
void qof_entity_init (QofEntity *, QofIdType, QofCollection *);
|
||||
|
||||
/** Release the data associated with this entity. Dont actually free
|
||||
* the memory associated with the instance. */
|
||||
void qof_entity_release (QofEntity *);
|
||||
/** @} */
|
||||
void qof_entity_init (QofInstance *ent, QofIdType type, QofCollection * tab);
|
||||
void qof_entity_release (QofInstance *ent);
|
||||
void qof_instance_set_guid (QofInstance *ent, const GUID *guid);
|
||||
|
||||
/** Is QOF operating in "alternate" dirty mode. In normal mode,
|
||||
* whenever an instance is dirtied, the collection (and therefore the
|
||||
@ -178,7 +156,7 @@ gboolean qof_get_alt_dirty_mode (void);
|
||||
void qof_set_alt_dirty_mode (gboolean enabled);
|
||||
|
||||
/** Return the GUID of this entity */
|
||||
const GUID * qof_entity_get_guid (const QofEntity *);
|
||||
const GUID * qof_instance_get_guid (const QofInstance *);
|
||||
|
||||
/** @name Collections of Entities
|
||||
@{ */
|
||||
@ -196,13 +174,13 @@ void qof_collection_destroy (QofCollection *col);
|
||||
QofIdType qof_collection_get_type (const QofCollection *);
|
||||
|
||||
/** Find the entity going only from its guid */
|
||||
QofEntity * qof_collection_lookup_entity (const QofCollection *, const GUID *);
|
||||
QofInstance * qof_collection_lookup_entity (const QofCollection *, const GUID *);
|
||||
|
||||
/** Callback type for qof_entity_foreach */
|
||||
typedef void (*QofEntityForeachCB) (QofEntity *, gpointer user_data);
|
||||
/** Callback type for qof_collection_foreach */
|
||||
typedef void (*QofInstanceForeachCB) (QofInstance *, gpointer user_data);
|
||||
|
||||
/** Call the callback for each entity in the collection. */
|
||||
void qof_collection_foreach (const QofCollection *, QofEntityForeachCB,
|
||||
void qof_collection_foreach (const QofCollection *, QofInstanceForeachCB,
|
||||
gpointer user_data);
|
||||
|
||||
/** Store and retreive arbitrary object-defined data
|
||||
@ -234,11 +212,13 @@ of one object type as references of another entity.
|
||||
Entities can be
|
||||
freely added and merged across these secondary collections, they
|
||||
will not be removed from the original collection as they would
|
||||
by using ::qof_entity_insert_entity or ::qof_entity_remove_entity.
|
||||
by using ::qof_instance_insert_entity or ::qof_instance_remove_entity.
|
||||
|
||||
*/
|
||||
gboolean
|
||||
qof_collection_add_entity (QofCollection *coll, QofEntity *ent);
|
||||
qof_collection_add_entity (QofCollection *coll, QofInstance *ent);
|
||||
|
||||
void qof_collection_remove_entity (QofInstance *ent);
|
||||
|
||||
/** \brief Merge two QOF_TYPE_COLLECT of the same type.
|
||||
|
||||
@ -246,8 +226,8 @@ qof_collection_add_entity (QofCollection *coll, QofEntity *ent);
|
||||
|
||||
QOF_TYPE_COLLECT uses a secondary collection, independent of
|
||||
those in the book. Entities will not be removed from the
|
||||
original collection as when using ::qof_entity_insert_entity
|
||||
or ::qof_entity_remove_entity.
|
||||
original collection as when using ::qof_instance_insert_entity
|
||||
or ::qof_instance_remove_entity.
|
||||
|
||||
*/
|
||||
gboolean
|
||||
@ -255,7 +235,7 @@ qof_collection_merge (QofCollection *target, QofCollection *merge);
|
||||
|
||||
/** \brief Compare two secondary collections.
|
||||
|
||||
Performs a deep comparision of the collections. Each QofEntity in
|
||||
Performs a deep comparision of the collections. Each QofInstance in
|
||||
each collection is looked up in the other collection, via the GUID.
|
||||
|
||||
\return 0 if the collections are identical or both are NULL
|
||||
|
@ -31,49 +31,6 @@
|
||||
|
||||
#include "qofinstance.h"
|
||||
|
||||
/*
|
||||
* UNDER CONSTRUCTION!
|
||||
* This is mostly scaffolding for now,
|
||||
* eventually, it may hold more fields, such as refrence counting...
|
||||
*
|
||||
*/
|
||||
struct QofInstance_s
|
||||
{
|
||||
/* Globally unique id identifying this instance */
|
||||
QofEntity entity;
|
||||
|
||||
/* The entity_table in which this instance is stored */
|
||||
QofBook * book;
|
||||
|
||||
/* kvp_data is a key-value pair database for storing arbirtary
|
||||
* information associated with this instance.
|
||||
* See src/engine/kvp_doc.txt for a list and description of the
|
||||
* important keys. */
|
||||
KvpFrame *kvp_data;
|
||||
|
||||
/* Timestamp used to track the last modification to this
|
||||
* instance. Typically used to compare two versions of the
|
||||
* same object, to see which is newer. When used with the
|
||||
* SQL backend, this field is reserved for SQL use, to compare
|
||||
* the version in local memory to the remote, server version.
|
||||
*/
|
||||
Timespec last_update;
|
||||
|
||||
/* Keep track of nesting level of begin/end edit calls */
|
||||
int editlevel;
|
||||
|
||||
/* In process of being destroyed */
|
||||
gboolean do_free;
|
||||
|
||||
/* dirty/clean flag. If dirty, then this instance has been modified,
|
||||
* but has not yet been written out to storage (file/database)
|
||||
*/
|
||||
gboolean dirty;
|
||||
|
||||
/* True iff this instance has never been committed. */
|
||||
gboolean infant;
|
||||
};
|
||||
|
||||
void qof_instance_set_slots (QofInstance *, KvpFrame *);
|
||||
|
||||
/* Set the last_update time. Reserved for use by the SQL backend;
|
||||
|
@ -39,22 +39,21 @@ static QofLogModule log_module = QOF_MOD_ENGINE;
|
||||
|
||||
/* ========================================================== */
|
||||
|
||||
QofInstance*
|
||||
qof_instance_create (QofIdType type, QofBook *book)
|
||||
{
|
||||
QofInstance *inst;
|
||||
QOF_GOBJECT_GET_TYPE(QofInstance, qof_instance, G_TYPE_OBJECT, {});
|
||||
QOF_GOBJECT_FINALIZE(qof_instance);
|
||||
|
||||
inst = g_new0(QofInstance, 1);
|
||||
qof_instance_init(inst, type, book);
|
||||
return inst;
|
||||
static void qof_instance_dispose(GObject*);
|
||||
static void qof_instance_class_init(QofInstanceClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||
object_class->finalize = qof_instance_finalize;
|
||||
object_class->dispose = qof_instance_dispose;
|
||||
}
|
||||
|
||||
void
|
||||
qof_instance_init (QofInstance *inst, QofIdType type, QofBook *book)
|
||||
static void
|
||||
qof_instance_init (QofInstance *inst)
|
||||
{
|
||||
QofCollection *col;
|
||||
|
||||
inst->book = book;
|
||||
inst->book = NULL;
|
||||
inst->kvp_data = kvp_frame_new();
|
||||
inst->last_update.tv_sec = 0;
|
||||
inst->last_update.tv_nsec = -1;
|
||||
@ -62,27 +61,45 @@ qof_instance_init (QofInstance *inst, QofIdType type, QofBook *book)
|
||||
inst->do_free = FALSE;
|
||||
inst->dirty = FALSE;
|
||||
inst->infant = TRUE;
|
||||
|
||||
col = qof_book_get_collection (book, type);
|
||||
qof_entity_init (&inst->entity, type, col);
|
||||
}
|
||||
|
||||
void
|
||||
qof_instance_release (QofInstance *inst)
|
||||
qof_instance_init_data (QofInstance *inst, QofIdType type, QofBook *book)
|
||||
{
|
||||
QofCollection *col;
|
||||
g_return_if_fail(QOF_IS_INSTANCE(inst));
|
||||
g_return_if_fail(!inst->book);
|
||||
|
||||
inst->book = book;
|
||||
col = qof_book_get_collection (book, type);
|
||||
qof_entity_init (inst, type, col);
|
||||
}
|
||||
|
||||
static void
|
||||
qof_instance_dispose (GObject *instp)
|
||||
{
|
||||
QofInstance* inst = QOF_INSTANCE(instp);
|
||||
qof_entity_release (inst);
|
||||
G_OBJECT_CLASS(qof_instance_parent_class)->dispose(instp);
|
||||
}
|
||||
|
||||
static void
|
||||
qof_instance_finalize_real (GObject *instp)
|
||||
{
|
||||
QofInstance* inst = QOF_INSTANCE(instp);
|
||||
|
||||
kvp_frame_delete (inst->kvp_data);
|
||||
inst->kvp_data = NULL;
|
||||
inst->editlevel = 0;
|
||||
inst->do_free = FALSE;
|
||||
inst->dirty = FALSE;
|
||||
qof_entity_release (&inst->entity);
|
||||
}
|
||||
|
||||
const GUID *
|
||||
qof_instance_get_guid (const QofInstance *inst)
|
||||
{
|
||||
if (!inst) return NULL;
|
||||
return &inst->entity.guid;
|
||||
if (!inst) return guid_null();
|
||||
return &(inst->guid);
|
||||
}
|
||||
|
||||
QofBook *
|
||||
@ -124,13 +141,13 @@ qof_instance_version_cmp (const QofInstance *left, const QofInstance *right)
|
||||
}
|
||||
|
||||
void
|
||||
qof_instance_print_dirty (const QofEntity *entity, gpointer dummy)
|
||||
qof_instance_print_dirty (const QofInstance *entity, gpointer dummy)
|
||||
{
|
||||
QofInstance *inst = QOF_INSTANCE(entity);
|
||||
|
||||
if (inst->dirty)
|
||||
printf("%s instance %s is dirty.\n", inst->entity.e_type,
|
||||
guid_to_string(&inst->entity.guid));
|
||||
printf("%s instance %s is dirty.\n", inst->e_type,
|
||||
guid_to_string(&inst->guid));
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -141,7 +158,7 @@ qof_instance_is_dirty (QofInstance *inst)
|
||||
if (!inst) { return FALSE; }
|
||||
if (qof_get_alt_dirty_mode())
|
||||
return inst->dirty;
|
||||
coll = inst->entity.collection;
|
||||
coll = inst->collection;
|
||||
if(qof_collection_is_dirty(coll)) { return inst->dirty; }
|
||||
inst->dirty = FALSE;
|
||||
return FALSE;
|
||||
@ -154,7 +171,7 @@ qof_instance_set_dirty(QofInstance* inst)
|
||||
|
||||
inst->dirty = TRUE;
|
||||
if (!qof_get_alt_dirty_mode()) {
|
||||
coll = inst->entity.collection;
|
||||
coll = inst->collection;
|
||||
qof_collection_mark_dirty(coll);
|
||||
}
|
||||
}
|
||||
@ -222,12 +239,12 @@ qof_instance_gemini (QofInstance *to, const QofInstance *from)
|
||||
|
||||
/* Make a note of where the copy came from */
|
||||
gnc_kvp_bag_add (to->kvp_data, "gemini", now,
|
||||
"inst_guid", &from->entity.guid,
|
||||
"book_guid", &from->book->inst.entity.guid,
|
||||
"inst_guid", &from->guid,
|
||||
"book_guid", &from->book->inst.guid,
|
||||
NULL);
|
||||
gnc_kvp_bag_add (from->kvp_data, "gemini", now,
|
||||
"inst_guid", &to->entity.guid,
|
||||
"book_guid", &to->book->inst.entity.guid,
|
||||
"inst_guid", &to->guid,
|
||||
"book_guid", &to->book->inst.guid,
|
||||
NULL);
|
||||
|
||||
to->dirty = TRUE;
|
||||
@ -245,11 +262,11 @@ qof_instance_lookup_twin (const QofInstance *src, QofBook *target_book)
|
||||
ENTER (" ");
|
||||
|
||||
fr = gnc_kvp_bag_find_by_guid (src->kvp_data, "gemini",
|
||||
"book_guid", &target_book->inst.entity.guid);
|
||||
"book_guid", &target_book->inst.guid);
|
||||
|
||||
twin_guid = kvp_frame_get_guid (fr, "inst_guid");
|
||||
|
||||
col = qof_book_get_collection (target_book, src->entity.e_type);
|
||||
col = qof_book_get_collection (target_book, src->e_type);
|
||||
twin = (QofInstance *) qof_collection_lookup_entity (col, twin_guid);
|
||||
|
||||
LEAVE (" found twin=%p", twin);
|
||||
|
@ -22,7 +22,7 @@
|
||||
/** @addtogroup Entity
|
||||
@{ */
|
||||
/** @addtogroup Instance
|
||||
Qof Instances are a derived type of QofEntity. The Instance
|
||||
Qof Instances are a derived type of QofInstance. The Instance
|
||||
adds some common features and functions that most objects
|
||||
will want to use.
|
||||
|
||||
@ -36,25 +36,82 @@
|
||||
#ifndef QOF_INSTANCE_H
|
||||
#define QOF_INSTANCE_H
|
||||
|
||||
typedef struct _QofInstanceClass QofInstanceClass;
|
||||
typedef struct QofInstance_s QofInstance;
|
||||
|
||||
/** \brief QofBook reference */
|
||||
typedef struct _QofBook QofBook;
|
||||
|
||||
#include "qofid.h"
|
||||
#include "guid.h"
|
||||
#include "gnc-date.h"
|
||||
#include "kvp_frame.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofid.h"
|
||||
#include "qof-gobject.h"
|
||||
|
||||
/* --- type macros --- */
|
||||
/* cheesy, but will do for now, eventually should be more gtk-like, handle
|
||||
* thunks, etc. */
|
||||
#define QOF_INSTANCE(object) ((QofInstance *)(object))
|
||||
#define QOF_TYPE_INSTANCE (qof_instance_get_type ())
|
||||
#define QOF_INSTANCE(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((o), QOF_TYPE_INSTANCE, QofInstance))
|
||||
#define QOF_INSTANCE_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((k), QOF_TYPE_INSTANCE, QofInstanceClass))
|
||||
#define QOF_IS_INSTANCE(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((o), QOF_TYPE_INSTANCE))
|
||||
#define QOF_IS_INSTANCE_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((k), QOF_TYPE_INSTANCE))
|
||||
#define QOF_INSTANCE_GET_CLASS(o) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((o), QOF_TYPE_INSTANCE, QofInstanceClass))
|
||||
|
||||
typedef struct QofInstance_s QofInstance;
|
||||
struct QofInstance_s
|
||||
{
|
||||
GObject object;
|
||||
|
||||
/** Initialise the memory associated with an instance */
|
||||
void qof_instance_init (QofInstance *, QofIdType, QofBook *);
|
||||
/* Globally unique id identifying this instance */
|
||||
QofIdType e_type; /**< Entity type */
|
||||
GUID guid; /**< GUID for the entity */
|
||||
QofCollection * collection; /**< Entity collection */
|
||||
|
||||
/** release the data associated with this instance. Dont actually free
|
||||
* the memory associated with the instance. */
|
||||
void qof_instance_release (QofInstance *inst);
|
||||
/* The entity_table in which this instance is stored */
|
||||
QofBook * book;
|
||||
|
||||
/* kvp_data is a key-value pair database for storing arbirtary
|
||||
* information associated with this instance.
|
||||
* See src/engine/kvp_doc.txt for a list and description of the
|
||||
* important keys. */
|
||||
KvpFrame *kvp_data;
|
||||
|
||||
/* Timestamp used to track the last modification to this
|
||||
* instance. Typically used to compare two versions of the
|
||||
* same object, to see which is newer. When used with the
|
||||
* SQL backend, this field is reserved for SQL use, to compare
|
||||
* the version in local memory to the remote, server version.
|
||||
*/
|
||||
Timespec last_update;
|
||||
|
||||
/* Keep track of nesting level of begin/end edit calls */
|
||||
int editlevel;
|
||||
|
||||
/* In process of being destroyed */
|
||||
gboolean do_free;
|
||||
|
||||
/* dirty/clean flag. If dirty, then this instance has been modified,
|
||||
* but has not yet been written out to storage (file/database)
|
||||
*/
|
||||
gboolean dirty;
|
||||
|
||||
/* True iff this instance has never been committed. */
|
||||
gboolean infant;
|
||||
};
|
||||
|
||||
struct _QofInstanceClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
/** Return the GType of a QofInstance */
|
||||
GType qof_instance_get_type(void);
|
||||
|
||||
/** Initialise the settings associated with an instance */
|
||||
void qof_instance_init_data (QofInstance *, QofIdType, QofBook *);
|
||||
|
||||
/** Return the book pointer */
|
||||
QofBook * qof_instance_get_book (const QofInstance *);
|
||||
@ -81,7 +138,7 @@ Timespec qof_instance_get_last_update (const QofInstance *inst);
|
||||
*/
|
||||
int qof_instance_version_cmp (const QofInstance *left, const QofInstance *right);
|
||||
|
||||
void qof_instance_print_dirty (const QofEntity *entity, gpointer dummy);
|
||||
void qof_instance_print_dirty (const QofInstance *entity, gpointer dummy);
|
||||
|
||||
/** Return value of is_dirty flag */
|
||||
gboolean qof_instance_is_dirty (QofInstance *);
|
||||
@ -101,8 +158,6 @@ gboolean qof_instance_do_free(const QofInstance *inst);
|
||||
|
||||
void qof_instance_mark_free(QofInstance *inst);
|
||||
|
||||
QofInstance* qof_instance_create (QofIdType type, QofBook *book);
|
||||
|
||||
/** 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,
|
||||
|
@ -156,7 +156,7 @@ qof_object_compliance (QofIdTypeConst type_name, gboolean warn)
|
||||
|
||||
void
|
||||
qof_object_foreach (QofIdTypeConst type_name, QofBook *book,
|
||||
QofEntityForeachCB cb, gpointer user_data)
|
||||
QofInstanceForeachCB cb, gpointer user_data)
|
||||
{
|
||||
QofCollection *col;
|
||||
const QofObject *obj;
|
||||
|
@ -104,7 +104,7 @@ struct _QofObject
|
||||
* provide this routine, as without it, little of interest can
|
||||
* be done.
|
||||
*/
|
||||
void (*foreach)(const QofCollection *, QofEntityForeachCB, gpointer);
|
||||
void (*foreach)(const QofCollection *, QofInstanceForeachCB, gpointer);
|
||||
|
||||
/** Given a particular item of this type, return a printable string.
|
||||
*/
|
||||
@ -160,7 +160,7 @@ void qof_object_foreach_type (QofForeachTypeCB cb, gpointer user_data);
|
||||
* be invoked only for those instances stored in the book.
|
||||
*/
|
||||
void qof_object_foreach (QofIdTypeConst type_name, QofBook *book,
|
||||
QofEntityForeachCB cb, gpointer user_data);
|
||||
QofInstanceForeachCB cb, gpointer user_data);
|
||||
|
||||
/** Register and lookup backend-specific data for this particular object */
|
||||
gboolean qof_object_register_backend (QofIdTypeConst type_name,
|
||||
|
@ -809,7 +809,7 @@ static void qof_query_run_cb(QofQueryCB* qcb, gpointer cb_arg)
|
||||
|
||||
/* And then iterate over all the objects */
|
||||
qof_object_foreach (qcb->query->search_for, book,
|
||||
(QofEntityForeachCB) check_item_cb, qcb);
|
||||
(QofInstanceForeachCB) check_item_cb, qcb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1450,13 +1450,13 @@ collect_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2)
|
||||
}
|
||||
|
||||
static void
|
||||
query_collect_cb(QofEntity* ent, gpointer user_data)
|
||||
query_collect_cb(QofInstance* ent, gpointer user_data)
|
||||
{
|
||||
query_coll_t pdata;
|
||||
GUID *guid;
|
||||
|
||||
guid = guid_malloc();
|
||||
guid = (GUID*)qof_entity_get_guid(ent);
|
||||
guid = (GUID*)qof_instance_get_guid(ent);
|
||||
pdata = (query_coll_t)user_data;
|
||||
pdata->guids = g_list_append(pdata->guids, guid);
|
||||
}
|
||||
|
@ -26,16 +26,16 @@
|
||||
#include "qofreference.h"
|
||||
|
||||
static void
|
||||
entity_set_reference_cb(QofEntity *ent, gpointer user_data)
|
||||
entity_set_reference_cb(QofInstance *ent, gpointer user_data)
|
||||
{
|
||||
void (*reference_setter) (QofEntity*, QofEntity*);
|
||||
void (*choice_setter) (QofEntity*, QofEntity*);
|
||||
void (*collect_setter)(QofEntity*, QofCollection*);
|
||||
QofEntityReference *ref;
|
||||
void (*reference_setter) (QofInstance*, QofInstance*);
|
||||
void (*choice_setter) (QofInstance*, QofInstance*);
|
||||
void (*collect_setter)(QofInstance*, QofCollection*);
|
||||
QofInstanceReference *ref;
|
||||
GList *book_ref_list;
|
||||
QofCollection *coll;
|
||||
QofIdType type;
|
||||
QofEntity *reference;
|
||||
QofInstance *reference;
|
||||
QofBook *partial_book;
|
||||
|
||||
partial_book = (QofBook*)user_data;
|
||||
@ -45,8 +45,8 @@ entity_set_reference_cb(QofEntity *ent, gpointer user_data)
|
||||
book_ref_list = qof_book_get_data(partial_book, ENTITYREFERENCE);
|
||||
while(book_ref_list)
|
||||
{
|
||||
ref = (QofEntityReference*)book_ref_list->data;
|
||||
if(0 == guid_compare(ref->ref_guid, qof_entity_get_guid(ent)))
|
||||
ref = (QofInstanceReference*)book_ref_list->data;
|
||||
if(0 == guid_compare(ref->ref_guid, qof_instance_get_guid(ent)))
|
||||
{
|
||||
/* avoid setting the entity's own guid as a reference. */
|
||||
book_ref_list = g_list_next(book_ref_list);
|
||||
@ -56,7 +56,7 @@ entity_set_reference_cb(QofEntity *ent, gpointer user_data)
|
||||
type = ref->param->param_type;
|
||||
coll = qof_book_get_collection(partial_book, type);
|
||||
reference = qof_collection_lookup_entity(coll, ref->ref_guid);
|
||||
reference_setter = (void(*)(QofEntity*, QofEntity*))ref->param->param_setfcn;
|
||||
reference_setter = (void(*)(QofInstance*, QofInstance*))ref->param->param_setfcn;
|
||||
if((reference) && (reference_setter))
|
||||
{
|
||||
qof_begin_edit((QofInstance*)ent);
|
||||
@ -66,10 +66,10 @@ entity_set_reference_cb(QofEntity *ent, gpointer user_data)
|
||||
qof_commit_edit((QofInstance*)reference);
|
||||
}
|
||||
/* collect and choice handling */
|
||||
collect_setter = (void(*)(QofEntity*, QofCollection*))ref->param->param_setfcn;
|
||||
choice_setter = (void(*)(QofEntity*, QofEntity*))ref->param->param_setfcn;
|
||||
collect_setter = (void(*)(QofInstance*, QofCollection*))ref->param->param_setfcn;
|
||||
choice_setter = (void(*)(QofInstance*, QofInstance*))ref->param->param_setfcn;
|
||||
if ((0 == safe_strcmp(ref->param->param_type, QOF_TYPE_COLLECT)) &&
|
||||
(0 == guid_compare(qof_entity_get_guid(ent), ref->ent_guid)) &&
|
||||
(0 == guid_compare(qof_instance_get_guid(ent), ref->ent_guid)) &&
|
||||
(0 == safe_strcmp(ref->type, ent->e_type)))
|
||||
{
|
||||
QofCollection *temp_col;
|
||||
@ -113,18 +113,18 @@ set_each_type(QofObject *obj, gpointer user_data)
|
||||
qof_object_foreach(obj->e_type, book, entity_set_reference_cb, book);
|
||||
}
|
||||
|
||||
static QofEntityReference*
|
||||
create_reference(QofEntity *ent, const QofParam *param)
|
||||
static QofInstanceReference*
|
||||
create_reference(QofInstance *ent, const QofParam *param)
|
||||
{
|
||||
QofEntityReference *reference;
|
||||
QofEntity *ref_ent;
|
||||
QofInstanceReference *reference;
|
||||
QofInstance *ref_ent;
|
||||
const GUID *cm_guid;
|
||||
char cm_sa[GUID_ENCODING_LENGTH + 1];
|
||||
gchar *cm_string;
|
||||
|
||||
ref_ent = (QofEntity*)param->param_getfcn(ent, param);
|
||||
ref_ent = QOF_INSTANCE(param->param_getfcn(ent, param));
|
||||
if(!ref_ent) { return NULL; }
|
||||
reference = g_new0(QofEntityReference, 1);
|
||||
reference = g_new0(QofInstanceReference, 1);
|
||||
reference->type = ent->e_type;
|
||||
reference->ref_guid = g_new(GUID, 1);
|
||||
reference->ent_guid = &ent->guid;
|
||||
@ -133,7 +133,7 @@ create_reference(QofEntity *ent, const QofParam *param)
|
||||
reference->choice_type = ref_ent->e_type;
|
||||
}
|
||||
reference->param = param;
|
||||
cm_guid = qof_entity_get_guid(ref_ent);
|
||||
cm_guid = qof_instance_get_guid(ref_ent);
|
||||
guid_to_string_buff(cm_guid, cm_sa);
|
||||
cm_string = g_strdup(cm_sa);
|
||||
if(TRUE == string_to_guid(cm_string, reference->ref_guid)) {
|
||||
@ -144,8 +144,8 @@ create_reference(QofEntity *ent, const QofParam *param)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QofEntityReference*
|
||||
qof_entity_get_reference_from(QofEntity *ent, const QofParam *param)
|
||||
QofInstanceReference*
|
||||
qof_instance_get_reference_from(QofInstance *ent, const QofParam *param)
|
||||
{
|
||||
g_return_val_if_fail(param, NULL);
|
||||
param = qof_class_get_parameter(ent->e_type, param->param_name);
|
||||
|
@ -39,15 +39,15 @@ a partial book and then convert the same book to a standard book.
|
||||
|
||||
Different backends have different requirements for a complete book - some
|
||||
(like gnucash) are highly customised to that application - however all complete
|
||||
QofBooks must be self-contained, only a partial book uses QofEntityReference.
|
||||
QofBooks must be self-contained, only a partial book uses QofInstanceReference.
|
||||
|
||||
To retain the relationships between entities, including between a partial and
|
||||
a complete book, QofEntityReference data is stored in the QofBook. This data
|
||||
a complete book, QofInstanceReference data is stored in the QofBook. This data
|
||||
should be read by backends that support partial books so that the exported
|
||||
data contains the GUID and QofIdType of the referenced entity. Even if that
|
||||
entity does not then exist within the partial book, it can be located when
|
||||
the partial book is merged back into the original, complete, book. (Remember
|
||||
that given the GUID and QofIdType of any QofEntity it is possible to uniquely
|
||||
that given the GUID and QofIdType of any QofInstance it is possible to uniquely
|
||||
identify that entity in another book.)
|
||||
|
||||
Entities in partial books may need to refer to the entities that remain within
|
||||
@ -81,7 +81,7 @@ When the file is imported back in, the list needs to be rebuilt.
|
||||
The QSF backend rebuilds the references by linking to real entities.
|
||||
Other backends can process the list in similar ways.
|
||||
|
||||
The list stores the QofEntityReference to the referenced entity -
|
||||
The list stores the QofInstanceReference to the referenced entity -
|
||||
a struct that contains the GUID and the QofIdType of the referenced
|
||||
entity as well as the parameter used to obtain the reference.
|
||||
|
||||
@ -102,7 +102,7 @@ It is used by the entity copy functions and by the QSF backend.
|
||||
Creates a GList stored in the Book hashtable to contain
|
||||
repeated references for a single entity.
|
||||
*/
|
||||
typedef struct qof_entity_reference {
|
||||
typedef struct qof_instance_reference {
|
||||
QofIdType choice_type;/**< Used when the reference is a QOF_TYPE_CHOICE type
|
||||
- stores the actual type of the reference from the list of available choices. */
|
||||
QofIdType type; /**< The type of the original entity -
|
||||
@ -112,7 +112,7 @@ typedef struct qof_entity_reference {
|
||||
const QofParam *param; /**< The parameter of the original entity to use
|
||||
to get or set the reference. */
|
||||
const GUID *ent_guid; /**< The GUID of the original entity. */
|
||||
}QofEntityReference;
|
||||
}QofInstanceReference;
|
||||
|
||||
/** \brief Adds a new reference to the partial book data hash.
|
||||
|
||||
@ -122,17 +122,17 @@ If the book is not already marked as partial, it will be marked as
|
||||
partial.
|
||||
*/
|
||||
void
|
||||
qof_session_update_reference_list(QofSession *session, QofEntityReference *reference);
|
||||
qof_session_update_reference_list(QofSession *session, QofInstanceReference *reference);
|
||||
|
||||
/** Used as the key value for the QofBook data hash.
|
||||
*
|
||||
* Retrieved later by QSF (or any other suitable backend) to
|
||||
* rebuild the references from the QofEntityReference struct
|
||||
* rebuild the references from the QofInstanceReference struct
|
||||
* that contains the QofIdType and GUID of the referenced entity
|
||||
* of the original QofBook as well as the parameter data and the
|
||||
* GUID of the original entity.
|
||||
* */
|
||||
#define ENTITYREFERENCE "QofEntityReference"
|
||||
#define ENTITYREFERENCE "QofInstanceReference"
|
||||
|
||||
/** \brief Flag indicating a partial QofBook.
|
||||
|
||||
@ -143,11 +143,11 @@ books can be used to save this session.
|
||||
|
||||
#define PARTIAL_QOFBOOK "PartialQofBook"
|
||||
|
||||
/** \brief Read QofEntityReference data for this book and set values.
|
||||
/** \brief Read QofInstanceReference data for this book and set values.
|
||||
|
||||
@param book The partial book containing the referenceList
|
||||
|
||||
The referenceList is a GList of QofEntityReference structures that contain
|
||||
The referenceList is a GList of QofInstanceReference structures that contain
|
||||
the GUID of each end of a reference. e.g. where one entity refers to another.
|
||||
|
||||
The referenceList is used in partial books to store relationships between
|
||||
@ -173,14 +173,14 @@ void qof_book_set_references(QofBook *book);
|
||||
been checked \b NOT to be QOF_TYPE_COLLECT or other known QOF types
|
||||
because this function expects to return a single reference and
|
||||
a collect parameter would need to return a list of references, other
|
||||
parameters would not return a viable QofEntity. (A string cannot be
|
||||
parameters would not return a viable QofInstance. (A string cannot be
|
||||
cast to an entity.)
|
||||
|
||||
Used in the preparation of a partial QofBook when the known entity
|
||||
(the one currently being copied into the partial book) refers to
|
||||
any other entity, usually as a parent or child.
|
||||
The routine calls the param_getfcn of the supplied parameter,
|
||||
which must return an object (QofEntity*), not a known QOF data type, to
|
||||
which must return an object (QofInstance*), not a known QOF data type, to
|
||||
retrieve the referenced entity and therefore the GUID. The GUID of
|
||||
both entities are stored in the reference which then needs to be added
|
||||
to the reference list which is added to the partial book data hash.
|
||||
@ -199,10 +199,10 @@ the integrity of the partial book during sequential copy operations.
|
||||
@param ent The known entity.
|
||||
@param param The parameter to use to get the referenced entity.
|
||||
|
||||
@return FALSE on error, otherwise a pointer to the QofEntityReference.
|
||||
@return FALSE on error, otherwise a pointer to the QofInstanceReference.
|
||||
*/
|
||||
QofEntityReference*
|
||||
qof_entity_get_reference_from(QofEntity *ent, const QofParam *param);
|
||||
QofInstanceReference*
|
||||
qof_instance_get_reference_from(QofInstance *ent, const QofParam *param);
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
@ -38,7 +38,7 @@ struct _QofSession
|
||||
* an Entity. NOTE: THIS IS NOT AN ENTITY! THE ONLY PART OF ENTITY
|
||||
* THAT IS VALID IS E_TYPE!
|
||||
*/
|
||||
QofEntity entity;
|
||||
QofInstance entity;
|
||||
|
||||
/* A book holds pointers to the various types of datasets.
|
||||
* A session may have multiple books. */
|
||||
|
@ -305,15 +305,15 @@ qof_session_get_url (QofSession *session)
|
||||
|
||||
/* =============================================================== */
|
||||
|
||||
typedef struct qof_entity_copy_data {
|
||||
QofEntity *from;
|
||||
QofEntity *to;
|
||||
typedef struct qof_instance_copy_data {
|
||||
QofInstance *from;
|
||||
QofInstance *to;
|
||||
QofParam *param;
|
||||
GList *referenceList;
|
||||
GSList *param_list;
|
||||
QofSession *new_session;
|
||||
gboolean error;
|
||||
}QofEntityCopyData;
|
||||
}QofInstanceCopyData;
|
||||
|
||||
static void
|
||||
qof_book_set_partial(QofBook *book)
|
||||
@ -328,7 +328,7 @@ qof_book_set_partial(QofBook *book)
|
||||
}
|
||||
|
||||
void
|
||||
qof_session_update_reference_list(QofSession *session, QofEntityReference *reference)
|
||||
qof_session_update_reference_list(QofSession *session, QofInstanceReference *reference)
|
||||
{
|
||||
QofBook *book;
|
||||
GList *book_ref_list;
|
||||
@ -341,12 +341,12 @@ qof_session_update_reference_list(QofSession *session, QofEntityReference *refer
|
||||
}
|
||||
|
||||
static void
|
||||
qof_entity_param_cb(QofParam *param, gpointer data)
|
||||
qof_instance_param_cb(QofParam *param, gpointer data)
|
||||
{
|
||||
QofEntityCopyData *qecd;
|
||||
QofInstanceCopyData *qecd;
|
||||
|
||||
g_return_if_fail(data != NULL);
|
||||
qecd = (QofEntityCopyData*)data;
|
||||
qecd = (QofInstanceCopyData*)data;
|
||||
g_return_if_fail(param != NULL);
|
||||
/* KVP doesn't need a set routine to be copied. */
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_KVP)) {
|
||||
@ -359,24 +359,24 @@ qof_entity_param_cb(QofParam *param, gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
col_ref_cb (QofEntity* ref_ent, gpointer user_data)
|
||||
col_ref_cb (QofInstance* ref_ent, gpointer user_data)
|
||||
{
|
||||
QofEntityReference *ref;
|
||||
QofEntityCopyData *qecd;
|
||||
QofEntity *ent;
|
||||
QofInstanceReference *ref;
|
||||
QofInstanceCopyData *qecd;
|
||||
QofInstance *ent;
|
||||
const GUID *cm_guid;
|
||||
char cm_sa[GUID_ENCODING_LENGTH + 1];
|
||||
gchar *cm_string;
|
||||
|
||||
qecd = (QofEntityCopyData*)user_data;
|
||||
qecd = (QofInstanceCopyData*)user_data;
|
||||
ent = qecd->from;
|
||||
ref = g_new0(QofEntityReference, 1);
|
||||
ref = g_new0(QofInstanceReference, 1);
|
||||
ref->type = ent->e_type;
|
||||
ref->ref_guid = g_new(GUID, 1);
|
||||
ref->ent_guid = &ent->guid;
|
||||
ref->param = qof_class_get_parameter(ent->e_type,
|
||||
qecd->param->param_name);
|
||||
cm_guid = qof_entity_get_guid(ref_ent);
|
||||
cm_guid = qof_instance_get_guid(ref_ent);
|
||||
guid_to_string_buff(cm_guid, cm_sa);
|
||||
cm_string = g_strdup(cm_sa);
|
||||
if(TRUE == string_to_guid(cm_string, ref->ref_guid)) {
|
||||
@ -386,11 +386,11 @@ col_ref_cb (QofEntity* ref_ent, gpointer user_data)
|
||||
}
|
||||
|
||||
static void
|
||||
qof_entity_foreach_copy(gpointer data, gpointer user_data)
|
||||
qof_instance_foreach_copy(gpointer data, gpointer user_data)
|
||||
{
|
||||
QofEntity *importEnt, *targetEnt/*, *referenceEnt*/;
|
||||
QofEntityCopyData *context;
|
||||
QofEntityReference *reference;
|
||||
QofInstance *importEnt, *targetEnt/*, *referenceEnt*/;
|
||||
QofInstanceCopyData *context;
|
||||
QofInstanceReference *reference;
|
||||
gboolean registered_type;
|
||||
/* cm_ prefix used for variables that hold the data to commit */
|
||||
QofParam *cm_param;
|
||||
@ -399,26 +399,26 @@ qof_entity_foreach_copy(gpointer data, gpointer user_data)
|
||||
KvpFrame *cm_kvp;
|
||||
QofCollection *cm_col;
|
||||
/* function pointers and variables for parameter getters that don't use pointers normally */
|
||||
gnc_numeric cm_numeric, (*numeric_getter) (QofEntity*, QofParam*);
|
||||
double cm_double, (*double_getter) (QofEntity*, QofParam*);
|
||||
gboolean cm_boolean, (*boolean_getter) (QofEntity*, QofParam*);
|
||||
gint32 cm_i32, (*int32_getter) (QofEntity*, QofParam*);
|
||||
gint64 cm_i64, (*int64_getter) (QofEntity*, QofParam*);
|
||||
Timespec cm_date, (*date_getter) (QofEntity*, QofParam*);
|
||||
gnc_numeric cm_numeric, (*numeric_getter) (QofInstance*, QofParam*);
|
||||
double cm_double, (*double_getter) (QofInstance*, QofParam*);
|
||||
gboolean cm_boolean, (*boolean_getter) (QofInstance*, QofParam*);
|
||||
gint32 cm_i32, (*int32_getter) (QofInstance*, QofParam*);
|
||||
gint64 cm_i64, (*int64_getter) (QofInstance*, QofParam*);
|
||||
Timespec cm_date, (*date_getter) (QofInstance*, QofParam*);
|
||||
/* function pointers to the parameter setters */
|
||||
void (*string_setter) (QofEntity*, const char*);
|
||||
void (*date_setter) (QofEntity*, Timespec);
|
||||
void (*numeric_setter) (QofEntity*, gnc_numeric);
|
||||
void (*guid_setter) (QofEntity*, const GUID*);
|
||||
void (*double_setter) (QofEntity*, double);
|
||||
void (*boolean_setter) (QofEntity*, gboolean);
|
||||
void (*i32_setter) (QofEntity*, gint32);
|
||||
void (*i64_setter) (QofEntity*, gint64);
|
||||
void (*char_setter) (QofEntity*, char*);
|
||||
void (*kvp_frame_setter) (QofEntity*, KvpFrame*);
|
||||
void (*string_setter) (QofInstance*, const char*);
|
||||
void (*date_setter) (QofInstance*, Timespec);
|
||||
void (*numeric_setter) (QofInstance*, gnc_numeric);
|
||||
void (*guid_setter) (QofInstance*, const GUID*);
|
||||
void (*double_setter) (QofInstance*, double);
|
||||
void (*boolean_setter) (QofInstance*, gboolean);
|
||||
void (*i32_setter) (QofInstance*, gint32);
|
||||
void (*i64_setter) (QofInstance*, gint64);
|
||||
void (*char_setter) (QofInstance*, char*);
|
||||
void (*kvp_frame_setter) (QofInstance*, KvpFrame*);
|
||||
|
||||
g_return_if_fail(user_data != NULL);
|
||||
context = (QofEntityCopyData*) user_data;
|
||||
context = (QofInstanceCopyData*) user_data;
|
||||
cm_date.tv_nsec = 0;
|
||||
cm_date.tv_sec = 0;
|
||||
importEnt = context->from;
|
||||
@ -430,63 +430,63 @@ qof_entity_foreach_copy(gpointer data, gpointer user_data)
|
||||
if(safe_strcmp(cm_param->param_type, QOF_TYPE_STRING) == 0) {
|
||||
cm_string = (gchar*)cm_param->param_getfcn(importEnt, cm_param);
|
||||
if(cm_string) {
|
||||
string_setter = (void(*)(QofEntity*, const char*))cm_param->param_setfcn;
|
||||
string_setter = (void(*)(QofInstance*, const char*))cm_param->param_setfcn;
|
||||
if(string_setter != NULL) { string_setter(targetEnt, cm_string); }
|
||||
}
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(cm_param->param_type, QOF_TYPE_DATE) == 0) {
|
||||
date_getter = (Timespec (*)(QofEntity*, QofParam*))cm_param->param_getfcn;
|
||||
date_getter = (Timespec (*)(QofInstance*, QofParam*))cm_param->param_getfcn;
|
||||
cm_date = date_getter(importEnt, cm_param);
|
||||
date_setter = (void(*)(QofEntity*, Timespec))cm_param->param_setfcn;
|
||||
date_setter = (void(*)(QofInstance*, Timespec))cm_param->param_setfcn;
|
||||
if(date_setter != NULL) { date_setter(targetEnt, cm_date); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if((safe_strcmp(cm_param->param_type, QOF_TYPE_NUMERIC) == 0) ||
|
||||
(safe_strcmp(cm_param->param_type, QOF_TYPE_DEBCRED) == 0)) {
|
||||
numeric_getter = (gnc_numeric (*)(QofEntity*, QofParam*))cm_param->param_getfcn;
|
||||
numeric_getter = (gnc_numeric (*)(QofInstance*, QofParam*))cm_param->param_getfcn;
|
||||
cm_numeric = numeric_getter(importEnt, cm_param);
|
||||
numeric_setter = (void(*)(QofEntity*, gnc_numeric))cm_param->param_setfcn;
|
||||
numeric_setter = (void(*)(QofInstance*, gnc_numeric))cm_param->param_setfcn;
|
||||
if(numeric_setter != NULL) { numeric_setter(targetEnt, cm_numeric); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(cm_param->param_type, QOF_TYPE_GUID) == 0) {
|
||||
cm_guid = (const GUID*)cm_param->param_getfcn(importEnt, cm_param);
|
||||
guid_setter = (void(*)(QofEntity*, const GUID*))cm_param->param_setfcn;
|
||||
guid_setter = (void(*)(QofInstance*, const GUID*))cm_param->param_setfcn;
|
||||
if(guid_setter != NULL) { guid_setter(targetEnt, cm_guid); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(cm_param->param_type, QOF_TYPE_INT32) == 0) {
|
||||
int32_getter = (gint32 (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
|
||||
int32_getter = (gint32 (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
|
||||
cm_i32 = int32_getter(importEnt, cm_param);
|
||||
i32_setter = (void(*)(QofEntity*, gint32))cm_param->param_setfcn;
|
||||
i32_setter = (void(*)(QofInstance*, gint32))cm_param->param_setfcn;
|
||||
if(i32_setter != NULL) { i32_setter(targetEnt, cm_i32); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(cm_param->param_type, QOF_TYPE_INT64) == 0) {
|
||||
int64_getter = (gint64 (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
|
||||
int64_getter = (gint64 (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
|
||||
cm_i64 = int64_getter(importEnt, cm_param);
|
||||
i64_setter = (void(*)(QofEntity*, gint64))cm_param->param_setfcn;
|
||||
i64_setter = (void(*)(QofInstance*, gint64))cm_param->param_setfcn;
|
||||
if(i64_setter != NULL) { i64_setter(targetEnt, cm_i64); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(cm_param->param_type, QOF_TYPE_DOUBLE) == 0) {
|
||||
double_getter = (double (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
|
||||
double_getter = (double (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
|
||||
cm_double = double_getter(importEnt, cm_param);
|
||||
double_setter = (void(*)(QofEntity*, double))cm_param->param_setfcn;
|
||||
double_setter = (void(*)(QofInstance*, double))cm_param->param_setfcn;
|
||||
if(double_setter != NULL) { double_setter(targetEnt, cm_double); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(cm_param->param_type, QOF_TYPE_BOOLEAN) == 0){
|
||||
boolean_getter = (gboolean (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
|
||||
boolean_getter = (gboolean (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
|
||||
cm_boolean = boolean_getter(importEnt, cm_param);
|
||||
boolean_setter = (void(*)(QofEntity*, gboolean))cm_param->param_setfcn;
|
||||
boolean_setter = (void(*)(QofInstance*, gboolean))cm_param->param_setfcn;
|
||||
if(boolean_setter != NULL) { boolean_setter(targetEnt, cm_boolean); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(cm_param->param_type, QOF_TYPE_KVP) == 0) {
|
||||
cm_kvp = (KvpFrame*)cm_param->param_getfcn(importEnt,cm_param);
|
||||
kvp_frame_setter = (void(*)(QofEntity*, KvpFrame*))cm_param->param_setfcn;
|
||||
kvp_frame_setter = (void(*)(QofInstance*, KvpFrame*))cm_param->param_setfcn;
|
||||
if(kvp_frame_setter != NULL) { kvp_frame_setter(targetEnt, cm_kvp); }
|
||||
else
|
||||
{
|
||||
@ -500,7 +500,7 @@ qof_entity_foreach_copy(gpointer data, gpointer user_data)
|
||||
}
|
||||
if(safe_strcmp(cm_param->param_type, QOF_TYPE_CHAR) == 0) {
|
||||
cm_char = (gchar*)cm_param->param_getfcn(importEnt,cm_param);
|
||||
char_setter = (void(*)(QofEntity*, char*))cm_param->param_setfcn;
|
||||
char_setter = (void(*)(QofInstance*, char*))cm_param->param_setfcn;
|
||||
if(char_setter != NULL) { char_setter(targetEnt, cm_char); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
@ -514,10 +514,10 @@ qof_entity_foreach_copy(gpointer data, gpointer user_data)
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(registered_type == FALSE) {
|
||||
/* referenceEnt = (QofEntity*)cm_param->param_getfcn(importEnt, cm_param);
|
||||
/* referenceEnt = QOF_INSTANCE(cm_param->param_getfcn(importEnt, cm_param));
|
||||
if(!referenceEnt) { return; }
|
||||
if(!referenceEnt->e_type) { return; }*/
|
||||
reference = qof_entity_get_reference_from(importEnt, cm_param);
|
||||
reference = qof_instance_get_reference_from(importEnt, cm_param);
|
||||
if(reference) {
|
||||
qof_session_update_reference_list(context->new_session, reference);
|
||||
}
|
||||
@ -525,9 +525,9 @@ qof_entity_foreach_copy(gpointer data, gpointer user_data)
|
||||
}
|
||||
|
||||
static gboolean
|
||||
qof_entity_guid_match(QofSession *new_session, QofEntity *original)
|
||||
qof_instance_guid_match(QofSession *new_session, QofInstance *original)
|
||||
{
|
||||
QofEntity *copy;
|
||||
QofInstance *copy;
|
||||
const GUID *g;
|
||||
QofIdTypeConst type;
|
||||
QofBook *targetBook;
|
||||
@ -537,7 +537,7 @@ qof_entity_guid_match(QofSession *new_session, QofEntity *original)
|
||||
g_return_val_if_fail(original != NULL, FALSE);
|
||||
targetBook = qof_session_get_book(new_session);
|
||||
g_return_val_if_fail(targetBook != NULL, FALSE);
|
||||
g = qof_entity_get_guid(original);
|
||||
g = qof_instance_get_guid(original);
|
||||
type = g_strdup(original->e_type);
|
||||
coll = qof_book_get_collection(targetBook, type);
|
||||
copy = qof_collection_lookup_entity(coll, g);
|
||||
@ -546,19 +546,19 @@ qof_entity_guid_match(QofSession *new_session, QofEntity *original)
|
||||
}
|
||||
|
||||
static void
|
||||
qof_entity_list_foreach(gpointer data, gpointer user_data)
|
||||
qof_instance_list_foreach(gpointer data, gpointer user_data)
|
||||
{
|
||||
QofEntityCopyData *qecd;
|
||||
QofEntity *original;
|
||||
QofInstanceCopyData *qecd;
|
||||
QofInstance *original;
|
||||
QofInstance *inst;
|
||||
QofBook *book;
|
||||
const GUID *g;
|
||||
|
||||
g_return_if_fail(data != NULL);
|
||||
original = (QofEntity*)data;
|
||||
original = QOF_INSTANCE(data);
|
||||
g_return_if_fail(user_data != NULL);
|
||||
qecd = (QofEntityCopyData*)user_data;
|
||||
if(qof_entity_guid_match(qecd->new_session, original)) { return; }
|
||||
qecd = (QofInstanceCopyData*)user_data;
|
||||
if(qof_instance_guid_match(qecd->new_session, original)) { return; }
|
||||
qecd->from = original;
|
||||
if(!qof_object_compliance(original->e_type, FALSE))
|
||||
{
|
||||
@ -573,69 +573,69 @@ qof_entity_list_foreach(gpointer data, gpointer user_data)
|
||||
qecd->error = TRUE;
|
||||
return;
|
||||
}
|
||||
qecd->to = &inst->entity;
|
||||
g = qof_entity_get_guid(original);
|
||||
qof_entity_set_guid(qecd->to, g);
|
||||
qecd->to = inst;
|
||||
g = qof_instance_get_guid(original);
|
||||
qof_instance_set_guid(qecd->to, g);
|
||||
if(qecd->param_list != NULL) {
|
||||
g_slist_free(qecd->param_list);
|
||||
qecd->param_list = NULL;
|
||||
}
|
||||
qof_class_param_foreach(original->e_type, qof_entity_param_cb, qecd);
|
||||
qof_class_param_foreach(original->e_type, qof_instance_param_cb, qecd);
|
||||
qof_begin_edit(inst);
|
||||
g_slist_foreach(qecd->param_list, qof_entity_foreach_copy, qecd);
|
||||
g_slist_foreach(qecd->param_list, qof_instance_foreach_copy, qecd);
|
||||
qof_commit_edit(inst);
|
||||
}
|
||||
|
||||
static void
|
||||
qof_entity_coll_foreach(QofEntity *original, gpointer user_data)
|
||||
qof_instance_coll_foreach(QofInstance *original, gpointer user_data)
|
||||
{
|
||||
QofEntityCopyData *qecd;
|
||||
QofInstanceCopyData *qecd;
|
||||
const GUID *g;
|
||||
QofBook *targetBook;
|
||||
QofCollection *coll;
|
||||
QofEntity *copy;
|
||||
QofInstance *copy;
|
||||
|
||||
g_return_if_fail(user_data != NULL);
|
||||
copy = NULL;
|
||||
qecd = (QofEntityCopyData*)user_data;
|
||||
qecd = (QofInstanceCopyData*)user_data;
|
||||
targetBook = qof_session_get_book(qecd->new_session);
|
||||
g = qof_entity_get_guid(original);
|
||||
g = qof_instance_get_guid(original);
|
||||
coll = qof_book_get_collection(targetBook, original->e_type);
|
||||
copy = qof_collection_lookup_entity(coll, g);
|
||||
if(copy) { qecd->error = TRUE; }
|
||||
}
|
||||
|
||||
static void
|
||||
qof_entity_coll_copy(QofEntity *original, gpointer user_data)
|
||||
qof_instance_coll_copy(QofInstance *original, gpointer user_data)
|
||||
{
|
||||
QofEntityCopyData *qecd;
|
||||
QofInstanceCopyData *qecd;
|
||||
QofBook *book;
|
||||
QofInstance *inst;
|
||||
const GUID *g;
|
||||
|
||||
g_return_if_fail(user_data != NULL);
|
||||
qecd = (QofEntityCopyData*)user_data;
|
||||
qecd = (QofInstanceCopyData*)user_data;
|
||||
book = qof_session_get_book(qecd->new_session);
|
||||
if(!qof_object_compliance(original->e_type, TRUE)) { return; }
|
||||
inst = (QofInstance*)qof_object_new_instance(original->e_type, book);
|
||||
qecd->to = &inst->entity;
|
||||
qecd->to = inst;
|
||||
qecd->from = original;
|
||||
g = qof_entity_get_guid(original);
|
||||
qof_entity_set_guid(qecd->to, g);
|
||||
g = qof_instance_get_guid(original);
|
||||
qof_instance_set_guid(qecd->to, g);
|
||||
qof_begin_edit(inst);
|
||||
g_slist_foreach(qecd->param_list, qof_entity_foreach_copy, qecd);
|
||||
g_slist_foreach(qecd->param_list, qof_instance_foreach_copy, qecd);
|
||||
qof_commit_edit(inst);
|
||||
}
|
||||
|
||||
gboolean
|
||||
qof_entity_copy_to_session(QofSession* new_session, QofEntity* original)
|
||||
qof_instance_copy_to_session(QofSession* new_session, QofInstance* original)
|
||||
{
|
||||
QofEntityCopyData qecd;
|
||||
QofInstanceCopyData qecd;
|
||||
QofInstance *inst;
|
||||
QofBook *book;
|
||||
|
||||
if(!new_session || !original) { return FALSE; }
|
||||
if(qof_entity_guid_match(new_session, original)) { return FALSE; }
|
||||
if(qof_instance_guid_match(new_session, original)) { return FALSE; }
|
||||
if(!qof_object_compliance(original->e_type, TRUE)) { return FALSE; }
|
||||
qof_event_suspend();
|
||||
qecd.param_list = NULL;
|
||||
@ -643,31 +643,31 @@ qof_entity_copy_to_session(QofSession* new_session, QofEntity* original)
|
||||
qecd.new_session = new_session;
|
||||
qof_book_set_partial(book);
|
||||
inst = (QofInstance*)qof_object_new_instance(original->e_type, book);
|
||||
qecd.to = &inst->entity;
|
||||
qecd.to = inst;
|
||||
qecd.from = original;
|
||||
qof_entity_set_guid(qecd.to, qof_entity_get_guid(original));
|
||||
qof_instance_set_guid(qecd.to, qof_instance_get_guid(original));
|
||||
qof_begin_edit(inst);
|
||||
qof_class_param_foreach(original->e_type, qof_entity_param_cb, &qecd);
|
||||
qof_class_param_foreach(original->e_type, qof_instance_param_cb, &qecd);
|
||||
qof_commit_edit(inst);
|
||||
if(g_slist_length(qecd.param_list) == 0) { return FALSE; }
|
||||
g_slist_foreach(qecd.param_list, qof_entity_foreach_copy, &qecd);
|
||||
g_slist_foreach(qecd.param_list, qof_instance_foreach_copy, &qecd);
|
||||
g_slist_free(qecd.param_list);
|
||||
qof_event_resume();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean qof_entity_copy_list(QofSession *new_session, GList *entity_list)
|
||||
gboolean qof_instance_copy_list(QofSession *new_session, GList *entity_list)
|
||||
{
|
||||
QofEntityCopyData *qecd;
|
||||
QofInstanceCopyData *qecd;
|
||||
|
||||
if(!new_session || !entity_list) { return FALSE; }
|
||||
ENTER (" list=%d", g_list_length(entity_list));
|
||||
qecd = g_new0(QofEntityCopyData, 1);
|
||||
qecd = g_new0(QofInstanceCopyData, 1);
|
||||
qof_event_suspend();
|
||||
qecd->param_list = NULL;
|
||||
qecd->new_session = new_session;
|
||||
qof_book_set_partial(qof_session_get_book(new_session));
|
||||
g_list_foreach(entity_list, qof_entity_list_foreach, qecd);
|
||||
g_list_foreach(entity_list, qof_instance_list_foreach, qecd);
|
||||
qof_event_resume();
|
||||
if(qecd->error)
|
||||
{
|
||||
@ -679,9 +679,9 @@ gboolean qof_entity_copy_list(QofSession *new_session, GList *entity_list)
|
||||
}
|
||||
|
||||
gboolean
|
||||
qof_entity_copy_coll(QofSession *new_session, QofCollection *entity_coll)
|
||||
qof_instance_copy_coll(QofSession *new_session, QofCollection *entity_coll)
|
||||
{
|
||||
QofEntityCopyData qecd;
|
||||
QofInstanceCopyData qecd;
|
||||
|
||||
g_return_val_if_fail(new_session, FALSE);
|
||||
if(!entity_coll) { return FALSE; }
|
||||
@ -689,10 +689,10 @@ qof_entity_copy_coll(QofSession *new_session, QofCollection *entity_coll)
|
||||
qecd.param_list = NULL;
|
||||
qecd.new_session = new_session;
|
||||
qof_book_set_partial(qof_session_get_book(qecd.new_session));
|
||||
qof_collection_foreach(entity_coll, qof_entity_coll_foreach, &qecd);
|
||||
qof_collection_foreach(entity_coll, qof_instance_coll_foreach, &qecd);
|
||||
qof_class_param_foreach(qof_collection_get_type(entity_coll),
|
||||
qof_entity_param_cb, &qecd);
|
||||
qof_collection_foreach(entity_coll, qof_entity_coll_copy, &qecd);
|
||||
qof_instance_param_cb, &qecd);
|
||||
qof_collection_foreach(entity_coll, qof_instance_coll_copy, &qecd);
|
||||
if(qecd.param_list != NULL) { g_slist_free(qecd.param_list); }
|
||||
qof_event_resume();
|
||||
return TRUE;
|
||||
@ -707,25 +707,25 @@ struct recurse_s
|
||||
};
|
||||
|
||||
static void
|
||||
recurse_collection_cb (QofEntity *ent, gpointer user_data)
|
||||
recurse_collection_cb (QofInstance *ent, gpointer user_data)
|
||||
{
|
||||
struct recurse_s *store;
|
||||
|
||||
if(user_data == NULL) { return; }
|
||||
store = (struct recurse_s*)user_data;
|
||||
if(!ent || !store) { return; }
|
||||
store->success = qof_entity_copy_to_session(store->session, ent);
|
||||
store->success = qof_instance_copy_to_session(store->session, ent);
|
||||
if(store->success) {
|
||||
store->ent_list = g_list_append(store->ent_list, ent);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
recurse_ent_cb(QofEntity *ent, gpointer user_data)
|
||||
recurse_ent_cb(QofInstance *ent, gpointer user_data)
|
||||
{
|
||||
GList *ref_list, *i, *j, *ent_list, *child_list;
|
||||
QofParam *ref_param;
|
||||
QofEntity *ref_ent, *child_ent;
|
||||
QofInstance *ref_ent, *child_ent;
|
||||
QofSession *session;
|
||||
struct recurse_s *store;
|
||||
gboolean success;
|
||||
@ -756,17 +756,17 @@ recurse_ent_cb(QofEntity *ent, gpointer user_data)
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ref_ent = (QofEntity*)ref_param->param_getfcn(ent, ref_param);
|
||||
ref_ent = QOF_INSTANCE(ref_param->param_getfcn(ent, ref_param));
|
||||
if((ref_ent)&&(ref_ent->e_type))
|
||||
{
|
||||
store->success = qof_entity_copy_to_session(session, ref_ent);
|
||||
store->success = qof_instance_copy_to_session(session, ref_ent);
|
||||
if(store->success) { ent_list = g_list_append(ent_list, ref_ent); }
|
||||
}
|
||||
}
|
||||
for(i = ent_list; i != NULL; i = i->next)
|
||||
{
|
||||
if(i->data == NULL) { continue; }
|
||||
child_ent = (QofEntity*)i->data;
|
||||
child_ent = QOF_INSTANCE(i->data);
|
||||
if(child_ent == NULL) { continue; }
|
||||
ref_list = qof_class_get_referenceList(child_ent->e_type);
|
||||
for(j = ref_list; j != NULL; j = j->next)
|
||||
@ -776,7 +776,7 @@ recurse_ent_cb(QofEntity *ent, gpointer user_data)
|
||||
ref_ent = ref_param->param_getfcn(child_ent, ref_param);
|
||||
if(ref_ent != NULL)
|
||||
{
|
||||
success = qof_entity_copy_to_session(session, ref_ent);
|
||||
success = qof_instance_copy_to_session(session, ref_ent);
|
||||
if(success) { child_list = g_list_append(child_list, ref_ent); }
|
||||
}
|
||||
}
|
||||
@ -784,7 +784,7 @@ recurse_ent_cb(QofEntity *ent, gpointer user_data)
|
||||
for(i = child_list; i != NULL; i = i->next)
|
||||
{
|
||||
if(i->data == NULL) { continue; }
|
||||
ref_ent = (QofEntity*)i->data;
|
||||
ref_ent = QOF_INSTANCE(i->data);
|
||||
if(ref_ent == NULL) { continue; }
|
||||
ref_list = qof_class_get_referenceList(ref_ent->e_type);
|
||||
for(j = ref_list; j != NULL; j = j->next)
|
||||
@ -794,14 +794,14 @@ recurse_ent_cb(QofEntity *ent, gpointer user_data)
|
||||
child_ent = ref_param->param_getfcn(ref_ent, ref_param);
|
||||
if(child_ent != NULL)
|
||||
{
|
||||
qof_entity_copy_to_session(session, child_ent);
|
||||
qof_instance_copy_to_session(session, child_ent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
qof_entity_copy_coll_r(QofSession *new_session, QofCollection *coll)
|
||||
qof_instance_copy_coll_r(QofSession *new_session, QofCollection *coll)
|
||||
{
|
||||
struct recurse_s store;
|
||||
gboolean success;
|
||||
@ -812,12 +812,12 @@ qof_entity_copy_coll_r(QofSession *new_session, QofCollection *coll)
|
||||
store.success = success;
|
||||
store.ent_list = NULL;
|
||||
store.ref_list = qof_class_get_referenceList(qof_collection_get_type(coll));
|
||||
success = qof_entity_copy_coll(new_session, coll);
|
||||
success = qof_instance_copy_coll(new_session, coll);
|
||||
if(success){ qof_collection_foreach(coll, recurse_ent_cb, &store); }
|
||||
return success;
|
||||
}
|
||||
|
||||
gboolean qof_entity_copy_one_r(QofSession *new_session, QofEntity *ent)
|
||||
gboolean qof_instance_copy_one_r(QofSession *new_session, QofInstance *ent)
|
||||
{
|
||||
struct recurse_s store;
|
||||
QofCollection *coll;
|
||||
@ -828,7 +828,7 @@ gboolean qof_entity_copy_one_r(QofSession *new_session, QofEntity *ent)
|
||||
success = TRUE;
|
||||
store.success = success;
|
||||
store.ref_list = qof_class_get_referenceList(ent->e_type);
|
||||
success = qof_entity_copy_to_session(new_session, ent);
|
||||
success = qof_instance_copy_to_session(new_session, ent);
|
||||
if(success == TRUE) {
|
||||
coll = qof_book_get_collection(qof_session_get_book(new_session), ent->e_type);
|
||||
if(coll) { qof_collection_foreach(coll, recurse_ent_cb, &store); }
|
||||
|
@ -264,7 +264,7 @@ using the GnuCash XML v2 file backend will be switched to QSF.
|
||||
|
||||
Copied entities are identical to the source entity, all parameters
|
||||
defined with ::QofAccessFunc and ::QofSetterFunc in QOF are copied
|
||||
and the ::GUID of the original ::QofEntity is set in the new entity.
|
||||
and the ::GUID of the original ::QofInstance is set in the new entity.
|
||||
Sessions containing copied entities are intended for use
|
||||
as mechanisms for data export.
|
||||
|
||||
@ -280,19 +280,19 @@ see \ref BookMerge
|
||||
|
||||
*/
|
||||
|
||||
/** \brief Copy a single QofEntity to another session
|
||||
/** \brief Copy a single QofInstance to another session
|
||||
|
||||
Checks first that no entity in the session book contains
|
||||
the GUID of the source entity.
|
||||
|
||||
@param new_session - the target session
|
||||
@param original - the QofEntity* to copy
|
||||
@param original - the QofInstance* to copy
|
||||
|
||||
@return FALSE without copying if the session contains an entity
|
||||
with the same GUID already, otherwise TRUE.
|
||||
*/
|
||||
|
||||
gboolean qof_entity_copy_to_session(QofSession* new_session, QofEntity* original);
|
||||
gboolean qof_instance_copy_to_session(QofSession* new_session, QofInstance* original);
|
||||
|
||||
/** @brief Copy a GList of entities to another session
|
||||
|
||||
@ -301,18 +301,18 @@ with the same GUID as any of the source entities - there is
|
||||
no support for handling collisions, instead use \ref BookMerge
|
||||
|
||||
Note that the GList (e.g. from ::qof_sql_query_run) can contain
|
||||
QofEntity pointers of any ::QofIdType, in any sequence. As long
|
||||
as all members of the list are ::QofEntity*, and all GUID's are
|
||||
QofInstance pointers of any ::QofIdType, in any sequence. As long
|
||||
as all members of the list are ::QofInstance*, and all GUID's are
|
||||
unique, the list can be copied.
|
||||
|
||||
@param new_session - the target session
|
||||
@param entity_list - a GList of QofEntity pointers of any type(s).
|
||||
@param entity_list - a GList of QofInstance pointers of any type(s).
|
||||
|
||||
@return FALSE, without copying, if new_session contains any entities
|
||||
with the same GUID. Otherwise TRUE.
|
||||
|
||||
*/
|
||||
gboolean qof_entity_copy_list(QofSession *new_session, GList *entity_list);
|
||||
gboolean qof_instance_copy_list(QofSession *new_session, GList *entity_list);
|
||||
|
||||
/** @brief Copy a QofCollection of entities.
|
||||
|
||||
@ -327,12 +327,12 @@ no support for handling collisions - instead, use \ref BookMerge
|
||||
with the same GUID. Otherwise TRUE.
|
||||
*/
|
||||
|
||||
gboolean qof_entity_copy_coll(QofSession *new_session, QofCollection *entity_coll);
|
||||
gboolean qof_instance_copy_coll(QofSession *new_session, QofCollection *entity_coll);
|
||||
|
||||
/** \brief Recursively copy a collection of entities to a session.
|
||||
|
||||
\note This function creates a <b>partial QofBook</b>. See
|
||||
::qof_entity_copy_to_session for more information.
|
||||
::qof_instance_copy_to_session for more information.
|
||||
|
||||
The QofBook in the new_session must \b not contain any entities
|
||||
with the same GUID as any entities to be copied - there is
|
||||
@ -341,7 +341,7 @@ no support for handling collisions - instead, use \ref BookMerge
|
||||
Objects can be defined solely in terms of QOF data types or
|
||||
as a mix of data types and other objects, which may in turn
|
||||
include other objects. These references can be copied recursively
|
||||
down to the third level. See ::QofEntityReference.
|
||||
down to the third level. See ::QofInstanceReference.
|
||||
|
||||
\note This is a deep recursive copy - every referenced entity is copied
|
||||
to the new session, including all parameters. The starting point is all
|
||||
@ -358,7 +358,7 @@ one of the references fails to copy.
|
||||
|
||||
*/
|
||||
gboolean
|
||||
qof_entity_copy_coll_r(QofSession *new_session, QofCollection *coll);
|
||||
qof_instance_copy_coll_r(QofSession *new_session, QofCollection *coll);
|
||||
|
||||
/** \brief Recursively copy a single entity to a new session.
|
||||
|
||||
@ -369,7 +369,7 @@ copied.
|
||||
|
||||
This is a deep copy - all parameters of all referenced entities are copied. If
|
||||
the top level entity has no references, this is identical to
|
||||
::qof_entity_copy_to_session.
|
||||
::qof_instance_copy_to_session.
|
||||
|
||||
@param ent A single entity that may or may not have references.
|
||||
|
||||
@ -380,7 +380,7 @@ the top level entity has no references, this is identical to
|
||||
one of the references fails to copy.
|
||||
*/
|
||||
gboolean
|
||||
qof_entity_copy_one_r(QofSession *new_session, QofEntity *ent);
|
||||
qof_instance_copy_one_r(QofSession *new_session, QofInstance *ent);
|
||||
|
||||
/** @}
|
||||
*/
|
||||
|
@ -52,7 +52,7 @@ struct _QofSqlQuery
|
||||
char * single_global_tablename;
|
||||
KvpFrame *kvp_join;
|
||||
GList *param_list;
|
||||
QofEntity *inserted_entity;
|
||||
QofInstance *inserted_entity;
|
||||
};
|
||||
|
||||
/* ========================================================== */
|
||||
@ -573,7 +573,7 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
|
||||
QofIdTypeConst type;
|
||||
sql_insert_statement *sis;
|
||||
gboolean registered_type;
|
||||
QofEntity *ent;
|
||||
QofInstance *ent;
|
||||
struct tm query_time;
|
||||
time_t query_time_t;
|
||||
/* cm_ prefix used for variables that hold the data to commit */
|
||||
@ -588,15 +588,15 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
|
||||
/* KvpFrame *cm_kvp;
|
||||
KvpValue *cm_value;
|
||||
KvpValueType cm_type;*/
|
||||
void (*string_setter) (QofEntity*, const char*);
|
||||
void (*date_setter) (QofEntity*, Timespec);
|
||||
void (*numeric_setter) (QofEntity*, gnc_numeric);
|
||||
void (*double_setter) (QofEntity*, double);
|
||||
void (*boolean_setter) (QofEntity*, gboolean);
|
||||
void (*i32_setter) (QofEntity*, gint32);
|
||||
void (*i64_setter) (QofEntity*, gint64);
|
||||
void (*char_setter) (QofEntity*, char);
|
||||
/* void (*kvp_frame_setter) (QofEntity*, KvpFrame*);*/
|
||||
void (*string_setter) (QofInstance*, const char*);
|
||||
void (*date_setter) (QofInstance*, Timespec);
|
||||
void (*numeric_setter) (QofInstance*, gnc_numeric);
|
||||
void (*double_setter) (QofInstance*, double);
|
||||
void (*boolean_setter) (QofInstance*, gboolean);
|
||||
void (*i32_setter) (QofInstance*, gint32);
|
||||
void (*i64_setter) (QofInstance*, gint64);
|
||||
void (*char_setter) (QofInstance*, char);
|
||||
/* void (*kvp_frame_setter) (QofInstance*, KvpFrame*);*/
|
||||
|
||||
g_return_if_fail(param || insert_string || query);
|
||||
ent = query->inserted_entity;
|
||||
@ -606,12 +606,12 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
|
||||
ENTER (" param=%s param_type=%s type=%s content=%s",
|
||||
param->param_name, param->param_type, type, insert_string);
|
||||
if(safe_strcmp(param->param_type, QOF_TYPE_STRING) == 0) {
|
||||
string_setter = (void(*)(QofEntity*, const char*))param->param_setfcn;
|
||||
string_setter = (void(*)(QofInstance*, const char*))param->param_setfcn;
|
||||
if(string_setter != NULL) { string_setter(ent, insert_string); }
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(param->param_type, QOF_TYPE_DATE) == 0) {
|
||||
date_setter = (void(*)(QofEntity*, Timespec))param->param_setfcn;
|
||||
date_setter = (void(*)(QofInstance*, Timespec))param->param_setfcn;
|
||||
strptime(insert_string, QOF_UTC_DATE_FORMAT, &query_time);
|
||||
query_time_t = mktime(&query_time);
|
||||
timespecFromTime_t(&cm_date, query_time_t);
|
||||
@ -619,7 +619,7 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
|
||||
}
|
||||
if((safe_strcmp(param->param_type, QOF_TYPE_NUMERIC) == 0) ||
|
||||
(safe_strcmp(param->param_type, QOF_TYPE_DEBCRED) == 0)) {
|
||||
numeric_setter = (void(*)(QofEntity*, gnc_numeric))param->param_setfcn;
|
||||
numeric_setter = (void(*)(QofInstance*, gnc_numeric))param->param_setfcn;
|
||||
string_to_gnc_numeric(insert_string, &cm_numeric);
|
||||
if(numeric_setter != NULL) { numeric_setter(ent, cm_numeric); }
|
||||
}
|
||||
@ -633,10 +633,10 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
|
||||
/* reference_type = xmlGetProp(node, QSF_OBJECT_TYPE);
|
||||
if(0 == safe_strcmp(QOF_PARAM_GUID, reference_type))
|
||||
{
|
||||
qof_entity_set_guid(qsf_ent, cm_guid);
|
||||
qof_instance_set_guid(qsf_ent, cm_guid);
|
||||
}
|
||||
else {
|
||||
reference = qof_entity_get_reference_from(qsf_ent, cm_param);
|
||||
reference = qof_instance_get_reference_from(qsf_ent, cm_param);
|
||||
if(reference) {
|
||||
params->referenceList = g_list_append(params->referenceList, reference);
|
||||
}
|
||||
@ -646,7 +646,7 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
|
||||
errno = 0;
|
||||
cm_i32 = (gint32)strtol (insert_string, &tail, 0);
|
||||
if(errno == 0) {
|
||||
i32_setter = (void(*)(QofEntity*, gint32))param->param_setfcn;
|
||||
i32_setter = (void(*)(QofInstance*, gint32))param->param_setfcn;
|
||||
if(i32_setter != NULL) { i32_setter(ent, cm_i32); }
|
||||
}
|
||||
else
|
||||
@ -663,7 +663,7 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
|
||||
errno = 0;
|
||||
cm_i64 = strtoll(insert_string, &tail, 0);
|
||||
if(errno == 0) {
|
||||
i64_setter = (void(*)(QofEntity*, gint64))param->param_setfcn;
|
||||
i64_setter = (void(*)(QofInstance*, gint64))param->param_setfcn;
|
||||
if(i64_setter != NULL) { i64_setter(ent, cm_i64); }
|
||||
}
|
||||
else
|
||||
@ -680,7 +680,7 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
|
||||
errno = 0;
|
||||
cm_double = strtod(insert_string, &tail);
|
||||
if(errno == 0) {
|
||||
double_setter = (void(*)(QofEntity*, double))param->param_setfcn;
|
||||
double_setter = (void(*)(QofInstance*, double))param->param_setfcn;
|
||||
if(double_setter != NULL) { double_setter(ent, cm_double); }
|
||||
}
|
||||
}
|
||||
@ -691,7 +691,7 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
|
||||
cm_boolean = TRUE;
|
||||
}
|
||||
else { cm_boolean = FALSE; }
|
||||
boolean_setter = (void(*)(QofEntity*, gboolean))param->param_setfcn;
|
||||
boolean_setter = (void(*)(QofInstance*, gboolean))param->param_setfcn;
|
||||
if(boolean_setter != NULL) { boolean_setter(ent, cm_boolean); }
|
||||
}
|
||||
if(safe_strcmp(param->param_type, QOF_TYPE_KVP) == 0) {
|
||||
@ -699,7 +699,7 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
|
||||
}
|
||||
if(safe_strcmp(param->param_type, QOF_TYPE_CHAR) == 0) {
|
||||
cm_char = *insert_string;
|
||||
char_setter = (void(*)(QofEntity*, char))param->param_setfcn;
|
||||
char_setter = (void(*)(QofInstance*, char))param->param_setfcn;
|
||||
if(char_setter != NULL) { char_setter(ent, cm_char); }
|
||||
}
|
||||
LEAVE (" ");
|
||||
@ -725,7 +725,7 @@ qof_query_set_insert_table(QofSqlQuery *query)
|
||||
}
|
||||
}
|
||||
|
||||
static QofEntity*
|
||||
static QofInstance*
|
||||
qof_query_insert(QofSqlQuery *query)
|
||||
{
|
||||
GList *field_list, *value_list, *cur;
|
||||
@ -755,7 +755,7 @@ qof_query_insert(QofSqlQuery *query)
|
||||
LEAVE (" unable to create instance of type %s", type);
|
||||
return NULL;
|
||||
}
|
||||
query->inserted_entity = &inst->entity;
|
||||
query->inserted_entity = inst;
|
||||
value_list = sis->values;
|
||||
for (field_list = sis->fields; field_list != NULL; field_list = field_list->next)
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ search loop, aka a 'join', which is not currently supported in the
|
||||
underlying QofQuery code.
|
||||
|
||||
However, by repeating queries and adding the entities to a new session using
|
||||
::qof_entity_copy_list, a series of queries can be added to a single
|
||||
::qof_instance_copy_list, a series of queries can be added to a single
|
||||
book. e.g. You can insert multiple entities and save out as a QSF XML
|
||||
file or use multiple SELECT queries to build a precise list - this
|
||||
can be used to replicate most of the functionality of a SQL join.
|
||||
@ -77,7 +77,7 @@ When combined with a foreach callback on the value of param_id for each
|
||||
entity in the QofBook, you can produce the effect of a join from running
|
||||
the two SELECT queries for each value of param_id held in 'value'.
|
||||
|
||||
See ::QofEntityForeachCB and ::qof_object_foreach.
|
||||
See ::QofInstanceForeachCB and ::qof_object_foreach.
|
||||
|
||||
Date queries handle full date and time strings, using the format
|
||||
exported by the QSF backend. To query dates and times, convert
|
||||
|
@ -306,7 +306,7 @@ qof_commit_edit_part2(QofInstance *inst,
|
||||
}
|
||||
if (dirty && qof_get_alt_dirty_mode() &&
|
||||
!(inst->infant && inst->do_free)) {
|
||||
qof_collection_mark_dirty(inst->entity.collection);
|
||||
qof_collection_mark_dirty(inst->collection);
|
||||
qof_book_mark_dirty(inst->book);
|
||||
}
|
||||
inst->infant = FALSE;
|
||||
@ -397,7 +397,7 @@ qof_util_string_cache_insert(gconstpointer key)
|
||||
}
|
||||
|
||||
gchar*
|
||||
qof_util_param_as_string(QofEntity *ent, QofParam *param)
|
||||
qof_util_param_as_string(QofInstance *ent, QofParam *param)
|
||||
{
|
||||
gchar *param_string, param_date[MAX_DATE_LENGTH];
|
||||
gchar param_sa[GUID_ENCODING_LENGTH + 1];
|
||||
@ -405,13 +405,13 @@ qof_util_param_as_string(QofEntity *ent, QofParam *param)
|
||||
QofType paramType;
|
||||
const GUID *param_guid;
|
||||
time_t param_t;
|
||||
gnc_numeric param_numeric, (*numeric_getter) (QofEntity*, QofParam*);
|
||||
Timespec param_ts, (*date_getter) (QofEntity*, QofParam*);
|
||||
double param_double, (*double_getter) (QofEntity*, QofParam*);
|
||||
gboolean param_boolean, (*boolean_getter) (QofEntity*, QofParam*);
|
||||
gint32 param_i32, (*int32_getter) (QofEntity*, QofParam*);
|
||||
gint64 param_i64, (*int64_getter) (QofEntity*, QofParam*);
|
||||
gchar param_char, (*char_getter) (QofEntity*, QofParam*);
|
||||
gnc_numeric param_numeric, (*numeric_getter) (QofInstance*, QofParam*);
|
||||
Timespec param_ts, (*date_getter) (QofInstance*, QofParam*);
|
||||
double param_double, (*double_getter) (QofInstance*, QofParam*);
|
||||
gboolean param_boolean, (*boolean_getter) (QofInstance*, QofParam*);
|
||||
gint32 param_i32, (*int32_getter) (QofInstance*, QofParam*);
|
||||
gint64 param_i64, (*int64_getter) (QofInstance*, QofParam*);
|
||||
gchar param_char, (*char_getter) (QofInstance*, QofParam*);
|
||||
|
||||
param_string = NULL;
|
||||
known_type = FALSE;
|
||||
@ -423,7 +423,7 @@ qof_util_param_as_string(QofEntity *ent, QofParam *param)
|
||||
return param_string;
|
||||
}
|
||||
if(safe_strcmp(paramType, QOF_TYPE_DATE) == 0) {
|
||||
date_getter = (Timespec (*)(QofEntity*, QofParam*))param->param_getfcn;
|
||||
date_getter = (Timespec (*)(QofInstance*, QofParam*))param->param_getfcn;
|
||||
param_ts = date_getter(ent, param);
|
||||
param_t = timespecToTime_t(param_ts);
|
||||
qof_strftime(param_date, MAX_DATE_LENGTH,
|
||||
@ -434,7 +434,7 @@ qof_util_param_as_string(QofEntity *ent, QofParam *param)
|
||||
}
|
||||
if((safe_strcmp(paramType, QOF_TYPE_NUMERIC) == 0) ||
|
||||
(safe_strcmp(paramType, QOF_TYPE_DEBCRED) == 0)) {
|
||||
numeric_getter = (gnc_numeric (*)(QofEntity*, QofParam*)) param->param_getfcn;
|
||||
numeric_getter = (gnc_numeric (*)(QofInstance*, QofParam*)) param->param_getfcn;
|
||||
param_numeric = numeric_getter(ent, param);
|
||||
param_string = g_strdup(gnc_numeric_to_string(param_numeric));
|
||||
known_type = TRUE;
|
||||
@ -448,28 +448,28 @@ qof_util_param_as_string(QofEntity *ent, QofParam *param)
|
||||
return param_string;
|
||||
}
|
||||
if(safe_strcmp(paramType, QOF_TYPE_INT32) == 0) {
|
||||
int32_getter = (gint32 (*)(QofEntity*, QofParam*)) param->param_getfcn;
|
||||
int32_getter = (gint32 (*)(QofInstance*, QofParam*)) param->param_getfcn;
|
||||
param_i32 = int32_getter(ent, param);
|
||||
param_string = g_strdup_printf("%d", param_i32);
|
||||
known_type = TRUE;
|
||||
return param_string;
|
||||
}
|
||||
if(safe_strcmp(paramType, QOF_TYPE_INT64) == 0) {
|
||||
int64_getter = (gint64 (*)(QofEntity*, QofParam*)) param->param_getfcn;
|
||||
int64_getter = (gint64 (*)(QofInstance*, QofParam*)) param->param_getfcn;
|
||||
param_i64 = int64_getter(ent, param);
|
||||
param_string = g_strdup_printf("%"G_GINT64_FORMAT, param_i64);
|
||||
known_type = TRUE;
|
||||
return param_string;
|
||||
}
|
||||
if(safe_strcmp(paramType, QOF_TYPE_DOUBLE) == 0) {
|
||||
double_getter = (double (*)(QofEntity*, QofParam*)) param->param_getfcn;
|
||||
double_getter = (double (*)(QofInstance*, QofParam*)) param->param_getfcn;
|
||||
param_double = double_getter(ent, param);
|
||||
param_string = g_strdup_printf("%f", param_double);
|
||||
known_type = TRUE;
|
||||
return param_string;
|
||||
}
|
||||
if(safe_strcmp(paramType, QOF_TYPE_BOOLEAN) == 0){
|
||||
boolean_getter = (gboolean (*)(QofEntity*, QofParam*)) param->param_getfcn;
|
||||
boolean_getter = (gboolean (*)(QofInstance*, QofParam*)) param->param_getfcn;
|
||||
param_boolean = boolean_getter(ent, param);
|
||||
/* Boolean values need to be lowercase for QSF validation. */
|
||||
if(param_boolean == TRUE) { param_string = g_strdup("true"); }
|
||||
@ -491,7 +491,7 @@ qof_util_param_as_string(QofEntity *ent, QofParam *param)
|
||||
return param_string;
|
||||
}
|
||||
if(safe_strcmp(paramType, QOF_TYPE_CHAR) == 0) {
|
||||
char_getter = (gchar (*)(QofEntity*, QofParam*)) param->param_getfcn;
|
||||
char_getter = (gchar (*)(QofInstance*, QofParam*)) param->param_getfcn;
|
||||
param_char = char_getter(ent, param);
|
||||
known_type = TRUE;
|
||||
return g_strdup_printf("%c", param_char);
|
||||
@ -507,7 +507,7 @@ qof_util_param_as_string(QofEntity *ent, QofParam *param)
|
||||
}
|
||||
if(safe_strcmp(paramType, QOF_TYPE_CHOICE) == 0)
|
||||
{
|
||||
QofEntity *child = NULL;
|
||||
QofInstance *child = NULL;
|
||||
child = param->param_getfcn(ent, param);
|
||||
if(!child) { return param_string; }
|
||||
known_type = TRUE;
|
||||
@ -534,7 +534,7 @@ qof_util_param_as_string(QofEntity *ent, QofParam *param)
|
||||
}
|
||||
if(!known_type)
|
||||
{
|
||||
QofEntity *child = NULL;
|
||||
QofInstance *child = NULL;
|
||||
child = param->param_getfcn(ent, param);
|
||||
if(!child) { return param_string; }
|
||||
return g_strdup(qof_object_printable(child->e_type, child));
|
||||
@ -545,7 +545,8 @@ qof_util_param_as_string(QofEntity *ent, QofParam *param)
|
||||
void
|
||||
qof_init (void)
|
||||
{
|
||||
qof_log_init();
|
||||
g_type_init();
|
||||
qof_log_init();
|
||||
qof_util_get_string_cache ();
|
||||
guid_init ();
|
||||
qof_object_initialize ();
|
||||
|
@ -235,7 +235,7 @@ gint qof_util_bool_to_int (const gchar * val);
|
||||
|
||||
The returned string must be freed by the caller.
|
||||
*/
|
||||
gchar* qof_util_param_as_string(QofEntity *ent, QofParam *param);
|
||||
gchar* qof_util_param_as_string(QofInstance *ent, QofParam *param);
|
||||
|
||||
/** The QOF String Cache:
|
||||
*
|
||||
|
@ -253,12 +253,12 @@ add_event_type (ComponentEventInfo *cei, GNCIdTypeConst entity_type,
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_cm_event_handler (QofEntity *entity,
|
||||
gnc_cm_event_handler (QofInstance *entity,
|
||||
QofEventId event_type,
|
||||
gpointer user_data,
|
||||
gpointer event_data)
|
||||
{
|
||||
const GUID *guid = qof_entity_get_guid(entity);
|
||||
const GUID *guid = qof_instance_get_guid(entity);
|
||||
#if CM_DEBUG
|
||||
fprintf (stderr, "event_handler: event %d, entity %p, guid %s\n", event_type,
|
||||
entity, guid);
|
||||
|
@ -56,7 +56,7 @@ static gint _get_vars_helper(Transaction *txn, void *var_hash_data);
|
||||
|
||||
static GncSxVariable* gnc_sx_variable_new(gchar *name);
|
||||
|
||||
static void _gnc_sx_instance_event_handler(QofEntity *ent, QofEventId event_type, gpointer user_data, gpointer evt_data);
|
||||
static void _gnc_sx_instance_event_handler(QofInstance *ent, QofEventId event_type, gpointer user_data, gpointer evt_data);
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
@ -613,7 +613,7 @@ _gnc_sx_instance_find_by_sx(GncSxInstances *in_list_instances, SchedXaction *sx_
|
||||
}
|
||||
|
||||
static void
|
||||
_gnc_sx_instance_event_handler(QofEntity *ent, QofEventId event_type, gpointer user_data, gpointer evt_data)
|
||||
_gnc_sx_instance_event_handler(QofInstance *ent, QofEventId event_type, gpointer user_data, gpointer evt_data)
|
||||
{
|
||||
GncSxInstanceModel *instances = GNC_SX_INSTANCE_MODEL(user_data);
|
||||
|
||||
|
@ -364,7 +364,7 @@ write_out (QofMap *qm, QofInstance *inst)
|
||||
{
|
||||
if (!inst) return;
|
||||
|
||||
GUID *guid = &QOF_ENTITY(inst)->guid;
|
||||
GUID *guid = &QOF_INSTANCE(inst)->guid;
|
||||
|
||||
dui_connection_lock(qm->db_conn, qm->table_name);
|
||||
/* Use a temp book when loading from the database */
|
||||
@ -376,8 +376,8 @@ write_out (QofMap *qm, QofInstance *inst)
|
||||
|
||||
/* See if we got something back from the DB */
|
||||
QofCollection *col;
|
||||
col = qof_book_get_collection (qm->tmp_book, QOF_ENTITY(inst)->e_type);
|
||||
QofEntity * db_ent = qof_collection_lookup_entity (col, guid);
|
||||
col = qof_book_get_collection (qm->tmp_book, QOF_INSTANCE(inst)->e_type);
|
||||
QofInstance * db_ent = qof_collection_lookup_entity (col, guid);
|
||||
QofInstance *db_inst = QOF_INSTANCE(db_ent);
|
||||
|
||||
/* If its not already in the database, then insert it in */
|
||||
|
@ -821,7 +821,7 @@ file_begin_edit (QofBackend *be, QofInstance *inst)
|
||||
QofBook *book = gp;
|
||||
const char * filepath;
|
||||
|
||||
QofIdTypeConst typ = QOF_ENTITY(inst)->e_type;
|
||||
QofIdTypeConst typ = QOF_INSTANCE(inst)->e_type;
|
||||
if (strcmp (GNC_ID_PERIOD, typ)) return;
|
||||
filepath = build_period_filepath(fbe, book);
|
||||
PINFO (" ====================== book=%p filepath=%s\n", book, filepath);
|
||||
|
@ -196,7 +196,7 @@ book_id_handler(xmlNodePtr node, gpointer book_pdata)
|
||||
GUID *guid;
|
||||
|
||||
guid = dom_tree_to_guid(node);
|
||||
qof_entity_set_guid(QOF_ENTITY(book), guid);
|
||||
qof_instance_set_guid(QOF_INSTANCE(book), guid);
|
||||
g_free(guid);
|
||||
|
||||
return TRUE;
|
||||
|
@ -111,7 +111,7 @@ budget_id_handler (xmlNodePtr node, gpointer bgt)
|
||||
|
||||
guid = dom_tree_to_guid(node);
|
||||
g_return_val_if_fail(guid, FALSE);
|
||||
qof_entity_set_guid(QOF_ENTITY(bgt), guid);
|
||||
qof_instance_set_guid(QOF_INSTANCE(bgt), guid);
|
||||
g_free(guid);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ price_parse_xml_sub_node(GNCPrice *p, xmlNodePtr sub_node, QofBook *book)
|
||||
} else if(safe_strcmp("price:type", (char*)sub_node->name) == 0) {
|
||||
char *text = dom_tree_to_text(sub_node);
|
||||
if(!text) return FALSE;
|
||||
gnc_price_set_type(p, text);
|
||||
gnc_price_set_typestr(p, text);
|
||||
g_free(text);
|
||||
} else if(safe_strcmp("price:value", (char*)sub_node->name) == 0) {
|
||||
gnc_numeric *value = dom_tree_to_gnc_numeric(sub_node);
|
||||
@ -406,7 +406,7 @@ gnc_price_to_dom_tree(const xmlChar *tag, GNCPrice *price)
|
||||
if(!add_child_or_kill_parent(price_xml, tmpnode)) return NULL;
|
||||
}
|
||||
|
||||
typestr = gnc_price_get_type(price);
|
||||
typestr = gnc_price_get_typestr(price);
|
||||
if(typestr && (strlen(typestr) != 0)) {
|
||||
tmpnode = text_to_dom_tree("price:type", typestr);
|
||||
if(!add_child_or_kill_parent(price_xml, tmpnode)) return NULL;
|
||||
|
@ -3585,7 +3585,7 @@ price_parse_xml_sub_node(GNCPrice *p, xmlNodePtr sub_node, QofBook *book)
|
||||
} else if(safe_strcmp("price:type", (char*)sub_node->name) == 0) {
|
||||
char *text = dom_tree_to_text(sub_node);
|
||||
if(!text) return FALSE;
|
||||
gnc_price_set_type(p, text);
|
||||
gnc_price_set_typestr(p, text);
|
||||
g_free(text);
|
||||
} else if(safe_strcmp("price:value", (char*)sub_node->name) == 0) {
|
||||
gnc_numeric *value = dom_tree_to_gnc_numeric(sub_node);
|
||||
|
@ -860,7 +860,7 @@ static void write_pricedb (FILE *out, QofBook *book, sixtp_gdv2 *gd);
|
||||
static void write_transactions (FILE *out, QofBook *book, sixtp_gdv2 *gd);
|
||||
static void write_template_transaction_data (FILE *out, QofBook *book, sixtp_gdv2 *gd);
|
||||
static void write_schedXactions(FILE *out, QofBook *book, sixtp_gdv2 *gd);
|
||||
static void write_budget (QofEntity *ent, gpointer data);
|
||||
static void write_budget (QofInstance *ent, gpointer data);
|
||||
|
||||
static void
|
||||
write_counts_cb (const char *type, gpointer data_p, gpointer be_data_p)
|
||||
@ -1098,7 +1098,7 @@ write_schedXactions( FILE *out, QofBook *book, sixtp_gdv2 *gd)
|
||||
}
|
||||
|
||||
static void
|
||||
write_budget (QofEntity *ent, gpointer data)
|
||||
write_budget (QofInstance *ent, gpointer data)
|
||||
{
|
||||
xmlNodePtr node;
|
||||
struct file_backend* be = data;
|
||||
|
@ -184,7 +184,7 @@ pgendSplitLookup (PGBackend *be, const GUID *split_guid)
|
||||
|
||||
struct _iter {
|
||||
const GUID *guid;
|
||||
QofEntity *ent;
|
||||
QofInstance *ent;
|
||||
};
|
||||
|
||||
static void
|
||||
@ -1627,7 +1627,7 @@ static void
|
||||
pgend_do_begin (QofBackend *bend, QofInstance *inst)
|
||||
{
|
||||
PGBackend *be = (PGBackend*)bend;
|
||||
QofIdTypeConst type = inst->entity.e_type;
|
||||
QofIdTypeConst type = inst->e_type;
|
||||
|
||||
ENTER ("be=%p, type=%s", bend, type);
|
||||
// if (!safe_strcmp (type, GNC_ID_PERIOD))
|
||||
@ -1653,7 +1653,7 @@ static void
|
||||
pgend_do_commit (QofBackend *bend, QofInstance *inst)
|
||||
{
|
||||
PGBackend *be = (PGBackend*)bend;
|
||||
QofIdTypeConst type = inst->entity.e_type;
|
||||
QofIdTypeConst type = inst->e_type;
|
||||
|
||||
ENTER ("be=%p, type=%s", bend, type);
|
||||
// if (!safe_strcmp (type, GNC_ID_PERIOD))
|
||||
@ -1689,7 +1689,7 @@ static void
|
||||
pgend_do_rollback (QofBackend *bend, QofInstance *inst)
|
||||
{
|
||||
PGBackend *be = (PGBackend*)bend;
|
||||
QofIdTypeConst type = inst->entity.e_type;
|
||||
QofIdTypeConst type = inst->e_type;
|
||||
|
||||
ENTER ("be=%p, type=%s", bend, type);
|
||||
switch (be->session_mode) {
|
||||
|
@ -139,7 +139,7 @@ get_one_book_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
guid = nullguid; /* just in case the read fails ... */
|
||||
string_to_guid (DB_GET_VAL("bookGuid",j), &guid);
|
||||
|
||||
qof_entity_set_guid ((QofEntity*)book, &guid);
|
||||
qof_instance_set_guid (QOF_INSTANCE(book), &guid);
|
||||
|
||||
if((DB_GET_VAL("book_open",j))[0] == 'n')
|
||||
{
|
||||
@ -208,14 +208,14 @@ get_book_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
for (node=blist; node; node=node->next)
|
||||
{
|
||||
book = node->data;
|
||||
if (guid_equal (qof_entity_get_guid((QofEntity*)book), &guid)) break;
|
||||
if (guid_equal (qof_instance_get_guid(QOF_INSTANCE(book)), &guid)) break;
|
||||
book = NULL;
|
||||
}
|
||||
|
||||
if (!book)
|
||||
{
|
||||
book = qof_book_new();
|
||||
qof_entity_set_guid ((QofEntity*)book, &guid);
|
||||
qof_instance_set_guid (QOF_INSTANCE(book), &guid);
|
||||
}
|
||||
|
||||
if((DB_GET_VAL("book_open",j))[0] == 'n')
|
||||
|
@ -259,7 +259,7 @@ pgendProcessEvents (QofBackend *bend)
|
||||
{
|
||||
Event *ev = (Event *) node->data;
|
||||
QofIdType local_obj_type;
|
||||
QofEntity *ent;
|
||||
QofInstance *ent;
|
||||
|
||||
ent = NULL;
|
||||
/* lets see if the local cache has this item in it */
|
||||
@ -290,14 +290,14 @@ pgendProcessEvents (QofBackend *bend)
|
||||
|
||||
/* if the remote user created an account, mirror it here */
|
||||
acc = pgendCopyAccountToEngine (be, &(ev->guid));
|
||||
ent = (QofEntity*)acc;
|
||||
ent = QOF_INSTANCE(acc);
|
||||
break;
|
||||
}
|
||||
case QOF_EVENT_DESTROY: {
|
||||
Account * acc = pgendAccountLookup (be, &(ev->guid));
|
||||
xaccAccountBeginEdit (acc);
|
||||
xaccAccountDestroy (acc);
|
||||
ent = (QofEntity*)acc;
|
||||
ent = QOF_INSTANCE(acc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -319,7 +319,7 @@ pgendProcessEvents (QofBackend *bend)
|
||||
/* don't mirror transaction creations. If a register needs
|
||||
* it, it will do a query. */
|
||||
trans = pgendTransLookup (be, &(ev->guid));
|
||||
ent = (QofEntity*)trans;
|
||||
ent = QOF_INSTANCE(trans);
|
||||
PINFO ("create transaction");
|
||||
break;
|
||||
}
|
||||
@ -327,7 +327,7 @@ pgendProcessEvents (QofBackend *bend)
|
||||
Transaction *trans;
|
||||
trans = pgendTransLookup (be, &(ev->guid));
|
||||
pgendCopyTransactionToEngine (be, &(ev->guid));
|
||||
ent = (QofEntity*)trans;
|
||||
ent = QOF_INSTANCE(trans);
|
||||
break;
|
||||
}
|
||||
case QOF_EVENT_DESTROY: {
|
||||
@ -336,7 +336,7 @@ pgendProcessEvents (QofBackend *bend)
|
||||
/* mark trans for freeing */
|
||||
xaccTransDestroy (trans);
|
||||
xaccTransCommitEdit (trans);
|
||||
ent = (QofEntity*)trans;
|
||||
ent = QOF_INSTANCE(trans);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ get_price_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
gnc_price_set_time (pr, ts);
|
||||
|
||||
gnc_price_set_source (pr, DB_GET_VAL("source",j));
|
||||
gnc_price_set_type (pr, DB_GET_VAL("type",j));
|
||||
gnc_price_set_typestr (pr, DB_GET_VAL("type",j));
|
||||
|
||||
num = strtoll (DB_GET_VAL("valueNum", j), NULL, 0);
|
||||
denom = strtoll (DB_GET_VAL("valueDenom", j), NULL, 0);
|
||||
|
@ -358,7 +358,7 @@ int finishQuery(PGBackend *be);
|
||||
for (node=be->blist; node; node=node->next) \
|
||||
{ \
|
||||
book = node->data; \
|
||||
if (guid_equal (qof_entity_get_guid((QofEntity*)book), &book_guid)) break; \
|
||||
if (guid_equal (qof_instance_get_guid((QofInstance*)book), &book_guid)) break; \
|
||||
book = NULL; \
|
||||
} \
|
||||
if (!book) return data; \
|
||||
|
@ -13,7 +13,7 @@ define(`account', `gncAccount, Account, Account, a,
|
||||
commodity, , char *, gnc_commodity_get_unique_name(xaccAccountGetCommodity(ptr)),
|
||||
version, , int32, xaccAccountGetVersion(ptr),
|
||||
iguid, , int32, ptr->idata,
|
||||
bookGUID, , GUID *, qof_entity_get_guid((QofEntity*)gnc_account_get_book(ptr)),
|
||||
bookGUID, , GUID *, qof_instance_get_guid((QofInstance*)gnc_account_get_book(ptr)),
|
||||
parentGUID, , GUID *, xaccAccountGetGUID(gnc_account_get_parent(ptr)),
|
||||
accountGUID, KEY, GUID *, xaccAccountGetGUID(ptr),
|
||||
')
|
||||
@ -73,7 +73,7 @@ define(`price', `gncPrice, Price, GNCPrice, p,
|
||||
currency, , commod, gnc_commodity_get_unique_name(gnc_price_get_currency(ptr)),
|
||||
time, , Timespec, gnc_price_get_time(ptr),
|
||||
source, , char *, gnc_price_get_source(ptr),
|
||||
type, , char *, gnc_price_get_type(ptr),
|
||||
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),
|
||||
@ -362,7 +362,7 @@ define(`compare_version',
|
||||
|
||||
p = be->buff; *p = 0;
|
||||
p = stpcpy (p, "SELECT version FROM tablename($@) WHERE key_fieldname($@) = ''`");
|
||||
p = guid_to_string_buff (qof_entity_get_guid(QOF_ENTITY(ptr)), p);
|
||||
p = guid_to_string_buff (qof_instance_get_guid(QOF_INSTANCE(ptr)), p);
|
||||
p = stpcpy (p, "''`;");
|
||||
SEND_QUERY (be,be->buff, -1);
|
||||
sql_version = GPOINTER_TO_INT(pgendGetResults (be, get_version_cb, (gpointer) -1));
|
||||
@ -392,7 +392,7 @@ define(`is_deleted',
|
||||
|
||||
p = be->buff; *p = 0;
|
||||
p = stpcpy (p, "SELECT version FROM tablename($@)" "Trail WHERE key_fieldname($@) = ''`");
|
||||
p = guid_to_string_buff (qof_entity_get_guid(QOF_ENTITY(ptr)), p);
|
||||
p = guid_to_string_buff (qof_instance_get_guid(QOF_INSTANCE(ptr)), p);
|
||||
p = stpcpy (p, "''` AND change = ''`d''`;");
|
||||
SEND_QUERY (be,be->buff, -1);
|
||||
sql_version = GPOINTER_TO_INT(pgendGetResults (be, get_version_cb, (gpointer) -1));
|
||||
|
@ -171,7 +171,7 @@ pgendStoreTransactionNoLock (PGBackend *be, Transaction *trans,
|
||||
{
|
||||
Split *s = split_node->data;
|
||||
|
||||
if (s && guid_equal (&s->inst.entity.guid, &dti->guid))
|
||||
if (s && guid_equal (&s->inst.guid, &dti->guid))
|
||||
{
|
||||
pgendStoreAuditSplit (be, s, SQL_DELETE);
|
||||
break;
|
||||
|
@ -482,7 +482,7 @@ billterm_sixtp_parser_create(void)
|
||||
}
|
||||
|
||||
static void
|
||||
do_count (QofEntity *term_p, gpointer count_p)
|
||||
do_count (QofInstance *term_p, gpointer count_p)
|
||||
{
|
||||
int *count = count_p;
|
||||
(*count)++;
|
||||
@ -497,7 +497,7 @@ billterm_get_count (QofBook *book)
|
||||
}
|
||||
|
||||
static void
|
||||
xml_add_billterm (QofEntity *term_p, gpointer out_p)
|
||||
xml_add_billterm (QofInstance *term_p, gpointer out_p)
|
||||
{
|
||||
xmlNodePtr node;
|
||||
GncBillTerm *term = (GncBillTerm *) term_p;
|
||||
@ -556,7 +556,7 @@ billterm_find_senior (GncBillTerm *term)
|
||||
|
||||
/* build a list of bill terms that are grandchildren or bogus (empty entry list). */
|
||||
static void
|
||||
billterm_scrub_cb (QofEntity *term_p, gpointer list_p)
|
||||
billterm_scrub_cb (QofInstance *term_p, gpointer list_p)
|
||||
{
|
||||
GncBillTerm *term = GNC_BILLTERM(term_p);
|
||||
GList **list = list_p;
|
||||
@ -590,7 +590,7 @@ billterm_scrub_cb (QofEntity *term_p, gpointer list_p)
|
||||
* grandchildren, then fix them to point to the most senior child
|
||||
*/
|
||||
static void
|
||||
billterm_scrub_invoices (QofEntity * invoice_p, gpointer ht_p)
|
||||
billterm_scrub_invoices (QofInstance * invoice_p, gpointer ht_p)
|
||||
{
|
||||
GHashTable *ht = ht_p;
|
||||
GncInvoice *invoice = GNC_INVOICE(invoice_p);
|
||||
@ -617,7 +617,7 @@ billterm_scrub_invoices (QofEntity * invoice_p, gpointer ht_p)
|
||||
}
|
||||
|
||||
static void
|
||||
billterm_scrub_cust (QofEntity * cust_p, gpointer ht_p)
|
||||
billterm_scrub_cust (QofInstance * cust_p, gpointer ht_p)
|
||||
{
|
||||
GHashTable *ht = ht_p;
|
||||
GncCustomer *cust = GNC_CUSTOMER(cust_p);
|
||||
@ -637,7 +637,7 @@ billterm_scrub_cust (QofEntity * cust_p, gpointer ht_p)
|
||||
}
|
||||
|
||||
static void
|
||||
billterm_scrub_vendor (QofEntity * vendor_p, gpointer ht_p)
|
||||
billterm_scrub_vendor (QofInstance * vendor_p, gpointer ht_p)
|
||||
{
|
||||
GHashTable *ht = ht_p;
|
||||
GncVendor *vendor = GNC_VENDOR(vendor_p);
|
||||
|
@ -470,7 +470,7 @@ customer_should_be_saved (GncCustomer *customer)
|
||||
}
|
||||
|
||||
static void
|
||||
do_count (QofEntity * cust_p, gpointer count_p)
|
||||
do_count (QofInstance * cust_p, gpointer count_p)
|
||||
{
|
||||
int *count = count_p;
|
||||
if (customer_should_be_saved ((GncCustomer *)cust_p))
|
||||
@ -486,7 +486,7 @@ customer_get_count (QofBook *book)
|
||||
}
|
||||
|
||||
static void
|
||||
xml_add_customer (QofEntity * cust_p, gpointer out_p)
|
||||
xml_add_customer (QofInstance * cust_p, gpointer out_p)
|
||||
{
|
||||
xmlNodePtr node;
|
||||
GncCustomer *cust = (GncCustomer *) cust_p;
|
||||
|
@ -389,7 +389,7 @@ employee_should_be_saved (GncEmployee *employee)
|
||||
}
|
||||
|
||||
static void
|
||||
do_count (QofEntity * employee_p, gpointer count_p)
|
||||
do_count (QofInstance * employee_p, gpointer count_p)
|
||||
{
|
||||
int *count = count_p;
|
||||
if (employee_should_be_saved ((GncEmployee *) employee_p))
|
||||
@ -405,7 +405,7 @@ employee_get_count (QofBook *book)
|
||||
}
|
||||
|
||||
static void
|
||||
xml_add_employee (QofEntity * employee_p, gpointer out_p)
|
||||
xml_add_employee (QofInstance * employee_p, gpointer out_p)
|
||||
{
|
||||
xmlNodePtr node;
|
||||
GncEmployee *employee = (GncEmployee *) employee_p;
|
||||
|
@ -781,7 +781,7 @@ entry_sixtp_parser_create(void)
|
||||
}
|
||||
|
||||
static void
|
||||
do_count (QofEntity * entry_p, gpointer count_p)
|
||||
do_count (QofInstance * entry_p, gpointer count_p)
|
||||
{
|
||||
int *count = count_p;
|
||||
(*count)++;
|
||||
@ -796,7 +796,7 @@ entry_get_count (QofBook *book)
|
||||
}
|
||||
|
||||
static void
|
||||
xml_add_entry (QofEntity * entry_p, gpointer out_p)
|
||||
xml_add_entry (QofInstance * entry_p, gpointer out_p)
|
||||
{
|
||||
xmlNodePtr node;
|
||||
GncEntry *entry = (GncEntry *) entry_p;
|
||||
|
@ -501,7 +501,7 @@ invoice_should_be_saved (GncInvoice *invoice)
|
||||
}
|
||||
|
||||
static void
|
||||
do_count (QofEntity * invoice_p, gpointer count_p)
|
||||
do_count (QofInstance * invoice_p, gpointer count_p)
|
||||
{
|
||||
int *count = count_p;
|
||||
if (invoice_should_be_saved ((GncInvoice *)invoice_p))
|
||||
@ -517,7 +517,7 @@ invoice_get_count (QofBook *book)
|
||||
}
|
||||
|
||||
static void
|
||||
xml_add_invoice (QofEntity * invoice_p, gpointer out_p)
|
||||
xml_add_invoice (QofInstance * invoice_p, gpointer out_p)
|
||||
{
|
||||
xmlNodePtr node;
|
||||
GncInvoice *invoice = (GncInvoice *) invoice_p;
|
||||
|
@ -288,7 +288,7 @@ job_should_be_saved (GncJob *job)
|
||||
}
|
||||
|
||||
static void
|
||||
do_count (QofEntity * job_p, gpointer count_p)
|
||||
do_count (QofInstance * job_p, gpointer count_p)
|
||||
{
|
||||
int *count = count_p;
|
||||
if (job_should_be_saved ((GncJob *)job_p))
|
||||
@ -304,7 +304,7 @@ job_get_count (QofBook *book)
|
||||
}
|
||||
|
||||
static void
|
||||
xml_add_job (QofEntity * job_p, gpointer out_p)
|
||||
xml_add_job (QofInstance * job_p, gpointer out_p)
|
||||
{
|
||||
xmlNodePtr node;
|
||||
GncJob *job = (GncJob *) job_p;
|
||||
|
@ -331,7 +331,7 @@ order_should_be_saved (GncOrder *order)
|
||||
}
|
||||
|
||||
static void
|
||||
do_count (QofEntity * order_p, gpointer count_p)
|
||||
do_count (QofInstance * order_p, gpointer count_p)
|
||||
{
|
||||
int *count = count_p;
|
||||
if (order_should_be_saved ((GncOrder *) order_p))
|
||||
@ -347,7 +347,7 @@ order_get_count (QofBook *book)
|
||||
}
|
||||
|
||||
static void
|
||||
xml_add_order (QofEntity * order_p, gpointer out_p)
|
||||
xml_add_order (QofInstance * order_p, gpointer out_p)
|
||||
{
|
||||
xmlNodePtr node;
|
||||
GncOrder *order = (GncOrder *) order_p;
|
||||
|
@ -445,7 +445,7 @@ taxtable_sixtp_parser_create(void)
|
||||
}
|
||||
|
||||
static void
|
||||
do_count (QofEntity * table_p, gpointer count_p)
|
||||
do_count (QofInstance * table_p, gpointer count_p)
|
||||
{
|
||||
int *count = count_p;
|
||||
(*count)++;
|
||||
@ -460,7 +460,7 @@ taxtable_get_count (QofBook *book)
|
||||
}
|
||||
|
||||
static void
|
||||
xml_add_taxtable (QofEntity * table_p, gpointer out_p)
|
||||
xml_add_taxtable (QofInstance * table_p, gpointer out_p)
|
||||
{
|
||||
xmlNodePtr node;
|
||||
GncTaxTable *table = (GncTaxTable *) table_p;
|
||||
@ -520,7 +520,7 @@ taxtable_find_senior (GncTaxTable *table)
|
||||
|
||||
/* build a list of tax tables that are grandchildren or bogus (empty entry list). */
|
||||
static void
|
||||
taxtable_scrub_cb (QofEntity * table_p, gpointer list_p)
|
||||
taxtable_scrub_cb (QofInstance * table_p, gpointer list_p)
|
||||
{
|
||||
GncTaxTable *table = GNC_TAXTABLE(table_p);
|
||||
GList **list = list_p;
|
||||
@ -533,7 +533,7 @@ taxtable_scrub_cb (QofEntity * table_p, gpointer list_p)
|
||||
* grandchildren, then fix them to point to the most senior child
|
||||
*/
|
||||
static void
|
||||
taxtable_scrub_entries (QofEntity * entry_p, gpointer ht_p)
|
||||
taxtable_scrub_entries (QofInstance * entry_p, gpointer ht_p)
|
||||
{
|
||||
GHashTable *ht = ht_p;
|
||||
GncEntry *entry = GNC_ENTRY(entry_p);
|
||||
@ -578,7 +578,7 @@ taxtable_scrub_entries (QofEntity * entry_p, gpointer ht_p)
|
||||
}
|
||||
|
||||
static void
|
||||
taxtable_scrub_cust (QofEntity * cust_p, gpointer ht_p)
|
||||
taxtable_scrub_cust (QofInstance * cust_p, gpointer ht_p)
|
||||
{
|
||||
GHashTable *ht = ht_p;
|
||||
GncCustomer *cust = GNC_CUSTOMER(cust_p);
|
||||
@ -594,7 +594,7 @@ taxtable_scrub_cust (QofEntity * cust_p, gpointer ht_p)
|
||||
}
|
||||
|
||||
static void
|
||||
taxtable_scrub_vendor (QofEntity * vendor_p, gpointer ht_p)
|
||||
taxtable_scrub_vendor (QofInstance * vendor_p, gpointer ht_p)
|
||||
{
|
||||
GHashTable *ht = ht_p;
|
||||
GncVendor *vendor = GNC_VENDOR(vendor_p);
|
||||
|
@ -407,7 +407,7 @@ vendor_should_be_saved (GncVendor *vendor)
|
||||
}
|
||||
|
||||
static void
|
||||
do_count (QofEntity * vendor_p, gpointer count_p)
|
||||
do_count (QofInstance * vendor_p, gpointer count_p)
|
||||
{
|
||||
int *count = count_p;
|
||||
if (vendor_should_be_saved ((GncVendor *)vendor_p))
|
||||
@ -423,7 +423,7 @@ vendor_get_count (QofBook *book)
|
||||
}
|
||||
|
||||
static void
|
||||
xml_add_vendor (QofEntity * vendor_p, gpointer out_p)
|
||||
xml_add_vendor (QofInstance * vendor_p, gpointer out_p)
|
||||
{
|
||||
xmlNodePtr node;
|
||||
GncVendor *vendor = (GncVendor *) vendor_p;
|
||||
|
@ -38,7 +38,7 @@ struct _gncAddress
|
||||
QofInstance inst;
|
||||
|
||||
QofBook * book;
|
||||
QofEntity * parent;
|
||||
QofInstance * parent;
|
||||
gboolean dirty;
|
||||
char * name;
|
||||
char * addr1;
|
||||
@ -50,6 +50,11 @@ struct _gncAddress
|
||||
char * email;
|
||||
};
|
||||
|
||||
struct _gncAddressClass
|
||||
{
|
||||
QofInstanceClass parent_class;
|
||||
};
|
||||
|
||||
static QofLogModule log_module = GNC_MOD_BUSINESS;
|
||||
|
||||
#define _GNC_MOD_NAME GNC_ADDRESS_MODULE_NAME
|
||||
@ -62,17 +67,35 @@ void mark_address (GncAddress *address)
|
||||
qof_event_gen (address->parent, QOF_EVENT_MODIFY, NULL);
|
||||
}
|
||||
|
||||
/* GObject Initialization */
|
||||
QOF_GOBJECT_IMPL(gnc_address, GncAddress, QOF_TYPE_INSTANCE);
|
||||
|
||||
static void
|
||||
gnc_address_init(GncAddress* addr)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_address_dispose_real (GObject *addrp)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_address_finalize_real(GObject* addrp)
|
||||
{
|
||||
}
|
||||
|
||||
/* Create/Destroy functions */
|
||||
|
||||
GncAddress *
|
||||
gncAddressCreate (QofBook *book, QofEntity *prnt)
|
||||
gncAddressCreate (QofBook *book, QofInstance *prnt)
|
||||
{
|
||||
GncAddress *addr;
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
addr = g_new0 (GncAddress, 1);
|
||||
qof_instance_init(&addr->inst, GNC_ID_ADDRESS, book);
|
||||
addr = g_object_new (GNC_TYPE_ADDRESS, NULL);
|
||||
qof_instance_init_data(&addr->inst, GNC_ID_ADDRESS, book);
|
||||
addr->book = book;
|
||||
addr->dirty = FALSE;
|
||||
addr->parent = prnt;
|
||||
@ -97,13 +120,13 @@ qofAddressCreate (QofBook *book)
|
||||
}
|
||||
|
||||
static void
|
||||
qofAddressSetOwner(GncAddress *addr, QofEntity *ent)
|
||||
qofAddressSetOwner(GncAddress *addr, QofInstance *ent)
|
||||
{
|
||||
if(!addr || !ent) { return; }
|
||||
if(addr->parent == NULL) { addr->parent = ent; }
|
||||
}
|
||||
|
||||
static QofEntity*
|
||||
static QofInstance*
|
||||
qofAddressGetOwner(GncAddress *addr)
|
||||
{
|
||||
|
||||
@ -112,13 +135,14 @@ qofAddressGetOwner(GncAddress *addr)
|
||||
}
|
||||
|
||||
GncAddress *
|
||||
gncCloneAddress (GncAddress *from, QofEntity *new_parent, QofBook *book)
|
||||
gncCloneAddress (GncAddress *from, QofInstance *new_parent, QofBook *book)
|
||||
{
|
||||
GncAddress *addr;
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
addr = g_new0 (GncAddress, 1);
|
||||
addr = g_object_new (GNC_TYPE_ADDRESS, NULL);
|
||||
qof_instance_init_data(&addr->inst, GNC_ID_ADDRESS, book);
|
||||
addr->book = book;
|
||||
addr->dirty = TRUE;
|
||||
addr->parent = new_parent;
|
||||
@ -148,7 +172,7 @@ gncAddressFree (GncAddress *addr)
|
||||
{
|
||||
if (!addr) return;
|
||||
|
||||
qof_event_gen (&addr->inst.entity, QOF_EVENT_DESTROY, NULL);
|
||||
qof_event_gen (&addr->inst, QOF_EVENT_DESTROY, NULL);
|
||||
|
||||
CACHE_REMOVE (addr->name);
|
||||
CACHE_REMOVE (addr->addr1);
|
||||
@ -159,8 +183,8 @@ gncAddressFree (GncAddress *addr)
|
||||
CACHE_REMOVE (addr->fax);
|
||||
CACHE_REMOVE (addr->email);
|
||||
|
||||
qof_instance_release (&addr->inst);
|
||||
g_free (addr);
|
||||
/* qof_instance_release (&addr->inst); */
|
||||
g_object_unref (addr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,7 +65,7 @@ up to you to pass a suitable entity.
|
||||
|
||||
@param QofInstance The address instance.
|
||||
@param QofBook* Copy of the book pointer.
|
||||
@param QofEntity* parent entity.
|
||||
@param QofInstance* parent entity.
|
||||
@param gboolean dirty flag
|
||||
@param char* name of addressee
|
||||
@param char* first line of address
|
||||
@ -77,10 +77,25 @@ up to you to pass a suitable entity.
|
||||
@param char* email address
|
||||
*/
|
||||
typedef struct _gncAddress GncAddress;
|
||||
typedef struct _gncAddressClass GncAddressClass;
|
||||
|
||||
/* --- type macros --- */
|
||||
#define GNC_TYPE_ADDRESS (gnc_address_get_type ())
|
||||
#define GNC_ADDRESS(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_ADDRESS, GncAddress))
|
||||
#define GNC_ADDRESS_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_ADDRESS, GncAddressClass))
|
||||
#define GNC_IS_ADDRESS(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_ADDRESS))
|
||||
#define GNC_IS_ADDRESS_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_ADDRESS))
|
||||
#define GNC_ADDRESS_GET_CLASS(o) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_ADDRESS, GncAddressClass))
|
||||
GType gnc_address_get_type(void);
|
||||
|
||||
/** @name Create/Destroy functions
|
||||
@{ */
|
||||
GncAddress *gncAddressCreate (QofBook *book, QofEntity *parent);
|
||||
GncAddress *gncAddressCreate (QofBook *book, QofInstance *parent);
|
||||
void gncAddressDestroy (GncAddress *addr);
|
||||
void gncAddressBeginEdit (GncAddress *addr);
|
||||
void gncAddressCommitEdit (GncAddress *addr);
|
||||
|
@ -33,7 +33,7 @@
|
||||
gboolean gncAddressRegister (void);
|
||||
|
||||
/** Make a copy of the address, setting the parent to 'new_parent' */
|
||||
GncAddress * gncCloneAddress (GncAddress *from, QofEntity *new_parent, QofBook *book);
|
||||
GncAddress * gncCloneAddress (GncAddress *from, QofInstance *new_parent, QofBook *book);
|
||||
|
||||
|
||||
#endif /* GNC_ADDRESSP_H_ */
|
||||
|
@ -56,6 +56,11 @@ struct _gncBillTerm
|
||||
GList * children; /* list of children for disconnection */
|
||||
};
|
||||
|
||||
struct _gncBillTermClass
|
||||
{
|
||||
QofInstanceClass parent_class;
|
||||
};
|
||||
|
||||
struct _book_info
|
||||
{
|
||||
GList * terms; /* visible terms */
|
||||
@ -85,7 +90,7 @@ static inline void
|
||||
mark_term (GncBillTerm *term)
|
||||
{
|
||||
qof_instance_set_dirty(&term->inst);
|
||||
qof_event_gen (&term->inst.entity, QOF_EVENT_MODIFY, NULL);
|
||||
qof_event_gen (&term->inst, QOF_EVENT_MODIFY, NULL);
|
||||
}
|
||||
|
||||
static inline void maybe_resort_list (GncBillTerm *term)
|
||||
@ -128,19 +133,37 @@ gncBillTermRemoveChild (GncBillTerm *table, GncBillTerm *child)
|
||||
|
||||
/* ============================================================== */
|
||||
|
||||
/* GObject Initialization */
|
||||
QOF_GOBJECT_IMPL(gnc_billterm, GncBillTerm, QOF_TYPE_INSTANCE);
|
||||
|
||||
static void
|
||||
gnc_billterm_init(GncBillTerm* bt)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_billterm_dispose_real (GObject *btp)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_billterm_finalize_real(GObject* btp)
|
||||
{
|
||||
}
|
||||
|
||||
/* Create/Destroy Functions */
|
||||
GncBillTerm * gncBillTermCreate (QofBook *book)
|
||||
{
|
||||
GncBillTerm *term;
|
||||
if (!book) return NULL;
|
||||
|
||||
term = g_new0 (GncBillTerm, 1);
|
||||
qof_instance_init(&term->inst, _GNC_MOD_NAME, book);
|
||||
term = g_object_new (GNC_TYPE_BILLTERM, NULL);
|
||||
qof_instance_init_data(&term->inst, _GNC_MOD_NAME, book);
|
||||
term->name = CACHE_INSERT ("");
|
||||
term->desc = CACHE_INSERT ("");
|
||||
term->discount = gnc_numeric_zero ();
|
||||
addObj (term);
|
||||
qof_event_gen (&term->inst.entity, QOF_EVENT_CREATE, NULL);
|
||||
qof_event_gen (&term->inst, QOF_EVENT_CREATE, NULL);
|
||||
return term;
|
||||
}
|
||||
|
||||
@ -161,7 +184,7 @@ static void gncBillTermFree (GncBillTerm *term)
|
||||
|
||||
if (!term) return;
|
||||
|
||||
qof_event_gen (&term->inst.entity, QOF_EVENT_DESTROY, NULL);
|
||||
qof_event_gen (&term->inst, QOF_EVENT_DESTROY, NULL);
|
||||
CACHE_REMOVE (term->name);
|
||||
CACHE_REMOVE (term->desc);
|
||||
remObj (term);
|
||||
@ -180,8 +203,8 @@ static void gncBillTermFree (GncBillTerm *term)
|
||||
}
|
||||
g_list_free(term->children);
|
||||
|
||||
qof_instance_release(&term->inst);
|
||||
g_free (term);
|
||||
/* qof_instance_release(&term->inst); */
|
||||
g_object_unref (term);
|
||||
}
|
||||
|
||||
GncBillTerm *
|
||||
@ -192,8 +215,8 @@ gncCloneBillTerm (GncBillTerm *from, QofBook *book)
|
||||
|
||||
if (!book || !from) return NULL;
|
||||
|
||||
term = g_new0 (GncBillTerm, 1);
|
||||
qof_instance_init(&term->inst, _GNC_MOD_NAME, book);
|
||||
term = g_object_new (GNC_TYPE_BILLTERM, NULL);
|
||||
qof_instance_init_data(&term->inst, _GNC_MOD_NAME, book);
|
||||
qof_instance_gemini (&term->inst, &from->inst);
|
||||
|
||||
term->name = CACHE_INSERT (from->name);
|
||||
@ -228,7 +251,7 @@ gncCloneBillTerm (GncBillTerm *from, QofBook *book)
|
||||
}
|
||||
|
||||
addObj (term);
|
||||
qof_event_gen (&term->inst.entity, QOF_EVENT_CREATE, NULL);
|
||||
qof_event_gen (&term->inst, QOF_EVENT_CREATE, NULL);
|
||||
return term;
|
||||
}
|
||||
|
||||
|
@ -32,14 +32,27 @@
|
||||
#define GNC_BILLTERM_H_
|
||||
|
||||
typedef struct _gncBillTerm GncBillTerm;
|
||||
typedef struct _gncBillTermClass GncBillTermClass;
|
||||
|
||||
#include "qof.h"
|
||||
#ifdef GNUCASH_MAJOR_VERSION
|
||||
#include "gncBusiness.h"
|
||||
#endif
|
||||
#define GNC_ID_BILLTERM "gncBillTerm"
|
||||
#define GNC_IS_BILLTERM(obj) (QOF_CHECK_TYPE((obj), GNC_ID_BILLTERM))
|
||||
#define GNC_BILLTERM(obj) (QOF_CHECK_CAST((obj), GNC_ID_BILLTERM, GncBillTerm))
|
||||
|
||||
/* --- type macros --- */
|
||||
#define GNC_TYPE_BILLTERM (gnc_billterm_get_type ())
|
||||
#define GNC_BILLTERM(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_BILLTERM, GncBillTerm))
|
||||
#define GNC_BILLTERM_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_BILLTERM, GncBillTermClass))
|
||||
#define GNC_IS_BILLTERM(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_BILLTERM))
|
||||
#define GNC_IS_BILLTERM_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_BILLTERM))
|
||||
#define GNC_BILLTERM_GET_CLASS(o) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_BILLTERM, GncBillTermClass))
|
||||
GType gnc_billterm_get_type(void);
|
||||
|
||||
/** @name BillTerm parameter names
|
||||
@{ */
|
||||
|
@ -64,7 +64,7 @@ GncBillTerm * gncCloneBillTerm (GncBillTerm *from, QofBook *);
|
||||
*/
|
||||
GncBillTerm * gncBillTermObtainTwin (GncBillTerm *from, QofBook *book);
|
||||
|
||||
#define gncBillTermSetGUID(E,G) qof_entity_set_guid(QOF_ENTITY(E),(G))
|
||||
#define gncBillTermSetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
|
||||
|
||||
|
||||
#endif /* GNC_BILLTERMP_H_ */
|
||||
|
@ -68,6 +68,11 @@ struct _gncCustomer
|
||||
GncAddress * shipaddr;
|
||||
};
|
||||
|
||||
struct _gncCustomerClass
|
||||
{
|
||||
QofInstanceClass parent_class;
|
||||
};
|
||||
|
||||
static QofLogModule log_module = GNC_MOD_BUSINESS;
|
||||
|
||||
#define _GNC_MOD_NAME GNC_ID_CUSTOMER
|
||||
@ -79,34 +84,52 @@ G_INLINE_FUNC void mark_customer (GncCustomer *customer);
|
||||
void mark_customer (GncCustomer *customer)
|
||||
{
|
||||
qof_instance_set_dirty(&customer->inst);
|
||||
qof_event_gen (&customer->inst.entity, QOF_EVENT_MODIFY, NULL);
|
||||
qof_event_gen (&customer->inst, QOF_EVENT_MODIFY, NULL);
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
/* Create/Destroy Functions */
|
||||
|
||||
/* GObject Initialization */
|
||||
QOF_GOBJECT_IMPL(gnc_customer, GncCustomer, QOF_TYPE_INSTANCE);
|
||||
|
||||
static void
|
||||
gnc_customer_init(GncCustomer* cust)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_customer_dispose_real (GObject *custp)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_customer_finalize_real(GObject* custp)
|
||||
{
|
||||
}
|
||||
|
||||
/* Create/Destroy Functions */
|
||||
GncCustomer *gncCustomerCreate (QofBook *book)
|
||||
{
|
||||
GncCustomer *cust;
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
cust = g_new0 (GncCustomer, 1);
|
||||
qof_instance_init (&cust->inst, _GNC_MOD_NAME, book);
|
||||
cust = g_object_new (GNC_TYPE_CUSTOMER, NULL);
|
||||
qof_instance_init_data (&cust->inst, _GNC_MOD_NAME, book);
|
||||
|
||||
cust->id = CACHE_INSERT ("");
|
||||
cust->name = CACHE_INSERT ("");
|
||||
cust->notes = CACHE_INSERT ("");
|
||||
cust->addr = gncAddressCreate (book, &cust->inst.entity);
|
||||
cust->addr = gncAddressCreate (book, &cust->inst);
|
||||
cust->taxincluded = GNC_TAXINCLUDED_USEGLOBAL;
|
||||
cust->active = TRUE;
|
||||
cust->jobs = NULL;
|
||||
|
||||
cust->discount = gnc_numeric_zero();
|
||||
cust->credit = gnc_numeric_zero();
|
||||
cust->shipaddr = gncAddressCreate (book, &cust->inst.entity);
|
||||
cust->shipaddr = gncAddressCreate (book, &cust->inst);
|
||||
|
||||
qof_event_gen (&cust->inst.entity, QOF_EVENT_CREATE, NULL);
|
||||
qof_event_gen (&cust->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
return cust;
|
||||
}
|
||||
@ -118,9 +141,9 @@ gncCloneCustomer (GncCustomer *from, QofBook *book)
|
||||
GList *node;
|
||||
GncCustomer *cust;
|
||||
|
||||
cust = g_new0 (GncCustomer, 1);
|
||||
cust = g_object_new (GNC_TYPE_CUSTOMER, NULL);
|
||||
|
||||
qof_instance_init (&cust->inst, _GNC_MOD_NAME, book);
|
||||
qof_instance_init_data (&cust->inst, _GNC_MOD_NAME, book);
|
||||
qof_instance_gemini (&cust->inst, &from->inst);
|
||||
|
||||
cust->id = CACHE_INSERT (from->id);
|
||||
@ -132,8 +155,8 @@ gncCloneCustomer (GncCustomer *from, QofBook *book)
|
||||
cust->active = from->active;
|
||||
cust->taxtable_override = from->taxtable_override;
|
||||
|
||||
cust->addr = gncCloneAddress (from->addr, &cust->inst.entity, book);
|
||||
cust->shipaddr = gncCloneAddress (from->shipaddr, &cust->inst.entity, book);
|
||||
cust->addr = gncCloneAddress (from->addr, &cust->inst, book);
|
||||
cust->shipaddr = gncCloneAddress (from->shipaddr, &cust->inst, book);
|
||||
|
||||
/* Find the matching currency in the new book, assumes
|
||||
* currency has already been copied into new book. */
|
||||
@ -150,7 +173,7 @@ gncCloneCustomer (GncCustomer *from, QofBook *book)
|
||||
cust->jobs = g_list_prepend(cust->jobs, job);
|
||||
}
|
||||
|
||||
qof_event_gen (&cust->inst.entity, QOF_EVENT_CREATE, NULL);
|
||||
qof_event_gen (&cust->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
return cust;
|
||||
}
|
||||
@ -167,7 +190,7 @@ static void gncCustomerFree (GncCustomer *cust)
|
||||
{
|
||||
if (!cust) return;
|
||||
|
||||
qof_event_gen (&cust->inst.entity, QOF_EVENT_DESTROY, NULL);
|
||||
qof_event_gen (&cust->inst, QOF_EVENT_DESTROY, NULL);
|
||||
|
||||
CACHE_REMOVE (cust->id);
|
||||
CACHE_REMOVE (cust->name);
|
||||
@ -182,8 +205,8 @@ static void gncCustomerFree (GncCustomer *cust)
|
||||
gncTaxTableDecRef (cust->taxtable);
|
||||
}
|
||||
|
||||
qof_instance_release (&cust->inst);
|
||||
g_free (cust);
|
||||
/* qof_instance_release (&cust->inst); */
|
||||
g_object_unref (cust);
|
||||
}
|
||||
|
||||
GncCustomer *
|
||||
@ -340,7 +363,7 @@ void gncCustomerAddJob (GncCustomer *cust, GncJob *job)
|
||||
cust->jobs = g_list_insert_sorted (cust->jobs, job,
|
||||
(GCompareFunc)gncJobCompare);
|
||||
|
||||
qof_event_gen (&cust->inst.entity, QOF_EVENT_MODIFY, NULL);
|
||||
qof_event_gen (&cust->inst, QOF_EVENT_MODIFY, NULL);
|
||||
}
|
||||
|
||||
void gncCustomerRemoveJob (GncCustomer *cust, GncJob *job)
|
||||
@ -357,7 +380,7 @@ void gncCustomerRemoveJob (GncCustomer *cust, GncJob *job)
|
||||
cust->jobs = g_list_remove_link (cust->jobs, node);
|
||||
g_list_free_1 (node);
|
||||
}
|
||||
qof_event_gen (&cust->inst.entity, QOF_EVENT_MODIFY, NULL);
|
||||
qof_event_gen (&cust->inst, QOF_EVENT_MODIFY, NULL);
|
||||
}
|
||||
|
||||
void gncCustomerBeginEdit (GncCustomer *cust)
|
||||
@ -412,7 +435,7 @@ GncAddress * gncCustomerGetAddr (GncCustomer *cust)
|
||||
}
|
||||
|
||||
static void
|
||||
qofCustomerSetAddr (GncCustomer *cust, QofEntity *addr_ent)
|
||||
qofCustomerSetAddr (GncCustomer *cust, QofInstance *addr_ent)
|
||||
{
|
||||
GncAddress *addr;
|
||||
|
||||
@ -426,7 +449,7 @@ qofCustomerSetAddr (GncCustomer *cust, QofEntity *addr_ent)
|
||||
}
|
||||
|
||||
static void
|
||||
qofCustomerSetShipAddr (GncCustomer *cust, QofEntity *ship_addr_ent)
|
||||
qofCustomerSetShipAddr (GncCustomer *cust, QofInstance *ship_addr_ent)
|
||||
{
|
||||
GncAddress *ship_addr;
|
||||
|
||||
|
@ -55,6 +55,7 @@ taxincluded, active and jobs are identical to ::GncVendor.
|
||||
|
||||
*/
|
||||
typedef struct _gncCustomer GncCustomer;
|
||||
typedef struct _gncCustomerClass GncCustomerClass;
|
||||
|
||||
#include "gncAddress.h"
|
||||
#include "gncBillTerm.h"
|
||||
@ -62,8 +63,20 @@ typedef struct _gncCustomer GncCustomer;
|
||||
#include "gncJob.h"
|
||||
|
||||
#define GNC_ID_CUSTOMER "gncCustomer"
|
||||
#define GNC_IS_CUSTOMER(obj) (QOF_CHECK_TYPE((obj), GNC_ID_CUSTOMER))
|
||||
#define GNC_CUSTOMER(obj) (QOF_CHECK_CAST((obj), GNC_ID_CUSTOMER, GncCustomer))
|
||||
|
||||
/* --- type macros --- */
|
||||
#define GNC_TYPE_CUSTOMER (gnc_customer_get_type ())
|
||||
#define GNC_CUSTOMER(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_CUSTOMER, GncCustomer))
|
||||
#define GNC_CUSTOMER_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_CUSTOMER, GncCustomerClass))
|
||||
#define GNC_IS_CUSTOMER(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_CUSTOMER))
|
||||
#define GNC_IS_CUSTOMER_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_CUSTOMER))
|
||||
#define GNC_CUSTOMER_GET_CLASS(o) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_CUSTOMER, GncCustomerClass))
|
||||
GType gnc_customer_get_type(void);
|
||||
|
||||
/** @name Create/Destroy Functions
|
||||
@{ */
|
||||
|
@ -53,6 +53,6 @@ GncCustomer * gncCloneCustomer (GncCustomer *from, QofBook *book);
|
||||
*/
|
||||
GncCustomer * gncCustomerObtainTwin (GncCustomer *from, QofBook *book);
|
||||
|
||||
#define gncCustomerSetGUID(E,G) qof_entity_set_guid(QOF_ENTITY(E),(G))
|
||||
#define gncCustomerSetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
|
||||
|
||||
#endif /* GNC_CUSTOMERP_H_ */
|
||||
|
@ -54,6 +54,11 @@ struct _gncEmployee
|
||||
Account * ccard_acc;
|
||||
};
|
||||
|
||||
struct _gncEmployeeClass
|
||||
{
|
||||
QofInstanceClass parent_class;
|
||||
};
|
||||
|
||||
static QofLogModule log_module = GNC_MOD_BUSINESS;
|
||||
|
||||
#define _GNC_MOD_NAME GNC_ID_EMPLOYEE
|
||||
@ -62,31 +67,48 @@ G_INLINE_FUNC void mark_employee (GncEmployee *employee);
|
||||
void mark_employee (GncEmployee *employee)
|
||||
{
|
||||
qof_instance_set_dirty(&employee->inst);
|
||||
qof_event_gen (&employee->inst.entity, QOF_EVENT_MODIFY, NULL);
|
||||
qof_event_gen (&employee->inst, QOF_EVENT_MODIFY, NULL);
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
/* Create/Destroy Functions */
|
||||
/* GObject Initialization */
|
||||
QOF_GOBJECT_IMPL(gnc_employee, GncEmployee, QOF_TYPE_INSTANCE);
|
||||
|
||||
static void
|
||||
gnc_employee_init(GncEmployee* emp)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_employee_dispose_real (GObject *empp)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_employee_finalize_real(GObject* empp)
|
||||
{
|
||||
}
|
||||
|
||||
/* Create/Destroy Functions */
|
||||
GncEmployee *gncEmployeeCreate (QofBook *book)
|
||||
{
|
||||
GncEmployee *employee;
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
employee = g_new0 (GncEmployee, 1);
|
||||
qof_instance_init (&employee->inst, _GNC_MOD_NAME, book);
|
||||
employee = g_object_new (GNC_TYPE_EMPLOYEE, NULL);
|
||||
qof_instance_init_data (&employee->inst, _GNC_MOD_NAME, book);
|
||||
|
||||
employee->id = CACHE_INSERT ("");
|
||||
employee->username = CACHE_INSERT ("");
|
||||
employee->language = CACHE_INSERT ("");
|
||||
employee->acl = CACHE_INSERT ("");
|
||||
employee->addr = gncAddressCreate (book, &employee->inst.entity);
|
||||
employee->addr = gncAddressCreate (book, &employee->inst);
|
||||
employee->workday = gnc_numeric_zero();
|
||||
employee->rate = gnc_numeric_zero();
|
||||
employee->active = TRUE;
|
||||
|
||||
qof_event_gen (&employee->inst.entity, QOF_EVENT_CREATE, NULL);
|
||||
qof_event_gen (&employee->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
return employee;
|
||||
}
|
||||
@ -102,7 +124,7 @@ static void gncEmployeeFree (GncEmployee *employee)
|
||||
{
|
||||
if (!employee) return;
|
||||
|
||||
qof_event_gen (&employee->inst.entity, QOF_EVENT_DESTROY, NULL);
|
||||
qof_event_gen (&employee->inst, QOF_EVENT_DESTROY, NULL);
|
||||
|
||||
CACHE_REMOVE (employee->id);
|
||||
CACHE_REMOVE (employee->username);
|
||||
@ -110,8 +132,8 @@ static void gncEmployeeFree (GncEmployee *employee)
|
||||
CACHE_REMOVE (employee->acl);
|
||||
gncAddressDestroy (employee->addr);
|
||||
|
||||
qof_instance_release (&employee->inst);
|
||||
g_free (employee);
|
||||
/* qof_instance_release (&employee->inst); */
|
||||
g_object_unref (employee);
|
||||
}
|
||||
|
||||
GncEmployee *
|
||||
@ -120,15 +142,15 @@ gncCloneEmployee (GncEmployee *from, QofBook *book)
|
||||
GncEmployee *employee;
|
||||
if (!book || !from) return NULL;
|
||||
|
||||
employee = g_new0 (GncEmployee, 1);
|
||||
qof_instance_init(&employee->inst, _GNC_MOD_NAME, book);
|
||||
employee = g_object_new (GNC_TYPE_EMPLOYEE, NULL);
|
||||
qof_instance_init_data(&employee->inst, _GNC_MOD_NAME, book);
|
||||
qof_instance_gemini (&employee->inst, &from->inst);
|
||||
|
||||
employee->id = CACHE_INSERT (from->id);
|
||||
employee->username = CACHE_INSERT (from->username);
|
||||
employee->language = CACHE_INSERT (from->language);
|
||||
employee->acl = CACHE_INSERT (from->acl);
|
||||
employee->addr = gncCloneAddress (from->addr, &employee->inst.entity, book);
|
||||
employee->addr = gncCloneAddress (from->addr, &employee->inst, book);
|
||||
employee->workday = from->workday;
|
||||
employee->rate = from->rate;
|
||||
employee->active = from->active;
|
||||
@ -136,7 +158,7 @@ gncCloneEmployee (GncEmployee *from, QofBook *book)
|
||||
employee->ccard_acc =
|
||||
GNC_ACCOUNT(qof_instance_lookup_twin(QOF_INSTANCE(from->ccard_acc), book));
|
||||
|
||||
qof_event_gen (&employee->inst.entity, QOF_EVENT_CREATE, NULL);
|
||||
qof_event_gen (&employee->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
return employee;
|
||||
}
|
||||
@ -258,7 +280,7 @@ void gncEmployeeSetCCard (GncEmployee *employee, Account* ccard_acc)
|
||||
}
|
||||
|
||||
void
|
||||
qofEmployeeSetAddr (GncEmployee *employee, QofEntity *addr_ent)
|
||||
qofEmployeeSetAddr (GncEmployee *employee, QofInstance *addr_ent)
|
||||
{
|
||||
GncAddress *addr;
|
||||
|
||||
|
@ -32,13 +32,26 @@
|
||||
#define GNC_EMPLOYEE_H_
|
||||
|
||||
typedef struct _gncEmployee GncEmployee;
|
||||
typedef struct _gncEmployeeClass GncEmployeeClass;
|
||||
|
||||
#include "gncAddress.h"
|
||||
#include "Account.h"
|
||||
|
||||
#define GNC_ID_EMPLOYEE "gncEmployee"
|
||||
#define GNC_IS_EMPLOYEE(obj) (QOF_CHECK_TYPE((obj), GNC_ID_EMPLOYEE))
|
||||
#define GNC_EMPLOYEE(obj) (QOF_CHECK_CAST((obj), GNC_ID_EMPLOYEE, GncEmployee))
|
||||
|
||||
/* --- type macros --- */
|
||||
#define GNC_TYPE_EMPLOYEE (gnc_employee_get_type ())
|
||||
#define GNC_EMPLOYEE(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_EMPLOYEE, GncEmployee))
|
||||
#define GNC_EMPLOYEE_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_EMPLOYEE, GncEmployeeClass))
|
||||
#define GNC_IS_EMPLOYEE(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_EMPLOYEE))
|
||||
#define GNC_IS_EMPLOYEE_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_EMPLOYEE))
|
||||
#define GNC_EMPLOYEE_GET_CLASS(o) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_EMPLOYEE, GncEmployeeClass))
|
||||
GType gnc_employee_get_type(void);
|
||||
|
||||
/** @name Create/Destroy Functions
|
||||
@{ */
|
||||
@ -60,7 +73,7 @@ void gncEmployeeSetRate (GncEmployee *employee, gnc_numeric rate);
|
||||
void gncEmployeeSetCurrency (GncEmployee *employee, gnc_commodity * currency);
|
||||
void gncEmployeeSetActive (GncEmployee *employee, gboolean active);
|
||||
void gncEmployeeSetCCard (GncEmployee *employee, Account* ccard_acc);
|
||||
void qofEmployeeSetAddr (GncEmployee *employee, QofEntity *addr_ent);
|
||||
void qofEmployeeSetAddr (GncEmployee *employee, QofInstance *addr_ent);
|
||||
|
||||
/** @} */
|
||||
|
||||
@ -101,9 +114,9 @@ gboolean gncEmployeeIsDirty (GncEmployee *employee);
|
||||
#define EMPLOYEE_CC "credit_card_account"
|
||||
|
||||
/** deprecated routines */
|
||||
#define gncEmployeeGetGUID(E) qof_entity_get_guid(QOF_ENTITY(E))
|
||||
#define gncEmployeeGetGUID(E) qof_instance_get_guid(QOF_INSTANCE(E))
|
||||
#define gncEmployeeGetBook(E) qof_instance_get_book(QOF_INSTANCE(E))
|
||||
#define gncEmployeeRetGUID(E) (E ? *(qof_entity_get_guid(QOF_ENTITY(E))) : *(guid_null()))
|
||||
#define gncEmployeeRetGUID(E) (E ? *(qof_instance_get_guid(QOF_INSTANCE(E))) : *(guid_null()))
|
||||
#define gncEmployeeLookupDirect(G,B) gncEmployeeLookup((B),&(G))
|
||||
|
||||
#endif /* GNC_EMPLOYEE_H_ */
|
||||
|
@ -57,6 +57,6 @@ GncEmployee * gncCloneEmployee (GncEmployee *from, QofBook *);
|
||||
*/
|
||||
GncEmployee * gncEmployeeObtainTwin (GncEmployee *from, QofBook *book);
|
||||
|
||||
#define gncEmployeeSetGUID(E,G) qof_entity_set_guid(QOF_ENTITY(E),(G))
|
||||
#define gncEmployeeSetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
|
||||
|
||||
#endif /* GNC_EMPLOYEEP_H_ */
|
||||
|
@ -96,6 +96,11 @@ struct _gncEntry
|
||||
Timespec b_taxtable_modtime;
|
||||
};
|
||||
|
||||
struct _gncEntryClass
|
||||
{
|
||||
QofInstanceClass parent_class;
|
||||
};
|
||||
|
||||
static QofLogModule log_module = GNC_MOD_BUSINESS;
|
||||
|
||||
/* You must edit the functions in this block in tandem. KEEP THEM IN
|
||||
@ -169,12 +174,29 @@ G_INLINE_FUNC void mark_entry (GncEntry *entry);
|
||||
void mark_entry (GncEntry *entry)
|
||||
{
|
||||
qof_instance_set_dirty(&entry->inst);
|
||||
qof_event_gen (&entry->inst.entity, QOF_EVENT_MODIFY, NULL);
|
||||
qof_event_gen (&entry->inst, QOF_EVENT_MODIFY, NULL);
|
||||
}
|
||||
|
||||
/* ================================================================ */
|
||||
/* Create/Destroy Functions */
|
||||
/* GObject Initialization */
|
||||
QOF_GOBJECT_IMPL(gnc_entry, GncEntry, QOF_TYPE_INSTANCE);
|
||||
|
||||
static void
|
||||
gnc_entry_init(GncEntry* entry)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_entry_dispose_real (GObject *entryp)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_entry_finalize_real(GObject* entryp)
|
||||
{
|
||||
}
|
||||
|
||||
/* Create/Destroy Functions */
|
||||
GncEntry *gncEntryCreate (QofBook *book)
|
||||
{
|
||||
GncEntry *entry;
|
||||
@ -182,8 +204,8 @@ GncEntry *gncEntryCreate (QofBook *book)
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
entry = g_new0 (GncEntry, 1);
|
||||
qof_instance_init (&entry->inst, _GNC_MOD_NAME, book);
|
||||
entry = g_object_new (GNC_TYPE_ENTRY, NULL);
|
||||
qof_instance_init_data (&entry->inst, _GNC_MOD_NAME, book);
|
||||
|
||||
entry->desc = CACHE_INSERT ("");
|
||||
entry->action = CACHE_INSERT ("");
|
||||
@ -203,7 +225,7 @@ GncEntry *gncEntryCreate (QofBook *book)
|
||||
|
||||
entry->values_dirty = TRUE;
|
||||
|
||||
qof_event_gen (&entry->inst.entity, QOF_EVENT_CREATE, NULL);
|
||||
qof_event_gen (&entry->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
return entry;
|
||||
}
|
||||
@ -219,7 +241,7 @@ static void gncEntryFree (GncEntry *entry)
|
||||
{
|
||||
if (!entry) return;
|
||||
|
||||
qof_event_gen (&entry->inst.entity, QOF_EVENT_DESTROY, NULL);
|
||||
qof_event_gen (&entry->inst, QOF_EVENT_DESTROY, NULL);
|
||||
|
||||
CACHE_REMOVE (entry->desc);
|
||||
CACHE_REMOVE (entry->action);
|
||||
@ -233,8 +255,8 @@ static void gncEntryFree (GncEntry *entry)
|
||||
if (entry->b_tax_table)
|
||||
gncTaxTableDecRef (entry->b_tax_table);
|
||||
|
||||
qof_instance_release (&entry->inst);
|
||||
g_free (entry);
|
||||
/* qof_instance_release (&entry->inst); */
|
||||
g_object_unref (entry);
|
||||
}
|
||||
|
||||
GncEntry *
|
||||
@ -1209,7 +1231,7 @@ int gncEntryCompare (GncEntry *a, GncEntry *b)
|
||||
compare = safe_strcmp (a->action, b->action);
|
||||
if (compare) return compare;
|
||||
|
||||
return guid_compare (&(a->inst.entity.guid), &(b->inst.entity.guid));
|
||||
return guid_compare (&(a->inst.guid), &(b->inst.guid));
|
||||
}
|
||||
|
||||
/* ============================================================= */
|
||||
|
@ -32,6 +32,7 @@
|
||||
#define GNC_ENTRY_H_
|
||||
|
||||
typedef struct _gncEntry GncEntry;
|
||||
typedef struct _gncEntryClass GncEntryClass;
|
||||
|
||||
typedef enum {
|
||||
GNC_PAYMENT_CASH = 1,
|
||||
@ -53,8 +54,20 @@ typedef enum {
|
||||
#include "gncOwner.h"
|
||||
|
||||
#define GNC_ID_ENTRY "gncEntry"
|
||||
#define GNC_IS_ENTRY(obj) (QOF_CHECK_TYPE((obj), GNC_ID_ENTRY))
|
||||
#define GNC_ENTRY(obj) (QOF_CHECK_CAST((obj), GNC_ID_ENTRY, GncEntry))
|
||||
|
||||
/* --- type macros --- */
|
||||
#define GNC_TYPE_ENTRY (gnc_entry_get_type ())
|
||||
#define GNC_ENTRY(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_ENTRY, GncEntry))
|
||||
#define GNC_ENTRY_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_ENTRY, GncEntryClass))
|
||||
#define GNC_IS_ENTRY(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_ENTRY))
|
||||
#define GNC_IS_ENTRY_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_ENTRY))
|
||||
#define GNC_ENTRY_GET_CLASS(o) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_ENTRY, GncEntryClass))
|
||||
GType gnc_entry_get_type(void);
|
||||
|
||||
/** How to apply the discount and taxes. There are three distinct ways to
|
||||
* apply them:
|
||||
|
@ -59,6 +59,6 @@ GncEntry * gncCloneEntry (GncEntry *from, QofBook *);
|
||||
*/
|
||||
GncEntry * gncEntryObtainTwin (GncEntry *from, QofBook *book);
|
||||
|
||||
#define gncEntrySetGUID(E,G) qof_entity_set_guid(QOF_ENTITY(E),(G))
|
||||
#define gncEntrySetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
|
||||
|
||||
#endif /* GNC_ENTRYP_H_ */
|
||||
|
@ -69,6 +69,11 @@ struct _gncInvoice
|
||||
GNCLot *posted_lot;
|
||||
};
|
||||
|
||||
struct _gncInvoiceClass
|
||||
{
|
||||
QofInstanceClass parent_class;
|
||||
};
|
||||
|
||||
static QofLogModule log_module = GNC_MOD_BUSINESS;
|
||||
|
||||
#define _GNC_MOD_NAME GNC_ID_INVOICE
|
||||
@ -91,7 +96,7 @@ static void
|
||||
mark_invoice (GncInvoice *invoice)
|
||||
{
|
||||
qof_instance_set_dirty(&invoice->inst);
|
||||
qof_event_gen (&invoice->inst.entity, QOF_EVENT_MODIFY, NULL);
|
||||
qof_event_gen (&invoice->inst, QOF_EVENT_MODIFY, NULL);
|
||||
}
|
||||
|
||||
QofBook * gncInvoiceGetBook(GncInvoice *x)
|
||||
@ -100,16 +105,33 @@ QofBook * gncInvoiceGetBook(GncInvoice *x)
|
||||
}
|
||||
|
||||
/* ================================================================== */
|
||||
/* Create/Destroy Functions */
|
||||
/* GObject Initialization */
|
||||
QOF_GOBJECT_IMPL(gnc_invoice, GncInvoice, QOF_TYPE_INSTANCE);
|
||||
|
||||
static void
|
||||
gnc_invoice_init(GncInvoice* inv)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_invoice_dispose_real (GObject *invp)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_invoice_finalize_real(GObject* invp)
|
||||
{
|
||||
}
|
||||
|
||||
/* Create/Destroy Functions */
|
||||
GncInvoice *gncInvoiceCreate (QofBook *book)
|
||||
{
|
||||
GncInvoice *invoice;
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
invoice = g_new0 (GncInvoice, 1);
|
||||
qof_instance_init (&invoice->inst, _GNC_MOD_NAME, book);
|
||||
invoice = g_object_new (GNC_TYPE_INVOICE, NULL);
|
||||
qof_instance_init_data (&invoice->inst, _GNC_MOD_NAME, book);
|
||||
|
||||
invoice->id = CACHE_INSERT ("");
|
||||
invoice->notes = CACHE_INSERT ("");
|
||||
@ -120,7 +142,7 @@ GncInvoice *gncInvoiceCreate (QofBook *book)
|
||||
|
||||
invoice->to_charge_amount = gnc_numeric_zero();
|
||||
|
||||
qof_event_gen (&invoice->inst.entity, QOF_EVENT_CREATE, NULL);
|
||||
qof_event_gen (&invoice->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
return invoice;
|
||||
}
|
||||
@ -136,7 +158,7 @@ static void gncInvoiceFree (GncInvoice *invoice)
|
||||
{
|
||||
if (!invoice) return;
|
||||
|
||||
qof_event_gen (&invoice->inst.entity, QOF_EVENT_DESTROY, NULL);
|
||||
qof_event_gen (&invoice->inst, QOF_EVENT_DESTROY, NULL);
|
||||
|
||||
CACHE_REMOVE (invoice->id);
|
||||
CACHE_REMOVE (invoice->notes);
|
||||
@ -148,8 +170,8 @@ static void gncInvoiceFree (GncInvoice *invoice)
|
||||
if (invoice->terms)
|
||||
gncBillTermDecRef (invoice->terms);
|
||||
|
||||
qof_instance_release (&invoice->inst);
|
||||
g_free (invoice);
|
||||
/* qof_instance_release (&invoice->inst); */
|
||||
g_object_unref (invoice);
|
||||
}
|
||||
|
||||
GncInvoice *
|
||||
@ -160,8 +182,8 @@ gncCloneInvoice (GncInvoice *from, QofBook *book)
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
invoice = g_new0 (GncInvoice, 1);
|
||||
qof_instance_init (&invoice->inst, _GNC_MOD_NAME, book);
|
||||
invoice = g_object_new (GNC_TYPE_INVOICE, NULL);
|
||||
qof_instance_init_data (&invoice->inst, _GNC_MOD_NAME, book);
|
||||
|
||||
invoice->id = CACHE_INSERT (from->id);
|
||||
invoice->notes = CACHE_INSERT (from->notes);
|
||||
@ -199,7 +221,7 @@ XXX not done */
|
||||
GNCLot * posted_lot;
|
||||
#endif
|
||||
|
||||
qof_event_gen (&invoice->inst.entity, QOF_EVENT_CREATE, NULL);
|
||||
qof_event_gen (&invoice->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
return invoice;
|
||||
}
|
||||
@ -241,7 +263,7 @@ void gncInvoiceSetOwner (GncInvoice *invoice, GncOwner *owner)
|
||||
}
|
||||
|
||||
static void
|
||||
qofInvoiceSetOwner (GncInvoice *invoice, QofEntity *ent)
|
||||
qofInvoiceSetOwner (GncInvoice *invoice, QofInstance *ent)
|
||||
{
|
||||
if(!invoice || !ent) { return; }
|
||||
gncInvoiceBeginEdit (invoice);
|
||||
@ -251,7 +273,7 @@ qofInvoiceSetOwner (GncInvoice *invoice, QofEntity *ent)
|
||||
}
|
||||
|
||||
static void
|
||||
qofInvoiceSetBillTo (GncInvoice *invoice, QofEntity *ent)
|
||||
qofInvoiceSetBillTo (GncInvoice *invoice, QofInstance *ent)
|
||||
{
|
||||
if(!invoice || !ent) { return; }
|
||||
gncInvoiceBeginEdit (invoice);
|
||||
@ -459,18 +481,18 @@ GncOwner * gncInvoiceGetOwner (GncInvoice *invoice)
|
||||
return &invoice->owner;
|
||||
}
|
||||
|
||||
static QofEntity*
|
||||
static QofInstance*
|
||||
qofInvoiceGetOwner (GncInvoice *invoice)
|
||||
{
|
||||
if(!invoice) { return NULL; }
|
||||
return (QofEntity*)&invoice->owner;
|
||||
return QOF_INSTANCE(&invoice->owner);
|
||||
}
|
||||
|
||||
static QofEntity*
|
||||
static QofInstance*
|
||||
qofInvoiceGetBillTo (GncInvoice *invoice)
|
||||
{
|
||||
if(!invoice) { return NULL; }
|
||||
return (QofEntity*)&invoice->billto;
|
||||
return QOF_INSTANCE(&invoice->billto);
|
||||
}
|
||||
|
||||
Timespec gncInvoiceGetDateOpened (GncInvoice *invoice)
|
||||
@ -655,19 +677,19 @@ qofInvoiceGetEntries (GncInvoice *invoice)
|
||||
{
|
||||
QofCollection *entry_coll;
|
||||
GList *list;
|
||||
QofEntity *entry;
|
||||
QofInstance *entry;
|
||||
|
||||
entry_coll = qof_collection_new(GNC_ID_ENTRY);
|
||||
for(list = gncInvoiceGetEntries(invoice); list != NULL; list = list->next)
|
||||
{
|
||||
entry = (QofEntity*)list->data;
|
||||
entry = QOF_INSTANCE(list->data);
|
||||
qof_collection_add_entity(entry_coll, entry);
|
||||
}
|
||||
return entry_coll;
|
||||
}
|
||||
|
||||
static void
|
||||
qofInvoiceEntryCB (QofEntity *ent, gpointer user_data)
|
||||
qofInvoiceEntryCB (QofInstance *ent, gpointer user_data)
|
||||
{
|
||||
GncInvoice *invoice;
|
||||
|
||||
@ -1385,7 +1407,7 @@ gncOwnerApplyPayment (GncOwner *owner, GncInvoice* invoice,
|
||||
/* Now send an event for the invoice so it gets updated as paid */
|
||||
this_invoice = gncInvoiceGetInvoiceFromLot(lot);
|
||||
if (this_invoice)
|
||||
qof_event_gen (&this_invoice->inst.entity, QOF_EVENT_MODIFY, NULL);
|
||||
qof_event_gen (&this_invoice->inst, QOF_EVENT_MODIFY, NULL);
|
||||
|
||||
if (gnc_numeric_zero_p (amount))
|
||||
break;
|
||||
@ -1482,7 +1504,7 @@ int gncInvoiceCompare (GncInvoice *a, GncInvoice *b)
|
||||
compare = timespec_cmp (&(a->date_posted), &(b->date_posted));
|
||||
if (compare) return compare;
|
||||
|
||||
return guid_compare (&(a->inst.entity.guid), &(b->inst.entity.guid));
|
||||
return guid_compare (&(a->inst.guid), &(b->inst.guid));
|
||||
}
|
||||
|
||||
/* ============================================================= */
|
||||
|
@ -38,6 +38,7 @@ transaction and lot for the posted invoice.
|
||||
|
||||
struct _gncInvoice;
|
||||
typedef struct _gncInvoice GncInvoice;
|
||||
typedef struct _gncInvoiceClass GncInvoiceClass;
|
||||
|
||||
#include "gncBillTerm.h"
|
||||
#include "gncEntry.h"
|
||||
@ -46,8 +47,20 @@ typedef struct _gncInvoice GncInvoice;
|
||||
#include "qofbook.h"
|
||||
|
||||
#define GNC_ID_INVOICE "gncInvoice"
|
||||
#define GNC_IS_INVOICE(obj) (QOF_CHECK_TYPE((obj), GNC_ID_INVOICE))
|
||||
#define GNC_INVOICE(obj) (QOF_CHECK_CAST((obj), GNC_ID_INVOICE, GncInvoice))
|
||||
|
||||
/* --- type macros --- */
|
||||
#define GNC_TYPE_INVOICE (gnc_invoice_get_type ())
|
||||
#define GNC_INVOICE(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_INVOICE, GncInvoice))
|
||||
#define GNC_INVOICE_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_INVOICE, GncInvoiceClass))
|
||||
#define GNC_IS_INVOICE(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_INVOICE))
|
||||
#define GNC_IS_INVOICE_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_INVOICE))
|
||||
#define GNC_INVOICE_GET_CLASS(o) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_INVOICE, GncInvoiceClass))
|
||||
GType gnc_invoice_get_type(void);
|
||||
|
||||
/** @name Create/Destroy Functions
|
||||
@{ */
|
||||
|
@ -63,5 +63,5 @@ GncInvoice * gncCloneInvoice (GncInvoice *from, QofBook *);
|
||||
* different ways.
|
||||
*/
|
||||
GncInvoice * gncInvoiceObtainTwin (GncInvoice *from, QofBook *book);
|
||||
#define gncInvoiceSetGUID(I,G) qof_entity_set_guid(QOF_ENTITY(I),(G))
|
||||
#define gncInvoiceSetGUID(I,G) qof_instance_set_guid(QOF_INSTANCE(I),(G))
|
||||
#endif /* GNC_INVOICEP_H_ */
|
||||
|
@ -46,6 +46,11 @@ struct _gncJob
|
||||
gboolean active;
|
||||
};
|
||||
|
||||
struct _gncJobClass
|
||||
{
|
||||
QofInstanceClass parent_class;
|
||||
};
|
||||
|
||||
static QofLogModule log_module = GNC_MOD_BUSINESS;
|
||||
|
||||
#define _GNC_MOD_NAME GNC_ID_JOB
|
||||
@ -57,20 +62,37 @@ G_INLINE_FUNC void mark_job (GncJob *job);
|
||||
void mark_job (GncJob *job)
|
||||
{
|
||||
qof_instance_set_dirty(&job->inst);
|
||||
qof_event_gen (&job->inst.entity, QOF_EVENT_MODIFY, NULL);
|
||||
qof_event_gen (&job->inst, QOF_EVENT_MODIFY, NULL);
|
||||
}
|
||||
|
||||
/* ================================================================== */
|
||||
/* Create/Destroy Functions */
|
||||
/* GObject Initialization */
|
||||
QOF_GOBJECT_IMPL(gnc_job, GncJob, QOF_TYPE_INSTANCE);
|
||||
|
||||
static void
|
||||
gnc_job_init(GncJob* job)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_job_dispose_real (GObject *jobp)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_job_finalize_real(GObject* jobp)
|
||||
{
|
||||
}
|
||||
|
||||
/* Create/Destroy Functions */
|
||||
GncJob *gncJobCreate (QofBook *book)
|
||||
{
|
||||
GncJob *job;
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
job = g_new0 (GncJob, 1);
|
||||
qof_instance_init (&job->inst, _GNC_MOD_NAME, book);
|
||||
job = g_object_new (GNC_TYPE_JOB, NULL);
|
||||
qof_instance_init_data (&job->inst, _GNC_MOD_NAME, book);
|
||||
|
||||
job->id = CACHE_INSERT ("");
|
||||
job->name = CACHE_INSERT ("");
|
||||
@ -78,7 +100,7 @@ GncJob *gncJobCreate (QofBook *book)
|
||||
job->active = TRUE;
|
||||
|
||||
/* GncOwner not initialized */
|
||||
qof_event_gen (&job->inst.entity, QOF_EVENT_CREATE, NULL);
|
||||
qof_event_gen (&job->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
return job;
|
||||
}
|
||||
@ -90,8 +112,8 @@ gncCloneJob (GncJob *from, QofBook *book)
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
job = g_new0 (GncJob, 1);
|
||||
qof_instance_init (&job->inst, _GNC_MOD_NAME, book);
|
||||
job = g_object_new (GNC_TYPE_JOB, NULL);
|
||||
qof_instance_init_data (&job->inst, _GNC_MOD_NAME, book);
|
||||
qof_instance_gemini (&job->inst, &from->inst);
|
||||
|
||||
job->id = CACHE_INSERT (from->id);
|
||||
@ -101,7 +123,7 @@ gncCloneJob (GncJob *from, QofBook *book)
|
||||
|
||||
job->owner = gncCloneOwner(&from->owner, book);
|
||||
|
||||
qof_event_gen (&job->inst.entity, QOF_EVENT_CREATE, NULL);
|
||||
qof_event_gen (&job->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
return job;
|
||||
}
|
||||
@ -117,7 +139,7 @@ static void gncJobFree (GncJob *job)
|
||||
{
|
||||
if (!job) return;
|
||||
|
||||
qof_event_gen (&job->inst.entity, QOF_EVENT_DESTROY, NULL);
|
||||
qof_event_gen (&job->inst, QOF_EVENT_DESTROY, NULL);
|
||||
|
||||
CACHE_REMOVE (job->id);
|
||||
CACHE_REMOVE (job->name);
|
||||
@ -134,8 +156,8 @@ static void gncJobFree (GncJob *job)
|
||||
break;
|
||||
}
|
||||
|
||||
qof_instance_release (&job->inst);
|
||||
g_free (job);
|
||||
/* qof_instance_release (&job->inst); */
|
||||
g_object_unref (job);
|
||||
}
|
||||
|
||||
GncJob *
|
||||
@ -248,7 +270,7 @@ void gncJobSetActive (GncJob *job, gboolean active)
|
||||
}
|
||||
|
||||
static void
|
||||
qofJobSetOwner (GncJob *job, QofEntity *ent)
|
||||
qofJobSetOwner (GncJob *job, QofInstance *ent)
|
||||
{
|
||||
if(!job || !ent) { return; }
|
||||
qof_begin_edit(&job->inst);
|
||||
@ -315,11 +337,11 @@ gboolean gncJobGetActive (GncJob *job)
|
||||
return job->active;
|
||||
}
|
||||
|
||||
static QofEntity*
|
||||
static QofInstance*
|
||||
qofJobGetOwner (GncJob *job)
|
||||
{
|
||||
if(!job) { return NULL; }
|
||||
return (QofEntity*)qofOwnerGetOwner(&job->owner);
|
||||
return QOF_INSTANCE(qofOwnerGetOwner(&job->owner));
|
||||
}
|
||||
|
||||
/* Other functions */
|
||||
|
@ -32,13 +32,26 @@
|
||||
#define GNC_JOB_H_
|
||||
|
||||
typedef struct _gncJob GncJob;
|
||||
typedef struct _gncJobClass GncJobClass;
|
||||
|
||||
#include "gncAddress.h"
|
||||
#include "gncOwner.h"
|
||||
|
||||
#define GNC_ID_JOB "gncJob"
|
||||
#define GNC_IS_JOB(obj) (QOF_CHECK_TYPE((obj), GNC_ID_JOB))
|
||||
#define GNC_JOB(obj) (QOF_CHECK_CAST((obj), GNC_ID_JOB, GncJob))
|
||||
|
||||
/* --- type macros --- */
|
||||
#define GNC_TYPE_JOB (gnc_job_get_type ())
|
||||
#define GNC_JOB(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_JOB, GncJob))
|
||||
#define GNC_JOB_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_JOB, GncJobClass))
|
||||
#define GNC_IS_JOB(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_JOB))
|
||||
#define GNC_IS_JOB_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_JOB))
|
||||
#define GNC_JOB_GET_CLASS(o) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_JOB, GncJobClass))
|
||||
GType gnc_job_get_type(void);
|
||||
|
||||
/* Create/Destroy Functions */
|
||||
|
||||
|
@ -53,6 +53,6 @@ GncJob * gncCloneJob (GncJob *from, QofBook *book);
|
||||
*/
|
||||
GncJob * gncJobObtainTwin (GncJob *from, QofBook *book);
|
||||
|
||||
#define gncJobSetGUID(E,G) qof_entity_set_guid(QOF_ENTITY(E),(G))
|
||||
#define gncJobSetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
|
||||
|
||||
#endif /* GNC_JOBP_H_ */
|
||||
|
@ -53,6 +53,11 @@ struct _gncOrder
|
||||
Timespec closed;
|
||||
};
|
||||
|
||||
struct _gncOrderClass
|
||||
{
|
||||
QofInstanceClass parent_class;
|
||||
};
|
||||
|
||||
static QofLogModule log_module = GNC_MOD_BUSINESS;
|
||||
|
||||
#define _GNC_MOD_NAME GNC_ID_ORDER
|
||||
@ -71,20 +76,37 @@ G_INLINE_FUNC void mark_order (GncOrder *order);
|
||||
void mark_order (GncOrder *order)
|
||||
{
|
||||
qof_instance_set_dirty(&order->inst);
|
||||
qof_event_gen (&order->inst.entity, QOF_EVENT_MODIFY, NULL);
|
||||
qof_event_gen (&order->inst, QOF_EVENT_MODIFY, NULL);
|
||||
}
|
||||
|
||||
/* =============================================================== */
|
||||
/* Create/Destroy Functions */
|
||||
/* GObject Initialization */
|
||||
QOF_GOBJECT_IMPL(gnc_order, GncOrder, QOF_TYPE_INSTANCE);
|
||||
|
||||
static void
|
||||
gnc_order_init(GncOrder* order)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_order_dispose_real (GObject *orderp)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_order_finalize_real(GObject* orderp)
|
||||
{
|
||||
}
|
||||
|
||||
/* Create/Destroy Functions */
|
||||
GncOrder *gncOrderCreate (QofBook *book)
|
||||
{
|
||||
GncOrder *order;
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
order = g_new0 (GncOrder, 1);
|
||||
qof_instance_init (&order->inst, _GNC_MOD_NAME, book);
|
||||
order = g_object_new (GNC_TYPE_ORDER, NULL);
|
||||
qof_instance_init_data (&order->inst, _GNC_MOD_NAME, book);
|
||||
|
||||
order->id = CACHE_INSERT ("");
|
||||
order->notes = CACHE_INSERT ("");
|
||||
@ -92,7 +114,7 @@ GncOrder *gncOrderCreate (QofBook *book)
|
||||
|
||||
order->active = TRUE;
|
||||
|
||||
qof_event_gen (&order->inst.entity, QOF_EVENT_CREATE, NULL);
|
||||
qof_event_gen (&order->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
return order;
|
||||
}
|
||||
@ -108,7 +130,7 @@ static void gncOrderFree (GncOrder *order)
|
||||
{
|
||||
if (!order) return;
|
||||
|
||||
qof_event_gen (&order->inst.entity, QOF_EVENT_DESTROY, NULL);
|
||||
qof_event_gen (&order->inst, QOF_EVENT_DESTROY, NULL);
|
||||
|
||||
g_list_free (order->entries);
|
||||
CACHE_REMOVE (order->id);
|
||||
@ -117,8 +139,8 @@ static void gncOrderFree (GncOrder *order)
|
||||
|
||||
if (order->printname) g_free (order->printname);
|
||||
|
||||
qof_instance_release (&order->inst);
|
||||
g_free (order);
|
||||
/* qof_instance_release (&order->inst); */
|
||||
g_object_unref (order);
|
||||
}
|
||||
|
||||
GncOrder *
|
||||
@ -129,8 +151,8 @@ gncCloneOrder (GncOrder *from, QofBook *book)
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
order = g_new0 (GncOrder, 1);
|
||||
qof_instance_init (&order->inst, _GNC_MOD_NAME, book);
|
||||
order = g_object_new (GNC_TYPE_ORDER, NULL);
|
||||
qof_instance_init_data (&order->inst, _GNC_MOD_NAME, book);
|
||||
qof_instance_gemini (&order->inst, &from->inst);
|
||||
|
||||
order->id = CACHE_INSERT (from->id);
|
||||
@ -152,7 +174,7 @@ gncCloneOrder (GncOrder *from, QofBook *book)
|
||||
order->entries = g_list_prepend (order->entries, entry);
|
||||
}
|
||||
|
||||
qof_event_gen (&order->inst.entity, QOF_EVENT_CREATE, NULL);
|
||||
qof_event_gen (&order->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
return order;
|
||||
}
|
||||
@ -373,7 +395,7 @@ int gncOrderCompare (GncOrder *a, GncOrder *b)
|
||||
compare = timespec_cmp (&(a->closed), &(b->closed));
|
||||
if (compare) return compare;
|
||||
|
||||
return guid_compare (&(a->inst.entity.guid), &(b->inst.entity.guid));
|
||||
return guid_compare (&(a->inst.guid), &(b->inst.guid));
|
||||
}
|
||||
|
||||
/* =========================================================== */
|
||||
|
@ -35,14 +35,27 @@
|
||||
#define GNC_ORDER_H_
|
||||
|
||||
typedef struct _gncOrder GncOrder;
|
||||
typedef struct _gncOrderClass GncOrderClass;
|
||||
|
||||
#include "gncEntry.h"
|
||||
#include "gncOwner.h"
|
||||
#include "qof.h"
|
||||
|
||||
#define GNC_ID_ORDER "gncOrder"
|
||||
#define GNC_IS_ORDER(obj) (QOF_CHECK_TYPE((obj), GNC_ID_ORDER))
|
||||
#define GNC_ORDER(obj) (QOF_CHECK_CAST((obj), GNC_ID_ORDER, GncOrder))
|
||||
|
||||
/* --- type macros --- */
|
||||
#define GNC_TYPE_ORDER (gnc_order_get_type ())
|
||||
#define GNC_ORDER(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_ORDER, GncOrder))
|
||||
#define GNC_ORDER_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_ORDER, GncOrderClass))
|
||||
#define GNC_IS_ORDER(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_ORDER))
|
||||
#define GNC_IS_ORDER_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_ORDER))
|
||||
#define GNC_ORDER_GET_CLASS(o) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_ORDER, GncOrderClass))
|
||||
GType gnc_order_get_type(void);
|
||||
|
||||
/* Create/Destroy Functions */
|
||||
|
||||
|
@ -54,6 +54,6 @@ GncOrder * gncCloneOrder (GncOrder *from, QofBook *);
|
||||
*/
|
||||
GncOrder * gncOrderObtainTwin (GncOrder *from, QofBook *book);
|
||||
|
||||
#define gncOrderSetGUID(O,G) qof_entity_set_guid(QOF_ENTITY(O),(G))
|
||||
#define gncOrderSetGUID(O,G) qof_instance_set_guid(QOF_INSTANCE(O),(G))
|
||||
|
||||
#endif /* GNC_ORDERP_H_ */
|
||||
|
@ -138,10 +138,10 @@ qofOwnerGetType(GncOwner *owner)
|
||||
return type;
|
||||
}
|
||||
|
||||
QofEntity*
|
||||
QofInstance*
|
||||
qofOwnerGetOwner (GncOwner *owner)
|
||||
{
|
||||
QofEntity *ent;
|
||||
QofInstance *ent;
|
||||
|
||||
if(!owner) { return NULL; }
|
||||
ent = NULL;
|
||||
@ -154,19 +154,19 @@ qofOwnerGetOwner (GncOwner *owner)
|
||||
break;
|
||||
}
|
||||
case GNC_OWNER_CUSTOMER : {
|
||||
ent = (QofEntity*)owner->owner.customer;
|
||||
ent = QOF_INSTANCE(owner->owner.customer);
|
||||
break;
|
||||
}
|
||||
case GNC_OWNER_JOB : {
|
||||
ent = (QofEntity*)owner->owner.job;
|
||||
ent = QOF_INSTANCE(owner->owner.job);
|
||||
break;
|
||||
}
|
||||
case GNC_OWNER_VENDOR : {
|
||||
ent = (QofEntity*)owner->owner.vendor;
|
||||
ent = QOF_INSTANCE(owner->owner.vendor);
|
||||
break;
|
||||
}
|
||||
case GNC_OWNER_EMPLOYEE : {
|
||||
ent = (QofEntity*)owner->owner.employee;
|
||||
ent = QOF_INSTANCE(owner->owner.employee);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -174,7 +174,7 @@ qofOwnerGetOwner (GncOwner *owner)
|
||||
}
|
||||
|
||||
void
|
||||
qofOwnerSetEntity (GncOwner *owner, QofEntity *ent)
|
||||
qofOwnerSetEntity (GncOwner *owner, QofInstance *ent)
|
||||
{
|
||||
if(!owner || !ent) { return; }
|
||||
if(0 == safe_strcmp(ent->e_type, GNC_ID_CUSTOMER))
|
||||
|
@ -63,9 +63,9 @@ to QOF as they can be used by objects like GncInvoice.
|
||||
/** return the type for the collection. */
|
||||
QofIdType qofOwnerGetType(GncOwner *owner);
|
||||
/** return the owner itself as an entity. */
|
||||
QofEntity* qofOwnerGetOwner (GncOwner *owner);
|
||||
QofInstance* qofOwnerGetOwner (GncOwner *owner);
|
||||
/** set the owner from the entity. */
|
||||
void qofOwnerSetEntity (GncOwner *owner, QofEntity *ent);
|
||||
void qofOwnerSetEntity (GncOwner *owner, QofInstance *ent);
|
||||
|
||||
gboolean
|
||||
gncOwnerRegister(void);
|
||||
|
@ -48,6 +48,11 @@ struct _gncTaxTable
|
||||
GList * children; /* list of children for disconnection */
|
||||
};
|
||||
|
||||
struct _gncTaxTableClass
|
||||
{
|
||||
QofInstanceClass parent_class;
|
||||
};
|
||||
|
||||
struct _gncTaxTableEntry
|
||||
{
|
||||
GncTaxTable * table;
|
||||
@ -144,7 +149,7 @@ static inline void
|
||||
mark_table (GncTaxTable *table)
|
||||
{
|
||||
qof_instance_set_dirty(&table->inst);
|
||||
qof_event_gen (&table->inst.entity, QOF_EVENT_MODIFY, NULL);
|
||||
qof_event_gen (&table->inst, QOF_EVENT_MODIFY, NULL);
|
||||
}
|
||||
|
||||
static inline void
|
||||
@ -200,19 +205,36 @@ gncTaxTableRemoveChild (GncTaxTable *table, GncTaxTable *child)
|
||||
}
|
||||
|
||||
/* =============================================================== */
|
||||
/* Create/Destroy Functions */
|
||||
/* GObject Initialization */
|
||||
QOF_GOBJECT_IMPL(gnc_taxtable, GncTaxTable, QOF_TYPE_INSTANCE);
|
||||
|
||||
static void
|
||||
gnc_taxtable_init(GncTaxTable* tt)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_taxtable_dispose_real (GObject *ttp)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_taxtable_finalize_real(GObject* ttp)
|
||||
{
|
||||
}
|
||||
|
||||
/* Create/Destroy Functions */
|
||||
GncTaxTable *
|
||||
gncTaxTableCreate (QofBook *book)
|
||||
{
|
||||
GncTaxTable *table;
|
||||
if (!book) return NULL;
|
||||
|
||||
table = g_new0 (GncTaxTable, 1);
|
||||
qof_instance_init (&table->inst, _GNC_MOD_NAME, book);
|
||||
table = g_object_new (GNC_TYPE_TAXTABLE, NULL);
|
||||
qof_instance_init_data (&table->inst, _GNC_MOD_NAME, book);
|
||||
table->name = CACHE_INSERT ("");
|
||||
addObj (table);
|
||||
qof_event_gen (&table->inst.entity, QOF_EVENT_CREATE, NULL);
|
||||
qof_event_gen (&table->inst, QOF_EVENT_CREATE, NULL);
|
||||
return table;
|
||||
}
|
||||
|
||||
@ -224,8 +246,8 @@ gncCloneTaxTable (GncTaxTable *from, QofBook *book)
|
||||
GncTaxTable *table;
|
||||
if (!book) return NULL;
|
||||
|
||||
table = g_new0 (GncTaxTable, 1);
|
||||
qof_instance_init (&table->inst, _GNC_MOD_NAME, book);
|
||||
table = g_object_new (GNC_TYPE_TAXTABLE, NULL);
|
||||
qof_instance_init_data (&table->inst, _GNC_MOD_NAME, book);
|
||||
qof_instance_gemini (&table->inst, &from->inst);
|
||||
|
||||
table->name = CACHE_INSERT (from->name);
|
||||
@ -264,7 +286,7 @@ gncCloneTaxTable (GncTaxTable *from, QofBook *book)
|
||||
}
|
||||
|
||||
addObj (table);
|
||||
qof_event_gen (&table->inst.entity, QOF_EVENT_CREATE, NULL);
|
||||
qof_event_gen (&table->inst, QOF_EVENT_CREATE, NULL);
|
||||
return table;
|
||||
}
|
||||
|
||||
@ -300,7 +322,7 @@ gncTaxTableFree (GncTaxTable *table)
|
||||
|
||||
if (!table) return;
|
||||
|
||||
qof_event_gen (&table->inst.entity, QOF_EVENT_DESTROY, NULL);
|
||||
qof_event_gen (&table->inst, QOF_EVENT_DESTROY, NULL);
|
||||
CACHE_REMOVE (table->name);
|
||||
remObj (table);
|
||||
|
||||
@ -323,8 +345,8 @@ gncTaxTableFree (GncTaxTable *table)
|
||||
}
|
||||
g_list_free(table->children);
|
||||
|
||||
qof_instance_release (&table->inst);
|
||||
g_free (table);
|
||||
/* qof_instance_release (&table->inst); */
|
||||
g_object_unref (table);
|
||||
}
|
||||
|
||||
/* =============================================================== */
|
||||
|
@ -49,6 +49,7 @@ is *identical* to that in ::GncBillTerm
|
||||
@param GList * children; list of children for disconnection
|
||||
*/
|
||||
typedef struct _gncTaxTable GncTaxTable;
|
||||
typedef struct _gncTaxTableClass GncTaxTableClass;
|
||||
|
||||
/** @struct GncTaxTableEntry
|
||||
|
||||
@ -70,8 +71,20 @@ typedef struct _gncAccountValue GncAccountValue;
|
||||
#endif
|
||||
|
||||
#define GNC_ID_TAXTABLE "gncTaxTable"
|
||||
#define GNC_IS_TAXTABLE(obj) (QOF_CHECK_TYPE((obj), GNC_ID_TAXTABLE))
|
||||
#define GNC_TAXTABLE(obj) (QOF_CHECK_CAST((obj), GNC_ID_TAXTABLE, GncTaxTable))
|
||||
|
||||
/* --- type macros --- */
|
||||
#define GNC_TYPE_TAXTABLE (gnc_taxtable_get_type ())
|
||||
#define GNC_TAXTABLE(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TAXTABLE, GncTaxTable))
|
||||
#define GNC_TAXTABLE_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_TAXTABLE, GncTaxTableClass))
|
||||
#define GNC_IS_TAXTABLE(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_TAXTABLE))
|
||||
#define GNC_IS_TAXTABLE_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_TAXTABLE))
|
||||
#define GNC_TAXTABLE_GET_CLASS(o) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_TAXTABLE, GncTaxTableClass))
|
||||
GType gnc_taxtable_get_type(void);
|
||||
|
||||
/**
|
||||
* How to interpret the amount.
|
||||
|
@ -63,6 +63,6 @@ GncTaxTable * gncCloneTaxTable (GncTaxTable *from, QofBook *book);
|
||||
*/
|
||||
GncTaxTable * gncTaxTableObtainTwin (GncTaxTable *from, QofBook *book);
|
||||
|
||||
#define gncTaxTableSetGUID(E,G) qof_entity_set_guid(QOF_ENTITY(E),(G))
|
||||
#define gncTaxTableSetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
|
||||
|
||||
#endif /* GNC_TAXTABLEP_H_ */
|
||||
|
@ -57,6 +57,11 @@ struct _gncVendor
|
||||
GList * jobs;
|
||||
};
|
||||
|
||||
struct _gncVendorClass
|
||||
{
|
||||
QofInstanceClass parent_class;
|
||||
};
|
||||
|
||||
static QofLogModule log_module = GNC_MOD_BUSINESS;
|
||||
|
||||
#define _GNC_MOD_NAME GNC_ID_VENDOR
|
||||
@ -68,30 +73,47 @@ G_INLINE_FUNC void mark_vendor (GncVendor *vendor);
|
||||
void mark_vendor (GncVendor *vendor)
|
||||
{
|
||||
qof_instance_set_dirty(&vendor->inst);
|
||||
qof_event_gen (&vendor->inst.entity, QOF_EVENT_MODIFY, NULL);
|
||||
qof_event_gen (&vendor->inst, QOF_EVENT_MODIFY, NULL);
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
/* Create/Destroy Functions */
|
||||
/* GObject Initialization */
|
||||
QOF_GOBJECT_IMPL(gnc_vendor, GncVendor, QOF_TYPE_INSTANCE);
|
||||
|
||||
static void
|
||||
gnc_vendor_init(GncVendor* vendor)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_vendor_dispose_real (GObject *vendorp)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_vendor_finalize_real(GObject* vendorp)
|
||||
{
|
||||
}
|
||||
|
||||
/* Create/Destroy Functions */
|
||||
GncVendor *gncVendorCreate (QofBook *book)
|
||||
{
|
||||
GncVendor *vendor;
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
vendor = g_new0 (GncVendor, 1);
|
||||
qof_instance_init (&vendor->inst, _GNC_MOD_NAME, book);
|
||||
vendor = g_object_new (GNC_TYPE_VENDOR, NULL);
|
||||
qof_instance_init_data (&vendor->inst, _GNC_MOD_NAME, book);
|
||||
|
||||
vendor->id = CACHE_INSERT ("");
|
||||
vendor->name = CACHE_INSERT ("");
|
||||
vendor->notes = CACHE_INSERT ("");
|
||||
vendor->addr = gncAddressCreate (book, &vendor->inst.entity);
|
||||
vendor->addr = gncAddressCreate (book, &vendor->inst);
|
||||
vendor->taxincluded = GNC_TAXINCLUDED_USEGLOBAL;
|
||||
vendor->active = TRUE;
|
||||
vendor->jobs = NULL;
|
||||
|
||||
qof_event_gen (&vendor->inst.entity, QOF_EVENT_CREATE, NULL);
|
||||
qof_event_gen (&vendor->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
return vendor;
|
||||
}
|
||||
@ -107,7 +129,7 @@ static void gncVendorFree (GncVendor *vendor)
|
||||
{
|
||||
if (!vendor) return;
|
||||
|
||||
qof_event_gen (&vendor->inst.entity, QOF_EVENT_DESTROY, NULL);
|
||||
qof_event_gen (&vendor->inst, QOF_EVENT_DESTROY, NULL);
|
||||
|
||||
CACHE_REMOVE (vendor->id);
|
||||
CACHE_REMOVE (vendor->name);
|
||||
@ -120,8 +142,8 @@ static void gncVendorFree (GncVendor *vendor)
|
||||
if (vendor->taxtable)
|
||||
gncTaxTableDecRef (vendor->taxtable);
|
||||
|
||||
qof_instance_release (&vendor->inst);
|
||||
g_free (vendor);
|
||||
/* qof_instance_release (&vendor->inst); */
|
||||
g_object_unref (vendor);
|
||||
}
|
||||
|
||||
/** Create a copy of a vendor, placing the copy into a new book. */
|
||||
@ -133,14 +155,14 @@ gncCloneVendor (GncVendor *from, QofBook *book)
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
vendor = g_new0 (GncVendor, 1);
|
||||
qof_instance_init (&vendor->inst, _GNC_MOD_NAME, book);
|
||||
vendor = g_object_new (GNC_TYPE_VENDOR, NULL);
|
||||
qof_instance_init_data (&vendor->inst, _GNC_MOD_NAME, book);
|
||||
qof_instance_gemini (&vendor->inst, &from->inst);
|
||||
|
||||
vendor->id = CACHE_INSERT (from->id);
|
||||
vendor->name = CACHE_INSERT (from->name);
|
||||
vendor->notes = CACHE_INSERT (from->notes);
|
||||
vendor->addr = gncCloneAddress (from->addr, &vendor->inst.entity, book);
|
||||
vendor->addr = gncCloneAddress (from->addr, &vendor->inst, book);
|
||||
vendor->taxincluded = from->taxincluded;
|
||||
vendor->taxtable_override = from->taxtable_override;
|
||||
vendor->active = from->active;
|
||||
@ -161,7 +183,7 @@ gncCloneVendor (GncVendor *from, QofBook *book)
|
||||
vendor->jobs = g_list_prepend(vendor->jobs, job);
|
||||
}
|
||||
|
||||
qof_event_gen (&vendor->inst.entity, QOF_EVENT_CREATE, NULL);
|
||||
qof_event_gen (&vendor->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
return vendor;
|
||||
}
|
||||
@ -293,7 +315,7 @@ void gncVendorSetTaxTable (GncVendor *vendor, GncTaxTable *table)
|
||||
}
|
||||
|
||||
static void
|
||||
qofVendorSetAddr (GncVendor *vendor, QofEntity *addr_ent)
|
||||
qofVendorSetAddr (GncVendor *vendor, QofInstance *addr_ent)
|
||||
{
|
||||
GncAddress *addr;
|
||||
|
||||
@ -396,7 +418,7 @@ void gncVendorAddJob (GncVendor *vendor, GncJob *job)
|
||||
vendor->jobs = g_list_insert_sorted (vendor->jobs, job,
|
||||
(GCompareFunc)gncJobCompare);
|
||||
|
||||
qof_event_gen (&vendor->inst.entity, QOF_EVENT_MODIFY, NULL);
|
||||
qof_event_gen (&vendor->inst, QOF_EVENT_MODIFY, NULL);
|
||||
}
|
||||
|
||||
void gncVendorRemoveJob (GncVendor *vendor, GncJob *job)
|
||||
@ -414,7 +436,7 @@ void gncVendorRemoveJob (GncVendor *vendor, GncJob *job)
|
||||
g_list_free_1 (node);
|
||||
}
|
||||
|
||||
qof_event_gen (&vendor->inst.entity, QOF_EVENT_MODIFY, NULL);
|
||||
qof_event_gen (&vendor->inst, QOF_EVENT_MODIFY, NULL);
|
||||
}
|
||||
|
||||
void gncVendorBeginEdit (GncVendor *vendor)
|
||||
|
@ -32,6 +32,7 @@
|
||||
#define GNC_VENDOR_H_
|
||||
|
||||
typedef struct _gncVendor GncVendor;
|
||||
typedef struct _gncVendorClass GncVendorClass;
|
||||
|
||||
#include "gncAddress.h"
|
||||
#include "gncBillTerm.h"
|
||||
@ -39,8 +40,20 @@ typedef struct _gncVendor GncVendor;
|
||||
#include "gncJob.h"
|
||||
|
||||
#define GNC_ID_VENDOR "gncVendor"
|
||||
#define GNC_IS_VENDOR(obj) (QOF_CHECK_TYPE((obj), GNC_ID_VENDOR))
|
||||
#define GNC_VENDOR(obj) (QOF_CHECK_CAST((obj), GNC_ID_VENDOR, GncVendor))
|
||||
|
||||
/* --- type macros --- */
|
||||
#define GNC_TYPE_VENDOR (gnc_vendor_get_type ())
|
||||
#define GNC_VENDOR(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_VENDOR, GncVendor))
|
||||
#define GNC_VENDOR_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_VENDOR, GncVendorClass))
|
||||
#define GNC_IS_VENDOR(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_VENDOR))
|
||||
#define GNC_IS_VENDOR_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_VENDOR))
|
||||
#define GNC_VENDOR_GET_CLASS(o) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_VENDOR, GncVendorClass))
|
||||
GType gnc_vendor_get_type(void);
|
||||
|
||||
/* Create/Destroy Functions */
|
||||
|
||||
|
@ -52,7 +52,7 @@ GncVendor * gncCloneVendor (GncVendor *from, QofBook *);
|
||||
* different ways.
|
||||
*/
|
||||
GncVendor * gncVendorObtainTwin (GncVendor *from, QofBook *book);
|
||||
#define gncVendorSetGUID(V,G) qof_entity_set_guid(QOF_ENTITY(V),(G))
|
||||
#define gncVendorSetGUID(V,G) qof_instance_set_guid(QOF_INSTANCE(V),(G))
|
||||
|
||||
|
||||
#endif /* GNC_VENDORP_H_ */
|
||||
|
@ -38,7 +38,7 @@ test_string_fcn (GncAddress *address, const char *message,
|
||||
static void
|
||||
test_address (void)
|
||||
{
|
||||
QofEntity ent;
|
||||
QofInstance ent;
|
||||
GncAddress *address;
|
||||
QofBook *book = qof_book_new ();
|
||||
|
||||
|
@ -208,19 +208,13 @@ test_bool_fcn (QofBook *book, const char *message,
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
qof_log_init();
|
||||
guid_init ();
|
||||
qof_query_init ();
|
||||
qof_object_initialize ();
|
||||
qof_book_register ();
|
||||
qof_init();
|
||||
do_test (cashobjects_register(), "Cannot register cash objects");
|
||||
do_test (gncInvoiceRegister(), "Cannot register GncInvoice");
|
||||
do_test (gncJobRegister (), "Cannot register GncJob");
|
||||
do_test (gncCustomerRegister(), "Cannot register GncCustomer");
|
||||
test_customer();
|
||||
print_test_results();
|
||||
qof_query_shutdown();
|
||||
guid_shutdown();
|
||||
qof_object_shutdown ();
|
||||
qof_close ();
|
||||
return 0;
|
||||
}
|
||||
|
@ -218,19 +218,13 @@ test_gint_fcn (QofBook *book, const char *message,
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
qof_log_init();
|
||||
guid_init ();
|
||||
qof_query_init ();
|
||||
qof_object_initialize ();
|
||||
qof_book_register ();
|
||||
qof_init();
|
||||
do_test (gncInvoiceRegister(), "Cannot register GncInvoice");
|
||||
do_test (gncJobRegister (), "Cannot register GncJob");
|
||||
do_test (gncCustomerRegister(), "Cannot register GncCustomer");
|
||||
do_test (gncEmployeeRegister(), "Cannot register GncEmployee");
|
||||
test_employee();
|
||||
print_test_results();
|
||||
qof_query_shutdown();
|
||||
guid_shutdown();
|
||||
qof_object_shutdown ();
|
||||
qof_close();
|
||||
return 0;
|
||||
}
|
||||
|
@ -235,19 +235,13 @@ test_gint_fcn (QofBook *book, const char *message,
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
qof_log_init();
|
||||
guid_init ();
|
||||
qof_query_init ();
|
||||
qof_object_initialize ();
|
||||
qof_book_register ();
|
||||
qof_init();
|
||||
do_test (gncInvoiceRegister(), "Cannot register GncInvoice");
|
||||
do_test (gncJobRegister (), "Cannot register GncJob");
|
||||
do_test (gncCustomerRegister(), "Cannot register GncCustomer");
|
||||
test_job();
|
||||
print_test_results();
|
||||
qof_query_shutdown();
|
||||
guid_shutdown();
|
||||
qof_object_shutdown ();
|
||||
qof_close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -216,19 +216,13 @@ test_gint_fcn (QofBook *book, const char *message,
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
qof_log_init();
|
||||
guid_init ();
|
||||
qof_query_init ();
|
||||
qof_object_initialize ();
|
||||
qof_book_register ();
|
||||
qof_init();
|
||||
do_test (gncInvoiceRegister(), "Cannot register GncInvoice");
|
||||
do_test (gncJobRegister (), "Cannot register GncJob");
|
||||
do_test (gncCustomerRegister(), "Cannot register GncCustomer");
|
||||
do_test (gncVendorRegister(), "Cannot register GncVendor");
|
||||
test_vendor();
|
||||
print_test_results();
|
||||
qof_query_shutdown();
|
||||
guid_shutdown();
|
||||
qof_object_shutdown ();
|
||||
qof_close();
|
||||
return 0;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ static gboolean
|
||||
customerCB (const char *location, const char *label,
|
||||
gboolean new_window, GNCURLResult * result)
|
||||
{
|
||||
QofEntity *entity;
|
||||
QofInstance *entity;
|
||||
GncCustomer *customer;
|
||||
|
||||
/* href="...:customer=<guid>" */
|
||||
@ -94,7 +94,7 @@ static gboolean
|
||||
vendorCB (const char *location, const char *label,
|
||||
gboolean new_window, GNCURLResult * result)
|
||||
{
|
||||
QofEntity *entity;
|
||||
QofInstance *entity;
|
||||
GncVendor *vendor;
|
||||
|
||||
/* href="...:vendor=<guid>" */
|
||||
@ -109,7 +109,7 @@ static gboolean
|
||||
employeeCB (const char *location, const char *label,
|
||||
gboolean new_window, GNCURLResult * result)
|
||||
{
|
||||
QofEntity *entity;
|
||||
QofInstance *entity;
|
||||
GncEmployee *employee;
|
||||
|
||||
/* href="...:employee=<guid>" */
|
||||
@ -125,7 +125,7 @@ static gboolean
|
||||
invoiceCB (const char *location, const char *label,
|
||||
gboolean new_window, GNCURLResult * result)
|
||||
{
|
||||
QofEntity *entity;
|
||||
QofInstance *entity;
|
||||
GncInvoice *invoice;
|
||||
|
||||
/* href="...:invoice=<guid>" */
|
||||
@ -141,7 +141,7 @@ static gboolean
|
||||
jobCB (const char *location, const char *label,
|
||||
gboolean new_window, GNCURLResult * result)
|
||||
{
|
||||
QofEntity *entity;
|
||||
QofInstance *entity;
|
||||
GncJob *job;
|
||||
|
||||
/* href="...:job=<guid>" */
|
||||
|
@ -727,10 +727,10 @@ gnc_plugin_business_cmd_export_invoice (GtkAction *action, GncMainWindowActionDa
|
||||
{
|
||||
qof_session_begin(chart_session, filename, TRUE, TRUE);
|
||||
coll = qof_book_get_collection(book, GNC_ID_INVOICE);
|
||||
success = qof_entity_copy_coll_r(chart_session, coll);
|
||||
success = qof_instance_copy_coll_r(chart_session, coll);
|
||||
/* Need to get the GList of GncEntry's - KVP */
|
||||
coll = qof_book_get_collection(book, GNC_ID_CUSTOMER);
|
||||
success = qof_entity_copy_coll_r(chart_session, coll);
|
||||
success = qof_instance_copy_coll_r(chart_session, coll);
|
||||
if(success)
|
||||
{
|
||||
qof_session_save(chart_session, NULL);
|
||||
@ -762,7 +762,7 @@ gnc_plugin_business_cmd_export_customer (GtkAction *action, GncMainWindowActionD
|
||||
{
|
||||
qof_session_begin(chart_session, filename, TRUE, TRUE);
|
||||
coll = qof_book_get_collection(book, GNC_ID_CUSTOMER);
|
||||
success = qof_entity_copy_coll_r(chart_session, coll);
|
||||
success = qof_instance_copy_coll_r(chart_session, coll);
|
||||
if(success)
|
||||
{
|
||||
qof_session_save(chart_session, NULL);
|
||||
@ -794,7 +794,7 @@ gnc_plugin_business_cmd_export_vendor (GtkAction *action, GncMainWindowActionDat
|
||||
{
|
||||
qof_session_begin(chart_session, filename, TRUE, TRUE);
|
||||
coll = qof_book_get_collection(book, GNC_ID_VENDOR);
|
||||
success = qof_entity_copy_coll_r(chart_session, coll);
|
||||
success = qof_instance_copy_coll_r(chart_session, coll);
|
||||
if(success)
|
||||
{
|
||||
qof_session_save(chart_session, NULL);
|
||||
@ -826,7 +826,7 @@ gnc_plugin_business_cmd_export_employee (GtkAction *action, GncMainWindowActionD
|
||||
{
|
||||
qof_session_begin(chart_session, filename, TRUE, TRUE);
|
||||
coll = qof_book_get_collection(book, GNC_ID_EMPLOYEE);
|
||||
success = qof_entity_copy_coll_r(chart_session, coll);
|
||||
success = qof_instance_copy_coll_r(chart_session, coll);
|
||||
if(success)
|
||||
{
|
||||
qof_session_save(chart_session, NULL);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user