SocketAPI: Don't use ERROR for SoftErrors #3944
authorChristian Kamm <mail@ckamm.de>
Thu, 10 Dec 2015 09:42:49 +0000 (10:42 +0100)
committerChristian Kamm <mail@ckamm.de>
Thu, 10 Dec 2015 10:02:38 +0000 (11:02 +0100)
src/gui/folder.cpp
src/libsync/syncfileitem.h

index f23b5d8c8cf449972efbc50c5ee4f2182c5cc3a4..d15efbf6ce5af4520c9849aa4f058ca6c7e4f531 100644 (file)
@@ -622,9 +622,24 @@ void Folder::slotWatchedPathChanged(const QString& path)
     }
 }
 
+/**
+ * Whether this item should get an ERROR icon through the Socket API.
+ *
+ * The Socket API should only present serious, permanent errors to the user.
+ * In particular SoftErrors should just retain their 'needs to be synced'
+ * icon as the problem is most likely going to resolve itself quickly and
+ * automatically.
+ */
+static bool showErrorInSocketApi(const SyncFileItem& item)
+{
+    const auto status = item._status;
+    return status == SyncFileItem::NormalError
+        || status == SyncFileItem::FatalError;
+}
+
 static void addErroredSyncItemPathsToList(const SyncFileItemVector& items, QSet<QString>* set) {
-    Q_FOREACH(const SyncFileItemPtr &item, items) {
-        if (item->hasErrorStatus()) {
+    foreach (const SyncFileItemPtr &item, items) {
+        if (showErrorInSocketApi(*item)) {
             set->insert(item->_file);
         }
     }
@@ -1090,7 +1105,7 @@ void Folder::slotTransmissionProgress(const ProgressInfo &pi)
 // a item is completed: count the errors and forward to the ProgressDispatcher
 void Folder::slotItemCompleted(const SyncFileItem &item, const PropagatorJob& job)
 {
-    if (item.hasErrorStatus()) {
+    if (showErrorInSocketApi(item)) {
         _stateLastSyncItemsWithErrorNew.insert(item._file);
     }
 
index 1642ab27faed6041265b3d750b8f57a3e38ef668..26c9ed4ef3ba9519cf2e2b7d41023d824fa5a05c 100644 (file)
@@ -118,6 +118,13 @@ public:
         return _file.isEmpty();
     }
 
+    /**
+     * True if the item had any kind of error.
+     *
+     * Used for deciding whether an item belongs to the protocol or the
+     * issues list on the activity page and for checking whether an
+     * item should be announced in the notification message.
+     */
     bool hasErrorStatus() const {
         return _status == SyncFileItem::SoftError
                 || _status == SyncFileItem::NormalError