Debian Codegraph @

click-hooks/online-accounts-hooks/main.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2014 Canonical Ltd.
3 *
4 * Contact: Alberto Mardegan <[email protected]>
5 *
6 * This file is part of lomiri-online-accounts-ui's click hooks
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include <Accounts/Manager>
22 #include <QCoreApplication>
23 #include <QDateTime>
24 #include <QDebug>
25 #include <QDir>
26 #include <QDomDocument>
27 #include <QDomElement>
28 #include <QFile>
29 #include <QFileInfo>
30 #include <QStandardPaths>
31 #include <QStringList>
32 #include <click.h>
33 #include <sys/stat.h>
34 #include <sys/types.h>
35 #include <unistd.h>
36 #include <utime.h>
37
38 static QStringcxx . . $ QString# findPackageDircxx . . $ findPackageDir(fd988a2ab94d906b).(const QStringcxx . . $ QString# &appId)
39 {
40 /* For testing */
41 QByteArraycxx . . $ QByteArray# packageDirEnv = qgetenvcxx . . $ qgetenv(531409eeffcde449).("OAH_CLICK_DIR");
42 if (!packageDirEnv.isEmptycxx . . $ QByteArray#isEmpty(50ce9a9e25b4a850).()) {
43 return QStringcxx . . $ QString#::fromUtf8cxx . . $ QString#fromUtf8(4e15edac36d215be).(packageDirEnv);
44 }
45
46 QStringListcxx . . $ QStringList# components = appId.splitcxx . . $ QString#split(92030b8bf74e4227).('_'cxx . . $ QChar#QChar(f349c77f591a7878).);
47 QByteArraycxx . . $ QByteArray# package = components.firstcxx . . $ QList#first(19b2b6f17af048b).().toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).();
48
49 GError *error = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
50 ClickUser *user = click_user_new_for_user(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, &error);
51 if (Q_UNLIKELYcxx . . $ `<external>/4507883856836070869/qcompilerdetection.h:247:11`!(!user)) {
52 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Unable to read Click database:" <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). error->messagecxx . . $ _GError#message.;
53 g_error_free(error);
54 return QStringcxx . . $ QString#QString(ced63f7c635d850d).();
55 }
56
57 gchar *pkgDir = click_user_get_path(user, package.constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).(), &error);
58 if (Q_UNLIKELYcxx . . $ `<external>/4507883856836070869/qcompilerdetection.h:247:11`!(!pkgDir)) {
59 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Unable to get the Click package directory for" <<cxx . . $ QDebug#`operator<<`(1387ba1672043913).
60 package <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). ":" <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). error->messagecxx . . $ _GError#message.;
61 g_error_free(error);
62 g_object_unref(user);
63 return QStringcxx . . $ QString#QString(ced63f7c635d850d).();
64 }
65
66 QStringcxx . . $ QString# ret = QStringcxx . . $ QString#::fromUtf8cxx . . $ QString#fromUtf8(5ac70cc0fa2a874e).(pkgDir);
67 g_object_unref(user);
68 g_free(pkgDir);
69 return retcxx . . $ QString#QString(28715ad661ad3cec).;
70 }
71
72 static QStringcxx . . $ QString# stripVersioncxx . . $ stripVersion(fd988a2ab94d906b).(const QStringcxx . . $ QString# &appId)
73 {
74 QStringListcxx . . $ QStringList# components = appId.splitcxx . . $ QString#split(92030b8bf74e4227).('_'cxx . . $ QChar#QChar(f349c77f591a7878).);
75 if (components.countcxx . . $ QList#count(455f465bc33b4cdf).() != 3) return appIdcxx . . $ QString#QString(132dd6869045752b).;
76
77 /* Click packages have a profile of the form
78 * $name_$application_$version
79 * (see https://wiki.ubuntu.com/SecurityTeam/Specifications/ApplicationConfinement/Manifest#Click)
80 *
81 * So we just need to strip out the last part.
82 */
83 components.removeLastcxx . . $ QList#removeLast(49f6e7a06ebc5aa8).();
84 return components.joincxx . . $ QListSpecialMethods#join(227e33e1a3bf1f91).('_'cxx . . $ QChar#QChar(f349c77f591a7878).);
85 }
86
87 /* Get the modification time of a file; this differs from
88 * QFileInfo::lastModified() in that if the file is a symlink here we take the
89 * info from the symlink itself. */
90 static QDateTimecxx . . $ QDateTime# lastModifiedcxx . . $ lastModified(b660c26f576c0856).(const QFileInfocxx . . $ QFileInfo# &fileInfo)
91 {
92 struct stat data;
93 if (lstat(fileInfo.filePathcxx . . $ QFileInfo#filePath(6ef7b6c27b00b43d).().toUtf8cxx . . $ QString#toUtf8(7c2073558a834e49).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).(), &data) < 0) {
94 return QDateTimecxx . . $ QDateTime#QDateTime(ced63f7c635d850d).();
95 }
96 return QDateTimecxx . . $ QDateTime#::fromSecsSinceEpochcxx . . $ QDateTime#fromSecsSinceEpoch(3ddfaf8b563ea524).(data.st_mtimecxx . . $ `<external>/16045971866008360577/struct_stat.h:78:11`!);
97 }
98
99 class LibAccountsFilecxx . . $ LibAccountsFile#: public QDomDocumentcxx . . $ QDomDocument# {
100 public:
101 explicit LibAccountsFilecxx . . $ LibAccountsFile#LibAccountsFile(208c3155c9413262).(const QFileInfocxx . . $ QFileInfo# &hookFileInfo);
102
103 void checkIdcxx . . $ LibAccountsFile#checkId(3520e46b33348bf6).(const QStringcxx . . $ QString# &shortAppId);
104 void addProfilecxx . . $ LibAccountsFile#addProfile(3520e46b33348bf6).(const QStringcxx . . $ QString# &appId);
105 void addPackageDircxx . . $ LibAccountsFile#addPackageDir(3520e46b33348bf6).(const QStringcxx . . $ QString# &appId);
106 QStringcxx . . $ QString# profilecxx . . $ LibAccountsFile#profile(6ef7b6c27b00b43d).() const;
107 void addDesktopFilecxx . . $ LibAccountsFile#addDesktopFile(3520e46b33348bf6).(const QStringcxx . . $ QString# &appId);
108 void addServiceTypecxx . . $ LibAccountsFile#addServiceType(3520e46b33348bf6).(const QStringcxx . . $ QString# &shortAppId);
109 void checkIconPathcxx . . $ LibAccountsFile#checkIconPath(3520e46b33348bf6).(const QStringcxx . . $ QString# &appId);
110 bool writeTocxx . . $ LibAccountsFile#writeTo(f3b39adf77d9c36c).(const QStringcxx . . $ QString# &fileName) const;
111 void addCreatorMarkcxx . . $ LibAccountsFile#addCreatorMark(49f6e7a06ebc5aa8).();
112 bool createdByUscxx . . $ LibAccountsFile#createdByUs(50ce9a9e25b4a850).() const;
113 bool isValidcxx . . $ LibAccountsFile#isValid(50ce9a9e25b4a850).() const { return m_isValidcxx . . $ LibAccountsFile#m_isValid.; }
114
115 private:
116 QFileInfocxx . . $ QFileInfo# m_hookFileInfocxx . . $ LibAccountsFile#m_hookFileInfo.;
117 bool m_isValidcxx . . $ LibAccountsFile#m_isValid.;
118 };
119
120 LibAccountsFilecxx . . $ LibAccountsFile#::LibAccountsFilecxx . . $ LibAccountsFile#LibAccountsFile(208c3155c9413262).(const QFileInfocxx . . $ QFileInfo# &hookFileInfo):
121 QDomDocumentcxx . . $ QDomDocument#QDomDocument(49f6e7a06ebc5aa8).(),
122 m_hookFileInfocxx . . $ LibAccountsFile#m_hookFileInfo.(hookFileInfo),
123 m_isValidcxx . . $ LibAccountsFile#m_isValid.(false)
124 {
125 QFilecxx . . $ QFile# filecxx . . $ QFile#QFile(3520e46b33348bf6).(hookFileInfo.filePathcxx . . $ QFileInfo#filePath(6ef7b6c27b00b43d).());
126 if (file.opencxx . . $ QFile#open(dca164408be960c8).(QIODevicecxx . . $ QFlags#QFlags(93d577a3e9528307).::ReadOnlycxx . . $ QIODevice#ReadOnly.)) {
127 if (setContentcxx . . $ QDomDocument#setContent(561bc04b7005bb24).(&file)) {
128 m_isValidcxx . . $ LibAccountsFile#m_isValid. = true;
129 }
130 file.closecxx . . $ QFileDevice#close(49f6e7a06ebc5aa8).();
131 }
132 }
133
134 void LibAccountsFilecxx . . $ LibAccountsFile#::checkIdcxx . . $ LibAccountsFile#checkId(3520e46b33348bf6).(const QStringcxx . . $ QString# &shortAppId)
135 {
136 /* checks that the root element's "id" attributes is consistent with the
137 * file name */
138 QDomElementcxx . . $ QDomElement# root = documentElementcxx . . $ QDomDocument#documentElement(654df8c29726cab1).();
139 root.setAttributecxx . . $ QDomElement#setAttribute(c1427772cd1877b0).(QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("id"), shortAppId);
140 }
141
142 void LibAccountsFilecxx . . $ LibAccountsFile#::addProfilecxx . . $ LibAccountsFile#addProfile(3520e46b33348bf6).(const QStringcxx . . $ QString# &appId)
143 {
144 QDomElementcxx . . $ QDomElement# root = documentElementcxx . . $ QDomDocument#documentElement(654df8c29726cab1).();
145 QDomElementcxx . . $ QDomElement# elem = createElementcxx . . $ QDomDocument#createElement(2ec621aca303d14e).(QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("profile"));
146 elem.appendChildcxx . . $ QDomNode#appendChild(1fce9d70e2f1e814).(createTextNodecxx . . $ QDomDocument#createTextNode(9b156b786da100e8).(appId));
147 root.appendChildcxx . . $ QDomNode#appendChild(1fce9d70e2f1e814).(elem);
148 }
149
150 void LibAccountsFilecxx . . $ LibAccountsFile#::addPackageDircxx . . $ LibAccountsFile#addPackageDir(3520e46b33348bf6).(const QStringcxx . . $ QString# &appId)
151 {
152 QStringcxx . . $ QString# packageDir = findPackageDircxx . . $ findPackageDir(fd988a2ab94d906b).(appId);
153 if (Q_UNLIKELYcxx . . $ `<external>/4507883856836070869/qcompilerdetection.h:247:11`!(packageDir.isEmpty())) return;
154
155 QDomElementcxx . . $ QDomElement# root = documentElementcxx . . $ QDomDocument#documentElement(654df8c29726cab1).();
156 QDomElementcxx . . $ QDomElement# elem = createElementcxx . . $ QDomDocument#createElement(2ec621aca303d14e).(QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("package-dir"));
157 elem.appendChildcxx . . $ QDomNode#appendChild(1fce9d70e2f1e814).(createTextNodecxx . . $ QDomDocument#createTextNode(9b156b786da100e8).(packageDir));
158 root.appendChildcxx . . $ QDomNode#appendChild(1fce9d70e2f1e814).(elem);
159 }
160
161 QStringcxx . . $ QString# LibAccountsFilecxx . . $ LibAccountsFile#::profilecxx . . $ LibAccountsFile#profile(6ef7b6c27b00b43d).() const
162 {
163 QDomElementcxx . . $ QDomElement# root = documentElementcxx . . $ QDomDocument#documentElement(654df8c29726cab1).();
164 return root.firstChildElementcxx . . $ QDomNode#firstChildElement(d563d9084a4b323c).("profile"cxx . . $ QString#QString(85c52e162fed56f9).).textcxx . . $ QDomElement#text(6ef7b6c27b00b43d).();
165 }
166
167 void LibAccountsFilecxx . . $ LibAccountsFile#::addDesktopFilecxx . . $ LibAccountsFile#addDesktopFile(3520e46b33348bf6).(const QStringcxx . . $ QString# &appId)
168 {
169 QStringcxx . . $ QString# desktopEntryTag = QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("desktop-entry");
170 QDomElementcxx . . $ QDomElement# root = documentElementcxx . . $ QDomDocument#documentElement(654df8c29726cab1).();
171 /* if a <desktop-entry> element already exists, don't touch it */
172 QDomElementcxx . . $ QDomElement# elem = root.firstChildElementcxx . . $ QDomNode#firstChildElement(d563d9084a4b323c).(desktopEntryTag);
173 if (!elem.isNullcxx . . $ QDomNode#isNull(50ce9a9e25b4a850).()) return;
174
175 elem =cxx . . $ QDomElement#`operator=`(b7fc97416e752cd8). createElementcxx . . $ QDomDocument#createElement(2ec621aca303d14e).(desktopEntryTag);
176 elem.appendChildcxx . . $ QDomNode#appendChild(1fce9d70e2f1e814).(createTextNodecxx . . $ QDomDocument#createTextNode(9b156b786da100e8).(appId));
177 root.appendChildcxx . . $ QDomNode#appendChild(1fce9d70e2f1e814).(elem);
178 }
179
180 void LibAccountsFilecxx . . $ LibAccountsFile#::addServiceTypecxx . . $ LibAccountsFile#addServiceType(3520e46b33348bf6).(const QStringcxx . . $ QString# &shortAppId)
181 {
182 QStringcxx . . $ QString# serviceTypeTag = QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("type");
183 QDomElementcxx . . $ QDomElement# root = documentElementcxx . . $ QDomDocument#documentElement(654df8c29726cab1).();
184 /* if a <service-type> element already exists, don't touch it */
185 QDomElementcxx . . $ QDomElement# elem = root.firstChildElementcxx . . $ QDomNode#firstChildElement(d563d9084a4b323c).(serviceTypeTag);
186 if (!elem.isNullcxx . . $ QDomNode#isNull(50ce9a9e25b4a850).()) return;
187
188 elem =cxx . . $ QDomElement#`operator=`(b7fc97416e752cd8). createElementcxx . . $ QDomDocument#createElement(2ec621aca303d14e).(serviceTypeTag);
189 elem.appendChildcxx . . $ QDomNode#appendChild(1fce9d70e2f1e814).(createTextNodecxx . . $ QDomDocument#createTextNode(9b156b786da100e8).(shortAppId));
190 root.appendChildcxx . . $ QDomNode#appendChild(1fce9d70e2f1e814).(elem);
191 }
192
193 void LibAccountsFilecxx . . $ LibAccountsFile#::checkIconPathcxx . . $ LibAccountsFile#checkIconPath(3520e46b33348bf6).(const QStringcxx . . $ QString# &appId)
194 {
195 QStringcxx . . $ QString# iconTag = QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("icon");
196 QDomElementcxx . . $ QDomElement# root = documentElementcxx . . $ QDomDocument#documentElement(654df8c29726cab1).();
197 /* if the <icon> element does not exist, do nothing*/
198 QDomElementcxx . . $ QDomElement# elem = root.firstChildElementcxx . . $ QDomNode#firstChildElement(d563d9084a4b323c).(iconTag);
199 if (elem.isNullcxx . . $ QDomNode#isNull(50ce9a9e25b4a850).()) return;
200
201 /* If the icon path is absolute, do nothing */
202 QStringcxx . . $ QString# icon = elem.textcxx . . $ QDomElement#text(6ef7b6c27b00b43d).();
203 if (QDircxx . . $ QDir#::isAbsolutePathcxx . . $ QDir#isAbsolutePath(e1defb592416720d).(icon)) return;
204
205 /* Otherwise, try appending it to the click package install dir */
206 QStringcxx . . $ QString# packageDir = findPackageDircxx . . $ findPackageDir(fd988a2ab94d906b).(appId);
207 if (Q_UNLIKELYcxx . . $ `<external>/4507883856836070869/qcompilerdetection.h:247:11`!(packageDir.isEmpty())) return;
208
209 QFileInfocxx . . $ QFileInfo# iconFilecxx . . $ QFileInfo#QFileInfo(3520e46b33348bf6).(packageDir +cxx . . $ operator+(3d22f08efddf8107). "/" +cxx . . $ operator+(fab9b4f80031f353). icon);
210 if (iconFile.existscxx . . $ QFileInfo#exists(50ce9a9e25b4a850).()) {
211 while (elem.hasChildNodescxx . . $ QDomNode#hasChildNodes(50ce9a9e25b4a850).()) {
212 elem.removeChildcxx . . $ QDomNode#removeChild(1fce9d70e2f1e814).(elem.firstChildcxx . . $ QDomNode#firstChild(573df4c535fc6ee7).());
213 }
214 elem.appendChildcxx . . $ QDomNode#appendChild(1fce9d70e2f1e814).(createTextNodecxx . . $ QDomDocument#createTextNode(9b156b786da100e8).(iconFile.canonicalFilePathcxx . . $ QFileInfo#canonicalFilePath(6ef7b6c27b00b43d).()));
215 }
216 }
217
218 bool LibAccountsFilecxx . . $ LibAccountsFile#::writeTocxx . . $ LibAccountsFile#writeTo(f3b39adf77d9c36c).(const QStringcxx . . $ QString# &fileName) const
219 {
220 /* Make sure that the target directory exists */
221 QFileInfocxx . . $ QFileInfo# fileInfocxx . . $ QFileInfo#QFileInfo(3520e46b33348bf6).(fileName);
222 fileInfo.absoluteDircxx . . $ QFileInfo#absoluteDir(ac6552cf9b6b4ed1).().mkpathcxx . . $ QDir#mkpath(f3b39adf77d9c36c).("."cxx . . $ QString#QString(85c52e162fed56f9).);
223 /* Make sure there isn't a directory with the same name:
224 * Fixes: https://github.com/ubports/ubuntu-touch/issues/602
225 */
226 fileInfo.absoluteDircxx . . $ QFileInfo#absoluteDir(ac6552cf9b6b4ed1).().rmdircxx . . $ QDir#rmdir(f3b39adf77d9c36c).(fileInfo.fileNamecxx . . $ QFileInfo#fileName(6ef7b6c27b00b43d).());
227
228 QFilecxx . . $ QFile# filecxx . . $ QFile#QFile(3520e46b33348bf6).(fileName);
229 if (!file.opencxx . . $ QFile#open(dca164408be960c8).(QIODevicecxx . . $ QIODevice#::WriteOnlycxx . . $ QIODevice#WriteOnly. |cxx . . $ `operator|`(c9e45f682471e48d). QIODevicecxx . . $ QIODevice#::Textcxx . . $ QIODevice#Text.)) return false;
230
231 bool ok = (file.writecxx . . $ QIODevice#write(4ee2750a0be83987).(toByteArraycxx . . $ QDomDocument#toByteArray(1e245adf2d5d15b2).(2)) > 0);
232 file.closecxx . . $ QFileDevice#close(49f6e7a06ebc5aa8).();
233
234 if (ok) {
235 struct utimbuf sourceTime;
236 sourceTime.actime = sourceTime.modtime =
237 lastModifiedcxx . . $ lastModified(b660c26f576c0856).(m_hookFileInfocxx . . $ LibAccountsFile#m_hookFileInfo.).toSecsSinceEpochcxx . . $ QDateTime#toSecsSinceEpoch(98833e9ab7de59a4).();
238 utime(fileName.toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).(), &sourceTime);
239 return true;
240 } else {
241 QFilecxx . . $ QFile#::removecxx . . $ QFile#remove(e1defb592416720d).(fileName);
242 return false;
243 }
244 }
245
246 void LibAccountsFilecxx . . $ LibAccountsFile#::addCreatorMarkcxx . . $ LibAccountsFile#addCreatorMark(49f6e7a06ebc5aa8).()
247 {
248 QStringcxx . . $ QString# comment = QStringcxx . . $ QString#QString(85c52e162fed56f9).("this file is auto-generated by %1; do not modify").
249 argcxx . . $ QString#arg(bc823072288cbbb5).(QCoreApplicationcxx . . $ QCoreApplication#::applicationNamecxx . . $ QCoreApplication#applicationName(4365c3963150523e).());
250 appendChildcxx . . $ QDomNode#appendChild(1fce9d70e2f1e814).(createCommentcxx . . $ QDomDocument#createComment(60c900734d52b713).(comment));
251 }
252
253 bool LibAccountsFilecxx . . $ LibAccountsFile#::createdByUscxx . . $ LibAccountsFile#createdByUs(50ce9a9e25b4a850).() const
254 {
255 QStringcxx . . $ QString# creatorMark = QCoreApplicationcxx . . $ QCoreApplication#::applicationNamecxx . . $ QCoreApplication#applicationName(4365c3963150523e).() +cxx . . $ operator+(3d22f08efddf8107). ";";
256 for (QDomNodecxx . . $ QDomNode# n = firstChildcxx . . $ QDomNode#firstChild(573df4c535fc6ee7).(); !n.isNullcxx . . $ QDomNode#isNull(50ce9a9e25b4a850).(); n =cxx . . $ QDomNode#`operator=`(942bdfb15aedefaf). n.nextSiblingcxx . . $ QDomNode#nextSibling(573df4c535fc6ee7).()) {
257 if (n.isCommentcxx . . $ QDomNode#isComment(50ce9a9e25b4a850).() && n.nodeValuecxx . . $ QDomNode#nodeValue(6ef7b6c27b00b43d).().containscxx . . $ QString#contains(8cce4688c16f48f3).(creatorMark)) {
258 return true;
259 }
260 }
261 return false;
262 }
263
264 static void removeStaleAccountscxx . . $ removeStaleAccounts(bafb010a866eb68d).(Accountscxx . . $ Accounts/::Managercxx . . $ Accounts/Manager# *manager,
265 const QStringcxx . . $ QString# &providerName)
266 {
267 Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(Accounts::AccountId id, manager->accountList()) {
268 Accountscxx . . $ Accounts/::Accountcxx . . $ Accounts/Account# *account = manager->accountcxx . . $ Accounts/Manager#account(e94dad5fac3d2066).(id);
269 if (account->providerNamecxx . . $ Accounts/Account#providerName(6ef7b6c27b00b43d).() ==cxx . . $ `operator==`(5bc2975d2d751687). providerName) {
270 account->removecxx . . $ Accounts/Account#remove(49f6e7a06ebc5aa8).();
271 account->syncAndBlockcxx . . $ Accounts/Account#syncAndBlock(c9857a73d68e59ba).();
272 }
273 }
274 }
275
276 static void removeStaleFilescxx . . $ removeStaleFiles(43babb63b3df9c93).(Accountscxx . . $ Accounts/::Managercxx . . $ Accounts/Manager# *manager,
277 const QStringListcxx . . $ QStringList# &fileTypes,
278 const QStringcxx . . $ QString# &localShare,
279 const QDircxx . . $ QDir# &hooksDirIn)
280 {
281 /* Walk through all of
282 * ~/.local/share/accounts/{providers,services,service-types,applications}/
283 * and remove files which are no longer present in hooksDirIn.
284 */
285 Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(const QString &fileType, fileTypes) {
286 QDircxx . . $ QDir# dircxx . . $ QDir#QDir(3520e46b33348bf6).(QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1/accounts/%2s").argcxx . . $ QString#arg(bc823072288cbbb5).(localShare).argcxx . . $ QString#arg(bc823072288cbbb5).(fileType));
287 dir.setFiltercxx . . $ QDir#setFilter(3cb6a626764edf13).(QDircxx . . $ QDir#::Filescxx . . $ QDir#Files. |cxx . . $ `operator|`(153b300229e4e3d0). QDircxx . . $ QDir#::Readablecxx . . $ QDir#Readable.);
288 QStringListcxx . . $ QStringList# fileTypeFiltercxx . . $ QStringList#QStringList(ced63f7c635d850d).;
289 fileTypeFilter <<cxx . . $ QStringList#`operator<<`(85116071a693d053). "*." +cxx . . $ operator+(c75c3ae4eb9af1a8). fileType;
290 dir.setNameFilterscxx . . $ QDir#setNameFilters(631c0101495f0328).(fileTypeFilter);
291
292 Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(const QFileInfo &fileInfo, dir.entryInfoList()) {
293 LibAccountsFilecxx . . $ LibAccountsFile# filecxx . . $ LibAccountsFile#LibAccountsFile(208c3155c9413262).(fileInfo);
294
295 /* If this file was not created by our hook let's ignore it. */
296 if (!file.createdByUscxx . . $ LibAccountsFile#createdByUs(50ce9a9e25b4a850).()) continue;
297
298 QStringcxx . . $ QString# profile = file.profilecxx . . $ LibAccountsFile#profile(6ef7b6c27b00b43d).();
299
300 /* Check that the hook file is still there; if it isn't, then it
301 * means that the click package was removed, and we must remove our
302 * copy as well. */
303 QStringcxx . . $ QString# hookFileName = stripVersioncxx . . $ stripVersion(fd988a2ab94d906b).(profile) +cxx . . $ operator+(3d22f08efddf8107). "_*." +cxx . . $ operator+(fab9b4f80031f353). fileType;
304 QStringListcxx . . $ QStringList# nameFilters = QStringListcxx . . $ QStringList#QStringList(ced63f7c635d850d).() <<cxx . . $ QStringList#`operator<<`(85116071a693d053). hookFileName;
305 if (!hooksDirIn.entryListcxx . . $ QDir#entryList(4575c08c50802968).(nameFilters).isEmptycxx . . $ QList#isEmpty(3482b152b9333168).()) continue;
306
307 QFilecxx . . $ QFile#::removecxx . . $ QFile#remove(e1defb592416720d).(fileInfo.filePathcxx . . $ QFileInfo#filePath(6ef7b6c27b00b43d).());
308 /* If this is a provider, we must also remove any accounts
309 * associated with it */
310 if (fileType ==cxx . . $ `operator==`(5bc2975d2d751687). QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("provider")) {
311 removeStaleAccountscxx . . $ removeStaleAccounts(bafb010a866eb68d).(manager, fileInfo.completeBaseNamecxx . . $ QFileInfo#completeBaseName(6ef7b6c27b00b43d).());
312 }
313 }
314 }
315 }
316
317 int maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv)
318 {
319 QCoreApplicationcxx . . $ QCoreApplication# appcxx . . $ QCoreApplication#QCoreApplication(6e9b1c7df49e191d).(argc, argv);
320
321 Accountscxx . . $ Accounts/::Managercxx . . $ Accounts/Manager#::Optionscxx . . $ Accounts/Manager#Options# managerOptionscxx . . $ QFlags#QFlags(ced63f7c635d850d).;
322 if (qgetenvcxx . . $ qgetenv(531409eeffcde449).("DBUS_SESSION_BUS_ADDRESS").isEmptycxx . . $ QByteArray#isEmpty(50ce9a9e25b4a850).()) {
323 managerOptions |=cxx . . $ QFlags#`operator|=`(fd64b2b07d6098e0). Accountscxx . . $ Accounts/::Managercxx . . $ Accounts/Manager#::DisableNotificationscxx . . $ Accounts/Manager#DisableNotifications.;
324 }
325 Accountscxx . . $ Accounts/::Managercxx . . $ Accounts/Manager# *manager = new Accountscxx . . $ Accounts/::Managercxx . . $ Accounts/Manager#(managerOptions);
326
327 /* Go through the hook files in ~/.local/share/online-accounts-hooks/ and
328 * check if they have already been processed into a file under
329 * ~/.local/share/accounts/{providers,services,service-types,applications}/;
330 * if not, open the hook file, write the APP_ID somewhere in it, and
331 * save the result in the location where libaccounts expects to find it.
332 */
333
334 QStringListcxx . . $ QStringList# fileTypescxx . . $ QStringList#QStringList(ced63f7c635d850d).;
335 fileTypes <<cxx . . $ QStringList#`operator<<`(85116071a693d053). QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("provider") <<cxx . . $ QStringList#`operator<<`(85116071a693d053).
336 QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("service") <<cxx . . $ QStringList#`operator<<`(85116071a693d053).
337 QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("service-type") <<cxx . . $ QStringList#`operator<<`(85116071a693d053).
338 QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("application");
339
340 // This is ~/.local/share/
341 const QStringcxx . . $ QString# localShare =
342 QStandardPathscxx . . $ QStandardPaths#::writableLocationcxx . . $ QStandardPaths#writableLocation(7d8b34fbb6a9c1bf).(QStandardPathscxx . . $ QStandardPaths#::GenericDataLocationcxx . . $ QStandardPaths#GenericDataLocation.);
343 QDircxx . . $ QDir# hooksDirIncxx . . $ QDir#QDir(3520e46b33348bf6).(localShare +cxx . . $ operator+(3d22f08efddf8107). "/" HOOK_FILES_SUBDIRcxx . . $ `<built-in>:477:9`!);
344
345 removeStaleFilescxx . . $ removeStaleFiles(43babb63b3df9c93).(manager, fileTypes, localShare, hooksDirIn);
346
347 Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(const QFileInfo &fileInfo, hooksDirIn.entryInfoList()) {
348 const QStringcxx . . $ QString# fileType = fileInfo.suffixcxx . . $ QFileInfo#suffix(6ef7b6c27b00b43d).();
349 // Filter out the files which we don't support
350 if (!fileTypes.containscxx . . $ QStringList#contains(8cce4688c16f48f3).(fileType)) continue;
351
352 // Our click hook sets the base name to the APP_ID
353 QStringcxx . . $ QString# appId = fileInfo.completeBaseNamecxx . . $ QFileInfo#completeBaseName(6ef7b6c27b00b43d).();
354
355 /* When publishing this file for libaccounts, we want to strip
356 * the version number out. */
357 QStringcxx . . $ QString# shortAppId = stripVersioncxx . . $ stripVersion(fd988a2ab94d906b).(appId);
358
359 /* When building the destination file name, use the file suffix with an
360 * "s" appended: remember that libaccounts uses
361 * ~/.local/share/accounts/{providers,services,service-types,applications}.
362 * */
363 QStringcxx . . $ QString# destination = QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1/accounts/%2s/%3.%2").
364 argcxx . . $ QString#arg(bc823072288cbbb5).(localShare).argcxx . . $ QString#arg(bc823072288cbbb5).(fileInfo.suffixcxx . . $ QFileInfo#suffix(6ef7b6c27b00b43d).()).argcxx . . $ QString#arg(bc823072288cbbb5).(shortAppId);
365
366 QFileInfocxx . . $ QFileInfo# destinationInfocxx . . $ QFileInfo#QFileInfo(3520e46b33348bf6).(destination);
367 /* If the destination is there and up to date, we have nothing to do */
368 if (destinationInfo.existscxx . . $ QFileInfo#exists(50ce9a9e25b4a850).() &&
369 destinationInfo.lastModifiedcxx . . $ QFileInfo#lastModified(4e062b5c490497ac).() ==cxx . . $ QDateTime#`operator==`(147858620bc979f5). lastModifiedcxx . . $ lastModified(b660c26f576c0856).(fileInfo)) {
370 continue;
371 }
372
373 LibAccountsFilecxx . . $ LibAccountsFile# xml = LibAccountsFilecxx . . $ LibAccountsFile#(fileInfo);
374 if (!xml.isValidcxx . . $ LibAccountsFile#isValid(50ce9a9e25b4a850).()) continue;
375
376 xml.addCreatorMarkcxx . . $ LibAccountsFile#addCreatorMark(49f6e7a06ebc5aa8).();
377 xml.checkIdcxx . . $ LibAccountsFile#checkId(3520e46b33348bf6).(shortAppId);
378 xml.addProfilecxx . . $ LibAccountsFile#addProfile(3520e46b33348bf6).(appId);
379 xml.addPackageDircxx . . $ LibAccountsFile#addPackageDir(3520e46b33348bf6).(appId);
380 xml.checkIconPathcxx . . $ LibAccountsFile#checkIconPath(3520e46b33348bf6).(appId);
381 if (fileType ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "application") {
382 xml.addDesktopFilecxx . . $ LibAccountsFile#addDesktopFile(3520e46b33348bf6).(appId);
383 } else if (fileType ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "service") {
384 xml.addServiceTypecxx . . $ LibAccountsFile#addServiceType(3520e46b33348bf6).(shortAppId);
385 }
386 xml.writeTocxx . . $ LibAccountsFile#writeTo(f3b39adf77d9c36c).(destination);
387 }
388
389 /* To ensure that all the installed services are parsed into
390 * libaccounts' DB, we enumerate them now.
391 */
392 manager->serviceListcxx . . $ Accounts/Manager#serviceList(afa5a1da79d6f492).();
393 delete manager;
394
395 return EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:93:9`!;
396 }
397