[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-mac
Subject:    [KDE/Mac] Remove Mac dbus hack from kdelibs?
From:       Jonas_Bähr <jonas.baehr () web ! de>
Date:       2009-01-18 0:20:00
Message-ID: 039A1286-6CB0-400D-8D74-F4CDFB407104 () web ! de
[Download RAW message or body]

Hi,

kdelibs currently contain some Mac OS X specific dbus init functions.  
However, for them to work a patched dbus is needed. This dbus patch  
has evolved in the mean time and it now works without any hack in the  
dbus clients [1,2] and I see no reasons to keep this code in kdelibs.  
Did I miss anything that keeps us from removing it? Patch attached,  
tested on Mac OS X 10.5 with dbus installed via macports.

Maybe we can have a word from Benjamin, who wrote the kdelibs code as  
well as the first version of the dbus patch.

[1] http://trac.macports.org/ticket/17950
[2] http://bugs.freedesktop.org/show_bug.cgi?id=14259

bye,
Jonas

["kdelibs_mac_dbus_hack_removal.diff" (kdelibs_mac_dbus_hack_removal.diff)]

--- ./kdelibs-4.1.85/kdecore/kernel/kkernel_mac.cpp.orig	2009-01-18 \
                00:29:04.000000000 +0100
+++ ./kdelibs-4.1.85/kdecore/kernel/kkernel_mac.cpp	2009-01-18 00:56:15.000000000 \
+0100 @@ -43,10 +43,6 @@
 #include <kconfig.h>
 #include <kdebug.h>
 
-int timeout = 3000; // msec
-
-bool dbus_initialized = false;
-
 /**
   qAppFileName() is not public in qt4/mac, so we need to redo it here
 */
@@ -112,83 +108,6 @@ mac_fork_and_reexec_self()
 	}
 }
 
-/**
- Set the D-Bus environment based on session bus socket
-*/
-
-bool mac_set_dbus_address(QString value)
-{
-	if (!value.isEmpty() && QFile::exists(value) && (QFile::permissions(value) & \
                QFile::WriteUser)) {
-		value = "unix:path=" + value;
-		::setenv("DBUS_SESSION_BUS_ADDRESS", value.toLocal8Bit(), 1);
-		kDebug() << "set session bus address to" << value;
-		return true;
-	}
-	return false;
-}
-
-/**
- Make sure D-Bus is initialized, by any means necessary.
-*/
-
-void mac_initialize_dbus()
-{
-	if (dbus_initialized)
-		return;
-
-	QString dbusVar = qgetenv("DBUS_SESSION_BUS_ADDRESS");
-	if (!dbusVar.isEmpty()) {
-		dbus_initialized = true;
-		return;
-	}
-
-	dbusVar = QFile::decodeName(qgetenv("DBUS_LAUNCHD_SESSION_BUS_SOCKET"));
-	if (mac_set_dbus_address(dbusVar)) {
-		dbus_initialized = true;
-		return;
-	}
-
-	QString externalProc;
-	QStringList path = \
QFile::decodeName(qgetenv("KDEDIRS")).split(':').replaceInStrings(QRegExp("$"), \
                "/bin");
-	path << QFile::decodeName(qgetenv("PATH")).split(':') << "/usr/local/bin";
-
-	for (int i = 0; i < path.size(); ++i) {
-		QString testLaunchctl = QString(path.at(i)).append("/launchctl");
-		if (QFile(testLaunchctl).exists()) {
-			externalProc = testLaunchctl;
-			break;
-		}
-	}
-
-	QString line;
-	QProcess qp;
-	qp.setTextModeEnabled(true);
-
-	if (!externalProc.isEmpty()) {
-		qp.start(externalProc, QStringList() << "getenv" << \
                "DBUS_LAUNCHD_SESSION_BUS_SOCKET");
-		if (!qp.waitForStarted(timeout)) {
-			kDebug() << externalProc << "never started";
-		} else {
-			if (!qp.waitForReadyRead(timeout)) {
-				kDebug() << externalProc << "never wrote anything";
-			} else {
-				while (qp.atEnd() == false) {
-					line = qp.readLine().trimmed();
-					if (mac_set_dbus_address(line)) {
-						dbus_initialized = true;
-					}
-				}
-			}
-			qp.waitForFinished(timeout);
-		}
-	}
-
-	if (dbus_initialized == false) {
-		kDebug() << "warning: unable to initialize D-Bus environment!";
-	}
-
-}
-
 QString mac_app_filename() {
 	static QString appFileName;
 	if (appFileName.isEmpty()) {
--- ./kdelibs-4.1.85/kdecore/kernel/kkernel_mac.h.orig	2009-01-18 00:28:22.000000000 \
                +0100
+++ ./kdelibs-4.1.85/kdecore/kernel/kkernel_mac.h	2009-01-18 00:28:57.000000000 +0100
@@ -41,11 +41,6 @@
 KDECORE_EXPORT void mac_fork_and_reexec_self();
 
 /**
-  * Initialize D-Bus Mac-specific stuff if necessary.
-  */
-KDECORE_EXPORT void mac_initialize_dbus();
-
-/**
   * Get the application name.
   */
 KDECORE_EXPORT QString mac_app_filename();
--- ./kdelibs-4.1.85/kdeui/kernel/kapplication.cpp.orig	2009-01-18 00:32:40.000000000 \
                +0100
+++ ./kdelibs-4.1.85/kdeui/kernel/kapplication.cpp	2009-01-18 00:33:28.000000000 \
+0100 @@ -472,10 +472,6 @@ void KApplicationPrivate::init(bool GUIe
      ::exit(127);
   }
 
-#ifdef Q_WS_MAC
-  mac_initialize_dbus();
-#endif
-
   KApplication::KApp = q;
 
   parseCommandLine();
--- ./kdelibs-4.1.85/kdeui/kernel/kuniqueapplication.cpp.orig	2009-01-18 \
                00:34:22.000000000 +0100
+++ ./kdelibs-4.1.85/kdeui/kernel/kuniqueapplication.cpp	2009-01-18 \
00:36:06.000000000 +0100 @@ -141,10 +141,6 @@ KUniqueApplication::start(StartFlags \
fla  appName.prepend(s);
      }
 
-#ifdef Q_WS_MAC
-  mac_initialize_dbus();
-#endif
-
   bool forceNewProcess = Private::s_multipleInstances || flags & NonUniqueInstance;
 
   if (Private::s_nofork)





_______________________________________________
kde-mac@kde.org
List Information: https://mail.kde.org/mailman/listinfo/kde-mac
KDE/Mac Information: http://techbase.kde.org/index.php?title=Projects/KDE_on_Mac_OS_X

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic