8#include "authentication.h"
12#include <QMutexLocker>
15#include <ksanecore_debug.h>
21Q_GLOBAL_STATIC(
QMutex, s_mutex)
23struct Authentication::Private {
35#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
41 if (s_instance ==
nullptr) {
42 s_instance =
new Authentication();
47Authentication::Authentication() : d(new Private) {}
49Authentication::~Authentication()
51#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
60void Authentication::setDeviceAuth(
const QString &resource,
const QString &username,
const QString &password)
64 for (i = 0; i < d->authList.size(); i++) {
65 if (resource == d->authList.at(i).resource) {
67 d->authList[i].username = username;
68 d->authList[i].password = password;
72 if (i == d->authList.size()) {
74 Private::AuthStruct tmp;
75 tmp.resource = resource;
76 tmp.username = username;
77 tmp.password = password;
82void Authentication::clearDeviceAuth(
const QString &resource)
85 for (
int i = 0; i < d->authList.size(); i++) {
86 if (resource == d->authList.at(i).resource) {
87 d->authList.removeAt(i);
94void Authentication::authorization(SANE_String_Const resource, SANE_Char *username, SANE_Char *password)
96 qCDebug(KSANECORE_LOG) << resource;
102 int end = res.
indexOf(QStringLiteral(
"$MD5$"));
104 qCDebug(KSANECORE_LOG) << res;
107 for (
const auto &authItem : list) {
108 qCDebug(KSANECORE_LOG) << res << authItem.resource;
109 if (authItem.resource.contains(res)) {
110 qstrncpy(username, authItem.username.toLocal8Bit().constData(), SANE_MAX_USERNAME_LEN);
111 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 Mon Nov 18 2024 12:17:19 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.