[Pkg-owncloud-commits] [owncloud-client] 56/333: OwncloudCmd: Print update phase duration values
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu Apr 17 23:16:33 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 63083a558bb695a97c7f56f011dc6cb50eb8ade2
Author: Markus Goetz <markus at woboq.com>
Date: Wed Feb 19 10:51:04 2014 +0100
OwncloudCmd: Print update phase duration values
---
src/CMakeLists.txt | 1 +
src/mirall/csyncthread.cpp | 20 +++++++++++---------
src/mirall/progressdispatcher.cpp | 10 ++++++++++
src/mirall/progressdispatcher.h | 6 +++++-
src/owncloudcmd/owncloudcmd.cpp | 32 +++++++++++++++++++++++++++++++-
5 files changed, 58 insertions(+), 11 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 81b3ccf..82f1418 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -439,6 +439,7 @@ endif()
set(owncloudcmd_NAME ${APPLICATION_EXECUTABLE}cmd)
set(OWNCLOUDCMD_SRC owncloudcmd/owncloudcmd.cpp)
+qt_wrap_cpp(OWNCLOUDCMD_MOCS owncloudcmd/owncloudcmd.cpp)
add_executable(${owncloudcmd_NAME} ${OWNCLOUDCMD_SRC})
qt5_use_modules(${owncloudcmd_NAME} Network Sql)
set_target_properties(${owncloudcmd_NAME} PROPERTIES
diff --git a/src/mirall/csyncthread.cpp b/src/mirall/csyncthread.cpp
index c20d601..0589c9c 100644
--- a/src/mirall/csyncthread.cpp
+++ b/src/mirall/csyncthread.cpp
@@ -411,19 +411,21 @@ void CSyncThread::handleSyncError(CSYNC *ctx, const char *state) {
static void updater_progress_callback(CSYNC_PROGRESS *progress, void *userdata)
{
- static QElapsedTimer localTimer;
- static QElapsedTimer remoteTimer;
+ Progress::Info pInfo;
if (progress->kind == CSYNC_NOTIFY_START_LOCAL_UPDATE) {
- localTimer.start();
+ pInfo.kind = Progress::StartLocalUpdate;
} else if (progress->kind == CSYNC_NOTIFY_FINISHED_LOCAL_UPDATE) {
- // There is also localTimer.nsecsElapsed()
- qDebug() << "Local Update took" << localTimer.elapsed() << "msec";
+ pInfo.kind = Progress::EndLocalUpdate;
} else if (progress->kind == CSYNC_NOTIFY_START_REMOTE_UPDATE) {
- remoteTimer.start();
+ pInfo.kind = Progress::StartRemoteUpdate;
} else if (progress->kind == CSYNC_NOTIFY_FINISHED_REMOTE_UPDATE) {
- qDebug() << "Remote Update took" << remoteTimer.elapsed() << "msec";
+ pInfo.kind = Progress::EndRemoteUpdate;
+ } else {
+ return; // FIXME, but most progress stuff should come from the new propagator
}
-
+ pInfo.timestamp = QDateTime::currentDateTime();
+ CSyncThread *self = static_cast<CSyncThread*>(userdata);
+ emit self->transmissionProgress( pInfo );
}
void CSyncThread::startSync()
@@ -506,7 +508,7 @@ void CSyncThread::startSync()
// csync_set_auth_callback( _csync_ctx, getauth );
csync_set_log_callback( csyncLogCatcher );
- csync_set_log_level( 11 );
+ //csync_set_log_level( 11 ); don't set the loglevel here, it shall be done by folder.cpp or owncloudcmd.cpp
_syncTime.start();
diff --git a/src/mirall/progressdispatcher.cpp b/src/mirall/progressdispatcher.cpp
index 4b5a6d9..a0e52b3 100644
--- a/src/mirall/progressdispatcher.cpp
+++ b/src/mirall/progressdispatcher.cpp
@@ -64,6 +64,11 @@ QString Progress::asResultString( const Progress::Info& progress)
case EndRename:
re = QCoreApplication::translate( "progress", "Moved to %1").arg(progress.rename_target);
break;
+ case StartLocalUpdate:
+ case EndLocalUpdate:
+ case StartRemoteUpdate:
+ case EndRemoteUpdate:
+ break; // FIXME
default:
Q_ASSERT(false);
}
@@ -118,6 +123,11 @@ QString Progress::asActionString( Kind kind )
case EndRename:
re = QCoreApplication::translate( "progress", "moved");
break;
+ case StartLocalUpdate:
+ case EndLocalUpdate:
+ case StartRemoteUpdate:
+ case EndRemoteUpdate:
+ break; // FIXME
default:
Q_ASSERT(false);
}
diff --git a/src/mirall/progressdispatcher.h b/src/mirall/progressdispatcher.h
index 2b6a597..6a38b6d 100644
--- a/src/mirall/progressdispatcher.h
+++ b/src/mirall/progressdispatcher.h
@@ -46,7 +46,11 @@ namespace Progress
EndRename,
SoftError,
NormalError,
- FatalError
+ FatalError,
+ StartLocalUpdate,
+ EndLocalUpdate,
+ StartRemoteUpdate,
+ EndRemoteUpdate
};
struct Info {
diff --git a/src/owncloudcmd/owncloudcmd.cpp b/src/owncloudcmd/owncloudcmd.cpp
index d8e53a6..e4d7103 100644
--- a/src/owncloudcmd/owncloudcmd.cpp
+++ b/src/owncloudcmd/owncloudcmd.cpp
@@ -30,6 +30,29 @@
using namespace Mirall;
+class OwncloudCmd : public QObject {
+ Q_OBJECT
+public:
+ OwncloudCmd() : QObject() { }
+public slots:
+ void transmissionProgressSlot(Progress::Info pI) {
+ static QElapsedTimer localTimer;
+ static QElapsedTimer remoteTimer;
+ if (pI.kind == Progress::StartLocalUpdate) {
+ localTimer.start();
+ } else if (pI.kind == Progress::EndLocalUpdate) {
+ // There is also localTimer.nsecsElapsed()
+ qDebug() << "Local Update took" << localTimer.elapsed() << "msec";
+ } else if (pI.kind == Progress::StartRemoteUpdate) {
+ remoteTimer.start();
+ } else if (pI.kind == Progress::EndRemoteUpdate) {
+ qDebug() << "Remote Update took" << remoteTimer.elapsed() << "msec";
+ }
+ }
+};
+#include "owncloudcmd/moc_owncloudcmd.cpp"
+
+
int getauth(const char* prompt, char* buf, size_t len, int echo, int verify, void*)
{
std::cout << "** Authentication required: \n" << prompt << std::endl;
@@ -44,6 +67,7 @@ struct CmdOptions {
QString target_url;
QString config_directory;
QString proxy;
+ bool silent;
};
void help()
@@ -56,6 +80,7 @@ void help()
std::cout << "uses the setting from a configured sync client." << std::endl;
std::cout << std::endl;
std::cout << "Options:" << std::endl;
+ std::cout << " --silent Don't be so verbose" << std::endl;
std::cout << " --confdir = configdir: Read config from there." << std::endl;
std::cout << " --httpproxy = proxy: Specify a http proxy to use." << std::endl;
std::cout << " Proxy is http://server:port" << std::endl;
@@ -97,6 +122,8 @@ void parseOptions( const QStringList& app_args, CmdOptions *options )
options->config_directory = it.next();
} else if( option == "--httpproxy" && !it.peekNext().startsWith("-")) {
options->proxy = it.next();
+ } else if( option == "--silent") {
+ options->silent = true;
} else {
help();
}
@@ -126,7 +153,7 @@ int main(int argc, char **argv) {
qFatal("ne_sock_init failed!");
}
- csync_set_log_level(11);
+ csync_set_log_level(options.silent ? 1 : 11);
csync_enable_conflictcopys(_csync_ctx);
Logger::instance()->setLogFile("-");
@@ -174,9 +201,12 @@ int main(int argc, char **argv) {
clientProxy.setCSyncProxy(QUrl(url), _csync_ctx);
}
+ OwncloudCmd owncloudCmd;
+
SyncJournalDb db(options.source_dir);
CSyncThread csyncthread(_csync_ctx, options.source_dir, QUrl(options.target_url).path(), &db);
QObject::connect(&csyncthread, SIGNAL(finished()), &app, SLOT(quit()));
+ QObject::connect(&csyncthread, SIGNAL(transmissionProgress(Progress::Info)), &owncloudCmd, SLOT(transmissionProgressSlot(Progress::Info)));
csyncthread.startSync();
app.exec();
--
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