feat: wxWidgets gui

This commit is contained in:
CLARATION committed 2026-06-19 17:51:51 -07:00
1 parent 7ee6976c7d
commit fa05fd34e1
53 files changed
+2494 -296

No files matched your search

+130
View File
@@ -0,0 +1,130 @@
#ifdef WITH_GUI
#include "RecoveryPanel.hpp"
#include <wx/wx.h>
#include "AppFrame.hpp"
#include "DevicePanel.hpp"
#include "../state.hpp"
#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include <libirecovery.h>
RecoveryPanel::RecoveryPanel(MainFrame* frame, wxWindow* parent)
: DevicePanel(frame, parent)
{
auto* root = new wxBoxSizer(wxVERTICAL);
root->Add(new wxStaticText(this, wxID_ANY,
"The device needs to be put into DFU mode to apply the jailbreak. This is a\n"
"manual process and we will guide you through it.\n\n"
"In order to prevent filesystem corruption through hard reset, the device will\n"
"be put into recovery mode first. Click next when you are ready."), 0, wxALL, 10);
m_statusText = new wxStaticText(this, wxID_ANY, "");
root->Add(m_statusText, 0, wxALL, 10);
m_backButton = new wxButton(this, wxID_ANY, "Back");
m_nextButton = new wxButton(this, wxID_ANY, "Next");
m_backButton->Bind(wxEVT_BUTTON, [frame](wxCommandEvent&)
{
frame->ShowMain();
});
m_nextButton->Bind(wxEVT_BUTTON, [this](wxCommandEvent&)
{
m_statusText->SetLabel("Entering recovery mode...");
m_backButton->Disable();
m_nextButton->Disable();
EnterRecoveryMode();
});
m_timer.Bind(wxEVT_TIMER, [this](wxTimerEvent&)
{
m_backButton->Enable();
m_nextButton->Enable();
m_isEnteringRecovery = false;
GetMainFrame()->ShowDfu();
m_statusText->SetLabel("");
});
auto* bottomRow = new wxBoxSizer(wxHORIZONTAL);
bottomRow->AddStretchSpacer();
bottomRow->Add(m_backButton, 0, wxALL, 10);
bottomRow->Add(m_nextButton, 0, wxALL, 10);
root->AddStretchSpacer();
root->Add(bottomRow, 0, wxEXPAND);
SetSizer(root);
}
void RecoveryPanel::SetDeviceState(const DeviceState& state)
{
DevicePanel::SetDeviceState(state);
if (!(this->IsShown()))
return;
if (m_isEnteringRecovery && state.mode == DeviceMode::Recovery)
{
m_statusText->SetLabel("Device is now in recovery mode.");
m_timer.StartOnce(3000);
}
if (m_isEnteringRecovery && state.mode == DeviceMode::Normal)
{
m_isEnteringRecovery = false;
m_statusText->SetLabel("Hmm... It seems like the device didn't enter recovery mode. Please try again.");
m_backButton->Enable();
m_nextButton->Enable();
}
if (!m_isEnteringRecovery && state.mode == DeviceMode::None)
{
m_backButton->Enable();
m_nextButton->Enable();
GetMainFrame()->ShowMain();
}
}
void RecoveryPanel::EnterRecoveryMode()
{
const auto& state = GetDeviceState();
if (!state.connected)
return;
idevice_t device = nullptr;
lockdownd_client_t client = nullptr;
if (idevice_new(&device, state.udid.c_str()) != IDEVICE_E_SUCCESS)
return;
if (lockdownd_client_new_with_handshake(
device,
&client,
"palera1n") != LOCKDOWN_E_SUCCESS)
{
idevice_free(device);
return;
}
m_isEnteringRecovery = true;
lockdownd_enter_recovery(client);
lockdownd_client_free(client);
idevice_free(device);
}
void RecoveryPanel::SetStatusText(const wxString& text)
{
m_statusText->SetLabel(text);
}
#endif