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)
def connect_to_wifi(self, ssid, encrypted, password=None, scan=False): if scan: self.show_busy_dialogue() osmc_network.scan_wifi() self.clear_busy_dialogue() if ssid in osmc_network.get_wifi_networks(): # 'Configuring' self.wireless_status_label.setLabel(lang(32016)) path = osmc_network.get_wifi_networks()[ssid]['path'] connection_status = False # 'Wireless' 'Connect to' if DIALOG.yesno(lang(32041), lang(32052) + ' ' + ssid + '?'): self.show_busy_dialogue() connection_status = osmc_network.wifi_connect(path) self.clear_busy_dialogue() if not connection_status and encrypted: if password is None: password = DIALOG.input(lang(32013), type=xbmcgui.INPUT_ALPHANUM, option=xbmcgui.ALPHANUM_HIDE_INPUT) if password: self.wireless_password = password self.show_busy_dialogue() connection_status = osmc_network.wifi_connect(path, password) self.clear_busy_dialogue() if not connection_status: # 'Connection to ' 'failed' message = lang(32043) + ' ' + ssid + ' ' + lang(32025) # 'Wireless' xbmc.executebuiltin("XBMC.Notification(%s,%s,%s)" % (lang(32041), message, "2500")) self.current_network_config = {} self.clear_ip_controls(WIRELESS_IP_VALUES) self.toggle_controls(False, [WIRELESS_DHCP_MANUAL_BUTTON]) # 'Status' 'Not connected' status = lang(32044) + ': ' + lang(32050) self.wireless_status_label.setLabel(status) return False else: self.show_busy_dialogue() self.current_network_config = self.get_wireless_config(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_NETWORKS, WIRELESS_DHCP_MANUAL_BUTTON]) self.conn_ssid = ssid interface = self.current_network_config['Interface'] if osmc_network.has_internet_connection(): # 'Status' 'Connected' status = lang(32044) + ': ' + interface + ' (' + lang(32046) + ')' else: # 'Status' 'No internet' status = lang(32044) + ': ' + interface + ' (' + lang(32047) + ')' self.wireless_status_label.setLabel(status) self.clear_busy_dialogue() return True else: return False
def populate_wired_panel(self): if os.path.isfile(self.reboot_required_file): # 'NFS Network Settings' # 'The displayed network configuration may be out dated - A reboot is recommended before proceeding' DIALOG.ok(lang(32036), lang(32038)) # Clear wired network Panel self.hide_controls(ALL_WIRED_CONTROLS) if osmc_network.is_ethernet_enabled(): self.current_network_config = self.get_wired_config() if self.current_network_config: interface = self.current_network_config['Interface'] if osmc_network.has_internet_connection(): # 'Status' 'Connected' status = lang(32044) + ': ' + interface + ' (' + lang( 32046) + ')' else: # 'Status' 'No internet' status = lang(32044) + ': ' + interface + ' (' + lang( 32047) + ')' self.wired_status_label.setLabel(status) self.toggle_controls(True, ALL_WIRED_CONTROLS) self.update_manual_DHCP_button(WIRED_DHCP_MANUAL_BUTTON, WIRED_IP_VALUES, WIRED_IP_LABELS) self.populate_ip_controls(self.current_network_config, WIRED_IP_VALUES) # enable reset and apply button self.update_apply_reset_button('WIRED') else: # no wired connection self.hide_controls(WIRED_IP_VALUES + WIRELESS_IP_VALUES) # 'Status' 'no wired connection' status = lang(32044) + ': ' + lang(32049) self.wired_status_label.setLabel(status) self.clear_ip_controls(WIRED_IP_VALUES) else: # Disabled self.clear_ip_controls(WIRED_IP_VALUES) self.hide_controls(ALL_WIRED_CONTROLS) # 'Status' 'disabled' status = lang(32044) + ': ' + lang(32048) self.wired_status_label.setLabel(status) self.update_apply_reset_button('WIRED') adapterRadioButton = self.getControl(WIRED_ADAPTER_TOGGLE) adapterRadioButton.setSelected(osmc_network.is_ethernet_enabled()) adapterRadioButton.setEnabled(True) waitForNetworkRadioButton = self.getControl(WIRED_WAIT_FOR_NETWORK) waitForNetworkRadioButton.setSelected( osmc_network.is_connman_wait_for_network_enabled()) waitForNetworkRadioButton.setEnabled(True)
def populate_wired_panel(self): if os.path.isfile(self.reboot_required_file): # 'NFS Network Settings' # 'The displayed network configuration may be out dated - A reboot is recommended before proceeding' DIALOG.ok(lang(32036), lang(32038)) # Clear wired network Panel self.hide_controls(ALL_WIRED_CONTROLS) if osmc_network.is_ethernet_enabled(): self.current_network_config = self.get_wired_config() if self.current_network_config: interface = self.current_network_config['Interface'] if osmc_network.has_internet_connection(): # 'Status' 'Connected' status = lang(32044) + ': ' + interface + ' (' + lang(32046) + ')' else: # 'Status' 'No internet' status = lang(32044) + ': ' + interface + ' (' + lang(32047) + ')' self.wired_status_label.setLabel(status) self.toggle_controls(True, ALL_WIRED_CONTROLS) self.update_manual_DHCP_button(WIRED_DHCP_MANUAL_BUTTON, WIRED_IP_VALUES, WIRED_IP_LABELS) self.populate_ip_controls(self.current_network_config, WIRED_IP_VALUES) # enable reset and apply button self.update_apply_reset_button('WIRED') else: # no wired connection self.hide_controls(WIRED_IP_VALUES + WIRELESS_IP_VALUES) # 'Status' 'no wired connection' status = lang(32044) + ': ' + lang(32049) self.wired_status_label.setLabel(status) self.clear_ip_controls(WIRED_IP_VALUES) else: # Disabled self.clear_ip_controls(WIRED_IP_VALUES) self.hide_controls(ALL_WIRED_CONTROLS) # 'Status' 'disabled' status = lang(32044) + ': ' + lang(32048) self.wired_status_label.setLabel(status) self.update_apply_reset_button('WIRED') adapterRadioButton = self.getControl(WIRED_ADAPTER_TOGGLE) adapterRadioButton.setSelected(osmc_network.is_ethernet_enabled()) adapterRadioButton.setEnabled(True) waitForNetworkRadioButton = self.getControl(WIRED_WAIT_FOR_NETWORK) waitForNetworkRadioButton.setSelected(osmc_network.is_connman_wait_for_network_enabled()) waitForNetworkRadioButton.setEnabled(True)
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)
def check_internet(self): return osmc_network.has_internet_connection()
def connect_to_wifi(self, ssid, encrypted, password=None, scan=False): if scan: self.show_busy_dialogue() osmc_network.scan_wifi() self.clear_busy_dialogue() if ssid in osmc_network.get_wifi_networks(): # 'Configuring' self.wireless_status_label.setLabel(lang(32016)) path = osmc_network.get_wifi_networks()[ssid]['path'] connection_status = False # 'Wireless' 'Connect to' if DIALOG.yesno(lang(32041), lang(32052) + ' ' + ssid + '?'): self.show_busy_dialogue() connection_status = osmc_network.wifi_connect(path) self.clear_busy_dialogue() if not connection_status and encrypted: if password is None: password = DIALOG.input( lang(32013), type=xbmcgui.INPUT_ALPHANUM, option=xbmcgui.ALPHANUM_HIDE_INPUT) if password: self.wireless_password = password self.show_busy_dialogue() connection_status = osmc_network.wifi_connect( path, password) self.clear_busy_dialogue() if not connection_status: # 'Connection to ' 'failed' message = lang(32043) + ' ' + ssid + ' ' + lang(32025) # 'Wireless' xbmc.executebuiltin("XBMC.Notification(%s,%s,%s)" % (lang(32041), message, "2500")) self.current_network_config = {} self.clear_ip_controls(WIRELESS_IP_VALUES) self.toggle_controls(False, [WIRELESS_DHCP_MANUAL_BUTTON]) # 'Status' 'Not connected' status = lang(32044) + ': ' + lang(32050) self.wireless_status_label.setLabel(status) return False else: self.show_busy_dialogue() self.current_network_config = self.get_wireless_config( 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_NETWORKS, WIRELESS_DHCP_MANUAL_BUTTON ]) self.conn_ssid = ssid interface = self.current_network_config['Interface'] if osmc_network.has_internet_connection(): # 'Status' 'Connected' status = lang(32044) + ': ' + interface + ' (' + lang( 32046) + ')' else: # 'Status' 'No internet' status = lang(32044) + ': ' + interface + ' (' + lang( 32047) + ')' self.wireless_status_label.setLabel(status) self.clear_busy_dialogue() return True else: return False
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)