1 /***************************************************************************
2 * Copyright (C) 2005-2010 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This contains code from KStatusNotifierItem, part of the KDE libs *
6 * Copyright (C) 2009 Marco Martin <notmart@gmail.com> *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) version 3. *
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. *
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 ***************************************************************************/
24 #ifndef STATUSNOTIFIERITEM_H_
25 #define STATUSNOTIFIERITEM_H_
29 #include "notificationsclient.h"
30 #include "systemtray.h"
31 #include "statusnotifierwatcher.h"
33 #ifdef QT_NO_SYSTEMTRAYICON
34 # define StatusNotifierItemParent SystemTray
36 # define StatusNotifierItemParent LegacySystemTray
37 # include "legacysystemtray.h"
40 class StatusNotifierItemDBus;
42 class StatusNotifierItem : public StatusNotifierItemParent {
46 explicit StatusNotifierItem(QWidget *parent);
47 virtual ~StatusNotifierItem();
50 virtual void setState(State state);
51 virtual void showMessage(const QString &title, const QString &message, MessageIcon icon = Information, int msTimeout = 10000, uint notificationId = 0);
52 virtual void closeMessage(uint notificationId);
56 virtual void setMode(Mode mode);
58 QString title() const;
59 QString iconName() const;
60 QString attentionIconName() const;
61 QString toolTipIconName() const;
63 virtual bool eventFilter(QObject *watched, QEvent *event);
66 void activated(const QPoint &pos);
67 void serviceChange(const QString& name, const QString& oldOwner, const QString& newOwner);
69 void notificationClosed(uint id, uint reason);
70 void notificationInvoked(uint id, const QString &action);
73 void registerToDaemon();
75 static const int _protocolVersion;
76 StatusNotifierItemDBus *_statusNotifierItemDBus;
78 org::kde::StatusNotifierWatcher *_statusNotifierWatcher;
79 org::freedesktop::Notifications *_notificationsClient;
80 bool _notificationsClientSupportsMarkup;
81 quint32 _lastNotificationsDBusId;
82 QHash<uint, uint> _notificationsIdMap; ///< Maps our own notification ID to the D-Bus one
84 friend class StatusNotifierItemDBus;
87 #endif /* HAVE_DBUS */
88 #endif /* STATUSNOTIFIERITEM_H_ */