File indexing completed on 2024-04-28 07:45:19
0001 /* 0002 SPDX-FileCopyrightText: 2005-2009 Olivier Goffart <ogoffart at kde.org> 0003 SPDX-FileCopyrightText: 2023 Kai Uwe Broulik <kde@broulik.de> 0004 0005 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 0008 #ifndef KNOTIFYCONFIG_H 0009 #define KNOTIFYCONFIG_H 0010 0011 #include "knotifications_export.h" 0012 #include <QSharedDataPointer> 0013 0014 class KNotifyConfigPrivate; 0015 0016 /** 0017 * @class KNotifyConfig knotifyconfig.h KNotifyConfig 0018 * 0019 * Represent the configuration for an event 0020 * 0021 * @author Olivier Goffart <ogoffart@kde.org> 0022 * @author Kai Uwe Broulik <kde@broulik.de> 0023 */ 0024 class KNOTIFICATIONS_EXPORT KNotifyConfig 0025 { 0026 public: 0027 /** 0028 * Creates a notify config for the given application name and event id 0029 * @param applicationName The application name, typically the name of the notifyrc file without its extension. 0030 * @param eventId The notification event ID, i.e. the part after Event/ in its notifyrc file. 0031 */ 0032 KNotifyConfig(const QString &applicationName, const QString &eventId); 0033 ~KNotifyConfig(); 0034 0035 KNotifyConfig(const KNotifyConfig &other); 0036 KNotifyConfig &operator=(const KNotifyConfig &other); 0037 0038 /** 0039 * the name of the application that triggered the notification 0040 */ 0041 QString applicationName() const; 0042 0043 /** 0044 * the name of the notification 0045 */ 0046 QString eventId() const; 0047 0048 /** 0049 * Whether there exists an event with the given id under the given application name. 0050 */ 0051 bool isValid() const; 0052 0053 /** 0054 * @return entry from the relevant Global notifyrc config group 0055 * 0056 * This will return the configuration from the user for the given key. 0057 * It first look into the user config file, and then in the global config file. 0058 * 0059 * return a null string if the entry doesn't exist 0060 */ 0061 QString readGlobalEntry(const QString &key) const; 0062 0063 /** 0064 * @return entry from the relevant Event/ notifyrc config group 0065 * 0066 * This will return the configuration from the user for the given key. 0067 * It first look into the user config file, and then in the global config file. 0068 * 0069 * return a null string if the entry doesn't exist 0070 */ 0071 QString readEntry(const QString &key) const; 0072 0073 /** 0074 * @return path entry from the relevant Event/ notifyrc config group 0075 * 0076 * This will return the configuration from the user for the given key 0077 * and interpret it as a path. 0078 */ 0079 QString readPathEntry(const QString &key) const; 0080 /** 0081 * reparse the cached configs. to be used when the config may have changed 0082 */ 0083 static void reparseConfiguration(); 0084 0085 static void reparseSingleConfiguration(const QString &app); 0086 0087 private: 0088 QSharedDataPointer<KNotifyConfigPrivate> d; 0089 }; 0090 0091 #endif