Commit 18eef194 authored by Robert Lancaster's avatar Robert Lancaster Committed by Jasem Mutlaq

This patch should both make the dbus commands work in kstars for scripting and...

This patch should both make the dbus commands work in kstars for scripting and also for the scheduler, as well as starting up a dbus server from inside the bundle if none is currently running.  This should be combined with changes I made to the OS X build script already to make it all work properly.  Hopefully this solves the dbus problems.
parent 6eea8fd8
......@@ -97,6 +97,52 @@ KStars::KStars( bool doSplash, bool clockrun, const QString &startdate )
new KstarsAdaptor(this); // NOTE the weird case convention, which cannot be changed as the file is generated by the moc.
#ifdef Q_OS_OSX
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString path=env.value("PATH","");
env.insert("PATH","/usr/bin:/usr/local/bin:\"" + QCoreApplication::applicationDirPath() + "\":" + path);
QProcess dbusCheck;
dbusCheck.setProcessEnvironment(env);
dbusCheck.start("launchctl list");
dbusCheck.waitForFinished();
QString output(dbusCheck.readAllStandardOutput());
QString pluginsDir=QDir(QCoreApplication::applicationDirPath() + "/../PlugIns").absolutePath();
QString dbusPlist=pluginsDir + "/dbus/org.freedesktop.dbus-kstars.plist";
if(!output.contains("homebrew.mxcl.dbus")&&!output.contains("org.freedesktop.dbus")&&QFileInfo(dbusPlist).exists()){
QFile file(dbusPlist);
if(file.open(QIODevice::ReadOnly))
{
QTextStream in(&file);
QString pListText=in.readAll();
file.close();
int programArgsLeft=pListText.indexOf("<key>ProgramArguments</key>");
int programArgsRight=pListText.indexOf("</array>" , programArgsLeft) + 8 - programArgsLeft;
QString currentProgramArgs=pListText.mid(programArgsLeft,programArgsRight);
QString newProgramArguments = "" \
"<key>ProgramArguments</key>\n" \
" <array>\n" \
" <string>" + QCoreApplication::applicationDirPath() + "/dbus-daemon</string>\n" \
" <string>--nofork</string>\n" \
" <string>--config-file=" + pluginsDir + "/dbus/kstars.conf</string>\n" \
" </array>";
pListText.replace(currentProgramArgs, newProgramArguments);
if(file.open(QIODevice::WriteOnly)){
QTextStream stream( &file );
stream << pListText;
file.close();
dbusCheck.start("chmod 775 " + dbusPlist);
dbusCheck.waitForFinished();
dbusCheck.start("launchctl load -w \"" + dbusPlist + "\"");
dbusCheck.waitForFinished();
}
}
}
#endif
QDBusConnection::sessionBus().registerObject("/KStars", this);
QDBusConnection::sessionBus().registerService("org.kde.kstars");
......
......@@ -991,6 +991,12 @@ void ScriptBuilder::slotRunScript()
#endif
QProcess p;
#ifdef Q_OS_OSX
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString path=env.value("PATH","");
env.insert("PATH","/usr/local/bin:" + QCoreApplication::applicationDirPath() + ":" + path);
p.setProcessEnvironment(env);
#endif
p.start(f.fileName());
if( !p.waitForStarted() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment