kdecore Library API Documentation

kstartupinfo.h

00001 /****************************************************************************
00002 
00003  $Id: kstartupinfo.h,v 1.32 2004/09/09 15:23:51 faure 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 
00035 #include <qcstring.h>
00036 #include <qstring.h>
00037 #include <qvaluelist.h>
00038 #include "kdelibs_export.h"
00039 
00040 class KStartupInfoId;
00041 class KStartupInfoData;
00042 
00043 class KStartupInfoPrivate;
00044 
00066 class KDECORE_EXPORT KStartupInfo
00067     : public QObject
00068     {
00069     Q_OBJECT
00070     public:
00079         static void disableAutoAppStartedSending( bool disable = true );
00080 
00088         static void appStarted();
00089 
00095         static void appStarted( const QCString& startup_id );
00096         
00106         static void setNewStartupId( QWidget* window, const QCString& startup_id );
00107 
00117         static void silenceStartup( bool silence );
00118 
00124         static QCString createNewStartupId();
00128     enum {
00129         CleanOnCantDetect       = 1 << 0,
00130         DisableKWinModule       = 1 << 1,
00131         AnnounceSilenceChanges  = 1 << 2
00132         };
00133     
00152     KStartupInfo( int flags, QObject* parent = NULL, const char* name = NULL );
00164         KStartupInfo( bool clean_on_cantdetect, QObject* parent = 0, const char* name = 0 );
00165         virtual ~KStartupInfo();
00178         static bool sendStartup( const KStartupInfoId& id, const KStartupInfoData& data );
00179 
00188         static bool sendStartupX( Display* dpy, const KStartupInfoId& id,
00189             const KStartupInfoData& data );
00190 
00201         static bool sendChange( const KStartupInfoId& id, const KStartupInfoData& data );
00202 
00210         static bool sendChangeX( Display* dpy, const KStartupInfoId& id,
00211             const KStartupInfoData& data );
00212 
00218         static bool sendFinish( const KStartupInfoId& id );
00219 
00226         static bool sendFinishX( Display* dpy, const KStartupInfoId& id );
00227 
00235         static bool sendFinish( const KStartupInfoId& id, const KStartupInfoData& data );
00236 
00244         static bool sendFinishX( Display* dpy, const KStartupInfoId& id,
00245             const KStartupInfoData& data );
00246 
00253         static KStartupInfoId currentStartupIdEnv();
00257         static void resetStartupEnv();
00264         enum startup_t { NoMatch, Match, CantDetect };
00270         startup_t checkStartup( WId w );
00278         startup_t checkStartup( WId w, KStartupInfoId& id );
00286         startup_t checkStartup( WId w, KStartupInfoData& data );
00295         startup_t checkStartup( WId w, KStartupInfoId& id, KStartupInfoData& data );
00300         void setTimeout( unsigned int secs );
00306         static void setWindowStartupId( WId window, const QCString& id );
00312         static QCString windowStartupId( WId w );
00316         static void handleAutoAppStartedSending();
00320         class Data;
00321     signals:
00328         void gotNewStartup( const KStartupInfoId& id, const KStartupInfoData& data );
00334         void gotStartupChange( const KStartupInfoId& id, const KStartupInfoData& data );
00341         void gotRemoveStartup( const KStartupInfoId& id, const KStartupInfoData& data );
00342     protected:
00346     virtual void customEvent( QCustomEvent* e_P );
00347     private slots:
00348         void startups_cleanup();
00349         void startups_cleanup_no_age();
00350         void got_message( const QString& msg );
00351         void window_added( WId w );
00352     void slot_window_added( WId w );
00353     private:
00354         void init( int flags );
00355         friend class KStartupInfoPrivate;
00356         void got_startup_info( const QString& msg_P, bool update_only_P );
00357         void got_remove_startup_info( const QString& msg_P );
00358         void new_startup_info_internal( const KStartupInfoId& id_P,
00359             Data& data_P, bool update_only_P );
00360         void remove_startup_info_internal( const KStartupInfoId& id_P );
00361         void remove_startup_pids( const KStartupInfoId& id, const KStartupInfoData& data );
00362         void remove_startup_pids( const KStartupInfoData& data );
00363         startup_t check_startup_internal( WId w, KStartupInfoId* id, KStartupInfoData* data );
00364         bool find_id( const QCString& id_P, KStartupInfoId* id_O,
00365             KStartupInfoData* data_O );
00366         bool find_pid( pid_t pid_P, const QCString& hostname, KStartupInfoId* id_O,
00367             KStartupInfoData* data_O );
00368         bool find_wclass( QCString res_name_P, QCString res_class_P,
00369             KStartupInfoId* id_O, KStartupInfoData* data_O );
00370         static QCString get_window_hostname( WId w_P );
00371         void startups_cleanup_internal( bool age_P );
00372         void clean_all_noncompliant();
00373         static QString check_required_startup_fields( const QString& msg,
00374             const KStartupInfoData& data, int screen );
00375         bool clean_on_cantdetect_; // KDE4 remove unused
00376         unsigned int timeout;
00377         KStartupInfoPrivate* d;
00378     };
00379 
00380 class KStartupInfoIdPrivate;
00381 
00394 class KDECORE_EXPORT KStartupInfoId
00395     {
00396     public:
00401         bool operator==( const KStartupInfoId& id ) const;
00406         bool operator!=( const KStartupInfoId& id ) const;
00411         bool none() const;
00419         void initId( const QCString& id = "" );
00424         const QCString& id() const;
00430         unsigned long timestamp() const;
00435         bool setupStartupEnv() const;
00439         KStartupInfoId();
00443         KStartupInfoId( const KStartupInfoId& data );
00444         ~KStartupInfoId();
00445         KStartupInfoId& operator=( const KStartupInfoId& data );
00446         bool operator<( const KStartupInfoId& id ) const;
00447     private:
00448         KStartupInfoId( const QString& txt );
00449         QString to_text() const;
00450         friend class KStartupInfo;
00451         KStartupInfoIdPrivate* d;
00452     };
00453 
00454 class KStartupInfoDataPrivate;
00455 
00468 class KDECORE_EXPORT KStartupInfoData
00469     {
00470     public:
00475         void setBin( const QString& bin );
00480         const QString& bin() const;
00484         void setName( const QString& name );
00490         const QString& findName() const;
00496         const QString& name() const;
00503         void setDescription( const QString& descr );
00510         const QString& findDescription() const;
00517         const QString& description() const;
00522         void setIcon( const QString& icon );
00529         const QString& findIcon() const;
00534         const QString& icon() const;
00540         void setDesktop( int desktop );
00545         int desktop() const;
00552         void setWMClass( const QCString& wmclass );
00559         const QCString findWMClass() const;
00565         const QCString& WMClass() const;
00573         void addPid( pid_t pid );
00578         const QValueList< pid_t >& pids() const;
00584         bool is_pid( pid_t pid ) const;
00590         void setHostname( const QCString& hostname = QCString());
00595         const QCString& hostname() const;
00596     
00600     enum TriState { Yes, No, Unknown };
00601     
00607     void setSilent( TriState state );
00608     
00614     TriState silent() const;
00615         
00624         void setTimestamp( unsigned long time );
00625         
00631         unsigned long timestamp() const;
00632         
00636         int screen() const;
00637         
00642         void setScreen( int screen );
00643 
00649         void update( const KStartupInfoData& data );
00650 
00654         KStartupInfoData();
00655 
00659         KStartupInfoData( const KStartupInfoData& data );
00660         ~KStartupInfoData();
00661         KStartupInfoData& operator=( const KStartupInfoData& data );
00662     private:
00663         KStartupInfoData( const QString& txt );
00664         QString to_text() const;
00665         void remove_pid( pid_t pid );
00666         friend class KStartupInfo;
00667         friend class KStartupInfo::Data;
00668         KStartupInfoDataPrivate* d;
00669     };
00670 
00671 #endif //Q_WS_X11
00672 
00673 #endif
KDE Logo
This file is part of the documentation for kdecore Library Version 3.3.90.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 30 10:09:41 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003