示例#1
0
    def handle_bluetooth_selection(self, control_id):
        if control_id == BLUETOOTH_ENABLE_TOGGLE:  # Enable Bluetooth
            if osmc_bluetooth.is_bluetooth_enabled():
                osmc_bluetooth.toggle_bluetooth_state(False)
            else:
                osmc_bluetooth.toggle_bluetooth_state(True)

        if control_id == BLUETOOTH_DISCOVERY:  # Discovery
            if not osmc_bluetooth.is_discovering():
                osmc_bluetooth.start_discovery()
            else:
                osmc_bluetooth.stop_discovery()
            xbmc.sleep(100)

        if control_id == 6000:  # paired devices
            item = self.BTP.getSelectedItem()
            if item:
                address = item.getProperty('address')
                alias = item.getProperty('alias')
                # 'Bluetooth' , 'Remove Device'
                if DIALOG.yesno(lang(32020), lang(32021) + ' ' + alias + '?'):
                    osmc_bluetooth.remove_device(address)
                self.setFocusId(BLUETOOTH_ENABLE_TOGGLE)

        if control_id == 7000:  # Discovered devices
            item = self.BTD.getSelectedItem()
            if item:
                address = item.getProperty('address')
                alias = item.getProperty('alias')
                #              'Connect With Device'            'No'     Pair and Connect'    'pair'
                selection = DIALOG.select(
                    lang(32022) + ' ' + alias + '?',
                    [lang(32055), lang(32056),
                     lang(32057)])
                if selection == 0:
                    return
                if selection == 1:
                    self.show_busy_dialogue()
                    script_base_path = os.path.join(
                        __addon__.getAddonInfo('path'), 'resources',
                        'lib') + '/'
                    result = osmc_bluetooth.pair_device(
                        address, script_base_path)
                    self.setFocusId(BLUETOOTH_DISCOVERY)
                    if not result:
                        #         'Pairing with'                       'failed'
                        message = lang(32024) + ' ' + alias + ' ' + lang(32025)
                        #                                                     'Bluetooth'
                        xbmc.executebuiltin("XBMC.Notification(%s,%s,%s)" %
                                            (lang(32020), message, "2500"))
                        return
                    self.clear_busy_dialogue()
                osmc_bluetooth.connect_device(address)
                osmc_bluetooth.set_device_trusted(address, True)
示例#2
0
    def handle_bluetooth_selection(self, control_id):
        if control_id == BLUETOOTH_ENABLE_TOGGLE:  # Enable Bluetooth
            self.show_busy_dialogue()
            if osmc_bluetooth.is_bluetooth_enabled():
                osmc_bluetooth.toggle_bluetooth_state(False)
            else:
                osmc_bluetooth.toggle_bluetooth_state(True)
            self.clear_busy_dialogue()

        if control_id == BLUETOOTH_DISCOVERY:  # Discovery
            if not osmc_bluetooth.is_discovering():
                osmc_bluetooth.start_discovery()
            else:
                osmc_bluetooth.stop_discovery()
            xbmc.sleep(100)

        if control_id == 6000:  # paired devices
            item = self.BTP.getSelectedItem()
            if item:
                address = item.getProperty('address')
                alias = item.getProperty('alias')
                # 'Bluetooth' , 'Remove Device'
                if DIALOG.yesno(lang(32020), lang(32021) + ' ' + alias + '?'):
                    osmc_bluetooth.remove_device(address)
                    self.setFocusId(BLUETOOTH_ENABLE_TOGGLE)
                    self.bluetooth_population_thread.update_bluetooth_lists()

        if control_id == 7000:  # Discovered devices
            item = self.BTD.getSelectedItem()
            if item:
                address = item.getProperty('address')
                alias = item.getProperty('alias')
                #              'Connect With Device'            'No'     Pair and Connect'    'pair'
                selection = DIALOG.select(lang(32022) + ' ' + alias + '?', [lang(32055),lang(32056), lang(32057)])
                if selection == 0:
                    return
                self.show_busy_dialogue()
                self.setFocusId(BLUETOOTH_DISCOVERY)
                if selection == 1:
                    script_base_path = os.path.join(__addon__.getAddonInfo('path'), 'resources', 'lib') + '/'
                    result = osmc_bluetooth.pair_device(address, script_base_path)

                    if not result:
                        #         'Pairing with'                       'failed'
                        message = lang(32024) + ' ' + alias + ' ' + lang(32025)
                        #                                                     'Bluetooth'
                        xbmc.executebuiltin("XBMC.Notification(%s,%s,%s)" % (lang(32020), message, "2500"))
                        return
                osmc_bluetooth.connect_device(address)
                osmc_bluetooth.set_device_trusted(address, True)
                self.bluetooth_population_thread.update_bluetooth_lists()
                self.clear_busy_dialogue()
示例#3
0
    def populate_bluetooth_panel(self):
        """
                Populates the bluetooth panel
        """
        # clear discovered and paired lists
        self.BTD.reset()
        self.BTP.reset()

        # enable all controls
        self.toggle_controls(True, BLUETOOTH_CONTROLS)
        # disable all if bluetooth is not detected
        if not osmc_bluetooth.is_bluetooth_available():
            self.toggle_controls(False, BLUETOOTH_CONTROLS)
            return
        else:
            if not osmc_bluetooth.is_bluetooth_enabled():
                controls_to_disable = list(BLUETOOTH_CONTROLS)
                controls_to_disable.remove(BLUETOOTH_ENABLE_TOGGLE)
                self.toggle_controls(False, controls_to_disable)
                return

        bluetoothRadioButton = self.getControl(10301)
        bluetoothRadioButton.setSelected(osmc_bluetooth.is_bluetooth_enabled())
        discoveryRadioButton = self.getControl(10303)
        discoveryRadioButton.setSelected(osmc_bluetooth.is_discovering())

        bluetooth_paired_dict = self.populate_bluetooth_dict(True)
        bluetooth_discovered_dict = self.populate_bluetooth_dict(False)

        # add paired devices to the list
        self.paired_bluetooths = list(
            self.create_bluetooth_items(bluetooth_paired_dict))
        # sort the list of paired based on alias
        self.paired_bluetooths.sort(key=self.sort_alias)
        # remove everything from the existing panel
        self.BTP.reset()
        # add the paired devices
        self.BTP.addItems(self.paired_bluetooths)

        # add discovered devices to the list
        self.discovered_bluetooths = list(
            self.create_bluetooth_items(bluetooth_discovered_dict))
        # sort the list of discovered based on alias
        self.discovered_bluetooths.sort(key=self.sort_alias)
        # remove everything from the existing panel
        self.BTD.reset()
        # add the paired devices
        self.BTD.addItems(self.discovered_bluetooths)
示例#4
0
    def populate_bluetooth_panel(self):
        bluetoothRadioButton = self.getControl(BLUETOOTH_ENABLE_TOGGLE)
        bluetoothRadioButton.setSelected(osmc_bluetooth.is_bluetooth_enabled())

        # disable all if bluetooth is not enabled
        if not osmc_bluetooth.is_bluetooth_enabled():
            # disable all controls
            self.toggle_controls(False, BLUETOOTH_CONTROLS)
            return

        self.toggle_controls(True, BLUETOOTH_CONTROLS)
        discoveryRadioButton = self.getControl(BLUETOOTH_DISCOVERY)
        discoveryRadioButton.setSelected(osmc_bluetooth.is_discovering())

        self.bluetooth_population_thread = bluetooth_population_thread(self.BTD, self.BTP)
        self.bluetooth_population_thread.setDaemon(True)
        self.bluetooth_population_thread.start()
示例#5
0
    def populate_bluetooth_panel(self):
        bluetoothRadioButton = self.getControl(BLUETOOTH_ENABLE_TOGGLE)
        bluetoothRadioButton.setSelected(osmc_bluetooth.is_bluetooth_enabled())

        # disable all if bluetooth is not enabled
        if not osmc_bluetooth.is_bluetooth_enabled():
            # disable all controls
            self.toggle_controls(False, BLUETOOTH_CONTROLS)
            return

        self.toggle_controls(True, BLUETOOTH_CONTROLS)
        discoveryRadioButton = self.getControl(BLUETOOTH_DISCOVERY)
        discoveryRadioButton.setSelected(osmc_bluetooth.is_discovering())

        self.bluetooth_population_thread = bluetooth_population_thread(
            self.BTD, self.BTP)
        self.bluetooth_population_thread.setDaemon(True)
        self.bluetooth_population_thread.start()
示例#6
0
    def handle_bluetooth_selection(self, control_id):
        # 10300 - No Action Here - Refresh - populate_bluetooth_panel() will be called by calling code
        if control_id == BLUETOOTH_ENABLE_TOGGLE:  # Enable Bluetooth
            if osmc_bluetooth.is_bluetooth_enabled():
                osmc_bluetooth.toggle_bluetooth_state(False)
            else:
                osmc_bluetooth.toggle_bluetooth_state(True)

        if control_id == BLUETOOTH_DISCOVERY:  # Discovery
            if not osmc_bluetooth.is_discovering():
                osmc_bluetooth.start_discovery()
            else:
                osmc_bluetooth.stop_discovery()
            time.sleep(1)

        if control_id == 6000:  # paired devices
            item = self.BTP.getSelectedItem()
            if item:
                address = item.getProperty('address')
                alias = item.getProperty('alias')
                # 'Bluetooth' , 'Remove Device'
                if DIALOG.yesno(lang(32020), lang(32021) + ' ' + alias + '?'):
                    osmc_bluetooth.remove_device(address)
                    self.setFocusId(BLUETOOTH_REFRESH)

        if control_id == 7000:  # Discovered devices
            item = self.BTD.getSelectedItem()
            if item:
                address = item.getProperty('address')
                alias = item.getProperty('alias')
                # 'Bluetooth' ,        'Pair with Device'
                if DIALOG.yesno(lang(32020), lang(32022) + ' ' + alias + '?'):
                    script_base_path = os.path.join(__addon__.getAddonInfo('path'), 'resources', 'lib') + '/'
                    result = osmc_bluetooth.pair_device(address, script_base_path)
                    self.setFocusId(BLUETOOTH_REFRESH)
                    if result:
                        # 'Paired Sucessfully with'
                        message = lang(32023) + ' ' + alias
                    else:
                        # 'Pairing with'                            'failed'
                        message = lang(32024) + ' ' + alias + ' ' + lang(32025)
                    # 'Bluetooth'
                    xbmc.executebuiltin("XBMC.Notification(%s,%s,%s)" % (lang(32020), message, "2500"))
示例#7
0
    def populate_bluetooth_panel(self):
        """
                Populates the bluetooth panel
        """
        # clear discovered and paired lists
        self.BTD.reset()
        self.BTP.reset()

        bluetoothRadioButton = self.getControl(10301)
        bluetoothRadioButton.setSelected(osmc_bluetooth.is_bluetooth_enabled())

        # disable all if bluetooth is not enabled
        if not osmc_bluetooth.is_bluetooth_enabled():
            # disable all controls
            self.toggle_controls(False, BLUETOOTH_CONTROLS)
            return

        self.toggle_controls(True, BLUETOOTH_CONTROLS)
        discoveryRadioButton = self.getControl(BLUETOOTH_DISCOVERY)

        discoveryRadioButton.setSelected(osmc_bluetooth.is_discovering())

        bluetooth_paired_dict = self.populate_bluetooth_dict(True)
        bluetooth_discovered_dict = self.populate_bluetooth_dict(False)

        # add paired devices to the list
        self.paired_bluetooths = list(self.create_bluetooth_items(bluetooth_paired_dict))
        # sort the list of paired based on alias
        self.paired_bluetooths.sort(key=self.sort_alias)
        # remove everything from the existing panel
        self.BTP.reset()
        # add the paired devices
        self.BTP.addItems(self.paired_bluetooths)

        # add discovered devices to the list
        self.discovered_bluetooths = list(self.create_bluetooth_items(bluetooth_discovered_dict))
        # sort the list of discovered based on alias
        self.discovered_bluetooths.sort(key=self.sort_alias)
        # remove everything from the existing panel
        self.BTD.reset()
        # add the paired devices
        self.BTD.addItems(self.discovered_bluetooths)
示例#8
0
    def handle_bluetooth_selection(self, control_id):
        # 10300 - No Action Here - Refresh - populate_bluetooth_panel() will be called by calling code
        if control_id == 10301:  # Enable Bluetooth
            osmc_bluetooth.toggle_bluetooth_state(
                not osmc_bluetooth.is_bluetooth_enabled())

        if control_id == 10303:  # Discovery
            if not osmc_bluetooth.is_discovering():
                osmc_bluetooth.start_discovery()
            else:
                osmc_bluetooth.stop_discovery()

        if control_id == 6000:  # paired devices
            item = self.BTP.getSelectedItem()
            address = item.getProperty('address')
            alias = item.getProperty('alias')
            # 'Bluetooth' , 'Remove Device'
            if DIALOG.yesno(lang(32020), lang(32021) + ' ' + alias + '?'):
                osmc_bluetooth.remove_device(address)

        if control_id == 7000:  # Discovered devices
            item = self.BTD.getSelectedItem()
            address = item.getProperty('address')
            alias = item.getProperty('alias')
            # 'Bluetooth' , 'Pair with Device'
            if DIALOG.yesno(lang(32020), lang(32022) + ' ' + alias + '?'):
                script_base_path = os.path.join(__addon__.getAddonInfo('path'),
                                                'resources', 'lib') + '/'
                result = osmc_bluetooth.pair_device(address, script_base_path)
                if result:
                    # 'Paired Sucessfully with'
                    message = lang(32023) + ' ' + alias
                else:
                    # 'Pairing with'         'failed'
                    message = lang(32024) + alias + lang(320025)
                # 'Bluetooth'
                xbmc.executebuiltin("XBMC.Notification(%s,%s,%s)" %
                                    (lang(32020), message, "2500"))
示例#9
0
    def populate_bluetooth_panel(self):
        bluetoothRadioButton = self.getControl(BLUETOOTH_ENABLE_TOGGLE)
        bluetoothRadioButton.setSelected(osmc_bluetooth.is_bluetooth_enabled())

        # disable all if bluetooth is not enabled
        if not osmc_bluetooth.is_bluetooth_enabled():
            # disable all controls
            self.toggle_controls(False, BLUETOOTH_CONTROLS)
            return

        self.toggle_controls(True, BLUETOOTH_CONTROLS)
        discoveryRadioButton = self.getControl(BLUETOOTH_DISCOVERY)
        discoveryRadioButton.setSelected(osmc_bluetooth.is_discovering())
        # Start Bluetooth Poulation Thread
        threadRunning = False
        for t in threading.enumerate():
            if t.getName() == BLUETOOTH_THREAD_NAME:
                threadRunning = True
        if not threadRunning:
            log('Starting ' + BLUETOOTH_THREAD_NAME)
            self.bluetooth_population_thread = bluetooth_population_thread(self.BTD, self.BTP)
            self.bluetooth_population_thread.setDaemon(True)
            self.bluetooth_population_thread.start()
示例#10
0
    def populate_bluetooth_panel(self):
        bluetoothRadioButton = self.getControl(BLUETOOTH_ENABLE_TOGGLE)
        bluetoothRadioButton.setSelected(osmc_bluetooth.is_bluetooth_enabled())

        # disable all if bluetooth is not enabled
        if not osmc_bluetooth.is_bluetooth_enabled():
            # disable all controls
            self.toggle_controls(False, BLUETOOTH_CONTROLS)
            return

        self.toggle_controls(True, BLUETOOTH_CONTROLS)
        discoveryRadioButton = self.getControl(BLUETOOTH_DISCOVERY)
        discoveryRadioButton.setSelected(osmc_bluetooth.is_discovering())
        # Start Bluetooth Poulation Thread
        threadRunning = False
        for t in threading.enumerate():
            if t.getName() == BLUETOOTH_THREAD_NAME:
                threadRunning = True
        if not threadRunning:
            log('Starting ' + BLUETOOTH_THREAD_NAME)
            self.bluetooth_population_thread = bluetooth_population_thread(
                self.BTD, self.BTP)
            self.bluetooth_population_thread.setDaemon(True)
            self.bluetooth_population_thread.start()