mirror of
https://github.com/palera1n/palera1n.git
synced 2026-10-21 01:37:02 +02:00
73 lines
1.7 KiB
C++
73 lines
1.7 KiB
C++
#ifdef WITH_GUI
|
|
|
|
#include "ExploitPanel.hpp"
|
|
|
|
#include <thread>
|
|
|
|
#include <wx/wx.h>
|
|
|
|
#include "AppFrame.hpp"
|
|
#include "DevicePanel.hpp"
|
|
#include "../state.hpp"
|
|
#include "../utils/log.h"
|
|
|
|
ExploitPanel::ExploitPanel(MainFrame* frame, wxWindow* parent)
|
|
: DevicePanel(frame, parent)
|
|
{
|
|
auto* root = new wxBoxSizer(wxVERTICAL);
|
|
auto* text = new wxStaticText(this, wxID_ANY,
|
|
"Installing jailbreak, this will take a moment. If the device asks for a passcode\nplease enter it. Do not disconnect the device until finished.");
|
|
|
|
m_statusText = new wxStaticText(this, wxID_ANY, "");
|
|
|
|
root->Add(text, 0, wxALL, 10);
|
|
root->Add(m_statusText, 0, wxALL, 10);
|
|
|
|
m_backButton = new wxButton(this, wxID_ANY, "Back");
|
|
m_backButton->Disable();
|
|
m_backButton->Bind(wxEVT_BUTTON, [frame](wxCommandEvent&)
|
|
{
|
|
frame->ShowMain();
|
|
});
|
|
|
|
auto* bottomRow = new wxBoxSizer(wxHORIZONTAL);
|
|
bottomRow->AddStretchSpacer();
|
|
bottomRow->Add(m_backButton, 0, wxALL, 10);
|
|
|
|
root->AddStretchSpacer();
|
|
root->Add(bottomRow, 0, wxEXPAND);
|
|
|
|
SetSizer(root);
|
|
}
|
|
|
|
void ExploitPanel::SetDeviceState(const DeviceState& state)
|
|
{
|
|
DevicePanel::SetDeviceState(state);
|
|
|
|
if (!(this->IsShown()))
|
|
return;
|
|
|
|
if (state.mode == DeviceMode::Normal)
|
|
{
|
|
m_statusText->SetLabel("Done.");
|
|
m_backButton->Enable();
|
|
}
|
|
}
|
|
|
|
void ExploitPanel::StartExploit()
|
|
{
|
|
m_statusText->SetLabel("Exploiting device...");
|
|
m_backButton->Disable();
|
|
|
|
std::thread([this]()
|
|
{
|
|
const auto state = GetDeviceState();
|
|
if (!state.connected || state.mode != DeviceMode::DFU)
|
|
return;
|
|
|
|
LOG("Starting exploit on worker thread...");
|
|
}).detach();
|
|
}
|
|
|
|
#endif // WITH_GUI
|