1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
/*
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 _TDELAUNCHER_H_
#define _TDELAUNCHER_H_
#include <sys/types.h>
#include <unistd.h>
#include <time.h>
#include <tqstring.h>
#include <tqvaluelist.h>
#include <tqsocketnotifier.h>
#include <tqptrlist.h>
#include <tqtimer.h>
#include <dcopclient.h>
#include <tdeio/connection.h>
#include <ksock.h>
#include <kurl.h>
#include <tdeuniqueapplication.h>
#include <kservice.h>
#include "autostart.h"
class IdleSlave : public TQObject
{
TQ_OBJECT
public:
IdleSlave(TDESocket *socket);
bool match( const TQString &protocol, const TQString &host, bool connected);
void connect( const TQString &app_socket);
pid_t pid() const { return mPid;}
int age(time_t now);
void reparseConfiguration();
bool onHold(const KURL &url);
TQString protocol() const {return mProtocol;}
signals:
void statusUpdate(IdleSlave *);
protected slots:
void gotInput();
protected:
TDEIO::Connection mConn;
TQString mProtocol;
TQString mHost;
bool mConnected;
pid_t mPid;
time_t mBirthDate;
bool mOnHold;
KURL mUrl;
};
class SlaveWaitRequest
{
public:
pid_t pid;
DCOPClientTransaction *transaction;
};
class TDELaunchRequest
{
public:
TQCString name;
TQValueList<TQCString> arg_list;
TQCString dcop_name;
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;
TQString errorMsg;
#ifdef TQ_WS_X11
TQCString startup_id; // "" is the default, "0" for none
TQCString startup_dpy; // Display to send startup notification to.
#endif
TQValueList<TQCString> envs; // env. variables to be app's environment
TQCString cwd;
};
struct serviceResult
{
int result; // 0 means success. > 0 means error (-1 means pending)
TQCString dcopName; // Contains DCOP name on success
TQString error; // Contains error description on failure.
pid_t pid;
};
class TDELauncher : public TDEApplication, public DCOPObject
{
TQ_OBJECT
public:
TDELauncher(int _tdeinitSocket, bool new_startup);
~TDELauncher();
void close();
static void destruct(int exit_code); // exit!
// DCOP
virtual bool process(const TQCString &fun, const TQByteArray &data,
TQCString &replyType, TQByteArray &replyData);
virtual QCStringList functions();
virtual QCStringList interfaces();
protected:
void processDied(pid_t pid, long exitStatus);
void requestStart(TDELaunchRequest *request);
void requestDone(TDELaunchRequest *request);
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 = "",
bool blind = false, bool autoStart = false );
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);
bool tdeinit_exec(const TQString &app, const TQStringList &args,
const TQValueList<TQCString> &envs, TQCString startup_id, bool wait);
void waitForSlave(pid_t pid);
void autoStart(int phase);
void createArgs( TDELaunchRequest *request, const KService::Ptr service,
const TQStringList &url);
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);
void queueRequest(TDELaunchRequest *);
void send_service_startup_info( TDELaunchRequest *request, KService::Ptr service, const TQCString& startup_id,
const TQValueList<TQCString> &envs );
void cancel_service_startup_info( TDELaunchRequest *request, const TQCString& startup_id,
const TQValueList<TQCString> &envs );
public slots:
void slotAutoStart();
void slotDequeue();
void slotKDEInitData(int);
void slotAppRegistered(const TQCString &appId);
void slotSlaveStatus(IdleSlave *);
void acceptSlave( TDESocket *);
void slotSlaveGone();
void idleTimeout();
protected:
TQPtrList<TDELaunchRequest> requestList; // Requests being handled
TQPtrList<TDELaunchRequest> requestQueue; // Requests waiting to being handled
int tdeinitSocket;
TQSocketNotifier *tdeinitNotifier;
serviceResult DCOPresult;
TDELaunchRequest *lastRequest;
TQPtrList<SlaveWaitRequest> mSlaveWaitRequest;
TQString mPoolSocketName;
TDEServerSocket *mPoolSocket;
TQPtrList<IdleSlave> mSlaveList;
TQTimer mTimer;
TQTimer mAutoTimer;
bool bProcessingQueue;
AutoStart mAutoStart;
TQCString mSlaveDebug;
TQCString mSlaveValgrind;
TQCString mSlaveValgrindSkin;
bool dontBlockReading;
bool newStartup;
#ifdef TQ_WS_X11
Display *mCached_dpy;
#endif
};
#endif
|