1 // Copyright (c) 2016- PPSSPP Project. 2 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation, version 2.0 or later versions. 6 7 // This program is distributed in the hope that it will be useful, 8 // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 // GNU General Public License 2.0 for more details. 11 12 // A copy of the GPL 2.0 should have been included with the program. 13 // If not, see http://www.gnu.org/licenses/ 14 15 // Official git repository and contact information can be found at 16 // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. 17 18 #pragma once 19 20 #include <thread> 21 #include <mutex> 22 23 #include "Common/UI/UIScreen.h" 24 #include "Common/UI/ViewGroup.h" 25 #include "UI/MiscScreens.h" 26 #include "UI/MainScreen.h" 27 28 class RemoteISOScreen : public UIScreenWithBackground { 29 public: 30 RemoteISOScreen(); 31 32 protected: 33 void update() override; 34 void CreateViews() override; 35 36 UI::EventReturn HandleStartServer(UI::EventParams &e); 37 UI::EventReturn HandleStopServer(UI::EventParams &e); 38 UI::EventReturn HandleBrowse(UI::EventParams &e); 39 UI::EventReturn HandleSettings(UI::EventParams &e); 40 41 UI::TextView *firewallWarning_ = nullptr; 42 bool serverRunning_ = false; 43 bool serverStopping_ = false; 44 }; 45 46 enum class ScanStatus { 47 SCANNING, 48 RETRY_SCAN, 49 FOUND, 50 FAILED, 51 LOADING, 52 LOADED, 53 }; 54 55 class RemoteISOConnectScreen : public UIScreenWithBackground { 56 public: 57 RemoteISOConnectScreen(); 58 ~RemoteISOConnectScreen() override; 59 60 protected: 61 void update() override; 62 void CreateViews() override; 63 64 ScanStatus GetStatus(); 65 void ExecuteScan(); 66 void ExecuteLoad(); 67 bool FindServer(std::string &resultHost, int &resultPort); 68 69 UI::TextView *statusView_; 70 71 ScanStatus status_ = ScanStatus::SCANNING; 72 std::string statusMessage_; 73 double nextRetry_ = 0.0; 74 std::thread *scanThread_; 75 std::mutex statusLock_; 76 std::string host_; 77 int port_; 78 std::string url_; 79 std::vector<Path> games_; 80 }; 81 82 class RemoteISOBrowseScreen : public MainScreen { 83 public: 84 RemoteISOBrowseScreen(const std::string &url, const std::vector<Path> &games); 85 86 protected: 87 void CreateViews() override; 88 89 std::string url_; 90 std::vector<Path> games_; 91 }; 92 93 class RemoteISOSettingsScreen : public UIDialogScreenWithBackground { 94 public: 95 RemoteISOSettingsScreen(); 96 97 UI::EventReturn OnClickRemoteISOSubdir(UI::EventParams &e); 98 UI::EventReturn OnClickRemoteServer(UI::EventParams &e); 99 protected: 100 101 void update() override; 102 void CreateViews() override; 103 104 UI::EventReturn OnChangeRemoteISOSubdir(UI::EventParams &e); 105 106 bool serverRunning_ = false; 107 }; 108