1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
/*
SPDX-License-Identifier: GPL-2.0-or-later
SPDX-FileCopyrightText: 2020 Harald Sitter <sitter@kde.org>
*/
#pragma once
#include "smbcontext.h"
#include <QString>
namespace KIO
{
class AuthInfo;
}
// Abstracts WorkerBase API so Authenticator may be used without
// a WorkerBase for the KDirNotify implementation)
class SMBAbstractFrontend
{
public:
virtual ~SMBAbstractFrontend() = default;
virtual bool checkCachedAuthentication(KIO::AuthInfo &info) = 0;
};
// Base class for SMBC management + basic authentication
class SMBAuthenticator
{
public:
SMBAuthenticator(SMBAbstractFrontend &frontend);
QString defaultWorkgroup() const;
void setDefaultWorkgroup(const QString &workGroup);
// Callback for authentication requests.
void
auth(SMBCCTX *context, const char *server, const char *share, char *workgroup, int wgmaxlen, char *username, int unmaxlen, char *password, int pwmaxlen);
private:
// Frontend for authentication requests.
SMBAbstractFrontend &m_frontend;
QString m_defaultUser;
QString m_defaultPassword;
QString m_defaultEncoding;
QString m_defaultWorkgroup = QStringLiteral("WORKGROUP"); // overwritten with value from smbc
Q_DISABLE_COPY(SMBAuthenticator)
};
|