summaryrefslogtreecommitdiff
path: root/Userland/Applications/Mail/MailWidget.h
blob: fe135f6035c65d878468909b90d8513ec5ca2385 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
 * Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include "AccountHolder.h"
#include "InboxModel.h"
#include <AK/NonnullOwnPtrVector.h>
#include <LibGUI/Widget.h>
#include <LibGfx/ShareableBitmap.h>
#include <LibIMAP/Client.h>
#include <LibWeb/OutOfProcessWebView.h>

class MailWidget final : public GUI::Widget {
    C_OBJECT(MailWidget)
public:
    virtual ~MailWidget() override;

    bool connect_and_login();

    void on_window_close();

private:
    MailWidget();

    void selected_mailbox();
    void selected_email_to_load();

    struct Alternative {
        IMAP::BodyStructureData const& body_structure;
        Vector<u32> position;
    };

    IMAP::MultiPartBodyStructureData const* look_for_alternative_body_structure(IMAP::MultiPartBodyStructureData const& current_body_structure, Vector<u32>& position_stack) const;
    Vector<Alternative> get_alternatives(IMAP::MultiPartBodyStructureData const&) const;
    bool is_supported_alternative(Alternative const&) const;

    OwnPtr<IMAP::Client> m_imap_client;

    RefPtr<GUI::TreeView> m_mailbox_list;
    RefPtr<GUI::TableView> m_individual_mailbox_view;
    RefPtr<Web::OutOfProcessWebView> m_web_view;
    RefPtr<GUI::Statusbar> m_statusbar;

    RefPtr<GUI::Menu> m_link_context_menu;
    RefPtr<GUI::Action> m_link_context_menu_default_action;
    URL m_link_context_menu_url;

    RefPtr<GUI::Menu> m_image_context_menu;
    Gfx::ShareableBitmap m_image_context_menu_bitmap;
    URL m_image_context_menu_url;

    OwnPtr<AccountHolder> m_account_holder;
};