diff --git a/po/pamac.pot b/po/pamac.pot
index 678b8dc..e9d75ef 100644
--- a/po/pamac.pot
+++ b/po/pamac.pot
@@ -21,8 +21,7 @@ msgstr ""
msgid "Authentication is required"
msgstr ""
-
-#: ../src/daemon.vala
+#: ../src/daemon.vala ../src/manager_window.vala ../src/preferences_dialog.vala
msgid "Failed to initialize alpm library"
msgstr ""
@@ -30,14 +29,6 @@ msgstr ""
msgid "Failed to synchronize any databases"
msgstr ""
-#: ../src/daemon.vala
-msgid "No"
-msgstr ""
-
-#: ../src/daemon.vala
-msgid "Yes"
-msgstr ""
-
#: ../src/daemon.vala
msgid "Failed to init transaction"
msgstr ""
@@ -90,7 +81,7 @@ msgstr ""
msgid "%s is invalid or corrupted"
msgstr ""
-#: ../src/daemon.vala
+#: ../src/daemon.vala ../src/transaction.vala
msgid "Authentication failed"
msgstr ""
@@ -110,6 +101,11 @@ msgstr ""
msgid "Preparing"
msgstr ""
+#: ../src/transaction.vala
+#, c-format
+msgid "Choose a provider for %s"
+msgstr ""
+
#: ../src/transaction.vala ../resources/transaction_sum_dialog.ui
msgid "Transaction Summary"
msgstr ""
@@ -146,6 +142,14 @@ msgstr ""
msgid "Building packages"
msgstr ""
+#: ../src/transaction.vala
+msgid "Running pre-transaction hooks"
+msgstr ""
+
+#: ../src/transaction.vala
+msgid "Running post-transaction hooks"
+msgstr ""
+
#: ../src/transaction.vala
msgid "Checking dependencies"
msgstr ""
@@ -259,19 +263,26 @@ msgstr ""
#: ../src/transaction.vala
#, c-format
-msgid "%s installed as %s.pacorig"
+msgid "Refreshing %s"
msgstr ""
#: ../src/transaction.vala
#, c-format
-msgid "Refreshing %s"
+msgid "Downloading %s"
msgstr ""
#: ../src/transaction.vala
#, c-format
-msgid "Downloading %s"
+msgid "About %u seconds remaining"
msgstr ""
+#: ../src/transaction.vala
+#, c-format
+msgid "About %lu minute remaining"
+msgid_plural "About %lu minutes remaining"
+msgstr[0] ""
+msgstr[1] ""
+
#: ../src/transaction.vala
msgid "Warning"
msgstr ""
@@ -281,7 +292,7 @@ msgstr ""
msgid "Error"
msgstr ""
-#: ../src/transaction.vala ../src/progress_dialog.vala
+#: ../src/transaction.vala
msgid "Transaction cancelled"
msgstr ""
@@ -324,22 +335,6 @@ msgstr[1] ""
msgid "Show available updates"
msgstr ""
-#: ../src/choose_provider_dialog.vala
-#, c-format
-msgid "Choose a provider for %s"
-msgstr ""
-
-#: ../src/choose_dep_dialog.vala
-#, c-format
-msgid ""
-"%s has %u uninstalled optional dependency.\n"
-"Choose if you would like to install it"
-msgid_plural ""
-"%s has %u uninstalled optional dependencies.\n"
-"Choose those you would like to install"
-msgstr[0] ""
-msgstr[1] ""
-
#: ../src/manager_window.vala
msgid "Deselect"
msgstr ""
@@ -380,6 +375,10 @@ msgstr ""
msgid "Licenses"
msgstr ""
+#: ../src/manager_window.vala
+msgid "Unknown"
+msgstr ""
+
#: ../src/manager_window.vala
msgid "Depends On"
msgstr ""
@@ -417,65 +416,76 @@ msgid "Groups"
msgstr ""
#: ../src/manager_window.vala
-msgid "Maintainer"
+msgid "Packager"
msgstr ""
#: ../src/manager_window.vala
-msgid "First Submitted"
+msgid "Build Date"
msgstr ""
#: ../src/manager_window.vala
-msgid "Last Modified"
+msgid "Install Date"
msgstr ""
#: ../src/manager_window.vala
-msgid "Packager"
+msgid "Explicitly installed"
msgstr ""
#: ../src/manager_window.vala
-msgid "Build Date"
+msgid "Installed as a dependency for another package"
msgstr ""
#: ../src/manager_window.vala
-msgid "Install Date"
+msgid "Install Reason"
msgstr ""
#: ../src/manager_window.vala
-msgid "Explicitly installed"
+msgid "Yes"
msgstr ""
#: ../src/manager_window.vala
-msgid "Installed as a dependency for another package"
+msgid "No"
msgstr ""
#: ../src/manager_window.vala
-msgid "Unknown"
+msgid "Signatures"
msgstr ""
#: ../src/manager_window.vala
-msgid "Install Reason"
+msgid "Backup files"
msgstr ""
#: ../src/manager_window.vala
-msgid "Signatures"
+msgid "Maintainer"
msgstr ""
#: ../src/manager_window.vala
-msgid "Votes"
+msgid "First Submitted"
msgstr ""
#: ../src/manager_window.vala
-msgid "Out of Date"
+msgid "Last Modified"
msgstr ""
-#: ../src/manager_window.vala
-msgid "Backup files"
+#: ../src/manager_window.vala ../resources/manager_window.ui
+msgid "Votes"
msgstr ""
#: ../src/manager_window.vala
-msgid "No package found"
+msgid "Out of Date"
msgstr ""
+#: ../src/manager_window.vala
+#, c-format
+msgid ""
+"%s has %u uninstalled optional dependency.\n"
+"Choose if you would like to install it"
+msgid_plural ""
+"%s has %u uninstalled optional dependencies.\n"
+"Choose those you would like to install"
+msgstr[0] ""
+msgstr[1] ""
+
#: ../src/manager_window.vala
msgid "Uninstalled"
msgstr ""
@@ -595,7 +605,7 @@ msgstr ""
msgid "State"
msgstr ""
-#: ../resources/manager_window.ui
+#: ../resources/manager_window.ui ../resources/updater_window.ui
msgid "Repositories"
msgstr ""
@@ -611,6 +621,11 @@ msgstr ""
msgid "Size"
msgstr ""
+#: ../resources/manager_window.ui ../resources/updater_window.ui
+#: ../resources/preferences_dialog.ui
+msgid "AUR"
+msgstr ""
+
#: ../resources/manager_window.ui
msgid "Description"
msgstr ""
@@ -708,10 +723,6 @@ msgstr ""
msgid "Do not ask for confirmation when building packages"
msgstr ""
-#: ../resources/preferences_dialog.ui
-msgid "AUR"
-msgstr ""
-
#: ../resources/choose_ignorepkgs_dialog.ui
msgid "Choose Ignored Upgrades"
msgstr ""
diff --git a/resources/manager_window.ui b/resources/manager_window.ui
index 590864d..20f65d8 100644
--- a/resources/manager_window.ui
+++ b/resources/manager_window.ui
@@ -207,8 +207,8 @@
@@ -437,117 +437,242 @@
True
vertical
-
@@ -563,11 +688,11 @@
True
in
-
+
True
- True
+ False
-
+
True
False
vertical
@@ -575,8 +700,10 @@
True
- True
+ False
start
+ 6
+ 6
6
6
6
@@ -592,8 +719,10 @@
True
- True
+ False
start
+ 6
+ 6
6
6
6
@@ -609,9 +738,10 @@
True
- True
- True
+ False
start
+ 6
+ 6
6
6
6
@@ -626,8 +756,10 @@
True
- True
+ False
start
+ 6
+ 6
6
6
6
@@ -647,7 +779,7 @@
-
+
True
False
Description
@@ -670,7 +802,7 @@
False
False
-
+
none
@@ -678,7 +810,7 @@
autosize
-
+
0
600
@@ -692,7 +824,7 @@
autosize
-
+
1
@@ -707,7 +839,7 @@
-
+
True
False
Dependencies
@@ -732,7 +864,7 @@
0
False
-
+
none
@@ -740,7 +872,7 @@
autosize
-
+
0
600
word
@@ -752,10 +884,10 @@
-
+
autosize
-
+
word
@@ -772,7 +904,7 @@
-
+
True
False
Details
@@ -824,7 +956,7 @@
True
- False
+ True
diff --git a/resources/progress_dialog.ui b/resources/progress_dialog.ui
index 5fdcc5d..e00357f 100644
--- a/resources/progress_dialog.ui
+++ b/resources/progress_dialog.ui
@@ -6,7 +6,7 @@
Progress
True
center-on-parent
- 500
+ 500
system-software-install
dialog
False
@@ -29,7 +29,6 @@
True
True
True
-
False
diff --git a/resources/updater_window.ui b/resources/updater_window.ui
index c313d75..d09ed27 100644
--- a/resources/updater_window.ui
+++ b/resources/updater_window.ui
@@ -1,5 +1,5 @@
-
+
@@ -30,64 +30,142 @@
-
- 400
- 400
+
True
- False
- True
- True
+ True
-
+
+ 400
+ 400
True
True
+ True
True
- False
- False
- 0
-
-
- none
-
-
-
+
+ True
+ True
+ True
+ False
+ False
+ 0
+
+
+ none
+
+
-
-
+
+
+
+
+
+
+ 0
+
+
-
- 0
-
-
-
-
-
- True
-
-
- 1
-
+
+ True
+
+
+
+ 1
+
+
+
+
+
+
+
+
+
+ 2
+
+
+
+
+
+
+
+ True
+ False
+ Repositories
+
+
+ False
+
+
+
+
+ 400
+ 400
+ True
+ True
+ True
+ True
-
+
+ True
+ True
+ True
+ False
+ False
+ 0
+
+
+ none
+
+
-
-
- 2
-
+
+
+
+
+
+
+ 0
+
+
+
+
+
+
+ True
+
+
+
+ 1
+
+
+
+
+ 1
+
+
+
+
+ True
+ False
+ AUR
+
+
+ 1
+ False
+
- True
+ False
True
1
diff --git a/src/Makefile b/src/Makefile
index d0ea1d5..c932344 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,23 +1,28 @@
-COMMON_VALA_FLAGS = -X -w \
+COMMON_VALA_FLAGS = -g --save-temps -X -w \
--pkg=libalpm \
--pkg=gio-2.0 \
+ --pkg=posix \
+ --pkg=json-glib-1.0 \
+ --pkg=libsoup-2.4 \
--vapidir=../vapi \
--Xcc=-I../util \
-X -D_FILE_OFFSET_BITS=64 \
-X -DGETTEXT_PACKAGE="pamac" \
--target-glib=2.38
-TRANSACTION_VALA_FLAGS = --pkg=json-glib-1.0 \
- --pkg=gtk+-3.0 \
+TRANSACTION_VALA_FLAGS = --pkg=gtk+-3.0 \
--pkg=gmodule-2.0 \
--pkg=gdk-3.0 \
- --pkg=vte-2.91
+ --pkg=vte-2.91 \
+ -X -lm
COMMON_SOURCES = ../util/alpm-util.c \
common.vala \
pamac_config.vala \
- package.vala \
+ alpm_config.vala \
+ alpm_utils.vala \
+ aur.vala \
TRANSACTION_SOURCES = transaction.vala \
choose_provider_dialog.vala \
@@ -44,37 +49,28 @@ pamac-refresh: pamac_config.vala refresh.vala
valac -o pamac-refresh \
-X -w \
--pkg=gio-2.0 \
+ --pkg=posix \
pamac_config.vala \
refresh.vala
-pamac-tray: ../vapi/libalpm.vapi ../util/alpm-util.c common.vala alpm_config.vala pamac_config.vala tray.vala
+pamac-tray: ../vapi/libalpm.vapi $(COMMON_SOURCES) tray.vala
valac -o pamac-tray \
$(COMMON_VALA_FLAGS) \
- ../util/alpm-util.c \
- --pkg=posix \
--pkg=gtk+-3.0 \
--pkg=libnotify \
- common.vala \
- alpm_config.vala \
- pamac_config.vala \
+ $(COMMON_SOURCES) \
tray.vala
-pamac-daemon: ../vapi/libalpm.vapi ../vapi/polkit-gobject-1.vapi $(COMMON_SOURCES) mirrors_config.vala alpm_config.vala alpm_utils.vala aur.vala daemon.vala
+pamac-daemon: ../vapi/libalpm.vapi ../vapi/polkit-gobject-1.vapi $(COMMON_SOURCES) mirrors_config.vala daemon.vala
valac -o pamac-daemon \
$(COMMON_VALA_FLAGS) \
- --pkg=posix \
- --pkg=json-glib-1.0 \
- --pkg=libsoup-2.4 \
--pkg=polkit-gobject-1 \
--thread \
$(COMMON_SOURCES) \
mirrors_config.vala \
- alpm_config.vala \
- aur.vala \
- alpm_utils.vala \
daemon.vala
-pamac-manager: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) $(PREFERENCES_SOURCES) choose_dep_dialog.vala history_dialog.vala ../resources/manager_resources.c packages_model.vala manager_window.vala manager.vala
+pamac-manager: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) $(PREFERENCES_SOURCES) choose_dep_dialog.vala history_dialog.vala ../resources/manager_resources.c packages_model.vala aur_model.vala manager_window.vala manager.vala
valac -o pamac-manager \
$(COMMON_VALA_FLAGS) \
$(TRANSACTION_VALA_FLAGS) \
@@ -86,6 +82,7 @@ pamac-manager: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) $(P
choose_dep_dialog.vala \
history_dialog.vala \
packages_model.vala \
+ aur_model.vala \
manager_window.vala \
manager.vala
diff --git a/src/alpm_config.vala b/src/alpm_config.vala
index 95ce58c..a0d8e7d 100644
--- a/src/alpm_config.vala
+++ b/src/alpm_config.vala
@@ -1,7 +1,7 @@
/*
* pamac-vala
*
- * Copyright (C) 2014-2015 Guillaume Benoit
+ * Copyright (C) 2014-2016 Guillaume Benoit
*
* 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
@@ -18,112 +18,163 @@
*/
namespace Alpm {
- class Repo {
+ [Compact]
+ public class Repo {
public string name;
public Signature.Level siglevel;
+ public Signature.Level siglevel_mask;
public DB.Usage usage;
- public string[] urls;
+ public GLib.List urls;
public Repo (string name) {
this.name = name;
siglevel = Signature.Level.USE_DEFAULT;
usage = 0;
- urls = {};
- }
+ urls = new GLib.List ();
+ }
+
+ public static int compare_name (Repo a, Repo b) {
+ return strcmp (a.name, b.name);
+ }
+
+ public static int search_name (Repo a, string name) {
+ return strcmp (a.name, name);
+ }
+
}
+ [Compact]
public class Config {
- string conf_path;
- string rootdir;
- string dbpath;
- string gpgdir;
- string logfile;
- string arch;
- double deltaratio;
- int usesyslog;
+ public string conf_path;
+ public string? rootdir;
+ public string? dbpath;
+ public string? logfile;
+ public string? gpgdir;
+ public string? arch;
+ public double deltaratio;
+ public int usesyslog;
public int checkspace;
- Alpm.List *cachedirs;
- Alpm.List *ignoregroups;
- public Alpm.List *ignorepkgs;
- Alpm.List *noextracts;
- Alpm.List *noupgrades;
- public GLib.List holdpkgs;
- public GLib.List syncfirsts;
- Signature.Level defaultsiglevel;
- Signature.Level localfilesiglevel;
- Signature.Level remotefilesiglevel;
- Repo[] repo_order;
- public unowned Handle? handle;
+ public Alpm.List? cachedirs;
+ public Alpm.List? hookdirs;
+ public Alpm.List? ignoregroups;
+ public Alpm.List? ignorepkgs;
+ public Alpm.List? noextracts;
+ public Alpm.List? noupgrades;
+ public GLib.List? holdpkgs;
+ public GLib.List? syncfirsts;
+ public Signature.Level siglevel;
+ public Signature.Level localfilesiglevel;
+ public Signature.Level remotefilesiglevel;
+ public Signature.Level siglevel_mask;
+ public Signature.Level localfilesiglevel_mask;
+ public Signature.Level remotefilesiglevel_mask;
+ public GLib.List repo_order;
+ public Handle? handle;
public Config (string path) {
conf_path = path;
- handle = null;
reload ();
}
public void reload () {
// set default options
- rootdir = "/";
- dbpath = "/var/lib/pacman";
- gpgdir = "/etc/pacman.d/gnupg/";
- logfile = "/var/log/pacman.log";
- string default_cachedir = "/var/cache/pacman/pkg/";
- arch = Posix.utsname().machine;
holdpkgs = new GLib.List ();
syncfirsts = new GLib.List ();
- Alpm.List.free_all (cachedirs);
- Alpm.List.free_all (ignoregroups);
- Alpm.List.free_all (ignorepkgs);
- Alpm.List.free_all (noextracts);
- Alpm.List.free_all (noupgrades);
- cachedirs = new Alpm.List ();
- cachedirs->add_str (default_cachedir);
- ignoregroups = new Alpm.List ();
- ignorepkgs = new Alpm.List ();
- noextracts = new Alpm.List ();
- noupgrades = new Alpm.List ();
+ // free internal data of alpm lists
+ if (cachedirs != null) {
+ cachedirs.free_data ();
+ }
+ if (hookdirs != null) {
+ hookdirs.free_data ();
+ }
+ if (ignoregroups != null) {
+ ignoregroups.free_data ();
+ }
+ if (ignorepkgs != null) {
+ ignorepkgs.free_data ();
+ }
+ if (noextracts != null) {
+ noextracts.free_data ();
+ }
+ if (noupgrades != null) {
+ noupgrades.free_data ();
+ }
usesyslog = 0;
checkspace = 0;
deltaratio = 0.7;
- defaultsiglevel = Signature.Level.PACKAGE | Signature.Level.PACKAGE_OPTIONAL | Signature.Level.DATABASE | Signature.Level.DATABASE_OPTIONAL;
+ siglevel = Signature.Level.PACKAGE | Signature.Level.PACKAGE_OPTIONAL | Signature.Level.DATABASE | Signature.Level.DATABASE_OPTIONAL;
localfilesiglevel = Signature.Level.USE_DEFAULT;
remotefilesiglevel = Signature.Level.USE_DEFAULT;
- repo_order = {};
+ repo_order = new GLib.List ();
// parse conf file
parse_file (conf_path);
+ // if rootdir is set and dbpath/logfile are not
+ // set, then set those as well to reside under the root.
+ if (rootdir != null) {
+ if (dbpath == null) {
+ dbpath = Path.build_path ("/", rootdir, "var/lib/pacman/");
+ }
+ if (logfile == null) {
+ logfile = Path.build_path ("/", rootdir, "var/log/pacman.log");
+ }
+ } else {
+ rootdir = "/";
+ if (dbpath == null) {
+ dbpath = "/var/lib/pacman/";
+ }
+ if (logfile == null) {
+ logfile = "/var/log/pacman.log";
+ }
+ }
+ if (cachedirs.length == 0) {
+ cachedirs.add ("/var/cache/pacman/pkg/");
+ }
+ if (hookdirs.length == 0) {
+ hookdirs.add ("/etc/pacman.d/hooks/");
+ }
+ if (gpgdir == null) {
+ // gpgdir it is not relative to rootdir, even if
+ // rootdir is defined because it contains configuration data.
+ gpgdir = "/etc/pacman.d/gnupg/";
+ }
+ if (arch == null) {
+ arch = Posix.utsname().machine;
+ }
}
public void get_handle () {
Alpm.Errno error;
- if (handle != null) {
- Handle.release (handle);
- }
handle = Handle.new (rootdir, dbpath, out error);
if (handle == null) {
stderr.printf ("Failed to initialize alpm library" + " (%s)\n".printf(Alpm.strerror (error)));
return;
}
// define options
- handle.gpgdir = gpgdir;
handle.logfile = logfile;
+ handle.gpgdir = gpgdir;
handle.arch = arch;
handle.deltaratio = deltaratio;
handle.usesyslog = usesyslog;
handle.checkspace = checkspace;
- handle.defaultsiglevel = defaultsiglevel;
- localfilesiglevel = merge_siglevel (defaultsiglevel, localfilesiglevel);
- remotefilesiglevel = merge_siglevel (defaultsiglevel, remotefilesiglevel);
+ handle.defaultsiglevel = siglevel;
+ localfilesiglevel = merge_siglevel (siglevel, localfilesiglevel, localfilesiglevel_mask);
+ remotefilesiglevel = merge_siglevel (siglevel, remotefilesiglevel, remotefilesiglevel_mask);
handle.localfilesiglevel = localfilesiglevel;
handle.remotefilesiglevel = remotefilesiglevel;
handle.cachedirs = cachedirs;
+ // add hook directories 1-by-1 to avoid overwriting the system directory
+ foreach (unowned string hookdir in hookdirs) {
+ handle.add_hookdir (hookdir);
+ }
handle.ignoregroups = ignoregroups;
handle.ignorepkgs = ignorepkgs;
handle.noextracts = noextracts;
handle.noupgrades = noupgrades;
// register dbs
- foreach (var repo in repo_order) {
+ foreach (unowned Repo repo in repo_order) {
+ repo.siglevel = merge_siglevel (siglevel, repo.siglevel, repo.siglevel_mask);
unowned DB db = handle.register_syncdb (repo.name, repo.siglevel);
- foreach (var url in repo.urls) {
+ foreach (unowned string url in repo.urls) {
db.add_server (url.replace ("$repo", repo.name).replace ("$arch", handle.arch));
}
if (repo.usage == 0) {
@@ -158,21 +209,37 @@ namespace Alpm {
current_section = line[1:-1];
if (current_section != "options") {
var repo = new Repo (current_section);
- repo_order += repo;
+ if (repo_order.find_custom (repo, Repo.compare_name) == null) {
+ repo_order.append ((owned) repo);
+ }
}
continue;
}
splitted = line.split ("=", 2);
- string key = splitted[0].strip ();
- string? val = null;
- if (splitted[1] != null) {
- val = splitted[1].strip ();
+ unowned string key = splitted[0]._strip ();
+ unowned string? val = null;
+ if (splitted.length == 2) {
+ val = splitted[1]._strip ();
}
if (key == "Include") {
parse_file (val, current_section);
}
if (current_section == "options") {
- if (key == "GPGDir") {
+ if (key == "RootDir") {
+ rootdir = val;
+ } else if (key == "DBPath") {
+ dbpath = val;
+ } else if (key == "CacheDir") {
+ foreach (unowned string dir in val.split (" ")) {
+ cachedirs.add (dir);
+ }
+ } else if (key == "HookDir") {
+ foreach (unowned string dir in val.split (" ")) {
+ hookdirs.add (dir);
+ }
+ } else if (key == "LogFile") {
+ logfile = val;
+ } else if (key == "GPGDir") {
gpgdir = val;
} else if (key == "LogFile") {
logfile = val;
@@ -189,53 +256,46 @@ namespace Alpm {
} else if (key == "CheckSpace") {
checkspace = 1;
} else if (key == "SigLevel") {
- defaultsiglevel = define_siglevel (defaultsiglevel, val);
+ process_siglevel (val, ref siglevel, ref siglevel_mask);
} else if (key == "LocalFileSigLevel") {
- localfilesiglevel = define_siglevel (localfilesiglevel, val);
+ process_siglevel (val, ref localfilesiglevel, ref localfilesiglevel_mask);
} else if (key == "RemoteFileSigLevel") {
- remotefilesiglevel = define_siglevel (remotefilesiglevel, val);
+ process_siglevel (val, ref remotefilesiglevel, ref remotefilesiglevel_mask);
} else if (key == "HoldPkg") {
- foreach (string name in val.split (" ")) {
+ foreach (unowned string name in val.split (" ")) {
holdpkgs.append (name);
}
} else if (key == "SyncFirst") {
- foreach (string name in val.split (" ")) {
+ foreach (unowned string name in val.split (" ")) {
syncfirsts.append (name);
}
- } else if (key == "CacheDir") {
- foreach (string dir in val.split (" ")) {
- cachedirs->add_str (dir);
- }
} else if (key == "IgnoreGroup") {
- foreach (string name in val.split (" ")) {
- ignoregroups->add_str (name);
+ foreach (unowned string name in val.split (" ")) {
+ ignoregroups.add (name);
}
} else if (key == "IgnorePkg") {
- foreach (string name in val.split (" ")) {
- ignorepkgs->add_str (name);
+ foreach (unowned string name in val.split (" ")) {
+ ignorepkgs.add (name);
}
} else if (key == "Noextract") {
- foreach (string name in val.split (" ")) {
- noextracts->add_str (name);
+ foreach (unowned string name in val.split (" ")) {
+ noextracts.add (name);
}
} else if (key == "NoUpgrade") {
- foreach (string name in val.split (" ")) {
- noupgrades->add_str (name);
+ foreach (unowned string name in val.split (" ")) {
+ noupgrades.add (name);
}
}
} else {
- foreach (var repo in repo_order) {
- if (repo.name == current_section) {
- if (key == "Server") {
- repo.urls += val;
- } else if (key == "SigLevel") {
- if (repo.siglevel == Signature.Level.USE_DEFAULT) {
- repo.siglevel = defaultsiglevel;
- }
- repo.siglevel = define_siglevel (repo.siglevel, val);
- } else if (key == "Usage") {
- repo.usage = define_usage (val);
- }
+ unowned GLib.List? found = repo_order.search (current_section, (SearchFunc) Repo.search_name);
+ if (found != null) {
+ unowned Repo repo = found.data;
+ if (key == "Server") {
+ repo.urls.append (val);
+ } else if (key == "SigLevel") {
+ process_siglevel (val, ref repo.siglevel, ref repo.siglevel_mask);
+ } else if (key == "Usage") {
+ repo.usage = define_usage (val);
}
}
}
@@ -295,7 +355,7 @@ namespace Alpm {
file.delete ();
// creating a DataOutputStream to the file
var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION));
- foreach (string new_line in data) {
+ foreach (unowned string new_line in data) {
// writing a short string to the stream
dos.put_string (new_line);
}
@@ -309,7 +369,7 @@ namespace Alpm {
public DB.Usage define_usage (string conf_string) {
DB.Usage usage = 0;
- foreach (string directive in conf_string.split(" ")) {
+ foreach (unowned string directive in conf_string.split(" ")) {
if (directive == "Sync") {
usage |= DB.Usage.SYNC;
} else if (directive == "Search") {
@@ -325,8 +385,8 @@ namespace Alpm {
return usage;
}
- public Signature.Level define_siglevel (Signature.Level default_level, string conf_string) {
- foreach (string directive in conf_string.split(" ")) {
+ public void process_siglevel (string conf_string, ref Signature.Level siglevel, ref Signature.Level siglevel_mask) {
+ foreach (unowned string directive in conf_string.split(" ")) {
bool affect_package = false;
bool affect_database = false;
if ("Package" in directive) {
@@ -339,72 +399,62 @@ namespace Alpm {
}
if ("Never" in directive) {
if (affect_package) {
- default_level &= ~Signature.Level.PACKAGE;
- default_level |= Signature.Level.PACKAGE_SET;
+ siglevel &= ~Signature.Level.PACKAGE;
+ siglevel_mask |= Signature.Level.PACKAGE;
}
if (affect_database) {
- default_level &= ~Signature.Level.DATABASE;
+ siglevel &= ~Signature.Level.DATABASE;
+ siglevel_mask |= Signature.Level.DATABASE;
}
} else if ("Optional" in directive) {
if (affect_package) {
- default_level |= Signature.Level.PACKAGE;
- default_level |= Signature.Level.PACKAGE_OPTIONAL;
- default_level |= Signature.Level.PACKAGE_SET;
+ siglevel |= (Signature.Level.PACKAGE | Signature.Level.PACKAGE_OPTIONAL);
+ siglevel_mask |= (Signature.Level.PACKAGE | Signature.Level.PACKAGE_OPTIONAL);
}
if (affect_database) {
- default_level |= Signature.Level.DATABASE;
- default_level |= Signature.Level.DATABASE_OPTIONAL;
+ siglevel |= (Signature.Level.DATABASE | Signature.Level.DATABASE_OPTIONAL);
+ siglevel_mask |= (Signature.Level.DATABASE | Signature.Level.DATABASE_OPTIONAL);
}
} else if ("Required" in directive) {
if (affect_package) {
- default_level |= Signature.Level.PACKAGE;
- default_level &= ~Signature.Level.PACKAGE_OPTIONAL;
- default_level |= Signature.Level.PACKAGE_SET;
+ siglevel |= Signature.Level.PACKAGE;
+ siglevel_mask |= Signature.Level.PACKAGE;
+ siglevel &= ~Signature.Level.PACKAGE_OPTIONAL;
+ siglevel_mask |= Signature.Level.PACKAGE_OPTIONAL;
}
if (affect_database) {
- default_level |= Signature.Level.DATABASE;
- default_level &= ~Signature.Level.DATABASE_OPTIONAL;
+ siglevel |= Signature.Level.DATABASE;
+ siglevel_mask |= Signature.Level.DATABASE;
+ siglevel &= ~Signature.Level.DATABASE_OPTIONAL;
+ siglevel_mask |= Signature.Level.DATABASE_OPTIONAL;
}
} else if ("TrustedOnly" in directive) {
if (affect_package) {
- default_level &= ~Signature.Level.PACKAGE_MARGINAL_OK;
- default_level &= ~Signature.Level.PACKAGE_UNKNOWN_OK;
- default_level |= Signature.Level.PACKAGE_TRUST_SET;
+ siglevel &= ~(Signature.Level.PACKAGE_MARGINAL_OK | Signature.Level.PACKAGE_UNKNOWN_OK);
+ siglevel_mask |= (Signature.Level.PACKAGE_MARGINAL_OK | Signature.Level.PACKAGE_UNKNOWN_OK);
}
if (affect_database) {
- default_level &= ~Signature.Level.DATABASE_MARGINAL_OK;
- default_level &= ~Signature.Level.DATABASE_UNKNOWN_OK;
+ siglevel &= ~(Signature.Level.DATABASE_MARGINAL_OK | Signature.Level.DATABASE_UNKNOWN_OK);
+ siglevel_mask |= (Signature.Level.DATABASE_MARGINAL_OK | Signature.Level.DATABASE_UNKNOWN_OK);
}
} else if ("TrustAll" in directive) {
if (affect_package) {
- default_level |= Signature.Level.PACKAGE_MARGINAL_OK;
- default_level |= Signature.Level.PACKAGE_UNKNOWN_OK;
- default_level |= Signature.Level.PACKAGE_TRUST_SET;
+ siglevel |= (Signature.Level.PACKAGE_MARGINAL_OK | Signature.Level.PACKAGE_UNKNOWN_OK);
+ siglevel_mask |= (Signature.Level.PACKAGE_MARGINAL_OK | Signature.Level.PACKAGE_UNKNOWN_OK);
}
if (affect_database) {
- default_level |= Signature.Level.DATABASE_MARGINAL_OK;
- default_level |= Signature.Level.DATABASE_UNKNOWN_OK;
+ siglevel |= (Signature.Level.DATABASE_MARGINAL_OK | Signature.Level.DATABASE_UNKNOWN_OK);
+ siglevel_mask |= (Signature.Level.DATABASE_MARGINAL_OK | Signature.Level.DATABASE_UNKNOWN_OK);
}
} else {
GLib.stderr.printf("unrecognized siglevel: %s\n", conf_string);
}
}
- default_level &= ~Signature.Level.USE_DEFAULT;
- return default_level;
+ siglevel &= ~Signature.Level.USE_DEFAULT;
}
- public Signature.Level merge_siglevel (Signature.Level base_level, Signature.Level over_level) {
- if ((over_level & Signature.Level.USE_DEFAULT) == 0) {
- if ((over_level & Signature.Level.PACKAGE_SET) == 0) {
- over_level |= base_level & Signature.Level.PACKAGE;
- over_level |= base_level & Signature.Level.PACKAGE_OPTIONAL;
- }
- if ((over_level & Signature.Level.PACKAGE_TRUST_SET) == 0) {
- over_level |= base_level & Signature.Level.PACKAGE_MARGINAL_OK;
- over_level |= base_level & Signature.Level.PACKAGE_UNKNOWN_OK;
- }
- }
- return over_level;
+ public Signature.Level merge_siglevel(Signature.Level sigbase, Signature.Level sigover, Signature.Level sigmask) {
+ return (sigmask != 0) ? (sigover & sigmask) | (sigbase & ~sigmask) : sigover;
}
}
}
diff --git a/src/alpm_utils.vala b/src/alpm_utils.vala
index 4f7ffbb..36d0377 100644
--- a/src/alpm_utils.vala
+++ b/src/alpm_utils.vala
@@ -17,59 +17,22 @@
* along with this program. If not, see .
*/
-public int pkgcmp (Alpm.Package pkg1, Alpm.Package pkg2) {
- return strcmp (pkg1.name, pkg2.name);
+public int compare_name (Alpm.Package pkg_a, Alpm.Package pkg_b) {
+ return strcmp (pkg_a.name, pkg_b.name);
}
-public Alpm.List search_all_dbs (Alpm.Handle handle, Alpm.List needles) {
- var syncpkgs = new Alpm.List ();
- var result = handle.localdb.search (needles);
-
- foreach (var db in handle.syncdbs) {
- if (syncpkgs.length == 0)
- syncpkgs = db.search (needles);
- else {
- syncpkgs.join (db.search (needles).diff (syncpkgs, (Alpm.List.CompareFunc) pkgcmp));
- }
- }
-
- result.join (syncpkgs.diff (result, (Alpm.List.CompareFunc) pkgcmp));
- //result.sort ((Alpm.List.CompareFunc) pkgcmp);
-
- return result;
+public int compare_state (Alpm.Package pkg_a, Alpm.Package pkg_b) {
+ return (int) (pkg_a.origin > pkg_b.origin) - (int) (pkg_a.origin < pkg_b.origin);
}
-public Alpm.List group_pkgs (Alpm.Handle handle, string grp_name) {
- var result = new Alpm.List ();
-
- unowned Alpm.Group? grp = handle.localdb.get_group (grp_name);
- if (grp != null) {
- foreach (var pkg in grp.packages)
- result.add (pkg);
- }
-
- result.join (Alpm.find_group_pkgs (handle.syncdbs, grp_name).diff (result, (Alpm.List.CompareFunc) pkgcmp));
-
- //result.sort ((Alpm.List.CompareFunc) pkgcmp);
-
- return result;
+public int compare_version (Alpm.Package pkg_a, Alpm.Package pkg_b) {
+ return Alpm.pkg_vercmp (pkg_a.version, pkg_b.version);
}
-public Alpm.List all_pkgs (Alpm.Handle handle) {
- var syncpkgs = new Alpm.List ();
- var result = new Alpm.List ();
- result = handle.localdb.pkgcache.copy ();
-
- foreach (var db in handle.syncdbs) {
- if (syncpkgs.length == 0)
- syncpkgs = db.pkgcache.copy ();
- else {
- syncpkgs.join (db.pkgcache.diff (syncpkgs, (Alpm.List.CompareFunc) pkgcmp));
- }
- }
-
- result.join (syncpkgs.diff (result, (Alpm.List.CompareFunc) pkgcmp));
- //result.sort ((Alpm.List.CompareFunc) pkgcmp);
+public int compare_repo (Alpm.Package pkg_a, Alpm.Package pkg_b) {
+ return strcmp (pkg_a.db.name, pkg_b.db.name);
+}
- return result;
+public int compare_size (Alpm.Package pkg_a, Alpm.Package pkg_b) {
+ return (int) (pkg_a.isize > pkg_b.isize) - (int) (pkg_a.isize < pkg_b.isize);
}
diff --git a/src/aur_model.vala b/src/aur_model.vala
new file mode 100644
index 0000000..fa6009d
--- /dev/null
+++ b/src/aur_model.vala
@@ -0,0 +1,271 @@
+/*
+ * pamac-vala
+ *
+ * Copyright (C) 2014-2016 Guillaume Benoit
+ *
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a get of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+Pamac.ManagerWindow manager_window;
+
+// custom sort functions
+public int aur_compare_name (Json.Object pkg_a, Json.Object pkg_b) {
+ return strcmp (pkg_a.get_string_member ("Name"), pkg_b.get_string_member ("Name"));
+}
+
+public int aur_compare_state (Json.Object pkg_a, Json.Object pkg_b) {
+ unowned Alpm.Package? alpm_pkg_a = manager_window.alpm_config.handle.localdb.get_pkg (pkg_a.get_string_member ("Name"));
+ unowned Alpm.Package? alpm_pkg_b = manager_window.alpm_config.handle.localdb.get_pkg (pkg_b.get_string_member ("Name"));
+ if (pkg_a != null) {
+ if (pkg_b != null) {
+ return (int) (alpm_pkg_a.origin > alpm_pkg_b.origin) - (int) (alpm_pkg_a.origin < alpm_pkg_b.origin);
+ } else {
+ return 1;
+ }
+ } else {
+ if (pkg_b != null) {
+ return -1;
+ } else {
+ return 0;
+ }
+ }
+}
+
+public int aur_compare_version (Json.Object pkg_a, Json.Object pkg_b) {
+ return Alpm.pkg_vercmp (pkg_a.get_string_member ("Version"), pkg_b.get_string_member ("Version"));
+}
+
+public int aur_compare_votes (Json.Object pkg_a, Json.Object pkg_b) {
+ return (int) (pkg_a.get_int_member ("NumVotes") > pkg_b.get_int_member ("NumVotes")) - (int) (pkg_a.get_int_member ("NumVotes") < pkg_b.get_int_member ("NumVotes"));
+}
+
+namespace Pamac {
+
+ public class AURModel : Object, Gtk.TreeModel {
+ private Json.Array pkgs_infos;
+ private GLib.List pkgs;
+
+ public AURModel (Json.Array? pkgs_infos, ManagerWindow _manager_window) {
+ manager_window = _manager_window;
+ this.pkgs_infos = pkgs_infos;
+ pkgs = new GLib.List ();
+ if (pkgs_infos != null) {
+ pkgs_infos.foreach_element ((array, index, node) => {
+ pkgs.append (node.get_object ());
+ });
+ }
+ }
+
+ // TreeModel interface
+ public Type get_column_type (int index) {
+ switch (index) {
+ case 0: // name
+ case 2: // version
+ return typeof (string);
+ case 3: // votes
+ return typeof (int64);
+ case 1: // icon
+ return typeof (Gdk.Pixbuf);
+ default:
+ return Type.INVALID;
+ }
+ }
+
+ public Gtk.TreeModelFlags get_flags () {
+ return Gtk.TreeModelFlags.LIST_ONLY | Gtk.TreeModelFlags.ITERS_PERSIST;
+ }
+
+ public void get_value (Gtk.TreeIter iter, int column, out Value val) {
+ unowned Json.Object? pkg_info = pkgs.nth_data (iter.stamp);
+ switch (column) {
+ case 0:
+ val = Value (typeof (string));
+ if (pkg_info == null) {
+ val.set_string (dgettext (null, "No package found"));
+ } else {
+ val.set_string (pkg_info.get_string_member ("Name"));
+ }
+ break;
+ case 1:
+ val = Value (typeof (Object));
+ if (pkg_info != null) {
+ unowned Alpm.Package? pkg = manager_window.alpm_config.handle.localdb.get_pkg (pkg_info.get_string_member ("Name"));
+ if (pkg != null) {
+ if (manager_window.alpm_config.holdpkgs.find_custom (pkg.name, strcmp) != null) {
+ val.set_object (manager_window.locked_icon);
+ } else if (manager_window.transaction.to_add.contains (pkg.name)) {
+ val.set_object (manager_window.to_reinstall_icon);
+ } else if (manager_window.transaction.to_remove.contains (pkg.name)) {
+ val.set_object (manager_window.to_remove_icon);
+ } else {
+ val.set_object (manager_window.installed_icon);
+ }
+ } else if (manager_window.transaction.to_build.contains (pkg_info.get_string_member ("Name"))) {
+ val.set_object (manager_window.to_install_icon);
+ } else {
+ val.set_object (manager_window.uninstalled_icon);
+ }
+ }
+ break;
+ case 2:
+ val = Value (typeof (string));
+ if (pkg_info != null) {
+ unowned Alpm.Package? pkg = manager_window.alpm_config.handle.localdb.get_pkg (pkg_info.get_string_member ("Name"));
+ if (pkg != null) {
+ val.set_string (pkg.version);
+ } else {
+ val.set_string (pkg_info.get_string_member ("Version"));
+ }
+ }
+ break;
+ case 3:
+ if (pkg_info != null) {
+ val = Value (typeof (int64));
+ val.set_int64 (pkg_info.get_int_member ("NumVotes"));
+ } else {
+ // if pkg_info is null, set val to an empty string to not display "0"
+ val = Value (typeof (string));
+ }
+ break;
+ default:
+ val = Value (Type.INVALID);
+ break;
+ }
+ }
+
+ public bool get_iter (out Gtk.TreeIter iter, Gtk.TreePath path) {;
+ if (path.get_depth () != 1) {
+ return invalid_iter (out iter);
+ }
+ iter = Gtk.TreeIter ();
+ int pos = path.get_indices ()[0];
+ iter.stamp = pos;
+ return true;
+ }
+
+ public int get_n_columns () {
+ // name, icon, version, votes
+ return 4;
+ }
+
+ public Gtk.TreePath? get_path (Gtk.TreeIter iter) {
+ return new Gtk.TreePath.from_indices (iter.stamp);
+ }
+
+ public int iter_n_children (Gtk.TreeIter? iter) {
+ return 0;
+ }
+
+ public bool iter_next (ref Gtk.TreeIter iter) {
+ int pos = (iter.stamp) + 1;
+ if (pos >= pkgs.length ()) {
+ return false;
+ }
+ iter.stamp = pos;
+ return true;
+ }
+
+ public bool iter_previous (ref Gtk.TreeIter iter) {
+ int pos = iter.stamp;
+ if (pos >= 0) {
+ return false;
+ }
+ iter.stamp = (--pos);
+ return true;
+ }
+
+ public bool iter_nth_child (out Gtk.TreeIter iter, Gtk.TreeIter? parent, int n) {
+ return invalid_iter (out iter);
+ }
+
+ public bool iter_children (out Gtk.TreeIter iter, Gtk.TreeIter? parent) {
+ return invalid_iter (out iter);
+ }
+
+ public bool iter_has_child (Gtk.TreeIter iter) {
+ return false;
+ }
+
+ public bool iter_parent (out Gtk.TreeIter iter, Gtk.TreeIter child) {
+ return invalid_iter (out iter);
+ }
+
+ private bool invalid_iter (out Gtk.TreeIter iter) {
+ iter = Gtk.TreeIter ();
+ iter.stamp = -1;
+ return false;
+ }
+
+ // custom get pkg function
+ public unowned Json.Object? get_pkg_at_path (Gtk.TreePath path) {
+ return pkgs.nth_data (path.get_indices ()[0]);
+ }
+
+ public void sort_by_name (Gtk.SortType order) {
+ pkgs.sort ((GLib.CompareFunc) aur_compare_name);
+ if (order == Gtk.SortType.DESCENDING) {
+ pkgs.reverse ();
+ }
+ manager_window.aur_name_column.sort_order = order;
+ manager_window.aur_state_column.sort_indicator = false;
+ manager_window.aur_name_column.sort_indicator = true;
+ manager_window.aur_version_column.sort_indicator = false;
+ manager_window.aur_votes_column.sort_indicator = false;
+ manager_window.sortinfo.column_number = 0;
+ manager_window.sortinfo.sort_type = order;
+ }
+
+ public void sort_by_state (Gtk.SortType order) {
+ pkgs.sort ((GLib.CompareFunc) aur_compare_state);
+ if (order == Gtk.SortType.DESCENDING) {
+ pkgs.reverse ();
+ }
+ manager_window.aur_state_column.sort_order = order;
+ manager_window.aur_state_column.sort_indicator = true;
+ manager_window.aur_name_column.sort_indicator = false;
+ manager_window.aur_version_column.sort_indicator = false;
+ manager_window.aur_votes_column.sort_indicator = false;
+ manager_window.sortinfo.column_number = 1;
+ manager_window.sortinfo.sort_type = order;
+ }
+
+ public void sort_by_version (Gtk.SortType order) {
+ pkgs.sort ((GLib.CompareFunc) aur_compare_version);
+ if (order == Gtk.SortType.DESCENDING) {
+ pkgs.reverse ();
+ }
+ manager_window.aur_version_column.sort_order = order;
+ manager_window.aur_state_column.sort_indicator = false;
+ manager_window.aur_name_column.sort_indicator = false;
+ manager_window.aur_version_column.sort_indicator = true;
+ manager_window.aur_votes_column.sort_indicator = false;
+ manager_window.sortinfo.column_number = 2;
+ manager_window.sortinfo.sort_type = order;
+ }
+
+ public void sort_by_votes (Gtk.SortType order) {
+ pkgs.sort ((GLib.CompareFunc) aur_compare_votes);
+ if (order == Gtk.SortType.DESCENDING) {
+ pkgs.reverse ();
+ }
+ manager_window.aur_votes_column.sort_order = order;
+ manager_window.aur_state_column.sort_indicator = false;
+ manager_window.aur_name_column.sort_indicator = false;
+ manager_window.aur_version_column.sort_indicator = false;
+ manager_window.aur_votes_column.sort_indicator = true;
+ manager_window.sortinfo.column_number = 3;
+ manager_window.sortinfo.sort_type = order;
+ }
+ }
+}
diff --git a/src/choose_dep_dialog.vala b/src/choose_dep_dialog.vala
index 6f3a437..e900ffa 100644
--- a/src/choose_dep_dialog.vala
+++ b/src/choose_dep_dialog.vala
@@ -31,38 +31,20 @@ namespace Pamac {
public Gtk.ListStore deps_list;
- Transaction transaction;
-
- public ChooseDependenciesDialog (Transaction transaction, string pkgname, Gtk.ApplicationWindow? window) {
+ public ChooseDependenciesDialog (Gtk.ApplicationWindow? window) {
Object (transient_for: window, use_header_bar: 0);
- this.transaction = transaction;
-
- string[] optdeps = transaction.get_pkg_uninstalled_optdeps (pkgname);
- label.set_markup ("%s".printf (
- dngettext (null, "%s has %u uninstalled optional dependency.\nChoose if you would like to install it",
- "%s has %u uninstalled optional dependencies.\nChoose those you would like to install", optdeps.length).printf (pkgname, optdeps.length)));
deps_list = new Gtk.ListStore (3, typeof (bool), typeof (string), typeof (string));
treeview.set_model (deps_list);
- Gtk.TreeIter iter;
- foreach (var optdep in optdeps) {
- string[] split = optdep.split (":", 2);
- deps_list.insert_with_values (out iter, -1,
- 0, false,
- 1, split[0],
- 2, split[1]);
- }
}
[GtkCallback]
void on_renderertoggle_toggled (string path) {
Gtk.TreeIter iter;
- GLib.Value val;
- bool selected;
+ GLib.Value selected;
if (deps_list.get_iter_from_string (out iter, path)) {;
- deps_list.get_value (iter, 0, out val);
- selected = val.get_boolean ();
- deps_list.set_value (iter, 0, !selected);
+ deps_list.get_value (iter, 0, out selected);
+ deps_list.set_value (iter, 0, !((bool) selected));
}
}
}
diff --git a/src/choose_ignorepkgs_dialog.vala b/src/choose_ignorepkgs_dialog.vala
index 108f79d..75d6b7d 100644
--- a/src/choose_ignorepkgs_dialog.vala
+++ b/src/choose_ignorepkgs_dialog.vala
@@ -31,39 +31,21 @@ namespace Pamac {
public Gtk.ListStore pkgs_list;
- Transaction transaction;
-
- public ChooseIgnorepkgsDialog (Gtk.Window window, Transaction transaction) {
+ public ChooseIgnorepkgsDialog (Gtk.Window window) {
Object (transient_for: window, use_header_bar: 0);
- this.transaction = transaction;
-
label.set_markup ("%s".printf (dgettext (null, "Choose the packages you do not want to upgrade")));
pkgs_list = new Gtk.ListStore (2, typeof (bool), typeof (string));
treeview.set_model (pkgs_list);
- transaction.get_installed_pkgs.begin ((obj, res) => {
- Pamac.Package[] pkgs = transaction.get_installed_pkgs.end (res);
- Gtk.TreeIter iter;
- string[] already_ignorepkgs = transaction.get_ignorepkgs ();
- foreach (var pkg in pkgs) {
- if (pkg.name in already_ignorepkgs) {
- pkgs_list.insert_with_values (out iter, -1, 0, true, 1, pkg.name);
- } else {
- pkgs_list.insert_with_values (out iter, -1, 0, false, 1, pkg.name);
- }
- }
- });
}
[GtkCallback]
void on_renderertoggle_toggled (string path) {
Gtk.TreeIter iter;
- GLib.Value val;
- bool selected;
- if (pkgs_list.get_iter_from_string (out iter, path)) {;
- pkgs_list.get_value (iter, 0, out val);
- selected = val.get_boolean ();
- pkgs_list.set_value (iter, 0, !selected);
+ GLib.Value selected;
+ if (pkgs_list.get_iter_from_string (out iter, path)) {
+ pkgs_list.get_value (iter, 0, out selected);
+ pkgs_list.set_value (iter, 0, !((bool) selected));
}
}
}
diff --git a/src/choose_provider_dialog.vala b/src/choose_provider_dialog.vala
index 8b9dc74..a54ac56 100644
--- a/src/choose_provider_dialog.vala
+++ b/src/choose_provider_dialog.vala
@@ -27,14 +27,8 @@ namespace Pamac {
[GtkChild]
public Gtk.ComboBoxText comboboxtext;
- public ChooseProviderDialog (string depend, string[] providers, Gtk.ApplicationWindow? window) {
+ public ChooseProviderDialog (Gtk.ApplicationWindow? window) {
Object (transient_for: window, use_header_bar: 0);
-
- label.set_markup ("%s".printf (dgettext (null, "Choose a provider for %s").printf (depend)));
- foreach (string provider in providers) {
- comboboxtext.append_text (provider);
- }
- comboboxtext.active = 0;
}
}
}
diff --git a/src/common.vala b/src/common.vala
index 5986ab1..ebc09b8 100644
--- a/src/common.vala
+++ b/src/common.vala
@@ -18,7 +18,7 @@
*/
namespace Pamac {
- public struct UpdateInfos {
+ public struct PackageInfos {
public string name;
public string version;
public string db_name;
@@ -27,13 +27,8 @@ namespace Pamac {
public struct Updates {
public bool is_syncfirst;
- public UpdateInfos[] repos_updates;
- public UpdateInfos[] aur_updates;
- public Updates () {
- is_syncfirst = false;
- repos_updates = {};
- aur_updates = {};
- }
+ public PackageInfos[] repos_updates;
+ public PackageInfos[] aur_updates;
}
public struct ErrorInfos {
diff --git a/src/daemon.vala b/src/daemon.vala
index 4727b9c..960ad6e 100644
--- a/src/daemon.vala
+++ b/src/daemon.vala
@@ -17,9 +17,6 @@
* along with this program. If not, see .
*/
-using Alpm;
-using Polkit;
-
// i18n
const string GETTEXT_PACKAGE = "pamac";
@@ -27,46 +24,48 @@ Pamac.Daemon pamac_daemon;
MainLoop loop;
public delegate void AlpmActionDelegate ();
-
-public class AlpmAction: Object {
- unowned AlpmActionDelegate action_delegate;
- public AlpmAction (AlpmActionDelegate action_delegate) {
- this.action_delegate = action_delegate;
- }
- public void run () {
- action_delegate ();
- }
+
+[Compact]
+public class AlpmAction {
+ public unowned AlpmActionDelegate action_delegate;
+ public AlpmAction (AlpmActionDelegate action_delegate) {
+ this.action_delegate = action_delegate;
+ }
+ public void run () {
+ action_delegate ();
}
+}
namespace Pamac {
[DBus (name = "org.manjaro.pamac")]
public class Daemon : Object {
private Alpm.Config alpm_config;
- public uint64 previous_percent;
public Cond provider_cond;
public Mutex provider_mutex;
public int? choosen_provider;
- private int force_refresh;
+ private bool force_refresh;
private ThreadPool thread_pool;
private Mutex databases_lock_mutex;
- private HashTable aur_search_results;
private Json.Array aur_updates_results;
private bool intern_lock;
private bool extern_lock;
private GLib.File lockfile;
+ private ErrorInfos current_error;
+ public Timer timer;
public signal void emit_event (uint primary_event, uint secondary_event, string[] details);
public signal void emit_providers (string depend, string[] providers);
- public signal void emit_progress (uint progress, string pkgname, int percent, uint n_targets, uint current_target);
+ public signal void emit_progress (uint progress, string pkgname, uint percent, uint n_targets, uint current_target);
public signal void emit_download (string filename, uint64 xfered, uint64 total);
public signal void emit_totaldownload (uint64 total);
public signal void emit_log (uint level, string msg);
public signal void set_pkgreason_finished ();
- public signal void refresh_finished (ErrorInfos error);
- public signal void trans_prepare_finished (ErrorInfos error);
- public signal void trans_commit_finished (ErrorInfos error);
+ public signal void refresh_finished (bool success);
+ public signal void get_updates_finished (Updates updates);
+ public signal void trans_prepare_finished (bool success);
+ public signal void trans_commit_finished (bool success);
public signal void get_authorization_finished (bool authorized);
- public signal void write_pamac_config_finished (bool recurse, int refresh_period, bool no_update_hide_icon,
+ public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur, bool check_aur_updates,
bool no_confirm_build);
public signal void write_alpm_config_finished (bool checkspace);
@@ -77,16 +76,34 @@ namespace Pamac {
public Daemon () {
alpm_config = new Alpm.Config ("/etc/pacman.conf");
databases_lock_mutex = Mutex ();
- aur_search_results = new HashTable (str_hash, str_equal);
aur_updates_results = new Json.Array ();
+ timer = new Timer ();
intern_lock = false;
extern_lock = false;
- force_refresh = 0;
refresh_handle ();
Timeout.add (500, check_pacman_running);
create_thread_pool ();
}
+ public void set_environment_variables (HashTable variables) {
+ string[] keys = { "HTTP_USER_AGENT",
+ "http_proxy",
+ "https_proxy",
+ "ftp_proxy",
+ "socks_proxy",
+ "no_proxy" };
+ foreach (unowned string key in keys) {
+ unowned string val;
+ if (variables.lookup_extended (key, null, out val)) {
+ Environment.set_variable (key, val, true);
+ }
+ }
+ }
+
+ public ErrorInfos get_current_error () {
+ return current_error;
+ }
+
private void create_thread_pool () {
// create a thread pool which will run alpm action one after one
try {
@@ -108,30 +125,31 @@ namespace Pamac {
private void refresh_handle () {
alpm_config.get_handle ();
if (alpm_config.handle == null) {
- var err = ErrorInfos ();
- err.message = _("Failed to initialize alpm library");
- trans_commit_finished (err);
+ current_error = ErrorInfos () {
+ message = _("Failed to initialize alpm library"),
+ details = {}
+ };
+ trans_commit_finished (false);
} else {
- alpm_config.handle.eventcb = (EventCallBack) cb_event;
- alpm_config.handle.progresscb = (ProgressCallBack) cb_progress;
- alpm_config.handle.questioncb = (QuestionCallBack) cb_question;
- alpm_config.handle.dlcb = (DownloadCallBack) cb_download;
- alpm_config.handle.totaldlcb = (TotalDownloadCallBack) cb_totaldownload;
- alpm_config.handle.logcb = (LogCallBack) cb_log;
+ alpm_config.handle.eventcb = (Alpm.EventCallBack) cb_event;
+ alpm_config.handle.progresscb = (Alpm.ProgressCallBack) cb_progress;
+ alpm_config.handle.questioncb = (Alpm.QuestionCallBack) cb_question;
+ alpm_config.handle.dlcb = (Alpm.DownloadCallBack) cb_download;
+ alpm_config.handle.totaldlcb = (Alpm.TotalDownloadCallBack) cb_totaldownload;
+ alpm_config.handle.logcb = (Alpm.LogCallBack) cb_log;
lockfile = GLib.File.new_for_path (alpm_config.handle.lockfile);
}
- previous_percent = 0;
}
private bool check_pacman_running () {
if (extern_lock) {
- if (lockfile.query_exists () == false) {
+ if (!lockfile.query_exists ()) {
extern_lock = false;
refresh_handle ();
}
} else {
- if (lockfile.query_exists () == true) {
- if (intern_lock == false) {
+ if (lockfile.query_exists ()) {
+ if (!intern_lock) {
extern_lock = true;
}
}
@@ -161,10 +179,10 @@ namespace Pamac {
Idle.add ((owned) callback);
}
);
+ yield;
} catch (GLib.Error e) {
stderr.printf ("%s\n", e.message);
}
- yield;
return authorized;
}
@@ -197,7 +215,7 @@ namespace Pamac {
alpm_config.reload ();
refresh_handle ();
}
- write_alpm_config_finished (get_checkspace ());
+ write_alpm_config_finished ((alpm_config.checkspace == 1));
});
}
@@ -282,32 +300,48 @@ namespace Pamac {
});
}
+ public PackageInfos get_installed_pkg (string pkgname) {
+ unowned Alpm.Package? pkg = alpm_config.handle.localdb.get_pkg (pkgname);
+ if (pkg == null) {
+ return PackageInfos () {
+ name = "",
+ version = "",
+ db_name = "",
+ download_size = 0
+ };
+ }
+ return PackageInfos () {
+ name = pkg.name,
+ version = pkg.version,
+ db_name = pkg.db.name,
+ download_size = pkg.download_size
+ };
+ }
+
private void refresh () {
intern_lock = true;
- var err = ErrorInfos ();
- string[] details = {};
- int success = 0;
- int ret;
+ current_error = ErrorInfos ();
+ int force = (force_refresh) ? 1 : 0;
+ uint success = 0;
foreach (var db in alpm_config.handle.syncdbs) {
- ret = db.update (force_refresh);
- if (ret >= 0) {
+ if (db.update (force) >= 0) {
success++;
}
}
+ refresh_handle ();
// We should always succeed if at least one DB was upgraded - we may possibly
// fail later with unresolved deps, but that should be rare, and would be expected
if (success == 0) {
- err.message = _("Failed to synchronize any databases");
- details += Alpm.strerror (alpm_config.handle.errno ());
- err.details = details;
+ current_error.message = _("Failed to synchronize any databases");
+ current_error.details = { Alpm.strerror (alpm_config.handle.errno ()) };
+ refresh_finished (false);
+ } else {
+ refresh_finished (true);
}
- refresh_handle ();
- refresh_finished (err);
- force_refresh = 0;
intern_lock = false;
}
- public void start_refresh (int force) {
+ public void start_refresh (bool force) {
force_refresh = force;
try {
thread_pool.add (new AlpmAction (refresh));
@@ -316,18 +350,6 @@ namespace Pamac {
}
}
- public bool get_checkspace () {
- return alpm_config.checkspace == 1 ? true : false;
- }
-
- public string[] get_ignorepkgs () {
- string[] ignorepkgs = {};
- for (size_t i = 0; i < alpm_config.ignorepkgs->length; i++) {
- ignorepkgs += alpm_config.ignorepkgs->nth_data (i);
- }
- return ignorepkgs;
- }
-
public void add_ignorepkg (string pkgname) {
alpm_config.handle.add_ignorepkg (pkgname);
}
@@ -336,338 +358,8 @@ namespace Pamac {
alpm_config.handle.remove_ignorepkg (pkgname);
}
- public bool should_hold (string pkgname) {
- if (alpm_config.holdpkgs.find_custom (pkgname, strcmp) != null) {
- return true;
- }
- return false;
- }
-
- public async Pamac.Package[] get_all_pkgs () {
- Pamac.Package[] pkgs = {};
- var alpm_pkgs = all_pkgs (alpm_config.handle);
- foreach (var alpm_pkg in alpm_pkgs) {
- pkgs += Pamac.Package (alpm_pkg, null);
- }
- return pkgs;
- }
-
- public async Pamac.Package[] get_installed_pkgs () {
- Pamac.Package[] pkgs = {};
- foreach (var alpm_pkg in alpm_config.handle.localdb.pkgcache) {
- pkgs += Pamac.Package (alpm_pkg, null);
- }
- return pkgs;
- }
-
- public async Pamac.Package[] get_local_pkgs () {
- Pamac.Package[] pkgs = {};
- foreach (var alpm_pkg in alpm_config.handle.localdb.pkgcache) {
- bool sync_found = false;
- foreach (var db in alpm_config.handle.syncdbs) {
- unowned Alpm.Package? sync_pkg = db.get_pkg (alpm_pkg.name);
- if (sync_pkg != null) {
- sync_found = true;
- break;
- }
- }
- if (sync_found == false) {
- pkgs += Pamac.Package (alpm_pkg, null);
- }
- }
- return pkgs;
- }
-
- public async Pamac.Package[] get_orphans () {
- Pamac.Package[] pkgs = {};
- foreach (var alpm_pkg in alpm_config.handle.localdb.pkgcache) {
- if (alpm_pkg.reason == Alpm.Package.Reason.DEPEND) {
- Alpm.List *requiredby = alpm_pkg.compute_requiredby ();
- if (requiredby->length == 0) {
- Alpm.List *optionalfor = alpm_pkg.compute_optionalfor ();
- if (optionalfor->length == 0) {
- pkgs += Pamac.Package (alpm_pkg, null);
- }
- Alpm.List.free_all (optionalfor);
- }
- Alpm.List.free_all (requiredby);
- }
- }
- return pkgs;
- }
-
- public Pamac.Package find_local_pkg (string pkgname) {
- return Pamac.Package (alpm_config.handle.localdb.get_pkg (pkgname), null);
- }
-
- public Pamac.Package find_local_satisfier (string pkgname) {
- return Pamac.Package (Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, pkgname), null);
- }
-
- private unowned Alpm.Package? get_syncpkg (string name) {
- unowned Alpm.Package? pkg = null;
- foreach (var db in alpm_config.handle.syncdbs) {
- pkg = db.get_pkg (name);
- if (pkg != null) {
- break;
- }
- }
- return pkg;
- }
-
- public Pamac.Package find_sync_pkg (string pkgname) {
- return Pamac.Package (get_syncpkg (pkgname), null);
- }
-
- public async Pamac.Package[] search_pkgs (string search_string, bool search_aur) {
- Pamac.Package[] result = {};
- var needles = new Alpm.List ();
- string[] splitted = search_string.split (" ");
- foreach (unowned string part in splitted) {
- needles.add (part);
- }
- var alpm_pkgs = search_all_dbs (alpm_config.handle, needles);
- foreach (var alpm_pkg in alpm_pkgs) {
- result += Pamac.Package (alpm_pkg, null);
- }
- if (search_aur) {
- Json.Array aur_pkgs;
- if (aur_search_results.contains (search_string)) {
- aur_pkgs = aur_search_results.get (search_string);
- } else {
- aur_pkgs = AUR.search (splitted);
- aur_search_results.insert (search_string, aur_pkgs);
- }
- aur_pkgs.foreach_element ((array, index, node) => {
- var aur_pkg = node.get_object ();
- var pamac_pkg = Pamac.Package (null, aur_pkg);
- bool found = false;
- foreach (var pkg in result) {
- if (pkg.name == pamac_pkg.name) {
- found = true;
- break;
- }
- }
- if (found == false) {
- result += pamac_pkg;
- }
- });
- }
- return result;
- }
-
- public string[] get_repos_names () {
- string[] repos_names = {};
- foreach (var db in alpm_config.handle.syncdbs) {
- repos_names += db.name;
- }
- return repos_names;
- }
-
- public async Pamac.Package[] get_repo_pkgs (string repo) {
- Pamac.Package[] pkgs = {};
- unowned Alpm.Package? local_pkg = null;
- foreach (var db in alpm_config.handle.syncdbs) {
- if (db.name == repo) {
- foreach (var sync_pkg in db.pkgcache) {
- local_pkg = alpm_config.handle.localdb.get_pkg (sync_pkg.name);
- if (local_pkg != null) {
- pkgs += Pamac.Package (local_pkg, null);
- } else {
- pkgs += Pamac.Package (sync_pkg, null);
- }
- }
- }
- }
- return pkgs;
- }
-
- public string[] get_groups_names () {
- string[] groups_names = {};
- foreach (var db in alpm_config.handle.syncdbs) {
- foreach (var group in db.groupcache) {
- if ((group.name in groups_names) == false) {
- groups_names += group.name;
- }
- }
- }
- return groups_names;
- }
-
- public async Pamac.Package[] get_group_pkgs (string groupname) {
- Pamac.Package[] pkgs = {};
- var alpm_pkgs = group_pkgs (alpm_config.handle, groupname);
- foreach (var alpm_pkg in alpm_pkgs) {
- pkgs += Pamac.Package (alpm_pkg, null);
- }
- return pkgs;
- }
-
- public string[] get_pkg_files (string pkgname) {
- string[] files = {};
- unowned Alpm.Package? alpm_pkg = alpm_config.handle.localdb.get_pkg (pkgname);
- if (alpm_pkg != null) {
- foreach (var file in alpm_pkg.files) {
- files += file.name;
- }
- }
- return files;
- }
-
- public string[] get_pkg_uninstalled_optdeps (string pkgname) {
- string[] optdeps = {};
- unowned Alpm.Package? alpm_pkg = alpm_config.handle.localdb.get_pkg (pkgname);
- if (alpm_pkg == null) {
- alpm_pkg = get_syncpkg (pkgname);
- }
- if (alpm_pkg != null) {
- foreach (unowned Depend optdep in alpm_pkg.optdepends) {
- if (Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, optdep.name) == null) {
- optdeps += optdep.compute_string ();
- }
- }
- }
- return optdeps;
- }
-
- public PackageDetails get_pkg_details (string pkgname) {
- string repo = "";
- string has_signature = _("No");
- int reason = 0;
- string packager = "";
- string build_date = "";
- string install_date = "";
- string[] groups = {};
- string[] backups = {};
- var details = PackageDetails ();
- unowned Alpm.Package? alpm_pkg = alpm_config.handle.localdb.get_pkg (pkgname);
- if (alpm_pkg == null) {
- alpm_pkg = get_syncpkg (pkgname);
- }
- if (alpm_pkg == null) {
- // search for the corresponding Json.Object in aur_search_result
- var iter = HashTableIter (aur_search_results);
- unowned Json.Array array;
- bool found = false;
- while (iter.next (null, out array)) {
- array.foreach_element((array, index, node) => {
- var pkg_info = node.get_object ();
- if (pkg_info.get_string_member ("Name") == pkgname) {
- found = true;
- repo = "AUR";
- if (!pkg_info.get_null_member ("OutOfDate")) {
- GLib.Time time = GLib.Time.local ((time_t) pkg_info.get_int_member ("OutOfDate"));
- has_signature = time.format ("%a %d %b %Y %X %Z");
- }
- reason = (int) pkg_info.get_int_member ("NumVotes");
- packager = pkg_info.get_string_member ("Maintainer") ?? "";
- GLib.Time time = GLib.Time.local ((time_t) pkg_info.get_int_member ("FirstSubmitted"));
- build_date = time.format ("%a %d %b %Y %X %Z");
- time = GLib.Time.local ((time_t) pkg_info.get_int_member ("LastModified"));
- install_date = time.format ("%a %d %b %Y %X %Z");
- }
- });
- if (found) {
- break;
- }
- }
- } else {
- packager = alpm_pkg.packager ?? "";
- foreach (var group in alpm_pkg.groups) {
- groups += group;
- }
- GLib.Time time = GLib.Time.local ((time_t) alpm_pkg.builddate);
- build_date = time.format ("%a %d %b %Y %X %Z");
- if (alpm_pkg.db != null) {
- repo = alpm_pkg.db.name ?? "";
- if (alpm_pkg.db.name == "local") {
- reason = alpm_pkg.reason;
- time = GLib.Time.local ((time_t) alpm_pkg.installdate);
- install_date = time.format ("%a %d %b %Y %X %Z");
- foreach (var backup in alpm_pkg.backups) {
- backups += backup.name;
- }
- } else {
- has_signature = alpm_pkg.base64_sig != null ? _("Yes") : _("No");
- }
- }
- }
- details.repo = repo;
- details.has_signature = has_signature;
- details.reason = reason;
- details.packager = packager;
- details.build_date = build_date;
- details.install_date = install_date;
- details.groups = groups;
- details.backups = backups;
- return details;
- }
-
- public PackageDeps get_pkg_deps (string pkgname) {
- string repo = "";
- string[] depends = {};
- string[] optdepends = {};
- string[] requiredby = {};
- string[] optionalfor = {};
- string[] provides = {};
- string[] replaces = {};
- string[] conflicts = {};
- var deps = PackageDeps ();
- unowned Alpm.Package? alpm_pkg = alpm_config.handle.localdb.get_pkg (pkgname);
- if (alpm_pkg == null) {
- alpm_pkg = get_syncpkg (pkgname);
- }
- if (alpm_pkg != null) {
- repo = alpm_pkg.db.name;
- foreach (var depend in alpm_pkg.depends) {
- depends += depend.compute_string ();
- }
- foreach (var optdepend in alpm_pkg.optdepends) {
- optdepends += optdepend.compute_string ();
- }
- foreach (var provide in alpm_pkg.provides) {
- provides += provide.compute_string ();
- }
- foreach (var replace in alpm_pkg.replaces) {
- replaces += replace.compute_string ();
- }
- foreach (var conflict in alpm_pkg.conflicts) {
- conflicts += conflict.compute_string ();
- }
- if (alpm_pkg.db.name == "local") {
- Alpm.List *list = alpm_pkg.compute_requiredby ();
- int i = 0;
- while (i < list->length) {
- requiredby += list->nth_data (i);
- i++;
- }
- Alpm.List.free_all (list);
- }
- if (alpm_pkg.db.name == "local") {
- Alpm.List *list = alpm_pkg.compute_optionalfor ();
- int i = 0;
- while (i < list->length) {
- optionalfor += list->nth_data (i);
- i++;
- }
- Alpm.List.free_all (list);
- }
- }
- deps.repo = repo;
- deps.depends = depends;
- deps.optdepends = optdepends;
- deps.requiredby = requiredby;
- deps.optionalfor = optionalfor;
- deps.provides = provides;
- deps.replaces = replaces;
- deps.conflicts = conflicts;
- return deps;
- }
-
- public async Updates get_updates (bool check_aur_updates) {
- var infos = UpdateInfos ();
- UpdateInfos[] updates_infos = {};
- var updates = Updates ();
+ public void start_get_updates (bool check_aur_updates) {
+ PackageInfos[] updates_infos = {};
unowned Alpm.Package? pkg = null;
unowned Alpm.Package? candidate = null;
foreach (var name in alpm_config.syncfirsts) {
@@ -675,18 +367,24 @@ namespace Pamac {
if (pkg != null) {
candidate = pkg.sync_newversion (alpm_config.handle.syncdbs);
if (candidate != null) {
- infos.name = candidate.name;
- infos.version = candidate.version;
- infos.db_name = candidate.db.name;
- infos.download_size = candidate.download_size;
- updates_infos += infos;
+ var infos = PackageInfos () {
+ name = candidate.name,
+ version = candidate.version,
+ db_name = candidate.db.name,
+ download_size = candidate.download_size
+ };
+ updates_infos += (owned) infos;
}
}
}
if (updates_infos.length != 0) {
- updates.is_syncfirst = true;
- updates.repos_updates = updates_infos;
- return updates;
+ var updates = Updates () {
+ is_syncfirst = true,
+ repos_updates = (owned) updates_infos,
+ aur_updates = {}
+ };
+ get_updates_finished (updates);
+ return;
} else {
string[] local_pkgs = {};
foreach (var installed_pkg in alpm_config.handle.localdb.pkgcache) {
@@ -694,11 +392,13 @@ namespace Pamac {
if (alpm_config.handle.should_ignore (installed_pkg) == 0) {
candidate = installed_pkg.sync_newversion (alpm_config.handle.syncdbs);
if (candidate != null) {
- infos.name = candidate.name;
- infos.version = candidate.version;
- infos.db_name = candidate.db.name;
- infos.download_size = candidate.download_size;
- updates_infos += infos;
+ var infos = PackageInfos () {
+ name = candidate.name,
+ version = candidate.version,
+ db_name = candidate.db.name,
+ download_size = candidate.download_size
+ };
+ updates_infos += (owned) infos;
} else {
if (check_aur_updates) {
// check if installed_pkg is a local pkg
@@ -715,89 +415,96 @@ namespace Pamac {
}
}
}
- updates.repos_updates = updates_infos;
+ PackageInfos[] aur_updates_infos = {};
if (check_aur_updates) {
// get aur updates
if (aur_updates_results.get_length () == 0) {
aur_updates_results = AUR.multiinfo (local_pkgs);
}
- updates_infos = {};
aur_updates_results.foreach_element ((array, index,node) => {
unowned Json.Object pkg_info = node.get_object ();
string version = pkg_info.get_string_member ("Version");
string name = pkg_info.get_string_member ("Name");
int cmp = Alpm.pkg_vercmp (version, alpm_config.handle.localdb.get_pkg (name).version);
if (cmp == 1) {
- infos.name = name;
- infos.version = version;
- infos.db_name = "AUR";
- infos.download_size = 0;
- updates_infos += infos;
+ var infos = PackageInfos () {
+ name = name,
+ version = version,
+ db_name = "AUR",
+ download_size = 0
+ };
+ aur_updates_infos += (owned) infos;
}
});
- updates.aur_updates = updates_infos;
}
- return updates;
+ var updates = Updates () {
+ is_syncfirst = false,
+ repos_updates = (owned) updates_infos,
+ aur_updates = (owned) aur_updates_infos
+ };
+ get_updates_finished (updates);
}
}
- public ErrorInfos trans_init (TransFlag transflags) {
- var err = ErrorInfos ();
- string[] details = {};
- int ret = alpm_config.handle.trans_init (transflags);
- if (ret == -1) {
- err.message = _("Failed to init transaction");
- details += Alpm.strerror (alpm_config.handle.errno ());
- err.details = details;
+ public bool trans_init (Alpm.TransFlag transflags) {
+ current_error = ErrorInfos ();
+ if (alpm_config.handle.trans_init (transflags) == -1) {
+ current_error.message = _("Failed to init transaction");
+ current_error.details = { Alpm.strerror (alpm_config.handle.errno ()) };
+ return false;
} else {
intern_lock = true;
}
- return err;
+ return true;
}
- public ErrorInfos trans_sysupgrade (int enable_downgrade) {
- var err = ErrorInfos ();
- string[] details = {};
- int ret = alpm_config.handle.trans_sysupgrade (enable_downgrade);
- if (ret == -1) {
- err.message = _("Failed to prepare transaction");
- details += Alpm.strerror (alpm_config.handle.errno ());
- err.details = details;
+ public bool trans_sysupgrade (bool enable_downgrade) {
+ current_error = ErrorInfos ();
+ if (alpm_config.handle.trans_sysupgrade ((enable_downgrade) ? 1 : 0) == -1) {
+ current_error.message = _("Failed to prepare transaction");
+ current_error.details = { Alpm.strerror (alpm_config.handle.errno ()) };
+ return false;
}
- return err;
+ return true;
}
- private ErrorInfos trans_add_pkg_real (Alpm.Package pkg) {
- var err = ErrorInfos ();
- string[] details = {};
- int ret = alpm_config.handle.trans_add_pkg (pkg);
- if (ret == -1) {
+ private bool trans_add_pkg_real (Alpm.Package pkg) {
+ current_error = ErrorInfos ();
+ if (alpm_config.handle.trans_add_pkg (pkg) == -1) {
Alpm.Errno errno = alpm_config.handle.errno ();
- if (errno == Errno.TRANS_DUP_TARGET || errno == Errno.PKG_IGNORED) {
+ if (errno == Alpm.Errno.TRANS_DUP_TARGET || errno == Alpm.Errno.PKG_IGNORED) {
// just skip duplicate or ignored targets
- return err;
+ return true;
} else {
- err.message = _("Failed to prepare transaction");
- details += "%s: %s".printf (pkg.name, Alpm.strerror (errno));
- err.details = details;
- return err;
+ current_error.message = _("Failed to prepare transaction");
+ current_error.details = { "%s: %s".printf (pkg.name, Alpm.strerror (errno)) };
+ return false;
}
}
- return err;
+ return true;
}
- public ErrorInfos trans_add_pkg (string pkgname) {
- var err = ErrorInfos ();
- string[] details = {};
- unowned Alpm.Package? pkg = get_syncpkg (pkgname);
+ private unowned Alpm.Package? get_sync_pkg (string pkgname) {
+ unowned Alpm.Package? pkg = null;
+ foreach (var db in alpm_config.handle.syncdbs) {
+ pkg = db.get_pkg (pkgname);
+ if (pkg != null) {
+ break;
+ }
+ }
+ return pkg;
+ }
+
+ public bool trans_add_pkg (string pkgname) {
+ current_error = ErrorInfos ();
+ unowned Alpm.Package? pkg = get_sync_pkg (pkgname);
if (pkg == null) {
- err.message = _("Failed to prepare transaction");
- details += _("target not found: %s").printf (pkgname);
- err.details = details;
- return err;
+ current_error.message = _("Failed to prepare transaction");
+ current_error.details = { _("target not found: %s").printf (pkgname) };
+ return false;
} else {
- err = trans_add_pkg_real (pkg);
- if (err.message == "") {
+ bool success = trans_add_pkg_real (pkg);
+ if (success) {
if (("linux31" in pkg.name) || ("linux4" in pkg.name)) {
string[] installed_kernels = {};
string[] installed_modules = {};
@@ -818,9 +525,9 @@ namespace Pamac {
if (splitted.length == 2) {
// we are adding a module
// add the same module for other installed kernels
- foreach (var installed_kernel in installed_kernels) {
+ foreach (unowned string installed_kernel in installed_kernels) {
string module = installed_kernel + "-" + splitted[1];
- unowned Alpm.Package? module_pkg = get_syncpkg (module);
+ unowned Alpm.Package? module_pkg = get_sync_pkg (module);
if (module_pkg != null) {
trans_add_pkg_real (module_pkg);
}
@@ -828,9 +535,9 @@ namespace Pamac {
} else if (splitted.length == 1) {
// we are adding a kernel
// add all installed modules for other kernels
- foreach (var installed_module in installed_modules) {
+ foreach (unowned string installed_module in installed_modules) {
string module = splitted[0] + "-" + installed_module;
- unowned Alpm.Package? module_pkg = get_syncpkg (module);
+ unowned Alpm.Package? module_pkg = get_sync_pkg (module);
if (module_pkg != null) {
trans_add_pkg_real (module_pkg);
}
@@ -838,107 +545,90 @@ namespace Pamac {
}
}
}
- return err;
+ return success;
}
}
- public ErrorInfos trans_load_pkg (string pkgpath) {
- var err = ErrorInfos ();
- string[] details = {};
+ public bool trans_load_pkg (string pkgpath) {
+ current_error = ErrorInfos ();
Alpm.Package* pkg = alpm_config.handle.load_file (pkgpath, 1, alpm_config.handle.localfilesiglevel);
if (pkg == null) {
- err.message = _("Failed to prepare transaction");
- details += "%s: %s".printf (pkgpath, Alpm.strerror (alpm_config.handle.errno ()));
- err.details = details;
- return err;
- } else {
- int ret = alpm_config.handle.trans_add_pkg (pkg);
- if (ret == -1) {
- Alpm.Errno errno = alpm_config.handle.errno ();
- if (errno == Errno.TRANS_DUP_TARGET || errno == Errno.PKG_IGNORED) {
- // just skip duplicate or ignored targets
- return err;
- } else {
- err.message = _("Failed to prepare transaction");
- details += "%s: %s".printf (pkg->name, Alpm.strerror (errno));
- err.details = details;
- // free the package because it will not be used
- delete pkg;
- return err;
- }
- }
+ current_error.message = _("Failed to prepare transaction");
+ current_error.details = { "%s: %s".printf (pkgpath, Alpm.strerror (alpm_config.handle.errno ())) };
+ return false;
+ } else if (alpm_config.handle.trans_add_pkg (pkg) == -1) {
+ current_error.message = _("Failed to prepare transaction");
+ current_error.details = { "%s: %s".printf (pkg->name, Alpm.strerror (alpm_config.handle.errno ())) };
+ // free the package because it will not be used
+ delete pkg;
+ return false;
}
- return err;
+ return true;
}
- public ErrorInfos trans_remove_pkg (string pkgname) {
- var err = ErrorInfos ();
- string[] details = {};
+ public bool trans_remove_pkg (string pkgname) {
+ current_error = ErrorInfos ();
unowned Alpm.Package? pkg = alpm_config.handle.localdb.get_pkg (pkgname);
if (pkg == null) {
- err.message = _("Failed to prepare transaction");
- details += _("target not found: %s").printf (pkgname);
- err.details = details;
- return err;
- }
- int ret = alpm_config.handle.trans_remove_pkg (pkg);
- if (ret == -1) {
- err.message = _("Failed to prepare transaction");
- details += "%s: %s".printf (pkg.name, Alpm.strerror (alpm_config.handle.errno ()));
- err.details = details;
+ current_error.message = _("Failed to prepare transaction");
+ current_error.details = { _("target not found: %s").printf (pkgname) };
+ return false;
+ } else if (alpm_config.handle.trans_remove_pkg (pkg) == -1) {
+ current_error.message = _("Failed to prepare transaction");
+ current_error.details = { "%s: %s".printf (pkg.name, Alpm.strerror (alpm_config.handle.errno ())) };
+ return false;
}
- return err;
+ return true;
}
private void trans_prepare () {
- var err = ErrorInfos ();
+ current_error = ErrorInfos ();
string[] details = {};
- Alpm.List err_data = null;
- int ret = alpm_config.handle.trans_prepare (out err_data);
- if (ret == -1) {
+ Alpm.List err_data;
+ if (alpm_config.handle.trans_prepare (out err_data) == -1) {
Alpm.Errno errno = alpm_config.handle.errno ();
- err.message = _("Failed to prepare transaction");
+ current_error.message = _("Failed to prepare transaction");
string detail = Alpm.strerror (errno);
switch (errno) {
- case Errno.PKG_INVALID_ARCH:
+ case Alpm.Errno.PKG_INVALID_ARCH:
detail += ":";
- details += detail;
- foreach (void *i in err_data) {
- string *pkgname = i;
+ details += (owned) detail;
+ foreach (void* i in err_data) {
+ string* pkgname = i;
details += _("package %s does not have a valid architecture").printf (pkgname);
delete pkgname;
}
break;
- case Errno.UNSATISFIED_DEPS:
+ case Alpm.Errno.UNSATISFIED_DEPS:
detail += ":";
- details += detail;
- foreach (void *i in err_data) {
- DepMissing *miss = i;
- string depstring = miss->depend.compute_string ();
- details += _("%s: requires %s").printf (miss->target, depstring);
+ details += (owned) detail;
+ foreach (void* i in err_data) {
+ Alpm.DepMissing* miss = i;
+ details += _("%s: requires %s").printf (miss->target, miss->depend.compute_string ());
delete miss;
}
break;
- case Errno.CONFLICTING_DEPS:
+ case Alpm.Errno.CONFLICTING_DEPS:
detail += ":";
- details += detail;
- foreach (void *i in err_data) {
- Conflict *conflict = i;
- detail = _("%s and %s are in conflict").printf (conflict->package1, conflict->package2);
+ details += (owned) detail;
+ foreach (void* i in err_data) {
+ Alpm.Conflict* conflict = i;
+ string conflict_detail = _("%s and %s are in conflict").printf (conflict->package1, conflict->package2);
// only print reason if it contains new information
- if (conflict->reason.mod != Depend.Mode.ANY) {
- detail += " (%s)".printf (conflict->reason.compute_string ());
+ if (conflict->reason.mod != Alpm.Depend.Mode.ANY) {
+ conflict_detail += " (%s)".printf (conflict->reason.compute_string ());
}
- details += detail;
+ details += (owned) conflict_detail;
delete conflict;
}
break;
default:
- details += detail;
+ details += (owned) detail;
break;
}
- err.details = details;
+ current_error.details = (owned) details;
trans_release ();
+ trans_prepare_finished (false);
} else {
// Search for holdpkg in target list
bool found_locked_pkg = false;
@@ -950,12 +640,14 @@ namespace Pamac {
}
}
if (found_locked_pkg) {
- err.message = _("Failed to prepare transaction");
- err.details = details;
+ current_error.message = _("Failed to prepare transaction");
+ current_error.details = (owned) details;
trans_release ();
+ trans_prepare_finished (false);
+ } else {
+ trans_prepare_finished (true);
}
}
- trans_prepare_finished (err);
}
public void start_trans_prepare () {
@@ -973,61 +665,59 @@ namespace Pamac {
provider_mutex.unlock ();
}
- public UpdateInfos[] trans_to_add () {
- UpdateInfos info = UpdateInfos ();
- UpdateInfos[] infos = {};
+ public PackageInfos[] trans_to_add () {
+ PackageInfos[] to_add = {};
foreach (var pkg in alpm_config.handle.trans_to_add ()) {
- info.name = pkg.name;
- info.version = pkg.version;
- // if pkg was load from a file, pkg.db is null
- if (pkg.db != null) {
- info.db_name = pkg.db.name;
- } else {
- info.db_name = "";
- }
- info.download_size = pkg.download_size;
- infos += info;
+ var infos = PackageInfos () {
+ name = pkg.name,
+ version = pkg.version,
+ // if pkg was load from a file, pkg.db is null
+ db_name = pkg.db != null ? pkg.db.name : "",
+ download_size = pkg.download_size
+ };
+ to_add += (owned) infos;
}
- return infos;
+ return to_add;
}
- public UpdateInfos[] trans_to_remove () {
- UpdateInfos info = UpdateInfos ();
- UpdateInfos[] infos = {};
+ public PackageInfos[] trans_to_remove () {
+ PackageInfos[] to_remove = {};
foreach (var pkg in alpm_config.handle.trans_to_remove ()) {
- info.name = pkg.name;
- info.version = pkg.version;
- info.db_name = pkg.db.name;
- info.download_size = pkg.download_size;
- infos += info;
+ var infos = PackageInfos () {
+ name = pkg.name,
+ version = pkg.version,
+ db_name = pkg.db.name,
+ download_size = pkg.download_size
+ };
+ to_remove += (owned) infos;
}
- return infos;
+ return to_remove;
}
private void trans_commit () {
- var err = ErrorInfos ();
- string[] details = {};
- Alpm.List err_data = null;
- int ret = alpm_config.handle.trans_commit (out err_data);
- if (ret == -1) {
+ current_error = ErrorInfos ();
+ bool success = true;
+ Alpm.List err_data;
+ if (alpm_config.handle.trans_commit (out err_data) == -1) {
Alpm.Errno errno = alpm_config.handle.errno ();
- err.message = _("Failed to commit transaction");
+ current_error.message = _("Failed to commit transaction");
string detail = Alpm.strerror (errno);
+ string[] details = {};
switch (errno) {
case Alpm.Errno.FILE_CONFLICTS:
detail += ":";
- details += detail;
+ details += (owned) detail;
//TransFlag flags = alpm_config.handle.trans_get_flags ();
//if ((flags & TransFlag.FORCE) != 0) {
//details += _("unable to %s directory-file conflicts").printf ("--force");
//}
- foreach (void *i in err_data) {
- FileConflict *conflict = i;
+ foreach (void* i in err_data) {
+ Alpm.FileConflict* conflict = i;
switch (conflict->type) {
- case FileConflict.Type.TARGET:
+ case Alpm.FileConflict.Type.TARGET:
details += _("%s exists in both %s and %s").printf (conflict->file, conflict->target, conflict->ctarget);
break;
- case FileConflict.Type.FILESYSTEM:
+ case Alpm.FileConflict.Type.FILESYSTEM:
details += _("%s: %s already exists in filesystem").printf (conflict->target, conflict->file);
break;
}
@@ -1039,23 +729,23 @@ namespace Pamac {
case Alpm.Errno.PKG_INVALID_SIG:
case Alpm.Errno.DLT_INVALID:
detail += ":";
- details += detail;
- foreach (void *i in err_data) {
- string *filename = i;
+ details += (owned) detail;
+ foreach (void* i in err_data) {
+ string* filename = i;
details += _("%s is invalid or corrupted").printf (filename);
delete filename;
}
break;
default:
- details += detail;
+ details += (owned) detail;
break;
}
- err.details = details;
+ current_error.details = (owned) details;
+ success = false;
}
trans_release ();
refresh_handle ();
- trans_commit_finished (err);
- intern_lock = false;
+ trans_commit_finished (success);
}
public void start_trans_commit (GLib.BusName sender) {
@@ -1068,31 +758,35 @@ namespace Pamac {
stderr.printf ("Thread Error %s\n", e.message);
}
} else {
- var err = ErrorInfos ();
- err.message = _("Authentication failed");
+ current_error = ErrorInfos () {
+ message = _("Authentication failed"),
+ details = {}
+ };
trans_release ();
refresh_handle ();
- trans_commit_finished (err);
- intern_lock = false;
+ trans_commit_finished (false);
}
});
}
- public int trans_release () {
- return alpm_config.handle.trans_release ();
+ public void trans_release () {
+ alpm_config.handle.trans_release ();
+ intern_lock = false;
}
+ [DBus (no_reply = true)]
public void trans_cancel () {
if (alpm_config.handle.trans_interrupt () == 0) {
// a transaction is being interrupted
// it will end the normal way
return;
}
- var err = ErrorInfos ();
- trans_release ();
- refresh_handle ();
- trans_commit_finished (err);
+ Posix.raise (Posix.SIGINT);
+ current_error = ErrorInfos ();
+ trans_commit_finished (false);
+ alpm_config.handle.unlock ();
intern_lock = false;
+ refresh_handle ();
}
[DBus (no_reply = true)]
@@ -1101,6 +795,7 @@ namespace Pamac {
// the above function will wait for all task in queue
// to be processed before return;
ThreadPool.free ((owned) thread_pool, false, true);
+ alpm_config.handle.unlock ();
loop.quit ();
}
// End of Daemon Object
@@ -1121,11 +816,29 @@ private void write_log_file (string event) {
}
}
-private void cb_event (Event.Data data) {
+private void cb_event (Alpm.Event.Data data) {
string[] details = {};
uint secondary_type = 0;
switch (data.type) {
- case Event.Type.PACKAGE_OPERATION_START:
+ case Alpm.Event.Type.HOOK_START:
+ switch (data.hook_when) {
+ case Alpm.HookWhen.PRE_TRANSACTION:
+ secondary_type = (uint) Alpm.HookWhen.PRE_TRANSACTION;
+ break;
+ case Alpm.HookWhen.POST_TRANSACTION:
+ secondary_type = (uint) Alpm.HookWhen.POST_TRANSACTION;
+ break;
+ default:
+ break;
+ }
+ break;
+ case Alpm.Event.Type.HOOK_RUN_START:
+ details += data.hook_run_name;
+ details += data.hook_run_desc;
+ details += data.hook_run_position.to_string ();
+ details += data.hook_run_total.to_string ();
+ break;
+ case Alpm.Event.Type.PACKAGE_OPERATION_START:
switch (data.package_operation_operation) {
case Alpm.Package.Operation.REMOVE:
details += data.package_operation_oldpkg.name;
@@ -1154,9 +867,11 @@ private void cb_event (Event.Data data) {
details += data.package_operation_newpkg.version;
secondary_type = (uint) Alpm.Package.Operation.DOWNGRADE;
break;
+ default:
+ break;
}
break;
- case Event.Type.PACKAGE_OPERATION_DONE:
+ case Alpm.Event.Type.PACKAGE_OPERATION_DONE:
switch (data.package_operation_operation) {
case Alpm.Package.Operation.INSTALL:
string log = "Installed %s (%s)\n".printf (data.package_operation_newpkg.name, data.package_operation_newpkg.version);
@@ -1180,58 +895,55 @@ private void cb_event (Event.Data data) {
break;
}
break;
- case Event.Type.DELTA_PATCH_START:
+ case Alpm.Event.Type.DELTA_PATCH_START:
details += data.delta_patch_delta.to;
details += data.delta_patch_delta.delta;
break;
- case Event.Type.SCRIPTLET_INFO:
+ case Alpm.Event.Type.SCRIPTLET_INFO:
details += data.scriptlet_info_line;
write_log_file (data.scriptlet_info_line);
break;
- case Event.Type.PKGDOWNLOAD_START:
+ case Alpm.Event.Type.PKGDOWNLOAD_START:
details += data.pkgdownload_file;
break;
- case Event.Type.OPTDEP_REMOVAL:
+ case Alpm.Event.Type.OPTDEP_REMOVAL:
details += data.optdep_removal_pkg.name;
details += data.optdep_removal_optdep.compute_string ();
break;
- case Event.Type.DATABASE_MISSING:
+ case Alpm.Event.Type.DATABASE_MISSING:
details += data.database_missing_dbname;
break;
- case Event.Type.PACNEW_CREATED:
+ case Alpm.Event.Type.PACNEW_CREATED:
details += data.pacnew_created_file;
break;
- case Event.Type.PACSAVE_CREATED:
+ case Alpm.Event.Type.PACSAVE_CREATED:
details += data.pacsave_created_file;
break;
- case Event.Type.PACORIG_CREATED:
- details += data.pacorig_created_file;
- break;
default:
break;
}
pamac_daemon.emit_event ((uint) data.type, secondary_type, details);
}
-private void cb_question (Question.Data data) {
+private void cb_question (Alpm.Question.Data data) {
switch (data.type) {
- case Question.Type.INSTALL_IGNOREPKG:
+ case Alpm.Question.Type.INSTALL_IGNOREPKG:
// Do not install package in IgnorePkg/IgnoreGroup
data.install_ignorepkg_install = 0;
break;
- case Question.Type.REPLACE_PKG:
+ case Alpm.Question.Type.REPLACE_PKG:
// Auto-remove conflicts in case of replaces
data.replace_replace = 1;
break;
- case Question.Type.CONFLICT_PKG:
+ case Alpm.Question.Type.CONFLICT_PKG:
// Auto-remove conflicts
data.conflict_remove = 1;
break;
- case Question.Type.REMOVE_PKGS:
+ case Alpm.Question.Type.REMOVE_PKGS:
// Do not upgrade packages which have unresolvable dependencies
data.remove_pkgs_skip = 1;
break;
- case Question.Type.SELECT_PROVIDER:
+ case Alpm.Question.Type.SELECT_PROVIDER:
string depend_str = data.select_provider_depend.compute_string ();
string[] providers_str = {};
foreach (unowned Alpm.Package pkg in data.select_provider_providers) {
@@ -1248,11 +960,11 @@ private void cb_question (Question.Data data) {
data.select_provider_use_index = pamac_daemon.choosen_provider;
pamac_daemon.provider_mutex.unlock ();
break;
- case Question.Type.CORRUPTED_PKG:
+ case Alpm.Question.Type.CORRUPTED_PKG:
// Auto-remove corrupted pkgs in cache
data.corrupted_remove = 1;
break;
- case Question.Type.IMPORT_KEY:
+ case Alpm.Question.Type.IMPORT_KEY:
if (data.import_key_key.revoked == 1) {
// Do not get revoked key
data.import_key_import = 0;
@@ -1267,17 +979,33 @@ private void cb_question (Question.Data data) {
}
}
-private void cb_progress (Progress progress, string pkgname, int percent, uint n_targets, uint current_target) {
- if ((uint64) percent != pamac_daemon.previous_percent) {
- pamac_daemon.previous_percent = (uint64) percent;
- pamac_daemon.emit_progress ((uint) progress, pkgname, percent, n_targets, current_target);
+private void cb_progress (Alpm.Progress progress, string pkgname, int percent, uint n_targets, uint current_target) {
+ if (percent == 0) {
+ pamac_daemon.emit_progress ((uint) progress, pkgname, (uint) percent, n_targets, current_target);
+ pamac_daemon.timer.start ();
+ } else if (percent == 100) {
+ pamac_daemon.emit_progress ((uint) progress, pkgname, (uint) percent, n_targets, current_target);
+ pamac_daemon.timer.stop ();
+ }else if (pamac_daemon.timer.elapsed () < 0.5) {
+ return;
+ } else {
+ pamac_daemon.emit_progress ((uint) progress, pkgname, (uint) percent, n_targets, current_target);
+ pamac_daemon.timer.start ();
}
}
private void cb_download (string filename, uint64 xfered, uint64 total) {
- if (xfered != pamac_daemon.previous_percent) {
- pamac_daemon.previous_percent = xfered;
+ if (xfered == 0) {
+ pamac_daemon.emit_download (filename, xfered, total);
+ pamac_daemon.timer.start ();
+ } else if (xfered == total) {
+ pamac_daemon.emit_download (filename, xfered, total);
+ pamac_daemon.timer.stop ();
+ } else if (pamac_daemon.timer.elapsed () < 0.5) {
+ return;
+ } else {
pamac_daemon.emit_download (filename, xfered, total);
+ pamac_daemon.timer.start ();
}
}
@@ -1285,8 +1013,8 @@ private void cb_totaldownload (uint64 total) {
pamac_daemon.emit_totaldownload (total);
}
-private void cb_log (LogLevel level, string fmt, va_list args) {
- LogLevel logmask = LogLevel.ERROR | LogLevel.WARNING;
+private void cb_log (Alpm.LogLevel level, string fmt, va_list args) {
+ Alpm.LogLevel logmask = Alpm.LogLevel.ERROR | Alpm.LogLevel.WARNING;
if ((level & logmask) == 0) {
return;
}
@@ -1313,7 +1041,9 @@ void main () {
Intl.setlocale (LocaleCategory.ALL, "");
Intl.textdomain (GETTEXT_PACKAGE);
- Bus.own_name (BusType.SYSTEM, "org.manjaro.pamac", BusNameOwnerFlags.NONE,
+ Bus.own_name (BusType.SYSTEM,
+ "org.manjaro.pamac",
+ BusNameOwnerFlags.NONE,
on_bus_acquired,
null,
() => {
diff --git a/src/installer.vala b/src/installer.vala
index 9fe37da..0cd62ce 100644
--- a/src/installer.vala
+++ b/src/installer.vala
@@ -46,13 +46,13 @@ namespace Pamac {
transaction_info_dialog.hide ();
} else {
transaction = new Pamac.Transaction (null);
- transaction.finished.connect (on_emit_trans_finished);
+ transaction.finished.connect (on_transaction_finished);
this.hold ();
}
}
public override void activate () {
- if (pamac_run == false) {
+ if (!pamac_run) {
print ("\nError: Path(s) of tarball(s) to install is needed\n");
transaction.stop_daemon ();
this.release ();
@@ -60,10 +60,9 @@ namespace Pamac {
}
public override void open (File[] files, string hint) {
- if (pamac_run == false) {
- foreach (File file in files) {
- string? path = file.get_path ();
- transaction.to_load.add ((owned) path);
+ if (!pamac_run) {
+ foreach (unowned File file in files) {
+ transaction.to_load.add (file.get_path ());
}
transaction.run ();
}
@@ -92,7 +91,7 @@ namespace Pamac {
return run;
}
- public void on_emit_trans_finished (bool error) {
+ public void on_transaction_finished () {
transaction.stop_daemon ();
this.release ();
}
diff --git a/src/manager.vala b/src/manager.vala
index 8870e06..dd0cc13 100644
--- a/src/manager.vala
+++ b/src/manager.vala
@@ -50,18 +50,17 @@ namespace Pamac {
}
public override void activate () {
- if (pamac_run == false) {
+ if (!pamac_run) {
manager_window.present ();
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
- manager_window.show_all_pkgs ();
}
}
public override void shutdown () {
base.shutdown ();
- if (pamac_run == false) {
+ if (!pamac_run) {
manager_window.transaction.stop_daemon ();
}
}
diff --git a/src/manager_window.vala b/src/manager_window.vala
index d17cf63..989c7dd 100644
--- a/src/manager_window.vala
+++ b/src/manager_window.vala
@@ -1,7 +1,7 @@
/*
* pamac-vala
*
- * Copyright (C) 2014-2015 Guillaume Benoit
+ * Copyright (C) 2014-2016 Guillaume Benoit
*
* 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
@@ -17,11 +17,6 @@
* along with this program. If not, see .
*/
-using Gtk;
-using Alpm;
-
-const string VERSION = "2.4.3";
-
namespace Pamac {
public struct SortInfo {
@@ -43,15 +38,27 @@ namespace Pamac {
[GtkChild]
public Gtk.TreeView packages_treeview;
[GtkChild]
- public Gtk.TreeViewColumn state_column;
+ public Gtk.TreeViewColumn packages_state_column;
+ [GtkChild]
+ public Gtk.TreeViewColumn packages_name_column;
+ [GtkChild]
+ public Gtk.TreeViewColumn packages_version_column;
+ [GtkChild]
+ public Gtk.TreeViewColumn packages_repo_column;
+ [GtkChild]
+ public Gtk.TreeViewColumn packages_size_column;
[GtkChild]
- public Gtk.TreeViewColumn name_column;
+ public Gtk.TreeView aur_treeview;
[GtkChild]
- public Gtk.TreeViewColumn version_column;
+ public Gtk.ScrolledWindow aur_scrolledwindow;
[GtkChild]
- public Gtk.TreeViewColumn repo_column;
+ public Gtk.TreeViewColumn aur_state_column;
[GtkChild]
- public Gtk.TreeViewColumn size_column;
+ public Gtk.TreeViewColumn aur_name_column;
+ [GtkChild]
+ public Gtk.TreeViewColumn aur_version_column;
+ [GtkChild]
+ public Gtk.TreeViewColumn aur_votes_column;
[GtkChild]
public Gtk.Notebook filters_notebook;
[GtkChild]
@@ -65,6 +72,8 @@ namespace Pamac {
[GtkChild]
public Gtk.TreeView repos_treeview;
[GtkChild]
+ public Gtk.Notebook packages_notebook;
+ [GtkChild]
public Gtk.Notebook properties_notebook;
[GtkChild]
public Gtk.TreeView deps_treeview;
@@ -100,11 +109,11 @@ namespace Pamac {
Gtk.MenuItem deselect_item;
Gtk.MenuItem install_item;
Gtk.MenuItem remove_item;
- Gtk.SeparatorMenuItem separator_item;
Gtk.MenuItem reinstall_item;
Gtk.MenuItem install_optional_deps_item;
Gtk.MenuItem explicitly_installed_item;
- Pamac.Package[] selected_pkgs;
+ Alpm.List selected_pkgs;
+ GLib.List selected_aur;
// liststore
Gtk.ListStore search_list;
@@ -115,6 +124,11 @@ namespace Pamac {
Gtk.ListStore details_list;
PackagesModel packages_list;
+ AURModel aur_list;
+
+ public HashTable aur_search_results;
+
+ public Alpm.Config alpm_config;
public Transaction transaction;
@@ -133,7 +147,7 @@ namespace Pamac {
remove_item = new Gtk.MenuItem.with_label (dgettext (null, "Remove"));
remove_item.activate.connect (on_remove_item_activate);
right_click_menu.append (remove_item);
- separator_item = new Gtk.SeparatorMenuItem ();
+ var separator_item = new Gtk.SeparatorMenuItem ();
right_click_menu.append (separator_item);
reinstall_item = new Gtk.MenuItem.with_label (dgettext (null, "Reinstall"));
reinstall_item.activate.connect (on_reinstall_item_activate);
@@ -157,7 +171,7 @@ namespace Pamac {
deps_list = new Gtk.ListStore (2, typeof (string), typeof (string));
deps_treeview.set_model (deps_list);
details_list = new Gtk.ListStore (2, typeof (string), typeof (string));
- details_treeview.set_model (details_list);;
+ details_treeview.set_model (details_list);
try {
installed_icon = new Gdk.Pixbuf.from_resource ("/org/manjaro/pamac/manager/package-installed-updated.png");
@@ -170,37 +184,53 @@ namespace Pamac {
stderr.printf (e.message);
}
- transaction = new Pamac.Transaction (this as Gtk.ApplicationWindow);
+ transaction = new Transaction (this as Gtk.ApplicationWindow);
transaction.mode = Mode.MANAGER;
transaction.finished.connect (on_transaction_finished);
- transaction.support_aur.connect (support_aur);
+ transaction.daemon.write_pamac_config_finished.connect (on_write_pamac_config_finished);
transaction.daemon.set_pkgreason_finished.connect (display_package_properties);
- var pamac_config = new Pamac.Config ("/etc/pamac.conf");
- if (pamac_config.recurse) {
- transaction.flags |= Alpm.TransFlag.RECURSE;
- }
- Pamac.Package pkg = transaction.find_local_satisfier ("yaourt");
- if (pkg.name == "") {
+ alpm_config = new Alpm.Config ("/etc/pacman.conf");
+ refresh_handle ();
+
+ unowned Alpm.Package? pkg = Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, "yaourt");
+ if (pkg == null) {
support_aur (false, false);
} else {
- support_aur (pamac_config.enable_aur, pamac_config.search_aur);
+ support_aur (transaction.pamac_config.enable_aur, transaction.pamac_config.search_aur);
}
set_buttons_sensitive (false);
// sort by name by default
sortinfo = {0, Gtk.SortType.ASCENDING};
+
+ aur_search_results = new HashTable (str_hash, str_equal);
+
update_lists ();
+ show_default_pkgs ();
+ }
+
+ void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
+ bool enable_aur, bool search_aur) {
+ if (recurse) {
+ transaction.flags |= Alpm.TransFlag.RECURSE;
+ }
+ unowned Alpm.Package? pkg = Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, "yaourt");
+ if (pkg != null) {
+ support_aur (enable_aur, search_aur);
+ }
}
public void support_aur (bool enable_aur, bool search_aur) {
if (enable_aur) {
search_aur_button.set_active (search_aur);
search_aur_box.set_visible (true);
+ aur_scrolledwindow.set_visible (true);
} else {
search_aur_button.set_active (false);
search_aur_box.set_visible (false);
+ aur_scrolledwindow.set_visible (false);
}
}
@@ -209,12 +239,127 @@ namespace Pamac {
cancel_button.set_sensitive (sensitive);
}
- public void show_all_pkgs () {
+ public void refresh_handle () {
+ alpm_config.get_handle ();
+ if (alpm_config.handle == null) {
+ stderr.printf (dgettext (null, "Failed to initialize alpm library"));
+ }
+ }
+
+ public async Alpm.List search_all_dbs (string search_string) {
+ var syncpkgs = new Alpm.List ();
+ var needles = new Alpm.List ();
+ string[] splitted = search_string.split (" ");
+ foreach (unowned string part in splitted) {
+ needles.add (part);
+ }
+ var result = alpm_config.handle.localdb.search (needles);
+ foreach (var db in alpm_config.handle.syncdbs) {
+ if (syncpkgs.length == 0) {
+ syncpkgs = db.search (needles);
+ } else {
+ syncpkgs.join (db.search (needles).diff (syncpkgs, (Alpm.List.CompareFunc) compare_name));
+ }
+ }
+ result.join (syncpkgs.diff (result, (Alpm.List.CompareFunc) compare_name));
+ //result.sort ((Alpm.List.CompareFunc) compare_name);
+ return result;
+ }
+
+ public async Alpm.List get_group_pkgs (string grp_name) {
+ var result = new Alpm.List ();
+ unowned Alpm.Group? grp = alpm_config.handle.localdb.get_group (grp_name);
+ if (grp != null) {
+ foreach (var pkg in grp.packages) {
+ result.add (pkg);
+ }
+ }
+ result.join (Alpm.find_group_pkgs (alpm_config.handle.syncdbs, grp_name).diff (result, (Alpm.List.CompareFunc) compare_name));
+ //result.sort ((Alpm.List.CompareFunc) compare_name);
+ return result;
+ }
+
+ public async Alpm.List get_installed_pkgs () {
+ return alpm_config.handle.localdb.pkgcache.copy ();
+ }
+
+ public async Alpm.List get_orphans () {
+ var result = new Alpm.List ();
+ foreach (var pkg in alpm_config.handle.localdb.pkgcache) {
+ if (pkg.reason == Alpm.Package.Reason.DEPEND) {
+ Alpm.List requiredby = pkg.compute_requiredby ();
+ if (requiredby.length == 0) {
+ Alpm.List optionalfor = pkg.compute_optionalfor ();
+ if (optionalfor.length == 0) {
+ result.add (pkg);
+ }
+ optionalfor.free_data ();
+ }
+ requiredby.free_data ();
+ }
+ }
+ return result;
+ }
+
+ public async Alpm.List get_local_pkgs () {
+ var result = new Alpm.List ();
+ foreach (var pkg in alpm_config.handle.localdb.pkgcache) {
+ if (get_sync_pkg (pkg.name) == null) {
+ result.add (pkg);
+ }
+ }
+ return result;
+ }
+
+ public async Alpm.List get_repo_pkgs (string reponame) {
+ var result = new Alpm.List ();
+ foreach (var db in alpm_config.handle.syncdbs) {
+ if (db.name == reponame) {
+ foreach (var sync_pkg in db.pkgcache) {
+ unowned Alpm.Package?local_pkg = alpm_config.handle.localdb.get_pkg (sync_pkg.name);
+ if (local_pkg != null) {
+ result.add (local_pkg);
+ } else {
+ result.add (sync_pkg);
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+//~ public async Alpm.List get_all_pkgs () {
+//~ var syncpkgs = new Alpm.List ();
+//~ var result = new Alpm.List ();
+//~ result = alpm_config.handle.localdb.pkgcache.copy ();
+//~ foreach (var db in alpm_config.handle.syncdbs) {
+//~ if (syncpkgs.length == 0)
+//~ syncpkgs = db.pkgcache.copy ();
+//~ else {
+//~ syncpkgs.join (db.pkgcache.diff (syncpkgs, (Alpm.List.CompareFunc) compare_name));
+//~ }
+//~ }
+//~ result.join (syncpkgs.diff (result, (Alpm.List.CompareFunc) compare_name));
+//~ //result.sort ((Alpm.List.CompareFunc) compare_name);
+//~ return result;
+//~ }
+
+ public unowned Alpm.Package? get_sync_pkg (string pkgname) {
+ unowned Alpm.Package? pkg = null;
+ foreach (var db in alpm_config.handle.syncdbs) {
+ pkg = db.get_pkg (pkgname);
+ if (pkg != null) {
+ break;
+ }
+ }
+ return pkg;
+ }
+
+ public void show_default_pkgs () {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
- transaction.get_all_pkgs.begin ((obj, res) => {
- var pkgs = transaction.get_all_pkgs.end (res);
- populate_packages_list (pkgs);
- this.get_window ().set_cursor (null);
+ get_installed_pkgs.begin ((obj, res) => {
+ var pkgs = get_installed_pkgs.end (res);
+ populate_packages_list ((owned) pkgs);
});
}
@@ -223,8 +368,14 @@ namespace Pamac {
Gtk.TreeSelection selection;
selection = repos_treeview.get_selection ();
selection.changed.disconnect (on_repos_treeview_selection_changed);
- foreach (var repo in transaction.get_repos_names ()) {
- repos_list.insert_with_values (out iter, -1, 0, repo);
+ var groups_names = new GLib.List ();
+ foreach (var db in alpm_config.handle.syncdbs) {
+ repos_list.insert_with_values (out iter, -1, 0, db.name);
+ foreach (var group in db.groupcache) {
+ if (groups_names.find_custom (group.name, strcmp) == null) {
+ groups_names.append (group.name);
+ }
+ }
}
repos_list.insert_with_values (out iter, -1, 0, dgettext (null, "local"));
repos_list.get_iter_first (out iter);
@@ -233,8 +384,13 @@ namespace Pamac {
selection = groups_treeview.get_selection ();
selection.changed.disconnect (on_groups_treeview_selection_changed);
- foreach (var grpname in transaction.get_groups_names ()) {
- groups_list.insert_with_values (out iter, -1, 0, grpname);
+ foreach (var group in alpm_config.handle.localdb.groupcache) {
+ if (groups_names.find_custom (group.name, strcmp) == null) {
+ groups_names.append (group.name);
+ }
+ }
+ foreach (unowned string group_name in groups_names) {
+ groups_list.insert_with_values (out iter, -1, 0, group_name);
}
groups_list.set_sort_column_id (0, Gtk.SortType.ASCENDING);
groups_list.get_iter_first (out iter);
@@ -253,222 +409,247 @@ namespace Pamac {
selection.changed.connect_after (on_states_treeview_selection_changed);
}
- public void set_infos_list (Pamac.Package pkg) {
+ public void set_package_infos_list (Alpm.Package pkg) {
name_label.set_markup ("%s %s".printf (pkg.name, pkg.version));
desc_label.set_markup (Markup.escape_text (pkg.desc));
string url = Markup.escape_text (pkg.url);
- if (pkg.repo == "AUR") {
- string aur_url = "http://aur.archlinux.org/packages/" + pkg.name;
- link_label.set_markup ("%s\n\n%s".printf (url, url, aur_url, aur_url));
- } else {
- link_label.set_markup ("%s".printf (url, url));
+ link_label.set_markup ("%s".printf (url, url));
+ StringBuilder licenses = new StringBuilder ();
+ licenses.append (dgettext (null, "Licenses"));
+ licenses.append (": ");
+ foreach (unowned string license in pkg.licenses) {
+ if (licenses.len != 0) {
+ licenses.append (" ");
+ }
+ licenses.append (license);
}
+ licenses_label.set_markup (licenses.str);
+ }
+
+ public void set_aur_infos_list (Json.Object pkg_info) {
+ name_label.set_markup ("%s %s".printf (pkg_info.get_string_member ("Name"),
+ pkg_info.get_string_member ("Version")));
+ desc_label.set_markup (Markup.escape_text (pkg_info.get_string_member ("Description")));
+ string url = Markup.escape_text (pkg_info.get_string_member ("URL") ?? "");
+ string aur_url = "http://aur.archlinux.org/packages/" + pkg_info.get_string_member ("Name");
+ link_label.set_markup ("%s\n\n%s".printf (url, url, aur_url, aur_url));
StringBuilder licenses = new StringBuilder ();
licenses.append (dgettext (null, "Licenses"));
licenses.append (": ");
- licenses.append (pkg.licenses);
+ licenses.append (pkg_info.get_string_member ("License") ?? dgettext (null, "Unknown"));
licenses_label.set_markup (licenses.str);
}
- public void set_deps_list (string pkgname) {
+ public void set_package_deps_list (Alpm.Package pkg) {
deps_list.clear ();
Gtk.TreeIter iter;
- PackageDeps deps = transaction.get_pkg_deps (pkgname);
- int i;
- if (deps.depends.length != 0) {
+ unowned Alpm.List deps = pkg.depends;
+ unowned Alpm.List? list;
+ if (deps.length != 0) {
+ list = deps;
deps_list.insert_with_values (out iter, -1,
0, dgettext (null, "Depends On") + ":",
- 1, deps.depends[0]);
- i = 1;
- while (i < deps.depends.length) {
+ 1, list.data.compute_string ());
+ for (list = list.next (); list != null; list = list.next ()) {
deps_list.insert_with_values (out iter, -1,
- 1, deps.depends[i]);
- i++;
+ 1, list.data.compute_string ());
}
}
- if (deps.optdepends.length != 0) {
- string[] uninstalled_optdeps = transaction.get_pkg_uninstalled_optdeps (pkgname);
- string optdep = deps.optdepends[0];
- if ((optdep in uninstalled_optdeps) == false) {
- optdep = optdep + " [" + dgettext (null, "Installed") + "]";
+ deps = pkg.optdepends;
+ if (deps.length != 0) {
+ list = deps;
+ string optdep_str = list.data.compute_string ();
+ var optdep = new StringBuilder (optdep_str);
+ if (Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, optdep_str) != null) {
+ optdep.append (" [");
+ optdep.append (dgettext (null, "Installed"));
+ optdep.append ("]");
}
deps_list.insert_with_values (out iter, -1,
- 0, dgettext (null, "Optional Dependencies") + ":",
- 1, optdep);
- i = 1;
- while (i < deps.optdepends.length) {
- optdep = deps.optdepends[i];
- if ((optdep in uninstalled_optdeps) == false) {
- optdep = optdep + " [" + dgettext (null, "Installed") + "]";
+ 0, dgettext (null, "Optional Dependencies") + ":",
+ 1, optdep.str);
+ for (list = list.next (); list != null; list = list.next ()) {
+ optdep_str = list.data.compute_string ();
+ optdep = new StringBuilder (optdep_str);
+ if (Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, optdep_str) != null) {
+ optdep.append (" [");
+ optdep.append (dgettext (null, "Installed"));
+ optdep.append ("]");
}
- deps_list.insert_with_values (out iter, -1, 1, optdep);
- i++;
+ deps_list.insert_with_values (out iter, -1, 1, optdep.str);
}
}
- if (deps.repo == "local") {
- if (deps.requiredby.length != 0) {
+ if (pkg.origin == Alpm.Package.From.LOCALDB) {
+ Alpm.List requiredby = pkg.compute_requiredby ();
+ unowned Alpm.List? list2;
+ if (requiredby.length != 0) {
+ list2 = requiredby;
deps_list.insert_with_values (out iter, -1,
0, dgettext (null, "Required By") + ":",
- 1, deps.requiredby[0]);
- i = 1;
- while (i < deps.requiredby.length) {
+ 1, list2.data);
+ for (list2 = list2.next (); list2 != null; list2 = list2.next ()) {
deps_list.insert_with_values (out iter, -1,
- 1, deps.requiredby[i]);
- i++;
+ 1, list2.data);
}
}
- }
- if (deps.repo == "local") {
- if (deps.optionalfor.length != 0) {
+ requiredby.free_data ();
+ Alpm.List optionalfor = pkg.compute_optionalfor ();
+ if (optionalfor.length != 0) {
+ list2 = optionalfor;
deps_list.insert_with_values (out iter, -1,
0, dgettext (null, "Optional For") + ":",
- 1, deps.optionalfor[0]);
- i = 1;
- while (i < deps.optionalfor.length) {
+ 1, list2.data);
+ for (list2 = list2.next (); list2 != null; list2 = list2.next ()) {
deps_list.insert_with_values (out iter, -1,
- 1, deps.optionalfor[i]);
- i++;
+ 1, list2.data);
}
}
+ optionalfor.free_data ();
}
- if (deps.provides.length != 0) {
+ deps = pkg.provides;
+ if (deps.length != 0) {
+ list = deps;
deps_list.insert_with_values (out iter, -1,
0, dgettext (null, "Provides") + ":",
- 1, deps.provides[0]);
- i = 1;
- while (i < deps.provides.length) {
+ 1, list.data.compute_string ());
+ for (list = list.next (); list != null; list = list.next ()) {
deps_list.insert_with_values (out iter, -1,
- 1, deps.provides[i]);
- i++;
+ 1, list.data.compute_string ());
}
}
- if (deps.replaces.length != 0) {
+ deps = pkg.replaces;
+ if (deps.length != 0) {
+ list = deps;
deps_list.insert_with_values (out iter, -1,
0, dgettext (null, "Replaces") + ":",
- 1, deps.replaces[0]);
- i = 1;
- while (i < deps.replaces.length) {
+ 1, list.data.compute_string ());
+ for (list = list.next (); list != null; list = list.next ()) {
deps_list.insert_with_values (out iter, -1,
- 1, deps.replaces[i]);
- i++;
+ 1, list.data.compute_string ());
}
}
- if (deps.conflicts.length != 0) {
+ deps = pkg.conflicts;
+ if (deps.length != 0) {
+ list = deps;
deps_list.insert_with_values (out iter, -1,
0, dgettext (null, "Conflicts With") + ":",
- 1, deps.conflicts[0]);
- i = 1;
- while (i < deps.conflicts.length) {
+ 1, list.data.compute_string ());
+ for (list = list.next (); list != null; list = list.next ()) {
deps_list.insert_with_values (out iter, -1,
- 1, deps.conflicts[i]);
- i++;
+ 1, list.data.compute_string ());
}
}
}
- public void set_details_list (string pkgname) {
+ public void set_package_details_list (Alpm.Package pkg) {
details_list.clear ();
Gtk.TreeIter iter;
- PackageDetails details = transaction.get_pkg_details (pkgname);
- int i;
- if (details.repo != "local" && details.repo != "AUR") {
+ if (pkg.origin == Alpm.Package.From.SYNCDB) {
details_list.insert_with_values (out iter, -1,
- 0, dgettext (null, "Repository") + ":",
- 1, details.repo);
+ 0, dgettext (null, "Repository") + ":",
+ 1, pkg.db.name);
}
- if (details.groups.length != 0) {
+ unowned Alpm.List groups = pkg.groups;
+ if (groups.length != 0) {
+ unowned Alpm.List? list = groups;
details_list.insert_with_values (out iter, -1,
0, dgettext (null, "Groups") + ":",
- 1, details.groups[0]);
- i = 1;
- while (i < details.groups.length) {
+ 1, list.data);
+ for (list = list.next (); list != null; list = list.next ()) {
details_list.insert_with_values (out iter, -1,
- 1, details.groups[i]);
- i++;
+ 1, list.data);
}
}
- if (details.repo == "AUR") {
- details_list.insert_with_values (out iter, -1,
- 0, dgettext (null, "Maintainer") + ":",
- 1, details.packager);
- details_list.insert_with_values (out iter, -1,
- 0, dgettext (null, "First Submitted") + ":",
- 1, details.build_date);
- details_list.insert_with_values (out iter, -1,
- 0, dgettext (null, "Last Modified") + ":",
- 1, details.install_date);
- } else {
- details_list.insert_with_values (out iter, -1,
- 0, dgettext (null, "Packager") + ":",
- 1, details.packager);
- details_list.insert_with_values (out iter, -1,
- 0, dgettext (null, "Build Date") + ":",
- 1, details.build_date);
- }
- if (details.repo == "local") {
+ details_list.insert_with_values (out iter, -1,
+ 0, dgettext (null, "Packager") + ":",
+ 1, pkg.packager);
+ GLib.Time time = GLib.Time.local ((time_t) pkg.builddate);
+ string build_date = time.format ("%a %d %b %Y %X %Z");
+ details_list.insert_with_values (out iter, -1,
+ 0, dgettext (null, "Build Date") + ":",
+ 1, build_date);
+ if (pkg.origin == Alpm.Package.From.LOCALDB) {
+ time = GLib.Time.local ((time_t) pkg.installdate);
+ string install_date = time.format ("%a %d %b %Y %X %Z");
details_list.insert_with_values (out iter, -1,
- 0, dgettext (null, "Install Date") + ":",
- 1, details.install_date);
+ 0, dgettext (null, "Install Date") + ":",
+ 1, install_date);
string reason;
- if (details.reason == Alpm.Package.Reason.EXPLICIT) {
+ if (pkg.reason == Alpm.Package.Reason.EXPLICIT) {
reason = dgettext (null, "Explicitly installed");
- } else if (details.reason == Alpm.Package.Reason.DEPEND) {
+ } else if (pkg.reason == Alpm.Package.Reason.DEPEND) {
reason = dgettext (null, "Installed as a dependency for another package");
} else {
reason = dgettext (null, "Unknown");
}
details_list.insert_with_values (out iter, -1,
- 0, dgettext (null, "Install Reason") + ":",
- 1, reason);
+ 0, dgettext (null, "Install Reason") + ":",
+ 1, reason);
}
- if (details.repo != "local" && details.repo != "AUR") {
+ if (pkg.origin == Alpm.Package.From.SYNCDB) {
+ string has_signature = pkg.base64_sig != null ? dgettext (null, "Yes") : dgettext (null, "No");
details_list.insert_with_values (out iter, -1,
- 0, dgettext (null, "Signatures") + ":",
- 1, details.has_signature);
+ 0, dgettext (null, "Signatures") + ":",
+ 1, has_signature);
}
- if (details.repo == "AUR") {
- details_list.insert_with_values (out iter, -1,
- 0, dgettext (null, "Votes") + ":",
- 1, details.reason.to_string ());
- if (details.has_signature != "") {
- details_list.insert_with_values (out iter, -1,
- 0, dgettext (null, "Out of Date") + ":",
- 1, details.has_signature);
- }
- }
- if (details.repo == "local") {
- if (details.backups.length != 0) {
+ if (pkg.origin == Alpm.Package.From.LOCALDB) {
+ unowned Alpm.List backups = pkg.backups;
+ if (backups.length != 0) {
+ unowned Alpm.List? list = backups;
details_list.insert_with_values (out iter, -1,
0, dgettext (null, "Backup files") + ":",
- 1, "/" + details.backups[0]);
- i = 1;
- while (i < details.backups.length) {
+ 1, "/" + list.data.name);
+ for (list = list.next (); list != null; list = list.next ()) {
details_list.insert_with_values (out iter, -1,
- 1, "/" + details.backups[i]);
- i++;
+ 1, "/" + list.data.name);
}
}
}
}
- public void set_files_list (string pkgname) {
+ public void set_aur_details_list (Json.Object pkg_info) {
+ details_list.clear ();
+ Gtk.TreeIter iter;
+ details_list.insert_with_values (out iter, -1,
+ 0, dgettext (null, "Maintainer") + ":",
+ 1, pkg_info.get_string_member ("Maintainer"));
+ GLib.Time time = GLib.Time.local ((time_t) pkg_info.get_int_member ("FirstSubmitted"));
+ details_list.insert_with_values (out iter, -1,
+ 0, dgettext (null, "First Submitted") + ":",
+ 1, time.format ("%a %d %b %Y %X %Z"));
+ time = GLib.Time.local ((time_t) pkg_info.get_int_member ("LastModified"));
+ details_list.insert_with_values (out iter, -1,
+ 0, dgettext (null, "Last Modified") + ":",
+ 1, time.format ("%a %d %b %Y %X %Z"));
+ details_list.insert_with_values (out iter, -1,
+ 0, dgettext (null, "Votes") + ":",
+ 1, pkg_info.get_int_member ("NumVotes").to_string ());
+ if (!pkg_info.get_null_member ("OutOfDate")) {
+ time = GLib.Time.local ((time_t) pkg_info.get_int_member ("OutOfDate"));
+ details_list.insert_with_values (out iter, -1,
+ 0, dgettext (null, "Out of Date") + ":",
+ 1, time.format ("%a %d %b %Y %X %Z"));
+ }
+ }
+
+ public void set_package_files_list (Alpm.Package pkg) {
StringBuilder text = new StringBuilder ();
- foreach (var file in transaction.get_pkg_files (pkgname)) {
+ foreach (var file in pkg.files) {
if (text.len != 0) {
text.append ("\n");
}
text.append ("/");
- text.append (file);
+ text.append (file.name);
}
files_textview.buffer.set_text (text.str, (int) text.len);
}
- public void populate_packages_list (Pamac.Package[] pkgs) {
+ public void populate_packages_list (owned Alpm.List? pkgs) {
packages_treeview.freeze_child_notify ();
packages_treeview.set_model (null);
// populate liststore
- packages_list = new PackagesModel (pkgs, this);
+ packages_list = new PackagesModel ((owned) pkgs, this);
// sort liststore
int column = sortinfo.column_number;
@@ -498,59 +679,159 @@ namespace Pamac {
this.get_window ().set_cursor (null);
}
+ public void populate_aur_list (Json.Array? pkgs_infos) {
+ aur_treeview.freeze_child_notify ();
+ aur_treeview.set_model (null);
+
+ // populate liststore
+ aur_list = new AURModel (pkgs_infos, this);
+
+ // sort liststore
+ int column = sortinfo.column_number;
+ switch (column) {
+ case 0:
+ aur_list.sort_by_name (sortinfo.sort_type);
+ break;
+ case 1:
+ aur_list.sort_by_state (sortinfo.sort_type);
+ break;
+ case 2:
+ aur_list.sort_by_version (sortinfo.sort_type);
+ break;
+ case 3:
+ aur_list.sort_by_votes (sortinfo.sort_type);
+ break;
+ default:
+ break;
+ }
+
+ aur_treeview.set_model (aur_list);
+ aur_treeview.thaw_child_notify ();
+
+ this.get_window ().set_cursor (null);
+ }
+
public void refresh_packages_list () {
- int current_page = filters_notebook.get_current_page ();
- if (current_page == 0) {
- Gtk.TreeSelection selection = search_treeview.get_selection ();
- if (selection.get_selected (null, null)) {
- on_search_treeview_selection_changed ();
- } else {
- show_all_pkgs ();
- }
- } else if (current_page == 1) {
- on_groups_treeview_selection_changed ();
- } else if (current_page == 2) {
- on_states_treeview_selection_changed ();
- } else if (current_page == 3) {
- on_repos_treeview_selection_changed ();
+ switch (filters_notebook.get_current_page ()) {
+ case 0:
+ if (search_aur_button.get_active ()) {
+ aur_scrolledwindow.set_visible (true);
+ }
+ Gtk.TreeSelection selection = search_treeview.get_selection ();
+ if (selection.get_selected (null, null)) {
+ on_search_treeview_selection_changed ();
+ } else {
+ show_default_pkgs ();
+ }
+ break;
+ case 1:
+ aur_scrolledwindow.set_visible (false);
+ on_groups_treeview_selection_changed ();
+ break;
+ case 2:
+ aur_scrolledwindow.set_visible (false);
+ on_states_treeview_selection_changed ();
+ break;
+ case 3:
+ aur_scrolledwindow.set_visible (false);
+ on_repos_treeview_selection_changed ();
+ break;
+ default:
+ break;
}
}
public void display_package_properties () {
- Gtk.TreeSelection selection = packages_treeview.get_selection ();
- GLib.List selected = selection.get_selected_rows (null);
- if (selected.length () > 0) {
- // display info for the first package of the selection
- Pamac.Package pkg = packages_list.get_pkg_at_path (selected.nth_data (0));
- if (pkg.name == dgettext (null, "No package found")) {
- return;
- }
- if (pkg.repo == "local") {
- deps_scrolledwindow.visible = true;
- files_scrolledwindow.visible = true;
- } else if (pkg.repo == "AUR") {
- deps_scrolledwindow.visible = false;
- files_scrolledwindow.visible = false;
- } else {
- deps_scrolledwindow.visible = true;
- files_scrolledwindow.visible = false;
- }
- switch (properties_notebook.get_current_page ()) {
- case 0:
- set_infos_list (pkg);
- break;
- case 1:
- set_deps_list (pkg.name);
- break;
- case 2:
- set_details_list (pkg.name);
- break;
- case 3:
- set_files_list (pkg.name);
- break;
- default:
- break;
- }
+ switch (packages_notebook.get_current_page ()) {
+ case 0:
+ Gtk.TreeSelection selection = packages_treeview.get_selection ();
+ GLib.List selected = selection.get_selected_rows (null);
+ if (selected.length () > 0) {
+ // display info for the first package of the selection
+ unowned Alpm.Package? pkg = packages_list.get_pkg_at_path (selected.nth_data (0));
+ if (pkg == null) {
+ return;
+ }
+ if (pkg.origin == Alpm.Package.From.LOCALDB) {
+ files_scrolledwindow.visible = true;
+ } else {
+ files_scrolledwindow.visible = false;
+ }
+ switch (properties_notebook.get_current_page ()) {
+ case 0:
+ set_package_infos_list (pkg);
+ deps_scrolledwindow.visible = true;
+ break;
+ case 1:
+ set_package_deps_list (pkg);
+ break;
+ case 2:
+ set_package_details_list (pkg);
+ deps_scrolledwindow.visible = true;
+ break;
+ case 3:
+ if (pkg.origin == Alpm.Package.From.LOCALDB) {
+ set_package_files_list (pkg);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case 1:
+ Gtk.TreeSelection selection = aur_treeview.get_selection ();
+ GLib.List selected = selection.get_selected_rows (null);
+ if (selected.length () > 0) {
+ // display info for the first package of the selection
+ unowned Json.Object? pkg_info = aur_list.get_pkg_at_path (selected.nth_data (0));
+ if (pkg_info == null) {
+ return;
+ }
+ unowned Alpm.Package? pkg = alpm_config.handle.localdb.get_pkg (pkg_info.get_string_member ("Name"));
+ if (pkg != null) {
+ files_scrolledwindow.visible = true;
+ switch (properties_notebook.get_current_page ()) {
+ case 0:
+ set_package_infos_list (pkg);
+ deps_scrolledwindow.visible = true;
+ break;
+ case 1:
+ set_package_deps_list (pkg);
+ break;
+ case 2:
+ set_package_details_list (pkg);
+ deps_scrolledwindow.visible = true;
+ break;
+ case 3:
+ set_package_files_list (pkg);
+ break;
+ default:
+ break;
+ }
+ } else {
+ files_scrolledwindow.visible = false;
+ deps_scrolledwindow.visible = false;
+ switch (properties_notebook.get_current_page ()) {
+ case 0:
+ set_aur_infos_list (pkg_info);
+ break;
+ case 1:
+ break;
+ case 2:
+ set_aur_details_list (pkg_info);
+ break;
+ case 3:
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+ }
+ break;
+ default:
+ break;
}
}
@@ -559,6 +840,11 @@ namespace Pamac {
display_package_properties ();
}
+ [GtkCallback]
+ public void on_aur_treeview_selection_changed () {
+ display_package_properties ();
+ }
+
[GtkCallback]
public void on_properties_notebook_switch_page (Gtk.Widget page, uint page_num) {
display_package_properties ();
@@ -566,31 +852,21 @@ namespace Pamac {
[GtkCallback]
public void on_packages_treeview_row_activated (Gtk.TreeView treeview, Gtk.TreePath path, Gtk.TreeViewColumn column) {
- Gtk.TreeIter iter;
- if (packages_list.get_iter (out iter, path)) {
- GLib.Value val;
- packages_list.get_value (iter, 0, out val);
- string name = val.get_string ();
- if (name != dgettext (null, "No package found")) {
- if (transaction.to_add.remove (name)) {
- } else if (transaction.to_remove.remove (name)) {
- } else if (transaction.to_build.remove (name)) {
- } else {
- packages_list.get_value (iter, 3, out val);
- string db_name = val.get_string ();
- if (db_name == "local") {
- if (transaction.should_hold (name) == false) {
- transaction.to_remove.add ((owned) name);
- }
- } else if (db_name == "AUR") {
- transaction.to_build.add ((owned) name);
- } else {
- transaction.to_add.add ((owned) name);
+ unowned Alpm.Package? pkg = packages_list.get_pkg_at_path (path);
+ if (pkg != null) {
+ if (transaction.to_add.remove (pkg.name)) {
+ } else if (transaction.to_remove.remove (pkg.name)) {
+ } else {
+ if (pkg.origin == Alpm.Package.From.LOCALDB) {
+ if (alpm_config.holdpkgs.find_custom (pkg.name, strcmp) == null) {
+ transaction.to_remove.add (pkg.name);
}
+ } else {
+ transaction.to_add.add (pkg.name);
}
}
}
- if (transaction.to_add.length + transaction.to_remove.length + transaction.to_build.length == 0) {
+ if ((transaction.to_add.length == 0) && (transaction.to_remove.length == 0)) {
set_buttons_sensitive (false);
} else {
set_buttons_sensitive (true);
@@ -599,27 +875,49 @@ namespace Pamac {
packages_treeview.queue_draw ();
}
- void on_install_item_activate () {
- Pamac.Package find_pkg;
- foreach (Pamac.Package pkg in selected_pkgs) {
- if (pkg.repo == "AUR") {
- transaction.to_build.add (pkg.name);
- } else {
- find_pkg = transaction.find_local_pkg (pkg.name);
- if (find_pkg.name == "") {
- transaction.to_add.add (pkg.name);
+ [GtkCallback]
+ public void on_aur_treeview_row_activated (Gtk.TreeView treeview, Gtk.TreePath path, Gtk.TreeViewColumn column) {
+ unowned Json.Object? pkg_info = aur_list.get_pkg_at_path (path);
+ if (pkg_info != null) {
+ unowned Alpm.Package? pkg = alpm_config.handle.localdb.get_pkg (pkg_info.get_string_member ("Name"));
+ if (pkg != null) {
+ if (pkg.origin == Alpm.Package.From.LOCALDB) {
+ if (alpm_config.holdpkgs.find_custom (pkg.name, strcmp) == null) {
+ transaction.to_remove.add (pkg.name);
+ }
}
+ } else if (transaction.to_build.remove (pkg_info.get_string_member ("Name"))) {
+ } else {
+ transaction.to_build.add (pkg_info.get_string_member ("Name"));
}
}
+ if ((transaction.to_build.length == 0) && (transaction.to_remove.length == 0)) {
+ set_buttons_sensitive (false);
+ } else {
+ set_buttons_sensitive (true);
+ }
+ // force a display refresh
+ aur_treeview.queue_draw ();
+ }
+
+ void on_install_item_activate () {
+ foreach (var pkg in selected_pkgs) {
+ if (pkg.origin == Alpm.Package.From.SYNCDB) {
+ transaction.to_add.add (pkg.name);
+ }
+ }
+ foreach (var pkg_info in selected_aur) {
+ transaction.to_build.add (pkg_info.get_string_member ("Name"));
+ }
if (transaction.to_add.length != 0 || transaction.to_build.length != 0) {
set_buttons_sensitive (true);
}
}
void on_reinstall_item_activate () {
- foreach (Pamac.Package pkg in selected_pkgs) {
+ foreach (var pkg in selected_pkgs) {
transaction.to_remove.remove (pkg.name);
- if (pkg.repo == "local") {
+ if (pkg.origin == Alpm.Package.From.LOCALDB) {
transaction.to_add.add (pkg.name);
}
}
@@ -629,10 +927,10 @@ namespace Pamac {
}
void on_remove_item_activate () {
- foreach (Pamac.Package pkg in selected_pkgs) {
+ foreach (var pkg in selected_pkgs) {
transaction.to_add.remove (pkg.name);
- if (transaction.should_hold (pkg.name) == false) {
- if (pkg.repo == "local") {
+ if (alpm_config.holdpkgs.find_custom (pkg.name, strcmp) == null) {
+ if (pkg.origin == Alpm.Package.From.LOCALDB) {
transaction.to_remove.add (pkg.name);
}
}
@@ -643,21 +941,40 @@ namespace Pamac {
}
void on_deselect_item_activate () {
- foreach (Pamac.Package pkg in selected_pkgs) {
+ foreach (var pkg in selected_pkgs) {
if (transaction.to_add.remove (pkg.name)) {
- } else if (transaction.to_remove.remove (pkg.name)) {
- } else if (transaction.to_build.remove (pkg.name)) {
+ } else {
+ transaction.to_remove.remove (pkg.name);
}
}
- if (transaction.to_add.length == 0 && transaction.to_remove.length == 0
- && transaction.to_load.length == 0 && transaction.to_build.length == 0) {
+ foreach (var pkg_info in selected_aur) {
+ transaction.to_build.remove (pkg_info.get_string_member ("Name"));
+ }
+ if ((transaction.to_add.length == 0)
+ && (transaction.to_remove.length == 0)
+ && (transaction.to_load.length == 0)
+ && (transaction.to_build.length == 0)) {
set_buttons_sensitive (false);
}
}
- public void choose_opt_dep (Pamac.Package[] pkgs) {
- foreach (Pamac.Package pkg in pkgs) {
- var choose_dep_dialog = new ChooseDependenciesDialog (transaction, pkg.name, this);
+ public void choose_opt_dep (Alpm.List pkgs) {
+ foreach (var pkg in pkgs) {
+ var choose_dep_dialog = new ChooseDependenciesDialog (this);
+ Gtk.TreeIter iter;
+ int length = 0;
+ foreach (var optdep in pkg.optdepends) {
+ if (Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, optdep.name) == null) {
+ length++;
+ }
+ choose_dep_dialog.deps_list.insert_with_values (out iter, -1,
+ 0, false,
+ 1, optdep.name,
+ 2, optdep.desc);
+ }
+ choose_dep_dialog.label.set_markup ("%s".printf (
+ dngettext (null, "%s has %u uninstalled optional dependency.\nChoose if you would like to install it",
+ "%s has %u uninstalled optional dependencies.\nChoose those you would like to install", length).printf (pkg.name, length)));
if (choose_dep_dialog.run () == Gtk.ResponseType.OK) {
choose_dep_dialog.deps_list.foreach ((model, path, iter) => {
GLib.Value val;
@@ -665,8 +982,10 @@ namespace Pamac {
bool selected = val.get_boolean ();
if (selected) {
choose_dep_dialog.deps_list.get_value (iter, 1, out val);
- string name = val.get_string ();
- transaction.to_add.add ((owned) name);
+ unowned Alpm.Package? sync_pkg = get_sync_pkg (val.get_string ());
+ if (sync_pkg != null) {
+ transaction.to_add.add (sync_pkg.name);
+ }
}
return false;
});
@@ -686,26 +1005,39 @@ namespace Pamac {
}
void on_explicitly_installed_item_activate () {
- foreach (Pamac.Package pkg in selected_pkgs) {
+ foreach (var pkg in selected_pkgs) {
transaction.start_set_pkgreason (pkg.name, Alpm.Package.Reason.EXPLICIT);
}
refresh_packages_list ();
}
+
+ public async void search_in_aur (string search_string) {
+ if (!aur_search_results.contains (search_string)) {
+ Json.Array results = AUR.search (search_string.split (" "));
+ aur_search_results.insert (search_string, results);
+ }
+ }
+
+ [GtkCallback]
+ public void on_packages_notebook_switch_page (Gtk.Widget page, uint page_num) {
+ refresh_packages_list ();
+ }
+
[GtkCallback]
public bool on_packages_treeview_button_press_event (Gdk.EventButton event) {
packages_treeview.grab_focus ();
// Check if right mouse button was clicked
if (event.type == Gdk.EventType.BUTTON_PRESS && event.button == 3) {
Gtk.TreePath? treepath;
- Pamac.Package clicked_pkg;
+ unowned Alpm.Package? clicked_pkg;
Gtk.TreeSelection selection = packages_treeview.get_selection ();
packages_treeview.get_path_at_pos ((int) event.x, (int) event.y, out treepath, null, null, null);
- clicked_pkg = packages_list.get_pkg_at_path (treepath);;
- if (clicked_pkg.name == dgettext (null, "No package found")) {
+ clicked_pkg = packages_list.get_pkg_at_path (treepath);
+ if (clicked_pkg == null) {
return true;
}
- if (selection.path_is_selected (treepath) == false) {
+ if (!selection.path_is_selected (treepath)) {
selection.unselect_all ();
selection.select_path (treepath);
}
@@ -716,41 +1048,43 @@ namespace Pamac {
reinstall_item.set_sensitive (false);
install_optional_deps_item.set_sensitive (false);
explicitly_installed_item.set_sensitive (false);
- selected_pkgs = {};
- foreach (Gtk.TreePath path in selected_paths) {
- selected_pkgs += packages_list.get_pkg_at_path (path);
+ selected_pkgs = new Alpm.List ();
+ foreach (unowned Gtk.TreePath path in selected_paths) {
+ selected_pkgs.add (packages_list.get_pkg_at_path (path));
}
- foreach (Pamac.Package pkg in selected_pkgs) {
+ foreach (var pkg in selected_pkgs) {
if (transaction.to_add.contains (pkg.name)
- || transaction.to_remove.contains (pkg.name)
- || transaction.to_build.contains (pkg.name)) {
+ || transaction.to_remove.contains (pkg.name)) {
deselect_item.set_sensitive (true);
break;
}
}
- foreach (Pamac.Package pkg in selected_pkgs) {
- if (pkg.repo != "local") {
+ foreach (var pkg in selected_pkgs) {
+ if (pkg.origin == Alpm.Package.From.SYNCDB) {
install_item.set_sensitive (true);
break;
}
}
- foreach (Pamac.Package pkg in selected_pkgs) {
- if (pkg.repo == "local") {
+ foreach (var pkg in selected_pkgs) {
+ if (pkg.origin == Alpm.Package.From.LOCALDB) {
remove_item.set_sensitive (true);
break;
}
}
if (selected_pkgs.length == 1) {
- clicked_pkg = selected_pkgs[0];
- if (clicked_pkg.repo == "local") {
- if (transaction.get_pkg_uninstalled_optdeps (clicked_pkg.name).length != 0) {
- install_optional_deps_item.set_sensitive (true);
+ clicked_pkg = selected_pkgs.data;
+ if (clicked_pkg.origin == Alpm.Package.From.LOCALDB) {
+ foreach (var optdep in clicked_pkg.optdepends) {
+ if (Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, optdep.name) == null) {
+ install_optional_deps_item.set_sensitive (true);
+ break;
+ }
}
if (clicked_pkg.reason == Alpm.Package.Reason.DEPEND) {
explicitly_installed_item.set_sensitive (true);
}
- Pamac.Package find_pkg = transaction.find_sync_pkg (clicked_pkg.name);
- if (find_pkg.name != "") {
+ unowned Alpm.Package? find_pkg = get_sync_pkg (clicked_pkg.name);
+ if (find_pkg != null) {
if (Alpm.pkg_vercmp (find_pkg.version, clicked_pkg.version) == 0) {
reinstall_item.set_sensitive (true);
}
@@ -765,9 +1099,70 @@ namespace Pamac {
}
[GtkCallback]
- public void on_name_column_clicked () {
+ public bool on_aur_treeview_button_press_event (Gdk.EventButton event) {
+ aur_treeview.grab_focus ();
+ // Check if right mouse button was clicked
+ if (event.type == Gdk.EventType.BUTTON_PRESS && event.button == 3) {
+ Gtk.TreePath? treepath;
+ unowned Json.Object? clicked_pkg_info;
+ Gtk.TreeSelection selection = aur_treeview.get_selection ();
+ aur_treeview.get_path_at_pos ((int) event.x, (int) event.y, out treepath, null, null, null);
+ clicked_pkg_info = aur_list.get_pkg_at_path (treepath);
+ if (clicked_pkg_info == null) {
+ return true;
+ }
+ if (!selection.path_is_selected (treepath)) {
+ selection.unselect_all ();
+ selection.select_path (treepath);
+ }
+ GLib.List selected_paths = selection.get_selected_rows (null);
+ deselect_item.set_sensitive (false);
+ install_item.set_sensitive (false);
+ remove_item.set_sensitive (false);
+ reinstall_item.set_sensitive (false);
+ install_optional_deps_item.set_sensitive (false);
+ explicitly_installed_item.set_sensitive (false);
+ selected_pkgs = new Alpm.List ();
+ selected_aur = new GLib.List ();
+ foreach (unowned Gtk.TreePath path in selected_paths) {
+ unowned Alpm.Package? pkg = alpm_config.handle.localdb.get_pkg (clicked_pkg_info.get_string_member ("Name"));
+ if (pkg != null) {
+ selected_pkgs.add (pkg);
+ // there is for sure a pkg to remove
+ remove_item.set_sensitive (true);
+ } else {
+ selected_aur.append (aur_list.get_pkg_at_path (path));
+ }
+ }
+ foreach (var pkg_info in selected_aur) {
+ if (transaction.to_build.contains (pkg_info.get_string_member ("Name"))) {
+ deselect_item.set_sensitive (true);
+ break;
+ }
+ }
+ foreach (var pkg_info in selected_aur) {
+ if (!transaction.to_build.contains (pkg_info.get_string_member ("Name"))) {
+ install_item.set_sensitive (true);
+ break;
+ }
+ }
+ foreach (var pkg in selected_pkgs) {
+ if (transaction.to_remove.contains (pkg.name)) {
+ deselect_item.set_sensitive (true);
+ break;
+ }
+ }
+ right_click_menu.popup (null, null, null, event.button, event.time);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ [GtkCallback]
+ public void on_packages_name_column_clicked () {
Gtk.SortType new_order;
- if (name_column.sort_indicator == false) {
+ if (!packages_name_column.sort_indicator) {
new_order = Gtk.SortType.ASCENDING;
} else {
if (sortinfo.sort_type == Gtk.SortType.ASCENDING) {
@@ -782,9 +1177,26 @@ namespace Pamac {
}
[GtkCallback]
- public void on_state_column_clicked () {
+ public void on_aur_name_column_clicked () {
+ Gtk.SortType new_order;
+ if (!aur_name_column.sort_indicator) {
+ new_order = Gtk.SortType.ASCENDING;
+ } else {
+ if (sortinfo.sort_type == Gtk.SortType.ASCENDING) {
+ new_order = Gtk.SortType.DESCENDING;
+ } else {
+ new_order = Gtk.SortType.ASCENDING;
+ }
+ }
+ aur_list.sort_by_name (new_order);
+ // force a display refresh
+ aur_treeview.queue_draw ();
+ }
+
+ [GtkCallback]
+ public void on_packages_state_column_clicked () {
Gtk.SortType new_order;
- if (state_column.sort_indicator == false) {
+ if (!packages_state_column.sort_indicator) {
new_order = Gtk.SortType.ASCENDING;
} else {
if (sortinfo.sort_type == Gtk.SortType.ASCENDING) {
@@ -799,9 +1211,26 @@ namespace Pamac {
}
[GtkCallback]
- public void on_version_column_clicked () {
+ public void on_aur_state_column_clicked () {
+ Gtk.SortType new_order;
+ if (!aur_state_column.sort_indicator) {
+ new_order = Gtk.SortType.ASCENDING;
+ } else {
+ if (sortinfo.sort_type == Gtk.SortType.ASCENDING) {
+ new_order = Gtk.SortType.DESCENDING;
+ } else {
+ new_order = Gtk.SortType.ASCENDING;
+ }
+ }
+ aur_list.sort_by_state (new_order);
+ // force a display refresh
+ aur_treeview.queue_draw ();
+ }
+
+ [GtkCallback]
+ public void on_packages_version_column_clicked () {
Gtk.SortType new_order;
- if (version_column.sort_indicator == false) {
+ if (!packages_version_column.sort_indicator) {
new_order = Gtk.SortType.ASCENDING;
} else {
if (sortinfo.sort_type == Gtk.SortType.ASCENDING) {
@@ -816,9 +1245,26 @@ namespace Pamac {
}
[GtkCallback]
- public void on_repo_column_clicked () {
+ public void on_aur_version_column_clicked () {
+ Gtk.SortType new_order;
+ if (!aur_version_column.sort_indicator) {
+ new_order = Gtk.SortType.ASCENDING;
+ } else {
+ if (sortinfo.sort_type == Gtk.SortType.ASCENDING) {
+ new_order = Gtk.SortType.DESCENDING;
+ } else {
+ new_order = Gtk.SortType.ASCENDING;
+ }
+ }
+ aur_list.sort_by_version (new_order);
+ // force a display refresh
+ aur_treeview.queue_draw ();
+ }
+
+ [GtkCallback]
+ public void on_packages_repo_column_clicked () {
Gtk.SortType new_order;
- if (repo_column.sort_indicator == false) {
+ if (!packages_repo_column.sort_indicator) {
new_order = Gtk.SortType.ASCENDING;
} else {
if (sortinfo.sort_type == Gtk.SortType.ASCENDING) {
@@ -833,9 +1279,9 @@ namespace Pamac {
}
[GtkCallback]
- public void on_size_column_clicked () {
+ public void on_packages_size_column_clicked () {
Gtk.SortType new_order;
- if (size_column.sort_indicator == false) {
+ if (!packages_size_column.sort_indicator) {
new_order = Gtk.SortType.ASCENDING;
} else {
if (sortinfo.sort_type == Gtk.SortType.ASCENDING) {
@@ -849,57 +1295,50 @@ namespace Pamac {
packages_treeview.queue_draw ();
}
+ [GtkCallback]
+ public void on_aur_votes_column_clicked () {
+ Gtk.SortType new_order;
+ if (!aur_votes_column.sort_indicator) {
+ new_order = Gtk.SortType.ASCENDING;
+ } else {
+ if (sortinfo.sort_type == Gtk.SortType.ASCENDING) {
+ new_order = Gtk.SortType.DESCENDING;
+ } else {
+ new_order = Gtk.SortType.ASCENDING;
+ }
+ }
+ aur_list.sort_by_votes (new_order);
+ // force a display refresh
+ aur_treeview.queue_draw ();
+ }
+
[GtkCallback]
public void on_search_entry_activate () {
- string search_string = search_entry.get_text ();
+ unowned string search_string = search_entry.get_text ();
if (search_string != "") {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
- transaction.search_pkgs.begin (search_string, search_aur_button.get_active (), (obj, res) => {
- var pkgs = transaction.search_pkgs.end (res);
- if (pkgs.length != 0) {
- // add search string in search_list if needed
- bool found = false;
- Gtk.TreeIter? iter;
- Gtk.TreeModel model;
- Gtk.TreeSelection selection = search_treeview.get_selection ();
- // check if search string is already selected in search list
- if (selection.get_selected (out model, out iter)) {
- GLib.Value val;
- model.get_value (iter, 0, out val);
- string selected_string = val.get_string ();
- if (selected_string == search_string) {
- found = true;
- // we need to populate packages_list
- populate_packages_list (pkgs);
- } else {
- search_list.foreach ((_model, _path, _iter) => {
- GLib.Value line;
- model.get_value (_iter, 0, out line);
- if ((string) line == search_string) {
- found = true;
- // block the signal to not populate when we select the iter in search_list
- selection.changed.disconnect (on_search_treeview_selection_changed);
- selection.select_iter (_iter);
- selection.changed.connect_after (on_search_treeview_selection_changed);
- populate_packages_list (pkgs);
- }
- return found;
- });
- }
- }
- if (found == false) {
- search_list.insert_with_values (out iter, -1, 0, search_string);
- // block the signal to not populate when we select the iter in search_list
- selection.changed.disconnect (on_search_treeview_selection_changed);
- selection.select_iter (iter);
- selection.changed.connect_after (on_search_treeview_selection_changed);
- populate_packages_list (pkgs);
- }
- } else {
- // populate with empty lists
- populate_packages_list (pkgs);
+ Gtk.TreeSelection selection = search_treeview.get_selection ();
+ // add search string in search_list if needed
+ bool found = false;
+ // check if search string is already selected in search list
+ search_list.foreach ((_model, _path, _iter) => {
+ GLib.Value line;
+ _model.get_value (_iter, 0, out line);
+ if ((string) line == search_string) {
+ found = true;
+ // we select the iter in search_list
+ // it will populate the list with the selection changed signal
+ selection.select_iter (_iter);
}
+ return found;
});
+ if (!found) {
+ Gtk.TreeIter? iter;
+ search_list.insert_with_values (out iter, -1, 0, search_string);
+ // we select the iter in search_list
+ // it will populate the list with the selection changed signal
+ selection.select_iter (iter);
+ }
}
}
@@ -918,10 +1357,24 @@ namespace Pamac {
GLib.Value val;
model.get_value (iter, 0, out val);
string search_string = val.get_string ();
- transaction.search_pkgs.begin (search_string, search_aur_button.get_active (), (obj, res) => {
- var pkgs = transaction.search_pkgs.end (res);
- populate_packages_list (pkgs);
- });
+ switch (packages_notebook.get_current_page ()) {
+ case 0:
+ search_all_dbs.begin (search_string, (obj, res) => {
+ var pkgs = search_all_dbs.end (res);
+ if (search_aur_button.get_active ()) {
+ search_in_aur.begin (search_string);
+ }
+ populate_packages_list ((owned) pkgs);
+ });
+ break;
+ case 1:
+ search_in_aur.begin (search_string, (obj, res) => {
+ populate_aur_list (aur_search_results.lookup (search_string));
+ });
+ break;
+ default:
+ break;
+ }
}
}
@@ -932,12 +1385,11 @@ namespace Pamac {
Gtk.TreeSelection selection = groups_treeview.get_selection ();
if (selection.get_selected (out model, out iter)) {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
- GLib.Value val;
- model.get_value (iter, 0, out val);
- string grp_name = val.get_string ();
- transaction.get_group_pkgs.begin (grp_name, (obj, res) => {
- var pkgs = transaction.get_group_pkgs.end (res);
- populate_packages_list (pkgs);
+ GLib.Value grp_name;
+ model.get_value (iter, 0, out grp_name);
+ get_group_pkgs.begin ((string) grp_name, (obj, res) => {
+ var pkgs = get_group_pkgs.end (res);
+ populate_packages_list ((owned) pkgs);
});
}
}
@@ -945,50 +1397,48 @@ namespace Pamac {
[GtkCallback]
public void on_states_treeview_selection_changed () {
Gtk.TreeModel model;
- Gtk.TreeIter? iter;
+ Gtk.TreeIter? treeiter;
Gtk.TreeSelection selection = states_treeview.get_selection ();
- if (selection.get_selected (out model, out iter)) {
+ if (selection.get_selected (out model, out treeiter)) {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
GLib.Value val;
- model.get_value (iter, 0, out val);
- string state = val.get_string ();
- Pamac.Package[] pkgs = {};
- Pamac.Package find_pkg;
+ model.get_value (treeiter, 0, out val);
+ unowned string state = val.get_string ();
if (state == dgettext (null, "To install")) {
- foreach (string name in transaction.to_add) {
- find_pkg = transaction.find_local_pkg (name);
- if (find_pkg.name != "") {
- pkgs += find_pkg;
- } else {
- find_pkg = transaction.find_sync_pkg (name);
- if (find_pkg.name != "") {
- pkgs += find_pkg;
- }
+ var pkgs = new Alpm.List ();
+ foreach (unowned string pkgname in transaction.to_add) {
+ unowned Alpm.Package? pkg = alpm_config.handle.localdb.get_pkg (pkgname);
+ if (pkg == null) {
+ pkg = get_sync_pkg (pkgname);
+ }
+ if (pkg != null) {
+ pkgs.add (pkg);
}
}
- populate_packages_list (pkgs);
+ populate_packages_list ((owned) pkgs);
} else if (state == dgettext (null, "To remove")) {
- foreach (string name in transaction.to_remove) {
- find_pkg = transaction.find_local_pkg (name);
- if (find_pkg.name != "") {
- pkgs += find_pkg;
+ var pkgs = new Alpm.List ();
+ foreach (unowned string pkgname in transaction.to_remove) {
+ unowned Alpm.Package? pkg = alpm_config.handle.localdb.get_pkg (pkgname);
+ if (pkg != null) {
+ pkgs.add (pkg);
}
}
- populate_packages_list (pkgs);
+ populate_packages_list ((owned) pkgs);
} else if (state == dgettext (null, "Installed")) {
- transaction.get_installed_pkgs.begin ((obj, res) => {
- pkgs = transaction.get_installed_pkgs.end (res);
- populate_packages_list (pkgs);
+ get_installed_pkgs.begin ((obj, res) => {
+ var pkgs = get_installed_pkgs.end (res);
+ populate_packages_list ((owned) pkgs);
});
} else if (state == dgettext (null, "Uninstalled")) {
- //transaction.get_sync_pkgs.begin ((obj, res) => {
- //pkgs = transaction.get_sync_pkgs.end (res);
- //populate_packages_list (pkgs);
+ //get_sync_pkgs.begin ((obj, res) => {
+ //var pkgs = get_sync_pkgs.end (res);
+ //populate_packages_list ((owned) pkgs);
//});
} else if (state == dgettext (null, "Orphans")) {
- transaction.get_orphans.begin ((obj, res) => {
- pkgs = transaction.get_orphans.end (res);
- populate_packages_list (pkgs);
+ get_orphans.begin ((obj, res) => {
+ var pkgs = get_orphans.end (res);
+ populate_packages_list ((owned) pkgs);
});
}
}
@@ -1003,16 +1453,16 @@ namespace Pamac {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
GLib.Value val;
model.get_value (iter, 0, out val);
- string repo = val.get_string ();
+ unowned string repo = val.get_string ();
if (repo == dgettext (null, "local")) {
- transaction.get_local_pkgs.begin ((obj, res) => {
- var pkgs = transaction.get_local_pkgs.end (res);
- populate_packages_list (pkgs);
+ get_local_pkgs.begin ((obj, res) => {
+ var pkgs = get_local_pkgs.end (res);
+ populate_packages_list ((owned) pkgs);
});
} else {
- transaction.get_repo_pkgs.begin (repo, (obj, res) => {
- var pkgs = transaction.get_repo_pkgs.end (res);
- populate_packages_list (pkgs);
+ get_repo_pkgs.begin (repo, (obj, res) => {
+ var pkgs = get_repo_pkgs.end (res);
+ populate_packages_list ((owned) pkgs);
});
}
}
@@ -1074,7 +1524,7 @@ namespace Pamac {
if (chooser.run () == Gtk.ResponseType.ACCEPT) {
SList packages_paths = chooser.get_filenames ();
if (packages_paths.length () != 0) {
- foreach (string path in packages_paths) {
+ foreach (unowned string path in packages_paths) {
transaction.to_load.add (path);
}
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
@@ -1096,7 +1546,7 @@ namespace Pamac {
SourceFunc callback = run_preferences_dialog.callback;
ulong handler_id = transaction.daemon.get_authorization_finished.connect ((authorized) => {
if (authorized) {
- var preferences_dialog = new PreferencesDialog (transaction, this);
+ var preferences_dialog = new PreferencesDialog (this, transaction);
preferences_dialog.run ();
preferences_dialog.destroy ();
while (Gtk.events_pending ()) {
@@ -1140,21 +1590,24 @@ namespace Pamac {
set_buttons_sensitive (false);
// force a display refresh
packages_treeview.queue_draw ();
+ aur_treeview.queue_draw ();
}
[GtkCallback]
public void on_refresh_button_clicked () {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
- transaction.start_refresh (0);
+ transaction.start_refresh (false);
}
- public void on_transaction_finished (bool error) {
- if (error == false) {
+ public void on_transaction_finished (bool database_modified) {
+ if (database_modified) {
set_buttons_sensitive (false);
+ refresh_handle ();
refresh_packages_list ();
+ } else {
+ this.get_window ().set_cursor (null);
}
transaction.to_load.remove_all ();
- this.get_window ().set_cursor (null);
}
}
}
diff --git a/src/mirrors_config.vala b/src/mirrors_config.vala
index 2c55dc5..c1c61ed 100644
--- a/src/mirrors_config.vala
+++ b/src/mirrors_config.vala
@@ -18,9 +18,10 @@
*/
namespace Alpm {
+ [Compact]
public class MirrorsConfig: Object {
- string conf_path;
- string mirrorlists_dir;
+ public string conf_path;
+ public string mirrorlists_dir;
public string choosen_generation_method;
public string choosen_country;
public GLib.List countrys;
@@ -47,9 +48,7 @@ namespace Alpm {
while ((file_info = enumerator.next_file ()) != null) {
countrys.append(file_info.get_name ());
}
- countrys.sort ((a, b) => {
- return strcmp (a, b);
- });
+ countrys.sort (strcmp);
} catch (Error e) {
stderr.printf ("%s\n", e.message);
}
@@ -57,9 +56,7 @@ namespace Alpm {
public void parse_file (string path) {
var file = GLib.File.new_for_path (path);
- if (file.query_exists () == false) {
- GLib.stderr.printf ("File '%s' doesn't exist.\n", path);
- } else {
+ if (file.query_exists ()) {
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
@@ -76,11 +73,11 @@ namespace Alpm {
if (line.length == 0) {
continue;
}
- splitted = line.split ("=");
- string key = splitted[0].strip ();
- string? val = null;
- if (splitted[1] != null) {
- val = splitted[1].strip ();
+ splitted = line.split ("=", 2);
+ unowned string key = splitted[0]._strip ();
+ unowned string? val = null;
+ if (splitted.length == 2) {
+ val = splitted[1]._strip ();
}
if (key == "Method") {
choosen_generation_method = val;
@@ -93,59 +90,60 @@ namespace Alpm {
} catch (Error e) {
GLib.stderr.printf("%s\n", e.message);
}
+ } else {
+ GLib.stderr.printf ("File '%s' doesn't exist.\n", path);
}
}
public void write (HashTable new_conf) {
var file = GLib.File.new_for_path (conf_path);
- if (file.query_exists () == false) {
- GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
- } else {
+ if (file.query_exists ()) {
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
var dis = new DataInputStream (file.read ());
string? line;
- string[] data = {};
+ var data = new GLib.List ();
// Read lines until end of file (null) is reached
while ((line = dis.read_line ()) != null) {
if (line.length == 0) {
- data += "\n";
+ data.append ("\n");
continue;
}
+ unowned Variant variant;
if (line.contains ("Method")) {
- if (new_conf.contains ("Method")) {
- string val = new_conf.get ("Method").get_string ();
- data += "Method=%s\n".printf (val);
+ if (new_conf.lookup_extended ("Method", null, out variant)) {
+ data.append ("Method=%s\n".printf (variant.get_string ()));
} else {
- data += line + "\n";
+ data.append (line + "\n");
}
} else if (line.contains ("OnlyCountry")) {
- if (new_conf.contains ("OnlyCountry")) {
- string val = new_conf.get ("OnlyCountry").get_string ();
- if (val == dgettext (null, "Worldwide")) {
- data += "#%s\n".printf (line);
+ if (new_conf.lookup_extended ("OnlyCountry", null, out variant)) {
+ if (variant.get_string () == dgettext (null, "Worldwide")) {
+ data.append ("#%s\n".printf (line));
} else {
- data += "OnlyCountry=%s\n".printf (val);
+ data.append ("OnlyCountry=%s\n".printf (variant.get_string ()));
}
} else {
- data += line + "\n";
+ data.append (line + "\n");
}
} else {
- data += line + "\n";
+ data.append (line + "\n");
}
}
// delete the file before rewrite it
file.delete ();
// creating a DataOutputStream to the file
var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION));
- foreach (string new_line in data) {
+ foreach (unowned string new_line in data) {
// writing a short string to the stream
dos.put_string (new_line);
}
} catch (GLib.Error e) {
GLib.stderr.printf("%s\n", e.message);
}
+ } else {
+ GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
}
}
}
diff --git a/src/package.vala b/src/package.vala
index 44c6a7e..0c36423 100644
--- a/src/package.vala
+++ b/src/package.vala
@@ -31,12 +31,13 @@ namespace Pamac {
public Package (Alpm.Package? alpm_pkg, Json.Object? aur_json) {
if (alpm_pkg != null) {
- name = alpm_pkg.name ?? "";
- version = alpm_pkg.version ?? "";
- desc = alpm_pkg.desc ?? "";
- repo = (alpm_pkg.db != null ? (alpm_pkg.db.name ?? "") : "");
+ name = alpm_pkg.name;
+ version = alpm_pkg.version;
+ desc = alpm_pkg.desc;
+ repo = alpm_pkg.db != null ? alpm_pkg.db.name : "";
size = alpm_pkg.isize;
size_string = format_size (alpm_pkg.isize);
+ // alpm pkg url can be null
url = alpm_pkg.url ?? "";
StringBuilder licenses_build = new StringBuilder ();
foreach (var license in alpm_pkg.licenses) {
@@ -48,9 +49,9 @@ namespace Pamac {
licenses = licenses_build.str;
reason = alpm_pkg.reason;
} else if (aur_json != null ) {
- name = aur_json.get_string_member ("Name") ?? "";
- version = aur_json.get_string_member ("Version") ?? "";
- desc = aur_json.get_string_member ("Description") ?? "";
+ name = aur_json.get_string_member ("Name");
+ version = aur_json.get_string_member ("Version");
+ desc = aur_json.get_string_member ("Description");
repo = "AUR";
size = 0;
size_string = "";
@@ -73,15 +74,9 @@ namespace Pamac {
public struct PackageDetails {
string repo;
- // for AUR package it is OutOfDate
string has_signature;
- // for AUR package it is NumVotes
int reason;
- // for AUR package it is Maintainer
string packager;
- // for AUR package it is FirstSubmitted
- string build_date;
- // for AUR package it is LastModified
string install_date;
string[] groups;
string[] backups;
diff --git a/src/packages_model.vala b/src/packages_model.vala
index 2650888..f03bb9c 100644
--- a/src/packages_model.vala
+++ b/src/packages_model.vala
@@ -20,21 +20,12 @@
namespace Pamac {
public class PackagesModel : Object, Gtk.TreeModel {
- private GLib.List all_pkgs;
- public ManagerWindow manager_window;
+ private Alpm.List? pkgs;
+ private ManagerWindow manager_window;
- public PackagesModel (Pamac.Package[] pkgs, ManagerWindow manager_window) {
+ public PackagesModel (owned Alpm.List? pkgs, ManagerWindow manager_window) {
this.manager_window = manager_window;
- all_pkgs = new GLib.List ();
- foreach (var pkg in pkgs) {
- all_pkgs.append (pkg);
- }
- if (all_pkgs.length () == 0) {
- // create a fake "No package found" package
- var fake_pkg = Pamac.Package (null, null);
- fake_pkg.name = dgettext (null, "No package found");
- all_pkgs.append (fake_pkg);
- }
+ this.pkgs = (owned) pkgs;
}
// TreeModel interface
@@ -57,16 +48,21 @@ namespace Pamac {
}
public void get_value (Gtk.TreeIter iter, int column, out Value val) {
- Pamac.Package pkg = all_pkgs.nth_data (iter.stamp);
+ unowned Alpm.Package? pkg = pkgs.nth (iter.stamp).data;
switch (column) {
case 0:
val = Value (typeof (string));
- val.set_string (pkg.name);
+ if (pkg == null) {
+ val.set_string (dgettext (null, "No package found"));
+ } else {
+ val.set_string (pkg.name);
+ }
break;
case 1:
val = Value (typeof (Object));
- if (pkg.repo == "local") {
- if (manager_window.transaction.should_hold (pkg.name)) {
+ if (pkg != null) {
+ if (pkg.origin == Alpm.Package.From.LOCALDB) {
+ if (manager_window.alpm_config.holdpkgs.find_custom (pkg.name, strcmp) != null) {
val.set_object (manager_window.locked_icon);
} else if (manager_window.transaction.to_add.contains (pkg.name)) {
val.set_object (manager_window.to_reinstall_icon);
@@ -75,32 +71,30 @@ namespace Pamac {
} else {
val.set_object (manager_window.installed_icon);
}
- } else if (pkg.repo == "AUR") {
- if (manager_window.transaction.to_build.contains (pkg.name)) {
- val.set_object (manager_window.to_install_icon);
- } else {
- val.set_object (manager_window.uninstalled_icon);
- }
- } else if (pkg.name == dgettext (null, "No package found")) {
- // nothing to do
- break;
} else if (manager_window.transaction.to_add.contains (pkg.name)) {
val.set_object (manager_window.to_install_icon);
} else {
val.set_object (manager_window.uninstalled_icon);
}
+ }
break;
case 2:
val = Value (typeof (string));
- val.set_string (pkg.version);
+ if (pkg != null) {
+ val.set_string (pkg.version);
+ }
break;
case 3:
val = Value (typeof (string));
- val.set_string (pkg.repo);
+ if (pkg != null) {
+ val.set_string (pkg.db.name);
+ }
break;
case 4:
val = Value (typeof (string));
- val.set_string (pkg.size_string);
+ if (pkg != null) {
+ val.set_string (format_size (pkg.isize));
+ }
break;
default:
val = Value (Type.INVALID);
@@ -109,7 +103,7 @@ namespace Pamac {
}
public bool get_iter (out Gtk.TreeIter iter, Gtk.TreePath path) {;
- if (path.get_depth () != 1 || all_pkgs.length () == 0) {
+ if (path.get_depth () != 1) {
return invalid_iter (out iter);
}
iter = Gtk.TreeIter ();
@@ -133,7 +127,7 @@ namespace Pamac {
public bool iter_next (ref Gtk.TreeIter iter) {
int pos = (iter.stamp) + 1;
- if (pos >= all_pkgs.length ()) {
+ if (pos >= pkgs.length) {
return false;
}
iter.stamp = pos;
@@ -172,109 +166,82 @@ namespace Pamac {
}
// custom get pkg function
- public Pamac.Package get_pkg_at_path (Gtk.TreePath path) {
- return all_pkgs.nth_data (path.get_indices ()[0]);
+ public unowned Alpm.Package? get_pkg_at_path (Gtk.TreePath path) {
+ return pkgs.nth (path.get_indices ()[0]).data;
}
// custom sort functions
public void sort_by_name (Gtk.SortType order) {
- CompareFunc namecmp = (pkg_a, pkg_b) => {
- return strcmp (pkg_a.name, pkg_b.name);
- };
- all_pkgs.sort (namecmp);
+ pkgs.sort ((Alpm.List.CompareFunc) compare_name);
if (order == Gtk.SortType.DESCENDING) {
- all_pkgs.reverse ();
+ pkgs.reverse ();
}
- manager_window.name_column.sort_order = order;
- manager_window.state_column.sort_indicator = false;
- manager_window.name_column.sort_indicator = true;
- manager_window.version_column.sort_indicator = false;
- manager_window.repo_column.sort_indicator = false;
- manager_window.size_column.sort_indicator = false;
+ manager_window.packages_name_column.sort_order = order;
+ manager_window.packages_state_column.sort_indicator = false;
+ manager_window.packages_name_column.sort_indicator = true;
+ manager_window.packages_version_column.sort_indicator = false;
+ manager_window.packages_repo_column.sort_indicator = false;
+ manager_window.packages_size_column.sort_indicator = false;
manager_window.sortinfo.column_number = 0;
manager_window.sortinfo.sort_type = order;
}
public void sort_by_state (Gtk.SortType order) {
- CompareFunc statecmp = (pkg_a, pkg_b) => {
- int state_a;
- int state_b;
- if (pkg_a.repo == "local") {
- state_a = 0;
- } else {
- state_a = 1;
- }
- if (pkg_b.repo == "local") {
- state_b = 0;
- } else {
- state_b = 1;
- }
- return (int) (state_a > state_b) - (int) (state_a < state_b);
- };
- all_pkgs.sort (statecmp);
+ pkgs.sort ((Alpm.List.CompareFunc) compare_state);
if (order == Gtk.SortType.DESCENDING) {
- all_pkgs.reverse ();
+ pkgs.reverse ();
}
- manager_window.state_column.sort_order = order;
- manager_window.state_column.sort_indicator = true;
- manager_window.name_column.sort_indicator = false;
- manager_window.version_column.sort_indicator = false;
- manager_window.repo_column.sort_indicator = false;
- manager_window.size_column.sort_indicator = false;
+ manager_window.packages_state_column.sort_order = order;
+ manager_window.packages_state_column.sort_indicator = true;
+ manager_window.packages_name_column.sort_indicator = false;
+ manager_window.packages_version_column.sort_indicator = false;
+ manager_window.packages_repo_column.sort_indicator = false;
+ manager_window.packages_size_column.sort_indicator = false;
manager_window.sortinfo.column_number = 1;
manager_window.sortinfo.sort_type = order;
}
public void sort_by_version (Gtk.SortType order) {
- CompareFunc versioncmp = (pkg_a, pkg_b) => {
- return Alpm.pkg_vercmp (pkg_a.version, pkg_b.version);
- };
- all_pkgs.sort (versioncmp);
+ pkgs.sort ((Alpm.List.CompareFunc) compare_version);
if (order == Gtk.SortType.DESCENDING) {
- all_pkgs.reverse ();
+ pkgs.reverse ();
}
- manager_window.version_column.sort_order = order;
- manager_window.state_column.sort_indicator = false;
- manager_window.name_column.sort_indicator = false;
- manager_window.version_column.sort_indicator = true;
- manager_window.repo_column.sort_indicator = false;
- manager_window.size_column.sort_indicator = false;
+ manager_window.packages_version_column.sort_order = order;
+ manager_window.packages_state_column.sort_indicator = false;
+ manager_window.packages_name_column.sort_indicator = false;
+ manager_window.packages_version_column.sort_indicator = true;
+ manager_window.packages_repo_column.sort_indicator = false;
+ manager_window.packages_size_column.sort_indicator = false;
manager_window.sortinfo.column_number = 2;
manager_window.sortinfo.sort_type = order;
}
public void sort_by_repo (Gtk.SortType order) {
- CompareFunc repocmp = (pkg_a, pkg_b) => {
- return strcmp (pkg_a.repo, pkg_b.repo);
- };
- all_pkgs.sort (repocmp);
+ pkgs.sort ((Alpm.List.CompareFunc) compare_repo);
if (order == Gtk.SortType.DESCENDING) {
- all_pkgs.reverse ();
+ pkgs.reverse ();
}
- manager_window.repo_column.sort_order = order;
- manager_window.state_column.sort_indicator = false;
- manager_window.name_column.sort_indicator = false;
- manager_window.version_column.sort_indicator = false;
- manager_window.repo_column.sort_indicator = true;
- manager_window.size_column.sort_indicator = false;
+ manager_window.packages_repo_column.sort_order = order;
+ manager_window.packages_state_column.sort_indicator = false;
+ manager_window.packages_name_column.sort_indicator = false;
+ manager_window.packages_version_column.sort_indicator = false;
+ manager_window.packages_repo_column.sort_indicator = true;
+ manager_window.packages_size_column.sort_indicator = false;
manager_window.sortinfo.column_number = 3;
manager_window.sortinfo.sort_type = order;
}
public void sort_by_size (Gtk.SortType order) {
- CompareFunc sizecmp = (pkg_a, pkg_b) => {
- return (int) (pkg_a.size > pkg_b.size) - (int) (pkg_a.size < pkg_b.size);
- };
- all_pkgs.sort (sizecmp);
+ pkgs.sort ((Alpm.List.CompareFunc) compare_size);
if (order == Gtk.SortType.DESCENDING) {
- all_pkgs.reverse ();
+ pkgs.reverse ();
}
- manager_window.size_column.sort_order = order;
- manager_window.state_column.sort_indicator = false;
- manager_window.name_column.sort_indicator = false;
- manager_window.version_column.sort_indicator = false;
- manager_window.repo_column.sort_indicator = false;
- manager_window.size_column.sort_indicator = true;
+ manager_window.packages_size_column.sort_order = order;
+ manager_window.packages_state_column.sort_indicator = false;
+ manager_window.packages_name_column.sort_indicator = false;
+ manager_window.packages_version_column.sort_indicator = false;
+ manager_window.packages_repo_column.sort_indicator = false;
+ manager_window.packages_size_column.sort_indicator = true;
manager_window.sortinfo.column_number = 4;
manager_window.sortinfo.sort_type = order;
}
diff --git a/src/pamac_config.vala b/src/pamac_config.vala
index da48648..ad9eb1e 100644
--- a/src/pamac_config.vala
+++ b/src/pamac_config.vala
@@ -17,19 +17,47 @@
* along with this program. If not, see .
*/
+const string VERSION = "3.0.0";
+
namespace Pamac {
- public class Config: Object {
- string conf_path;
+ [Compact]
+ public class Config {
+ public string conf_path;
public bool recurse;
- public int refresh_period;
+ public uint64 refresh_period;
public bool no_update_hide_icon;
public bool enable_aur;
public bool search_aur;
public bool check_aur_updates;
public bool no_confirm_build;
+ public HashTable environment_variables;
public Config (string path) {
conf_path = path;
+ //get environment variables
+ environment_variables = new HashTable (str_hash, str_equal);
+ var utsname = Posix.utsname();
+ environment_variables.insert ("HTTP_USER_AGENT", "pamac/%s (%s %s)".printf (VERSION, utsname.sysname, utsname.machine));
+ unowned string? variable = Environment.get_variable ("http_proxy");
+ if (variable != null) {
+ environment_variables.insert ("http_proxy", variable);
+ }
+ variable = Environment.get_variable ("https_proxy");
+ if (variable != null) {
+ environment_variables.insert ("https_proxy", variable);
+ }
+ variable = Environment.get_variable ("ftp_proxy");
+ if (variable != null) {
+ environment_variables.insert ("ftp_proxy", variable);
+ }
+ variable = Environment.get_variable ("socks_proxy");
+ if (variable != null) {
+ environment_variables.insert ("socks_proxy", variable);
+ }
+ variable = Environment.get_variable ("no_proxy");
+ if (variable != null) {
+ environment_variables.insert ("no_proxy", variable);
+ }
// set default option
refresh_period = 6;
reload ();
@@ -65,16 +93,15 @@ namespace Pamac {
if (line.length == 0) {
continue;
}
- splitted = line.split ("=");
- string key = splitted[0].strip ();
- string? val = null;
- if (splitted[1] != null) {
- val = splitted[1].strip ();
- }
+ splitted = line.split ("=", 2);
+ unowned string key = splitted[0]._strip ();
if (key == "RemoveUnrequiredDeps") {
recurse = true;
} else if (key == "RefreshPeriod") {
- refresh_period = int.parse (val);
+ if (splitted.length == 2) {
+ unowned string val = splitted[1]._strip ();
+ refresh_period = uint64.parse (val);
+ }
} else if (key == "NoUpdateHideIcon") {
no_update_hide_icon = true;
} else if (key == "EnableAUR") {
@@ -97,7 +124,7 @@ namespace Pamac {
public void write (HashTable new_conf) {
var file = GLib.File.new_for_path (conf_path);
- string[] data = {};
+ var data = new GLib.List ();
if (file.query_exists ()) {
try {
// Open file for reading and wrap returned FileInputStream into a
@@ -107,91 +134,85 @@ namespace Pamac {
// Read lines until end of file (null) is reached
while ((line = dis.read_line ()) != null) {
if (line.length == 0) {
- data += "\n";
+ data.append ("\n");
continue;
}
+ unowned Variant variant;
if (line.contains ("RemoveUnrequiredDeps")) {
- if (new_conf.contains ("RemoveUnrequiredDeps")) {
- bool val = new_conf.get ("RemoveUnrequiredDeps").get_boolean ();
- if (val == true) {
- data += "RemoveUnrequiredDeps\n";
+ if (new_conf.lookup_extended ("RemoveUnrequiredDeps", null, out variant)) {
+ if (variant.get_boolean ()) {
+ data.append ("RemoveUnrequiredDeps\n");
} else {
- data += "#RemoveUnrequiredDeps\n";
+ data.append ("#RemoveUnrequiredDeps\n");
}
new_conf.remove ("RemoveUnrequiredDeps");
} else {
- data += line + "\n";
+ data.append (line + "\n");
}
} else if (line.contains ("RefreshPeriod")) {
- if (new_conf.contains ("RefreshPeriod")) {
- int val = new_conf.get ("RefreshPeriod").get_int32 ();
- data += "RefreshPeriod = %u\n".printf (val);
+ if (new_conf.lookup_extended ("RefreshPeriod", null, out variant)) {
+ data.append ("RefreshPeriod = %llu\n".printf (variant.get_uint64 ()));
new_conf.remove ("RefreshPeriod");
} else {
- data += line + "\n";
+ data.append (line + "\n");
}
} else if (line.contains ("NoUpdateHideIcon")) {
- if (new_conf.contains ("NoUpdateHideIcon")) {
- bool val = new_conf.get ("NoUpdateHideIcon").get_boolean ();
- if (val == true) {
- data += "NoUpdateHideIcon\n";
+ if (new_conf.lookup_extended ("NoUpdateHideIcon", null, out variant)) {
+ if (variant.get_boolean ()) {
+ data.append ("NoUpdateHideIcon\n");
} else {
- data += "#NoUpdateHideIcon\n";
+ data.append ("#NoUpdateHideIcon\n");
}
new_conf.remove ("NoUpdateHideIcon");
} else {
- data += line + "\n";
+ data.append (line + "\n");
}
} else if (line.contains ("EnableAUR")) {
- if (new_conf.contains ("EnableAUR")) {
- bool val = new_conf.get ("EnableAUR").get_boolean ();
- if (val == true) {
- data += "EnableAUR\n";
+ if (new_conf.lookup_extended ("EnableAUR", null, out variant)) {
+ if (variant.get_boolean ()) {
+ data.append ("EnableAUR\n");
} else {
- data += "#EnableAUR\n";
+ data.append ("#EnableAUR\n");
}
new_conf.remove ("EnableAUR");
} else {
- data += line + "\n";
+ data.append (line + "\n");
}
} else if (line.contains ("SearchInAURByDefault")) {
- if (new_conf.contains ("SearchInAURByDefault")) {
- bool val = new_conf.get ("SearchInAURByDefault").get_boolean ();
- if (val == true) {
- data += "SearchInAURByDefault\n";
+ if (new_conf.lookup_extended ("SearchInAURByDefault", null, out variant)) {
+ if (variant.get_boolean ()) {
+ data.append ("SearchInAURByDefault\n");
} else {
- data += "#SearchInAURByDefault\n";
+ data.append ("#SearchInAURByDefault\n");
}
new_conf.remove ("SearchInAURByDefault");
} else {
- data += line + "\n";
+ data.append (line + "\n");
}
} else if (line.contains ("CheckAURUpdates")) {
- if (new_conf.contains ("CheckAURUpdates")) {
- bool val = new_conf.get ("CheckAURUpdates").get_boolean ();
- if (val == true) {
- data += "CheckAURUpdates\n";
+ if (new_conf.lookup_extended ("CheckAURUpdates", null, out variant)) {
+ if (variant.get_boolean ()) {
+ data.append ("CheckAURUpdates\n");
} else {
- data += "#CheckAURUpdates\n";
+ data.append ("#CheckAURUpdates\n");
}
new_conf.remove ("CheckAURUpdates");
} else {
- data += line + "\n";
+ data.append (line + "\n");
}
} else if (line.contains ("NoConfirmBuild")) {
- if (new_conf.contains ("NoConfirmBuild")) {
- bool val = new_conf.get ("NoConfirmBuild").get_boolean ();
- if (val == true) {
- data += "NoConfirmBuild\n";
+ if (new_conf.lookup_extended ("NoConfirmBuild", null, out variant)) {
+ if (variant.get_boolean ()) {
+ data.append ("NoConfirmBuild\n");
} else {
- data += "#NoConfirmBuild\n";
+ data.append ("#NoConfirmBuild\n");
}
new_conf.remove ("NoConfirmBuild");
} else {
- data += line + "\n";
+ data.append (line + "\n");
}
} else {
- data += line + "\n";
+ data.append (line + "\n");
}
}
// delete the file before rewrite it
@@ -204,54 +225,57 @@ namespace Pamac {
}
// create lines for unexisted options
if (new_conf.size () != 0) {
- data += "\n";
- new_conf.foreach ((key, val) => {
+ data.append ("\n");
+ var iter = HashTableIter (new_conf);
+ unowned string key;
+ unowned Variant val;
+ while (iter.next (out key, out val)) {
if (key == "RemoveUnrequiredDeps") {
- if (val.get_boolean () == true) {
- data += "RemoveUnrequiredDeps\n";
+ if (val.get_boolean ()) {
+ data.append ("RemoveUnrequiredDeps\n");
} else {
- data += "#RemoveUnrequiredDeps\n";
+ data.append ("#RemoveUnrequiredDeps\n");
}
} else if (key == "RefreshPeriod") {
- data += "RefreshPeriod = %u\n".printf (val.get_int32 ());
+ data.append ("RefreshPeriod = %llu\n".printf (val.get_uint64 ()));
} else if (key =="NoUpdateHideIcon") {
- if (val.get_boolean () == true) {
- data += "NoUpdateHideIcon\n";
+ if (val.get_boolean ()) {
+ data.append ("NoUpdateHideIcon\n");
} else {
- data += "#NoUpdateHideIcon\n";
+ data.append ("#NoUpdateHideIcon\n");
}
} else if (key == "EnableAUR") {
- if (val.get_boolean () == true) {
- data += "EnableAUR\n";
+ if (val.get_boolean ()) {
+ data.append ("EnableAUR\n");
} else {
- data += "#EnableAUR\n";
+ data.append ("#EnableAUR\n");
}
} else if (key == "SearchInAURByDefault") {
- if (val.get_boolean () == true) {
- data += "SearchInAURByDefault\n";
+ if (val.get_boolean ()) {
+ data.append ("SearchInAURByDefault\n");
} else {
- data += "#SearchInAURByDefault\n";
+ data.append ("#SearchInAURByDefault\n");
}
} else if (key == "CheckAURUpdates") {
- if (val.get_boolean () == true) {
- data += "CheckAURUpdates\n";
+ if (val.get_boolean ()) {
+ data.append ("CheckAURUpdates\n");
} else {
- data += "#CheckAURUpdates\n";
+ data.append ("#CheckAURUpdates\n");
}
} else if (key == "NoConfirmBuild") {
- if (val.get_boolean () == true) {
- data += "NoConfirmBuild\n";
+ if (val.get_boolean ()) {
+ data.append ("NoConfirmBuild\n");
} else {
- data += "#NoConfirmBuild\n";
+ data.append ("#NoConfirmBuild\n");
}
}
- });
+ }
}
// write the file
try {
// creating a DataOutputStream to the file
var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION));
- foreach (string new_line in data) {
+ foreach (unowned string new_line in data) {
// writing a short string to the stream
dos.put_string (new_line);
}
diff --git a/src/preferences_dialog.vala b/src/preferences_dialog.vala
index 244a50c..58f2db1 100644
--- a/src/preferences_dialog.vala
+++ b/src/preferences_dialog.vala
@@ -60,17 +60,22 @@ namespace Pamac {
public Gtk.CheckButton no_confirm_build_checkbutton;
Transaction transaction;
- int previous_refresh_period;
+ Alpm.Config alpm_config;
+ uint64 previous_refresh_period;
- public PreferencesDialog (Transaction transaction, Gtk.ApplicationWindow? window) {
+ public PreferencesDialog (Gtk.ApplicationWindow? window, Transaction transaction) {
Object (transient_for: window, use_header_bar: 0);
this.transaction = transaction;
+ alpm_config = new Alpm.Config ("/etc/pacman.conf");
+ alpm_config.get_handle ();
+ if (alpm_config.handle == null) {
+ stderr.printf (dgettext (null, "Failed to initialize alpm library"));
+ }
refresh_period_label.set_markup (dgettext (null, "How often to check for updates, value in hours") +":");
- var pamac_config = new Pamac.Config ("/etc/pamac.conf");
- remove_unrequired_deps_button.active = pamac_config.recurse;
- check_space_button.active = transaction.get_checkspace ();
- if (pamac_config.refresh_period == 0) {
+ remove_unrequired_deps_button.active = transaction.pamac_config.recurse;
+ check_space_button.active = (alpm_config.checkspace == 1);
+ if (transaction.pamac_config.refresh_period == 0) {
check_updates_button.active = false;
refresh_period_label.sensitive = false;
// set default value
@@ -81,15 +86,15 @@ namespace Pamac {
ignorepkgs_box.sensitive = false;
} else {
check_updates_button.active = true;
- refresh_period_spin_button.value = pamac_config.refresh_period;
- previous_refresh_period = pamac_config.refresh_period;
+ refresh_period_spin_button.value = transaction.pamac_config.refresh_period;
+ previous_refresh_period = transaction.pamac_config.refresh_period;
}
- no_update_hide_icon_checkbutton.active = pamac_config.no_update_hide_icon;
+ no_update_hide_icon_checkbutton.active = transaction.pamac_config.no_update_hide_icon;
// populate ignorepkgs_liststore
Gtk.TreeIter iter;
- foreach (var name in transaction.get_ignorepkgs ()) {
- ignorepkgs_liststore.insert_with_values (out iter, -1, 0, name);
+ for (unowned Alpm.List list = alpm_config.ignorepkgs; list != null; list = list.next ()) {
+ ignorepkgs_liststore.insert_with_values (out iter, -1, 0, list.data);
}
remove_unrequired_deps_button.state_set.connect (on_remove_unrequired_deps_button_state_set);
check_space_button.state_set.connect (on_check_space_button_state_set);
@@ -98,8 +103,8 @@ namespace Pamac {
no_update_hide_icon_checkbutton.toggled.connect (on_no_update_hide_icon_checkbutton_toggled);
transaction.daemon.write_pamac_config_finished.connect (on_write_pamac_config_finished);
- Pamac.Package pkg = this.transaction.find_local_satisfier ("pacman-mirrorlist");
- if (pkg.name == "") {
+ unowned Alpm.Package? pkg = Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, "pacman-mirrorlist");
+ if (pkg == null) {
mirrors_config_box.visible = false;
} else {
var mirrors_config = new Alpm.MirrorsConfig ("/etc/pacman-mirrors.conf");
@@ -107,7 +112,7 @@ namespace Pamac {
mirrors_country_comboboxtext.active = 0;
int index = 1;
mirrors_config.get_countrys ();
- foreach (string country in mirrors_config.countrys) {
+ foreach (unowned string country in mirrors_config.countrys) {
mirrors_country_comboboxtext.append_text (country);
if (country == mirrors_config.choosen_country) {
mirrors_country_comboboxtext.active = index;
@@ -126,17 +131,17 @@ namespace Pamac {
transaction.daemon.write_mirrors_config_finished.connect (on_write_mirrors_config_finished);
}
- pkg = this.transaction.find_local_satisfier ("yaourt");
- if (pkg.name == "") {
+ pkg = Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, "yaourt");
+ if (pkg == null) {
aur_config_box.visible = false;
} else {
- enable_aur_button.active = pamac_config.enable_aur;
- search_aur_checkbutton.active = pamac_config.search_aur;
- search_aur_checkbutton.sensitive = pamac_config.enable_aur;
- check_aur_updates_checkbutton.active = pamac_config.check_aur_updates;
- check_aur_updates_checkbutton.sensitive = pamac_config.enable_aur;
- no_confirm_build_checkbutton.active = pamac_config.no_confirm_build;
- no_confirm_build_checkbutton.sensitive = pamac_config.enable_aur;
+ enable_aur_button.active = transaction.pamac_config.enable_aur;
+ search_aur_checkbutton.active = transaction.pamac_config.search_aur;
+ search_aur_checkbutton.sensitive = transaction.pamac_config.enable_aur;
+ check_aur_updates_checkbutton.active = transaction.pamac_config.check_aur_updates;
+ check_aur_updates_checkbutton.sensitive = transaction.pamac_config.enable_aur;
+ no_confirm_build_checkbutton.active = transaction.pamac_config.no_confirm_build;
+ no_confirm_build_checkbutton.sensitive = transaction.pamac_config.enable_aur;
enable_aur_button.state_set.connect (on_enable_aur_button_state_set);
search_aur_checkbutton.toggled.connect (on_search_aur_checkbutton_toggled);
check_aur_updates_checkbutton.toggled.connect (on_check_aur_updates_checkbutton_toggled);
@@ -158,10 +163,10 @@ namespace Pamac {
refresh_period_spin_button.sensitive = new_state;
no_update_hide_icon_checkbutton.sensitive = new_state;
ignorepkgs_box.sensitive = new_state;
- if (new_state == true) {
- new_pamac_conf.insert ("RefreshPeriod", new Variant.int32 (previous_refresh_period));
+ if (new_state) {
+ new_pamac_conf.insert ("RefreshPeriod", new Variant.uint64 (previous_refresh_period));
} else {
- new_pamac_conf.insert ("RefreshPeriod", new Variant.int32 (0));
+ new_pamac_conf.insert ("RefreshPeriod", new Variant.uint64 (0));
}
transaction.start_write_pamac_config (new_pamac_conf);
return true;
@@ -204,7 +209,7 @@ namespace Pamac {
transaction.start_write_pamac_config (new_pamac_conf);
}
- void on_write_pamac_config_finished (bool recurse, int refresh_period, bool no_update_hide_icon,
+ void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur, bool check_aur_updates,
bool no_confirm_build) {
remove_unrequired_deps_button.state = recurse;
@@ -248,7 +253,15 @@ namespace Pamac {
[GtkCallback]
void on_add_ignorepkgs_button_clicked () {
- var choose_ignorepkgs_dialog = new ChooseIgnorepkgsDialog (this, transaction);
+ var choose_ignorepkgs_dialog = new ChooseIgnorepkgsDialog (this);
+ foreach (var pkg in alpm_config.handle.localdb.pkgcache) {
+ Gtk.TreeIter iter;
+ if (alpm_config.ignorepkgs.find_str (pkg.name) == null) {
+ choose_ignorepkgs_dialog.pkgs_list.insert_with_values (out iter, -1, 0, false, 1, pkg.name);
+ } else {
+ choose_ignorepkgs_dialog.pkgs_list.insert_with_values (out iter, -1, 0, true, 1, pkg.name);
+ }
+ }
if (choose_ignorepkgs_dialog.run () == Gtk.ResponseType.OK) {
var ignorepkg_string = new StringBuilder ();
choose_ignorepkgs_dialog.pkgs_list.foreach ((model, path, iter) => {
@@ -257,7 +270,7 @@ namespace Pamac {
bool selected = val.get_boolean ();
if (selected) {
choose_ignorepkgs_dialog.pkgs_list.get_value (iter, 1, out val);
- string name = val.get_string ();
+ unowned string name = val.get_string ();
if (ignorepkg_string.len != 0) {
ignorepkg_string.append (" ");
}
@@ -287,7 +300,7 @@ namespace Pamac {
ignorepkgs_liststore.foreach ((model, path, iter) => {
GLib.Value val;
ignorepkgs_liststore.get_value (iter, 0, out val);
- string name = val.get_string ();
+ unowned string name = val.get_string ();
if (ignorepkg_string.len != 0) {
ignorepkg_string.append (" ");
}
@@ -305,8 +318,8 @@ namespace Pamac {
// re-populate ignorepkgs_liststore
Gtk.TreeIter iter;
ignorepkgs_liststore.clear ();
- foreach (var name in transaction.get_ignorepkgs ()) {
- ignorepkgs_liststore.insert_with_values (out iter, -1, 0, name);
+ for (unowned Alpm.List list = alpm_config.ignorepkgs; list != null; list = list.next ()) {
+ ignorepkgs_liststore.insert_with_values (out iter, -1, 0, list.data);
}
}
@@ -331,7 +344,7 @@ namespace Pamac {
mirrors_country_comboboxtext.model.foreach ((model, path, iter) => {
GLib.Value val;
model.get_value (iter, 0, out val);
- string country = val.get_string ();
+ unowned string country = val.get_string ();
if (choosen_country == country) {
return true;
}
diff --git a/src/progress_dialog.vala b/src/progress_dialog.vala
index 81fd124..8a94332 100644
--- a/src/progress_dialog.vala
+++ b/src/progress_dialog.vala
@@ -33,14 +33,12 @@ namespace Pamac {
[GtkChild]
public Gtk.Expander expander;
- Transaction transaction;
public Vte.Terminal term;
Vte.Pty pty;
- public ProgressDialog (Transaction transaction, Gtk.ApplicationWindow? window) {
+ public ProgressDialog (Gtk.ApplicationWindow? window) {
Object (transient_for: window, use_header_bar: 0);
- this.transaction = transaction;
//creating terminal
term = new Vte.Terminal ();
term.scroll_on_output = false;
@@ -72,18 +70,6 @@ namespace Pamac {
}
}
- [GtkCallback]
- public void on_cancel_button_clicked () {
- transaction.cancel ();
- transaction.clear_lists ();
- spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"});
- this.hide ();
- transaction.finished (false);
- while (Gtk.events_pending ()) {
- Gtk.main_iteration ();
- }
- }
-
public void spawn_in_term (string[] args, out Pid child_pid = null) {
Pid intern_pid;
try {
diff --git a/src/refresh.vala b/src/refresh.vala
index b3997ce..fd2c5bc 100644
--- a/src/refresh.vala
+++ b/src/refresh.vala
@@ -1,7 +1,7 @@
/*
* pamac-vala
*
- * Copyright (C) 2014-2015 Guillaume Benoit
+ * Copyright (C) 2014-2016 Guillaume Benoit
*
* 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
@@ -24,10 +24,10 @@ namespace Pamac {
}
[DBus (name = "org.manjaro.pamac")]
public interface Daemon : Object {
- public abstract void start_refresh (int force) throws IOError;
+ public abstract void start_refresh (bool force) throws IOError;
[DBus (no_reply = true)]
public abstract void quit () throws IOError;
- public signal void refresh_finished (ErrorInfos error);
+ public signal void refresh_finished (bool success);
}
}
@@ -84,10 +84,9 @@ int main () {
if (pamac_config.refresh_period != 0) {
if (!check_pamac_running ()) {
try {
- pamac_daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac",
- "/org/manjaro/pamac");
+ pamac_daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac", "/org/manjaro/pamac");
pamac_daemon.refresh_finished.connect (on_refresh_finished);
- pamac_daemon.start_refresh (0);
+ pamac_daemon.start_refresh (false);
loop = new MainLoop ();
loop.run ();
} catch (IOError e) {
diff --git a/src/transaction.vala b/src/transaction.vala
index cae7d48..1cbfd94 100644
--- a/src/transaction.vala
+++ b/src/transaction.vala
@@ -20,61 +20,47 @@
namespace Pamac {
[DBus (name = "org.manjaro.pamac")]
public interface Daemon : Object {
+ public abstract void set_environment_variables (HashTable variables) throws IOError;
+ public abstract ErrorInfos get_current_error () throws IOError;
public abstract void start_get_authorization () throws IOError;
public abstract void start_write_pamac_config (HashTable new_pamac_conf) throws IOError;
public abstract void start_write_alpm_config (HashTable new_alpm_conf) throws IOError;
public abstract void start_write_mirrors_config (HashTable new_mirrors_conf) throws IOError;
public abstract void start_generate_mirrors_list () throws IOError;
public abstract void start_set_pkgreason (string pkgname, uint reason) throws IOError;
- public abstract void start_refresh (int force) throws IOError;
- public abstract bool get_checkspace () throws IOError;
- public abstract string[] get_ignorepkgs () throws IOError;
+ public abstract PackageInfos get_installed_pkg (string pkgname) throws IOError;
+ public abstract void start_refresh (bool force) throws IOError;
public abstract void add_ignorepkg (string pkgname) throws IOError;
public abstract void remove_ignorepkg (string pkgname) throws IOError;
- public abstract bool should_hold (string pkgname) throws IOError;
- public abstract async Pamac.Package[] get_all_pkgs () throws IOError;
- public abstract async Pamac.Package[] get_installed_pkgs () throws IOError;
- public abstract async Pamac.Package[] get_local_pkgs () throws IOError;
- public abstract async Pamac.Package[] get_orphans () throws IOError;
- public abstract Pamac.Package find_local_pkg (string pkgname) throws IOError;
- public abstract Pamac.Package find_local_satisfier (string pkgname) throws IOError;
- public abstract Pamac.Package find_sync_pkg (string pkgname) throws IOError;
- public abstract async Pamac.Package[] search_pkgs (string search_string, bool search_from_aur) throws IOError;
- public abstract string[] get_repos_names () throws IOError;
- public abstract async Pamac.Package[] get_repo_pkgs (string repo) throws IOError;
- public abstract string[] get_groups_names () throws IOError;
- public abstract async Pamac.Package[] get_group_pkgs (string group_name) throws IOError;
- public abstract string[] get_pkg_files (string pkgname) throws IOError;
- public abstract string[] get_pkg_uninstalled_optdeps (string pkgname) throws IOError;
- public abstract PackageDeps get_pkg_deps (string pkgname) throws IOError;
- public abstract PackageDetails get_pkg_details (string pkgname) throws IOError;
- public abstract async Updates get_updates (bool check_aur_updates) throws IOError;
- public abstract ErrorInfos trans_init (Alpm.TransFlag transflags) throws IOError;
- public abstract ErrorInfos trans_sysupgrade (int enable_downgrade) throws IOError;
- public abstract ErrorInfos trans_add_pkg (string pkgname) throws IOError;
- public abstract ErrorInfos trans_remove_pkg (string pkgname) throws IOError;
- public abstract ErrorInfos trans_load_pkg (string pkgpath) throws IOError;
+ public abstract void start_get_updates (bool check_aur_updates) throws IOError;
+ public abstract bool trans_init (Alpm.TransFlag transflags) throws IOError;
+ public abstract bool trans_sysupgrade (bool enable_downgrade) throws IOError;
+ public abstract bool trans_add_pkg (string pkgname) throws IOError;
+ public abstract bool trans_remove_pkg (string pkgname) throws IOError;
+ public abstract bool trans_load_pkg (string pkgpath) throws IOError;
public abstract void start_trans_prepare () throws IOError;
public abstract void choose_provider (int provider) throws IOError;
- public abstract UpdateInfos[] trans_to_add () throws IOError;
- public abstract UpdateInfos[] trans_to_remove () throws IOError;
+ public abstract PackageInfos[] trans_to_add () throws IOError;
+ public abstract PackageInfos[] trans_to_remove () throws IOError;
public abstract void start_trans_commit () throws IOError;
- public abstract int trans_release () throws IOError;
+ public abstract void trans_release () throws IOError;
+ [DBus (no_reply = true)]
public abstract void trans_cancel () throws IOError;
[DBus (no_reply = true)]
public abstract void quit () throws IOError;
public signal void emit_event (uint primary_event, uint secondary_event, string[] details);
public signal void emit_providers (string depend, string[] providers);
- public signal void emit_progress (uint progress, string pkgname, int percent, uint n_targets, uint current_target);
+ public signal void emit_progress (uint progress, string pkgname, uint percent, uint n_targets, uint current_target);
public signal void emit_download (string filename, uint64 xfered, uint64 total);
public signal void emit_totaldownload (uint64 total);
public signal void emit_log (uint level, string msg);
public signal void set_pkgreason_finished ();
- public signal void refresh_finished (ErrorInfos error);
- public signal void trans_prepare_finished (ErrorInfos error);
- public signal void trans_commit_finished (ErrorInfos error);
+ public signal void refresh_finished (bool success);
+ public signal void get_updates_finished (Updates updates);
+ public signal void trans_prepare_finished (bool success);
+ public signal void trans_commit_finished (bool success);
public signal void get_authorization_finished (bool authorized);
- public signal void write_pamac_config_finished (bool recurse, int refresh_period, bool no_update_hide_icon,
+ public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur, bool check_aur_updates,
bool no_confirm_build);
public signal void write_alpm_config_finished (bool checkspace);
@@ -83,22 +69,24 @@ namespace Pamac {
public signal void generate_mirrors_list_finished ();
}
+ public enum Mode {
+ MANAGER,
+ UPDATER
+ }
+
public enum TransactionType {
STANDARD = (1 << 0),
UPDATE = (1 << 1),
BUILD = (1 << 2)
}
- public enum Mode {
- MANAGER,
- UPDATER
- }
-
public class Transaction: Object {
public Daemon daemon;
+ public Pamac.Config pamac_config;
+
public Alpm.TransFlag flags;
- // those hashtables will be used as set
+
public GenericSet to_add;
public GenericSet to_remove;
public GenericSet to_load;
@@ -111,25 +99,31 @@ namespace Pamac {
uint64 already_downloaded;
string previous_label;
string previous_textbar;
- double previous_percent;
+ float previous_percent;
string previous_filename;
uint pulse_timeout_id;
bool sysupgrade_after_trans;
- int build_status;
- int enable_downgrade;
+ bool enable_downgrade;
+ uint64 previous_xfered;
+ uint64 download_rate;
+ uint64 rates_nb;
+ Timer timer;
//dialogs
TransactionSumDialog transaction_sum_dialog;
TransactionInfoDialog transaction_info_dialog;
ProgressDialog progress_dialog;
//parent window
- Gtk.ApplicationWindow? window;
+ Gtk.ApplicationWindow? application_window;
- public signal void finished (bool with_error);
- public signal void support_aur (bool enable_aur, bool search_aur);
+ public signal void finished (bool database_modified);
- public Transaction (Gtk.ApplicationWindow? window) {
+ public Transaction (Gtk.ApplicationWindow? application_window) {
+ pamac_config = new Pamac.Config ("/etc/pamac.conf");
flags = Alpm.TransFlag.CASCADE;
+ if (pamac_config.recurse) {
+ flags |= Alpm.TransFlag.RECURSE;
+ }
to_add = new GenericSet (str_hash, str_equal);
to_remove = new GenericSet (str_hash, str_equal);
to_load = new GenericSet (str_hash, str_equal);
@@ -137,21 +131,28 @@ namespace Pamac {
special_ignorepkgs = new GenericSet (str_hash, str_equal);
connecting_dbus_signals ();
//creating dialogs
- this.window = window;
- transaction_sum_dialog = new TransactionSumDialog (window);
- transaction_info_dialog = new TransactionInfoDialog (window);
- progress_dialog = new ProgressDialog (this, window);
+ this.application_window = application_window;
+ transaction_sum_dialog = new TransactionSumDialog (application_window);
+ transaction_info_dialog = new TransactionInfoDialog (application_window);
+ progress_dialog = new ProgressDialog (application_window);
+ progress_dialog.cancel_button.clicked.connect (on_cancel_button_clicked);
// connect to child_exited signal which will only be emit after a call to watch_child
progress_dialog.term.child_exited.connect (on_term_child_exited);
// progress data
- total_download = 0;
- already_downloaded = 0;
previous_label = "";
previous_textbar = "";
- previous_percent = 0.0;
previous_filename = "";
sysupgrade_after_trans = false;
- build_status = 0;
+ timer = new Timer ();
+ }
+
+ public ErrorInfos get_current_error () {
+ try {
+ return daemon.get_current_error ();
+ } catch (IOError e) {
+ stderr.printf ("IOError: %s\n", e.message);
+ return ErrorInfos ();
+ }
}
public void start_get_authorization () {
@@ -205,6 +206,7 @@ namespace Pamac {
daemon.start_generate_mirrors_list ();
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
+ Source.remove (pulse_timeout_id);
}
}
@@ -216,7 +218,7 @@ namespace Pamac {
}
}
- public void start_refresh (int force) {
+ public void start_refresh (bool force) {
string action = dgettext (null, "Synchronizing package databases") + "...";
progress_dialog.spawn_in_term ({"echo", action});
progress_dialog.action_label.set_text (action);
@@ -234,33 +236,23 @@ namespace Pamac {
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
daemon.refresh_finished.disconnect (on_refresh_finished);
+ finished (true);
}
}
- public bool get_checkspace () {
- bool checkspace = false;
- try {
- checkspace = daemon.get_checkspace ();
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return checkspace;
- }
-
- public string[] get_ignorepkgs () {
- string[] ignorepkgs = {};
+ public void start_get_updates () {
try {
- ignorepkgs = daemon.get_ignorepkgs ();
+ daemon.start_get_updates (pamac_config.enable_aur && pamac_config.check_aur_updates);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
+ finished (false);
}
- return ignorepkgs;
}
public void add_ignorepkg (string pkgname) {
try {
daemon.add_ignorepkg (pkgname);
- special_ignorepkgs.add (pkgname);
+ //special_ignorepkgs.add (pkgname);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
@@ -274,214 +266,30 @@ namespace Pamac {
}
}
- public bool should_hold (string pkgname) {
- bool should_hold = false;
- try {
- should_hold = daemon.should_hold (pkgname);
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return should_hold;
- }
-
- public async Pamac.Package[] get_all_pkgs () {
- Pamac.Package[] pkgs = {};
- try {
- pkgs = yield daemon.get_all_pkgs ();
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return pkgs;
- }
-
- public async Pamac.Package[] get_installed_pkgs () {
- Pamac.Package[] pkgs = {};
- try {
- pkgs = yield daemon.get_installed_pkgs ();
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return pkgs;
- }
-
- public async Pamac.Package[] get_local_pkgs () {
- Pamac.Package[] pkgs = {};
- try {
- pkgs = yield daemon.get_local_pkgs ();
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return pkgs;
- }
-
- public async Pamac.Package[] get_orphans () {
- Pamac.Package[] pkgs = {};
- try {
- pkgs = yield daemon.get_orphans ();
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return pkgs;
- }
-
- public Pamac.Package find_local_pkg (string pkgname) {
- var pkg = Pamac.Package (null, null);
- try {
- pkg = daemon.find_local_pkg (pkgname);
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return pkg;
- }
-
- public Pamac.Package find_local_satisfier (string pkgname) {
- var pkg = Pamac.Package (null, null);
- try {
- pkg = daemon.find_local_satisfier (pkgname);
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return pkg;
- }
-
- public Pamac.Package find_sync_pkg (string pkgname) {
- var pkg = Pamac.Package (null, null);
- try {
- pkg = daemon.find_sync_pkg (pkgname);
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return pkg;
- }
-
- public async Pamac.Package[] search_pkgs (string search_string, bool search_aur) {
- Pamac.Package[] pkgs = {};
- try {
- pkgs = yield daemon.search_pkgs (search_string, search_aur);
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return pkgs;
- }
-
- public string[] get_repos_names () {
- string[] repos_names = {};
- try {
- repos_names = daemon.get_repos_names ();
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return repos_names;
- }
-
- public async Pamac.Package[] get_repo_pkgs (string repo) {
- Pamac.Package[] pkgs = {};
- try {
- pkgs = yield daemon.get_repo_pkgs (repo);
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return pkgs;
- }
-
- public string[] get_groups_names () {
- string[] groups_names = {};
- try {
- groups_names = daemon.get_groups_names ();
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return groups_names;
- }
-
- public async Pamac.Package[] get_group_pkgs (string group_name) {
- Pamac.Package[] pkgs = {};
- try {
- pkgs = yield daemon.get_group_pkgs (group_name);
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return pkgs;
- }
-
- public string[] get_pkg_files (string pkgname) {
- string[] files = {};
- try {
- files = daemon.get_pkg_files (pkgname);
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return files;
- }
-
- public string[] get_pkg_uninstalled_optdeps (string pkgname) {
- string[] optdeps = {};
- try {
- optdeps = daemon.get_pkg_uninstalled_optdeps (pkgname);
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return optdeps;
- }
-
- public PackageDeps get_pkg_deps (string pkgname) {
- var deps = PackageDeps ();
- try {
- deps = daemon.get_pkg_deps (pkgname);
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return deps;
- }
-
- public PackageDetails get_pkg_details (string pkgname) {
- var details = PackageDetails ();
- try {
- details = daemon.get_pkg_details (pkgname);
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return details;
- }
-
- public async Updates get_updates () {
- var updates = Updates ();
- var pamac_config = new Pamac.Config ("/etc/pamac.conf");
- try {
- updates = yield daemon.get_updates (pamac_config.enable_aur && pamac_config.check_aur_updates);
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- return updates;
- }
-
- public ErrorInfos init () {
- var err = ErrorInfos ();
- foreach (string pkgname in special_ignorepkgs) {
+ public bool init (Alpm.TransFlag flags) {
+ foreach (unowned string pkgname in special_ignorepkgs) {
add_ignorepkg (pkgname);
}
try {
- err = daemon.trans_init (0);
+ return daemon.trans_init (flags);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
+ return false;
}
- return err;
}
- public void sysupgrade_simple (int enable_downgrade) {
+ public void sysupgrade_simple (bool enable_downgrade) {
progress_dialog.progressbar.set_fraction (0);
progress_dialog.cancel_button.set_visible (true);
- var err = init ();
- if (err.message != "") {
- finished (true);
- handle_error (err);
- } else {
+ bool success = init (0);
+ if (success) {
try {
- err = daemon.trans_sysupgrade (enable_downgrade);
+ success = daemon.trans_sysupgrade (enable_downgrade);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
+ success = false;
}
- if (err.message == "") {
+ if (success) {
progress_dialog.show ();
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
@@ -490,16 +298,20 @@ namespace Pamac {
daemon.start_trans_prepare ();
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
+ finished (false);
}
} else {
release ();
- finished (true);
- handle_error (err);
+ finished (false);
+ handle_error (get_current_error ());
}
+ } else {
+ finished (false);
+ handle_error (get_current_error ());
}
}
- public void sysupgrade (int enable_downgrade) {
+ public void sysupgrade (bool enable_downgrade) {
this.enable_downgrade = enable_downgrade;
string action = dgettext (null, "Starting full system upgrade") + "...";
progress_dialog.spawn_in_term ({"echo", action});
@@ -512,40 +324,42 @@ namespace Pamac {
Gtk.main_iteration ();
}
// sysupgrade
- get_updates.begin ((obj, res) => {
- Updates updates = get_updates.end (res);
- // get syncfirst updates
- if (updates.is_syncfirst) {
+ daemon.get_updates_finished.connect (on_get_updates_finished);
+ start_get_updates ();
+ }
+
+ public void on_get_updates_finished (Updates updates) {
+ // get syncfirst updates
+ if (updates.is_syncfirst) {
+ clear_lists ();
+ if (mode == Mode.MANAGER) {
+ sysupgrade_after_trans = true;
+ }
+ foreach (unowned PackageInfos infos in updates.repos_updates) {
+ to_add.add (infos.name);
+ }
+ // run as a standard transaction
+ run ();
+ } else {
+ if (updates.aur_updates.length != 0) {
clear_lists ();
- if (mode == Mode.MANAGER) {
- sysupgrade_after_trans = true;
- }
- foreach (UpdateInfos infos in updates.repos_updates) {
- to_add.add (infos.name);
- }
- // run as a standard transaction
- run ();
- } else {
- if (updates.aur_updates.length != 0) {
- clear_lists ();
- foreach (UpdateInfos infos in updates.aur_updates) {
- if ((infos.name in special_ignorepkgs) == false) {
- to_build.add (infos.name);
- }
+ foreach (unowned PackageInfos infos in updates.aur_updates) {
+ if (!(infos.name in special_ignorepkgs)) {
+ to_build.add (infos.name);
}
}
- if (updates.repos_updates.length != 0) {
- sysupgrade_simple (enable_downgrade);
- } else {
- progress_dialog.show ();
- while (Gtk.events_pending ()) {
- Gtk.main_iteration ();
- }
- var err = ErrorInfos ();
- on_trans_prepare_finished (err);
+ }
+ if (updates.repos_updates.length != 0) {
+ sysupgrade_simple (enable_downgrade);
+ } else {
+ progress_dialog.show ();
+ while (Gtk.events_pending ()) {
+ Gtk.main_iteration ();
}
+ on_trans_prepare_finished (true);
}
- });
+ }
+ daemon.get_updates_finished.disconnect (on_get_updates_finished);
}
public void clear_lists () {
@@ -567,70 +381,77 @@ namespace Pamac {
Gtk.main_iteration ();
}
// run
- var err = ErrorInfos ();
if (to_add.length == 0
&& to_remove.length == 0
&& to_load.length == 0
&& to_build.length != 0) {
// there only AUR packages to build so no need to prepare transaction
- on_trans_prepare_finished (err);
+ on_trans_prepare_finished (true);
} else {
+ bool success = false;
try {
- err = daemon.trans_init (flags);
+ success = daemon.trans_init (flags);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
- if (err.message != "") {
- finished (true);
- handle_error (err);
- } else {
- foreach (string name in to_add) {
+ if (success) {
+ success = false;
+ foreach (unowned string name in to_add) {
try {
- err = daemon.trans_add_pkg (name);
+ success = daemon.trans_add_pkg (name);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
- if (err.message != "") {
+ if (!success) {
break;
}
}
- foreach (string name in to_remove) {
+ foreach (unowned string name in to_remove) {
try {
- err = daemon.trans_remove_pkg (name);
+ success = daemon.trans_remove_pkg (name);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
- if (err.message != "") {
+ if (!success) {
break;
}
}
- foreach (string path in to_load) {
+ foreach (unowned string path in to_load) {
try {
- err = daemon.trans_load_pkg (path);
+ success = daemon.trans_load_pkg (path);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
- if (err.message != "") {
+ if (!success) {
break;
}
}
- if (err.message == "") {
+ if (success) {
try {
daemon.start_trans_prepare ();
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
+ finished (false);
}
} else {
release ();
- finished (true);
- handle_error (err);
+ finished (false);
+ handle_error (get_current_error ());
}
+ } else {
+ finished (false);
+ handle_error (get_current_error ());
}
}
}
public void choose_provider (string depend, string[] providers) {
- var choose_provider_dialog = new ChooseProviderDialog (depend, providers, window);
+ var choose_provider_dialog = new ChooseProviderDialog (application_window);
+ choose_provider_dialog.label.set_markup ("%s".printf (dgettext (null, "Choose a provider for %s").printf (depend)));
+ foreach (unowned string provider in providers) {
+ choose_provider_dialog.comboboxtext.append_text (provider);
+ }
+ choose_provider_dialog.comboboxtext.active = 0;
choose_provider_dialog.run ();
try {
daemon.choose_provider (choose_provider_dialog.comboboxtext.active);
@@ -647,8 +468,8 @@ namespace Pamac {
// return 0 if transaction_sum is empty, 2, if there are only aur updates, 1 otherwise
TransactionType type = 0;
uint64 dsize = 0;
- UpdateInfos[] prepared_to_add = {};
- UpdateInfos[] prepared_to_remove = {};
+ PackageInfos[] prepared_to_add = {};
+ PackageInfos[] prepared_to_remove = {};
string[] to_downgrade = {};
string[] to_install = {};
string[] to_reinstall = {};
@@ -663,23 +484,27 @@ namespace Pamac {
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
- foreach (UpdateInfos pkg_info in prepared_to_add) {
+ foreach (unowned PackageInfos pkg_info in prepared_to_add) {
dsize += pkg_info.download_size;
- Pamac.Package local_pkg = find_local_pkg (pkg_info.name);
- if (local_pkg.name == "") {
- to_install += "%s %s".printf (pkg_info.name, pkg_info.version);
- } else {
- int cmp = Alpm.pkg_vercmp (pkg_info.version, local_pkg.version);
- if (cmp == 1) {
- to_update += "%s %s".printf (pkg_info.name, pkg_info.version);
- } else if (cmp == 0) {
- to_reinstall += "%s %s".printf (pkg_info.name, pkg_info.version);
+ try {
+ PackageInfos local_pkg_info = daemon.get_installed_pkg (pkg_info.name);
+ if (local_pkg_info.name == "") {
+ to_install += "%s %s".printf (pkg_info.name, pkg_info.version);
} else {
- to_downgrade += "%s %s".printf (pkg_info.name, pkg_info.version);
+ int cmp = Alpm.pkg_vercmp (pkg_info.version, local_pkg_info.version);
+ if (cmp == 1) {
+ to_update += "%s %s".printf (pkg_info.name, pkg_info.version);
+ } else if (cmp == 0) {
+ to_reinstall += "%s %s".printf (pkg_info.name, pkg_info.version);
+ } else {
+ to_downgrade += "%s %s".printf (pkg_info.name, pkg_info.version);
+ }
}
+ } catch (IOError e) {
+ stderr.printf ("IOError: %s\n", e.message);
}
}
- foreach (string name in to_build) {
+ foreach (unowned string name in to_build) {
_to_build += name;
}
int len = prepared_to_remove.length;
@@ -778,6 +603,7 @@ namespace Pamac {
daemon.start_trans_commit ();
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
+ finished (true);
}
}
@@ -794,11 +620,10 @@ namespace Pamac {
progress_dialog.term.grab_focus ();
pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_dialog.progressbar.pulse);
string[] cmds = {"yaourt", "-S"};
- var pamac_config = new Pamac.Config ("/etc/pamac.conf");
if (pamac_config.no_confirm_build) {
cmds += "--noconfirm";
}
- foreach (string name in to_build) {
+ foreach (unowned string name in to_build) {
cmds += name;
}
Pid child_pid;
@@ -813,6 +638,12 @@ namespace Pamac {
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
+ progress_dialog.expander.set_expanded (false);
+ Gtk.TextIter start_iter;
+ Gtk.TextIter end_iter;
+ transaction_info_dialog.textbuffer.get_start_iter (out start_iter);
+ transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
+ transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
}
public void release () {
@@ -821,7 +652,7 @@ namespace Pamac {
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
- foreach (string pkgname in special_ignorepkgs) {
+ foreach (unowned string pkgname in special_ignorepkgs) {
remove_ignorepkg (pkgname);
}
}
@@ -837,6 +668,26 @@ namespace Pamac {
void on_emit_event (uint primary_event, uint secondary_event, string[] details) {
string msg;
switch (primary_event) {
+ case Alpm.Event.Type.HOOK_START:
+ switch (secondary_event) {
+ case Alpm.HookWhen.PRE_TRANSACTION:
+ msg = dgettext (null, "Running pre-transaction hooks") + "...";
+ progress_dialog.action_label.set_text (msg);
+ progress_dialog.spawn_in_term ({"echo", msg});
+ break;
+ case Alpm.HookWhen.POST_TRANSACTION:
+ msg = dgettext (null, "Running post-transaction hooks") + "...";
+ progress_dialog.action_label.set_text (msg);
+ progress_dialog.spawn_in_term ({"echo", msg});
+ break;
+ default:
+ break;
+ }
+ break;
+ case Alpm.Event.Type.HOOK_RUN_START:
+ msg = "%s:%s %s/%s".printf (details[0], details[1], details[2], details[3]);
+ progress_dialog.spawn_in_term ({"echo", msg});
+ break;
case Alpm.Event.Type.CHECKDEPS_START:
msg = dgettext (null, "Checking dependencies") + "...";
progress_dialog.action_label.set_text (msg);
@@ -857,10 +708,12 @@ namespace Pamac {
progress_dialog.action_label.set_text (msg);
progress_dialog.spawn_in_term ({"echo", msg});
break;
+ case Alpm.Event.Type.TRANSACTION_START:
+ progress_dialog.cancel_button.set_visible (false);
+ break;
case Alpm.Event.Type.PACKAGE_OPERATION_START:
switch (secondary_event) {
case Alpm.Package.Operation.INSTALL:
- progress_dialog.cancel_button.set_visible (false);
previous_filename = details[0];
msg = dgettext (null, "Installing %s").printf (details[0]) + "...";
progress_dialog.action_label.set_text (msg);
@@ -868,7 +721,6 @@ namespace Pamac {
progress_dialog.spawn_in_term ({"echo", msg});
break;
case Alpm.Package.Operation.REINSTALL:
- progress_dialog.cancel_button.set_visible (false);
previous_filename = details[0];
msg = dgettext (null, "Reinstalling %s").printf (details[0]) + "...";
progress_dialog.action_label.set_text (msg);
@@ -876,7 +728,6 @@ namespace Pamac {
progress_dialog.spawn_in_term ({"echo", msg});
break;
case Alpm.Package.Operation.REMOVE:
- progress_dialog.cancel_button.set_visible (false);
previous_filename = details[0];
msg = dgettext (null, "Removing %s").printf (details[0]) + "...";
progress_dialog.action_label.set_text (msg);
@@ -884,7 +735,6 @@ namespace Pamac {
progress_dialog.spawn_in_term ({"echo", msg});
break;
case Alpm.Package.Operation.UPGRADE:
- progress_dialog.cancel_button.set_visible (false);
previous_filename = details[0];
msg = dgettext (null, "Upgrading %s").printf (details[0]) + "...";
progress_dialog.action_label.set_text (msg);
@@ -892,7 +742,6 @@ namespace Pamac {
progress_dialog.spawn_in_term ({"echo", msg});
break;
case Alpm.Package.Operation.DOWNGRADE:
- progress_dialog.cancel_button.set_visible (false);
previous_filename = details[0];
msg = dgettext (null, "Downgrading %s").printf (details[0]) + "...";
progress_dialog.action_label.set_text (msg);
@@ -980,9 +829,6 @@ namespace Pamac {
case Alpm.Event.Type.PACSAVE_CREATED:
progress_dialog.spawn_in_term ({"echo", dgettext (null, "%s installed as %s.pacsave").printf (details[0])});
break;
- case Alpm.Event.Type.PACORIG_CREATED:
- progress_dialog.spawn_in_term ({"echo", dgettext (null, "%s installed as %s.pacorig").printf (details[0])});
- break;
default:
break;
}
@@ -995,15 +841,15 @@ namespace Pamac {
choose_provider (depend, providers);
}
- void on_emit_progress (uint progress, string pkgname, int percent, uint n_targets, uint current_target) {
- double fraction;
+ void on_emit_progress (uint progress, string pkgname, uint percent, uint n_targets, uint current_target) {
+ float fraction;
switch (progress) {
case Alpm.Progress.ADD_START:
case Alpm.Progress.UPGRADE_START:
case Alpm.Progress.DOWNGRADE_START:
case Alpm.Progress.REINSTALL_START:
case Alpm.Progress.REMOVE_START:
- fraction = ((float) (current_target-1)/n_targets)+((float) percent/(100*n_targets));
+ fraction = ((float) (current_target - 1) / n_targets) + ((float) percent / (100 * n_targets));
break;
case Alpm.Progress.CONFLICTS_START:
case Alpm.Progress.DISKSPACE_START:
@@ -1011,7 +857,7 @@ namespace Pamac {
case Alpm.Progress.KEYRING_START:
case Alpm.Progress.LOAD_START:
default:
- fraction = (float) percent/100;
+ fraction = (float) percent / 100;
break;
}
string textbar = "%lu/%lu".printf (current_target, n_targets);
@@ -1023,15 +869,15 @@ namespace Pamac {
previous_percent = fraction;
progress_dialog.progressbar.set_fraction (fraction);
}
- while (Gtk.events_pending ()) {
- Gtk.main_iteration ();
- }
+//~ while (Gtk.events_pending ()) {
+//~ Gtk.main_iteration ();
+//~ }
}
void on_emit_download (string filename, uint64 xfered, uint64 total) {
string label;
- string textbar;
- double fraction;
+ var text = new StringBuilder ();
+ float fraction;
if (filename != previous_filename) {
previous_filename = filename;
if (filename.has_suffix (".db")) {
@@ -1046,40 +892,95 @@ namespace Pamac {
}
}
if (total_download > 0) {
- fraction = (float) (xfered + already_downloaded) / total_download;
- if (fraction <= 1) {
- textbar = "%s/%s".printf (format_size (xfered + already_downloaded), format_size (total_download));
+ if (xfered == 0) {
+ previous_xfered = 0;
+ fraction = previous_percent;
+ text.append (previous_textbar);
+ timer.start ();
} else {
- textbar = "%s".printf (format_size (xfered + already_downloaded));
+ download_rate = ((download_rate * rates_nb) + (uint64) ((xfered - previous_xfered) / timer.elapsed ())) / (rates_nb + 1);
+ rates_nb++;
+ previous_xfered = xfered;
+ uint64 downloaded_total = xfered + already_downloaded;
+ fraction = (float) downloaded_total / total_download;
+ if (fraction <= 1) {
+ text.append ("%s/%s ".printf (format_size (xfered + already_downloaded), format_size (total_download)));
+ uint64 remaining_seconds = (total_download - downloaded_total) / download_rate;
+ if (remaining_seconds > 9) {
+ if (remaining_seconds <= 50) {
+ text.append (dgettext (null, "About %u seconds remaining").printf ((uint) Math.ceilf ((float) remaining_seconds / 10) * 10));
+ } else {
+ uint remaining_minutes = (uint) Math.ceilf ((float) remaining_seconds / 60);
+ text.append (dngettext (null, "About %lu minute remaining",
+ "About %lu minutes remaining", remaining_minutes).printf (remaining_minutes));
+ }
+ }
+ } else {
+ text.append ("%s".printf (format_size (xfered + already_downloaded)));
+ }
+ if (xfered == total) {
+ previous_filename = "";
+ already_downloaded += total;
+ } else {
+ timer.start ();
+ }
}
} else {
- fraction = (float) xfered / total;
- if (fraction <= 1) {
- textbar = "%s/%s".printf (format_size (xfered), format_size (total));
+ if (xfered == 0) {
+ previous_xfered = 0;
+ download_rate = 0;
+ rates_nb = 0;
+ fraction = 0;
+ timer.start ();
+ } else if (xfered == total) {
+ timer.stop ();
+ fraction = 1;
+ previous_filename = "";
} else {
- textbar = "%s".printf (format_size (xfered));
- }
- }
- if (fraction > 0) {
- if (fraction != previous_percent) {
- previous_percent = fraction;
- progress_dialog.progressbar.set_fraction (fraction);
+ download_rate = ((download_rate * rates_nb) + (uint64) ((xfered - previous_xfered) / timer.elapsed ())) / (rates_nb + 1);
+ previous_xfered = xfered;
+ rates_nb++;
+ fraction = (float) xfered / total;
+ if (fraction <= 1) {
+ text.append ("%s/%s ".printf (format_size (xfered), format_size (total)));
+ uint64 remaining_seconds = (total - xfered) / download_rate;
+ if (remaining_seconds > 9) {
+ if (remaining_seconds <= 50) {
+ text.append (dgettext (null, "About %u seconds remaining").printf ((uint) Math.ceilf ((float) remaining_seconds / 10) * 10));
+ } else {
+ uint remaining_minutes = (uint) Math.ceilf ((float) remaining_seconds / 60);
+ text.append (dngettext (null, "About %lu minute remaining",
+ "About %lu minutes remaining", remaining_minutes).printf (remaining_minutes));
+ }
+ }
+ } else {
+ text.append ("%s".printf (format_size (xfered)));
+ }
+ // reinitialize timer
+ timer.start ();
}
- } else {
- progress_dialog.progressbar.set_fraction (0);
}
- if (textbar != previous_textbar) {
- previous_textbar = textbar;
- progress_dialog.progressbar.set_text (textbar);
+ if (fraction != previous_percent) {
+ previous_percent = fraction;
+ progress_dialog.progressbar.set_fraction (fraction);
}
- if (xfered == total) {
- already_downloaded += total;
- previous_filename = "";
+ if (text.str != previous_textbar) {
+ previous_textbar = text.str;
+ progress_dialog.progressbar.set_text (text.str);
}
}
void on_emit_totaldownload (uint64 total) {
+ download_rate = 0;
+ rates_nb = 0;
+ previous_percent = 0;
+ previous_textbar = "";
total_download = total;
+ // this is emitted at the end of the total download
+ // with the value 0 so stop our timer
+ if (total == 0) {
+ timer.stop ();
+ }
}
void on_emit_log (uint level, string msg) {
@@ -1130,63 +1031,78 @@ namespace Pamac {
}
public void handle_error (ErrorInfos error) {
- progress_dialog.expander.set_expanded (true);
- progress_dialog.spawn_in_term ({"echo", "-n", error.message});
- Gtk.TextIter start_iter;
- Gtk.TextIter end_iter;
- transaction_info_dialog.set_title (dgettext (null, "Error"));
- transaction_info_dialog.label.set_visible (true);
- transaction_info_dialog.label.set_markup (error.message);
- if (error.details.length != 0) {
+ if (error.message != null && error.message != "") {
+ progress_dialog.expander.set_expanded (true);
+ progress_dialog.spawn_in_term ({"echo", "-n", error.message});
+ Gtk.TextIter start_iter;
+ Gtk.TextIter end_iter;
+ transaction_info_dialog.set_title (dgettext (null, "Error"));
+ transaction_info_dialog.label.set_visible (true);
+ transaction_info_dialog.label.set_markup (error.message);
+ if (error.details.length != 0) {
+ transaction_info_dialog.textbuffer.get_start_iter (out start_iter);
+ transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
+ transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
+ transaction_info_dialog.expander.set_visible (true);
+ transaction_info_dialog.expander.set_expanded (true);
+ progress_dialog.spawn_in_term ({"echo", ":"});
+ foreach (unowned string detail in error.details) {
+ progress_dialog.spawn_in_term ({"echo", detail});
+ string str = detail + "\n";
+ transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
+ transaction_info_dialog.textbuffer.insert (ref end_iter, str, str.length);
+ }
+ } else {
+ transaction_info_dialog.expander.set_visible (false);
+ }
+ progress_dialog.spawn_in_term ({"echo"});
+ transaction_info_dialog.run ();
+ transaction_info_dialog.hide ();
transaction_info_dialog.textbuffer.get_start_iter (out start_iter);
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
- transaction_info_dialog.expander.set_visible (true);
- transaction_info_dialog.expander.set_expanded (true);
- progress_dialog.spawn_in_term ({"echo", ":"});
- foreach (string detail in error.details) {
- progress_dialog.spawn_in_term ({"echo", detail});
- string str = detail + "\n";
- transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
- transaction_info_dialog.textbuffer.insert (ref end_iter, str, str.length);
+ progress_dialog.progressbar.set_fraction (0);
+ progress_dialog.cancel_button.set_visible (false);
+ progress_dialog.close_button.set_visible (true);
+ progress_dialog.spawn_in_term ({"echo"});
+ while (Gtk.events_pending ()) {
+ Gtk.main_iteration ();
}
- } else {
- transaction_info_dialog.expander.set_visible (false);
- }
- progress_dialog.spawn_in_term ({"echo"});
- transaction_info_dialog.run ();
- transaction_info_dialog.hide ();
- progress_dialog.hide ();
- transaction_info_dialog.textbuffer.get_start_iter (out start_iter);
- transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
- transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
- while (Gtk.events_pending ()) {
- Gtk.main_iteration ();
}
}
- public void on_refresh_finished (ErrorInfos error) {
- if (error.message == "") {
+ public void on_refresh_finished (bool success) {
+ if (success) {
if (mode == Mode.UPDATER) {
+ finished (true);
progress_dialog.hide ();
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
- finished (false);
} else {
clear_lists ();
- sysupgrade (0);
+ sysupgrade (false);
}
} else {
finished (true);
- handle_error (error);
+ handle_error (get_current_error ());
}
previous_filename = "";
daemon.refresh_finished.disconnect (on_refresh_finished);
}
- public void on_trans_prepare_finished (ErrorInfos error) {
- if (error.message == "") {
+ public void on_cancel_button_clicked () {
+ cancel ();
+ clear_lists ();
+ progress_dialog.spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"});
+ progress_dialog.hide ();
+ while (Gtk.events_pending ()) {
+ Gtk.main_iteration ();
+ }
+ }
+
+ public void on_trans_prepare_finished (bool success) {
+ if (success) {
show_warnings ();
TransactionType type = set_transaction_sum ();
if (type == TransactionType.UPDATE && mode == Mode.UPDATER) {
@@ -1200,8 +1116,8 @@ namespace Pamac {
}
if (type == TransactionType.BUILD) {
// there only AUR packages to build
- var err = ErrorInfos ();
- on_trans_commit_finished (err);
+ release ();
+ on_trans_commit_finished (true);
} else {
start_commit ();
}
@@ -1213,9 +1129,9 @@ namespace Pamac {
Gtk.main_iteration ();
}
release ();
- to_build.remove_all ();
+ //to_build.remove_all ();
sysupgrade_after_trans = false;
- finished (true);
+ finished (false);
}
} else {
//var err = ErrorInfos ();
@@ -1231,13 +1147,13 @@ namespace Pamac {
//handle_error (err);
}
} else {
- finished (true);
- handle_error (error);
+ finished (false);
+ handle_error (get_current_error ());
}
}
- public void on_trans_commit_finished (ErrorInfos error) {
- if (error.message == "") {
+ public void on_trans_commit_finished (bool success) {
+ if (success) {
if (to_build.length != 0) {
if (to_add.length != 0
|| to_remove.length != 0
@@ -1246,61 +1162,59 @@ namespace Pamac {
}
build_aur_packages ();
} else {
- //progress_dialog.action_label.set_text (dgettext (null, "Transaction successfully finished"));
clear_lists ();
show_warnings ();
if (sysupgrade_after_trans) {
sysupgrade_after_trans = false;
- sysupgrade (0);
+ sysupgrade (false);
} else {
- if (build_status == 0) {
- progress_dialog.spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"});
- progress_dialog.hide ();
- while (Gtk.events_pending ()) {
- Gtk.main_iteration ();
- }
- } else {
- progress_dialog.progressbar.set_fraction (0);
- progress_dialog.cancel_button.set_visible (false);
- progress_dialog.close_button.set_visible (true);
- progress_dialog.spawn_in_term ({"echo"});
+ finished (true);
+ progress_dialog.spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"});
+ progress_dialog.hide ();
+ while (Gtk.events_pending ()) {
+ Gtk.main_iteration ();
}
- finished (false);
}
}
} else {
- finished (true);
- handle_error (error);
+ // if it is an authentication error, database was not modified
+ var err = get_current_error ();
+ if (err.message == dgettext (null, "Authentication failed")) {
+ finished (false);
+ } else {
+ finished (true);
+ }
+ handle_error (err);
}
total_download = 0;
already_downloaded = 0;
- build_status = 0;
previous_filename = "";
}
void on_term_child_exited (int status) {
Source.remove (pulse_timeout_id);
to_build.remove_all ();
- build_status = status;
- // let the time to the daemon to update packages
+ // let the time to the daemon to update databases
Timeout.add (1000, () => {
- var err = ErrorInfos ();
- on_trans_commit_finished (err);
+ finished (true);
+ if (status == 0) {
+ progress_dialog.spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"});
+ progress_dialog.hide ();
+ while (Gtk.events_pending ()) {
+ Gtk.main_iteration ();
+ }
+ } else {
+ progress_dialog.progressbar.set_fraction (0);
+ progress_dialog.cancel_button.set_visible (false);
+ progress_dialog.close_button.set_visible (true);
+ progress_dialog.spawn_in_term ({"echo"});
+ }
return false;
});
}
- void on_write_pamac_config_finished (bool recurse, int refresh_period, bool no_update_hide_icon,
- bool enable_aur, bool search_aur, bool check_aur_updates,
- bool no_confirm_build) {
- flags = Alpm.TransFlag.CASCADE;
- if (recurse) {
- flags |= Alpm.TransFlag.RECURSE;
- }
- Pamac.Package pkg = find_local_satisfier ("yaourt");
- if (pkg.name != "") {
- support_aur (enable_aur, search_aur);
- }
+ void on_write_pamac_config_finished () {
+ pamac_config.reload ();
}
void on_generate_mirrors_list_data (string line) {
@@ -1311,13 +1225,14 @@ namespace Pamac {
Source.remove (pulse_timeout_id);
progress_dialog.spawn_in_term ({"echo"});
// force a dbs refresh
- start_refresh (1);
+ start_refresh (true);
}
void connecting_dbus_signals () {
try {
- daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac",
- "/org/manjaro/pamac");
+ daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac", "/org/manjaro/pamac");
+ // Set environment variables
+ daemon.set_environment_variables (pamac_config.environment_variables);
// Connecting to signals
daemon.emit_event.connect (on_emit_event);
daemon.emit_providers.connect (on_emit_providers);
diff --git a/src/tray.vala b/src/tray.vala
index 300ee72..835706f 100644
--- a/src/tray.vala
+++ b/src/tray.vala
@@ -1,7 +1,7 @@
/*
* pamac-vala
*
- * Copyright (C) 2014-2015 Guillaume Benoit
+ * Copyright (C) 2014-2016 Guillaume Benoit
*
* 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
@@ -27,12 +27,12 @@ const string noupdate_info = _("Your system is up-to-date");
namespace Pamac {
[DBus (name = "org.manjaro.pamac")]
public interface Daemon : Object {
- public abstract void start_refresh (int force) throws IOError;
- public abstract async Updates get_updates (bool check_aur_updates) throws IOError;
+ public abstract void start_refresh (bool force) throws IOError;
+ public abstract void start_get_updates (bool check_aur_updates) throws IOError;
[DBus (no_reply = true)]
public abstract void quit () throws IOError;
- public signal void refresh_finished (ErrorInfos error);
- public signal void write_pamac_config_finished (bool recurse, int refresh_period, bool no_update_hide_icon,
+ public signal void get_updates_finished (Updates updates);
+ public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur, bool check_aur_updates,
bool no_confirm_build);
public signal void write_alpm_config_finished (bool checkspace);
@@ -40,6 +40,7 @@ namespace Pamac {
public class TrayIcon: Gtk.Application {
Notify.Notification notification;
+//~ Notification notification;
Daemon daemon;
bool extern_lock;
uint refresh_timeout_id;
@@ -54,9 +55,9 @@ namespace Pamac {
void start_daemon () {
try {
- daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac",
- "/org/manjaro/pamac");
+ daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac", "/org/manjaro/pamac");
// Connecting to signals
+ daemon.get_updates_finished.connect (on_get_updates_finished);
daemon.write_pamac_config_finished.connect (on_write_pamac_config_finished);
daemon.write_alpm_config_finished.connect (on_write_alpm_config_finished);
} catch (IOError e) {
@@ -65,7 +66,7 @@ namespace Pamac {
}
void stop_daemon () {
- if (check_pamac_running () == false) {
+ if (!check_pamac_running ()) {
try {
daemon.quit ();
} catch (IOError e) {
@@ -128,7 +129,7 @@ namespace Pamac {
check_updates ();
} else {
try {
- daemon.start_refresh (0);
+ daemon.start_refresh (false);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
@@ -136,10 +137,8 @@ namespace Pamac {
return true;
}
- void on_write_pamac_config_finished (bool recurse, int refresh_period, bool no_update_hide_icon,
- bool enable_aur, bool search_aur, bool check_aur_updates,
- bool no_confirm_build) {
- launch_refresh_timeout ((uint) refresh_period);
+ void on_write_pamac_config_finished (bool recurse, uint64 refresh_period) {
+ launch_refresh_timeout (refresh_period);
if (refresh_period == 0) {
status_icon.visible = false;
} else {
@@ -151,36 +150,40 @@ namespace Pamac {
check_updates ();
}
+ void on_get_updates_finished (Updates updates) {
+ uint updates_nb = updates.repos_updates.length + updates.aur_updates.length;
+ if (updates_nb == 0) {
+ this.update_icon (noupdate_icon_name, noupdate_info);
+ var pamac_config = new Pamac.Config ("/etc/pamac.conf");
+ if (pamac_config.no_update_hide_icon) {
+ status_icon.visible = false;
+ } else {
+ status_icon.visible = true;
+ }
+ close_notification();
+ } else {
+ string info = ngettext ("%u available update", "%u available updates", updates_nb).printf (updates_nb);
+ this.update_icon (update_icon_name, info);
+ status_icon.visible = true;
+ if (check_pamac_running ()) {
+ update_notification (info);
+ } else {
+ show_notification (info);
+ }
+ }
+ stop_daemon ();
+ }
+
void check_updates () {
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
if (pamac_config.refresh_period == 0) {
return;
}
- daemon.get_updates.begin ((pamac_config.enable_aur && pamac_config.check_aur_updates), (obj, res) => {
- var updates = Updates ();
- try {
- updates = daemon.get_updates.end (res);
- } catch (IOError e) {
- stderr.printf ("IOError: %s\n", e.message);
- }
- uint updates_nb = updates.repos_updates.length + updates.aur_updates.length;
- if (updates_nb == 0) {
- this.update_icon (noupdate_icon_name, noupdate_info);
- if (pamac_config.no_update_hide_icon) {
- status_icon.visible = false;
- } else {
- status_icon.visible = true;
- }
- } else {
- string info = ngettext ("%u available update", "%u available updates", updates_nb).printf (updates_nb);
- this.update_icon (update_icon_name, info);
- status_icon.visible = true;
- if (check_pamac_running () == false) {
- show_notification (info);
- }
- }
- stop_daemon ();
- });
+ try {
+ daemon.start_get_updates (pamac_config.enable_aur && pamac_config.check_aur_updates);
+ } catch (IOError e) {
+ stderr.printf ("IOError: %s\n", e.message);
+ }
}
void show_notification (string info) {
@@ -193,16 +196,44 @@ namespace Pamac {
//~ action.activate.connect (execute_updater);
//~ this.add_action (action);
//~ notification.add_button (_("Show available updates"), "app.update");
+//~ notification.set_default_action ("app.update");
//~ this.send_notification (_("Update Manager"), notification);
try {
+ close_notification();
notification = new Notify.Notification (_("Update Manager"), info, "system-software-update");
- notification.add_action ("update", _("Show available updates"), execute_updater);
+ notification.add_action ("default", _("Show available updates"), execute_updater);
notification.show ();
} catch (Error e) {
stderr.printf ("Notify Error: %s", e.message);
}
}
+ void update_notification (string info) {
+ try {
+ if (notification != null) {
+ if (notification.get_closed_reason() == -1 && notification.body != info) {
+ notification.update (_("Update Manager"), info, "system-software-update");
+ notification.show ();
+ }
+ } else {
+ show_notification (info);
+ }
+ } catch (Error e) {
+ stderr.printf ("Notify Error: %s", e.message);
+ }
+ }
+
+ void close_notification () {
+ try {
+ if (notification != null) {
+ notification.close();
+ notification = null;
+ }
+ } catch (Error e) {
+ stderr.printf ("Notify Error: %s", e.message);
+ }
+ }
+
bool check_pamac_running () {
Application app;
bool run = false;
@@ -238,7 +269,7 @@ namespace Pamac {
bool check_pacman_running () {
if (extern_lock) {
- if (lockfile.query_exists () == false) {
+ if (!lockfile.query_exists ()) {
extern_lock = false;
// let the time to the daemon to update packages
Timeout.add (1000, () => {
@@ -247,20 +278,20 @@ namespace Pamac {
});
}
} else {
- if (lockfile.query_exists () == true) {
+ if (lockfile.query_exists ()) {
extern_lock = true;
}
}
return true;
}
- void launch_refresh_timeout (uint refresh_period_in_hours) {
+ void launch_refresh_timeout (uint64 refresh_period_in_hours) {
if (refresh_timeout_id != 0) {
Source.remove (refresh_timeout_id);
refresh_timeout_id = 0;
}
if (refresh_period_in_hours != 0) {
- refresh_timeout_id = Timeout.add_seconds (refresh_period_in_hours*3600, start_refresh);
+ refresh_timeout_id = Timeout.add_seconds ((uint) refresh_period_in_hours*3600, start_refresh);
}
}
@@ -293,9 +324,9 @@ namespace Pamac {
alpm_config.get_handle ();
lockfile = GLib.File.new_for_path (alpm_config.handle.lockfile);
start_daemon ();
- Timeout.add (500, check_pacman_running);
+ Timeout.add (200, check_pacman_running);
start_refresh ();
- launch_refresh_timeout ((uint) pamac_config.refresh_period);
+ launch_refresh_timeout (pamac_config.refresh_period);
this.hold ();
}
diff --git a/src/updater.vala b/src/updater.vala
index c24e9e3..b430aa8 100644
--- a/src/updater.vala
+++ b/src/updater.vala
@@ -50,14 +50,14 @@ namespace Pamac {
}
public override void activate () {
- if (pamac_run == false) {
+ if (!pamac_run) {
updater_window.present ();
}
}
public override void shutdown () {
base.shutdown ();
- if (pamac_run == false) {
+ if (!pamac_run) {
updater_window.transaction.stop_daemon ();
}
}
diff --git a/src/updater_window.vala b/src/updater_window.vala
index 19be1ac..0b09d31 100644
--- a/src/updater_window.vala
+++ b/src/updater_window.vala
@@ -1,7 +1,7 @@
/*
* pamac-vala
*
- * Copyright (C) 2014-2015 Guillaume Benoit
+ * Copyright (C) 2014-2016 Guillaume Benoit
*
* 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
@@ -25,58 +25,114 @@ namespace Pamac {
[GtkChild]
public Gtk.Label top_label;
[GtkChild]
- public Gtk.TreeView updates_treeview;
+ public Gtk.Notebook notebook;
[GtkChild]
- public Gtk.CellRendererToggle select_update;
+ public Gtk.ScrolledWindow repos_scrolledwindow;
+ [GtkChild]
+ public Gtk.ScrolledWindow aur_scrolledwindow;
+ [GtkChild]
+ public Gtk.TreeView repos_updates_treeview;
+ [GtkChild]
+ public Gtk.CellRendererToggle repos_select_update;
+ [GtkChild]
+ public Gtk.TreeView aur_updates_treeview;
+ [GtkChild]
+ public Gtk.CellRendererToggle aur_select_update;
[GtkChild]
public Gtk.Label bottom_label;
[GtkChild]
public Gtk.Button apply_button;
- public Gtk.ListStore updates_list;
+ public Gtk.ListStore repos_updates_list;
+ public Gtk.ListStore aur_updates_list;
public Pamac.Transaction transaction;
public UpdaterWindow (Gtk.Application application) {
Object (application: application);
- updates_list = new Gtk.ListStore (3, typeof (bool), typeof (string), typeof (string));
- updates_treeview.set_model (updates_list);
+ repos_updates_list = new Gtk.ListStore (3, typeof (bool), typeof (string), typeof (string));
+ repos_updates_treeview.set_model (repos_updates_list);
+ aur_updates_list = new Gtk.ListStore (2, typeof (bool), typeof (string));
+ aur_updates_treeview.set_model (aur_updates_list);
transaction = new Transaction (this as Gtk.ApplicationWindow);
transaction.mode = Mode.UPDATER;
transaction.finished.connect (on_transaction_finished);
+ transaction.daemon.get_updates_finished.connect (on_get_updates_finished);
+
bottom_label.set_visible (false);
apply_button.set_sensitive (false);
+ notebook.set_show_tabs (false);
+ aur_scrolledwindow.set_visible (false);
+
on_refresh_button_clicked ();
}
+ public void set_apply_button_sensitive () {
+ bool sensitive = false;
+ repos_updates_list.foreach ((model, path, iter) => {
+ GLib.Value selected;
+ repos_updates_list.get_value (iter, 0, out selected);
+ sensitive = (bool) selected;
+ return sensitive;
+ });
+ if (!sensitive) {
+ aur_updates_list.foreach ((model, path, iter) => {
+ GLib.Value selected;
+ aur_updates_list.get_value (iter, 0, out selected);
+ sensitive = (bool) selected;
+ return sensitive;
+ });
+ }
+ apply_button.set_sensitive (sensitive);
+ }
+
[GtkCallback]
- public void on_select_update_toggled (string path) {
+ public void on_repos_select_update_toggled (string path) {
Gtk.TreePath treepath = new Gtk.TreePath.from_string (path);
Gtk.TreeIter iter;
- updates_list.get_iter (out iter, treepath);
- updates_list.set (iter, 0, !select_update.active);
- updates_list.foreach ((model, path, iter) => {
- GLib.Value val;
- updates_list.get_value (iter, 0, out val);
- bool selected = val.get_boolean ();
- if (selected) {
- apply_button.set_sensitive (true);
- return true;
- }
- apply_button.set_sensitive (false);
- return false;
- });
+ GLib.Value name_string;
+ repos_updates_list.get_iter (out iter, treepath);
+ repos_updates_list.get_value (iter, 1, out name_string);
+ // string has the form "pkgname pkgversion"
+ string pkgname = name_string.get_string ().split (" ", 2)[0];
+ if (repos_select_update.active) {
+ repos_updates_list.set (iter, 0, false);
+ transaction.special_ignorepkgs.add (pkgname);
+ } else {
+ repos_updates_list.set (iter, 0, true);
+ transaction.special_ignorepkgs.remove (pkgname);
+ }
+ set_apply_button_sensitive ();
+ }
+
+ [GtkCallback]
+ public void on_aur_select_update_toggled (string path) {
+ Gtk.TreePath treepath = new Gtk.TreePath.from_string (path);
+ Gtk.TreeIter iter;
+ GLib.Value name_string;
+ aur_updates_list.get_iter (out iter, treepath);
+ aur_updates_list.get_value (iter, 1, out name_string);
+ // string has the form "pkgname pkgversion"
+ string pkgname = name_string.get_string ().split (" ", 2)[0];
+ if (aur_select_update.active) {
+ aur_updates_list.set (iter, 0, false);
+ transaction.special_ignorepkgs.add (pkgname);
+ } else {
+ aur_updates_list.set (iter, 0, true);
+ transaction.special_ignorepkgs.remove (pkgname);
+ }
+ set_apply_button_sensitive ();
}
public async void run_preferences_dialog () {
SourceFunc callback = run_preferences_dialog.callback;
ulong handler_id = transaction.daemon.get_authorization_finished.connect ((authorized) => {
if (authorized) {
- var preferences_dialog = new PreferencesDialog (transaction, this);
+ var preferences_dialog = new PreferencesDialog (this, transaction);
preferences_dialog.run ();
preferences_dialog.destroy ();
while (Gtk.events_pending ()) {
@@ -93,37 +149,20 @@ namespace Pamac {
[GtkCallback]
public void on_preferences_button_clicked () {
run_preferences_dialog.begin (() => {
- set_updates_list.begin ();
+ populate_updates_list ();
});
}
[GtkCallback]
public void on_apply_button_clicked () {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
- updates_list.foreach ((model, path, iter) => {
- GLib.Value val;
- updates_list.get_value (iter, 0, out val);
- bool selected = val.get_boolean ();
- if (selected) {
- updates_list.get_value (iter, 1, out val);
- // string has the form "pkgname pkgversion"
- string pkgname = val.get_string ().split (" ", 2)[0];
- transaction.special_ignorepkgs.remove (pkgname);
- } else {
- updates_list.get_value (iter, 1, out val);
- // string has the form "pkgname pkgversion"
- string pkgname = val.get_string ().split (" ", 2)[0];
- transaction.special_ignorepkgs.add ((owned) pkgname);
- }
- return false;
- });
- transaction.sysupgrade (0);
+ transaction.sysupgrade (false);
}
[GtkCallback]
public void on_refresh_button_clicked () {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
- transaction.start_refresh (0);
+ transaction.start_refresh (false);
}
[GtkCallback]
@@ -131,55 +170,75 @@ namespace Pamac {
this.application.quit ();
}
- public void on_transaction_finished (bool error) {
- set_updates_list.begin ();
+ public void on_transaction_finished (bool database_modified) {
+ if (database_modified) {
+ populate_updates_list ();
+ } else {
+ this.get_window ().set_cursor (null);
+ }
}
- public async void set_updates_list () {
+ public void populate_updates_list () {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
+ transaction.start_get_updates ();
+ }
+
+ public void on_get_updates_finished (Updates updates) {
top_label.set_markup ("");
- updates_list.clear ();
+ repos_updates_list.clear ();
+ notebook.set_show_tabs (false);
+ repos_scrolledwindow.set_visible (true);
+ aur_updates_list.clear ();
bottom_label.set_visible (false);
Gtk.TreeIter iter;
- string name;
- string size;
uint64 dsize = 0;
- uint updates_nb = 0;
- Updates updates = yield transaction.get_updates ();
- foreach (UpdateInfos infos in updates.repos_updates) {
- name = infos.name + " " + infos.version;
- if (infos.download_size != 0) {
- size = format_size (infos.download_size);
- } else {
- size = "";
- }
+ uint repos_updates_nb = 0;
+ uint aur_updates_nb = 0;
+ foreach (unowned PackageInfos infos in updates.repos_updates) {
+ string name = infos.name + " " + infos.version;
+ string size = infos.download_size != 0 ? format_size (infos.download_size) : "";
dsize += infos.download_size;
- updates_nb++;
+ repos_updates_nb++;
if (infos.name in transaction.special_ignorepkgs) {
- updates_list.insert_with_values (out iter, -1, 0, false, 1, name, 2, size);
+ repos_updates_list.insert_with_values (out iter, -1, 0, false, 1, name, 2, size);
} else {
- updates_list.insert_with_values (out iter, -1, 0, true, 1, name, 2, size);
+ repos_updates_list.insert_with_values (out iter, -1, 0, true, 1, name, 2, size);
}
}
- foreach (UpdateInfos infos in updates.aur_updates) {
- name = infos.name + " " + infos.version;
- size = "";
- updates_nb++;
- updates_list.insert_with_values (out iter, -1, 0, true, 1, name, 2, size);
+ foreach (unowned PackageInfos infos in updates.aur_updates) {
+ string name = infos.name + " " + infos.version;
+ aur_updates_nb++;
+ if (infos.name in transaction.special_ignorepkgs) {
+ aur_updates_list.insert_with_values (out iter, -1, 0, false, 1, name);
+ } else {
+ aur_updates_list.insert_with_values (out iter, -1, 0, true, 1, name);
+ }
}
+ uint updates_nb = repos_updates_nb + aur_updates_nb;
if (updates_nb == 0) {
top_label.set_markup("%s".printf (dgettext (null, "Your system is up-to-date")));
- apply_button.set_sensitive (false);
} else {
top_label.set_markup("%s".printf (dngettext (null, "%u available update", "%u available updates", updates_nb).printf (updates_nb)));
- apply_button.set_sensitive (true);
}
+ set_apply_button_sensitive ();
if (dsize != 0) {
bottom_label.set_markup("%s: %s".printf (dgettext (null, "Total download size"), format_size(dsize)));
bottom_label.set_visible (true);
} else {
bottom_label.set_visible (false);
}
+ if (repos_updates_nb != 0) {
+ notebook.set_show_tabs (true);
+ }
+ if (aur_updates_nb == 0) {
+ aur_scrolledwindow.set_visible (false);
+ } else {
+ aur_scrolledwindow.set_visible (true);
+ if (repos_updates_nb == 0) {
+ repos_scrolledwindow.set_visible (false);
+ }
+ notebook.set_show_tabs (true);
+ }
this.get_window ().set_cursor (null);
}
}
diff --git a/util/alpm-util.c b/util/alpm-util.c
index 69dc726..ec9a5c0 100644
--- a/util/alpm-util.c
+++ b/util/alpm-util.c
@@ -1,70 +1,59 @@
-#include
#include "alpm-util.h"
-alpm_pkg_t* alpm_pkg_load_file (alpm_handle_t *handle, const char *filename, int full, alpm_siglevel_t level) {
- alpm_pkg_t *p;
- int err = alpm_pkg_load(handle, filename, full, level, &p);
- if (err == -1) return NULL;
- else return p;
+alpm_pkg_t* alpm_pkg_load_file (alpm_handle_t* handle, const char* filename, int full, alpm_siglevel_t level) {
+ alpm_pkg_t* p;
+ if (alpm_pkg_load(handle, filename, full, level, &p) != -1) {
+ return p;
+ } else {
+ return NULL;
+ }
}
alpm_list_t* alpm_pkg_get_files_list (alpm_pkg_t* pkg) {
- alpm_list_t *list = NULL;
- alpm_filelist_t *pkgfiles;
+ alpm_list_t* list = NULL;
+ alpm_filelist_t* pkgfiles;
size_t i;
pkgfiles = alpm_pkg_get_files(pkg);
for(i = 0; i < pkgfiles->count; i++) {
- const alpm_file_t *file = pkgfiles->files + i;
+ const alpm_file_t* file = pkgfiles->files + i;
list = alpm_list_add(list, file);
}
return list;
}
-void* alpm_list_get_data (alpm_list_t *list) {
- return list->data;
-}
-
-void* alpm_list_nth_data (alpm_list_t *list, size_t n) {
- return alpm_list_nth (list, n)->data;
-}
-
-alpm_list_t* alpm_list_add_str (alpm_list_t *list, const char *str) {
- char *dup = strdup (str);
- list = alpm_list_add (list, dup);
- return list;
-}
-
-alpm_list_t* alpm_list_remove_data (alpm_list_t *list, const void *needle, alpm_list_fn_cmp fn) {
- void *data = NULL;
- list = alpm_list_remove (list, needle, fn, data);
- free(data);
- return list;
+void* alpm_list_get_data (alpm_list_t* list) {
+ if (list) {
+ return list->data;
+ } else {
+ return NULL;
+ }
}
-alpm_list_t* alpm_list_sort_data (alpm_list_t *list, alpm_list_fn_cmp fn) {
+alpm_list_t* alpm_list_sort (alpm_list_t* list, alpm_list_fn_cmp fn) {
list = alpm_list_msort (list, alpm_list_count (list), fn);
return list;
}
-alpm_list_t *alpm_list_new () {
+alpm_list_t* alpm_list_new () {
return NULL;
}
-void alpm_list_free_all (alpm_list_t *list) {
- do { alpm_list_free_inner (list, free); alpm_list_free (list); list = NULL; } while (0);
+void alpm_list_free_data (alpm_list_t* list) {
+ alpm_list_free_inner (list, free);
}
-void alpm_list_iterator (alpm_list_t *list, alpm_list_iterator_t* iter) {
+void alpm_list_iterator (alpm_list_t* list, alpm_list_iterator_t* iter) {
iter->pos = list;
}
-void* alpm_list_iterator_next_value (alpm_list_iterator_t *iter) {
+void* alpm_list_iterator_next_value (alpm_list_iterator_t* iter) {
if (iter->pos) {
- void* result = alpm_list_get_data (iter->pos);
+ void* data = alpm_list_get_data (iter->pos);
iter->pos = alpm_list_next (iter->pos);
- return result;
+ return data;
+ } else {
+ return NULL;
}
- else return NULL;
}
diff --git a/util/alpm-util.h b/util/alpm-util.h
index f4444bd..7cebc82 100644
--- a/util/alpm-util.h
+++ b/util/alpm-util.h
@@ -7,17 +7,14 @@ typedef struct __alpm_list_iterator_t {
alpm_list_t* pos;
} alpm_list_iterator_t;
-void* alpm_list_get_data (alpm_list_t *list);
-void* alpm_list_nth_data (alpm_list_t *list, size_t n);
-alpm_list_t* alpm_list_add_str (alpm_list_t *list, const char *str);
-alpm_list_t *alpm_list_remove_data (alpm_list_t *list, const void *needle, alpm_list_fn_cmp fn);
-alpm_list_t *alpm_list_sort_data (alpm_list_t *list, alpm_list_fn_cmp fn);
-alpm_list_t *alpm_list_new ();
-void alpm_list_free_all (alpm_list_t *list);
-void alpm_list_iterator (alpm_list_t *list, alpm_list_iterator_t* i);
-void* alpm_list_iterator_next_value (alpm_list_iterator_t *iter);
+void* alpm_list_get_data (alpm_list_t* list);
+alpm_list_t* alpm_list_sort (alpm_list_t* list, alpm_list_fn_cmp fn);
+alpm_list_t* alpm_list_new ();
+void alpm_list_free_data (alpm_list_t* list);
+void alpm_list_iterator (alpm_list_t* list, alpm_list_iterator_t* i);
+void* alpm_list_iterator_next_value (alpm_list_iterator_t* iter);
-alpm_pkg_t* alpm_pkg_load_file (alpm_handle_t *handle, const char *filename, int full, alpm_siglevel_t level);
+alpm_pkg_t* alpm_pkg_load_file (alpm_handle_t* handle, const char* filename, int full, alpm_siglevel_t level);
alpm_list_t* alpm_pkg_get_files_list (alpm_pkg_t* pkg);
#endif //!ALPM_UTIL_H
diff --git a/vapi/libalpm.vapi b/vapi/libalpm.vapi
index 0017ded..12ce4c4 100644
--- a/vapi/libalpm.vapi
+++ b/vapi/libalpm.vapi
@@ -31,6 +31,14 @@ namespace Alpm {
*/
public unowned string version();
+ [CCode (cname = "alpm_caps", cprefix = "ALPM_CAPABILITY_")]
+ public enum Capabilities {
+ NLS = (1 << 0),
+ DOWNLOADER = (1 << 1),
+ SIGNATURES = (1 << 2)
+ }
+ public Capabilities capabilities();
+
public unowned Package? find_satisfier(Alpm.List pkgs, string depstring);
public unowned Package? pkg_find(Alpm.List haystack, string needle);
@@ -45,14 +53,11 @@ namespace Alpm {
/**
* Handle
*/
- [CCode (cname = "alpm_handle_t")]
+ [CCode (cname = "alpm_handle_t", free_function = "alpm_release")]
[Compact]
public class Handle {
[CCode (cname = "alpm_initialize")]
- public static unowned Handle @new(string root, string dbpath, out Alpm.Errno error);
-
- [CCode (cname = "alpm_release")]
- public static int release (Handle handle);
+ public static Handle? @new(string root, string dbpath, out Alpm.Errno error);
public unowned string root {
[CCode (cname = "alpm_option_get_root")] get;
@@ -73,6 +78,15 @@ namespace Alpm {
[CCode (cname = "alpm_option_remove_cachedir")]
public int remove_cachedir(string cachedir);
+ public unowned Alpm.List hookdirs {
+ [CCode (cname = "alpm_option_get_hookdirs")] get;
+ [CCode (cname = "alpm_option_set_hookdirs")] set;
+ }
+ [CCode (cname = "alpm_option_add_hookdir")]
+ public int add_hookdir(string hookdir);
+ [CCode (cname = "alpm_option_remove_hookdir")]
+ public int remove_hookdir(string hookdir);
+
public unowned string logfile {
[CCode (cname = "alpm_option_get_logfile")] get;
[CCode (cname = "alpm_option_set_logfile")] set;
@@ -146,6 +160,11 @@ namespace Alpm {
[CCode (cname = "alpm_option_set_checkspace")] set;
}
+ public unowned string dbext {
+ [CCode (cname = "alpm_option_get_dbext")] get;
+ [CCode (cname = "alpm_option_set_dbext")] set;
+ }
+
public Signature.Level defaultsiglevel {
[CCode (cname = "alpm_option_get_default_siglevel")] get;
[CCode (cname = "alpm_option_set_default_siglevel")] set;
@@ -195,6 +214,9 @@ namespace Alpm {
[CCode (cname = "alpm_option_set_progresscb")] set;
}
+ [CCode (cname = "alpm_unlock")]
+ public int unlock();
+
[CCode (cname = "alpm_register_syncdb")]
public unowned DB? register_syncdb(string treename, Signature.Level level);
[CCode (cname = "alpm_unregister_all_syncdbs")]
@@ -301,7 +323,7 @@ namespace Alpm {
[CCode (cname = "alpm_db_t", cprefix = "alpm_db_")]
[Compact]
public class DB {
- public static int unregister(DB db);
+ public static int unregister(owned DB db);
public unowned string name {
[CCode (cname = "alpm_db_get_name")] get;
@@ -354,12 +376,9 @@ namespace Alpm {
/**
* Packages
*/
- [CCode (cname = "alpm_pkg_t", cprefix = "alpm_pkg_")]
+ [CCode (cname = "alpm_pkg_t", cprefix = "alpm_pkg_", free_function = "alpm_pkg_free")]
[Compact]
public class Package {
-
- public static int free(Package pkg);
-
/* properties */
public unowned string filename {
[CCode (cname = "alpm_pkg_get_filename")] get;
@@ -370,6 +389,9 @@ namespace Alpm {
public unowned string version {
[CCode (cname = "alpm_pkg_get_version")] get;
}
+ public unowned string pkgbase {
+ [CCode (cname = "alpm_pkg_get_base")] get;
+ }
public From origin {
[CCode (cname = "alpm_pkg_get_origin")] get;
}
@@ -684,9 +706,6 @@ namespace Alpm {
DATABASE_MARGINAL_OK = (1 << 12),
DATABASE_UNKNOWN_OK = (1 << 13),
- PACKAGE_SET = (1 << 27),
- PACKAGE_TRUST_SET = (1 << 28),
-
USE_DEFAULT = (1 << 31)
}
@@ -719,6 +738,13 @@ namespace Alpm {
public unowned Signature.Result[] results;
}
+ /** Hooks */
+ [CCode (cname = "alpm_hook_when_t", cprefix = "ALPM_HOOK_")]
+ public enum HookWhen {
+ PRE_TRANSACTION = 1,
+ POST_TRANSACTION
+ }
+
/** Logging Levels */
[CCode (cname = "alpm_loglevel_t", cprefix = "ALPM_LOG_")]
public enum LogLevel {
@@ -754,6 +780,10 @@ namespace Alpm {
INTERCONFLICTS_START,
/** Inter-conflicts were checked for target package. */
INTERCONFLICTS_DONE,
+ /** Processing the package transaction is starting. */
+ TRANSACTION_START,
+ /** Processing the package transaction is finished. */
+ TRANSACTION_DONE,
/** Package will be installed/upgraded/downgraded/re-installed/removed; See
* PackageOperation for arguments. */
PACKAGE_OPERATION_START,
@@ -824,9 +854,14 @@ namespace Alpm {
/** A .pacsave file was created; See PacsaveCreated for
* arguments */
PACSAVE_CREATED,
- /** A .pacorig file was created; See PacorigCreated for
- * arguments */
- PACORIG_CREATED
+ /** Processing hooks will be started. */
+ HOOK_START,
+ /** Processing hooks is finished. */
+ HOOK_DONE,
+ /** A hook is starting */
+ HOOK_RUN_START,
+ /** A hook has finnished runnning */
+ HOOK_RUN_DONE
}
[CCode (cname = "alpm_event_any_t", has_type_id = false)]
@@ -913,14 +948,26 @@ namespace Alpm {
public unowned string file;
}
- [CCode (cname = "alpm_event_pacorig_created_t", has_type_id = false)]
- public class PacorigCreated {
- /** Type of event. */
+ [CCode (cname = "alpm_event_hook_t", has_type_id = false)]
+ public class Hook {
+ /** Type of event.*/
public Type type;
- /** New package. */
- public unowned Package newpkg;
- /** Filename of the file without the .pacorig suffix. */
- public unowned string file;
+ /** Type of hooks. */
+ public HookWhen when;
+ }
+
+ [CCode (cname = "alpm_event_hook_run_t", has_type_id = false)]
+ public class HookRun {
+ /** Type of event.*/
+ public Type type;
+ /** Name of hook */
+ public unowned string name;
+ /** Description of hook to be outputted */
+ public unowned string desc;
+ /** position of hook being run */
+ public size_t position;
+ /** total hooks being run */
+ public size_t total;
}
/** This is an union passed to the callback, that allows the frontend to know
@@ -969,11 +1016,18 @@ namespace Alpm {
public unowned Package pacsave_created_oldpkg;
[CCode (cname = "pacsave_created.file")]
public unowned string pacsave_created_file;
- // PacorigCreated pacorig_created;
- [CCode (cname = "pacorig_created.newpkg")]
- public unowned Package pacorig_created_newpkg;
- [CCode (cname = "pacorig_created.file")]
- public unowned string pacorig_created_file;
+ // Hook hook;
+ [CCode (cname = "hook.when")]
+ public HookWhen hook_when;
+ // HookRun hook_run;
+ [CCode (cname = "hook_run.name")]
+ public unowned string hook_run_name;
+ [CCode (cname = "hook_run.desc")]
+ public unowned string hook_run_desc;
+ [CCode (cname = "hook_run.position")]
+ public size_t hook_run_position;
+ [CCode (cname = "hook_run.total")]
+ public size_t hook_run_total;
}
}
@@ -1070,7 +1124,7 @@ namespace Alpm {
/** Answer: which provider to use (index from providers). */
public int use_index;
/** List of alpm_pkg_t* as possible providers. */
- public unowned Alpm.List providers;
+ public unowned Alpm.List providers;
/** What providers provide for. */
public unowned Depend depend;
}
@@ -1130,7 +1184,7 @@ namespace Alpm {
[CCode (cname = "select_provider.use_index")]
public int select_provider_use_index;
[CCode (cname = "select_provider.providers")]
- public unowned Alpm.List select_provider_providers;
+ public unowned Alpm.List select_provider_providers;
[CCode (cname = "select_provider.depend")]
public unowned Depend select_provider_depend;
// ImportKey import_key;
@@ -1261,6 +1315,7 @@ namespace Alpm {
TRANS_ABORT,
TRANS_TYPE,
TRANS_NOT_LOCKED,
+ TRANS_HOOK_FAILED,
/* Packages */
PKG_NOT_FOUND,
PKG_IGNORED,
@@ -1293,17 +1348,14 @@ namespace Alpm {
GPGME
}
-[CCode (cname = "alpm_list_t", cprefix = "alpm_list_", cheader_filename = "alpm_list.h,alpm-util.h",
- free_function = "alpm_list_free")]
+ [CCode (cname = "alpm_list_t", cprefix = "alpm_list_", cheader_filename = "alpm_list.h,alpm-util.h",
+ dup_function = "alpm_list_copy", free_function = "alpm_list_free")]
[Compact]
public class List {
- [CCode (cname = "alpm_list_new")]
public List ();
- public static void free_all(List list);
-
- /* Comparator*/
+ /* comparator */
[CCode (cname = "alpm_list_fn_cmp", has_target = false)]
public delegate int CompareFunc(G a, G b);
@@ -1317,25 +1369,25 @@ namespace Alpm {
/* item mutators */
[ReturnsModifiedPointer ()]
- public unowned void add(G data);
+ public void add(owned G data);
[ReturnsModifiedPointer ()]
- public unowned void add_str(string str);
+ public void join(owned List list);
[ReturnsModifiedPointer ()]
- public unowned void join(List list);
+ public void sort(CompareFunc fn);
- [CCode (cname = "alpm_list_sort_data"), ReturnsModifiedPointer ()]
- public unowned void sort(CompareFunc fn);
+ [ReturnsModifiedPointer ()]
+ public void remove(G data, CompareFunc fn, out G removed_data );
- [CCode (cname = "alpm_list_remove_data"), ReturnsModifiedPointer ()]
- public unowned void? remove(G data, CompareFunc fn);
+ /* free the internal data of this */
+ public void free_data();
- public List copy();
+ public List copy();
public List copy_data();
[ReturnsModifiedPointer ()]
- public unowned void reverse ();
+ public void reverse ();
/* item accessors */
public unowned List? first();
@@ -1344,13 +1396,12 @@ namespace Alpm {
public unowned List? next();
public unowned List? previous();
- public unowned G? nth_data(size_t index);
-
/* misc */
+ public unowned G? find(G needle, CompareFunc fn);
public unowned string? find_str(string needle);
/** @return a list containing all items in `this` not present in `list` */
- public unowned List? diff(List? list, CompareFunc fn);
+ public List? diff(List? list, CompareFunc fn);
/* iterator */
public Iterator iterator();
@@ -1359,6 +1410,7 @@ namespace Alpm {
public struct Iterator {
public unowned G? next_value();
}
+
}
}