You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
201 lines
6.1 KiB
201 lines
6.1 KiB
15 years ago
|
/*
|
||
|
This file is part of the KDE libraries
|
||
|
Copyright (c) 1999 Waldo Bastian <bastian@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License version 2 as published by the Free Software Foundation.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#ifndef _KLAUNCHER_H_
|
||
|
#define _KLAUNCHER_H_
|
||
|
|
||
|
#include <sys/types.h>
|
||
|
#include <unistd.h>
|
||
|
#include <time.h>
|
||
15 years ago
|
#include <tqstring.h>
|
||
|
#include <tqvaluelist.h>
|
||
|
#include <tqsocketnotifier.h>
|
||
|
#include <tqptrlist.h>
|
||
|
#include <tqtimer.h>
|
||
15 years ago
|
|
||
|
#include <dcopclient.h>
|
||
12 years ago
|
#include <tdeio/connection.h>
|
||
15 years ago
|
#include <ksock.h>
|
||
|
#include <kurl.h>
|
||
|
#include <kuniqueapplication.h>
|
||
|
|
||
|
#include <kservice.h>
|
||
|
|
||
|
#include "autostart.h"
|
||
|
|
||
14 years ago
|
class IdleSlave : public TQObject
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
|
public:
|
||
12 years ago
|
IdleSlave(TDESocket *socket);
|
||
15 years ago
|
bool match( const TQString &protocol, const TQString &host, bool connected);
|
||
|
void connect( const TQString &app_socket);
|
||
15 years ago
|
pid_t pid() const { return mPid;}
|
||
|
int age(time_t now);
|
||
|
void reparseConfiguration();
|
||
|
bool onHold(const KURL &url);
|
||
15 years ago
|
TQString protocol() const {return mProtocol;}
|
||
15 years ago
|
|
||
|
signals:
|
||
|
void statusUpdate(IdleSlave *);
|
||
|
|
||
|
protected slots:
|
||
|
void gotInput();
|
||
|
|
||
|
protected:
|
||
12 years ago
|
TDEIO::Connection mConn;
|
||
15 years ago
|
TQString mProtocol;
|
||
|
TQString mHost;
|
||
15 years ago
|
bool mConnected;
|
||
|
pid_t mPid;
|
||
|
time_t mBirthDate;
|
||
|
bool mOnHold;
|
||
|
KURL mUrl;
|
||
|
};
|
||
|
|
||
|
class SlaveWaitRequest
|
||
|
{
|
||
|
public:
|
||
|
pid_t pid;
|
||
|
DCOPClientTransaction *transaction;
|
||
|
};
|
||
|
|
||
12 years ago
|
class TDELaunchRequest
|
||
15 years ago
|
{
|
||
|
public:
|
||
15 years ago
|
TQCString name;
|
||
|
TQValueList<TQCString> arg_list;
|
||
|
TQCString dcop_name;
|
||
15 years ago
|
enum status_t { Init = 0, Launching, Running, Error, Done };
|
||
|
pid_t pid;
|
||
|
status_t status;
|
||
|
DCOPClientTransaction *transaction;
|
||
|
KService::DCOPServiceType_t dcop_service_type;
|
||
|
bool autoStart;
|
||
15 years ago
|
TQString errorMsg;
|
||
15 years ago
|
#ifdef Q_WS_X11
|
||
15 years ago
|
TQCString startup_id; // "" is the default, "0" for none
|
||
|
TQCString startup_dpy; // Display to send startup notification to.
|
||
15 years ago
|
#endif
|
||
15 years ago
|
TQValueList<TQCString> envs; // env. variables to be app's environment
|
||
|
TQCString cwd;
|
||
15 years ago
|
};
|
||
|
|
||
|
struct serviceResult
|
||
|
{
|
||
|
int result; // 0 means success. > 0 means error (-1 means pending)
|
||
15 years ago
|
TQCString dcopName; // Contains DCOP name on success
|
||
|
TQString error; // Contains error description on failure.
|
||
15 years ago
|
pid_t pid;
|
||
|
};
|
||
|
|
||
12 years ago
|
class TDELauncher : public TDEApplication, public DCOPObject
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
|
|
||
|
public:
|
||
12 years ago
|
TDELauncher(int _tdeinitSocket, bool new_startup);
|
||
15 years ago
|
|
||
12 years ago
|
~TDELauncher();
|
||
15 years ago
|
|
||
|
void close();
|
||
|
static void destruct(int exit_code); // exit!
|
||
|
|
||
|
// DCOP
|
||
15 years ago
|
virtual bool process(const TQCString &fun, const TQByteArray &data,
|
||
|
TQCString &replyType, TQByteArray &replyData);
|
||
15 years ago
|
virtual QCStringList functions();
|
||
|
virtual QCStringList interfaces();
|
||
|
|
||
|
protected:
|
||
|
void processDied(pid_t pid, long exitStatus);
|
||
|
|
||
12 years ago
|
void requestStart(TDELaunchRequest *request);
|
||
|
void requestDone(TDELaunchRequest *request);
|
||
15 years ago
|
|
||
15 years ago
|
void setLaunchEnv(const TQCString &name, const TQCString &value);
|
||
|
void exec_blind(const TQCString &name, const TQValueList<TQCString> &arg_list,
|
||
|
const TQValueList<TQCString> &envs, const TQCString& startup_id = "" );
|
||
|
bool start_service(KService::Ptr service, const TQStringList &urls,
|
||
|
const TQValueList<TQCString> &envs, const TQCString& startup_id = "",
|
||
15 years ago
|
bool blind = false, bool autoStart = false );
|
||
15 years ago
|
bool start_service_by_name(const TQString &serviceName, const TQStringList &urls,
|
||
|
const TQValueList<TQCString> &envs, const TQCString& startup_id, bool blind);
|
||
|
bool start_service_by_desktop_path(const TQString &serviceName, const TQStringList &urls,
|
||
|
const TQValueList<TQCString> &envs, const TQCString& startup_id, bool blind);
|
||
|
bool start_service_by_desktop_name(const TQString &serviceName, const TQStringList &urls,
|
||
|
const TQValueList<TQCString> &envs, const TQCString& startup_id, bool blind);
|
||
13 years ago
|
bool tdeinit_exec(const TQString &app, const TQStringList &args,
|
||
15 years ago
|
const TQValueList<TQCString> &envs, TQCString startup_id, bool wait);
|
||
15 years ago
|
|
||
|
void waitForSlave(pid_t pid);
|
||
|
|
||
|
void autoStart(int phase);
|
||
|
|
||
12 years ago
|
void createArgs( TDELaunchRequest *request, const KService::Ptr service,
|
||
15 years ago
|
const TQStringList &url);
|
||
15 years ago
|
|
||
15 years ago
|
pid_t requestHoldSlave(const KURL &url, const TQString &app_socket);
|
||
|
pid_t requestSlave(const TQString &protocol, const TQString &host,
|
||
|
const TQString &app_socket, TQString &error);
|
||
15 years ago
|
|
||
|
|
||
12 years ago
|
void queueRequest(TDELaunchRequest *);
|
||
15 years ago
|
|
||
12 years ago
|
void send_service_startup_info( TDELaunchRequest *request, KService::Ptr service, const TQCString& startup_id,
|
||
15 years ago
|
const TQValueList<TQCString> &envs );
|
||
12 years ago
|
void cancel_service_startup_info( TDELaunchRequest *request, const TQCString& startup_id,
|
||
15 years ago
|
const TQValueList<TQCString> &envs );
|
||
15 years ago
|
|
||
|
public slots:
|
||
|
void slotAutoStart();
|
||
|
void slotDequeue();
|
||
|
void slotKDEInitData(int);
|
||
15 years ago
|
void slotAppRegistered(const TQCString &appId);
|
||
14 years ago
|
void slotSlaveStatus(IdleSlave *);
|
||
12 years ago
|
void acceptSlave( TDESocket *);
|
||
15 years ago
|
void slotSlaveGone();
|
||
|
void idleTimeout();
|
||
|
|
||
|
protected:
|
||
12 years ago
|
TQPtrList<TDELaunchRequest> requestList; // Requests being handled
|
||
|
TQPtrList<TDELaunchRequest> requestQueue; // Requests waiting to being handled
|
||
13 years ago
|
int tdeinitSocket;
|
||
|
TQSocketNotifier *tdeinitNotifier;
|
||
15 years ago
|
serviceResult DCOPresult;
|
||
12 years ago
|
TDELaunchRequest *lastRequest;
|
||
15 years ago
|
TQPtrList<SlaveWaitRequest> mSlaveWaitRequest;
|
||
|
TQString mPoolSocketName;
|
||
12 years ago
|
TDEServerSocket *mPoolSocket;
|
||
15 years ago
|
TQPtrList<IdleSlave> mSlaveList;
|
||
|
TQTimer mTimer;
|
||
|
TQTimer mAutoTimer;
|
||
15 years ago
|
bool bProcessingQueue;
|
||
|
AutoStart mAutoStart;
|
||
15 years ago
|
TQCString mSlaveDebug;
|
||
|
TQCString mSlaveValgrind;
|
||
|
TQCString mSlaveValgrindSkin;
|
||
15 years ago
|
bool dontBlockReading;
|
||
|
bool newStartup;
|
||
|
#ifdef Q_WS_X11
|
||
|
Display *mCached_dpy;
|
||
|
#endif
|
||
|
};
|
||
|
#endif
|