Author: lslezak
Date: Wed Jun 4 17:25:51 2008
New Revision: 48079
URL: http://svn.opensuse.org/viewcvs/yast?rev=48079&view=rev
Log:
- added PackageLock::Connect() - similar to PackageLock::Check()
but [Abort] is always displayed and [Continue] is optional
(bnc#293356)
Modified:
trunk/yast2/library/packages/src/PackageLock.ycp
trunk/yast2/package/yast2.changes
Modified: trunk/yast2/library/packages/src/PackageLock.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/library/packages/src/PackageLock.ycp?rev=48079&r1=48078&r2=48079&view=diff
==============================================================================
--- trunk/yast2/library/packages/src/PackageLock.ycp (original)
+++ trunk/yast2/library/packages/src/PackageLock.ycp Wed Jun 4 17:25:51 2008
@@ -18,6 +18,7 @@
import "Label";
boolean have_lock = nil;
+boolean aborted = false;
/**
* Tries to acquire the packager (zypp) lock.
@@ -63,5 +64,88 @@
return have_lock;
}
+/**
+ * Tries to acquire the packager (zypp) lock.
+ * Reports an error if another process has the lock already.
+ * Will only report once even if called multiple times.
+ * @return true if we can continue
+ */
+global map Connect(boolean show_continue_button)
+{
+ // we already have a lock
+ if (have_lock != nil) return $[ "connected" : have_lock, "aborted" : aborted ];
+
+ boolean try_again = true;
+
+ // while not having a lock and user wants to try again
+ while (try_again) {
+ // Invoke a cheap call that accesses the zypp lock
+ have_lock = Pkg::Connect () == true; // nil guard
+ if (have_lock == true) break;
+
+ if (have_lock != true) {
+ if (show_continue_button)
+ {
+ symbol ret = Popup::AnyQuestion3(
+ // TRANSLATORS: a popup headline
+ _("Accessing the Package Management Failed"),
+ // TRANSLATORS: an error message with question
+ _("Another process is accessing the package database.
+Package management cannot be used now.
+")
+ + "\n" +
+ _("Would you like to retry to access it,
+continue without having access to the package management
+or abort?
+"),
+ Label::RetryButton(),
+ Label::ContinueButton(),
+ Label::AbortButton(),
+ // default is 'Retry'
+ `focus_yes
+ );
+
+ try_again = (ret == `yes);
+
+ // NOTE: due to the changed labels this actually means that [Abort] was pressed!!
+ if (ret == `retry)
+ {
+ aborted = true;
+ }
+ }
+ else
+ {
+ boolean ret = Popup::AnyQuestion(
+ // TRANSLATORS: a popup headline
+ _("Accessing the Package Management Failed"),
+ // TRANSLATORS: an error message with question
+ _("Another process is accessing the package database.
+Package management cannot be used now.
+")
+ + "\n" +
+_("Would you like to abort or retry to access it?
+"),
+ Label::RetryButton(),
+ Label::AbortButton(),
+ // default is 'Retry'
+ `focus_yes
+ );
+
+ try_again = ret;
+ aborted = !ret;
+ }
+
+ y2milestone("try_again: %1, aborted: %2", try_again, aborted);
+
+ }
+
+ if (try_again) y2milestone ("User decided to retry...");
+ }
+
+ map ret = $[ "connected" : have_lock, "aborted" : aborted ];
+ y2milestone ("PackageLock::Connect result: %1", ret);
+
+ return ret;
+}
}
Modified: trunk/yast2/package/yast2.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/package/yast2.changes?rev=48079&r1=48078&r2=48079&view=diff
==============================================================================
--- trunk/yast2/package/yast2.changes (original)
+++ trunk/yast2/package/yast2.changes Wed Jun 4 17:25:51 2008
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Wed Jun 4 16:32:13 CEST 2008 - lslezak@suse.cz
+
+- added PackageLock::Connect() - similar to PackageLock::Check()
+ but [Abort] is always displayed and [Continue] is optional
+ (bnc#293356)
+
+-------------------------------------------------------------------
Tue Jun 3 16:49:06 CEST 2008 - locilka@suse.cz
- Always calling NetworkInterfaces::Read in SuSEFirewall::Read
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org