KEMBAR78
CLOUD: Add new storage connection flow by Tkachov · Pull Request #4860 · scummvm/scummvm · GitHub
Skip to content

Conversation

@Tkachov
Copy link
Contributor

@Tkachov Tkachov commented Apr 1, 2023

This changes how users would connect Cloud storages in ScummVM. Instead of the old flow, where user would enter a short code to retrieve data stored on cloud.scummvm.org, now there is a GUI wizard that allows "quick" and "manual" modes. In both modes, cloud.scummvm.org doesn't store the data anymore (see the corresponding PR for scummvm-sites: #21).

image

In quick mode, user is asked to enable Local Webserver, so their browser could send an AJAX request to /connect_cloud.
In manual mode, the data of that request is displayed in browser, and user copies it into ScummVM.

I've tried to split the changes into small logically finished commits for easier review. The GUI change is quite big though.

Copy link
Member

@sev- sev- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent stuff. I have a few small notes.

@@ -0,0 +1,669 @@
/* ScummVM - Graphic Adventure Engine
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file needs to be added to po/POTFILES

*/
JSON::JSON() {}

char *JSON::getPreparedContents(Common::MemoryWriteStreamDynamic &stream) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend renaming this to JSON::untaintContents()

_nextStepButton->setEnabled(serverIsRunning);

if (_button0) {
_button0->setLabel(_(serverIsRunning ? "Stop server" : "Run server"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these should be marked for translation. e.g. wrap them into _(). Same for the buttons below.

_label1->setLabel(Common::U32String());

// get the code entered
Common::String code = "";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assignment is redundant: the String constructor initializes it with an empty string already.

_connecting = false;
delete callback;
if (_label1)
_label1->setLabel(_("There is likely a mistake in the code."));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which code? Please clarify, especially for the translators.

@Tkachov Tkachov requested a review from sev- April 3, 2023 08:40
Tkachov added 13 commits April 8, 2023 13:25
Made the method that prepares the JSON received via network static and moved to Common::JSON, so it could be used not only in CurlJsonRequest.
Local webserver's helper class, Reader, supported simple GET requests and POST form/multipart ones. The code for the latter was a bit specific, and didn't allow handling more generic POST requests.

This change adds ReaderMode enum, with RM_HTTP_GENERIC mode, that allows such generic requests to be handled. In Networking::Client class, that uses Reader, readContent() was renamed to readFirstContent(), and corresponds to previously existing POST form/multipart mode. readContent() should now be used for generic POST requests handling.
Just a small helper method to make a Common::SeekableReadStream for local webserver's handlers from Common::String contents.
- allow OPTIONS HTTP method to be handled by local webserver;
- add /connect_cloud endpoint;
- add new DropboxStorage constructor that works with JSON response instead of requesting that via shortcode;
- add CloudManager::connectStorage() overload for this new JSON flow.

/connect_cloud endpoint allows cross-origin request (via CORS HTTP headers) from cloud.scummvm.org, so user's browser sends the JSON response directly to ScummVM app, instead of the app requesting that response from the site.

This commit is WIP, introducing a new constructor for Dropbox only, and not changing the GUI part at all.
This new version looks for "storage" key in JSON and uses it to determine which storage needs to be connected.
- remove Options widgets of the old wizard;
- add CloudConnectionWizard dialog;
- remove old widgets and add new ones in the layouts;
- update local webserver to allow passing a callback that needs to be called if storage was connected via /connect_cloud.
- rename JSON::getPreparedContents() to JSON::untaintContents();
- minor changes to ConnectCloudClientHandler and CloudConnectionWizard.
- regenerate themes .zips;
- minor cleanup.
@Tkachov Tkachov force-pushed the cloud-2023-change branch from f779ce8 to 733be3b Compare April 8, 2023 11:35
@sev- sev- merged commit 7798c2a into scummvm:master Apr 8, 2023
@Tkachov Tkachov deleted the cloud-2023-change branch April 9, 2023 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants