[Pkg-owncloud-commits] [owncloud-client] 63/332: SocketAPI: broadcast change when an item is done

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Aug 14 21:06:38 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 abf0f90a13fc1b592eeb1923bf90b8e93c58c7f1
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Fri Jun 6 15:52:55 2014 +0200

    SocketAPI: broadcast change when an item is done
---
 src/mirall/folder.cpp           | 20 +++++++++++++-------
 src/mirall/folder.h             |  1 +
 src/mirall/progressdispatcher.h |  6 ++++++
 src/mirall/socketapi.cpp        | 18 ++++++++++++++++++
 src/mirall/socketapi.h          |  3 +++
 5 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp
index 7e7ebdf..86d2069 100644
--- a/src/mirall/folder.cpp
+++ b/src/mirall/folder.cpp
@@ -603,6 +603,7 @@ void Folder::startSync(const QStringList &pathList)
     connect(_engine.data(), SIGNAL(aboutToRemoveAllFiles(SyncFileItem::Direction,bool*)),
                     SLOT(slotAboutToRemoveAllFiles(SyncFileItem::Direction,bool*)));
     connect(_engine.data(), SIGNAL(transmissionProgress(Progress::Info)), this, SLOT(slotTransmissionProgress(Progress::Info)));
+    connect(_engine.data(), SIGNAL(jobCompleted(SyncFileItem)), this, SLOT(slotJobCompleted(SyncFileItem)));
 
     QMetaObject::invokeMethod(_engine.data(), "startSync", Qt::QueuedConnection);
 
@@ -686,19 +687,24 @@ void Folder::slotEmitFinishedDelayed()
 // and hand the result over to the progress dispatcher.
 void Folder::slotTransmissionProgress(const Progress::Info &pi)
 {
-    if (!pi._lastCompletedItem.isEmpty()
-            && Progress::isWarningKind(pi._lastCompletedItem._status)) {
-        // Count all error conditions.
-        _syncResult.setWarnCount(_syncResult.warnCount()+1);
-    }
-
-    // remember problems happening to set the correct Sync status in slot slotCSyncFinished.
     if( pi._completedFileCount ) {
+        // No job completed yet, this is the beginning of a sync, set the warning level to 0
         _syncResult.setWarnCount(0);
     }
     ProgressDispatcher::instance()->setProgressInfo(alias(), pi);
 }
 
+// a job is completed: count the errors and forward to the ProgressDispatcher
+void Folder::slotJobCompleted(const SyncFileItem &item)
+{
+    if (Progress::isWarningKind(item._status)) {
+        // Count all error conditions.
+        _syncResult.setWarnCount(_syncResult.warnCount()+1);
+    }
+    emit ProgressDispatcher::instance()->jobCompleted(alias(), item);
+}
+
+
 void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction direction, bool *cancel)
 {
 #ifndef TOKEN_AUTH_ONLY
diff --git a/src/mirall/folder.h b/src/mirall/folder.h
index 575b601..2615a17 100644
--- a/src/mirall/folder.h
+++ b/src/mirall/folder.h
@@ -185,6 +185,7 @@ private slots:
     void slotSyncFinished();
 
     void slotTransmissionProgress(const Progress::Info& pi);
+    void slotJobCompleted(const SyncFileItem&);
 
     void slotPollTimerTimeout();
     void etagRetreived(const QString &);
diff --git a/src/mirall/progressdispatcher.h b/src/mirall/progressdispatcher.h
index 73fb62b..603be1b 100644
--- a/src/mirall/progressdispatcher.h
+++ b/src/mirall/progressdispatcher.h
@@ -103,6 +103,7 @@ public:
     static ProgressDispatcher* instance();
     ~ProgressDispatcher();
 
+
 signals:
     /**
       @brief Signals the progress of data transmission.
@@ -113,6 +114,11 @@ signals:
      */
     void progressInfo( const QString& folder, const Progress::Info& progress );
 
+    /**
+     * @brief: the item's job is completed
+     */
+    void jobCompleted(const QString &folder, const SyncFileItem & item);
+
 protected:
     void setProgressInfo(const QString& folder, const Progress::Info& progress);
 
diff --git a/src/mirall/socketapi.cpp b/src/mirall/socketapi.cpp
index f1df5a2..231e9e2 100644
--- a/src/mirall/socketapi.cpp
+++ b/src/mirall/socketapi.cpp
@@ -61,6 +61,7 @@ SocketApi::SocketApi(QObject* parent, const QUrl& localFile)
 
     // folder watcher
     connect(FolderMan::instance(), SIGNAL(folderSyncStateChange(QString)), SLOT(slotSyncStateChanged(QString)));
+    connect(ProgressDispatcher::instance(), SIGNAL(jobCompleted(QString,SyncFileItem)), SLOT(slotJobCompleted(QString,SyncFileItem)));
 }
 
 SocketApi::~SocketApi()
@@ -119,6 +120,23 @@ void SocketApi::slotSyncStateChanged(const QString&)
     broadcastMessage("UPDATE_VIEW");
 }
 
+void SocketApi::slotJobCompleted(const QString &folder, const SyncFileItem &item)
+{
+    Folder *f = FolderMan::instance()->folder(folder);
+    if (!f)
+        return;
+
+    const QString path = f->path() + item.destination();
+
+    QString command = QLatin1String("OK");
+    if (Progress::isWarningKind(item._status)) {
+        command = QLatin1String("ERROR");
+    }
+
+    broadcastMessage(QLatin1String("BROADCAST:") + command + QLatin1Char(':') + path);
+}
+
+
 
 void SocketApi::sendMessage(QLocalSocket* socket, const QString& message)
 {
diff --git a/src/mirall/socketapi.h b/src/mirall/socketapi.h
index be0572e..3e3f90f 100644
--- a/src/mirall/socketapi.h
+++ b/src/mirall/socketapi.h
@@ -25,6 +25,8 @@ class QStringList;
 
 namespace Mirall {
 
+class SyncFileItem;
+
 class SocketApi : public QObject
 {
 Q_OBJECT
@@ -38,6 +40,7 @@ private slots:
     void onLostConnection();
     void slotReadSocket();
     void slotSyncStateChanged(const QString&);
+    void slotJobCompleted(const QString &, const SyncFileItem &);
 
 private:
     void sendMessage(QLocalSocket* socket, const QString& message);

-- 
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