add build_date for repo pkgs and details tab for AUR pkgs

This commit is contained in:
guinux 2015-10-07 15:35:26 +02:00
parent ce20a39e6c
commit 00fd98ae27
7 changed files with 146 additions and 81 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -257,7 +257,12 @@ namespace Pamac {
name_label.set_markup ("<big><b>%s %s</b></big>".printf (pkg.name, pkg.version)); name_label.set_markup ("<big><b>%s %s</b></big>".printf (pkg.name, pkg.version));
desc_label.set_markup (Markup.escape_text (pkg.desc)); desc_label.set_markup (Markup.escape_text (pkg.desc));
string url = Markup.escape_text (pkg.url); 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 ("<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)); link_label.set_markup ("<a href=\"%s\">%s</a>".printf (url, url));
}
StringBuilder licenses = new StringBuilder (); StringBuilder licenses = new StringBuilder ();
licenses.append (dgettext (null, "Licenses")); licenses.append (dgettext (null, "Licenses"));
licenses.append (": "); licenses.append (": ");
@ -366,7 +371,7 @@ namespace Pamac {
Gtk.TreeIter iter; Gtk.TreeIter iter;
PackageDetails details = transaction.get_pkg_details (pkgname); PackageDetails details = transaction.get_pkg_details (pkgname);
int i; int i;
if (details.repo != "local") { if (details.repo != "local" && details.repo != "AUR") {
details_list.insert_with_values (out iter, -1, details_list.insert_with_values (out iter, -1,
0, dgettext (null, "Repository") + ":", 0, dgettext (null, "Repository") + ":",
1, details.repo); 1, details.repo);
@ -382,9 +387,24 @@ namespace Pamac {
i++; i++;
} }
} }
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, details_list.insert_with_values (out iter, -1,
0, dgettext (null, "Packager") + ":", 0, dgettext (null, "Packager") + ":",
1, details.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") { if (details.repo == "local") {
details_list.insert_with_values (out iter, -1, details_list.insert_with_values (out iter, -1,
0, dgettext (null, "Install Date") + ":", 0, dgettext (null, "Install Date") + ":",
@ -401,11 +421,21 @@ namespace Pamac {
0, dgettext (null, "Install Reason") + ":", 0, dgettext (null, "Install Reason") + ":",
1, reason); 1, reason);
} }
if (details.repo != "local") { if (details.repo != "local" && details.repo != "AUR") {
details_list.insert_with_values (out iter, -1, details_list.insert_with_values (out iter, -1,
0, dgettext (null, "Signatures") + ":", 0, dgettext (null, "Signatures") + ":",
1, details.has_signature); 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.repo == "local") {
if (details.backups.length != 0) { if (details.backups.length != 0) {
details_list.insert_with_values (out iter, -1, details_list.insert_with_values (out iter, -1,
@ -492,48 +522,31 @@ namespace Pamac {
if (selected.length () > 0) { if (selected.length () > 0) {
// display info for the first package of the selection // display info for the first package of the selection
Pamac.Package pkg = packages_list.get_pkg_at_path (selected.nth_data (0)); 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") { if (pkg.repo == "local") {
deps_scrolledwindow.visible = true;
files_scrolledwindow.visible = true; files_scrolledwindow.visible = true;
} else if (pkg.repo == "AUR") {
deps_scrolledwindow.visible = false;
files_scrolledwindow.visible = false;
} else { } else {
deps_scrolledwindow.visible = true;
files_scrolledwindow.visible = false; files_scrolledwindow.visible = false;
} }
switch (properties_notebook.get_current_page ()) { switch (properties_notebook.get_current_page ()) {
case 0: case 0:
set_infos_list (pkg); 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; break;
case 1: 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; break;
case 2: 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; break;
case 3: case 3:
if (pkg.repo == "local") {
set_files_list (pkg.name); set_files_list (pkg.name);
} else {
files_scrolledwindow.visible = false;
if (pkg.repo == "AUR") {
deps_scrolledwindow.visible = false;
details_scrolledwindow.visible = false;
}
}
break; break;
default: default:
break; break;

View File

@ -31,13 +31,12 @@ namespace Pamac {
public Package (Alpm.Package? alpm_pkg, Json.Object? aur_json) { public Package (Alpm.Package? alpm_pkg, Json.Object? aur_json) {
if (alpm_pkg != null) { if (alpm_pkg != null) {
name = alpm_pkg.name; name = alpm_pkg.name ?? "";
version = alpm_pkg.version; version = alpm_pkg.version ?? "";
desc = alpm_pkg.desc; desc = alpm_pkg.desc ?? "";
repo = alpm_pkg.db != null ? alpm_pkg.db.name : ""; repo = (alpm_pkg.db != null ? (alpm_pkg.db.name ?? "") : "");
size = alpm_pkg.isize; size = alpm_pkg.isize;
size_string = format_size (alpm_pkg.isize); size_string = format_size (alpm_pkg.isize);
// alpm pkg url can be null
url = alpm_pkg.url ?? ""; url = alpm_pkg.url ?? "";
StringBuilder licenses_build = new StringBuilder (); StringBuilder licenses_build = new StringBuilder ();
foreach (var license in alpm_pkg.licenses) { foreach (var license in alpm_pkg.licenses) {
@ -49,9 +48,9 @@ namespace Pamac {
licenses = licenses_build.str; licenses = licenses_build.str;
reason = alpm_pkg.reason; reason = alpm_pkg.reason;
} else if (aur_json != null ) { } else if (aur_json != null ) {
name = aur_json.get_string_member ("Name"); name = aur_json.get_string_member ("Name") ?? "";
version = aur_json.get_string_member ("Version"); version = aur_json.get_string_member ("Version") ?? "";
desc = aur_json.get_string_member ("Description"); desc = aur_json.get_string_member ("Description") ?? "";
repo = "AUR"; repo = "AUR";
size = 0; size = 0;
size_string = ""; size_string = "";
@ -74,9 +73,15 @@ namespace Pamac {
public struct PackageDetails { public struct PackageDetails {
string repo; string repo;
// for AUR package it is OutOfDate
string has_signature; string has_signature;
// for AUR package it is NumVotes
int reason; int reason;
// for AUR package it is Maintainer
string packager; string packager;
// for AUR package it is FirstSubmitted
string build_date;
// for AUR package it is LastModified
string install_date; string install_date;
string[] groups; string[] groups;
string[] backups; string[] backups;

View File

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