Exemplo n.º 1
0
 def draw_record(self, line, row):
     date = convert_date(row["date"], row["timezone"])
     self._draw_record(
         line,
         row["gm_msgid"] == -self._indicator[1],
         date,
         convert_addrs(row["from"]),
         row["subject"],
         convert_flags(row["flags"]),
     )
Exemplo n.º 2
0
 def draw_key(self, line, key):
     gm_msgid = -key[1]
     row = self._cache.db.execute(
         """
     SELECT date, timezone, "from", subject, flags FROM gmail_messages
     WHERE gm_msgid=?
     """,
         (gm_msgid,),
     ).fetchone()
     date = convert_date(row["date"], row["timezone"])
     self._draw_record(
         line,
         gm_msgid == -self._indicator[1],
         date,
         convert_addrs(row["from"]),
         row["subject"],
         convert_flags(row["flags"]),
     )
Exemplo n.º 3
0
    def __init__(self, root_view, mailbox, uid, gm_msgid, window, color_scheme):
        self._root_view = root_view
        self._cache = root_view._cache
        self._mailbox = mailbox
        self._uid = uid
        self._gm_msgid = gm_msgid

        self._cache.db.create_function("message_view_update_bodystructure", 1, self.on_update_bodystructure)
        self._cache.db.execute(
            """
        CREATE TEMP TRIGGER message_view_update_bodystructure
        AFTER UPDATE OF bodystructure ON gmail_messages
        WHEN NEW.gm_msgid=%d
        BEGIN
            SELECT message_view_update_bodystructure(NEW.bodystructure);
        END"""
            % self._gm_msgid
        )

        self._cache.db.create_function("message_view_add_body_section", 2, self.on_add_body_section)
        self._cache.db.execute(
            """
        CREATE TEMP TRIGGER message_view_add_body_section
        AFTER INSERT ON gmail_message_bodies
        WHEN NEW.gm_msgid=%d
        BEGIN
            SELECT message_view_add_body_section(NEW.section, NEW.body);
        END"""
            % self._gm_msgid
        )

        self._widget = ScrollWidget(window, color_scheme)

        row = self._cache.db.execute(
            """
        SELECT date, timezone, subject, "from", "to", cc, bcc, bodystructure
        FROM gmail_messages
        WHERE gm_msgid=?
        """,
            (self._gm_msgid,),
        ).fetchone()
        self._date = convert_date(row["date"], row["timezone"])
        self._from = convert_addrs(row["from"])
        self._to = convert_addrs(row["to"])
        self._cc = convert_addrs(row["cc"])
        self._bcc = convert_addrs(row["bcc"])
        self._subject = row["subject"]
        self._bodystructure = convert_bodystructure(row["bodystructure"])

        cur = self._cache.db.execute(
            """
        SELECT section, body FROM gmail_message_bodies
        WHERE gm_msgid=?
        """,
            (self._gm_msgid,),
        )
        self._body_sections = {row["section"]: row["body"] for row in cur}

        self._root_view.on_open_message(self._mailbox, self._uid, self._bodystructure is None)
        if self._bodystructure:
            self._open_body_sections()
        self._redraw()