From f99efb2a8317f20f7b5bd8189ddb4ab442b27906 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Sat, 9 Jan 2016 04:53:04 -0600 Subject: [PATCH] Add settings monitor Prompt for reset if playback mode change is detected --- resources/lib/kodimonitor.py | 22 ++++++++++++++++++++++ resources/lib/userclient.py | 10 ---------- service.py | 1 + 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index fe22a270..80e664f6 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -43,6 +43,28 @@ class KodiMonitor(xbmc.Monitor): if library == "video": utils.window('emby_kodiScan', clear=True) + def onSettingsChanged(self): + # Monitor emby settings + currentPath = utils.settings('useDirectPaths') + if utils.window('emby_pluginpath') != currentPath: + # Plugin path value changed. Offer to reset + self.logMsg("Changed to playback mode detected", 1) + utils.window('emby_pluginpath', value=currentPath) + resp = xbmcgui.Dialog().yesno( + heading="Playback mode change detected", + line1=( + "Detected the playback mode has changed. The database " + "needs to be recreated for the change to be applied. " + "Proceed?")) + if resp: + utils.reset() + + currentLog = utils.settings('logLevel') + if utils.window('emby_logLevel') != currentLog: + # The log level changed, set new prop + self.logMsg("New log level: %s" % currentLog, 1) + utils.window('emby_logLevel', value=currentLog) + def onNotification(self, sender, method, data): doUtils = self.doUtils diff --git a/resources/lib/userclient.py b/resources/lib/userclient.py index 035cf784..9b4bce17 100644 --- a/resources/lib/userclient.py +++ b/resources/lib/userclient.py @@ -44,7 +44,6 @@ class UserClient(threading.Thread): self.addonName = clientinfo.ClientInfo().getAddonName() self.doUtils = downloadutils.DownloadUtils() - self.logLevel = int(utils.settings('logLevel')) threading.Thread.__init__(self) @@ -411,15 +410,6 @@ class UserClient(threading.Thread): while not monitor.abortRequested(): - # Verify the log level - currLogLevel = self.getLogLevel() - if self.logLevel != currLogLevel: - # Set new log level - self.logLevel = currLogLevel - utils.window('emby_logLevel', value=str(currLogLevel)) - self.logMsg("New Log Level: %s" % currLogLevel, 0) - - status = utils.window('emby_serverStatus') if status: # Verify the connection status to server diff --git a/service.py b/service.py index 2c97d50e..cfd36fdb 100644 --- a/service.py +++ b/service.py @@ -55,6 +55,7 @@ class Service(): utils.window('emby_logLevel', value=str(logLevel)) utils.window('emby_kodiProfile', value=xbmc.translatePath("special://profile")) + utils.window('emby_pluginpath', value=utils.settings('useDirectPaths')) # Initial logging self.logMsg("======== START %s ========" % self.addonName, 0)