8#include "authentication.h"
12#include <QMutexLocker>
15#include <ksanecore_debug.h>
21Q_GLOBAL_STATIC(
QMutex, s_mutex)
23struct Authentication::Private {
37 if (s_instance ==
nullptr) {
38 s_instance =
new Authentication();
43Authentication::Authentication() : d(new Private) {}
45Authentication::~Authentication()
52void Authentication::setDeviceAuth(
const QString &resource,
const QString &username,
const QString &password)
56 for (i = 0; i < d->authList.size(); i++) {
57 if (resource == d->authList.at(i).resource) {
59 d->authList[i].username = username;
60 d->authList[i].password = password;
64 if (i == d->authList.size()) {
66 Private::AuthStruct tmp;
67 tmp.resource = resource;
68 tmp.username = username;
69 tmp.password = password;
74void Authentication::clearDeviceAuth(
const QString &resource)
77 for (
int i = 0; i < d->authList.size(); i++) {
78 if (resource == d->authList.at(i).resource) {
79 d->authList.removeAt(i);
86void Authentication::authorization(SANE_String_Const resource, SANE_Char *username, SANE_Char *password)
88 qCDebug(KSANECORE_LOG) << resource;
94 int end = res.
indexOf(QStringLiteral(
"$MD5$"));
96 qCDebug(KSANECORE_LOG) << res;
99 for (
const auto &authItem : list) {
100 qCDebug(KSANECORE_LOG) << res << authItem.resource;
101 if (authItem.resource.contains(res)) {
102 qstrncpy(username, authItem.username.toLocal8Bit().constData(), SANE_MAX_USERNAME_LEN);
103 qstrncpy(password, authItem.password.toLocal8Bit().constData(), SANE_MAX_PASSWORD_LEN);
QString fromUtf8(QByteArrayView str)
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
QString left(qsizetype n) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:10:39 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.