From: Robin Burchell <[email protected]> This improves servercontroller's ability to start messageserver automatically in some cases.
Signed-off-by: Robin Burchell <[email protected]> Signed-off-by: John Brooks <[email protected]> --- src/servercontroller.cpp | 33 +++++++++++++++++++++++++-------- 1 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/servercontroller.cpp b/src/servercontroller.cpp index 61803e6..2e17aa5 100644 --- a/src/servercontroller.cpp +++ b/src/servercontroller.cpp @@ -13,6 +13,7 @@ #include <qmailnamespace.h> #include <QtDebug> +#include <QFile> ServerController *ServerController::m_instance = 0; @@ -56,15 +57,31 @@ bool ServerController::startServer() connect(m_serverProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError))); -#ifdef Q_OS_WIN - const QString servername("/messageserver.exe"); -#else - const QString servername("messageserver"); -#endif + // Magic to try find messageserver on $PATH. + // This isn't pretty, but unless we can rely on the system starting it (which we can't) this will work. + QString messageServerPath; + char splitter; + #ifdef Q_OS_WIN + const QString serverBinary("/messageserver.exe"); + splitter = ';'; // windows uses a semicolon. how quaint. + #else + const QString serverBinary("/messageserver"); + splitter = ':'; + #endif + QList<QByteArray> pathElements = qgetenv("PATH").split(splitter); + + foreach (const QByteArray &pathElement, pathElements) { + QString serverBinaryPath = pathElement + serverBinary; + if (QFile::exists(serverBinaryPath)) { + qDebug() << "starting messageserver " << serverBinaryPath; + m_serverProcess->start(serverBinaryPath); + return m_serverProcess->waitForStarted(); + } + } - qDebug() << "starting messageserver " << QMail::messageServerPath() + servername; - m_serverProcess->start(QMail::messageServerPath() + servername); - return m_serverProcess->waitForStarted(); + // can't find messageserver! + qDebug() << "Unable to locate QMF messageserver binary."; + return false; } void ServerController::processError(QProcess::ProcessError error) -- 1.7.4.1 _______________________________________________ MeeGo-dev mailing list [email protected] http://lists.meego.com/listinfo/meego-dev http://wiki.meego.com/Mailing_list_guidelines
