Debian Codegraph @

src/librssguard/miscellaneous/notification.cpp

raw symbols SCIP
1 // For license of this file, see <project-root-folder>/LICENSE.md.cxx . . $ `<file>/src/librssguard/miscellaneous/notification.cpp`/
2
3 #include "miscellaneous/notification.h"cxx . . $ `<file>/src/librssguard/miscellaneous/notification.h`/
4
5 #include "miscellaneous/application.h"cxx . . $ `<file>/src/librssguard/miscellaneous/application.h`/
6
7 #include <QDir>
8
9 #if !defined(Q_OS_OS2)
10 #include <QMediaPlayer>
11 #include <QSoundEffect>
12
13 #if QT_VERSION_MAJORcxx . . $ `<external>/9758848313111604122/qconfig.h:67:9`! == 6
14 #include <QAudioOutput>
15 #endif
16 #endif
17
18 Notificationcxx . . $ Notification#::Notificationcxx . . $ Notification#Notification(113beba568247365).(Notificationcxx . . $ Notification#::Eventcxx . . $ Notification#Event# event,
19 bool balloon,
20 bool dialog,
21 bool play_sound,
22 const QStringcxx . . $ QString#& sound_path,
23 int volume)
24 : m_eventcxx . . $ Notification#m_event.(event), m_balloonEnabledcxx . . $ Notification#m_balloonEnabled.(balloon), m_dialogEnabledcxx . . $ Notification#m_dialogEnabled.(dialog), m_soundEnabledcxx . . $ Notification#m_soundEnabled.(play_sound),
25 m_soundPathcxx . . $ Notification#m_soundPath.(sound_path), m_volumecxx . . $ Notification#m_volume.(volume) {}
26
27 Notificationcxx . . $ Notification#::Eventcxx . . $ Notification#Event# Notificationcxx . . $ Notification#::eventcxx . . $ Notification#event(752d85c5520a3778).() const {
28 return m_eventcxx . . $ Notification#m_event.;
29 }
30
31 void Notificationcxx . . $ Notification#::setEventcxx . . $ Notification#setEvent(4d81b92070311c96).(Eventcxx . . $ Notification#Event# event) {
32 m_eventcxx . . $ Notification#m_event. = event;
33 }
34
35 QStringcxx . . $ QString# Notificationcxx . . $ Notification#::soundPathcxx . . $ Notification#soundPath(6ef7b6c27b00b43d).() const {
36 return m_soundPathcxx . . $ QString#QString(132dd6869045752b).;
37 }
38
39 void Notificationcxx . . $ Notification#::setSoundPathcxx . . $ Notification#setSoundPath(3520e46b33348bf6).(const QStringcxx . . $ QString#& sound_path) {
40 m_soundPathcxx . . $ Notification#m_soundPath. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). sound_path;
41 }
42
43 void Notificationcxx . . $ Notification#::playSoundcxx . . $ Notification#playSound(20e408e26c1df836).(Applicationcxx . . $ Application#* app) const {
44 if (!m_soundPathcxx . . $ Notification#m_soundPath..isEmptycxx . . $ QString#isEmpty(3482b152b9333168).()) {
45 #if !defined(Q_OS_OS2)
46 if (m_soundPathcxx . . $ Notification#m_soundPath..endsWithcxx . . $ QString#endsWith(8cce4688c16f48f3).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(".wav"), Qtcxx . . $ Qt/::CaseSensitivitycxx . . $ Qt/CaseSensitivity#::CaseInsensitivecxx . . $ Qt/CaseInsensitive.)) {
47 qDebugNNcxx . . $ `src/librssguard/definitions/definitions.h:413:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_COREcxx . . $ `src/librssguard/definitions/definitions.h:178:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Using QSoundEffect to play notification sound.";
48
49 QSoundEffectcxx . . $ QSoundEffect#* play = new QSoundEffectcxx . . $ QSoundEffect#(app);
50
51 QObjectcxx . . $ QObject#::connectcxx . . $ QObject#connect(dad3a9587f3dce3c).(play, &QSoundEffectcxx . . $ QSoundEffect#::playingChangedcxx . . $ QSoundEffect#playingChanged(49f6e7a06ebc5aa8)., play, [play]() {
52 if (!play->isPlayingcxx . . $ QSoundEffect#isPlaying(50ce9a9e25b4a850).()) {
53 play->deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).();
54 }
55 });
56
57 if (m_soundPathcxx . . $ Notification#m_soundPath..startsWithcxx . . $ QString#startsWith(8cce4688c16f48f3).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(":"))) {
58 play->setSourcecxx . . $ QSoundEffect#setSource(37355d2f77053a23).(QUrlcxx . . $ QUrl#QUrl(ea1f3831e370f1cb).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("qrc") +cxx . . $ operator+(adfbdceb504720ce). m_soundPathcxx . . $ Notification#m_soundPath.));
59 }
60 else {
61 play
62 ->setSourcecxx . . $ QSoundEffect#setSource(37355d2f77053a23).(QUrlcxx . . $ QUrl#::fromLocalFilecxx . . $ QUrl#fromLocalFile(daf4b0201622af21).(QDircxx . . $ QDir#::toNativeSeparatorscxx . . $ QDir#toNativeSeparators(fd988a2ab94d906b).(app
63 ->replaceUserDataFolderPlaceholdercxx . . $ Application#replaceUserDataFolderPlaceholder(f6736f2569bd2ccc).(m_soundPathcxx . . $ QString#QString(132dd6869045752b).))));
64 }
65
66 play->setVolumecxx . . $ QSoundEffect#setVolume(9364e6e7bff7660).(fractionalVolumecxx . . $ Notification#fractionalVolume(21b6c25e127938e2).());
67 play->playcxx . . $ QSoundEffect#play(49f6e7a06ebc5aa8).();
68 }
69 else {
70 qDebugNNcxx . . $ `src/librssguard/definitions/definitions.h:413:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_COREcxx . . $ `src/librssguard/definitions/definitions.h:178:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Using QMediaPlayer to play notification sound.";
71
72 QMediaPlayercxx . . $ QMediaPlayer#* play = new QMediaPlayercxx . . $ QMediaPlayer#(app);
73
74 #if QT_VERSION_MAJORcxx . . $ `<external>/9758848313111604122/qconfig.h:67:9`! == 6
75 QAudioOutputcxx . . $ QAudioOutput#* out = new QAudioOutputcxx . . $ QAudioOutput#QAudioOutput(749de1b6ae65bddd).(app);
76
77 play->setAudioOutputcxx . . $ QMediaPlayer#setAudioOutput(da1ecd4cf99cf8a7).(out);
78
79 QObjectcxx . . $ QObject#::connectcxx . . $ QObject#connect(dad3a9587f3dce3c).(play, &QMediaPlayercxx . . $ QMediaPlayer#::playbackStateChangedcxx . . $ QMediaPlayer#playbackStateChanged(19cb1d35488f1357)., play, [play, out](QMediaPlayercxx . . $ QMediaPlayer#::PlaybackStatecxx . . $ QMediaPlayer#PlaybackState# state) {
80 if (state == QMediaPlayercxx . . $ QMediaPlayer#::PlaybackStatecxx . . $ QMediaPlayer#PlaybackState#::StoppedStatecxx . . $ QMediaPlayer#StoppedState.) {
81 out->deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).();
82 play->deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).();
83 }
84 });
85
86 if (m_soundPathcxx . . $ Notification#m_soundPath..startsWithcxx . . $ QString#startsWith(8cce4688c16f48f3).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(":"))) {
87 play->setSourcecxx . . $ QMediaPlayer#setSource(37355d2f77053a23).(QUrlcxx . . $ QUrl#QUrl(ea1f3831e370f1cb).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("qrc") +cxx . . $ operator+(adfbdceb504720ce). m_soundPathcxx . . $ Notification#m_soundPath.));
88 }
89 else {
90 play
91 ->setSourcecxx . . $ QMediaPlayer#setSource(37355d2f77053a23).(QUrlcxx . . $ QUrl#::fromLocalFilecxx . . $ QUrl#fromLocalFile(daf4b0201622af21).(QDircxx . . $ QDir#::toNativeSeparatorscxx . . $ QDir#toNativeSeparators(fd988a2ab94d906b).(app
92 ->replaceUserDataFolderPlaceholdercxx . . $ Application#replaceUserDataFolderPlaceholder(f6736f2569bd2ccc).(m_soundPathcxx . . $ QString#QString(132dd6869045752b).))));
93 }
94
95 play->audioOutputcxx . . $ QMediaPlayer#audioOutput(39ee5d0a3e976ea6).()->setVolumecxx . . $ QAudioOutput#setVolume(9364e6e7bff7660).(fractionalVolumecxx . . $ Notification#fractionalVolume(21b6c25e127938e2).());
96 play->playcxx . . $ QMediaPlayer#play(49f6e7a06ebc5aa8).();
97 #else
98 QObject::connect(play, &QMediaPlayer::stateChanged, play, [play](QMediaPlayer::State state) {
99 if (state == QMediaPlayer::State::StoppedState) {
100 play->deleteLater();
101 }
102 });
103
104 if (m_soundPath.startsWith(QSL(":"))) {
105 play->setMedia(QMediaContent(QUrl(QSL("qrc") + m_soundPath)));
106 }
107 else {
108 play->setMedia(QMediaContent(
109 QUrl::fromLocalFile(QDir::toNativeSeparators(app->replaceUserDataFolderPlaceholder(m_soundPath)))));
110 }
111
112 play->setVolume(m_volume);
113 play->play();
114 #endif
115 }
116 #endif
117 }
118 }
119
120 QListcxx . . $ QList#<Notificationcxx . . $ Notification#::Eventcxx . . $ Notification#Event#> Notificationcxx . . $ Notification#::allEventscxx . . $ Notification#allEvents(7ddaa241c28a488e).() {
121 return {cxx . . $ QList#QList(b6da5b9a9f304025).Eventcxx . . $ Notification#Event#::GeneralEventcxx . . $ Notification#Event#GeneralEvent.,
122 Eventcxx . . $ Notification#Event#::NewUnreadArticlesFetchedcxx . . $ Notification#Event#NewUnreadArticlesFetched.,
123 Eventcxx . . $ Notification#Event#::ArticlesFetchingStartedcxx . . $ Notification#Event#ArticlesFetchingStarted.,
124 Eventcxx . . $ Notification#Event#::ArticlesFetchingErrorcxx . . $ Notification#Event#ArticlesFetchingError.,
125 Eventcxx . . $ Notification#Event#::LoginDataRefreshedcxx . . $ Notification#Event#LoginDataRefreshed.,
126 Eventcxx . . $ Notification#Event#::LoginFailurecxx . . $ Notification#Event#LoginFailure.,
127 Eventcxx . . $ Notification#Event#::NewAppVersionAvailablecxx . . $ Notification#Event#NewAppVersionAvailable.,
128 Eventcxx . . $ Notification#Event#::NodePackageUpdatedcxx . . $ Notification#Event#NodePackageUpdated.,
129 Eventcxx . . $ Notification#Event#::NodePackageFailedToUpdatecxx . . $ Notification#Event#NodePackageFailedToUpdate.};
130 }
131
132 QStringcxx . . $ QString# Notificationcxx . . $ Notification#::nameForEventcxx . . $ Notification#nameForEvent(50042268f9318a56).(Notificationcxx . . $ Notification#::Eventcxx . . $ Notification#Event# event) {
133 switch (event) {
134 case Notificationcxx . . $ Notification#::Eventcxx . . $ Notification#Event#::NewUnreadArticlesFetchedcxx . . $ Notification#Event#NewUnreadArticlesFetched.:
135 return QObjectcxx . . $ QObject#::trcxx . . $ QObject#tr(75d9f1c324b4579d).("New (unread) articles fetched");
136
137 case Notificationcxx . . $ Notification#::Eventcxx . . $ Notification#Event#::ArticlesFetchingStartedcxx . . $ Notification#Event#ArticlesFetchingStarted.:
138 return QObjectcxx . . $ QObject#::trcxx . . $ QObject#tr(75d9f1c324b4579d).("Fetching articles right now");
139
140 case Notificationcxx . . $ Notification#::Eventcxx . . $ Notification#Event#::LoginDataRefreshedcxx . . $ Notification#Event#LoginDataRefreshed.:
141 return QObjectcxx . . $ QObject#::trcxx . . $ QObject#tr(75d9f1c324b4579d).("Login data refreshed");
142
143 case Notificationcxx . . $ Notification#::Eventcxx . . $ Notification#Event#::LoginFailurecxx . . $ Notification#Event#LoginFailure.:
144 return QObjectcxx . . $ QObject#::trcxx . . $ QObject#tr(75d9f1c324b4579d).("Login failed");
145
146 case Notificationcxx . . $ Notification#::Eventcxx . . $ Notification#Event#::NewAppVersionAvailablecxx . . $ Notification#Event#NewAppVersionAvailable.:
147 return QObjectcxx . . $ QObject#::trcxx . . $ QObject#tr(75d9f1c324b4579d).("New %1 version is available").argcxx . . $ QString#arg(ad0bca07273edcc2).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(APP_NAMEcxx . . $ `<built-in>:487:9`!));
148
149 case Notificationcxx . . $ Notification#::Eventcxx . . $ Notification#Event#::GeneralEventcxx . . $ Notification#Event#GeneralEvent.:
150 return QObjectcxx . . $ QObject#::trcxx . . $ QObject#tr(75d9f1c324b4579d).("Miscellaneous events");
151
152 case Notificationcxx . . $ Notification#::Eventcxx . . $ Notification#Event#::NodePackageUpdatedcxx . . $ Notification#Event#NodePackageUpdated.:
153 return QObjectcxx . . $ QObject#::trcxx . . $ QObject#tr(75d9f1c324b4579d).("Node.js - package(s) updated");
154
155 case Notificationcxx . . $ Notification#::Eventcxx . . $ Notification#Event#::NodePackageFailedToUpdatecxx . . $ Notification#Event#NodePackageFailedToUpdate.:
156 return QObjectcxx . . $ QObject#::trcxx . . $ QObject#tr(75d9f1c324b4579d).("Node.js - package(s) failed to update");
157
158 case Notificationcxx . . $ Notification#::Eventcxx . . $ Notification#Event#::ArticlesFetchingErrorcxx . . $ Notification#Event#ArticlesFetchingError.:
159 return QObjectcxx . . $ QObject#::trcxx . . $ QObject#tr(75d9f1c324b4579d).("Error when fetching articles");
160
161 default:
162 return QObjectcxx . . $ QObject#::trcxx . . $ QObject#tr(75d9f1c324b4579d).("Unknown event");
163 }
164 }
165
166 bool Notificationcxx . . $ Notification#::dialogEnabledcxx . . $ Notification#dialogEnabled(50ce9a9e25b4a850).() const {
167 return m_dialogEnabledcxx . . $ Notification#m_dialogEnabled.;
168 }
169
170 void Notificationcxx . . $ Notification#::setSoundEnabledcxx . . $ Notification#setSoundEnabled(b45ddcbc8423892c).(bool play_sound) {
171 m_soundEnabledcxx . . $ Notification#m_soundEnabled. = play_sound;
172 }
173
174 int Notificationcxx . . $ Notification#::volumecxx . . $ Notification#volume(455f465bc33b4cdf).() const {
175 return m_volumecxx . . $ Notification#m_volume.;
176 }
177
178 qrealcxx . . $ qreal# Notificationcxx . . $ Notification#::fractionalVolumecxx . . $ Notification#fractionalVolume(21b6c25e127938e2).() const {
179 return (m_volumecxx . . $ Notification#m_volume. * 1.0f) / 100.0f;
180 }
181
182 void Notificationcxx . . $ Notification#::setVolumecxx . . $ Notification#setVolume(d4f767463ce0a6b3).(int volume) {
183 m_volumecxx . . $ Notification#m_volume. = volume;
184 }
185
186 bool Notificationcxx . . $ Notification#::soundEnabledcxx . . $ Notification#soundEnabled(50ce9a9e25b4a850).() const {
187 return m_soundEnabledcxx . . $ Notification#m_soundEnabled.;
188 }
189
190 bool Notificationcxx . . $ Notification#::balloonEnabledcxx . . $ Notification#balloonEnabled(50ce9a9e25b4a850).() const {
191 return m_balloonEnabledcxx . . $ Notification#m_balloonEnabled.;
192 }