103 lines
4.2 KiB
C++
103 lines
4.2 KiB
C++
/**
|
|
This file is a part of rexy's matrix client
|
|
Copyright (C) 2019-2020 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_ROOMCXN_HPP
|
|
#define MATRIX_ROOMCXN_HPP
|
|
|
|
#include "matrix/connection.hpp"
|
|
#include "matrix/upload_info.hpp"
|
|
#include <rexy/string.hpp>
|
|
#include "raii/rjp_string.hpp"
|
|
#include "matrix/rest/room_url_list.hpp"
|
|
#include "matrix/iterable.hpp"
|
|
#include "matrix/netreturn.hpp"
|
|
|
|
#include <vector>
|
|
|
|
namespace matrix{
|
|
|
|
class roomcxn : public connection
|
|
{
|
|
private:
|
|
rexy::string m_roomid;
|
|
room_url_list m_urls;
|
|
|
|
public:
|
|
roomcxn(const std::shared_ptr<session_info>&, const rexy::string_base& roomid);
|
|
roomcxn(const std::shared_ptr<session_info>& ses, rexy::string&& roomid);
|
|
|
|
roomcxn(const roomcxn&) = default;
|
|
roomcxn(roomcxn&&) = default;
|
|
~roomcxn(void) = default;
|
|
|
|
roomcxn& operator=(const roomcxn&) = default;
|
|
roomcxn& operator=(roomcxn&&) = default;
|
|
|
|
//membership
|
|
netreturn<void> join(void)const;
|
|
netreturn<void> leave(void)const;
|
|
netreturn<void> forget(void)const;
|
|
[[deprecated("Use roomcxn::join_room instead")]]
|
|
netreturn<void> accept_invite(void)const;
|
|
[[deprecated("Use roomcxn::leave_room instead")]]
|
|
netreturn<void> reject_invite(void)const;
|
|
netreturn<std::vector<raii::rjp_string>> members(void)const;
|
|
|
|
//member management
|
|
netreturn<void> invite(const rexy::string_base& userid);
|
|
[[deprecated("Use roomcxn::kick instead")]]
|
|
netreturn<void> uninvite(const rexy::string_base& userid, const rexy::string_base& reason = rexy::string());
|
|
netreturn<void> kick(const rexy::string_base& userid, const rexy::string_base& reason = rexy::string());
|
|
netreturn<void> ban(const rexy::string_base& userid, const rexy::string_base& reason = rexy::string());
|
|
netreturn<void> unban(const rexy::string_base& userid);
|
|
|
|
//sending events
|
|
netreturn<raii::rjp_string> send_custom_event(const rexy::string_base& event, const rexy::string_base& eventtype)const;
|
|
netreturn<raii::rjp_string> send_message(const rexy::string_base& text)const;
|
|
netreturn<raii::rjp_string> send_notice(const rexy::string_base& text)const;
|
|
netreturn<raii::rjp_string> send_file(const uploaded_file& file)const;
|
|
netreturn<raii::rjp_string> send_image(const uploaded_image& image)const;
|
|
netreturn<raii::rjp_string> send_video(const uploaded_video& video)const;
|
|
netreturn<raii::rjp_string> send_audio(const uploaded_audio& audio)const;
|
|
netreturn<raii::rjp_string> forward_event(const sync::room_event&)const;
|
|
netreturn<void> send_typing(bool active, int timeout = 5000)const;
|
|
netreturn<void> send_read_receipt(const rexy::string_base& eventid)const;
|
|
|
|
netreturn<sync::roomcxn_message_event_list> get_event(const rexy::string_base& eventid)const;
|
|
netreturn<raii::rjp_string> redact_event(const rexy::string_base& eventid, const rexy::string_base& reason)const;
|
|
netreturn<raii::rjp_string> redact_event(const rexy::string_base& eventid)const;
|
|
|
|
//recieve events
|
|
netreturn<sync::roomcxn_message_event_list> get_events_forward(int amount);
|
|
netreturn<sync::roomcxn_message_event_list> get_events_backward(int amount);
|
|
netreturn<sync::roomcxn_message_event_list> get_events_forward(int amount, const rexy::string_base& from, const rexy::string_base& to);
|
|
netreturn<sync::roomcxn_message_event_list> get_events_backward(int amount, const rexy::string_base& from, const rexy::string_base& to);
|
|
|
|
//meta stuff
|
|
void regenerate_urls(void);
|
|
netreturn<raii::rjp_string> upgrade(int version)const;
|
|
|
|
private:
|
|
netreturn<sync::roomcxn_message_event_list> _get_events(int amount, rexy::static_string direction, const rexy::string_base& from, const rexy::string_base& to);
|
|
netreturn<raii::rjp_string> _send_message(const rexy::string_base& msg)const;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|