Add option to delete user info

Added prompt after delete local db. Deletes settings.xml
This commit is contained in:
angelblue05 2015-04-12 08:32:25 -05:00
parent 67f90e6dcc
commit 705b5f29d5
2 changed files with 20 additions and 3 deletions

View file

@ -154,10 +154,18 @@ def removeDirectory(path):
def reset(): def reset():
WINDOW = xbmcgui.Window( 10000 )
return_value = xbmcgui.Dialog().yesno("Warning", "Are you sure you want to reset your local database?") return_value = xbmcgui.Dialog().yesno("Warning", "Are you sure you want to reset your local database?")
if return_value == 0: if return_value == 0:
return 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?")
if return_user == 1:
WINDOW.setProperty("EraseUserInfo", "true")
# first stop any db sync # first stop any db sync
WINDOW = xbmcgui.Window( 10000 ) WINDOW = xbmcgui.Window( 10000 )
WINDOW.setProperty("SyncDatabaseShouldStop", "true") WINDOW.setProperty("SyncDatabaseShouldStop", "true")
@ -189,6 +197,6 @@ def reset():
WINDOW.setProperty("SyncInstallRunDone", "false") WINDOW.setProperty("SyncInstallRunDone", "false")
dialog = xbmcgui.Dialog() 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") xbmc.executebuiltin("RestartApp")

View file

@ -1,6 +1,8 @@
import xbmcaddon import xbmcaddon
import xbmc import xbmc
import xbmcgui import xbmcgui
import xbmcvfs
import os import os
import threading import threading
import json import json
@ -118,7 +120,7 @@ class Service():
xbmc.log("Doing_Db_Sync: syncDatabase (Finished) " + str(libSync)) xbmc.log("Doing_Db_Sync: syncDatabase (Finished) " + str(libSync))
countSync = librarySync.updatePlayCounts() countSync = librarySync.updatePlayCounts()
xbmc.log("Doing_Db_Sync: updatePlayCounts (Finished) " + str(countSync)) xbmc.log("Doing_Db_Sync: updatePlayCounts (Finished) " + str(countSync))
xbmc.executebuiltin("UpdateLibrary(video)")
if(libSync and countSync): if(libSync and countSync):
startupComplete = True startupComplete = True
else: else:
@ -133,10 +135,17 @@ class Service():
# If user reset library database. # If user reset library database.
WINDOW = xbmcgui.Window(10000) WINDOW = xbmcgui.Window(10000)
if WINDOW.getProperty("SyncInstallRunDone") == "false":
addon = xbmcaddon.Addon('plugin.video.emby') addon = xbmcaddon.Addon('plugin.video.emby')
if WINDOW.getProperty("SyncInstallRunDone") == "false":
addon.setSetting("SyncInstallRunDone", "false") addon.setSetting("SyncInstallRunDone", "false")
if WINDOW.getProperty("EraseUserInfo") == "true":
addondir = xbmc.translatePath(addon.getAddonInfo('profile'))
dataPath = os.path.join(addondir + "settings.xml")
xbmcvfs.delete(dataPath)
xbmc.log("Deleted saved user information for: %s" % user.currUser)
if (self.newWebSocketThread != None): if (self.newWebSocketThread != None):
ws.stopClient() ws.stopClient()