コード例 #1
0
    def hydrate(self):
        has_card = False
        hw = self.hw

        if not hw.Name:
            conf = NCisdnhardware.ConfISDN()
            new_card = conf.detect()
            if new_card:
                has_card = True
                self.cardname = new_card.keys()[0]
                conf.get_resource(self.cardname)
                hw.Card.ChannelProtocol = conf.ChannelProtocol
                hw.Card.IRQ = conf.IRQ
                hw.Card.Mem = conf.Mem
                hw.Card.IoPort = conf.IoPort
                hw.Card.IoPort1 = conf.IoPort1
                hw.Card.IoPort2 = conf.IoPort2
        else:
            has_card = True

        if has_card:
            if hw.Card.ChannelProtocol == '2':
                self.xml.get_widget("euroIsdnButton").set_active(True)
            else:
                self.xml.get_widget("1tr6Button").set_active(True)

            if self.hw.Description:
                self.xml.get_widget("adapterEntry").set_text(
                    self.hw.Description)

            if hw.Card.IRQ:
                self.xml.get_widget("irqSpinButton").set_sensitive(True)
                self.xml.get_widget("irqSpinButton").set_value(int(
                    hw.Card.IRQ))
            else:
                self.xml.get_widget("irqSpinButton").set_sensitive(False)

            if hw.Card.Mem:
                self.xml.get_widget("memEntry").set_sensitive(True)
                self.xml.get_widget("memEntry").set_text(hw.Card.Mem)
            else:
                self.xml.get_widget("memEntry").set_sensitive(False)

            if hw.Card.IoPort:
                self.xml.get_widget("ioEntry").set_sensitive(True)
                self.xml.get_widget("ioEntry").set_text(hw.Card.IoPort)
            else:
                self.xml.get_widget("ioEntry").set_sensitive(False)

            if hw.Card.IoPort1:
                self.xml.get_widget("io1Entry").set_sensitive(True)
                self.xml.get_widget("io1Entry").set_text(hw.Card.IoPort1)
            else:
                self.xml.get_widget("io1Entry").set_sensitive(False)

            if hw.Card.IoPort2:
                self.xml.get_widget("io2Entry").set_sensitive(True)
                self.xml.get_widget("io2Entry").set_text(hw.Card.IoPort2)
            else:
                self.xml.get_widget("io2Entry").set_sensitive(False)
コード例 #2
0
    def on_isdnCardEntry_changed(self, entry):
        cardname = entry.get_text()
        card = NCisdnhardware.ConfISDN()
        card.get_resource(cardname)

        if card.IRQ:
            self.xml.get_widget("irqSpinButton").set_sensitive(True)
            self.xml.get_widget("irqSpinButton").set_value(int(card.IRQ))
        else:
            self.xml.get_widget("irqSpinButton").set_sensitive(False)

        if card.Mem:
            self.xml.get_widget("memEntry").set_sensitive(True)
            self.xml.get_widget("memEntry").set_text(card.Mem)
        else:
            self.xml.get_widget("memEntry").set_sensitive(False)

        if card.IoPort:
            self.xml.get_widget("ioEntry").set_sensitive(True)
            self.xml.get_widget("ioEntry").set_text(card.IoPort)
        else:
            self.xml.get_widget("ioEntry").set_sensitive(False)

        if card.IoPort1:
            self.xml.get_widget("io1Entry").set_sensitive(True)
            self.xml.get_widget("io1Entry").set_text(card.IoPort1)
        else:
            self.xml.get_widget("io1Entry").set_sensitive(False)

        if card.IoPort2:
            self.xml.get_widget("io2Entry").set_sensitive(True)
            self.xml.get_widget("io2Entry").set_text(card.IoPort2)
        else:
            self.xml.get_widget("io2Entry").set_sensitive(False)
コード例 #3
0
    def hydrate(self):
        has_card = False
        mid = self.hardwarelist.addHardware(ISDN)
        self.hw = self.hardwarelist[mid]
        self.hw.Type = 'ISDN'
        self.hw.createCard()
        self.hw.Name = "ISDN Card 0"
        conf = NCisdnhardware.ConfISDN()
        new_card = conf.detect()
        cardname = ''
        if new_card:
            has_card = True
            cardname = new_card.keys()[0]
            conf.get_resource(cardname)
            self.hw.Card.ChannelProtocol = '2'
            self.hw.Card.IRQ = conf.IRQ
            self.hw.Card.Mem = conf.Mem
            self.hw.Card.IoPort = conf.IoPort
            self.hw.Card.IoPort1 = conf.IoPort1
            self.hw.Card.IoPort2 = conf.IoPort2

        if has_card:
            if self.hw.Card.ChannelProtocol == '2':
                self.xml.get_widget("euroIsdnButton").set_active(True)
            else:
                self.xml.get_widget("1tr6Button").set_active(True)

            self.xml.get_widget("isdnCardEntry").set_text(cardname)

            if self.hw.Card.IRQ:
                self.xml.get_widget("irqSpinButton").set_sensitive(True)
                self.xml.get_widget("irqSpinButton").set_value(
                    self.hw.Card.IRQ.atoi())
            else:
                self.xml.get_widget("irqSpinButton").set_sensitive(False)

            if self.hw.Card.Mem:
                self.xml.get_widget("memEntry").set_sensitive(True)
                self.xml.get_widget("memEntry").set_text(self.hw.Card.Mem)
            else:
                self.xml.get_widget("memEntry").set_sensitive(False)

            if self.hw.Card.IoPort:
                self.xml.get_widget("ioEntry").set_sensitive(True)
                self.xml.get_widget("ioEntry").set_text(self.hw.Card.IoPort)
            else:
                self.xml.get_widget("ioEntry").set_sensitive(False)

            if self.hw.Card.IoPort1:
                self.xml.get_widget("io1Entry").set_sensitive(True)
                self.xml.get_widget("io1Entry").set_text(self.hw.Card.IoPort1)
            else:
                self.xml.get_widget("io1Entry").set_sensitive(False)

            if self.hw.Card.IoPort2:
                self.xml.get_widget("io2Entry").set_sensitive(True)
                self.xml.get_widget("io2Entry").set_text(self.hw.Card.IoPort2)
            else:
                self.xml.get_widget("io2Entry").set_sensitive(False)
コード例 #4
0
    def dehydrate(self):
        isdncard = NCisdnhardware.ConfISDN()
        isdncard.get_resource(self.xml.get_widget('adapterEntry').get_text())

        self.hw.Name = "ISDN Card 0"
        self.hw.Description = isdncard.Description
        self.hw.Card.ModuleName = isdncard.ModuleName
        self.hw.Card.Type = isdncard.Type
        self.hw.Card.Firmware = isdncard.Firmware
        self.hw.Card.VendorId = isdncard.VendorId
        self.hw.Card.DeviceId = isdncard.DeviceId
        self.hw.Card.DriverId = isdncard.DriverId

        if self.xml.get_widget("euroIsdnButton").get_active():
            self.hw.Card.ChannelProtocol = '2'
        else:
            self.hw.Card.ChannelProtocol = '1'

        if not self.xml.get_widget('irqSpinButton').get_property("sensitive"):
            self.hw.Card.IRQ = isdncard.IRQ
        else:
            self.hw.Card.IRQ = str(
                self.xml.get_widget('irqSpinButton').get_value_as_int())

        if not self.xml.get_widget('memEntry').get_property("sensitive"):
            self.hw.Card.Mem = isdncard.Mem
        else:
            self.hw.Card.Mem = self.xml.get_widget('memEntry').get_text()

        if not self.xml.get_widget('ioEntry').get_property("sensitive"):
            self.hw.Card.IoPort = isdncard.IoPort
        else:
            self.hw.Card.IoPort = self.xml.get_widget('ioEntry').get_text()

        if not self.xml.get_widget('io1Entry').get_property("sensitive"):
            self.hw.Card.IoPort1 = isdncard.IoPort1
        else:
            self.hw.Card.IoPort1 = self.xml.get_widget('io1Entry').get_text()

        if not self.xml.get_widget('io2Entry').get_property("sensitive"):
            self.hw.Card.IoPort2 = isdncard.IoPort2
        else:
            self.hw.Card.IoPort2 = self.xml.get_widget('io2Entry').get_text()
コード例 #5
0
    def save(self):
        self.commit() 

        modules = getMyConfModules(refresh = True)

        # cleanup isdnconf
        isdn = NCisdnhardware.ConfISDN()
        isdn.cleanup()

        for hw in self:
            hw.save()

        try:
            wvdial = getMyWvDial(create_if_missing = False)
        except:
            wvdial = None

        if wvdial:
            # Clean up wvdial
            for dev in wvdial.keys():
                if dev[:5] != 'Modem':
                    continue
                for hw in self:
                    if hw.Type == MODEM and hw.Name == dev:
                        break
                else:
                    # if the loop does not get interrupted by break
                    # we did not find the Modem in the hardwarelist
                    # and it gets deleted
                    del wvdial[dev]

        # FIXME: [198070] use modinfo to determine options
        # Clean up modules
        for mod in modules.keys():
            mtype = getDeviceType(mod)
            #
            # FIXME: This is not OO!!
            #
            if mtype != ETHERNET and mtype != TOKENRING and mtype != QETH and mtype != LCS:
                continue
            #print "Testing " + str(mod)
            for hw in self:
                if (hw.Type == ETHERNET or \
                    hw.Type == TOKENRING or \
                        hw.Type == QETH or \
                        hw.type == LCS) and \
                        hw.Name == mod:
                    break
            else:
                #print "Removing " + str(mod)
                #print str(modules.vars[mod].keys())
                del modules[mod]
                #print "Test: " + str(modules[mod])


        modules.write()
        if wvdial:
            wvdial.write()

        self.commit() 
        self.setunmodified() 
コード例 #6
0
    def load(self):
        #hwconf = ConfHWConf()

        # first clear the list
        self.__delslice__(0, len(self)) 

        # FIXME: move HW detection to NCDev*
        dosysupdate = True
        if getTestEnv():
            dosysupdate = False
        if dosysupdate:
            self.updateFromSystem()

        self.updateFromModules()

        for hw in self:
            if hw.Name == "ISDN Card 0":
                break
        else:
            #
            # XXX FIXME... this is not OO
            #
            isdncard = NCisdnhardware.ConfISDN()
            if isdncard.load() > 0:
                i = self.addHardware(ISDN)
                hw = self[i]
                hw.Name = "ISDN Card 0"
                hw.Description = isdncard.Description
                hw.Type = ISDN
                hw.Status = HW_CONF
                hw.Card = Card()
                hw.Card.ModuleName = isdncard.ModuleName
                hw.Card.Type = isdncard.Type
                hw.Card.IoPort = isdncard.IoPort
                hw.Card.IoPort1 = isdncard.IoPort1
                hw.Card.IoPort2 = isdncard.IoPort2
                hw.Card.Mem = isdncard.Mem
                hw.Card.IRQ = isdncard.IRQ
                hw.Card.ChannelProtocol = isdncard.ChannelProtocol
                hw.Card.Firmware = isdncard.Firmware
                hw.Card.DriverId = isdncard.DriverId
                hw.Card.VendorId = isdncard.VendorId
                hw.Card.DeviceId = isdncard.DeviceId

        #
        # FIXME: This is not OO!
        #
        try:
            wvdial = ConfSMB(getRoot() + WVDIALCONF)
        except FileMissing:
            pass
        else:
            for dev in wvdial.keys():
                if dev[:5] != 'Modem':
                    continue

                i = self.addHardware(MODEM)
                hw = self[i]
                hw.Name = dev
                hw.Description = 'Generic Modem'
                hw.Type = MODEM
                hw.Status = HW_CONF
                hw.createModem()
                if not wvdial[dev].has_key('Modem'):
                    wvdial[dev]['Modem'] = '/dev/modem'
                hw.Modem.DeviceName = wvdial[dev]['Modem']

                if not wvdial[dev].has_key('Baud'):
                    wvdial[dev]['Baud'] = '38400'
                try:
                    hw.Modem.BaudRate = int(wvdial[dev]['Baud'])
                except ValueError:
                    hw.Modem.BaudRate = 38400

                if not wvdial[dev].has_key('SetVolume'):
                    wvdial[dev]['SetVolume'] = '0'
                hw.Modem.ModemVolume = int(wvdial[dev]['SetVolume'])

                if not wvdial[dev].has_key('Dial Command'):
                    wvdial[dev]['Dial Command'] = 'ATDT'
                hw.Modem.DialCommand = wvdial[dev]['Dial Command']

                if not wvdial[dev].has_key('Init1'):
                    wvdial[dev]['Init1'] = 'ATZ'
                hw.Modem.InitString =  wvdial[dev]['Init1']

                if not wvdial[dev].has_key('FlowControl'):
                    wvdial[dev]['FlowControl'] = CRTSCTS
                hw.Modem.FlowControl =  wvdial[dev]['FlowControl']

        self.commit() 
        self.setunmodified() 
コード例 #7
0
 def setup(self):
     cardlist = NCisdnhardware.getCards().keys()  # pylint: disable-msg=
     cardlist.sort()
     self.xml.get_widget("isdnCardComboBox").set_popdown_strings(cardlist)