pamac-classic/src/package.vala

96 lines
2.6 KiB
Vala
Raw Normal View History

2014-10-22 13:44:02 -03:00
/*
* pamac-vala
*
2015-03-04 11:55:36 -03:00
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
2014-10-22 13:44:02 -03:00
*
* 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 <http://www.gnu.org/licenses/>.
*/
namespace Pamac {
2015-03-04 11:55:36 -03:00
public struct Package {
2014-10-22 13:44:02 -03:00
public string name;
public string version;
2015-03-04 11:55:36 -03:00
public string desc;
2014-10-22 13:44:02 -03:00
public string repo;
public uint64 size;
public string size_string;
2015-03-04 11:55:36 -03:00
public string url;
public string licenses;
public int reason;
2014-10-22 13:44:02 -03:00
public Package (Alpm.Package? alpm_pkg, Json.Object? aur_json) {
if (alpm_pkg != null) {
2016-02-02 05:28:07 -03:00
name = alpm_pkg.name;
version = alpm_pkg.version;
desc = alpm_pkg.desc;
repo = alpm_pkg.db != null ? alpm_pkg.db.name : "";
2014-10-22 13:44:02 -03:00
size = alpm_pkg.isize;
size_string = format_size (alpm_pkg.isize);
2016-02-02 05:28:07 -03:00
// alpm pkg url can be null
2015-03-04 11:55:36 -03:00
url = alpm_pkg.url ?? "";
StringBuilder licenses_build = new StringBuilder ();
foreach (var license in alpm_pkg.licenses) {
if (licenses_build.len != 0) {
licenses_build.append (" ");
}
licenses_build.append (license);
}
licenses = licenses_build.str;
reason = alpm_pkg.reason;
2014-10-22 13:44:02 -03:00
} else if (aur_json != null ) {
2016-02-02 05:28:07 -03:00
name = aur_json.get_string_member ("Name");
version = aur_json.get_string_member ("Version");
desc = aur_json.get_string_member ("Description");
2014-10-22 13:44:02 -03:00
repo = "AUR";
size = 0;
size_string = "";
url = aur_json.get_string_member ("URL") ?? "";
2015-03-08 08:06:29 -03:00
licenses = aur_json.get_string_member ("License") ?? dgettext (null, "Unknown");
2015-03-04 11:55:36 -03:00
reason = 0;
2014-10-22 13:44:02 -03:00
} else {
2015-03-04 11:55:36 -03:00
name = "";
2014-10-22 13:44:02 -03:00
version = "";
2015-03-04 11:55:36 -03:00
desc = "";
2014-10-22 13:44:02 -03:00
repo = "";
size = 0;
size_string = "";
2015-03-04 11:55:36 -03:00
url = "";
licenses= "";
reason = 0;
2014-10-22 13:44:02 -03:00
}
}
}
2015-03-04 11:55:36 -03:00
public struct PackageDetails {
string repo;
string has_signature;
int reason;
string packager;
string install_date;
string[] groups;
string[] backups;
}
public struct PackageDeps {
string repo;
string[] depends;
string[] optdepends;
string[] requiredby;
string[] optionalfor;
2015-03-04 11:55:36 -03:00
string[] provides;
string[] replaces;
string[] conflicts;
}
2014-10-22 13:44:02 -03:00
}