File indexing completed on 2024-05-05 08:56:07
0001 /* 0002 SnoreNotify is a Notification Framework based on Qt 0003 Copyright (C) 2013-2015 Hannah von Reth <vonreth@kde.org> 0004 0005 SnoreNotify is free software: you can redistribute it and/or modify 0006 it under the terms of the GNU Lesser General Public License as published by 0007 the Free Software Foundation, either version 3 of the License, or 0008 (at your option) any later version. 0009 0010 SnoreNotify is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 GNU Lesser General Public License for more details. 0014 0015 You should have received a copy of the GNU Lesser General Public License 0016 along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>. 0017 */ 0018 0019 #ifndef APPLICATION_H 0020 #define APPLICATION_H 0021 #include "snore_exports.h" 0022 #include "hint.h" 0023 #include "notification/icon.h" 0024 #include "alert.h" 0025 0026 #include <QHash> 0027 namespace Snore 0028 { 0029 0030 class ApplicationData; 0031 0032 /** 0033 * Application contains all relevant data to manage applications with the notification backend. 0034 * Application uses a shared datamodel, its content is never copied and automatically released. 0035 * 0036 * @author Hannah von Reth \<vonreth at kde.org\> 0037 */ 0038 0039 class SNORE_EXPORT Application 0040 { 0041 public: 0042 Application(); 0043 0044 /** 0045 * Creates a new Application object. 0046 * @param name the name of the Application. Used in Snore::applications(). 0047 * @param icon the icon of the Application. 0048 * @see SnoreCore::registerApplication 0049 */ 0050 explicit Application(const QString &name, const Icon &icon); 0051 0052 /** 0053 * Creates a new Application object. 0054 * @param key the key of the application. Used in Snore::applications(). 0055 * @param name the name of the Application. 0056 * @param icon the icon of the Application. 0057 * @see SnoreCore::registerApplication 0058 */ 0059 explicit Application(const QString &key, const QString &name, const Icon &icon); 0060 0061 /** 0062 * The copy constructor 0063 * @param other 0064 */ 0065 Application(const Application &other); 0066 0067 /** 0068 * The copy operator 0069 * @param other 0070 */ 0071 Application &operator= (const Application &other); 0072 0073 ~Application(); 0074 0075 /** 0076 * Add an alert to the Application. 0077 * Alerts must be added before the application is registered. 0078 * @param alert the Alert 0079 */ 0080 void addAlert(const Alert &alert); 0081 0082 /** 0083 * Returns the key of the Application. 0084 * Might be the same as name(). 0085 */ 0086 QString key() const; 0087 0088 /** 0089 * Returns the name of the Application. 0090 */ 0091 QString name() const; 0092 0093 /** 0094 * Returns the icon of this Application. 0095 */ 0096 const Icon &icon() const; 0097 0098 /** 0099 * Returns a map with the Alers registered with this Application. 0100 */ 0101 const QHash<QString, Alert> &alerts() const; 0102 0103 /** 0104 * Returns the default alert for notifications. 0105 */ 0106 const Alert defaultAlert() const; 0107 0108 /** 0109 * Returns whether the Application is valid. 0110 */ 0111 bool isValid() const; 0112 0113 /** 0114 * Returns application specific hints. 0115 * Hints are inherited by Notification's. 0116 * Key | Type | Value | Required 0117 * ------------- | ----------- | ----------- | ----------- 0118 * use-markup | QString |Enable markup support for title and message, strings must be html escaped. | Many Backends. 0119 * desktop-entry | QString | The name of the desktop enty associated with the application. | Used for The freedesktop backend. 0120 * windows-app-id | QString | The app id associated with the application. | Needed for the Windows 8 backend [See MSDN Documentation](http://msdn.microsoft.com/en-us/library/windows/apps/dd378459.aspx). 0121 * tray-icon | QPointer<QSystemTray> | A QSystemTray item. | Needed for the System Tray Backend. 0122 * pushover-token | QString | The token associated with your application. | Needed to associate pushover notification with your application, to register your application visit [Pushover](https://pushover.net/apps/build). 0123 * silent | bool | Don't play notification sounds. | Multiple backends. 0124 * sound | QString | Local uri to a sound file. | Secondary Backend Sound. 0125 */ 0126 Hint &hints(); 0127 0128 /** 0129 * Same as hints 0130 * @see hints 0131 */ 0132 const Hint &constHints() const; 0133 0134 private: 0135 QExplicitlySharedDataPointer<ApplicationData> d; 0136 0137 }; 0138 0139 } 0140 Q_DECLARE_METATYPE(Snore::Application) 0141 0142 SNORE_EXPORT QDebug operator<< (QDebug debug, const Snore::Application &app); 0143 0144 #endif // APPLICATION_H