Skip to content

Commit

Permalink
Share dialog: More error handling with password policy owncloud#4209
Browse files Browse the repository at this point in the history
  • Loading branch information
ckamm committed Jan 22, 2016
1 parent f15f4aa commit 826abd0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/gui/share.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/gui/share.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,13 @@ class LinkShare : public Share {
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;
Expand Down
27 changes: 21 additions & 6 deletions src/gui/sharelinkwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -280,7 +281,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;
}
Expand Down Expand Up @@ -510,13 +512,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 );
Expand Down
3 changes: 2 additions & 1 deletion src/gui/sharelinkwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 826abd0

Please sign in to comment.