[Scummvm-git-logs] scummvm master -> 5ab92b6e050f4fddce0b5bba48da361708d74a2e

sev- noreply at scummvm.org
Fri Nov 19 23:56:30 UTC 2021


This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
92ec44b6ab BACKENDS: NETWORKING: Preparations for aborting the request
b51ed2cf01 GUI: Abort session when user requests to do so in the Icon updater
d00f894aa6 GUI: Refresh Grid View after icon packs were downloaded
5ab92b6e05 GUI: Cleanup Ipdate Icons dialog state after successful download


Commit: 92ec44b6ab082f5329b23b3cfc53518b314b8870
    https://github.com/scummvm/scummvm/commit/92ec44b6ab082f5329b23b3cfc53518b314b8870
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-11-20T00:55:44+01:00

Commit Message:
BACKENDS: NETWORKING: Preparations for aborting the request

Looks like we need API for removing DumpFile, but that must be done
in a safe way.

Changed paths:
    backends/networking/curl/session.cpp
    backends/networking/curl/session.h
    backends/networking/curl/sessionrequest.cpp
    backends/networking/curl/sessionrequest.h


diff --git a/backends/networking/curl/session.cpp b/backends/networking/curl/session.cpp
index 2a15d73727..82136408f1 100644
--- a/backends/networking/curl/session.cpp
+++ b/backends/networking/curl/session.cpp
@@ -83,4 +83,9 @@ void Session::close() {
 		_request->close();
 }
 
+void Session::abortRequest() {
+	if (_request)
+		_request->abortRequest();
+}
+
 } // End of namespace Networking
diff --git a/backends/networking/curl/session.h b/backends/networking/curl/session.h
index da8c3ca05c..e464acc571 100644
--- a/backends/networking/curl/session.h
+++ b/backends/networking/curl/session.h
@@ -37,7 +37,17 @@ public:
 	~Session();
 
 	SessionRequest *get(Common::String url, Common::String localFile, DataCallback cb = nullptr, ErrorCallback ecb = nullptr, bool binary = false);
+	/**
+	 * @brief Gracefully close the session
+	 *
+	 */
 	void close();
+
+	/**
+	 * @brief Abort session and remove unfinished downloads if they go to local file
+	 *
+	 */
+	void abortRequest();
 };
 
 } // End of namespace Networking
diff --git a/backends/networking/curl/sessionrequest.cpp b/backends/networking/curl/sessionrequest.cpp
index 3213c2dab9..2600609e36 100644
--- a/backends/networking/curl/sessionrequest.cpp
+++ b/backends/networking/curl/sessionrequest.cpp
@@ -109,6 +109,7 @@ void SessionRequest::finishSuccess() {
 
 	if (_localFile) {
 		_localFile->close();
+		delete _localFile;
 		_localFile = nullptr;
 	}
 
@@ -213,6 +214,17 @@ void SessionRequest::close() {
 	_state = FINISHED;
 }
 
+void SessionRequest::abortRequest() {
+	if (_localFile) {
+		_localFile->close();
+		delete _localFile;
+		_localFile = nullptr;
+
+		// TODO we need to remove file, but there is no API
+	}
+	_state = FINISHED;
+}
+
 bool SessionRequest::complete() {
 	return _complete;
 }
diff --git a/backends/networking/curl/sessionrequest.h b/backends/networking/curl/sessionrequest.h
index 7de34fafe1..b868505cdf 100644
--- a/backends/networking/curl/sessionrequest.h
+++ b/backends/networking/curl/sessionrequest.h
@@ -81,6 +81,12 @@ public:
 	/** This request DOES NOT delete automatically after calling callbacks. It gets PAUSED, and in order to make it FINISHED (i.e. delete), this method MUST be called. */
 	void close();
 
+	/**
+	 * @brief Closes the current request and removes any unfinished files
+	 *
+	 */
+	void abortRequest();
+
 	bool complete();
 	bool success();
 


Commit: b51ed2cf017d2cd2da7ade8c35ffd63d64ac9933
    https://github.com/scummvm/scummvm/commit/b51ed2cf017d2cd2da7ade8c35ffd63d64ac9933
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-11-20T00:55:44+01:00

Commit Message:
GUI: Abort session when user requests to do so in the Icon updater

Changed paths:
    gui/downloadiconsdialog.cpp


diff --git a/gui/downloadiconsdialog.cpp b/gui/downloadiconsdialog.cpp
index 59185fd8bf..0fa430fb32 100644
--- a/gui/downloadiconsdialog.cpp
+++ b/gui/downloadiconsdialog.cpp
@@ -196,7 +196,7 @@ void DownloadIconsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
 	switch (cmd) {
 	case kDownloadCancelCmd:
 		{
-			g_state->session.close();
+			g_state->session.abortRequest();
 			delete g_state;
 			g_state = nullptr;
 


Commit: d00f894aa618ffea043adcecbfe296b65db9028f
    https://github.com/scummvm/scummvm/commit/d00f894aa618ffea043adcecbfe296b65db9028f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-11-20T00:55:44+01:00

Commit Message:
GUI: Refresh Grid View after icon packs were downloaded

Changed paths:
    gui/downloadiconsdialog.cpp
    gui/gui-manager.cpp
    gui/gui-manager.h
    gui/options.cpp


diff --git a/gui/downloadiconsdialog.cpp b/gui/downloadiconsdialog.cpp
index 0fa430fb32..f7ae31f2e0 100644
--- a/gui/downloadiconsdialog.cpp
+++ b/gui/downloadiconsdialog.cpp
@@ -211,6 +211,8 @@ void DownloadIconsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
 		break;
 	case kDownloadEndedCmd:
 		setState(kDownloadComplete);
+		g_gui.initIconsSet();
+		setResult(1); // Need tell the options to refresh launcher
 		break;
 	case kListDownloadFinishedCmd:
 		setState(kDownloadStateListDownloaded);
diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp
index 1dac0da788..06b7e43015 100644
--- a/gui/gui-manager.cpp
+++ b/gui/gui-manager.cpp
@@ -117,6 +117,8 @@ struct ArchiveMemberListBackComparator {
 void GuiManager::initIconsSet() {
 	Common::Archive *dat = nullptr;
 
+	_iconsSet.clear();
+
 	if (ConfMan.hasKey("iconspath")) {
 		Common::FSDirectory *iconDir = new Common::FSDirectory(ConfMan.get("iconspath"));
 		Common::ArchiveMemberList iconFiles;
diff --git a/gui/gui-manager.h b/gui/gui-manager.h
index ec771502ac..4cd2f2949d 100644
--- a/gui/gui-manager.h
+++ b/gui/gui-manager.h
@@ -132,6 +132,8 @@ public:
 
 	void redrawFull();
 
+	void initIconsSet();
+
 protected:
 	enum RedrawStatus {
 		kRedrawDisabled = 0,
@@ -193,8 +195,6 @@ protected:
 	void initKeymap();
 	void enableKeymap(bool enabled);
 
-	void initIconsSet();
-
 	void saveState();
 	void restoreState();
 
diff --git a/gui/options.cpp b/gui/options.cpp
index 3af1a97f75..6bc00c5b9a 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -2947,7 +2947,8 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
 		DownloadIconsDialog dia;
 
 		if (dia.runModal() > 0) {
-			warning("Success");
+			if (_launcher && _launcher->getType() == kLauncherDisplayGrid)
+				_launcher->rebuild();
 		}
 
 		break;


Commit: 5ab92b6e050f4fddce0b5bba48da361708d74a2e
    https://github.com/scummvm/scummvm/commit/5ab92b6e050f4fddce0b5bba48da361708d74a2e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-11-20T00:55:44+01:00

Commit Message:
GUI: Cleanup Ipdate Icons dialog state after successful download

Changed paths:
    gui/downloadiconsdialog.cpp


diff --git a/gui/downloadiconsdialog.cpp b/gui/downloadiconsdialog.cpp
index f7ae31f2e0..7e6ff7a664 100644
--- a/gui/downloadiconsdialog.cpp
+++ b/gui/downloadiconsdialog.cpp
@@ -41,9 +41,9 @@
 namespace GUI {
 
 enum {
-	kDownloadCancelCmd = 'Dlcn',
 	kDownloadProceedCmd = 'Dlpr',
-	kListDownloadFinishedCmd = 'DlLE'
+	kListDownloadFinishedCmd = 'DlLE',
+	kCleanupCmd = 'DlCL'
 };
 
 struct DialogState {
@@ -91,7 +91,7 @@ DownloadIconsDialog::DownloadIconsDialog() :
 	_percentLabel = new StaticTextWidget(this, "GlobalOptions_DownloadIconsDialog.PercentText", Common::String::format("%u %%", progress));
 	_downloadSizeLabel = new StaticTextWidget(this, "GlobalOptions_DownloadIconsDialog.DownloadSize", Common::U32String());
 	_downloadSpeedLabel = new StaticTextWidget(this, "GlobalOptions_DownloadIconsDialog.DownloadSpeed", Common::U32String());
-	_cancelButton = new ButtonWidget(this, "GlobalOptions_DownloadIconsDialog.MainButton", _("Cancel download"), Common::U32String(), kDownloadCancelCmd);
+	_cancelButton = new ButtonWidget(this, "GlobalOptions_DownloadIconsDialog.MainButton", _("Cancel download"), Common::U32String(), kCleanupCmd);
 	_closeButton = new ButtonWidget(this, "GlobalOptions_DownloadIconsDialog.CloseButton", _("Hide"), Common::U32String(), kCloseCmd);
 
 	if (!g_state) {
@@ -135,7 +135,7 @@ void DownloadIconsDialog::setState(IconProcessState state) {
 	case kDownloadStateList:
 		_statusText->setLabel(_("Downloading icons list..."));
 		_cancelButton->setLabel(_("Cancel download"));
-		_cancelButton->setCmd(kDownloadCancelCmd);
+		_cancelButton->setCmd(kCleanupCmd);
 		_closeButton->setVisible(false);
 
 		g_state->totalSize = 0;
@@ -145,7 +145,7 @@ void DownloadIconsDialog::setState(IconProcessState state) {
 	case kDownloadStateListDownloaded:
 		_statusText->setLabel(Common::U32String::format(_("Downloading icons list... %d entries"), g_state->fileHash.size()));
 		_cancelButton->setLabel(_("Cancel download"));
-		_cancelButton->setCmd(kDownloadCancelCmd);
+		_cancelButton->setCmd(kCleanupCmd);
 		_closeButton->setVisible(false);
 		break;
 
@@ -160,14 +160,14 @@ void DownloadIconsDialog::setState(IconProcessState state) {
 
 			_closeButton->setVisible(true);
 			_closeButton->setLabel(_("Cancel"));
-			_closeButton->setCmd(kDownloadCancelCmd);
+			_closeButton->setCmd(kCleanupCmd);
 			_closeButton->setEnabled(true);
 			break;
 		}
 
 	case kDownloadStateDownloading:
 		_cancelButton->setLabel(_("Cancel download"));
-		_cancelButton->setCmd(kDownloadCancelCmd);
+		_cancelButton->setCmd(kCleanupCmd);
 
 		_closeButton->setVisible(true);
 		_closeButton->setLabel(_("Hide"));
@@ -181,11 +181,11 @@ void DownloadIconsDialog::setState(IconProcessState state) {
 			_statusText->setLabel(Common::U32String::format(_("Download complete, downloaded %d packs, %s %S"), g_state->totalFiles, size.c_str(), _(sizeUnits).c_str()));
 			_cancelButton->setVisible(false);
 			_cancelButton->setLabel(_("Cancel download"));
-			_cancelButton->setCmd(kDownloadCancelCmd);
+			_cancelButton->setCmd(kCleanupCmd);
 
 			_closeButton->setVisible(true);
 			_closeButton->setLabel(_("Close"));
-			_closeButton->setCmd(kCloseCmd);
+			_closeButton->setCmd(kCleanupCmd);
 			_closeButton->setEnabled(true);
 			break;
 		}
@@ -194,7 +194,7 @@ void DownloadIconsDialog::setState(IconProcessState state) {
 
 void DownloadIconsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
 	switch (cmd) {
-	case kDownloadCancelCmd:
+	case kCleanupCmd:
 		{
 			g_state->session.abortRequest();
 			delete g_state;
@@ -302,7 +302,7 @@ void DownloadIconsDialog::setError(Common::U32String &msg) {
 	_errorText->setLabel(msg);
 
 	_cancelButton->setLabel(_("Close"));
-	_cancelButton->setCmd(kDownloadCancelCmd);
+	_cancelButton->setCmd(kCleanupCmd);
 }
 
 void DownloadIconsDialog::errorCallback(Networking::ErrorResponse error) {




More information about the Scummvm-git-logs mailing list