Comparar commits

..

4 Commits

Autor SHA1 Mensagem Data
Piotr M 7fd00b2cd5 add server capabilities to owncloudcmd 2016-09-12 14:43:40 +02:00
Olivier Goffart 1d09f6b60f Allow to disable Shiboleth to build without QtWebkit (#5166) 2016-09-11 16:14:08 +02:00
Olivier Goffart 98268d102f ExcludeFiles: Fix when the folder casing is not the same in the settings and in the FS
If the folder has different case in the settings and in the FS, we should
not ignore all the files. This is important for the files system watcher.
2016-09-11 12:12:10 +02:00
Olivier Goffart 9e895a6ecc FolderStatusModel: Fix beginInsertRow/endInsertRow
We need to do the change between the begin and the end call so the selection
don't get broken
2016-09-11 12:12:10 +02:00
21 arquivos alterados com 268 adições e 680 exclusões
+7
Ver Arquivo
@@ -136,6 +136,13 @@ if(OWNCLOUD_RESTORE_RENAME)
add_definitions(-DOWNCLOUD_RESTORE_RENAME=1)
endif()
# Disable shibboleth.
# So the client can be built without QtWebKit
option(NO_SHIBBOLETH "Build without Shibboleth support. Allow to build the client without QtWebKit" OFF)
if(NO_SHIBBOLETH)
message("Compiling without shibboleth")
add_definitions(-DNO_SHIBBOLETH=1)
endif()
if(APPLE)
set( SOCKETAPI_TEAM_IDENTIFIER_PREFIX "" CACHE STRING "SocketApi prefix (including a following dot) that must match the codesign key's TeamIdentifier/Organizational Unit" )
+8 -2
Ver Arquivo
@@ -22,12 +22,18 @@ if( Qt5Core_FOUND )
find_package(Qt5Test REQUIRED)
endif()
if(NOT TOKEN_AUTH_ONLY)
find_package(Qt5WebKitWidgets REQUIRED)
find_package(Qt5WebKit REQUIRED)
find_package(Qt5Widgets REQUIRED)
if(APPLE)
find_package(Qt5MacExtras REQUIRED)
endif(APPLE)
if(NOT NO_SHIBBOLETH)
find_package(Qt5WebKitWidgets)
find_package(Qt5WebKit)
if(NOT Qt5WebKitWidgets_FOUND)
message(FATAL_ERROR "Qt5WebKit required for Shibboleth. Use -DNO_SHIBBOLETH=1 to disable it.")
endif()
endif()
endif()
else( Qt5Core_FOUND )
+20
Ver Arquivo
@@ -29,6 +29,7 @@
#include "syncengine.h"
#include "syncjournaldb.h"
#include "config.h"
#include "connectionvalidator.h"
#include "cmd.h"
@@ -68,6 +69,8 @@ struct CmdOptions {
// So we have to use a global variable
CmdOptions *opts = 0;
const qint64 timeoutToUseMsec = qMax(1000, ConnectionValidator::DefaultCallingIntervalMsec - 5*1000);
class EchoDisabler
{
public:
@@ -388,6 +391,23 @@ int main(int argc, char **argv) {
account->setCredentials(cred);
account->setSslErrorHandler(sslErrorHandler);
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
//obtain capabilities using event loop
QEventLoop loop;
JsonApiJob *job = new JsonApiJob(account, QLatin1String("ocs/v1.php/cloud/capabilities"));
job->setTimeout(timeoutToUseMsec);
QObject::connect(job, &JsonApiJob::jsonReceived, [&](const QVariantMap &json) {
auto caps = json.value("ocs").toMap().value("data").toMap().value("capabilities");
qDebug() << "Server capabilities" << caps;
account->setCapabilities(caps.toMap());
loop.quit();
});
job->start();
loop.exec();
#endif
// much lower age than the default since this utility is usually made to be run right after a change in the tests
SyncEngine::minimumFileAgeForUpload = 0;
+13 -7
Ver Arquivo
@@ -68,7 +68,6 @@ set(client_SRCS
activitylistmodel.cpp
activitywidget.cpp
activityitemdelegate.cpp
activityfetcher.cpp
selectivesyncdialog.cpp
settingsdialog.cpp
share.cpp
@@ -95,22 +94,26 @@ set(client_SRCS
servernotificationhandler.cpp
creds/credentialsfactory.cpp
creds/httpcredentialsgui.cpp
creds/shibbolethcredentials.cpp
creds/shibboleth/shibbolethwebview.cpp
creds/shibboleth/shibbolethuserjob.cpp
wizard/postfixlineedit.cpp
wizard/abstractcredswizardpage.cpp
wizard/owncloudadvancedsetuppage.cpp
wizard/owncloudconnectionmethoddialog.cpp
wizard/owncloudhttpcredspage.cpp
wizard/owncloudsetuppage.cpp
wizard/owncloudshibbolethcredspage.cpp
wizard/owncloudwizardcommon.cpp
wizard/owncloudwizard.cpp
wizard/owncloudwizardresultpage.cpp
../3rdparty/qjson/json.cpp
)
IF(NOT NO_SHIBBOLETH)
list(APPEND client_SRCS
creds/shibbolethcredentials.cpp
creds/shibboleth/shibbolethwebview.cpp
creds/shibboleth/shibbolethuserjob.cpp
wizard/owncloudshibbolethcredspage.cpp
)
endif()
set(updater_SRCS
updater/ocupdater.cpp
@@ -233,6 +236,9 @@ set(ownCloud ${ownCloud_old})
if (WITH_DBUS)
set(ADDITIONAL_APP_MODULES DBus)
endif(WITH_DBUS)
if (NOT NO_SHIBBOLETH)
list(APPEND ADDITIONAL_APP_MODULES WebKitWidgets)
endif()
if(NOT BUILD_OWNCLOUD_OSX_BUNDLE)
@@ -251,14 +257,14 @@ if(NOT BUILD_OWNCLOUD_OSX_BUNDLE)
# add_executable( ${APPLICATION_EXECUTABLE} main.cpp ${final_src})
add_executable( ${APPLICATION_EXECUTABLE} WIN32 main.cpp ${final_src})
qt5_use_modules(${APPLICATION_EXECUTABLE} Widgets Network Xml WebKitWidgets Sql ${ADDITIONAL_APP_MODULES})
qt5_use_modules(${APPLICATION_EXECUTABLE} Widgets Network Xml Sql ${ADDITIONAL_APP_MODULES})
else()
# set(CMAKE_INSTALL_PREFIX ".") # Examples use /Applications. hurmpf.
set(MACOSX_BUNDLE_ICON_FILE "ownCloud.icns")
# we must add MACOSX_BUNDLE only if building a bundle
add_executable( ${APPLICATION_EXECUTABLE} WIN32 MACOSX_BUNDLE main.cpp ${final_src})
qt5_use_modules(${APPLICATION_EXECUTABLE} Widgets Network Xml WebKitWidgets Sql ${ADDITIONAL_APP_MODULES})
qt5_use_modules(${APPLICATION_EXECUTABLE} Widgets Network Xml Sql ${ADDITIONAL_APP_MODULES})
set (QM_DIR ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/Translations)
install(FILES ${client_I18N} DESTINATION ${QM_DIR})
+1 -70
Ver Arquivo
@@ -15,45 +15,10 @@
#include "activitydata.h"
namespace OCC
{
ActivityFile::ActivityFile()
:_type(Unknown)
{
}
ActivityFile::ActivityFile( const QString& file )
:_relFileName(file),
_type(File)
{
}
void ActivityFile::setType( FileType type )
{
_type = type;
}
QString ActivityFile::relativePath() const
{
return _relFileName;
}
QString ActivityFile::fullPath( const QString _accountName ) const
{
QString fullPath(_relFileName);
// FIXME: get the account and prepend the base path.
if( _type == Directory && !fullPath.endsWith('/')) {
fullPath.append('/');
}
return fullPath;
}
/* ==================================================================== */
bool operator<( const Activity& rhs, const Activity& lhs ) {
return rhs._dateTime.toMSecsSinceEpoch() > lhs._dateTime.toMSecsSinceEpoch();
}
@@ -66,39 +31,5 @@ Activity::Identifier Activity::ident() const {
return Identifier( _id, _accName );
}
void Activity::addFile( const QString& file )
{
ActivityFile f(file);
_files.append(f);
}
void Activity::addDirectory( const QString& dir )
{
ActivityFile f(dir);
f.setType(ActivityFile::Directory);
_files.append(f);
}
QVector<ActivityFile> Activity::files()
{
return _files;
}
/* ==================================================================== */
ActivityList::ActivityList()
{
}
void ActivityList::setAccountState(AccountState *ast)
{
_ast = ast;
}
AccountState* ActivityList::accountState()
{
return _ast;
}
}
+1 -52
Ver Arquivo
@@ -16,8 +16,6 @@
#include <QtCore>
#include "accountstate.h"
namespace OCC {
/**
* @brief The ActivityLink class describes actions of an activity
@@ -35,32 +33,6 @@ public:
};
/* ==================================================================== */
/**
* @brief ActivityFile Structure
* @ingroup gui
*
* contains information about a file of an activity.
* Can handle the thumbnail and stuff later.
*/
class ActivityFile
{
public:
enum FileType {Unknown, File, Directory};
explicit ActivityFile();
explicit ActivityFile( const QString& file );
void setType( FileType type );
QString relativePath() const;
QString fullPath( const QString _accountName ) const;
private:
QString _relFileName;
FileType _type;
};
/* ==================================================================== */
/**
* @brief Activity Structure
* @ingroup gui
@@ -78,11 +50,6 @@ public:
NotificationType
};
void addFile( const QString& file );
void addDirectory( const QString& dir );
QVector<ActivityFile> files();
Type _type;
qlonglong _id;
QString _subject;
@@ -101,10 +68,6 @@ public:
Identifier ident() const;
private:
QVector<ActivityFile> _files;
};
bool operator==( const Activity& rhs, const Activity& lhs );
@@ -118,22 +81,8 @@ bool operator<( const Activity& rhs, const Activity& lhs );
* A QList based list of Activities
*/
/**
* @brief The ActivityList
* @ingroup gui
*
* A QList based list of Activities
*/
class ActivityList:public QList<Activity>
{
public:
ActivityList();
void setAccountState(AccountState *ast);
AccountState* accountState();
typedef QList<Activity> ActivityList;
private:
AccountState *_ast;
};
}
-245
Ver Arquivo
@@ -1,245 +0,0 @@
/*
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include "activityfetcher.h"
#include "activitydata.h"
#include "account.h"
#include "accountstate.h"
#include "json.h"
#include "networkjobs.h"
namespace OCC {
ActivityFetcher::ActivityFetcher(QObject *parent) : QObject(parent)
{
}
void ActivityFetcher::slotFetch(AccountState* s)
{
if( !(s && s->isConnected() )) {
return;
}
JsonApiJob *job = new JsonApiJob(s->account(), QLatin1String("ocs/v1.php/cloud/activity"), this);
QObject::connect(job, SIGNAL(jsonReceived(QVariantMap, int)),
this, SLOT(slotActivitiesReceived(QVariantMap, int)));
job->setProperty("AccountStatePtr", QVariant::fromValue<AccountState*>(s));
QList< QPair<QString,QString> > params;
params.append(qMakePair(QString::fromLatin1("page"), QString::fromLatin1("0")));
params.append(qMakePair(QString::fromLatin1("pagesize"), QString::fromLatin1("100")));
job->addQueryParams(params);
qDebug() << "Start fetching activities for " << s->account()->displayName();
job->start();
}
void ActivityFetcher::slotActivitiesReceived(const QVariantMap& json, int statusCode)
{
auto activities = json.value("ocs").toMap().value("data").toList();
qDebug() << "*** activities" << activities;
ActivityList list;
AccountState* ai = qvariant_cast<AccountState*>(sender()->property("AccountStatePtr"));
list.setAccountState( ai );
foreach( auto activ, activities ) {
auto json = activ.toMap();
Activity a;
a._accName = ai->account()->displayName();
a._id = json.value("id").toLongLong();
a._subject = json.value("subject").toString();
a._message = json.value("message").toString();
const QString f = json.value("file").toString();
a.addFile(f);
a._link = json.value("link").toUrl();
a._dateTime = json.value("date").toDateTime();
list.append(a);
}
// activity app is not enabled, signalling.
if( statusCode == 999 ) {
emit accountWithoutActivityApp(ai);
}
emit newActivityList(list);
}
/* ==================================================================== */
ActivityFetcherV2::ActivityFetcherV2()
: ActivityFetcher()
{
}
ActivityList ActivityFetcherV2::fetchFromDb( const QString& accountId )
{
// TODO fetch from database
ActivityList dbActivities;
return dbActivities;
}
int ActivityFetcherV2::lastSeenId()
{
int lastId = 0;
return lastId;
}
void ActivityFetcherV2::slotFetch(AccountState* s)
{
if( !(s && s->isConnected() )) {
return;
}
JsonApiJob *job = new JsonApiJob(s->account(), QLatin1String("ocs/v2.php/apps/activity/api/v2/activity"), this);
QObject::connect(job, SIGNAL(jsonReceived(QVariantMap, int)),
this, SLOT(slotActivitiesReceived(QVariantMap, int)));
job->setProperty("AccountStatePtr", QVariant::fromValue<AccountState*>(s));
QList< QPair<QString,QString> > params;
int lastId = lastSeenId();
if( lastId > 0 ) {
params.append(qMakePair(QString::fromLatin1("since"), QString::number(lastId)));
job->addQueryParams(params);
}
qDebug() << "Start fetching V2 activities for " << s->account()->displayName();
job->start();
}
#define QL1(X) QLatin1String(X)
bool ActivityFetcherV2::parseActionString( Activity *activity, const QString& subject, const QVariantList& params)
{
// the action contains a string describing what happened
bool re = true;
if( subject == QL1("shared_user_self") ) {
} else if( subject == QL1("reshared_user_by") ) {
} else if( subject == QL1("shared_group_self") ) {
} else if( subject == QL1("reshared_group_by") ) {
} else if( subject == QL1("reshared_link_by") ) {
} else if( subject == QL1("shared_user_self") ) {
} else if( subject == QL1("created_self") ) {
} else if( subject == QL1("created_by") ) {
} else if( subject == QL1("created_public") ) {
} else if( subject == QL1("changed_self") ) {
} else if( subject == QL1("changed_by") ) {
} else if( subject == QL1("deleted_self") ) {
} else if( subject == QL1("deleted_by") ) {
} else if( subject == QL1("restored_self") ) {
} else if( subject == QL1("restored_by") ) {
} else {
// unknown action.
re = false;
}
// parse the params
foreach( QVariant v, params ) {
QVariantMap vm = v.toMap();
if( vm.contains("type") ) {
const QString type = vm.value("type").toString();
const QString val = vm.value("value").toString();
if( type == QL1("collection") ) {
QVariantList items = vm.value("value").toList();
foreach( QVariant vFile, items ) {
QVariantMap vMap = vFile.toMap();
const QString fileType = vMap.value("type").toString();
const QString relFileName = vMap.value("value").toString();
if( fileType != QL1("file")) {
activity->addDirectory(relFileName);
} else {
activity->addFile(relFileName);
}
}
} else if( type == QL1("file")) {
const QString relFileName = val;
activity->addFile(relFileName);
} else if( type == QL1("dir")) {
const QString relFileName = val;
activity->addDirectory(relFileName);
// needs verification!
} else if( type == QL1("username")) {
const QString user = val;
} else if( type == QL1("typeicon")) {
const QString icon = val;
} else {
}
}
}
return re;
}
void ActivityFetcherV2::slotActivitiesReceived(const QVariantMap& json, int statusCode)
{
auto activities = json.value("ocs").toMap().value("data").toList();
qDebug() << "*** activities" << activities;
AccountState* ai = qvariant_cast<AccountState*>(sender()->property("AccountStatePtr"));
ActivityList list;
if( ai ) {
list = fetchFromDb(ai->account()->id());
list.setAccountState( ai );
foreach( auto activ, activities ) {
auto json = activ.toMap();
Activity a;
a._accName = ai->account()->displayName();
a._id = json.value("activity_id").toLongLong();
QString subject = json.value("subject").toString();
QVariantList subjectParams = json.value("subjectparams").toList();
bool knownAction = parseActionString( &a, subject, subjectParams );
a._subject = json.value("subject").toString();
a._message = json.value("message_prepared").toString();
// a._file = json.value("file").toString();
// a._link = json.value("link").toUrl();
a._dateTime = json.value("datetime").toDateTime();
list.append(a);
}
// activity app is not enabled, signalling.
if( statusCode == 999 ) {
emit accountWithoutActivityApp(ai);
}
}
emit newActivityList(list);
}
}
-79
Ver Arquivo
@@ -1,79 +0,0 @@
/*
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#ifndef ACTIVITYFETCHER_H
#define ACTIVITYFETCHER_H
#include <QtCore>
#include "activitydata.h"
#include "accountstate.h"
/**
* @brief The ActivityFetcher class
*
* Used to fetch the list of server acitivities from the server. Accesses
* the old ocs based API.
*/
namespace OCC {
class ActivityFetcher : public QObject
{
Q_OBJECT
public:
explicit ActivityFetcher(QObject *parent = 0);
public slots:
virtual void slotFetch(AccountState* s);
private slots:
virtual void slotActivitiesReceived(const QVariantMap& json, int statusCode);
signals:
void newActivityList( ActivityList list );
void accountWithoutActivityApp(AccountState*);
};
/* ==================================================================== */
/**
* @brief The ActivityFetcherV2 class
*
* To be used with the next version of the activity API. By now, it is
* completely unused.
*/
class ActivityFetcherV2 : public ActivityFetcher
{
Q_OBJECT
public:
explicit ActivityFetcherV2();
public slots:
virtual void slotFetch(AccountState* s);
private slots:
virtual void slotActivitiesReceived(const QVariantMap& json, int statusCode);
private:
bool parseActionString( Activity *activity, const QString& subject, const QVariantList& params);
ActivityList fetchFromDb(const QString &accountId );
int lastSeenId();
};
}
#endif // ACTIVITYFETCHER_H
+75 -132
Ver Arquivo
@@ -26,35 +26,10 @@
#include "activitydata.h"
#include "activitylistmodel.h"
#define FETCH_ACTIVITIES_AMOUNT 1000
namespace OCC {
/* ==================================================================== */
ActivitySortProxyModel::ActivitySortProxyModel(QObject *parent)
:QSortFilterProxyModel(parent)
{
setFilterRole(ActivityItemDelegate::ActionTextRole);
}
bool ActivitySortProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
{
QVariant leftData = sourceModel()->data(left);
QVariant rightData = sourceModel()->data(right);
if (leftData.type() == QVariant::DateTime) {
return leftData.toDateTime() < rightData.toDateTime();
} else {
qDebug() << "OOOOO " << endl;
}
return true;
}
/* ==================================================================== */
ActivityListModel::ActivityListModel(QWidget *parent)
:QAbstractListModel(parent),
_fetchEntriesAmount(FETCH_ACTIVITIES_AMOUNT)
:QAbstractListModel(parent)
{
}
@@ -65,8 +40,7 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
if (!index.isValid())
return QVariant();
a = findItem(index.row());
a = _finalList.at(index.row());
AccountStatePtr ast = AccountManager::instance()->account(a._accName);
QStringList list;
@@ -115,48 +89,47 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
int ActivityListModel::rowCount(const QModelIndex&) const
{
int cnt = 0;
foreach( ActivityList al, _activityLists) {
cnt += al.count();
}
return cnt;
return _finalList.count();
}
void ActivityListModel::startFetchJob(AccountState* ast)
// current strategy: Fetch 100 items per Account
// ATTENTION: This method is const and thus it is not possible to modify
// the _activityLists hash or so. Doesn't make it easier...
bool ActivityListModel::canFetchMore(const QModelIndex& ) const
{
if( !ast->isConnected() || _currentlyFetching.contains(ast)) {
if( _activityLists.count() == 0 ) return true;
for(auto i = _activityLists.begin() ; i != _activityLists.end(); ++i) {
AccountState *ast = i.key();
if( ast && ast->isConnected() ) {
ActivityList activities = i.value();
if( activities.count() == 0 &&
! _currentlyFetching.contains(ast) ) {
return true;
}
}
}
return false;
}
void ActivityListModel::startFetchJob(AccountState* s)
{
if( !s->isConnected() ) {
return;
}
int activityListIndx = activityListIndxForAccountState(ast);
ActivityList activityList = _activityLists.at(activityListIndx);
// remove entries that might exist in this list.
int startItem = 0;
for( int i = 0; i < activityListIndx; i++ ) {
ActivityList al = _activityLists.at(i);
startItem += al.count();
}
beginRemoveRows(QModelIndex(), startItem, activityList.count() );
activityList.clear();
endRemoveRows();
_activityLists[activityListIndx] = activityList;
// start a new fetch job.
JsonApiJob *job = new JsonApiJob(ast->account(), QLatin1String("ocs/v1.php/cloud/activity"), this);
JsonApiJob *job = new JsonApiJob(s->account(), QLatin1String("ocs/v1.php/cloud/activity"), this);
QObject::connect(job, SIGNAL(jsonReceived(QVariantMap, int)),
this, SLOT(slotActivitiesReceived(QVariantMap, int)));
job->setProperty("AccountStatePtr", QVariant::fromValue<AccountState*>(ast));
job->setProperty("AccountStatePtr", QVariant::fromValue<AccountState*>(s));
QList< QPair<QString,QString> > params;
params.append(qMakePair(QString::fromLatin1("start"), QLatin1String("0")));
params.append(qMakePair(QString::fromLatin1("count"), QString::number(_fetchEntriesAmount)));
params.append(qMakePair(QString::fromLatin1("page"), QString::fromLatin1("0")));
params.append(qMakePair(QString::fromLatin1("pagesize"), QString::fromLatin1("100")));
job->addQueryParams(params);
_currentlyFetching.insert(ast);
qDebug() << Q_FUNC_INFO << "Start fetching activities for " << ast->account()->displayName();
_currentlyFetching.insert(s);
qDebug() << Q_FUNC_INFO << "Start fetching activities for " << s->account()->displayName();
job->start();
}
@@ -164,14 +137,12 @@ void ActivityListModel::slotActivitiesReceived(const QVariantMap& json, int stat
{
auto activities = json.value("ocs").toMap().value("data").toList();
ActivityList list;
AccountState* ast = qvariant_cast<AccountState*>(sender()->property("AccountStatePtr"));
_currentlyFetching.remove(ast);
// Read the new entries into a temporary list
ActivityList list;
foreach( auto activity, activities ) {
auto json = activity.toMap();
foreach( auto activ, activities ) {
auto json = activ.toMap();
Activity a;
a._type = Activity::ActivityType;
@@ -185,101 +156,73 @@ void ActivityListModel::slotActivitiesReceived(const QVariantMap& json, int stat
list.append(a);
}
_activityLists[ast] = list;
emit activityJobStatusCode(ast, statusCode);
addNewActivities(ast, list);
combineActivityLists();
}
void ActivityListModel::addNewActivities(AccountState* ast, const ActivityList& newItemsList)
void ActivityListModel::combineActivityLists()
{
int startItem = 0; // the start number of items to delete in the virtual overall list
int activityListIndx = activityListIndxForAccountState(ast);
Q_ASSERT(activityListIndx != -1);
ActivityList resultList;
ActivityList accountList = _activityLists.at(activityListIndx);
for( int i = 0; i < activityListIndx; i++ ) {
ActivityList li = _activityLists.at(i);
startItem += li.count();
foreach( ActivityList list, _activityLists.values() ) {
resultList.append(list);
}
// insert the new list
beginInsertRows(QModelIndex(), startItem, newItemsList.count() );
accountList.append(newItemsList);
std::sort( resultList.begin(), resultList.end() );
beginResetModel();
_finalList.clear();
endResetModel();
beginInsertRows(QModelIndex(), 0, resultList.count());
_finalList = resultList;
endInsertRows();
_activityLists[activityListIndx] = accountList;
}
int ActivityListModel::activityListIndxForAccountState(AccountState *ast)
void ActivityListModel::fetchMore(const QModelIndex &)
{
int i;
QList<AccountStatePtr> accounts = AccountManager::instance()->accounts();
for( i = 0; i < _activityLists.count(); i++ ) {
ActivityList li = _activityLists.at(i);
if( li.accountState() == ast )
return i;
foreach (const AccountStatePtr& asp, accounts) {
if( !_activityLists.contains(asp.data()) && asp->isConnected() ) {
_activityLists[asp.data()] = ActivityList();
startFetchJob(asp.data());
}
}
// if the AccountState was not found yet, add it to the list
if( i == _activityLists.count() ) {
ActivityList li;
li.setAccountState(ast);
_activityLists.append(li);
}
return i;
}
void ActivityListModel::slotRefreshActivity(AccountState *ast)
{
if(ast ) {
qDebug() << "**** Refreshing Activity list for" << ast->account()->displayName();
startFetchJob(ast);
if(ast && _activityLists.contains(ast)) {
_activityLists.remove(ast);
}
startFetchJob(ast);
}
void ActivityListModel::slotRemoveAccount(AccountState *ast )
{
int removeIndx = activityListIndxForAccountState(ast);
if( _activityLists.contains(ast) ) {
int i = 0;
const QString accountToRemove = ast->account()->displayName();
int startRow = 0;
for( int i = 0; i < removeIndx; i++) {
ActivityList al = _activityLists.at(i);
startRow += al.count();
}
QMutableListIterator<Activity> it(_finalList);
beginRemoveRows(QModelIndex(), startRow, startRow+_activityLists.at(removeIndx).count());
_activityLists.removeAt(removeIndx);
endRemoveRows();
_currentlyFetching.remove(ast);
}
// combine all activities into one big result list
ActivityList ActivityListModel::activityList()
{
ActivityList all;
int i;
for( i = 0; i < _activityLists.count(); i++) {
ActivityList al = _activityLists.at(i);
all.append(al);
}
return all;
}
Activity ActivityListModel::findItem(int indx) const
{
Activity a;
foreach( ActivityList al, _activityLists ) {
if( indx < al.count() ) {
a = al.at(indx);
break;
while (it.hasNext()) {
Activity activity = it.next();
if( activity._accName == accountToRemove ) {
beginRemoveRows(QModelIndex(), i, i+1);
it.remove();
endRemoveRows();
}
}
indx -= al.count();
_activityLists.remove(ast);
_currentlyFetching.remove(ast);
}
return a;
}
}
+8 -19
Ver Arquivo
@@ -17,21 +17,10 @@
#include <QtCore>
#include "activitydata.h"
#include "accountstate.h"
namespace OCC {
class ActivitySortProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
ActivitySortProxyModel(QObject *parent = 0);
protected:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE;
};
class AccountState;
/**
* @brief The ActivityListModel
@@ -49,8 +38,10 @@ public:
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE;
ActivityList activityList();
Activity findItem(int indx) const;
bool canFetchMore(const QModelIndex& ) const Q_DECL_OVERRIDE;
void fetchMore(const QModelIndex&) Q_DECL_OVERRIDE;
ActivityList activityList() { return _finalList; }
public slots:
void slotRefreshActivity(AccountState* ast);
@@ -63,16 +54,14 @@ signals:
void activityJobStatusCode(AccountState* ast, int statusCode);
private:
void addNewActivities(AccountState* ast, const ActivityList& newItemsList);
void startFetchJob(AccountState *ast);
void startFetchJob(AccountState* s);
void combineActivityLists();
int activityListIndxForAccountState(AccountState *ast );
QList<ActivityList> _activityLists;
QMap<AccountState*, ActivityList> _activityLists;
ActivityList _finalList;
QSet<AccountState*> _currentlyFetching;
int _fetchEntriesAmount;
};
}
#endif // ACTIVITYLISTMODEL_H
+30 -22
Ver Arquivo
@@ -63,19 +63,15 @@ ActivityWidget::ActivityWidget(QWidget *parent) :
_ui->_activityList->setMinimumWidth(400);
#endif
_model = new ActivitySortProxyModel(this);
ActivityListModel *rawModel = new ActivityListModel;
_model->setSourceModel(rawModel);
_model = new ActivityListModel(this);
ActivityItemDelegate *delegate = new ActivityItemDelegate;
delegate->setParent(this);
_ui->_activityList->setItemDelegate(delegate);
_ui->_activityList->setAlternatingRowColors(true);
_ui->_activityList->setModel(_model);
_ui->_filterEdit->setClearButtonEnabled(true);
connect(_ui->_filterEdit, SIGNAL(textChanged(QString)),
SLOT(slotFilterTextChanged(QString)));
_ui->_notifyLabel->hide();
_ui->_notifyScroll->hide();
// Create a widget container for the notifications. The ui file defines
// a scroll area that get a widget with a layout as children
@@ -83,10 +79,12 @@ ActivityWidget::ActivityWidget(QWidget *parent) :
_notificationsLayout = new QVBoxLayout;
w->setLayout(_notificationsLayout);
_notificationsLayout->setAlignment(Qt::AlignTop);
_ui->_notifyScroll->setAlignment(Qt::AlignTop);
_ui->_notifyScroll->setWidget(w);
showLabels();
connect(rawModel, SIGNAL(activityJobStatusCode(AccountState*,int)),
connect(_model, SIGNAL(activityJobStatusCode(AccountState*,int)),
this, SLOT(slotAccountActivityStatus(AccountState*,int)));
_copyBtn = _ui->_dialogButtonBox->addButton(tr("Copy"), QDialogButtonBox::ActionRole);
@@ -107,17 +105,11 @@ ActivityWidget::~ActivityWidget()
delete _ui;
}
void ActivityWidget::slotFilterTextChanged(const QString& exp)
{
_model->setFilterRegExp(QRegExp(exp, Qt::CaseInsensitive, QRegExp::RegExp));
}
void ActivityWidget::slotRefreshActivities(AccountState *ptr)
{
qobject_cast<ActivityListModel*>(_model->sourceModel())->slotRefreshActivity(ptr);
_model->slotRefreshActivity(ptr);
}
void ActivityWidget::slotRefreshNotifications(AccountState *ptr)
{
// start a server notification handler if no notification requests
@@ -127,7 +119,7 @@ void ActivityWidget::slotRefreshNotifications(AccountState *ptr)
connect(snh, SIGNAL(newNotificationList(ActivityList)), this,
SLOT(slotBuildNotificationDisplay(ActivityList)));
snh->fetchNotifications(ptr);
snh->slotFetchNotifications(ptr);
} else {
qDebug() << Q_FUNC_INFO << "========> notification request counter not zero.";
}
@@ -135,20 +127,24 @@ void ActivityWidget::slotRefreshNotifications(AccountState *ptr)
void ActivityWidget::slotRemoveAccount( AccountState *ptr )
{
qobject_cast<ActivityListModel*>(_model->sourceModel())->slotRemoveAccount(ptr);
_model->slotRemoveAccount(ptr);
}
void ActivityWidget::showLabels()
{
QString t;
QString t = tr("Server Activities");
_ui->_headerLabel->setTextFormat(Qt::RichText);
_ui->_headerLabel->setText(t);
_ui->_notifyLabel->setText(tr("Action Required: Notifications"));
t.clear();
QSetIterator<QString> i(_accountsWithoutActivities);
while (i.hasNext() ) {
t.append( tr("<br/>Account %1 does not have activities enabled.").arg(i.next()));
}
_ui->_bottomLabel->setTextFormat(Qt::RichText);
_ui->_bottomLabel->setText(t);
_ui->_bottomLabel->setVisible(!t.isEmpty());
}
void ActivityWidget::slotAccountActivityStatus(AccountState *ast, int statusCode)
@@ -178,7 +174,7 @@ QString ActivityWidget::timeString(QDateTime dt, QLocale::FormatType format) con
void ActivityWidget::storeActivityList( QTextStream& ts )
{
ActivityList activities = qobject_cast<ActivityListModel*>(_model->sourceModel())->activityList();
ActivityList activities = _model->activityList();
foreach( Activity activity, activities ) {
ts << right
@@ -222,9 +218,11 @@ void ActivityWidget::checkActivityTabVisibility()
_accountsWithoutActivities.count() != accountCount;
bool hasNotifications = !_widgetForNotifId.isEmpty();
_ui->_filterLabel->setVisible( hasAccountsWithActivity );
_ui->_headerLabel->setVisible( hasAccountsWithActivity );
_ui->_activityList->setVisible( hasAccountsWithActivity );
_ui->_filterEdit->setVisible(hasAccountsWithActivity);
_ui->_notifyLabel->setVisible( hasNotifications );
_ui->_notifyScroll->setVisible( hasNotifications );
emit hideActivityTab(!hasAccountsWithActivity && !hasNotifications);
}
@@ -271,6 +269,10 @@ void ActivityWidget::slotBuildNotificationDisplay(const ActivityList& list)
this, SLOT(slotRequestCleanupAndBlacklist(Activity)));
_notificationsLayout->addWidget(widget);
// _ui->_notifyScroll->setMinimumHeight( widget->height());
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
_ui->_notifyScroll->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContentsOnFirstShow);
#endif
_widgetForNotifId[activity.ident()] = widget;
newNotificationShown = true;
}
@@ -498,6 +500,12 @@ void ActivityWidget::slotCheckToCleanWidgets()
if( _widgetsToRemove.isEmpty() ) {
_removeTimer.stop();
}
// check to see if the whole notification pane should be hidden
if( _widgetForNotifId.isEmpty() ) {
_ui->_notifyLabel->setHidden(true);
_ui->_notifyScroll->setHidden(true);
}
}
+1 -3
Ver Arquivo
@@ -42,7 +42,6 @@ namespace Ui {
class ActivityWidget;
}
class Application;
class ActivitySortProxyModel;
/**
* @brief The ActivityWidget class
@@ -85,7 +84,6 @@ signals:
void newNotification();
private slots:
void slotFilterTextChanged(const QString& exp);
void slotBuildNotificationDisplay(const ActivityList& list);
void slotSendNotificationRequest(const QString &accountName, const QString& link, const QByteArray &verb);
void slotNotifyNetworkError( QNetworkReply* );
@@ -113,7 +111,7 @@ private:
// no query for notifications is started.
int _notificationRequestsRunning;
ActivitySortProxyModel *_model;
ActivityListModel *_model;
QVBoxLayout *_notificationsLayout;
};
+67 -39
Ver Arquivo
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>690</width>
<height>513</height>
<width>693</width>
<height>556</height>
</rect>
</property>
<property name="windowTitle">
@@ -15,53 +15,81 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="_filterLabel">
<property name="text">
<string>&amp;Filter</string>
</property>
<property name="buddy">
<cstring>_filterEdit</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="_filterEdit">
<property name="maximumSize">
<size>
<width>180</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
<widget class="QLabel" name="_notifyLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QListView" name="_activityList"/>
<widget class="QScrollArea" name="_notifyScroll">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="_scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>677</width>
<height>70</height>
</rect>
</property>
</widget>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="_bottomLabel">
<widget class="QLabel" name="_headerLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QListView" name="_activityList">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="_bottomLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QDialogButtonBox" name="_dialogButtonBox"/>
</item>
</layout>
+4
Ver Arquivo
@@ -16,7 +16,9 @@
#include "creds/credentialsfactory.h"
#include "creds/httpcredentialsgui.h"
#include "creds/dummycredentials.h"
#ifndef NO_SHIBBOLETH
#include "creds/shibbolethcredentials.h"
#endif
namespace OCC
{
@@ -31,8 +33,10 @@ AbstractCredentials* create(const QString& type)
return new HttpCredentialsGui;
} else if (type == "dummy") {
return new DummyCredentials;
#ifndef NO_SHIBBOLETH
} else if (type == "shibboleth") {
return new ShibbolethCredentials;
#endif
} else {
qWarning("Unknown credentials type: %s", qPrintable(type));
return new DummyCredentials;
+5 -2
Ver Arquivo
@@ -1076,11 +1076,14 @@ void FolderStatusModel::slotShowFetchProgress()
auto idx = it.key();
auto* info = infoForIndex(idx);
if (info && info->_fetching) {
if (!info->hasLabel()) {
bool add = !info->hasLabel();
if (add) {
beginInsertRows(idx, 0, 0);
endInsertRows();
}
info->_fetchingLabel = true;
if (add) {
endInsertRows();
}
}
it.remove();
}
+4 -1
Ver Arquivo
@@ -539,12 +539,15 @@ bool DetermineAuthTypeJob::finished()
setupConnections(reply());
return false; // don't discard
} else {
#ifndef NO_SHIBBOLETH
QRegExp shibbolethyWords("SAML|wayf");
shibbolethyWords.setCaseSensitivity(Qt::CaseInsensitive);
if (redirection.toString().contains(shibbolethyWords)) {
emit authType(WizardCommon::Shibboleth);
} else {
} else
#endif
{
// TODO: Send an error.
// eh?
emit authType(WizardCommon::HttpCreds);
+3 -4
Ver Arquivo
@@ -26,14 +26,14 @@ ServerNotificationHandler::ServerNotificationHandler(QObject *parent)
}
bool ServerNotificationHandler::fetchNotifications(AccountState *ptr)
void ServerNotificationHandler::slotFetchNotifications(AccountState *ptr)
{
// check connectivity and credentials
if( !( ptr && ptr->isConnected() && ptr->account() &&
ptr->account()->credentials() &&
ptr->account()->credentials()->ready() ) ) {
deleteLater();
return false;
return;
}
// check if the account has notifications enabled. If the capabilities are
// not yet valid, its assumed that notifications are available.
@@ -41,7 +41,7 @@ bool ServerNotificationHandler::fetchNotifications(AccountState *ptr)
if( ! ptr->account()->capabilities().notificationsAvailable() ) {
qDebug() << Q_FUNC_INFO << "Account" << ptr->account()->displayName() << "does not have notifications enabled.";
deleteLater();
return false;
return;
}
}
@@ -52,7 +52,6 @@ bool ServerNotificationHandler::fetchNotifications(AccountState *ptr)
_notificationJob->setProperty("AccountStatePtr", QVariant::fromValue<AccountState*>(ptr));
_notificationJob->start();
return true;
}
void ServerNotificationHandler::slotNotificationsReceived(const QVariantMap& json, int statusCode)
+1 -1
Ver Arquivo
@@ -26,12 +26,12 @@ class ServerNotificationHandler : public QObject
Q_OBJECT
public:
explicit ServerNotificationHandler(QObject *parent = 0);
bool fetchNotifications(AccountState *ptr);
signals:
void newNotificationList(ActivityList);
public slots:
void slotFetchNotifications(AccountState *ptr);
private slots:
void slotNotificationsReceived(const QVariantMap& json, int statusCode);
+14 -1
Ver Arquivo
@@ -20,7 +20,9 @@
#include "wizard/owncloudwizard.h"
#include "wizard/owncloudsetuppage.h"
#include "wizard/owncloudhttpcredspage.h"
#ifndef NO_SHIBBOLETH
#include "wizard/owncloudshibbolethcredspage.h"
#endif
#include "wizard/owncloudadvancedsetuppage.h"
#include "wizard/owncloudwizardresultpage.h"
@@ -39,7 +41,9 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
_account(0),
_setupPage(new OwncloudSetupPage(this)),
_httpCredsPage(new OwncloudHttpCredsPage(this)),
#ifndef NO_SHIBBOLETH
_shibbolethCredsPage(new OwncloudShibbolethCredsPage),
#endif
_advancedSetupPage(new OwncloudAdvancedSetupPage),
_resultPage(new OwncloudWizardResultPage),
_credentialsPage(0),
@@ -48,7 +52,9 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setPage(WizardCommon::Page_ServerSetup, _setupPage);
setPage(WizardCommon::Page_HttpCreds, _httpCredsPage);
#ifndef NO_SHIBBOLETH
setPage(WizardCommon::Page_ShibbolethCreds, _shibbolethCredsPage);
#endif
setPage(WizardCommon::Page_AdvancedSetup, _advancedSetupPage);
setPage(WizardCommon::Page_Result, _resultPage);
@@ -61,7 +67,9 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
connect( this, SIGNAL(currentIdChanged(int)), SLOT(slotCurrentPageChanged(int)));
connect( _setupPage, SIGNAL(determineAuthType(QString)), SIGNAL(determineAuthType(QString)));
connect( _httpCredsPage, SIGNAL(connectToOCUrl(QString)), SIGNAL(connectToOCUrl(QString)));
#ifndef NO_SHIBBOLETH
connect( _shibbolethCredsPage, SIGNAL(connectToOCUrl(QString)), SIGNAL(connectToOCUrl(QString)));
#endif
connect( _advancedSetupPage, SIGNAL(createLocalAndRemoteFolders(QString, QString)),
SIGNAL(createLocalAndRemoteFolders(QString, QString)));
connect(this, SIGNAL(customButtonClicked(int)), this, SIGNAL(skipFolderConfiguration()));
@@ -128,9 +136,11 @@ void OwncloudWizard::successfulStep()
_httpCredsPage->setConnected();
break;
#ifndef NO_SHIBBOLETH
case WizardCommon::Page_ShibbolethCreds:
_shibbolethCredsPage->setConnected();
break;
#endif
case WizardCommon::Page_AdvancedSetup:
_advancedSetupPage->directoriesCreated();
@@ -148,9 +158,12 @@ void OwncloudWizard::successfulStep()
void OwncloudWizard::setAuthType(WizardCommon::AuthType type)
{
_setupPage->setAuthType(type);
#ifndef NO_SHIBBOLETH
if (type == WizardCommon::Shibboleth) {
_credentialsPage = _shibbolethCredsPage;
} else {
} else
#endif
{
_credentialsPage = _httpCredsPage;
}
next();
+4
Ver Arquivo
@@ -25,7 +25,9 @@ namespace OCC {
class OwncloudSetupPage;
class OwncloudHttpCredsPage;
#ifndef NO_SHIBBOLETH
class OwncloudShibbolethCredsPage;
#endif
class OwncloudAdvancedSetupPage;
class OwncloudWizardResultPage;
class AbstractCredentials;
@@ -88,7 +90,9 @@ private:
AccountPtr _account;
OwncloudSetupPage* _setupPage;
OwncloudHttpCredsPage* _httpCredsPage;
#ifndef NO_SHIBBOLETH
OwncloudShibbolethCredsPage* _shibbolethCredsPage;
#endif
OwncloudAdvancedSetupPage* _advancedSetupPage;
OwncloudWizardResultPage* _resultPage;
AbstractCredentialsWizardPage* _credentialsPage;
+2 -1
Ver Arquivo
@@ -12,6 +12,7 @@
*/
#include "excludedfiles.h"
#include "utility.h"
#include <QFileInfo>
@@ -70,7 +71,7 @@ bool ExcludedFiles::isExcluded(
const QString& basePath,
bool excludeHidden) const
{
if (!filePath.startsWith(basePath)) {
if (!filePath.startsWith(basePath, Utility::fsCasePreserving() ? Qt::CaseInsensitive : Qt::CaseSensitive)) {
// Mark paths we're not responsible for as excluded...
return true;
}