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/audio/audio-interface.vala | 8 +- src/audio/audio.vala | 10 +-- src/audio/main.vala | 2 + src/cli/cli.vala | 2 +- src/cli/main.vala | 8 +- src/config/config-interface.vala | 16 ++-- src/config/config.vala | 16 ++-- src/curses-ui/main.vala | 17 ++--- src/database/database.vala | 107 ++++++++++++++------------- src/database/db-interface.vala | 106 +++++++++++++------------- src/database/main.vala | 2 + src/input-device/input-device-interface.vala | 2 +- src/input-device/input-device.vala | 2 +- src/input-device/main.vala | 2 + src/invoice/invoice.vala | 8 +- src/mail/mail.vala | 6 +- src/mail/mailer-interface.vala | 12 +-- src/mail/mailer.vala | 10 +-- src/mail/main.vala | 2 +- src/pdf-invoice/main.vala | 6 +- src/pdf-invoice/pdf-invoice-interface.vala | 4 +- src/pdf-invoice/pdf-invoice.vala | 16 ++-- src/pdf-stock/pdf-stock-interface.vala | 2 +- src/pdf-stock/pdf-stock.vala | 2 +- src/pgp/main.vala | 2 + src/pgp/pgp-interface.vala | 6 +- src/pgp/pgp.vala | 6 +- src/scanner-session/scannersession.vala | 18 +++-- src/serial-device/main.vala | 2 + src/serial-device/serial-device.vala | 2 +- src/web/csv.vala | 2 +- src/web/main.vala | 2 + src/web/web.vala | 48 ++++++++++++ src/web/websession.vala | 6 +- 34 files changed, 262 insertions(+), 200 deletions(-) diff --git a/src/audio/audio-interface.vala b/src/audio/audio-interface.vala index 12bfae4..721a484 100644 --- a/src/audio/audio-interface.vala +++ b/src/audio/audio-interface.vala @@ -17,10 +17,10 @@ public interface AudioPlayer : Object { public abstract signal void end_of_stream(); - public abstract void play_system(string file) throws IOError; - public abstract string get_random_user_theme() throws IOError; - public abstract string[] get_user_themes() throws IOError; - public abstract void play_user(string theme, string type) throws IOError; + public abstract void play_system(string file) throws DBusError, IOError; + public abstract string get_random_user_theme() throws DBusError, IOError; + public abstract string[] get_user_themes() throws DBusError, IOError; + public abstract void play_user(string theme, string type) throws DBusError, IOError; } public enum AudioType { diff --git a/src/audio/audio.vala b/src/audio/audio.vala index 9afb840..ccced20 100644 --- a/src/audio/audio.vala +++ b/src/audio/audio.vala @@ -30,7 +30,7 @@ public class AudioPlayerImplementation { return true; } - public AudioPlayerImplementation(string path) throws IOError { + public AudioPlayerImplementation(string path) throws IOError, DBusError { this.path = path; var alsa = Gst.ElementFactory.make("alsasink", "alsa"); @@ -45,7 +45,7 @@ public class AudioPlayerImplementation { p.get_bus().add_watch(Priority.DEFAULT, bus_callback); } - public void play_system(string file) { + public void play_system(string file) throws IOError, DBusError { p.set_state(Gst.State.NULL); p.uri = "file://" + path + "system/" + file; p.set_state(Gst.State.PLAYING); @@ -76,15 +76,15 @@ public class AudioPlayerImplementation { return files[index]; } - public string get_random_user_theme() { + public string get_random_user_theme() throws IOError, DBusError { return get_random_file(path + "user/"); } - public string[] get_user_themes() { + public string[] get_user_themes() throws IOError, DBusError { return get_files(path + "user/"); } - public void play_user(string theme, string type) { + public void play_user(string theme, string type) throws IOError, DBusError { p.set_state(Gst.State.NULL); var file = get_random_file(path + "user/" + theme+ "/" + type); p.uri = "file://" + path + "user/" + theme+ "/" + type + "/" + file; diff --git a/src/audio/main.vala b/src/audio/main.vala index ac64f52..2a7d918 100644 --- a/src/audio/main.vala +++ b/src/audio/main.vala @@ -34,6 +34,8 @@ public static int main(string[] args) { error("IOError: %s\n", e.message); } catch(KeyFileError e) { error("Config Error: %s\n", e.message); + } catch(DBusError e) { + error("DBus Error: %s\n", e.message); } new MainLoop().run(); diff --git a/src/cli/cli.vala b/src/cli/cli.vala index bc6fe9d..c0ba61e 100644 --- a/src/cli/cli.vala +++ b/src/cli/cli.vala @@ -21,7 +21,7 @@ public class CliImpl { public CliImpl() { } - public void send(string msg) { + public void send(string msg) throws IOError, DBusError { stdout.printf("Sending: %s\n", msg); received_barcode(msg); } diff --git a/src/cli/main.vala b/src/cli/main.vala index a3208dd..377efa1 100644 --- a/src/cli/main.vala +++ b/src/cli/main.vala @@ -42,7 +42,11 @@ public static int main(string[] args) { void on_name_aquired() { foreach (string cmd in commands) { - cli.send(cmd); + try { + cli.send(cmd); + } catch (Error e) { + stderr.printf("Error sending command: %s", e.message); + } } // wait a minimal amount of time, to ensure the event was sent @@ -62,4 +66,4 @@ void on_bus_aquired(DBusConnection con) { stderr.printf("Could not register service\n"); } -} \ No newline at end of file +} diff --git a/src/config/config-interface.vala b/src/config/config-interface.vala index c34e3a7..369071e 100644 --- a/src/config/config-interface.vala +++ b/src/config/config-interface.vala @@ -15,12 +15,12 @@ [DBus (name = "io.mainframe.shopsystem.Config")] public interface Config : Object { - public abstract bool has_group(string group_name) throws IOError, KeyFileError; - public abstract bool has_key(string group_name, string key) throws IOError, KeyFileError; - public abstract string get_string(string group_name, string key) throws IOError, KeyFileError; - public abstract bool get_boolean(string group_name, string key) throws IOError, KeyFileError; - public abstract int get_integer(string group_name, string key) throws IOError, KeyFileError; - public abstract int64 get_int64(string group_name, string key) throws IOError, KeyFileError; - public abstract uint64 get_uint64(string group_name, string key) throws IOError, KeyFileError; - public abstract double get_double(string group_name, string key) throws IOError, KeyFileError; + public abstract bool has_group(string group_name) throws DBusError, IOError, KeyFileError; + public abstract bool has_key(string group_name, string key) throws DBusError, IOError, KeyFileError; + public abstract string get_string(string group_name, string key) throws DBusError, IOError, KeyFileError; + public abstract bool get_boolean(string group_name, string key) throws DBusError, IOError, KeyFileError; + public abstract int get_integer(string group_name, string key) throws DBusError, IOError, KeyFileError; + public abstract int64 get_int64(string group_name, string key) throws DBusError, IOError, KeyFileError; + public abstract uint64 get_uint64(string group_name, string key) throws DBusError, IOError, KeyFileError; + public abstract double get_double(string group_name, string key) throws DBusError, IOError, KeyFileError; } diff --git a/src/config/config.vala b/src/config/config.vala index 60fd835..b25b667 100644 --- a/src/config/config.vala +++ b/src/config/config.vala @@ -27,35 +27,35 @@ public class Cfg { } } - public bool has_group(string group_name) throws KeyFileError { + public bool has_group(string group_name) throws DBusError, IOError, KeyFileError { return file.has_group(group_name); } - public bool has_key(string group_name, string key) throws KeyFileError { + public bool has_key(string group_name, string key) throws DBusError, IOError, KeyFileError { return file.has_key(group_name, key); } - public string get_string(string group_name, string key) throws KeyFileError { + public string get_string(string group_name, string key) throws DBusError, IOError, KeyFileError { return file.get_string(group_name, key); } - public bool get_boolean(string group_name, string key) throws KeyFileError { + public bool get_boolean(string group_name, string key) throws DBusError, IOError, KeyFileError { return file.get_boolean(group_name, key); } - public int get_integer(string group_name, string key) throws KeyFileError { + public int get_integer(string group_name, string key) throws DBusError, IOError, KeyFileError { return file.get_integer(group_name, key); } - public int64 get_int64(string group_name, string key) throws KeyFileError { + public int64 get_int64(string group_name, string key) throws DBusError, IOError, KeyFileError { return file.get_int64(group_name, key); } - public uint64 get_uint64(string group_name, string key) throws KeyFileError { + public uint64 get_uint64(string group_name, string key) throws DBusError, IOError, KeyFileError { return file.get_uint64(group_name, key); } - public double get_double(string group_name, string key) throws KeyFileError { + public double get_double(string group_name, string key) throws DBusError, IOError, KeyFileError { return file.get_double(group_name, key); } diff --git a/src/curses-ui/main.vala b/src/curses-ui/main.vala index 47be40a..7c2e762 100644 --- a/src/curses-ui/main.vala +++ b/src/curses-ui/main.vala @@ -23,6 +23,8 @@ private static void play(string file) { audio.play_system(file); } catch(IOError e) { ui.log(MessageType.WARNING, "could not play audio: %s".printf(e.message)); + } catch(DBusError e) { + ui.log(MessageType.WARNING, "could not play audio: %s".printf(e.message)); } } @@ -43,8 +45,8 @@ public static int main(string[] args) { loop = new MainLoop(); /* handle unix signals */ - Unix.signal_add(Posix.SIGTERM, handle_signals); - Unix.signal_add(Posix.SIGINT, handle_signals); + Unix.signal_add(Posix.Signal.TERM, handle_signals); + Unix.signal_add(Posix.Signal.INT, handle_signals); try { audio = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.AudioPlayer", "/io/mainframe/shopsystem/audio"); @@ -62,16 +64,7 @@ public static int main(string[] args) { scanner.msg.connect(msg_handler); scanner.msg_overlay.connect(msg_overlay_handler); - /* get configuration */ - Config config = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config"); - var shopname = "--SHOPNAME--"; - try { - shopname = config.get_string("GENERAL", "longname"); - } catch(KeyFileError e) { - shopname = "Missing in Config"; - } - - ui.log(MessageType.INFO, "KtT Shop System has been started"); + ui.log(MessageType.INFO, "Shop System has been started"); play("startup.ogg"); /* run mainloop */ 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); diff --git a/src/database/db-interface.vala b/src/database/db-interface.vala index b6d1395..5d0fdfb 100644 --- a/src/database/db-interface.vala +++ b/src/database/db-interface.vala @@ -15,59 +15,59 @@ [DBus (name = "io.mainframe.shopsystem.Database")] public interface Database : Object { - public abstract DetailedProduct[] get_stock() throws IOError; - public abstract DetailedProduct get_product_for_ean(uint64 ean) throws IOError, DatabaseError; - 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 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 int get_userid_for_rfid(string rfid) throws IOError, DatabaseError; - public abstract void addrfid(string rfid, int user) throws IOError, DatabaseError; - public abstract void delete_rfid_for_user(int user) throws IOError, DatabaseError; + 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; + 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; + 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 { diff --git a/src/database/main.vala b/src/database/main.vala index 72e3813..f65707b 100644 --- a/src/database/main.vala +++ b/src/database/main.vala @@ -28,6 +28,8 @@ public static int main(string[] args) { error("IOError: %s\n", e.message); } catch(KeyFileError e) { error("Config Error: %s\n", e.message); + } catch(DBusError e) { + error("DBusError: %s\n", e.message); } Bus.own_name( diff --git a/src/input-device/input-device-interface.vala b/src/input-device/input-device-interface.vala index 067b827..9b16da4 100644 --- a/src/input-device/input-device-interface.vala +++ b/src/input-device/input-device-interface.vala @@ -16,5 +16,5 @@ [DBus (name = "io.mainframe.shopsystem.InputDevice")] public interface InputDevice : Object { public abstract signal void received_barcode(string barcode); - public abstract void blink(uint duration) throws IOError; + public abstract void blink(uint duration) throws IOError, DBusError; } diff --git a/src/input-device/input-device.vala b/src/input-device/input-device.vala index 6988c6d..d3a7691 100644 --- a/src/input-device/input-device.vala +++ b/src/input-device/input-device.vala @@ -315,7 +315,7 @@ public class Device { /** * @param duration duration of the blink in 0.1 seconds */ - public void blink(uint duration) { + public void blink(uint duration) throws IOError, DBusError { /* not supported */ } } diff --git a/src/input-device/main.vala b/src/input-device/main.vala index 30119b0..757de46 100644 --- a/src/input-device/main.vala +++ b/src/input-device/main.vala @@ -25,6 +25,8 @@ public static int main(string[] args) { error("IOError: %s\n", e.message); } catch(KeyFileError e) { error("Config Error: %s\n", e.message); + } catch(DBusError e) { + error("DBus Error: %s\n", e.message); } Bus.own_name( diff --git a/src/invoice/invoice.vala b/src/invoice/invoice.vala index ce47c7b..c0a162c 100644 --- a/src/invoice/invoice.vala +++ b/src/invoice/invoice.vala @@ -39,7 +39,7 @@ public class InvoiceImplementation { string vat; string jverein_membership_number; - public InvoiceImplementation() throws IOError, KeyFileError { + public InvoiceImplementation() throws DBusError, IOError, KeyFileError { mailer = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Mail", "/io/mainframe/shopsystem/mailer"); db = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Database", "/io/mainframe/shopsystem/database"); pdf = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.InvoicePDF", "/io/mainframe/shopsystem/invoicepdf"); @@ -53,7 +53,7 @@ public class InvoiceImplementation { jverein_membership_number = cfg.get_string("JVEREIN", "membership_number"); } - public void send_invoice(bool temporary, int64 timestamp, int user) throws IOError, InvoicePDFError, DatabaseError { + public void send_invoice(bool temporary, int64 timestamp, int user) throws DBusError, IOError, InvoicePDFError, DatabaseError { int64 prevtimestamp = timestamp - day_in_seconds; if(!temporary) @@ -121,7 +121,7 @@ public class InvoiceImplementation { } } - public void send_invoices(bool temporary, int64 timestamp) throws IOError, InvoicePDFError, DatabaseError { + public void send_invoices(bool temporary, int64 timestamp) throws DBusError, IOError, InvoicePDFError, DatabaseError { int64 prevtimestamp = timestamp - day_in_seconds; string due_date_string = ""; @@ -200,7 +200,7 @@ public class InvoiceImplementation { } } - public InvoiceData generate_invoice(bool temporary, int64 timestamp, int userid, string invoiceid) throws IOError, InvoicePDFError, DatabaseError { + public InvoiceData generate_invoice(bool temporary, int64 timestamp, int userid, string invoiceid) throws DBusError, IOError, InvoicePDFError, DatabaseError { int64 prevtimestamp = timestamp - day_in_seconds; if(!temporary) prevtimestamp = new DateTime.from_unix_local(timestamp).add_months(-1).to_unix(); diff --git a/src/mail/mail.vala b/src/mail/mail.vala index 63e9362..e1eec1d 100644 --- a/src/mail/mail.vala +++ b/src/mail/mail.vala @@ -101,12 +101,12 @@ public class MailImplementation { } #endif - public void add_recipient(MailContact contact, GMime.AddressType type) { + public void add_recipient(MailContact contact, GMime.AddressType type) throws DBusError, IOError { m.add_mailbox(type, contact.name, contact.email); recipients += contact.email; } - public void set_main_part(string text, MessageType type) { + public void set_main_part(string text, MessageType type) throws DBusError, IOError { GMime.DataWrapper content = new GMime.DataWrapper.with_stream( new GMime.StreamMem.with_buffer(text.data), GMime.ContentEncoding.DEFAULT); @@ -129,7 +129,7 @@ public class MailImplementation { } } - public void add_attachment(string filename, string content_type, uint8[] data) { + public void add_attachment(string filename, string content_type, uint8[] data) throws DBusError, IOError { GMime.Part part = new GMime.Part(); GMime.DataWrapper content = new GMime.DataWrapper.with_stream( diff --git a/src/mail/mailer-interface.vala b/src/mail/mailer-interface.vala index 1b819d5..019585b 100644 --- a/src/mail/mailer-interface.vala +++ b/src/mail/mailer-interface.vala @@ -15,9 +15,9 @@ [DBus (name = "io.mainframe.shopsystem.Mailer")] public interface Mailer : Object { - public abstract string create_mail() throws IOError; - public abstract void delete_mail(string path) throws IOError; - public abstract void send_mail(string path) throws IOError; + public abstract string create_mail() throws IOError, DBusError; + public abstract void delete_mail(string path) throws IOError, DBusError; + public abstract void send_mail(string path) throws IOError, DBusError; } [DBus (name = "io.mainframe.shopsystem.Mail")] @@ -28,9 +28,9 @@ public interface Mail : Object { public abstract string reply_to { owned get; set; } public abstract MailDate date { owned get; set; } - public abstract void add_recipient(MailContact contact, RecipientType type = RecipientType.TO) throws IOError; - public abstract void set_main_part(string text, MessageType type = MessageType.PLAIN) throws IOError; - public abstract void add_attachment(string filename, string content_type, uint8[] data) throws IOError; + public abstract void add_recipient(MailContact contact, RecipientType type = RecipientType.TO) throws IOError, DBusError; + public abstract void set_main_part(string text, MessageType type = MessageType.PLAIN) throws IOError, DBusError; + public abstract void add_attachment(string filename, string content_type, uint8[] data) throws IOError, DBusError; } public struct MailAttachment { diff --git a/src/mail/mailer.vala b/src/mail/mailer.vala index d83e4b0..c8d609c 100644 --- a/src/mail/mailer.vala +++ b/src/mail/mailer.vala @@ -56,7 +56,7 @@ public class MailerImplementation { return 1; } - public MailerImplementation() throws IOError { + public MailerImplementation() throws DBusError, IOError { int result; GMime.init(); @@ -67,7 +67,7 @@ public class MailerImplementation { send_queue = new Queue(); /* ignore SIGPIPE, as suggested by libESMTP */ - Posix.signal(Posix.SIGPIPE, Posix.SIG_IGN); + Posix.signal(Posix.Signal.PIPE, Posix.SIG_IGN); /* get configuration */ Config config = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config"); @@ -120,7 +120,7 @@ public class MailerImplementation { GMime.shutdown(); } - public string create_mail() throws IOError { + public string create_mail() throws DBusError, IOError { string path = @"/io/mainframe/shopsystem/mail/$mailcounter"; var mail = new MailImplementation(); @@ -136,7 +136,7 @@ public class MailerImplementation { return path; } - public void delete_mail(string path) throws IOError { + public void delete_mail(string path) throws DBusError, IOError { if(!(path in mails)) throw new IOError.NOT_FOUND("No such mail"); @@ -144,7 +144,7 @@ public class MailerImplementation { mails.remove(path); } - public void send_mail(string path) throws IOError { + public void send_mail(string path) throws DBusError, IOError { if(!(path in mails)) throw new IOError.NOT_FOUND("No such mail"); diff --git a/src/mail/main.vala b/src/mail/main.vala index 0c36f6b..989c4f1 100644 --- a/src/mail/main.vala +++ b/src/mail/main.vala @@ -19,7 +19,7 @@ DBusConnection mail_bus; public static int main(string[] args) { try { m = new MailerImplementation(); - } catch(IOError e) { + } catch(Error e) { stderr.printf("Error: %s\n", e.message); } diff --git a/src/pdf-invoice/main.vala b/src/pdf-invoice/main.vala index 3d8e298..dc95bde 100644 --- a/src/pdf-invoice/main.vala +++ b/src/pdf-invoice/main.vala @@ -19,6 +19,8 @@ public static int main(string[] args) { try { Config cfg = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config"); datadir = cfg.get_string("INVOICE", "datadir"); + } catch(DBusError e) { + error("DBusError: %s\n", e.message); } catch(IOError e) { error("IOError: %s\n", e.message); } catch(KeyFileError e) { @@ -41,7 +43,7 @@ public static int main(string[] args) { void on_bus_aquired(DBusConnection conn) { try { conn.register_object("/io/mainframe/shopsystem/invoicepdf", new InvoicePDF(datadir)); - } catch(IOError e) { - stderr.printf("Could not register service\n"); + } catch(Error e) { + stderr.printf("Could not register service: %s\n", e.message); } } diff --git a/src/pdf-invoice/pdf-invoice-interface.vala b/src/pdf-invoice/pdf-invoice-interface.vala index 8fccbf0..41abc6d 100644 --- a/src/pdf-invoice/pdf-invoice-interface.vala +++ b/src/pdf-invoice/pdf-invoice-interface.vala @@ -43,6 +43,6 @@ public interface PDFInvoice : Object { public abstract InvoiceRecipient invoice_recipient { set; owned get; } public abstract InvoiceEntry[] invoice_entries { set; owned get; } - public abstract uint8[] generate() throws IOError, InvoicePDFError; - public abstract void clear() throws IOError; + public abstract uint8[] generate() throws DBusError, IOError, InvoicePDFError; + public abstract void clear() throws DBusError, IOError; } diff --git a/src/pdf-invoice/pdf-invoice.vala b/src/pdf-invoice/pdf-invoice.vala index 6fd4383..a5696b1 100644 --- a/src/pdf-invoice/pdf-invoice.vala +++ b/src/pdf-invoice/pdf-invoice.vala @@ -65,7 +65,7 @@ public class InvoicePDF { string longname; string vat; - public InvoicePDF(string datadir) { + public InvoicePDF(string datadir) throws DBusError, IOError, KeyFileError { this.datadir = datadir; cfg = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config"); longname = cfg.get_string("GENERAL", "longname"); @@ -96,7 +96,7 @@ public class InvoicePDF { ctx.restore(); } - private void draw_address(Cairo.Context ctx) { + private void draw_address(Cairo.Context ctx) throws DBusError, IOError, KeyFileError { ctx.save(); ctx.set_source_rgb(0, 0, 0); ctx.set_line_width(1.0); @@ -206,7 +206,7 @@ public class InvoicePDF { ctx.restore(); } - private void draw_footer_text_left(Cairo.Context ctx) { + private void draw_footer_text_left(Cairo.Context ctx) throws DBusError, IOError, KeyFileError { ctx.save(); ctx.move_to(64.0, 742.0); ctx.set_source_rgb(0, 0, 0); @@ -242,7 +242,7 @@ public class InvoicePDF { ctx.restore(); } - private void draw_footer_text_middle(Cairo.Context ctx) { + private void draw_footer_text_middle(Cairo.Context ctx) throws DBusError, IOError, KeyFileError { ctx.save(); ctx.move_to(216.5, 742.0); ctx.set_source_rgb(0, 0, 0); @@ -278,7 +278,7 @@ public class InvoicePDF { ctx.restore(); } - private void draw_footer_text_right(Cairo.Context ctx) { + private void draw_footer_text_right(Cairo.Context ctx) throws DBusError, IOError, KeyFileError { ctx.save(); ctx.move_to(410.0, 742.0); ctx.set_source_rgb(0, 0, 0); @@ -331,7 +331,7 @@ public class InvoicePDF { return "Moin"; } - private void draw_first_page_text(Cairo.Context ctx) { + private void draw_first_page_text(Cairo.Context ctx) throws IOError { ctx.save(); ctx.move_to(56.5, 352.5); ctx.set_source_rgb(0, 0, 0); @@ -616,7 +616,7 @@ public class InvoicePDF { return Cairo.Status.SUCCESS; } - public uint8[] generate() throws InvoicePDFError { + public uint8[] generate() throws DBusError, IOError, InvoicePDFError, KeyFileError { data = null; var document = new Cairo.PdfSurface.for_stream(pdf_write, width, height); @@ -657,7 +657,7 @@ public class InvoicePDF { return data; } - public void clear() { + public void clear() throws DBusError, IOError { invoice_date = 0; invoice_id = ""; invoice_recipient.firstname = ""; diff --git a/src/pdf-stock/pdf-stock-interface.vala b/src/pdf-stock/pdf-stock-interface.vala index 415916f..5168250 100644 --- a/src/pdf-stock/pdf-stock-interface.vala +++ b/src/pdf-stock/pdf-stock-interface.vala @@ -15,5 +15,5 @@ [DBus (name = "io.mainframe.shopsystem.StockPDF")] public interface PDFStock : Object { - public abstract uint8[] generate() throws IOError; + public abstract uint8[] generate() throws DBusError, IOError; } diff --git a/src/pdf-stock/pdf-stock.vala b/src/pdf-stock/pdf-stock.vala index 1d16e4a..2edba88 100644 --- a/src/pdf-stock/pdf-stock.vala +++ b/src/pdf-stock/pdf-stock.vala @@ -154,7 +154,7 @@ public class StockPDF { return Cairo.Status.SUCCESS; } - public uint8[] generate() { + public uint8[] generate() throws DBusError, IOError { data = null; var surface = new Cairo.PdfSurface.for_stream(pdf_write, a4w, a4h); diff --git a/src/pgp/main.vala b/src/pgp/main.vala index c866c7b..332bcd5 100644 --- a/src/pgp/main.vala +++ b/src/pgp/main.vala @@ -24,6 +24,8 @@ public static int main(string[] args) { try { cfg = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config"); pgp = new PGPKeyArchive(cfg.get_string("PGP", "keyring")); + } catch(DBusError e) { + error("DBusError: %s\n", e.message); } catch(IOError e) { error("IOError: %s\n", e.message); } catch(KeyFileError e) { diff --git a/src/pgp/pgp-interface.vala b/src/pgp/pgp-interface.vala index 62bfe67..2621fae 100644 --- a/src/pgp/pgp-interface.vala +++ b/src/pgp/pgp-interface.vala @@ -15,7 +15,7 @@ [DBus (name = "io.mainframe.shopsystem.PGP")] public interface PGP : Object { - public abstract string[] import_archive(uint8[] data) throws IOError; - public abstract string[] list_keys() throws IOError; - public abstract string get_key(string fingerprint) throws IOError; + public abstract string[] import_archive(uint8[] data) throws IOError, DBusError; + public abstract string[] list_keys() throws IOError, DBusError; + public abstract string get_key(string fingerprint) throws IOError, DBusError; } diff --git a/src/pgp/pgp.vala b/src/pgp/pgp.vala index bb48c61..560b00f 100644 --- a/src/pgp/pgp.vala +++ b/src/pgp/pgp.vala @@ -42,7 +42,7 @@ public class PGPKeyArchive { gpg.set_armor(true); } - public string[] import_archive(uint8[] data) { + public string[] import_archive(uint8[] data) throws DBusError, IOError { string[] result = {}; unowned Archive.Entry entry; var archive = new Archive.Read(); @@ -93,7 +93,7 @@ public class PGPKeyArchive { return result; } - public string[] list_keys() { + public string[] list_keys() throws DBusError, IOError { string[] result = {}; GPG.Key key; @@ -108,7 +108,7 @@ public class PGPKeyArchive { return result; } - public string get_key(string fingerprint) { + public string get_key(string fingerprint) throws DBusError, IOError { GPG.Data keydata; GPG.Data.create(out keydata); diff --git a/src/scanner-session/scannersession.vala b/src/scanner-session/scannersession.vala index 7cc9cc4..c1b513e 100644 --- a/src/scanner-session/scannersession.vala +++ b/src/scanner-session/scannersession.vala @@ -56,7 +56,7 @@ public class ScannerSessionImplementation { msg(type, message); } - private bool login(int user) throws IOError { + private bool login(int user) throws DBusError, IOError { this.user = user; try { this.name = db.get_username(user); @@ -79,7 +79,7 @@ public class ScannerSessionImplementation { return true; } - private ScannerSessionCodeType getCodeType(string scannerdata){ + private ScannerSessionCodeType getCodeType(string scannerdata) { if(scannerdata.has_prefix("USER ")){ return ScannerSessionCodeType.USER; } else if(scannerdata == "GUEST") { @@ -103,7 +103,7 @@ public class ScannerSessionImplementation { } } - private void play_audio(AudioType audioType){ + private void play_audio(AudioType audioType) throws DBusError, IOError { switch (audioType) { case AudioType.ERROR: audio.play_system("error.ogg"); @@ -123,7 +123,7 @@ public class ScannerSessionImplementation { } } - private ScannerResult handleReadyState(string scannerdata) throws DatabaseError, IOError{ + private ScannerResult handleReadyState(string scannerdata) throws DatabaseError, DBusError, IOError { ScannerSessionCodeType codeType = getCodeType(scannerdata); ScannerResult scannerResult = ScannerResult(); switch (codeType) { @@ -199,7 +199,7 @@ public class ScannerSessionImplementation { } } - private ScannerResult handleUserState(string scannerdata) throws DatabaseError, IOError { + private ScannerResult handleUserState(string scannerdata) throws DatabaseError, DBusError, IOError { ScannerSessionCodeType codeType = getCodeType(scannerdata); ScannerResult scannerResult = ScannerResult(); switch (codeType) { @@ -268,7 +268,7 @@ public class ScannerSessionImplementation { return scannerResult; } - private ScannerResult buyShoppingCard() { + private ScannerResult buyShoppingCard() throws DatabaseError, DBusError, IOError { ScannerResult scannerResult = ScannerResult(); uint8 amountOfItems = 0; Price totalPrice = 0; @@ -295,6 +295,8 @@ public class ScannerSessionImplementation { stdout.printf("scannerdata: %s\n", scannerdata); if(interpret(scannerdata)) devScanner.blink(1000); + } catch(DBusError e) { + send_message(MessageType.ERROR, "DBusError: %s", e.message); } catch(IOError e) { send_message(MessageType.ERROR, "IOError: %s", e.message); } catch(DatabaseError e) { @@ -302,7 +304,7 @@ public class ScannerSessionImplementation { } } - private bool interpret(string scannerdata) throws DatabaseError, IOError { + private bool interpret(string scannerdata) throws DatabaseError, DBusError, IOError { ScannerResult scannerResult = ScannerResult(); switch (state) { case ScannerSessionState.READY: @@ -321,7 +323,7 @@ public class ScannerSessionImplementation { return true; } - private ScannerResult logout() { + private ScannerResult logout() throws DatabaseError, DBusError, IOError { ScannerResult scannerResult = ScannerResult(); scannerResult = buyShoppingCard(); logged_in = false; diff --git a/src/serial-device/main.vala b/src/serial-device/main.vala index 70d50e2..d8dadf3 100644 --- a/src/serial-device/main.vala +++ b/src/serial-device/main.vala @@ -23,6 +23,8 @@ public static int main(string[] args) { error("IOError: %s\n", e.message); } catch(KeyFileError e) { error("Config Error: %s\n", e.message); + } catch(DBusError e) { + error("DBus Error: %s\n", e.message); } Bus.own_name( diff --git a/src/serial-device/serial-device.vala b/src/serial-device/serial-device.vala index 549cd74..ae7480b 100644 --- a/src/serial-device/serial-device.vala +++ b/src/serial-device/serial-device.vala @@ -272,7 +272,7 @@ public class Device { /** * @param duration duration of the blink in 0.1 seconds */ - public void blink(uint duration) { + public void blink(uint duration) throws IOError, DBusError { uint size = (byterate/1000) * duration; var msg = new uint8[size]; Posix.memset(msg, 0xFF, msg.length); diff --git a/src/web/csv.vala b/src/web/csv.vala index 5d4daba..6356f77 100644 --- a/src/web/csv.vala +++ b/src/web/csv.vala @@ -17,7 +17,7 @@ public class CSVMemberFile { private UserInfo[] members; - public Gee.List missing_unblocked_members() throws DatabaseError, IOError { + public Gee.List missing_unblocked_members() throws DatabaseError, IOError, DBusError { var result = new Gee.ArrayList(); var dbusers = db.get_member_ids(); diff --git a/src/web/main.vala b/src/web/main.vala index 7070e66..e249d81 100644 --- a/src/web/main.vala +++ b/src/web/main.vala @@ -44,6 +44,8 @@ public static int main(string[] args) { error("IOError: %s\n", e.message); } catch(KeyFileError e) { error("KeyFileError: %s\n", e.message); + } catch(DBusError e) { + error("DBusError: %s\n", e.message); } stdout.printf("Web Server Port: %u\n", port); diff --git a/src/web/web.vala b/src/web/web.vala index f4207ad..9280fef 100644 --- a/src/web/web.vala +++ b/src/web/web.vala @@ -34,6 +34,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -54,6 +56,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -123,6 +127,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -177,6 +183,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -282,6 +290,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -322,6 +332,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -409,6 +421,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -527,6 +541,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -594,6 +610,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -627,6 +645,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -650,6 +670,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -731,6 +753,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -782,6 +806,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -840,6 +866,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -886,6 +914,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -919,6 +949,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -967,6 +999,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -1139,6 +1173,8 @@ public class WebServer { } catch(IOError e) { stderr.printf(e.message+"\n"); handler_400_fallback(server, msg, path, query, client); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -1163,6 +1199,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -1182,6 +1220,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -1230,6 +1270,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -1302,6 +1344,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } @@ -1328,6 +1372,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } } @@ -1409,6 +1455,8 @@ public class WebServer { handler_400(server, msg, path, query, client, e.message); } catch(IOError e) { handler_400(server, msg, path, query, client, e.message); + } catch(DBusError e) { + handler_400(server, msg, path, query, client, e.message); } } diff --git a/src/web/websession.vala b/src/web/websession.vala index ae3cafc..839d0a2 100644 --- a/src/web/websession.vala +++ b/src/web/websession.vala @@ -82,7 +82,7 @@ public class WebSession { return result; } - private void setup_auth(int user) throws DatabaseError, IOError { + private void setup_auth(int user) throws DatabaseError, IOError, DBusError { var auth = db.get_user_auth(user); this.disabled = db.user_is_disabled(user); this.superuser = auth.superuser; @@ -92,7 +92,7 @@ public class WebSession { this.logged_in = true; } - public void logout() throws DatabaseError, IOError { + public void logout() throws DatabaseError, IOError, DBusError { if(logged_in) { db.set_sessionid(user, ""); superuser = false; @@ -103,7 +103,7 @@ public class WebSession { } } - public WebSession(Soup.Server server, Soup.Message msg, string path, GLib.HashTable? query, Soup.ClientContext client) throws DatabaseError, IOError { + public WebSession(Soup.Server server, Soup.Message msg, string path, GLib.HashTable? query, Soup.ClientContext client) throws DatabaseError, IOError, DBusError { var cookies = Soup.cookies_from_request(msg); /* Check for existing session */ -- cgit v1.2.3