mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #18631 from hrydgard/remote-iso-folder-prep
Remote ISO: Prepare to allow sharing folders directly
This commit is contained in:
commit
1e6584148d
9 changed files with 59 additions and 8 deletions
|
@ -178,6 +178,7 @@ bool Connection::Connect(int maxTries, double timeout, bool *cancelConnect) {
|
|||
|
||||
selectResult = select(maxfd, nullptr, &fds, nullptr, &tv);
|
||||
if (cancelConnect && *cancelConnect) {
|
||||
WARN_LOG(HTTP, "connect: cancelled (1)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -196,6 +197,7 @@ bool Connection::Connect(int maxTries, double timeout, bool *cancelConnect) {
|
|||
}
|
||||
|
||||
if (cancelConnect && *cancelConnect) {
|
||||
WARN_LOG(HTTP, "connect: cancelled (2)");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
enum RequestType {
|
||||
SIMPLE, FULL,
|
||||
};
|
||||
RequestType type;
|
||||
RequestType type = SIMPLE;
|
||||
enum Method {
|
||||
GET,
|
||||
HEAD,
|
||||
|
|
|
@ -81,7 +81,7 @@ ServerRequest::~ServerRequest() {
|
|||
}
|
||||
delete in_;
|
||||
if (!out_->Empty()) {
|
||||
ERROR_LOG(IO, "Output not empty - connection abort? (%s)", this->header_.resource);
|
||||
WARN_LOG(IO, "Output not empty - connection abort? (%s) (%d bytes)", this->header_.resource, out_->BytesRemaining());
|
||||
}
|
||||
delete out_;
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ void InputSink::AccountDrain(size_t bytes) {
|
|||
}
|
||||
}
|
||||
|
||||
bool InputSink::Empty() {
|
||||
bool InputSink::Empty() const {
|
||||
return valid_ == 0;
|
||||
}
|
||||
|
||||
|
@ -418,8 +418,12 @@ void OutputSink::AccountDrain(int bytes) {
|
|||
}
|
||||
}
|
||||
|
||||
bool OutputSink::Empty() {
|
||||
bool OutputSink::Empty() const {
|
||||
return valid_ == 0;
|
||||
}
|
||||
|
||||
};
|
||||
int OutputSink::BytesRemaining() const {
|
||||
return valid_;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
bool Skip(size_t bytes);
|
||||
void Discard();
|
||||
|
||||
bool Empty();
|
||||
bool Empty() const;
|
||||
bool TryFill();
|
||||
|
||||
private:
|
||||
|
@ -54,7 +54,8 @@ public:
|
|||
bool Flush(bool allowBlock = true);
|
||||
void Discard();
|
||||
|
||||
bool Empty();
|
||||
bool Empty() const;
|
||||
int BytesRemaining() const;
|
||||
|
||||
private:
|
||||
void Drain();
|
||||
|
@ -72,4 +73,4 @@ private:
|
|||
size_t valid_;
|
||||
};
|
||||
|
||||
};
|
||||
} // namespace net
|
||||
|
|
|
@ -692,4 +692,28 @@ std::string FileChooserChoice::ValueText() const {
|
|||
return path.GetFilename();
|
||||
}
|
||||
|
||||
FolderChooserChoice::FolderChooserChoice(std::string *value, const std::string &text, LayoutParams *layoutParams)
|
||||
: AbstractChoiceWithValueDisplay(text, layoutParams), value_(value) {
|
||||
OnClick.Add([=](UI::EventParams &) {
|
||||
System_BrowseForFolder(text_, [=](const std::string &returnValue, int) {
|
||||
if (*value_ != returnValue) {
|
||||
*value = returnValue;
|
||||
UI::EventParams e{};
|
||||
e.s = *value;
|
||||
OnChange.Trigger(e);
|
||||
}
|
||||
});
|
||||
return UI::EVENT_DONE;
|
||||
});
|
||||
}
|
||||
|
||||
std::string FolderChooserChoice::ValueText() const {
|
||||
if (value_->empty()) {
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
return di->T("Default");
|
||||
}
|
||||
Path path(*value_);
|
||||
return path.GetFilename();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -436,4 +436,17 @@ private:
|
|||
BrowseFileType fileType_;
|
||||
};
|
||||
|
||||
class FolderChooserChoice : public AbstractChoiceWithValueDisplay {
|
||||
public:
|
||||
FolderChooserChoice(std::string *value, const std::string &title, LayoutParams *layoutParams = nullptr);
|
||||
std::string ValueText() const override;
|
||||
|
||||
Event OnChange;
|
||||
|
||||
private:
|
||||
std::string *value_;
|
||||
BrowseFileType fileType_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace UI
|
||||
|
|
|
@ -162,6 +162,12 @@ static Path LocalFromRemotePath(const std::string &path) {
|
|||
|
||||
static void DiscHandler(const http::ServerRequest &request, const Path &filename) {
|
||||
s64 sz = File::GetFileSize(filename);
|
||||
if (sz == 0) {
|
||||
// Probably failed
|
||||
request.WriteHttpResponseHeader("1.0", 404, -1, "text/plain");
|
||||
request.Out()->Push("File not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string range;
|
||||
if (request.Method() == http::RequestHeader::HEAD) {
|
||||
|
|
|
@ -118,6 +118,7 @@ bool RemoteISOConnectScreen::FindServer(std::string &resultHost, int &resultPort
|
|||
|
||||
std::lock_guard<std::mutex> guard(statusLock_);
|
||||
statusMessage_ = formatted;
|
||||
INFO_LOG(SYSTEM, "Remote: %s", formatted.c_str());
|
||||
};
|
||||
|
||||
http.SetUserAgent(StringFromFormat("PPSSPP/%s", PPSSPP_GIT_VERSION));
|
||||
|
|
Loading…
Add table
Reference in a new issue