Description: Use KDE's KNotify when running under KDE
Author: Raphael Geissert <geissert@debian.org>
Bug-Debian: http://bugs.debian.org/582793
---
--- a/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
@@ -17,11 +17,14 @@
 #endif /* CONFIG_NATIVE_WINDOWS */
 
 #include <cstdio>
+#include <cstdlib>
 #include <unistd.h>
 #include <QMessageBox>
 #include <QCloseEvent>
 #include <QImageReader>
+#include <QProcess>
 #include <QSettings>
+#include <QStringList>
 
 #include "wpagui.h"
 #include "dirent.h"
@@ -1339,10 +1342,21 @@ void WpaGui::createTrayIcon(bool trayOnl
 void WpaGui::showTrayMessage(QSystemTrayIcon::MessageIcon type, int sec,
 			     const QString & msg)
 {
-	if (!QSystemTrayIcon::supportsMessages())
+	if (isVisible() || !tray_icon || !tray_icon->isVisible())
 		return;
 
-	if (isVisible() || !tray_icon || !tray_icon->isVisible())
+	/* first try to use KDE's notifications system if running under
+	 * a KDE session */
+	if (getenv("KDE_FULL_SESSION") != NULL) {
+		QStringList args;
+		args << "--passivepopup" << msg << QString::number(sec);
+		args << "--title" << "wpa_gui";
+
+		if (QProcess::execute("/usr/bin/kdialog", args) == 0)
+		    return;
+	}
+
+	if (!QSystemTrayIcon::supportsMessages())
 		return;
 
 	tray_icon->showMessage(qAppName(), msg, type, sec * 1000);
