• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KInit

klauncher.h

Go to the documentation of this file.
00001 /*
00002    This file is part of the KDE libraries
00003    Copyright (c) 1999 Waldo Bastian <bastian@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License version 2 as published by the Free Software Foundation.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef _KLAUNCHER_H_
00021 #define _KLAUNCHER_H_
00022 
00023 #include "autostart.h"
00024 
00025 #include <sys/types.h>
00026 #include <unistd.h>
00027 #include <time.h>
00028 
00029 #ifdef Q_WS_X11
00030 #include <X11/Xlib.h>
00031 #include <fixx11h.h>
00032 #endif
00033 
00034 #include <QtCore/QString>
00035 #include <QtCore/QSocketNotifier>
00036 #include <QtCore/QTimer>
00037 #include <QtCore/QList>
00038 #include <QtCore/QObject>
00039 #include <QtDBus/QtDBus>
00040 
00041 #include <kservice.h>
00042 #include <kprocess.h>
00043 #include <kurl.h>
00044 #include <kio/connection.h>
00045 
00046 class IdleSlave : public QObject
00047 {
00048    Q_OBJECT
00049 public:
00050    explicit IdleSlave(QObject *parent);
00051    bool match( const QString &protocol, const QString &host, bool connected);
00052    void connect( const QString &app_socket);
00053    pid_t pid() const { return mPid;}
00054    int age(time_t now);
00055    void reparseConfiguration();
00056    bool onHold(const KUrl &url);
00057    QString protocol() const   {return mProtocol;}
00058 
00059 Q_SIGNALS:
00060    void statusUpdate(IdleSlave *);
00061 
00062 protected Q_SLOTS:
00063    void gotInput();
00064 
00065 public:
00066    KIO::Connection mConn;
00067 protected:
00068    QString mProtocol;
00069    QString mHost;
00070    bool mConnected;
00071    pid_t mPid;
00072    time_t mBirthDate;
00073    bool mOnHold;
00074    KUrl mUrl;
00075 };
00076 
00077 class SlaveWaitRequest
00078 {
00079 public:
00080    pid_t pid;
00081    QDBusMessage transaction;
00082 };
00083 
00084 class KLaunchRequest
00085 {
00086 public:
00087    QString name;
00088    QStringList arg_list;
00089    QString dbus_name;
00090    enum status_t { Init = 0, Launching, Running, Error, Done };
00091    pid_t pid;
00092    status_t status;
00093    QDBusMessage transaction;
00094    KService::DBusStartupType dbus_startup_type;
00095    bool autoStart;
00096    QString errorMsg;
00097 #ifdef Q_WS_X11
00098    QString startup_id; // "" is the default, "0" for none
00099    QString startup_dpy; // Display to send startup notification to.
00100 #endif
00101    QStringList envs; // env. variables to be app's environment
00102    QString cwd;
00103 #ifdef Q_WS_WIN
00104 protected:
00105    KProcess *process;
00106    friend class KLauncher;
00107 #endif
00108 };
00109 
00110 struct serviceResult
00111 {
00112   int result;        // 0 means success. > 0 means error (-1 means pending)
00113   QString dbusName; // Contains DBUS name on success
00114   QString error;     // Contains error description on failure.
00115   pid_t pid;
00116 };
00117 
00118 class KLauncher : public QObject
00119 {
00120    Q_OBJECT
00121 
00122 public:
00123    KLauncher(int kdeinitSocket);
00124 
00125    ~KLauncher();
00126 
00127    void close();
00128 
00129 public slots:
00130    void destruct(); // exit!
00131 
00132 protected:
00133    void processDied(pid_t pid, long exitStatus);
00134 
00135    void requestStart(KLaunchRequest *request);
00136    void requestDone(KLaunchRequest *request);
00137 
00138    bool start_service(KService::Ptr service, const QStringList &urls,
00139        const QStringList &envs, const QString &startup_id,
00140        bool blind, bool autoStart, const QDBusMessage &msg );
00141 
00142    void createArgs( KLaunchRequest *request, const KService::Ptr service,
00143                     const QStringList &url);
00144 
00145    void queueRequest(KLaunchRequest *);
00146 
00147    void send_service_startup_info( KLaunchRequest *request, KService::Ptr service, const QString &startup_id,
00148        const QStringList &envs );
00149    void cancel_service_startup_info( KLaunchRequest *request, const QString& startup_id,
00150        const QStringList &envs );
00151 
00152 Q_SIGNALS:
00153     void autoStart0Done();
00154     void autoStart1Done();
00155     void autoStart2Done();
00156 
00157 public: // remote methods, called by KLauncherAdaptor
00158     void autoStart(int phase = 1);
00159     void exec_blind(const QString &name, const QStringList &arg_list, const QStringList &envs, const QString &startup_id);
00160     inline void exec_blind(const QString &name, const QStringList &arg_list)
00161     { exec_blind(name, arg_list, QStringList(), QLatin1String("0")); }
00162 
00163     bool kdeinit_exec(const QString &app, const QStringList &args,
00164                       const QString& workdir, const QStringList &envs,
00165                       const QString &startup_id, bool wait, const QDBusMessage &msg);
00166 
00167     void reparseConfiguration();
00168     void setLaunchEnv(const QString &name, const QString &value);
00169     bool start_service_by_desktop_name(const QString &serviceName, const QStringList &urls, const QStringList &envs, const QString &startup_id, bool blind, const QDBusMessage &msg);
00170     bool start_service_by_desktop_path(const QString &serviceName, const QStringList &urls, const QStringList &envs, const QString &startup_id, bool blind, const QDBusMessage &msg);
00171     bool start_service_by_name(const QString &serviceName, const QStringList &urls, const QStringList &envs, const QString &startup_id, bool blind, const QDBusMessage &msg); // KDE5: remove
00172     pid_t requestHoldSlave(const KUrl &url, const QString &app_socket);
00173 
00174     pid_t requestSlave(const QString &protocol, const QString &host,
00175                        const QString &app_socket, QString &error);
00176     void waitForSlave(int pid, const QDBusMessage &msg);
00177 
00178 public Q_SLOTS:
00179    void slotAutoStart();
00180    void slotDequeue();
00181 #ifndef Q_WS_WIN
00182    void slotKDEInitData(int);
00183 #endif
00184    void slotNameOwnerChanged(const QString &name, const QString &oldOnwer, const QString &newOwner);
00185    void slotSlaveStatus(IdleSlave *);
00186    void acceptSlave();
00187    void slotSlaveGone();
00188    void idleTimeout();
00189 
00190 public:
00191    serviceResult requestResult; // accessed by the adaptor
00192 protected:
00193    QList<KLaunchRequest*> requestList; // Requests being handled
00194    QList<KLaunchRequest*> requestQueue; // Requests waiting to being handled
00195    KLaunchRequest *lastRequest;
00196    QList<SlaveWaitRequest*> mSlaveWaitRequest;
00197    int kdeinitSocket;
00198 #ifndef Q_WS_WIN
00199    QSocketNotifier *kdeinitNotifier;
00200 #endif
00201    KIO::ConnectionServer mConnectionServer;
00202    QList<IdleSlave*> mSlaveList;
00203    QTimer mTimer;
00204    QTimer mAutoTimer;
00205    bool bProcessingQueue;
00206    AutoStart mAutoStart;
00207    QString mSlaveDebug;
00208    QString mSlaveValgrind;
00209    QString mSlaveValgrindSkin;
00210    bool dontBlockReading;
00211 #ifdef Q_WS_X11
00212    Display *mCached_dpy;
00213 #endif
00214    void processRequestReturn(int status, const QByteArray &requestData);
00215 
00216 protected Q_SLOTS:
00217 #ifdef Q_WS_WIN
00218     void slotGotOutput();
00219     void slotFinished(int exitCode, QProcess::ExitStatus exitStatus);
00220 #endif
00221 };
00222 #endif

KInit

Skip menu "KInit"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal