1 | /* |
2 | Copyright (C) 2005-2006 by Olivier Goffart <ogoffart at kde.org> |
3 | Copyright (C) 2008 by Dmitry Suzdalev <dimsuz@gmail.com> |
4 | |
5 | |
6 | This program 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, or (at your option) |
9 | 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 Free Software |
18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
19 | |
20 | */ |
21 | |
22 | #ifndef NOTIFYBYPOPUP_H |
23 | #define NOTIFYBYPOPUP_H |
24 | |
25 | #include "knotifyplugin.h" |
26 | #include <QMap> |
27 | #include <QHash> |
28 | #include <QStringList> |
29 | #include <QXmlStreamEntityResolver> |
30 | |
31 | class ; |
32 | |
33 | class : public KNotifyPlugin |
34 | { Q_OBJECT |
35 | public: |
36 | (QObject *parent=0l); |
37 | virtual (); |
38 | |
39 | virtual QString () { return "Popup" ; } |
40 | virtual void (int id , KNotifyConfig *config); |
41 | virtual void ( int id ); |
42 | virtual void (int id, KNotifyConfig *config); |
43 | |
44 | QStringList (); |
45 | |
46 | private: |
47 | QMap<int, KPassivePopup * > ; |
48 | // the y coordinate of the next position popup should appears |
49 | int ; |
50 | int ; |
51 | void (KPassivePopup *,int id,KNotifyConfig *config); |
52 | /** |
53 | * Make sure a popup is completely supported by the notification backend. |
54 | * Changes the popup to be compatible if needed. |
55 | * @param config the notification data to check |
56 | * @return the new notification data allocated with 'new' |
57 | */ |
58 | KNotifyConfig *( const KNotifyConfig *config ); |
59 | /** |
60 | * Removes HTML from a given string. Replaces line breaks with \n and |
61 | * HTML entities by their 'normal forms'. |
62 | * @param string the HTML to remove. |
63 | * @return the cleaned string. |
64 | */ |
65 | QString ( const QString &text ); |
66 | /** |
67 | * Sends notification to DBus "/Notifications" interface. |
68 | * @param id knotify-sid identifier of notification |
69 | * @param replacesId knotify-side notification identifier. If not 0, will |
70 | * request DBus service to replace existing notification with data in config |
71 | * @param config notification data |
72 | * @return true for success or false if there was an error. |
73 | */ |
74 | bool (int id, int replacesId, KNotifyConfig* config); |
75 | /** |
76 | * Sends request to close Notification with id to DBus "/Notification" interface |
77 | * @param id knotify-side notification ID to close |
78 | */ |
79 | void (int id); |
80 | /** |
81 | * Specifies if DBus Notifications interface exists on session bus |
82 | */ |
83 | bool ; |
84 | /** |
85 | * DBus notification daemon capabilities cache. |
86 | * Do not use this variable. Use #popupServerCapabilities() instead. |
87 | * @see popupServerCapabilities |
88 | */ |
89 | QStringList ; |
90 | /** |
91 | * Whether the DBus notification daemon capability cache is up-to-date. |
92 | */ |
93 | bool ; |
94 | /** |
95 | * Find the caption and the icon name of the application |
96 | */ |
97 | void getAppCaptionAndIconName(KNotifyConfig *config, QString *appCaption, QString *iconName); |
98 | |
99 | protected: |
100 | void (QTimerEvent *event); |
101 | |
102 | private Q_SLOTS: |
103 | void (); |
104 | void (const QString & ); |
105 | // slot to catch appearance or dissapearance of Notifications DBus service |
106 | void (const QString &, const QString &, const QString &); |
107 | // slot which gets called when DBus signals that some notification action was invoked |
108 | void (uint, const QString&); |
109 | // slot which gets called when DBus signals that some notification was closed |
110 | void (uint, uint); |
111 | |
112 | private: |
113 | /** |
114 | * Maps knotify notification IDs to DBus notifications IDs |
115 | */ |
116 | QHash<int,uint> ; |
117 | |
118 | /** |
119 | * A class for resolving HTML entities in XML documents (used |
120 | * during HTML stripping) |
121 | */ |
122 | class : public QXmlStreamEntityResolver |
123 | { |
124 | QString ( const QString &name ); |
125 | }; |
126 | }; |
127 | |
128 | #endif |
129 | |