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(); animatedHide();
} }
QString NotificationWidget::getNotificationText()
{
return text();
}
void NotificationWidget::setFuture(const QFuture<void> &future) void NotificationWidget::setFuture(const QFuture<void> &future)
{ {
future_watcher->setFuture(future); future_watcher->setFuture(future);

View file

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

View file

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