Cloud storage: clear our last error if verification succeeds

This is cosmetic but makes things friendlier, I think.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-06-14 14:18:51 -07:00
parent 4b120d1bf5
commit 0c44bc7271
3 changed files with 13 additions and 0 deletions

View file

@ -21,6 +21,11 @@ void NotificationWidget::hideNotification()
animatedHide();
}
QString NotificationWidget::getNotificationText()
{
return text();
}
void NotificationWidget::setFuture(const QFuture<void> &future)
{
future_watcher->setFuture(future);

View file

@ -18,6 +18,7 @@ public:
void setFuture(const QFuture<void> &future);
void showNotification(QString message, KMessageWidget::MessageType type);
void hideNotification();
QString getNotificationText();
~NotificationWidget();
private:

View file

@ -974,14 +974,21 @@ QNetworkReply* CloudStorageAuthenticate::authenticate(QString email, QString pas
void CloudStorageAuthenticate::uploadFinished()
{
static QString myLastError;
QString cloudAuthReply(reply->readAll());
qDebug() << "Completed connection with cloud storage backend, response" << cloudAuthReply;
if (cloudAuthReply == "[VERIFIED]" || cloudAuthReply == "[OK]") {
prefs.cloud_verification_status = CS_VERIFIED;
NotificationWidget *nw = MainWindow::instance()->getNotificationWidget();
if (nw->getNotificationText() == myLastError)
nw->hideNotification();
myLastError.clear();
} else if (cloudAuthReply == "[VERIFY]") {
prefs.cloud_verification_status = CS_NEED_TO_VERIFY;
} else {
prefs.cloud_verification_status = CS_INCORRECT_USER_PASSWD;
myLastError = cloudAuthReply;
report_error("%s", qPrintable(cloudAuthReply));
MainWindow::instance()->getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
}