Changeset View
Changeset View
Standalone View
Standalone View
src/runtime/kwalletd/kwalletsessionstore.cpp
Show All 28 Lines | |||||
29 | }; | 29 | }; | ||
30 | 30 | | |||
31 | KWalletSessionStore::KWalletSessionStore() | 31 | KWalletSessionStore::KWalletSessionStore() | ||
32 | { | 32 | { | ||
33 | } | 33 | } | ||
34 | 34 | | |||
35 | KWalletSessionStore::~KWalletSessionStore() | 35 | KWalletSessionStore::~KWalletSessionStore() | ||
36 | { | 36 | { | ||
37 | Q_FOREACH (const QList<Session *> &l, m_sessions) { | 37 | for (const QList<Session *> &l : qAsConst(m_sessions)) { | ||
38 | qDeleteAll(l); | 38 | qDeleteAll(l); | ||
39 | } | 39 | } | ||
40 | } | 40 | } | ||
41 | 41 | | |||
42 | void KWalletSessionStore::addSession(const QString &appid, const QString &service, int handle) | 42 | void KWalletSessionStore::addSession(const QString &appid, const QString &service, int handle) | ||
43 | { | 43 | { | ||
44 | Session *sess = new Session(); | 44 | Session *sess = new Session(); | ||
45 | sess->m_service = service; | 45 | sess->m_service = service; | ||
Show All 19 Lines | 51 | { | |||
65 | } | 65 | } | ||
66 | 66 | | |||
67 | return false; | 67 | return false; | ||
68 | } | 68 | } | ||
69 | 69 | | |||
70 | QList<KWalletAppHandlePair> KWalletSessionStore::findSessions(const QString &service) const | 70 | QList<KWalletAppHandlePair> KWalletSessionStore::findSessions(const QString &service) const | ||
71 | { | 71 | { | ||
72 | QList<KWalletAppHandlePair> rc; | 72 | QList<KWalletAppHandlePair> rc; | ||
73 | QList<QString> sessionKeys(m_sessions.keys()); | 73 | const QList<QString> sessionKeys(m_sessions.keys()); | ||
74 | Q_FOREACH (const QString &appid, sessionKeys) { | 74 | for (const QString &appid : sessionKeys) { | ||
75 | Q_FOREACH (const Session *sess, m_sessions[appid]) { | 75 | const auto lst = m_sessions[appid]; | ||
76 | for (const Session *sess : lst) { | ||||
76 | Q_ASSERT(sess); | 77 | Q_ASSERT(sess); | ||
77 | if (sess->m_service == service) { | 78 | if (sess->m_service == service) { | ||
78 | rc.append(qMakePair(appid, sess->m_handle)); | 79 | rc.append(qMakePair(appid, sess->m_handle)); | ||
79 | } | 80 | } | ||
80 | } | 81 | } | ||
81 | } | 82 | } | ||
82 | return rc; | 83 | return rc; | ||
83 | } | 84 | } | ||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 111 | { | |||
129 | 130 | | |||
130 | return removed; | 131 | return removed; | ||
131 | } | 132 | } | ||
132 | 133 | | |||
133 | int KWalletSessionStore::removeAllSessions(int handle) | 134 | int KWalletSessionStore::removeAllSessions(int handle) | ||
134 | { | 135 | { | ||
135 | QList<QString> appremove; | 136 | QList<QString> appremove; | ||
136 | int numrem = 0; | 137 | int numrem = 0; | ||
137 | QList<QString> sessionKeys(m_sessions.keys()); | 138 | const QList<QString> sessionKeys(m_sessions.keys()); | ||
138 | Q_FOREACH (const QString &appid, sessionKeys) { | 139 | for (const QString &appid : sessionKeys) { | ||
139 | QList<Session *>::iterator it; | 140 | QList<Session *>::iterator it; | ||
140 | QList<Session *>::iterator end = m_sessions[appid].end(); | 141 | QList<Session *>::iterator end = m_sessions[appid].end(); | ||
141 | for (it = m_sessions[appid].begin(); it != end; ++it) { | 142 | for (it = m_sessions[appid].begin(); it != end; ++it) { | ||
142 | Q_ASSERT(*it); | 143 | Q_ASSERT(*it); | ||
143 | if ((*it)->m_handle == handle) { | 144 | if ((*it)->m_handle == handle) { | ||
144 | delete *it; | 145 | delete *it; | ||
145 | *it = nullptr; | 146 | *it = nullptr; | ||
146 | numrem++; | 147 | numrem++; | ||
147 | } | 148 | } | ||
148 | } | 149 | } | ||
149 | // remove all zeroed sessions | 150 | // remove all zeroed sessions | ||
150 | m_sessions[appid].removeAll(nullptr); | 151 | m_sessions[appid].removeAll(nullptr); | ||
151 | if (m_sessions[appid].isEmpty()) { | 152 | if (m_sessions[appid].isEmpty()) { | ||
152 | appremove.append(appid); | 153 | appremove.append(appid); | ||
153 | } | 154 | } | ||
154 | } | 155 | } | ||
155 | 156 | | |||
156 | // now remove all applications without sessions | 157 | // now remove all applications without sessions | ||
157 | Q_FOREACH (const QString &appid, appremove) { | 158 | for (const QString &appid : qAsConst(appremove)) { | ||
158 | m_sessions.remove(appid); | 159 | m_sessions.remove(appid); | ||
159 | } | 160 | } | ||
160 | 161 | | |||
161 | return numrem; | 162 | return numrem; | ||
162 | } | 163 | } | ||
163 | 164 | | |||
164 | QStringList KWalletSessionStore::getApplications(int handle) const | 165 | QStringList KWalletSessionStore::getApplications(int handle) const | ||
165 | { | 166 | { | ||
166 | QStringList rc; | 167 | QStringList rc; | ||
167 | Q_FOREACH (const QString &appid, m_sessions.uniqueKeys()) { | 168 | const auto lst = m_sessions.uniqueKeys(); | ||
169 | for (const QString &appid : lst) { | ||||
168 | if (hasSession(appid, handle)) { | 170 | if (hasSession(appid, handle)) { | ||
169 | rc.append(appid); | 171 | rc.append(appid); | ||
170 | } | 172 | } | ||
171 | } | 173 | } | ||
172 | return rc; | 174 | return rc; | ||
173 | } | 175 | } |