Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 9fc00974 authored by Michael Weghorn's avatar Michael Weghorn Committed by Luigi Toscano

Show more information on CUPS auth dialog

Summary:
This extends 'KCupsPasswordDialog' so that a prompt text can be
set.
It is explicitly stated that authentication is required
by CUPS, which was not totally clear beforehand and
prompt information as passed via the CUPS
callback function is displayed in addition.

This e.g. makes clear what host the authentication
information is sent to.

BUGS: 397125

Test Plan:
Set up a remote CUPS server that requires authentication
and modify '~/.cups/client.conf' so that it points to this server,
e.g. as described in https://bugs.kde.org/show_bug.cgi?id=397125#c6 .

Start print-manager and make sure the authentication dialog is clear
what the authentication is needed for and where the information is sent.

Reviewers: dantti, ngraham

Reviewed By: dantti, ngraham

Subscribers: ltoscano, ngraham, kde-utils-devel

Differential Revision: https://phabricator.kde.org/D18648
parent 39886c6a
......@@ -858,7 +858,6 @@ bool KCupsConnection::retry(const char *resource, int operation) const
const char * password_cb(const char *prompt, http_t *http, const char *method, const char *resource, void *user_data)
{
Q_UNUSED(prompt)
Q_UNUSED(http)
Q_UNUSED(method)
Q_UNUSED(resource)
......@@ -872,6 +871,9 @@ const char * password_cb(const char *prompt, http_t *http, const char *method, c
auto passwordDialog = static_cast<KCupsPasswordDialog *>(user_data);
bool wrongPassword = password_retries > 1;
// use prompt text from CUPS callback for dialog
passwordDialog->setPromptText(i18n("A CUPS connection requires authentication: \"") + QString::fromUtf8(prompt) + QStringLiteral("\""));
// This will block this thread until exec is not finished
qCDebug(LIBKCUPS) << password_retries;
QMetaObject::invokeMethod(passwordDialog,
......
......@@ -31,7 +31,9 @@
KCupsPasswordDialog::KCupsPasswordDialog(QObject *parent) :
QObject(parent),
m_accepted(false),
m_mainwindow(0)
m_mainwindow(0),
// default text, can be overriden using setPromptText()
m_promptText(i18n("Enter an username and a password to complete the task"))
{
}
......@@ -40,10 +42,15 @@ void KCupsPasswordDialog::setMainWindow(WId mainwindow)
m_mainwindow = mainwindow;
}
void KCupsPasswordDialog::setPromptText(const QString &text)
{
m_promptText = text;
}
void KCupsPasswordDialog::exec(const QString &username, bool wrongPassword)
{
QPointer<KPasswordDialog> dialog = new KPasswordDialog(nullptr, KPasswordDialog::ShowUsernameLine);
dialog->setPrompt(i18n("Enter an username and a password to complete the task"));
dialog->setPrompt(m_promptText);
dialog->setModal(false);
dialog->setUsername(username);
if (wrongPassword) {
......
......@@ -30,6 +30,7 @@ class KCupsPasswordDialog : public QObject
public:
explicit KCupsPasswordDialog(QObject *parent = nullptr);
void setMainWindow(WId mainwindow);
void setPromptText(const QString &promptText);
public slots:
void exec(const QString &username, bool wrongPassword);
......@@ -43,6 +44,7 @@ private:
WId m_mainwindow;
QString m_username;
QString m_password;
QString m_promptText;
};
#endif // KCUPSPASSWORDDIALOG_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment