From 2f1fe0ed1f0d8c32f67460403829d779eca01272 Mon Sep 17 00:00:00 2001
From: Patrick Simpson 
Date: Wed, 14 Jun 2017 14:47:25 +0200
Subject: [PATCH 1/4] [KOE-22] Changed string if no shared folders are
 available to indicate this might be a permission issue
---
 .../AcaciaZPushPlugin/Properties/Resources.Designer.cs          | 2 +-
 .../AcaciaZPushPlugin/Properties/Resources.resx                 | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.Designer.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.Designer.cs
index 2187695..fe4a3e3 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.Designer.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.Designer.cs
@@ -1076,7 +1076,7 @@ namespace Acacia.Properties {
         }
         
         /// 
-        ///   Looks up a localized string similar to No shared folders are available.
+        ///   Looks up a localized string similar to No shared folders are available or you do not have permissions to view the root of the inbox..
         /// 
         internal static string SharedFolders_None {
             get {
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.resx b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.resx
index 6e77c5c..3013c37 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.resx
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.resx
@@ -366,7 +366,7 @@
     There was an error retrieving shared folders
   
   
-    No shared folders are available
+    No shared folders are available or you do not have permissions to view the root of the inbox.
   
   
     TreeLoading.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
From ce707469a072e43db3574942fda48e8dcc4877c3 Mon Sep 17 00:00:00 2001
From: Patrick Simpson 
Date: Wed, 14 Jun 2017 15:14:12 +0200
Subject: [PATCH 2/4] Revert "[KOE-115] Added check to sync stall detection to
 see if anything has synced. If not, it's considered a startup delay and
 doesn't trigger the warning"
This reverts commit 21c5da59e6c83d7dcd6b4c14e52e1825e8cf9532.
This approach didn't work
---
 .../Features/SyncState/FeatureSyncState.cs                | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs
index 33a4bdf..ce7978e 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs
@@ -409,11 +409,6 @@ namespace Acacia.Features.SyncState
 
                 return !string.IsNullOrWhiteSpace(content.synckey);
             }
-
-            public bool HasAnythingSynced
-            {
-                get { return Done > 0; }
-            }
         }
 
         private void CheckSyncState(ZPushAccount account)
@@ -508,8 +503,7 @@ namespace Acacia.Features.SyncState
                 if (folderId != null)
                 {
                     SyncSession sync = account.GetFeatureData(this, null);
-                    // If nothing has synced yet, it's probably just a delay
-                    if (!sync.HasAnythingSynced || sync.HasFolderSynced(folderId))
+                    if (sync.HasFolderSynced(folderId))
                         return;
                 }
             }
From db2ad7d83ca22f4c1a1eabf4d4f45ce6273979a5 Mon Sep 17 00:00:00 2001
From: Patrick Simpson 
Date: Wed, 14 Jun 2017 16:08:11 +0200
Subject: [PATCH 3/4] [KOE-115] Added lastsynctime to automatic resync check.
---
 .../Features/SyncState/FeatureSyncState.cs    | 27 +++++++++++++++----
 1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs
index ce7978e..7519300 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs
@@ -99,6 +99,7 @@ namespace Acacia.Features.SyncState
         /// 
         private DateTime? _syncStallStarted;
         private bool _syncStallAsked;
+        private DateTime? _syncStallLastSyncTime;
 
         #endregion
 
@@ -308,6 +309,11 @@ namespace Acacia.Features.SyncState
             {
                 get { return _data.data.contentdata; } 
             }
+
+            public DateTime LastSyncTime
+            {
+                get { return _data.data.lastsynctime; }
+            }
         }
 
         private class GetDeviceDetailsRequest : SoapRequest
@@ -322,6 +328,7 @@ namespace Acacia.Features.SyncState
             public long Total { get; private set; }
             public long Done { get; private set; }
             public bool IsSyncing { get; private set; }
+            public DateTime? LastSyncTime { get; private set; }
 
             private readonly FeatureSyncState _feature;
             private readonly ZPushAccount _account;
@@ -340,6 +347,8 @@ namespace Acacia.Features.SyncState
             {
                 StringBuilder debug = new StringBuilder();
 
+                LastSyncTime = details.LastSyncTime;
+
                 // If a folder is no longer reported as it's already synced, we don't necessarily get the
                 // last step where (done == total). This causes some folders to keep lingering. To clean these
                 // up, keep a list of folders syncing in this iteration.
@@ -495,16 +504,24 @@ namespace Acacia.Features.SyncState
                 string syncId = (string)inbox.GetProperty(OutlookConstants.PR_ZPUSH_SYNC_ID);
 
                 // If it's syncing, it's not stalled
-                if (syncId != null && syncId != "0")
-                    return;
+                //if (syncId != null && syncId != "0")
+                // return;
 
-                // Check if the folder has synced. In that case, it's not stalled.
+                SyncSession sync = account.GetFeatureData(this, null);
+
+                // If the last sync time hasn't changed, it hasn't actually synced yet
+                if (sync.LastSyncTime != null && _syncStallLastSyncTime == sync.LastSyncTime)
+                    return;
+                _syncStallLastSyncTime = sync.LastSyncTime;
+
+                // Get the sync state
                 string folderId = (string)inbox.GetProperty(OutlookConstants.PR_ZPUSH_FOLDER_ID);
                 if (folderId != null)
                 {
-                    SyncSession sync = account.GetFeatureData(this, null);
+
+                    // Check if the folder has synced. In that case, it's not stalled.
                     if (sync.HasFolderSynced(folderId))
-                        return;
+                      return;
                 }
             }
 
From 6b354eadbfdde6e589a59da00f1730f9737d3cda Mon Sep 17 00:00:00 2001
From: Patrick Simpson 
Date: Wed, 21 Jun 2017 16:07:32 +0200
Subject: [PATCH 4/4] Fixed disabled sync stall test
---
 .../AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs
index 7519300..2366ef6 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs
@@ -504,8 +504,8 @@ namespace Acacia.Features.SyncState
                 string syncId = (string)inbox.GetProperty(OutlookConstants.PR_ZPUSH_SYNC_ID);
 
                 // If it's syncing, it's not stalled
-                //if (syncId != null && syncId != "0")
-                // return;
+                if (syncId != null && syncId != "0")
+                    return;
 
                 SyncSession sync = account.GetFeatureData(this, null);