From 0ba24d8dbdcfed81e906aec45214c8abe2bf4f99 Mon Sep 17 00:00:00 2001
From: angelblue05 <tamara.angel05@gmail.com>
Date: Sun, 12 Apr 2015 04:49:02 -0500
Subject: [PATCH] Fix for db reset

setSetting() now works to reset the initial scan state. I also removed
deprecated behavior from addon.xml
---
 addon.xml              | 2 +-
 resources/lib/Utils.py | 3 +--
 service.py             | 6 ++++++
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/addon.xml b/addon.xml
index 7676aa3f..a578717d 100644
--- a/addon.xml
+++ b/addon.xml
@@ -6,7 +6,7 @@
   <requires>
     <import addon="xbmc.python" version="2.1.0"/>
   </requires>
-  <extension    point="xbmc.python.pluginsource"
+  <extension    point="xbmc.python.script"
                 library="default.py">
         <provides>executable video audio image</provides>
   </extension>
diff --git a/resources/lib/Utils.py b/resources/lib/Utils.py
index 4c82ddbc..6d6d5309 100644
--- a/resources/lib/Utils.py
+++ b/resources/lib/Utils.py
@@ -186,8 +186,7 @@ def reset():
     cursor.close()
     
     # reset the install run flag
-    addon = xbmcaddon.Addon(id='plugin.video.emby')
-    addon.setSetting("SyncInstallRunDone", "false") # this is not working for some reason
+    WINDOW.setProperty("SyncInstallRunDone", "false")
 
     dialog = xbmcgui.Dialog()
     dialog.ok('Emby Reset', 'Database reset has completed, kodi will now restart to apply the changes.')
diff --git a/service.py b/service.py
index 8b41ab4a..95b32aff 100644
--- a/service.py
+++ b/service.py
@@ -130,6 +130,12 @@ class Service():
                     xbmc.log("Not authenticated yet")
                     
         utils.logMsg("MB3 Sync Service", "stopping Service",0)
+
+        # If user reset library database.
+        WINDOW = xbmcgui.Window(10000)
+        if WINDOW.getProperty("SyncInstallRunDone") == "false":
+            addon = xbmcaddon.Addon('plugin.video.emby')
+            addon.setSetting("SyncInstallRunDone", "false")
         
         if (self.newWebSocketThread != None):
             ws.stopClient()