knotify.h

00001 /*
00002    Copyright (c) 1997 Christian Esken (esken@kde.org)
00003 
00004    This program is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; either version 2, or (at your option)
00007    any later version.
00008 
00009    This program 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
00012    GNU General Public License for more details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with this program; if not, write to the Free Software
00016    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00017 
00018 */
00019 
00020 #ifndef KNOTIFY_H
00021 #define KNOTIFY_H
00022 
00023 #include <qobject.h>
00024 #include <knotifyclient.h>
00025 #include <dcopobject.h>
00026 
00027 class KNotifyPrivate;
00028 class KProcess;
00029 
00030 class KNotify : public QObject, public DCOPObject
00031 {
00032 Q_OBJECT
00033 K_DCOP
00034 
00035 public:
00036     KNotify( bool useArts );
00037     ~KNotify();
00038 
00039     enum PlayingFinishedStatus
00040     {
00041         PlayedOK = 0,        // success, all following mean failure
00042         NoSoundFile,
00043         FileAlreadyPlaying,
00044         NoSoundSupport,
00045         PlayerBusy,
00046         Aborted,
00047         Unknown = 5000
00048     };
00049 
00050 protected:
00051 k_dcop:
00052     // deprecated
00053     void notify(const QString &event, const QString &fromApp,
00054                          const QString &text, QString sound, QString file,
00055                          int present, int level);
00056 
00057     // deprecated
00058     void notify(const QString &event, const QString &fromApp,
00059                          const QString &text, QString sound, QString file,
00060                          int present, int level, int winId);
00061 
00062     void notify(const QString &event, const QString &fromApp,
00063                          const QString &text, QString sound, QString file,
00064                          int present, int level, int winId, int eventId);
00065 
00066 
00067     void reconfigure();
00068     void setVolume( int volume );
00069         void sessionReady(); // from ksmserver
00070 
00071 private:
00072     bool notifyBySound(const QString &sound, const QString &appname, int eventId);
00073     bool notifyByMessagebox(const QString &text, int level, WId winId);
00074     bool notifyByLogfile(const QString &text, const QString &file);
00075     bool notifyByStderr(const QString &text);
00076     bool notifyByPassivePopup(const QString &text, const QString &appName,
00077                                   WId winId );
00078     bool notifyByExecute(const QString &command, 
00079                              const QString& event, 
00080                              const QString& fromApp, 
00081                              const QString& text,
00082                              int winId,
00083                              int eventId );
00084     bool notifyByTaskbar( WId winId );
00085     
00086     bool isPlaying( const QString& soundFile ) const;
00087 
00088     void soundFinished( int eventId, PlayingFinishedStatus reason );
00089     void abortFirstPlayObject();
00090     
00091         WId checkWinId( const QString& appName, WId senderWinId );
00092 
00096     bool isGlobal(const QString &eventname);
00097 
00098 private slots:
00099     void playTimeout();
00100     void slotPlayerProcessExited( KProcess *proc );
00101     void restartedArtsd();
00102 
00103 private:
00104     KNotifyPrivate* d;
00105     void loadConfig();
00106 };
00107 
00108 
00109 #endif
00110 
KDE Home | KDE Accessibility Home | Description of Access Keys