Skip to content
This repository has been archived by the owner on Mar 4, 2023. It is now read-only.

Commit

Permalink
internal code updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Skycoder42 committed Feb 18, 2018
1 parent 5a2fd28 commit 09c02f0
Show file tree
Hide file tree
Showing 60 changed files with 185 additions and 117 deletions.
7 changes: 6 additions & 1 deletion .qmake.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ win32:cross_compile: CONFIG += winrt

DEFINES += QT_DEPRECATED_WARNINGS QT_ASCII_CAST_WARNINGS

MODULE_VERSION = 4.0.0
MODULE_VERSION_MAJOR = 4
MODULE_VERSION_MINOR = 0
MODULE_VERSION_PATCH = 1
MODULE_VERSION_IMPORT = $${MODULE_VERSION_MAJOR}.$${MODULE_VERSION_MINOR}
MODULE_VERSION = $${MODULE_VERSION_MAJOR}.$${MODULE_VERSION_MINOR}.$${MODULE_VERSION_PATCH}

9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ osx_image: xcode9.2

env:
global:
- QT_VER=5.10.0
- QPMX_CACHE_DIR=$HOME/.qpmx-cache
- QT_VER=5.10.1
- EXTRA_MODULES=".qtremoteobjects .skycoder42.jsonserializer"
- STATIC_QT_MODS="qttools qtwebsockets qtscxml qtremoteobjects"
- STATIC_EXTRA_MODS="qtjsonserializer"
Expand All @@ -20,7 +21,7 @@ matrix:
env:
- PLATFORM=gcc_64
- BUILD_DOC=true
- EXTRA_PKG="libsecret-1-dev gnome-keyring" #in order to build secrectservice keystore
- EXTRA_PKG="libsecret-1-dev" #in order to build secrectservice keystore
- os: linux
env:
- PLATFORM=android_armv7
Expand Down Expand Up @@ -59,10 +60,10 @@ deploy:
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
#TODO rm qpmx locks
- rm -fr $QPMX_CACHE_DIR/locks
cache:
directories:
- $HOME/.cache/Skycoder42/qpmx
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.android/build-cache
- $QPMX_CACHE_DIR
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ auto store = new QtDataSync::DataStore(this); //Use the "default setup"
//store an entry
store->save<Data>({42, "tree"});
//load all entries
foreach(Data d, store->loadAll<Data>()) {
for(Data d : store->loadAll<Data>()) {
qDebug() << d.key << d.value;
});
```
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ image:
version: build-{build}

environment:
QT_VER: 5.10.0
QT_VER: 5.10.1
EXTRA_MODULES: .qtremoteobjects;.skycoder42.jsonserializer
STATIC_QT_MODS: qttools qtwebsockets qtscxml qtremoteobjects
STATIC_EXTRA_MODS: qtjsonserializer
Expand Down
2 changes: 1 addition & 1 deletion doc/datatypestore.dox
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ initially. This can be a potentially long operation, and thus you should only us
number of datasets does not get extremly big.

One additional feature of the store is that it provides read-only STL iterators for easy access.
Using it with foreach however is currently not possible, as the store is not a value type.
Using it with for/foreach however is currently not possible, as the store is not a value type.

@sa DataStore, DataStore::loadAll, DataTypeStore
*/
Expand Down
4 changes: 2 additions & 2 deletions examples/datasync/Sample/accountdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void AccountDialog::exec(const QString &setup, QWidget *parent)
void AccountDialog::updateDevices(const QList<QtDataSync::DeviceInfo> &devices)
{
ui->treeWidget->clear();
foreach(auto device, devices) {
for(auto device : devices) {
auto item = new QTreeWidgetItem(ui->treeWidget);
item->setText(0, device.name());
item->setText(1, printFingerprint(device.fingerprint()));
Expand Down Expand Up @@ -111,7 +111,7 @@ void AccountDialog::login(QtDataSync::LoginRequest request)
QString AccountDialog::printFingerprint(const QByteArray &fingerprint)
{
QByteArrayList res;
foreach(char c, fingerprint)
for(char c : fingerprint)
res.append(QByteArray(1, c).toHex());
return QString::fromUtf8(res.join(':'));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/datasync/Sample/exchangedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void ExchangeDialog::exec(QtDataSync::AccountManager *manager, QWidget *parent)
void ExchangeDialog::devicesChanged(QList<QtDataSync::UserInfo> devices)
{
ui->treeWidget->clear();
foreach(auto dev, devices) {
for(auto dev : devices) {
auto item = new QTreeWidgetItem(ui->treeWidget);
item->setText(0, dev.name());
item->setText(1, QStringLiteral("%1:%2").arg(dev.address().toString()).arg(dev.port()));
Expand Down
2 changes: 1 addition & 1 deletion src/datasync/changecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void ChangeController::uploadNext(bool emitStarted)

//skip stuff already beeing uploaded (could still have changed, but to prevent errors)
auto skip = false;
foreach(auto mKey, _activeUploads.keys()) {
for(auto mKey : _activeUploads.keys()) {
if(key == mKey) {
skip = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/datasync/changeemitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void ChangeEmitter::triggerRemoteClear(const QByteArray &typeName)
{
if(_cache) {
QWriteLocker _(&_cache->lock);
foreach(auto key, _cache->cache.keys()) {
for(auto key : _cache->cache.keys()) {
if(key.typeName == typeName)
_cache->cache.remove(key);
}
Expand Down
4 changes: 2 additions & 2 deletions src/datasync/cryptocontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ QStringList CryptoController::allKeystoreKeys()
QStringList CryptoController::availableKeystoreKeys()
{
QStringList keys;
foreach(auto key, factory->allKeys()) {
for(auto key : factory->allKeys()) {
if(factory->isAvailable(key))
keys.append(key);
}
Expand Down Expand Up @@ -860,7 +860,7 @@ void CryptoController::cleanCiphers() const
auto keys = settings()->childKeys();
settings()->endGroup();

foreach(auto key, keys) {
for(auto key : keys) {
auto ok = false;
auto keyIndex = key.toUInt(&ok);
if(!ok)
Expand Down
9 changes: 3 additions & 6 deletions src/datasync/datastore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ QStringList DataStore::keys(int metaTypeId) const

QVariantList DataStore::loadAll(int metaTypeId) const
{
auto jsonList = d->store->loadAll(d->typeName(metaTypeId));
QVariantList resList;
foreach(auto val, jsonList)
for(auto val : d->store->loadAll(d->typeName(metaTypeId)))
resList.append(d->serializer->deserialize(val, metaTypeId));
return resList;
}
Expand Down Expand Up @@ -139,17 +138,15 @@ void DataStore::update(int metaTypeId, QObject *object) const

QVariantList DataStore::search(int metaTypeId, const QString &query, SearchMode mode) const
{
auto jsonList = d->store->find(d->typeName(metaTypeId), query, mode);
QVariantList resList;
foreach(auto val, jsonList)
for(auto val : d->store->find(d->typeName(metaTypeId), query, mode))
resList.append(d->serializer->deserialize(val, metaTypeId));
return resList;
}

void DataStore::iterate(int metaTypeId, const function<bool (QVariant)> &iterator) const
{
auto keyList = keys(metaTypeId);
foreach(auto key, keyList) {
for(auto key : keys(metaTypeId)) {
if(!iterator(load(metaTypeId, key)))
break;
}
Expand Down
9 changes: 3 additions & 6 deletions src/datasync/datastore.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,8 @@ template<typename T, typename K>
QList<K> DataStore::keys() const
{
QTDATASYNC_STORE_ASSERT(T);
auto kList = keys<T>();
QList<K> rList;
foreach(auto k, kList)
for(auto k : keys<T>())
rList.append(QVariant(k).template value<K>());
return rList;
}
Expand All @@ -249,9 +248,8 @@ template<typename T>
QList<T> DataStore::loadAll() const
{
QTDATASYNC_STORE_ASSERT(T);
auto mList = loadAll(qMetaTypeId<T>());
QList<T> rList;
foreach(auto v, mList)
for(auto v : loadAll(qMetaTypeId<T>()))
rList.append(v.template value<T>());
return rList;
}
Expand Down Expand Up @@ -302,9 +300,8 @@ template<typename T>
QList<T> DataStore::search(const QString &query, SearchMode mode) const
{
QTDATASYNC_STORE_ASSERT(T);
auto mList = search(qMetaTypeId<T>(), query, mode);
QList<T> rList;
foreach(auto v, mList)
for(auto v : search(qMetaTypeId<T>(), query, mode))
rList.append(v.template value<T>());
return rList;
}
Expand Down
2 changes: 1 addition & 1 deletion src/datasync/datastoremodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ void DataStoreModelPrivate::createRoleNames()
void DataStoreModelPrivate::clearHashObjects()
{
if(QMetaType::typeFlags(type).testFlag(QMetaType::PointerToQObject)) {
foreach(auto v, dataHash)
for(auto v : dataHash)
deleteObject(v);
}
dataHash.clear();
Expand Down
6 changes: 3 additions & 3 deletions src/datasync/datatypestore.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ CachingDataTypeStore<TType, TKey>::CachingDataTypeStore(DataStore *store, QObjec
_data()
{
auto userProp = TType::staticMetaObject.userProperty();
foreach(auto data, store->loadAll<TType>())
for(auto data : store->loadAll<TType>())
_data.insert(userProp.readOnGadget(&data).template value<TKey>(), data);

connect(_store, &DataStore::dataChanged,
Expand Down Expand Up @@ -474,7 +474,7 @@ CachingDataTypeStore<TType*, TKey>::CachingDataTypeStore(DataStore *store, QObje
_data()
{
auto userProp = TType::staticMetaObject.userProperty();
foreach(auto data, store->loadAll<TType*>()){
for(auto data : store->loadAll<TType*>()){
data->setParent(this);
_data.insert(userProp.read(data).template value<TKey>(), data);
}
Expand Down Expand Up @@ -616,7 +616,7 @@ void CachingDataTypeStore<TType*, TKey>::evalDataResetted()
auto data = _data;
_data.clear();
emit dataResetted();
foreach(auto d, data)
for(auto d : data)
d->deleteLater();
}

Expand Down
4 changes: 2 additions & 2 deletions src/datasync/defaults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void DefaultsPrivate::clearDefaults()
for(auto it = setupDefaults.constBegin(); it != setupDefaults.constEnd(); it++)
weakRefs.append({it.key(), it.value().toWeakRef()});
setupDefaults.clear();
foreach(auto ref, weakRefs) {
for(auto ref : weakRefs) {
#undef QTDATASYNC_LOG
#define QTDATASYNC_LOG ref.second.toStrongRef()->logger
if(ref.second)
Expand Down Expand Up @@ -305,7 +305,7 @@ DefaultsPrivate::DefaultsPrivate(const QString &setupName, const QDir &storageDi
DefaultsPrivate::~DefaultsPrivate()
{
QMutexLocker _(&roMutex);
foreach(auto node, roNodes)
for(auto node : roNodes)
node->deleteLater();
roNodes.clear();
}
Expand Down
2 changes: 1 addition & 1 deletion src/datasync/emitteradapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void EmitterAdapter::dropCached(const QByteArray &typeName)
return;

QWriteLocker _(&_cache->lock);
foreach(auto key, _cache->cache.keys()) {
for(auto key : _cache->cache.keys()) {
if(key.typeName == typeName)
_cache->cache.remove(key);
}
Expand Down
2 changes: 1 addition & 1 deletion src/datasync/migrationhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void MigrationRunnable::run()
//special: copy headers
oldSettings->beginGroup(QStringLiteral("RemoteConnector/headers"));
currentSettings->beginGroup(QStringLiteral("connector/") + RemoteConnector::keyRemoteHeaders);
foreach(auto key, oldSettings->childKeys()) {
for(auto key : oldSettings->childKeys()) {
copyConf(oldSettings, key,
currentSettings, key);
}
Expand Down
9 changes: 4 additions & 5 deletions src/datasync/remoteconnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ void RemoteConnector::error(QAbstractSocket::SocketError error)
void RemoteConnector::sslErrors(const QList<QSslError> &errors)
{
auto shouldClose = true;
foreach(auto error, errors) {
for(auto error : errors) {
if(error.error() == QSslError::SelfSignedCertificate ||
error.error() == QSslError::SelfSignedCertificateInChain)
shouldClose = shouldClose &&
Expand Down Expand Up @@ -790,9 +790,8 @@ QVariant RemoteConnector::sValue(const QString &key) const
if(key == keyRemoteHeaders) {
if(settings()->childGroups().contains(keyRemoteHeaders)) {
settings()->beginGroup(keyRemoteHeaders);
auto keys = settings()->childKeys();
RemoteConfig::HeaderHash headers;
foreach(auto key, keys)
for(auto key : settings()->childKeys())
headers.insert(key.toUtf8(), settings()->value(key).toByteArray());
settings()->endGroup();
return QVariant::fromValue(headers);
Expand Down Expand Up @@ -1074,7 +1073,7 @@ void RemoteConnector::onDevices(const DevicesMessage &message)
if(checkIdle(message)) {
logDebug() << "Received list of devices with" << message.devices.size() << "entries";
_deviceCache.clear();
foreach(auto device, message.devices)
for(auto device : message.devices)
_deviceCache.append(DeviceInfo{get<0>(device), get<1>(device), get<2>(device)});
emit devicesListed(_deviceCache);
}
Expand Down Expand Up @@ -1180,7 +1179,7 @@ void RemoteConnector::onDeviceKeys(const DeviceKeysMessage &message)
reply.cmac = _cryptoController->generateEncryptionKeyCmac(reply.keyIndex); //cmac for the new key
//do not store this mac to be send again!

foreach(auto info, message.devices) {
for(auto info : message.devices) {
try {
//verify the device knows the previous secret (which is still the current one)
auto cryptInfo = QSharedPointer<AsymmetricCryptoInfo>::create(_cryptoController->rng(),
Expand Down
2 changes: 1 addition & 1 deletion src/datasync/synchelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void hashNext(QCryptographicHash &hash, const QJsonValue &value)
hash.addData(value.toString().toUtf8());
break;
case QJsonValue::Array:
foreach(auto v, value.toArray())
for(auto v : value.toArray())
hashNext(hash, v);
break;
case QJsonValue::Object:
Expand Down
4 changes: 2 additions & 2 deletions src/datasync/userexchangemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void UserExchangeManager::readDatagram()

auto isSelf = false;
if(datagram.senderPort() == d->socket->localPort()) {
foreach(auto addr, QNetworkInterface::allAddresses()) {
for(auto addr : QNetworkInterface::allAddresses()) {
if(addr.isEqual(datagram.senderAddress())) {
isSelf = true;
break;
Expand Down Expand Up @@ -250,7 +250,7 @@ void UserExchangeManager::readDatagram()

//try to find the already existing user info for that data
bool found = false;
foreach(auto key, d->devices.keys()) {
for(auto key : d->devices.keys()) {
if(info == key) {
found = true;
if(isInfo) { //isInfo -> reset timeout, update name if neccessary
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
QT = core datasync qml

CXX_MODULE = datasync
TARGETPATH = de/skycoder42/QtDataSync
IMPORT_VERSION = 1.0
TARGET = declarative_datasync
IMPORT_VERSION = $$MODULE_VERSION_IMPORT
DEFINES += "VERSION_MAJOR=$$MODULE_VERSION_MAJOR"
DEFINES += "VERSION_MINOR=$$MODULE_VERSION_MINOR"

HEADERS += qmldatasync_plugin.h \
HEADERS += \
qqmldatastore.h \
qqmlsyncmanager.h \
qqmlaccountmanager.h \
qqmldatastoremodel.h \
qqmluserexchangemanager.h
qqmluserexchangemanager.h \
qtdatasync_plugin.h

SOURCES += qmldatasync_plugin.cpp \
SOURCES += \
qqmldatastore.cpp \
qqmlsyncmanager.cpp \
qqmlaccountmanager.cpp \
qqmldatastoremodel.cpp \
qqmluserexchangemanager.cpp
qqmluserexchangemanager.cpp \
qtdatasync_plugin.cpp

OTHER_FILES += qmldir

IMPORT_VERSION = 1.0

generate_qmltypes {
typeextra1.target = qmltypes
typeextra1.depends += export LD_LIBRARY_PATH := "$$shadowed($$dirname(_QMAKE_CONF_))/lib/:$(LD_LIBRARY_PATH)"
qmltypes.depends += typeextra1

typeextra2.target = qmltypes
typeextra2.depends += export QML2_IMPORT_PATH := "$$shadowed($$dirname(_QMAKE_CONF_))/qml/"
qmltypes.depends += typeextra2
QMAKE_EXTRA_TARGETS += typeextra1 typeextra2
}

load(qml_plugin)

generate_qmltypes {
qmltypes.depends = ../../../qml/$$TARGETPATH/$(TARGET) #overwrite the target deps

mfirst.target = all
mfirst.depends += qmltypes
QMAKE_EXTRA_TARGETS += mfirst
Expand Down
Loading

0 comments on commit 09c02f0

Please sign in to comment.