diff options
Diffstat (limited to 'src/database/db-interface.vala')
-rw-r--r-- | src/database/db-interface.vala | 113 |
1 files changed, 61 insertions, 52 deletions
diff --git a/src/database/db-interface.vala b/src/database/db-interface.vala index ac8c215..f2d3e87 100644 --- a/src/database/db-interface.vala +++ b/src/database/db-interface.vala @@ -1,4 +1,5 @@ /* Copyright 2013, Sebastian Reichel <sre@ring0.de> + * Copyright 2017-2018, Johannes Rudolph <johannes.rudolph@gmx.com> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -15,56 +16,61 @@ [DBus (name = "io.mainframe.shopsystem.Database")] public interface Database : Object { - public abstract StockEntry[] get_stock() throws IOError; - public abstract PriceEntry[] get_prices(uint64 product) throws IOError; - public abstract RestockEntry[] get_restocks(uint64 product, bool descending) throws IOError; - public abstract bool buy(int32 user, uint64 article) throws IOError, DatabaseError; - public abstract string get_product_name(uint64 article) throws IOError, DatabaseError; - public abstract string get_product_category(uint64 article) throws IOError, DatabaseError; - public abstract int get_product_amount(uint64 article) throws IOError, DatabaseError; - public abstract bool get_product_deprecated(uint64 article) throws IOError, DatabaseError; - public abstract void product_deprecate(uint64 article, bool value) throws IOError, DatabaseError; - public abstract Price get_product_price(int user, uint64 article) throws IOError, DatabaseError; - public abstract string undo(int32 user) throws IOError, DatabaseError; - public abstract void restock(int user, uint64 product, uint amount, uint price, int supplier, int64 best_before_date) throws IOError, DatabaseError; - public abstract void new_product(uint64 id, string name, int category, int memberprice, int guestprice) throws IOError, DatabaseError; - public abstract void new_price(uint64 product, int64 timestamp, int memberprice, int guestprice) throws IOError, DatabaseError; - public abstract bool check_user_password(int32 user, string password) throws IOError; - public abstract void set_user_password(int32 user, string password) throws IOError, DatabaseError; - public abstract void set_sessionid(int user, string sessionid) throws IOError, DatabaseError; - public abstract void set_userTheme(int user, string userTheme) throws IOError, DatabaseError; - public abstract int get_user_by_sessionid(string sessionid) throws IOError, DatabaseError; - public abstract UserInfo get_user_info(int user) throws IOError, DatabaseError; - public abstract UserAuth get_user_auth(int user) throws IOError, DatabaseError; - public abstract void set_user_auth(UserAuth auth) throws IOError, DatabaseError; - public abstract string get_username(int user) throws IOError, DatabaseError; - public abstract string get_user_theme(int user, string fallback) throws IOError, DatabaseError; - public abstract InvoiceEntry[] get_invoice(int user, int64 from=0, int64 to=-1) throws IOError, DatabaseError; - public abstract int64 get_first_purchase(int user) throws IOError; - public abstract int64 get_last_purchase(int user) throws IOError; - public abstract StatsInfo get_stats_info() throws IOError; - public abstract int[] get_member_ids() throws IOError; - public abstract int[] get_system_member_ids() throws IOError; - public abstract void user_disable(int user, bool value) throws IOError, DatabaseError; - public abstract void user_replace(UserInfo u) throws IOError, DatabaseError; - public abstract bool user_is_disabled(int user) throws IOError, DatabaseError; - public abstract bool user_exists(int user) throws IOError, DatabaseError; - public abstract bool user_equals(UserInfo u) throws IOError, DatabaseError; - public abstract int64 get_timestamp_of_last_purchase() throws IOError; - public abstract Category[] get_category_list() throws IOError; - public abstract Supplier[] get_supplier_list() throws IOError; - public abstract Supplier get_supplier(int id) throws IOError; - public abstract void add_supplier(string name, string postal_code, string city, string street, string phone, string website) throws IOError, DatabaseError; - public abstract int[] get_users_with_sales(int64 timestamp_from, int64 timestamp_to) throws IOError; - public abstract Price get_user_invoice_sum(int user, int64 timestamp_from, int64 timestamp_to) throws IOError; - public abstract Price cashbox_status() throws IOError; - public abstract void cashbox_add(int user, Price amount, int64 timestamp) throws IOError, DatabaseError; - public abstract CashboxDiff[] cashbox_history() throws IOError; - public abstract CashboxDiff[] cashbox_changes(int64 start, int64 stop) throws IOError; - public abstract void ean_alias_add(uint64 ean, uint64 real_ean) throws IOError, DatabaseError; - public abstract uint64 ean_alias_get(uint64 ean) throws IOError; - public abstract EanAlias[] ean_alias_list() throws IOError; - public abstract BestBeforeEntry[] bestbeforelist() throws IOError; + public abstract DetailedProduct[] get_stock() throws DBusError, IOError; + public abstract DetailedProduct get_product_for_ean(uint64 ean) throws DBusError, IOError, DatabaseError; + public abstract PriceEntry[] get_prices(uint64 product) throws DBusError, IOError; + public abstract RestockEntry[] get_restocks(uint64 product, bool descending) throws DBusError, IOError; + public abstract bool buy(int32 user, uint64 article) throws DBusError, IOError, DatabaseError; + public abstract string get_product_name(uint64 article) throws DBusError, IOError, DatabaseError; + public abstract string get_product_category(uint64 article) throws DBusError, IOError, DatabaseError; + public abstract int get_product_amount(uint64 article) throws DBusError, IOError, DatabaseError; + public abstract bool get_product_deprecated(uint64 article) throws DBusError, IOError, DatabaseError; + public abstract void product_deprecate(uint64 article, bool value) throws DBusError, IOError, DatabaseError; + public abstract Price get_product_price(int user, uint64 article) throws DBusError, IOError, DatabaseError; + public abstract string undo(int32 user) throws DBusError, IOError, DatabaseError; + public abstract void restock(int user, uint64 product, uint amount, uint price, int supplier, int64 best_before_date) throws DBusError, IOError, DatabaseError; + public abstract void new_product(uint64 id, string name, int category, int memberprice, int guestprice) throws DBusError, IOError, DatabaseError; + public abstract void new_price(uint64 product, int64 timestamp, int memberprice, int guestprice) throws DBusError, IOError, DatabaseError; + public abstract bool check_user_password(int32 user, string password) throws DBusError, IOError; + public abstract void set_user_password(int32 user, string password) throws DBusError, IOError, DatabaseError; + public abstract void set_sessionid(int user, string sessionid) throws DBusError, IOError, DatabaseError; + public abstract void set_userTheme(int user, string userTheme) throws DBusError, IOError, DatabaseError; + public abstract int get_user_by_sessionid(string sessionid) throws DBusError, IOError, DatabaseError; + public abstract UserInfo get_user_info(int user) throws DBusError, IOError, DatabaseError; + public abstract UserAuth get_user_auth(int user) throws DBusError, IOError, DatabaseError; + public abstract void set_user_auth(UserAuth auth) throws DBusError, IOError, DatabaseError; + public abstract string get_username(int user) throws DBusError, IOError, DatabaseError; + public abstract string get_user_theme(int user, string fallback) throws DBusError, IOError, DatabaseError; + public abstract InvoiceEntry[] get_invoice(int user, int64 from=0, int64 to=-1) throws DBusError, IOError, DatabaseError; + public abstract int64 get_first_purchase(int user) throws DBusError, IOError; + public abstract int64 get_last_purchase(int user) throws DBusError, IOError; + public abstract StatsInfo get_stats_info() throws DBusError, IOError; + public abstract int[] get_member_ids() throws DBusError, IOError, DatabaseError; + public abstract int[] get_system_member_ids() throws DBusError, IOError, DatabaseError; + public abstract void user_disable(int user, bool value) throws DBusError, IOError, DatabaseError; + public abstract void user_replace(UserInfo u) throws DBusError, IOError, DatabaseError; + public abstract bool user_is_disabled(int user) throws DBusError, IOError, DatabaseError; + public abstract bool user_exists(int user) throws DBusError, IOError, DatabaseError; + public abstract bool user_equals(UserInfo u) throws DBusError, IOError, DatabaseError; + public abstract int64 get_timestamp_of_last_purchase() throws DBusError, IOError; + public abstract Category[] get_category_list() throws DBusError, IOError, DatabaseError; + public abstract int add_category(string name) throws DBusError, IOError, DatabaseError; + public abstract Supplier[] get_supplier_list() throws DBusError, IOError; + public abstract Supplier get_supplier(int id) throws DBusError, IOError; + public abstract void add_supplier(string name, string postal_code, string city, string street, string phone, string website) throws DBusError, IOError, DatabaseError; + public abstract int[] get_users_with_sales(int64 timestamp_from, int64 timestamp_to) throws DBusError, IOError; + public abstract Price get_user_invoice_sum(int user, int64 timestamp_from, int64 timestamp_to) throws DBusError, IOError; + public abstract Price cashbox_status() throws DBusError, IOError; + public abstract void cashbox_add(int user, Price amount, int64 timestamp) throws DBusError, IOError, DatabaseError; + public abstract CashboxDiff[] cashbox_history() throws DBusError, IOError; + public abstract CashboxDiff[] cashbox_changes(int64 start, int64 stop) throws DBusError, IOError; + public abstract void ean_alias_add(uint64 ean, uint64 real_ean) throws DBusError, IOError, DatabaseError; + public abstract uint64 ean_alias_get(uint64 ean) throws DBusError, IOError; + public abstract EanAlias[] ean_alias_list() throws DBusError, IOError; + public abstract BestBeforeEntry[] bestbeforelist() throws DBusError, IOError; + public abstract int get_userid_for_rfid(string rfid) throws DBusError, IOError, DatabaseError; + public abstract void addrfid(string rfid, int user) throws DBusError, IOError, DatabaseError; + public abstract void delete_rfid_for_user(int user) throws DBusError, IOError, DatabaseError; } public struct Category { @@ -72,8 +78,8 @@ public struct Category { public string name; } -public struct StockEntry { - public string id; +public struct DetailedProduct { + public uint64 ean; public string name; public string category; public int amount; @@ -126,6 +132,7 @@ public struct UserInfo { public bool disabled; public bool hidden; public string soundTheme; + public string[] rfid; public bool equals(UserInfo x) { if(id != x.id) return false; @@ -140,6 +147,7 @@ public struct UserInfo { if(joined_at != x.joined_at) return false; if(disabled != x.disabled) return false; if(hidden != x.hidden) return false; + if(rfid != x.rfid) return false; return true; } @@ -197,4 +205,5 @@ public errordomain DatabaseError { SESSION_NOT_FOUND, USER_NOT_FOUND, CONSTRAINT_FAILED, + RFID_NOT_FOUND, } |