diff --git a/data/polkit/org.pamac.policy b/data/polkit/org.pamac.policy index b5b0bed..b66fb7f 100644 --- a/data/polkit/org.pamac.policy +++ b/data/polkit/org.pamac.policy @@ -43,7 +43,6 @@ Απαιτείται πιστοποίηση Authentifizierung erforderlich Godkendelse er påkrævet - Je vyžadováno ověření Cal autenticació Cal autenticació Изисква се идентификация @@ -51,6 +50,7 @@ Ríquese l'autenticación صلاحيات مطلوبة საჭიროა ავთენტიფიკაცია + Je vyžadováno ověření no auth_admin_keep diff --git a/pamac.avprj b/pamac.avprj index 8bd724a..1d04120 100644 --- a/pamac.avprj +++ b/pamac.avprj @@ -1,7 +1,7 @@ ### AutoVala Project ### autovala_version: 30 project_name: pamac -project_version: 7.2.1 +project_version: 7.3.0 vala_version: 0.48 custom: data/systemd/pamac-system.service /usr/lib/systemd/system @@ -22,7 +22,7 @@ define: KDE_TRAY vapidir: src/vapis vala_binary: src/pamac-clean-cache/pamac-clean-cache -*version: 7.2.1 +*version: 7.3.0 vala_local_package: Pamac vala_vapi: ../vapis/libalpm.vapi vala_package: posix @@ -32,7 +32,7 @@ vala_check_package: json-glib-1.0 *vala_source: clean_cache.vala vala_binary: src/pamac-install/pamac-install -*version: 7.2.1 +*version: 7.3.0 use_gresource: pamac_installer_gresource_xml vala_local_package: Pamac vala_vapi: ../vapis/libalpm.vapi @@ -45,7 +45,7 @@ vala_check_package: json-glib-1.0 *vala_source: progress_dialog.vala vala_binary: src/pamac-manager/pamac-manager -*version: 7.2.1 +*version: 7.3.0 alias: pamac-updater use_gresource: pamac_manager_gresource_xml vala_local_package: Pamac @@ -60,7 +60,7 @@ vala_check_package: json-glib-1.0 *vala_source: manager_window.vala vala_binary: src/pamac-system-daemon/pamac-system-daemon -*version: 7.2.1 +*version: 7.3.0 vala_local_package: Pamac vala_package: posix vala_check_package: gtk+-3.0 @@ -75,7 +75,7 @@ vala_check_package: polkit-gobject-1 *vala_source: system_daemon.vala vala_binary: src/pamac-tray/pamac-tray -*version: 7.2.1 +*version: 7.3.0 vala_local_package: Pamac vala_package: posix vala_check_package: json-glib-1.0 @@ -97,7 +97,7 @@ end *vala_source: tray.vala vala_binary: src/pamac-user-daemon/pamac-user-daemon -*version: 7.2.1 +*version: 7.3.0 vala_local_package: Pamac vala_package: posix vala_check_package: gtk+-3.0 @@ -111,7 +111,7 @@ vala_check_package: libsoup-2.4 vala_library: src/pamac -*version: 7.2.1 +*version: 7.3.0 *namespace: Pamac use_gresource: pamac_transaction_gresource_xml *vala_package: posix diff --git a/po/pamac.pot b/po/pamac.pot index 737c546..8ef754d 100644 --- a/po/pamac.pot +++ b/po/pamac.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Pamac\n" "Report-Msgid-Bugs-To: cromer@cromnix.org\n" -"POT-Creation-Date: 2020-04-01 21:04-0300\n" +"POT-Creation-Date: 2021-07-10 13:27-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/src/alpm_config.vala b/src/alpm_config.vala index a280c28..07701a4 100644 --- a/src/alpm_config.vala +++ b/src/alpm_config.vala @@ -51,7 +51,6 @@ public class AlpmConfig { string? dbpath; string? logfile; string? gpgdir; - string? arch; int usesyslog; public int checkspace; GLib.List cachedirs; @@ -62,6 +61,7 @@ public class AlpmConfig { GLib.List noupgrades; GLib.List holdpkgs; GLib.List syncfirsts; + GLib.List architectures; Alpm.Signature.Level siglevel; Alpm.Signature.Level localfilesiglevel; Alpm.Signature.Level remotefilesiglevel; @@ -93,6 +93,7 @@ public class AlpmConfig { noupgrades = new GLib.List (); holdpkgs = new GLib.List (); syncfirsts = new GLib.List (); + architectures = new GLib.List (); usesyslog = 0; checkspace = 0; 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. gpgdir = "/etc/pacman.d/gnupg/"; } - if (arch == null) { - arch = Posix.utsname().machine; + if (architectures.length () == 0) { + architectures.append (Posix.utsname().machine); } } @@ -171,7 +172,9 @@ public class AlpmConfig { handle.logfile = logfile; } handle.gpgdir = gpgdir; - handle.arch = arch; + foreach (unowned string arch in architectures) { + handle.add_architecture (arch); + } handle.usesyslog = usesyslog; handle.checkspace = checkspace; handle.defaultsiglevel = siglevel; @@ -202,7 +205,9 @@ public class AlpmConfig { repo.siglevel = merge_siglevel (siglevel, repo.siglevel, repo.siglevel_mask); unowned Alpm.DB db = handle.register_syncdb (repo.name, repo.siglevel); 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) { db.usage = Alpm.DB.Usage.ALL; @@ -272,10 +277,12 @@ public class AlpmConfig { } else if (key == "LogFile") { logfile = val; } else if (key == "Architecture") { - if (val == "auto") { - arch = Posix.utsname ().machine; - } else { - arch = val; + foreach (unowned string arch in val.split (" ")) { + if (val == "auto") { + architectures.append (Posix.utsname ().machine); + } else { + architectures.append (arch); + } } } else if (key == "UseSysLog") { usesyslog = 1; diff --git a/src/choose_ignorepkgs_dialog.vala b/src/choose_ignorepkgs_dialog.vala index 95ad5fe..1242526 100644 --- a/src/choose_ignorepkgs_dialog.vala +++ b/src/choose_ignorepkgs_dialog.vala @@ -27,7 +27,7 @@ namespace Pamac { class ChooseIgnorepkgsDialog : Gtk.Dialog { [GtkChild] - public Gtk.TreeView treeview; + public unowned Gtk.TreeView treeview; public Gtk.ListStore pkgs_list; diff --git a/src/meson.build b/src/meson.build index 472bbf0..2bd74a0 100644 --- a/src/meson.build +++ b/src/meson.build @@ -4,7 +4,7 @@ cfg_pamac.set('PKGDATADIR', join_paths(get_option('prefix'),get_option('datadir' cfg_pamac.set('GETTEXT_PACKAGE', 'pamac') cfg_pamac.set('RELEASE_NAME', 'pamac') cfg_pamac.set('PREFIX', get_option('prefix')) -cfg_pamac.set('VERSION', '7.2.1') +cfg_pamac.set('VERSION', '7.3.0') cfg_pamac.set('TESTSRCDIR', meson.source_root()) cfgfile_1 = configure_file( @@ -70,7 +70,7 @@ Pamac_library = shared_library('Pamac', pamac_sources, vala_args: pamac_vala_args, c_args: pamac_c_args, link_args: pamac_link_args, - version: '7.2.1', + version: '7.3.0', soversion: '7', install: true, install_dir: [true, true, true, true]) @@ -100,7 +100,7 @@ pamac_requires += ['vte-2.91'] pamac_requires += ['x11'] pkg_mod = import('pkgconfig') pkg_mod.generate(libraries : Pamac_library, - version : '7.2.1', + version : '7.3.0', name : 'Pamac', filebase : 'Pamac', description : 'Pamac', diff --git a/src/pamac-clean-cache/meson.build b/src/pamac-clean-cache/meson.build index 4e4a7ec..de8985f 100644 --- a/src/pamac-clean-cache/meson.build +++ b/src/pamac-clean-cache/meson.build @@ -4,7 +4,7 @@ cfg_pamac_clean_cache.set('PKGDATADIR', join_paths(get_option('prefix'),get_opti cfg_pamac_clean_cache.set('GETTEXT_PACKAGE', 'pamac') cfg_pamac_clean_cache.set('RELEASE_NAME', 'pamac') cfg_pamac_clean_cache.set('PREFIX', get_option('prefix')) -cfg_pamac_clean_cache.set('VERSION', '7.2.1') +cfg_pamac_clean_cache.set('VERSION', '7.3.0') cfg_pamac_clean_cache.set('TESTSRCDIR', meson.source_root()) cfgfile_4 = configure_file( diff --git a/src/pamac-install/meson.build b/src/pamac-install/meson.build index ae0fdf2..d5b29ca 100644 --- a/src/pamac-install/meson.build +++ b/src/pamac-install/meson.build @@ -4,7 +4,7 @@ cfg_pamac_install.set('PKGDATADIR', join_paths(get_option('prefix'),get_option(' cfg_pamac_install.set('GETTEXT_PACKAGE', 'pamac') cfg_pamac_install.set('RELEASE_NAME', 'pamac') cfg_pamac_install.set('PREFIX', get_option('prefix')) -cfg_pamac_install.set('VERSION', '7.2.1') +cfg_pamac_install.set('VERSION', '7.3.0') cfg_pamac_install.set('TESTSRCDIR', meson.source_root()) cfgfile_5 = configure_file( diff --git a/src/pamac-install/progress_dialog.vala b/src/pamac-install/progress_dialog.vala index c208c65..e25a8f2 100644 --- a/src/pamac-install/progress_dialog.vala +++ b/src/pamac-install/progress_dialog.vala @@ -26,11 +26,11 @@ namespace Pamac { class ProgressDialog : Gtk.ApplicationWindow { [GtkChild] - public Gtk.Box box; + public unowned Gtk.Box box; [GtkChild] - public Gtk.Button close_button; + public unowned Gtk.Button close_button; [GtkChild] - public Gtk.Expander expander; + public unowned Gtk.Expander expander; public ProgressDialog () { Object (); diff --git a/src/pamac-manager/history_dialog.vala b/src/pamac-manager/history_dialog.vala index 72f0108..ce02cd9 100644 --- a/src/pamac-manager/history_dialog.vala +++ b/src/pamac-manager/history_dialog.vala @@ -26,7 +26,7 @@ namespace Pamac { class HistoryDialog : Gtk.Dialog { [GtkChild] - public Gtk.TextView textview; + public unowned Gtk.TextView textview; public HistoryDialog (Gtk.ApplicationWindow window) { int use_header_bar; diff --git a/src/pamac-manager/manager_window.vala b/src/pamac-manager/manager_window.vala index d7cb410..8c90ae1 100644 --- a/src/pamac-manager/manager_window.vala +++ b/src/pamac-manager/manager_window.vala @@ -53,88 +53,88 @@ namespace Pamac { // manager objects [GtkChild] - public Gtk.Stack main_stack; + public unowned Gtk.Stack main_stack; [GtkChild] - Gtk.Button button_back; + unowned Gtk.Button button_back; [GtkChild] - Gtk.MenuButton button_menu; + unowned Gtk.MenuButton button_menu; #if ENABLE_HAMBURGER [GtkChild] - Gtk.ModelButton preferences_button; + unowned Gtk.ModelButton preferences_button; #else [GtkChild] - Gtk.HeaderBar headerbar; + unowned Gtk.HeaderBar headerbar; #endif [GtkChild] - Gtk.TreeView packages_treeview; + unowned Gtk.TreeView packages_treeview; [GtkChild] - Gtk.TreeViewColumn packages_state_column; + unowned Gtk.TreeViewColumn packages_state_column; #if DISABLE_AUR [GtkChild] - Gtk.ScrolledWindow aur_scrolledwindow; + unowned Gtk.ScrolledWindow aur_scrolledwindow; #else [GtkChild] - Gtk.TreeView aur_treeview; + unowned Gtk.TreeView aur_treeview; [GtkChild] - Gtk.TreeViewColumn aur_state_column; + unowned Gtk.TreeViewColumn aur_state_column; #endif [GtkChild] - public Gtk.Stack filters_stack; + public unowned Gtk.Stack filters_stack; [GtkChild] - Gtk.StackSwitcher filters_stackswitcher; + unowned Gtk.StackSwitcher filters_stackswitcher; [GtkChild] - Gtk.SearchEntry search_entry; + unowned Gtk.SearchEntry search_entry; [GtkChild] - Gtk.TreeView search_treeview; + unowned Gtk.TreeView search_treeview; [GtkChild] - Gtk.TreeView groups_treeview; + unowned Gtk.TreeView groups_treeview; [GtkChild] - Gtk.TreeView states_treeview; + unowned Gtk.TreeView states_treeview; [GtkChild] - Gtk.TreeView repos_treeview; + unowned Gtk.TreeView repos_treeview; [GtkChild] - Gtk.Stack packages_stack; + unowned Gtk.Stack packages_stack; [GtkChild] - Gtk.StackSwitcher packages_stackswitcher; + unowned Gtk.StackSwitcher packages_stackswitcher; [GtkChild] - Gtk.Label updated_label; + unowned Gtk.Label updated_label; [GtkChild] - Gtk.Stack properties_stack; + unowned Gtk.Stack properties_stack; #if DISABLE_AUR #else [GtkChild] - Gtk.StackSwitcher properties_stackswitcher; + unowned Gtk.StackSwitcher properties_stackswitcher; #endif [GtkChild] - Gtk.Grid deps_grid; + unowned Gtk.Grid deps_grid; [GtkChild] - Gtk.Grid details_grid; + unowned Gtk.Grid details_grid; [GtkChild] - Gtk.ScrolledWindow files_scrolledwindow; + unowned Gtk.ScrolledWindow files_scrolledwindow; [GtkChild] - Gtk.Label name_label; + unowned Gtk.Label name_label; [GtkChild] - Gtk.Label desc_label; + unowned Gtk.Label desc_label; [GtkChild] - Gtk.Label link_label; + unowned Gtk.Label link_label; [GtkChild] - Gtk.Label licenses_label; + unowned Gtk.Label licenses_label; [GtkChild] - Gtk.ToggleButton remove_togglebutton; + unowned Gtk.ToggleButton remove_togglebutton; [GtkChild] - Gtk.ToggleButton reinstall_togglebutton; + unowned Gtk.ToggleButton reinstall_togglebutton; [GtkChild] - Gtk.ToggleButton install_togglebutton; + unowned Gtk.ToggleButton install_togglebutton; [GtkChild] - Gtk.TextView files_textview; + unowned Gtk.TextView files_textview; [GtkChild] - Gtk.Box transaction_infobox; + unowned Gtk.Box transaction_infobox; [GtkChild] - Gtk.Button details_button; + unowned Gtk.Button details_button; [GtkChild] - Gtk.Button apply_button; + unowned Gtk.Button apply_button; [GtkChild] - Gtk.Button cancel_button; + unowned Gtk.Button cancel_button; // menu Gtk.Menu right_click_menu; diff --git a/src/pamac-manager/meson.build b/src/pamac-manager/meson.build index 6c393a8..782747d 100644 --- a/src/pamac-manager/meson.build +++ b/src/pamac-manager/meson.build @@ -4,7 +4,7 @@ cfg_pamac_manager.set('PKGDATADIR', join_paths(get_option('prefix'),get_option(' cfg_pamac_manager.set('GETTEXT_PACKAGE', 'pamac') cfg_pamac_manager.set('RELEASE_NAME', 'pamac') cfg_pamac_manager.set('PREFIX', get_option('prefix')) -cfg_pamac_manager.set('VERSION', '7.2.1') +cfg_pamac_manager.set('VERSION', '7.3.0') cfg_pamac_manager.set('TESTSRCDIR', meson.source_root()) cfgfile_6 = configure_file( diff --git a/src/pamac-system-daemon/meson.build b/src/pamac-system-daemon/meson.build index 0717dc8..089b84c 100644 --- a/src/pamac-system-daemon/meson.build +++ b/src/pamac-system-daemon/meson.build @@ -4,7 +4,7 @@ cfg_pamac_system_daemon.set('PKGDATADIR', join_paths(get_option('prefix'),get_op cfg_pamac_system_daemon.set('GETTEXT_PACKAGE', 'pamac') cfg_pamac_system_daemon.set('RELEASE_NAME', 'pamac') cfg_pamac_system_daemon.set('PREFIX', get_option('prefix')) -cfg_pamac_system_daemon.set('VERSION', '7.2.1') +cfg_pamac_system_daemon.set('VERSION', '7.3.0') cfg_pamac_system_daemon.set('TESTSRCDIR', meson.source_root()) cfgfile_7 = configure_file( diff --git a/src/pamac-system-daemon/system_daemon.vala b/src/pamac-system-daemon/system_daemon.vala index a40f3fa..69afd7a 100644 --- a/src/pamac-system-daemon/system_daemon.vala +++ b/src/pamac-system-daemon/system_daemon.vala @@ -183,12 +183,12 @@ namespace Pamac { trans_commit_finished (false); return; } else { - alpm_handle.eventcb = (Alpm.EventCallBack) cb_event; - alpm_handle.progresscb = (Alpm.ProgressCallBack) cb_progress; - alpm_handle.questioncb = (Alpm.QuestionCallBack) cb_question; - alpm_handle.fetchcb = (Alpm.FetchCallBack) cb_fetch; - alpm_handle.totaldlcb = (Alpm.TotalDownloadCallBack) cb_totaldownload; - alpm_handle.logcb = (Alpm.LogCallBack) cb_log; + alpm_handle.set_eventcb((Alpm.EventCallBack) cb_event, null); + alpm_handle.set_progresscb((Alpm.ProgressCallBack) cb_progress, null); + alpm_handle.set_questioncb((Alpm.QuestionCallBack) cb_question, null); + alpm_handle.set_fetchcb((Alpm.FetchCallBack) cb_fetch, null); + alpm_handle.set_dlcb((Alpm.DownloadCallBack) cb_download, null); + alpm_handle.set_logcb((Alpm.LogCallBack) cb_log, null); lockfile = GLib.File.new_for_path (alpm_handle.lockfile); var pamac_config = new Pamac.Config (); if (pamac_config.update_files_db) { @@ -196,12 +196,12 @@ namespace Pamac { } else { files_handle = alpm_config.get_handle (false); } - files_handle.eventcb = (Alpm.EventCallBack) cb_event; - files_handle.progresscb = (Alpm.ProgressCallBack) cb_progress; - files_handle.questioncb = (Alpm.QuestionCallBack) cb_question; - files_handle.fetchcb = (Alpm.FetchCallBack) cb_fetch; - files_handle.totaldlcb = (Alpm.TotalDownloadCallBack) cb_totaldownload; - files_handle.logcb = (Alpm.LogCallBack) cb_log; + files_handle.set_eventcb((Alpm.EventCallBack) cb_event, null); + files_handle.set_progresscb((Alpm.ProgressCallBack) cb_progress, null); + files_handle.set_questioncb((Alpm.QuestionCallBack) cb_question, null); + files_handle.set_fetchcb((Alpm.FetchCallBack) cb_fetch, null); + files_handle.set_dlcb((Alpm.DownloadCallBack) cb_download, null); + files_handle.set_logcb((Alpm.LogCallBack) cb_log, null); } } @@ -475,26 +475,19 @@ namespace Pamac { private bool update_dbs (Alpm.Handle handle, int force) { bool success = false; unowned Alpm.List syncdbs = handle.syncdbs; - while (syncdbs != null) { - if (cancellable.is_cancelled ()) { - break; - } - unowned Alpm.DB db = syncdbs.data; - if (db.update (force) >= 0) { - // 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 - success = true; - } else { - Alpm.Errno errnos = handle.errno (); - 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) }; - } + if (handle.update_dbs (syncdbs, force) >= 0) { + // 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 + success = true; + } else { + Alpm.Errno errnos = handle.errno (); + 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; } @@ -1268,7 +1261,7 @@ namespace Pamac { }; trans_commit_finished (false); } 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); // fake aur db 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 = {}; uint secondary_type = 0; switch (data.type) { @@ -1778,13 +1771,14 @@ private void cb_event (Alpm.Event.Data data) { case Alpm.Event.Type.SCRIPTLET_INFO: details += data.scriptlet_info_line; break; - case Alpm.Event.Type.PKGDOWNLOAD_START: + case Alpm.Event.Type.PKG_RETRIEVE_START: // do not emit event when download is cancelled if (system_daemon.cancellable.is_cancelled ()) { return; } - details += data.pkgdownload_file; - break; + system_daemon.emit_totaldownload (data.pkg_retrieve_total_size); + // event will be emitted by cb_fetch + return; case Alpm.Event.Type.OPTDEP_REMOVAL: details += data.optdep_removal_pkg.name; 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); } -private void cb_question (Alpm.Question.Data data) { +private void cb_question (void *ctx, Alpm.Question.Data data) { switch (data.type) { case Alpm.Question.Type.INSTALL_IGNOREPKG: // 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) { system_daemon.emit_progress ((uint) progress, pkgname, (uint) percent, n_targets, current_target); system_daemon.timer.start (); @@ -1878,7 +1872,7 @@ private void cb_progress (Alpm.Progress progress, string pkgname, int percent, u 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 ())) { return 1; @@ -1907,7 +1901,7 @@ private int cb_download (void* data, uint64 dltotal, uint64 dlnow, uint64 ultota 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 ()) { 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 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.setopt (Curl.Option.FAILONERROR, 1L); system_daemon.curl.setopt (Curl.Option.CONNECTTIMEOUT, 30L); system_daemon.curl.setopt (Curl.Option.FILETIME, 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_TIME, 30L); 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. system_daemon.curl.setopt (Curl.Option.TIMECONDITION, Curl.TimeCond.IFMODSINCE); FileInfo info = destfile.query_info ("time::modified", 0); - TimeVal time = info.get_modification_time (); - system_daemon.curl.setopt (Curl.Option.TIMEVALUE, time.tv_sec); + DateTime time = info.get_modification_date_time (); + system_daemon.curl.setopt (Curl.Option.TIMEVALUE, time.to_unix()); } else if (tempfile.query_exists ()) { // a previous partial download exists, resume from end of file. FileInfo info = tempfile.query_info ("standard::size", 0); @@ -2082,11 +2078,13 @@ private int cb_fetch (string fileurl, string localpath, int force) { return ret; } -private void cb_totaldownload (uint64 total) { - system_daemon.emit_totaldownload (total); +private void cb_download (void* ctx, string filename, Alpm.Download.Event event_type, void* event_data) { + 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 if (system_daemon.cancellable.is_cancelled ()) { return; diff --git a/src/pamac-tray/meson.build b/src/pamac-tray/meson.build index 7b4ca77..6184dc2 100644 --- a/src/pamac-tray/meson.build +++ b/src/pamac-tray/meson.build @@ -4,7 +4,7 @@ cfg_pamac_tray.set('PKGDATADIR', join_paths(get_option('prefix'),get_option('dat cfg_pamac_tray.set('GETTEXT_PACKAGE', 'pamac') cfg_pamac_tray.set('RELEASE_NAME', 'pamac') cfg_pamac_tray.set('PREFIX', get_option('prefix')) -cfg_pamac_tray.set('VERSION', '7.2.1') +cfg_pamac_tray.set('VERSION', '7.3.0') cfg_pamac_tray.set('TESTSRCDIR', meson.source_root()) cfgfile_3 = configure_file( diff --git a/src/pamac-user-daemon/meson.build b/src/pamac-user-daemon/meson.build index b7f3600..a26b2da 100644 --- a/src/pamac-user-daemon/meson.build +++ b/src/pamac-user-daemon/meson.build @@ -4,7 +4,7 @@ cfg_pamac_user_daemon.set('PKGDATADIR', join_paths(get_option('prefix'),get_opti cfg_pamac_user_daemon.set('GETTEXT_PACKAGE', 'pamac') cfg_pamac_user_daemon.set('RELEASE_NAME', 'pamac') cfg_pamac_user_daemon.set('PREFIX', get_option('prefix')) -cfg_pamac_user_daemon.set('VERSION', '7.2.1') +cfg_pamac_user_daemon.set('VERSION', '7.3.0') cfg_pamac_user_daemon.set('TESTSRCDIR', meson.source_root()) cfgfile_2 = configure_file( diff --git a/src/pamac-user-daemon/user_daemon.vala b/src/pamac-user-daemon/user_daemon.vala index a895492..e51d33c 100644 --- a/src/pamac-user-daemon/user_daemon.vala +++ b/src/pamac-user-daemon/user_daemon.vala @@ -214,9 +214,9 @@ namespace Pamac { unowned Alpm.Package alpm_pkg = pkgcache.data; if (alpm_pkg.reason == Alpm.Package.Reason.DEPEND) { Alpm.List requiredby = alpm_pkg.compute_requiredby (); - if (requiredby.length == 0) { + if (requiredby.length () == 0) { Alpm.List optionalfor = alpm_pkg.compute_optionalfor (); - if (optionalfor.length == 0) { + if (optionalfor.length () == 0) { pkgs += initialise_pkg_struct (alpm_pkg); } else { optionalfor.free_inner (GLib.free); @@ -280,22 +280,26 @@ namespace Pamac { foreach (unowned string part in splitted) { needles.add (part); } - Alpm.List result = alpm_handle.localdb.search (needles); + Alpm.List result; + // TODO: handle return value + alpm_handle.localdb.search (needles, out result); Alpm.List syncpkgs = null; unowned Alpm.List syncdbs = alpm_handle.syncdbs; while (syncdbs != null) { unowned Alpm.DB db = syncdbs.data; - if (syncpkgs.length == 0) { - syncpkgs = db.search (needles); + if (syncpkgs.length () == 0) { + db.search (needles, out syncpkgs); } else { - syncpkgs.join (db.search (needles).diff (syncpkgs, (Alpm.List.CompareFunc) alpm_pkg_compare_name)); + Alpm.List newsyncpkgs = null; + db.search (needles, out newsyncpkgs); + syncpkgs.join (newsyncpkgs.diff (syncpkgs, (Alpm.List.CompareFunc) alpm_pkg_compare_name)); } syncdbs.next (); } result.join (syncpkgs.diff (result, (Alpm.List.CompareFunc) alpm_pkg_compare_name)); // use custom sort function 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; } @@ -828,29 +832,18 @@ namespace Pamac { var tmp_handle = alpm_config.get_handle (false, true); // refresh tmp dbs unowned Alpm.List syncdbs = tmp_handle.syncdbs; - while (syncdbs != null) { - unowned Alpm.DB db = syncdbs.data; - db.update (0); - syncdbs.next (); - } + // TODO: read return value + tmp_handle.update_dbs(syncdbs, 0); // refresh file dbs var pamac_config = new Pamac.Config (); if (pamac_config.update_files_db) { var tmp_files_handle = alpm_config.get_handle (true, true); syncdbs = tmp_files_handle.syncdbs; - while (syncdbs != null) { - unowned Alpm.DB db = syncdbs.data; - db.update (0); - syncdbs.next (); - } + tmp_files_handle.update_dbs(syncdbs, 0); } else { var tmp_files_handle = alpm_config.get_handle (false, true); syncdbs = tmp_files_handle.syncdbs; - while (syncdbs != null) { - unowned Alpm.DB db = syncdbs.data; - db.update (0); - syncdbs.next (); - } + tmp_files_handle.update_dbs(syncdbs, 0); } #if DISABLE_AUR #else diff --git a/src/preferences_dialog.vala b/src/preferences_dialog.vala index 3efe032..cc6f07b 100644 --- a/src/preferences_dialog.vala +++ b/src/preferences_dialog.vala @@ -24,47 +24,47 @@ namespace Pamac { class PreferencesDialog : Gtk.Dialog { [GtkChild] - Gtk.Switch remove_unrequired_deps_button; + unowned Gtk.Switch remove_unrequired_deps_button; [GtkChild] - Gtk.Switch update_files_db_button; + unowned Gtk.Switch update_files_db_button; [GtkChild] - Gtk.Switch check_space_button; + unowned Gtk.Switch check_space_button; [GtkChild] - Gtk.Switch check_updates_button; + unowned Gtk.Switch check_updates_button; [GtkChild] - Gtk.Label refresh_period_label; + unowned Gtk.Label refresh_period_label; [GtkChild] - Gtk.SpinButton refresh_period_spin_button; + unowned Gtk.SpinButton refresh_period_spin_button; [GtkChild] - Gtk.CheckButton no_update_hide_icon_checkbutton; + unowned Gtk.CheckButton no_update_hide_icon_checkbutton; [GtkChild] - Gtk.Box ignorepkgs_box; + unowned Gtk.Box ignorepkgs_box; [GtkChild] - Gtk.TreeView ignorepkgs_treeview; + unowned Gtk.TreeView ignorepkgs_treeview; [GtkChild] - Gtk.Box mirrors_config_box; + unowned Gtk.Box mirrors_config_box; [GtkChild] - Gtk.ComboBoxText mirrors_country_comboboxtext; + unowned Gtk.ComboBoxText mirrors_country_comboboxtext; [GtkChild] - Gtk.ComboBoxText mirrors_list_generation_method_comboboxtext; + unowned Gtk.ComboBoxText mirrors_list_generation_method_comboboxtext; [GtkChild] - Gtk.Button generate_mirrors_list_button; + unowned Gtk.Button generate_mirrors_list_button; #if DISABLE_AUR [GtkChild] - Gtk.Stack stack; + unowned Gtk.Stack stack; [GtkChild] - Gtk.Box aur_config_box; + unowned Gtk.Box aur_config_box; #else [GtkChild] - Gtk.Switch enable_aur_button; + unowned Gtk.Switch enable_aur_button; [GtkChild] - Gtk.CheckButton search_aur_checkbutton; + unowned Gtk.CheckButton search_aur_checkbutton; [GtkChild] - Gtk.Label aur_build_dir_label; + unowned Gtk.Label aur_build_dir_label; [GtkChild] - Gtk.FileChooserButton aur_build_dir_file_chooser; + unowned Gtk.FileChooserButton aur_build_dir_file_chooser; [GtkChild] - Gtk.CheckButton check_aur_updates_checkbutton; + unowned Gtk.CheckButton check_aur_updates_checkbutton; [GtkChild] unowned Gtk.Switch aur_keep_pkgs_button; [GtkChild] @@ -73,17 +73,17 @@ namespace Pamac { unowned Gtk.FileChooserButton aur_move_dir_file_chooser; #endif [GtkChild] - Gtk.Label cache_keep_nb_label; + unowned Gtk.Label cache_keep_nb_label; [GtkChild] - Gtk.SpinButton cache_keep_nb_spin_button; + unowned Gtk.SpinButton cache_keep_nb_spin_button; [GtkChild] - Gtk.CheckButton cache_only_uninstalled_checkbutton; + unowned Gtk.CheckButton cache_only_uninstalled_checkbutton; [GtkChild] - Gtk.ColorButton terminal_background; + unowned Gtk.ColorButton terminal_background; [GtkChild] - Gtk.ColorButton terminal_foreground; + unowned Gtk.ColorButton terminal_foreground; [GtkChild] - Gtk.FontButton terminal_font; + unowned Gtk.FontButton terminal_font; Gtk.ListStore ignorepkgs_liststore; Transaction transaction; diff --git a/src/progress_box.vala b/src/progress_box.vala index d5c2e8f..3af29c9 100644 --- a/src/progress_box.vala +++ b/src/progress_box.vala @@ -26,9 +26,9 @@ namespace Pamac { public class ProgressBox : Gtk.Box { [GtkChild] - public Gtk.ProgressBar progressbar; + public unowned Gtk.ProgressBar progressbar; [GtkChild] - public Gtk.Label action_label; + public unowned Gtk.Label action_label; public ProgressBox () { Object (); diff --git a/src/transaction.vala b/src/transaction.vala index 1effa7a..4eb7bcb 100644 --- a/src/transaction.vala +++ b/src/transaction.vala @@ -1553,15 +1553,15 @@ namespace Pamac { detailed_action = details[0].replace ("\n", ""); important_details_outpout (false); break; - case Alpm.Event.Type.RETRIEVE_START: + case Alpm.Event.Type.DB_RETRIEVE_START: start_downloading (); action = dgettext (null, "Downloading") + "..."; break; - case Alpm.Event.Type.RETRIEVE_DONE: - case Alpm.Event.Type.RETRIEVE_FAILED: + case Alpm.Event.Type.DB_RETRIEVE_DONE: + case Alpm.Event.Type.DB_RETRIEVE_FAILED: stop_downloading (); break; - case Alpm.Event.Type.PKGDOWNLOAD_START: + case Alpm.Event.Type.PKG_RETRIEVE_START: // special case handle differently show_in_term (dgettext (null, "Downloading %s").printf (details[0]) + "..."); string name_version_release = details[0].slice (0, details[0].last_index_of_char ('-')); diff --git a/src/transaction_sum_dialog.vala b/src/transaction_sum_dialog.vala index bf2088a..13cbc39 100644 --- a/src/transaction_sum_dialog.vala +++ b/src/transaction_sum_dialog.vala @@ -26,9 +26,9 @@ namespace Pamac { class TransactionSumDialog : Gtk.Dialog { [GtkChild] - public Gtk.Label top_label; + public unowned Gtk.Label top_label; [GtkChild] - Gtk.TreeView treeview; + unowned Gtk.TreeView treeview; public Gtk.ListStore sum_list; diff --git a/src/vapis/libalpm.vapi b/src/vapis/libalpm.vapi index 30c25dc..5a6226a 100644 --- a/src/vapis/libalpm.vapi +++ b/src/vapis/libalpm.vapi @@ -1,7 +1,7 @@ /* * Vala bindings for libalpm * - * Copyright (C) 2014-2019 Guillaume Benoit + * Copyright (C) 2014-2020 Guillaume Benoit * Copyright (c) 2011 Rémy Oudompheng * * This program is free software; you can redistribute it and/or modify @@ -23,7 +23,7 @@ namespace Alpm { [SimpleType] [CCode (cname = "alpm_time_t", has_type_id = false)] - public struct Time : uint64 {} + public struct Time : int64 {} /** * Library @@ -65,13 +65,20 @@ namespace Alpm { public unowned string root { [CCode (cname = "alpm_option_get_root")] get; } + public unowned string dbpath { [CCode (cname = "alpm_option_get_dbpath")] get; } - public unowned string arch { - [CCode (cname = "alpm_option_get_arch")] get; - [CCode (cname = "alpm_option_set_arch")] set; + + public unowned Alpm.List architectures { + [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 cachedirs { [CCode (cname = "alpm_option_get_cachedirs")] get; [CCode (cname = "alpm_option_set_cachedirs")] set; @@ -103,18 +110,22 @@ namespace Alpm { [CCode (cname = "alpm_option_get_logfile")] get; [CCode (cname = "alpm_option_set_logfile")] set; } + public unowned string lockfile { [CCode (cname = "alpm_option_get_lockfile")] get; } + public unowned string gpgdir { [CCode (cname = "alpm_option_get_gpgdir")] get; [CCode (cname = "alpm_option_set_gpgdir")] set; } + public int usesyslog { [CCode (cname = "alpm_option_get_usesyslog")] get; /** Sets whether to use syslog (0 is FALSE, TRUE otherwise). */ [CCode (cname = "alpm_option_set_usesyslog")] set; } + public unowned Alpm.List noupgrades { [CCode (cname = "alpm_option_get_noupgrades")] get; [CCode (cname = "alpm_option_set_noupgrades")] set; @@ -150,7 +161,7 @@ namespace Alpm { } [CCode (cname = "alpm_option_add_ignoregroup")] 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 unowned Alpm.List assumeinstalled { @@ -172,6 +183,11 @@ namespace Alpm { [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 { [CCode (cname = "alpm_option_get_default_siglevel")] get; [CCode (cname = "alpm_option_set_default_siglevel")] set; @@ -192,33 +208,56 @@ namespace Alpm { [CCode (cname = "alpm_get_syncdbs")] get; } - public LogCallBack logcb { - [CCode (cname = "alpm_option_get_logcb")] get; - [CCode (cname = "alpm_option_set_logcb")] set; - } - public DownloadCallBack dlcb { - [CCode (cname = "alpm_option_get_dlcb")] get; - [CCode (cname = "alpm_option_set_dlcb")] set; - } - public FetchCallBack fetchcb { - [CCode (cname = "alpm_option_get_fetchcb")] get; - [CCode (cname = "alpm_option_set_fetchcb")] set; - } - public TotalDownloadCallBack totaldlcb { - [CCode (cname = "alpm_option_get_totaldlcb")] get; - [CCode (cname = "alpm_option_set_totaldlcb")] set; - } - public EventCallBack eventcb { - [CCode (cname = "alpm_option_get_eventcb")] get; - [CCode (cname = "alpm_option_set_eventcb")] set; - } - public QuestionCallBack questioncb { - [CCode (cname = "alpm_option_get_questioncb")] get; - [CCode (cname = "alpm_option_set_questioncb")] set; - } - public ProgressCallBack progresscb { - [CCode (cname = "alpm_option_get_progresscb")] get; - [CCode (cname = "alpm_option_set_progresscb")] set; + [CCode (cname = "alpm_option_get_logcb")] + public LogCallBack get_logcb(); + [CCode (cname = "alpm_option_set_logcb")] + public int set_logcb(LogCallBack? logcb, void* ctx); + [CCode (cname = "alpm_option_get_logcb_ctx")] + public void* get_logcb_ctx(); + + [CCode (cname = "alpm_option_get_dlcb")] + public DownloadCallBack get_dlcb(); + [CCode (cname = "alpm_option_set_dlcb")] + public int set_dlcb(DownloadCallBack? dlcb, void* ctx); + [CCode (cname = "alpm_option_get_dlcb_ctx")] + public void* get_dlcb_ctx(); + + [CCode (cname = "alpm_option_get_fetchcb")] + public FetchCallBack get_fetchcb(); + [CCode (cname = "alpm_option_set_fetchcb")] + public int set_fetchcb(FetchCallBack? fetchcb, void* ctx); + [CCode (cname = "alpm_option_get_fetchcb_ctx")] + public void* get_fetchcb_ctx(); + + [CCode (cname = "alpm_option_get_eventcb")] + public EventCallBack get_eventcb(); + [CCode (cname = "alpm_option_set_eventcb")] + public int set_eventcb(EventCallBack? eventcb, void* ctx); + [CCode (cname = "alpm_option_get_eventcb_ctx")] + 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")] @@ -229,6 +268,15 @@ namespace Alpm { [CCode (cname = "alpm_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 dbs, int force); + // the return package can be freed except if it is added to a transaction, // it will be freed upon Handle.trans_release() invocation. [CCode (cname = "alpm_pkg_load")] @@ -243,8 +291,16 @@ namespace Alpm { [CCode (cname = "alpm_pkg_should_ignore")] 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")] - public string? fetch_pkgurl(string url); + public int fetch_pkgurl(Alpm.List urls, out Alpm.List fetched); [CCode (cname = "alpm_find_dbs_satisfier")] public unowned Package? find_dbs_satisfier(Alpm.List dbs, string depstring); @@ -370,12 +426,9 @@ namespace Alpm { public int add_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 Group? get_group(string name); - public Alpm.List search(Alpm.List needles); + public int search(Alpm.List needles, out Alpm.List ret); public int check_pgp_signature(out SigList siglist); } @@ -460,10 +513,10 @@ namespace Alpm { [CCode (cname = "alpm_pkg_get_optdepends")] get; } public unowned Alpm.List checkdepends { - [CCode (cname = "alpm_pkg_get_depends")] get; + [CCode (cname = "alpm_pkg_get_checkdepends")] get; } public unowned Alpm.List makedepends { - [CCode (cname = "alpm_pkg_get_optdepends")] get; + [CCode (cname = "alpm_pkg_get_makedepends")] get; } public unowned Alpm.List conflicts { [CCode (cname = "alpm_pkg_get_conflicts")] get; @@ -755,9 +808,18 @@ namespace Alpm { 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)] - 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 { /** @@ -802,21 +864,18 @@ namespace Alpm { /** Scriptlet has printed information; See ScriptletInfo for * arguments. */ SCRIPTLET_INFO, - /** Files will be downloaded from a repository. */ - RETRIEVE_START, - /** Files were downloaded from a repository. */ - RETRIEVE_DONE, - /** Not all files were successfully downloaded from a repository. */ - RETRIEVE_FAILED, - /** A file will be downloaded from a repository; See PkgDownload - * for arguments */ - PKGDOWNLOAD_START, - /** A file was downloaded from a repository; See PkgDownload - * for arguments */ - PKGDOWNLOAD_DONE, - /** A file failed to be downloaded from a repository; See - * PkgDownload for arguments */ - PKGDOWNLOAD_FAILED, + /** Database files will be downloaded from a repository. */ + DB_RETRIEVE_START, + /** Database files were downloaded from a repository. */ + DB_RETRIEVE_DONE, + /** Not all database files were successfully downloaded from a repository. */ + DB_RETRIEVE_FAILED, + /** Package files will be downloaded from a repository. */ + PKG_RETRIEVE_START, + /** Package files were downloaded from a repository. */ + PKG_RETRIEVE_DONE, + /** Not all package files were successfully downloaded from a repository. */ + PKG_RETRIEVE_FAILED, /** Disk space usage will be computed for a package. */ DISKSPACE_START, /** Disk space usage was computed for a package. */ @@ -958,6 +1017,18 @@ namespace Alpm { 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 * 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 @@ -1014,12 +1085,21 @@ namespace Alpm { public size_t hook_run_position; [CCode (cname = "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)] - public delegate void EventCallBack (Event.Data data); + public delegate void EventCallBack (void* ctx, Event.Data data); 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)] - public delegate void QuestionCallBack (Question.Data data); + public delegate void QuestionCallBack (void* ctx, Question.Data data); /** Progress */ [CCode (cname = "alpm_progress_t", cprefix = "ALPM_PROGRESS_")] @@ -1209,22 +1294,79 @@ namespace Alpm { 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)] - 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. + * @param ctx user-provided context * @param filename the name of the file being downloaded - * @param xfered the number of transferred bytes - * @param total the total number of bytes to transfer + * @param event the event type + * @param data the event data of type alpm_download_event_*_t */ [CCode (cname = "alpm_cb_download", has_type_id = false, has_target = false)] - public delegate void DownloadCallBack (string filename, uint64 xfered, uint64 total); - - [CCode (cname = "alpm_cb_totaldl", has_type_id = false, has_target = false)] - public delegate void TotalDownloadCallBack (uint64 total); + public delegate void DownloadCallBack (void* ctx, string filename, Download.Event event_type, void* event_data); /** A callback for downloading files + * @param ctx user-provided context * @param url the URL of the file to 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 @@ -1232,7 +1374,7 @@ namespace Alpm { * error. */ [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 */ [CCode (cname = "alpm_transflag_t", cprefix = "ALPM_TRANS_FLAG_")] @@ -1354,10 +1496,8 @@ namespace Alpm { [CCode (cname = "alpm_list_fn_free", has_target = false)] public delegate void FreeFunc(G a); - /* properties */ - public size_t length { - [CCode (cname = "alpm_list_count")] get; - } + [CCode (cname = "alpm_list_count")] + public size_t length(); /* field */ public G data;