Debian Codegraph @

src/librssguard/services/abstract/cacheforserviceroot.cpp

raw symbols SCIP
1 // For license of this file, see <project-root-folder>/LICENSE.md.cxx . . $ `<file>/src/librssguard/services/abstract/cacheforserviceroot.cpp`/
2
3 #include "services/abstract/cacheforserviceroot.h"cxx . . $ `<file>/src/librssguard/services/abstract/cacheforserviceroot.h`/
4
5 #include "miscellaneous/application.h"cxx . . $ `<file>/src/librssguard/miscellaneous/application.h`/
6 #include "services/abstract/label.h"cxx . . $ `<file>/src/librssguard/services/abstract/label.h`/
7
8 #include <QDir>
9 #include <QSet>
10
11 CacheForServiceRootcxx . . $ CacheForServiceRoot#::CacheForServiceRootcxx . . $ CacheForServiceRoot#CacheForServiceRoot(49f6e7a06ebc5aa8).() : m_uniqueIdcxx . . $ CacheForServiceRoot#m_uniqueId.(NO_PARENT_CATEGORYcxx . . $ `src/librssguard/definitions/definitions.h:42:9`!), m_cacheSaveMutexcxx . . $ CacheForServiceRoot#m_cacheSaveMutex.(new QMutexcxx . . $ QMutex#QMutex(49f6e7a06ebc5aa8).()) {}
12
13 CacheForServiceRootcxx . . $ CacheForServiceRoot#::~cxx . . $ CacheForServiceRoot#`~CacheForServiceRoot`(ced63f7c635d850d).CacheForServiceRootcxx . . $ CacheForServiceRoot#() {}
14
15 void CacheForServiceRootcxx . . $ CacheForServiceRoot#::addLabelsAssignmentsToCachecxx . . $ CacheForServiceRoot#addLabelsAssignmentsToCache(a9c1f6ad514aa17c).(const QStringListcxx . . $ QStringList#& ids_of_messages,
16 const QStringcxx . . $ QString#& lbl_custom_id,
17 bool assign) {
18 if (ids_of_messages.isEmptycxx . . $ QList#isEmpty(3482b152b9333168).()) {
19 return;
20 }
21
22 if (assign) {
23 for (const QStringcxx . . $ QString#& custom_id : ids_of_messages) {
24 if (m_cachedLabelDeassignmentscxx . . $ CacheForServiceRoot#m_cachedLabelDeassignments.[cxx . . $ QMap#`operator[]`(bbd415b616967878).lbl_custom_id].containscxx . . $ QListSpecialMethods#contains(89bcd3f9aa09e28b).(custom_id)) {
25 // We want to assign this ID but it was marked for deassignment, remove from deassignment.
26 m_cachedLabelDeassignmentscxx . . $ CacheForServiceRoot#m_cachedLabelDeassignments.[cxx . . $ QMap#`operator[]`(bbd415b616967878).lbl_custom_id].removeAllcxx . . $ QList#removeAll(5aa96cff9a2299b8).(custom_id);
27 }
28 else {
29 m_cachedLabelAssignmentscxx . . $ CacheForServiceRoot#m_cachedLabelAssignments.[cxx . . $ QMap#`operator[]`(bbd415b616967878).lbl_custom_id].appendcxx . . $ QList#append(200d2dc08238a4ed).(custom_id);
30 m_cachedLabelAssignmentscxx . . $ CacheForServiceRoot#m_cachedLabelAssignments.[cxx . . $ QMap#`operator[]`(bbd415b616967878).lbl_custom_id].removeDuplicatescxx . . $ QListSpecialMethods#removeDuplicates(a5d9f2bf8849668d).();
31 }
32 }
33 }
34 else {
35 for (const QStringcxx . . $ QString#& custom_id : ids_of_messages) {
36 if (m_cachedLabelAssignmentscxx . . $ CacheForServiceRoot#m_cachedLabelAssignments.[cxx . . $ QMap#`operator[]`(bbd415b616967878).lbl_custom_id].containscxx . . $ QListSpecialMethods#contains(89bcd3f9aa09e28b).(custom_id)) {
37 // We want to deassign this ID but it was marked for assignment, remove from assignment.
38 m_cachedLabelAssignmentscxx . . $ CacheForServiceRoot#m_cachedLabelAssignments.[cxx . . $ QMap#`operator[]`(bbd415b616967878).lbl_custom_id].removeAllcxx . . $ QList#removeAll(5aa96cff9a2299b8).(custom_id);
39 }
40 else {
41 m_cachedLabelDeassignmentscxx . . $ CacheForServiceRoot#m_cachedLabelDeassignments.[cxx . . $ QMap#`operator[]`(bbd415b616967878).lbl_custom_id].appendcxx . . $ QList#append(200d2dc08238a4ed).(custom_id);
42 m_cachedLabelDeassignmentscxx . . $ CacheForServiceRoot#m_cachedLabelDeassignments.[cxx . . $ QMap#`operator[]`(bbd415b616967878).lbl_custom_id].removeDuplicatescxx . . $ QListSpecialMethods#removeDuplicates(a5d9f2bf8849668d).();
43 }
44 }
45 }
46
47 saveCacheToFilecxx . . $ CacheForServiceRoot#saveCacheToFile(49f6e7a06ebc5aa8).();
48 }
49
50 void CacheForServiceRootcxx . . $ CacheForServiceRoot#::addLabelsAssignmentsToCachecxx . . $ CacheForServiceRoot#addLabelsAssignmentsToCache(f01e5ff6d23cefdf).(const QListcxx . . $ QList#<Messagecxx . . $ Message#>& ids_of_messages, Labelcxx . . $ Label#* lbl, bool assign) {
51 auto custom_ids = lbl->getParentServiceRootcxx . . $ RootItem#getParentServiceRoot(56209a8cf0725652).()->customIDsOfMessagescxx . . $ ServiceRoot#customIDsOfMessages(484dd2f321a6295e).(ids_of_messages);
52
53 addLabelsAssignmentsToCachecxx . . $ CacheForServiceRoot#addLabelsAssignmentsToCache(a9c1f6ad514aa17c).(custom_ids, lbl->customIdcxx . . $ RootItem#customId(6ef7b6c27b00b43d).(), assign);
54 }
55
56 void CacheForServiceRootcxx . . $ CacheForServiceRoot#::addMessageStatesToCachecxx . . $ CacheForServiceRoot#addMessageStatesToCache(559cd80f2974816d).(const QListcxx . . $ QList#<Messagecxx . . $ Message#>& ids_of_messages,
57 RootItemcxx . . $ RootItem#::Importancecxx . . $ RootItem#Importance# importance) {
58 if (ids_of_messages.isEmptycxx . . $ QList#isEmpty(3482b152b9333168).()) {
59 return;
60 }
61
62 QMutexLocker lckcxx . . $ QMutexLocker#QMutexLocker(35605a8b3c396497).(m_cacheSaveMutexcxx . . $ CacheForServiceRoot#m_cacheSaveMutex..datacxx . . $ QScopedPointer#data(34d6acfd341ba7ab).());
63 QListcxx . . $ QList#<Messagecxx . . $ Message#>& list_act = m_cachedStatesImportantcxx . . $ CacheForServiceRoot#m_cachedStatesImportant.[cxx . . $ QMap#`operator[]`(bbd415b616967878).importance];
64 QListcxx . . $ QList#<Messagecxx . . $ Message#>& list_other =
65 m_cachedStatesImportantcxx . . $ CacheForServiceRoot#m_cachedStatesImportant.[cxx . . $ QMap#`operator[]`(bbd415b616967878).importance == RootItemcxx . . $ RootItem#::Importancecxx . . $ RootItem#Importance#::Importantcxx . . $ RootItem#Importance#Important. ? RootItemcxx . . $ RootItem#::Importancecxx . . $ RootItem#Importance#::NotImportantcxx . . $ RootItem#Importance#NotImportant.
66 : RootItemcxx . . $ RootItem#::Importancecxx . . $ RootItem#Importance#::Importantcxx . . $ RootItem#Importance#Important.];
67
68 // Store changes, they will be sent to server later.
69 list_act.appendcxx . . $ QList#append(3d2301cfd89f773a).(ids_of_messages);
70
71 #if QT_VERSIONcxx . . $ `<external>/3898848398875472725/qtversionchecks.h:17:9`! >= 0x050E00 // Qt >= 5.14.0
72 QSetcxx . . $ QSet#<Messagecxx . . $ Message#> set_actcxx . . $ QSet#QSet(50ef72ff69bc573d).(list_act.begincxx . . $ QList#begin(ca2520f641887418).(), list_act.endcxx . . $ QList#end(ca2520f641887418).());
73 QSetcxx . . $ QSet#<Messagecxx . . $ Message#> set_othercxx . . $ QSet#QSet(50ef72ff69bc573d).(list_other.begincxx . . $ QList#begin(ca2520f641887418).(), list_other.endcxx . . $ QList#end(ca2520f641887418).());
74 #else
75 QSet<Message> set_act = list_act.toSet();
76 QSet<Message> set_other = list_other.toSet();
77 #endif
78
79 // Now, we want to remove all IDS from list_other, which are contained in list.
80 set_other -=cxx . . $ QSet#`operator-=`(ccebfa87892ac54d). set_act;
81 list_act.clearcxx . . $ QList#clear(49f6e7a06ebc5aa8).();
82 list_act.appendcxx . . $ QList#append(b1a5d2b9a710f6d1).(set_act.valuescxx . . $ QSet#values(bf6c511543d55010).());
83 list_other.clearcxx . . $ QList#clear(49f6e7a06ebc5aa8).();
84 list_other.appendcxx . . $ QList#append(b1a5d2b9a710f6d1).(set_other.valuescxx . . $ QSet#values(bf6c511543d55010).());
85
86 saveCacheToFilecxx . . $ CacheForServiceRoot#saveCacheToFile(49f6e7a06ebc5aa8).();
87 }
88
89 void CacheForServiceRootcxx . . $ CacheForServiceRoot#::addMessageStatesToCachecxx . . $ CacheForServiceRoot#addMessageStatesToCache(c21502b1d481d06b).(const QStringListcxx . . $ QStringList#& ids_of_messages, RootItemcxx . . $ RootItem#::ReadStatuscxx . . $ RootItem#ReadStatus# read) {
90 if (ids_of_messages.isEmptycxx . . $ QList#isEmpty(3482b152b9333168).()) {
91 return;
92 }
93
94 QMutexLocker lckcxx . . $ QMutexLocker#QMutexLocker(35605a8b3c396497).(m_cacheSaveMutexcxx . . $ CacheForServiceRoot#m_cacheSaveMutex..datacxx . . $ QScopedPointer#data(34d6acfd341ba7ab).());
95 QStringListcxx . . $ QStringList#& list_act = m_cachedStatesReadcxx . . $ CacheForServiceRoot#m_cachedStatesRead.[cxx . . $ QMap#`operator[]`(bbd415b616967878).read];
96 QStringListcxx . . $ QStringList#& list_other =
97 m_cachedStatesReadcxx . . $ CacheForServiceRoot#m_cachedStatesRead.[cxx . . $ QMap#`operator[]`(bbd415b616967878).read == RootItemcxx . . $ RootItem#::ReadStatuscxx . . $ RootItem#ReadStatus#::Readcxx . . $ RootItem#ReadStatus#Read. ? RootItemcxx . . $ RootItem#::ReadStatuscxx . . $ RootItem#ReadStatus#::Unreadcxx . . $ RootItem#ReadStatus#Unread. : RootItemcxx . . $ RootItem#::ReadStatuscxx . . $ RootItem#ReadStatus#::Readcxx . . $ RootItem#ReadStatus#Read.];
98
99 // Store changes, they will be sent to server later.
100 list_act.appendcxx . . $ QList#append(3d2301cfd89f773a).(ids_of_messages);
101
102 #if QT_VERSIONcxx . . $ `<external>/3898848398875472725/qtversionchecks.h:17:9`! >= 0x050E00 // Qt >= 5.14.0
103 QSetcxx . . $ QSet#<QStringcxx . . $ QString#> set_actcxx . . $ QSet#QSet(50ef72ff69bc573d).(list_act.begincxx . . $ QList#begin(ca2520f641887418).(), list_act.endcxx . . $ QList#end(ca2520f641887418).());
104 QSetcxx . . $ QSet#<QStringcxx . . $ QString#> set_othercxx . . $ QSet#QSet(50ef72ff69bc573d).(list_other.begincxx . . $ QList#begin(ca2520f641887418).(), list_other.endcxx . . $ QList#end(ca2520f641887418).());
105 #else
106 QSet<QString> set_act = list_act.toSet();
107 QSet<QString> set_other = list_other.toSet();
108 #endif
109
110 // Now, we want to remove all IDS from list_other, which are contained in list.
111 set_other -=cxx . . $ QSet#`operator-=`(ccebfa87892ac54d). set_act;
112 list_act.clearcxx . . $ QList#clear(49f6e7a06ebc5aa8).();
113 list_act.appendcxx . . $ QList#append(b1a5d2b9a710f6d1).(set_act.valuescxx . . $ QSet#values(bf6c511543d55010).());
114 list_other.clearcxx . . $ QList#clear(49f6e7a06ebc5aa8).();
115 list_other.appendcxx . . $ QList#append(b1a5d2b9a710f6d1).(set_other.valuescxx . . $ QSet#values(bf6c511543d55010).());
116
117 saveCacheToFilecxx . . $ CacheForServiceRoot#saveCacheToFile(49f6e7a06ebc5aa8).();
118 }
119
120 void CacheForServiceRootcxx . . $ CacheForServiceRoot#::saveCacheToFilecxx . . $ CacheForServiceRoot#saveCacheToFile(49f6e7a06ebc5aa8).() {
121 // Save to file.
122 const QStringcxx . . $ QString# file_cache =
123 qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->userDataFoldercxx . . $ Application#userDataFolder(4365c3963150523e).() + QDircxx . . $ QDir#::separatorcxx . . $ QDir#separator(44eb9225326fcbf5).() + QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(m_uniqueIdcxx . . $ CacheForServiceRoot#m_uniqueId.) + "-cached-msgs.dat";
124
125 if (isEmptycxx . . $ CacheForServiceRoot#isEmpty(50ce9a9e25b4a850).()) {
126 QFilecxx . . $ QFile#::removecxx . . $ QFile#remove(e1defb592416720d).(file_cache);
127 }
128 else {
129 QFilecxx . . $ QFile# filecxx . . $ QFile#QFile(3520e46b33348bf6).(file_cache);
130
131 if (file.opencxx . . $ QFile#open(da34f43c1eae080c).(QIODevicecxx . . $ QIODevice#::WriteOnlycxx . . $ QIODeviceBase#WriteOnly. |cxx . . $ `operator|`(64b8367948668350). QIODevicecxx . . $ QIODevice#::Truncatecxx . . $ QIODeviceBase#Truncate.)) {
132 QDataStreamcxx . . $ QDataStream# streamcxx . . $ QDataStream#QDataStream(bebe8f2dee7f9e86).(&file);
133
134 stream <<cxx . . $ `operator<<`(1fe74581aea68806). m_cachedStatesImportantcxx . . $ CacheForServiceRoot#m_cachedStatesImportant. <<cxx . . $ `operator<<`(1fe74581aea68806). m_cachedStatesReadcxx . . $ CacheForServiceRoot#m_cachedStatesRead. <<cxx . . $ `operator<<`(1fe74581aea68806). m_cachedLabelAssignmentscxx . . $ CacheForServiceRoot#m_cachedLabelAssignments. <<cxx . . $ `operator<<`(1fe74581aea68806). m_cachedLabelDeassignmentscxx . . $ CacheForServiceRoot#m_cachedLabelDeassignments.;
135 file.flushcxx . . $ QFileDevice#flush(c9857a73d68e59ba).();
136 file.closecxx . . $ QFileDevice#close(49f6e7a06ebc5aa8).();
137 }
138 }
139 }
140
141 void CacheForServiceRootcxx . . $ CacheForServiceRoot#::clearCachecxx . . $ CacheForServiceRoot#clearCache(49f6e7a06ebc5aa8).() {
142 m_cachedStatesReadcxx . . $ CacheForServiceRoot#m_cachedStatesRead..clearcxx . . $ QMap#clear(49f6e7a06ebc5aa8).();
143 m_cachedStatesImportantcxx . . $ CacheForServiceRoot#m_cachedStatesImportant..clearcxx . . $ QMap#clear(49f6e7a06ebc5aa8).();
144 m_cachedLabelAssignmentscxx . . $ CacheForServiceRoot#m_cachedLabelAssignments..clearcxx . . $ QMap#clear(49f6e7a06ebc5aa8).();
145 m_cachedLabelDeassignmentscxx . . $ CacheForServiceRoot#m_cachedLabelDeassignments..clearcxx . . $ QMap#clear(49f6e7a06ebc5aa8).();
146 }
147
148 void CacheForServiceRootcxx . . $ CacheForServiceRoot#::loadCacheFromFilecxx . . $ CacheForServiceRoot#loadCacheFromFile(49f6e7a06ebc5aa8).() {
149 QMutexLocker lckcxx . . $ QMutexLocker#QMutexLocker(35605a8b3c396497).(m_cacheSaveMutexcxx . . $ CacheForServiceRoot#m_cacheSaveMutex..datacxx . . $ QScopedPointer#data(34d6acfd341ba7ab).());
150
151 clearCachecxx . . $ CacheForServiceRoot#clearCache(49f6e7a06ebc5aa8).();
152
153 // Load from file.
154 const QStringcxx . . $ QString# file_cache =
155 qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->userDataFoldercxx . . $ Application#userDataFolder(4365c3963150523e).() + QDircxx . . $ QDir#::separatorcxx . . $ QDir#separator(44eb9225326fcbf5).() + QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(m_uniqueIdcxx . . $ CacheForServiceRoot#m_uniqueId.) + "-cached-msgs.dat";
156 QFilecxx . . $ QFile# filecxx . . $ QFile#QFile(3520e46b33348bf6).(file_cache);
157
158 if (file.existscxx . . $ QFile#exists(50ce9a9e25b4a850).()) {
159 if (file.opencxx . . $ QFile#open(da34f43c1eae080c).(QIODevicecxx . . $ QFlags#QFlags(93d577a3e9528307).::OpenModeFlagcxx . . $ QIODeviceBase#OpenModeFlag#::ReadOnlycxx . . $ QIODeviceBase#ReadOnly.)) {
160 QDataStreamcxx . . $ QDataStream# streamcxx . . $ QDataStream#QDataStream(bebe8f2dee7f9e86).(&file);
161
162 stream >>cxx . . $ `operator>>`(e12c3171284e86e1). m_cachedStatesImportantcxx . . $ CacheForServiceRoot#m_cachedStatesImportant. >>cxx . . $ `operator>>`(e12c3171284e86e1). m_cachedStatesReadcxx . . $ CacheForServiceRoot#m_cachedStatesRead. >>cxx . . $ `operator>>`(e12c3171284e86e1). m_cachedLabelAssignmentscxx . . $ CacheForServiceRoot#m_cachedLabelAssignments. >>cxx . . $ `operator>>`(e12c3171284e86e1). m_cachedLabelDeassignmentscxx . . $ CacheForServiceRoot#m_cachedLabelDeassignments.;
163 file.closecxx . . $ QFileDevice#close(49f6e7a06ebc5aa8).();
164 }
165 }
166 }
167
168 void CacheForServiceRootcxx . . $ CacheForServiceRoot#::setUniqueIdcxx . . $ CacheForServiceRoot#setUniqueId(d4f767463ce0a6b3).(int unique_id) {
169 m_uniqueIdcxx . . $ CacheForServiceRoot#m_uniqueId. = unique_id;
170 }
171
172 CacheSnapshotcxx . . $ CacheSnapshot# CacheForServiceRootcxx . . $ CacheForServiceRoot#::takeMessageCachecxx . . $ CacheForServiceRoot#takeMessageCache(36f721e47644ccd0).() {
173 QMutexLocker lckcxx . . $ QMutexLocker#QMutexLocker(35605a8b3c396497).(m_cacheSaveMutexcxx . . $ CacheForServiceRoot#m_cacheSaveMutex..datacxx . . $ QScopedPointer#data(34d6acfd341ba7ab).());
174
175 if (isEmptycxx . . $ CacheForServiceRoot#isEmpty(50ce9a9e25b4a850).()) {
176 return CacheSnapshotcxx . . $ CacheSnapshot#();
177 }
178
179 // Make copy of changes.
180 auto cached_data_read = m_cachedStatesReadcxx . . $ CacheForServiceRoot#m_cachedStatesRead.;
181 auto cached_data_imp = m_cachedStatesImportantcxx . . $ CacheForServiceRoot#m_cachedStatesImportant.;
182 auto cached_ass_lbl = m_cachedLabelAssignmentscxx . . $ CacheForServiceRoot#m_cachedLabelAssignments.;
183 auto cached_deass_lbl = m_cachedLabelDeassignmentscxx . . $ CacheForServiceRoot#m_cachedLabelDeassignments.;
184
185 cached_data_read.detachcxx . . $ QMap#detach(49f6e7a06ebc5aa8).();
186 cached_data_imp.detachcxx . . $ QMap#detach(49f6e7a06ebc5aa8).();
187 cached_ass_lbl.detachcxx . . $ QMap#detach(49f6e7a06ebc5aa8).();
188 cached_deass_lbl.detachcxx . . $ QMap#detach(49f6e7a06ebc5aa8).();
189
190 clearCachecxx . . $ CacheForServiceRoot#clearCache(49f6e7a06ebc5aa8).();
191 saveCacheToFilecxx . . $ CacheForServiceRoot#saveCacheToFile(49f6e7a06ebc5aa8).();
192
193 CacheSnapshotcxx . . $ CacheSnapshot# c;
194
195 c.m_cachedLabelAssignmentscxx . . $ CacheSnapshot#m_cachedLabelAssignments. =cxx . . $ QMap#`operator=`(f510c86b9fad02c5). cached_ass_lbl;
196 c.m_cachedLabelDeassignmentscxx . . $ CacheSnapshot#m_cachedLabelDeassignments. =cxx . . $ QMap#`operator=`(f510c86b9fad02c5). cached_deass_lbl;
197 c.m_cachedStatesImportantcxx . . $ CacheSnapshot#m_cachedStatesImportant. =cxx . . $ QMap#`operator=`(755209c8d7d0439a). cached_data_imp;
198 c.m_cachedStatesReadcxx . . $ CacheSnapshot#m_cachedStatesRead. =cxx . . $ QMap#`operator=`(7d615d2c1c63d438). cached_data_read;
199
200 return c;
201 }
202
203 bool CacheForServiceRootcxx . . $ CacheForServiceRoot#::isEmptycxx . . $ CacheForServiceRoot#isEmpty(50ce9a9e25b4a850).() const {
204 return m_cachedStatesReadcxx . . $ CacheForServiceRoot#m_cachedStatesRead..isEmptycxx . . $ QMap#isEmpty(50ce9a9e25b4a850).() && m_cachedStatesImportantcxx . . $ CacheForServiceRoot#m_cachedStatesImportant..isEmptycxx . . $ QMap#isEmpty(50ce9a9e25b4a850).() && m_cachedLabelAssignmentscxx . . $ CacheForServiceRoot#m_cachedLabelAssignments..isEmptycxx . . $ QMap#isEmpty(50ce9a9e25b4a850).() &&
205 m_cachedLabelDeassignmentscxx . . $ CacheForServiceRoot#m_cachedLabelDeassignments..isEmptycxx . . $ QMap#isEmpty(50ce9a9e25b4a850).();
206 }