1/*
2 Copyright (C) 2005-2009 by Olivier Goffart <ogoffart at kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) version 3, or any
8 later version accepted by the membership of KDE e.V. (or its
9 successor approved by the membership of KDE e.V.), which shall
10 act as a proxy defined in Section 6 of version 3 of the license.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library. If not, see <http://www.gnu.org/licenses/>.
19
20 */
21
22#ifndef KNOTIFYCONFIG_H
23#define KNOTIFYCONFIG_H
24
25#include <ksharedconfig.h>
26
27#include <QPair>
28#include <QPixmap>
29#include <QObject> //for Wid
30
31#include "knotifications_export.h"
32
33typedef QList< QPair<QString,QString> > ContextList;
34
35/**
36 * @class KNotifyImage knotifyconfig.h KNotifyConfig
37 *
38 * An image with lazy loading from the byte array
39 */
40class KNOTIFICATIONS_EXPORT KNotifyImage
41{
42 public:
43 KNotifyImage() : dirty(false) {}
44 KNotifyImage(const QByteArray &data) : source(data), dirty(true) {}
45 QImage toImage();
46 bool isNull() {
47 return dirty ? source.isEmpty() : image.isNull();
48 }
49 QByteArray data() const {
50 return source;
51 }
52 private:
53 QByteArray source;
54 QImage image;
55 bool dirty;
56};
57
58
59/**
60 * @class KNotifyConfig knotifyconfig.h KNotifyConfig
61 *
62 * Represent the configuration for an event
63 * @author Olivier Goffart <ogoffart@kde.org>
64*/
65class KNOTIFICATIONS_EXPORT KNotifyConfig
66{
67public:
68 KNotifyConfig(const QString &appname, const ContextList &_contexts , const QString &_eventid);
69 ~KNotifyConfig();
70
71 KNotifyConfig *copy() const;
72
73 /**
74 * @return entry from the knotifyrc file
75 *
76 * This will return the configuration from the user for the given key.
77 * It first look into the user config file, and then in the global config file.
78 *
79 * return a null string if the entry doesn't exist
80 */
81 QString readEntry(const QString &entry , bool path = false);
82
83 /**
84 * the pixmap to put on the notification
85 */
86 KNotifyImage image;
87
88 /**
89 * the name of the application that triggered the notification
90 */
91 QString appname;
92
93 /**
94 * @internal
95 */
96 KSharedConfig::Ptr eventsfile,configfile;
97 ContextList contexts;
98
99 /**
100 * the name of the notification
101 */
102 QString eventid;
103
104 /**
105 * reparse the cached configs. to be used when the config may have changed
106 */
107 static void reparseConfiguration();
108
109 static void reparseSingleConfiguration(const QString &app);
110};
111
112#endif
113