| 1 | /* |
| 2 | * This file is part of OnlineAccountsDaemon |
| 3 | * |
| 4 | * Copyright (C) 2015 Canonical Ltd. |
| 5 | * |
| 6 | * Contact: Alberto Mardegan <[email protected]> |
| 7 | * |
| 8 | * This program is free software: you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU Lesser General Public License version 3, as |
| 10 | * published 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 Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public License |
| 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #include "client_registry.h"cxx . . $ `<file>/online-accounts-daemon/lib/LomiriOnlineAccountsDaemon/client_registry.h`/ |
| 22 | |
| 23 | #include <QByteArray> |
| 24 | #include <QDBusConnection> |
| 25 | #include <QDBusConnectionInterface> |
| 26 | #include <QDBusMessage> |
| 27 | #include <QDBusReply> |
| 28 | #include <QDBusServiceWatcher> |
| 29 | #include <QDebug> |
| 30 | #include <QHash> |
| 31 | #include <QVariantMap> |
| 32 | #include <sys/apparmor.h> |
| 33 | |
| 34 | using namespace OnlineAccountsDaemon; |
| 35 | |
| 36 | namespace OnlineAccountsDaemoncxx . . $ OnlineAccountsDaemon/ { |
| 37 | |
| 38 | class ClientRegistryPrivatecxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#: public QObjectcxx . . $ QObject# |
| 39 | { |
| 40 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 41 | Q_DECLARE_PUBLICcxx . . $ `<external>/15045578679651060896/qglobal.h:1172:9`!(ClientRegistry) |
| 42 | |
| 43 | public: |
| 44 | ClientRegistryPrivatecxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#ClientRegistryPrivate(100aabdb6911362a).(ClientRegistrycxx . . $ OnlineAccountsDaemon/ClientRegistry# *q); |
| 45 | |
| 46 | void registerClientcxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#registerClient(3520e46b33348bf6).(const QStringcxx . . $ QString# &client); |
| 47 | QStringcxx . . $ QString# getSecurityContextcxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#getSecurityContext(5555d9024dcf93fb).(const QStringcxx . . $ QString# &client) const; |
| 48 | pid_t getPidcxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#getPid(fbf1bd5053f90658).(const QStringcxx . . $ QString# &client) const; |
| 49 | |
| 50 | private Q_SLOTScxx . . $ `<external>/1208926524888476972/qobjectdefs.h:92:10`!: |
| 51 | void onServiceUnregisteredcxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#onServiceUnregistered(3520e46b33348bf6).(const QStringcxx . . $ QString# &client); |
| 52 | |
| 53 | private: |
| 54 | static ClientRegistrycxx . . $ OnlineAccountsDaemon/ClientRegistry# *m_instancecxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_instance.; |
| 55 | QDBusConnectioncxx . . $ QDBusConnection# m_connectioncxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_connection.; |
| 56 | QDBusServiceWatchercxx . . $ QDBusServiceWatcher# m_watchercxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_watcher.; |
| 57 | QHashcxx . . $ QHash#<QStringcxx . . $ QString#,QStringcxx . . $ QString#> m_clientContextscxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_clientContexts.; |
| 58 | ClientRegistrycxx . . $ OnlineAccountsDaemon/ClientRegistry# *q_ptrcxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#q_ptr.; |
| 59 | }; |
| 60 | |
| 61 | ClientRegistrycxx . . $ OnlineAccountsDaemon/ClientRegistry# *ClientRegistryPrivatecxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#::m_instancecxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_instance. = 0; |
| 62 | |
| 63 | } // namespace |
| 64 | |
| 65 | ClientRegistryPrivatecxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#::ClientRegistryPrivatecxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#ClientRegistryPrivate(100aabdb6911362a).(ClientRegistrycxx . . $ OnlineAccountsDaemon/ClientRegistry# *q): |
| 66 | QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(q), |
| 67 | m_connectioncxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_connection.(QDBusConnectioncxx . . $ QDBusConnection#::sessionBuscxx . . $ QDBusConnection#sessionBus(45d475f1888103b2).()), |
| 68 | q_ptrcxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#q_ptr.(q) |
| 69 | { |
| 70 | m_watchercxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_watcher..setConnectioncxx . . $ QDBusServiceWatcher#setConnection(970609fd3373f52d).(m_connectioncxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_connection.); |
| 71 | QObjectcxx . . $ QObject#::connectcxx . . $ QObject#connect(158df1d9a01a3410).(&m_watchercxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_watcher., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(serviceUnregistered(const QString&)), |
| 72 | this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(onServiceUnregistered(const QString&))); |
| 73 | } |
| 74 | |
| 75 | void ClientRegistryPrivatecxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#::registerClientcxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#registerClient(3520e46b33348bf6).(const QStringcxx . . $ QString# &client) |
| 76 | { |
| 77 | Q_Qcxx . . $ `<external>/15045578679651060896/qglobal.h:1178:9`!(ClientRegistry); |
| 78 | |
| 79 | if (m_clientContextscxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_clientContexts..containscxx . . $ QHash#contains(8877ebe272b9620d).(client)) return; |
| 80 | |
| 81 | bool wasEmpty = m_clientContextscxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_clientContexts..isEmptycxx . . $ QHash#isEmpty(50ce9a9e25b4a850).(); |
| 82 | m_clientContextscxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_clientContexts..insertcxx . . $ QHash#insert(d77b19c31d2eb147).(client, getSecurityContextcxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#getSecurityContext(5555d9024dcf93fb).(client)); |
| 83 | m_watchercxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_watcher..addWatchedServicecxx . . $ QDBusServiceWatcher#addWatchedService(3520e46b33348bf6).(client); |
| 84 | if (wasEmpty) { |
| 85 | Q_EMITcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:95:10`! q->hasClientsChangedcxx . . $ OnlineAccountsDaemon/ClientRegistry#hasClientsChanged(49f6e7a06ebc5aa8).(); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | QStringcxx . . $ QString# ClientRegistryPrivatecxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#::getSecurityContextcxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#getSecurityContext(5555d9024dcf93fb).(const QStringcxx . . $ QString# &client) const |
| 90 | { |
| 91 | QStringcxx . . $ QString# dbusService = qEnvironmentVariableIsEmptycxx . . $ QString#QString(85c52e162fed56f9).("OAD_TESTING") ? |
| 92 | "org.freedesktop.DBus" : "mocked.org.freedesktop.dbus"; |
| 93 | QDBusMessagecxx . . $ QDBusMessage# msg = |
| 94 | QDBusMessagecxx . . $ QDBusMessage#::createMethodCallcxx . . $ QDBusMessage#createMethodCall(53922711d019cf27).(dbusService, |
| 95 | "/org/freedesktop/DBus"cxx . . $ QString#QString(85c52e162fed56f9)., |
| 96 | "org.freedesktop.DBus"cxx . . $ QString#QString(85c52e162fed56f9)., |
| 97 | "GetConnectionCredentials"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 98 | msg <<cxx . . $ QDBusMessage#`operator<<`(ef5601b8018cb889). clientcxx . . $ QVariant#QVariant(3520e46b33348bf6).; |
| 99 | QDBusReplycxx . . $ QDBusReply#<QVariantMapcxx . . $ QVariantMap#> reply = m_connectioncxx . . $ QDBusReply#QDBusReply(65337ba3304bf734)..callcxx . . $ QDBusConnection#call(55e43a351c9b9118).(msg, QDBuscxx . . $ QDBus/::Blockcxx . . $ QDBus/Block.); |
| 100 | |
| 101 | QStringcxx . . $ QString# contextcxx . . $ QString#QString(ced63f7c635d850d).; |
| 102 | if (reply.isValidcxx . . $ QDBusReply#isValid(50ce9a9e25b4a850).()) { |
| 103 | QVariantMapcxx . . $ QVariantMap# map = reply.valuecxx . . $ QDBusReply#value(8f5363d873dd4781).(); |
| 104 | QByteArraycxx . . $ QByteArray# label = map.valuecxx . . $ QMap#value(866b0a4e5fb46e14).("LinuxSecurityLabel"cxx . . $ QString#QString(85c52e162fed56f9).).toByteArraycxx . . $ QVariant#toByteArray(a96750bfbcb1fbe9).(); |
| 105 | if (!label.isEmptycxx . . $ QByteArray#isEmpty(50ce9a9e25b4a850).()) { |
| 106 | aa_splitcon(label.datacxx . . $ QByteArray#data(41208ce6ca65dd58).(), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 107 | context =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#::fromUtf8cxx . . $ QString#fromUtf8(4e15edac36d215be).(label); |
| 108 | } |
| 109 | } else { |
| 110 | QDBusErrorcxx . . $ QDBusError# error = replycxx . . $ QDBusError#QDBusError(8b965b05cb8f2b40)..errorcxx . . $ QDBusReply#error(1a61ff5b6ea1d08d).(); |
| 111 | qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Error getting app ID:" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). error.namecxx . . $ QDBusError#name(6ef7b6c27b00b43d).() <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). |
| 112 | error.messagecxx . . $ QDBusError#message(6ef7b6c27b00b43d).(); |
| 113 | context =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("unconfined"); |
| 114 | } |
| 115 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Client security context:" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). context; |
| 116 | |
| 117 | return contextcxx . . $ QString#QString(28715ad661ad3cec).; |
| 118 | } |
| 119 | |
| 120 | pid_t ClientRegistryPrivatecxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#::getPidcxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#getPid(fbf1bd5053f90658).(const QStringcxx . . $ QString# &client) const |
| 121 | { |
| 122 | QDBusReplycxx . . $ QDBusReply#<uintcxx . . $ uint#> reply = m_connectioncxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_connection..interfacecxx . . $ QDBusConnection#interface(c7d87ae32aa26b17).()->servicePidcxx . . $ QDBusConnectionInterface#servicePid(93ac1b59c7cd7857).(client); |
| 123 | return pid_t(reply.valuecxx . . $ QDBusReply#value(8f5363d873dd4781).()); |
| 124 | } |
| 125 | |
| 126 | void ClientRegistryPrivatecxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#::onServiceUnregisteredcxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#onServiceUnregistered(3520e46b33348bf6).(const QStringcxx . . $ QString# &client) |
| 127 | { |
| 128 | Q_Qcxx . . $ `<external>/15045578679651060896/qglobal.h:1178:9`!(ClientRegistry); |
| 129 | |
| 130 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Client disappeared:" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). client; |
| 131 | m_clientContextscxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_clientContexts..removecxx . . $ QHash#remove(dd8e59d271e40448).(client); |
| 132 | if (m_clientContextscxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_clientContexts..isEmptycxx . . $ QHash#isEmpty(50ce9a9e25b4a850).()) { |
| 133 | Q_EMITcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:95:10`! q->hasClientsChangedcxx . . $ OnlineAccountsDaemon/ClientRegistry#hasClientsChanged(49f6e7a06ebc5aa8).(); |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | ClientRegistrycxx . . $ OnlineAccountsDaemon/ClientRegistry#::ClientRegistrycxx . . $ OnlineAccountsDaemon/ClientRegistry#ClientRegistry(49f6e7a06ebc5aa8).(): |
| 138 | QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(), |
| 139 | d_ptrcxx . . $ OnlineAccountsDaemon/ClientRegistry#d_ptr.(new ClientRegistryPrivatecxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#ClientRegistryPrivate(100aabdb6911362a).(this)) |
| 140 | { |
| 141 | } |
| 142 | |
| 143 | ClientRegistrycxx . . $ OnlineAccountsDaemon/ClientRegistry#::~cxx . . $ OnlineAccountsDaemon/ClientRegistry#`~ClientRegistry`(ced63f7c635d850d).ClientRegistrycxx . . $ OnlineAccountsDaemon/ClientRegistry#() |
| 144 | { |
| 145 | delete d_ptrcxx . . $ OnlineAccountsDaemon/ClientRegistry#d_ptr.; |
| 146 | } |
| 147 | |
| 148 | ClientRegistrycxx . . $ OnlineAccountsDaemon/ClientRegistry# *ClientRegistrycxx . . $ OnlineAccountsDaemon/ClientRegistry#::instancecxx . . $ OnlineAccountsDaemon/ClientRegistry#instance(bedb1e5b8c4f59e2).() |
| 149 | { |
| 150 | if (!ClientRegistryPrivatecxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#::m_instancecxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_instance.) { |
| 151 | ClientRegistryPrivatecxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#::m_instancecxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_instance. = new ClientRegistrycxx . . $ OnlineAccountsDaemon/ClientRegistry#(); |
| 152 | } |
| 153 | return ClientRegistryPrivatecxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#::m_instancecxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_instance.; |
| 154 | } |
| 155 | |
| 156 | QStringcxx . . $ QString# ClientRegistrycxx . . $ OnlineAccountsDaemon/ClientRegistry#::registerClientcxx . . $ OnlineAccountsDaemon/ClientRegistry#registerClient(41aa20dcba818a8c).(const QDBusConnectioncxx . . $ QDBusConnection# &connection, |
| 157 | const QDBusMessagecxx . . $ QDBusMessage# &message) |
| 158 | { |
| 159 | Q_UNUSEDcxx . . $ `<external>/15045578679651060896/qglobal.h:117:9`!(connection); // only needed for p2p clients |
| 160 | |
| 161 | QStringcxx . . $ QString# client = message.servicecxx . . $ QDBusMessage#service(6ef7b6c27b00b43d).(); |
| 162 | registerClientcxx . . $ OnlineAccountsDaemon/ClientRegistry#registerClient(3520e46b33348bf6).(client); |
| 163 | return clientcxx . . $ QString#QString(28715ad661ad3cec).; |
| 164 | } |
| 165 | |
| 166 | void ClientRegistrycxx . . $ OnlineAccountsDaemon/ClientRegistry#::registerClientcxx . . $ OnlineAccountsDaemon/ClientRegistry#registerClient(3520e46b33348bf6).(const QStringcxx . . $ QString# &client) |
| 167 | { |
| 168 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(ClientRegistry); |
| 169 | d->registerClientcxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#registerClient(3520e46b33348bf6).(client); |
| 170 | } |
| 171 | |
| 172 | QStringListcxx . . $ QStringList# ClientRegistrycxx . . $ OnlineAccountsDaemon/ClientRegistry#::clientscxx . . $ OnlineAccountsDaemon/ClientRegistry#clients(e1dbd5c4feadc8f5).() const |
| 173 | { |
| 174 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(const ClientRegistry); |
| 175 | return dcxx . . $ QStringList#QStringList(6fe09f9fe6e0f503).->m_clientContextscxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_clientContexts..keyscxx . . $ QHash#keys(bf6c511543d55010).(); |
| 176 | } |
| 177 | |
| 178 | void ClientRegistrycxx . . $ OnlineAccountsDaemon/ClientRegistry#::registerActiveClientscxx . . $ OnlineAccountsDaemon/ClientRegistry#registerActiveClients(631c0101495f0328).(const QStringListcxx . . $ QStringList# &clients) |
| 179 | { |
| 180 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(const ClientRegistry); |
| 181 | QStringListcxx . . $ QStringList# activeServices = |
| 182 | d->m_connectioncxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_connection..interfacecxx . . $ QDBusConnection#interface(c7d87ae32aa26b17).()->registeredServiceNamescxx . . $ QDBusConnectionInterface#registeredServiceNames(f47d2682a84d843a).().valuecxx . . $ QDBusReply#value(8f5363d873dd4781).(); |
| 183 | Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(const QString &client, clients) { |
| 184 | if (activeServices.containscxx . . $ QStringList#contains(8cce4688c16f48f3).(client)) { |
| 185 | registerClientcxx . . $ OnlineAccountsDaemon/ClientRegistry#registerClient(3520e46b33348bf6).(client); |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | QStringcxx . . $ QString# ClientRegistrycxx . . $ OnlineAccountsDaemon/ClientRegistry#::clientSecurityContextcxx . . $ OnlineAccountsDaemon/ClientRegistry#clientSecurityContext(5555d9024dcf93fb).(const QStringcxx . . $ QString# &client) const |
| 191 | { |
| 192 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(const ClientRegistry); |
| 193 | QHashcxx . . $ QHash#<QString,QString>::const_iteratorcxx . . $ QHash#const_iterator# i = |
| 194 | d->m_clientContextscxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_clientContexts..findcxx . . $ QHash#find(8350f99e9328307f).(client); |
| 195 | if (i !=cxx . . $ QHash#const_iterator#`operator!=`(ed375b04c2ec1e10). d->m_clientContextscxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#m_clientContexts..constEndcxx . . $ QHash#constEnd(bacd0392ad39bf1c).()) { |
| 196 | return icxx . . $ QString#QString(132dd6869045752b)..valuecxx . . $ QHash#const_iterator#value(bdbd05d619d62250).(); |
| 197 | } |
| 198 | |
| 199 | return d->getSecurityContextcxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#getSecurityContext(5555d9024dcf93fb).(client); |
| 200 | } |
| 201 | |
| 202 | pid_t ClientRegistrycxx . . $ OnlineAccountsDaemon/ClientRegistry#::clientPidcxx . . $ OnlineAccountsDaemon/ClientRegistry#clientPid(fbf1bd5053f90658).(const QStringcxx . . $ QString# &client) const |
| 203 | { |
| 204 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(const ClientRegistry); |
| 205 | return d->getPidcxx . . $ OnlineAccountsDaemon/ClientRegistryPrivate#getPid(fbf1bd5053f90658).(client); |
| 206 | } |
| 207 | |
| 208 | #include "client_registry.moc"cxx . . $ `<file>/build/online-accounts-daemon/lib/LomiriOnlineAccountsDaemon/lomiri-online-accounts-daemon_autogen/include/client_registry.moc`/ |