pull in the toxcore enums, so the interface does not directly depend on toxcore

This commit is contained in:
Green Sky 2023-11-12 19:35:55 +01:00
parent f8851c1033
commit 9cfd920fca
No known key found for this signature in database
5 changed files with 312 additions and 1 deletions

View File

@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
project(solanaceae) project(solanaceae)
add_library(solanaceae_toxcore_interface INTERFACE add_library(solanaceae_toxcore_interface INTERFACE
#./solanaceae/toxcore/toxcore_enums.hpp
#./solanaceae/toxcore/tox_interface.hpp #./solanaceae/toxcore/tox_interface.hpp
) )
target_include_directories(solanaceae_toxcore_interface INTERFACE .) target_include_directories(solanaceae_toxcore_interface INTERFACE .)
@ -15,6 +16,7 @@ add_library(solanaceae_toxcore
./solanaceae/toxcore/tox_key.hpp ./solanaceae/toxcore/tox_key.hpp
./solanaceae/toxcore/tox_key.cpp ./solanaceae/toxcore/tox_key.cpp
./solanaceae/toxcore/toxcore_enums.hpp
./solanaceae/toxcore/tox_interface.hpp ./solanaceae/toxcore/tox_interface.hpp
./solanaceae/toxcore/tox_interface.cpp ./solanaceae/toxcore/tox_interface.cpp
./solanaceae/toxcore/tox_event_interface.hpp ./solanaceae/toxcore/tox_event_interface.hpp

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <tox/tox.h>
#include "./tox_interface.hpp" #include "./tox_interface.hpp"
struct ToxDefaultImpl : public ToxI { struct ToxDefaultImpl : public ToxI {

View File

@ -1,3 +1,4 @@
#include <tox/tox.h> // before interface
#include "./tox_interface.hpp" #include "./tox_interface.hpp"
#include "./utils.hpp" #include "./utils.hpp"

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <tox/tox.h> //#include <tox/tox.h>
#include "./toxcore_enums.hpp"
#include <string_view> #include <string_view>
#include <vector> #include <vector>

View File

@ -0,0 +1,306 @@
#pragma once
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team.
* Copyright © 2013 Tox project.
*/
// this file contains extracts from c-toxcore tox.h to use in tox_interface.hpp interface
// this is temporary until proper replacements have been put in place
// only define if primary h not included first
#ifndef C_TOXCORE_TOXCORE_TOX_H
// TODO: replace all types
// TODO: replace all errors with custom
enum Tox_Connection {
TOX_CONNECTION_NONE,
TOX_CONNECTION_TCP,
TOX_CONNECTION_UDP,
};
enum Tox_Err_Set_Info {
TOX_ERR_SET_INFO_OK,
TOX_ERR_SET_INFO_NULL,
TOX_ERR_SET_INFO_TOO_LONG,
};
enum Tox_User_Status {
TOX_USER_STATUS_NONE,
TOX_USER_STATUS_AWAY,
TOX_USER_STATUS_BUSY,
};
enum Tox_Err_Friend_Add {
TOX_ERR_FRIEND_ADD_OK,
TOX_ERR_FRIEND_ADD_NULL,
TOX_ERR_FRIEND_ADD_TOO_LONG,
TOX_ERR_FRIEND_ADD_NO_MESSAGE,
TOX_ERR_FRIEND_ADD_OWN_KEY,
TOX_ERR_FRIEND_ADD_ALREADY_SENT,
TOX_ERR_FRIEND_ADD_BAD_CHECKSUM,
TOX_ERR_FRIEND_ADD_SET_NEW_NOSPAM,
TOX_ERR_FRIEND_ADD_MALLOC,
};
enum Tox_Err_Friend_Delete {
TOX_ERR_FRIEND_DELETE_OK,
TOX_ERR_FRIEND_DELETE_FRIEND_NOT_FOUND,
};
enum Tox_Err_Friend_By_Public_Key {
TOX_ERR_FRIEND_BY_PUBLIC_KEY_OK,
TOX_ERR_FRIEND_BY_PUBLIC_KEY_NULL,
TOX_ERR_FRIEND_BY_PUBLIC_KEY_NOT_FOUND,
};
enum Tox_Err_Set_Typing {
TOX_ERR_SET_TYPING_OK,
TOX_ERR_SET_TYPING_FRIEND_NOT_FOUND,
};
enum Tox_Err_Friend_Send_Message {
TOX_ERR_FRIEND_SEND_MESSAGE_OK,
TOX_ERR_FRIEND_SEND_MESSAGE_NULL,
TOX_ERR_FRIEND_SEND_MESSAGE_FRIEND_NOT_FOUND,
TOX_ERR_FRIEND_SEND_MESSAGE_FRIEND_NOT_CONNECTED,
TOX_ERR_FRIEND_SEND_MESSAGE_SENDQ,
TOX_ERR_FRIEND_SEND_MESSAGE_TOO_LONG,
TOX_ERR_FRIEND_SEND_MESSAGE_EMPTY,
};
enum Tox_Message_Type {
TOX_MESSAGE_TYPE_NORMAL,
TOX_MESSAGE_TYPE_ACTION,
};
enum Tox_Err_File_Control {
TOX_ERR_FILE_CONTROL_OK,
TOX_ERR_FILE_CONTROL_FRIEND_NOT_FOUND,
TOX_ERR_FILE_CONTROL_FRIEND_NOT_CONNECTED,
TOX_ERR_FILE_CONTROL_NOT_FOUND,
TOX_ERR_FILE_CONTROL_NOT_PAUSED,
TOX_ERR_FILE_CONTROL_DENIED,
TOX_ERR_FILE_CONTROL_ALREADY_PAUSED,
TOX_ERR_FILE_CONTROL_SENDQ,
};
enum Tox_File_Control {
TOX_FILE_CONTROL_RESUME,
TOX_FILE_CONTROL_PAUSE,
TOX_FILE_CONTROL_CANCEL,
};
enum Tox_Err_File_Seek {
TOX_ERR_FILE_SEEK_OK,
TOX_ERR_FILE_SEEK_FRIEND_NOT_FOUND,
TOX_ERR_FILE_SEEK_FRIEND_NOT_CONNECTED,
TOX_ERR_FILE_SEEK_NOT_FOUND,
TOX_ERR_FILE_SEEK_DENIED,
TOX_ERR_FILE_SEEK_INVALID_POSITION,
TOX_ERR_FILE_SEEK_SENDQ,
};
enum Tox_Err_File_Get {
TOX_ERR_FILE_GET_OK,
TOX_ERR_FILE_GET_NULL,
TOX_ERR_FILE_GET_FRIEND_NOT_FOUND,
TOX_ERR_FILE_GET_NOT_FOUND,
};
enum Tox_Err_File_Send {
TOX_ERR_FILE_SEND_OK,
TOX_ERR_FILE_SEND_NULL,
TOX_ERR_FILE_SEND_FRIEND_NOT_FOUND,
TOX_ERR_FILE_SEND_FRIEND_NOT_CONNECTED,
TOX_ERR_FILE_SEND_NAME_TOO_LONG,
TOX_ERR_FILE_SEND_TOO_MANY,
};
enum Tox_Err_File_Send_Chunk {
TOX_ERR_FILE_SEND_CHUNK_OK,
TOX_ERR_FILE_SEND_CHUNK_NULL,
TOX_ERR_FILE_SEND_CHUNK_FRIEND_NOT_FOUND,
TOX_ERR_FILE_SEND_CHUNK_FRIEND_NOT_CONNECTED,
TOX_ERR_FILE_SEND_CHUNK_NOT_FOUND,
TOX_ERR_FILE_SEND_CHUNK_NOT_TRANSFERRING,
TOX_ERR_FILE_SEND_CHUNK_INVALID_LENGTH,
TOX_ERR_FILE_SEND_CHUNK_SENDQ,
TOX_ERR_FILE_SEND_CHUNK_WRONG_POSITION,
};
enum Tox_Err_Conference_Join {
TOX_ERR_CONFERENCE_JOIN_OK,
TOX_ERR_CONFERENCE_JOIN_INVALID_LENGTH,
TOX_ERR_CONFERENCE_JOIN_WRONG_TYPE,
TOX_ERR_CONFERENCE_JOIN_FRIEND_NOT_FOUND,
TOX_ERR_CONFERENCE_JOIN_DUPLICATE,
TOX_ERR_CONFERENCE_JOIN_INIT_FAIL,
TOX_ERR_CONFERENCE_JOIN_FAIL_SEND,
};
enum Tox_Err_Conference_Send_Message {
TOX_ERR_CONFERENCE_SEND_MESSAGE_OK,
TOX_ERR_CONFERENCE_SEND_MESSAGE_CONFERENCE_NOT_FOUND,
TOX_ERR_CONFERENCE_SEND_MESSAGE_TOO_LONG,
TOX_ERR_CONFERENCE_SEND_MESSAGE_NO_CONNECTION,
TOX_ERR_CONFERENCE_SEND_MESSAGE_FAIL_SEND,
};
enum Tox_Err_Friend_Custom_Packet {
TOX_ERR_FRIEND_CUSTOM_PACKET_OK,
TOX_ERR_FRIEND_CUSTOM_PACKET_NULL,
TOX_ERR_FRIEND_CUSTOM_PACKET_FRIEND_NOT_FOUND,
TOX_ERR_FRIEND_CUSTOM_PACKET_FRIEND_NOT_CONNECTED,
TOX_ERR_FRIEND_CUSTOM_PACKET_INVALID,
TOX_ERR_FRIEND_CUSTOM_PACKET_EMPTY,
TOX_ERR_FRIEND_CUSTOM_PACKET_TOO_LONG,
TOX_ERR_FRIEND_CUSTOM_PACKET_SENDQ,
};
enum Tox_Err_Group_New {
TOX_ERR_GROUP_NEW_OK,
TOX_ERR_GROUP_NEW_TOO_LONG,
TOX_ERR_GROUP_NEW_EMPTY,
TOX_ERR_GROUP_NEW_INIT,
TOX_ERR_GROUP_NEW_STATE,
TOX_ERR_GROUP_NEW_ANNOUNCE,
};
enum Tox_Group_Privacy_State {
TOX_GROUP_PRIVACY_STATE_PUBLIC,
TOX_GROUP_PRIVACY_STATE_PRIVATE,
};
enum Tox_Err_Group_Join {
TOX_ERR_GROUP_JOIN_OK,
TOX_ERR_GROUP_JOIN_INIT,
TOX_ERR_GROUP_JOIN_BAD_CHAT_ID,
TOX_ERR_GROUP_JOIN_EMPTY,
TOX_ERR_GROUP_JOIN_TOO_LONG,
TOX_ERR_GROUP_JOIN_PASSWORD,
TOX_ERR_GROUP_JOIN_CORE,
};
enum Tox_Err_Group_Disconnect {
TOX_ERR_GROUP_DISCONNECT_OK,
TOX_ERR_GROUP_DISCONNECT_GROUP_NOT_FOUND,
TOX_ERR_GROUP_DISCONNECT_ALREADY_DISCONNECTED,
};
enum Tox_Err_Group_Reconnect {
TOX_ERR_GROUP_RECONNECT_OK,
TOX_ERR_GROUP_RECONNECT_GROUP_NOT_FOUND,
TOX_ERR_GROUP_RECONNECT_CORE,
};
enum Tox_Err_Group_Leave {
TOX_ERR_GROUP_LEAVE_OK,
TOX_ERR_GROUP_LEAVE_GROUP_NOT_FOUND,
TOX_ERR_GROUP_LEAVE_TOO_LONG,
TOX_ERR_GROUP_LEAVE_FAIL_SEND,
};
enum Tox_Err_Group_Self_Name_Set {
TOX_ERR_GROUP_SELF_NAME_SET_OK,
TOX_ERR_GROUP_SELF_NAME_SET_GROUP_NOT_FOUND,
TOX_ERR_GROUP_SELF_NAME_SET_TOO_LONG,
TOX_ERR_GROUP_SELF_NAME_SET_INVALID,
TOX_ERR_GROUP_SELF_NAME_SET_FAIL_SEND,
};
enum Tox_Group_Role {
TOX_GROUP_ROLE_FOUNDER,
TOX_GROUP_ROLE_MODERATOR,
TOX_GROUP_ROLE_USER,
TOX_GROUP_ROLE_OBSERVER,
};
enum Tox_Err_Group_Peer_Query {
TOX_ERR_GROUP_PEER_QUERY_OK,
TOX_ERR_GROUP_PEER_QUERY_GROUP_NOT_FOUND,
TOX_ERR_GROUP_PEER_QUERY_PEER_NOT_FOUND,
};
enum Tox_Err_Group_Topic_Set {
TOX_ERR_GROUP_TOPIC_SET_OK,
TOX_ERR_GROUP_TOPIC_SET_GROUP_NOT_FOUND,
TOX_ERR_GROUP_TOPIC_SET_TOO_LONG,
TOX_ERR_GROUP_TOPIC_SET_PERMISSIONS,
TOX_ERR_GROUP_TOPIC_SET_FAIL_CREATE,
TOX_ERR_GROUP_TOPIC_SET_FAIL_SEND,
TOX_ERR_GROUP_TOPIC_SET_DISCONNECTED,
};
enum Tox_Err_Group_Send_Message {
TOX_ERR_GROUP_SEND_MESSAGE_OK,
TOX_ERR_GROUP_SEND_MESSAGE_GROUP_NOT_FOUND,
TOX_ERR_GROUP_SEND_MESSAGE_TOO_LONG,
TOX_ERR_GROUP_SEND_MESSAGE_EMPTY,
TOX_ERR_GROUP_SEND_MESSAGE_BAD_TYPE,
TOX_ERR_GROUP_SEND_MESSAGE_PERMISSIONS,
TOX_ERR_GROUP_SEND_MESSAGE_FAIL_SEND,
TOX_ERR_GROUP_SEND_MESSAGE_DISCONNECTED,
};
enum Tox_Err_Group_Send_Private_Message {
TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_OK,
TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_GROUP_NOT_FOUND,
TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_PEER_NOT_FOUND,
TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_TOO_LONG,
TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_EMPTY,
TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_PERMISSIONS,
TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_FAIL_SEND,
TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_DISCONNECTED,
TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_BAD_TYPE,
};
enum Tox_Err_Group_Self_Status_Set {
TOX_ERR_GROUP_SELF_STATUS_SET_OK,
TOX_ERR_GROUP_SELF_STATUS_SET_GROUP_NOT_FOUND,
TOX_ERR_GROUP_SELF_STATUS_SET_FAIL_SEND,
};
enum Tox_Err_Group_Send_Custom_Packet {
TOX_ERR_GROUP_SEND_CUSTOM_PACKET_OK,
TOX_ERR_GROUP_SEND_CUSTOM_PACKET_GROUP_NOT_FOUND,
TOX_ERR_GROUP_SEND_CUSTOM_PACKET_TOO_LONG,
TOX_ERR_GROUP_SEND_CUSTOM_PACKET_EMPTY,
TOX_ERR_GROUP_SEND_CUSTOM_PACKET_PERMISSIONS,
TOX_ERR_GROUP_SEND_CUSTOM_PACKET_DISCONNECTED,
};
enum Tox_Err_Group_Send_Custom_Private_Packet {
TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_OK,
TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_GROUP_NOT_FOUND,
TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_TOO_LONG,
TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_EMPTY,
TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_PEER_NOT_FOUND,
TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_PERMISSIONS,
TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_FAIL_SEND,
TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_DISCONNECTED,
};
enum Tox_Err_Group_Invite_Friend {
TOX_ERR_GROUP_INVITE_FRIEND_OK,
TOX_ERR_GROUP_INVITE_FRIEND_GROUP_NOT_FOUND,
TOX_ERR_GROUP_INVITE_FRIEND_FRIEND_NOT_FOUND,
TOX_ERR_GROUP_INVITE_FRIEND_INVITE_FAIL,
TOX_ERR_GROUP_INVITE_FRIEND_FAIL_SEND,
TOX_ERR_GROUP_INVITE_FRIEND_DISCONNECTED,
};
enum Tox_Err_Group_Invite_Accept {
TOX_ERR_GROUP_INVITE_ACCEPT_OK,
TOX_ERR_GROUP_INVITE_ACCEPT_BAD_INVITE,
TOX_ERR_GROUP_INVITE_ACCEPT_INIT_FAILED,
TOX_ERR_GROUP_INVITE_ACCEPT_TOO_LONG,
TOX_ERR_GROUP_INVITE_ACCEPT_EMPTY,
TOX_ERR_GROUP_INVITE_ACCEPT_PASSWORD,
TOX_ERR_GROUP_INVITE_ACCEPT_CORE,
TOX_ERR_GROUP_INVITE_ACCEPT_FAIL_SEND,
};
#endif // C_TOXCORE_TOXCORE_TOX_H