From 060a6f132327da31c1be09039f766c879f75c7ef Mon Sep 17 00:00:00 2001
From: angelblue05 <tamara.angel05@gmail.com>
Date: Sun, 12 Apr 2015 08:49:36 -0500
Subject: [PATCH] Add option to delete user info

Added for testing update library to force refresh newly set thumbnails
after first sync (only).
---
 resources/lib/Utils.py | 19 ++++++++++++++++++-
 service.py             |  2 ++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/resources/lib/Utils.py b/resources/lib/Utils.py
index 6d6d5309..c84da723 100644
--- a/resources/lib/Utils.py
+++ b/resources/lib/Utils.py
@@ -154,9 +154,20 @@ def removeDirectory(path):
         
 def reset():
 
+    WINDOW = xbmcgui.Window( 10000 )
+    username = WINDOW.getProperty('currUser')
+
+    user_delete = False
     return_value = xbmcgui.Dialog().yesno("Warning", "Are you sure you want to reset your local database?")
+
     if return_value == 0:
         return
+
+    # Ask if user information should be deleted too.
+    return_user = xbmcgui.Dialog().yesno("Warning", "Do you wish to erase your saved Emby user information for %s?" % username)
+
+    if return_user == 1:
+        user_delete = True
     
     # first stop any db sync
     WINDOW = xbmcgui.Window( 10000 )
@@ -188,7 +199,13 @@ def reset():
     # reset the install run flag
     WINDOW.setProperty("SyncInstallRunDone", "false")
 
+    if (user_delete == True):
+        addondir = xbmc.translatePath(addonSettings.getAddonInfo('profile'))
+        dataPath = os.path.join(addondir + "settings.xml")
+        xbmcvfs.delete(dataPath)
+        xbmc.log("Deleted saved user information for: %s" % username)
+
     dialog = xbmcgui.Dialog()
-    dialog.ok('Emby Reset', 'Database reset has completed, kodi will now restart to apply the changes.')
+    dialog.ok('Emby Reset', 'Database reset has completed, Kodi will now restart to apply the changes.')
     xbmc.executebuiltin("RestartApp")
      
diff --git a/service.py b/service.py
index 95b32aff..edb25b37 100644
--- a/service.py
+++ b/service.py
@@ -119,6 +119,8 @@ class Service():
                         countSync = librarySync.updatePlayCounts()
                         xbmc.log("Doing_Db_Sync: updatePlayCounts (Finished) "  + str(countSync))
 
+                        # Force refresh newly set thumbnails
+                        xbmc.executebuiltin("UpdateLibrary(video)")
                         if(libSync and countSync):
                             startupComplete = True
                     else: