summaryrefslogtreecommitdiff
path: root/core/launcher/applauncher.cpp
Side-by-side diff
Diffstat (limited to 'core/launcher/applauncher.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/applauncher.cpp83
1 files changed, 40 insertions, 43 deletions
diff --git a/core/launcher/applauncher.cpp b/core/launcher/applauncher.cpp
index 5a5517c..7000346 100644
--- a/core/launcher/applauncher.cpp
+++ b/core/launcher/applauncher.cpp
@@ -26,40 +26,37 @@
#endif
#ifndef QTOPIA_PROGRAM_MONITOR
#define QTOPIA_PROGRAM_MONITOR
#endif
+
+#include "applauncher.h"
+#include "documentlist.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
#include <opie2/oglobal.h>
+#include <qtopia/qcopenvelope_qws.h>
+#include <qtopia/qpeapplication.h>
+using namespace Opie::Core;
-#ifndef Q_OS_WIN32
+/* QT */
+#include <qtimer.h>
+#include <qwindowsystem_qws.h>
+#include <qmessagebox.h>
+#include <qfileinfo.h>
+
+/* STD */
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/file.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <errno.h>
-#else
-#include <process.h>
-#include <windows.h>
-#include <winbase.h>
-#endif
-
#include <signal.h>
#include <sys/types.h>
#include <stdlib.h>
-#include <qtimer.h>
-#include <qwindowsystem_qws.h>
-#include <qmessagebox.h>
-#include <qfileinfo.h>
-
-#include <qtopia/qcopenvelope_qws.h>
-#include <qtopia/qpeapplication.h>
-
-#include "applauncher.h"
-#include "documentlist.h"
-
-using namespace Opie::Core;
const int AppLauncher::RAISE_TIMEOUT_MS = 5000;
//---------------------------------------------------------------------------
@@ -126,9 +123,9 @@ AppLauncher::~AppLauncher()
/* We use the QCopChannel of the app as an indicator of when it has been launched
so that we can disable the busy indicators */
void AppLauncher::newQcopChannel(const QString& channelName)
{
-// qDebug("channel %s added", channelName.data() );
+// odebug << "channel " << channelName.data() << " added" << oendl;
QString prefix("QPE/Application/");
if (channelName.startsWith(prefix)) {
{
QCopEnvelope e("QPE/System", "newChannel(QString)");
@@ -140,9 +137,9 @@ void AppLauncher::newQcopChannel(const QString& channelName)
QCopEnvelope e("QPE/System", "notBusy(QString)");
e << appName;
}
} else if (channelName.startsWith("QPE/QuickLauncher-")) {
- qDebug("Registered %s", channelName.latin1());
+ odebug << "Registered " << channelName << "" << oendl;
int pid = channelName.mid(18).toInt();
if (pid == qlPid)
qlReady = TRUE;
}
@@ -179,9 +176,9 @@ void AppLauncher::received(const QCString& msg, const QByteArray& data)
stream >> appName;
if ( !executeBuiltin( appName, QString::null ) ) {
if ( !waitingHeartbeat.contains( appName ) && appKillerName != appName ) {
- //qDebug( "Raising: %s", appName.latin1() );
+ //odebug << "Raising: " << appName << "" << oendl;
QCString channel = "QPE/Application/";
channel += appName.latin1();
// Need to lock it to avoid race conditions with QPEApplication::processQCopFile
@@ -216,9 +213,9 @@ void AppLauncher::received(const QCString& msg, const QByteArray& data)
e << apps;
} else if ( msg == "appRaised(QString)" ) {
QString appName;
stream >> appName;
- qDebug("Got a heartbeat from %s", appName.latin1());
+ odebug << "Got a heartbeat from " << appName << "" << oendl;
QMap<QString,int>::Iterator it = waitingHeartbeat.find(appName);
if ( it != waitingHeartbeat.end() ) {
killTimer( *it );
waitingHeartbeat.remove(it);
@@ -239,14 +236,14 @@ void AppLauncher::signalHandler(int)
#ifndef Q_OS_WIN32
int status;
pid_t pid = waitpid(-1, &status, WNOHANG);
/* if (pid == 0 || &status == 0 ) {
- qDebug("hmm, could not get return value from signal");
+ odebug << "hmm, could not get return value from signal" << oendl;
}
*/
QApplication::postEvent(appLauncherPtr, new AppStoppedEvent(pid, status) );
#else
- qDebug("Unhandled signal see by AppLauncher::signalHandler(int)");
+ odebug << "Unhandled signal see by AppLauncher::signalHandler(int)" << oendl;
#endif
}
bool AppLauncher::event(QEvent *e)
@@ -272,9 +269,9 @@ void AppLauncher::timerEvent( QTimerEvent *e )
appKillerName = it.key();
killTimer( id );
waitingHeartbeat.remove( it );
- // qDebug("Checking in on %s", appKillerName.latin1());
+ // odebug << "Checking in on " << appKillerName << "" << oendl;
// We store this incase the application responds while we're
// waiting for user input so we know not to delete ourselves.
appKillerBox = new QMessageBox(tr("Application Problem"),
@@ -283,9 +280,9 @@ void AppLauncher::timerEvent( QTimerEvent *e )
QMessageBox::Warning, QMessageBox::Yes,
QMessageBox::No | QMessageBox::Default,
QMessageBox::NoButton);
if (appKillerBox->exec() == QMessageBox::Yes) {
- // qDebug("Killing the app!!! Bwuhahahaha!");
+ // odebug << "Killing the app!!! Bwuhahahaha!" << oendl;
int pid = pidForName(appKillerName);
if ( pid > 0 )
kill( pid );
}
@@ -314,19 +311,19 @@ void AppLauncher::sigStopped(int sigPid, int sigStatus)
QMap<int,QString>::Iterator it = runningApps.find( sigPid );
if ( it == runningApps.end() ) {
if ( sigPid == qlPid ) {
- qDebug( "quicklauncher stopped" );
+ odebug << "quicklauncher stopped" << oendl;
qlPid = 0;
qlReady = FALSE;
QFile::remove("/tmp/qcop-msg-quicklauncher" );
QTimer::singleShot( 2000, this, SLOT(createQuickLauncher()) );
}
/*
if ( sigPid == -1 )
- qDebug("non-qtopia application exited (disregarded)");
+ odebug << "non-qtopia application exited (disregarded)" << oendl;
else
- qDebug("==== no pid matching %d in list, definite bug", sigPid);
+ odebug << "==== no pid matching " << sigPid << " in list, definite bug" << oendl;
*/
return;
}
QString appName = *it;
@@ -368,9 +365,9 @@ void AppLauncher::sigStopped(int sigPid, int sigStatus)
}
/*
// debug info
for (it = runningApps.begin(); it != runningApps.end(); ++it) {
- qDebug("running according to internal list: %s, with pid %d", (*it).data(), it.key() );
+ odebug << "running according to internal list: " << (*it).data() << ", with pid " << it.key() << "" << oendl;
}
*/
#ifdef QTOPIA_PROGRAM_MONITOR
@@ -402,9 +399,9 @@ void AppLauncher::sigStopped(int sigPid, int sigStatus)
} else {
QFileInfo fi(QString::fromLatin1("/tmp/qcop-msg-") + appName);
if ( fi.exists() && fi.size() ) {
emit terminated(sigPid, appName);
- qWarning("Re executing obmitted for %s", appName.latin1() );
+ owarn << "Re executing obmitted for " << appName << "" << oendl;
// execute( appName, QString::null );
return;
}
}
@@ -416,9 +413,9 @@ void AppLauncher::sigStopped(int sigPid, int sigStatus)
}
#else
void AppLauncher::sigStopped(int sigPid, int sigStatus)
{
- qDebug("Unhandled signal : AppLauncher::sigStopped(int sigPid, int sigStatus)");
+ odebug << "Unhandled signal : AppLauncher::sigStopped(int sigPid, int sigStatus)" << oendl;
}
#endif // Q_OS_WIN32
bool AppLauncher::isRunning(const QString &app)
@@ -427,9 +424,9 @@ bool AppLauncher::isRunning(const QString &app)
if ( *it == app ) {
#ifdef Q_OS_UNIX
pid_t t = ::__getpgid( it.key() );
if ( t == -1 ) {
- qDebug("appLauncher bug, %s believed running, but pid %d is not existing", app.data(), it.key() );
+ odebug << "appLauncher bug, " << app.data() << " believed running, but pid " << it.key() << " is not existing" << oendl;
runningApps.remove( it.key() );
return FALSE;
}
#endif
@@ -480,9 +477,9 @@ bool AppLauncher::executeBuiltin(const QString &c, const QString &document)
}
bool AppLauncher::execute(const QString &c, const QString &docParam, bool noRaise)
{
- qWarning("AppLauncher::execute '%s' '%s'", (const char*) c, (const char*) docParam );
+ owarn << "AppLauncher::execute '" << c << "' '" << docParam << "'" << oendl;
// Convert the command line in to a list of arguments
QStringList list = QStringList::split(QRegExp(" *"),c);
QStringList arglist = QStringList::split(QRegExp(" *"),docParam);
for ( QStringList::Iterator it = arglist.begin(); it != arglist.end(); ++it )
@@ -547,9 +544,9 @@ bool AppLauncher::execute(const QString &c, const QString &docParam, bool noRais
if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".dylib" ) ) {
#else
if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".so" ) ) {
#endif /* Q_OS_MACX */
- qDebug( "Quick launching: %s", args[0] );
+ odebug << "Quick launching: " << args[0] << "" << oendl;
if ( getuid() == 0 )
setpriority( PRIO_PROCESS, qlPid, 0 );
QCString qlch("QPE/QuickLauncher-");
qlch += QString::number(qlPid);
@@ -583,9 +580,9 @@ bool AppLauncher::execute(const QString &c, const QString &docParam, bool noRais
for (int i=0; i < slist.count(); i++)
proc->addArgument(args[i]);
connect(proc, SIGNAL(processExited()), this, SLOT(processExited()));
if (!proc->start()){
- qDebug("Unable to start application %s", args[0]);
+ odebug << "Unable to start application " << args[0] << "" << oendl;
}else{
PROCESS_INFORMATION *procInfo = (PROCESS_INFORMATION *)proc->processIdentifier();
if (procInfo){
DWORD pid = procInfo->dwProcessId;
@@ -593,13 +590,13 @@ bool AppLauncher::execute(const QString &c, const QString &docParam, bool noRais
runningAppsProc.append(proc);
emit launched(pid, QString(args[0]));
QCopEnvelope e("QPE/System", "busy()");
}else{
- qDebug("Unable to read process inforation #1 for %s", args[0]);
+ odebug << "Unable to read process inforation #1 for " << args[0] << "" << oendl;
}
}
}else{
- qDebug("Unable to create process for application %s", args[0]);
+ odebug << "Unable to create process for application " << args[0] << "" << oendl;
return FALSE;
}
#endif
#endif //QT_NO_QWS_MULTIPROCESS
@@ -677,18 +674,18 @@ void AppLauncher::createQuickLauncher()
// Used only by Win32
void AppLauncher::processExited()
{
#ifdef Q_OS_WIN32
- qDebug("AppLauncher::processExited()");
+ odebug << "AppLauncher::processExited()" << oendl;
bool found = FALSE;
QProcess *proc = (QProcess *) sender();
if (!proc){
- qDebug("Interanl error NULL proc");
+ odebug << "Interanl error NULL proc" << oendl;
return;
}
QString appName = proc->arguments()[0];
- qDebug("Removing application %s", appName.latin1());
+ odebug << "Removing application " << appName << "" << oendl;
runningAppsProc.remove(proc);
QMap<QString,int>::Iterator hbit = waitingHeartbeat.find(appName);
if ( hbit != waitingHeartbeat.end() ) {
@@ -713,9 +710,9 @@ void AppLauncher::processExited()
if (found){
emit terminated(it.key(), it.data());
runningApps.remove(it.key());
}else{
- qDebug("Internal error application %s not listed as running", appName.latin1());
+ odebug << "Internal error application " << appName << " not listed as running" << oendl;
}
#endif
}