예제 #1
0
    def TakeAction(self, item):
        dialog = xbmcgui.Dialog()
        selectednetwork = self.allnetworks[int(item.getProperty('index'))]
        isaction = False
        isConnected = selectednetwork.connected
        self.activeUuid = selectednetwork.uuid

        if not selectednetwork.connected:            
            try:
                if selectednetwork.securityenabled:
                    passwd = dialog.input(xbmc.getLocalizedString(31714).format(selectednetwork.ssid),type=xbmcgui.INPUT_ALPHANUM, option=xbmcgui.ALPHANUM_HIDE_INPUT)
                    if passwd != "":
                        selectednetwork.connect(passwd)
                        isaction = True
                else:
                    selectednetwork.connectNoPassword()
                    isaction = True
            except:
                dialog.notification(xbmc.getLocalizedString(31715), xbmc.getLocalizedString(31716), xbmcgui.NOTIFICATION_ERROR, 10000)

        else:
            try:
                ret = dialog.yesno(xbmc.getLocalizedString(31717), xbmc.getLocalizedString(31718).format(selectednetwork.ssid))
                if ret:
                    selectednetwork.disconnect()
                    isaction = True
            except:
                dialog.notification(xbmc.getLocalizedString(31715), xbmc.getLocalizedString(31719), xbmcgui.NOTIFICATION_ERROR, 10000)

        if isaction:
            confirmDialog = ConfirmDialog()
            if isConnected:
                dialogStr = xbmc.getLocalizedString(31729) + xbmc.getLocalizedString(31724)
            else:
                dialogStr = xbmc.getLocalizedString(31729) + xbmc.getLocalizedString(31728)

            ret = confirmDialog.doModalWithCallback(dialogStr,ConfirmDialogType.ok,20,self.RefreshWifiState)
            del confirmDialog
            wifis = AlphaUINetworkUtils.WiFis()

            for wifi in wifis:
                if wifi.UUID == self.activeUuid:
                    if isConnected:
                        if wifi.State != 4 and wifi.State != 1:
                            dialog.notification(xbmc.getLocalizedString(31715), xbmc.getLocalizedString(31719), xbmcgui.NOTIFICATION_ERROR, 5000)
                    else:
                        if wifi.State != 1:
                            dialog.notification(xbmc.getLocalizedString(31715), xbmc.getLocalizedString(31716), xbmcgui.NOTIFICATION_ERROR, 5000)
            self.FillList()
        pass
예제 #2
0
    def TakeAction(self, item):
        dialog = xbmcgui.Dialog()
        selectednetwork = self.allnetworks[int(item.getProperty('index'))]
        isaction = False
        isConnected = selectednetwork.connected
        self.activeUuid = selectednetwork.uuid

        if not selectednetwork.connected:
            try:
                if selectednetwork.securityenabled:
                    passwd = dialog.input(
                        xbmc.getLocalizedString(31714).format(
                            selectednetwork.ssid),
                        type=xbmcgui.INPUT_ALPHANUM,
                        option=xbmcgui.ALPHANUM_HIDE_INPUT)
                    if passwd != "":
                        selectednetwork.connect(passwd)
                        isaction = True
                else:
                    selectednetwork.connectNoPassword()
                    isaction = True
            except:
                dialog.notification(xbmc.getLocalizedString(31715),
                                    xbmc.getLocalizedString(31716),
                                    xbmcgui.NOTIFICATION_ERROR, 10000)

        else:
            try:
                ret = dialog.yesno(
                    xbmc.getLocalizedString(31717),
                    xbmc.getLocalizedString(31718).format(
                        selectednetwork.ssid))
                if ret:
                    selectednetwork.disconnect()
                    isaction = True
            except:
                dialog.notification(xbmc.getLocalizedString(31715),
                                    xbmc.getLocalizedString(31719),
                                    xbmcgui.NOTIFICATION_ERROR, 10000)

        if isaction:
            confirmDialog = ConfirmDialog()
            if isConnected:
                dialogStr = xbmc.getLocalizedString(
                    31729) + xbmc.getLocalizedString(31724)
            else:
                dialogStr = xbmc.getLocalizedString(
                    31729) + xbmc.getLocalizedString(31728)

            ret = confirmDialog.doModalWithCallback(dialogStr,
                                                    ConfirmDialogType.ok, 20,
                                                    self.RefreshWifiState)
            del confirmDialog
            wifis = AlphaUINetworkUtils.WiFis()

            for wifi in wifis:
                if wifi.UUID == self.activeUuid:
                    if isConnected:
                        if wifi.State != 4 and wifi.State != 1:
                            dialog.notification(xbmc.getLocalizedString(31715),
                                                xbmc.getLocalizedString(31719),
                                                xbmcgui.NOTIFICATION_ERROR,
                                                5000)
                    else:
                        if wifi.State != 1:
                            dialog.notification(xbmc.getLocalizedString(31715),
                                                xbmc.getLocalizedString(31716),
                                                xbmcgui.NOTIFICATION_ERROR,
                                                5000)
            self.FillList()
        pass