properly rewind oidentd config file
[quassel.git] / src / qtui / statusnotifieritem.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2010 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This contains code from KStatusNotifierItem, part of the KDE libs     *
6  *   Copyright (C) 2009 Marco Martin <notmart@gmail.com>                   *
7  *                                                                         *
8  *   This file is free software; you can redistribute it and/or modify     *
9  *   it under the terms of the GNU Library General Public License (LGPL)   *
10  *   as published by the Free Software Foundation; either version 2 of the *
11  *   License, or (at your option) any later version.                       *
12  *                                                                         *
13  *   This program is distributed in the hope that it will be useful,       *
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
16  *   GNU General Public License for more details.                          *
17  *                                                                         *
18  *   You should have received a copy of the GNU General Public License     *
19  *   along with this program; if not, write to the                         *
20  *   Free Software Foundation, Inc.,                                       *
21  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
22  ***************************************************************************/
23
24 #ifndef STATUSNOTIFIERITEM_H_
25 #define STATUSNOTIFIERITEM_H_
26
27 #ifdef HAVE_DBUS
28
29 #include "notificationsclient.h"
30 #include "systemtray.h"
31 #include "statusnotifierwatcher.h"
32
33 #ifdef QT_NO_SYSTEMTRAYICON
34 #  define StatusNotifierItemParent SystemTray
35 #else
36 #  define StatusNotifierItemParent LegacySystemTray
37 #  include "legacysystemtray.h"
38 #endif
39
40 class StatusNotifierItemDBus;
41
42 class StatusNotifierItem : public StatusNotifierItemParent {
43   Q_OBJECT
44
45 public:
46   explicit StatusNotifierItem(QWidget *parent);
47   virtual ~StatusNotifierItem();
48
49   virtual bool isSystemTrayAvailable() const;
50   virtual bool isVisible() const;
51
52 public slots:
53   virtual void setState(State state);
54   virtual void setVisible(bool visible);
55   virtual void showMessage(const QString &title, const QString &message, MessageIcon icon = Information, int msTimeout = 10000, uint notificationId = 0);
56   virtual void closeMessage(uint notificationId);
57
58 protected:
59   virtual void init();
60   virtual void setMode(Mode mode);
61
62   QString title() const;
63   QString iconName() const;
64   QString attentionIconName() const;
65   QString toolTipIconName() const;
66   QString iconThemePath() const;
67   QString menuObjectPath() const;
68
69   virtual bool eventFilter(QObject *watched, QEvent *event);
70
71 private slots:
72   void activated(const QPoint &pos);
73   void serviceChange(const QString& name, const QString& oldOwner, const QString& newOwner);
74   void checkForRegisteredHosts();
75
76   void notificationClosed(uint id, uint reason);
77   void notificationInvoked(uint id, const QString &action);
78
79 private:
80   void registerToDaemon();
81
82   static const int _protocolVersion;
83   static const QString _statusNotifierWatcherServiceName;
84   StatusNotifierItemDBus *_statusNotifierItemDBus;
85
86   org::kde::StatusNotifierWatcher *_statusNotifierWatcher;
87   org::freedesktop::Notifications *_notificationsClient;
88   bool _notificationsClientSupportsMarkup;
89   bool _notificationsClientSupportsActions;
90   quint32 _lastNotificationsDBusId;
91   QHash<uint, uint> _notificationsIdMap; ///< Maps our own notification ID to the D-Bus one
92
93   QString _iconThemePath;
94   QString _menuObjectPath;
95
96   friend class StatusNotifierItemDBus;
97 };
98
99 #endif /* HAVE_DBUS */
100 #endif /* STATUSNOTIFIERITEM_H_ */