solanaceae_ipc1/solanaceae/ipc1/tox_ipc_client.hpp
2023-04-08 23:24:58 +02:00

98 lines
4.8 KiB
C++

#pragma once
#include <solanaceae/core/tox_interface.hpp>
#include <solanaceae/core/tox_event_provider_base.hpp>
#include <ipc.h>
class ToxIPCClient : public ToxI, public ToxEventProviderBase {
ipc_sharedmemory _mem_rpc;
ipc_sharedsemaphore _sem_rpc_c;
ipc_sharedsemaphore _sem_rpc_s;
ipc_sharedmemory _mem_events;
ipc_sharedsemaphore _sem_events_lock;
public:
ToxIPCClient(void);
~ToxIPCClient(void);
bool connect(void);
// pulls events and handles them
void iterate(void);
public: // ToxI
Tox_Connection toxSelfGetConnectionStatus(void) override;
uint32_t toxIterationInterval(void) override;
std::vector<uint8_t> toxSelfGetAddress(void) override;
void toxSelfSetNospam(uint32_t nospam) override;
uint32_t toxSelfGetNospam(void) override;
std::vector<uint8_t> toxSelfGetPublicKey(void) override;
Tox_Err_Set_Info toxSelfSetName(std::string_view name) override;
std::string toxSelfGetName(void) override;
Tox_Err_Set_Info toxSelfSetStatusMessage(std::string_view status_message) override;
std::string toxSelfGetStatusMessage(void) override;
void toxSelfSetStatus(Tox_User_Status status) override;
Tox_User_Status toxSelfGetStatus(void) override;
std::tuple<std::optional<uint32_t>, Tox_Err_Friend_Add> toxFriendAdd(const std::vector<uint8_t>& address, std::string_view message) override;
std::tuple<std::optional<uint32_t>, Tox_Err_Friend_Add> toxFriendAddNorequest(const std::vector<uint8_t>& public_key) override;
Tox_Err_Friend_Delete toxFriendDelete(uint32_t friend_number) override;
std::tuple<std::optional<std::vector<uint8_t>>, Tox_Err_Friend_Get_Public_Key> toxFriendGetPublicKey(uint32_t friend_number) override;
std::tuple<std::optional<uint32_t>, Tox_Err_Friend_Send_Message> toxFriendSendMessage(uint32_t friend_number, Tox_Message_Type type, std::string_view message) override;
// should this be virtual at all?
// TODO: array? make it type agnostic?
std::vector<uint8_t> toxHash(const std::vector<uint8_t>& data) override;
// files
// conferece
std::tuple<std::optional<uint32_t>, Tox_Err_Conference_Join> toxConferenceJoin(uint32_t friend_number, const std::vector<uint8_t>& cookie) override;
Tox_Err_Conference_Send_Message toxConferenceSendMessage(uint32_t conference_number, Tox_Message_Type type, std::string_view message) override;
Tox_Err_Friend_Custom_Packet toxFriendSendLossyPacket(uint32_t friend_number, const std::vector<uint8_t>& data) override;
Tox_Err_Friend_Custom_Packet toxFriendSendLosslessPacket(uint32_t friend_number, const std::vector<uint8_t>& data) override;
// dht
// udp
// tcp
// group
std::tuple<std::optional<uint32_t>, Tox_Err_Group_New> toxGroupNew(Tox_Group_Privacy_State privacy_state, std::string_view group_name, std::string_view name) override;
std::tuple<std::optional<uint32_t>, Tox_Err_Group_Join> toxGroupJoin(const std::vector<uint8_t>& chat_id, std::string_view name, std::string_view password) override;
std::optional<bool> toxGroupIsConnected(uint32_t group_number) override;
Tox_Err_Group_Reconnect toxGroupReconnect(uint32_t group_number) override;
Tox_Err_Group_Leave toxGroupLeave(uint32_t group_number, std::string_view part_message) override;
std::optional<std::string> toxGroupSelfGetName(uint32_t group_number) override;
std::tuple<std::optional<std::string>, Tox_Err_Group_Peer_Query> toxGroupPeerGetName(uint32_t group_number, uint32_t peer_id) override;
std::tuple<std::optional<Tox_Connection>, Tox_Err_Group_Peer_Query> toxGroupPeerGetConnectionStatus(uint32_t group_number, uint32_t peer_id) override;
Tox_Err_Group_Topic_Set toxGroupSetTopic(uint32_t group_number, std::string_view topic) override;
std::optional<std::string> toxGroupGetTopic(uint32_t group_number) override;
std::optional<std::string> toxGroupGetName(uint32_t group_number) override;
std::optional<std::vector<uint8_t>> toxGroupGetChatId(uint32_t group_number) override;
// TODO: str
std::tuple<std::optional<uint32_t>, Tox_Err_Group_Send_Message> toxGroupSendMessage(uint32_t group_number, Tox_Message_Type type, std::string_view message) override;
Tox_Err_Group_Send_Private_Message toxGroupSendPrivateMessage(uint32_t group_number, uint32_t peer_id, Tox_Message_Type type, std::string_view message) override;
Tox_Err_Group_Send_Custom_Packet toxGroupSendCustomPacket(uint32_t group_number, bool lossless, const std::vector<uint8_t>& data) override;
Tox_Err_Group_Send_Custom_Private_Packet toxGroupSendCustomPrivatePacket(uint32_t group_number, uint32_t peer_id, bool lossless, const std::vector<uint8_t>& data) override;
Tox_Err_Group_Invite_Friend toxGroupInviteFriend(uint32_t group_number, uint32_t friend_number) override;
std::tuple<std::optional<uint32_t>, Tox_Err_Group_Invite_Accept> toxGroupInviteAccept(uint32_t friend_number, const std::vector<uint8_t>& invite_data, std::string_view name, std::string_view password) override;
};