8#include "kwalletsessionstore.h"
10class KWalletSessionStore::Session
17KWalletSessionStore::KWalletSessionStore()
21KWalletSessionStore::~KWalletSessionStore()
23 for (
const QList<Session *> &l : std::as_const(m_sessions)) {
28void KWalletSessionStore::addSession(
const QString &appid,
const QString &service,
int handle)
30 Session *sess =
new Session();
31 sess->m_service = service;
32 sess->m_handle = handle;
33 m_sessions[appid].append(sess);
36bool KWalletSessionStore::hasSession(
const QString &appid,
int handle)
const
38 if (!m_sessions.contains(appid)) {
40 }
else if (handle == -1) {
44 QList<Session *>::const_iterator it;
45 QList<Session *>::const_iterator
end = m_sessions[appid].constEnd();
46 for (it = m_sessions[appid].constBegin(); it !=
end; ++it) {
48 if ((*it)->m_handle == handle) {
58 QList<KWalletAppHandlePair> rc;
59 const QList<QString> sessionKeys(m_sessions.keys());
60 for (
const QString &appid : sessionKeys) {
61 const auto lst = m_sessions[appid];
62 for (
const Session *sess : lst) {
64 if (sess->m_service == service) {
65 rc.
append(qMakePair(appid, sess->m_handle));
72bool KWalletSessionStore::removeSession(
const QString &appid,
const QString &service,
int handle)
74 if (!m_sessions.contains(appid)) {
78 QList<Session *>::const_iterator it;
79 QList<Session *>::const_iterator
end = m_sessions[appid].constEnd();
80 for (it = m_sessions[appid].constBegin(); it !=
end; ++it) {
82 if ((*it)->m_service == service && (*it)->m_handle == handle) {
84 m_sessions[appid].removeAll(sess);
86 if (m_sessions[appid].isEmpty()) {
87 m_sessions.remove(appid);
96int KWalletSessionStore::removeAllSessions(
const QString &appid,
int handle)
98 if (!m_sessions.contains(appid)) {
102 QList<Session *>::iterator it;
103 QList<Session *>::iterator
end = m_sessions[appid].end();
104 for (it = m_sessions[appid].
begin(); it !=
end; ++it) {
106 if ((*it)->m_handle == handle) {
112 int removed = m_sessions[appid].removeAll(
nullptr);
113 if (m_sessions[appid].isEmpty()) {
114 m_sessions.remove(appid);
120int KWalletSessionStore::removeAllSessions(
int handle)
122 QList<QString> appremove;
124 const QList<QString> sessionKeys(m_sessions.keys());
125 for (
const QString &appid : sessionKeys) {
126 QList<Session *>::iterator it;
127 QList<Session *>::iterator
end = m_sessions[appid].end();
128 for (it = m_sessions[appid].
begin(); it !=
end; ++it) {
130 if ((*it)->m_handle == handle) {
137 m_sessions[appid].removeAll(
nullptr);
138 if (m_sessions[appid].isEmpty()) {
144 for (
const QString &appid : std::as_const(appremove)) {
145 m_sessions.remove(appid);
151QStringList KWalletSessionStore::getApplications(
int handle)
const
154 const auto lst = m_sessions.keys();
155 for (
const QString &appid : lst) {
156 if (hasSession(appid, handle)) {
const QList< QKeySequence > & begin()
const QList< QKeySequence > & end()
void append(QList< T > &&value)