From ca8da1bf83ecc90ba882520b79c1cda03ee7485d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 28 May 2017 16:55:45 +0200 Subject: allow frontends to override releaseinfo change behaviour MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Having messages being printed on the error stack and confirm them by commandline flags is an okayish first step, but some frontends will probably want to have a more interactive feeling here with a proper question the user can just press yes/no for as for some frontends a commandline flag makes no sense… --- apt-pkg/acquire.h | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'apt-pkg/acquire.h') diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 5f1212338..8331c56e9 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -86,6 +86,7 @@ using std::string; #endif class pkgAcquireStatus; +class metaIndex; /** \brief The core download scheduler. {{{ * @@ -794,7 +795,39 @@ class pkgAcquireStatus * with prejudice. */ virtual bool MediaChange(std::string Media,std::string Drive) = 0; - + + struct ReleaseInfoChange + { + std::string Type; /*!< Type of the change like "Origin", "Codename", "Version", … */ + std::string From; /*!< old value */ + std::string To; /*!< new value */ + std::string Message; /*!< translated message describing the change */ + bool DefaultAction; /*!< true if the change is informational, false if it must be explicitly confirmed */ + }; + /** \brief ask the user for confirmation of changes to infos about a repository + * + * This method should present the user with a choice of accepting the change + * or not and indicate the user opinion via the return value. If DefaultAction is true + * it is acceptable to only notify the user about the change, but to accept the change + * automatically on behalf of the user. + * + * The default implementation will fail if any Change has DefaultAction == false. Regardless of + * success it will print for each change the message attached to it via GlobalError either as an + * error (if DefaultAction == false) or as a notice otherwise. + * + * \b Note: To keep ABI compatibility for now this method isn't marked as + * virtual, but you can derive your class from #pkgAcquireStatus2 which has it + * marked as virtual. TODO on next ABI break: merge both classes. + * + * @param LastRelease can be used to extract further information from the previous Release file + * @param CurrentRelease can be used to extract further information from the current Release file + * @param Changes is an array of changes alongside explanatory messages + * which should be presented in some way to the user. + * @return \b true if all changes are accepted by user, otherwise or if user can't be asked \b false + */ + bool ReleaseInfoChanges(metaIndex const * const LastRelease, metaIndex const * const CurrentRelease, std::vector &&Changes); + APT_HIDDEN static bool ReleaseInfoChangesAsGlobalErrors(std::vector &&Changes); + /** \brief Invoked when an item is confirmed to be up-to-date. * For instance, when an HTTP download is informed that the file on @@ -834,6 +867,14 @@ class pkgAcquireStatus /** \brief Initialize all counters to 0 and the time to the current time. */ pkgAcquireStatus(); virtual ~pkgAcquireStatus(); +}; +class pkgAcquireStatus2: public pkgAcquireStatus +{ +public: + virtual bool ReleaseInfoChanges(metaIndex const * const LastRelease, metaIndex const * const CurrentRelease, std::vector &&Changes); + + pkgAcquireStatus2(); + virtual ~pkgAcquireStatus2(); }; /*}}}*/ /** @} */ -- cgit v1.2.3