fixed uninitialized qint32
[quassel.git] / src / qtui / statusnotifieritemdbus.h
1 /***************************************************************************
2  *   The original file is part of the KDE libraries                        *
3  *   Copyright (C) 2009 by Marco Martin <notmart@gmail.com>                *
4  *   Quasselfied 2010 by Manuel Nickschas <sputnick@quassel-irc.org>       *
5  *                                                                         *
6  *   This file is free software; you can redistribute it and/or modify     *
7  *   it under the terms of the GNU General Public License as published by  *
8  *   the Free Software Foundation; either version 2 of the License, or     *
9  *   (at your option) any later version.                                   *
10  *                                                                         *
11  *   This program is distributed in the hope that it will be useful,       *
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14  *   GNU General Public License for more details.                          *
15  *                                                                         *
16  *   You should have received a copy of the GNU General Public License     *
17  *   along with this program; if not, write to the                         *
18  *   Free Software Foundation, Inc.,                                       *
19  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
20  ***************************************************************************/
21
22 #ifndef STATUSNOTIFIERITEMDBUS_H_
23 #define STATUSNOTIFIERITEMDBUS_H_
24
25 #include <QObject>
26 #include <QString>
27 #include <QDBusArgument>
28 #include <QDBusConnection>
29 #include <QPixmap>
30
31 //Custom message type for DBus
32 struct DBusImageStruct {
33     int width;
34     int height;
35     QByteArray data;
36 };
37
38 typedef QVector<DBusImageStruct> DBusImageVector;
39
40 struct DBusToolTipStruct {
41     QString icon;
42     DBusImageVector image;
43     QString title;
44     QString subTitle;
45 };
46
47 class StatusNotifierItem;
48
49 class StatusNotifierItemDBus : public QObject
50 {
51     Q_OBJECT
52
53     Q_PROPERTY(QString Category READ Category)
54     Q_PROPERTY(QString Id READ Id)
55     Q_PROPERTY(QString Title READ Title)
56     Q_PROPERTY(QString Status READ Status)
57     Q_PROPERTY(int WindowId READ WindowId)
58     Q_PROPERTY(QString IconName READ IconName)
59     Q_PROPERTY(DBusImageVector IconPixmap READ IconPixmap)
60     Q_PROPERTY(QString OverlayIconName READ OverlayIconName)
61     Q_PROPERTY(DBusImageVector OverlayIconPixmap READ OverlayIconPixmap)
62     Q_PROPERTY(QString AttentionIconName READ AttentionIconName)
63     Q_PROPERTY(DBusImageVector AttentionIconPixmap READ AttentionIconPixmap)
64     Q_PROPERTY(QString AttentionMovieName READ AttentionMovieName)
65     Q_PROPERTY(DBusToolTipStruct ToolTip READ ToolTip)
66
67     friend class StatusNotifierItem;
68 public:
69     StatusNotifierItemDBus(StatusNotifierItem *parent);
70     ~StatusNotifierItemDBus();
71
72     /**
73      * @return the service this object is registered on the bus under
74      */
75     QString service() const;
76
77     /**
78      * @return the category of the application associated to this item
79      * @see Category
80      */
81     QString Category() const;
82
83     /**
84      * @return the id of this item
85      */
86     QString Id() const;
87
88     /**
89      * @return the title of this item
90      */
91     QString Title() const;
92
93     /**
94      * @return The status of this item
95      * @see Status
96      */
97     QString Status() const;
98
99     /**
100      * @return The id of the main window of the application that controls the item
101      */
102     int WindowId() const;
103
104     /**
105      * @return the name of the main icon to be displayed
106      * if image() is not empty this will always return an empty string
107      */
108     QString IconName() const;
109
110     /**
111      * @return a serialization of the icon data
112      */
113     DBusImageVector IconPixmap() const;
114
115     /**
116      * @return the name of the overlay of the main icon to be displayed
117      * if image() is not empty this will always return an empty string
118      */
119     QString OverlayIconName() const;
120
121     /**
122      * @return a serialization of the icon data
123      */
124     DBusImageVector OverlayIconPixmap() const;
125
126     /**
127      * @return the name of the icon to be displayed when the application
128      * is requesting the user's attention
129      * if attentionImage() is not empty this will always return an empty string
130      */
131     QString AttentionIconName() const;
132
133     /**
134      * @return a serialization of the requesting attention icon data
135      */
136     DBusImageVector AttentionIconPixmap() const;
137
138     /**
139      * @return the name of the attention movie
140      */
141     QString AttentionMovieName() const;
142
143     /**
144      * all the data needed for a tooltip
145      */
146     DBusToolTipStruct ToolTip() const;
147
148
149 public Q_SLOTS:
150     //interaction
151     /**
152      * Shows the context menu associated to this item
153      * at the desired screen position
154      */
155     void ContextMenu(int x, int y);
156
157     /**
158      * Shows the main widget and try to position it on top
159      * of the other windows, if the widget is already visible, hide it.
160      */
161     void Activate(int x, int y);
162
163     /**
164      * The user activated the item in an alternate way (for instance with middle mouse button, this depends from the systray implementation)
165      */
166     void SecondaryActivate(int x, int y);
167
168     /**
169      * Inform this item that the mouse wheel was used on its representation
170      */
171     void Scroll(int delta, const QString &orientation);
172
173 Q_SIGNALS:
174     /**
175      * Inform the systemtray that the own main icon has been changed,
176      * so should be reloaded
177      */
178     void NewIcon();
179
180     /**
181      * Inform the systemtray that there is a new icon to be used as overlay
182      */
183     void NewOverlayIcon();
184
185     /**
186      * Inform the systemtray that the requesting attention icon
187      * has been changed, so should be reloaded
188      */
189     void NewAttentionIcon();
190
191     /**
192      * Inform the systemtray that something in the tooltip has been changed
193      */
194     void NewToolTip();
195
196     /**
197      * Signal the new status when it has been changed
198      * @see Status
199      */
200     void NewStatus(const QString &status);
201
202 private:
203     StatusNotifierItem *m_statusNotifierItem;
204     QString m_service;
205     QDBusConnection m_dbus;
206     static int s_serviceCount;
207 };
208
209
210 const QDBusArgument &operator<<(QDBusArgument &argument, const DBusImageStruct &icon);
211 const QDBusArgument &operator>>(const QDBusArgument &argument, DBusImageStruct &icon);
212
213 Q_DECLARE_METATYPE(DBusImageStruct)
214
215 const QDBusArgument &operator<<(QDBusArgument &argument, const DBusImageVector &iconVector);
216 const QDBusArgument &operator>>(const QDBusArgument &argument, DBusImageVector &iconVector);
217
218 Q_DECLARE_METATYPE(DBusImageVector)
219
220 const QDBusArgument &operator<<(QDBusArgument &argument, const DBusToolTipStruct &toolTip);
221 const QDBusArgument &operator>>(const QDBusArgument &argument, DBusToolTipStruct &toolTip);
222
223 Q_DECLARE_METATYPE(DBusToolTipStruct)
224
225 #endif