mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Share dialog: More error handling with password policy #4209
This commit is contained in:
parent
8486a2fd2b
commit
7eba784b0c
4 changed files with 32 additions and 8 deletions
|
@ -151,7 +151,7 @@ void LinkShare::setPassword(const QString &password)
|
|||
{
|
||||
OcsShareJob *job = new OcsShareJob(_account);
|
||||
connect(job, SIGNAL(shareJobFinished(QVariantMap, QVariant)), SLOT(slotPasswordSet(QVariantMap, QVariant)));
|
||||
connect(job, SIGNAL(ocsError(int, QString)), SLOT(slotOcsError(int, QString)));
|
||||
connect(job, SIGNAL(ocsError(int, QString)), SLOT(slotSetPasswordError(int,QString)));
|
||||
job->setPassword(getId(), password);
|
||||
}
|
||||
|
||||
|
@ -175,6 +175,11 @@ void LinkShare::slotExpireDateSet(const QVariantMap&, const QVariant &value)
|
|||
emit expireDateSet();
|
||||
}
|
||||
|
||||
void LinkShare::slotSetPasswordError(int statusCode, const QString &message)
|
||||
{
|
||||
emit passwordSetError(statusCode, message);
|
||||
}
|
||||
|
||||
ShareManager::ShareManager(AccountPtr account, QObject *parent)
|
||||
: QObject(parent),
|
||||
_account(account)
|
||||
|
|
|
@ -195,11 +195,13 @@ signals:
|
|||
void expireDateSet();
|
||||
void publicUploadSet();
|
||||
void passwordSet();
|
||||
void passwordSetError(int statusCode, const QString &message);
|
||||
|
||||
private slots:
|
||||
void slotPasswordSet(const QVariantMap&, const QVariant &value);
|
||||
void slotPublicUploadSet(const QVariantMap&, const QVariant &value);
|
||||
void slotExpireDateSet(const QVariantMap&, const QVariant &value);
|
||||
void slotSetPasswordError(int statusCode, const QString &message);
|
||||
|
||||
private:
|
||||
bool _passwordSet;
|
||||
|
|
|
@ -141,7 +141,7 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
|
|||
connect(_manager, SIGNAL(sharesFetched(QList<QSharedPointer<Share>>)), SLOT(slotSharesFetched(QList<QSharedPointer<Share>>)));
|
||||
connect(_manager, SIGNAL(linkShareCreated(QSharedPointer<LinkShare>)), SLOT(slotCreateShareFetched(const QSharedPointer<LinkShare>)));
|
||||
connect(_manager, SIGNAL(linkShareRequiresPassword(QString)), SLOT(slotCreateShareRequiresPassword(QString)));
|
||||
connect(_manager, SIGNAL(serverError(int, QString)), SLOT(displayError(int, QString)));
|
||||
connect(_manager, SIGNAL(serverError(int, QString)), SLOT(slotServerError(int,QString)));
|
||||
}
|
||||
|
||||
void ShareLinkWidget::setExpireDate(const QDate &date)
|
||||
|
@ -171,8 +171,6 @@ ShareLinkWidget::~ShareLinkWidget()
|
|||
void ShareLinkWidget::slotPasswordReturnPressed()
|
||||
{
|
||||
setPassword(_ui->lineEdit_password->text());
|
||||
_ui->lineEdit_password->setText(QString());
|
||||
_ui->lineEdit_password->setPlaceholderText(tr("Password Protected"));
|
||||
_ui->lineEdit_password->clearFocus();
|
||||
}
|
||||
|
||||
|
@ -201,6 +199,9 @@ void ShareLinkWidget::setPassword(const QString &password)
|
|||
|
||||
void ShareLinkWidget::slotPasswordSet()
|
||||
{
|
||||
_ui->lineEdit_password->setText(QString());
|
||||
_ui->lineEdit_password->setPlaceholderText(tr("Password Protected"));
|
||||
|
||||
/*
|
||||
* When setting/deleting a password from a share the old share is
|
||||
* deleted and a new one is created. So we need to refetch the shares
|
||||
|
@ -240,6 +241,7 @@ void ShareLinkWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shar
|
|||
_ui->lineEdit_password->setEnabled(true);
|
||||
_ui->checkBox_password->setChecked(true);
|
||||
_ui->lineEdit_password->setPlaceholderText("********");
|
||||
_ui->lineEdit_password->setText(QString());
|
||||
_ui->lineEdit_password->show();
|
||||
_ui->pushButton_setPassword->show();
|
||||
} else {
|
||||
|
@ -280,7 +282,8 @@ void ShareLinkWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shar
|
|||
connect(_share.data(), SIGNAL(publicUploadSet()), SLOT(slotPublicUploadSet()));
|
||||
connect(_share.data(), SIGNAL(passwordSet()), SLOT(slotPasswordSet()));
|
||||
connect(_share.data(), SIGNAL(shareDeleted()), SLOT(slotDeleteShareFetched()));
|
||||
connect(_share.data(), SIGNAL(serverError(int, QString)), SLOT(displayError(int, QString)));
|
||||
connect(_share.data(), SIGNAL(serverError(int, QString)), SLOT(slotServerError(int,QString)));
|
||||
connect(_share.data(), SIGNAL(passwordSetError(int, QString)), SLOT(slotPasswordSetError(int,QString)));
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -510,13 +513,26 @@ void ShareLinkWidget::setShareCheckBoxTitle(bool haveShares)
|
|||
|
||||
}
|
||||
|
||||
void ShareLinkWidget::displayError(int code, const QString &message)
|
||||
void ShareLinkWidget::slotServerError(int code, const QString &message)
|
||||
{
|
||||
const QString arg = QString("%1, %2").arg(code).arg(message);
|
||||
_pi_link->stopAnimation();
|
||||
_pi_date->stopAnimation();
|
||||
_pi_password->stopAnimation();
|
||||
_pi_editing->stopAnimation();
|
||||
|
||||
qDebug() << "Error from server" << code << message;
|
||||
displayError(message);
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotPasswordSetError(int code, const QString &message)
|
||||
{
|
||||
slotServerError(code, message);
|
||||
|
||||
_ui->checkBox_password->setEnabled(true);
|
||||
_ui->lineEdit_password->setEnabled(true);
|
||||
_ui->lineEdit_password->setFocus();
|
||||
}
|
||||
|
||||
void ShareLinkWidget::displayError(const QString& errMsg)
|
||||
{
|
||||
_ui->errorLabel->setText( errMsg );
|
||||
|
|
|
@ -70,7 +70,8 @@ private slots:
|
|||
void slotCheckBoxEditingClicked();
|
||||
void slotPublicUploadSet();
|
||||
|
||||
void displayError(int code, const QString &message);
|
||||
void slotServerError(int code, const QString &message);
|
||||
void slotPasswordSetError(int code, const QString &message);
|
||||
|
||||
private:
|
||||
void setShareCheckBoxTitle(bool haveShares);
|
||||
|
|
Loading…
Reference in a new issue