diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 067eba0..6eeaa57 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,16 +2,16 @@ name: iDescriptor CI (Linux) on: workflow_dispatch: - push: - paths: - - "**.cpp" - - "**.h" - - "**.hpp" - - "**.cxx" - - "**.cc" - - "CMakeLists.txt" - - "**.cmake" - - ".github/workflows/ci.yml" + # push: + # paths: + # - "**.cpp" + # - "**.h" + # - "**.hpp" + # - "**.cxx" + # - "**.cc" + # - "CMakeLists.txt" + # - "**.cmake" + # - ".github/workflows/ci.yml" env: QT_VERSION: "6.7.2" diff --git a/CMakeLists.txt b/CMakeLists.txt index 5774aa9..30504b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -434,6 +434,7 @@ target_include_directories(iDescriptor PRIVATE ${IDEVICE_CPP_INCLUDE_DIR} ${IDEVICE_FFI_INCLUDE_DIR} ${PLIST_CPP_INCLUDE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/lib ${CMAKE_CURRENT_SOURCE_DIR}/lib/zupdater/src # System includes last ${IDEVICE_IMPLEMENTATION_INCLUDES} diff --git a/src/appcontext.cpp b/src/appcontext.cpp index aaa77e3..bf490fb 100644 --- a/src/appcontext.cpp +++ b/src/appcontext.cpp @@ -336,7 +336,6 @@ void AppContext::addDevice(QString udid, .afcClient = initResult->afcClient, .afc2Client = initResult->afc2Client, .lockdown = initResult->lockdown, - .mutex = new std::recursive_mutex(), .imageMounter = initResult->imageMounter, .diagRelay = initResult->diagRelay, .locationSimulation = initResult->locationSimulation, @@ -423,7 +422,6 @@ void AppContext::removeDevice(QString _udid) delete device->heartbeatThread; } - delete device->mutex; delete device; } diff --git a/src/deviceinfowidget.cpp b/src/deviceinfowidget.cpp index b02f1d0..dd0b30f 100644 --- a/src/deviceinfowidget.cpp +++ b/src/deviceinfowidget.cpp @@ -76,19 +76,21 @@ DeviceInfoWidget::DeviceInfoWidget(iDescriptorDevice *device, QWidget *parent) ZIconWidget *shutdownBtn = new ZIconWidget( QIcon(":/resources/icons/IcOutlinePowerSettingsNew.png"), "Shutdown", - this); + 1.0, this); shutdownBtn->setIconSize(QSize(20, 20)); // connect(shutdownBtn, &ZIconWidget::clicked, this, // [device]() { ToolboxWidget::shutdownDevice(device); }); - ZIconWidget *restartBtn = new ZIconWidget( - QIcon(":/resources/icons/IcTwotoneRestartAlt.png"), "Restart", this); + ZIconWidget *restartBtn = + new ZIconWidget(QIcon(":/resources/icons/IcTwotoneRestartAlt.png"), + "Restart", 1.0, this); restartBtn->setIconSize(QSize(20, 20)); // connect(restartBtn, &ZIconWidget::clicked, this, // [device]() { ToolboxWidget::restartDevice(device); }); - ZIconWidget *recoveryBtn = new ZIconWidget( - QIcon(":/resources/icons/HugeiconsWrench01.png"), "Recovery", this); + ZIconWidget *recoveryBtn = + new ZIconWidget(QIcon(":/resources/icons/HugeiconsWrench01.png"), + "Recovery", 1.0, this); recoveryBtn->setIconSize(QSize(20, 20)); // connect(recoveryBtn, &ZIconWidget::clicked, this, // [device]() { ToolboxWidget::_enterRecoveryMode(device); }); diff --git a/src/devicesidebarwidget.cpp b/src/devicesidebarwidget.cpp index 3bb339e..29e407c 100644 --- a/src/devicesidebarwidget.cpp +++ b/src/devicesidebarwidget.cpp @@ -61,7 +61,7 @@ void DeviceSidebarItem::setupUI() if (m_wireless) { auto wirelessIcon = new ZIconLabel( QIcon(":/resources/icons/QlementineIconsWireless116.png"), - "Wireless", this); + "Wireless", 1.0, this); nameLayout->setSpacing(5); nameLayout->addWidget(wirelessIcon); } diff --git a/src/exportmanager.cpp b/src/exportmanager.cpp index 9422558..64006a5 100644 --- a/src/exportmanager.cpp +++ b/src/exportmanager.cpp @@ -59,7 +59,7 @@ QUuid ExportManager::startExport(iDescriptorDevice *device, { qDebug() << "startExport() entry - items:" << items.size() << "dest:" << destinationPath; - if (!device || !device->mutex) { + if (!device) { qWarning() << "Invalid device provided to ExportManager"; return QUuid(); } @@ -157,4 +157,4 @@ void ExportManager::cleanupJob(const QUuid &jobId) // m_activeJobs.erase(it); // qDebug() << "Cleaned up export job" << jobId; // } -} \ No newline at end of file +} diff --git a/src/iDescriptor.h b/src/iDescriptor.h index 20f1131..00b3c4d 100644 --- a/src/iDescriptor.h +++ b/src/iDescriptor.h @@ -76,6 +76,8 @@ #define HEARTBEAT_RETRY_LIMIT 2 +#define DONATE_URL "https://opencollective.com/idescriptor" + #ifdef __linux__ #define LOCKDOWN_PATH "/var/lib/lockdown" #elif __APPLE__ @@ -219,7 +221,7 @@ struct iDescriptorDevice { // nullptr if the device is not jailbroken or doesn't have AFC2 installed AfcClientHandle *afc2Client; LockdowndClientHandle *lockdown; - std::recursive_mutex *mutex; + mutable std::recursive_mutex mutex; ImageMounterHandle *imageMounter; std::shared_ptr diagRelay; LocationSimulationHandle *locationSimulation; diff --git a/src/servicemanager.h b/src/servicemanager.h index 7ad2846..f1af482 100644 --- a/src/servicemanager.h +++ b/src/servicemanager.h @@ -73,7 +73,7 @@ public: std::function operation, std::optional altAfc = std::nullopt) { - if (!device || !device->mutex) { + if (!device) { qDebug() << "[executeOperation] Device or mutex is null"; return T{}; // Return default-constructed value for the type } @@ -152,12 +152,12 @@ public: AfcFileHandle *handle) { try { - if (!device || !device->mutex) { + if (!device) { // FIXME: we have to free error return new IdeviceFfiError{1, "DEVICE_OR_MUTEX_IS_NULL"}; } - std::lock_guard lock(*device->mutex); + std::lock_guard lock(device->mutex); // Double-check device is still valid after acquiring lock if (!device->afcClient) { @@ -181,21 +181,13 @@ public: std::optional altAfc = std::nullopt) { try { - if (!device || !device->mutex) { + if (!device) { // FIXME: we have to free error qDebug() << "[executeAfcClientOperation] Device or mutex is null"; return new IdeviceFfiError{1, "DEVICE_OR_MUTEX_IS_NULL"}; } - std::lock_guard lock(*device->mutex); - - // Double-check device is still valid after acquiring lock - if (!device->afcClient) { - qDebug() << "[executeAfcClientOperation] AFC client is null"; - return new IdeviceFfiError{1, "AFC_CLIENT_IS_NULL"}; - } - std::lock_guard lock(device->mutex); // Double-check device is still valid after acquiring lock diff --git a/src/toolboxwidget.cpp b/src/toolboxwidget.cpp index d3f98ed..7a36728 100644 --- a/src/toolboxwidget.cpp +++ b/src/toolboxwidget.cpp @@ -44,6 +44,13 @@ struct iDescriptorToolWidget { QString iconName; }; +ToolboxWidget *ToolboxWidget::sharedInstance() +{ + static ToolboxWidget *instance = new ToolboxWidget(); + return instance; +} + + ToolboxWidget::ToolboxWidget(QWidget *parent) : QWidget{parent} { setupUI(); @@ -391,7 +398,7 @@ void ToolboxWidget::onCurrentDeviceChanged(const DeviceSelection &selection) } } -void ToolboxWidget::onToolboxClicked(iDescriptorTool tool) +void ToolboxWidget::onToolboxClicked(iDescriptorTool tool, bool requiresDevice) { // final check to make sure device is connected if required iDescriptorDevice *device = AppContext::sharedInstance()->getDevice(m_uuid); @@ -637,4 +644,25 @@ void ToolboxWidget::_enterRecoveryMode(iDescriptorDevice *device) // unplugged."); // qDebug() << "Entering recovery mode"; // } +} + + +void ToolboxWidget::restartAirPlayWindow() +{ + if (!m_airplayWindow) { + onToolboxClicked(iDescriptorTool::Airplayer, false); + return; + } + + connect( + m_airplayWindow, &QObject::destroyed, this, + [this]() { + // give some time for cleanup + QTimer::singleShot(100, this, [this]() { + onToolboxClicked(iDescriptorTool::Airplayer, false); + }); + }, + Qt::SingleShotConnection); + + m_airplayWindow->close(); } \ No newline at end of file