Пример #1
0
    def add_wireless_sub(self, ssid, encryption, connection_created, con_path, asked=False):
        # Prompt for key
        key = ""
        if not encryption == 'NONE':
            message = 'Enter Password:'******'Connection Failed, please enter password again:'
            kb = xbmc.Keyboard("", message, False)

            kb.doModal()
            if (kb.isConfirmed()):
                key = kb.getText()
                errors = qfpynm.validate_wifi_input(key, encryption)

            if key == "" or errors != '':
                self.msg = getLS(30109)
                self.status_label.setLabel(self.msg)
                return True, connection_created, con_path
        if encryption == 'WEP':
            wep_alg = 'shared'
        else:
            wep_alg = ''
        if connection_created == False:
            con_path = qfpynm.add_wifi(ssid, key, encryption, wep_alg, True)
        else:
            aUUID = qfpynm.get_con_uuid_by_path(con_path)
            qfpynm.update_wifi(aUUID, key, encryption)
            qfpynm.activate_connection(aUUID)

        asked = False

        for i in range(1, 150):
            state, stateTXT = qfpynm.get_device_state(qfpynm.get_wifi_device())
            self.msg = stateTXT
            self.status_label.setLabel(self.msg)
            # Do not exit directly just to be sure.
            # If trying with a bad key when wifi is disconnected do not give state 60 but 30....
            # better never to disconnect wifi and only deactivate c
            if (i > 10 and state == 60) or (i > 10 and state == 30) or (state == 100 and i > 2):
                break
            time.sleep(1)
            self.msg = ''
            self.status_label.setLabel(self.msg)
            time.sleep(1)
        if state == 100:
            self.msg = getLS(30120)  # "Connected!"
            self.status_label.setLabel(self.msg)
            xbmc.executebuiltin('XBMC.ActivateWindow(Home)')
            self.close()
            return True, True, con_path
        if (state == 60 or state == 30) and encryption != "NONE":
            self.msg = getLS(30121)  # "Not Autorized!"
            self.status_label.setLabel(self.msg)
            return False, True, con_path

        self.msg = qfpynm.nm_state.get(state, '')  # "Connection failed"
        self.status_label.setLabel(self.msg)
        return True, True, con_path
Пример #2
0
    def add_wireless_sub(self, ssid, encryption, connection_created, con_path):
        #Prompt for key
        key = ""
        if not encryption == 'NONE':
            kb = xbmc.Keyboard("", getLS(30104), False)
            kb.doModal()
            if (kb.isConfirmed()):
                key = kb.getText()
                errors = qfpynm.validate_wifi_input(key, encryption)

            if key == "" or errors != '':
                self.msg = getLS(30109)
                self.status_label.setLabel(self.msg)
                return True, connection_created, con_path
        if encryption == 'WEP':
            wep_alg = 'shared'
        else:
            wep_alg = ''
        if connection_created == False:
            con_path = qfpynm.add_wifi(ssid, key, encryption, wep_alg,
                                       self.disable_ipv6)
        else:
            aUUID = qfpynm.get_con_uuid_by_path(con_path)
            qfpynm.update_wifi(aUUID, key, encryption)
            qfpynm.activate_connection(aUUID)

        for i in range(1, 150):
            state, stateTXT = qfpynm.get_device_state(qfpynm.get_wifi_device())
            self.msg = stateTXT
            self.status_label.setLabel(self.msg)
            # Do not exit directly just to be sure.
            # If trying with a bad key when wifi is disconnected do not give state 60 but 30....
            # better never to disconnect wifi and only deactivate c
            if (i > 10 and state == 60) or (i > 10
                                            and state == 30) or (state == 100
                                                                 and i > 2):
                break
            time.sleep(1)
            self.msg = ''
            self.status_label.setLabel(self.msg)
            time.sleep(1)
        if state == 100:
            self.msg = getLS(30120)  #"Connected!"
            self.status_label.setLabel(self.msg)
            return True, True, con_path
        if (state == 60 or state == 30) and encryption != "NONE":
            self.msg = getLS(30121)  #"Not Autorized!"
            self.status_label.setLabel(self.msg)
            return False, True, con_path

        self.msg = getLS(30122)  #"Connection failed"
        self.status_label.setLabel(self.msg)
        return True, True, con_path
Пример #3
0
 def add_wireless_sub(self, ssid, encryption, connection_created, con_path):
     #Prompt for key
     key = ""
     if not encryption == 'NONE':
         kb = xbmc.Keyboard("", getLS(30104), False)
         kb.doModal()
         if (kb.isConfirmed()):
             key=kb.getText()
             errors = qfpynm.validate_wifi_input(key,encryption)
        
         if key == "" or errors != '':
             self.msg = getLS(30109)  
             self.status_label.setLabel(self.msg)
             return True, connection_created, con_path
     if encryption == 'WEP':
         wep_alg = 'shared'
     else:
         wep_alg = ''
     if connection_created == False:
         con_path = qfpynm.add_wifi(ssid,key,encryption,wep_alg,self.disable_ipv6 )
     else:
         aUUID = qfpynm.get_con_uuid_by_path(con_path)
         qfpynm.update_wifi(aUUID, key, encryption)
         qfpynm.activate_connection(aUUID)
         
     for i in range(1, 150):
         state,stateTXT = qfpynm.get_device_state(qfpynm.get_wifi_device())
         self.msg = stateTXT
         self.status_label.setLabel(self.msg)
         # Do not exit directly just to be sure.
         # If trying with a bad key when wifi is disconnected do not give state 60 but 30....
         # better never to disconnect wifi and only deactivate c
         if (i > 10 and state == 60) or (i > 10 and state == 30)  or (state == 100 and i >2):
             break
         time.sleep(1)
         self.msg = ''
         self.status_label.setLabel(self.msg)
         time.sleep(1)
     if state == 100:
         self.msg = getLS(30120) #"Connected!"
         self.status_label.setLabel(self.msg)
         return True, True, con_path
     if (state == 60  or state == 30) and encryption != "NONE":
         self.msg = getLS(30121) #"Not Autorized!"
         self.status_label.setLabel(self.msg)
         return False, True, con_path
     
     self.msg = getLS(30122) #"Connection failed"
     self.status_label.setLabel(self.msg)      
     return True, True, con_path
Пример #4
0
    def onClick(self, controlId):
        self.msg = ""
        self.status_label.setLabel(self.msg)

        #Activate connection from list
        if controlId == self.control_list_id:
            #position = self.list.getSelectedPosition()

            #Get UUID
            item = self.list.getSelectedItem()

            uuid =  item.getProperty('uuid')
            encryption = item.getProperty('encryption')
            #print uuid

            self.activate_connection(uuid)
            for i in range(1, 100):
                state,stateTXT = qfpynm.get_device_state(qfpynm.get_wifi_device())
                msg = stateTXT
                self.status_label.setLabel(msg)
                if (state == 100 and i >2):
                    break
                if (i > 2 and state == 60):
                    if encryption not in ['WPA','WEP']:
                        print ("Strange encryption:" + encryption)
                        break
                    #Prompt for key
                    key = ""
                    kb = xbmc.Keyboard("", getLS(30104), False)
                    kb.doModal()
                    if (kb.isConfirmed()):
                        key=kb.getText()
                        errors = qfpynm.validate_wifi_input(key,encryption)

                    if key == "" or errors != '':
                        self.msg = getLS(30109)
                        self.status_label.setLabel(self.msg)
                        break

                    qfpynm.update_wifi(uuid, key, encryption)
                    qfpynm.activate_connection(uuid)
                    continue
                time.sleep(1)
                msg = ''
                self.status_label.setLabel(msg)
                time.sleep(1)
            if state == 100:
                msg = getLS(30120) #"Connected!"

            elif state == 60:
                msg = getLS(30121) #"Not Autorized!"
            else:
                msg = getLS(30122) #"Connection failed"
            self.updateList()
            self.status_label.setLabel(msg)

        #Add connection button
        elif controlId == self.control_add_connection_button_id:
            import addConnection
            addConnectionUI = addConnection.GUI("script_linux_nm1-add.xml", __cwd__, "default")
            self.close()
            del addConnectionUI

        #disconnect button
        elif controlId == self.control_disconnect_button_id:
            self.disconnect()

            for i in range(1, 20):
                state,stateTXT = qfpynm.get_device_state(qfpynm.get_wifi_device())
                self.msg = stateTXT
                self.status_label.setLabel(self.msg)

                if (state == 30):
                    break
                time.sleep(1)
            self.updateList()

        #Delete button
        elif controlId == self.control_delete_button_id:
            item = self.list.getSelectedItem()

            uuid =  item.getProperty('uuid')

            self.delete_connection(uuid)

            msg = getLS(30115) #Refreshing
            self.status_label.setLabel(msg)

            time.sleep(2)
            self.updateList()

            msg = getLS(30126) #Done
            self.status_label.setLabel(msg)
            self.setFocus(self.control_add_connection_button)

        #Status button
        elif controlId == self.control_status_button_id:
            state,stateTXT = qfpynm.get_nm_state()
            msg = stateTXT
            self.status_label.setLabel(msg)

        #cancel dialog
        elif controlId == self.control_cancel_button_id:
            self.closeDialog()
Пример #5
0
    def onClick(self, controlId):
        self.msg = ""
        self.status_label.setLabel(self.msg)

        #Activate connection from list
        if controlId == self.control_list_id:
            #position = self.list.getSelectedPosition()

            #Get UUID
            item = self.list.getSelectedItem()

            uuid = item.getProperty('uuid')
            encryption = item.getProperty('encryption')
            #print uuid

            self.activate_connection(uuid)
            for i in range(1, 100):
                state, stateTXT = qfpynm.get_device_state(
                    qfpynm.get_wifi_device())
                msg = stateTXT
                self.status_label.setLabel(msg)
                if (state == 100 and i > 2):
                    break
                if (i > 2 and state == 60):
                    if encryption not in ['WPA', 'WEP']:
                        print("Strange encryption:" + encryption)
                        break
                    #Prompt for key
                    key = ""
                    kb = xbmc.Keyboard("", getLS(30104), False)
                    kb.doModal()
                    if (kb.isConfirmed()):
                        key = kb.getText()
                        errors = qfpynm.validate_wifi_input(key, encryption)

                    if key == "" or errors != '':
                        self.msg = getLS(30109)
                        self.status_label.setLabel(self.msg)
                        break

                    qfpynm.update_wifi(uuid, key, encryption)
                    qfpynm.activate_connection(uuid)
                    continue
                time.sleep(1)
                msg = ''
                self.status_label.setLabel(msg)
                time.sleep(1)
            if state == 100:
                msg = getLS(30120)  #"Connected!"

            elif state == 60:
                msg = getLS(30121)  #"Not Autorized!"
            else:
                msg = getLS(30122)  #"Connection failed"
            self.updateList()
            self.status_label.setLabel(msg)

        #Add connection button
        elif controlId == self.control_add_connection_button_id:
            import addConnection
            addConnectionUI = addConnection.GUI("script_linux_nm-add.xml",
                                                __cwd__, "default")
            self.close()
            del addConnectionUI

        #disconnect button
        elif controlId == self.control_disconnect_button_id:
            self.disconnect()

            for i in range(1, 20):
                state, stateTXT = qfpynm.get_device_state(
                    qfpynm.get_wifi_device())
                self.msg = stateTXT
                self.status_label.setLabel(self.msg)

                if (state == 30):
                    break
                time.sleep(1)
            self.updateList()

        #Delete button
        elif controlId == self.control_delete_button_id:
            item = self.list.getSelectedItem()

            uuid = item.getProperty('uuid')

            self.delete_connection(uuid)

            msg = getLS(30115)  #Refreshing
            self.status_label.setLabel(msg)

            time.sleep(2)
            self.updateList()

            msg = getLS(30126)  #Done
            self.status_label.setLabel(msg)
            self.setFocus(self.control_add_connection_button)

        #Status button
        elif controlId == self.control_status_button_id:
            state, stateTXT = qfpynm.get_nm_state()
            msg = stateTXT
            self.status_label.setLabel(msg)

        #cancel dialog
        elif controlId == self.control_cancel_button_id:
            self.closeDialog()
Пример #6
0
    def make_connection(self, item, ask_password=False):

        if item.getProperty('active') == 'True':
            return True

        ssid = item.getProperty('ssid')
        uuid = item.getProperty('uuid')
        encryption = item.getProperty('encryption')

        # print uuid
        # if ask_password:
        #     key = ""
        #     kb = xbmc.Keyboard("", getLS(30104), False)
        #     kb.doModal()
        #     if (kb.isConfirmed()):
        #         key=kb.getText()
        #         errors = qfpynm.validate_wifi_input(key,encryption)

        #     if key == "" or errors != '':
        #         self.msg = getLS(30109)
        #         self.status_label.setLabel(self.msg)
        #     else:
        #         qfpynm.update_wifi(uuid, key, encryption)
        #         qfpynm.activate_connection(uuid)
        # else:
        if uuid != '':
            self.activate_connection(uuid)
        else:
            self.add_wireless(ssid, encryption)
            state, stateTXT = qfpynm.get_device_state(qfpynm.get_wifi_device())
            self.updateList()

        asked = False

        for i in range(1, 150):
            state, stateTXT = qfpynm.get_device_state(qfpynm.get_wifi_device())
            msg = stateTXT
            self.status_label.setLabel(msg)
            if (state == 100 and i > 2):
                break
            if (i > 2 and state == 60):
                if encryption not in ['WPA', 'WEP']:
                    print("Strange encryption:" + encryption)
                    break
                # Prompt for key
                key = ""

                message = 'Enter Password:'******'Connection Failed, please enter password again:'

                kb = xbmc.Keyboard("", message, False)
                kb.doModal()

                if (kb.isConfirmed()):
                    key = kb.getText()
                    asked = True
                    errors = qfpynm.validate_wifi_input(key, encryption)

                if key == "" or errors != '':
                    self.msg = getLS(30109)
                    self.status_label.setLabel(self.msg)
                    break

                qfpynm.update_wifi(uuid, key, encryption)
                qfpynm.activate_connection(uuid)
                continue
            time.sleep(1)
            msg = msg
            self.status_label.setLabel(msg)

        if state == 100:
            msg = getLS(30120)  # "Connected!"

        elif state == 60:
            msg = getLS(30121)  # "Not Autorized!"
        else:
            msg = qfpynm.nm_state.get(state, '')  # "Connection failed"

        self.updateList()
        self.status_label.setLabel(msg)

        if state == 100:
            xbmc.executebuiltin('XBMC.ActivateWindow(Home)')
            self.close()
            return True
        return False