예제 #1
0
    def populate_wifi_panel(self, scan=True):
        # remove everything from the existing panel
        self.WFP.reset()
        self.toggle_controls(False, ALL_WIRELESS_CONTROLS)
        if osmc_network.is_wifi_available():
            if osmc_network.is_wifi_enabled():
                self.populate_wifi_networks(scan)
                if self.conn_ssid:
                    self.update_manual_DHCP_button(WIRELESS_DHCP_MANUAL_BUTTON,
                                                   WIRELESS_IP_VALUES,
                                                   WIRELESS_IP_LABELS)
                    self.populate_ip_controls(self.current_network_config,
                                              WIRELESS_IP_VALUES)
                    self.toggle_controls(True, [
                        WIRELESS_ADAPTER_TOGGLE, WIRELESS_SCAN_BUTTON,
                        WIRELESS_NETWORKS, WIRELESS_DHCP_MANUAL_BUTTON
                    ])
                else:  # not connected to a network
                    self.toggle_controls(True, [
                        WIRELESS_ADAPTER_TOGGLE, WIRELESS_SCAN_BUTTON,
                        WIRELESS_NETWORKS
                    ])
                    self.clear_ip_controls(WIRELESS_IP_VALUES)
                self.setFocusId(WIRELESS_SCAN_BUTTON)
            else:
                self.setFocusId(WIRELESS_ADAPTER_TOGGLE)

            adapterRadioButton = self.getControl(WIRELESS_ADAPTER_TOGGLE)
            adapterRadioButton.setSelected(osmc_network.is_wifi_enabled())
            adapterRadioButton.setEnabled(True)
예제 #2
0
    def onInit(self):
        # Wired Network Label
        self.status_label = self.getControl(STATUS_LABEL)

        # wifi panel (WFP)
        self.WFP = self.getControl(5000)

        # bluetooth paired device panel (BTP)
        self.BTP = self.getControl(6000)

        # bluetooth discovered device panel (BTD)
        self.BTD = self.getControl(7000)

        panel_to_show = WIRED_NETWORK_SELECTOR
        if self.use_preseed and not osmc_network.get_nfs_ip_cmdline_value():
            self.preseed_data = osmc_network.parse_preseed()
            if self.preseed_data:
                if self.preseed_data['Interface'].startswith(
                        'wlan') and osmc_network.is_wifi_available():
                    panel_to_show = WIRELESS_NETWORK_SELECTOR
                else:
                    panel_to_show = WIRED_NETWORK_SELECTOR

        # set all the panels to invisible except the first one
        for ctl in MAIN_MENU:
            self.getControl(
                ctl * 10).setVisible(True if ctl == panel_to_show else False)
        if panel_to_show == WIRED_NETWORK_SELECTOR:
            self.populate_wired_panel()
        if panel_to_show == WIRELESS_NETWORK_SELECTOR:
            self.populate_wifi_panel(False)

        if self.use_preseed and not osmc_network.get_nfs_ip_cmdline_value():
            self.setup_networking_from_preseed()
예제 #3
0
    def populate_wifi_panel(self, scan=False):
        if osmc_network.is_wifi_available():
            if osmc_network.is_wifi_enabled():
                # Start the wifi population thread
                threadRunning = False
                for t in threading.enumerate():
                    if t.getName() == WIFI_THREAD_NAME:
                        threadRunning = True
                if not threadRunning:
                    log('Starting ' + WIFI_THREAD_NAME)
                    self.wifi_populate_bot = wifi_populate_bot(scan, self.getControl(5000), self.conn_ssid)
                    self.wifi_populate_bot.setDaemon(True)
                    self.wifi_populate_bot.start()

                self.current_network_config = osmc_network.get_connected_wifi()
                self.conn_ssid = None
                log(self.current_network_config)
                if 'SSID' in self.current_network_config:
                    self.conn_ssid = self.current_network_config['SSID']
                if self.conn_ssid:
                    if 'Address' in self.current_network_config:
                        self.update_manual_DHCP_button(WIRELESS_DHCP_MANUAL_BUTTON, WIRELESS_IP_VALUES, WIRELESS_IP_LABELS)
                        self.populate_ip_controls(self.current_network_config, WIRELESS_IP_VALUES)
                    self.toggle_controls(True, [WIRELESS_ADAPTER_TOGGLE,  WIRELESS_NETWORKS,
                                                WIRELESS_DHCP_MANUAL_BUTTON])
                    if osmc_network.has_internet_connection():
                        # 'Status'            'Connected'
                        status = lang(32044) + ': ' + lang(32046)
                    else:
                        # 'Status'            'No internet'
                        status = lang(32044) + ':  ' + lang(32047)
                    self.wireless_status_label.setLabel(status)
                else:  # not connected to a network
                    self.hide_controls(WIRELESS_IP_VALUES + WIRELESS_IP_LABELS + [WIRELESS_DHCP_MANUAL_BUTTON,
                                                                                  WIRELESS_APPLY_BUTTON,
                                                                                  WIRELESS_RESET_BUTTON])
                    self.toggle_controls(True, [WIRELESS_ADAPTER_TOGGLE, WIRELESS_NETWORKS])
                    self.clear_ip_controls(WIRELESS_IP_VALUES)
                    # 'Status'           'No wireless Connection'
                    status = lang(32044) + ': ' + lang(32050)
                    self.wireless_status_label.setLabel(status)

            else:  # Wifi disabled
                self.hide_controls(ALL_WIRELESS_CONTROLS)
                # 'Status'            'disabled'
                status = lang(32044) + ': ' + lang(32048)
                self.wireless_status_label.setLabel(status)

            adapterRadioButton = self.getControl(WIRELESS_ADAPTER_TOGGLE)
            adapterRadioButton.setSelected(osmc_network.is_wifi_enabled())
            adapterRadioButton.setEnabled(True)

        else:  # Wifi not available
            self.toggle_controls(False, ALL_WIRELESS_CONTROLS)

        waitForNetworkRadioButton = self.getControl(WIRELESS_WAIT_FOR_NETWORK)
        waitForNetworkRadioButton.setSelected(osmc_network.is_connman_wait_for_network_enabled())
        waitForNetworkRadioButton.setEnabled(True)
예제 #4
0
    def onInit(self):
        # Wired Network Label
        self.wired_status_label = self.getControl(WIRED_STATUS_LABEL)

        # wifi panel (WFP)
        self.WFP = self.getControl(5000)

        # Wireless Network Label
        self.wireless_status_label = self.getControl(WIRELESS_STATUS_LABEL)

        # bluetooth paired device panel (BTP)
        self.BTP = self.getControl(6000)

        # bluetooth discovered device panel (BTD)
        self.BTD = self.getControl(7000)

        # Hide panel selectors if devices are not present
        if not osmc_network.is_wifi_available():
            self.toggle_controls(False, [SELECTOR_WIRELESS_NETWORK])
        if not osmc_bluetooth.is_bluetooth_available():
            self.toggle_controls(False, [SELECTOR_BLUETOOTH])

        panel_to_show = SELECTOR_WIRED_NETWORK
        if self.use_preseed and not osmc_network.get_nfs_ip_cmdline_value():
            self.preseed_data = osmc_network.parse_preseed()
            if self.preseed_data:
                if self.preseed_data['Interface'].startswith(
                        'wlan') and osmc_network.is_wifi_available():
                    panel_to_show = SELECTOR_WIRELESS_NETWORK
                else:
                    panel_to_show = SELECTOR_WIRED_NETWORK

        # set all the panels to invisible except the first one
        for ctl in MAIN_MENU:
            self.getControl(
                ctl * 10).setVisible(True if ctl == panel_to_show else False)
        if panel_to_show == SELECTOR_WIRED_NETWORK:
            self.populate_wired_panel()
        if panel_to_show == SELECTOR_WIRELESS_NETWORK:
            self.populate_wifi_panel(False)

        if self.use_preseed and not osmc_network.get_nfs_ip_cmdline_value():
            self.setup_networking_from_preseed()
예제 #5
0
    def onInit(self):
        # Wired Network Label
        self.wired_status_label = self.getControl(WIRED_STATUS_LABEL);

        # wifi panel (WFP)
        self.WFP = self.getControl(5000)

        # Wireless Network Label
        self.wireless_status_label = self.getControl(WIRELESS_STATUS_LABEL);

        # bluetooth paired device panel (BTP)
        self.BTP = self.getControl(6000)

        # bluetooth discovered device panel (BTD)
        self.BTD = self.getControl(7000)

        # Hide panel selectors if devices are not present
        if not osmc_network.is_wifi_available():
            self.toggle_controls(False, [SELECTOR_WIRELESS_NETWORK])
        if not osmc_bluetooth.is_bluetooth_available():
            self.toggle_controls(False, [SELECTOR_BLUETOOTH])

        panel_to_show = SELECTOR_WIRED_NETWORK
        if self.use_preseed and not osmc_network.get_nfs_ip_cmdline_value():
            self.preseed_data = osmc_network.parse_preseed()
            if self.preseed_data:
                if self.preseed_data['Interface'].startswith('wlan') and osmc_network.is_wifi_available():
                    panel_to_show = SELECTOR_WIRELESS_NETWORK
                else:
                    panel_to_show = SELECTOR_WIRED_NETWORK

        # set all the panels to invisible except the first one
        for ctl in MAIN_MENU:
            self.getControl(ctl * 10).setVisible(True if ctl == panel_to_show else False)
        if panel_to_show == SELECTOR_WIRED_NETWORK:
            self.populate_wired_panel()
        if panel_to_show == SELECTOR_WIRELESS_NETWORK:
            self.populate_wifi_panel(False)

        if self.use_preseed and not osmc_network.get_nfs_ip_cmdline_value():
            self.setup_networking_from_preseed()
예제 #6
0
    def setup_networking_from_preseed(self):
        wired = False
        connected = False

        if self.preseed_data['Interface'].startswith(
                'wlan') and osmc_network.is_wifi_available():
            if not osmc_network.is_wifi_enabled():
                self.toggle_wifi()
            ssid = self.preseed_data['SSID']
            encrypted = False
            preseed_password = None
            if 'Password' in self.preseed_data:
                encrypted = True
                preseed_password = self.preseed_data['Password']

            connected = self.connect_to_wifi(ssid, encrypted, preseed_password,
                                             True)

        if self.preseed_data is None or self.preseed_data[
                'Interface'].startswith('eth') or not connected:
            wired = True
            if not osmc_network.is_ethernet_enabled():
                self.toggle_ethernet()
            self.current_network_config = self.get_wired_config()
            connected = True

        if connected:
            if self.preseed_data is None or 'dhcp' in self.preseed_data[
                    'Method']:
                self.current_network_config['Method'] = 'dhcp'
            else:
                self.current_network_config['Method'] = 'manual'
                self.current_network_config['Address'] = self.preseed_data[
                    'Address']
                self.current_network_config['Netmask'] = self.preseed_data[
                    'Netmask']
                if 'Gateway' in self.preseed_data:
                    self.current_network_config['Gateway'] = self.preseed_data[
                        'Gateway']
                if 'DNS_1' in self.preseed_data:
                    self.current_network_config['DNS_1'] = self.preseed_data[
                        'DNS_1']
                if 'DNS_2' in self.preseed_data:
                    self.current_network_config['DNS_2'] = self.preseed_data[
                        'DNS_2']

            osmc_network.apply_network_changes(self.current_network_config)

        if wired:
            self.populate_wired_panel()
        else:
            self.populate_wifi_panel(False)
예제 #7
0
    def populate_wifi_panel(self, scan=False):
        # remove everything from the existing panel
        if osmc_network.is_wifi_available():
            if osmc_network.is_wifi_enabled():
                self.populate_wifi_networks(scan)
                self.current_network_config = osmc_network.get_connected_wifi()
                self.conn_ssid = None
                if 'SSID' in self.current_network_config:
                    self.conn_ssid = self.current_network_config['SSID']
                if self.conn_ssid:
                    self.update_manual_DHCP_button(WIRELESS_DHCP_MANUAL_BUTTON, WIRELESS_IP_VALUES, WIRELESS_IP_LABELS)
                    self.populate_ip_controls(self.current_network_config, WIRELESS_IP_VALUES)
                    self.toggle_controls(True, [WIRELESS_ADAPTER_TOGGLE, WIRELESS_SCAN_BUTTON, WIRELESS_NETWORKS,
                                                WIRELESS_DHCP_MANUAL_BUTTON])
                    if osmc_network.has_internet_connection():
                        #         'Status'            'Connected'
                        status = lang(32044) + ': ' + lang(32046)
                    else:
                        #         'Status'            'No internet'
                        status = lang(32044) + ':  ' + lang(32047)
                    self.wireless_status_label.setLabel(status)
                else:# not connected to a network
                    self.hide_controls(WIRELESS_IP_VALUES + WIRELESS_IP_LABELS + [WIRELESS_DHCP_MANUAL_BUTTON,
                                       WIRELESS_APPLY_BUTTON, WIRELESS_RESET_BUTTON])
                    self.toggle_controls(True, [WIRELESS_ADAPTER_TOGGLE, WIRELESS_SCAN_BUTTON, WIRELESS_NETWORKS])
                    self.clear_ip_controls(WIRELESS_IP_VALUES)
                    #         'Status'           'No wireless Connection'
                    status = lang(32044) + ': ' + lang(32050)
                    self.wireless_status_label.setLabel(status)

            else:# Wifi disabled
                self.hide_controls(ALL_WIRELESS_CONTROLS)
                #         'Status'            'disabled'
                status = lang(32044) + ': ' + lang(32048)
                self.wireless_status_label.setLabel(status)

            adapterRadioButton = self.getControl(WIRELESS_ADAPTER_TOGGLE)
            adapterRadioButton.setSelected(osmc_network.is_wifi_enabled())
            adapterRadioButton.setEnabled(True)

        else:# Wifi not available
            self.toggle_controls(False, ALL_WIRELESS_CONTROLS)

        waitForNetworkRadioButton = self.getControl(WIRELESS_WAIT_FOR_NETWORK)
        waitForNetworkRadioButton.setSelected(osmc_network.is_connman_wait_for_network_enabled())
        waitForNetworkRadioButton.setEnabled(True)
예제 #8
0
    def setup_networking_from_preseed(self):
        wired = False
        connected = False

        if self.preseed_data['Interface'].startswith('wlan') and osmc_network.is_wifi_available():
            if not osmc_network.is_wifi_enabled():
                self.toggle_wifi()
            ssid = self.preseed_data['SSID']
            encrypted = False
            preseed_password = None
            if 'Password' in self.preseed_data:
                encrypted = True
                preseed_password = self.preseed_data['Password']

            connected = self.connect_to_wifi(ssid, encrypted, preseed_password, True)

        if self.preseed_data is None or self.preseed_data['Interface'].startswith('eth') or not connected:
            wired = True
            if not osmc_network.is_ethernet_enabled():
                self.toggle_ethernet()
            self.current_network_config = self.get_wired_config()
            connected = True

        if connected:
            if self.preseed_data is None or 'dhcp' in self.preseed_data['Method']:
                self.current_network_config['Method'] = 'dhcp'
            else:
                self.current_network_config['Method'] = 'manual'
                self.current_network_config['Address'] = self.preseed_data['Address']
                self.current_network_config['Netmask'] = self.preseed_data['Netmask']
                if 'Gateway' in self.preseed_data:
                    self.current_network_config['Gateway'] = self.preseed_data['Gateway']
                if 'DNS_1' in self.preseed_data:
                    self.current_network_config['DNS_1'] = self.preseed_data['DNS_1']
                if 'DNS_2' in self.preseed_data:
                    self.current_network_config['DNS_2'] = self.preseed_data['DNS_2']

            osmc_network.apply_network_changes(self.current_network_config)


        if wired:
            self.populate_wired_panel()
        else:
            self.populate_wifi_panel(False)
예제 #9
0
    def populate_wifi_panel(self, scan=False):
        if osmc_network.is_wifi_available():
            if osmc_network.is_wifi_enabled():
                # Start the wifi population thread
                threadRunning = False
                for t in threading.enumerate():
                    if t.getName() == WIFI_THREAD_NAME:
                        threadRunning = True
                if not threadRunning:
                    log('Starting ' + WIFI_THREAD_NAME)
                    self.wifi_populate_bot = wifi_populate_bot(
                        scan, self.getControl(5000), self.conn_ssid)
                    self.wifi_populate_bot.setDaemon(True)
                    self.wifi_populate_bot.start()

                self.current_network_config = osmc_network.get_connected_wifi()
                self.conn_ssid = None
                log(self.current_network_config)
                if 'SSID' in self.current_network_config:
                    self.conn_ssid = self.current_network_config['SSID']
                if self.conn_ssid:
                    if 'Address' in self.current_network_config:
                        self.update_manual_DHCP_button(
                            WIRELESS_DHCP_MANUAL_BUTTON, WIRELESS_IP_VALUES,
                            WIRELESS_IP_LABELS)
                        self.populate_ip_controls(self.current_network_config,
                                                  WIRELESS_IP_VALUES)
                    self.toggle_controls(True, [
                        WIRELESS_ADAPTER_TOGGLE, WIRELESS_NETWORKS,
                        WIRELESS_DHCP_MANUAL_BUTTON
                    ])
                    if osmc_network.has_internet_connection():
                        # 'Status'            'Connected'
                        status = lang(32044) + ': ' + lang(32046)
                    else:
                        # 'Status'            'No internet'
                        status = lang(32044) + ':  ' + lang(32047)
                    self.wireless_status_label.setLabel(status)
                else:  # not connected to a network
                    self.hide_controls(
                        WIRELESS_IP_VALUES + WIRELESS_IP_LABELS + [
                            WIRELESS_DHCP_MANUAL_BUTTON, WIRELESS_APPLY_BUTTON,
                            WIRELESS_RESET_BUTTON
                        ])
                    self.toggle_controls(
                        True, [WIRELESS_ADAPTER_TOGGLE, WIRELESS_NETWORKS])
                    self.clear_ip_controls(WIRELESS_IP_VALUES)
                    # 'Status'           'No wireless Connection'
                    status = lang(32044) + ': ' + lang(32050)
                    self.wireless_status_label.setLabel(status)

            else:  # Wifi disabled
                self.hide_controls(ALL_WIRELESS_CONTROLS)
                # 'Status'            'disabled'
                status = lang(32044) + ': ' + lang(32048)
                self.wireless_status_label.setLabel(status)

            adapterRadioButton = self.getControl(WIRELESS_ADAPTER_TOGGLE)
            adapterRadioButton.setSelected(osmc_network.is_wifi_enabled())
            adapterRadioButton.setEnabled(True)

        else:  # Wifi not available
            self.toggle_controls(False, ALL_WIRELESS_CONTROLS)

        waitForNetworkRadioButton = self.getControl(WIRELESS_WAIT_FOR_NETWORK)
        waitForNetworkRadioButton.setSelected(
            osmc_network.is_connman_wait_for_network_enabled())
        waitForNetworkRadioButton.setEnabled(True)