Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Molkentin <danimo@owncloud.com>2013-11-25 18:33:35 +0400
committerDaniel Molkentin <danimo@owncloud.com>2013-11-25 18:34:17 +0400
commit685c13dead14945c6674f1192513cbe445836c7c (patch)
tree06a46b49d5fb59a41601723b0693302ce235662c /src/mirall
parentc25c7daca7edcc9a082621ecb85de9a29e78f84e (diff)
Distiguish "Signed out" from "Disconnected"
Diffstat (limited to 'src/mirall')
-rw-r--r--src/mirall/account.cpp14
-rw-r--r--src/mirall/account.h13
-rw-r--r--src/mirall/accountsettings.cpp10
-rw-r--r--src/mirall/accountsettings.h2
-rw-r--r--src/mirall/application.cpp9
-rw-r--r--src/mirall/connectionvalidator.cpp13
-rw-r--r--src/mirall/folder.cpp2
-rw-r--r--src/mirall/networkjobs.cpp5
-rw-r--r--src/mirall/owncloudgui.cpp12
-rw-r--r--src/mirall/owncloudgui.h2
-rw-r--r--src/mirall/quotainfo.cpp8
-rw-r--r--src/mirall/quotainfo.h2
12 files changed, 52 insertions, 40 deletions
diff --git a/src/mirall/account.cpp b/src/mirall/account.cpp
index a469b2d0d..22c371bb4 100644
--- a/src/mirall/account.cpp
+++ b/src/mirall/account.cpp
@@ -65,7 +65,7 @@ Account::Account(AbstractSslErrorHandler *sslErrorHandler, QObject *parent)
, _am(0)
, _credentials(0)
, _treatSslErrorsAsFailure(false)
- , _isOnline(false)
+ , _state(Account::Disconnected)
{
}
@@ -285,16 +285,16 @@ void Account::setCredentialSetting(const QString &key, const QVariant &value)
}
}
-bool Account::isOnline() const
+int Account::state() const
{
- return _isOnline;
+ return _state;
}
-void Account::setOnline(bool online)
+void Account::setState(int state)
{
- if (_isOnline != online) {
- _isOnline = online;
- emit onlineStateChanged(online);
+ if (_state != state) {
+ _state = state;
+ emit stateChanged(state);
}
}
diff --git a/src/mirall/account.h b/src/mirall/account.h
index 0bbba26ad..de6f1169d 100644
--- a/src/mirall/account.h
+++ b/src/mirall/account.h
@@ -64,6 +64,11 @@ public:
class Account : public QObject {
Q_OBJECT
public:
+ enum State { Connected = 0, /// account is online
+ Disconnected = 1, /// no network connection
+ SignedOut = 2 /// Disconnected + credential token has been discarded
+ };
+
static QString davPath() { return "remote.php/webdav/"; }
Account(AbstractSslErrorHandler *sslErrorHandler = 0, QObject *parent = 0);
@@ -133,10 +138,10 @@ public:
QVariant credentialSetting(const QString& key) const;
void setCredentialSetting(const QString& key, const QVariant &value);
- bool isOnline() const;
- void setOnline(bool online);
+ int state() const;
+ void setState(int state);
signals:
- void onlineStateChanged(bool online);
+ void stateChanged(int state);
protected Q_SLOTS:
void slotHandleErrors(QNetworkReply*,QList<QSslError>);
@@ -150,7 +155,7 @@ private:
QNetworkAccessManager *_am;
AbstractCredentials* _credentials;
bool _treatSslErrorsAsFailure;
- bool _isOnline;
+ int _state;
static QString _configFileName;
};
diff --git a/src/mirall/accountsettings.cpp b/src/mirall/accountsettings.cpp
index b9263002b..f96f079e4 100644
--- a/src/mirall/accountsettings.cpp
+++ b/src/mirall/accountsettings.cpp
@@ -104,8 +104,8 @@ AccountSettings::AccountSettings(QWidget *parent) :
ui->connectLabel->setText(tr("No account configured."));
ui->_buttonAdd->setEnabled(false);
if (_account) {
- connect(_account, SIGNAL(onlineStateChanged(bool)), SLOT(slotOnlineStateChanged(bool)));
- slotOnlineStateChanged(_account->isOnline());
+ connect(_account, SIGNAL(stateChanged(int)), SLOT(slotAccountStateChanged(int)));
+ slotAccountStateChanged(_account->state());
}
setFolderList(FolderMan::instance()->map());
@@ -771,13 +771,13 @@ void AccountSettings::slotIgnoreFilesEditor()
}
}
-void AccountSettings::slotOnlineStateChanged(bool online)
+void AccountSettings::slotAccountStateChanged(int state)
{
if (_account) {
QUrl safeUrl(_account->url());
safeUrl.setPassword(QString()); // Remove the password from the URL to avoid showing it in the UI
- ui->_buttonAdd->setEnabled(online);
- if (online) {
+ ui->_buttonAdd->setEnabled(state == Account::Connected);
+ if (state == Account::Connected) {
QString user;
if (AbstractCredentials *cred = _account->credentials()) {
user = cred->user();
diff --git a/src/mirall/accountsettings.h b/src/mirall/accountsettings.h
index d85ac32ff..0b9b1f65a 100644
--- a/src/mirall/accountsettings.h
+++ b/src/mirall/accountsettings.h
@@ -68,7 +68,7 @@ public slots:
void slotUpdateQuota( qint64,qint64 );
void slotIgnoreFilesEditor();
- void slotOnlineStateChanged(bool online = true);
+ void slotAccountStateChanged(int state);
void setGeneralErrors( const QStringList& errors );
diff --git a/src/mirall/application.cpp b/src/mirall/application.cpp
index 5cccc1439..01855e6a9 100644
--- a/src/mirall/application.cpp
+++ b/src/mirall/application.cpp
@@ -125,7 +125,7 @@ Application::Application(int &argc, char **argv) :
}
connect( _gui, SIGNAL(setupProxy()), SLOT(slotSetupProxy()));
if (account) {
- connect(account, SIGNAL(onlineStateChanged(bool)), _gui, SLOT(slotOnlineStateChanged()));
+ connect(account, SIGNAL(stateChanged(int)), _gui, SLOT(slotAccountStateChanged()));
}
connect(AccountManager::instance(), SIGNAL(accountChanged(Account*,Account*)),
this, SLOT(slotAccountChanged(Account*,Account*)));
@@ -168,8 +168,7 @@ void Application::slotLogout()
folderMan->setSyncEnabled(false);
folderMan->terminateSyncProcess();
folderMan->unloadAllFolders();
- // go offline
- a->setOnline(false);
+ a->setState(Account::SignedOut);
// show result
_gui->slotComputeOverallSyncStatus();
}
@@ -177,8 +176,8 @@ void Application::slotLogout()
void Application::slotAccountChanged(Account *newAccount, Account *oldAccount)
{
- disconnect(oldAccount, SIGNAL(onlineStateChanged(bool)), _gui, SLOT(slotOnlineStateChanged()));
- connect(newAccount, SIGNAL(onlineStateChanged(bool)), _gui, SLOT(slotOnlineStateChanged()));
+ disconnect(oldAccount, SIGNAL(stateChanged(int)), _gui, SLOT(slotOnlineStateChanged()));
+ connect(newAccount, SIGNAL(stateChanged(int)), _gui, SLOT(slotOnlineStateChanged()));
}
diff --git a/src/mirall/connectionvalidator.cpp b/src/mirall/connectionvalidator.cpp
index 5d02b6de5..f6449c944 100644
--- a/src/mirall/connectionvalidator.cpp
+++ b/src/mirall/connectionvalidator.cpp
@@ -114,7 +114,7 @@ void ConnectionValidator::slotStatusFound(const QUrl&url, const QVariantMap &inf
// status.php could not be loaded.
void ConnectionValidator::slotNoStatusFound(QNetworkReply *reply)
{
- _account->setOnline(false);
+ _account->setState(false);
// ### TODO
_errors.append(tr("Unable to connect to %1").arg(_account->url().toString()));
@@ -147,7 +147,14 @@ void ConnectionValidator::slotAuthFailed(QNetworkReply *reply)
qDebug() << "******** Password is wrong!";
_errors << tr("The provided credentials are not correct");
stat = CredentialsWrong;
- _account->setOnline(false);
+ switch (_account->state()) {
+ case Account::SignedOut:
+ _account->setState(Account::SignedOut);
+ break;
+ default:
+ _account->setState(Account::Disconnected);
+ }
+
} else if( reply->error() != QNetworkReply::NoError ) {
_errors << reply->errorString();
}
@@ -157,7 +164,7 @@ void ConnectionValidator::slotAuthFailed(QNetworkReply *reply)
void ConnectionValidator::slotAuthSuccess()
{
- _account->setOnline(true);
+ _account->setState(Account::Connected);
emit connectionResult(Connected);
}
diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp
index 65d05936b..9922b0ab2 100644
--- a/src/mirall/folder.cpp
+++ b/src/mirall/folder.cpp
@@ -299,7 +299,7 @@ void Folder::etagRetreived(const QString& etag)
void Folder::slotNetworkUnavailable()
{
- AccountManager::instance()->account()->setOnline(false);
+ AccountManager::instance()->account()->setState(Account::Disconnected);
_syncResult.setStatus(SyncResult::Unavailable);
emit syncStateChange();
}
diff --git a/src/mirall/networkjobs.cpp b/src/mirall/networkjobs.cpp
index f42dde9ad..494926114 100644
--- a/src/mirall/networkjobs.cpp
+++ b/src/mirall/networkjobs.cpp
@@ -144,9 +144,10 @@ void AbstractNetworkJob::slotFinished()
// query the user
if (mutex.tryLock()) {
Account *a = account();
- //a->setOnline(false);
bool fetched = creds->fetchFromUser(a);
- a->setOnline(fetched);
+ if (fetched) {
+ a->setState(Account::Connected);
+ }
mutex.unlock();
}
}
diff --git a/src/mirall/owncloudgui.cpp b/src/mirall/owncloudgui.cpp
index 9df2cd9e6..70528b180 100644
--- a/src/mirall/owncloudgui.cpp
+++ b/src/mirall/owncloudgui.cpp
@@ -141,7 +141,7 @@ void ownCloudGui::slotOpenPath(const QString &path)
Utility::showInFileManager(path);
}
-void ownCloudGui::slotOnlineStateChanged()
+void ownCloudGui::slotAccountStateChanged()
{
setupContextMenu();
}
@@ -168,7 +168,7 @@ void ownCloudGui::startupConnected( bool connected, const QStringList& fails )
void ownCloudGui::slotComputeOverallSyncStatus()
{
if (Account *a = AccountManager::instance()->account()) {
- if (!a->isOnline()) {
+ if (a->state() == Account::SignedOut) {
_tray->setIcon(Theme::instance()->syncStateIcon( SyncResult::Unavailable, true));
_tray->setToolTip(tr("Please sign in"));
return;
@@ -225,9 +225,9 @@ void ownCloudGui::setupContextMenu()
bool isConfigured = (a != 0);
_actionOpenoC->setEnabled(isConfigured);
- bool isOnline = false;
+ bool isConnected = false;
if (isConfigured) {
- isOnline = a->isOnline();
+ isConnected = (a->state() == Account::Connected);
}
if ( _contextMenu ) {
@@ -276,7 +276,7 @@ void ownCloudGui::setupContextMenu()
}
_contextMenu->addSeparator();
- if (isConfigured && isOnline) {
+ if (isConfigured && isConnected) {
_contextMenu->addAction(_actionQuota);
_contextMenu->addSeparator();
_contextMenu->addAction(_actionStatus);
@@ -288,7 +288,7 @@ void ownCloudGui::setupContextMenu()
_contextMenu->addAction(_actionHelp);
}
_contextMenu->addSeparator();
- if (isConfigured && isOnline) {
+ if (isConfigured && isConnected) {
_contextMenu->addAction(_actionLogout);
} else {
_contextMenu->addAction(_actionLogin);
diff --git a/src/mirall/owncloudgui.h b/src/mirall/owncloudgui.h
index f78853e7d..af17d3835 100644
--- a/src/mirall/owncloudgui.h
+++ b/src/mirall/owncloudgui.h
@@ -67,7 +67,7 @@ public slots:
void slotOpenOwnCloud();
void slotHelp();
void slotOpenPath(const QString& path);
- void slotOnlineStateChanged();
+ void slotAccountStateChanged();
private slots:
void slotDisplayIdle();
diff --git a/src/mirall/quotainfo.cpp b/src/mirall/quotainfo.cpp
index 4b0c5f4f8..edcff759f 100644
--- a/src/mirall/quotainfo.cpp
+++ b/src/mirall/quotainfo.cpp
@@ -44,13 +44,13 @@ QuotaInfo::QuotaInfo(QObject *parent)
void QuotaInfo::slotAccountChanged(Account *newAccount, Account *oldAccount)
{
_account = newAccount;
- disconnect(oldAccount, SIGNAL(onlineStateChanged(bool)), this, SLOT(slotOnlineStateChanged(bool)));
- connect(newAccount, SIGNAL(onlineStateChanged(bool)), this, SLOT(slotOnlineStateChanged(bool)));
+ disconnect(oldAccount, SIGNAL(stateChanged(int)), this, SLOT(slotAccountStateChanged(int)));
+ connect(newAccount, SIGNAL(stateChanged(int)), this, SLOT(slotAccountStateChanged(int)));
}
-void QuotaInfo::slotOnlineStateChanged(bool online)
+void QuotaInfo::slotAccountStateChanged(int state)
{
- if (online) {
+ if (state == Account::Connected) {
slotCheckQuota();
} else {
_refreshTimer->stop();
diff --git a/src/mirall/quotainfo.h b/src/mirall/quotainfo.h
index 294a3928c..8d48e468e 100644
--- a/src/mirall/quotainfo.h
+++ b/src/mirall/quotainfo.h
@@ -34,7 +34,7 @@ public Q_SLOTS:
private Q_SLOTS:
void slotAccountChanged(Account *newAccount, Account *oldAccount);
- void slotOnlineStateChanged(bool online);
+ void slotAccountStateChanged(int state);
Q_SIGNALS:
void quotaUpdated(qint64 total, qint64 used);