mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-25 22:05:53 +03:00
Basic port, misses wizard
This commit is contained in:
parent
29c846a764
commit
d2b445c80c
20 changed files with 367 additions and 336 deletions
|
@ -212,14 +212,14 @@ set(mirall_SRCS
|
|||
mirall/folderwizard.cpp
|
||||
mirall/folderstatusmodel.cpp
|
||||
mirall/protocolwidget.cpp
|
||||
wizard/owncloudwizard.cpp
|
||||
wizard/owncloudsetuppage.cpp
|
||||
wizard/owncloudhttpcredspage.cpp
|
||||
wizard/owncloudwizardresultpage.cpp
|
||||
wizard/owncloudwizardcommon.cpp
|
||||
wizard/owncloudshibbolethcredspage.cpp
|
||||
wizard/owncloudadvancedsetuppage.cpp
|
||||
mirall/owncloudsetupwizard.cpp
|
||||
# wizard/owncloudwizard.cpp
|
||||
# wizard/owncloudsetuppage.cpp
|
||||
# wizard/owncloudhttpcredspage.cpp
|
||||
# wizard/owncloudwizardresultpage.cpp
|
||||
# wizard/owncloudwizardcommon.cpp
|
||||
# wizard/owncloudshibbolethcredspage.cpp
|
||||
# wizard/owncloudadvancedsetuppage.cpp
|
||||
# mirall/owncloudsetupwizard.cpp
|
||||
mirall/updatedetector.cpp
|
||||
mirall/occinfo.cpp
|
||||
mirall/sslerrordialog.cpp
|
||||
|
@ -237,14 +237,14 @@ set(mirall_HEADERS
|
|||
mirall/application.h
|
||||
mirall/systray.h
|
||||
mirall/folderwizard.h
|
||||
mirall/owncloudsetupwizard.h
|
||||
wizard/owncloudwizard.h
|
||||
wizard/owncloudsetuppage.h
|
||||
wizard/owncloudhttpcredspage.h
|
||||
wizard/owncloudwizardresultpage.h
|
||||
wizard/owncloudwizardcommon.h
|
||||
wizard/owncloudshibbolethcredspage.h
|
||||
wizard/owncloudadvancedsetuppage.h
|
||||
# mirall/owncloudsetupwizard.h
|
||||
# wizard/owncloudwizard.h
|
||||
# wizard/owncloudsetuppage.h
|
||||
# wizard/owncloudhttpcredspage.h
|
||||
# wizard/owncloudwizardresultpage.h
|
||||
# wizard/owncloudwizardcommon.h
|
||||
# wizard/owncloudshibbolethcredspage.h
|
||||
# wizard/owncloudadvancedsetuppage.h
|
||||
mirall/folderstatusmodel.h
|
||||
mirall/updatedetector.h
|
||||
mirall/sslerrordialog.h
|
||||
|
|
|
@ -19,10 +19,12 @@
|
|||
#include <QString>
|
||||
#include <QSslCertificate>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "creds/credentialscommon.h"
|
||||
|
||||
#include "mirall/utility.h"
|
||||
#include "mirall/owncloudinfo.h"
|
||||
#include "mirall/account.h"
|
||||
|
||||
namespace Mirall
|
||||
{
|
||||
|
@ -46,7 +48,7 @@ int handleNeonSSLProblems(const char* prompt,
|
|||
int pos = 0;
|
||||
// This is the set of certificates which QNAM accepted, so we should accept
|
||||
// them as well
|
||||
QList<QSslCertificate> certs = ownCloudInfo::instance()->certificateChain();
|
||||
QList<QSslCertificate> certs = AccountManager::instance()->account()->certificateChain();
|
||||
|
||||
while (!certOk && (pos = regexp.indexIn(qPrompt, 1+pos)) != -1) {
|
||||
QString neon_fingerprint = regexp.cap(1);
|
||||
|
|
|
@ -12,14 +12,17 @@
|
|||
* for more details.
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMutex>
|
||||
|
||||
#include "creds/shibbolethcredentials.h"
|
||||
#include "creds/shibboleth/shibbolethaccessmanager.h"
|
||||
#include "creds/shibboleth/shibbolethwebview.h"
|
||||
#include "creds/shibboleth/shibbolethrefresher.h"
|
||||
#include "creds/shibboleth/shibbolethconfigfile.h"
|
||||
#include "creds/credentialscommon.h"
|
||||
#include "mirall/owncloudinfo.h"
|
||||
#include "mirall/mirallconfigfile.h"
|
||||
#include "mirall/account.h"
|
||||
|
||||
namespace Mirall
|
||||
{
|
||||
|
@ -88,7 +91,7 @@ QByteArray ShibbolethCredentials::prepareCookieData() const
|
|||
// have any way to get "session_key" module property from
|
||||
// csync. Had we have it, then we could just append shibboleth
|
||||
// cookies to the "session_key" value and set it in csync module.
|
||||
QList<QNetworkCookie> cookies(ownCloudInfo::instance()->getLastAuthCookies());
|
||||
QList<QNetworkCookie> cookies(AccountManager::instance()->account()->lastAuthCookies());
|
||||
QMap<QString, QString> uniqueCookies;
|
||||
|
||||
cookies << _shibCookie;
|
||||
|
|
|
@ -12,18 +12,20 @@
|
|||
*/
|
||||
|
||||
#include "mirall/account.h"
|
||||
#include "mirall/mirallaccessmanager.h"
|
||||
#include "mirall/theme.h"
|
||||
#include "mirall/mirallconfigfile.h"
|
||||
#include "creds/abstractcredentials.h"
|
||||
#include "creds/credentialsfactory.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QMutex>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkAccessManager>
|
||||
|
||||
namespace Mirall {
|
||||
|
||||
static const char urlC[] = "url";
|
||||
static const char userC[] = "user";
|
||||
static const char authTypeC[] = "authType";
|
||||
|
||||
AccountManager *AccountManager::_instance = 0;
|
||||
|
@ -47,7 +49,7 @@ AccountManager *AccountManager::instance()
|
|||
|
||||
Account::Account(QObject *parent)
|
||||
: QObject(parent)
|
||||
, _am(new MirallAccessManager)
|
||||
, _am(0)
|
||||
, _credentials(0)
|
||||
{
|
||||
}
|
||||
|
@ -55,19 +57,27 @@ Account::Account(QObject *parent)
|
|||
void Account::save(QSettings &settings)
|
||||
{
|
||||
settings.beginGroup(Theme::instance()->appName());
|
||||
settings.setValue(QLatin1String(userC), _user);
|
||||
settings.setValue(QLatin1String(urlC), _url);
|
||||
if (_credentials) {
|
||||
settings.setValue(QLatin1String(authTypeC), _credentials->authType());
|
||||
}
|
||||
}
|
||||
|
||||
Account* Account::restore(QSettings settings)
|
||||
Account* Account::restore(QSettings &settings)
|
||||
{
|
||||
QString groupName = Theme::instance()->appName();
|
||||
if (settings.childGroups().contains(groupName)) {
|
||||
Account *acc = new Account;
|
||||
settings.beginGroup(Theme::instance()->appName());
|
||||
settings.beginGroup(groupName);
|
||||
acc->setUrl(settings.value(QLatin1String(urlC)).toUrl());
|
||||
acc->setCredentials(CredentialsFactory::create(settings.value(QLatin1String(authTypeC)).toString()));
|
||||
acc->setUser(settings.value(QLatin1String(userC)).toString());
|
||||
MirallConfigFile cfg;
|
||||
acc->setCredentials(cfg.getCredentials());
|
||||
return acc;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
AbstractCredentials *Account::credentials() const
|
||||
|
@ -78,11 +88,11 @@ AbstractCredentials *Account::credentials() const
|
|||
void Account::setCredentials(AbstractCredentials *cred)
|
||||
{
|
||||
_credentials = cred;
|
||||
}
|
||||
|
||||
QUrl Account::url() const
|
||||
{
|
||||
return _url;
|
||||
// set active credential manager
|
||||
if (_am) {
|
||||
_am->deleteLater();
|
||||
}
|
||||
_am = _credentials->getQNAM();
|
||||
}
|
||||
|
||||
static const char WEBDAV_PATH[] = "remote.php/webdav/";
|
||||
|
@ -104,11 +114,11 @@ QNetworkReply *Account::getRequest(const QString &relPath)
|
|||
return _am->get(request);
|
||||
}
|
||||
|
||||
QNetworkReply *Account::davRequest(const QString &relPath, const QByteArray &verb, QIODevice *data)
|
||||
QNetworkReply *Account::davRequest(const QByteArray &verb, const QString &relPath, QNetworkRequest req, QIODevice *data)
|
||||
{
|
||||
QNetworkRequest request(concatUrlPath(davUrl(), relPath));
|
||||
req.setUrl(concatUrlPath(davUrl(), relPath));
|
||||
// ### error handling
|
||||
return _am->sendCustomRequest(request, verb, data);
|
||||
return _am->sendCustomRequest(req, verb, data);
|
||||
}
|
||||
|
||||
void Account::setUrl(const QUrl &url)
|
||||
|
@ -116,9 +126,9 @@ void Account::setUrl(const QUrl &url)
|
|||
_url = url;
|
||||
}
|
||||
|
||||
QByteArray Account::caCerts() const
|
||||
void Account::setUser(const QString &user)
|
||||
{
|
||||
return _caCerts;
|
||||
_user = user;
|
||||
}
|
||||
|
||||
void Account::setCaCerts(const QByteArray &caCerts)
|
||||
|
@ -126,7 +136,12 @@ void Account::setCaCerts(const QByteArray &caCerts)
|
|||
_caCerts = caCerts;
|
||||
}
|
||||
|
||||
QUrl Account::concatUrlPath(const QUrl &url, const QString &concatPath) const
|
||||
QList<QSslCertificate> Account::certificateChain() const
|
||||
{
|
||||
return QList<QSslCertificate>();
|
||||
}
|
||||
|
||||
QUrl Account::concatUrlPath(const QUrl &url, const QString &concatPath)
|
||||
{
|
||||
QUrl tmpUrl = url;
|
||||
QString path = tmpUrl.path();
|
||||
|
|
|
@ -18,14 +18,16 @@
|
|||
#include <QByteArray>
|
||||
#include <QUrl>
|
||||
#include <QNetworkCookie>
|
||||
#include <QNetworkRequest>
|
||||
#include <QSslCertificate>
|
||||
|
||||
class QSettings;
|
||||
class QNetworkReply;
|
||||
class QUrl;
|
||||
class QNetworkAccessManager;
|
||||
|
||||
namespace Mirall {
|
||||
|
||||
class MirallAccessManager;
|
||||
class AbstractCredentials;
|
||||
class Account;
|
||||
|
||||
|
@ -38,7 +40,7 @@ public:
|
|||
Account *account() { return _account; }
|
||||
|
||||
private:
|
||||
AccountManager();
|
||||
AccountManager() {}
|
||||
Account *_account;
|
||||
static AccountManager *_instance;
|
||||
};
|
||||
|
@ -48,6 +50,7 @@ private:
|
|||
*/
|
||||
class Account : public QObject {
|
||||
public:
|
||||
Account(QObject *parent = 0);
|
||||
/**
|
||||
* Saves the account to a given settings file
|
||||
*/
|
||||
|
@ -56,7 +59,7 @@ public:
|
|||
/**
|
||||
* Creates an account object from from a given settings file.
|
||||
*/
|
||||
static Account* restore(QSettings settings);
|
||||
static Account* restore(QSettings &settings);
|
||||
|
||||
/** Holds the accounts credentials */
|
||||
AbstractCredentials* credentials() const;
|
||||
|
@ -64,7 +67,11 @@ public:
|
|||
|
||||
/** Server url of the account */
|
||||
void setUrl(const QUrl &url);
|
||||
QUrl url() const;
|
||||
QUrl url() const { return _url; }
|
||||
|
||||
/** User name of the account */
|
||||
void setUser(const QString &user);
|
||||
QString user() const { return _user; }
|
||||
|
||||
/** Returns webdav entry URL, based on url() */
|
||||
QUrl davUrl() const;
|
||||
|
@ -72,21 +79,27 @@ public:
|
|||
QList<QNetworkCookie> lastAuthCookies() const;
|
||||
|
||||
QNetworkReply* getRequest(const QString &relPath);
|
||||
QNetworkReply* davRequest(const QString &relPath, const QByteArray &verb, QIODevice *data = 0);
|
||||
QNetworkReply* davRequest(const QByteArray &verb, const QString &relPath, QNetworkRequest req, QIODevice *data = 0);
|
||||
|
||||
/** The certificates of the account */
|
||||
QByteArray caCerts() const;
|
||||
QByteArray caCerts() const { return _caCerts; }
|
||||
void setCaCerts(const QByteArray &certs);
|
||||
/** The certificates of the account */
|
||||
QByteArray acceptedCaCerts() const { return _acceptedCaCerts; }
|
||||
void setAcceptedCaCerts(const QByteArray &certs);
|
||||
|
||||
protected:
|
||||
QUrl concatUrlPath(const QUrl &url, const QString &concatPath) const;
|
||||
QList<QSslCertificate> certificateChain() const;
|
||||
|
||||
static QUrl concatUrlPath(const QUrl &url, const QString &concatPath);
|
||||
|
||||
private:
|
||||
Account(QObject *parent = 0);
|
||||
MirallAccessManager *_am;
|
||||
QNetworkAccessManager *_am;
|
||||
QByteArray _caCerts;
|
||||
QByteArray _acceptedCaCerts;
|
||||
QUrl _url;
|
||||
QString _user;
|
||||
AbstractCredentials* _credentials;
|
||||
QList<QSslCertificate> _certificateChain;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
#include "mirall/theme.h"
|
||||
#include "mirall/folderman.h"
|
||||
#include "mirall/owncloudinfo.h"
|
||||
#include "mirall/folderwizard.h"
|
||||
#include "mirall/folderstatusmodel.h"
|
||||
#include "mirall/utility.h"
|
||||
|
@ -25,6 +24,8 @@
|
|||
#include "mirall/owncloudsetupwizard.h"
|
||||
#include "mirall/mirallconfigfile.h"
|
||||
#include "mirall/ignorelisteditor.h"
|
||||
#include "mirall/account.h"
|
||||
#include "mirall/networkjobs.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
@ -88,15 +89,18 @@ AccountSettings::AccountSettings(QWidget *parent) :
|
|||
|
||||
QColor color = palette().highlight().color();
|
||||
ui->quotaProgressBar->setStyleSheet(QString::fromLatin1(progressBarStyleC).arg(color.name()));
|
||||
ownCloudInfo *ocInfo = ownCloudInfo::instance();
|
||||
slotUpdateQuota(ocInfo->lastQuotaTotalBytes(), ocInfo->lastQuotaUsedBytes());
|
||||
connect(ocInfo, SIGNAL(quotaUpdated(qint64,qint64)), SLOT(slotUpdateQuota(qint64,qint64)));
|
||||
|
||||
// ### TODO: merge with etag job when porting?
|
||||
// ownCloudInfo *ocInfo = ownCloudInfo::instance();
|
||||
// slotUpdateQuota(ocInfo->lastQuotaTotalBytes(), ocInfo->lastQuotaUsedBytes());
|
||||
// connect(ocInfo, SIGNAL(quotaUpdated(qint64,qint64)), SLOT(slotUpdateQuota(qint64,qint64)));
|
||||
|
||||
ui->connectLabel->setWordWrap( true );
|
||||
|
||||
setFolderList(FolderMan::instance()->map());
|
||||
|
||||
slotCheckConnection();
|
||||
// ### TODO
|
||||
//slotCheckConnection();
|
||||
}
|
||||
|
||||
void AccountSettings::slotFolderActivated( const QModelIndex& indx )
|
||||
|
@ -170,7 +174,8 @@ void AccountSettings::slotFolderWizardRejected()
|
|||
void AccountSettings::slotOpenAccountWizard()
|
||||
{
|
||||
this->topLevelWidget()->close();
|
||||
OwncloudSetupWizard::runWizard(qApp, SLOT(slotownCloudWizardDone(int)), 0);
|
||||
// ### TODO
|
||||
//OwncloudSetupWizard::runWizard(qApp, SLOT(slotownCloudWizardDone(int)), 0);
|
||||
}
|
||||
|
||||
void AccountSettings::slotAddFolder( Folder *folder )
|
||||
|
@ -180,7 +185,8 @@ void AccountSettings::slotAddFolder( Folder *folder )
|
|||
QStandardItem *item = new QStandardItem();
|
||||
folderToModelItem( item, folder );
|
||||
_model->appendRow( item );
|
||||
slotCheckConnection();
|
||||
// ### TODO
|
||||
//slotCheckConnection();
|
||||
}
|
||||
|
||||
|
||||
|
@ -299,7 +305,8 @@ void AccountSettings::slotRemoveCurrentFolder()
|
|||
_model->removeRow(row);
|
||||
|
||||
emit folderChanged();
|
||||
slotCheckConnection();
|
||||
// ### TODO
|
||||
//slotCheckConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -349,24 +356,6 @@ void AccountSettings::showConnectionLabel( const QString& message, const QString
|
|||
}
|
||||
}
|
||||
|
||||
void AccountSettings::slotCheckConnection()
|
||||
{
|
||||
if( ownCloudInfo::instance()->isConfigured() ) {
|
||||
connect(ownCloudInfo::instance(), SIGNAL(ownCloudInfoFound(const QString&, const QString&, const QString&, const QString&)),
|
||||
this, SLOT(slotOCInfo( const QString&, const QString&, const QString&, const QString& )));
|
||||
connect(ownCloudInfo::instance(), SIGNAL(noOwncloudFound(QNetworkReply*)),
|
||||
this, SLOT(slotOCInfoFail(QNetworkReply*)));
|
||||
|
||||
showConnectionLabel( tr("Checking %1 connection...").arg(Theme::instance()->appNameGUI()));
|
||||
qDebug() << "Check status.php from statusdialog.";
|
||||
ownCloudInfo::instance()->checkInstallation();
|
||||
} else {
|
||||
// ownCloud is not yet configured.
|
||||
showConnectionLabel( tr("No %1 connection configured.").arg(Theme::instance()->appNameGUI()) );
|
||||
ui->_ButtonAdd->setEnabled( false);
|
||||
}
|
||||
}
|
||||
|
||||
void AccountSettings::setFolderList( const Folder::Map &folders )
|
||||
{
|
||||
_model->clear();
|
||||
|
@ -480,52 +469,14 @@ void AccountSettings::slotUpdateFolderState( Folder *folder )
|
|||
} else {
|
||||
// the dialog is not visible.
|
||||
}
|
||||
slotCheckConnection();
|
||||
// ### TODO
|
||||
//slotCheckConnection();
|
||||
}
|
||||
|
||||
void AccountSettings::slotOCInfo( const QString& url, const QString& versionStr, const QString& version, const QString& )
|
||||
{
|
||||
#ifdef Q_OS_WIN32
|
||||
// work around a bug in QDesktopServices on Win32, see i-net
|
||||
QString filePath = url;
|
||||
// showConnectionLabel( tr("Connected to <a href=\"%1\">%2</a>.").arg(url, safeUrl.toString()),
|
||||
// tr("Version: %1 (%2)").arg(versionStr).arg(version) );
|
||||
// ui->_ButtonAdd->setEnabled(true);
|
||||
|
||||
if (filePath.startsWith("\\\\") || filePath.startsWith("//"))
|
||||
_OCUrl.setUrl(QDir::toNativeSeparators(filePath));
|
||||
else
|
||||
_OCUrl = QUrl::fromLocalFile(filePath);
|
||||
#else
|
||||
_OCUrl = QUrl::fromLocalFile(url);
|
||||
#endif
|
||||
|
||||
qDebug() << "#-------# oC found on " << url;
|
||||
/* enable the open button */
|
||||
ui->connectLabel->setOpenExternalLinks(true);
|
||||
QUrl safeUrl(url);
|
||||
safeUrl.setPassword(QString()); // Remove the password from the URL to avoid showing it in the UI
|
||||
showConnectionLabel( tr("Connected to <a href=\"%1\">%2</a>.").arg(url, safeUrl.toString()),
|
||||
tr("Version: %1 (%2)").arg(versionStr).arg(version) );
|
||||
ui->_ButtonAdd->setEnabled(true);
|
||||
|
||||
disconnect(ownCloudInfo::instance(), SIGNAL(ownCloudInfoFound(const QString&, const QString&, const QString&, const QString&)),
|
||||
this, SLOT(slotOCInfo( const QString&, const QString&, const QString&, const QString& )));
|
||||
disconnect(ownCloudInfo::instance(), SIGNAL(noOwncloudFound(QNetworkReply*)),
|
||||
this, SLOT(slotOCInfoFail(QNetworkReply*)));
|
||||
}
|
||||
|
||||
void AccountSettings::slotOCInfoFail( QNetworkReply *reply)
|
||||
{
|
||||
QString errStr = tr("unknown problem.");
|
||||
if( reply ) errStr = reply->errorString();
|
||||
|
||||
showConnectionLabel( tr("<p>Failed to connect to %1: <tt>%2</tt></p>").arg(Theme::instance()->appNameGUI()).arg(errStr) );
|
||||
ui->_ButtonAdd->setEnabled( false);
|
||||
|
||||
disconnect(ownCloudInfo::instance(), SIGNAL(ownCloudInfoFound(const QString&, const QString&, const QString&, const QString&)),
|
||||
this, SLOT(slotOCInfo( const QString&, const QString&, const QString&, const QString& )));
|
||||
disconnect(ownCloudInfo::instance(), SIGNAL(noOwncloudFound(QNetworkReply*)),
|
||||
this, SLOT(slotOCInfoFail(QNetworkReply*)));
|
||||
|
||||
}
|
||||
|
||||
void AccountSettings::slotOpenOC()
|
||||
{
|
||||
|
@ -568,9 +519,8 @@ QString AccountSettings::shortenFilename( const QString& folder, const QString&
|
|||
// rip off the whole ownCloud URL.
|
||||
Folder *f = FolderMan::instance()->folder(folder);
|
||||
if( f ) {
|
||||
QString remotePathUrl = ownCloudInfo::instance()->webdavUrl() + QLatin1Char('/') + f->remotePath();
|
||||
QString remotePathUrl = f->remoteUrl().toString();
|
||||
shortFile.remove(Utility::toCSyncScheme(remotePathUrl));
|
||||
|
||||
}
|
||||
}
|
||||
return shortFile;
|
||||
|
|
|
@ -60,9 +60,6 @@ public slots:
|
|||
void slotFolderActivated( const QModelIndex& );
|
||||
void slotOpenOC();
|
||||
void slotUpdateFolderState( Folder* );
|
||||
void slotCheckConnection();
|
||||
void slotOCInfo( const QString&, const QString&, const QString&, const QString& );
|
||||
void slotOCInfoFail( QNetworkReply* );
|
||||
void slotDoubleClicked( const QModelIndex& );
|
||||
void slotFolderOpenAction( const QString& );
|
||||
void slotSetProgress(const QString&, const Progress::Info& progress);
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "mirall/networklocation.h"
|
||||
#include "mirall/folder.h"
|
||||
#include "mirall/owncloudsetupwizard.h"
|
||||
#include "mirall/owncloudinfo.h"
|
||||
#include "mirall/sslerrordialog.h"
|
||||
#include "mirall/theme.h"
|
||||
#include "mirall/mirallconfigfile.h"
|
||||
|
@ -115,7 +114,9 @@ Application::Application(int &argc, char **argv) :
|
|||
|
||||
connect( this, SIGNAL(messageReceived(QString)), SLOT(slotParseOptions(QString)));
|
||||
|
||||
AccountManager::instance()->setAccount(Account::restore(Theme::instance()->appName()));
|
||||
MirallConfigFile cfg;
|
||||
QSettings settings(cfg.configFile(), QSettings::IniFormat);
|
||||
AccountManager::instance()->setAccount(Account::restore(settings));
|
||||
FolderMan::instance()->setSyncEnabled(false);
|
||||
|
||||
setQuitOnLastWindowClosed(false);
|
||||
|
@ -131,7 +132,6 @@ Application::Application(int &argc, char **argv) :
|
|||
|
||||
// connect(_networkMgr, SIGNAL(onlineStateChanged(bool)), SLOT(slotCheckConnection()));
|
||||
|
||||
MirallConfigFile cfg;
|
||||
_theme->setSystrayUseMonoIcons(cfg.monoIcons());
|
||||
connect (_theme, SIGNAL(systrayUseMonoIconsChanged(bool)), SLOT(slotUseMonoIconsChanged(bool)));
|
||||
|
||||
|
@ -145,8 +145,9 @@ Application::Application(int &argc, char **argv) :
|
|||
QTimer::singleShot( 3000, this, SLOT( slotStartUpdateDetector() ));
|
||||
}
|
||||
|
||||
connect( ownCloudInfo::instance(), SIGNAL(sslFailed(QNetworkReply*, QList<QSslError>)),
|
||||
this,SLOT(slotSSLFailed(QNetworkReply*, QList<QSslError>)));
|
||||
// ###
|
||||
// connect( ownCloudInfo::instance(), SIGNAL(sslFailed(QNetworkReply*, QList<QSslError>)),
|
||||
// this,SLOT(slotSSLFailed(QNetworkReply*, QList<QSslError>)));
|
||||
|
||||
connect (this, SIGNAL(aboutToQuit()), SLOT(slotCleanup()));
|
||||
|
||||
|
@ -206,7 +207,7 @@ void Application::slotCredentialsFetched()
|
|||
|
||||
void Application::runValidator()
|
||||
{
|
||||
_conValidator = new ConnectionValidator();
|
||||
_conValidator = new ConnectionValidator(AccountManager::instance()->account());
|
||||
connect( _conValidator, SIGNAL(connectionResult(ConnectionValidator::Status)),
|
||||
this, SLOT(slotConnectionValidatorResult(ConnectionValidator::Status)) );
|
||||
_conValidator->checkConnection();
|
||||
|
@ -238,38 +239,38 @@ void Application::slotConnectionValidatorResult(ConnectionValidator::Status stat
|
|||
|
||||
void Application::slotSSLFailed( QNetworkReply *reply, QList<QSslError> errors )
|
||||
{
|
||||
qDebug() << "SSL-Warnings happened for url " << reply->url().toString();
|
||||
// qDebug() << "SSL-Warnings happened for url " << reply->url().toString();
|
||||
|
||||
if( ownCloudInfo::instance()->certsUntrusted() ) {
|
||||
// User decided once to untrust. Honor this decision.
|
||||
qDebug() << "Untrusted by user decision, returning.";
|
||||
return;
|
||||
}
|
||||
// if( ownCloudInfo::instance()->certsUntrusted() ) {
|
||||
// // User decided once to untrust. Honor this decision.
|
||||
// qDebug() << "Untrusted by user decision, returning.";
|
||||
// return;
|
||||
// }
|
||||
|
||||
QString configHandle = ownCloudInfo::instance()->configHandle(reply);
|
||||
// QString configHandle = ownCloudInfo::instance()->configHandle(reply);
|
||||
|
||||
// make the ssl dialog aware of the custom config. It loads known certs.
|
||||
if( ! _sslErrorDialog ) {
|
||||
_sslErrorDialog = new SslErrorDialog;
|
||||
}
|
||||
_sslErrorDialog->setCustomConfigHandle( configHandle );
|
||||
// // make the ssl dialog aware of the custom config. It loads known certs.
|
||||
// if( ! _sslErrorDialog ) {
|
||||
// _sslErrorDialog = new SslErrorDialog;
|
||||
// }
|
||||
// _sslErrorDialog->setCustomConfigHandle( configHandle );
|
||||
|
||||
if( _sslErrorDialog->setErrorList( errors ) ) {
|
||||
// all ssl certs are known and accepted. We can ignore the problems right away.
|
||||
qDebug() << "Certs are already known and trusted, Warnings are not valid.";
|
||||
reply->ignoreSslErrors();
|
||||
} else {
|
||||
if( _sslErrorDialog->exec() == QDialog::Accepted ) {
|
||||
if( _sslErrorDialog->trustConnection() ) {
|
||||
reply->ignoreSslErrors();
|
||||
} else {
|
||||
// User does not want to trust.
|
||||
ownCloudInfo::instance()->setCertsUntrusted(true);
|
||||
}
|
||||
} else {
|
||||
ownCloudInfo::instance()->setCertsUntrusted(true);
|
||||
}
|
||||
}
|
||||
// if( _sslErrorDialog->setErrorList( errors ) ) {
|
||||
// // all ssl certs are known and accepted. We can ignore the problems right away.
|
||||
// qDebug() << "Certs are already known and trusted, Warnings are not valid.";
|
||||
// reply->ignoreSslErrors();
|
||||
// } else {
|
||||
// if( _sslErrorDialog->exec() == QDialog::Accepted ) {
|
||||
// if( _sslErrorDialog->trustConnection() ) {
|
||||
// reply->ignoreSslErrors();
|
||||
// } else {
|
||||
// // User does not want to trust.
|
||||
// ownCloudInfo::instance()->setCertsUntrusted(true);
|
||||
// }
|
||||
// } else {
|
||||
// ownCloudInfo::instance()->setCertsUntrusted(true);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void Application::slotownCloudWizardDone( int res )
|
||||
|
|
|
@ -40,7 +40,6 @@ namespace Mirall {
|
|||
class Theme;
|
||||
class Folder;
|
||||
class FolderWatcher;
|
||||
class ownCloudInfo;
|
||||
class SslErrorDialog;
|
||||
class SettingsDialog;
|
||||
class SocketApi;
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include "mirall/connectionvalidator.h"
|
||||
#include "mirall/mirallconfigfile.h"
|
||||
#include "mirall/theme.h"
|
||||
#include "mirall/account.h"
|
||||
#include "mirall/networkjobs.h"
|
||||
|
||||
namespace Mirall {
|
||||
|
||||
|
@ -26,12 +28,11 @@ ConnectionValidator::ConnectionValidator(QObject *parent) :
|
|||
|
||||
}
|
||||
|
||||
ConnectionValidator::ConnectionValidator(const QString& connection, QObject *parent)
|
||||
ConnectionValidator::ConnectionValidator(Account *account, QObject *parent)
|
||||
: QObject(parent),
|
||||
_connection(connection),
|
||||
_account(account),
|
||||
_networkError(QNetworkReply::NoError)
|
||||
{
|
||||
ownCloudInfo::instance()->setCustomConfigHandle(_connection);
|
||||
}
|
||||
|
||||
QStringList ConnectionValidator::errors() const
|
||||
|
@ -85,37 +86,27 @@ QString ConnectionValidator::statusString( Status stat ) const
|
|||
|
||||
void ConnectionValidator::checkConnection()
|
||||
{
|
||||
if( ownCloudInfo::instance()->isConfigured() ) {
|
||||
connect( ownCloudInfo::instance(),SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
|
||||
SLOT(slotStatusFound(QString,QString,QString,QString)));
|
||||
|
||||
connect( ownCloudInfo::instance(),SIGNAL(noOwncloudFound(QNetworkReply*)),
|
||||
SLOT(slotNoStatusFound(QNetworkReply*)));
|
||||
|
||||
// checks for status.php
|
||||
ownCloudInfo::instance()->checkInstallation();
|
||||
if( AccountManager::instance()->account() ) {
|
||||
CheckServerJob *checkJob = new CheckServerJob(_account, false, this);
|
||||
connect(checkJob, SIGNAL(instanceFound(QVariantMap)), SLOT(slotStatusFound(QVariantMap)));
|
||||
connect(checkJob, SIGNAL(networkError(QNetworkReply::NetworkError,QString)),
|
||||
SLOT(slotNoStatusFound(QNetworkReply::NetworkError,QString)));
|
||||
} else {
|
||||
_errors << tr("No ownCloud connection configured");
|
||||
_errors << tr("No ownCloud account configured");
|
||||
emit connectionResult( NotConfigured );
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionValidator::slotStatusFound( const QString& url, const QString& versionStr, const QString& version, const QString& /*edition*/)
|
||||
void ConnectionValidator::slotStatusFound( const QVariantMap &info )
|
||||
{
|
||||
// status.php was found.
|
||||
qDebug() << "** Application: ownCloud found: " << url << " with version " << versionStr << "(" << version << ")";
|
||||
qDebug() << "** Application: ownCloud found: "
|
||||
<< _account->url() << " with version "
|
||||
<< CheckServerJob::versionString(info)
|
||||
<< "(" << CheckServerJob::version(info) << ")";
|
||||
// now check the authentication
|
||||
MirallConfigFile cfgFile(_connection);
|
||||
|
||||
cfgFile.setOwnCloudVersion( version );
|
||||
// disconnect from ownCloudInfo
|
||||
disconnect( ownCloudInfo::instance(),SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
|
||||
this, SLOT(slotStatusFound(QString,QString,QString,QString)));
|
||||
|
||||
disconnect( ownCloudInfo::instance(),SIGNAL(noOwncloudFound(QNetworkReply*)),
|
||||
this, SLOT(slotNoStatusFound(QNetworkReply*)));
|
||||
|
||||
if( version.startsWith("4.0") ) {
|
||||
if( CheckServerJob::version(info).startsWith("4.0") ) {
|
||||
_errors.append( tr("The configured server for this client is too old") );
|
||||
_errors.append( tr("Please update to the latest server and restart the client.") );
|
||||
emit connectionResult( ServerVersionMismatch );
|
||||
|
@ -126,52 +117,46 @@ void ConnectionValidator::slotStatusFound( const QString& url, const QString& ve
|
|||
}
|
||||
|
||||
// status.php could not be loaded.
|
||||
void ConnectionValidator::slotNoStatusFound(QNetworkReply *reply)
|
||||
void ConnectionValidator::slotNoStatusFound(QNetworkReply::NetworkError error, const QString &errStr)
|
||||
{
|
||||
// disconnect from ownCloudInfo
|
||||
disconnect( ownCloudInfo::instance(),SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
|
||||
this, SLOT(slotStatusFound(QString,QString,QString,QString)));
|
||||
|
||||
disconnect( ownCloudInfo::instance(),SIGNAL(noOwncloudFound(QNetworkReply*)),
|
||||
this, SLOT(slotNoStatusFound(QNetworkReply*)));
|
||||
|
||||
_errors.append(tr("Unable to connect to %1").arg(reply->url().toString()));
|
||||
_errors.append( reply->errorString() );
|
||||
_networkError = (reply->error() != QNetworkReply::NoError);
|
||||
// ### TODO
|
||||
_errors.append(tr("Unable to connect to %1").arg(_account->url().toString()));
|
||||
_errors.append( errStr );
|
||||
_networkError = (error != QNetworkReply::NoError);
|
||||
emit connectionResult( StatusNotFound );
|
||||
|
||||
}
|
||||
|
||||
void ConnectionValidator::slotCheckAuthentication()
|
||||
{
|
||||
connect( ownCloudInfo::instance(), SIGNAL(ownCloudDirExists(QString,QNetworkReply*)),
|
||||
this, SLOT(slotAuthCheck(QString,QNetworkReply*)));
|
||||
|
||||
qDebug() << "# checking for authentication settings.";
|
||||
ownCloudInfo::instance()->getWebDAVPath(QLatin1String("/") ); // this call needs to be authenticated.
|
||||
// simply GET the webdav root, will fail if credentials are wrong.
|
||||
// continue in slotAuthCheck here :-)
|
||||
PropfindJob *propFind = new PropfindJob(_account, "/", QList<QByteArray>() << "getlastmodified", this);
|
||||
connect(propFind, SIGNAL(result(QVariantMap)), SLOT(slotAuthSuccess()));
|
||||
connect(propFind, SIGNAL(networkError(QNetworkReply::NetworkError, QString)),
|
||||
SLOT(slotAuthFailed(QNetworkReply::NetworkError, QString)));
|
||||
qDebug() << "# checking for authentication settings.";
|
||||
}
|
||||
|
||||
void ConnectionValidator::slotAuthCheck( const QString&, QNetworkReply *reply )
|
||||
void ConnectionValidator::slotAuthFailed(QNetworkReply::NetworkError error, const QString& errString)
|
||||
{
|
||||
Status stat = Connected;
|
||||
Status stat = StatusNotFound;
|
||||
|
||||
if( reply->error() == QNetworkReply::AuthenticationRequiredError ||
|
||||
reply->error() == QNetworkReply::OperationCanceledError ) { // returned if the user is wrong.
|
||||
if( error == QNetworkReply::AuthenticationRequiredError ||
|
||||
error == QNetworkReply::OperationCanceledError ) { // returned if the user is wrong.
|
||||
qDebug() << "******** Password is wrong!";
|
||||
_errors << tr("The provided credentials are not correct");
|
||||
stat = CredentialsWrong;
|
||||
} else if( reply->error() != QNetworkReply::NoError ) {
|
||||
_errors << reply->errorString();
|
||||
} else if( error != QNetworkReply::NoError ) {
|
||||
_errors << errString;
|
||||
}
|
||||
|
||||
// disconnect from ownCloud Info signals
|
||||
disconnect( ownCloudInfo::instance(),SIGNAL(ownCloudDirExists(QString,QNetworkReply*)),
|
||||
this,SLOT(slotAuthCheck(QString,QNetworkReply*)));
|
||||
|
||||
emit connectionResult( stat );
|
||||
}
|
||||
|
||||
|
||||
void ConnectionValidator::slotAuthSuccess()
|
||||
{
|
||||
emit connectionResult(Connected);
|
||||
}
|
||||
|
||||
} // namespace Mirall
|
||||
|
|
|
@ -16,17 +16,19 @@
|
|||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
|
||||
class QNetworkReply;
|
||||
#include <QVariantMap>
|
||||
#include <QNetworkReply>
|
||||
|
||||
namespace Mirall {
|
||||
|
||||
class Account;
|
||||
|
||||
class ConnectionValidator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConnectionValidator(QObject *parent = 0);
|
||||
explicit ConnectionValidator(const QString& connection, QObject *parent = 0);
|
||||
explicit ConnectionValidator(Account *account, QObject *parent = 0);
|
||||
|
||||
enum Status {
|
||||
Undefined,
|
||||
|
@ -56,15 +58,16 @@ signals:
|
|||
public slots:
|
||||
|
||||
protected slots:
|
||||
void slotStatusFound( const QString&, const QString&, const QString&, const QString& );
|
||||
void slotNoStatusFound(QNetworkReply *);
|
||||
void slotStatusFound( const QVariantMap &info );
|
||||
void slotNoStatusFound(QNetworkReply::NetworkError error, const QString& errString);
|
||||
|
||||
void slotCheckAuthentication();
|
||||
void slotAuthCheck( const QString& ,QNetworkReply * );
|
||||
void slotAuthFailed(QNetworkReply::NetworkError error, const QString& errString);
|
||||
void slotAuthSuccess();
|
||||
|
||||
private:
|
||||
QStringList _errors;
|
||||
QString _connection;
|
||||
Account *_account;
|
||||
bool _networkError;
|
||||
};
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ QString Folder::remotePath() const
|
|||
QUrl Folder::remoteUrl() const
|
||||
{
|
||||
Account *account = AccountManager::instance()->account();
|
||||
QUrl url = account->url();
|
||||
QUrl url = account->davUrl();
|
||||
QString path = url.path();
|
||||
if (path.endsWith('/')) {
|
||||
path.append('/');
|
||||
|
@ -272,7 +272,7 @@ void Folder::slotPollTimerTimeout()
|
|||
qDebug() << "** Force Sync now";
|
||||
evaluateSync(QStringList());
|
||||
} else {
|
||||
RequestEtagJob* job = new RequestEtagJob(remotePath(), this);
|
||||
RequestEtagJob* job = new RequestEtagJob(AccountManager::instance()->account(), remotePath(), this);
|
||||
// check if the etag is different
|
||||
QObject::connect(job, SIGNAL(etagRetreived(QString)), this, SLOT(etagRetreived(QString)));
|
||||
QObject::connect(job, SIGNAL(networkError()), this, SLOT(slotNetworkUnavailable()));
|
||||
|
|
|
@ -14,9 +14,10 @@
|
|||
|
||||
#include "mirall/folderwizard.h"
|
||||
#include "mirall/folderman.h"
|
||||
#include "mirall/owncloudinfo.h"
|
||||
#include "mirall/mirallconfigfile.h"
|
||||
#include "mirall/theme.h"
|
||||
#include "mirall/networkjobs.h"
|
||||
#include "mirall/account.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
|
@ -176,6 +177,8 @@ FolderWizardTargetPage::FolderWizardTargetPage()
|
|||
connect(_ui.refreshButton, SIGNAL(clicked()), SLOT(slotRefreshFolders()));
|
||||
connect(_ui.folderTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), SIGNAL(completeChanged()));
|
||||
connect(_ui.folderTreeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), SIGNAL(completeChanged()));
|
||||
connect(_ui.folderTreeWidget, SIGNAL(itemExpanded(QTreeWidgetItem*)), SLOT(slotItemExpanded(QTreeWidgetItem*)));
|
||||
|
||||
}
|
||||
|
||||
void FolderWizardTargetPage::slotAddRemoteFolder()
|
||||
|
@ -199,21 +202,26 @@ void FolderWizardTargetPage::slotAddRemoteFolder()
|
|||
void FolderWizardTargetPage::slotCreateRemoteFolder(QString folder)
|
||||
{
|
||||
if( folder.isEmpty() ) return;
|
||||
ownCloudInfo::instance()->mkdirRequest( folder );
|
||||
|
||||
MkColJob *job = new MkColJob(AccountManager::instance()->account(), folder, this);
|
||||
/* check the owncloud configuration file and query the ownCloud */
|
||||
connect(job, SIGNAL(finished()), SLOT(slotCreateRemoteFolderFinished()));
|
||||
connect(job, SIGNAL(networkError(QNetworkReply::NetworkError,QString)),
|
||||
SLOT(slotHandleNetworkError(QNetworkReply::NetworkError,QString)));
|
||||
}
|
||||
|
||||
void FolderWizardTargetPage::slotCreateRemoteFolderFinished( QNetworkReply::NetworkError error )
|
||||
void FolderWizardTargetPage::slotCreateRemoteFolderFinished()
|
||||
{
|
||||
qDebug() << "** webdav mkdir request finished " << error;
|
||||
|
||||
// the webDAV server seems to return a 202 even if mkdir was successful.
|
||||
if( error == QNetworkReply::NoError ||
|
||||
error == QNetworkReply::ContentOperationNotPermittedError) {
|
||||
showWarn( tr("Folder was successfully created on %1.").arg( Theme::instance()->appNameGUI() ) );
|
||||
qDebug() << "** webdav mkdir request finished";
|
||||
showWarn(tr("Folder was successfully created on %1.").arg(Theme::instance()->appNameGUI()));
|
||||
slotRefreshFolders();
|
||||
} else {
|
||||
showWarn( tr("Failed to create the folder on %1.<br/>Please check manually.").arg( Theme::instance()->appNameGUI() ) );
|
||||
}
|
||||
}
|
||||
|
||||
void FolderWizardTargetPage::slotHandleNetworkError(QNetworkReply::NetworkError, const QString& error)
|
||||
{
|
||||
qDebug() << "** webdav mkdir request failed:" << error;
|
||||
showWarn(tr("Failed to create the folder on %1.<br/>Please check manually.")
|
||||
.arg(Theme::instance()->appNameGUI()));
|
||||
}
|
||||
|
||||
static QTreeWidgetItem* findFirstChild(QTreeWidgetItem *parent, const QString& text)
|
||||
|
@ -254,7 +262,7 @@ static void recursiveInsert(QTreeWidgetItem *parent, QStringList pathTrail, QStr
|
|||
|
||||
void FolderWizardTargetPage::slotUpdateDirectories(QStringList list)
|
||||
{
|
||||
QString webdavFolder = QUrl(ownCloudInfo::instance()->webdavUrl()).path();
|
||||
QString webdavFolder = QUrl(AccountManager::instance()->account()->davUrl()).path();
|
||||
|
||||
QTreeWidgetItem *root = _ui.folderTreeWidget->topLevelItem(0);
|
||||
if (!root) {
|
||||
|
@ -275,13 +283,18 @@ void FolderWizardTargetPage::slotUpdateDirectories(QStringList list)
|
|||
|
||||
void FolderWizardTargetPage::slotRefreshFolders()
|
||||
{
|
||||
ownCloudInfo::instance()->getDirectoryListing("/");
|
||||
LsColJob *job = new LsColJob(AccountManager::instance()->account(), "/", this);
|
||||
connect(job, SIGNAL(directoryListingUpdated(QStringList)),
|
||||
SLOT(slotUpdateDirectories(QStringList)));
|
||||
_ui.folderTreeWidget->clear();
|
||||
}
|
||||
|
||||
void FolderWizardTargetPage::slotItemExpanded(QTreeWidgetItem *item)
|
||||
{
|
||||
ownCloudInfo::instance()->getDirectoryListing(item->data(0, Qt::UserRole).toString());
|
||||
QString dir = item->data(0, Qt::UserRole).toString();
|
||||
LsColJob *job = new LsColJob(AccountManager::instance()->account(), dir, this);
|
||||
connect(job, SIGNAL(directoryListingUpdated(QStringList)),
|
||||
SLOT(slotUpdateDirectories(QStringList)));
|
||||
}
|
||||
|
||||
FolderWizardTargetPage::~FolderWizardTargetPage()
|
||||
|
@ -329,21 +342,7 @@ void FolderWizardTargetPage::cleanupPage()
|
|||
void FolderWizardTargetPage::initializePage()
|
||||
{
|
||||
showWarn();
|
||||
|
||||
/* check the owncloud configuration file and query the ownCloud */
|
||||
ownCloudInfo *ocInfo = ownCloudInfo::instance();
|
||||
if( ocInfo->isConfigured() ) {
|
||||
connect( ocInfo, SIGNAL(ownCloudDirExists(QString,QNetworkReply*)),
|
||||
SLOT(slotDirCheckReply(QString,QNetworkReply*)));
|
||||
connect( ocInfo, SIGNAL(webdavColCreated(QNetworkReply::NetworkError)),
|
||||
SLOT(slotCreateRemoteFolderFinished( QNetworkReply::NetworkError )));
|
||||
connect( ocInfo, SIGNAL(directoryListingUpdated(QStringList)),
|
||||
SLOT(slotUpdateDirectories(QStringList)));
|
||||
connect(_ui.folderTreeWidget, SIGNAL(itemExpanded(QTreeWidgetItem*)),
|
||||
SLOT(slotItemExpanded(QTreeWidgetItem*)));
|
||||
|
||||
slotRefreshFolders();
|
||||
}
|
||||
}
|
||||
|
||||
void FolderWizardTargetPage::showWarn( const QString& msg ) const
|
||||
|
|
|
@ -76,7 +76,8 @@ protected slots:
|
|||
void showWarn( const QString& = QString() ) const;
|
||||
void slotAddRemoteFolder();
|
||||
void slotCreateRemoteFolder(QString);
|
||||
void slotCreateRemoteFolderFinished( QNetworkReply::NetworkError error );
|
||||
void slotCreateRemoteFolderFinished();
|
||||
void slotHandleNetworkError(QNetworkReply::NetworkError, const QString& error);
|
||||
void slotUpdateDirectories(QStringList);
|
||||
void slotRefreshFolders();
|
||||
void slotItemExpanded(QTreeWidgetItem*);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <QBuffer>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QStringList>
|
||||
#include <QStack>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
@ -28,10 +29,11 @@
|
|||
|
||||
namespace Mirall {
|
||||
|
||||
AbstractNetworkJob::AbstractNetworkJob(QObject *parent)
|
||||
AbstractNetworkJob::AbstractNetworkJob(Account *account, const QString &path, QObject *parent)
|
||||
: QObject(parent)
|
||||
, _reply(0)
|
||||
, _account(AccountManager::instance()->account())
|
||||
, _account(account)
|
||||
, _path(path)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -52,6 +54,11 @@ void AbstractNetworkJob::setAccount(Account *account)
|
|||
_account = account;
|
||||
}
|
||||
|
||||
void AbstractNetworkJob::setPath(const QString &path)
|
||||
{
|
||||
_path = path;
|
||||
}
|
||||
|
||||
void AbstractNetworkJob::slotError()
|
||||
{
|
||||
qDebug() << metaObject()->className() << "Error:" << _reply->errorString();
|
||||
|
@ -64,18 +71,20 @@ void AbstractNetworkJob::setupConnections(QNetworkReply *reply)
|
|||
connect( reply, SIGNAL( finished()), SLOT(slotFinished()) );
|
||||
connect( reply, SIGNAL(error(QNetworkReply::NetworkError)),
|
||||
this, SLOT(slotError()));
|
||||
connect( reply, SIGNAL(error(QNetworkReply::NetworkError)),
|
||||
ownCloudInfo::instance(), SLOT(slotError(QNetworkReply::NetworkError)));
|
||||
|
||||
// connect( reply, SIGNAL(error(QNetworkReply::NetworkError)),
|
||||
// ownCloudInfo::instance(), SLOT(slotError(QNetworkReply::NetworkError)));
|
||||
}
|
||||
|
||||
QNetworkReply* AbstractNetworkJob::davRequest(const QByteArray &verb, QNetworkRequest &req, QIODevice *data)
|
||||
QNetworkReply* AbstractNetworkJob::davRequest(const QByteArray &verb, const QString &relPath,
|
||||
QNetworkRequest req, QIODevice *data)
|
||||
{
|
||||
return _account->davRequest(verb, req, data);
|
||||
return _account->davRequest(verb, relPath, req, data);
|
||||
}
|
||||
|
||||
QNetworkReply* AbstractNetworkJob::getRequest(const QUrl &url)
|
||||
QNetworkReply* AbstractNetworkJob::getRequest(const QString &relPath)
|
||||
{
|
||||
return _account->getRequest(url);
|
||||
return _account->getRequest(relPath);
|
||||
}
|
||||
|
||||
AbstractNetworkJob::~AbstractNetworkJob() {
|
||||
|
@ -84,11 +93,11 @@ AbstractNetworkJob::~AbstractNetworkJob() {
|
|||
|
||||
/*********************************************************************************************/
|
||||
|
||||
RequestEtagJob::RequestEtagJob(const QUrl &url, bool isRoot, QObject *parent)
|
||||
: AbstractNetworkJob(parent)
|
||||
RequestEtagJob::RequestEtagJob(Account *account, const QString &path, QObject *parent)
|
||||
: AbstractNetworkJob(account, path, parent)
|
||||
{
|
||||
QNetworkRequest req(url);
|
||||
if (isRoot) {
|
||||
QNetworkRequest req;
|
||||
if (path.isEmpty() || path == QLatin1String("/")) {
|
||||
/* For the root directory, we need to query the etags of all the sub directories
|
||||
* because, at the time I am writing this comment (Owncloud 5.0.9), the etag of the
|
||||
* root directory is not updated when the sub directories changes */
|
||||
|
@ -99,14 +108,14 @@ RequestEtagJob::RequestEtagJob(const QUrl &url, bool isRoot, QObject *parent)
|
|||
QByteArray xml("<?xml version=\"1.0\" ?>\n"
|
||||
"<d:propfind xmlns:d=\"DAV:\">\n"
|
||||
" <d:prop>\n"
|
||||
" <d:getetag/>"
|
||||
" <d:getetag/>\n"
|
||||
" </d:prop>\n"
|
||||
"</d:propfind>\n");
|
||||
QBuffer *buf = new QBuffer;
|
||||
buf->setData(xml);
|
||||
buf->open(QIODevice::ReadOnly);
|
||||
// assumes ownership
|
||||
setReply(davRequest("PROPFIND", req, buf));
|
||||
setReply(davRequest("PROPFIND", path, req, buf));
|
||||
buf->setParent(reply());
|
||||
setupConnections(reply());
|
||||
|
||||
|
@ -140,12 +149,11 @@ void RequestEtagJob::slotFinished()
|
|||
|
||||
/*********************************************************************************************/
|
||||
|
||||
MkColJob::MkColJob(const QUrl &url, QObject* parent)
|
||||
: AbstractNetworkJob(parent)
|
||||
MkColJob::MkColJob(Account *account, const QString &path, QObject *parent)
|
||||
: AbstractNetworkJob(account, path, parent)
|
||||
{
|
||||
QNetworkRequest req(url);
|
||||
// assumes ownership
|
||||
QNetworkReply *reply = davRequest("MKCOL", req, 0);
|
||||
QNetworkReply *reply = davRequest("MKCOL", path);
|
||||
setReply(reply);
|
||||
setupConnections(reply);
|
||||
}
|
||||
|
@ -160,10 +168,10 @@ void MkColJob::slotFinished()
|
|||
|
||||
/*********************************************************************************************/
|
||||
|
||||
LsColJob::LsColJob(const QUrl &url, QObject* parent)
|
||||
: AbstractNetworkJob(parent)
|
||||
LsColJob::LsColJob(Account *account, const QString &path, QObject *parent)
|
||||
: AbstractNetworkJob(account, path, parent)
|
||||
{
|
||||
QNetworkRequest req(url);
|
||||
QNetworkRequest req;
|
||||
req.setRawHeader("Depth", "1");
|
||||
QByteArray xml("<?xml version=\"1.0\" ?>\n"
|
||||
"<d:propfind xmlns:d=\"DAV:\">\n"
|
||||
|
@ -174,7 +182,7 @@ LsColJob::LsColJob(const QUrl &url, QObject* parent)
|
|||
QBuffer *buf = new QBuffer;
|
||||
buf->setData(xml);
|
||||
buf->open(QIODevice::ReadOnly);
|
||||
QNetworkReply *reply = davRequest("PROPFIND", req, buf);
|
||||
QNetworkReply *reply = davRequest("PROPFIND", path, req, buf);
|
||||
buf->setParent(reply);
|
||||
setReply(reply);
|
||||
setupConnections(reply);
|
||||
|
@ -212,15 +220,32 @@ void LsColJob::slotFinished()
|
|||
|
||||
/*********************************************************************************************/
|
||||
|
||||
CheckOwncloudJob::CheckOwncloudJob(const QUrl &url, bool followRedirect, QObject *parent)
|
||||
: AbstractNetworkJob(parent), _followRedirects(followRedirect), _redirectCount(0)
|
||||
CheckServerJob::CheckServerJob(Account *account, bool followRedirect, QObject *parent)
|
||||
: AbstractNetworkJob(account, QLatin1String("/status.php") , parent)
|
||||
, _followRedirects(followRedirect)
|
||||
, _redirectCount(0)
|
||||
{
|
||||
// ### perform update of certificate chain
|
||||
setReply(getRequest(url));
|
||||
setReply(getRequest(path()));
|
||||
setupConnections(reply());
|
||||
}
|
||||
|
||||
void CheckOwncloudJob::slotFinished()
|
||||
QString CheckServerJob::version(const QVariantMap &info)
|
||||
{
|
||||
return info.value(QLatin1String("version")).toString();
|
||||
}
|
||||
|
||||
QString CheckServerJob::versionString(const QVariantMap &info)
|
||||
{
|
||||
return info.value(QLatin1String("versionstring")).toString();
|
||||
}
|
||||
|
||||
bool CheckServerJob::installed(const QVariantMap &info)
|
||||
{
|
||||
return info.value(QLatin1String("installed")).toBool();
|
||||
}
|
||||
|
||||
void CheckServerJob::slotFinished()
|
||||
{
|
||||
// ### this should no longer be needed
|
||||
if( reply()->error() == QNetworkReply::NoError && reply()->size() == 0 ) {
|
||||
|
@ -246,7 +271,8 @@ void CheckOwncloudJob::slotFinished()
|
|||
qDebug() << Q_FUNC_INFO << "Redirect loop detected!";
|
||||
} else {
|
||||
takeReply()->deleteLater();
|
||||
setReply(getRequest(redirectUrl));
|
||||
// ### FIXME
|
||||
//setReply(getRequest(redirectUrl));
|
||||
setupConnections(reply());
|
||||
return;
|
||||
}
|
||||
|
@ -270,30 +296,37 @@ void CheckOwncloudJob::slotFinished()
|
|||
deleteLater();
|
||||
}
|
||||
|
||||
CheckQuotaJob::CheckQuotaJob(const QUrl &url, QObject *parent)
|
||||
: AbstractNetworkJob(parent)
|
||||
PropfindJob::PropfindJob(Account *account, const QString &path,
|
||||
QList<QByteArray> properties,
|
||||
QObject *parent)
|
||||
: AbstractNetworkJob(account, path, parent)
|
||||
{
|
||||
QNetworkRequest req(url);
|
||||
if (properties.isEmpty()) {
|
||||
properties << "allprop";
|
||||
}
|
||||
QNetworkRequest req;
|
||||
req.setRawHeader("Depth", "0");
|
||||
QByteArray xml("<?xml version=\"1.0\" ?>\n"
|
||||
QByteArray propStr;
|
||||
foreach (const QByteArray &prop, properties) {
|
||||
propStr += " <d:" + prop + " />\n";
|
||||
}
|
||||
QByteArray xml = "<?xml version=\"1.0\" ?>\n"
|
||||
"<d:propfind xmlns:d=\"DAV:\">\n"
|
||||
" <d:prop>\n"
|
||||
" <d:quota-available-bytes/>\n"
|
||||
" <d:quota-used-bytes/>\n"
|
||||
" <d:getetag/>"
|
||||
+ propStr +
|
||||
" </d:prop>\n"
|
||||
"</d:propfind>\n");
|
||||
"</d:propfind>\n";
|
||||
|
||||
QBuffer *buf = new QBuffer;
|
||||
buf->setData(xml);
|
||||
buf->open(QIODevice::ReadOnly);
|
||||
setReply(davRequest("PROPFIND", req, buf));
|
||||
setReply(davRequest("PROPFIND", path, req, buf));
|
||||
buf->setParent(reply());
|
||||
setupConnections(reply());
|
||||
}
|
||||
|
||||
void CheckQuotaJob::slotFinished()
|
||||
void PropfindJob::slotFinished()
|
||||
{
|
||||
bool ok = true;
|
||||
int http_result_code = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
|
||||
if (http_result_code == 207) {
|
||||
|
@ -301,26 +334,28 @@ void CheckQuotaJob::slotFinished()
|
|||
QXmlStreamReader reader(reply());
|
||||
reader.addExtraNamespaceDeclaration(QXmlStreamNamespaceDeclaration("d", "DAV:"));
|
||||
|
||||
qint64 quotaUsedBytes = 0;
|
||||
qint64 quotaAvailableBytes = 0;
|
||||
QVariantMap items;
|
||||
// introduced to nesting is ignored
|
||||
QStack<QString> curElement;
|
||||
|
||||
while (!reader.atEnd()) {
|
||||
QXmlStreamReader::TokenType type = reader.readNext();
|
||||
if (type == QXmlStreamReader::StartElement &&
|
||||
reader.namespaceUri() == QLatin1String("DAV:")) {
|
||||
QString name = reader.name().toString();
|
||||
if (name == QLatin1String("quota-used-bytes")) {
|
||||
quotaUsedBytes = reader.readElementText().toLongLong(&ok);
|
||||
if (!ok) quotaUsedBytes = 0;
|
||||
} else if (name == QLatin1String("quota-available-bytes")) {
|
||||
quotaAvailableBytes = reader.readElementText().toLongLong(&ok);
|
||||
if (!ok) quotaAvailableBytes = 0;
|
||||
if (curElement.isEmpty()) {
|
||||
curElement.push(reader.name().toString());
|
||||
items.insert(reader.name().toString(), reader.text().toString());
|
||||
}
|
||||
}
|
||||
if (type == QXmlStreamReader::EndElement &&
|
||||
reader.namespaceUri() == QLatin1String("DAV:")) {
|
||||
if(curElement.top() == reader.name()) {
|
||||
curElement.pop();
|
||||
}
|
||||
}
|
||||
|
||||
qint64 total = quotaUsedBytes + quotaAvailableBytes;
|
||||
emit quotaRetreived(total, quotaUsedBytes);
|
||||
}
|
||||
emit result(items);
|
||||
} else {
|
||||
qDebug() << "Quota request *not* successful, http result code is " << http_result_code;
|
||||
}
|
||||
|
|
|
@ -32,11 +32,13 @@ class Account;
|
|||
class AbstractNetworkJob : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AbstractNetworkJob(QObject* parent = 0);
|
||||
explicit AbstractNetworkJob(Account *account, const QString &path, QObject* parent = 0);
|
||||
virtual ~AbstractNetworkJob();
|
||||
|
||||
void setAccount(Account *account);
|
||||
Account* account() const { return _account; }
|
||||
void setPath(const QString &path);
|
||||
QString path() const { return _path; }
|
||||
|
||||
void setReply(QNetworkReply *reply);
|
||||
QNetworkReply* reply() const { return _reply; }
|
||||
|
@ -47,8 +49,10 @@ signals:
|
|||
|
||||
protected:
|
||||
void setupConnections(QNetworkReply *reply);
|
||||
QNetworkReply* davRequest(const QByteArray& verb, QNetworkRequest& req, QIODevice *data);
|
||||
QNetworkReply* getRequest(const QUrl& url);
|
||||
QNetworkReply* davRequest(const QByteArray& verb, const QString &relPath,
|
||||
QNetworkRequest req = QNetworkRequest(),
|
||||
QIODevice *data = 0);
|
||||
QNetworkReply* getRequest(const QString &relPath);
|
||||
|
||||
private slots:
|
||||
virtual void slotFinished() = 0;
|
||||
|
@ -57,6 +61,7 @@ private slots:
|
|||
private:
|
||||
QNetworkReply *_reply;
|
||||
Account *_account;
|
||||
QString _path;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -65,7 +70,7 @@ private:
|
|||
class LsColJob : public AbstractNetworkJob {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LsColJob(const QUrl& url, QObject* parent = 0);
|
||||
explicit LsColJob(Account *account, const QString &path, QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
void directoryListing(const QStringList &items);
|
||||
|
@ -75,10 +80,30 @@ private slots:
|
|||
virtual void slotFinished();
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The CheckQuotaJob class
|
||||
*/
|
||||
class PropfindJob : public AbstractNetworkJob {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PropfindJob(Account *account, const QString &path,
|
||||
QList<QByteArray> properties,
|
||||
QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
void result(const QVariantMap &values);
|
||||
|
||||
private slots:
|
||||
virtual void slotFinished();
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The MkColJob class
|
||||
*/
|
||||
class MkColJob : public AbstractNetworkJob {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MkColJob(const QUrl& url, QObject* parent = 0);
|
||||
explicit MkColJob(Account *account, const QString &path, QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
|
@ -91,10 +116,14 @@ private slots:
|
|||
/**
|
||||
* @brief The CheckOwncloudJob class
|
||||
*/
|
||||
class CheckOwncloudJob : public AbstractNetworkJob {
|
||||
class CheckServerJob : public AbstractNetworkJob {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CheckOwncloudJob(const QUrl& url, bool followRedirect = false, QObject* parent = 0);
|
||||
explicit CheckServerJob(Account *account, bool followRedirect = false, QObject *parent = 0);
|
||||
|
||||
static QString version(const QVariantMap &info);
|
||||
static QString versionString(const QVariantMap &info);
|
||||
static bool installed(const QVariantMap &info);
|
||||
|
||||
signals:
|
||||
void instanceFound(const QVariantMap &info);
|
||||
|
@ -117,7 +146,7 @@ private:
|
|||
class RequestEtagJob : public AbstractNetworkJob {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RequestEtagJob(const QUrl &url, bool isRoot = false, QObject* parent = 0);
|
||||
explicit RequestEtagJob(Account *account, const QString &path, QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
void etagRetreived(const QString &etag);
|
||||
|
@ -126,21 +155,6 @@ private slots:
|
|||
virtual void slotFinished();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief The CheckQuotaJob class
|
||||
*/
|
||||
class CheckQuotaJob : public AbstractNetworkJob {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CheckQuotaJob(const QUrl &url, QObject* parent = 0);
|
||||
|
||||
signals:
|
||||
void quotaRetreived(qint64 total, qint64 quotaUsedBytes);
|
||||
|
||||
private slots:
|
||||
virtual void slotFinished();
|
||||
};
|
||||
} // namespace Mirall
|
||||
|
||||
#endif // NETWORKJOBS_H
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "mirall/owncloudgui.h"
|
||||
#include "mirall/theme.h"
|
||||
#include "mirall/folderman.h"
|
||||
#include "mirall/owncloudinfo.h"
|
||||
#include "mirall/mirallconfigfile.h"
|
||||
#include "mirall/utility.h"
|
||||
#include "mirall/progressdispatcher.h"
|
||||
|
@ -23,6 +22,7 @@
|
|||
#include "mirall/settingsdialog.h"
|
||||
#include "mirall/logger.h"
|
||||
#include "mirall/logbrowser.h"
|
||||
#include "mirall/account.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QMessageBox>
|
||||
|
@ -91,7 +91,8 @@ bool ownCloudGui::checkConfigExists(bool openSettings)
|
|||
return true;
|
||||
} else {
|
||||
qDebug() << "No configured folders yet, starting setup wizard";
|
||||
OwncloudSetupWizard::runWizard(this, SLOT(slotownCloudWizardDone(int)));
|
||||
//### TODO
|
||||
//OwncloudSetupWizard::runWizard(this, SLOT(slotownCloudWizardDone(int)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -202,9 +203,9 @@ void ownCloudGui::slotComputeOverallSyncStatus()
|
|||
|
||||
void ownCloudGui::setupContextMenu()
|
||||
{
|
||||
bool isConfigured = ownCloudInfo::instance()->isConfigured();
|
||||
FolderMan *folderMan = FolderMan::instance();
|
||||
|
||||
bool isConfigured = (AccountManager::instance()->account() != 0);
|
||||
_actionOpenoC->setEnabled(isConfigured);
|
||||
|
||||
if( _contextMenu ) {
|
||||
|
@ -327,8 +328,9 @@ void ownCloudGui::setupActions()
|
|||
_actionQuit = new QAction(tr("Quit %1").arg(Theme::instance()->appNameGUI()), this);
|
||||
QObject::connect(_actionQuit, SIGNAL(triggered(bool)), _app, SLOT(quit()));
|
||||
|
||||
connect( ownCloudInfo::instance(), SIGNAL(quotaUpdated(qint64,qint64)),
|
||||
SLOT(slotRefreshQuotaDisplay(qint64, qint64)));
|
||||
// ### TODO
|
||||
// connect( ownCloudInfo::instance(), SIGNAL(quotaUpdated(qint64,qint64)),
|
||||
// SLOT(slotRefreshQuotaDisplay(qint64, qint64)));
|
||||
}
|
||||
|
||||
void ownCloudGui::slotRefreshQuotaDisplay( qint64 total, qint64 used )
|
||||
|
|
|
@ -23,10 +23,12 @@
|
|||
#include "wizard/owncloudwizard.h"
|
||||
#include "mirall/owncloudsetupwizard.h"
|
||||
#include "mirall/mirallconfigfile.h"
|
||||
#include "mirall/owncloudinfo.h"
|
||||
#include "mirall/folderman.h"
|
||||
#include "mirall/utility.h"
|
||||
#include "mirall/mirallaccessmanager.h"
|
||||
#include "mirall/account.h"
|
||||
#include "mirall/networkjobs.h"
|
||||
|
||||
#include "creds/abstractcredentials.h"
|
||||
#include "creds/dummycredentials.h"
|
||||
|
||||
|
@ -80,11 +82,14 @@ void OwncloudSetupWizard::startWizard()
|
|||
{
|
||||
// Set useful default values.
|
||||
MirallConfigFile cfgFile;
|
||||
|
||||
Account *account = AccountManager::instance()->account();
|
||||
|
||||
_ocWizard->setConfigExists( account != 0 );
|
||||
// Fill the entry fields with existing values.
|
||||
QString url = cfgFile.ownCloudUrl();
|
||||
QString url = account->url();
|
||||
//QString user = cfgFile.ownCloudUser();
|
||||
bool configExists = !( url.isEmpty()/* || user.isEmpty()*/ );
|
||||
_ocWizard->setConfigExists( configExists );
|
||||
|
||||
if( !url.isEmpty() ) {
|
||||
_ocWizard->setOCUrl( url );
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include <QDir>
|
||||
#include <QApplication>
|
||||
|
||||
#include "mirall/utility.h"
|
||||
|
||||
namespace Mirall {
|
||||
|
||||
#define DEBUG qDebug() << "SocketApi: "
|
||||
|
@ -38,7 +40,13 @@ SocketApi::SocketApi(QObject* parent, const QUrl& localFile)
|
|||
: QObject(parent)
|
||||
, _localServer(0)
|
||||
{
|
||||
QString socketPath = localFile.toLocalFile();
|
||||
QString socketPath;
|
||||
if (Utility::isWindows()) {
|
||||
socketPath = QLatin1String("\\\\.\\pipe\\");
|
||||
} else {
|
||||
socketPath = localFile.toLocalFile();
|
||||
|
||||
}
|
||||
DEBUG << "ctor: " << socketPath;
|
||||
|
||||
// setup socket
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "mirall/mirallconfigfile.h"
|
||||
#include "mirall/utility.h"
|
||||
#include "mirall/sslerrordialog.h"
|
||||
#include "mirall/owncloudinfo.h"
|
||||
|
||||
#include <QtGui>
|
||||
#include <QtNetwork>
|
||||
|
|
Loading…
Reference in a new issue