kdecore Library API Documentation

kstartupinfo.h

00001 /****************************************************************************
00002 
00003  $Id: kstartupinfo.h,v 1.28 2003/10/23 17:40:25 lunakl Exp $
00004 
00005  Copyright (C) 2001-2003 Lubos Lunak        <l.lunak@kde.org>
00006 
00007 Permission is hereby granted, free of charge, to any person obtaining a
00008 copy of this software and associated documentation files (the "Software"),
00009 to deal in the Software without restriction, including without limitation
00010 the rights to use, copy, modify, merge, publish, distribute, sublicense,
00011 and/or sell copies of the Software, and to permit persons to whom the
00012 Software is furnished to do so, subject to the following conditions:
00013 
00014 The above copyright notice and this permission notice shall be included in
00015 all copies or substantial portions of the Software.
00016 
00017 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00020 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00021 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00022 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00023 DEALINGS IN THE SOFTWARE.
00024 
00025 ****************************************************************************/
00026 
00027 #ifndef __KSTARTUPINFO_H
00028 #define __KSTARTUPINFO_H
00029 
00030 #include <sys/types.h>
00031 #include <qobject.h>
00032 
00033 //#ifdef Q_WS_X11 // FIXME(E): Redo in a less X11-specific way
00034 #include <qcstring.h>
00035 #include <qstring.h>
00036 #include <qvaluelist.h>
00037 
00038 class KStartupInfoId;
00039 class KStartupInfoData;
00040 
00041 class KStartupInfoPrivate;
00042 
00064 class KStartupInfo
00065     : public QObject
00066     {
00067     Q_OBJECT
00068     public:
00077         static void disableAutoAppStartedSending( bool disable = true );
00078 
00086         static void appStarted();
00087 
00093         static void appStarted( const QCString& startup_id );
00094         
00104         static void setNewStartupId( QWidget* window, const QCString& startup_id );
00105 
00115         static void silenceStartup( bool silence );
00116 
00117     enum {
00118         CleanOnCantDetect       = 1 << 0,
00119         DisableKWinModule       = 1 << 1,
00120         AnnounceSilenceChanges  = 1 << 2
00121         };
00140     KStartupInfo( int flags, QObject* parent = NULL, const char* name = NULL );
00152         KStartupInfo( bool clean_on_cantdetect, QObject* parent = 0, const char* name = 0 );
00153         virtual ~KStartupInfo();
00166         static bool sendStartup( const KStartupInfoId& id, const KStartupInfoData& data );
00167 
00176         static bool sendStartupX( Display* dpy, const KStartupInfoId& id,
00177             const KStartupInfoData& data );
00178 
00189         static bool sendChange( const KStartupInfoId& id, const KStartupInfoData& data );
00190 
00198         static bool sendChangeX( Display* dpy, const KStartupInfoId& id,
00199             const KStartupInfoData& data );
00200 
00206         static bool sendFinish( const KStartupInfoId& id );
00207 
00214         static bool sendFinishX( Display* dpy, const KStartupInfoId& id );
00215 
00223         static bool sendFinish( const KStartupInfoId& id, const KStartupInfoData& data );
00224 
00232         static bool sendFinishX( Display* dpy, const KStartupInfoId& id,
00233             const KStartupInfoData& data );
00234 
00241         static KStartupInfoId currentStartupIdEnv();
00245         static void resetStartupEnv();
00252         enum startup_t { NoMatch, Match, CantDetect };
00258         startup_t checkStartup( WId w );
00266         startup_t checkStartup( WId w, KStartupInfoId& id );
00274         startup_t checkStartup( WId w, KStartupInfoData& data );
00283         startup_t checkStartup( WId w, KStartupInfoId& id, KStartupInfoData& data );
00288         void setTimeout( unsigned int secs );
00294         static void setWindowStartupId( WId window, const QCString& id );
00300         static QCString windowStartupId( WId w );
00304         static void handleAutoAppStartedSending();
00308         class Data;
00309     signals:
00316         void gotNewStartup( const KStartupInfoId& id, const KStartupInfoData& data );
00322         void gotStartupChange( const KStartupInfoId& id, const KStartupInfoData& data );
00329         void gotRemoveStartup( const KStartupInfoId& id, const KStartupInfoData& data );
00330     protected:
00331     virtual void customEvent( QCustomEvent* e_P );
00332     private slots:
00333         void startups_cleanup();
00334         void startups_cleanup_no_age();
00335         void got_message( const QString& msg );
00336         void window_added( WId w );
00337     void slot_window_added( WId w );
00338     private:
00339         void init( int flags );
00340         friend class KStartupInfoPrivate;
00341         void got_startup_info( const QString& msg_P, bool update_only_P );
00342         void got_remove_startup_info( const QString& msg_P );
00343         void new_startup_info_internal( const KStartupInfoId& id_P,
00344             Data& data_P, bool update_only_P );
00345         void remove_startup_info_internal( const KStartupInfoId& id_P );
00346         void remove_startup_pids( const KStartupInfoId& id, const KStartupInfoData& data );
00347         void remove_startup_pids( const KStartupInfoData& data );
00348         startup_t check_startup_internal( WId w, KStartupInfoId* id, KStartupInfoData* data );
00349         bool find_id( const QCString& id_P, KStartupInfoId* id_O,
00350             KStartupInfoData* data_O );
00351         bool find_pid( pid_t pid_P, const QCString& hostname, KStartupInfoId* id_O,
00352             KStartupInfoData* data_O );
00353         bool find_wclass( QCString res_name_P, QCString res_class_P,
00354             KStartupInfoId* id_O, KStartupInfoData* data_O );
00355         static QCString get_window_hostname( WId w_P );
00356         void startups_cleanup_internal( bool age_P );
00357         void clean_all_noncompliant();
00358         static QString check_required_startup_fields( const QString& msg,
00359             const KStartupInfoData& data, int screen );
00360         bool clean_on_cantdetect_; // KDE4 remove unused
00361         unsigned int timeout;
00362         KStartupInfoPrivate* d;
00363     };
00364 
00365 class KStartupInfoIdPrivate;
00366 
00379 class KStartupInfoId
00380     {
00381     public:
00386         bool operator==( const KStartupInfoId& id ) const;
00391         bool operator!=( const KStartupInfoId& id ) const;
00396         bool none() const;
00404         void initId( const QCString& id = "" );
00409         const QCString& id() const;
00414         bool setupStartupEnv() const;
00418         KStartupInfoId();
00422         KStartupInfoId( const KStartupInfoId& data );
00423         ~KStartupInfoId();
00424         KStartupInfoId& operator=( const KStartupInfoId& data );
00425         bool operator<( const KStartupInfoId& id ) const;
00426     private:
00427         KStartupInfoId( const QString& txt );
00428         QString to_text() const;
00429         friend class KStartupInfo;
00430         KStartupInfoIdPrivate* d;
00431     };
00432 
00433 class KStartupInfoDataPrivate;
00434 
00447 class KStartupInfoData
00448     {
00449     public:
00454         void setBin( const QString& bin );
00459         const QString& bin() const;
00463         void setName( const QString& name );
00469         const QString& findName() const;
00475         const QString& name() const;
00482         void setDescription( const QString& descr );
00489         const QString& findDescription() const;
00496         const QString& description() const;
00501         void setIcon( const QString& icon );
00508         const QString& findIcon() const;
00513         const QString& icon() const;
00519         void setDesktop( int desktop );
00524         int desktop() const;
00531         void setWMClass( const QCString& wmclass );
00538         const QCString findWMClass() const;
00544         const QCString& WMClass() const;
00552         void addPid( pid_t pid );
00557         const QValueList< pid_t >& pids() const;
00563         bool is_pid( pid_t pid ) const;
00569         void setHostname( const QCString& hostname = QCString());
00574         const QCString& hostname() const;
00575     
00576     enum TriState { Yes, No, Unknown };
00577     
00583     void setSilent( TriState state );
00584     
00590     TriState silent() const;
00591         
00599         void setTimestamp( unsigned long time );
00600         
00605         unsigned long timestamp() const;
00606         
00610         int screen() const;
00611         
00616         void setScreen( int screen );
00617 
00623         void update( const KStartupInfoData& data );
00624 
00628         KStartupInfoData();
00629 
00633         KStartupInfoData( const KStartupInfoData& data );
00634         ~KStartupInfoData();
00635         KStartupInfoData& operator=( const KStartupInfoData& data );
00636     private:
00637         KStartupInfoData( const QString& txt );
00638         QString to_text() const;
00639         void remove_pid( pid_t pid );
00640         friend class KStartupInfo;
00641         friend class KStartupInfo::Data;
00642         KStartupInfoDataPrivate* d;
00643     };
00644 
00645 #endif
KDE Logo
This file is part of the documentation for kdecore Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Apr 22 14:23:02 2004 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2003