Exemplo n.º 1
0
    async def send_join_demand(self, checked=False):
        if not self.model.connection:
            return
        if not self.model.get_identity_data()["membership_state"]:
            result = await self.view.licence_dialog(
                self.model.connection.currency, self.model.parameters())
            if result == QMessageBox.No:
                return

        secret_key, password = await PasswordInputController.open_dialog(
            self, self.model.connection)
        if not password or not secret_key:
            return
        result = await self.model.send_join(secret_key, password)
        if result[0]:
            if self.model.notifications():
                toast.display(self.tr("Membership"),
                              self.tr("Success sending Membership demand"))
            else:
                await QAsyncMessageBox.information(
                    self.view, self.tr("Membership"),
                    self.tr("Success sending Membership demand"))
        else:
            if self.model.notifications():
                toast.display(self.tr("Membership"), result[1])
            else:
                await QAsyncMessageBox.critical(self.view,
                                                self.tr("Membership"),
                                                result[1])
Exemplo n.º 2
0
    async def send_join_demand(self, checked=False):
        if not self.model.connection:
            return
        if not self.model.get_identity_data()["membership_state"]:
            result = await self.view.licence_dialog(self.model.connection.currency,
                                                    self.model.parameters())
            if result == QMessageBox.No:
                return

        secret_key, password = await PasswordInputController.open_dialog(self, self.model.connection)
        if not password or not secret_key:
            return
        result = await self.model.send_join(secret_key, password)
        if result[0]:
            if self.model.notifications():
                toast.display(self.tr("Membership"), self.tr("Success sending Membership demand"))
            else:
                await QAsyncMessageBox.information(self.view, self.tr("Membership"),
                                                        self.tr("Success sending Membership demand"))
        else:
            if self.model.notifications():
                toast.display(self.tr("Membership"), result[1])
            else:
                await QAsyncMessageBox.critical(self.view, self.tr("Membership"),
                                                        result[1])
Exemplo n.º 3
0
 async def show_success(self, notification):
     if notification:
         toast.display(self.tr("Certification"),
                       self.tr("Success sending certification"))
     else:
         await QAsyncMessageBox.information(self, self.tr("Certification"),
                                      self.tr("Success sending certification"))
Exemplo n.º 4
0
    def accept(self):
        self.button_box.setEnabled(False)
        if self.radio_contact.isChecked():
            for contact in self.account.contacts:
                if contact['name'] == self.combo_contact.currentText():
                    pubkey = contact['pubkey']
                    break
        else:
            pubkey = self.edit_pubkey.text()

        password = yield from self.password_asker.async_exec()
        if password == "":
            self.button_box.setEnabled(True)
            return
        QApplication.setOverrideCursor(Qt.WaitCursor)
        result = yield from self.account.certify(password, self.community, pubkey)
        if result[0]:
            if self.app.preferences['notifications']:
                toast.display(self.tr("Certification"),
                              self.tr("Success sending certification"))
            else:
                yield from QAsyncMessageBox.information(self, self.tr("Certification"),
                                             self.tr("Success sending certification"))
            QApplication.restoreOverrideCursor()
            super().accept()
        else:
            if self.app.preferences['notifications']:
                toast.display(self.tr("Certification"), self.tr("Could not broadcast certification : {0}"
                                                                .format(result[1])))
            else:
                yield from QAsyncMessageBox.critical(self, self.tr("Certification"),
                                          self.tr("Could not broadcast certification : {0}"
                                                                .format(result[1])))
            QApplication.restoreOverrideCursor()
            self.button_box.setEnabled(True)
Exemplo n.º 5
0
 async def show_success(self, notification):
     text = (self.tr("Identity proof"),
                       self.tr("Success sending identity proof"))
     if notification:
         toast.display(*text)
     else:
         await QAsyncMessageBox.information(self, *text)
Exemplo n.º 6
0
 async def show_error(self, notification, error_txt):
     text = (self.tr("Certification"), self.tr("Could not broadcast certification : {0}"
                                                         .format(error_txt)))
     if notification:
         toast.display(*text)
     else:
         await QAsyncMessageBox.critical(self, *text)
Exemplo n.º 7
0
 async def notification_reception(self, received_list):
     if len(received_list) > 0:
         localized_amount = await self.model.received_amount(received_list)
         text = self.tr("Received {amount} from {number} transfers").format(amount=localized_amount,
                                                                            number=len(received_list))
         if self.model.notifications():
             toast.display(self.tr("New transactions received"), text)
Exemplo n.º 8
0
    async def publish_uid(self, connection):
        identity = self.model.generate_identity(connection)
        identity_doc = identity.document()
        if not identity_doc.signatures:
            secret_key, password = await PasswordInputController.open_dialog(self, connection)
            if not password or not secret_key:
                return
            key = SigningKey(secret_key, password, connection.scrypt_params)
            identity_doc.sign([key])
            identity.signature = identity_doc.signatures[0]
            self.model.update_identity(identity)

        result = await self.model.send_identity(connection, identity_doc)
        if result[0]:
            if self.model.notifications():
                toast.display(self.tr("UID"), self.tr("Success publishing your UID"))
            else:
                await QAsyncMessageBox.information(self.view, self.tr("UID"),
                                                        self.tr("Success publishing your UID"))
        else:
            if not self.model.notifications():
                toast.display(self.tr("UID"), result[1])
            else:
                await QAsyncMessageBox.critical(self.view, self.tr("UID"),
                                                        result[1])
Exemplo n.º 9
0
 async def notification_reception(self, received_list):
     if len(received_list) > 0:
         localized_amount = await self.model.received_amount(received_list)
         text = self.tr("Received {amount} from {number} transfers").format(
             amount=localized_amount, number=len(received_list))
         if self.model.notifications():
             toast.display(self.tr("New transactions received"), text)
Exemplo n.º 10
0
 async def show_success(self, notification):
     if notification:
         toast.display(self.tr("Certification"),
                       self.tr("Success sending certification"))
     else:
         await QAsyncMessageBox.information(self, self.tr("Certification"),
                                      self.tr("Success sending certification"))
Exemplo n.º 11
0
    async def publish_uid(self, connection):
        identity = self.model.generate_identity(connection)
        identity_doc = identity.document()
        if not identity_doc.signatures:
            secret_key, password = await PasswordInputController.open_dialog(
                self, connection)
            if not password or not secret_key:
                return
            key = SigningKey(secret_key, password, connection.scrypt_params)
            identity_doc.sign([key])
            identity.signature = identity_doc.signatures[0]
            self.model.update_identity(identity)

        result = await self.model.send_identity(connection, identity_doc)
        if result[0]:
            if self.model.notifications():
                toast.display(self.tr("UID"),
                              self.tr("Success publishing your UID"))
            else:
                await QAsyncMessageBox.information(
                    self.view, self.tr("UID"),
                    self.tr("Success publishing your UID"))
        else:
            if not self.model.notifications():
                toast.display(self.tr("UID"), result[1])
            else:
                await QAsyncMessageBox.critical(self.view, self.tr("UID"),
                                                result[1])
Exemplo n.º 12
0
 async def show_success(self, notification, recipient):
     if notification:
         toast.display(self.tr("Transfer"),
                   self.tr("Success sending money to {0}").format(recipient))
     else:
         await QAsyncMessageBox.information(self, self.tr("Transfer"),
                   self.tr("Success sending money to {0}").format(recipient))
Exemplo n.º 13
0
    async def send_leave(self):
        reply = await QAsyncMessageBox.warning(
            self, self.tr("Warning"),
            self.tr("""Are you sure ?
Sending a leaving demand  cannot be canceled.
The process to join back the community later will have to be done again.""").
            format(self.account.pubkey), QMessageBox.Ok | QMessageBox.Cancel)
        if reply == QMessageBox.Ok:
            connection = self.model.navigation_model.navigation.current_connection(
            )
            secret_key, password = await PasswordInputController.open_dialog(
                self, connection)
            if not password or not secret_key:
                return
            result = await self.model.send_leave(connection, secret_key,
                                                 password)
            if result[0]:
                if self.app.preferences['notifications']:
                    toast.display(self.tr("Revoke"),
                                  self.tr("Success sending Revoke demand"))
                else:
                    await QAsyncMessageBox.information(
                        self, self.tr("Revoke"),
                        self.tr("Success sending Revoke demand"))
            else:
                if self.app.preferences['notifications']:
                    toast.display(self.tr("Revoke"), result[1])
                else:
                    await QAsyncMessageBox.critical(self, self.tr("Revoke"),
                                                    result[1])
Exemplo n.º 14
0
 async def show_success(self, notification):
     if notification:
         toast.display(self.tr("UID broadcast"),
                       self.tr("Identity broadcasted to the network"))
     else:
         await QAsyncMessageBox.information(
             self, self.tr("UID broadcast"),
             self.tr("Identity broadcasted to the network"))
Exemplo n.º 15
0
    async def show_error(self, notification, error_txt):

        if notification:
            toast.display(self.tr("Certification"), self.tr("Could not broadcast certification : {0}"
                                                            .format(error_txt)))
        else:
            await QAsyncMessageBox.critical(self, self.tr("Certification"),
                                            self.tr("Could not broadcast certification : {0}"
                                                    .format(error_txt)))
Exemplo n.º 16
0
 def notification_reception(self, received_list):
     if len(received_list) > 0:
         amount = 0
         for r in received_list:
             amount += r.metadata['amount']
         localized_amount = yield from self.app.current_account.current_ref(amount, self.community, self.app)\
                                         .localized(units=True,
                                 international_system=self.app.preferences['international_system_of_units'])
         text = self.tr("Received {amount} from {number} transfers").format(amount=localized_amount ,
                                                                         number=len(received_list))
         if self.app.preferences['notifications']:
             toast.display(self.tr("New transactions received"), text)
Exemplo n.º 17
0
    def latest_version_requested(self):
        latest = self.app.available_version
        logging.debug("Latest version requested")
        if not latest[0]:
            version_info = self.tr("Please get the latest release {version}") \
                .format(version=latest[1])
            version_url = latest[2]

            if self.app.preferences['notifications']:
                toast.display("sakia", """{version_info}""".format(
                version_info=version_info,
                version_url=version_url))
Exemplo n.º 18
0
    def accept(self):
        self.button_box.setEnabled(False)
        comment = self.edit_message.text()

        if self.radio_contact.isChecked():
            for contact in self.account.contacts:
                if contact["name"] == self.combo_contact.currentText():
                    recipient = contact["pubkey"]
                    break
        else:
            recipient = self.edit_pubkey.text()
        amount = self.spinbox_amount.value()

        if not amount:
            yield from QAsyncMessageBox.critical(
                self, self.tr("Money transfer"), self.tr("No amount. Please give the transfert amount"), QMessageBox.Ok
            )
            self.button_box.setEnabled(True)
            return

        password = yield from self.password_asker.async_exec()
        if self.password_asker.result() == QDialog.Rejected:
            return

        QApplication.setOverrideCursor(Qt.WaitCursor)
        QApplication.processEvents()
        result = yield from self.wallet.send_money(
            self.account.salt, password, self.community, recipient, amount, comment
        )
        if result[0]:
            if self.app.preferences["notifications"]:
                toast.display(self.tr("Transfer"), self.tr("Success sending money to {0}").format(recipient))
            else:
                yield from QAsyncMessageBox.information(
                    self, self.tr("Transfer"), self.tr("Success sending money to {0}").format(recipient)
                )
            QApplication.restoreOverrideCursor()

            # If we sent back a transaction we cancel the first one
            if self.transfer:
                self.transfer.cancel()

            super().accept()
        else:
            if self.app.preferences["notifications"]:
                toast.display(self.tr("Transfer"), "Error : {0}".format(result[1]))
            else:
                yield from QAsyncMessageBox.critical(self, self.tr("Transfer"), result[1])

            QApplication.restoreOverrideCursor()
            self.button_box.setEnabled(True)
Exemplo n.º 19
0
    def refresh_block(self, block_number):
        """
        When a new block is found, start handling data.
        @param: block_number: The number of the block mined
        """
        logging.debug("Refresh block")
        self.status_info.clear()
        try:
            person = yield from self.app.identities_registry.future_find(self.app.current_account.pubkey, self.community)
            expiration_time = yield from person.membership_expiration_time(self.community)
            parameters = yield from self.community.parameters()
            sig_validity = parameters['sigValidity']
            warning_expiration_time = int(sig_validity / 3)
            will_expire_soon = (expiration_time < warning_expiration_time)

            logging.debug("Try")
            if will_expire_soon:
                days = int(expiration_time / 3600 / 24)
                if days > 0:
                    if 'membership_expire_soon' not in self.status_info:
                        self.status_info.append('membership_expire_soon')

                    if self.app.preferences['notifications'] and\
                            self.app.notifications['membership_expire_soon'][1]+24*3600 < time.time():
                        toast.display(self.tr("Membership expiration"),
                                  self.tr("<b>Warning : Membership expiration in {0} days</b>").format(days))
                        self.app.notifications['membership_expire_soon'][1] = time.time()

            certifiers_of = yield from person.unique_valid_certifiers_of(self.app.identities_registry,
                                                                         self.community)
            if len(certifiers_of) < parameters['sigQty']:
                if 'warning_certifications' not in self.status_info:
                    self.status_info.append('warning_certifications')
                if self.app.preferences['notifications'] and\
                        self.app.notifications['warning_certifications'][1]+24*3600 < time.time():
                    toast.display(self.tr("Certifications number"),
                              self.tr("<b>Warning : You are certified by only {0} persons, need {1}</b>")
                              .format(len(certifiers_of),
                                     parameters['sigQty']))
                    self.app.notifications['warning_certifications'][1] = time.time()

        except MembershipNotFoundError as e:
            pass
        except NoPeerAvailable:
            logging.debug("No peer available")
        self.refresh_data()
Exemplo n.º 20
0
 def revoke_uid(self, checked=False):
     password = yield from self.password_asker.async_exec()
     if self.password_asker.result() == QDialog.Rejected:
         return
     result = yield from self.account.revoke(password, self.community)
     if result[0]:
         if self.app.preferences['notifications']:
             toast.display(self.tr("Revoke UID"), self.tr("Your UID was revoked successfully."))
         else:
             yield from QAsyncMessageBox.information(self, self.tr("Membership"),
                                                     self.tr("Your UID was revoked successfully."))
     else:
         if self.app.preferences['notifications']:
             toast.display(self.tr("Revoke UID"), result[1])
         else:
             yield from QAsyncMessageBox.critical(self, self.tr("UID"),
                                                     result[1])
Exemplo n.º 21
0
 def publish_uid(self, checked=False):
     password = yield from self.password_asker.async_exec()
     if self.password_asker.result() == QDialog.Rejected:
         return
     result = yield from self.account.send_selfcert(password, self.community)
     if result[0]:
         if self.app.preferences['notifications']:
             toast.display(self.tr("UID"), self.tr("Success publishing your UID"))
         else:
             yield from QAsyncMessageBox.information(self, self.tr("Membership"),
                                                     self.tr("Success publishing your UID"))
     else:
         if self.app.preferences['notifications']:
             toast.display(self.tr("UID"), result[1])
         else:
             yield from QAsyncMessageBox.critical(self, self.tr("UID"),
                                                     result[1])
Exemplo n.º 22
0
 def send_membership_demand(self, checked=False):
     password = yield from self.password_asker.async_exec()
     if self.password_asker.result() == QDialog.Rejected:
         return
     result = yield from self.account.send_membership(password, self.community, 'IN')
     if result[0]:
         if self.app.preferences['notifications']:
             toast.display(self.tr("Membership"), self.tr("Success sending Membership demand"))
         else:
             yield from QAsyncMessageBox.information(self, self.tr("Membership"),
                                                     self.tr("Success sending Membership demand"))
     else:
         if self.app.preferences['notifications']:
             toast.display(self.tr("Membership"), result[1])
         else:
             yield from QAsyncMessageBox.critical(self, self.tr("Membership"),
                                                     result[1])
Exemplo n.º 23
0
    def check_register(self, checked=False):
        server = self.config_dialog.lineedit_server.text()
        port = self.config_dialog.spinbox_port.value()
        logging.debug("Is valid ? ")
        try:
            self.node = yield from Node.from_address(None, server, port)
            community = Community.create(self.node)
            self.config_dialog.button_connect.setEnabled(False)
            self.config_dialog.button_register.setEnabled(False)
            registered = yield from self.account.check_registered(community)
            self.config_dialog.button_connect.setEnabled(True)
            self.config_dialog.button_register.setEnabled(True)
            if registered[0] is False and registered[2] is None:
                password = yield from self.password_asker.async_exec()
                if self.password_asker.result() == QDialog.Rejected:
                    return
                self.config_dialog.label_error.setText(self.tr("Broadcasting identity..."))
                result = yield from self.account.send_selfcert(password, community)
                if result[0]:
                    if self.app.preferences['notifications']:
                        toast.display(self.tr("UID broadcast"), self.tr("Identity broadcasted to the network"))
                    QApplication.restoreOverrideCursor()
                    self.config_dialog.next()
                else:
                    self.config_dialog.label_error.setText(self.tr("Error") + " " + \
                                                           self.tr("{0}".format(result[1])))
                    if self.app.preferences['notifications']:
                        toast.display(self.tr("Error"), self.tr("{0}".format(result[1])))
                QApplication.restoreOverrideCursor()
                self.config_dialog.community = community
            elif registered[0] is False and registered[2]:
                self.config_dialog.label_error.setText(self.tr("""Your pubkey or UID was already found on the network.
Yours : {0}, the network : {1}""".format(registered[1], registered[2])))
            else:
                self.config_dialog.label_error.setText(self.tr("Your account already exists on the network"))
        except aiohttp.errors.DisconnectedError as e:
            self.config_dialog.label_error.setText(str(e))
        except aiohttp.errors.ClientError as e:
            self.config_dialog.label_error.setText(str(e))
        except ValueError as e:
            self.config_dialog.label_error.setText(str(e))
Exemplo n.º 24
0
 async def publish_uid(self, connection):
     secret_key, password = await PasswordInputController.open_dialog(
         self, connection)
     if not password or not secret_key:
         return
     result = await self.model.send_identity(connection, secret_key,
                                             password)
     if result[0]:
         if self.app.preferences['notifications']:
             toast.display(self.tr("UID"),
                           self.tr("Success publishing your UID"))
         else:
             await QAsyncMessageBox.information(
                 self.view, self.tr("Membership"),
                 self.tr("Success publishing your UID"))
     else:
         if self.app.preferences['notifications']:
             toast.display(self.tr("UID"), result[1])
         else:
             await QAsyncMessageBox.critical(self.view, self.tr("UID"),
                                             result[1])
Exemplo n.º 25
0
    def send_membership_leaving(self):
        reply = yield from QAsyncMessageBox.warning(self, self.tr("Warning"),
                             self.tr("""Are you sure ?
Sending a leaving demand  cannot be canceled.
The process to join back the community later will have to be done again.""")
.format(self.account.pubkey), QMessageBox.Ok | QMessageBox.Cancel)
        if reply == QMessageBox.Ok:
            password = self.password_asker.exec_()
            if self.password_asker.result() == QDialog.Rejected:
                return
            result = yield from self.account.send_membership(password, self.community, 'OUT')
            if result[0]:
                if self.app.preferences['notifications']:
                    toast.display(self.tr("Revoke"), self.tr("Success sending Revoke demand"))
                else:
                    yield from QAsyncMessageBox.information(self, self.tr("Revoke"),
                                                            self.tr("Success sending Revoke demand"))
            else:
                if self.app.preferences['notifications']:
                    toast.display(self.tr("Revoke"), result[1])
                else:
                    yield from QAsyncMessageBox.critical(self, self.tr("Revoke"),
                                                         result[1])
Exemplo n.º 26
0
    async def send_leave(self):
        reply = await QAsyncMessageBox.warning(self, self.tr("Warning"),
                                               self.tr("""Are you sure ?
Sending a leaving demand  cannot be canceled.
The process to join back the community later will have to be done again.""")
                                               .format(self.account.pubkey), QMessageBox.Ok | QMessageBox.Cancel)
        if reply == QMessageBox.Ok:
            connection = self.model.navigation_model.navigation.current_connection()
            secret_key, password = await PasswordInputController.open_dialog(self, connection)
            if not password or not secret_key:
                return
            result = await self.model.send_leave(connection, secret_key, password)
            if result[0]:
                if self.app.preferences['notifications']:
                    toast.display(self.tr("Revoke"), self.tr("Success sending Revoke demand"))
                else:
                    await QAsyncMessageBox.information(self, self.tr("Revoke"),
                                                       self.tr("Success sending Revoke demand"))
            else:
                if self.app.preferences['notifications']:
                    toast.display(self.tr("Revoke"), result[1])
                else:
                    await QAsyncMessageBox.critical(self, self.tr("Revoke"),
                                                    result[1])
Exemplo n.º 27
0
 async def show_error(self, notification, error_txt):
     if notification:
         toast.display(self.tr("Transfer"), "Error : {0}".format(error_txt))
     else:
         await QAsyncMessageBox.critical(self, self.tr("Transfer"), error_txt)
Exemplo n.º 28
0
 async def show_error(self, notification, error_txt):
     if notification:
         toast.display(self.tr("Transfer"), "Error : {0}".format(error_txt))
     else:
         await QAsyncMessageBox.critical(self, self.tr("Transfer"),
                                         error_txt)
Exemplo n.º 29
0
 def show_error(self, notification, error_txt):
     if notification:
         toast.display(self.tr("UID broadcast"), error_txt)
     self.label_info.setText(self.tr("Error") + " " + error_txt)
Exemplo n.º 30
0
 def show_error(self, notification, error_txt):
     if notification:
         toast.display(self.tr("UID broadcast"), error_txt)
     self.label_info.setText(self.tr("Error") + " " + error_txt)
Exemplo n.º 31
0
 async def show_success(self, notification):
     if notification:
         toast.display(self.tr("UID broadcast"), self.tr("Identity broadcasted to the network"))
     else:
         await QAsyncMessageBox.information(self, self.tr("UID broadcast"),
                                            self.tr("Identity broadcasted to the network"))