From fb1ae39f1abe0dd0335489451e09a24e2336e606 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 13 Sep 2025 08:54:05 +0200 Subject: handle file saving through administration callbacks --- include/administration.hpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'include/administration.hpp') diff --git a/include/administration.hpp b/include/administration.hpp index 9df4335..b971e2c 100644 --- a/include/administration.hpp +++ b/include/administration.hpp @@ -307,6 +307,15 @@ typedef struct quarterly_report quarters[MAX_LEN_INCOME_STATEMENT_REPORT_QUARTERS]; } income_statement; +// Administration callback functions. +typedef void (*data_changed_event)(); +typedef void (*data_deleted_event)(char id[MAX_LEN_ID]); +typedef void (*invoice_changed_event)(invoice* invoice); +typedef void (*contact_changed_event)(contact* contact); +typedef void (*taxbracket_changed_event)(country_tax_bracket* bracket); +typedef void (*costcenter_changed_event)(cost_center* cost_center); +typedef void (*project_changed_event)(project* project); + typedef struct { contact company_info; // Company info used for invoices. User cannot create invoices when this is empty/invalid. @@ -333,9 +342,19 @@ void administration_create(); void administration_destroy(); void administration_create_empty(char* save_file); +// Callback functions. +// ======================= +void administration_set_data_changed_event_callback(data_changed_event ev); +void administration_set_data_deleted_event_callback(data_deleted_event ev); +void administration_set_invoice_changed_event_callback(invoice_changed_event ev); +void administration_set_contact_changed_event_callback(contact_changed_event ev); +void administration_set_taxbracket_changed_event_callback(taxbracket_changed_event ev); +void administration_set_costcenter_changed_event_callback(costcenter_changed_event ev); +void administration_set_project_changed_event_callback(project_changed_event ev); + // Other functions. // ======================= -administration* administration_get(); +administration* administration_get(); // TODO get rid of this and make indivual getters and setters char* administration_file_path_get(); contact administration_company_info_get(); void administration_company_info_set(contact data); @@ -343,7 +362,7 @@ void administration_create_income_statement(income_statement* statement); char* administration_get_currency_symbol_from_currency(char* code); char* administration_get_default_currency(); bool administration_can_create_invoices(); -bool administration_is_loaded(); +bool administration_has_save_path(); // Contact functions. // ======================= -- cgit v1.2.3-70-g09d2