Browse Source

add build_date for repo pkgs and details tab for AUR pkgs

pull/15/head
guinux 7 years ago
parent
commit
00fd98ae27
  1. 25
      po/pamac.pot
  2. 15
      src/aur.vala
  3. 1
      src/common.vala
  4. 80
      src/daemon.vala
  5. 81
      src/manager_window.vala
  6. 21
      src/package.vala
  7. 4
      src/packages_model.vala

25
po/pamac.pot

@ -21,6 +21,7 @@ msgstr ""
msgid "Authentication is required"
msgstr ""
#: ../src/daemon.vala
msgid "Failed to initialize alpm library"
msgstr ""
@ -415,10 +416,26 @@ msgstr ""
msgid "Groups"
msgstr ""
#: ../src/manager_window.vala
msgid "Maintainer"
msgstr ""
#: ../src/manager_window.vala
msgid "First Submitted"
msgstr ""
#: ../src/manager_window.vala
msgid "Last Modified"
msgstr ""
#: ../src/manager_window.vala
msgid "Packager"
msgstr ""
#: ../src/manager_window.vala
msgid "Build Date"
msgstr ""
#: ../src/manager_window.vala
msgid "Install Date"
msgstr ""
@ -443,6 +460,14 @@ msgstr ""
msgid "Signatures"
msgstr ""
#: ../src/manager_window.vala
msgid "Votes"
msgstr ""
#: ../src/manager_window.vala
msgid "Out of Date"
msgstr ""
#: ../src/manager_window.vala
msgid "Backup files"
msgstr ""

15
src/aur.vala

@ -72,14 +72,14 @@ namespace AUR {
found = root.get_object ().get_array_member ("results");
}
}
foreach (var prev_inter_node in prev_inter.get_elements ()) {
foreach (var found_node in found.get_elements ()) {
prev_inter.foreach_element ((prev_inter_array, prev_inter_index, prev_inter_node) => {
found.foreach_element ((found_array, found_index, found_node) => {
if (strcmp (prev_inter_node.get_object ().get_string_member ("Name"),
found_node.get_object ().get_string_member ("Name")) == 0) {
inter.add_element (prev_inter_node);
}
}
}
});
});
if (i != (length -1)) {
prev_inter = inter;
}
@ -88,8 +88,7 @@ namespace AUR {
return inter;
}
public Json.Object info (string pkgname) {
var pkg_info = new Json.Object ();
public unowned Json.Object? info (string pkgname) {
string uri = rpc_url + rpc_info + Uri.escape_string (pkgname);
var session = new Soup.Session ();
var message = new Soup.Message ("GET", uri);
@ -106,10 +105,10 @@ namespace AUR {
if (root.get_object ().get_string_member ("type") == "error") {
stderr.printf ("Failed to get infos about %s from AUR\n", pkgname);
} else {
pkg_info = root.get_object ().get_object_member ("results");
return root.get_object ().get_object_member ("results");
}
}
return pkg_info;
return null;
}
public Json.Array multiinfo (string[] pkgnames) {

1
src/common.vala

@ -22,7 +22,6 @@ namespace Pamac {
public string name;
public string version;
public string db_name;
public string tarpath;
public uint64 download_size;
}

80
src/daemon.vala

@ -434,7 +434,7 @@ namespace Pamac {
aur_pkgs = AUR.search (splitted);
aur_search_results.insert (search_string, aur_pkgs);
}
foreach (var node in aur_pkgs.get_elements ()) {
aur_pkgs.foreach_element ((array, index, node) => {
var aur_pkg = node.get_object ();
var pamac_pkg = Pamac.Package (null, aur_pkg);
bool found = false;
@ -447,7 +447,7 @@ namespace Pamac {
if (found == false) {
result += pamac_pkg;
}
}
});
}
return result;
}
@ -531,6 +531,7 @@ namespace Pamac {
string has_signature = _("No");
int reason = 0;
string packager = "";
string build_date = "";
string install_date = "";
string[] groups = {};
string[] backups = {};
@ -539,27 +540,59 @@ namespace Pamac {
if (alpm_pkg == null) {
alpm_pkg = get_syncpkg (pkgname);
}
if (alpm_pkg != null) {
repo = alpm_pkg.db.name;
packager = alpm_pkg.packager;
if (alpm_pkg == null) {
// search for the corresponding Json.Object in aur_search_result
var iter = HashTableIter<string, Json.Array> (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;
}
if (alpm_pkg.db.name == "local") {
reason = alpm_pkg.reason;
GLib.Time 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;
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");
}
} 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;
@ -641,7 +674,6 @@ namespace Pamac {
infos.name = candidate.name;
infos.version = candidate.version;
infos.db_name = candidate.db.name;
infos.tarpath = "";
infos.download_size = candidate.download_size;
updates_infos += infos;
}
@ -661,7 +693,6 @@ namespace Pamac {
infos.name = candidate.name;
infos.version = candidate.version;
infos.db_name = candidate.db.name;
infos.tarpath = "";
infos.download_size = candidate.download_size;
updates_infos += infos;
} else {
@ -686,25 +717,20 @@ namespace Pamac {
if (aur_updates_results.get_length () == 0) {
aur_updates_results = AUR.multiinfo (local_pkgs);
}
int cmp;
unowned Json.Object pkg_info;
string version;
string name;
updates_infos = {};
foreach (var node in aur_updates_results.get_elements ()) {
pkg_info = node.get_object ();
version = pkg_info.get_string_member ("Version");
name = pkg_info.get_string_member ("Name");
cmp = Alpm.pkg_vercmp (version, alpm_config.handle.localdb.get_pkg (name).version);
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.tarpath = pkg_info.get_string_member ("URLPath");
infos.download_size = 0;
updates_infos += infos;
}
}
});
updates.aur_updates = updates_infos;
}
return updates;
@ -955,7 +981,6 @@ namespace Pamac {
} else {
info.db_name = "";
}
info.tarpath = "";
info.download_size = pkg.download_size;
infos += info;
}
@ -969,7 +994,6 @@ namespace Pamac {
info.name = pkg.name;
info.version = pkg.version;
info.db_name = pkg.db.name;
info.tarpath = "";
info.download_size = pkg.download_size;
infos += info;
}

81
src/manager_window.vala

@ -257,7 +257,12 @@ namespace Pamac {
name_label.set_markup ("<big><b>%s %s</b></big>".printf (pkg.name, pkg.version));
desc_label.set_markup (Markup.escape_text (pkg.desc));
string url = Markup.escape_text (pkg.url);
link_label.set_markup ("<a href=\"%s\">%s</a>".printf (url, url));
if (pkg.repo == "AUR") {
string aur_url = "http://aur.archlinux.org/packages/" + pkg.name;
link_label.set_markup ("<a href=\"%s\">%s</a>\n\n<a href=\"%s\">%s</a>".printf (url, url, aur_url, aur_url));
} else {
link_label.set_markup ("<a href=\"%s\">%s</a>".printf (url, url));
}
StringBuilder licenses = new StringBuilder ();
licenses.append (dgettext (null, "Licenses"));
licenses.append (": ");
@ -366,7 +371,7 @@ namespace Pamac {
Gtk.TreeIter iter;
PackageDetails details = transaction.get_pkg_details (pkgname);
int i;
if (details.repo != "local") {
if (details.repo != "local" && details.repo != "AUR") {
details_list.insert_with_values (out iter, -1,
0, dgettext (null, "Repository") + ":",
1, details.repo);
@ -382,9 +387,24 @@ namespace Pamac {
i++;
}
}
details_list.insert_with_values (out iter, -1,
0, dgettext (null, "Packager") + ":",
1, details.packager);
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, "Install Date") + ":",
@ -401,11 +421,21 @@ namespace Pamac {
0, dgettext (null, "Install Reason") + ":",
1, reason);
}
if (details.repo != "local") {
if (details.repo != "local" && details.repo != "AUR") {
details_list.insert_with_values (out iter, -1,
0, dgettext (null, "Signatures") + ":",
1, details.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) {
details_list.insert_with_values (out iter, -1,
@ -492,48 +522,31 @@ namespace Pamac {
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);
if (pkg.repo == "AUR") {
deps_scrolledwindow.visible = false;
details_scrolledwindow.visible = false;
} else {
deps_scrolledwindow.visible = true;
details_scrolledwindow.visible = true;
}
break;
case 1:
if (pkg.repo == "AUR") {
deps_scrolledwindow.visible = false;
details_scrolledwindow.visible = false;
} else {
set_deps_list (pkg.name);
}
set_deps_list (pkg.name);
break;
case 2:
if (pkg.repo == "AUR") {
deps_scrolledwindow.visible = false;
details_scrolledwindow.visible = false;
} else {
set_details_list (pkg.name);
}
set_details_list (pkg.name);
break;
case 3:
if (pkg.repo == "local") {
set_files_list (pkg.name);
} else {
files_scrolledwindow.visible = false;
if (pkg.repo == "AUR") {
deps_scrolledwindow.visible = false;
details_scrolledwindow.visible = false;
}
}
set_files_list (pkg.name);
break;
default:
break;

21
src/package.vala

@ -31,13 +31,12 @@ 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) {
@ -49,9 +48,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 = "";
@ -74,9 +73,15 @@ 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;

4
src/packages_model.vala

@ -82,8 +82,8 @@ namespace Pamac {
val.set_object (manager_window.uninstalled_icon);
}
} else if (pkg.name == dgettext (null, "No package found")) {
Object? object = null;
val.set_object (object);
// nothing to do
break;
} else if (manager_window.transaction.to_add.contains (pkg.name)) {
val.set_object (manager_window.to_install_icon);
} else {

Loading…
Cancel
Save