summaryrefslogtreecommitdiff
path: root/apt-pkg/acquire.h
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2017-05-28 16:55:45 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2017-06-28 19:18:47 +0200
commitca8da1bf83ecc90ba882520b79c1cda03ee7485d (patch)
tree0c5d1cd61d0a62d2029ae4bd0a0bc733f2a151e6 /apt-pkg/acquire.h
parent96ebab48c25fcd1ee83729cdba4be8a6343a8766 (diff)
allow frontends to override releaseinfo change behaviour
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…
Diffstat (limited to 'apt-pkg/acquire.h')
-rw-r--r--apt-pkg/acquire.h43
1 files changed, 42 insertions, 1 deletions
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<ReleaseInfoChange> &&Changes);
+ APT_HIDDEN static bool ReleaseInfoChangesAsGlobalErrors(std::vector<ReleaseInfoChange> &&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
@@ -835,6 +868,14 @@ class pkgAcquireStatus
pkgAcquireStatus();
virtual ~pkgAcquireStatus();
};
+class pkgAcquireStatus2: public pkgAcquireStatus
+{
+public:
+ virtual bool ReleaseInfoChanges(metaIndex const * const LastRelease, metaIndex const * const CurrentRelease, std::vector<ReleaseInfoChange> &&Changes);
+
+ pkgAcquireStatus2();
+ virtual ~pkgAcquireStatus2();
+};
/*}}}*/
/** @} */