1/*
2 SPDX-FileCopyrightText: 2005-2009 Olivier Goffart <ogoffart at kde.org>
3 SPDX-FileCopyrightText: 2023 Kai Uwe Broulik <kde@broulik.de>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#ifndef KNOTIFYCONFIG_H
9#define KNOTIFYCONFIG_H
10
11#include "knotifications_export.h"
12#include <QSharedDataPointer>
13
14class KNotifyConfigPrivate;
15
16/**
17 * @class KNotifyConfig knotifyconfig.h KNotifyConfig
18 *
19 * Represent the configuration for an event
20 *
21 * @author Olivier Goffart <ogoffart@kde.org>
22 * @author Kai Uwe Broulik <kde@broulik.de>
23 */
24class KNOTIFICATIONS_EXPORT KNotifyConfig
25{
26public:
27 /**
28 * Creates a notify config for the given application name and event id
29 * @param applicationName The application name, typically the name of the notifyrc file without its extension.
30 * @param eventId The notification event ID, i.e. the part after Event/ in its notifyrc file.
31 */
32 KNotifyConfig(const QString &applicationName, const QString &eventId);
33 ~KNotifyConfig();
34
35 KNotifyConfig(const KNotifyConfig &other);
36 KNotifyConfig &operator=(const KNotifyConfig &other);
37
38 /**
39 * the name of the application that triggered the notification
40 */
41 QString applicationName() const;
42
43 /**
44 * the name of the notification
45 */
46 QString eventId() const;
47
48 /**
49 * Whether there exists an event with the given id under the given application name.
50 */
51 bool isValid() const;
52
53 /**
54 * @return entry from the relevant Global notifyrc config group
55 *
56 * This will return the configuration from the user for the given key.
57 * It first look into the user config file, and then in the global config file.
58 *
59 * return a null string if the entry doesn't exist
60 */
61 QString readGlobalEntry(const QString &key) const;
62
63 /**
64 * @return entry from the relevant Event/ notifyrc config group
65 *
66 * This will return the configuration from the user for the given key.
67 * It first look into the user config file, and then in the global config file.
68 *
69 * return a null string if the entry doesn't exist
70 */
71 QString readEntry(const QString &key) const;
72
73 /**
74 * @return path entry from the relevant Event/ notifyrc config group
75 *
76 * This will return the configuration from the user for the given key
77 * and interpret it as a path.
78 */
79 QString readPathEntry(const QString &key) const;
80 /**
81 * reparse the cached configs. to be used when the config may have changed
82 */
83 static void reparseConfiguration();
84
85 static void reparseSingleConfiguration(const QString &app);
86
87private:
88 QSharedDataPointer<KNotifyConfigPrivate> d;
89};
90
91#endif
92

source code of knotifications/src/knotifyconfig.h