[Pkg-owncloud-commits] [owncloud-client] 07/115: Move the update job in a new file named discoveryphase
Sandro Knauß
hefee-guest at moszumanska.debian.org
Fri Aug 29 22:03:53 UTC 2014
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 1f1eb933d19f3bc09ee65ae75aaa3c50a578b3ea
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Mon Aug 11 17:47:16 2014 +0200
Move the update job in a new file named discoveryphase
"Discovery" is a better name than "update"
---
src/CMakeLists.txt | 1 +
src/mirall/discoveryphase.cpp | 23 ++++++++++++++++++++++
src/mirall/discoveryphase.h | 44 +++++++++++++++++++++++++++++++++++++++++++
src/mirall/syncengine.cpp | 13 +++++++------
src/mirall/syncengine.h | 29 +---------------------------
5 files changed, 76 insertions(+), 34 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9d4e66b..9acb275 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -87,6 +87,7 @@ set(libsync_SRCS
mirall/clientproxy.cpp
mirall/cookiejar.cpp
mirall/syncfilestatus.cpp
+ mirall/discoveryphase.cpp
creds/dummycredentials.cpp
creds/abstractcredentials.cpp
creds/credentialsfactory.cpp
diff --git a/src/mirall/discoveryphase.cpp b/src/mirall/discoveryphase.cpp
new file mode 100644
index 0000000..b1e3d16
--- /dev/null
+++ b/src/mirall/discoveryphase.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) by Olivier Goffart <ogoffart at woboq.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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 "discoveryphase.h"
+
+void DiscoveryJob::start() {
+ csync_set_log_callback(_log_callback);
+ csync_set_log_level(_log_level);
+ csync_set_log_userdata(_log_userdata);
+ emit finished(csync_update(_csync_ctx));
+ deleteLater();
+}
diff --git a/src/mirall/discoveryphase.h b/src/mirall/discoveryphase.h
new file mode 100644
index 0000000..949794c
--- /dev/null
+++ b/src/mirall/discoveryphase.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) by Olivier Goffart <ogoffart at woboq.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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ */
+
+#pragma once
+
+#include <QObject>
+#include <csync.h>
+
+/**
+ * The Discovery Phase was once called "update" phase in csync therms.
+ * Its goal is to look at the files in one of the remote and check comared to the db
+ * if the files are new, or changed.
+ */
+
+class DiscoveryJob : public QObject {
+ Q_OBJECT
+ CSYNC *_csync_ctx;
+ csync_log_callback _log_callback;
+ int _log_level;
+ void* _log_userdata;
+ Q_INVOKABLE void start();
+public:
+ explicit DiscoveryJob(CSYNC *ctx, QObject* parent = 0)
+ : QObject(parent), _csync_ctx(ctx) {
+ // We need to forward the log property as csync uses thread local
+ // and updates run in another thread
+ _log_callback = csync_get_log_callback();
+ _log_level = csync_get_log_level();
+ _log_userdata = csync_get_log_userdata();
+ }
+signals:
+ void finished(int result);
+};
diff --git a/src/mirall/syncengine.cpp b/src/mirall/syncengine.cpp
index 90fa76a..cfff3de 100644
--- a/src/mirall/syncengine.cpp
+++ b/src/mirall/syncengine.cpp
@@ -19,6 +19,7 @@
#include "owncloudpropagator.h"
#include "syncjournaldb.h"
#include "syncjournalfilerecord.h"
+#include "discoveryphase.h"
#include "creds/abstractcredentials.h"
#include "csync_util.h"
@@ -529,21 +530,21 @@ void SyncEngine::startSync()
_stopWatch.start();
- qDebug() << "#### Update start #################################################### >>";
+ qDebug() << "#### Discovery start #################################################### >>";
- UpdateJob *job = new UpdateJob(_csync_ctx);
+ DiscoveryJob *job = new DiscoveryJob(_csync_ctx);
job->moveToThread(&_thread);
- connect(job, SIGNAL(finished(int)), this, SLOT(slotUpdateFinished(int)));
+ connect(job, SIGNAL(finished(int)), this, SLOT(slotDiscoveryJobFinished(int)));
QMetaObject::invokeMethod(job, "start", Qt::QueuedConnection);
}
-void SyncEngine::slotUpdateFinished(int updateResult)
+void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
{
- if (updateResult < 0 ) {
+ if (discoveryResult < 0 ) {
handleSyncError(_csync_ctx, "csync_update");
return;
}
- qDebug() << "<<#### Update end #################################################### " << _stopWatch.addLapTime(QLatin1String("Update Finished"));
+ qDebug() << "<<#### Discovery end #################################################### " << _stopWatch.addLapTime(QLatin1String("Discovery Finished"));
if( csync_reconcile(_csync_ctx) < 0 ) {
handleSyncError(_csync_ctx, "csync_reconcile");
diff --git a/src/mirall/syncengine.h b/src/mirall/syncengine.h
index 5e44d46..ac3df81 100644
--- a/src/mirall/syncengine.h
+++ b/src/mirall/syncengine.h
@@ -88,7 +88,7 @@ private slots:
void slotFinished();
void slotProgress(const SyncFileItem& item, quint64 curent);
void slotAdjustTotalTransmissionSize(qint64 change);
- void slotUpdateFinished(int updateResult);
+ void slotDiscoveryJobFinished(int updateResult);
private:
void handleSyncError(CSYNC *ctx, const char *state);
@@ -142,33 +142,6 @@ private:
};
-class UpdateJob : public QObject {
- Q_OBJECT
- CSYNC *_csync_ctx;
- csync_log_callback _log_callback;
- int _log_level;
- void* _log_userdata;
- Q_INVOKABLE void start() {
- csync_set_log_callback(_log_callback);
- csync_set_log_level(_log_level);
- csync_set_log_userdata(_log_userdata);
- emit finished(csync_update(_csync_ctx));
- deleteLater();
- }
-public:
- explicit UpdateJob(CSYNC *ctx, QObject* parent = 0)
- : QObject(parent), _csync_ctx(ctx) {
- // We need to forward the log property as csync uses thread local
- // and updates run in another thread
- _log_callback = csync_get_log_callback();
- _log_level = csync_get_log_level();
- _log_userdata = csync_get_log_userdata();
- }
-signals:
- void finished(int result);
-};
-
-
}
#endif // CSYNCTHREAD_H
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list