From 948af280a046cec4693b1dfb7ee94ab27cf747f6 Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Fri, 27 Jun 2003 05:51:05 +0000 Subject: [PATCH] * src/engine/gnc-event*.[ch]: Change the event generation and callback routines to pass a QofIdType in addition to the GUID* * src/app-utils/gnc-component-manager.c: * src/gnome-utils/gnc-account-sel.c: change to match the new event API. Remove the need for xaccGUIDType(), which means we no longer get the g_warning. * src/backend/postgres/events.c: * src/business/business-core/gncAddress.c: * src/business/business-core/gncAddress.h: * src/business/business-core/gncBillTerm.c: * src/business/business-core/gncCustomer.c: * src/business/business-core/gncEmployee.c: * src/business/business-core/gncEntry.c: * src/business/business-core/gncInvoice.c: * src/business/business-core/gncJob.c: * src/business/business-core/gncOrder.c: * src/business/business-core/gncTaxTable.c: * src/business/business-core/gncVendor.c: * src/business/business-core/test/test-address.c: * src/engine/Account.c: * src/engine/FreqSpec.c: * src/engine/Group.c: * src/engine/Period.c: * src/engine/SchedXaction.c: * src/engine/Transaction.c: * src/engine/gnc-lot.c: * src/engine/gnc-pricedb.c: * src/engine/qofbook.c: Pass the QofIdType into the event generation code. Fixes #115988 git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8776 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 36 +++++++++++++++++++ src/app-utils/gnc-component-manager.c | 18 ++++------ src/backend/postgres/events.c | 6 ++-- src/business/business-core/gncAddress.c | 6 ++-- src/business/business-core/gncAddress.h | 2 +- src/business/business-core/gncBillTerm.c | 6 ++-- src/business/business-core/gncCustomer.c | 14 ++++---- src/business/business-core/gncEmployee.c | 8 ++--- src/business/business-core/gncEntry.c | 8 +++-- src/business/business-core/gncInvoice.c | 6 ++-- src/business/business-core/gncJob.c | 6 ++-- src/business/business-core/gncOrder.c | 6 ++-- src/business/business-core/gncTaxTable.c | 6 ++-- src/business/business-core/gncVendor.c | 12 +++---- .../business-core/test/test-address.c | 6 ++-- src/engine/Account.c | 10 +++--- src/engine/FreqSpec.c | 4 +-- src/engine/Group.c | 22 ++++++------ src/engine/Period.c | 4 +-- src/engine/SchedXaction.c | 4 +-- src/engine/Transaction.c | 10 +++--- src/engine/gnc-event-p.h | 6 ++-- src/engine/gnc-event.c | 14 ++++---- src/engine/gnc-event.h | 5 +-- src/engine/gnc-lot.c | 2 +- src/engine/gnc-pricedb.c | 4 +-- src/engine/qofbook.c | 6 ++-- src/gnome-utils/gnc-account-sel.c | 8 ++--- 28 files changed, 140 insertions(+), 105 deletions(-) diff --git a/ChangeLog b/ChangeLog index 05ff6c8519..d89fbd18c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,39 @@ +2003-06-27 Derek Atkins + + * src/engine/gnc-event*.[ch]: + Change the event generation and callback routines to + pass a QofIdType in addition to the GUID* + + * src/app-utils/gnc-component-manager.c: + * src/gnome-utils/gnc-account-sel.c: + change to match the new event API. Remove the need for + xaccGUIDType(), which means we no longer get the g_warning. + + * src/backend/postgres/events.c: + * src/business/business-core/gncAddress.c: + * src/business/business-core/gncAddress.h: + * src/business/business-core/gncBillTerm.c: + * src/business/business-core/gncCustomer.c: + * src/business/business-core/gncEmployee.c: + * src/business/business-core/gncEntry.c: + * src/business/business-core/gncInvoice.c: + * src/business/business-core/gncJob.c: + * src/business/business-core/gncOrder.c: + * src/business/business-core/gncTaxTable.c: + * src/business/business-core/gncVendor.c: + * src/business/business-core/test/test-address.c: + * src/engine/Account.c: + * src/engine/FreqSpec.c: + * src/engine/Group.c: + * src/engine/Period.c: + * src/engine/SchedXaction.c: + * src/engine/Transaction.c: + * src/engine/gnc-lot.c: + * src/engine/gnc-pricedb.c: + * src/engine/qofbook.c: + Pass the QofIdType into the event generation code. + Fixes #115988 + 2003-06-27 Christian Stimming * src/import-export/hbci/dialog-hbcitrans.c: Fix stupid bug with diff --git a/src/app-utils/gnc-component-manager.c b/src/app-utils/gnc-component-manager.c index 9a27de75a2..ecb17e6dea 100644 --- a/src/app-utils/gnc-component-manager.c +++ b/src/app-utils/gnc-component-manager.c @@ -259,25 +259,19 @@ add_event_type (ComponentEventInfo *cei, GNCIdTypeConst entity_type, } static void -gnc_cm_event_handler (GUID *entity, +gnc_cm_event_handler (GUID *entity, QofIdType type, GNCEngineEventType event_type, gpointer user_data) { - GNCIdType id_type; - #if CM_DEBUG - fprintf (stderr, "event_handler: event %d, guid %s\n", event_type, - guid_to_string(entity)); + fprintf (stderr, "event_handler: event %d, type %s, guid %s\n", event_type, + (type ? type : "(null)"), guid_to_string(entity)); #endif add_event (&changes, entity, event_type, TRUE); - id_type = xaccGUIDType (entity, gnc_get_current_book ()); - g_return_if_fail (id_type); -#if CM_DEBUG - fprintf (stderr, " guid type: %s\n", id_type); -#endif + g_return_if_fail (type); - if (safe_strcmp (id_type, GNC_ID_SPLIT) == 0) + if (safe_strcmp (type, GNC_ID_SPLIT) == 0) { /* split events are never generated by the engine, but might * be generated by a backend (viz. the postgres backend.) @@ -285,7 +279,7 @@ gnc_cm_event_handler (GUID *entity, add_event_type (&changes, GNC_ID_TRANS, GNC_EVENT_MODIFY, TRUE); } else - add_event_type (&changes, id_type, event_type, TRUE); + add_event_type (&changes, type, event_type, TRUE); got_events = TRUE; diff --git a/src/backend/postgres/events.c b/src/backend/postgres/events.c index 53f3f260bd..7a0ea27997 100644 --- a/src/backend/postgres/events.c +++ b/src/backend/postgres/events.c @@ -368,7 +368,7 @@ pgendProcessEvents (Backend *bend) local_obj_type = pgendGUIDType (be, &(ev->guid)); if (GNC_ID_NONE != local_obj_type) { - gnc_engine_generate_event (&(ev->guid), GNC_EVENT_CREATE); + gnc_engine_generate_event (&(ev->guid), local_obj_type, GNC_EVENT_CREATE); } } else @@ -376,11 +376,11 @@ pgendProcessEvents (Backend *bend) local_obj_type = pgendGUIDType (be, &(ev->guid)); if (GNC_ID_NONE != local_obj_type) { - gnc_engine_generate_event (&(ev->guid), GNC_EVENT_MODIFY); + gnc_engine_generate_event (&(ev->guid), local_obj_type, GNC_EVENT_MODIFY); } else { - gnc_engine_generate_event (&(ev->guid), GNC_EVENT_DESTROY); + gnc_engine_generate_event (&(ev->guid), local_obj_type, GNC_EVENT_DESTROY); } } diff --git a/src/business/business-core/gncAddress.c b/src/business/business-core/gncAddress.c index bc336f4ed3..29284f0a92 100644 --- a/src/business/business-core/gncAddress.c +++ b/src/business/business-core/gncAddress.c @@ -20,6 +20,7 @@ struct _gncAddress { QofBook * book; const GUID * parent_guid; + QofIdType parent_type; gboolean dirty; char * name; char * addr1; @@ -43,12 +44,12 @@ mark_address (GncAddress *address) { address->dirty = TRUE; - gnc_engine_generate_event (address->parent_guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (address->parent_guid, address->parent_type, GNC_EVENT_MODIFY); } /* Create/Destroy functions */ -GncAddress * gncAddressCreate (QofBook *book, const GUID *parent) +GncAddress * gncAddressCreate (QofBook *book, const GUID *parent, QofIdType ptype) { GncAddress *addr; @@ -58,6 +59,7 @@ GncAddress * gncAddressCreate (QofBook *book, const GUID *parent) addr->book = book; addr->dirty = FALSE; addr->parent_guid = parent; + addr->parent_type = ptype; addr->name = CACHE_INSERT (""); addr->addr1 = CACHE_INSERT (""); diff --git a/src/business/business-core/gncAddress.h b/src/business/business-core/gncAddress.h index 7445a87a58..f5ce68c924 100644 --- a/src/business/business-core/gncAddress.h +++ b/src/business/business-core/gncAddress.h @@ -16,7 +16,7 @@ typedef struct _gncAddress GncAddress; /* Create/Destroy functions */ -GncAddress * gncAddressCreate (QofBook *book, const GUID *parent); +GncAddress * gncAddressCreate (QofBook *book, const GUID *parent, QofIdType ptype); void gncAddressDestroy (GncAddress *addr); /* Set functions */ diff --git a/src/business/business-core/gncBillTerm.c b/src/business/business-core/gncBillTerm.c index a63d21a7a7..6343c1aa91 100644 --- a/src/business/business-core/gncBillTerm.c +++ b/src/business/business-core/gncBillTerm.c @@ -83,7 +83,7 @@ mark_term (GncBillTerm *term) term->dirty = TRUE; gncBusinessSetDirtyFlag (term->book, _GNC_MOD_NAME, TRUE); - gnc_engine_generate_event (&term->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&term->guid, _GNC_MOD_NAME, GNC_EVENT_MODIFY); } /* Create/Destroy Functions */ @@ -99,7 +99,7 @@ GncBillTerm * gncBillTermCreate (QofBook *book) term->discount = gnc_numeric_zero (); qof_entity_guid_new (qof_book_get_entity_table (book), &term->guid); addObj (term); - gnc_engine_generate_event (&term->guid, GNC_EVENT_CREATE); + gnc_engine_generate_event (&term->guid, _GNC_MOD_NAME, GNC_EVENT_CREATE); return term; } @@ -118,7 +118,7 @@ static void gncBillTermFree (GncBillTerm *term) if (!term) return; - gnc_engine_generate_event (&term->guid, GNC_EVENT_DESTROY); + gnc_engine_generate_event (&term->guid, _GNC_MOD_NAME, GNC_EVENT_DESTROY); CACHE_REMOVE (term->name); CACHE_REMOVE (term->desc); remObj (term); diff --git a/src/business/business-core/gncCustomer.c b/src/business/business-core/gncCustomer.c index 4ef3ee4bbd..f8472b98bb 100644 --- a/src/business/business-core/gncCustomer.c +++ b/src/business/business-core/gncCustomer.c @@ -70,7 +70,7 @@ mark_customer (GncCustomer *customer) customer->dirty = TRUE; gncBusinessSetDirtyFlag (customer->book, _GNC_MOD_NAME, TRUE); - gnc_engine_generate_event (&customer->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&customer->guid, _GNC_MOD_NAME, GNC_EVENT_MODIFY); } /* Create/Destroy Functions */ @@ -87,8 +87,8 @@ GncCustomer *gncCustomerCreate (QofBook *book) cust->id = CACHE_INSERT (""); cust->name = CACHE_INSERT (""); cust->notes = CACHE_INSERT (""); - cust->addr = gncAddressCreate (book, &cust->guid); - cust->shipaddr = gncAddressCreate (book, &cust->guid); + cust->addr = gncAddressCreate (book, &cust->guid, _GNC_MOD_NAME); + cust->shipaddr = gncAddressCreate (book, &cust->guid, _GNC_MOD_NAME); cust->discount = gnc_numeric_zero(); cust->credit = gnc_numeric_zero(); cust->taxincluded = GNC_TAXINCLUDED_USEGLOBAL; @@ -98,7 +98,7 @@ GncCustomer *gncCustomerCreate (QofBook *book) qof_entity_guid_new (qof_book_get_entity_table (book),&cust->guid); addObj (cust); - gnc_engine_generate_event (&cust->guid, GNC_EVENT_CREATE); + gnc_engine_generate_event (&cust->guid, _GNC_MOD_NAME, GNC_EVENT_CREATE); return cust; } @@ -114,7 +114,7 @@ static void gncCustomerFree (GncCustomer *cust) { if (!cust) return; - gnc_engine_generate_event (&cust->guid, GNC_EVENT_DESTROY); + gnc_engine_generate_event (&cust->guid, _GNC_MOD_NAME, GNC_EVENT_DESTROY); CACHE_REMOVE (cust->id); CACHE_REMOVE (cust->name); @@ -284,7 +284,7 @@ void gncCustomerAddJob (GncCustomer *cust, GncJob *job) cust->jobs = g_list_insert_sorted (cust->jobs, job, (GCompareFunc)gncJobCompare); - gnc_engine_generate_event (&cust->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&cust->guid, _GNC_MOD_NAME, GNC_EVENT_MODIFY); } void gncCustomerRemoveJob (GncCustomer *cust, GncJob *job) @@ -301,7 +301,7 @@ void gncCustomerRemoveJob (GncCustomer *cust, GncJob *job) cust->jobs = g_list_remove_link (cust->jobs, node); g_list_free_1 (node); } - gnc_engine_generate_event (&cust->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&cust->guid, _GNC_MOD_NAME, GNC_EVENT_MODIFY); } void gncCustomerBeginEdit (GncCustomer *cust) diff --git a/src/business/business-core/gncEmployee.c b/src/business/business-core/gncEmployee.c index 4f6be69d1e..78d1115224 100644 --- a/src/business/business-core/gncEmployee.c +++ b/src/business/business-core/gncEmployee.c @@ -65,7 +65,7 @@ mark_employee (GncEmployee *employee) employee->dirty = TRUE; gncBusinessSetDirtyFlag (employee->book, _GNC_MOD_NAME, TRUE); - gnc_engine_generate_event (&employee->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&employee->guid, _GNC_MOD_NAME, GNC_EVENT_MODIFY); } /* Create/Destroy Functions */ @@ -84,7 +84,7 @@ GncEmployee *gncEmployeeCreate (QofBook *book) employee->username = CACHE_INSERT (""); employee->language = CACHE_INSERT (""); employee->acl = CACHE_INSERT (""); - employee->addr = gncAddressCreate (book, &employee->guid); + employee->addr = gncAddressCreate (book, &employee->guid, _GNC_MOD_NAME); employee->workday = gnc_numeric_zero(); employee->rate = gnc_numeric_zero(); employee->active = TRUE; @@ -92,7 +92,7 @@ GncEmployee *gncEmployeeCreate (QofBook *book) qof_entity_guid_new (qof_book_get_entity_table (book), &employee->guid); addObj (employee); - gnc_engine_generate_event (&employee->guid, GNC_EVENT_CREATE); + gnc_engine_generate_event (&employee->guid, _GNC_MOD_NAME, GNC_EVENT_CREATE); return employee; } @@ -108,7 +108,7 @@ static void gncEmployeeFree (GncEmployee *employee) { if (!employee) return; - gnc_engine_generate_event (&employee->guid, GNC_EVENT_DESTROY); + gnc_engine_generate_event (&employee->guid, _GNC_MOD_NAME, GNC_EVENT_DESTROY); CACHE_REMOVE (employee->id); CACHE_REMOVE (employee->username); diff --git a/src/business/business-core/gncEntry.c b/src/business/business-core/gncEntry.c index 77427a9abc..733f074fab 100644 --- a/src/business/business-core/gncEntry.c +++ b/src/business/business-core/gncEntry.c @@ -174,7 +174,7 @@ mark_entry (GncEntry *entry) entry->dirty = TRUE; gncBusinessSetDirtyFlag (entry->book, _GNC_MOD_NAME, TRUE); - gnc_engine_generate_event (&entry->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&entry->guid, _GNC_MOD_NAME, GNC_EVENT_MODIFY); } /* Create/Destroy Functions */ @@ -210,7 +210,7 @@ GncEntry *gncEntryCreate (QofBook *book) qof_entity_guid_new (qof_book_get_entity_table (book), &entry->guid); addObj (entry); - gnc_engine_generate_event (&entry->guid, GNC_EVENT_CREATE); + gnc_engine_generate_event (&entry->guid, _GNC_MOD_NAME, GNC_EVENT_CREATE); return entry; } @@ -226,7 +226,7 @@ static void gncEntryFree (GncEntry *entry) { if (!entry) return; - gnc_engine_generate_event (&entry->guid, GNC_EVENT_DESTROY); + gnc_engine_generate_event (&entry->guid, _GNC_MOD_NAME, GNC_EVENT_DESTROY); CACHE_REMOVE (entry->desc); CACHE_REMOVE (entry->action); @@ -511,8 +511,10 @@ void gncEntrySetOrder (GncEntry *entry, GncOrder *order) gncEntryCommitEdit (entry); /* Generate an event modifying the Order's end-owner */ +#if 0 gnc_engine_generate_event (gncOwnerGetEndGUID (gncOrderGetOwner (order)), GNC_EVENT_MODIFY); +#endif } /* called from gncInvoice when we're added to the Invoice */ diff --git a/src/business/business-core/gncInvoice.c b/src/business/business-core/gncInvoice.c index 991f870180..1826fccad3 100644 --- a/src/business/business-core/gncInvoice.c +++ b/src/business/business-core/gncInvoice.c @@ -93,7 +93,7 @@ mark_invoice (GncInvoice *invoice) invoice->dirty = TRUE; gncBusinessSetDirtyFlag (invoice->book, _GNC_MOD_NAME, TRUE); - gnc_engine_generate_event (&invoice->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&invoice->guid, _GNC_MOD_NAME, GNC_EVENT_MODIFY); } /* Create/Destroy Functions */ @@ -119,7 +119,7 @@ GncInvoice *gncInvoiceCreate (QofBook *book) qof_entity_guid_new (qof_book_get_entity_table (book), &invoice->guid); addObj (invoice); - gnc_engine_generate_event (&invoice->guid, GNC_EVENT_CREATE); + gnc_engine_generate_event (&invoice->guid, _GNC_MOD_NAME, GNC_EVENT_CREATE); return invoice; } @@ -135,7 +135,7 @@ static void gncInvoiceFree (GncInvoice *invoice) { if (!invoice) return; - gnc_engine_generate_event (&invoice->guid, GNC_EVENT_DESTROY); + gnc_engine_generate_event (&invoice->guid, _GNC_MOD_NAME, GNC_EVENT_DESTROY); CACHE_REMOVE (invoice->id); CACHE_REMOVE (invoice->notes); diff --git a/src/business/business-core/gncJob.c b/src/business/business-core/gncJob.c index fc222367d3..2a0ac7635a 100644 --- a/src/business/business-core/gncJob.c +++ b/src/business/business-core/gncJob.c @@ -57,7 +57,7 @@ mark_job (GncJob *job) job->dirty = TRUE; gncBusinessSetDirtyFlag (job->book, _GNC_MOD_NAME, TRUE); - gnc_engine_generate_event (&job->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&job->guid, _GNC_MOD_NAME, GNC_EVENT_MODIFY); } /* Create/Destroy Functions */ @@ -80,7 +80,7 @@ GncJob *gncJobCreate (QofBook *book) qof_entity_guid_new (qof_book_get_entity_table (book), &job->guid); addObj (job); - gnc_engine_generate_event (&job->guid, GNC_EVENT_CREATE); + gnc_engine_generate_event (&job->guid, _GNC_MOD_NAME, GNC_EVENT_CREATE); return job; } @@ -96,7 +96,7 @@ static void gncJobFree (GncJob *job) { if (!job) return; - gnc_engine_generate_event (&job->guid, GNC_EVENT_DESTROY); + gnc_engine_generate_event (&job->guid, _GNC_MOD_NAME, GNC_EVENT_DESTROY); CACHE_REMOVE (job->id); CACHE_REMOVE (job->name); diff --git a/src/business/business-core/gncOrder.c b/src/business/business-core/gncOrder.c index 7443a804a1..0b426f9923 100644 --- a/src/business/business-core/gncOrder.c +++ b/src/business/business-core/gncOrder.c @@ -75,7 +75,7 @@ mark_order (GncOrder *order) order->dirty = TRUE; gncBusinessSetDirtyFlag (order->book, _GNC_MOD_NAME, TRUE); - gnc_engine_generate_event (&order->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&order->guid, _GNC_MOD_NAME, GNC_EVENT_MODIFY); } /* Create/Destroy Functions */ @@ -98,7 +98,7 @@ GncOrder *gncOrderCreate (QofBook *book) qof_entity_guid_new (qof_book_get_entity_table (book), &order->guid); addObj (order); - gnc_engine_generate_event (&order->guid, GNC_EVENT_CREATE); + gnc_engine_generate_event (&order->guid, _GNC_MOD_NAME, GNC_EVENT_CREATE); return order; } @@ -114,7 +114,7 @@ static void gncOrderFree (GncOrder *order) { if (!order) return; - gnc_engine_generate_event (&order->guid, GNC_EVENT_DESTROY); + gnc_engine_generate_event (&order->guid, _GNC_MOD_NAME, GNC_EVENT_DESTROY); g_list_free (order->entries); CACHE_REMOVE (order->id); diff --git a/src/business/business-core/gncTaxTable.c b/src/business/business-core/gncTaxTable.c index cddf69f1ac..aa1373620b 100644 --- a/src/business/business-core/gncTaxTable.c +++ b/src/business/business-core/gncTaxTable.c @@ -143,7 +143,7 @@ mark_table (GncTaxTable *table) table->dirty = TRUE; gncBusinessSetDirtyFlag (table->book, _GNC_MOD_NAME, TRUE); - gnc_engine_generate_event (&table->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&table->guid, _GNC_MOD_NAME, GNC_EVENT_MODIFY); } G_INLINE_FUNC void mod_table (GncTaxTable *table); @@ -164,7 +164,7 @@ GncTaxTable * gncTaxTableCreate (QofBook *book) table->name = CACHE_INSERT (""); qof_entity_guid_new (qof_book_get_entity_table (book), &table->guid); addObj (table); - gnc_engine_generate_event (&table->guid, GNC_EVENT_CREATE); + gnc_engine_generate_event (&table->guid, _GNC_MOD_NAME, GNC_EVENT_CREATE); return table; } @@ -183,7 +183,7 @@ static void gncTaxTableFree (GncTaxTable *table) if (!table) return; - gnc_engine_generate_event (&table->guid, GNC_EVENT_DESTROY); + gnc_engine_generate_event (&table->guid, _GNC_MOD_NAME, GNC_EVENT_DESTROY); CACHE_REMOVE (table->name); remObj (table); diff --git a/src/business/business-core/gncVendor.c b/src/business/business-core/gncVendor.c index 0a29b7c0cf..e0ba6629ca 100644 --- a/src/business/business-core/gncVendor.c +++ b/src/business/business-core/gncVendor.c @@ -65,7 +65,7 @@ mark_vendor (GncVendor *vendor) vendor->dirty = TRUE; gncBusinessSetDirtyFlag (vendor->book, _GNC_MOD_NAME, TRUE); - gnc_engine_generate_event (&vendor->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&vendor->guid, _GNC_MOD_NAME, GNC_EVENT_MODIFY); } /* Create/Destroy Functions */ @@ -82,14 +82,14 @@ GncVendor *gncVendorCreate (QofBook *book) vendor->id = CACHE_INSERT (""); vendor->name = CACHE_INSERT (""); vendor->notes = CACHE_INSERT (""); - vendor->addr = gncAddressCreate (book, &vendor->guid); + vendor->addr = gncAddressCreate (book, &vendor->guid, _GNC_MOD_NAME); vendor->taxincluded = GNC_TAXINCLUDED_USEGLOBAL; vendor->active = TRUE; qof_entity_guid_new (qof_book_get_entity_table (book), &vendor->guid); addObj (vendor); - gnc_engine_generate_event (&vendor->guid, GNC_EVENT_CREATE); + gnc_engine_generate_event (&vendor->guid, _GNC_MOD_NAME, GNC_EVENT_CREATE); return vendor; } @@ -105,7 +105,7 @@ static void gncVendorFree (GncVendor *vendor) { if (!vendor) return; - gnc_engine_generate_event (&vendor->guid, GNC_EVENT_DESTROY); + gnc_engine_generate_event (&vendor->guid, _GNC_MOD_NAME, GNC_EVENT_DESTROY); CACHE_REMOVE (vendor->id); CACHE_REMOVE (vendor->name); @@ -329,7 +329,7 @@ void gncVendorAddJob (GncVendor *vendor, GncJob *job) vendor->jobs = g_list_insert_sorted (vendor->jobs, job, (GCompareFunc)gncJobCompare); - gnc_engine_generate_event (&vendor->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&vendor->guid, _GNC_MOD_NAME, GNC_EVENT_MODIFY); } void gncVendorRemoveJob (GncVendor *vendor, GncJob *job) @@ -347,7 +347,7 @@ void gncVendorRemoveJob (GncVendor *vendor, GncJob *job) g_list_free_1 (node); } - gnc_engine_generate_event (&vendor->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&vendor->guid, _GNC_MOD_NAME, GNC_EVENT_MODIFY); } void gncVendorBeginEdit (GncVendor *vendor) diff --git a/src/business/business-core/test/test-address.c b/src/business/business-core/test/test-address.c index 3c6df5fbb5..20b0f07034 100644 --- a/src/business/business-core/test/test-address.c +++ b/src/business/business-core/test/test-address.c @@ -22,8 +22,8 @@ test_address (void) /* Test creation/destruction */ { - do_test (gncAddressCreate (NULL, NULL) == NULL, "address create NULL"); - address = gncAddressCreate (book, NULL); + do_test (gncAddressCreate (NULL, NULL, NULL) == NULL, "address create NULL"); + address = gncAddressCreate (book, NULL, "x"); do_test (address != NULL, "address create"); gncAddressDestroy (address); @@ -32,7 +32,7 @@ test_address (void) /* Test setting routines */ { - address = gncAddressCreate (book, NULL); + address = gncAddressCreate (book, NULL, "x"); test_string_fcn (address, "Name", gncAddressSetName, gncAddressGetName); test_string_fcn (address, "Addr1", gncAddressSetAddr1, gncAddressGetAddr1); test_string_fcn (address, "Addr2", gncAddressSetAddr2, gncAddressGetAddr2); diff --git a/src/engine/Account.c b/src/engine/Account.c index 2dd4e59ac3..b863eb3257 100644 --- a/src/engine/Account.c +++ b/src/engine/Account.c @@ -70,7 +70,7 @@ G_INLINE_FUNC void account_event (Account *account); G_INLINE_FUNC void account_event (Account *account) { - gnc_engine_generate_event (&account->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&account->guid, GNC_ID_ACCOUNT, GNC_EVENT_MODIFY); } @@ -146,7 +146,7 @@ xaccMallocAccount (QofBook *book) xaccInitAccount (acc, book); - gnc_engine_generate_event (&acc->guid, GNC_EVENT_CREATE); + gnc_engine_generate_event (&acc->guid, GNC_ID_ACCOUNT, GNC_EVENT_CREATE); return acc; } @@ -279,7 +279,7 @@ xaccFreeAccount (Account *acc) if (!acc || !acc->book) return; - gnc_engine_generate_event (&acc->guid, GNC_EVENT_DESTROY); + gnc_engine_generate_event (&acc->guid, GNC_ID_ACCOUNT, GNC_EVENT_DESTROY); qof_entity_remove (acc->book->entity_table, &acc->guid); @@ -1082,7 +1082,7 @@ xaccAccountInsertSplit (Account *acc, Split *split) mark_account (acc); if (split->parent) - gnc_engine_generate_event (&split->parent->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&split->parent->guid, GNC_ID_TRANS, GNC_EVENT_MODIFY); } xaccTransCommitEdit(trans); @@ -1128,7 +1128,7 @@ xaccAccountRemoveSplit (Account *acc, Split *split) mark_account (acc); if (split->parent) - gnc_engine_generate_event (&split->parent->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&split->parent->guid, GNC_ID_TRANS, GNC_EVENT_MODIFY); } } xaccAccountCommitEdit(acc); diff --git a/src/engine/FreqSpec.c b/src/engine/FreqSpec.c index 266a0caa0a..fe12d9acae 100644 --- a/src/engine/FreqSpec.c +++ b/src/engine/FreqSpec.c @@ -202,7 +202,7 @@ xaccFreqSpecMalloc(QofBook *book) fs = g_new0(FreqSpec, 1); xaccFreqSpecInit( fs, book ); - gnc_engine_generate_event( &fs->guid, GNC_EVENT_CREATE ); + gnc_engine_generate_event( &fs->guid, GNC_ID_FREQSPEC, GNC_EVENT_CREATE ); return fs; } @@ -233,7 +233,7 @@ void xaccFreqSpecFree( FreqSpec *fs ) { if ( fs == NULL ) return; - gnc_engine_generate_event( &fs->guid, GNC_EVENT_DESTROY ); + gnc_engine_generate_event( &fs->guid, GNC_ID_FREQSPEC, GNC_EVENT_DESTROY ); qof_entity_remove( fs->entity_table, &fs->guid ); xaccFreqSpecCleanUp( fs ); diff --git a/src/engine/Group.c b/src/engine/Group.c index 5a3ceb1903..4f67c468c8 100644 --- a/src/engine/Group.c +++ b/src/engine/Group.c @@ -631,7 +631,7 @@ xaccAccountRemoveGroup (Account *acc) grp->saved = 0; - gnc_engine_generate_event (&acc->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&acc->guid, GNC_ID_ACCOUNT, GNC_EVENT_MODIFY); } /********************************************************************\ @@ -666,7 +666,7 @@ xaccGroupRemoveAccount (AccountGroup *grp, Account *acc) xaccFreeAccountGroup (grp); } - gnc_engine_generate_event (&acc->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&acc->guid, GNC_ID_ACCOUNT, GNC_EVENT_MODIFY); } /********************************************************************\ @@ -689,7 +689,7 @@ xaccAccountInsertSubAccount (Account *adult, Account *child) xaccGroupInsertAccount (adult->children, child); - gnc_engine_generate_event (&adult->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&adult->guid, GNC_ID_ACCOUNT, GNC_EVENT_MODIFY); } /********************************************************************\ @@ -744,11 +744,11 @@ xaccGroupInsertAccount (AccountGroup *grp, Account *acc) */ PWARN ("reparenting accounts accross books is not correctly supported\n"); - gnc_engine_generate_event (&acc->guid, GNC_EVENT_DESTROY); + gnc_engine_generate_event (&acc->guid, GNC_ID_ACCOUNT, GNC_EVENT_DESTROY); qof_entity_remove (acc->book->entity_table, &acc->guid); qof_entity_store (grp->book->entity_table, acc, &acc->guid, GNC_ID_ACCOUNT); - gnc_engine_generate_event (&acc->guid, GNC_EVENT_CREATE); + gnc_engine_generate_event (&acc->guid, GNC_ID_ACCOUNT, GNC_EVENT_CREATE); } } @@ -764,7 +764,7 @@ xaccGroupInsertAccount (AccountGroup *grp, Account *acc) grp->saved = 0; - gnc_engine_generate_event (&acc->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&acc->guid, GNC_ID_ACCOUNT, GNC_EVENT_MODIFY); } /********************************************************************\ @@ -832,7 +832,7 @@ xaccGroupCopyGroup (AccountGroup *to, AccountGroup *from) xaccGroupCopyGroup (to_acc->children, from_acc->children); } xaccAccountCommitEdit (to_acc); - gnc_engine_generate_event (&to_acc->guid, GNC_EVENT_CREATE); + gnc_engine_generate_event (&to_acc->guid, GNC_ID_ACCOUNT, GNC_EVENT_CREATE); /* make sure that we have a symmetric, uniform number of * begin-edits, so that subsequent GroupCommitEdit's @@ -892,14 +892,14 @@ xaccGroupMergeAccounts (AccountGroup *grp) gb->parent = acc_a; acc_b->children = NULL; - gnc_engine_generate_event (&acc_a->guid, GNC_EVENT_MODIFY); - gnc_engine_generate_event (&acc_b->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&acc_a->guid, GNC_ID_ACCOUNT, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&acc_b->guid, GNC_ID_ACCOUNT, GNC_EVENT_MODIFY); } else { xaccGroupConcatGroup (ga, gb); acc_b->children = NULL; - gnc_engine_generate_event (&acc_b->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&acc_b->guid, GNC_ID_ACCOUNT, GNC_EVENT_MODIFY); } } @@ -914,7 +914,7 @@ xaccGroupMergeAccounts (AccountGroup *grp) Split *split = lp->data; gnc_engine_generate_event (&xaccSplitGetAccount(split)->guid, - GNC_EVENT_MODIFY); + GNC_ID_ACCOUNT, GNC_EVENT_MODIFY); split->acc = NULL; xaccAccountInsertSplit (acc_a, split); } diff --git a/src/engine/Period.c b/src/engine/Period.c index 2e4982096e..dd3e82dc7d 100644 --- a/src/engine/Period.c +++ b/src/engine/Period.c @@ -112,7 +112,7 @@ gnc_book_insert_trans_clobber (QofBook *book, Transaction *trans) } xaccTransCommitEdit (newtrans); - gnc_engine_generate_event (&newtrans->guid, GNC_EVENT_CREATE); + gnc_engine_generate_event (&newtrans->guid, GNC_ID_TRANS, GNC_EVENT_CREATE); } /* ================================================================ */ @@ -172,7 +172,7 @@ gnc_book_insert_trans (QofBook *book, Transaction *trans) } xaccTransCommitEdit (trans); - gnc_engine_generate_event (&trans->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&trans->guid, GNC_ID_TRANS, GNC_EVENT_MODIFY); } /* ================================================================ */ diff --git a/src/engine/SchedXaction.c b/src/engine/SchedXaction.c index e5099ad76b..a30301a3f1 100644 --- a/src/engine/SchedXaction.c +++ b/src/engine/SchedXaction.c @@ -99,7 +99,7 @@ xaccSchedXactionMalloc(QofBook *book) sx = g_new0( SchedXaction, 1 ); xaccSchedXactionInit( sx, book ); - gnc_engine_generate_event( &sx->guid, GNC_EVENT_CREATE ); + gnc_engine_generate_event( &sx->guid, GNC_ID_SCHEDXACTION, GNC_EVENT_CREATE ); return sx; } @@ -153,7 +153,7 @@ xaccSchedXactionFree( SchedXaction *sx ) if ( sx == NULL ) return; xaccFreqSpecFree( sx->freq ); - gnc_engine_generate_event( &sx->guid, GNC_EVENT_DESTROY ); + gnc_engine_generate_event( &sx->guid, GNC_ID_SCHEDXACTION, GNC_EVENT_DESTROY ); qof_entity_remove( sx->entity_table, &sx->guid ); if ( sx->name ) diff --git a/src/engine/Transaction.c b/src/engine/Transaction.c index ac63eafaa2..65479f70e2 100644 --- a/src/engine/Transaction.c +++ b/src/engine/Transaction.c @@ -541,13 +541,13 @@ G_INLINE_FUNC void gen_event (Split *split) if (account) { xaccGroupMarkNotSaved (account->parent); - gnc_engine_generate_event (&account->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&account->guid, GNC_ID_ACCOUNT, GNC_EVENT_MODIFY); } trans = split->parent; if (trans) { - gnc_engine_generate_event (&trans->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&trans->guid, GNC_ID_TRANS, GNC_EVENT_MODIFY); } } @@ -563,7 +563,7 @@ G_INLINE_FUNC void gen_event_trans (Transaction *trans) xaccGroupMarkNotSaved (account->parent); } - gnc_engine_generate_event (&trans->guid, GNC_EVENT_MODIFY); + gnc_engine_generate_event (&trans->guid, GNC_ID_TRANS, GNC_EVENT_MODIFY); } /********************************************************************\ @@ -854,7 +854,7 @@ xaccMallocTransaction (QofBook *book) trans = g_new(Transaction, 1); xaccInitTransaction (trans, book); - gnc_engine_generate_event (&trans->guid, GNC_EVENT_CREATE); + gnc_engine_generate_event (&trans->guid, GNC_ID_TRANS, GNC_EVENT_CREATE); return trans; } @@ -2180,7 +2180,7 @@ xaccTransDestroy (Transaction *trans) trans->do_free = TRUE; xaccTransWriteLog (trans, 'D'); - gnc_engine_generate_event (&trans->guid, GNC_EVENT_DESTROY); + gnc_engine_generate_event (&trans->guid, GNC_ID_TRANS, GNC_EVENT_DESTROY); for (node = trans->splits; node; node = node->next) { diff --git a/src/engine/gnc-event-p.h b/src/engine/gnc-event-p.h index 9d8ac9fc89..ed155aece7 100644 --- a/src/engine/gnc-event-p.h +++ b/src/engine/gnc-event-p.h @@ -40,9 +40,11 @@ * event_type: the type of event -- this should be one of the * single-bit GNCEngineEventType values, not a combination. */ -void gnc_engine_generate_event (const GUID *entity, GNCEngineEventType event_type); +void gnc_engine_generate_event (const GUID *entity, QofIdType type, + GNCEngineEventType event_type); /* generates an event even when events are suspended! */ -void gnc_engine_force_event (const GUID *entity, GNCEngineEventType event_type); +void gnc_engine_force_event (const GUID *entity, QofIdType type, + GNCEngineEventType event_type); #endif diff --git a/src/engine/gnc-event.c b/src/engine/gnc-event.c index d761b2a599..53ecb42879 100644 --- a/src/engine/gnc-event.c +++ b/src/engine/gnc-event.c @@ -150,7 +150,7 @@ gnc_engine_resume_events (void) } static void -gnc_engine_generate_event_internal (const GUID *entity, +gnc_engine_generate_event_internal (const GUID *entity, QofIdType type, GNCEngineEventType event_type) { GList *node; @@ -177,21 +177,23 @@ gnc_engine_generate_event_internal (const GUID *entity, HandlerInfo *hi = node->data; if (hi->handler) - hi->handler ((GUID *)entity, event_type, hi->user_data); + hi->handler ((GUID *)entity, type, event_type, hi->user_data); } } void -gnc_engine_force_event (const GUID *entity, GNCEngineEventType event_type) +gnc_engine_force_event (const GUID *entity, QofIdType type, + GNCEngineEventType event_type) { if (!entity) return; - gnc_engine_generate_event_internal (entity, event_type); + gnc_engine_generate_event_internal (entity, type, event_type); } void -gnc_engine_generate_event (const GUID *entity, GNCEngineEventType event_type) +gnc_engine_generate_event (const GUID *entity, QofIdType type, + GNCEngineEventType event_type) { if (!entity) return; @@ -199,5 +201,5 @@ gnc_engine_generate_event (const GUID *entity, GNCEngineEventType event_type) if (suspend_counter) return; - gnc_engine_generate_event_internal (entity, event_type); + gnc_engine_generate_event_internal (entity, type, event_type); } diff --git a/src/engine/gnc-event.h b/src/engine/gnc-event.h index bdf51a3b71..e8ede7bf2e 100644 --- a/src/engine/gnc-event.h +++ b/src/engine/gnc-event.h @@ -27,7 +27,7 @@ #include #include "guid.h" - +#include "qofid.h" typedef enum { @@ -43,10 +43,11 @@ typedef enum * Handler invoked when an engine event occurs. * * entity: GUID of entity generating event + * type: QofIdType of the entity generating the event * event_type: one of the single-bit GNCEngineEventTypes, not a combination * user_data: user_data supplied when handler was registered. */ -typedef void (*GNCEngineEventHandler) (GUID *entity, +typedef void (*GNCEngineEventHandler) (GUID *entity, QofIdType type, GNCEngineEventType event_type, gpointer user_data); diff --git a/src/engine/gnc-lot.c b/src/engine/gnc-lot.c index 738e0bd905..e482756b1a 100644 --- a/src/engine/gnc-lot.c +++ b/src/engine/gnc-lot.c @@ -84,7 +84,7 @@ gnc_lot_destroy (GNCLot *lot) if (!lot) return; ENTER ("(lot=%p)", lot); - gnc_engine_generate_event (&lot->guid, GNC_EVENT_DESTROY); + gnc_engine_generate_event (&lot->guid, GNC_ID_LOT, GNC_EVENT_DESTROY); qof_entity_remove (lot->book->entity_table, &lot->guid); diff --git a/src/engine/gnc-pricedb.c b/src/engine/gnc-pricedb.c index 9c1bbf86e9..35c761a889 100644 --- a/src/engine/gnc-pricedb.c +++ b/src/engine/gnc-pricedb.c @@ -72,7 +72,7 @@ gnc_price_create (QofBook *book) qof_entity_guid_new (p->entity_table, &p->guid); qof_entity_store (p->entity_table, p, &p->guid, GNC_ID_PRICE); - gnc_engine_generate_event (&p->guid, GNC_EVENT_CREATE); + gnc_engine_generate_event (&p->guid, GNC_ID_PRICE, GNC_EVENT_CREATE); return p; } @@ -81,7 +81,7 @@ static void gnc_price_destroy (GNCPrice *p) { ENTER(" "); - gnc_engine_generate_event (&p->guid, GNC_EVENT_DESTROY); + gnc_engine_generate_event (&p->guid, GNC_ID_PRICE, GNC_EVENT_DESTROY); qof_entity_remove(p->entity_table, &p->guid); if(p->type) g_cache_remove(gnc_engine_get_string_cache(), p->type); diff --git a/src/engine/qofbook.c b/src/engine/qofbook.c index e12ed6f223..b6679f3ff0 100644 --- a/src/engine/qofbook.c +++ b/src/engine/qofbook.c @@ -84,9 +84,7 @@ qof_book_new (void) qof_book_init(book); qof_object_book_begin (book); -#if 0 - gnc_engine_generate_event (&book->guid, GNC_EVENT_CREATE); -#endif + gnc_engine_generate_event (&book->guid, QOF_ID_BOOK, GNC_EVENT_CREATE); LEAVE ("book=%p", book); return book; } @@ -97,7 +95,7 @@ qof_book_destroy (QofBook *book) if (!book) return; ENTER ("book=%p", book); - gnc_engine_force_event (&book->guid, GNC_EVENT_DESTROY); + gnc_engine_force_event (&book->guid, QOF_ID_BOOK, GNC_EVENT_DESTROY); qof_object_book_end (book); diff --git a/src/gnome-utils/gnc-account-sel.c b/src/gnome-utils/gnc-account-sel.c index a74a54fe3c..317c93fb75 100644 --- a/src/gnome-utils/gnc-account-sel.c +++ b/src/gnome-utils/gnc-account-sel.c @@ -50,7 +50,7 @@ static void gas_accounts_to_names( gpointer data, gpointer user_data ); static void gas_populate_list( GNCAccountSel *gas ); static void gas_strcmp_adapter( gpointer a, gpointer b ); -static void gnc_account_sel_event_cb( GUID *entity, +static void gnc_account_sel_event_cb( GUID *entity, QofIdType id_type, GNCEngineEventType event_type, gpointer user_data ); @@ -92,16 +92,14 @@ gnc_account_sel_get_type (void) static void -gnc_account_sel_event_cb( GUID *entity, +gnc_account_sel_event_cb( GUID *entity, QofIdType type, GNCEngineEventType event_type, gpointer user_data ) { if ( ! ( event_type == GNC_EVENT_CREATE || event_type == GNC_EVENT_MODIFY || event_type == GNC_EVENT_DESTROY ) - || strcmp( xaccGUIDType( entity, - gnc_get_current_book() ), - GNC_ID_ACCOUNT ) != 0 ) { + || strcmp( type, GNC_ID_ACCOUNT ) != 0 ) { return; } gas_populate_list( (GNCAccountSel*)user_data );