# Path: resources/lib/kodi_utils.py
# class HomeWindow:
#     """
#         xbmcgui.Window(10000) with add-on id prefixed to keys
#     """
# 
#     def __init__(self):
#         self.id_string = 'plugin.video.embycon-%s'
#         self.window = xbmcgui.Window(10000)
# 
#     def get_property(self, key):
#         key = self.id_string % key
#         value = self.window.getProperty(key)
#         # log.debug('HomeWindow: getProperty |{0}| -> |{1}|', key, value)
#         return value
# 
#     def set_property(self, key, value):
#         key = self.id_string % key
#         # log.debug('HomeWindow: setProperty |{0}| -> |{1}|', key, value)
#         self.window.setProperty(key, value)
# 
#     def clear_property(self, key):
#         key = self.id_string % key
#         # log.debug('HomeWindow: clearProperty |{0}|', key)
#         self.window.clearProperty(key)
# 
# Path: resources/lib/simple_logging.py
# class SimpleLogging:
#     name = ""
#     enable_logging = False
# 
#     def __init__(self, name):
#         settings = xbmcaddon.Addon()
#         prefix = settings.getAddonInfo('name')
#         self.name = prefix + '.' + name
#         self.enable_logging = settings.getSetting('log_debug') == "true"
# 
#         # params = {"setting": "debug.showloginfo"}
#         # setting_result = json_rpc('Settings.getSettingValue').execute(params)
#         # current_value = setting_result.get("result", None)
#         # if current_value is not None:
#         #     self.enable_logging = current_value.get("value", False)
#         # xbmc.log("LOGGING_ENABLED %s : %s" % (self.name, str(self.enable_logging)), level=xbmc.LOGDEBUG)
# 
#     def __str__(self):
#         return "LoggingEnabled: " + str(self.enable_logging)
# 
#     def info(self, fmt, *args, **kwargs):
#         log_line = self.name + "|INFO|" + self.log_line(fmt, *args)
#         xbmc.log(log_line, level=xbmc.LOGNOTICE)
# 
#     def error(self, fmt, *args, **kwargs):
#         log_line = self.name + "|ERROR|" + self.log_line(fmt, *args)
#         xbmc.log(log_line, level=xbmc.LOGERROR)
# 
#     def debug(self, fmt, *args, **kwargs):
#         if self.enable_logging:
#             log_line = self.name + "|DEBUG|" + self.log_line(fmt, *args)
#             xbmc.log(log_line, level=xbmc.LOGNOTICE)
# 
#     @staticmethod
#     def log_line(fmt, *args):
#         new_args = []
#         # convert any unicode to utf-8 strings
#         for arg in args:
#             if isinstance(arg, unicode):
#                 new_args.append(arg.encode("utf-8"))
#             else:
#                 new_args.append(arg)
#         log_line = fmt.format(*new_args)
#         return log_line


from uuid import uuid4 as uuid4
from .kodi_utils import HomeWindow
from .simple_logging import SimpleLogging
import xbmcaddon
import xbmc
import xbmcvfs
        if client_id:
            return client_id

        emby_guid_path = xbmc.translatePath("special://temp/embycon_guid").decode('utf-8')
        log.debug("emby_guid_path: {0}", emby_guid_path)
        guid = xbmcvfs.File(emby_guid_path)
        client_id = guid.read()
        guid.close()

        if not client_id:
            client_id = str("%012X" % uuid4())
            log.debug("Generating a new guid: {0}", client_id)
            guid = xbmcvfs.File(emby_guid_path, 'w')
            guid.write(client_id)
            guid.close()
            log.debug("emby_client_id (NEW): {0}", client_id)
        else:
            log.debug("emby_client_id: {0}", client_id)

        window.set_property("client_id", client_id)
        return client_id

    @staticmethod
    def get_version():
        addon = xbmcaddon.Addon()
        version = addon.getAddonInfo("version")
        return version

    @staticmethod
    def get_client():

# Path: resources/lib/kodi_utils.py
# class HomeWindow:
#     """
#         xbmcgui.Window(10000) with add-on id prefixed to keys
#     """
# 
#     def __init__(self):
#         self.id_string = 'plugin.video.embycon-%s'
#         self.window = xbmcgui.Window(10000)
# 
#     def get_property(self, key):
#         key = self.id_string % key
#         value = self.window.getProperty(key)
#         # log.debug('HomeWindow: getProperty |{0}| -> |{1}|', key, value)
#         return value
# 
#     def set_property(self, key, value):
#         key = self.id_string % key
#         # log.debug('HomeWindow: setProperty |{0}| -> |{1}|', key, value)
#         self.window.setProperty(key, value)
# 
#     def clear_property(self, key):
#         key = self.id_string % key
#         # log.debug('HomeWindow: clearProperty |{0}|', key)
#         self.window.clearProperty(key)
# 
# Path: resources/lib/simple_logging.py
# class SimpleLogging:
#     name = ""
#     enable_logging = False
# 
#     def __init__(self, name):
#         settings = xbmcaddon.Addon()
#         prefix = settings.getAddonInfo('name')
#         self.name = prefix + '.' + name
#         self.enable_logging = settings.getSetting('log_debug') == "true"
# 
#         # params = {"setting": "debug.showloginfo"}
#         # setting_result = json_rpc('Settings.getSettingValue').execute(params)
#         # current_value = setting_result.get("result", None)
#         # if current_value is not None:
#         #     self.enable_logging = current_value.get("value", False)
#         # xbmc.log("LOGGING_ENABLED %s : %s" % (self.name, str(self.enable_logging)), level=xbmc.LOGDEBUG)
# 
#     def __str__(self):
#         return "LoggingEnabled: " + str(self.enable_logging)
# 
#     def info(self, fmt, *args, **kwargs):
#         log_line = self.name + "|INFO|" + self.log_line(fmt, *args)
#         xbmc.log(log_line, level=xbmc.LOGNOTICE)
# 
#     def error(self, fmt, *args, **kwargs):
#         log_line = self.name + "|ERROR|" + self.log_line(fmt, *args)
#         xbmc.log(log_line, level=xbmc.LOGERROR)
# 
#     def debug(self, fmt, *args, **kwargs):
#         if self.enable_logging:
#             log_line = self.name + "|DEBUG|" + self.log_line(fmt, *args)
#             xbmc.log(log_line, level=xbmc.LOGNOTICE)
# 
#     @staticmethod
#     def log_line(fmt, *args):
#         new_args = []
#         # convert any unicode to utf-8 strings
#         for arg in args:
#             if isinstance(arg, unicode):
#                 new_args.append(arg.encode("utf-8"))
#             else:
#                 new_args.append(arg)
#         log_line = fmt.format(*new_args)
#         return log_line


# Path: resources/lib/clientinfo.py
from uuid import uuid4 as uuid4
from .kodi_utils import HomeWindow
from .simple_logging import SimpleLogging
import xbmcaddon
import xbmc
import xbmcvfs

        if client_id:
            return client_id

        emby_guid_path = xbmc.translatePath("special://temp/embycon_guid").decode('utf-8')
        log.debug("emby_guid_path: {0}", emby_guid_path)
        guid = xbmcvfs.File(emby_guid_path)
        client_id = guid.read()
        guid.close()

        if not client_id:
            client_id = str("%012X" % uuid4())
            log.debug("Generating a new guid: {0}", client_id)
            guid = xbmcvfs.File(emby_guid_path, 'w')
            guid.write(client_id)
            guid.close()
            log.debug("emby_client_id (NEW): {0}", client_id)
        else:
            log.debug("emby_client_id: {0}", client_id)

        window.set_property("client_id", client_id)
        return client_id

    @staticmethod
    def get_version():
        addon = xbmcaddon.Addon()
        version = addon.getAddonInfo("version")
        return version

    @staticmethod
    def get_client():

        return 'Kodi EmbyCon'