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);
};