diff --git a/src/system_daemon.vala b/src/system_daemon.vala index 9d3d97aeb666a604af8fe7ba0a3fdf2c6c8a190c..61f93e2e534e33fca778d4b2f6b1e5c7726ae310 100644 --- a/src/system_daemon.vala +++ b/src/system_daemon.vala @@ -114,7 +114,7 @@ namespace Pamac { refreshed = false; } - public void set_environment_variables (HashTable<string,string> variables) { + public void set_environment_variables (HashTable<string,string> variables) throws Error { string[] keys = { "HTTP_USER_AGENT", "http_proxy", "https_proxy", @@ -129,7 +129,7 @@ namespace Pamac { } } - public ErrorInfos get_current_error () { + public ErrorInfos get_current_error () throws Error { return current_error; } @@ -246,7 +246,7 @@ namespace Pamac { return true; } - public bool get_lock (GLib.BusName sender) { + public bool get_lock (GLib.BusName sender) throws Error { if (lock_id == sender) { return true; } else if (lock_id == "") { @@ -256,7 +256,7 @@ namespace Pamac { return false; } - public bool unlock (GLib.BusName sender) { + public bool unlock (GLib.BusName sender) throws Error { if (lock_id == sender) { lock_id = new BusName (""); return true; @@ -291,14 +291,14 @@ namespace Pamac { return authorized; } - public void start_get_authorization (GLib.BusName sender) { + public void start_get_authorization (GLib.BusName sender) throws Error { check_authorization.begin (sender, (obj, res) => { bool authorized = check_authorization.end (res); get_authorization_finished (authorized); }); } - public void start_write_pamac_config (HashTable<string,Variant> new_pamac_conf, GLib.BusName sender) { + public void start_write_pamac_config (HashTable<string,Variant> new_pamac_conf, GLib.BusName sender) throws Error { check_authorization.begin (sender, (obj, res) => { var pamac_config = new Pamac.Config ("/etc/pamac.conf"); bool authorized = check_authorization.end (res); @@ -318,7 +318,7 @@ namespace Pamac { write_alpm_config_finished ((alpm_handle.checkspace == 1)); } - public void start_write_alpm_config (HashTable<string,Variant> new_alpm_conf_, GLib.BusName sender) { + public void start_write_alpm_config (HashTable<string,Variant> new_alpm_conf_, GLib.BusName sender) throws Error { check_authorization.begin (sender, (obj, res) => { bool authorized = check_authorization.end (res); if (authorized ) { @@ -352,7 +352,7 @@ namespace Pamac { generate_mirrors_list_finished (); } - public void start_generate_mirrors_list (string country, GLib.BusName sender) { + public void start_generate_mirrors_list (string country, GLib.BusName sender) throws Error { check_authorization.begin (sender, (obj, res) => { bool authorized = check_authorization.end (res); if (authorized) { @@ -366,7 +366,7 @@ namespace Pamac { }); } - public void clean_cache (uint64 keep_nb, bool only_uninstalled, GLib.BusName sender) { + public void clean_cache (uint64 keep_nb, bool only_uninstalled, GLib.BusName sender) throws Error { check_authorization.begin (sender, (obj, res) => { bool authorized = check_authorization.end (res); if (authorized) { @@ -386,7 +386,7 @@ namespace Pamac { }); } - public void start_set_pkgreason (string pkgname, uint reason, GLib.BusName sender) { + public void start_set_pkgreason (string pkgname, uint reason, GLib.BusName sender) throws Error { check_authorization.begin (sender, (obj, res) => { bool authorized = check_authorization.end (res); if (authorized) { @@ -463,7 +463,7 @@ namespace Pamac { } } - public void start_refresh (bool force, GLib.BusName sender) { + public void start_refresh (bool force, GLib.BusName sender) throws Error { if (lock_id != sender) { refresh_finished (false); return; @@ -807,7 +807,7 @@ namespace Pamac { return aur_updates_infos; } - public void start_get_updates (bool check_aur_updates_) { + public void start_get_updates (bool check_aur_updates_) throws Error { check_aur_updates = check_aur_updates_; try { thread_pool.add (new AlpmAction (get_updates)); @@ -843,7 +843,7 @@ namespace Pamac { if (errno != 0) { current_error.details = { Alpm.strerror (errno) }; } - trans_release (lock_id); + trans_release_private (); success = false; } else { success = trans_prepare_real (); @@ -852,7 +852,7 @@ namespace Pamac { trans_prepare_finished (success); } - public void start_sysupgrade_prepare (bool enable_downgrade_, string[] temporary_ignorepkgs_, GLib.BusName sender) { + public void start_sysupgrade_prepare (bool enable_downgrade_, string[] temporary_ignorepkgs_, GLib.BusName sender) throws Error { if (lock_id != sender) { trans_prepare_finished (false); return; @@ -1067,7 +1067,7 @@ namespace Pamac { break; } current_error.details = (owned) details; - trans_release (lock_id); + trans_release_private (); success = false; } else { // Search for holdpkg in target list @@ -1085,7 +1085,7 @@ namespace Pamac { if (found_locked_pkg) { current_error.message = _("Failed to prepare transaction"); current_error.details = (owned) details; - trans_release (lock_id); + trans_release_private (); success = false; } } @@ -1120,7 +1120,7 @@ namespace Pamac { if (success) { success = trans_prepare_real (); } else { - trans_release (lock_id); + trans_release_private (); } } trans_prepare_finished (success); @@ -1281,7 +1281,7 @@ namespace Pamac { } pkgs_to_remove.next (); } - trans_release (lock_id); + trans_release_private (); try { Process.spawn_command_line_sync ("rm -f %ssync/aur.db".printf (alpm_handle.dbpath)); } catch (SpawnError e) { @@ -1294,7 +1294,7 @@ namespace Pamac { trans_prepare (); } } else { - trans_release (lock_id); + trans_release_private (); } } if (!success) { @@ -1310,7 +1310,7 @@ namespace Pamac { string[] to_remove_, string[] to_load_, string[] to_build_, - GLib.BusName sender) { + GLib.BusName sender) throws Error { if (lock_id != sender) { trans_prepare_finished (false); return; @@ -1339,14 +1339,14 @@ namespace Pamac { } } - public void choose_provider (int provider) { + public void choose_provider (int provider) throws Error { provider_mutex.lock (); choosen_provider = provider; provider_cond.signal (); provider_mutex.unlock (); } - public TransactionSummary get_transaction_summary () { + public TransactionSummary get_transaction_summary () throws Error { UpdateInfos[] to_install = {}; UpdateInfos[] to_upgrade = {}; UpdateInfos[] to_downgrade = {}; @@ -1421,7 +1421,7 @@ namespace Pamac { current_error.errno = (uint) errno; // cancel the download return an EXTERNAL_DOWNLOAD error if (errno == Alpm.Errno.EXTERNAL_DOWNLOAD && cancellable.is_cancelled ()) { - trans_release (lock_id); + trans_release_private (); trans_commit_finished (false); return; } @@ -1476,7 +1476,7 @@ namespace Pamac { } success = false; } - trans_release (lock_id); + trans_release_private (); to_install_as_dep.foreach_remove ((pkgname, val) => { unowned Alpm.Package? pkg = alpm_handle.localdb.get_pkg (pkgname); if (pkg != null) { @@ -1488,7 +1488,7 @@ namespace Pamac { trans_commit_finished (success); } - public void start_trans_commit (GLib.BusName sender) { + public void start_trans_commit (GLib.BusName sender) throws Error { check_authorization.begin (sender, (obj, res) => { bool authorized = check_authorization.end (res); if (authorized) { @@ -1498,21 +1498,25 @@ namespace Pamac { stderr.printf ("Thread Error %s\n", e.message); } } else { - trans_release (lock_id); + trans_release_private (); trans_commit_finished (false); } }); } - public void trans_release (GLib.BusName sender) { + private void trans_release_private () { + alpm_handle.trans_release (); + remove_ignorepkgs (); + } + + public void trans_release (GLib.BusName sender) throws Error { if (lock_id != sender) { return; } - alpm_handle.trans_release (); - remove_ignorepkgs (); + trans_release_private (); } - public void trans_cancel (GLib.BusName sender) { + public void trans_cancel (GLib.BusName sender) throws Error { if (lock_id != sender) { return; } @@ -1525,7 +1529,7 @@ namespace Pamac { } [DBus (no_reply = true)] - public void quit () { + public void quit () throws Error { // wait for all tasks to be processed ThreadPool.free ((owned) thread_pool, false, true); loop.quit (); @@ -1700,7 +1704,7 @@ private void cb_progress (Alpm.Progress progress, string pkgname, int percent, u } else if (percent == 100) { system_daemon.emit_progress ((uint) progress, pkgname, (uint) percent, n_targets, current_target); system_daemon.timer.stop (); - }else if (system_daemon.timer.elapsed () < 0.5) { + } else if (system_daemon.timer.elapsed () < 0.5) { return; } else { system_daemon.emit_progress ((uint) progress, pkgname, (uint) percent, n_targets, current_target); diff --git a/src/transaction.vala b/src/transaction.vala index 1c858fa2eb8c0b67ad38182c48a9243d4a05866f..3f80958eae7c229c70df7cd0d1c1a5e907a4dc1e 100644 --- a/src/transaction.vala +++ b/src/transaction.vala @@ -20,64 +20,64 @@ namespace Pamac { [DBus (name = "org.manjaro.pamac.user")] interface UserDaemon : Object { - public abstract void refresh_handle () throws IOError; - public abstract string[] get_mirrors_countries () throws IOError; - public abstract string get_mirrors_choosen_country () throws IOError; - public abstract string get_lockfile () throws IOError; - public abstract AlpmPackage get_installed_pkg (string pkgname) throws IOError; - public abstract bool get_checkspace () throws IOError; - public abstract string[] get_ignorepkgs () throws IOError; - public abstract bool should_hold (string pkgname) throws IOError; - public abstract uint get_pkg_reason (string pkgname) throws IOError; - public abstract uint get_pkg_origin (string pkgname) throws IOError; - public abstract async AlpmPackage[] get_installed_pkgs () throws IOError; - public abstract async AlpmPackage[] get_installed_apps () throws IOError; - public abstract async AlpmPackage[] get_explicitly_installed_pkgs () throws IOError; - public abstract async AlpmPackage[] get_foreign_pkgs () throws IOError; - public abstract async AlpmPackage[] get_orphans () throws IOError; - public abstract AlpmPackage find_installed_satisfier (string depstring) throws IOError; - public abstract AlpmPackage get_sync_pkg (string pkgname) throws IOError; - public abstract AlpmPackage find_sync_satisfier (string depstring) throws IOError; - public abstract async AlpmPackage[] search_pkgs (string search_string) throws IOError; - public abstract async AURPackage[] search_in_aur (string search_string) throws IOError; - public abstract async AlpmPackage[] get_category_pkgs (string category) throws IOError; - public abstract string[] get_repos_names () throws IOError; - public abstract async AlpmPackage[] get_repo_pkgs (string repo) throws IOError; - public abstract string[] get_groups_names () throws IOError; - public abstract async AlpmPackage[] get_group_pkgs (string groupname) throws IOError; - public abstract AlpmPackageDetails get_pkg_details (string pkgname, string app_name) throws IOError; - public abstract string[] get_pkg_files (string pkgname) throws IOError; - public abstract async AURPackageDetails get_aur_details (string pkgname) throws IOError; - public abstract string[] get_pkg_uninstalled_optdeps (string pkgname) throws IOError; - public abstract void start_get_updates (bool check_aur_updates) throws IOError; + public abstract void refresh_handle () throws Error; + public abstract string[] get_mirrors_countries () throws Error; + public abstract string get_mirrors_choosen_country () throws Error; + public abstract string get_lockfile () throws Error; + public abstract AlpmPackage get_installed_pkg (string pkgname) throws Error; + public abstract bool get_checkspace () throws Error; + public abstract string[] get_ignorepkgs () throws Error; + public abstract bool should_hold (string pkgname) throws Error; + public abstract uint get_pkg_reason (string pkgname) throws Error; + public abstract uint get_pkg_origin (string pkgname) throws Error; + public abstract async AlpmPackage[] get_installed_pkgs () throws Error; + public abstract async AlpmPackage[] get_installed_apps () throws Error; + public abstract async AlpmPackage[] get_explicitly_installed_pkgs () throws Error; + public abstract async AlpmPackage[] get_foreign_pkgs () throws Error; + public abstract async AlpmPackage[] get_orphans () throws Error; + public abstract AlpmPackage find_installed_satisfier (string depstring) throws Error; + public abstract AlpmPackage get_sync_pkg (string pkgname) throws Error; + public abstract AlpmPackage find_sync_satisfier (string depstring) throws Error; + public abstract async AlpmPackage[] search_pkgs (string search_string) throws Error; + public abstract async AURPackage[] search_in_aur (string search_string) throws Error; + public abstract async AlpmPackage[] get_category_pkgs (string category) throws Error; + public abstract string[] get_repos_names () throws Error; + public abstract async AlpmPackage[] get_repo_pkgs (string repo) throws Error; + public abstract string[] get_groups_names () throws Error; + public abstract async AlpmPackage[] get_group_pkgs (string groupname) throws Error; + public abstract AlpmPackageDetails get_pkg_details (string pkgname, string app_name) throws Error; + public abstract string[] get_pkg_files (string pkgname) throws Error; + public abstract async AURPackageDetails get_aur_details (string pkgname) throws Error; + public abstract string[] get_pkg_uninstalled_optdeps (string pkgname) throws Error; + public abstract void start_get_updates (bool check_aur_updates) throws Error; [DBus (no_reply = true)] - public abstract void quit () throws IOError; + public abstract void quit () throws Error; public signal void emit_get_updates_progress (uint percent); public signal void get_updates_finished (Updates updates); } [DBus (name = "org.manjaro.pamac.system")] interface SystemDaemon : Object { - public abstract void set_environment_variables (HashTable<string,string> variables) throws IOError; - public abstract ErrorInfos get_current_error () throws IOError; - public abstract bool get_lock () throws IOError; - public abstract bool unlock () throws IOError; - public abstract void start_get_authorization () throws IOError; - public abstract void start_write_pamac_config (HashTable<string,Variant> new_pamac_conf) throws IOError; - public abstract void start_write_alpm_config (HashTable<string,Variant> new_alpm_conf) throws IOError; - public abstract void start_generate_mirrors_list (string country) throws IOError; - public abstract void clean_cache (uint64 keep_nb, bool only_uninstalled) throws IOError; - public abstract void start_set_pkgreason (string pkgname, uint reason) throws IOError; - public abstract void start_refresh (bool force) throws IOError; - public abstract void start_sysupgrade_prepare (bool enable_downgrade, string[] temporary_ignorepkgs) throws IOError; - public abstract void start_trans_prepare (int transflags, string[] to_install, string[] to_remove, string[] to_load, string[] to_build) throws IOError; - public abstract void choose_provider (int provider) throws IOError; - public abstract TransactionSummary get_transaction_summary () throws IOError; - public abstract void start_trans_commit () throws IOError; - public abstract void trans_release () throws IOError; - public abstract void trans_cancel () throws IOError; - public abstract void start_get_updates (bool check_aur_updates) throws IOError; + public abstract void set_environment_variables (HashTable<string,string> variables) throws Error; + public abstract ErrorInfos get_current_error () throws Error; + public abstract bool get_lock () throws Error; + public abstract bool unlock () throws Error; + public abstract void start_get_authorization () throws Error; + public abstract void start_write_pamac_config (HashTable<string,Variant> new_pamac_conf) throws Error; + public abstract void start_write_alpm_config (HashTable<string,Variant> new_alpm_conf) throws Error; + public abstract void start_generate_mirrors_list (string country) throws Error; + public abstract void clean_cache (uint64 keep_nb, bool only_uninstalled) throws Error; + public abstract void start_set_pkgreason (string pkgname, uint reason) throws Error; + public abstract void start_refresh (bool force) throws Error; + public abstract void start_sysupgrade_prepare (bool enable_downgrade, string[] temporary_ignorepkgs) throws Error; + public abstract void start_trans_prepare (int transflags, string[] to_install, string[] to_remove, string[] to_load, string[] to_build) throws Error; + public abstract void choose_provider (int provider) throws Error; + public abstract TransactionSummary get_transaction_summary () throws Error; + public abstract void start_trans_commit () throws Error; + public abstract void trans_release () throws Error; + public abstract void trans_cancel () throws Error; + public abstract void start_get_updates (bool check_aur_updates) throws Error; [DBus (no_reply = true)] - public abstract void quit () throws IOError; + public abstract void quit () throws Error; public signal void get_updates_finished (Updates updates); public signal void emit_event (uint primary_event, uint secondary_event, string[] details); public signal void emit_providers (string depend, string[] providers); @@ -265,8 +265,8 @@ namespace Pamac { public ErrorInfos get_current_error () { try { return system_daemon.get_current_error (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); return ErrorInfos (); } } @@ -275,8 +275,8 @@ namespace Pamac { string[] countries = {}; try { countries = user_daemon.get_mirrors_countries (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return countries; } @@ -285,8 +285,8 @@ namespace Pamac { string country = ""; try { country = user_daemon.get_mirrors_choosen_country (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return country; } @@ -296,8 +296,8 @@ namespace Pamac { connecting_system_daemon (); try { locked = system_daemon.get_lock (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return locked; } @@ -306,8 +306,8 @@ namespace Pamac { bool unlocked = false; try { unlocked = system_daemon.unlock (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return unlocked; } @@ -321,8 +321,8 @@ namespace Pamac { }); try { system_daemon.start_get_authorization (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } yield; system_daemon.disconnect (handler_id); @@ -333,8 +333,8 @@ namespace Pamac { try { system_daemon.write_pamac_config_finished.connect (on_write_pamac_config_finished); system_daemon.start_write_pamac_config (new_pamac_conf); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); system_daemon.write_pamac_config_finished.disconnect (on_write_pamac_config_finished); } } @@ -343,8 +343,8 @@ namespace Pamac { try { system_daemon.write_alpm_config_finished.connect (on_write_alpm_config_finished); system_daemon.start_write_alpm_config (new_alpm_conf); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); system_daemon.write_alpm_config_finished.disconnect (on_write_alpm_config_finished); } } @@ -399,8 +399,8 @@ namespace Pamac { } } catch (Error e) { // cancelled - process.send_signal (Posix.SIGINT); - process.send_signal (Posix.SIGKILL); + process.send_signal (Posix.Signal.INT); + process.send_signal (Posix.Signal.KILL); } } catch (Error e) { stderr.printf ("Error: %s\n", e.message); @@ -439,8 +439,8 @@ namespace Pamac { system_daemon.generate_mirrors_list_data.connect (on_generate_mirrors_list_data); system_daemon.generate_mirrors_list_finished.connect (on_generate_mirrors_list_finished); system_daemon.start_generate_mirrors_list (country); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); stop_progressbar_pulse (); system_daemon.generate_mirrors_list_data.disconnect (on_generate_mirrors_list_data); system_daemon.generate_mirrors_list_finished.disconnect (on_generate_mirrors_list_finished); @@ -450,8 +450,8 @@ namespace Pamac { public void clean_cache (uint64 keep_nb, bool only_uninstalled) { try { system_daemon.clean_cache (keep_nb, only_uninstalled); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } } @@ -459,8 +459,8 @@ namespace Pamac { try { system_daemon.set_pkgreason_finished.connect (on_set_pkgreason_finished); system_daemon.start_set_pkgreason (pkgname, reason); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); system_daemon.set_pkgreason_finished.disconnect (on_set_pkgreason_finished); } } @@ -476,8 +476,8 @@ namespace Pamac { try { system_daemon.refresh_finished.connect (on_refresh_finished); system_daemon.start_refresh (force); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); system_daemon.refresh_finished.disconnect (on_refresh_finished); success = false; finish_transaction (); @@ -493,16 +493,16 @@ namespace Pamac { try { user_daemon.refresh_handle (); get_lockfile (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } } void get_lockfile () { try { lockfile = GLib.File.new_for_path (user_daemon.get_lockfile ()); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); //try standard lock file lockfile = GLib.File.new_for_path ("var/lib/pacman/db.lck"); } @@ -512,8 +512,8 @@ namespace Pamac { bool checkspace = false; try { checkspace = user_daemon.get_checkspace (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return checkspace; } @@ -522,8 +522,8 @@ namespace Pamac { string[] ignorepkgs = {}; try { ignorepkgs = user_daemon.get_ignorepkgs (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return ignorepkgs; } @@ -531,8 +531,8 @@ namespace Pamac { public AlpmPackage get_installed_pkg (string pkgname) { try { return user_daemon.get_installed_pkg (pkgname); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); return AlpmPackage () { name = "", version = "", @@ -545,8 +545,8 @@ namespace Pamac { public AlpmPackage find_installed_satisfier (string depstring) { try { return user_daemon.find_installed_satisfier (depstring); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); return AlpmPackage () { name = "", version = "", @@ -560,8 +560,8 @@ namespace Pamac { bool should_hold = false; try { should_hold = user_daemon.should_hold (pkgname); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return should_hold; } @@ -570,8 +570,8 @@ namespace Pamac { uint reason = 0; try { reason = user_daemon.get_pkg_reason (pkgname); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return reason; } @@ -580,8 +580,8 @@ namespace Pamac { uint origin = 0; try { origin = user_daemon.get_pkg_origin (pkgname); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return origin; } @@ -590,8 +590,8 @@ namespace Pamac { AlpmPackage[] pkgs = {}; try { pkgs = yield user_daemon.get_installed_pkgs (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return pkgs; } @@ -600,8 +600,8 @@ namespace Pamac { AlpmPackage[] pkgs = {}; try { pkgs = yield user_daemon.get_installed_apps (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return pkgs; } @@ -610,8 +610,8 @@ namespace Pamac { AlpmPackage[] pkgs = {}; try { pkgs = yield user_daemon.get_explicitly_installed_pkgs (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return pkgs; } @@ -620,8 +620,8 @@ namespace Pamac { AlpmPackage[] pkgs = {}; try { pkgs = yield user_daemon.get_foreign_pkgs (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return pkgs; } @@ -630,8 +630,8 @@ namespace Pamac { AlpmPackage[] pkgs = {}; try { pkgs = yield user_daemon.get_orphans (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return pkgs; } @@ -639,8 +639,8 @@ namespace Pamac { public AlpmPackage get_sync_pkg (string pkgname) { try { return user_daemon.get_sync_pkg (pkgname); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); return AlpmPackage () { name = "", version = "", @@ -653,8 +653,8 @@ namespace Pamac { public AlpmPackage find_sync_satisfier (string depstring) { try { return user_daemon.find_sync_satisfier (depstring); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); return AlpmPackage () { name = "", version = "", @@ -668,8 +668,8 @@ namespace Pamac { AlpmPackage[] pkgs = {}; try { pkgs = yield user_daemon.search_pkgs (search_string); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return pkgs; } @@ -678,8 +678,8 @@ namespace Pamac { AURPackage[] pkgs = {}; try { pkgs = yield user_daemon.search_in_aur (search_string); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return pkgs; } @@ -688,8 +688,8 @@ namespace Pamac { AlpmPackage[] pkgs = {}; try { pkgs = yield user_daemon.get_category_pkgs (category); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return pkgs; } @@ -698,8 +698,8 @@ namespace Pamac { string[] repos_names = {}; try { repos_names = user_daemon.get_repos_names (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return repos_names; } @@ -708,8 +708,8 @@ namespace Pamac { AlpmPackage[] pkgs = {}; try { pkgs = yield user_daemon.get_repo_pkgs (repo); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return pkgs; } @@ -718,8 +718,8 @@ namespace Pamac { string[] groups_names = {}; try { groups_names = user_daemon.get_groups_names (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return groups_names; } @@ -728,8 +728,8 @@ namespace Pamac { AlpmPackage[] pkgs = {}; try { pkgs = yield user_daemon.get_group_pkgs (group_name); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return pkgs; } @@ -738,8 +738,8 @@ namespace Pamac { string[] optdeps = {}; try { optdeps = user_daemon.get_pkg_uninstalled_optdeps (pkgname); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return optdeps; } @@ -747,8 +747,8 @@ namespace Pamac { public AlpmPackageDetails get_pkg_details (string pkgname, string app_name) { try { return user_daemon.get_pkg_details (pkgname, app_name); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); return AlpmPackageDetails () { name = "", version = "", @@ -767,8 +767,8 @@ namespace Pamac { public string[] get_pkg_files (string pkgname) { try { return user_daemon.get_pkg_files (pkgname); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); return {}; } } @@ -784,8 +784,8 @@ namespace Pamac { }; try { pkg = yield user_daemon.get_aur_details (pkgname); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } return pkg; } @@ -795,8 +795,8 @@ namespace Pamac { user_daemon.get_updates_finished.connect (on_get_updates_finished); try { user_daemon.start_get_updates (pamac_config.enable_aur && pamac_config.check_aur_updates); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); success = false; finish_transaction (); } @@ -806,8 +806,8 @@ namespace Pamac { system_daemon.get_updates_finished.connect (on_get_updates_for_sysupgrade_finished); try { system_daemon.start_get_updates (pamac_config.enable_aur && pamac_config.check_aur_updates); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); success = false; finish_transaction (); } @@ -824,8 +824,8 @@ namespace Pamac { try { // this will respond with trans_prepare_finished signal system_daemon.start_sysupgrade_prepare (enable_downgrade, temporary_ignorepkgs_); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); success = false; finish_transaction (); } @@ -903,8 +903,8 @@ namespace Pamac { void start_trans_prepare (int transflags, string[] to_install, string[] to_remove, string[] to_load, string[] to_build) { try { system_daemon.start_trans_prepare (transflags, to_install, to_remove, to_load, to_build); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); stop_progressbar_pulse (); success = false; finish_transaction (); @@ -963,8 +963,8 @@ namespace Pamac { if (radiobutton.active) { try { system_daemon.choose_provider (index); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } } index++; @@ -984,8 +984,8 @@ namespace Pamac { transaction_sum_dialog.sum_list.clear (); try { summary = system_daemon.get_transaction_summary (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } var iter = Gtk.TreeIter (); if (summary.to_remove.length > 0) { @@ -1105,8 +1105,8 @@ namespace Pamac { void start_commit () { try { system_daemon.start_trans_commit (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); success = false; finish_transaction (); } @@ -1192,8 +1192,8 @@ namespace Pamac { } else { try { system_daemon.trans_cancel (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } } show_in_term ("\n" + dgettext (null, "Transaction cancelled") + ".\n"); @@ -1204,8 +1204,8 @@ namespace Pamac { public void release () { try { system_daemon.trans_release (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } warning_textbuffer = new StringBuilder (); } @@ -1216,8 +1216,8 @@ namespace Pamac { if (system_daemon != null) { system_daemon.quit (); } - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } } @@ -1850,8 +1850,8 @@ namespace Pamac { void connecting_user_daemon () { try { user_daemon = Bus.get_proxy_sync (BusType.SESSION, "org.manjaro.pamac.user", "/org/manjaro/pamac/user"); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } } @@ -1860,8 +1860,8 @@ namespace Pamac { system_daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac.system", "/org/manjaro/pamac/system"); // Set environment variables system_daemon.set_environment_variables (pamac_config.environment_variables); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } } diff --git a/src/tray-gtk.vala b/src/tray-gtk.vala index f5d2a6ad19bd608140023243a17af0cbdaa585ed..a03fa6cc6b624532ca74f02fe5ab5605f68df7e3 100644 --- a/src/tray-gtk.vala +++ b/src/tray-gtk.vala @@ -1,7 +1,7 @@ /* * pamac-vala * - * Copyright (C) 2014-2017 Guillaume Benoit <guillaume@manjaro.org> + * Copyright (C) 2014-2018 Guillaume Benoit <guillaume@manjaro.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,8 +30,8 @@ namespace Pamac { } // Show popup menu on right button - void menu_popup (uint button, uint time) { - menu.popup (null, null, null, button, time); + void menu_popup () { + menu.popup_at_pointer (null); } public override void set_tooltip (string info) { diff --git a/src/tray.vala b/src/tray.vala index edae105347dec09577ccf836fb47ede73cc154b5..29266dd9a97e24af323193f4f091ea4330bba929 100644 --- a/src/tray.vala +++ b/src/tray.vala @@ -27,11 +27,11 @@ const string noupdate_info = _("Your system is up-to-date"); namespace Pamac { [DBus (name = "org.manjaro.pamac.user")] interface UserDaemon : Object { - public abstract void refresh_handle () throws IOError; - public abstract string get_lockfile () throws IOError; - public abstract void start_get_updates (bool check_aur_updates) throws IOError; + public abstract void refresh_handle () throws Error; + public abstract string get_lockfile () throws Error; + public abstract void start_get_updates (bool check_aur_updates) throws Error; [DBus (no_reply = true)] - public abstract void quit () throws IOError; + public abstract void quit () throws Error; public signal void get_updates_finished (Updates updates); } @@ -54,8 +54,8 @@ namespace Pamac { try { daemon = Bus.get_proxy_sync (BusType.SESSION, "org.manjaro.pamac.user", "/org/manjaro/pamac/user"); daemon.get_updates_finished.connect (on_get_updates_finished); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } } @@ -63,8 +63,8 @@ namespace Pamac { if (!check_pamac_running ()) { try { daemon.quit (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } } } @@ -118,8 +118,8 @@ namespace Pamac { if (pamac_config.refresh_period != 0) { try { daemon.start_get_updates (pamac_config.enable_aur && pamac_config.check_aur_updates); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } } return true; @@ -213,8 +213,8 @@ namespace Pamac { extern_lock = false; try { daemon.refresh_handle (); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); } check_updates (); } @@ -265,8 +265,8 @@ namespace Pamac { start_daemon (); try { lockfile = GLib.File.new_for_path (daemon.get_lockfile ()); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); //try standard lock file lockfile = GLib.File.new_for_path ("var/lib/pacman/db.lck"); } diff --git a/src/user_daemon.vala b/src/user_daemon.vala index eee93351c389ac22c6f4e159701c8f3a80c4a316..b054b83be2faf124f637f3e7672aef655d7e3b98 100644 --- a/src/user_daemon.vala +++ b/src/user_daemon.vala @@ -103,7 +103,11 @@ namespace Pamac { aur_updates = {}; aur_search_results = new HashTable<string, Json.Array> (str_hash, str_equal); aur_infos = new HashTable<string, Json.Object> (str_hash, str_equal); - refresh_handle (); + try { + refresh_handle (); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); + } // init appstream app_store = new As.Store (); app_store.set_add_flags (As.StoreAddFlags.USE_UNIQUE_ID @@ -128,7 +132,7 @@ namespace Pamac { } } - public void refresh_handle () { + public void refresh_handle () throws Error { alpm_config.reload (); alpm_handle = alpm_config.get_handle (); if (alpm_handle == null) { @@ -140,7 +144,7 @@ namespace Pamac { aur_updates_checked = false; } - public string[] get_mirrors_countries () { + public string[] get_mirrors_countries () throws Error { string[] countries = {}; try { string countries_str; @@ -162,7 +166,7 @@ namespace Pamac { return countries; } - public string get_mirrors_choosen_country () { + public string get_mirrors_choosen_country () throws Error { string country = ""; try { string countries_str; @@ -181,15 +185,15 @@ namespace Pamac { return country; } - public bool get_checkspace () { + public bool get_checkspace () throws Error { return alpm_handle.checkspace == 1 ? true : false; } - public string get_lockfile () { + public string get_lockfile () throws Error { return alpm_handle.lockfile; } - public string[] get_ignorepkgs () { + public string[] get_ignorepkgs () throws Error { string[] result = {}; unowned Alpm.List<unowned string> ignorepkgs = alpm_handle.ignorepkgs; while (ignorepkgs != null) { @@ -200,14 +204,14 @@ namespace Pamac { return result; } - public bool should_hold (string pkgname) { + public bool should_hold (string pkgname) throws Error { if (alpm_config.get_holdpkgs ().find_custom (pkgname, strcmp) != null) { return true; } return false; } - public uint get_pkg_reason (string pkgname) { + public uint get_pkg_reason (string pkgname) throws Error { unowned Alpm.Package? pkg = alpm_handle.localdb.get_pkg (pkgname); if (pkg != null) { return pkg.reason; @@ -215,7 +219,7 @@ namespace Pamac { return 0; } - public uint get_pkg_origin (string pkgname) { + public uint get_pkg_origin (string pkgname) throws Error { unowned Alpm.Package? pkg = alpm_handle.localdb.get_pkg (pkgname); if (pkg != null) { return pkg.origin; @@ -412,7 +416,7 @@ namespace Pamac { return pkgs; } - public async AlpmPackage[] get_installed_pkgs () { + public async AlpmPackage[] get_installed_pkgs () throws Error { AlpmPackage[] pkgs = {}; unowned Alpm.List<unowned Alpm.Package> pkgcache = alpm_handle.localdb.pkgcache; while (pkgcache != null) { @@ -425,7 +429,7 @@ namespace Pamac { return pkgs; } - public async AlpmPackage[] get_installed_apps () { + public async AlpmPackage[] get_installed_apps () throws Error { AlpmPackage[] pkgs = {}; app_store.get_apps ().foreach ((app) => { unowned string pkgname = app.get_pkgname_default (); @@ -451,7 +455,7 @@ namespace Pamac { return pkgs; } - public async AlpmPackage[] get_explicitly_installed_pkgs () { + public async AlpmPackage[] get_explicitly_installed_pkgs () throws Error { AlpmPackage[] pkgs = {}; unowned Alpm.List<unowned Alpm.Package> pkgcache = alpm_handle.localdb.pkgcache; while (pkgcache != null) { @@ -466,7 +470,7 @@ namespace Pamac { return pkgs; } - public async AlpmPackage[] get_foreign_pkgs () { + public async AlpmPackage[] get_foreign_pkgs () throws Error { AlpmPackage[] pkgs = {}; unowned Alpm.List<unowned Alpm.Package> pkgcache = alpm_handle.localdb.pkgcache; while (pkgcache != null) { @@ -492,7 +496,7 @@ namespace Pamac { return pkgs; } - public async AlpmPackage[] get_orphans () { + public async AlpmPackage[] get_orphans () throws Error { AlpmPackage[] pkgs = {}; unowned Alpm.List<unowned Alpm.Package> pkgcache = alpm_handle.localdb.pkgcache; while (pkgcache != null) { @@ -517,11 +521,11 @@ namespace Pamac { return pkgs; } - public AlpmPackage get_installed_pkg (string pkgname) { + public AlpmPackage get_installed_pkg (string pkgname) throws Error { return initialise_pkg_struct (alpm_handle.localdb.get_pkg (pkgname)); } - public AlpmPackage find_installed_satisfier (string depstring) { + public AlpmPackage find_installed_satisfier (string depstring) throws Error { return initialise_pkg_struct (Alpm.find_satisfier (alpm_handle.localdb.pkgcache, depstring)); } @@ -539,7 +543,7 @@ namespace Pamac { return pkg; } - public AlpmPackage get_sync_pkg (string pkgname) { + public AlpmPackage get_sync_pkg (string pkgname) throws Error { return initialise_pkg_struct (get_syncpkg (pkgname)); } @@ -557,7 +561,7 @@ namespace Pamac { return pkg; } - public AlpmPackage find_sync_satisfier (string depstring) { + public AlpmPackage find_sync_satisfier (string depstring) throws Error { return initialise_pkg_struct (find_dbs_satisfier (depstring)); } @@ -607,7 +611,7 @@ namespace Pamac { return result; } - public async AlpmPackage[] search_pkgs (string search_string) { + public async AlpmPackage[] search_pkgs (string search_string) throws Error { AlpmPackage[] pkgs = {}; Alpm.List<unowned Alpm.Package> alpm_pkgs = search_all_dbs (search_string); unowned Alpm.List<unowned Alpm.Package> list = alpm_pkgs; @@ -637,7 +641,7 @@ namespace Pamac { }; } - public async AURPackage[] search_in_aur (string search_string) { + public async AURPackage[] search_in_aur (string search_string) throws Error { if (!aur_search_results.contains (search_string)) { Json.Array pkgs = yield AUR.search (search_string.split (" ")); aur_search_results.insert (search_string, pkgs); @@ -654,7 +658,7 @@ namespace Pamac { return result; } - public async AURPackageDetails get_aur_details (string pkgname) { + public async AURPackageDetails get_aur_details (string pkgname) throws Error { string name = ""; string version = ""; string desc = ""; @@ -799,7 +803,7 @@ namespace Pamac { return details; } - public string[] get_repos_names () { + public string[] get_repos_names () throws Error { string[] repos_names = {}; unowned Alpm.List<unowned Alpm.DB> syncdbs = alpm_handle.syncdbs; while (syncdbs != null) { @@ -810,7 +814,7 @@ namespace Pamac { return repos_names; } - public async AlpmPackage[] get_repo_pkgs (string repo) { + public async AlpmPackage[] get_repo_pkgs (string repo) throws Error { AlpmPackage[] pkgs = {}; unowned Alpm.List<unowned Alpm.DB> syncdbs = alpm_handle.syncdbs; while (syncdbs != null) { @@ -838,7 +842,7 @@ namespace Pamac { return pkgs; } - public string[] get_groups_names () { + public string[] get_groups_names () throws Error { string[] groups_names = {}; unowned Alpm.List<unowned Alpm.Group> groupcache = alpm_handle.localdb.groupcache; while (groupcache != null) { @@ -894,7 +898,7 @@ namespace Pamac { return result; } - public async AlpmPackage[] get_group_pkgs (string groupname) { + public async AlpmPackage[] get_group_pkgs (string groupname) throws Error { AlpmPackage[] pkgs = {}; Alpm.List<unowned Alpm.Package> alpm_pkgs = group_pkgs (groupname); unowned Alpm.List<unowned Alpm.Package> list = alpm_pkgs; @@ -908,7 +912,7 @@ namespace Pamac { return pkgs; } - public async AlpmPackage[] get_category_pkgs (string category) { + public async AlpmPackage[] get_category_pkgs (string category) throws Error { AlpmPackage[] pkgs = {}; app_store.get_apps ().foreach ((app) => { app.get_categories ().foreach ((cat_name) => { @@ -947,7 +951,7 @@ namespace Pamac { return pkgs; } - public string[] get_pkg_uninstalled_optdeps (string pkgname) { + public string[] get_pkg_uninstalled_optdeps (string pkgname) throws Error { string[] optdeps = {}; unowned Alpm.Package? alpm_pkg = alpm_handle.localdb.get_pkg (pkgname); if (alpm_pkg == null) { @@ -966,7 +970,7 @@ namespace Pamac { return optdeps; } - public AlpmPackageDetails get_pkg_details (string pkgname, string appname) { + public AlpmPackageDetails get_pkg_details (string pkgname, string appname) throws Error { string name = ""; string app_name = ""; string version = ""; @@ -1166,7 +1170,7 @@ namespace Pamac { return details; } - public string[] get_pkg_files (string pkgname) { + public string[] get_pkg_files (string pkgname) throws Error { string[] files = {}; unowned Alpm.Package? alpm_pkg = alpm_handle.localdb.get_pkg (pkgname); if (alpm_pkg != null) { @@ -1321,13 +1325,13 @@ namespace Pamac { }); } - public void start_get_updates (bool check_aur_updates_) { + public void start_get_updates (bool check_aur_updates_) throws Error { check_aur_updates = check_aur_updates_; new Thread<int> ("get updates thread", get_updates); } [DBus (no_reply = true)] - public void quit () { + public void quit () throws Error { loop.quit (); } // End of Daemon Object