56 lines
2.1 KiB
C++
56 lines
2.1 KiB
C++
/**
|
|
This file is a part of r0nk, atlas_moon, and rexy's matrix client
|
|
Copyright (C) 2019 rexy712
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef MATRIX_CLIENT_BASE_HPP
|
|
#define MATRIX_CLIENT_BASE_HPP
|
|
|
|
#include "raii/curler.hpp"
|
|
#include "raii/string.hpp"
|
|
#include "raii/rjp_string.hpp"
|
|
|
|
namespace matrix::internal{
|
|
|
|
class client_base
|
|
{
|
|
protected:
|
|
mutable raii::curler m_curl;
|
|
protected:
|
|
client_base(void);
|
|
client_base(const client_base&) = default;
|
|
client_base(client_base&&) = default;
|
|
~client_base(void) = default;
|
|
client_base& operator=(const client_base&) = default;
|
|
client_base& operator=(client_base&&) = default;
|
|
|
|
void _set_curl_useragent(const raii::string_base& useragent);
|
|
|
|
protected:
|
|
static size_t _post_reply_curl_callback(char* ptr, size_t size, size_t nmemb, void* userdata);
|
|
raii::string _get_curl(const raii::string_base& url)const;
|
|
raii::string _post_curl(const raii::string_base& postdata, const raii::string_base& url, const raii::curl_llist& header)const;
|
|
raii::string _put_curl(const raii::string_base& postdata, const raii::string_base& url, const raii::curl_llist& header)const;
|
|
raii::rjp_string _post_and_find(const raii::string_base& data, const raii::string_base& url, const raii::curl_llist& header, const raii::string_base& target)const;
|
|
raii::rjp_string _get_and_find(const raii::string_base& url, const raii::string_base& search)const;
|
|
raii::rjp_string _curl_reply_search(const raii::string_base& reply, const raii::string_base& search)const;
|
|
void _set_curl_defaults(const raii::string_base& useragent)const;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|