Exemple #1
0
    def __init__(self, *args):
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_RootPassWidget()
        self.ui.setupUi(self)

        self.host_valid = True
        self.pass_valid = False

        self.ui.pass_error.setVisible(False)
        self.ui.host_error.setVisible(False)
        self.ui.caps_error.setVisible(False)

        self.ui.caps_error.setText(_('<center><font color="#FF6D19">Caps Lock is on!</font></center>'))

        self.connect(self.ui.pass1, SIGNAL("textChanged(const QString &)"), self.slotTextChanged)
        self.connect(self.ui.pass2, SIGNAL("textChanged(const QString &)"), self.slotTextChanged)
        self.connect(self.ui.pass2, SIGNAL("returnPressed()"), self.slotReturnPressed)
        self.connect(self.ui.hostname, SIGNAL("textChanged(const QString &)"), self.slotHostnameChanged)
Exemple #2
0
class Widget(QtGui.QWidget, ScreenWidget):
    title = _("Set Administrator")
    desc = _("Admins has important rights on the system..")
    icon = "iconAdmin"
    help = _(
        """
<font size="+2">System administrator password and hostname</font>

<font size="+1">

<p>Please give a password for the system administrator (i.e root) for your
system. This password should be unique and private, as it is used to 
manage your desktop. Choose a password difficult to guess, but easy
to remember. 
</p>
<p>
The password may include upper and lower case characters, numbers and 
punctuation marks. Do not use accented characters here.
</p>

<p>
And also set the name that the computer will be identified to the network it belongs. The hostname should be descriptive enough to describe the computer.  
</p>

<p>
Click Next button to proceed.
</p>
</font>
"""
    )

    def __init__(self, *args):
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_RootPassWidget()
        self.ui.setupUi(self)

        self.host_valid = True
        self.pass_valid = False

        self.ui.pass_error.setVisible(False)
        self.ui.host_error.setVisible(False)
        self.ui.caps_error.setVisible(False)

        self.ui.caps_error.setText(_('<center><font color="#FF6D19">Caps Lock is on!</font></center>'))

        self.connect(self.ui.pass1, SIGNAL("textChanged(const QString &)"), self.slotTextChanged)
        self.connect(self.ui.pass2, SIGNAL("textChanged(const QString &)"), self.slotTextChanged)
        self.connect(self.ui.pass2, SIGNAL("returnPressed()"), self.slotReturnPressed)
        self.connect(self.ui.hostname, SIGNAL("textChanged(const QString &)"), self.slotHostnameChanged)

    def shown(self):
        try:
            # Use first added user's name as machine name
            hostname_guess = "%s-pardus" % yali4.users.pending_users[0].username
            if self.ui.hostname.text() == "":
                self.ui.hostname.setText(hostname_guess)
        except:
            pass
        self.setNext()
        self.checkCapsLock()
        self.ui.pass1.setFocus()

    def execute(self):
        ctx.installData.rootPassword = unicode(self.ui.pass1.text())
        ctx.installData.hostName = self.ui.hostname.text().toAscii()
        return True

    def checkCapsLock(self):
        if pardus.xorg.capslock.isOn():
            self.ui.caps_error.setVisible(True)
        else:
            self.ui.caps_error.setVisible(False)

    def keyReleaseEvent(self, e):
        self.checkCapsLock()

    def slotTextChanged(self):

        p1 = self.ui.pass1.text()
        p2 = self.ui.pass2.text()

        if p1 == p2 and p1:
            if len(p1) < 4:
                self.ui.pass_error.setText(_('<center><font color="#FF6D19">Password is too short!</font></center>'))
                self.ui.pass_error.setVisible(True)
                self.pass_valid = False
            else:
                self.ui.pass_error.setVisible(False)
                self.pass_valid = True
        else:
            self.pass_valid = False
            if p2:
                self.ui.pass_error.setText(_('<center><font color="#FF6D19">Passwords do not match!</font></center>'))
                self.ui.pass_error.setVisible(True)

        self.setNext()

    ##
    # check hostname validity
    def slotHostnameChanged(self, string):

        if not string.toAscii():
            self.host_valid = False
            self.setNext()
            return

        self.host_valid = yali4.sysutils.text_is_valid(string.toAscii())

        if not self.host_valid:
            self.ui.host_error.setVisible(True)
            self.ui.host_error.setText(
                _('<center><font color="#FF6D19">Hostname contains invalid characters!</font></center>')
            )
        else:
            self.ui.host_error.setVisible(False)
        self.setNext()

    def setNext(self):
        if self.host_valid and self.pass_valid:
            ctx.mainScreen.enableNext()
        else:
            ctx.mainScreen.disableNext()

    def slotReturnPressed(self):
        if ctx.mainScreen.isNextEnabled():
            ctx.mainScreen.slotNext()
Exemple #3
0
class Widget(QtGui.QWidget, ScreenWidget):
    title = _('Set Administrator')
    desc = _('Admins have important rights on the system...')
    icon = "iconAdmin"
    help = _('''
<font size="+2">System administrator password and hostname</font>

<font size="+1">
<p>
You need to define a password for the "root" user that has full control over the system.
Your password must be easy to remember (for you) but hard to guess (for others). 
You can use lower case or upper case letters, numbers and punctuation marks in your password. 
You should take care not to use letters not found in English to avoid incompatibilities with other systems.
</p>
<p>
Here you can enter a name for your computer in the text box below. As your computer will be 
known with this name in the local network, it is advised to enter a descriptive text.
Proceed with the installation after you make your selections.
</p>
<p>
Click Next button to proceed.
</p>
</font>
''')

    def __init__(self, *args):
        QtGui.QWidget.__init__(self,None)
        self.ui = Ui_RootPassWidget()
        self.ui.setupUi(self)

        self.host_valid = True
        self.pass_valid = False

        self.ui.pass_error.setVisible(False)
        self.ui.host_error.setVisible(False)
        self.ui.caps_error.setVisible(False)

        self.ui.caps_error.setText(_('<center><font color="#FF6D19">Caps Lock is on!</font></center>'))

        self.connect(self.ui.pass1, SIGNAL("textChanged(const QString &)"),
                     self.slotTextChanged)
        self.connect(self.ui.pass2, SIGNAL("textChanged(const QString &)"),
                     self.slotTextChanged)
        self.connect(self.ui.pass2, SIGNAL("returnPressed()"),
                     self.slotReturnPressed)
        self.connect(self.ui.hostname, SIGNAL("textChanged(const QString &)"),
                     self.slotHostnameChanged)

    def shown(self):

        if ctx.installData.hostName:
            self.ui.hostname.setText(str(ctx.installData.hostName))
        else:
            try:
                # Use first added user's name as machine name
                hostname_guess = "%s-pardus" % yali4.users.pending_users[0].username
                if self.ui.hostname.text() == '':
                    self.ui.hostname.setText(hostname_guess)
            except:
                pass

        if ctx.installData.rootPassword:
            self.ui.pass1.setText(ctx.installData.rootPassword)
            self.ui.pass2.setText(ctx.installData.rootPassword)

        self.setNext()
        self.checkCapsLock()
        self.ui.pass1.setFocus()

    def execute(self):
        ctx.installData.rootPassword = unicode(self.ui.pass1.text())
        ctx.installData.hostName = self.ui.hostname.text().toAscii()
        return True

    def checkCapsLock(self):
        if pardus.xorg.capslock.isOn():
            self.ui.caps_error.setVisible(True)
        else:
            self.ui.caps_error.setVisible(False)

    def keyReleaseEvent(self, e):
        self.checkCapsLock()

    def slotTextChanged(self):

        p1 = self.ui.pass1.text()
        p2 = self.ui.pass2.text()

        if p1 == p2 and p1:
            if len(p1)<4:
                self.ui.pass_error.setText(_('<center><font color="#FF6D19">Password is too short!</font></center>'))
                self.ui.pass_error.setVisible(True)
                self.pass_valid = False
            else:
                self.ui.pass_error.setVisible(False)
                self.pass_valid = True
        else:
            self.pass_valid = False
            if p2:
                self.ui.pass_error.setText(_('<center><font color="#FF6D19">Passwords do not match!</font></center>'))
                self.ui.pass_error.setVisible(True)
        if str(p1).lower()=="root" or str(p2).lower()=="root":
            self.pass_valid = False
            if p2:
                self.ui.pass_error.setText(_('<center><font color="#FF6D19">Don\'t use your username as password !</font></center>'))
                self.ui.pass_error.setVisible(True)
        if self.pass_valid:
            self.ui.pass_error.setVisible(False)

        self.setNext()

    ##
    # check hostname validity
    def slotHostnameChanged(self, string):

        if not string.toAscii():
            self.host_valid = False
            self.setNext()
            return

        self.host_valid = yali4.sysutils.text_is_valid(string.toAscii())

        if not self.host_valid:
            self.ui.host_error.setVisible(True)
            self.ui.host_error.setText(_('<center><font color="#FF6D19">Hostname contains invalid characters!</font></center>'))
        else:
            self.ui.host_error.setVisible(False)
        self.setNext()

    def setNext(self):
        if self.host_valid and self.pass_valid:
            ctx.mainScreen.enableNext()
        else:
            ctx.mainScreen.disableNext()

    def slotReturnPressed(self):
        if ctx.mainScreen.isNextEnabled():
            ctx.mainScreen.slotNext()