Merge pull request 'Compatibility with libalpm 13.0.0' (#10) from matthiakl/pamac-classic:libalpm_13 into master

Reviewed-on: #10
This commit is contained in:
Chris Cromer 2021-07-10 13:15:19 -04:00
commit a9661508cb
12 changed files with 364 additions and 226 deletions

View File

@ -51,7 +51,6 @@ public class AlpmConfig {
string? dbpath; string? dbpath;
string? logfile; string? logfile;
string? gpgdir; string? gpgdir;
string? arch;
int usesyslog; int usesyslog;
public int checkspace; public int checkspace;
GLib.List<string> cachedirs; GLib.List<string> cachedirs;
@ -62,6 +61,7 @@ public class AlpmConfig {
GLib.List<string> noupgrades; GLib.List<string> noupgrades;
GLib.List<string> holdpkgs; GLib.List<string> holdpkgs;
GLib.List<string> syncfirsts; GLib.List<string> syncfirsts;
GLib.List<string> architectures;
Alpm.Signature.Level siglevel; Alpm.Signature.Level siglevel;
Alpm.Signature.Level localfilesiglevel; Alpm.Signature.Level localfilesiglevel;
Alpm.Signature.Level remotefilesiglevel; Alpm.Signature.Level remotefilesiglevel;
@ -93,6 +93,7 @@ public class AlpmConfig {
noupgrades = new GLib.List<string> (); noupgrades = new GLib.List<string> ();
holdpkgs = new GLib.List<string> (); holdpkgs = new GLib.List<string> ();
syncfirsts = new GLib.List<string> (); syncfirsts = new GLib.List<string> ();
architectures = new GLib.List<string> ();
usesyslog = 0; usesyslog = 0;
checkspace = 0; checkspace = 0;
siglevel = Alpm.Signature.Level.PACKAGE | Alpm.Signature.Level.PACKAGE_OPTIONAL | Alpm.Signature.Level.DATABASE | Alpm.Signature.Level.DATABASE_OPTIONAL; siglevel = Alpm.Signature.Level.PACKAGE | Alpm.Signature.Level.PACKAGE_OPTIONAL | Alpm.Signature.Level.DATABASE | Alpm.Signature.Level.DATABASE_OPTIONAL;
@ -130,8 +131,8 @@ public class AlpmConfig {
// rootdir is defined because it contains configuration data. // rootdir is defined because it contains configuration data.
gpgdir = "/etc/pacman.d/gnupg/"; gpgdir = "/etc/pacman.d/gnupg/";
} }
if (arch == null) { if (architectures.length () == 0) {
arch = Posix.utsname().machine; architectures.append (Posix.utsname().machine);
} }
} }
@ -171,7 +172,9 @@ public class AlpmConfig {
handle.logfile = logfile; handle.logfile = logfile;
} }
handle.gpgdir = gpgdir; handle.gpgdir = gpgdir;
handle.arch = arch; foreach (unowned string arch in architectures) {
handle.add_architecture (arch);
}
handle.usesyslog = usesyslog; handle.usesyslog = usesyslog;
handle.checkspace = checkspace; handle.checkspace = checkspace;
handle.defaultsiglevel = siglevel; handle.defaultsiglevel = siglevel;
@ -202,7 +205,9 @@ public class AlpmConfig {
repo.siglevel = merge_siglevel (siglevel, repo.siglevel, repo.siglevel_mask); repo.siglevel = merge_siglevel (siglevel, repo.siglevel, repo.siglevel_mask);
unowned Alpm.DB db = handle.register_syncdb (repo.name, repo.siglevel); unowned Alpm.DB db = handle.register_syncdb (repo.name, repo.siglevel);
foreach (unowned string url in repo.urls) { foreach (unowned string url in repo.urls) {
db.add_server (url.replace ("$repo", repo.name).replace ("$arch", handle.arch)); foreach (unowned string arch in architectures) {
db.add_server (url.replace ("$repo", repo.name).replace ("$arch", arch));
}
} }
if (repo.usage == 0) { if (repo.usage == 0) {
db.usage = Alpm.DB.Usage.ALL; db.usage = Alpm.DB.Usage.ALL;
@ -272,10 +277,12 @@ public class AlpmConfig {
} else if (key == "LogFile") { } else if (key == "LogFile") {
logfile = val; logfile = val;
} else if (key == "Architecture") { } else if (key == "Architecture") {
if (val == "auto") { foreach (unowned string arch in val.split (" ")) {
arch = Posix.utsname ().machine; if (val == "auto") {
} else { architectures.append (Posix.utsname ().machine);
arch = val; } else {
architectures.append (arch);
}
} }
} else if (key == "UseSysLog") { } else if (key == "UseSysLog") {
usesyslog = 1; usesyslog = 1;

View File

@ -27,7 +27,7 @@ namespace Pamac {
class ChooseIgnorepkgsDialog : Gtk.Dialog { class ChooseIgnorepkgsDialog : Gtk.Dialog {
[GtkChild] [GtkChild]
public Gtk.TreeView treeview; public unowned Gtk.TreeView treeview;
public Gtk.ListStore pkgs_list; public Gtk.ListStore pkgs_list;

View File

@ -26,11 +26,11 @@ namespace Pamac {
class ProgressDialog : Gtk.ApplicationWindow { class ProgressDialog : Gtk.ApplicationWindow {
[GtkChild] [GtkChild]
public Gtk.Box box; public unowned Gtk.Box box;
[GtkChild] [GtkChild]
public Gtk.Button close_button; public unowned Gtk.Button close_button;
[GtkChild] [GtkChild]
public Gtk.Expander expander; public unowned Gtk.Expander expander;
public ProgressDialog () { public ProgressDialog () {
Object (); Object ();

View File

@ -26,7 +26,7 @@ namespace Pamac {
class HistoryDialog : Gtk.Dialog { class HistoryDialog : Gtk.Dialog {
[GtkChild] [GtkChild]
public Gtk.TextView textview; public unowned Gtk.TextView textview;
public HistoryDialog (Gtk.ApplicationWindow window) { public HistoryDialog (Gtk.ApplicationWindow window) {
int use_header_bar; int use_header_bar;

View File

@ -53,88 +53,88 @@ namespace Pamac {
// manager objects // manager objects
[GtkChild] [GtkChild]
public Gtk.Stack main_stack; public unowned Gtk.Stack main_stack;
[GtkChild] [GtkChild]
Gtk.Button button_back; unowned Gtk.Button button_back;
[GtkChild] [GtkChild]
Gtk.MenuButton button_menu; unowned Gtk.MenuButton button_menu;
#if ENABLE_HAMBURGER #if ENABLE_HAMBURGER
[GtkChild] [GtkChild]
Gtk.ModelButton preferences_button; unowned Gtk.ModelButton preferences_button;
#else #else
[GtkChild] [GtkChild]
Gtk.HeaderBar headerbar; unowned Gtk.HeaderBar headerbar;
#endif #endif
[GtkChild] [GtkChild]
Gtk.TreeView packages_treeview; unowned Gtk.TreeView packages_treeview;
[GtkChild] [GtkChild]
Gtk.TreeViewColumn packages_state_column; unowned Gtk.TreeViewColumn packages_state_column;
#if DISABLE_AUR #if DISABLE_AUR
[GtkChild] [GtkChild]
Gtk.ScrolledWindow aur_scrolledwindow; unowned Gtk.ScrolledWindow aur_scrolledwindow;
#else #else
[GtkChild] [GtkChild]
Gtk.TreeView aur_treeview; unowned Gtk.TreeView aur_treeview;
[GtkChild] [GtkChild]
Gtk.TreeViewColumn aur_state_column; unowned Gtk.TreeViewColumn aur_state_column;
#endif #endif
[GtkChild] [GtkChild]
public Gtk.Stack filters_stack; public unowned Gtk.Stack filters_stack;
[GtkChild] [GtkChild]
Gtk.StackSwitcher filters_stackswitcher; unowned Gtk.StackSwitcher filters_stackswitcher;
[GtkChild] [GtkChild]
Gtk.SearchEntry search_entry; unowned Gtk.SearchEntry search_entry;
[GtkChild] [GtkChild]
Gtk.TreeView search_treeview; unowned Gtk.TreeView search_treeview;
[GtkChild] [GtkChild]
Gtk.TreeView groups_treeview; unowned Gtk.TreeView groups_treeview;
[GtkChild] [GtkChild]
Gtk.TreeView states_treeview; unowned Gtk.TreeView states_treeview;
[GtkChild] [GtkChild]
Gtk.TreeView repos_treeview; unowned Gtk.TreeView repos_treeview;
[GtkChild] [GtkChild]
Gtk.Stack packages_stack; unowned Gtk.Stack packages_stack;
[GtkChild] [GtkChild]
Gtk.StackSwitcher packages_stackswitcher; unowned Gtk.StackSwitcher packages_stackswitcher;
[GtkChild] [GtkChild]
Gtk.Label updated_label; unowned Gtk.Label updated_label;
[GtkChild] [GtkChild]
Gtk.Stack properties_stack; unowned Gtk.Stack properties_stack;
#if DISABLE_AUR #if DISABLE_AUR
#else #else
[GtkChild] [GtkChild]
Gtk.StackSwitcher properties_stackswitcher; unowned Gtk.StackSwitcher properties_stackswitcher;
#endif #endif
[GtkChild] [GtkChild]
Gtk.Grid deps_grid; unowned Gtk.Grid deps_grid;
[GtkChild] [GtkChild]
Gtk.Grid details_grid; unowned Gtk.Grid details_grid;
[GtkChild] [GtkChild]
Gtk.ScrolledWindow files_scrolledwindow; unowned Gtk.ScrolledWindow files_scrolledwindow;
[GtkChild] [GtkChild]
Gtk.Label name_label; unowned Gtk.Label name_label;
[GtkChild] [GtkChild]
Gtk.Label desc_label; unowned Gtk.Label desc_label;
[GtkChild] [GtkChild]
Gtk.Label link_label; unowned Gtk.Label link_label;
[GtkChild] [GtkChild]
Gtk.Label licenses_label; unowned Gtk.Label licenses_label;
[GtkChild] [GtkChild]
Gtk.ToggleButton remove_togglebutton; unowned Gtk.ToggleButton remove_togglebutton;
[GtkChild] [GtkChild]
Gtk.ToggleButton reinstall_togglebutton; unowned Gtk.ToggleButton reinstall_togglebutton;
[GtkChild] [GtkChild]
Gtk.ToggleButton install_togglebutton; unowned Gtk.ToggleButton install_togglebutton;
[GtkChild] [GtkChild]
Gtk.TextView files_textview; unowned Gtk.TextView files_textview;
[GtkChild] [GtkChild]
Gtk.Box transaction_infobox; unowned Gtk.Box transaction_infobox;
[GtkChild] [GtkChild]
Gtk.Button details_button; unowned Gtk.Button details_button;
[GtkChild] [GtkChild]
Gtk.Button apply_button; unowned Gtk.Button apply_button;
[GtkChild] [GtkChild]
Gtk.Button cancel_button; unowned Gtk.Button cancel_button;
// menu // menu
Gtk.Menu right_click_menu; Gtk.Menu right_click_menu;

View File

@ -183,12 +183,12 @@ namespace Pamac {
trans_commit_finished (false); trans_commit_finished (false);
return; return;
} else { } else {
alpm_handle.eventcb = (Alpm.EventCallBack) cb_event; alpm_handle.set_eventcb((Alpm.EventCallBack) cb_event, null);
alpm_handle.progresscb = (Alpm.ProgressCallBack) cb_progress; alpm_handle.set_progresscb((Alpm.ProgressCallBack) cb_progress, null);
alpm_handle.questioncb = (Alpm.QuestionCallBack) cb_question; alpm_handle.set_questioncb((Alpm.QuestionCallBack) cb_question, null);
alpm_handle.fetchcb = (Alpm.FetchCallBack) cb_fetch; alpm_handle.set_fetchcb((Alpm.FetchCallBack) cb_fetch, null);
alpm_handle.totaldlcb = (Alpm.TotalDownloadCallBack) cb_totaldownload; alpm_handle.set_dlcb((Alpm.DownloadCallBack) cb_download, null);
alpm_handle.logcb = (Alpm.LogCallBack) cb_log; alpm_handle.set_logcb((Alpm.LogCallBack) cb_log, null);
lockfile = GLib.File.new_for_path (alpm_handle.lockfile); lockfile = GLib.File.new_for_path (alpm_handle.lockfile);
var pamac_config = new Pamac.Config (); var pamac_config = new Pamac.Config ();
if (pamac_config.update_files_db) { if (pamac_config.update_files_db) {
@ -196,12 +196,12 @@ namespace Pamac {
} else { } else {
files_handle = alpm_config.get_handle (false); files_handle = alpm_config.get_handle (false);
} }
files_handle.eventcb = (Alpm.EventCallBack) cb_event; files_handle.set_eventcb((Alpm.EventCallBack) cb_event, null);
files_handle.progresscb = (Alpm.ProgressCallBack) cb_progress; files_handle.set_progresscb((Alpm.ProgressCallBack) cb_progress, null);
files_handle.questioncb = (Alpm.QuestionCallBack) cb_question; files_handle.set_questioncb((Alpm.QuestionCallBack) cb_question, null);
files_handle.fetchcb = (Alpm.FetchCallBack) cb_fetch; files_handle.set_fetchcb((Alpm.FetchCallBack) cb_fetch, null);
files_handle.totaldlcb = (Alpm.TotalDownloadCallBack) cb_totaldownload; files_handle.set_dlcb((Alpm.DownloadCallBack) cb_download, null);
files_handle.logcb = (Alpm.LogCallBack) cb_log; files_handle.set_logcb((Alpm.LogCallBack) cb_log, null);
} }
} }
@ -475,26 +475,19 @@ namespace Pamac {
private bool update_dbs (Alpm.Handle handle, int force) { private bool update_dbs (Alpm.Handle handle, int force) {
bool success = false; bool success = false;
unowned Alpm.List<unowned Alpm.DB> syncdbs = handle.syncdbs; unowned Alpm.List<unowned Alpm.DB> syncdbs = handle.syncdbs;
while (syncdbs != null) { if (handle.update_dbs (syncdbs, force) >= 0) {
if (cancellable.is_cancelled ()) { // We should always succeed if at least one DB was upgraded - we may possibly
break; // fail later with unresolved deps, but that should be rare, and would be expected
} success = true;
unowned Alpm.DB db = syncdbs.data; } else {
if (db.update (force) >= 0) { Alpm.Errno errnos = handle.errno ();
// We should always succeed if at least one DB was upgraded - we may possibly current_error.errnos = (uint) errnos;
// fail later with unresolved deps, but that should be rare, and would be expected if (errnos != 0) {
success = true; // download error details are set in cb_fetch
} else { if (errnos != Alpm.Errno.EXTERNAL_DOWNLOAD) {
Alpm.Errno errnos = handle.errno (); current_error.details = { Alpm.strerror (errnos) };
current_error.errnos = (uint) errnos;
if (errnos != 0) {
// download error details are set in cb_fetch
if (errnos != Alpm.Errno.EXTERNAL_DOWNLOAD) {
current_error.details = { Alpm.strerror (errnos) };
}
} }
} }
syncdbs.next ();
} }
return success; return success;
} }
@ -1268,7 +1261,7 @@ namespace Pamac {
}; };
trans_commit_finished (false); trans_commit_finished (false);
} else { } else {
alpm_handle.questioncb = (Alpm.QuestionCallBack) cb_question; alpm_handle.set_questioncb((Alpm.QuestionCallBack) cb_question, null);
lockfile = GLib.File.new_for_path (alpm_handle.lockfile); lockfile = GLib.File.new_for_path (alpm_handle.lockfile);
// fake aur db // fake aur db
alpm_handle.register_syncdb ("aur", 0); alpm_handle.register_syncdb ("aur", 0);
@ -1720,7 +1713,7 @@ private void write_log_file (string event) {
} }
} }
private void cb_event (Alpm.Event.Data data) { private void cb_event (void *ctx, Alpm.Event.Data data) {
string[] details = {}; string[] details = {};
uint secondary_type = 0; uint secondary_type = 0;
switch (data.type) { switch (data.type) {
@ -1778,13 +1771,14 @@ private void cb_event (Alpm.Event.Data data) {
case Alpm.Event.Type.SCRIPTLET_INFO: case Alpm.Event.Type.SCRIPTLET_INFO:
details += data.scriptlet_info_line; details += data.scriptlet_info_line;
break; break;
case Alpm.Event.Type.PKGDOWNLOAD_START: case Alpm.Event.Type.PKG_RETRIEVE_START:
// do not emit event when download is cancelled // do not emit event when download is cancelled
if (system_daemon.cancellable.is_cancelled ()) { if (system_daemon.cancellable.is_cancelled ()) {
return; return;
} }
details += data.pkgdownload_file; system_daemon.emit_totaldownload (data.pkg_retrieve_total_size);
break; // event will be emitted by cb_fetch
return;
case Alpm.Event.Type.OPTDEP_REMOVAL: case Alpm.Event.Type.OPTDEP_REMOVAL:
details += data.optdep_removal_pkg.name; details += data.optdep_removal_pkg.name;
details += data.optdep_removal_optdep.compute_string (); details += data.optdep_removal_optdep.compute_string ();
@ -1804,7 +1798,7 @@ private void cb_event (Alpm.Event.Data data) {
system_daemon.emit_event ((uint) data.type, secondary_type, details); system_daemon.emit_event ((uint) data.type, secondary_type, details);
} }
private void cb_question (Alpm.Question.Data data) { private void cb_question (void *ctx, Alpm.Question.Data data) {
switch (data.type) { switch (data.type) {
case Alpm.Question.Type.INSTALL_IGNOREPKG: case Alpm.Question.Type.INSTALL_IGNOREPKG:
// Do not install package in IgnorePkg/IgnoreGroup // Do not install package in IgnorePkg/IgnoreGroup
@ -1861,7 +1855,7 @@ private void cb_question (Alpm.Question.Data data) {
} }
} }
private void cb_progress (Alpm.Progress progress, string pkgname, int percent, uint n_targets, uint current_target) { private void cb_progress (void *ctx, Alpm.Progress progress, string pkgname, int percent, uint n_targets, uint current_target) {
if (percent == 0) { if (percent == 0) {
system_daemon.emit_progress ((uint) progress, pkgname, (uint) percent, n_targets, current_target); system_daemon.emit_progress ((uint) progress, pkgname, (uint) percent, n_targets, current_target);
system_daemon.timer.start (); system_daemon.timer.start ();
@ -1878,7 +1872,7 @@ private void cb_progress (Alpm.Progress progress, string pkgname, int percent, u
private uint64 prevprogress; private uint64 prevprogress;
private int cb_download (void* data, uint64 dltotal, uint64 dlnow, uint64 ultotal, uint64 ulnow) { private int cb_curldownload (void* data, uint64 dltotal, uint64 dlnow, uint64 ultotal, uint64 ulnow) {
if (unlikely (system_daemon.cancellable.is_cancelled ())) { if (unlikely (system_daemon.cancellable.is_cancelled ())) {
return 1; return 1;
@ -1907,7 +1901,7 @@ private int cb_download (void* data, uint64 dltotal, uint64 dlnow, uint64 ultota
return 0; return 0;
} }
private int cb_fetch (string fileurl, string localpath, int force) { private int cb_fetch (void *ctx, string fileurl, string localpath, int force) {
if (system_daemon.cancellable.is_cancelled ()) { if (system_daemon.cancellable.is_cancelled ()) {
return -1; return -1;
} }
@ -1917,12 +1911,14 @@ private int cb_fetch (string fileurl, string localpath, int force) {
var destfile = GLib.File.new_for_path (localpath + url.get_basename ()); var destfile = GLib.File.new_for_path (localpath + url.get_basename ());
var tempfile = GLib.File.new_for_path (destfile.get_path () + ".part"); var tempfile = GLib.File.new_for_path (destfile.get_path () + ".part");
system_daemon.emit_event(Alpm.Event.Type.PKG_RETRIEVE_START, 0, {url.get_basename ()});
system_daemon.curl.reset (); system_daemon.curl.reset ();
system_daemon.curl.setopt (Curl.Option.FAILONERROR, 1L); system_daemon.curl.setopt (Curl.Option.FAILONERROR, 1L);
system_daemon.curl.setopt (Curl.Option.CONNECTTIMEOUT, 30L); system_daemon.curl.setopt (Curl.Option.CONNECTTIMEOUT, 30L);
system_daemon.curl.setopt (Curl.Option.FILETIME, 1L); system_daemon.curl.setopt (Curl.Option.FILETIME, 1L);
system_daemon.curl.setopt (Curl.Option.FOLLOWLOCATION, 1L); system_daemon.curl.setopt (Curl.Option.FOLLOWLOCATION, 1L);
system_daemon.curl.setopt (Curl.Option.XFERINFOFUNCTION, cb_download); system_daemon.curl.setopt (Curl.Option.XFERINFOFUNCTION, cb_curldownload);
system_daemon.curl.setopt (Curl.Option.LOW_SPEED_LIMIT, 1L); system_daemon.curl.setopt (Curl.Option.LOW_SPEED_LIMIT, 1L);
system_daemon.curl.setopt (Curl.Option.LOW_SPEED_TIME, 30L); system_daemon.curl.setopt (Curl.Option.LOW_SPEED_TIME, 30L);
system_daemon.curl.setopt (Curl.Option.NETRC, Curl.NetRCOption.OPTIONAL); system_daemon.curl.setopt (Curl.Option.NETRC, Curl.NetRCOption.OPTIONAL);
@ -1946,8 +1942,8 @@ private int cb_fetch (string fileurl, string localpath, int force) {
// start from scratch only download if our local is out of date. // start from scratch only download if our local is out of date.
system_daemon.curl.setopt (Curl.Option.TIMECONDITION, Curl.TimeCond.IFMODSINCE); system_daemon.curl.setopt (Curl.Option.TIMECONDITION, Curl.TimeCond.IFMODSINCE);
FileInfo info = destfile.query_info ("time::modified", 0); FileInfo info = destfile.query_info ("time::modified", 0);
TimeVal time = info.get_modification_time (); DateTime time = info.get_modification_date_time ();
system_daemon.curl.setopt (Curl.Option.TIMEVALUE, time.tv_sec); system_daemon.curl.setopt (Curl.Option.TIMEVALUE, time.to_unix());
} else if (tempfile.query_exists ()) { } else if (tempfile.query_exists ()) {
// a previous partial download exists, resume from end of file. // a previous partial download exists, resume from end of file.
FileInfo info = tempfile.query_info ("standard::size", 0); FileInfo info = tempfile.query_info ("standard::size", 0);
@ -2082,11 +2078,13 @@ private int cb_fetch (string fileurl, string localpath, int force) {
return ret; return ret;
} }
private void cb_totaldownload (uint64 total) { private void cb_download (void* ctx, string filename, Alpm.Download.Event event_type, void* event_data) {
system_daemon.emit_totaldownload (total); if (event_type == Alpm.Download.Event.COMPLETED) {
system_daemon.emit_totaldownload (((Alpm.Download.Completed) event_data).total);
}
} }
private void cb_log (Alpm.LogLevel level, string fmt, va_list args) { private void cb_log (void *ctx, Alpm.LogLevel level, string fmt, va_list args) {
// do not log errors when download is cancelled // do not log errors when download is cancelled
if (system_daemon.cancellable.is_cancelled ()) { if (system_daemon.cancellable.is_cancelled ()) {
return; return;

View File

@ -214,9 +214,9 @@ namespace Pamac {
unowned Alpm.Package alpm_pkg = pkgcache.data; unowned Alpm.Package alpm_pkg = pkgcache.data;
if (alpm_pkg.reason == Alpm.Package.Reason.DEPEND) { if (alpm_pkg.reason == Alpm.Package.Reason.DEPEND) {
Alpm.List<string> requiredby = alpm_pkg.compute_requiredby (); Alpm.List<string> requiredby = alpm_pkg.compute_requiredby ();
if (requiredby.length == 0) { if (requiredby.length () == 0) {
Alpm.List<string> optionalfor = alpm_pkg.compute_optionalfor (); Alpm.List<string> optionalfor = alpm_pkg.compute_optionalfor ();
if (optionalfor.length == 0) { if (optionalfor.length () == 0) {
pkgs += initialise_pkg_struct (alpm_pkg); pkgs += initialise_pkg_struct (alpm_pkg);
} else { } else {
optionalfor.free_inner (GLib.free); optionalfor.free_inner (GLib.free);
@ -280,22 +280,26 @@ namespace Pamac {
foreach (unowned string part in splitted) { foreach (unowned string part in splitted) {
needles.add (part); needles.add (part);
} }
Alpm.List<unowned Alpm.Package> result = alpm_handle.localdb.search (needles); Alpm.List<unowned Alpm.Package> result;
// TODO: handle return value
alpm_handle.localdb.search (needles, out result);
Alpm.List<unowned Alpm.Package> syncpkgs = null; Alpm.List<unowned Alpm.Package> syncpkgs = null;
unowned Alpm.List<unowned Alpm.DB> syncdbs = alpm_handle.syncdbs; unowned Alpm.List<unowned Alpm.DB> syncdbs = alpm_handle.syncdbs;
while (syncdbs != null) { while (syncdbs != null) {
unowned Alpm.DB db = syncdbs.data; unowned Alpm.DB db = syncdbs.data;
if (syncpkgs.length == 0) { if (syncpkgs.length () == 0) {
syncpkgs = db.search (needles); db.search (needles, out syncpkgs);
} else { } else {
syncpkgs.join (db.search (needles).diff (syncpkgs, (Alpm.List.CompareFunc) alpm_pkg_compare_name)); Alpm.List<unowned Alpm.Package> newsyncpkgs = null;
db.search (needles, out newsyncpkgs);
syncpkgs.join (newsyncpkgs.diff (syncpkgs, (Alpm.List.CompareFunc) alpm_pkg_compare_name));
} }
syncdbs.next (); syncdbs.next ();
} }
result.join (syncpkgs.diff (result, (Alpm.List.CompareFunc) alpm_pkg_compare_name)); result.join (syncpkgs.diff (result, (Alpm.List.CompareFunc) alpm_pkg_compare_name));
// use custom sort function // use custom sort function
global_search_string = search_string; global_search_string = search_string;
result.sort (result.length, (Alpm.List.CompareFunc) alpm_pkg_sort_search_by_relevance); result.sort (result.length (), (Alpm.List.CompareFunc) alpm_pkg_sort_search_by_relevance);
return result; return result;
} }
@ -828,29 +832,18 @@ namespace Pamac {
var tmp_handle = alpm_config.get_handle (false, true); var tmp_handle = alpm_config.get_handle (false, true);
// refresh tmp dbs // refresh tmp dbs
unowned Alpm.List<unowned Alpm.DB> syncdbs = tmp_handle.syncdbs; unowned Alpm.List<unowned Alpm.DB> syncdbs = tmp_handle.syncdbs;
while (syncdbs != null) { // TODO: read return value
unowned Alpm.DB db = syncdbs.data; tmp_handle.update_dbs(syncdbs, 0);
db.update (0);
syncdbs.next ();
}
// refresh file dbs // refresh file dbs
var pamac_config = new Pamac.Config (); var pamac_config = new Pamac.Config ();
if (pamac_config.update_files_db) { if (pamac_config.update_files_db) {
var tmp_files_handle = alpm_config.get_handle (true, true); var tmp_files_handle = alpm_config.get_handle (true, true);
syncdbs = tmp_files_handle.syncdbs; syncdbs = tmp_files_handle.syncdbs;
while (syncdbs != null) { tmp_files_handle.update_dbs(syncdbs, 0);
unowned Alpm.DB db = syncdbs.data;
db.update (0);
syncdbs.next ();
}
} else { } else {
var tmp_files_handle = alpm_config.get_handle (false, true); var tmp_files_handle = alpm_config.get_handle (false, true);
syncdbs = tmp_files_handle.syncdbs; syncdbs = tmp_files_handle.syncdbs;
while (syncdbs != null) { tmp_files_handle.update_dbs(syncdbs, 0);
unowned Alpm.DB db = syncdbs.data;
db.update (0);
syncdbs.next ();
}
} }
#if DISABLE_AUR #if DISABLE_AUR
#else #else

View File

@ -24,60 +24,60 @@ namespace Pamac {
class PreferencesDialog : Gtk.Dialog { class PreferencesDialog : Gtk.Dialog {
[GtkChild] [GtkChild]
Gtk.Switch remove_unrequired_deps_button; unowned Gtk.Switch remove_unrequired_deps_button;
[GtkChild] [GtkChild]
Gtk.Switch update_files_db_button; unowned Gtk.Switch update_files_db_button;
[GtkChild] [GtkChild]
Gtk.Switch check_space_button; unowned Gtk.Switch check_space_button;
[GtkChild] [GtkChild]
Gtk.Switch check_updates_button; unowned Gtk.Switch check_updates_button;
[GtkChild] [GtkChild]
Gtk.Label refresh_period_label; unowned Gtk.Label refresh_period_label;
[GtkChild] [GtkChild]
Gtk.SpinButton refresh_period_spin_button; unowned Gtk.SpinButton refresh_period_spin_button;
[GtkChild] [GtkChild]
Gtk.CheckButton no_update_hide_icon_checkbutton; unowned Gtk.CheckButton no_update_hide_icon_checkbutton;
[GtkChild] [GtkChild]
Gtk.Box ignorepkgs_box; unowned Gtk.Box ignorepkgs_box;
[GtkChild] [GtkChild]
Gtk.TreeView ignorepkgs_treeview; unowned Gtk.TreeView ignorepkgs_treeview;
[GtkChild] [GtkChild]
Gtk.Box mirrors_config_box; unowned Gtk.Box mirrors_config_box;
[GtkChild] [GtkChild]
Gtk.ComboBoxText mirrors_country_comboboxtext; unowned Gtk.ComboBoxText mirrors_country_comboboxtext;
[GtkChild] [GtkChild]
Gtk.ComboBoxText mirrors_list_generation_method_comboboxtext; unowned Gtk.ComboBoxText mirrors_list_generation_method_comboboxtext;
[GtkChild] [GtkChild]
Gtk.Button generate_mirrors_list_button; unowned Gtk.Button generate_mirrors_list_button;
#if DISABLE_AUR #if DISABLE_AUR
[GtkChild] [GtkChild]
Gtk.Stack stack; unowned Gtk.Stack stack;
[GtkChild] [GtkChild]
Gtk.Box aur_config_box; unowned Gtk.Box aur_config_box;
#else #else
[GtkChild] [GtkChild]
Gtk.Switch enable_aur_button; unowned Gtk.Switch enable_aur_button;
[GtkChild] [GtkChild]
Gtk.CheckButton search_aur_checkbutton; unowned Gtk.CheckButton search_aur_checkbutton;
[GtkChild] [GtkChild]
Gtk.Label aur_build_dir_label; unowned Gtk.Label aur_build_dir_label;
[GtkChild] [GtkChild]
Gtk.FileChooserButton aur_build_dir_file_chooser; unowned Gtk.FileChooserButton aur_build_dir_file_chooser;
[GtkChild] [GtkChild]
Gtk.CheckButton check_aur_updates_checkbutton; unowned Gtk.CheckButton check_aur_updates_checkbutton;
#endif #endif
[GtkChild] [GtkChild]
Gtk.Label cache_keep_nb_label; unowned Gtk.Label cache_keep_nb_label;
[GtkChild] [GtkChild]
Gtk.SpinButton cache_keep_nb_spin_button; unowned Gtk.SpinButton cache_keep_nb_spin_button;
[GtkChild] [GtkChild]
Gtk.CheckButton cache_only_uninstalled_checkbutton; unowned Gtk.CheckButton cache_only_uninstalled_checkbutton;
[GtkChild] [GtkChild]
Gtk.ColorButton terminal_background; unowned Gtk.ColorButton terminal_background;
[GtkChild] [GtkChild]
Gtk.ColorButton terminal_foreground; unowned Gtk.ColorButton terminal_foreground;
[GtkChild] [GtkChild]
Gtk.FontButton terminal_font; unowned Gtk.FontButton terminal_font;
Gtk.ListStore ignorepkgs_liststore; Gtk.ListStore ignorepkgs_liststore;
Transaction transaction; Transaction transaction;

View File

@ -26,9 +26,9 @@ namespace Pamac {
public class ProgressBox : Gtk.Box { public class ProgressBox : Gtk.Box {
[GtkChild] [GtkChild]
public Gtk.ProgressBar progressbar; public unowned Gtk.ProgressBar progressbar;
[GtkChild] [GtkChild]
public Gtk.Label action_label; public unowned Gtk.Label action_label;
public ProgressBox () { public ProgressBox () {
Object (); Object ();

View File

@ -1548,15 +1548,15 @@ namespace Pamac {
detailed_action = details[0].replace ("\n", ""); detailed_action = details[0].replace ("\n", "");
important_details_outpout (false); important_details_outpout (false);
break; break;
case Alpm.Event.Type.RETRIEVE_START: case Alpm.Event.Type.DB_RETRIEVE_START:
start_downloading (); start_downloading ();
action = dgettext (null, "Downloading") + "..."; action = dgettext (null, "Downloading") + "...";
break; break;
case Alpm.Event.Type.RETRIEVE_DONE: case Alpm.Event.Type.DB_RETRIEVE_DONE:
case Alpm.Event.Type.RETRIEVE_FAILED: case Alpm.Event.Type.DB_RETRIEVE_FAILED:
stop_downloading (); stop_downloading ();
break; break;
case Alpm.Event.Type.PKGDOWNLOAD_START: case Alpm.Event.Type.PKG_RETRIEVE_START:
// special case handle differently // special case handle differently
show_in_term (dgettext (null, "Downloading %s").printf (details[0]) + "..."); show_in_term (dgettext (null, "Downloading %s").printf (details[0]) + "...");
string name_version_release = details[0].slice (0, details[0].last_index_of_char ('-')); string name_version_release = details[0].slice (0, details[0].last_index_of_char ('-'));

View File

@ -26,9 +26,9 @@ namespace Pamac {
class TransactionSumDialog : Gtk.Dialog { class TransactionSumDialog : Gtk.Dialog {
[GtkChild] [GtkChild]
public Gtk.Label top_label; public unowned Gtk.Label top_label;
[GtkChild] [GtkChild]
Gtk.TreeView treeview; unowned Gtk.TreeView treeview;
public Gtk.ListStore sum_list; public Gtk.ListStore sum_list;

View File

@ -1,7 +1,7 @@
/* /*
* Vala bindings for libalpm * Vala bindings for libalpm
* *
* Copyright (C) 2014-2019 Guillaume Benoit <guillaume@manjaro.org> * Copyright (C) 2014-2020 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (c) 2011 Rémy Oudompheng <remy@archlinux.org> * Copyright (c) 2011 Rémy Oudompheng <remy@archlinux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -23,7 +23,7 @@ namespace Alpm {
[SimpleType] [SimpleType]
[CCode (cname = "alpm_time_t", has_type_id = false)] [CCode (cname = "alpm_time_t", has_type_id = false)]
public struct Time : uint64 {} public struct Time : int64 {}
/** /**
* Library * Library
@ -65,13 +65,20 @@ namespace Alpm {
public unowned string root { public unowned string root {
[CCode (cname = "alpm_option_get_root")] get; [CCode (cname = "alpm_option_get_root")] get;
} }
public unowned string dbpath { public unowned string dbpath {
[CCode (cname = "alpm_option_get_dbpath")] get; [CCode (cname = "alpm_option_get_dbpath")] get;
} }
public unowned string arch {
[CCode (cname = "alpm_option_get_arch")] get; public unowned Alpm.List<unowned string> architectures {
[CCode (cname = "alpm_option_set_arch")] set; [CCode (cname = "alpm_option_get_architectures")] get;
[CCode (cname = "alpm_option_set_architectures")] set;
} }
[CCode (cname = "alpm_option_add_architecture")]
public int add_architecture(string path);
[CCode (cname = "alpm_option_remove_architecture")]
public int remove_architecture(string path);
public unowned Alpm.List<unowned string> cachedirs { public unowned Alpm.List<unowned string> cachedirs {
[CCode (cname = "alpm_option_get_cachedirs")] get; [CCode (cname = "alpm_option_get_cachedirs")] get;
[CCode (cname = "alpm_option_set_cachedirs")] set; [CCode (cname = "alpm_option_set_cachedirs")] set;
@ -103,18 +110,22 @@ namespace Alpm {
[CCode (cname = "alpm_option_get_logfile")] get; [CCode (cname = "alpm_option_get_logfile")] get;
[CCode (cname = "alpm_option_set_logfile")] set; [CCode (cname = "alpm_option_set_logfile")] set;
} }
public unowned string lockfile { public unowned string lockfile {
[CCode (cname = "alpm_option_get_lockfile")] get; [CCode (cname = "alpm_option_get_lockfile")] get;
} }
public unowned string gpgdir { public unowned string gpgdir {
[CCode (cname = "alpm_option_get_gpgdir")] get; [CCode (cname = "alpm_option_get_gpgdir")] get;
[CCode (cname = "alpm_option_set_gpgdir")] set; [CCode (cname = "alpm_option_set_gpgdir")] set;
} }
public int usesyslog { public int usesyslog {
[CCode (cname = "alpm_option_get_usesyslog")] get; [CCode (cname = "alpm_option_get_usesyslog")] get;
/** Sets whether to use syslog (0 is FALSE, TRUE otherwise). */ /** Sets whether to use syslog (0 is FALSE, TRUE otherwise). */
[CCode (cname = "alpm_option_set_usesyslog")] set; [CCode (cname = "alpm_option_set_usesyslog")] set;
} }
public unowned Alpm.List<unowned string> noupgrades { public unowned Alpm.List<unowned string> noupgrades {
[CCode (cname = "alpm_option_get_noupgrades")] get; [CCode (cname = "alpm_option_get_noupgrades")] get;
[CCode (cname = "alpm_option_set_noupgrades")] set; [CCode (cname = "alpm_option_set_noupgrades")] set;
@ -150,7 +161,7 @@ namespace Alpm {
} }
[CCode (cname = "alpm_option_add_ignoregroup")] [CCode (cname = "alpm_option_add_ignoregroup")]
public int add_ignoregroup(string grp); public int add_ignoregroup(string grp);
[CCode (cname = "alpm_option_remove_ignorepkg")] [CCode (cname = "alpm_option_remove_ignoregroup")]
public int remove_ignoregroup(string grp); public int remove_ignoregroup(string grp);
public unowned Alpm.List<unowned Depend> assumeinstalled { public unowned Alpm.List<unowned Depend> assumeinstalled {
@ -172,6 +183,11 @@ namespace Alpm {
[CCode (cname = "alpm_option_set_dbext")] set; [CCode (cname = "alpm_option_set_dbext")] set;
} }
public uint parallel_downloads {
[CCode (cname = "alpm_option_get_parallel_downloads")] get;
[CCode (cname = "alpm_option_set_parallel_downloads")] set;
}
public int defaultsiglevel { public int defaultsiglevel {
[CCode (cname = "alpm_option_get_default_siglevel")] get; [CCode (cname = "alpm_option_get_default_siglevel")] get;
[CCode (cname = "alpm_option_set_default_siglevel")] set; [CCode (cname = "alpm_option_set_default_siglevel")] set;
@ -192,33 +208,56 @@ namespace Alpm {
[CCode (cname = "alpm_get_syncdbs")] get; [CCode (cname = "alpm_get_syncdbs")] get;
} }
public LogCallBack logcb { [CCode (cname = "alpm_option_get_logcb")]
[CCode (cname = "alpm_option_get_logcb")] get; public LogCallBack get_logcb();
[CCode (cname = "alpm_option_set_logcb")] set; [CCode (cname = "alpm_option_set_logcb")]
} public int set_logcb(LogCallBack? logcb, void* ctx);
public DownloadCallBack dlcb { [CCode (cname = "alpm_option_get_logcb_ctx")]
[CCode (cname = "alpm_option_get_dlcb")] get; public void* get_logcb_ctx();
[CCode (cname = "alpm_option_set_dlcb")] set;
} [CCode (cname = "alpm_option_get_dlcb")]
public FetchCallBack fetchcb { public DownloadCallBack get_dlcb();
[CCode (cname = "alpm_option_get_fetchcb")] get; [CCode (cname = "alpm_option_set_dlcb")]
[CCode (cname = "alpm_option_set_fetchcb")] set; public int set_dlcb(DownloadCallBack? dlcb, void* ctx);
} [CCode (cname = "alpm_option_get_dlcb_ctx")]
public TotalDownloadCallBack totaldlcb { public void* get_dlcb_ctx();
[CCode (cname = "alpm_option_get_totaldlcb")] get;
[CCode (cname = "alpm_option_set_totaldlcb")] set; [CCode (cname = "alpm_option_get_fetchcb")]
} public FetchCallBack get_fetchcb();
public EventCallBack eventcb { [CCode (cname = "alpm_option_set_fetchcb")]
[CCode (cname = "alpm_option_get_eventcb")] get; public int set_fetchcb(FetchCallBack? fetchcb, void* ctx);
[CCode (cname = "alpm_option_set_eventcb")] set; [CCode (cname = "alpm_option_get_fetchcb_ctx")]
} public void* get_fetchcb_ctx();
public QuestionCallBack questioncb {
[CCode (cname = "alpm_option_get_questioncb")] get; [CCode (cname = "alpm_option_get_eventcb")]
[CCode (cname = "alpm_option_set_questioncb")] set; public EventCallBack get_eventcb();
} [CCode (cname = "alpm_option_set_eventcb")]
public ProgressCallBack progresscb { public int set_eventcb(EventCallBack? eventcb, void* ctx);
[CCode (cname = "alpm_option_get_progresscb")] get; [CCode (cname = "alpm_option_get_eventcb_ctx")]
[CCode (cname = "alpm_option_set_progresscb")] set; public void* get_eventcb_ctx();
[CCode (cname = "alpm_option_get_questioncb")]
public QuestionCallBack get_questioncb();
[CCode (cname = "alpm_option_set_questioncb")]
public int set_questioncb(QuestionCallBack? questioncb, void* ctx);
[CCode (cname = "alpm_option_get_questioncb_ctx")]
public void* get_questioncb_ctx();
[CCode (cname = "alpm_option_get_progresscb")]
public ProgressCallBack get_progresscb();
[CCode (cname = "alpm_option_set_progresscb")]
public int set_progresscb(ProgressCallBack? progresscb, void* ctx);
[CCode (cname = "alpm_option_get_progresscb_ctx")]
public void* get_progresscb_ctx();
/** Enables/disables the download timeout.
* By default, libalpm will timeout if a download has been transferring
* less than 1 byte for 10 seconds.
* @param disable_dl_timeout 0 for enabled, 1 for disabled
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
public uint disable_dl_timeout {
[CCode (cname = "alpm_option_set_disable_dl_timeout")] set;
} }
[CCode (cname = "alpm_unlock")] [CCode (cname = "alpm_unlock")]
@ -229,6 +268,15 @@ namespace Alpm {
[CCode (cname = "alpm_unregister_all_syncdbs")] [CCode (cname = "alpm_unregister_all_syncdbs")]
public int unregister_all_syncdbs(); public int unregister_all_syncdbs();
/** Update package databases.
* @param dbs list of package databases to update
* @param force if true, then forces the update, otherwise update only in case
* the databases aren't up to date
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
[CCode (cname = "alpm_db_update")]
public int update_dbs(Alpm.List<unowned DB> dbs, int force);
// the return package can be freed except if it is added to a transaction, // the return package can be freed except if it is added to a transaction,
// it will be freed upon Handle.trans_release() invocation. // it will be freed upon Handle.trans_release() invocation.
[CCode (cname = "alpm_pkg_load")] [CCode (cname = "alpm_pkg_load")]
@ -243,8 +291,16 @@ namespace Alpm {
[CCode (cname = "alpm_pkg_should_ignore")] [CCode (cname = "alpm_pkg_should_ignore")]
public int should_ignore(Package pkg); public int should_ignore(Package pkg);
/** Fetch a list of remote packages.
* @param urls list of package URLs to download
* @param fetched list of filepaths to the fetched packages, each item
* corresponds to one in `urls` list. This is an output parameter,
* the caller should provide a pointer to an empty list
* and the callee fills the list with data.
* @return 0 on success or -1 on failure
*/
[CCode (cname = "alpm_fetch_pkgurl")] [CCode (cname = "alpm_fetch_pkgurl")]
public string? fetch_pkgurl(string url); public int fetch_pkgurl(Alpm.List<string> urls, out Alpm.List<string> fetched);
[CCode (cname = "alpm_find_dbs_satisfier")] [CCode (cname = "alpm_find_dbs_satisfier")]
public unowned Package? find_dbs_satisfier(Alpm.List<unowned DB> dbs, string depstring); public unowned Package? find_dbs_satisfier(Alpm.List<unowned DB> dbs, string depstring);
@ -370,12 +426,9 @@ namespace Alpm {
public int add_server(string url); public int add_server(string url);
public int remove_server(string url); public int remove_server(string url);
[CCode (instance_pos = 1.1)]
public int update(int force);
public unowned Package? get_pkg(string name); public unowned Package? get_pkg(string name);
public unowned Group? get_group(string name); public unowned Group? get_group(string name);
public Alpm.List<unowned Package> search(Alpm.List<unowned string> needles); public int search(Alpm.List<unowned string> needles, out Alpm.List<unowned Package> ret);
public int check_pgp_signature(out SigList siglist); public int check_pgp_signature(out SigList siglist);
} }
@ -460,10 +513,10 @@ namespace Alpm {
[CCode (cname = "alpm_pkg_get_optdepends")] get; [CCode (cname = "alpm_pkg_get_optdepends")] get;
} }
public unowned Alpm.List<unowned Depend> checkdepends { public unowned Alpm.List<unowned Depend> checkdepends {
[CCode (cname = "alpm_pkg_get_depends")] get; [CCode (cname = "alpm_pkg_get_checkdepends")] get;
} }
public unowned Alpm.List<unowned Depend> makedepends { public unowned Alpm.List<unowned Depend> makedepends {
[CCode (cname = "alpm_pkg_get_optdepends")] get; [CCode (cname = "alpm_pkg_get_makedepends")] get;
} }
public unowned Alpm.List<unowned Depend> conflicts { public unowned Alpm.List<unowned Depend> conflicts {
[CCode (cname = "alpm_pkg_get_conflicts")] get; [CCode (cname = "alpm_pkg_get_conflicts")] get;
@ -755,9 +808,18 @@ namespace Alpm {
FUNCTION = (1 << 3) FUNCTION = (1 << 3)
} }
/** Log callback */ /** The callback type for logging.
*
* libalpm will call this function whenever something is to be logged.
* many libalpm will produce log output. Additionally any calls to \link alpm_logaction
* \endlink will also call this callback.
* @param ctx user-provided context
* @param level the currently set loglevel
* @param fmt the printf like format string
* @param args printf like arguments
*/
[CCode (cname = "alpm_cb_log", has_type_id = false, has_target = false)] [CCode (cname = "alpm_cb_log", has_type_id = false, has_target = false)]
public delegate void LogCallBack(LogLevel level, string fmt, va_list args); public delegate void LogCallBack(void* ctx, LogLevel level, string fmt, va_list args);
namespace Event { namespace Event {
/** /**
@ -802,21 +864,18 @@ namespace Alpm {
/** Scriptlet has printed information; See ScriptletInfo for /** Scriptlet has printed information; See ScriptletInfo for
* arguments. */ * arguments. */
SCRIPTLET_INFO, SCRIPTLET_INFO,
/** Files will be downloaded from a repository. */ /** Database files will be downloaded from a repository. */
RETRIEVE_START, DB_RETRIEVE_START,
/** Files were downloaded from a repository. */ /** Database files were downloaded from a repository. */
RETRIEVE_DONE, DB_RETRIEVE_DONE,
/** Not all files were successfully downloaded from a repository. */ /** Not all database files were successfully downloaded from a repository. */
RETRIEVE_FAILED, DB_RETRIEVE_FAILED,
/** A file will be downloaded from a repository; See PkgDownload /** Package files will be downloaded from a repository. */
* for arguments */ PKG_RETRIEVE_START,
PKGDOWNLOAD_START, /** Package files were downloaded from a repository. */
/** A file was downloaded from a repository; See PkgDownload PKG_RETRIEVE_DONE,
* for arguments */ /** Not all package files were successfully downloaded from a repository. */
PKGDOWNLOAD_DONE, PKG_RETRIEVE_FAILED,
/** A file failed to be downloaded from a repository; See
* PkgDownload for arguments */
PKGDOWNLOAD_FAILED,
/** Disk space usage will be computed for a package. */ /** Disk space usage will be computed for a package. */
DISKSPACE_START, DISKSPACE_START,
/** Disk space usage was computed for a package. */ /** Disk space usage was computed for a package. */
@ -958,6 +1017,18 @@ namespace Alpm {
public size_t total; public size_t total;
} }
/** Packages downloading about to start. */
[CCode (cname = "alpm_event_pkg_retrieve_t", has_type_id = false)]
[Compact]
public class PkgRetrieve {
/** Type of event */
public Type type;
/** Number of packages to download */
public size_t num;
/** Total size of packages to download */
public uint64 total_size;
}
/** This is an union passed to the callback, that allows the frontend to know /** This is an union passed to the callback, that allows the frontend to know
* which type of event was triggered (via type). It is then possible to * which type of event was triggered (via type). It is then possible to
* typecast the pointer to the right structure, or use the union field, in order * typecast the pointer to the right structure, or use the union field, in order
@ -1014,12 +1085,21 @@ namespace Alpm {
public size_t hook_run_position; public size_t hook_run_position;
[CCode (cname = "hook_run.total")] [CCode (cname = "hook_run.total")]
public size_t hook_run_total; public size_t hook_run_total;
// PkgRetrieve pkg_retrieve
[CCode (cname = "pkg_retrieve.num")]
public size_t pkg_retrieve_num;
[CCode (cname = "pkg_retrieve.total_size")]
public uint64 pkg_retrieve_total_size;
} }
} }
/** Event callback */ /** Event callback.
*
* Called when an event occurs
* @param ctx user-provided context
* @param event the event that occurred */
[CCode (cname = "alpm_cb_event", has_type_id = false, has_target = false)] [CCode (cname = "alpm_cb_event", has_type_id = false, has_target = false)]
public delegate void EventCallBack (Event.Data data); public delegate void EventCallBack (void* ctx, Event.Data data);
namespace Question { namespace Question {
/** /**
@ -1190,9 +1270,14 @@ namespace Alpm {
} }
} }
/** Question callback */ /** Question callback.
*
* This callback allows user to give input and decide what to do during certain events
* @param ctx user-provided context
* @param question the question being asked.
*/
[CCode (cname = "alpm_cb_question", has_type_id = false, has_target = false)] [CCode (cname = "alpm_cb_question", has_type_id = false, has_target = false)]
public delegate void QuestionCallBack (Question.Data data); public delegate void QuestionCallBack (void* ctx, Question.Data data);
/** Progress */ /** Progress */
[CCode (cname = "alpm_progress_t", cprefix = "ALPM_PROGRESS_")] [CCode (cname = "alpm_progress_t", cprefix = "ALPM_PROGRESS_")]
@ -1209,22 +1294,79 @@ namespace Alpm {
KEYRING_START KEYRING_START
} }
/** Progress callback */ /** Progress callback
*
* Alert the front end about the progress of certain events.
* Allows the implementation of loading bars for events that
* make take a while to complete.
* @param ctx user-provided context
* @param progress the kind of event that is progressing
* @param pkg for package operations, the name of the package being operated on
* @param percent the percent completion of the action
* @param howmany the total amount of items in the action
* @param current the current amount of items completed
*/
[CCode (cname = "alpm_cb_progress", has_type_id = false, has_target = false)] [CCode (cname = "alpm_cb_progress", has_type_id = false, has_target = false)]
public delegate void ProgressCallBack (Progress progress, string pkgname, int percent, uint n_targets, uint current_target); public delegate void ProgressCallBack (void* ctx, Progress progress, string pkgname, int percent, uint n_targets, uint current_target);
namespace Download {
/** File download events.
* These events are reported by ALPM via download callback.
*/
[CCode (cname = "alpm_download_event_type_t", cprefix = "ALPM_DOWNLOAD_")]
public enum Event {
/** A download was started */
INIT,
/** A download made progress */
PROGRESS,
/** A download completed */
COMPLETED
}
/** Context struct for when a download starts. */
[CCode (cname = "alpm_download_event_init_t", has_type_id = false)]
[Compact]
public class Init {
/** whether this file is optional and thus the errors could be ignored */
public int optional;
}
/** Context struct for when a download progresses. */
[CCode (cname = "alpm_download_event_progress_t", has_type_id = false)]
[Compact]
public class Progress {
/** Amount of data downloaded */
public uint64 downloaded;
/** Total amount need to be downloaded */
public uint64 total;
}
/** Context struct for when a download completes. */
[CCode (cname = "alpm_download_event_completed_t", has_type_id = false)]
[Compact]
public class Completed {
/** Total bytes in file */
public uint64 total;
/** download result code:
* 0 - download completed successfully
* 1 - the file is up-to-date
* -1 - error
*/
public int result;
}
}
/** Type of download progress callbacks. /** Type of download progress callbacks.
* @param ctx user-provided context
* @param filename the name of the file being downloaded * @param filename the name of the file being downloaded
* @param xfered the number of transferred bytes * @param event the event type
* @param total the total number of bytes to transfer * @param data the event data of type alpm_download_event_*_t
*/ */
[CCode (cname = "alpm_cb_download", has_type_id = false, has_target = false)] [CCode (cname = "alpm_cb_download", has_type_id = false, has_target = false)]
public delegate void DownloadCallBack (string filename, uint64 xfered, uint64 total); public delegate void DownloadCallBack (void* ctx, string filename, Download.Event event_type, void* event_data);
[CCode (cname = "alpm_cb_totaldl", has_type_id = false, has_target = false)]
public delegate void TotalDownloadCallBack (uint64 total);
/** A callback for downloading files /** A callback for downloading files
* @param ctx user-provided context
* @param url the URL of the file to be downloaded * @param url the URL of the file to be downloaded
* @param localpath the directory to which the file should be downloaded * @param localpath the directory to which the file should be downloaded
* @param force whether to force an update, even if the file is the same * @param force whether to force an update, even if the file is the same
@ -1232,7 +1374,7 @@ namespace Alpm {
* error. * error.
*/ */
[CCode (cname = "alpm_cb_fetch", has_type_id = false, has_target = false)] [CCode (cname = "alpm_cb_fetch", has_type_id = false, has_target = false)]
public delegate int FetchCallBack (string url, string localpath, int force); public delegate int FetchCallBack (void* ctx, string url, string localpath, int force);
/** Transaction flags */ /** Transaction flags */
[CCode (cname = "alpm_transflag_t", cprefix = "ALPM_TRANS_FLAG_")] [CCode (cname = "alpm_transflag_t", cprefix = "ALPM_TRANS_FLAG_")]
@ -1354,10 +1496,8 @@ namespace Alpm {
[CCode (cname = "alpm_list_fn_free", has_target = false)] [CCode (cname = "alpm_list_fn_free", has_target = false)]
public delegate void FreeFunc<G>(G a); public delegate void FreeFunc<G>(G a);
/* properties */ [CCode (cname = "alpm_list_count")]
public size_t length { public size_t length();
[CCode (cname = "alpm_list_count")] get;
}
/* field */ /* field */
public G data; public G data;