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.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/core/launcher/applauncher.cpp b/core/launcher/applauncher.cpp
index 0db99dd..f161e98 100644
--- a/core/launcher/applauncher.cpp
+++ b/core/launcher/applauncher.cpp
@@ -6,83 +6,82 @@
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef QTOPIA_INTERNAL_PRELOADACCESS
#define QTOPIA_INTERNAL_PRELOADACCESS
#endif
#ifndef QTOPIA_INTERNAL_FILEOPERATIONS
#define QTOPIA_INTERNAL_FILEOPERATIONS
#endif
#ifndef QTOPIA_PROGRAM_MONITOR
#define QTOPIA_PROGRAM_MONITOR
#endif
-#include <qtopia/global.h>
+#include <opie2/oglobal.h>
#ifndef Q_OS_WIN32
#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 <qfile.h>
#include <qfileinfo.h>
#include <qtopia/qcopenvelope_qws.h>
#include <qtopia/applnk.h>
#include <qtopia/qpeapplication.h>
#include <qtopia/config.h>
#include <qtopia/global.h>
#include "applauncher.h"
#include "documentlist.h"
-#include "launcherglobal.h"
const int AppLauncher::RAISE_TIMEOUT_MS = 5000;
//---------------------------------------------------------------------------
static AppLauncher* appLauncherPtr;
const int appStopEventID = 1290;
class AppStoppedEvent : public QCustomEvent
{
public:
AppStoppedEvent(int pid, int status)
: QCustomEvent( appStopEventID ), mPid(pid), mStatus(status) { }
int pid() { return mPid; }
int status() { return mStatus; }
private:
int mPid, mStatus;
};
AppLauncher::AppLauncher(QObject *parent, const char *name)
: QObject(parent, name), qlPid(0), qlReady(FALSE),
@@ -383,92 +382,92 @@ void AppLauncher::sigStopped(int sigPid, int sigStatus)
switch( exitStatus ) {
case SIGABRT: sig = "SIGABRT"; break;
case SIGALRM: sig = "SIGALRM"; break;
case SIGBUS: sig = "SIGBUS"; break;
case SIGFPE: sig = "SIGFPE"; break;
case SIGHUP: sig = "SIGHUP"; break;
case SIGILL: sig = "SIGILL"; break;
case SIGKILL: sig = "SIGKILL"; break;
case SIGPIPE: sig = "SIGPIPE"; break;
case SIGQUIT: sig = "SIGQUIT"; break;
case SIGSEGV: sig = "SIGSEGV"; break;
case SIGTERM: sig = "SIGTERM"; break;
case SIGTRAP: sig = "SIGTRAP"; break;
default: sig = QString("Unkown %1").arg(exitStatus);
}
if ( preloadDisabled )
sig += tr("<qt><p>Fast loading has been disabled for this application. Tap and hold the application icon to reenable it.</qt>");
QString str = tr("<qt><b>%1</b> was terminated due to signal code %2</qt>").arg( app->name() ).arg( sig );
QMessageBox::information(0, tr("Application terminated"), str );
} else {
if ( exitStatus == 255 ) { //could not find app (because global returns -1)
QMessageBox::information(0, tr("Application not found"), tr("<qt>Could not locate application <b>%1</b></qt>").arg( app->exec() ) );
} else {
- QFileInfo fi(Opie::Global::tempDir() + "qcop-msg-" + appName);
+ QFileInfo fi(OGlobal::tempDirPath() + "qcop-msg-" + appName);
if ( fi.exists() && fi.size() ) {
emit terminated(sigPid, appName);
qWarning("Re executing obmitted for %s", appName.latin1() );
// execute( appName, QString::null );
return;
}
}
}
#endif
emit terminated(sigPid, appName);
}
#else
void AppLauncher::sigStopped(int sigPid, int sigStatus)
{
qDebug("Unhandled signal : AppLauncher::sigStopped(int sigPid, int sigStatus)");
}
#endif // Q_OS_WIN32
bool AppLauncher::isRunning(const QString &app)
{
for (QMap<int,QString>::ConstIterator it = runningApps.begin(); it != runningApps.end(); ++it) {
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() );
runningApps.remove( it.key() );
return FALSE;
}
#endif
return TRUE;
}
}
return FALSE;
}
bool AppLauncher::executeBuiltin(const QString &c, const QString &document)
{
- Global::Command* builtin = Opie::Global::builtinCommands();
- QGuardedPtr<QWidget> *running = Opie::Global::builtinRunning();
+ Global::Command* builtin = OGlobal::builtinCommands();
+ QGuardedPtr<QWidget> *running = OGlobal::builtinRunning();
// Attempt to execute the app using a builtin class for the app
if (builtin) {
for (int i = 0; builtin[i].file; i++) {
if ( builtin[i].file == c ) {
if ( running[i] ) {
if ( !document.isNull() && builtin[i].documentary )
Global::setDocument(running[i], document);
running[i]->raise();
running[i]->show();
running[i]->setActiveWindow();
} else {
running[i] = builtin[i].func( builtin[i].maximized );
}
#ifndef QT_NO_COP
QCopEnvelope e("QPE/System", "notBusy(QString)" );
e << c; // that was quick ;-)
#endif
return TRUE;
}
}
}
// Convert the command line in to a list of arguments
@@ -476,49 +475,49 @@ bool AppLauncher::executeBuiltin(const QString &c, const QString &document)
QString ap=list[0];
if ( ap == "suspend" ) { // No tr
QWSServer::processKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
return TRUE;
}
return FALSE;
}
bool AppLauncher::execute(const QString &c, const QString &docParam, bool noRaise)
{
qWarning("AppLauncher::execute");
// Convert the command line in to a list of arguments
QStringList list = QStringList::split(QRegExp(" *"),c);
if ( !docParam.isEmpty() )
list.append( docParam );
QString appName = list[0];
if ( isRunning(appName) ) {
QCString channel = "QPE/Application/";
channel += appName.latin1();
// Need to lock it to avoid race conditions with QPEApplication::processQCopFile
- QFile f(Opie::Global::tempDir() + "qcop-msg-" + appName);
+ QFile f(OGlobal::tempDirPath() + "qcop-msg-" + appName);
if ( !noRaise && f.open(IO_WriteOnly | IO_Append) ) {
#ifndef Q_OS_WIN32
flock(f.handle(), LOCK_EX);
#endif
QDataStream ds(&f);
QByteArray b;
QDataStream bstream(b, IO_WriteOnly);
if ( !f.size() ) {
ds << channel << QCString("raise()") << b;
if ( !waitingHeartbeat.contains( appName ) && appKillerName != appName ) {
int id = startTimer(RAISE_TIMEOUT_MS);
waitingHeartbeat.insert( appName, id );
}
}
if ( !docParam.isEmpty() ) {
bstream << docParam;
ds << channel << QCString("setDocument(QString)") << b;
}
f.flush();
#ifndef Q_OS_WIN32
flock(f.handle(), LOCK_UN);
#endif