aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/instance.h
blob: 79c0b12810b90b2517f1c1e205d0e5f76ffb7e3b (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
#pragma once
#include "src/activitypub/appost.h"
#include "src/settings_interface.h"
#include <QMetaType>
#include <memory>

class Instance;
typedef std::shared_ptr<Instance> InstancePtr;

class Instance {
public:
    struct OAuth2Step2 {
        bool ok;
        QString token;
    };

    virtual ~Instance() {};
    virtual APPostPtr get_post_from_url(const QString &url) = 0;
    // Returns the URI the user has to visit in their browser
    virtual QString oauth2_step1();
    // auth_code is the code given by the user through the URI
    // Returns true if authenfication was successful.
    virtual OAuth2Step2 oauth2_step2(const QString &auth_code);
    bool supports_oauth2 = false;
    // Creates an instance by reading the type from settings
    static InstancePtr create_instance();
    // Creates a specific type of instance, for use with SettingsDialog
    static InstancePtr create_instance(AppSettingsTypes::InstanceType type);
};
n class="w"> private_icon; case StatusType::DIRECT: static QIcon direct_icon(ICON_PATH_PREFIX"/letter.png"); return direct_icon; case StatusType::REBLOG: static QIcon reblog_icon(ICON_PATH_PREFIX"/repeat.png"); return reblog_icon; case StatusType::UNKNOWN: static QIcon unknown_icon(ICON_PATH_PREFIX"/question.png"); return unknown_icon; } } #undef ICON_PATH_PREFIX StatusListItem::StatusListItem(const QString &text, StatusType status_type, bool has_attachement, Archive* data_archive, QListWidget *parent, int index) : status_index(index), has_attachement(has_attachement), status_type(status_type), data_archive(data_archive) { setText(text); setIcon(choose_icon(status_type)); parent->addItem(this); QString tool_tip; switch (status_type) { case PUBLIC: tool_tip = QObject::tr("Public"); break; case UNLISTED: tool_tip = QObject::tr("Unlisted"); break; case PRIVATE: tool_tip = QObject::tr("Private"); break; case DIRECT: tool_tip = QObject::tr("Direct"); break; case UNKNOWN: tool_tip = QObject::tr("Unknown"); break; case REBLOG: tool_tip = QObject::tr("Reblog"); break; } setToolTip(tool_tip); } int StatusListItem::get_status_index() { return status_index; } StatusType StatusListItem::get_status_type() { return status_type; } APActivity* StatusListItem::get_activity() { return data_archive->get_activity(status_index, {status_type}); } const QString StatusListItem::get_info_html(int text_zone_width, QLocale* locale) { APActivity* activity = data_archive->get_activity(status_index, {status_type}); QString html = activity->get_html_render({text_zone_width, locale}); delete activity; activity = nullptr; return html; }