Ejemplo n.º 1
0
 def run(self):
     dbus_utils.LOOP_THREAD.start()
     oe.load_modules()
     oe.start_service()
     service_thread = Service_Thread()
     service_thread.start()
     while not self.abortRequested():
         if self.waitForAbort(60):
             break
         if not oe.read_setting('bluetooth', 'standby'):
             continue
         timeout = oe.read_setting('bluetooth', 'idle_timeout')
         if not timeout:
             continue
         try:
             timeout = int(timeout)
         except:
             continue
         if timeout < 1:
             continue
         if xbmc.getGlobalIdleTime() / 60 >= timeout:
             log.log(f'Idle timeout reached', log.DEBUG)
             oe.standby_devices()
     if hasattr(oe, 'winOeMain') and hasattr(oe.winOeMain, 'visible'):
         if oe.winOeMain.visible == True:
             oe.winOeMain.close()
     oe.stop_service()
     service_thread.stop()
     dbus_utils.LOOP_THREAD.stop()
Ejemplo n.º 2
0
    def load_values(self):
        # Keyboard Layout
        (
            arrLayouts,
            arrTypes,
            self.arrVariants,
        ) = self.get_keyboard_layouts()
        if not arrTypes is None:
            self.struct['keyboard']['settings']['KeyboardType'][
                'values'] = arrTypes
            value = oe.read_setting('system', 'KeyboardType')
            if not value is None:
                self.struct['keyboard']['settings']['KeyboardType'][
                    'value'] = value
        if not arrLayouts is None:
            self.struct['keyboard']['settings']['KeyboardLayout1'][
                'values'] = arrLayouts
            self.struct['keyboard']['settings']['KeyboardLayout2'][
                'values'] = arrLayouts
            value = oe.read_setting('system', 'KeyboardLayout1')
            if not value is None:
                self.struct['keyboard']['settings']['KeyboardLayout1'][
                    'value'] = value
            value = oe.read_setting('system', 'KeyboardVariant1')
            if not value is None:
                self.struct['keyboard']['settings']['KeyboardVariant1'][
                    'value'] = value
            value = oe.read_setting('system', 'KeyboardLayout2')
            if not value is None:
                self.struct['keyboard']['settings']['KeyboardLayout2'][
                    'value'] = value
            value = oe.read_setting('system', 'KeyboardVariant2')
            if not value is None:
                self.struct['keyboard']['settings']['KeyboardVariant2'][
                    'value'] = value
            if not arrTypes == None:
                self.keyboard_layouts = True
        if not os.path.exists('/usr/bin/setxkbmap'):
            self.struct['keyboard']['settings']['KeyboardLayout2'][
                'hidden'] = 'true'
            self.struct['keyboard']['settings']['KeyboardType'][
                'hidden'] = 'true'
            self.struct['keyboard']['settings']['KeyboardVariant1'][
                'hidden'] = 'true'
            self.struct['keyboard']['settings']['KeyboardVariant2'][
                'hidden'] = 'true'
            self.nox_keyboard_layouts = True
        # Hostname
        self.struct['ident']['settings']['hostname'][
            'value'] = hostname.get_hostname()
        # PIN Lock
        self.struct['pinlock']['settings']['pinlock_enable'][
            'value'] = '1' if oe.PIN.isEnabled() else '0'

        # Journal
        self.get_setting('journal', 'journal_persistent')
        self.get_setting('journal', 'journal_size')
        self.get_setting('journal', 'journal_rate_limit')
Ejemplo n.º 3
0
 def standby_devices(self):
     if self.dbusBluezAdapter:
         devices = oe.read_setting('bluetooth', 'standby')
         if devices:
             for device in devices.split(','):
                 if dbus_bluez.device_get_connected(device):
                     self.disconnect_device_by_path(device)
Ejemplo n.º 4
0
    def load_values(self):
        # Hardware flags
        self.hardware_flags = self.get_hardware_flags()
        oe.dbg_log('system::load_values', f'loaded hardware_flag {self.hardware_flags}', oe.LOGDEBUG)

        # AutoUpdate

        value = oe.read_setting('updates', 'AutoUpdate')
        if not value is None:
            self.struct['update']['settings']['AutoUpdate']['value'] = value
        value = oe.read_setting('updates', 'SubmitStats')
        if not value is None:
            self.struct['update']['settings']['SubmitStats']['value'] = value
        value = oe.read_setting('updates', 'UpdateNotify')
        if not value is None:
            self.struct['update']['settings']['UpdateNotify']['value'] = value
        if os.path.isfile(f'{self.LOCAL_UPDATE_DIR}/SYSTEM'):
            self.update_in_progress = True

        # Manual Update

        value = oe.read_setting('updates', 'Channel')
        if not value is None:
            self.struct['update']['settings']['Channel']['value'] = value
        value = oe.read_setting('updates', 'ShowCustomChannels')
        if not value is None:
            self.struct['update']['settings']['ShowCustomChannels']['value'] = value

        value = oe.read_setting('updates', 'CustomChannel1')
        if not value is None:
            self.struct['update']['settings']['CustomChannel1']['value'] = value
        value = oe.read_setting('updates', 'CustomChannel2')
        if not value is None:
            self.struct['update']['settings']['CustomChannel2']['value'] = value
        value = oe.read_setting('updates', 'CustomChannel3')
        if not value is None:
            self.struct['update']['settings']['CustomChannel3']['value'] = value

        self.update_json = self.build_json()

        self.struct['update']['settings']['Channel']['values'] = self.get_channels()
        self.struct['update']['settings']['Build']['values'] = self.get_available_builds()

        # RPi4 EEPROM updating
        if oe.RPI_CPU_VER == '3':
            self.rpi_flashing_state = self.get_rpi_flashing_state()
            if self.rpi_flashing_state['incompatible']:
                self.struct['rpieeprom']['hidden'] = 'true'
            else:
                self.struct['rpieeprom']['settings']['bootloader']['value'] = self.get_rpi_eeprom('BOOTLOADER')
                self.struct['rpieeprom']['settings']['bootloader']['name'] = f"{oe._(32024)} ({self.rpi_flashing_state['bootloader']['state']})"
                self.struct['rpieeprom']['settings']['vl805']['value'] = self.get_rpi_eeprom('VL805')
                self.struct['rpieeprom']['settings']['vl805']['name'] = f"{oe._(32026)} ({self.rpi_flashing_state['vl805']['state']})"
        else:
            self.struct['rpieeprom']['hidden'] = 'true'
Ejemplo n.º 5
0
 def disable_device_standby(self, listItem=None):
     devices = oe.read_setting('bluetooth', 'standby')
     if devices is not None:
         devices = devices.split(',')
     else:
         devices = []
     if listItem.getProperty('entry') in devices:
         devices.remove(listItem.getProperty('entry'))
     oe.write_setting('bluetooth', 'standby', ','.join(devices))
Ejemplo n.º 6
0
 def standby_devices(self):
     if self.dbusBluezAdapter != None:
         devices = oe.read_setting('bluetooth', 'standby')
         if not devices == None:
             oe.input_request = True
             for device in devices.split(','):
                 if self.is_device_connected(device):
                     self.disconnect_device_by_path(device)
             oe.input_request = False
Ejemplo n.º 7
0
 def enable_device_standby(self, listItem=None):
     devices = oe.read_setting('bluetooth', 'standby')
     if not devices == None:
         devices = devices.split(',')
     else:
         devices = []
     if not listItem.getProperty('entry') in devices:
         devices.append(listItem.getProperty('entry'))
     oe.write_setting('bluetooth', 'standby', ','.join(devices))
Ejemplo n.º 8
0
 def run(self):
     if oe.read_setting('libreelec', 'wizard_completed') == None:
         threading.Thread(target=oe.openWizard).start()
     while self.stopped == False:
         log.log(f'Waiting', log.INFO)
         conn, addr = self.sock.accept()
         message = (conn.recv(1024)).decode('utf-8')
         conn.close()
         log.log(f'Received {message}', log.INFO)
         if message == 'openConfigurationWindow':
             if not hasattr(oe, 'winOeMain'):
                 threading.Thread(target=oe.openConfigurationWindow).start()
             else:
                 if oe.winOeMain.visible != True:
                     threading.Thread(
                         target=oe.openConfigurationWindow).start()
         if message == 'exit':
             self.stopped = True
Ejemplo n.º 9
0
 def open_context_menu(self, listItem):
     values = {}
     if listItem is None:
         listItem = oe.winOeMain.getControl(
             oe.listObject['btlist']).getSelectedItem()
     if listItem.getProperty('Paired') != '1':
         values[1] = {
             'text': oe._(32145),
             'action': 'init_device',
         }
         if listItem.getProperty('Trusted') != '1':
             values[2] = {
                 'text': oe._(32358),
                 'action': 'trust_connect_device',
             }
     if listItem.getProperty('Connected') == '1':
         values[3] = {
             'text': oe._(32143),
             'action': 'disconnect_device',
         }
         devices = oe.read_setting('bluetooth', 'standby')
         if devices is not None:
             devices = devices.split(',')
         else:
             devices = []
         if listItem.getProperty('entry') in devices:
             values[4] = {
                 'text': oe._(32389),
                 'action': 'disable_device_standby',
             }
         else:
             values[4] = {
                 'text': oe._(32388),
                 'action': 'enable_device_standby',
             }
     elif listItem.getProperty('Paired') == '1':
         values[1] = {
             'text': oe._(32144),
             'action': 'init_device',
         }
     elif listItem.getProperty('Trusted') == '1':
         values[2] = {
             'text': oe._(32144),
             'action': 'trust_connect_device',
         }
     values[5] = {
         'text': oe._(32141),
         'action': 'remove_device',
     }
     values[6] = {
         'text': oe._(32142),
         'action': 'menu_connections',
     }
     items = []
     actions = []
     for key in list(values.keys()):
         items.append(values[key]['text'])
         actions.append(values[key]['action'])
     select_window = xbmcgui.Dialog()
     title = oe._(32012)
     result = select_window.select(title, items)
     if result >= 0:
         getattr(self, actions[result])(listItem)
Ejemplo n.º 10
0
    def onClick(self, controlID):
        global strModule
        global prevModule
        try:
            oe.dbg_log(f'wizard::onClick({str(controlID)})', 'enter_function', oe.LOGDEBUG)
            for btn in self.buttons:
                if controlID == self.buttons[btn]['id'] and self.buttons[btn]['id'] > 2:
                    if hasattr(self.buttons[btn]['modul'], self.buttons[btn]['action']):
                        getattr(self.buttons[btn]['modul'], self.buttons[btn]['action'])()
            for btn in self.radiobuttons:
                if controlID == self.radiobuttons[btn]['id'] and self.radiobuttons[btn]['id'] > 1:
                    if hasattr(self.radiobuttons[btn]['modul'], self.radiobuttons[btn]['action']):
                        getattr(self.radiobuttons[btn]['modul'], self.radiobuttons[btn]['action'])()
            if controlID == self.guiNetList:
                selectedItem = self.getControl(controlID).getSelectedItem()
                if selectedItem.getProperty('action') != '':
                    if hasattr(oe.dictModules[self.last_wizard], selectedItem.getProperty('action')):
                        getattr(oe.dictModules[self.last_wizard], selectedItem.getProperty('action'))(selectedItem)
                        return
            if controlID == 1501:
                self.wizards.remove(strModule)
                oe.remove_node(strModule)
                if strModule == "system":
                    self.onInit()
                else:
                    self.wizards.remove(prevModule)
                    oe.remove_node(prevModule)
                    self.onClick(1500)
                oe.dbg_log(f'wizard::onClick({str(controlID)})', 'exit_function', oe.LOGDEBUG)

            if controlID == 1500:
                self.getControl(1390).setLabel('1')
                oe.xbmcm.waitForAbort(0.5)
                self.is_last_wizard = True
                self.getControl(1391).setLabel('')
                self.getControl(self.buttons[3]['id']).setVisible(False)
                self.getControl(self.buttons[4]['id']).setVisible(False)
                self.getControl(self.radiobuttons[1]['id']).setVisible(False)
                self.getControl(self.radiobuttons[2]['id']).setVisible(False)
                self.showButton(2, 32307)
                self.set_wizard_title('')
                self.set_wizard_text('')
                self.set_wizard_list_title('')
                self.set_wizard_button_title('')

                for module in sorted(oe.dictModules, key=lambda x: list(oe.dictModules[x].menu.keys())):
                    strModule = module
                    if hasattr(oe.dictModules[strModule], 'do_wizard') and oe.dictModules[strModule].ENABLED:
                        if strModule == self.last_wizard:
                            if hasattr(oe.dictModules[strModule], 'exit'):
                                oe.dictModules[strModule].exit()
                                if hasattr(oe.dictModules[strModule], 'is_wizard'):
                                    del oe.dictModules[strModule].is_wizard
                        setting = oe.read_setting(strModule, 'wizard_completed')
                        if self.wizards != []:
                            prevModule = self.wizards[-1]
                        if oe.read_setting(strModule, 'wizard_completed') == None and strModule not in self.wizards:
                            self.last_wizard = strModule
                            if hasattr(oe.dictModules[strModule], 'do_init'):
                                oe.dictModules[strModule].do_init()
                            self.getControl(1390).setLabel('')
                            oe.dictModules[strModule].do_wizard()
                            self.wizards.append(strModule)
                            oe.write_setting(strModule, 'wizard_completed', 'True')
                            self.is_last_wizard = False
                            break
                if self.is_last_wizard == True:
                    xbmc.executebuiltin('UpdateAddonRepos')
                    langAddon = f"InstallAddon({lang_new})"
                    xbmc.executebuiltin(langAddon)
                    oe.xbmcm.waitForAbort(0.5)
                    xbmc.executebuiltin('SendClick(10100,11)')
                    oe.write_setting('libreelec', 'wizard_completed', 'True')
                    self.visible = False
                    self.close()
                    xbmc.executebuiltin(lang_str)
            oe.dbg_log(f'wizard::onClick({str(controlID)})', 'exit_function', oe.LOGDEBUG)
        except Exception as e:
            oe.dbg_log('oeWindows.wizard::onClick()', f'ERROR: ({repr(e)})')
Ejemplo n.º 11
0
    def load_values(self):
        # SAMBA
        if os.path.isfile(self.SAMBA_NMDB) and os.path.isfile(self.SAMBA_SMDB):
            self.struct['samba']['settings']['samba_autostart']['value'] = oe.get_service_state('samba')
            self.struct['samba']['settings']['samba_workgroup']['value'] = oe.get_service_option('samba', 'SAMBA_WORKGROUP',
                    self.D_SAMBA_WORKGROUP).replace('"', '')
            self.struct['samba']['settings']['samba_secure']['value'] = oe.get_service_option('samba', 'SAMBA_SECURE',
                    self.D_SAMBA_SECURE).replace('true', '1').replace('false', '0').replace('"', '')
            self.struct['samba']['settings']['samba_username']['value'] = oe.get_service_option('samba', 'SAMBA_USERNAME',
                    self.D_SAMBA_USERNAME).replace('"', '')
            self.struct['samba']['settings']['samba_password']['value'] = oe.get_service_option('samba', 'SAMBA_PASSWORD',
                    self.D_SAMBA_PASSWORD).replace('"', '')
            self.struct['samba']['settings']['samba_minprotocol']['value'] = oe.get_service_option('samba', 'SAMBA_MINPROTOCOL',
                    self.D_SAMBA_MINPROTOCOL).replace('"', '')
            self.struct['samba']['settings']['samba_maxprotocol']['value'] = oe.get_service_option('samba', 'SAMBA_MAXPROTOCOL',
                    self.D_SAMBA_MAXPROTOCOL).replace('"', '')
            self.struct['samba']['settings']['samba_autoshare']['value'] = oe.get_service_option('samba', 'SAMBA_AUTOSHARE',
                    self.D_SAMBA_AUTOSHARE).replace('true', '1').replace('false', '0').replace('"', '')
        else:
            self.struct['samba']['hidden'] = 'true'
        # SSH
        if os.path.isfile(self.SSH_DAEMON):
            self.struct['ssh']['settings']['ssh_autostart']['value'] = oe.get_service_state('sshd')
            self.struct['ssh']['settings']['ssh_secure']['value'] = oe.get_service_option('sshd', 'SSHD_DISABLE_PW_AUTH',
                    self.D_SSH_DISABLE_PW_AUTH).replace('true', '1').replace('false', '0').replace('"', '')
            # hide ssh settings if Kernel Parameter is set
            with open(self.KERNEL_CMD, 'r') as cmd_file:
                cmd_args = cmd_file.read().split(' ')
            if 'ssh' in cmd_args:
                self.struct['ssh']['settings']['ssh_autostart']['value'] = '1'
                self.struct['ssh']['settings']['ssh_autostart']['hidden'] = 'true'
        else:
            self.struct['ssh']['hidden'] = 'true'
        # AVAHI
        if os.path.isfile(self.AVAHI_DAEMON):
            self.struct['avahi']['settings']['avahi_autostart']['value'] = oe.get_service_state('avahi')
        else:
            self.struct['avahi']['hidden'] = 'true'
        # CRON
        if os.path.isfile(self.CRON_DAEMON):
            self.struct['cron']['settings']['cron_autostart']['value'] = oe.get_service_state('crond')
        else:
            self.struct['cron']['hidden'] = 'true'
        # BLUEZ / OBEX
        if 'bluetooth' in oe.dictModules:
            if os.path.isfile(oe.dictModules['bluetooth'].BLUETOOTH_DAEMON):
                self.struct['bluez']['settings']['enabled']['value'] = oe.get_service_state('bluez')
                if os.path.isfile(oe.dictModules['bluetooth'].OBEX_DAEMON):
                    self.struct['bluez']['settings']['obex_enabled']['value'] = oe.get_service_state('obexd')
                    self.struct['bluez']['settings']['obex_root']['value'] = oe.get_service_option('obexd', 'OBEXD_ROOT',
                            oe.dictModules['bluetooth'].D_OBEXD_ROOT).replace('"', '')
                else:
                    self.struct['bluez']['settings']['obex_enabled']['hidden'] = True
                    self.struct['bluez']['settings']['obex_root']['hidden'] = True

                value = oe.read_setting('bluetooth', 'idle_timeout')
                if not value:
                    value = '0'
                self.struct['bluez']['settings']['idle_timeout']['value'] = oe.read_setting('bluetooth', 'idle_timeout')
            else:
                self.struct['bluez']['hidden'] = 'true'
Ejemplo n.º 12
0
 def get_setting(self, group, setting, allowEmpty=False):
     value = oe.read_setting('system', setting)
     if not value is None and not (allowEmpty == False and value == ''):
         self.struct[group]['settings'][setting]['value'] = value
Ejemplo n.º 13
0
 def onDPMSActivated(self):
     if oe.read_setting('bluetooth', 'standby'):
         threading.Thread(target=oe.standby_devices).start()