diff --git a/src/lay/lay/SaltManagerInstallConfirmationDialog.ui b/src/lay/lay/SaltManagerInstallConfirmationDialog.ui
index 104ed0ae7..87c932dd4 100644
--- a/src/lay/lay/SaltManagerInstallConfirmationDialog.ui
+++ b/src/lay/lay/SaltManagerInstallConfirmationDialog.ui
@@ -308,6 +308,13 @@
+ -
+
+
+ Abort
+
+
+
-
diff --git a/src/lay/lay/laySalt.cc b/src/lay/lay/laySalt.cc
index b256bee93..6c47c949b 100644
--- a/src/lay/lay/laySalt.cc
+++ b/src/lay/lay/laySalt.cc
@@ -380,7 +380,7 @@ public:
}
bool
-Salt::create_grain (const SaltGrain &templ, SaltGrain &target)
+Salt::create_grain (const SaltGrain &templ, SaltGrain &target, double timeout, tl::InputHttpStreamCallback *callback)
{
tl_assert (m_root.begin_collections () != m_root.end_collections ());
@@ -471,7 +471,7 @@ Salt::create_grain (const SaltGrain &templ, SaltGrain &target)
// otherwise download from the URL
tl::info << QObject::tr ("Downloading package from '%1' to '%2' ..").arg (tl::to_qstring (templ.url ())).arg (tl::to_qstring (target.path ()));
- res = tl::WebDAVObject::download (templ.url (), target.path ());
+ res = tl::WebDAVObject::download (templ.url (), target.path (), timeout, callback);
} else {
diff --git a/src/lay/lay/laySalt.h b/src/lay/lay/laySalt.h
index 670c9b990..59e8424be 100644
--- a/src/lay/lay/laySalt.h
+++ b/src/lay/lay/laySalt.h
@@ -183,7 +183,7 @@ public:
*
* Returns true, if the package could be created successfully.
*/
- bool create_grain (const SaltGrain &templ, SaltGrain &target);
+ bool create_grain (const SaltGrain &templ, SaltGrain &target, double timeout = 60.0, tl::InputHttpStreamCallback *callback = 0);
/**
* @brief Removes redundant entries with same names
diff --git a/src/lay/lay/laySaltDownloadManager.cc b/src/lay/lay/laySaltDownloadManager.cc
index 2dfabf129..8d9491926 100644
--- a/src/lay/lay/laySaltDownloadManager.cc
+++ b/src/lay/lay/laySaltDownloadManager.cc
@@ -26,6 +26,7 @@
#include "tlProgress.h"
#include "tlFileUtils.h"
#include "tlWebDAV.h"
+#include "tlLog.h"
#include
#include
@@ -38,16 +39,18 @@ namespace lay
// ----------------------------------------------------------------------------------
ConfirmationDialog::ConfirmationDialog (QWidget *parent)
- : QDialog (parent), m_confirmed (false), m_cancelled (false), m_file (50000, true)
+ : QDialog (parent), m_confirmed (false), m_cancelled (false), m_aborted (false), m_file (50000, true)
{
Ui::SaltManagerInstallConfirmationDialog::setupUi (this);
connect (ok_button, SIGNAL (clicked ()), this, SLOT (confirm_pressed ()));
connect (cancel_button, SIGNAL (clicked ()), this, SLOT (cancel_pressed ()));
connect (close_button, SIGNAL (clicked ()), this, SLOT (close_pressed ()));
+ connect (abort_button, SIGNAL (clicked ()), this, SLOT (abort_pressed ()));
log_panel->hide ();
attn_frame->hide ();
+ abort_button->hide ();
log_view->setModel (&m_file);
connect (&m_file, SIGNAL (layoutChanged ()), log_view, SLOT (scrollToBottom ()));
@@ -147,13 +150,15 @@ ConfirmationDialog::start ()
{
confirm_panel->hide ();
log_panel->show ();
- close_button->setEnabled (false);
+ close_button->hide ();
+ abort_button->show ();
}
void
ConfirmationDialog::finish ()
{
- close_button->setEnabled (true);
+ close_button->show ();
+ abort_button->hide ();
}
// ----------------------------------------------------------------------------------
@@ -400,16 +405,28 @@ SaltDownloadManager::make_confirmation_dialog (QWidget *parent, const lay::Salt
namespace
{
class DownloadProgressAdaptor
- : public tl::ProgressAdaptor
+ : public tl::ProgressAdaptor, public tl::InputHttpStreamCallback
{
public:
DownloadProgressAdaptor (lay::ConfirmationDialog *dialog, const std::string &name)
- : mp_dialog (dialog), m_name (name)
+ : mp_dialog (dialog), m_name (name), m_is_aborted (false)
{
mp_dialog->mark_fetching (m_name);
}
- virtual void yield (tl::Progress * /*progress*/) { }
+ virtual void yield (tl::Progress * /*progress*/)
+ {
+ QCoreApplication::processEvents (QEventLoop::AllEvents | QEventLoop::WaitForMoreEvents, 100);
+ if (mp_dialog->is_aborted ()) {
+ m_is_aborted = true;
+ throw tl::CancelException ();
+ }
+ }
+
+ virtual void wait_for_input ()
+ {
+ yield (0);
+ }
virtual void trigger (tl::Progress *progress)
{
@@ -426,9 +443,15 @@ namespace
mp_dialog->mark_success (m_name);
}
+ bool is_aborted () const
+ {
+ return m_is_aborted;
+ }
+
private:
lay::ConfirmationDialog *mp_dialog;
std::string m_name;
+ bool m_is_aborted;
};
}
@@ -473,15 +496,17 @@ SaltDownloadManager::execute (lay::SaltManagerDialog *parent, lay::Salt &salt)
int status = 1;
- {
- DownloadProgressAdaptor pa (dialog.get (), p->name);
- if (! salt.create_grain (p->grain, target)) {
- pa.error ();
- result = false;
- status = 0;
- } else {
- pa.success ();
- }
+ DownloadProgressAdaptor pa (dialog.get (), p->name);
+ if (! salt.create_grain (p->grain, target, 0.0 /*infinite timeout*/, &pa)) {
+ pa.error ();
+ result = false;
+ status = 0;
+ } else {
+ pa.success ();
+ }
+
+ if (pa.is_aborted ()) {
+ break;
}
try {
@@ -517,7 +542,7 @@ SaltDownloadManager::execute (lay::SaltManagerDialog *parent, lay::Salt &salt)
target.set_path (g->path ());
}
- if (! salt.create_grain (p->grain, target)) {
+ if (! salt.create_grain (p->grain, target, 60.0 /*timeout for offline installation*/)) {
tl::error << tl::to_string (QObject::tr ("Installation failed for package %1").arg (tl::to_qstring (target.name ())));
result = false;
} else {
diff --git a/src/lay/lay/laySaltDownloadManager.h b/src/lay/lay/laySaltDownloadManager.h
index ded523df8..ce5219dff 100644
--- a/src/lay/lay/laySaltDownloadManager.h
+++ b/src/lay/lay/laySaltDownloadManager.h
@@ -34,6 +34,11 @@
#include
#include