@@ -90,11 +90,21 @@ void DependencyItem::setInstalled(bool installed)
9090 setChecking (false );
9191
9292 if (installed) {
93- m_statusLabel->setText (" ✓ Installed" );
93+ if (m_name == " Avahi Daemon" ) {
94+ m_statusLabel->setText (" ✓ Activated" );
95+ } else {
96+ m_statusLabel->setText (" ✓ Installed" );
97+ }
9498 m_statusLabel->setStyleSheet (" color: green; font-weight: bold;" );
9599 m_installButton->setVisible (false );
96100 } else {
97- m_statusLabel->setText (" ✗ Not Installed" );
101+ if (m_name == " Avahi Daemon" ) {
102+ m_statusLabel->setText (" ✗ Not activated" );
103+ m_installButton->setText (" Enable" );
104+ } else {
105+ m_statusLabel->setText (" ✗ Not Installed" );
106+ m_installButton->setText (" Install" );
107+ }
98108 m_statusLabel->setStyleSheet (" color: red; font-weight: bold;" );
99109 m_installButton->setVisible (true );
100110 }
@@ -133,17 +143,19 @@ DiagnoseWidget::DiagnoseWidget(QWidget *parent)
133143 setupUI ();
134144
135145#ifdef WIN32
136- // Add dependency items
137146 addDependencyItem (" Apple Mobile Device Support" ,
138147 " Required for iOS device communication" );
139148 addDependencyItem (" WinFsp" , " Required for mounting your device as a drive" );
140149#endif
141150
142151#ifdef __linux__
143- // Add Linux-specific dependency items
152+ # ifdef ENABLE_RECOVERY_DEVICE_SUPPORT
144153 addDependencyItem (" USB Device Permissions" ,
145154 " Required for recovery devices (udev rules)" );
146155#endif
156+ addDependencyItem (" Avahi Daemon" ,
157+ " Required for Airplay, device discovery and more" );
158+ #endif
147159
148160 // Auto-check on startup
149161 QTimer::singleShot (100 , this , [this ]() { checkDependencies (); });
@@ -238,6 +250,8 @@ void DiagnoseWidget::checkDependencies(bool autoExpand)
238250#ifdef __linux__
239251 if (itemName == " USB Device Permissions" ) {
240252 installed = checkUdevRulesInstalled ();
253+ } else if (itemName == " Avahi Daemon" ) {
254+ installed = checkAvahiDaemonRunning ();
241255 }
242256#endif
243257
@@ -248,7 +262,7 @@ void DiagnoseWidget::checkDependencies(bool autoExpand)
248262
249263 if (installedCount == totalCount) {
250264 m_summaryLabel->setText (
251- QString (" All dependencies are installed (%1/%2)" )
265+ QString (" All dependencies are installed/activated (%1/%2)" )
252266 .arg (installedCount)
253267 .arg (totalCount));
254268 m_summaryLabel->setStyleSheet (" color: green; font-weight: bold;" );
@@ -497,6 +511,54 @@ void DiagnoseWidget::onInstallRequested(const QString &name)
497511 args << scriptPath << userName;
498512 installProcess->start (" pkexec" , args);
499513 }
514+
515+ if (name == " Avahi Daemon" ) {
516+ DependencyItem *itemToInstall = nullptr ;
517+ for (DependencyItem *item : m_dependencyItems) {
518+ if (item->property (" name" ).toString () == name) {
519+ itemToInstall = item;
520+ break ;
521+ }
522+ }
523+
524+ if (!itemToInstall)
525+ return ;
526+
527+ itemToInstall->setInstalling (true );
528+
529+ QProcess *installProcess = new QProcess (this );
530+ connect (
531+ installProcess, &QProcess::finished, this ,
532+ [this , installProcess,
533+ itemToInstall](int exitCode, QProcess::ExitStatus exitStatus) {
534+ if (exitStatus != QProcess::NormalExit || exitCode != 0 ) {
535+ QString errorOutput =
536+ installProcess->readAllStandardError ();
537+ if (errorOutput.isEmpty ()) {
538+ errorOutput = installProcess->readAllStandardOutput ();
539+ }
540+ QMessageBox::warning (
541+ this , " Error" ,
542+ " Failed to enable Avahi daemon. "
543+ " This might be because the action was cancelled or an "
544+ " error occurred.\n\n Details: " +
545+ errorOutput.trimmed ());
546+ checkDependencies (false );
547+ } else {
548+ checkDependencies (false );
549+ }
550+ itemToInstall->setInstalling (false );
551+ installProcess->deleteLater ();
552+ });
553+
554+ QStringList args;
555+ args << " systemctl"
556+ << " enable"
557+ << " --now"
558+ << " avahi-daemon.service" ;
559+ installProcess->start (" pkexec" , args);
560+ }
561+
500562#endif
501563}
502564
@@ -546,6 +608,22 @@ bool DiagnoseWidget::checkUdevRulesInstalled()
546608
547609 return isInIdeviceGroup;
548610}
611+
612+ bool DiagnoseWidget::checkAvahiDaemonRunning ()
613+ {
614+ QProcess checkProcess;
615+ checkProcess.start (" systemctl" , QStringList ()
616+ << " is-active" << " avahi-daemon" );
617+ checkProcess.waitForFinished (3000 );
618+
619+ if (checkProcess.exitCode () != 0 ) {
620+ return false ;
621+ }
622+
623+ QString output =
624+ QString::fromUtf8 (checkProcess.readAllStandardOutput ()).trimmed ();
625+ return output == " active" ;
626+ }
549627#endif
550628
551629void DiagnoseWidget::onToggleExpand ()
0 commit comments