• Skip to content
  • Skip to link menu
KDE 4.0 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 <sys/types.h>
00024 #include <unistd.h>
00025 #include <time.h>
00026 #include <QtCore/QString>
00027 #include <QtCore/QSocketNotifier>
00028 #include <QtCore/QTimer>
00029 #include <QtCore/QList>
00030 #include <QtCore/QObject>
00031 
00032 #include <kurl.h>
00033 #include <kio/connection.h>
00034 
00035 #include <kservice.h>
00036 
00037 #include <QtDBus/QtDBus>
00038 #ifdef Q_WS_X11
00039 #include <X11/Xlib.h>
00040 #include <fixx11h.h>
00041 #endif
00042 
00043 #include "autostart.h"
00044 
00045 #ifdef Q_WS_WIN
00046 class QProcess;
00047 #endif
00048 
00049 class IdleSlave : public QObject
00050 {
00051    Q_OBJECT
00052 public:
00053    explicit IdleSlave(QObject *parent);
00054    bool match( const QString &protocol, const QString &host, bool connected);
00055    void connect( const QString &app_socket);
00056    pid_t pid() const { return mPid;}
00057    int age(time_t now);
00058    void reparseConfiguration();
00059    bool onHold(const KUrl &url);
00060    QString protocol() const   {return mProtocol;}
00061 
00062 Q_SIGNALS:
00063    void statusUpdate(IdleSlave *);
00064 
00065 protected Q_SLOTS:
00066    void gotInput();
00067 
00068 public:
00069    KIO::Connection mConn;
00070 protected:
00071    QString mProtocol;
00072    QString mHost;
00073    bool mConnected;
00074    pid_t mPid;
00075    time_t mBirthDate;
00076    bool mOnHold;
00077    KUrl mUrl;
00078 };
00079 
00080 class SlaveWaitRequest
00081 {
00082 public:
00083    pid_t pid;
00084    QDBusMessage transaction;
00085 };
00086 
00087 class KLaunchRequest
00088 {
00089 public:
00090    QString name;
00091    QStringList arg_list;
00092    QString dbus_name;
00093    enum status_t { Init = 0, Launching, Running, Error, Done };
00094    pid_t pid;
00095    status_t status;
00096    QDBusMessage transaction;
00097    KService::DBusStartupType dbus_startup_type;
00098    bool autoStart;
00099    QString errorMsg;
00100 #ifdef Q_WS_X11
00101    QString startup_id; // "" is the default, "0" for none
00102    QString startup_dpy; // Display to send startup notification to.
00103 #endif
00104    QStringList envs; // env. variables to be app's environment
00105    QString cwd;
00106 };
00107 
00108 struct serviceResult
00109 {
00110   int result;        // 0 means success. > 0 means error (-1 means pending)
00111   QString dbusName; // Contains DBUS name on success
00112   QString error;     // Contains error description on failure.
00113   pid_t pid;
00114 };
00115 
00116 class KLauncher : public QObject
00117 {
00118    Q_OBJECT
00119 
00120 public:
00121    KLauncher(int kdeinitSocket);
00122 
00123    ~KLauncher();
00124 
00125    void close();
00126    static void destruct(int exit_code); // exit!
00127 
00128 protected:
00129    void processDied(pid_t pid, long exitStatus);
00130 
00131    void requestStart(KLaunchRequest *request);
00132    void requestDone(KLaunchRequest *request);
00133 
00134    bool start_service(KService::Ptr service, const QStringList &urls,
00135        const QStringList &envs, const QString &startup_id,
00136        bool blind, bool autoStart, const QDBusMessage &msg );
00137    bool kdeinit_exec(const QString &app, const QStringList &args,
00138        const QStringList &envs, const QString &startup_id, bool wait, const QDBusMessage &msg);
00139 
00140    void createArgs( KLaunchRequest *request, const KService::Ptr service,
00141                     const QStringList &url);
00142 
00143    void queueRequest(KLaunchRequest *);
00144 
00145    void send_service_startup_info( KLaunchRequest *request, KService::Ptr service, const QString &startup_id,
00146        const QStringList &envs );
00147    void cancel_service_startup_info( KLaunchRequest *request, const QString& startup_id,
00148        const QStringList &envs );
00149 
00150 Q_SIGNALS:
00151     void autoStart0Done();
00152     void autoStart1Done();
00153     void autoStart2Done();
00154 
00155 public: // remote methods, called by KLauncherAdaptor
00156     void autoStart(int phase = 1);
00157     void exec_blind(const QString &name, const QStringList &arg_list, const QStringList &envs, const QString &startup_id);
00158     inline void exec_blind(const QString &name, const QStringList &arg_list)
00159     { exec_blind(name, arg_list, QStringList(), QLatin1String("0")); }
00160     inline void kdeinit_exec(const QString &app, const QStringList &args, const QStringList &env, const QString& startup_id, const QDBusMessage &msg)
00161     { kdeinit_exec(app, args, env, startup_id, false, msg); }
00162     inline void kdeinit_exec_wait(const QString &app, const QStringList &args, const QStringList &env, const QString& startup_id, const QDBusMessage &msg)
00163     { kdeinit_exec(app, args, env, startup_id, true, msg); }
00164 
00165     void reparseConfiguration();
00166     void setLaunchEnv(const QString &name, const QString &value);
00167     bool start_service_by_desktop_name(const QString &serviceName, const QStringList &urls, const QStringList &envs, const QString &startup_id, bool blind, const QDBusMessage &msg);
00168     bool start_service_by_desktop_path(const QString &serviceName, const QStringList &urls, const QStringList &envs, const QString &startup_id, bool blind, const QDBusMessage &msg);
00169     bool start_service_by_name(const QString &serviceName, const QStringList &urls, const QStringList &envs, const QString &startup_id, bool blind, const QDBusMessage &msg);
00170     pid_t requestHoldSlave(const KUrl &url, const QString &app_socket);
00171 
00172     pid_t requestSlave(const QString &protocol, const QString &host,
00173                        const QString &app_socket, QString &error);
00174     void waitForSlave(int pid, const QDBusMessage &msg);
00175 
00176 public Q_SLOTS:
00177    void slotAutoStart();
00178    void slotDequeue();
00179 #ifndef Q_WS_WIN
00180    void slotKDEInitData(int);
00181 #endif
00182    void slotNameOwnerChanged(const QString &name, const QString &oldOnwer, const QString &newOwner);
00183    void slotSlaveStatus(IdleSlave *);
00184    void acceptSlave();
00185    void slotSlaveGone();
00186    void idleTimeout();
00187 
00188 public:
00189    serviceResult requestResult; // accessed by the adaptor
00190 protected:
00191    QList<KLaunchRequest*> requestList; // Requests being handled
00192    QList<KLaunchRequest*> requestQueue; // Requests waiting to being handled
00193    KLaunchRequest *lastRequest;
00194    QList<SlaveWaitRequest*> mSlaveWaitRequest;
00195    int kdeinitSocket;
00196 #ifdef Q_WS_WIN
00197    QList<QProcess *>processList;
00198 #else
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     void slotGotOutput();
00218 };
00219 #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
  •   WTF
  • KJSEmbed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  •   core
  • Phonon
  •   Backend
  • 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