diff --git a/lib/zupdater b/lib/zupdater index b292583..95c6759 160000 --- a/lib/zupdater +++ b/lib/zupdater @@ -1 +1 @@ -Subproject commit b292583b66433020925091ee4086a443ad99c462 +Subproject commit 95c675924977dbf04a7223662aa6942fdfb3fce1 diff --git a/src/diagnosewidget.cpp b/src/diagnosewidget.cpp index 3215a06..789425f 100644 --- a/src/diagnosewidget.cpp +++ b/src/diagnosewidget.cpp @@ -90,11 +90,21 @@ void DependencyItem::setInstalled(bool installed) setChecking(false); if (installed) { - m_statusLabel->setText("✓ Installed"); + if (m_name == "Avahi Daemon") { + m_statusLabel->setText("✓ Activated"); + } else { + m_statusLabel->setText("✓ Installed"); + } m_statusLabel->setStyleSheet("color: green; font-weight: bold;"); m_installButton->setVisible(false); } else { - m_statusLabel->setText("✗ Not Installed"); + if (m_name == "Avahi Daemon") { + m_statusLabel->setText("✗ Not activated"); + m_installButton->setText("Enable"); + } else { + m_statusLabel->setText("✗ Not Installed"); + m_installButton->setText("Install"); + } m_statusLabel->setStyleSheet("color: red; font-weight: bold;"); m_installButton->setVisible(true); } @@ -133,17 +143,19 @@ DiagnoseWidget::DiagnoseWidget(QWidget *parent) setupUI(); #ifdef WIN32 - // Add dependency items addDependencyItem("Apple Mobile Device Support", "Required for iOS device communication"); addDependencyItem("WinFsp", "Required for mounting your device as a drive"); #endif #ifdef __linux__ - // Add Linux-specific dependency items +#ifdef ENABLE_RECOVERY_DEVICE_SUPPORT addDependencyItem("USB Device Permissions", "Required for recovery devices (udev rules)"); #endif + addDependencyItem("Avahi Daemon", + "Required for Airplay, device discovery and more"); +#endif // Auto-check on startup QTimer::singleShot(100, this, [this]() { checkDependencies(); }); @@ -238,6 +250,8 @@ void DiagnoseWidget::checkDependencies(bool autoExpand) #ifdef __linux__ if (itemName == "USB Device Permissions") { installed = checkUdevRulesInstalled(); + } else if (itemName == "Avahi Daemon") { + installed = checkAvahiDaemonRunning(); } #endif @@ -248,7 +262,7 @@ void DiagnoseWidget::checkDependencies(bool autoExpand) if (installedCount == totalCount) { m_summaryLabel->setText( - QString("All dependencies are installed (%1/%2)") + QString("All dependencies are installed/activated (%1/%2)") .arg(installedCount) .arg(totalCount)); m_summaryLabel->setStyleSheet("color: green; font-weight: bold;"); @@ -497,6 +511,54 @@ void DiagnoseWidget::onInstallRequested(const QString &name) args << scriptPath << userName; installProcess->start("pkexec", args); } + + if (name == "Avahi Daemon") { + DependencyItem *itemToInstall = nullptr; + for (DependencyItem *item : m_dependencyItems) { + if (item->property("name").toString() == name) { + itemToInstall = item; + break; + } + } + + if (!itemToInstall) + return; + + itemToInstall->setInstalling(true); + + QProcess *installProcess = new QProcess(this); + connect( + installProcess, &QProcess::finished, this, + [this, installProcess, + itemToInstall](int exitCode, QProcess::ExitStatus exitStatus) { + if (exitStatus != QProcess::NormalExit || exitCode != 0) { + QString errorOutput = + installProcess->readAllStandardError(); + if (errorOutput.isEmpty()) { + errorOutput = installProcess->readAllStandardOutput(); + } + QMessageBox::warning( + this, "Error", + "Failed to enable Avahi daemon. " + "This might be because the action was cancelled or an " + "error occurred.\n\nDetails: " + + errorOutput.trimmed()); + checkDependencies(false); + } else { + checkDependencies(false); + } + itemToInstall->setInstalling(false); + installProcess->deleteLater(); + }); + + QStringList args; + args << "systemctl" + << "enable" + << "--now" + << "avahi-daemon.service"; + installProcess->start("pkexec", args); + } + #endif } @@ -546,6 +608,22 @@ bool DiagnoseWidget::checkUdevRulesInstalled() return isInIdeviceGroup; } + +bool DiagnoseWidget::checkAvahiDaemonRunning() +{ + QProcess checkProcess; + checkProcess.start("systemctl", QStringList() + << "is-active" << "avahi-daemon"); + checkProcess.waitForFinished(3000); + + if (checkProcess.exitCode() != 0) { + return false; + } + + QString output = + QString::fromUtf8(checkProcess.readAllStandardOutput()).trimmed(); + return output == "active"; +} #endif void DiagnoseWidget::onToggleExpand() diff --git a/src/diagnosewidget.h b/src/diagnosewidget.h index 006987d..f24093c 100644 --- a/src/diagnosewidget.h +++ b/src/diagnosewidget.h @@ -77,6 +77,7 @@ private: #ifdef __linux__ bool checkUdevRulesInstalled(); + bool checkAvahiDaemonRunning(); #endif QVBoxLayout *m_mainLayout; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7c68dc8..079af2e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -369,5 +369,5 @@ MainWindow::~MainWindow() #endif delete ui; delete m_updater; - sleep(2); // Give some time for cleanup to finish + sleep(2); } diff --git a/src/welcomewidget.cpp b/src/welcomewidget.cpp index 877166f..57bb706 100644 --- a/src/welcomewidget.cpp +++ b/src/welcomewidget.cpp @@ -90,11 +90,8 @@ void WelcomeWidget::setupUI() m_mainLayout->addWidget(m_githubLabel, 0, Qt::AlignCenter); - // FIXME: we need to disable specific deps in diagnosewidget - // not the whole widget when EnableRecoveryDeviceSupport is off // no additional deps needed on macOS -#if !defined(__APPLE__) && defined(ENABLE_RECOVERY_DEVICE_SUPPORT) - +#ifndef __APPLE__ DiagnoseWidget *diagnoseWidget = new DiagnoseWidget(); m_mainLayout->addWidget(diagnoseWidget); #endif