1/*
2 Copyright (C) 2005-2009 by Olivier Goffart <ogoffart at kde.org>
3
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
19 */
20
21#ifndef KNOTIFYCONFIG_H
22#define KNOTIFYCONFIG_H
23
24#include <ksharedconfig.h>
25
26#include <QPair>
27#include <QPixmap>
28#include <QObject> //for Wid
29
30#include "knotify_export.h"
31
32typedef QList< QPair<QString,QString> > ContextList;
33
34/**
35 * An image with lazy loading from the byte array
36 */
37class KNOTIFY_EXPORT KNotifyImage
38{
39 public:
40 KNotifyImage() : dirty(false) {}
41 KNotifyImage(const QByteArray &data) : source(data), dirty(true) {}
42 QImage toImage();
43 bool isNull() {
44 return dirty ? source.isEmpty() : image.isNull();
45 }
46 QByteArray data() const {
47 return source;
48 }
49 private:
50 QByteArray source;
51 QImage image;
52 bool dirty;
53};
54
55
56/**
57 * Represent the configuration for an event
58 * @author Olivier Goffart <ogoffart@kde.org>
59*/
60class KNOTIFY_EXPORT KNotifyConfig
61{
62 public:
63 KNotifyConfig(const QString &appname, const ContextList &_contexts , const QString &_eventid);
64 ~KNotifyConfig();
65
66 KNotifyConfig *copy() const;
67
68 /**
69 * @return entry from the knotifyrc file
70 *
71 * This will return the configuration from the user for the given key.
72 * It first look into the user config file, and then in the global config file.
73 *
74 * return a null string if the entry doesn't exist
75 */
76 QString readEntry(const QString& entry , bool path=false);
77
78 /**
79 * the title of the notification
80 */
81 QString title;
82 /**
83 * the text of the notification
84 */
85 QString text;
86 /**
87 * the pixmap to put on the notification
88 */
89 KNotifyImage image;
90 /**
91 * How long the notification should be presented (in seconds).
92 * -1 means server decides,
93 * 0 means infinite.
94 */
95 int timeout;
96 /**
97 * The windowsID of the window that initiated the notification
98 * (it is a window in the client)
99 */
100 WId winId;
101 /**
102 * the user-readable list of action.
103 */
104 QStringList actions;
105
106 /**
107 * the name of the application that triggered the notification
108 */
109 QString appname;
110
111 /**
112 * @internal
113 */
114 KSharedConfig::Ptr eventsfile,configfile;
115 ContextList contexts;
116
117 /**
118 * the name of the notification
119 */
120 QString eventid;
121
122 /**
123 * reparse the cached configs. to be used when the config may have changed
124 */
125 static void reparseConfiguration();
126};
127
128#endif
129