# Path: resources/lib/views/hostcontextmenu.py
# class HostContextMenu(xbmcgui.WindowXMLDialog):
#     def __new__(cls, *args, **kwargs):
#         return super(HostContextMenu, cls).__new__(cls, 'lunacontextmenu.xml', xbmcaddon.Addon().getAddonInfo('path'))
# 
#     def __init__(self, host, controller):
#         super(HostContextMenu, self).__init__('lunacontextmenu.xml', xbmcaddon.Addon().getAddonInfo('path'))
#         self.host = host
#         self.controller = controller
#         self.list = None
# 
#     def onInit(self):
#         self.list = self.getControl(70)
#         self.build_list()
#         self.setFocus(self.list)
# 
#     def build_list(self):
#         items = ['Wake Host', 'Remove Host']
#         self.list.addItems(items)
# 
#     def onAction(self, action):
#         if action == xbmcgui.ACTION_NAV_BACK:
#             self.close()
# 
#         focus_item_id = self.getFocusId()
# 
#         if focus_item_id:
#             focus_item = self.getControl(focus_item_id)
# 
#             if focus_item == self.list and action == xbmcgui.ACTION_SELECT_ITEM:
#                 selected_position = self.list.getSelectedPosition()
#                 if selected_position == 0:
#                     self.controller.render('host_wake', {'host': self.host})
#                     self.close()
#                 if selected_position == 1:
#                     self.controller.render('main_host_remove', {'host': self.host})
#                     self.close()
# 
# Path: resources/lib/views/windowxml.py
# class WindowXML(_BaseWindow, _WindowXML):
#     def __init__(self, xml_filename, script_path):
#         _WindowXML.__init__(self, xml_filename, script_path)
#         _BaseWindow.__init__(self)


import os
import xbmcaddon
import xbmcgui
            import xbmc
from resources.lib.views.hostcontextmenu import HostContextMenu
from resources.lib.views.windowxml import WindowXML
        self.options_list.reset()
        self.host_index_key_map.clear()
        self.build_list()

    def update_host_status(self, hosts):
        while len(hosts) != len(self.host_index_key_map):
            xbmc.sleep(500)

        for key, host in hosts.iteritems():
            index = self.host_index_key_map[key]
            list_item = self.list.getListItem(index)
            list_item.setProperty('state', str(host[0].state))

        return

    def onAction(self, action):
        if action == xbmcgui.ACTION_NAV_BACK:
            self.close()

        focus_item_id = self.getFocusId()

        if focus_item_id:
            focus_item = self.getControl(focus_item_id)

            if focus_item == self.options_list:
                if action == xbmcgui.ACTION_SELECT_ITEM:
                    # TODO: Assign actions as item properties and call them
                    if self.options_list.getSelectedPosition() == 0:
                        self.controller.render('settings_index')
                    if self.options_list.getSelectedPosition() == 1:

# Path: resources/lib/views/hostcontextmenu.py
# class HostContextMenu(xbmcgui.WindowXMLDialog):
#     def __new__(cls, *args, **kwargs):
#         return super(HostContextMenu, cls).__new__(cls, 'lunacontextmenu.xml', xbmcaddon.Addon().getAddonInfo('path'))
# 
#     def __init__(self, host, controller):
#         super(HostContextMenu, self).__init__('lunacontextmenu.xml', xbmcaddon.Addon().getAddonInfo('path'))
#         self.host = host
#         self.controller = controller
#         self.list = None
# 
#     def onInit(self):
#         self.list = self.getControl(70)
#         self.build_list()
#         self.setFocus(self.list)
# 
#     def build_list(self):
#         items = ['Wake Host', 'Remove Host']
#         self.list.addItems(items)
# 
#     def onAction(self, action):
#         if action == xbmcgui.ACTION_NAV_BACK:
#             self.close()
# 
#         focus_item_id = self.getFocusId()
# 
#         if focus_item_id:
#             focus_item = self.getControl(focus_item_id)
# 
#             if focus_item == self.list and action == xbmcgui.ACTION_SELECT_ITEM:
#                 selected_position = self.list.getSelectedPosition()
#                 if selected_position == 0:
#                     self.controller.render('host_wake', {'host': self.host})
#                     self.close()
#                 if selected_position == 1:
#                     self.controller.render('main_host_remove', {'host': self.host})
#                     self.close()
# 
# Path: resources/lib/views/windowxml.py
# class WindowXML(_BaseWindow, _WindowXML):
#     def __init__(self, xml_filename, script_path):
#         _WindowXML.__init__(self, xml_filename, script_path)
#         _BaseWindow.__init__(self)


# Path: resources/lib/views/main.py
import os
import xbmcaddon
import xbmcgui
            import xbmc
from resources.lib.views.hostcontextmenu import HostContextMenu
from resources.lib.views.windowxml import WindowXML

        self.options_list.reset()
        self.host_index_key_map.clear()
        self.build_list()

    def update_host_status(self, hosts):
        while len(hosts) != len(self.host_index_key_map):
            xbmc.sleep(500)

        for key, host in hosts.iteritems():
            index = self.host_index_key_map[key]
            list_item = self.list.getListItem(index)
            list_item.setProperty('state', str(host[0].state))

        return

    def onAction(self, action):
        if action == xbmcgui.ACTION_NAV_BACK:
            self.close()

        focus_item_id = self.getFocusId()

        if focus_item_id:
            focus_item = self.getControl(focus_item_id)

            if focus_item == self.options_list:
                if action == xbmcgui.ACTION_SELECT_ITEM:
                    # TODO: Assign actions as item properties and call them
                    if self.options_list.getSelectedPosition() == 0:
                        self.controller.render('settings_index')
                    if self.options_list.getSelectedPosition() == 1:

                        self.controller.render('controller_select')