Example #1
0
    def __init__(self):
        QWidget.__init__(self)
        self.ui = Ui_RescuePasswordWidget()
        self.ui.setupUi(self)

        self.ui.users.currentItemChanged[QListWidgetItem,
                                         QListWidgetItem].connect(self.refresh)
        self.ui.password.textChanged[str].connect(self.slotTextChanged)
        self.ui.confirm.textChanged[str].connect(self.slotTextChanged)
        #self.ui.password.focusInEvent[QFocusEvent].connect(self.checkCapsLock)
        #self.ui.confirm.focusInEvent[QFocusEvent].connect(self.checkCapsLock)
        self.ui.resetPassword.clicked.connect(self.slotResetPassword)
    def __init__(self):
        QWidget.__init__(self)
        self.ui = Ui_RescuePasswordWidget()
        self.ui.setupUi(self)

        self.ui.users.currentItemChanged[QListWidgetItem, QListWidgetItem].connect(self.refresh)
        self.ui.password.textChanged[str].connect(self.slotTextChanged)
        self.ui.confirm.textChanged[str].connect(self.slotTextChanged)
        #self.ui.password.focusInEvent[QFocusEvent].connect(self.checkCapsLock)
        #self.ui.confirm.focusInEvent[QFocusEvent].connect(self.checkCapsLock)
        self.ui.resetPassword.clicked.connect(self.slotResetPassword)
Example #3
0
    def __init__(self):
        QWidget.__init__(self)
        self.ui = Ui_RescuePasswordWidget()
        self.ui.setupUi(self)

        self.connect(self.ui.users, SIGNAL("currentItemChanged(QListWidgetItem*, QListWidgetItem*)"),
                     self.refresh)
        self.connect(self.ui.password, SIGNAL("textChanged(const QString &)"),
                     self.slotTextChanged)
        self.connect(self.ui.confirm, SIGNAL("textChanged(const QString &)"),
                     self.slotTextChanged)
        self.connect(self.ui.password, SIGNAL("focusInEvent(QFocusEvent*)"),
                     self.checkCapsLock)
        self.connect(self.ui.confirm, SIGNAL("focusInEvent(QFocusEvent*)"),
                     self.checkCapsLock)
        self.connect(self.ui.resetPassword, SIGNAL("clicked()"), self.slotResetPassword)
Example #4
0
    def __init__(self, *args):
        QtGui.QWidget.__init__(self,None)
        self.ui = Ui_RescuePasswordWidget()
        self.ui.setupUi(self)

        self.ui.pass_error.setVisible(False)
        self.ui.caps_error.setVisible(False)
        self.ui.caps_error.setText(_('Caps Lock is on.'))

        self.ui.updatePassword.setEnabled(False)

        self.steps = YaliSteps()
        self.steps.setOperations([{"text":_("Starting D-Bus..."),"operation":yali.sysutils.chrootDbus},
                                  {"text":_("Connecting to D-Bus..."),"operation":yali.postinstall.connectToDBus},
                                  {"text":_("Acquiring users..."),"operation":self.fillUserList}])

        self.connect(self.ui.updatePassword, SIGNAL("clicked()"), self.updatePassword)
        self.connect(self.ui.userList, SIGNAL("itemChanged(QListWidgetItem*)"),
                     self.resetWidgets)
        self.connect(self.ui.pass1, SIGNAL("textChanged(const QString &)"),
                     self.slotTextChanged)
        self.connect(self.ui.pass2, SIGNAL("textChanged(const QString &)"),
                     self.slotTextChanged)
Example #5
0
class Widget(QtGui.QWidget, ScreenWidget):
    title = _("Reset Forgotten Passwords")
    icon = "iconInstall"
    help = _("""
<font size="+2">Password Recovery</font>
<font size="+1">
<p>
Here you can reset..
</p>
""")

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

        self.ui.pass_error.setVisible(False)
        self.ui.caps_error.setVisible(False)
        self.ui.caps_error.setText(_('Caps Lock is on.'))

        self.ui.updatePassword.setEnabled(False)

        self.steps = YaliSteps()
        self.steps.setOperations([{"text":_("Starting D-Bus..."),"operation":yali.sysutils.chrootDbus},
                                  {"text":_("Connecting to D-Bus..."),"operation":yali.postinstall.connectToDBus},
                                  {"text":_("Acquiring users..."),"operation":self.fillUserList}])

        self.connect(self.ui.updatePassword, SIGNAL("clicked()"), self.updatePassword)
        self.connect(self.ui.userList, SIGNAL("itemChanged(QListWidgetItem*)"),
                     self.resetWidgets)
        self.connect(self.ui.pass1, SIGNAL("textChanged(const QString &)"),
                     self.slotTextChanged)
        self.connect(self.ui.pass2, SIGNAL("textChanged(const QString &)"),
                     self.slotTextChanged)

    def resetWidgets(self):
        self.ui.pass1.clear()
        self.ui.pass2.clear()
        self.ui.updatePassword.setEnabled(False)

    def showError(self,message):
        self.ui.pass_error.setText("<center>%s</center>" % message)
        self.ui.pass_error.setVisible(True)
        self.ui.updatePassword.setEnabled(False)

    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 updatePassword(self):
        password = unicode(self.ui.pass1.text())
        uid  = int(self.ui.userList.currentItem().getInfo()[0])
        yali.postinstall.setUserPass(uid, password)
        InfoDialog(_("The password has been successfully reset."), title = _("Info"))
        self.resetWidgets()

    def slotTextChanged(self):
        p1 = self.ui.pass1.text()
        p2 = self.ui.pass2.text()
        if not self.ui.userList.currentItem():
            return
        user = self.ui.userList.currentItem().getInfo()
        if not p1 == '' and (str(p1).lower() == str(user[1]).lower() or \
                str(p1).lower() == str(user[2]).lower()):
            self.showError(_('Do not use your username or real name as your password.'))
            return
        elif p2 != p1 and p2:
            self.showError(_('The passwords do not match.'))
            return
        elif len(p1) == len(p2) and len(p2) < 4 and not p1=='':
            self.showError(_('Password is too short.'))
            return
        elif p1 == '' or p2 == '':
            self.ui.pass_error.setVisible(False)
            return
        else:
            self.ui.pass_error.setVisible(False)
            self.ui.updatePassword.setEnabled(True)

    def shown(self):
        ctx.mainScreen.disableBack()
        ctx.yali.info.show()
        self.steps.slotRunOperations()
        ctx.yali.info.hide()

    def fillUserList(self):
        users = yali.postinstall.getUserList()
        for user in users:
            UserItem(self.ui.userList, user)

    def execute(self):
        return True

    def backCheck(self):
        ctx.mainScreen.moveInc = 3
        return True
Example #6
0
class Widget(QWidget, ScreenWidget):
    name = "passwordRescue"

    def __init__(self):
        QWidget.__init__(self)
        self.ui = Ui_RescuePasswordWidget()
        self.ui.setupUi(self)

        self.ui.users.currentItemChanged[QListWidgetItem,
                                         QListWidgetItem].connect(self.refresh)
        self.ui.password.textChanged[str].connect(self.slotTextChanged)
        self.ui.confirm.textChanged[str].connect(self.slotTextChanged)
        #self.ui.password.focusInEvent[QFocusEvent].connect(self.checkCapsLock)
        #self.ui.confirm.focusInEvent[QFocusEvent].connect(self.checkCapsLock)
        self.ui.resetPassword.clicked.connect(self.slotResetPassword)

    def eventFilter(self, obj, event):
        if even.type() == QEvent.FocusIn:
            if obj == self.ui.password or obj == self.ui.confirm:
                self.checkCapsLock()

    def refresh(self, current, previous):
        self.ui.password.clear()
        self.ui.confirm.clear()
        self.ui.resetPassword.setEnabled(False)

    def setCapsLockIcon(self, child):
        if type(child) == QLineEdit:
            if pardus.xorg.capslock.isOn():
                child.setStyleSheet("""QLineEdit {
                        background-image: url(:/gui/pics/caps.png);
                        background-repeat: no-repeat;
                        background-position: right;
                        padding-right: 35px;
                        }""")
            else:
                child.setStyleSheet("""QLineEdit {
                        background-image: none;
                        padding-right: 0px;
                        }""")

    def checkCapsLock(self):
        for child in self.ui.groupBox.children():
            self.setCapsLockIcon(child)
        for child in self.ui.groupBox_2.children():
            self.setCapsLockIcon(child)

    def showError(self, message):
        ctx.interface.informationWindow.update(message, type="error")
        ctx.mainScreen.disableNext()

    def slotResetPassword(self):
        user = self.ui.users.currentItem().user
        user.passwd = unicode(self.ui.password.text())
        user_exist = False
        for pending_user in yali.users.PENDING_USERS:
            if pending_user.uid == user.uid:
                pending_user = user
                break
        else:
            yali.users.PENDING_USERS.append(user)

        self.ui.resetPassword.setEnabled(False)
        ctx.mainScreen.enableNext()

    def slotTextChanged(self):
        self.ui.resetPassword.setEnabled(False)
        user = self.ui.users.currentItem().user
        username = user.username
        realname = user.realname
        password = unicode(self.ui.password.text())
        password_confirm = unicode(self.ui.confirm.text())

        if not password == '' and (password.lower() == username.lower()
                                   or password.lower() == realname.lower()):
            self.showError(
                _('Don\'t use your user name or name as a password'))
            return
        elif password_confirm and password_confirm != password:
            self.showError(_('Passwords do not match'))
            return
        elif len(password) == len(password_confirm) and len(
                password_confirm) < 4 and not password == '':
            self.showError(_('Password is too short'))
            return
        else:
            ctx.interface.informationWindow.hide()

        if password and password_confirm:
            self.ui.resetPassword.setEnabled(True)

    def fillUsers(self):
        self.ui.users.clear()
        users = yali.util.getUsers()
        for user in users:
            RescueUser(self.ui.users, user)

        if not self.ui.users.count():
            rc = ctx.interface.messageWindow(
                _("Cannot Rescue"),
                _("Your current installation cannot be rescued."),
                type="custom",
                customIcon="warning",
                customButtons=[_("Exit"), _("Continue")])
            if rc == 0:
                sys.exit(0)
            else:
                ctx.mainScreen.disableNext()

    def shown(self):
        ctx.mainScreen.disableBack()
        self.fillUsers()
        self.ui.resetPassword.setEnabled(False)

    def execute(self):
        return True

    def backCheck(self):
        ctx.mainScreen.step_increment += ctx.installData.rescueMode
        return True
Example #7
0
class Widget(QWidget, ScreenWidget):
    name = "passwordRescue"

    def __init__(self):
        QWidget.__init__(self)
        self.ui = Ui_RescuePasswordWidget()
        self.ui.setupUi(self)

        self.connect(self.ui.users, SIGNAL("currentItemChanged(QListWidgetItem*, QListWidgetItem*)"),
                     self.refresh)
        self.connect(self.ui.password, SIGNAL("textChanged(const QString &)"),
                     self.slotTextChanged)
        self.connect(self.ui.confirm, SIGNAL("textChanged(const QString &)"),
                     self.slotTextChanged)
        self.connect(self.ui.password, SIGNAL("focusInEvent(QFocusEvent*)"),
                     self.checkCapsLock)
        self.connect(self.ui.confirm, SIGNAL("focusInEvent(QFocusEvent*)"),
                     self.checkCapsLock)
        self.connect(self.ui.resetPassword, SIGNAL("clicked()"), self.slotResetPassword)

    def refresh(self, current, previous):
        self.ui.password.clear()
        self.ui.confirm.clear()
        self.ui.resetPassword.setEnabled(False)

    def setCapsLockIcon(self, child):
        if type(child) == QLineEdit:
            if pardus.xorg.capslock.isOn():
                child.setStyleSheet("""QLineEdit {
                        background-image: url(:/gui/pics/caps.png);
                        background-repeat: no-repeat;
                        background-position: right;
                        padding-right: 35px;
                        }""")
            else:
                child.setStyleSheet("""QLineEdit {
                        background-image: none;
                        padding-right: 0px;
                        }""")


    def checkCapsLock(self):
        for child in self.ui.groupBox.children():
            self.setCapsLockIcon(child)
        for child in self.ui.groupBox_2.children():
            self.setCapsLockIcon(child)

    def showError(self, message):
        ctx.interface.informationWindow.update(message, type="error")
        ctx.mainScreen.disableNext()

    def slotResetPassword(self):
        user = self.ui.users.currentItem().user
        user.passwd = unicode(self.ui.password.text())
        user_exist = False
        for pending_user in yali.users.PENDING_USERS:
            if pending_user.uid == user.uid:
                pending_user = user
                break
        else:
            yali.users.PENDING_USERS.append(user)

        self.ui.resetPassword.setEnabled(False)
        ctx.mainScreen.enableNext()

    def slotTextChanged(self):
        self.ui.resetPassword.setEnabled(False)
        user = self.ui.users.currentItem().user
        username = user.username
        realname = user.realname
        password = unicode(self.ui.password.text())
        password_confirm = unicode(self.ui.confirm.text())

        if not password == '' and (password.lower() == username.lower() or
                                   password.lower() == realname.lower()):
            self.showError(_('Don\'t use your user name or name as a password'))
            return
        elif password_confirm and password_confirm != password:
            self.showError(_('Passwords do not match'))
            return
        elif len(password) == len(password_confirm) and len(password_confirm) < 4 and not password =='':
            self.showError(_('Password is too short'))
            return
        else:
            ctx.interface.informationWindow.hide()

        if password and password_confirm:
            self.ui.resetPassword.setEnabled(True)

    def fillUsers(self):
        self.ui.users.clear()
        users = yali.util.getUsers()
        for user in users:
            RescueUser(self.ui.users, user)

        if not self.ui.users.count():
            rc = ctx.interface.messageWindow(_("Cannot Rescue"),
                                             _("Your current installation cannot be rescued."),
                                             type="custom", customIcon="warning",
                                             customButtons=[_("Exit"), _("Continue")])
            if rc == 0:
                sys.exit(0)
            else:
                ctx.mainScreen.disableNext()

    def shown(self):
        ctx.mainScreen.disableBack()
        self.fillUsers()
        self.ui.resetPassword.setEnabled(False)

    def execute(self):
        return True

    def backCheck(self):
        ctx.mainScreen.step_increment += ctx.installData.rescueMode
        return True