mastodonpp
0.5.5
|
Holds the access data of an instance. More...
#include <mastodonpp/instance.hpp>
Classes | |
class | ObtainToken |
Simplifies obtaining an OAuth 2.0 Bearer Access Token. More... | |
Public Member Functions | |
Instance (string_view hostname, string_view access_token) | |
Construct a new Instance object. More... | |
Instance (const Instance &other) | |
Copy constructor. A new CURLWrapper is constructed. More... | |
Instance (Instance &&other) noexcept=delete | |
Move constructor. More... | |
~Instance () noexcept override=default | |
Destructor. More... | |
Instance & | operator= (const Instance &other)=delete |
Copy assignment operator. More... | |
Instance & | operator= (Instance &&other) noexcept=delete |
Move assignment operator. More... | |
void | copy_connection_properties (CURLWrapper &curlwrapper) const |
Set the properties of the connection of the calling class up. More... | |
string_view | get_hostname () const noexcept |
Returns the hostname. More... | |
string_view | get_baseuri () const noexcept |
Returns the base URI. More... | |
string_view | get_access_token () const noexcept |
Returns the access token. More... | |
void | set_access_token (const string_view access_token) |
Set OAuth 2.0 Bearer Access Token. More... | |
uint64_t | get_max_chars () noexcept |
Returns the maximum number of characters per post. More... | |
void | set_proxy (const string_view proxy) override |
Set the proxy to use. More... | |
answer_type | get_nodeinfo () |
Returns the NodeInfo of the instance. More... | |
vector< string > | get_post_formats () noexcept |
Returns the allowed mime types for statuses. More... | |
void | set_cainfo (string_view path) override |
Set path to Certificate Authority (CA) bundle. More... | |
void | set_useragent (const string_view useragent) override |
Sets the User-Agent. More... | |
Public Member Functions inherited from mastodonpp::CURLWrapper | |
CURLWrapper () | |
Initializes curl and sets up connection. More... | |
CURLWrapper (const CURLWrapper &) | |
Copy constructor. Does the same as the Constructor. More... | |
CURLWrapper (CURLWrapper &&other) noexcept=delete | |
Move constructor. More... | |
virtual | ~CURLWrapper () noexcept |
Cleans up curl and connection. More... | |
CURLWrapper & | operator= (const CURLWrapper &other)=delete |
Copy assignment operator. More... | |
CURLWrapper & | operator= (CURLWrapper &&other) noexcept=delete |
Move assignment operator. More... | |
CURL * | get_curl_easy_handle () |
Returns pointer to the CURL easy handle. More... | |
string | escape_url (const string_view url) const |
URL encodes the given string. More... | |
string | unescape_url (const string_view url) const |
URL decodes the given string. More... | |
void | setup_connection_properties (string_view proxy, string_view access_token, string_view cainfo, string_view useragent) |
Set some properties of the connection. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from mastodonpp::CURLWrapper | |
answer_type | make_request (const http_method &method, string uri, const parametermap ¶meters) |
Make a HTTP request. More... | |
string & | get_buffer () |
Returns a reference to the buffer libcurl writes into. More... | |
void | cancel_stream () |
Cancel the stream. More... | |
void | set_access_token (string_view access_token) |
Set OAuth 2.0 Bearer Access Token. More... | |
Protected Attributes inherited from mastodonpp::CURLWrapper | |
mutex | _buffer_mutex |
Mutex for get_buffer a.k.a. _curl_buffer_body. More... | |
Holds the access data of an instance.
Instances are needed to initialize Connections. All properties you set here (with set_proxy(), set_useragent() and so on) are copied to every Connection you initialize afterwards.
|
explicit |
Construct a new Instance object.
hostname | The hostname of the instance. |
access_token | Your access token. |
mastodonpp::Instance::Instance | ( | const Instance & | other | ) |
Copy constructor. A new CURLWrapper is constructed.
|
deletenoexcept |
Move constructor.
|
overridedefaultnoexcept |
Destructor.
|
inline |
Set the properties of the connection of the calling class up.
Meant for internal use. This aligns the properties of the connection of the calling class with the properties of connection of this class.
curlwrapper | The CURLWrapper parent of the calling class. |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
noexcept |
Returns the maximum number of characters per post.
Queries /api/v1/instance
for ‘max_toot_chars’. If the instance doesn't support it, the limit is assumed to be 500.
After the first call, the value is saved internally. Subsequent calls return the saved value.
answer_type mastodonpp::Instance::get_nodeinfo | ( | ) |
Returns the NodeInfo of the instance.
Attempts to download the NodeInfo of the instance and returns it. Not every instance has it.
|
noexcept |
Returns the allowed mime types for statuses.
Extracts metadata.postFormats
from NodeInfo. If none can be found, returns {"text/plain"}
.
After the first call, the value is saved internally. Subsequent calls return the saved value.
Copy assignment operator.
Move assignment operator.
|
inline |
Set OAuth 2.0 Bearer Access Token.
Sets also the access token for all Connections that are initialized with this Instance afterwards.
|
inlineoverridevirtual |
Set path to Certificate Authority (CA) bundle.
Sets also the CA info for all Connections that are initialized with this Instance afterwards.
Reimplemented from mastodonpp::CURLWrapper.
|
inlineoverridevirtual |
Set the proxy to use.
See CURLOPT_PROXY(3).
proxy | Examples: "socks4a://127.0.0.1:9050", "http://[::1]:3128". |
Sets also the proxy for all Connections that are initialized with this Instance afterwards.
Reimplemented from mastodonpp::CURLWrapper.
|
inlineoverridevirtual |
Sets the User-Agent.
Sets also the User-Agent for all Connections that are initialized with this Instance afterwards.
Reimplemented from mastodonpp::CURLWrapper.