| 1 | // For license of this file, see <project-root-folder>/LICENSE.md.cxx . . $ `<file>/src/librssguard/miscellaneous/notificationfactory.cpp`/ |
| 2 | |
| 3 | #include "miscellaneous/notificationfactory.h"cxx . . $ `<file>/src/librssguard/miscellaneous/notificationfactory.h`/ |
| 4 | |
| 5 | #include "3rd-party/boolinq/boolinq.h"cxx . . $ `<file>/src/librssguard/3rd-party/boolinq/boolinq.h`/ |
| 6 | #include "definitions/definitions.h"cxx . . $ `<file>/src/librssguard/definitions/definitions.h`/ |
| 7 | #include "miscellaneous/application.h"cxx . . $ `<file>/src/librssguard/miscellaneous/application.h`/ |
| 8 | #include "miscellaneous/settings.h"cxx . . $ `<file>/src/librssguard/miscellaneous/settings.h`/ |
| 9 | |
| 10 | #include <QRegularExpression> |
| 11 | |
| 12 | NotificationFactorycxx . . $ NotificationFactory#::NotificationFactorycxx . . $ NotificationFactory#NotificationFactory(749de1b6ae65bddd).(QObjectcxx . . $ QObject#* parent) : QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(parent) {} |
| 13 | |
| 14 | QListcxx . . $ QList#<Notificationcxx . . $ Notification#> NotificationFactorycxx . . $ NotificationFactory#::allNotificationscxx . . $ NotificationFactory#allNotifications(497a155dc12c5218).() const { |
| 15 | return m_notificationscxx . . $ NotificationFactory#m_notifications.; |
| 16 | } |
| 17 | |
| 18 | bool NotificationFactorycxx . . $ NotificationFactory#::areNotificationsEnabledcxx . . $ NotificationFactory#areNotificationsEnabled(50ce9a9e25b4a850).() const { |
| 19 | return qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->valuecxx . . $ Settings#value(8f1f29a69568d71a).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(GUI), SETTINGcxx . . $ `src/librssguard/miscellaneous/settings.h:30:9`!(GUI::EnableNotifications)).toBoolcxx . . $ QVariant#toBool(50ce9a9e25b4a850).(); |
| 20 | } |
| 21 | |
| 22 | bool NotificationFactorycxx . . $ NotificationFactory#::useToastNotificationscxx . . $ NotificationFactory#useToastNotifications(50ce9a9e25b4a850).() const { |
| 23 | return qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->valuecxx . . $ Settings#value(8f1f29a69568d71a).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(GUI), SETTINGcxx . . $ `src/librssguard/miscellaneous/settings.h:30:9`!(GUI::UseToastNotifications)).toBoolcxx . . $ QVariant#toBool(50ce9a9e25b4a850).(); |
| 24 | } |
| 25 | |
| 26 | Notificationcxx . . $ Notification# NotificationFactorycxx . . $ NotificationFactory#::notificationForEventcxx . . $ NotificationFactory#notificationForEvent(5f161bf92a98a4ee).(Notificationcxx . . $ Notification#::Eventcxx . . $ Notification#Event# event) const { |
| 27 | if (!qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->valuecxx . . $ Settings#value(8f1f29a69568d71a).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(GUI), SETTINGcxx . . $ `src/librssguard/miscellaneous/settings.h:30:9`!(GUI::EnableNotifications)).toBoolcxx . . $ QVariant#toBool(50ce9a9e25b4a850).()) { |
| 28 | return Notificationcxx . . $ Notification#Notification(113beba568247365).(); |
| 29 | } |
| 30 | |
| 31 | auto good_n = boolinqcxx . . $ boolinq/::fromcxx . . $ boolinq/from(1a44d082b2747720).(m_notificationscxx . . $ NotificationFactory#m_notifications.).wherecxx . . $ boolinq/Linq#where(d169c8e6e9294137).([cxx . . $ std/function#function(bdc3712e480e4d04).event](const Notificationcxx . . $ Notification#& n) { |
| 32 | return n.eventcxx . . $ Notification#event(752d85c5520a3778).() == event; |
| 33 | }); |
| 34 | |
| 35 | if (good_n.countcxx . . $ boolinq/Linq#count(455f465bc33b4cdf).() <= 0) { |
| 36 | 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). "Notification for event" <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACEcxx . . $ `src/librssguard/definitions/definitions.h:432:9`!(int(event)) <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "not found"; |
| 37 | |
| 38 | return Notificationcxx . . $ Notification#Notification(113beba568247365).(); |
| 39 | } |
| 40 | else { |
| 41 | return good_n.firstcxx . . $ boolinq/Linq#first(7b7646ca7c721626).(); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | void NotificationFactorycxx . . $ NotificationFactory#::loadcxx . . $ NotificationFactory#load(2321cafd49114dd8).(Settingscxx . . $ Settings#* settings) { |
| 46 | auto notif_keys = settings->allKeyscxx . . $ Settings#allKeys(8335580dfd879b35).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(Notifications)).filtercxx . . $ QListSpecialMethods#filter(423e3013684dc83d).(QRegularExpressioncxx . . $ QRegularExpression#QRegularExpression(4279d2539df7cd4a).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("^\\d+$"))); |
| 47 | |
| 48 | m_notificationscxx . . $ NotificationFactory#m_notifications..clearcxx . . $ QList#clear(49f6e7a06ebc5aa8).(); |
| 49 | |
| 50 | for (const auto& key : notif_keys) { |
| 51 | auto event = Notificationcxx . . $ Notification#::Eventcxx . . $ Notification#Event#(key.toIntcxx . . $ QString#toInt(d7972accae11ee1f).()); |
| 52 | auto data = settings->valuecxx . . $ Settings#value(8f1f29a69568d71a).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(Notifications), key).toStringListcxx . . $ QVariant#toStringList(2b25566bdf736d18).(); |
| 53 | auto balloon = data.atcxx . . $ QList#at(c7965f769b39929).(0).toIntcxx . . $ QString#toInt(d7972accae11ee1f).() != 0; |
| 54 | auto sound_path = datacxx . . $ QString#QString(132dd6869045752b)..atcxx . . $ QList#at(c7965f769b39929).(1); |
| 55 | auto volume = data.sizecxx . . $ QList#size(6b0412d51016192f).() > 2 ? data.atcxx . . $ QList#at(c7965f769b39929).(2).toIntcxx . . $ QString#toInt(d7972accae11ee1f).() : DEFAULT_NOTIFICATION_VOLUMEcxx . . $ `src/librssguard/definitions/definitions.h:100:9`!; |
| 56 | auto play_sound = data.sizecxx . . $ QList#size(6b0412d51016192f).() > 3 ? data.atcxx . . $ QList#at(c7965f769b39929).(3).toIntcxx . . $ QString#toInt(d7972accae11ee1f).() != 0 : true; |
| 57 | auto dialog = data.sizecxx . . $ QList#size(6b0412d51016192f).() > 4 ? data.atcxx . . $ QList#at(c7965f769b39929).(4).toIntcxx . . $ QString#toInt(d7972accae11ee1f).() != 0 : false; |
| 58 | |
| 59 | m_notificationscxx . . $ NotificationFactory#m_notifications..appendcxx . . $ QList#append(1262c8661f7a27a7).(Notificationcxx . . $ Notification#Notification(113beba568247365).(event, balloon, dialog, play_sound, sound_path, volume)); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | void NotificationFactorycxx . . $ NotificationFactory#::savecxx . . $ NotificationFactory#save(2e6f17f64b96dd1f).(const QListcxx . . $ QList#<Notificationcxx . . $ Notification#>& new_notifications, Settingscxx . . $ Settings#* settings) { |
| 64 | settings->removecxx . . $ Settings#remove(c1427772cd1877b0).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(Notifications)); |
| 65 | m_notificationscxx . . $ NotificationFactory#m_notifications. =cxx . . $ QList#`operator=`(910ed1af1a450232). new_notifications; |
| 66 | |
| 67 | for (const auto& n : stdcxx . . $ std/::as_constcxx . . $ std/as_const(1dc117cbefefc300).(m_notificationscxx . . $ NotificationFactory#m_notifications.)) { |
| 68 | settings->setValuecxx . . $ Settings#setValue(365356ede4ebaabb).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(Notifications), |
| 69 | QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(int(n.eventcxx . . $ Notification#event(752d85c5520a3778).())), |
| 70 | QStringListcxx . . $ QVariant#QVariant(cdcda21a1866b6fa).{n.balloonEnabledcxx . . $ Notification#balloonEnabled(50ce9a9e25b4a850).() ? QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("1") : QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("0"), |
| 71 | n.soundPathcxx . . $ Notification#soundPath(6ef7b6c27b00b43d).(), |
| 72 | QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(n.volumecxx . . $ Notification#volume(455f465bc33b4cdf).()), |
| 73 | n.soundEnabledcxx . . $ Notification#soundEnabled(50ce9a9e25b4a850).() ? QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("1") : QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("0"), |
| 74 | n.dialogEnabledcxx . . $ Notification#dialogEnabled(50ce9a9e25b4a850).() ? QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("1") : QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("0")}); |
| 75 | } |
| 76 | } |