Commit a0897f65 authored by guinux's avatar guinux

support vala 0.40

parent 1424128d
......@@ -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);
......
This diff is collapsed.
/*
* 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) {
......
......@@ -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");
}
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment