Commit a07f301f authored by Robert Lancaster's avatar Robert Lancaster Committed by Jasem Mutlaq

This patch should add a function for KStars on OS X to detect if PTPCamera has...

This patch should add a function for KStars on OS X to detect if PTPCamera has commandeered the camera and provide the user with an option to quit that program before trying to start the indiserver. It also simplifies the way that KStars checks for a running indiserver on OS X.
parent b11c408a
...@@ -575,6 +575,25 @@ bool EkosManager::start() ...@@ -575,6 +575,25 @@ bool EkosManager::start()
connect(INDIListener::Instance(), SIGNAL(deviceRemoved(ISD::GDInterface *)), this, connect(INDIListener::Instance(), SIGNAL(deviceRemoved(ISD::GDInterface *)), this,
SLOT(removeDevice(ISD::GDInterface *)), Qt::DirectConnection); SLOT(removeDevice(ISD::GDInterface *)), Qt::DirectConnection);
#ifdef Q_OS_OSX
if (localMode||currentProfile->host=="localhost")
if (isRunning("PTPCamera"))
if (KMessageBox::Yes ==
i18n("Ekos detected that PTP Camera is running and may prevent a Canon or Nikon camera from connecting to Ekos. Do you want to quit PTP Camera now?"),
i18n("PTP Camera"), KStandardGuiItem::yes(), KStandardGuiItem::no(),
//TODO is there a better way to do this.
QProcess p;
p.start("killall PTPCamera");
if (localMode) if (localMode)
{ {
if (isRunning("indiserver")) if (isRunning("indiserver"))
...@@ -2003,17 +2022,19 @@ bool EkosManager::isRunning(const QString &process) ...@@ -2003,17 +2022,19 @@ bool EkosManager::isRunning(const QString &process)
{ {
QProcess ps; QProcess ps;
#ifdef Q_OS_OSX #ifdef Q_OS_OSX
ps.start("ps", QStringList() << "-o" ps.start("pgrep", QStringList() << process);
<< "comm"); ps.waitForFinished();
QString output = ps.readAllStandardOutput();
return output.length()>0;
#else #else
ps.start("ps", QStringList() << "-o" ps.start("ps", QStringList() << "-o"
<< "comm" << "comm"
<< "--no-headers" << "--no-headers"
<< "-C" << process); << "-C" << process);
ps.waitForFinished(); ps.waitForFinished();
QString output = ps.readAllStandardOutput(); QString output = ps.readAllStandardOutput();
return output.contains(process); return output.contains(process);
} }
void EkosManager::addObjectToScheduler(SkyObject *object) void EkosManager::addObjectToScheduler(SkyObject *object)
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