Merge branch 'develop' into main
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
commit
e6c2db91fd
@ -19,8 +19,8 @@
|
|||||||
link:{uri-mastodon-cpp}[mastodon-cpp].
|
link:{uri-mastodon-cpp}[mastodon-cpp].
|
||||||
|
|
||||||
We aim to create a library that is comfortable, yet minimal. All API endpoints
|
We aim to create a library that is comfortable, yet minimal. All API endpoints
|
||||||
from Mastodon and Pleroma are stored in ``enum class``es, to counteract typos and
|
from Mastodon and Pleroma are stored in ``enum class``es, to counteract typos
|
||||||
make your life easier. The network-facing code is built on
|
and make your life easier. The network-facing code is built on
|
||||||
link:{uri-libcurl}[libcurl], a mature and stable library that is available on
|
link:{uri-libcurl}[libcurl], a mature and stable library that is available on
|
||||||
virtually every operating system. The library does not parse the responses
|
virtually every operating system. The library does not parse the responses
|
||||||
itself, but returns to you the raw data, because we know everyone has their
|
itself, but returns to you the raw data, because we know everyone has their
|
||||||
|
@ -23,7 +23,6 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"
|
|||||||
"-Wformat=2"
|
"-Wformat=2"
|
||||||
"-ftrapv"
|
"-ftrapv"
|
||||||
"-fsanitize=undefined"
|
"-fsanitize=undefined"
|
||||||
"-g"
|
|
||||||
"-Og"
|
"-Og"
|
||||||
"-fno-omit-frame-pointer")
|
"-fno-omit-frame-pointer")
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||||
|
@ -68,6 +68,9 @@ struct event_type
|
|||||||
/*!
|
/*!
|
||||||
* @brief Represents a connection to an instance. Used for requests.
|
* @brief Represents a connection to an instance. Used for requests.
|
||||||
*
|
*
|
||||||
|
* Do not make 2 requests with the same Connection at the same time. You can
|
||||||
|
* create as many Connection%s as you want from one Instance.
|
||||||
|
*
|
||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
*
|
*
|
||||||
* @headerfile connection.hpp mastodonpp/connection.hpp
|
* @headerfile connection.hpp mastodonpp/connection.hpp
|
||||||
|
@ -79,7 +79,7 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
* @brief Cleans up curl and connection.
|
* @brief Cleans up curl and connection.
|
||||||
*
|
*
|
||||||
* Calls `curl_global_cleanup`, which is not thread-safe. For more
|
* May call `curl_global_cleanup`, which is not thread-safe. For more
|
||||||
* information consult [curl_global_cleanup(3)]
|
* information consult [curl_global_cleanup(3)]
|
||||||
* (https://curl.haxx.se/libcurl/c/curl_global_cleanup.html).
|
* (https://curl.haxx.se/libcurl/c/curl_global_cleanup.html).
|
||||||
*
|
*
|
||||||
@ -124,7 +124,7 @@ public:
|
|||||||
{
|
{
|
||||||
char *cbuf{curl_easy_escape(_connection, url.data(),
|
char *cbuf{curl_easy_escape(_connection, url.data(),
|
||||||
static_cast<int>(url.size()))};
|
static_cast<int>(url.size()))};
|
||||||
string sbuf{cbuf};
|
const string sbuf{cbuf};
|
||||||
curl_free(cbuf);
|
curl_free(cbuf);
|
||||||
return sbuf;
|
return sbuf;
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ public:
|
|||||||
{
|
{
|
||||||
char *cbuf{curl_easy_unescape(_connection, url.data(),
|
char *cbuf{curl_easy_unescape(_connection, url.data(),
|
||||||
static_cast<int>(url.size()), nullptr)};
|
static_cast<int>(url.size()), nullptr)};
|
||||||
string sbuf{cbuf};
|
const string sbuf{cbuf};
|
||||||
curl_free(cbuf);
|
curl_free(cbuf);
|
||||||
return sbuf;
|
return sbuf;
|
||||||
}
|
}
|
||||||
@ -193,7 +193,7 @@ protected:
|
|||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
*/
|
*/
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
string &get_buffer()
|
inline string &get_buffer()
|
||||||
{
|
{
|
||||||
return _curl_buffer_body;
|
return _curl_buffer_body;
|
||||||
}
|
}
|
||||||
@ -222,7 +222,7 @@ protected:
|
|||||||
*
|
*
|
||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
*/
|
*/
|
||||||
void set_proxy(string_view proxy);
|
virtual void set_proxy(string_view proxy);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Set OAuth 2.0 Bearer Access Token.
|
* @brief Set OAuth 2.0 Bearer Access Token.
|
||||||
@ -237,14 +237,14 @@ protected:
|
|||||||
*
|
*
|
||||||
* @since 0.3.0
|
* @since 0.3.0
|
||||||
*/
|
*/
|
||||||
void set_cainfo(string_view path);
|
virtual void set_cainfo(string_view path);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Sets the User-Agent.
|
* @brief Sets the User-Agent.
|
||||||
*
|
*
|
||||||
* @since 0.3.0
|
* @since 0.3.0
|
||||||
*/
|
*/
|
||||||
void set_useragent(string_view useragent);
|
virtual void set_useragent(string_view useragent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CURL *_connection;
|
CURL *_connection;
|
||||||
|
@ -38,6 +38,10 @@ using std::vector;
|
|||||||
/*!
|
/*!
|
||||||
* @brief Holds the access data of an instance.
|
* @brief Holds the access data of an instance.
|
||||||
*
|
*
|
||||||
|
* Instance%s are needed to initialize Connection%s. All properties you set
|
||||||
|
* here (with set_proxy(), set_useragent() and so on) are copied to every
|
||||||
|
* Connection you initialize afterwards.
|
||||||
|
*
|
||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
*
|
*
|
||||||
* @headerfile instance.hpp mastodonpp/instance.hpp
|
* @headerfile instance.hpp mastodonpp/instance.hpp
|
||||||
@ -144,7 +148,7 @@ public:
|
|||||||
* Sets also the proxy for all Connection%s that are initialized with this
|
* Sets also the proxy for all Connection%s that are initialized with this
|
||||||
* Instance afterwards.
|
* Instance afterwards.
|
||||||
*/
|
*/
|
||||||
void set_proxy(const string_view proxy)
|
void set_proxy(const string_view proxy) override
|
||||||
{
|
{
|
||||||
_proxy = proxy;
|
_proxy = proxy;
|
||||||
CURLWrapper::set_proxy(proxy);
|
CURLWrapper::set_proxy(proxy);
|
||||||
@ -183,7 +187,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @since 0.3.0
|
* @since 0.3.0
|
||||||
*/
|
*/
|
||||||
void set_cainfo(string_view path)
|
void set_cainfo(string_view path) override
|
||||||
{
|
{
|
||||||
_cainfo = path;
|
_cainfo = path;
|
||||||
CURLWrapper::set_cainfo(path);
|
CURLWrapper::set_cainfo(path);
|
||||||
@ -197,7 +201,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @since 0.3.0
|
* @since 0.3.0
|
||||||
*/
|
*/
|
||||||
void set_useragent(const string_view useragent)
|
void set_useragent(const string_view useragent) override
|
||||||
{
|
{
|
||||||
_useragent = useragent;
|
_useragent = useragent;
|
||||||
CURLWrapper::set_useragent(useragent);
|
CURLWrapper::set_useragent(useragent);
|
||||||
@ -206,7 +210,7 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
* @brief Simplifies obtaining an OAuth 2.0 Bearer Access Token.
|
* @brief Simplifies obtaining an OAuth 2.0 Bearer Access Token.
|
||||||
*
|
*
|
||||||
* * Create an Instance() and initialize this class with it.
|
* * Create an Instance and initialize this class with it.
|
||||||
* * Call step_1() to get the URI your user has to visit.
|
* * Call step_1() to get the URI your user has to visit.
|
||||||
* * Get the authorization code from your user.
|
* * Get the authorization code from your user.
|
||||||
* * Call step_2() with the code.
|
* * Call step_2() with the code.
|
||||||
@ -230,6 +234,8 @@ public:
|
|||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @since 0.3.0
|
* @since 0.3.0
|
||||||
|
*
|
||||||
|
* @headerfile instance.hpp mastodonpp/instance.hpp
|
||||||
*/
|
*/
|
||||||
class ObtainToken : public CURLWrapper
|
class ObtainToken : public CURLWrapper
|
||||||
{
|
{
|
||||||
@ -272,7 +278,8 @@ public:
|
|||||||
* The `body` of the returned @link answer_type answer @endlink
|
* The `body` of the returned @link answer_type answer @endlink
|
||||||
* contains only the access token, not the whole JSON response.
|
* contains only the access token, not the whole JSON response.
|
||||||
*
|
*
|
||||||
* The access token will be set in the parent Instance.
|
* The access token will be set in the Instance you initialized
|
||||||
|
* this ObtainToken with.
|
||||||
*
|
*
|
||||||
* @param code The authorization code you got from the user.
|
* @param code The authorization code you got from the user.
|
||||||
*
|
*
|
||||||
|
@ -70,7 +70,7 @@ string Connection::get_new_stream_contents()
|
|||||||
{
|
{
|
||||||
buffer_mutex.lock();
|
buffer_mutex.lock();
|
||||||
auto &buffer{get_buffer()};
|
auto &buffer{get_buffer()};
|
||||||
auto buffer_copy{buffer};
|
const string buffer_copy{buffer};
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
buffer_mutex.unlock();
|
buffer_mutex.unlock();
|
||||||
return buffer_copy;
|
return buffer_copy;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user