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
18 * \inmodule KNotifications
19 *
20 * \brief Represent the configuration for an event.
21 */
22class KNOTIFICATIONS_EXPORT KNotifyConfig
23{
24public:
25 /*!
26 * Creates a notify config for the given application name and event id
27 *
28 * \a applicationName The application name, typically the name of the notifyrc file without its extension.
29 *
30 * \a 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 * Returns 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 * Returns a null string if the entry doesn't exist
60 */
61 QString readGlobalEntry(const QString &key) const;
62
63 /*!
64 * Returns 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 * Returns a null string if the entry doesn't exist
70 */
71 QString readEntry(const QString &key) const;
72
73 /*!
74 * Returns 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 /*!
82 * reparse the cached configs. to be used when the config may have changed
83 */
84 static void reparseConfiguration();
85
86 /*!
87 *
88 */
89 static void reparseSingleConfiguration(const QString &app);
90
91private:
92 QSharedDataPointer<KNotifyConfigPrivate> d;
93};
94
95#endif
96

source code of knotifications/src/knotifyconfig.h