Пример #1
0
 def send(self):
     """Compile and send message from dialog data."""
     Loop.main().run(
         self._app.ioc.facade.api.mailbox.send_mail(self.__mail,
                                                    self.subject,
                                                    self.body,
                                                    reply=self.reply))
     self.dismiss()
Пример #2
0
 def save(self):
     """Compile and save message as draft from dialog data."""
     Loop.main().run(
         self._app.ioc.facade.api.mailbox.save_draft(self.__mail,
                                                     self.subject,
                                                     self.body,
                                                     reply=self.reply))
     self.dismiss()
Пример #3
0
    def __load_rv(coro,
                  content,
                  tab=None,
                  selectable=False,
                  preselected=set()):
        """Update the ScrollView with new and changed data."""
        data = content.data
        current = {e["item_id"] for e in data}
        loaded = Loop.main().run(coro, wait=True)

        # Remove from current that is not in loaded
        remove = (current - loaded)
        index = 0
        while index < len(data):
            if data[index]["item_id"] in remove:
                del data[index]
            else:
                index += 1

        # Add unique from loaded to current
        new = (loaded - current)
        for item in loaded:
            if item in new:
                model = {"item_id": item}
                if tab:
                    model["tab"] = tab
                if selectable:
                    model["selected"] = True if item in preselected else False
                data.append(model)
Пример #4
0
    def finish_init(self, dt):
        """Adapt the actions of the bottom sheet based on the entities contact status."""
        self.ids.avatar.source = os.path.join(
            os.environ["LOGO_MESSENGER_ASSETS"], "images/mask.png")
        favorite, friend, blocked = Loop.main().run(
            self._app.ioc.facade.api.contact.status(self.entity), wait=True)

        if blocked:
            self.remove_widget(self.ids.message)
            self.remove_widget(self.ids.friend)
            self.remove_widget(self.ids.unfriend)
            self.remove_widget(self.ids.favorite)
            self.remove_widget(self.ids.unfavorite)
            self.remove_widget(self.ids.block)
        else:
            self.remove_widget(self.ids.unblock)
            self.remove_widget(self.ids.delete)

            if friend:
                self.remove_widget(self.ids.friend)
            else:
                self.remove_widget(self.ids.unfriend)

            if favorite:
                self.remove_widget(self.ids.favorite)
            else:
                self.remove_widget(self.ids.unfavorite)
        self.do_layout()
Пример #5
0
    def _letter_trash(self):
        mail = Loop.main().run(self._app.ioc.facade.api.mailbox.get_trash(
            self.item_id),
                               wait=True)

        MessageDialog(MessageDialog.MODE_READER_RECEIVE,
                      mail,
                      title=strings.TEXT_MESSAGE_TRASH_TITLE).open()
Пример #6
0
    def _letter_inbox(self):
        mail = Loop.main().run(self._app.ioc.facade.api.mailbox.open_envelope(
            self.item_id),
                               wait=True)

        MessageDialog(MessageDialog.MODE_READER_RECEIVE,
                      mail,
                      title=strings.TEXT_MESSAGE_INBOX_TITLE).open()
Пример #7
0
    def _letter_drafts(self):
        mail = Loop.main().run(self._app.ioc.facade.api.mailbox.get_draft(
            self.item_id),
                               wait=True)

        MessageDialog(MessageDialog.MODE_WRITER,
                      mail,
                      title=strings.TEXT_DRAFT).open()
Пример #8
0
    def __prepare(self, x):
        app = App.get_running_app()
        vault_file = Util.path(app.user_data_dir, Const.CNL_VAULT)

        if os.path.isfile(vault_file):
            e = Loop.main().run(app.open_facade(), wait=True)
            if not isinstance(e, Exception):
                self.__goto = "home"
            else:
                self.__goto = "malfunction"
Пример #9
0
    def selection(self):
        portfolio = Loop.main().run(
            self._app.ioc.facade.storage.vault.load_portfolio(
                self.data.get("item_id"), PGroup.VERIFIER),
            wait=True)

        self._app.ioc.facade.data.client[
            "CurrentNetwork"] = portfolio.entity.id
        toast("{} {}".format(PrintPolicy.title(portfolio),
                             strings.TEXT_NETWORK_SELECTED))
Пример #10
0
    def _populate_main(self):
        portfolio = Loop.main().run(
            self._app.ioc.facade.storage.vault.load_portfolio(
                self.data.get("item_id"), PGroup.VERIFIER),
            wait=True)

        self.data.setdefault("text", PrintPolicy.title(portfolio))  # Posted

        source = os.path.join(os.environ["LOGO_MESSENGER_ASSETS"],
                              "images/dove.png")
        self.data.setdefault("source", source)
Пример #11
0
    def _populate_drafts(self):
        info = Loop.main().run(self._app.ioc.facade.api.mailbox.get_info_draft(
            self.data.get("item_id")),
                               wait=True)

        self.data.setdefault("target_id", info[1])  # Owner
        self.data.setdefault("text", info[2] if info[2] else "")  # Subject
        self.data.setdefault("secondary_text",
                             info[3] if info[3] else "")  # Receiver

        source = os.path.join(os.environ["LOGO_MESSENGER_ASSETS"],
                              "images/dove.png")
        self.data.setdefault("source", source)
Пример #12
0
    def _populate_inbox(self):
        info = Loop.main().run(self._app.ioc.facade.api.mailbox.get_info_inbox(
            self.data.get("item_id")),
                               wait=True)

        self.data.setdefault("target_id", info[1])  # Issuer
        self.data.setdefault("text", "{:%c}".format(info[3]))  # Posted
        self.data.setdefault(
            "secondary_text",
            info[2] if info[2] != "n/a" else str(info[1]))  # Sender or Issuer

        source = os.path.join(os.environ["LOGO_MESSENGER_ASSETS"],
                              "images/dove.png")
        self.data.setdefault("source", source)
Пример #13
0
    def refresh_view_attrs(self, index, data_item, view):
        """Wrapper for the view refresher that loads extra entity data ad-hoc."""
        if "text" not in data_item:
            portfolio = Loop.main().run(
                self.app.ioc.facade.storage.vault.load_portfolio(
                    data_item.get("entity"), PGroup.VERIFIER),
                wait=True)
            data_item.setdefault("text", PrintPolicy.title(portfolio))
            source = os.path.join(os.environ["LOGO_MESSENGER_ASSETS"],
                                  "images/mask.png")
            data_item.setdefault("source", source)

        view.data = data_item
        super(ContactRecycleDataAdapter,
              self).refresh_view_attrs(index, data_item, view)
Пример #14
0
    def __load_rv(coro, content):
        """Update the ScrollView with new and changed data."""
        data = content.data
        current = {e["entity"] for e in data}
        loaded = Loop.main().run(coro, wait=True)

        # Remove from current that is not in loaded
        remove = (current - loaded)
        index = 0
        while index < len(data):
            if data[index]["entity"] in remove:
                del data[index]
            else:
                index += 1

        # Add unique from loaded to current
        for eid in (loaded - current):
            data.append({"entity": eid, "selected": False})
Пример #15
0
    def _finish_init(self, dt):
        if self.__mode is self.MODE_WRITER:
            tid = self.__mail.owner
        elif self.__mode is self.MODE_READER_RECEIVE:
            tid = self.__mail.issuer
        elif self.__mode is self.MODE_READER_SEND:
            tid = self._mail.owner

        self.target = PrintPolicy.title(Loop.main().run(
            self._app.ioc.facade.storage.vault.load_portfolio(
                tid, PGroup.VERIFIER),
            wait=True))

        self.source = os.path.join(os.environ["LOGO_MESSENGER_ASSETS"],
                                   "images", "dove.png")
        self.posted = "{:%c}".format(
            self.__mail.posted) if self.__mail.posted else ""
        self.reply = self.__mail.reply
        self.subject = self.__mail.subject if self.__mail.subject else ""
        self.body = self.__mail.body if self.__mail.body else ""
Пример #16
0
 def _async(self, coro, callback=None, wait=True):
     Loop.main().run(coro, callback, wait)
Пример #17
0
 def trash(self, *largs):
     Loop.main().run(self._app.ioc.facade.api.mailbox.move_trash(
         self.__mail.id),
                     wait=True)
     self.dismiss()
Пример #18
0
 def network_index(self):
     Loop.main().run(
         TaskWaitress().wait_for(
             App.get_running_app().ioc.facade.task.network_index),
         lambda x: toast(strings.TEXT_PREFERENCES_NETWORKS_SUCCESS))
Пример #19
0
 def contact_sync(self):
     Loop.main().run(
         TaskWaitress().wait_for(
             App.get_running_app().ioc.facade.task.contact_sync),
         lambda x: toast(strings.TEXT_PREFERENCES_SYNCHRO_SUCCESS))