From f466538a3527cd539c732d3abee481fa7a34fc2f Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Thu, 28 Jun 2018 01:03:02 +0200 Subject: all: Add DBusError to avoid warnings with valac 0.40 --- src/database/database.vala | 107 +++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 53 deletions(-) (limited to 'src/database/database.vala') diff --git a/src/database/database.vala b/src/database/database.vala index 0ce3f87..8106742 100644 --- a/src/database/database.vala +++ b/src/database/database.vala @@ -154,7 +154,7 @@ public class DataBase : Object { #endif } - public GLib.HashTable get_products() { + public GLib.HashTable get_products() throws DBusError, IOError, DatabaseError { var result = new GLib.HashTable(null, null); statements["products"].reset(); @@ -277,7 +277,7 @@ public class DataBase : Object { } #endif - public DetailedProduct[] get_stock() { + public DetailedProduct[] get_stock() throws DBusError, IOError, DatabaseError { DetailedProduct[] result = {}; statements["stock_status"].reset(); @@ -297,8 +297,9 @@ public class DataBase : Object { return result; } - public DetailedProduct get_product_for_ean(uint64 ean) throws DatabaseError { - var p = new DetailedProduct(); + public DetailedProduct get_product_for_ean(uint64 ean) throws DBusError, IOError, DatabaseError { + DetailedProduct p = {}; + try { p.ean = ean_alias_get(ean); p.name = get_product_name(ean); @@ -312,7 +313,7 @@ public class DataBase : Object { } } - public PriceEntry[] get_prices(uint64 product) { + public PriceEntry[] get_prices(uint64 product) throws DBusError, IOError, DatabaseError { PriceEntry[] result = {}; statements["prices"].reset(); @@ -330,7 +331,7 @@ public class DataBase : Object { return result; } - public RestockEntry[] get_restocks(uint64 product, bool descending) { + public RestockEntry[] get_restocks(uint64 product, bool descending) throws DBusError, IOError, DatabaseError { RestockEntry[] result = {}; var statement = statements[descending ? "restocks_desc" : "restocks_asc"]; @@ -354,7 +355,7 @@ public class DataBase : Object { return result; } - public bool buy(int32 user, uint64 article) throws DatabaseError { + public bool buy(int32 user, uint64 article) throws DBusError, IOError, DatabaseError { int rc = 0; int64 timestamp = (new DateTime.now_utc()).to_unix(); @@ -370,7 +371,7 @@ public class DataBase : Object { return true; } - public string get_product_name(uint64 article) throws DatabaseError { + public string get_product_name(uint64 article) throws DBusError, IOError, DatabaseError { statements["product_name"].reset(); statements["product_name"].bind_text(1, "%llu".printf(article)); @@ -386,7 +387,7 @@ public class DataBase : Object { } } - public string get_product_category(uint64 article) throws DatabaseError { + public string get_product_category(uint64 article) throws DBusError, IOError, DatabaseError { statements["product_category"].reset(); statements["product_category"].bind_text(1, "%llu".printf(article)); @@ -402,7 +403,7 @@ public class DataBase : Object { } } - public int get_product_amount(uint64 article) throws DatabaseError { + public int get_product_amount(uint64 article) throws DBusError, IOError, DatabaseError { statements["product_amount"].reset(); statements["product_amount"].bind_text(1, "%llu".printf(article)); @@ -418,7 +419,7 @@ public class DataBase : Object { } } - public bool get_product_deprecated(uint64 article) throws DatabaseError { + public bool get_product_deprecated(uint64 article) throws DBusError, IOError, DatabaseError { statements["product_deprecated"].reset(); statements["product_deprecated"].bind_text(1, "%llu".printf(article)); @@ -434,7 +435,7 @@ public class DataBase : Object { } } - public void product_deprecate(uint64 article, bool value) throws DatabaseError { + public void product_deprecate(uint64 article, bool value) throws DBusError, IOError, DatabaseError { int rc; statements["product_set_deprecated"].reset(); @@ -446,7 +447,7 @@ public class DataBase : Object { throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc); } - public Price get_product_price(int user, uint64 article) throws DatabaseError { + public Price get_product_price(int user, uint64 article) throws DBusError, IOError, DatabaseError { int64 timestamp = (new DateTime.now_utc()).to_unix(); bool member = user != 0; @@ -469,7 +470,7 @@ public class DataBase : Object { } } - public string undo(int32 user) throws DatabaseError { + public string undo(int32 user) throws DBusError, IOError, DatabaseError { uint64 pid = 0; int rc = 0; string pname; @@ -500,7 +501,7 @@ public class DataBase : Object { return pname; } - public void restock(int user, uint64 product, uint amount, uint price, int supplier, int64 best_before_date) throws DatabaseError { + public void restock(int user, uint64 product, uint amount, uint price, int supplier, int64 best_before_date) throws DBusError, IOError, DatabaseError { int rc = 0; int64 timestamp = (new DateTime.now_utc()).to_unix(); @@ -525,7 +526,7 @@ public class DataBase : Object { throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc); } - public void new_product(uint64 id, string name, int category, int memberprice, int guestprice) throws DatabaseError { + public void new_product(uint64 id, string name, int category, int memberprice, int guestprice) throws DBusError, IOError, DatabaseError { statements["product_create"].reset(); statements["product_create"].bind_text(1, @"$id"); statements["product_create"].bind_text(2, name); @@ -542,7 +543,7 @@ public class DataBase : Object { new_price(id, 0, memberprice, guestprice); } - public void new_price(uint64 product, int64 timestamp, int memberprice, int guestprice) throws DatabaseError { + public void new_price(uint64 product, int64 timestamp, int memberprice, int guestprice) throws DBusError, IOError, DatabaseError { statements["price_create"].reset(); statements["price_create"].bind_text(1, @"$product"); statements["price_create"].bind_int64(2, timestamp); @@ -555,7 +556,7 @@ public class DataBase : Object { } } - public bool check_user_password(int32 user, string password) { + public bool check_user_password(int32 user, string password) throws DBusError, IOError, DatabaseError { statements["password_get"].reset(); statements["password_get"].bind_int(1, user); @@ -569,7 +570,7 @@ public class DataBase : Object { } } - public void set_user_password(int32 user, string password) throws DatabaseError { + public void set_user_password(int32 user, string password) throws DBusError, IOError, DatabaseError { var pwhash = Checksum.compute_for_string(ChecksumType.SHA256, password); int rc; @@ -589,7 +590,7 @@ public class DataBase : Object { throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc); } - public void set_sessionid(int user, string sessionid) throws DatabaseError { + public void set_sessionid(int user, string sessionid) throws DBusError, IOError, DatabaseError { statements["session_set"].reset(); statements["session_set"].bind_text(1, sessionid); statements["session_set"].bind_int(2, user); @@ -599,7 +600,7 @@ public class DataBase : Object { throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc); } - public int get_user_by_sessionid(string sessionid) throws DatabaseError { + public int get_user_by_sessionid(string sessionid) throws DBusError, IOError, DatabaseError { statements["session_get"].reset(); statements["session_get"].bind_text(1, sessionid); @@ -610,7 +611,7 @@ public class DataBase : Object { } } - public UserInfo get_user_info(int user) throws DatabaseError { + public UserInfo get_user_info(int user) throws DBusError, IOError, DatabaseError { var result = UserInfo(); statements["userinfo"].reset(); statements["userinfo"].bind_int(1, user); @@ -650,7 +651,7 @@ public class DataBase : Object { return result; } - public UserAuth get_user_auth(int user) throws DatabaseError { + public UserAuth get_user_auth(int user) throws DBusError, IOError, DatabaseError { var result = UserAuth(); result.id = user; result.superuser = false; @@ -676,7 +677,7 @@ public class DataBase : Object { return result; } - public void set_user_auth(UserAuth auth) throws DatabaseError { + public void set_user_auth(UserAuth auth) throws DBusError, IOError, DatabaseError { int rc; /* create user auth line if not existing */ @@ -698,7 +699,7 @@ public class DataBase : Object { throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc); } - public string get_username(int user) throws DatabaseError { + public string get_username(int user) throws DBusError, IOError, DatabaseError { statements["username"].reset(); statements["username"].bind_int(1, user); @@ -709,7 +710,7 @@ public class DataBase : Object { } } - public string get_user_theme(int user, string fallback) throws DatabaseError { + public string get_user_theme(int user, string fallback) throws DBusError, IOError, DatabaseError { statements["user_theme_get"].reset(); statements["user_theme_get"].bind_text(1, fallback); statements["user_theme_get"].bind_int(2, user); @@ -721,7 +722,7 @@ public class DataBase : Object { } } - public void set_userTheme(int user, string userTheme) throws DatabaseError { + public void set_userTheme(int user, string userTheme) throws DBusError, IOError, DatabaseError { statements["user_theme_set"].reset(); if (userTheme == "") { statements["user_theme_set"].bind_null(1); @@ -735,7 +736,7 @@ public class DataBase : Object { throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc); } - public InvoiceEntry[] get_invoice(int user, int64 from=0, int64 to=-1) throws DatabaseError { + public InvoiceEntry[] get_invoice(int user, int64 from=0, int64 to=-1) throws DBusError, IOError, DatabaseError { InvoiceEntry[] result = {}; if(to == -1) { @@ -766,7 +767,7 @@ public class DataBase : Object { return result; } - public int64 get_first_purchase(int user) { + public int64 get_first_purchase(int user) throws DBusError, IOError, DatabaseError { statements["purchase_first"].reset(); statements["purchase_first"].bind_int(1, user); @@ -776,7 +777,7 @@ public class DataBase : Object { return 0; } - public int64 get_last_purchase(int user) { + public int64 get_last_purchase(int user) throws DBusError, IOError, DatabaseError { statements["purchase_last"].reset(); statements["purchase_last"].bind_int(1, user); @@ -786,7 +787,7 @@ public class DataBase : Object { return 0; } - public StatsInfo get_stats_info() { + public StatsInfo get_stats_info() throws DBusError, IOError, DatabaseError { var result = StatsInfo(); DateTime now = new DateTime.now_local(); @@ -861,7 +862,7 @@ public class DataBase : Object { return result; } - public int[] get_member_ids() { + public int[] get_member_ids() throws DBusError, IOError, DatabaseError { int[] result = {}; statements["user_get_ids"].reset(); @@ -871,7 +872,7 @@ public class DataBase : Object { return result; } - public void user_disable(int user, bool value) throws DatabaseError { + public void user_disable(int user, bool value) throws DBusError, IOError, DatabaseError { int rc; /* create user auth line if not existing */ @@ -890,7 +891,7 @@ public class DataBase : Object { throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc); } - public void user_replace(UserInfo u) throws DatabaseError { + public void user_replace(UserInfo u) throws DBusError, IOError, DatabaseError { statements["user_replace"].reset(); statements["user_replace"].bind_int(1, u.id); statements["user_replace"].bind_text(2, u.email); @@ -926,29 +927,29 @@ public class DataBase : Object { } } - public bool user_is_disabled(int user) throws DatabaseError { + public bool user_is_disabled(int user) throws DBusError, IOError, DatabaseError { return get_user_info(user).disabled; } - public bool user_exists(int user) throws DatabaseError { + public bool user_exists(int user) throws DBusError, IOError, DatabaseError { if(user in get_member_ids()) return true; return false; } - public bool user_equals(UserInfo u) throws DatabaseError { + public bool user_equals(UserInfo u) throws DBusError, IOError, DatabaseError { var dbu = get_user_info(u.id); return u.equals(dbu); } - public int64 get_timestamp_of_last_purchase() { + public int64 get_timestamp_of_last_purchase() throws DBusError, IOError, DatabaseError { statements["last_timestamp"].reset(); if(statements["last_timestamp"].step() != Sqlite.ROW) return 0; return statements["last_timestamp"].column_int64(0); } - public Category[] get_category_list() { + public Category[] get_category_list() throws DBusError, IOError, DatabaseError { Category[] result = {}; statements["category_list"].reset(); @@ -964,7 +965,7 @@ public class DataBase : Object { return result; } - public Supplier[] get_supplier_list() { + public Supplier[] get_supplier_list() throws DBusError, IOError, DatabaseError { Supplier[] result = {}; statements["supplier_list"].reset(); @@ -985,7 +986,7 @@ public class DataBase : Object { return result; } - public Supplier get_supplier(int id) { + public Supplier get_supplier(int id) throws DBusError, IOError, DatabaseError { Supplier result = Supplier(); statements["supplier_get"].reset(); @@ -1012,7 +1013,7 @@ public class DataBase : Object { return result; } - public void add_supplier(string name, string postal_code, string city, string street, string phone, string website) throws DatabaseError { + public void add_supplier(string name, string postal_code, string city, string street, string phone, string website) throws DBusError, IOError, DatabaseError { statements["supplier_add"].reset(); statements["supplier_add"].bind_text(1, name); statements["supplier_add"].bind_text(2, postal_code); @@ -1027,7 +1028,7 @@ public class DataBase : Object { } } - public int[] get_users_with_sales(int64 timestamp_from, int64 timestamp_to) { + public int[] get_users_with_sales(int64 timestamp_from, int64 timestamp_to) throws DBusError, IOError, DatabaseError { var result = new int[0]; statements["users_with_sales"].reset(); statements["users_with_sales"].bind_int64(1, timestamp_from); @@ -1040,7 +1041,7 @@ public class DataBase : Object { return result; } - public Price get_user_invoice_sum(int user, int64 timestamp_from, int64 timestamp_to) { + public Price get_user_invoice_sum(int user, int64 timestamp_from, int64 timestamp_to) throws DBusError, IOError, DatabaseError { Price result = 0; statements["user_invoice_sum"].reset(); @@ -1054,7 +1055,7 @@ public class DataBase : Object { return result; } - public Price cashbox_status() { + public Price cashbox_status() throws DBusError, IOError, DatabaseError { Price result = 0; statements["cashbox_status"].reset(); @@ -1065,7 +1066,7 @@ public class DataBase : Object { return result; } - public void cashbox_add(int user, Price amount, int64 timestamp) throws DatabaseError { + public void cashbox_add(int user, Price amount, int64 timestamp) throws DBusError, IOError, DatabaseError { statements["cashbox_add"].reset(); statements["cashbox_add"].bind_int(1, user); statements["cashbox_add"].bind_int(2, amount); @@ -1078,7 +1079,7 @@ public class DataBase : Object { } } - public CashboxDiff[] cashbox_history() { + public CashboxDiff[] cashbox_history() throws DBusError, IOError, DatabaseError { CashboxDiff[] result = {}; statements["cashbox_history"].reset(); @@ -1096,7 +1097,7 @@ public class DataBase : Object { return result; } - public CashboxDiff[] cashbox_changes(int64 start, int64 stop) { + public CashboxDiff[] cashbox_changes(int64 start, int64 stop) throws DBusError, IOError, DatabaseError { CashboxDiff[] result = {}; statements["cashbox_changes"].reset(); @@ -1116,7 +1117,7 @@ public class DataBase : Object { return result; } - public void ean_alias_add(uint64 ean, uint64 real_ean) throws DatabaseError { + public void ean_alias_add(uint64 ean, uint64 real_ean) throws DBusError, IOError, DatabaseError { statements["alias_ean_add"].reset(); statements["alias_ean_add"].bind_text(1, "%llu".printf(ean)); statements["alias_ean_add"].bind_text(2, "%llu".printf(real_ean)); @@ -1128,7 +1129,7 @@ public class DataBase : Object { } } - public uint64 ean_alias_get(uint64 ean) { + public uint64 ean_alias_get(uint64 ean) throws DBusError, IOError, DatabaseError { uint64 result = ean; statements["alias_ean_get"].reset(); @@ -1140,7 +1141,7 @@ public class DataBase : Object { return result; } - public EanAlias[] ean_alias_list() { + public EanAlias[] ean_alias_list() throws DBusError, IOError, DatabaseError { EanAlias[] result = {}; statements["alias_ean_list"].reset(); @@ -1165,7 +1166,7 @@ public class DataBase : Object { return 1; } - public BestBeforeEntry?[] bestbeforelist() { + public BestBeforeEntry?[] bestbeforelist() throws DBusError, IOError, DatabaseError { var bbdlist = new GLib.GenericArray(); foreach(var product in get_stock()) { @@ -1195,7 +1196,7 @@ public class DataBase : Object { return bbdlist.data; } - public int get_userid_for_rfid(string rfid) throws IOError, DatabaseError { + public int get_userid_for_rfid(string rfid) throws DBusError, IOError, DatabaseError { statements["userid_rfid"].reset(); statements["userid_rfid"].bind_text(1, rfid); -- cgit v1.2.3