Share dialog: Error reporting with password policy #4209

This commit is contained in:
Christian Kamm 2016-01-19 14:03:13 +01:00
parent 7f44e83cc7
commit 4d52838e2b
4 changed files with 23 additions and 6 deletions

View file

@ -201,7 +201,7 @@ void ShareManager::slotLinkShareCreated(const QVariantMap &reply)
* meant that a share was password protected * meant that a share was password protected
*/ */
if (code == 403) { if (code == 403) {
emit linkShareRequiresPassword(); emit linkShareRequiresPassword(message);
return; return;
} }

View file

@ -259,10 +259,17 @@ public:
signals: signals:
void shareCreated(const QSharedPointer<Share> &share); void shareCreated(const QSharedPointer<Share> &share);
void linkShareCreated(const QSharedPointer<LinkShare> &share); void linkShareCreated(const QSharedPointer<LinkShare> &share);
void linkShareRequiresPassword();
void sharesFetched(const QList<QSharedPointer<Share>> &shares); void sharesFetched(const QList<QSharedPointer<Share>> &shares);
void serverError(int code, const QString &message); void serverError(int code, const QString &message);
/** Emitted when creating a link share with password fails.
*
* @param message the error message reported by the server
*
* See createLinkShare().
*/
void linkShareRequiresPassword(const QString &message);
private slots: private slots:
void slotSharesFetched(const QVariantMap &reply); void slotSharesFetched(const QVariantMap &reply);
void slotLinkShareCreated(const QVariantMap &reply); void slotLinkShareCreated(const QVariantMap &reply);

View file

@ -140,13 +140,14 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
connect(_manager, SIGNAL(sharesFetched(QList<QSharedPointer<Share>>)), SLOT(slotSharesFetched(QList<QSharedPointer<Share>>))); 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(linkShareCreated(QSharedPointer<LinkShare>)), SLOT(slotCreateShareFetched(const QSharedPointer<LinkShare>)));
connect(_manager, SIGNAL(linkShareRequiresPassword()), SLOT(slotCreateShareRequiresPassword())); 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(displayError(int, QString)));
} }
void ShareLinkWidget::setExpireDate(const QDate &date) void ShareLinkWidget::setExpireDate(const QDate &date)
{ {
_pi_date->startAnimation(); _pi_date->startAnimation();
_ui->errorLabel->hide();
_share->setExpireDate(date); _share->setExpireDate(date);
} }
@ -185,6 +186,7 @@ void ShareLinkWidget::setPassword(const QString &password)
{ {
_pi_link->startAnimation(); _pi_link->startAnimation();
_pi_password->startAnimation(); _pi_password->startAnimation();
_ui->errorLabel->hide();
_ui->checkBox_password->setEnabled(false); _ui->checkBox_password->setEnabled(false);
_ui->lineEdit_password->setEnabled(false); _ui->lineEdit_password->setEnabled(false);
@ -378,6 +380,7 @@ void ShareLinkWidget::slotCheckBoxShareLinkClicked()
_pi_link->startAnimation(); _pi_link->startAnimation();
_ui->checkBox_shareLink->setEnabled(false); _ui->checkBox_shareLink->setEnabled(false);
_ui->errorLabel->hide();
_manager->createLinkShare(_sharePath); _manager->createLinkShare(_sharePath);
} else { } else {
@ -403,18 +406,24 @@ void ShareLinkWidget::slotCreateShareFetched(const QSharedPointer<LinkShare> sha
getShares(); getShares();
} }
void ShareLinkWidget::slotCreateShareRequiresPassword() void ShareLinkWidget::slotCreateShareRequiresPassword(const QString& message)
{ {
// there needs to be a password // there needs to be a password
_pi_editing->stopAnimation(); _pi_link->stopAnimation();
_pi_password->stopAnimation();
_ui->checkBox_password->setChecked(true); _ui->checkBox_password->setChecked(true);
_ui->checkBox_password->setEnabled(false); _ui->checkBox_password->setEnabled(false);
_ui->checkBox_password->setText(tr("Public sh&aring requires a password")); _ui->checkBox_password->setText(tr("Public sh&aring requires a password"));
_ui->lineEdit_password->setEnabled(true);
_ui->lineEdit_password->setFocus(); _ui->lineEdit_password->setFocus();
_ui->pushButton_copy->hide(); _ui->pushButton_copy->hide();
_ui->widget_shareLink->show(); _ui->widget_shareLink->show();
_ui->checkBox_expire->setEnabled(false); _ui->checkBox_expire->setEnabled(false);
_ui->checkBox_editing->setEnabled(false); _ui->checkBox_editing->setEnabled(false);
if (!message.isEmpty()) {
_ui->errorLabel->setText(message);
_ui->errorLabel->show();
}
_passwordRequired = true; _passwordRequired = true;
@ -477,6 +486,7 @@ void ShareLinkWidget::setPublicUpload(bool publicUpload)
{ {
_ui->checkBox_editing->setEnabled(false); _ui->checkBox_editing->setEnabled(false);
_pi_editing->startAnimation(); _pi_editing->startAnimation();
_ui->errorLabel->hide();
_share->setPublicUpload(publicUpload); _share->setPublicUpload(publicUpload);
} }

View file

@ -56,7 +56,7 @@ public:
private slots: private slots:
void slotSharesFetched(const QList<QSharedPointer<Share>> &shares); void slotSharesFetched(const QList<QSharedPointer<Share>> &shares);
void slotCreateShareFetched(const QSharedPointer<LinkShare> share); void slotCreateShareFetched(const QSharedPointer<LinkShare> share);
void slotCreateShareRequiresPassword(); void slotCreateShareRequiresPassword(const QString& message);
void slotDeleteShareFetched(); void slotDeleteShareFetched();
void slotPasswordSet(); void slotPasswordSet();
void slotExpireSet(); void slotExpireSet();