示例#1
0
    def box_commit(self, box_layout):
        passwd = box_layout.passwd.text()
        if not passwd:
            self.show_msg(self.msg["msg_password_empty"])
            return
        passwd = rsa_encode(passwd, self.keys["public"])

        if not passwd:
            self.show_msg(self.msg["msg_encrypt_error"])
            return
        # dict methods on add
        db_add = dict(emails=self.db.insert_email,
                      accounts=self.db.insert_account,
                      other_accounts=self.db.insert_other_account)

        db_add[box_layout.tbl]([
            box_layout.service.text(),
            box_layout.login.text(),
            passwd,
            box_layout.forgot.text(),
        ])
        self.box_connect(box_layout, False)
        del self.widgets["add"]
        box_layout.deleteLater()
        self.show_accounts(self.tbl, True)
        self.show_msg(self.msg["msg_account_add"].format(box_layout.login.text()))
示例#2
0
    def box_update(self, box_layout):
        if not box_layout.flag:
            self.show_msg(self.msg["msg_update_error_1"])
            return

        passwd = box_layout.passwd.text()
        if not passwd:
            self.show_msg(self.msg["msg_update_error_2"])
            return

        passwd = rsa_encode(passwd, self.keys["public"])
        if not passwd:
            self.show_msg(self.msg["msg_update_error_3"])
            return

        result, msg = self.db.update_account(
            box_layout.tbl,
            box_layout.service.text(),
            box_layout.login.text(),
            passwd,
            box_layout.forgot.text(),
            box_layout.id
        )

        if result:
            self.box_flag_change(box_layout, passwd)
            self.box_connect(box_layout, False)
            box_layout.set_hint()
            self.show_msg(self.msg["msg_update_ok"])
        else:
            self.show_msg(self.msg["msg_update_error_4"])
示例#3
0
    def box_update(self, box_layout):

        error = lambda: \
            self.animation_object(box_layout,
                                  color=
                                  list(self.animation_color["border"]),
                                  color_end=
                                  list(self.animation_color["error"]),
                                  font_color=
                                  list(self.animation_color["font"]),
                                  reverse=True)

        if not box_layout.flag:
            self.show_msg(self.msg["msg_update_error_1"])
            error()
            return

        passwd = box_layout.passwd.text()
        if not passwd:
            self.show_msg(self.msg["msg_update_error_2"])
            error()
            return

        passwd = rsa_encode(passwd, self.keys["public"])
        if not passwd:
            self.show_msg(self.msg["msg_update_error_3"])
            error()
            return

        result, _ = self.db.update_account(
            box_layout.tbl,
            box_layout.service.text(),
            box_layout.login.text(),
            passwd,
            box_layout.forgot.text(),
            box_layout.id
        )

        self.animation_object(box_layout,
                              color=
                              list(self.animation_color["border"]),
                              color_end=
                              list(self.animation_color["light"]),
                              font_color=
                              list(self.animation_color["font"]),
                              reverse=True)
        if result:
            self.box_flag_change(box_layout, passwd)
            self.box_connect(box_layout, False)
            box_layout.set_hint()
            self.show_msg(self.msg["msg_update_ok"])
        else:
            self.show_msg(self.msg["msg_update_error_4"])
            error()
示例#4
0
    def box_commit(self, box_layout):

        error = lambda: \
            self.animation_object(box_layout,
                                  color=
                                  list(self.animation_color["border"]),
                                  color_end=
                                  list(self.animation_color["error"]),
                                  font_color=
                                  list(self.animation_color["font"]),
                                  reverse=True)

        passwd = box_layout.passwd.text()
        if not passwd:
            self.show_msg(self.msg["msg_password_empty"])
            error()
            return
        passwd = rsa_encode(passwd, self.keys["public"])

        if not passwd:
            self.show_msg(self.msg["msg_encrypt_error"])
            error()
            return
        # dict methods on add
        db_add = dict(emails=self.db.insert_email,
                      accounts=self.db.insert_account,
                      other_accounts=self.db.insert_other_account)
        account_info = [0,
                        box_layout.service.text(),
                        box_layout.login.text(),
                        passwd,
                        box_layout.forgot.text()]
        id = db_add[box_layout.tbl](account_info[1:])
        account_info[0] = id
        self.box_connect(box_layout, False)
        box_layout.deleteLater()
        self.animation_object(box_layout,
                              color=
                              list(self.animation_color["border"]),
                              color_end=
                              list(self.animation_color["hide"]),
                              font_color=
                              list(self.animation_color["font"]),
                              font_end_color=
                              list(self.animation_color["hide"]),
                              reverse=True)
        del self.widgets["add"]
        wait((self, self.my_signal, self.tbl, True,
              [account_info],))
        self.show_msg(
            self.msg["msg_account_add"].format(account_info[2]))